diff --git a/sflphone-client-gnome/src/config/accountwindow.c b/sflphone-client-gnome/src/config/accountwindow.c index 3db8a4ee863413ec253aad3ec6a6e0b74d420dda..493233362a1fddd6e1614ebd44ad26462513a034 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 387098d4cb46219430d0aeb18f4bf1aad354329c..aa04c42826c11b72e10c1e3fa4f2b58b9d652f92 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 0f3e3239b968c7762b32c33a7c8e2f619212b69e..fbbaedbd089424fb3be140f64bba591554e83dd3 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/call.cpp b/sflphone-common/src/call.cpp index 0e7ee9f795fd50b67d7bebcc12f278949206144c..b10dcaebda1f4c64f190d8296d6a666f87be6e5b 100644 --- a/sflphone-common/src/call.cpp +++ b/sflphone-common/src/call.cpp @@ -39,16 +39,12 @@ Call::Call (const CallID& id, Call::CallType type) SOUND_FORMAT soundFormat = INT16; recAudio.setRecordingOption (fileType,soundFormat,44100, Manager::instance().getConfigString (AUDIO, RECORD_PATH),id); - // _debug("CALL::Constructor for this clss is called \n"); } Call::~Call() { - // _debug("CALL::~Call(): Destructor for this clss is called \n"); - if (recAudio.isOpenFile()) { - // _debug("CALL::~Call(): A recording file is open, close it \n"); recAudio.closeFile(); } } diff --git a/sflphone-common/src/managerimpl.cpp b/sflphone-common/src/managerimpl.cpp index 2f5a2b720a6e11ac706379717f446c8126e419b7..d7d337d084f2ba68a5ccdb12f5de27d5240562d6 100644 --- a/sflphone-common/src/managerimpl.cpp +++ b/sflphone-common/src/managerimpl.cpp @@ -350,7 +350,7 @@ ManagerImpl::hangupCall (const CallID& id) int nbCalls = getCallList().size(); - _debug ("nbCalls %i \n", nbCalls); + _debug ("hangupCall: callList is of size %i call(s)\n", nbCalls); // stop stream if (! (nbCalls > 1)) @@ -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); @@ -1422,7 +1421,7 @@ ManagerImpl::setActiveCodecList (const std::vector< std::string >& list) _codecDescriptorMap.saveActiveCodecs (list); // setConfig std::string s = serialize (list); - printf ("%s\n", s.c_str()); + _debug ("Setting codec with payload number %s to the active list\n", s.c_str()); setConfig ("Audio", "ActiveCodecs", s); } @@ -1467,7 +1466,7 @@ ManagerImpl::serialize (std::vector<std::string> v) std::vector <std::string> ManagerImpl::getActiveCodecList (void) { - _debug ("Get Active codecs list\n"); + _debug ("ManagerImpl::getActiveCodecList\n"); std::vector< std::string > v; CodecOrder active = _codecDescriptorMap.getActiveCodecs(); unsigned int i=0; @@ -1477,7 +1476,7 @@ ManagerImpl::getActiveCodecList (void) std::stringstream ss; ss << active[i]; v.push_back ( (ss.str()).data()); - _debug ("%s\n", ss.str().data()); + _debug ("Codec with payload number %s is active\n", ss.str().data()); i++; } @@ -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(); @@ -2709,7 +2708,7 @@ ManagerImpl::loadAccountMap() } if (tmpAccount != NULL) { - _debug (" %s \n", iter->c_str()); + _debug ("Loading account %s \n", iter->c_str()); _accountMap[iter->c_str() ] = tmpAccount; nbAccount++; } @@ -2775,7 +2774,6 @@ ManagerImpl::getAccountIdFromNameAndServer (const std::string& userName, const s for (iter = _accountMap.begin(); iter != _accountMap.end(); ++iter) { _debug ("for : account = %s\n", iter->first.c_str()); account = dynamic_cast<SIPAccount *> (iter->second); - _debug ("account != NULL = %i\n", (account != NULL)); if (account != NULL) { if (account->fullMatch (userName, server)) { diff --git a/sflphone-common/src/managerimpl.h b/sflphone-common/src/managerimpl.h index 740d0545c46a6e20a8783520b6f2cc0d75d14c81..a7d1ed4fb31d68599624848ac1a7832ea7cc9286 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/sdp.cpp b/sflphone-common/src/sdp.cpp index 8c79cb36dd98489ccf568fc3bf27e12335a36aff..3b5a0a347761838435e4cfb9da2d77c8300ad3e3 100644 --- a/sflphone-common/src/sdp.cpp +++ b/sflphone-common/src/sdp.cpp @@ -477,7 +477,7 @@ void Sdp::set_local_media_capabilities () // Clean it first _local_media_cap.clear(); - _debug ("Fetch local media capabilities .......... %i\n" , get_local_extern_audio_port()); + _debug ("Fetch local media capabilities. Local extern audio port: %i\n" , get_local_extern_audio_port()); /* Only one audio media used right now */ audio = new sdpMedia (MIME_TYPE_AUDIO); diff --git a/sflphone-common/src/sipaccount.cpp b/sflphone-common/src/sipaccount.cpp index cfb333972d0a1918b6494a9db09ba12a01343267..8d926c439fb410ea50ac9bb22e2d07b42f92b237 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 e1db28ce1ebd0286b29dabf3b0fca97441c770a3..d7d06f9ebc8a73935cda543ccf2a34dd2152a659 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/sipcall.cpp b/sflphone-common/src/sipcall.cpp index 8f1017ce0a314b6051234a6830ef4965f9c1e95b..0a87a613045804fcc64dee45106e8da96fd85204 100644 --- a/sflphone-common/src/sipcall.cpp +++ b/sflphone-common/src/sipcall.cpp @@ -33,7 +33,7 @@ SIPCall::SIPCall (const CallID& id, Call::CallType type, pj_pool_t *pool) : Call , _local_sdp (0) { _local_sdp = new Sdp (pool); - _debug ("SIPCALL::Constructor for this clss is called \n"); + _debug ("SIPCALL::Constructor for this class is called \n"); } SIPCall::~SIPCall() @@ -41,7 +41,7 @@ SIPCall::~SIPCall() delete _local_sdp; _local_sdp = 0; - _debug ("SIPCALL::Destructor for this clss is called \n"); + _debug ("SIPCALL::Destructor for this class is called \n"); } diff --git a/sflphone-common/src/sipvoiplink.cpp b/sflphone-common/src/sipvoiplink.cpp index fadfc65986a00c64043d33df49d420331881ee79..0e4a4cb0b64a31057f4b0937001e92ab00c34276 100644 --- a/sflphone-common/src/sipvoiplink.cpp +++ b/sflphone-common/src/sipvoiplink.cpp @@ -32,6 +32,28 @@ #define CAN_REINVITE 1 +static char * invitationStateMap[] = { +"PJSIP_INV_STATE_NULL", +"PJSIP_INV_STATE_CALLING", +"PJSIP_INV_STATE_INCOMING", +"PJSIP_INV_STATE_EARLY", +"PJSIP_INV_STATE_CONNECTING", +"PJSIP_INV_STATE_CONFIRMED", +"PJSIP_INV_STATE_DISCONNECTED" +}; + +static char * transactionStateMap[] = { +"PJSIP_TSX_STATE_NULL" , +"PJSIP_TSX_STATE_CALLING", +"PJSIP_TSX_STATE_TRYING", +"PJSIP_TSX_STATE_PROCEEDING", +"PJSIP_TSX_STATE_COMPLETED", +"PJSIP_TSX_STATE_CONFIRMED", +"PJSIP_TSX_STATE_TERMINATED", +"PJSIP_TSX_STATE_DESTROYED", +"PJSIP_TSX_STATE_MAX" +}; + struct result { pj_status_t status; @@ -411,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); @@ -445,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); @@ -574,7 +600,7 @@ SIPVoIPLink::newOutgoingCall (const CallID& id, const std::string& toUrl) setCallAudioLocal (call, getLocalIPAddress(), useStun(), getStunServer()); try { - _debug ("CREATE NEW RTP SESSION FROM NEWOUTGOINGCALL\n"); + _debug ("Creating new rtp session in newOutgoingCall\n"); _audiortp->createNewSession (call); } catch (...) { _debug ("Failed to create rtp thread from newOutGoingCall\n"); @@ -1154,12 +1180,10 @@ SIPVoIPLink::SIPStartCall (SIPCall* call, const std::string& subject UNUSED) strTo = getSipTo (call->getPeerNumber(), account->getHostname()); - _debug (" To: %s\n", strTo.data()); - // Generate the from URI strFrom = "sip:" + account->getUsername() + "@" + account->getHostname(); - _debug (" From: %s\n", strFrom.c_str()); + _debug ("Placing new call: \nTo: %s\nFrom: %s\n", strTo.data(), strFrom.c_str()); // pjsip need the from and to information in pj_str_t format pj_strdup2 (_pool, &from, strFrom.data()); @@ -1929,7 +1953,7 @@ void SIPVoIPLink::handle_reinvite (SIPCall *call) // This callback is called when the invite session state has changed void call_on_state_changed (pjsip_inv_session *inv, pjsip_event *e) { - _debug ("--------------------- call_on_state_changed --------------------- %i\n", inv->state); + _debug ("call_on_state_changed to state %s\n", invitationStateMap[inv->state]); SIPCall *call; AccountID accId; @@ -2039,7 +2063,7 @@ void call_on_state_changed (pjsip_inv_session *inv, pjsip_event *e) link->SIPCallAnswered (call, rdata); } else if (inv->state == PJSIP_INV_STATE_DISCONNECTED) { - _debug ("------------------- Call disconnected ---------------------\n"); + _debug ("Invitation falled in state \"disconnected\".\n"); _debug ("State: %i, Disconnection cause: %i\n", inv->state, inv->cause); switch (inv->cause) { @@ -2082,7 +2106,7 @@ void call_on_state_changed (pjsip_inv_session *inv, pjsip_event *e) // This callback is called after SDP offer/answer session has completed. void call_on_media_update (pjsip_inv_session *inv, pj_status_t status) { - _debug ("--------------------- call_on_media_update --------------------- \n"); + _debug ("call_on_media_update\n"); const pjmedia_sdp_session *local_sdp; const pjmedia_sdp_session *remote_sdp; @@ -2140,8 +2164,7 @@ void call_on_forked (pjsip_inv_session *inv, pjsip_event *e) void call_on_tsx_changed (pjsip_inv_session *inv, pjsip_transaction *tsx, pjsip_event *e) { - - _debug ("--------------------- call_on_tsx_changed --------------------- %i\n", tsx->state); + _debug ("call_on_tsx_changed to state %s\n", transactionStateMap[tsx->state]); if (tsx->role==PJSIP_ROLE_UAS && tsx->state==PJSIP_TSX_STATE_TRYING && pjsip_method_cmp (&tsx->method, &pjsip_refer_method) ==0) { @@ -2244,7 +2267,7 @@ mod_on_rx_request (pjsip_rx_data *rdata) userName = std::string (sip_uri->user.ptr, sip_uri->user.slen); server = std::string (sip_uri->host.ptr, sip_uri->host.slen); - std::cout << userName << " ------------------ " << server << std::endl; + _debug("mod_on_rx_request: %s@%s\n", userName.c_str(), server.c_str()); // Get the account id of callee from username and server account_id = Manager::instance().getAccountIdFromNameAndServer (userName, server); @@ -2433,7 +2456,7 @@ mod_on_rx_request (pjsip_rx_data *rdata) pj_bool_t mod_on_rx_response (pjsip_rx_data *rdata UNUSED) { - + _debug("Mod on rx response"); return PJ_SUCCESS; } diff --git a/sflphone-common/src/user_cfg.h b/sflphone-common/src/user_cfg.h index f6dc3ab80703b1f8fc02c3694568933f074ee594..252da7e57127ee6febfb8e9ab60c4557d8576c23 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"