From b8478025388510d9f6b7d2e8462f3ccc3e38def1 Mon Sep 17 00:00:00 2001
From: Emmanuel Milou <emmanuel.milou@savoirfairelinux.com>
Date: Tue, 20 May 2008 11:28:23 -0400
Subject: [PATCH] Add the SIP registration expire value in the user file

The default value for SIP registration is 180. But, to connect to the freebox, it seems we need a longer time
You can set the value tou want by editing the user configuration file
---
 src/managerimpl.cpp | 7 +++++++
 src/managerimpl.h   | 5 +++++
 src/sipvoiplink.cpp | 8 +++++---
 src/user_cfg.h      | 2 ++
 4 files changed, 19 insertions(+), 3 deletions(-)

diff --git a/src/managerimpl.cpp b/src/managerimpl.cpp
index 26f4dc9852..fe55bc1734 100644
--- a/src/managerimpl.cpp
+++ b/src/managerimpl.cpp
@@ -981,6 +981,7 @@ ManagerImpl::initConfigFile (void)
   fill_config_int(CONFIG_MAIL_NOTIFY , NO_STR);
   fill_config_int(CONFIG_VOLUME , YES_STR);
   fill_config_int(CONFIG_HISTORY , DFT_MAX_CALLS);
+  fill_config_int(REGISTRATION_EXPIRE , DFT_EXPIRE_VALUE);
 
   // Loads config from ~/.sflphone/sflphonedrc or so..
   if (createSettingsPath() == 1) {
@@ -1393,6 +1394,12 @@ ManagerImpl::getMailNotify( void )
   return getConfigInt( PREFERENCES , CONFIG_MAIL_NOTIFY );
 }
 
+int
+ManagerImpl::getRegistrationExpireValue( void)
+{
+  return getConfigInt( PREFERENCES , REGISTRATION_EXPIRE );
+}
+
 void
 ManagerImpl::setMailNotify( void )
 {
diff --git a/src/managerimpl.h b/src/managerimpl.h
index 5fa813b906..dde4dd67dc 100644
--- a/src/managerimpl.h
+++ b/src/managerimpl.h
@@ -541,6 +541,11 @@ class ManagerImpl {
      */
     ::DBus::Int32 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/src/sipvoiplink.cpp b/src/sipvoiplink.cpp
index 8cfafdcaad..6ef973af35 100644
--- a/src/sipvoiplink.cpp
+++ b/src/sipvoiplink.cpp
@@ -39,7 +39,7 @@
 #define EXOSIP_ERROR_BUILDING -2
 
 // for registration
-#define EXPIRES_VALUE 180
+//#define EXPIRES_VALUE 180
 
 // 1XX responses
 #define DIALOG_ESTABLISHED 101
@@ -443,6 +443,8 @@ SIPVoIPLink::getEvent()
 bool
 SIPVoIPLink::sendRegister()
 {
+  int expire_value = Manager::instance().getRegistrationExpireValue();
+  _debug("SIP Registration Expire Value = %i\n" , expire_value);
 
   if (_eXosipRegID != EXOSIP_ERROR_STD) {
     return false;
@@ -466,11 +468,11 @@ SIPVoIPLink::sendRegister()
   if (!_proxy.empty()) {
     _debug("* SIP Info: Register from: %s to %s\n", from.data(), proxy.data());
     _eXosipRegID = eXosip_register_build_initial_register(from.data(), 
-                  proxy.data(), NULL, EXPIRES_VALUE, &reg);
+                  proxy.data(), NULL, expire_value, &reg);
   } else {
     _debug("* SIP Info: Register from: %s to %s\n", from.data(), hostname.data());
     _eXosipRegID = eXosip_register_build_initial_register(from.data(), 
-                  hostname.data(), NULL, EXPIRES_VALUE, &reg);
+                  hostname.data(), NULL, expire_value, &reg);
   }
   eXosip_unlock();
   if (_eXosipRegID < EXOSIP_ERROR_NO ) {
diff --git a/src/user_cfg.h b/src/user_cfg.h
index 173a669337..056d631385 100644
--- a/src/user_cfg.h
+++ b/src/user_cfg.h
@@ -57,6 +57,7 @@
 #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 SIGNALISATION		"VoIPLink"	      /** Section Signalisation */
 #define PLAY_DTMF		"DTMF.playDtmf"	      /** Whether or not should play dtmf */
@@ -81,6 +82,7 @@
 #define DFT_SAMPLE_RATE		"44100"			/** Default sample rate in HZ */
 #define DFT_NOTIF_LEVEL		"2"			/** Default desktop notification level : maximum */
 #define DFT_MAX_CALLS		"20"			/** Default maximum calls in history */
+#define DFT_EXPIRE_VALUE	"180"			/** Default expire value for registration */
 
 #ifdef USE_ZEROCONF
 #define CONFIG_ZEROCONF_DEFAULT_STR "1"			/** Default Zero configuration networking module value */
-- 
GitLab