From a6562011160318f4e3fc40ace210dde8d13e7f98 Mon Sep 17 00:00:00 2001
From: pierre-luc <pierre-luc@aqra.ca>
Date: Wed, 22 Jul 2009 17:48:44 -0400
Subject: [PATCH] [#1904] The registration expire value is now configurable
 from the account window.

---
 .../src/config/accountwindow.c                | 155 +++++++++++++-----
 sflphone-client-gnome/src/sflphone_const.h    |  21 +--
 sflphone-common/src/account.h                 |   1 +
 sflphone-common/src/managerimpl.cpp           |  15 +-
 sflphone-common/src/managerimpl.h             |   5 -
 sflphone-common/src/sipaccount.cpp            |   5 +
 sflphone-common/src/sipaccount.h              |   3 +
 sflphone-common/src/sipvoiplink.cpp           |   8 +-
 sflphone-common/src/user_cfg.h                |   3 +-
 9 files changed, 145 insertions(+), 71 deletions(-)

diff --git a/sflphone-client-gnome/src/config/accountwindow.c b/sflphone-client-gnome/src/config/accountwindow.c
index 3db8a4ee86..493233362a 100644
--- a/sflphone-client-gnome/src/config/accountwindow.c
+++ b/sflphone-client-gnome/src/config/accountwindow.c
@@ -35,12 +35,8 @@
 #include <gtk/gtk.h>
 
 /** Local variables */
-account_t * currentAccount;
-
 GtkDialog * dialog;
 GtkWidget * hbox;
-GtkWidget * frame;
-GtkWidget * table;
 GtkWidget * label;
 GtkWidget * entryID;
 GtkWidget * entryAlias;
@@ -51,6 +47,7 @@ GtkWidget * entryHostname;
 GtkWidget * entryPassword;
 GtkWidget * entryMailbox;
 GtkWidget * entryResolveNameOnlyOnce;
+GtkWidget * entryExpire;
 
 /* Signal to entryProtocol 'changed' */
     void
@@ -69,12 +66,14 @@ is_iax_enabled(void)
         return FALSE;
 }
 
-    void
-show_account_window (account_t * a)
+static GtkWidget * createAccountTab(account_t * a) 
 {
-    gint response;
-
-    currentAccount = a;
+    GtkWidget * frame;
+    GtkWidget * table;
+#if GTK_CHECK_VERSION(2,16,0)
+#else
+    GtkWidget *image;
+#endif
 
     // Default settings
     gchar * curAccountID = "";
@@ -87,11 +86,8 @@ show_account_window (account_t * a)
     gchar * curPassword = "";
     /* TODO: add curProxy, and add boxes for Proxy support */
     gchar * curMailbox = "";
-
-#if GTK_CHECK_VERSION(2,16,0)
-#else
-    GtkWidget *image;
-#endif
+        
+    account_t * currentAccount = a;
 
     // Load from SIP/IAX/Unknown ?
     if(a)
@@ -112,30 +108,16 @@ show_account_window (account_t * a)
         currentAccount->properties = g_hash_table_new(NULL, g_str_equal);
         curAccountID = "new";
     }
-
-    dialog = GTK_DIALOG(gtk_dialog_new_with_buttons (_("Account settings"),
-                GTK_WINDOW(get_main_window()),
-                GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
-                GTK_STOCK_APPLY,
-                GTK_RESPONSE_ACCEPT,
-                GTK_STOCK_CANCEL,
-                GTK_RESPONSE_CANCEL,
-                NULL));
-
-    gtk_dialog_set_has_separator(dialog, TRUE);
-    gtk_container_set_border_width (GTK_CONTAINER(dialog), 0);
-
+    
     gnome_main_section_new (_("Account Parameters"), &frame);
-    gtk_box_pack_start(GTK_BOX(dialog->vbox), frame, FALSE, FALSE, 0);
     gtk_widget_show(frame);
 
-    table = gtk_table_new (10, 2  ,  FALSE/* homogeneous */);
+    table = gtk_table_new (9, 2  ,  FALSE/* homogeneous */);
     gtk_table_set_row_spacings( GTK_TABLE(table), 10);
     gtk_table_set_col_spacings( GTK_TABLE(table), 10);
     gtk_widget_show(table);
     gtk_container_add( GTK_CONTAINER( frame) , table );
 
-
 #ifdef DEBUG
     label = gtk_label_new_with_mnemonic ("ID:");
     gtk_table_attach ( GTK_TABLE( table ), label, 0, 1, 0, 1, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
@@ -197,14 +179,8 @@ show_account_window (account_t * a)
     gtk_entry_set_text(GTK_ENTRY(entryHostname), curHostname);
     gtk_table_attach ( GTK_TABLE( table ), entryHostname, 1, 2, 5, 6, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
 
-    entryResolveNameOnlyOnce = gtk_check_button_new_with_mnemonic(_("_Resolve host name only once for the session"));
-    gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(entryResolveNameOnlyOnce),
-            g_strcasecmp(curAccountResolveOnce,"TRUE") == 0 ? TRUE: FALSE);
-    gtk_table_attach ( GTK_TABLE( table ), entryResolveNameOnlyOnce, 0, 2, 6, 7, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
-    gtk_widget_set_sensitive( GTK_WIDGET( entryResolveNameOnlyOnce ) , TRUE );
-    
     label = gtk_label_new_with_mnemonic (_("_User name"));
-    gtk_table_attach ( GTK_TABLE( table ), label, 0, 1, 7, 8, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
+    gtk_table_attach ( GTK_TABLE( table ), label, 0, 1, 6, 7, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
     gtk_misc_set_alignment(GTK_MISC (label), 0, 0.5);
 #if GTK_CHECK_VERSION(2,16,0)
 	entryUsername = gtk_entry_new();
@@ -216,10 +192,10 @@ show_account_window (account_t * a)
 #endif
     gtk_label_set_mnemonic_widget (GTK_LABEL (label), entryUsername);
     gtk_entry_set_text(GTK_ENTRY(entryUsername), curUsername);
-    gtk_table_attach ( GTK_TABLE( table ), entryUsername, 1, 2, 7, 8, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
+    gtk_table_attach ( GTK_TABLE( table ), entryUsername, 1, 2, 6, 7, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
 
     label = gtk_label_new_with_mnemonic (_("_Password"));
-    gtk_table_attach ( GTK_TABLE( table ), label, 0, 1, 8, 9, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
+    gtk_table_attach ( GTK_TABLE( table ), label, 0, 1, 7, 8, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
     gtk_misc_set_alignment(GTK_MISC (label), 0, 0.5);
 #if GTK_CHECK_VERSION(2,16,0)
 	entryPassword = gtk_entry_new();
@@ -232,19 +208,107 @@ show_account_window (account_t * a)
     gtk_entry_set_visibility(GTK_ENTRY(entryPassword), FALSE);
     gtk_label_set_mnemonic_widget (GTK_LABEL (label), entryPassword);
     gtk_entry_set_text(GTK_ENTRY(entryPassword), curPassword);
-    gtk_table_attach ( GTK_TABLE( table ), entryPassword, 1, 2, 8, 9, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
+    gtk_table_attach ( GTK_TABLE( table ), entryPassword, 1, 2, 7, 8, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
 
     label = gtk_label_new_with_mnemonic (_("_Voicemail number"));
-    gtk_table_attach ( GTK_TABLE( table ), label, 0, 1, 9, 10, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
+    gtk_table_attach ( GTK_TABLE( table ), label, 0, 1, 8, 9, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
     gtk_misc_set_alignment(GTK_MISC (label), 0, 0.5);
     entryMailbox = gtk_entry_new();
     gtk_label_set_mnemonic_widget (GTK_LABEL (label), entryMailbox);
     gtk_entry_set_text(GTK_ENTRY(entryMailbox), curMailbox);
-    gtk_table_attach ( GTK_TABLE( table ), entryMailbox, 1, 2, 9, 10, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
+    gtk_table_attach ( GTK_TABLE( table ), entryMailbox, 1, 2, 8, 9, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
 
     gtk_widget_show_all( table );
     gtk_container_set_border_width (GTK_CONTAINER(table), 10);
 
+    return frame;
+}
+
+GtkWidget * createAdvancedTab(account_t * a)
+{
+    GtkWidget * frame;
+    GtkWidget * table;
+
+    // Default settings
+    gchar * curAccountResolveOnce = "FALSE"; 
+    gchar * curAccountExpire = "600"; 
+     
+    account_t * currentAccount = a;
+
+    // Load from SIP/IAX/Unknown ?
+    if(currentAccount) {
+        curAccountResolveOnce = g_hash_table_lookup(currentAccount->properties, ACCOUNT_RESOLVE_ONCE);
+        curAccountExpire = g_hash_table_lookup(currentAccount->properties, ACCOUNT_REGISTRATION_EXPIRE);
+    } 
+    
+    gnome_main_section_new (_("Advanced Settings"), &frame);
+    gtk_widget_show(frame);
+
+    table = gtk_table_new (2, 2,  FALSE/* homogeneous */);
+    gtk_table_set_row_spacings( GTK_TABLE(table), 10);
+    gtk_table_set_col_spacings( GTK_TABLE(table), 10);
+    gtk_widget_show(table);
+    gtk_container_add( GTK_CONTAINER( frame) , table );
+
+    label = gtk_label_new_with_mnemonic (_("Registration _expire"));
+    gtk_table_attach ( GTK_TABLE( table ), label, 0, 1, 0, 1, GTK_SHRINK | GTK_FILL, GTK_SHRINK | GTK_FILL, 0, 0);
+    gtk_misc_set_alignment(GTK_MISC (label), 0, 0.5);
+    entryExpire = gtk_entry_new();
+    gtk_label_set_mnemonic_widget (GTK_LABEL (label), entryExpire);
+    gtk_entry_set_text(GTK_ENTRY(entryExpire), curAccountExpire);
+    gtk_table_attach ( GTK_TABLE( table ), entryExpire, 1, 2, 0, 1, GTK_SHRINK | GTK_FILL, GTK_SHRINK | GTK_FILL, 0, 0);
+    
+    entryResolveNameOnlyOnce = gtk_check_button_new_with_mnemonic(_("_Conform to RFC 3263"));
+    gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(entryResolveNameOnlyOnce),
+            g_strcasecmp(curAccountResolveOnce,"FALSE") == 0 ? TRUE: FALSE);
+    gtk_table_attach ( GTK_TABLE( table ), entryResolveNameOnlyOnce, 0, 2, 1, 2, GTK_SHRINK | GTK_FILL, GTK_SHRINK | GTK_FILL, 0, 0);
+    gtk_widget_set_sensitive( GTK_WIDGET( entryResolveNameOnlyOnce ) , TRUE );
+    
+    gtk_widget_show_all( table );
+    gtk_container_set_border_width (GTK_CONTAINER(table), 10);
+
+    return frame;
+}
+
+    void
+show_account_window (account_t * a)
+{
+
+    GtkWidget * notebook;
+    GtkWidget * tab; 
+    gint response;
+     
+    account_t * currentAccount = a;
+       
+    dialog = GTK_DIALOG(gtk_dialog_new_with_buttons (_("Account settings"),
+                GTK_WINDOW(get_main_window()),
+                GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
+                GTK_STOCK_APPLY,
+                GTK_RESPONSE_ACCEPT,
+                GTK_STOCK_CANCEL,
+                GTK_RESPONSE_CANCEL,
+                NULL));
+
+    gtk_dialog_set_has_separator(dialog, TRUE);
+    gtk_container_set_border_width (GTK_CONTAINER(dialog), 0);
+
+    notebook = gtk_notebook_new();
+    gtk_box_pack_start(GTK_BOX (dialog->vbox), notebook, TRUE, TRUE, 0);
+    gtk_container_set_border_width(GTK_CONTAINER(notebook), 10);
+    gtk_widget_show(notebook);
+    
+    /* General Settings */
+    tab = createAccountTab(a);
+    gtk_notebook_append_page(GTK_NOTEBOOK(notebook), tab, gtk_label_new(_("Basic")));
+    gtk_notebook_page_num(GTK_NOTEBOOK(notebook), tab);
+    
+    /* Advanced */
+    tab = createAdvancedTab(a);
+    gtk_notebook_append_page(GTK_NOTEBOOK(notebook), tab, gtk_label_new(_("Advanced")));
+    gtk_notebook_page_num(GTK_NOTEBOOK(notebook), tab);
+    
+    gtk_notebook_set_current_page( GTK_NOTEBOOK( notebook) ,  0);
+        
     response = gtk_dialog_run (GTK_DIALOG (dialog));
     if(response == GTK_RESPONSE_ACCEPT)
     {
@@ -255,7 +319,7 @@ show_account_window (account_t * a)
                 g_strdup(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(entryEnabled)) ? "TRUE": "FALSE"));
         g_hash_table_replace(currentAccount->properties,
                 g_strdup(ACCOUNT_RESOLVE_ONCE),
-                g_strdup(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(entryResolveNameOnlyOnce)) ? "TRUE": "FALSE"));
+                g_strdup(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(entryResolveNameOnlyOnce)) ? "FALSE": "TRUE"));
         g_hash_table_replace(currentAccount->properties,
                 g_strdup(ACCOUNT_ALIAS),
                 g_strdup((gchar *)gtk_entry_get_text(GTK_ENTRY(entryAlias))));
@@ -274,6 +338,9 @@ show_account_window (account_t * a)
         g_hash_table_replace(currentAccount->properties,
                 g_strdup(ACCOUNT_MAILBOX),
                 g_strdup((gchar *)gtk_entry_get_text(GTK_ENTRY(entryMailbox))));
+        g_hash_table_replace(currentAccount->properties,
+                g_strdup(ACCOUNT_REGISTRATION_EXPIRE),
+                g_strdup((gchar *)gtk_entry_get_text(GTK_ENTRY(entryExpire))));
 
         if (strcmp(proto, "SIP") == 0) {
             guint i, size;
@@ -299,7 +366,7 @@ show_account_window (account_t * a)
                 }
             }
 
-            // Otherelse set a default value
+            // Otherwise set a default value
             if(!flag)
             {
                 g_hash_table_replace(currentAccount->properties, g_strdup(ACCOUNT_SIP_STUN_SERVER), (gchar*)"");
diff --git a/sflphone-client-gnome/src/sflphone_const.h b/sflphone-client-gnome/src/sflphone_const.h
index 387098d4cb..aa04c42826 100644
--- a/sflphone-client-gnome/src/sflphone_const.h
+++ b/sflphone-client-gnome/src/sflphone_const.h
@@ -43,16 +43,17 @@
 
 #define UNUSED  __attribute__((__unused__))
 
-#define ACCOUNT_TYPE               "Account.type"
-#define ACCOUNT_ALIAS		       "Account.alias"
-#define ACCOUNT_ENABLED		       "Account.enable"
-#define ACCOUNT_MAILBOX		       "Account.mailbox"
-#define ACCOUNT_HOSTNAME           "hostname"
-#define ACCOUNT_USERNAME           "username"
-#define ACCOUNT_PASSWORD           "password"
-#define ACCOUNT_SIP_STUN_SERVER	   "STUN.server"
-#define ACCOUNT_SIP_STUN_ENABLED   "STUN.enable"
-#define ACCOUNT_RESOLVE_ONCE       "Account.resolveOnce"
+#define ACCOUNT_TYPE                "Account.type"
+#define ACCOUNT_ALIAS		        "Account.alias"
+#define ACCOUNT_ENABLED		        "Account.enable"
+#define ACCOUNT_MAILBOX		        "Account.mailbox"
+#define ACCOUNT_RESOLVE_ONCE        "Account.resolveOnce"
+#define ACCOUNT_REGISTRATION_EXPIRE "Account.expire"
+#define ACCOUNT_SIP_STUN_SERVER	    "STUN.server"
+#define ACCOUNT_SIP_STUN_ENABLED    "STUN.enable"
+#define ACCOUNT_HOSTNAME            "hostname"
+#define ACCOUNT_USERNAME            "username"
+#define ACCOUNT_PASSWORD            "password"
 
 /**
  * Global logger
diff --git a/sflphone-common/src/account.h b/sflphone-common/src/account.h
index 0f3e3239b9..fbbaedbd08 100644
--- a/sflphone-common/src/account.h
+++ b/sflphone-common/src/account.h
@@ -59,6 +59,7 @@ typedef enum RegistrationState {
 #define CONFIG_ACCOUNT_MAILBOX	"Account.mailbox"
 #define CONFIG_ACCOUNT_ENABLE	"Account.enable"
 #define CONFIG_ACCOUNT_RESOLVE_ONCE "Account.resolveOnce"
+#define CONFIG_ACCOUNT_REGISTRATION_EXPIRE "Account.expire"
 
 #define HOSTNAME        "hostname"
 #define USERNAME        "username"
diff --git a/sflphone-common/src/managerimpl.cpp b/sflphone-common/src/managerimpl.cpp
index fb57815c6b..d7d337d084 100644
--- a/sflphone-common/src/managerimpl.cpp
+++ b/sflphone-common/src/managerimpl.cpp
@@ -1356,7 +1356,6 @@ ManagerImpl::initConfigFile (bool load_user_value, std::string alternate)
     fill_config_int (CONFIG_VOLUME , YES_STR);
     fill_config_int (CONFIG_HISTORY_LIMIT, DFT_HISTORY_LIMIT);
     fill_config_int (CONFIG_HISTORY_ENABLED, YES_STR);
-    fill_config_int (REGISTRATION_EXPIRE , DFT_EXPIRE_VALUE);
     fill_config_int (CONFIG_AUDIO , DFT_AUDIO_MANAGER);
     fill_config_int (CONFIG_PA_VOLUME_CTRL , YES_STR);
     fill_config_int (CONFIG_SIP_PORT, DFT_SIP_PORT);
@@ -1961,12 +1960,6 @@ ManagerImpl::getAudioManager (void)
     return getConfigInt (PREFERENCES , CONFIG_AUDIO);
 }
 
-int
-ManagerImpl::getRegistrationExpireValue (void)
-{
-    return getConfigInt (PREFERENCES , REGISTRATION_EXPIRE);
-}
-
 void
 ManagerImpl::setMailNotify (void)
 {
@@ -2469,7 +2462,12 @@ std::map< std::string, std::string > ManagerImpl::getAccountDetails (const Accou
     a.insert (std::pair<std::string, std::string> (PASSWORD, getConfigString (accountID, PASSWORD)));
     a.insert (std::pair<std::string, std::string> (HOSTNAME, getConfigString (accountID, HOSTNAME)));
     a.insert (std::pair<std::string, std::string> (CONFIG_ACCOUNT_MAILBOX, getConfigString (accountID, CONFIG_ACCOUNT_MAILBOX)));
-
+    
+    if (getConfigString (accountID, CONFIG_ACCOUNT_REGISTRATION_EXPIRE).empty()) {
+        a.insert (std::pair<std::string, std::string> (CONFIG_ACCOUNT_REGISTRATION_EXPIRE, DFT_EXPIRE_VALUE));
+    } else {
+        a.insert (std::pair<std::string, std::string> (CONFIG_ACCOUNT_REGISTRATION_EXPIRE, getConfigString (accountID, CONFIG_ACCOUNT_REGISTRATION_EXPIRE)));
+    }
     return a;
 }
 
@@ -2490,6 +2488,7 @@ void ManagerImpl::setAccountDetails (const std::string& accountID, const std::ma
     setConfig (accountID, PASSWORD, (*details.find (PASSWORD)).second);
     setConfig (accountID, HOSTNAME, (*details.find (HOSTNAME)).second);
     setConfig (accountID, CONFIG_ACCOUNT_MAILBOX, (*details.find (CONFIG_ACCOUNT_MAILBOX)).second);
+    setConfig (accountID, CONFIG_ACCOUNT_REGISTRATION_EXPIRE, (*details.find (CONFIG_ACCOUNT_REGISTRATION_EXPIRE)).second);
 
     saveConfig();
 
diff --git a/sflphone-common/src/managerimpl.h b/sflphone-common/src/managerimpl.h
index 740d0545c4..a7d1ed4fb3 100644
--- a/sflphone-common/src/managerimpl.h
+++ b/sflphone-common/src/managerimpl.h
@@ -646,11 +646,6 @@ class ManagerImpl {
      */
     int32_t getMailNotify( void );
 
-    /**
-     * Get the expire value for SIP registration, set in the user configuration file
-     */
-    int getRegistrationExpireValue( void );
-
     /**
      * Retrieve the formatted list of codecs payload in the user config file and
      * load in the active list of codecs
diff --git a/sflphone-common/src/sipaccount.cpp b/sflphone-common/src/sipaccount.cpp
index cfb333972d..8d926c439f 100644
--- a/sflphone-common/src/sipaccount.cpp
+++ b/sflphone-common/src/sipaccount.cpp
@@ -65,6 +65,11 @@ int SIPAccount::registerVoIPLink()
     setUsername (Manager::instance().getConfigString (_accountID, USERNAME));
     setPassword (Manager::instance().getConfigString (_accountID, PASSWORD));
     _resolveOnce = Manager::instance().getConfigString (_accountID, CONFIG_ACCOUNT_RESOLVE_ONCE) == "1" ? true : false;
+    if (Manager::instance().getConfigString (_accountID, CONFIG_ACCOUNT_REGISTRATION_EXPIRE).empty()) {
+        _registrationExpire = DFT_EXPIRE_VALUE;
+    } else {
+        _registrationExpire = Manager::instance().getConfigString (_accountID, CONFIG_ACCOUNT_REGISTRATION_EXPIRE);
+    }
     
     /* Start registration */
     status = _link->sendRegister (_accountID);
diff --git a/sflphone-common/src/sipaccount.h b/sflphone-common/src/sipaccount.h
index e1db28ce1e..d7d06f9ebc 100644
--- a/sflphone-common/src/sipaccount.h
+++ b/sflphone-common/src/sipaccount.h
@@ -87,6 +87,7 @@ class SIPAccount : public Account
 
         inline bool isResolveOnce(void) { return _resolveOnce; }
 
+        inline std::string& getRegistrationExpire(void) { return _registrationExpire; }
     private:
 
         /**
@@ -110,6 +111,8 @@ class SIPAccount : public Account
         std::string _contact;
         
         bool _resolveOnce;
+        
+        std::string _registrationExpire;
 };
 
 #endif
diff --git a/sflphone-common/src/sipvoiplink.cpp b/sflphone-common/src/sipvoiplink.cpp
index b3a93b22a2..0e4a4cb0b6 100644
--- a/sflphone-common/src/sipvoiplink.cpp
+++ b/sflphone-common/src/sipvoiplink.cpp
@@ -433,7 +433,11 @@ int SIPVoIPLink::sendRegister (AccountID id)
     account->setRegister (true);
 
     /* Set the expire value of the message from the config file */
-    expire_value = Manager::instance().getRegistrationExpireValue();
+    istringstream stream(account->getRegistrationExpire());
+    stream >> expire_value;
+    if(!expire_value) {
+        expire_value = PJSIP_REGC_EXPIRATION_NOT_SPECIFIED;
+    }
 
     /* Update the state of the voip link */
     account->setRegistrationState (Trying);
@@ -467,7 +471,7 @@ int SIPVoIPLink::sendRegister (AccountID id)
     pj_strdup2 (_pool, &contact, contactTmp);
     account->setContact (contactTmp);
 
-    status = pjsip_regc_init (regc, &svr, &aor, &aor, 1, &contact, 600);   //timeout);
+    status = pjsip_regc_init (regc, &svr, &aor, &aor, 1, &contact, expire_value);   //timeout);
 
     if (status != PJ_SUCCESS) {
         _debug ("UserAgent: Unable to initialize regc. %d\n", status);   //, regc->str_srv_url.ptr);
diff --git a/sflphone-common/src/user_cfg.h b/sflphone-common/src/user_cfg.h
index f6dc3ab807..252da7e571 100644
--- a/sflphone-common/src/user_cfg.h
+++ b/sflphone-common/src/user_cfg.h
@@ -58,7 +58,6 @@
 #define CONFIG_POPUP		"Window.popup"		  /** SFLphone pops up on incoming calls or not */
 #define CONFIG_VOLUME		"Volume.display"	  /** Display the mic and speaker volume controls */
 #define CONFIG_ZEROCONF		"Zeroconf.enable"	  /** Zero configuration networking module */
-#define REGISTRATION_EXPIRE	"Registration.expire"	  /** Registration expire value */
 #define CONFIG_AUDIO		"Audio.api"		  /** Audio manager (ALSA or pulseaudio) */
 #define CONFIG_PA_VOLUME_CTRL	"Pulseaudio.volumeCtrl"	  /** Whether or not PA should modify volume of other applications on the same sink */
 #define CONFIG_SIP_PORT         "SIP.portNum"
@@ -106,7 +105,7 @@
 #define DFT_SAMPLE_RATE		"44100"			/** Default sample rate in HZ */
 #define DFT_NOTIF_LEVEL		"2"			/** Default desktop notification level : maximum */
 #define DFT_HISTORY_LIMIT		"30"			/** Default maximum days in history */
-#define DFT_EXPIRE_VALUE	"180"			/** Default expire value for registration */
+#define DFT_EXPIRE_VALUE	"600"			/** Default expire value for registration */
 #define DFT_AUDIO_MANAGER	"1"			/** Default audio manager */
 #define DFT_SIP_PORT            "5060"
 #define DFT_STUN_ENABLE         "0"
-- 
GitLab