diff --git a/sflphone-client-gnome/src/actions.c b/sflphone-client-gnome/src/actions.c index 008592f7b231ae230d6b6563dff7874a8feac25a..38c5e8ba4d176a9cc5cbafdedddd5d4af054e367 100644 --- a/sflphone-client-gnome/src/actions.c +++ b/sflphone-client-gnome/src/actions.c @@ -243,16 +243,18 @@ void sflphone_fill_account_list (void) for (i = 0; i < account_list_get_size(); i++) { account_t * a = account_list_get_nth (i); - GHashTable * details = (GHashTable *) dbus_account_details (a->accountID); - - if (details == NULL) + if(a == NULL) { + ERROR("SFLphone: Error: Could not find account %d in list", i); break; + } - a->properties = details; + GHashTable * details = (GHashTable *) dbus_get_account_details (a->accountID); + if (details == NULL) { + ERROR("SFLphone: Error: Could not fetch detais for account %s", a->accountID); + break; + } - /* As this function might be called numberous time, we should free the - * previously allocated space to avoid memory leaks. - */ + a->properties = details; /* Fill the actual array of credentials */ int number_of_credential = dbus_get_number_of_credential (a->accountID); diff --git a/sflphone-client-gnome/src/config/accountconfigdialog.c b/sflphone-client-gnome/src/config/accountconfigdialog.c index 4b86dad105a00d167b715066775ab27e0ee61176..010f0fbce2adb8b2e8f2e33fceefa7a7a3d3fd4b 100644 --- a/sflphone-client-gnome/src/config/accountconfigdialog.c +++ b/sflphone-client-gnome/src/config/accountconfigdialog.c @@ -684,6 +684,9 @@ static void set_published_addr_manually_cb (GtkWidget * widget, gpointer data UN static void use_stun_cb (GtkWidget *widget, gpointer data UNUSED) { + + + if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget))) { DEBUG ("Config: Showing stun options, hiding Local/Published info"); @@ -713,6 +716,8 @@ static void use_stun_cb (GtkWidget *widget, gpointer data UNUSED) gtk_widget_show (publishedPortSpinBox); } } + + DEBUG("DONE"); } @@ -1105,11 +1110,13 @@ GtkWidget* create_published_address (account_t **a) useStunCheckBox = gtk_check_button_new_with_mnemonic (_ ("Using STUN")); gtk_table_attach_defaults (GTK_TABLE (table), useStunCheckBox, 0, 1, 0, 1); + g_signal_connect (useStunCheckBox, "toggled", G_CALLBACK (use_stun_cb), a); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (useStunCheckBox), g_strcasecmp (stun_enable, "true") == 0 ? TRUE: FALSE); gtk_widget_set_sensitive (GTK_WIDGET (useStunCheckBox), g_strcasecmp (use_tls,"true") == 0 ? FALSE: TRUE); + stunServerLabel = gtk_label_new_with_mnemonic (_ ("STUN server URL")); gtk_table_attach_defaults (GTK_TABLE (table), stunServerLabel, 0, 1, 1, 2); gtk_misc_set_alignment (GTK_MISC (stunServerLabel), 0, 0.5); @@ -1154,7 +1161,6 @@ GtkWidget* create_published_address (account_t **a) // widgets need to be instanciated before that. g_signal_connect (localAddressCombo, "changed", G_CALLBACK (local_interface_changed_cb), localAddressCombo); - g_signal_connect (useStunCheckBox, "toggled", G_CALLBACK (use_stun_cb), useStunCheckBox); g_signal_connect (sameAsLocalRadioButton, "toggled", G_CALLBACK (same_as_local_cb), sameAsLocalRadioButton); g_signal_connect (publishedAddrRadioButton, "toggled", G_CALLBACK (set_published_addr_manually_cb), publishedAddrRadioButton); @@ -1310,9 +1316,9 @@ void show_account_window (account_t * a) currentAccount = a; if (currentAccount == NULL) { - DEBUG ("Config: Account is NULL. Will fetch default values"); + DEBUG ("Config: Fetching default values for new account"); currentAccount = g_new0 (account_t, 1); - currentAccount->properties = dbus_account_details (NULL); + currentAccount->properties = dbus_get_account_details (NULL); currentAccount->accountID = "new"; sflphone_fill_codec_list_per_account (¤tAccount); } diff --git a/sflphone-client-gnome/src/config/accountlistconfigdialog.c b/sflphone-client-gnome/src/config/accountlistconfigdialog.c index f00701fa2079b64aeaa7ca202f42d324ef062196..5df3718fb3e36e81bc16dea4b6b8008123422109 100644 --- a/sflphone-client-gnome/src/config/accountlistconfigdialog.c +++ b/sflphone-client-gnome/src/config/accountlistconfigdialog.c @@ -67,10 +67,12 @@ enum { */ static void delete_account_cb (void) { - - if (selectedAccount != NULL) { - dbus_remove_account (selectedAccount->accountID); + if(selectedAccount == NULL) { + ERROR("Config: Error: No selected account in delete action"); + return; } + + dbus_remove_account (selectedAccount->accountID); } @@ -79,10 +81,12 @@ static void delete_account_cb (void) */ static void edit_account_cb (void) { - - if (selectedAccount != NULL) { - show_account_window (selectedAccount); + if(selectedAccount == NULL) { + ERROR("Config: Error: No selected account in edit action"); + return; } + + show_account_window (selectedAccount); } /** @@ -101,7 +105,7 @@ void account_list_config_dialog_fill() { if (accountListDialog == NULL) { - DEBUG ("Dialog is not opened"); + ERROR("Config: Error: Dialog is not opened"); return; } @@ -111,30 +115,37 @@ void account_list_config_dialog_fill() // IP2IP account must be first account_t *a = account_list_get_by_id ("IP2IP"); + if(a == NULL) { + ERROR("Config: Error: Could not find IP2IP account"); + return; + } - if (a) { - gtk_list_store_append (accountStore, &iter); + gtk_list_store_append (accountStore, &iter); - DEBUG ("Filling accounts: Account is enabled :%s", g_hash_table_lookup (a->properties, ACCOUNT_ENABLED)); + DEBUG ("Config: Filling accounts: Account is enabled :%s", g_hash_table_lookup (a->properties, ACCOUNT_ENABLED)); - gtk_list_store_set (accountStore, &iter, + gtk_list_store_set (accountStore, &iter, COLUMN_ACCOUNT_ALIAS, g_hash_table_lookup (a->properties, ACCOUNT_ALIAS), // Name COLUMN_ACCOUNT_TYPE, g_hash_table_lookup (a->properties, ACCOUNT_TYPE), // Protocol COLUMN_ACCOUNT_STATUS, account_state_name (a->state), // Status COLUMN_ACCOUNT_ACTIVE, (g_strcasecmp (g_hash_table_lookup (a->properties, ACCOUNT_ENABLED),"true") == 0) ? TRUE:FALSE, // Enable/Disable COLUMN_ACCOUNT_DATA, a, // Pointer -1); - } unsigned int i; - for (i = 0; i < account_list_get_size(); i++) { a = account_list_get_nth (i); - if (a && g_strcmp0 (a->accountID, "IP2IP") != 0) { + if(a==NULL) { + ERROR("Config: Error: Account %d is NULL while parsing the list", i); + return; + } + + // we dont wnat to process account twice + if (g_strcmp0 (a->accountID, "IP2IP") != 0) { gtk_list_store_append (accountStore, &iter); - DEBUG ("Filling accounts: Account is enabled :%s", g_hash_table_lookup (a->properties, ACCOUNT_ENABLED)); + DEBUG ("Config: Filling accounts: Account is enabled :%s", g_hash_table_lookup (a->properties, ACCOUNT_ENABLED)); gtk_list_store_set (accountStore, &iter, COLUMN_ACCOUNT_ALIAS, g_hash_table_lookup (a->properties, ACCOUNT_ALIAS), // Name @@ -145,11 +156,8 @@ void account_list_config_dialog_fill() -1); } } - } - - /** * Call back when the user click on an account in the list */ diff --git a/sflphone-client-gnome/src/config/assistant.c b/sflphone-client-gnome/src/config/assistant.c index 37a2ee04f9d91614e3e7e18792f845917c6e7b5e..84ce7cb06b0e3afbfd9e061ded12381c01160aad 100644 --- a/sflphone-client-gnome/src/config/assistant.c +++ b/sflphone-client-gnome/src/config/assistant.c @@ -242,7 +242,7 @@ void build_wizard (void) wiz = (struct _wizard*) g_malloc (sizeof (struct _wizard)); current = g_new0 (account_t, 1); current->properties = NULL; - current->properties = dbus_account_details (NULL); + current->properties = dbus_get_account_details (NULL); if (current->properties == NULL) { DEBUG ("Failed to get default values. Creating from scratch"); diff --git a/sflphone-client-gnome/src/dbus/dbus.c b/sflphone-client-gnome/src/dbus/dbus.c index 5598c85550bbff1116c49d3d74177040268b617f..1838cbee8fd318e142f30ce96b1ae071edcc4dc3 100644 --- a/sflphone-client-gnome/src/dbus/dbus.c +++ b/sflphone-client-gnome/src/dbus/dbus.c @@ -926,7 +926,7 @@ dbus_account_list() } GHashTable* -dbus_account_details (gchar * accountID) +dbus_get_account_details (gchar * accountID) { GError *error = NULL; GHashTable * details; diff --git a/sflphone-client-gnome/src/dbus/dbus.h b/sflphone-client-gnome/src/dbus/dbus.h index fc35b6eb3348b1c5185e700da8ab653ea5caefce..e7ee1f29571ebe48a009edc4a60e5b533fb0db9c 100644 --- a/sflphone-client-gnome/src/dbus/dbus.h +++ b/sflphone-client-gnome/src/dbus/dbus.h @@ -118,7 +118,7 @@ gchar ** dbus_account_list(); * @param accountID The unique of the account * @return GHashTable* The details of the account */ -GHashTable * dbus_account_details (gchar * accountID); +GHashTable * dbus_get_account_details (gchar * accountID); /** * ConfigurationManager - Set the details of a specific account diff --git a/sflphone-common/src/managerimpl.cpp b/sflphone-common/src/managerimpl.cpp index 16fe925b68197e3fb654d12deee6f215703f0bfa..f38c7bb4499195421290ab4498f88c03a0f1f759 100644 --- a/sflphone-common/src/managerimpl.cpp +++ b/sflphone-common/src/managerimpl.cpp @@ -3830,27 +3830,33 @@ void ManagerImpl::setAccountDetails (const std::string& accountID, const std::map<std::string, std::string>& details) { - _debug ("Manager: Set account details %s", accountID.c_str()); + _debug ("Manager: Set account details for %s", accountID.c_str()); - Account* account; - - if (! (account = getAccount (accountID))) { - _warn ("Manager: Cannot setAccountDetails on a non-existing accountID %s.", accountID.c_str()); + Account* account = getAccount(accountID); + if (account == NULL) { + _error ("Manager: Error: Could not find account %s", accountID.c_str()); return; } account->setAccountDetails (details); + // Serialize configuration to disk once it is done saveConfig(); - if (account->isEnabled()) + if (account->isEnabled()) { account->registerVoIPLink(); - else + } + else { account->unregisterVoIPLink(); + } // Update account details to the client side - if (_dbus) - _dbus->getConfigurationManager()->accountsChanged(); + if (_dbus) { + _error("Manager: Error: Dbus not initialized"); + return; + } + + _dbus->getConfigurationManager()->accountsChanged(); } diff --git a/sflphone-common/src/sip/sipaccount.cpp b/sflphone-common/src/sip/sipaccount.cpp index 628913d51b0bc046b80e237209882eb3d297ea90..0e7bef541dafddc966c38c3d0c3c6cef57f48570 100644 --- a/sflphone-common/src/sip/sipaccount.cpp +++ b/sflphone-common/src/sip/sipaccount.cpp @@ -719,15 +719,15 @@ void SIPAccount::setAccountDetails (const std::map<std::string, std::string>& de setDisplayName (displayName); setServiceRoute (routeset); setLocalInterface (localInterface); - setPublishedSameasLocal ( (publishedSameasLocal.compare ("true") == 0) ? true : false); + setPublishedSameasLocal (publishedSameasLocal == "true"); setPublishedAddress (publishedAddress); setLocalPort (atoi (localPort.data())); setPublishedPort (atoi (publishedPort.data())); setStunServer (stunServer); - setStunEnabled ( (stunEnable == "true")); + setStunEnabled (stunEnable == "true"); setDtmfType ( (dtmfType == "overrtp") ? OVERRTP : SIPINFO); - setResolveOnce ( (resolveOnce.compare ("true") ==0) ? true : false); + setResolveOnce (resolveOnce == "true"); setRegistrationExpire (registrationExpire); // sip credential @@ -746,13 +746,12 @@ void SIPAccount::setAccountDetails (const std::map<std::string, std::string>& de find_in_map (ZRTP_HELLO_HASH, zrtpHelloHash) find_in_map (SRTP_KEY_EXCHANGE, srtpKeyExchange) - setSrtpEnable ( (srtpEnable.compare ("true") == 0) ? true : false); - setSrtpFallback ( (srtpRtpFallback.compare ("true") == 0) ? true : false); - setZrtpDisplaySas ( (zrtpDisplaySas.compare ("true") == 0) ? true : false); - setZrtpDiaplaySasOnce ( (zrtpDisplaySasOnce.compare ("true") == 0) ? true : false); - setZrtpNotSuppWarning ( (zrtpNotSuppWarning.compare ("true") == 0) ? true : false); - setZrtpHelloHash ( (zrtpHelloHash.compare ("true") == 0) ? true : false); - // sipaccount->setSrtpKeyExchange((srtpKeyExchange.compare("true") == 0) ? true : false); + setSrtpEnable (srtpEnable == "true"); + setSrtpFallback (srtpRtpFallback == "true"); + setZrtpDisplaySas (zrtpDisplaySas == "true"); + setZrtpDiaplaySasOnce (zrtpDisplaySasOnce == "true"); + setZrtpNotSuppWarning (zrtpNotSuppWarning == "true"); + setZrtpHelloHash (zrtpHelloHash == "true"); setSrtpKeyExchange (srtpKeyExchange); // TLS settings @@ -787,9 +786,9 @@ void SIPAccount::setAccountDetails (const std::map<std::string, std::string>& de setTlsMethod (tlsMethod); setTlsCiphers (tlsCiphers); setTlsServerName (tlsServerName); - setTlsVerifyServer (tlsVerifyServer.compare ("true") ? true : false); - setTlsVerifyClient (tlsVerifyServer.compare ("true") ? true : false); - setTlsRequireClientCertificate (tlsRequireClientCertificate.compare ("true") ? true : false); + setTlsVerifyServer (tlsVerifyServer == "true"); + setTlsVerifyClient (tlsVerifyServer == "true"); + setTlsRequireClientCertificate (tlsRequireClientCertificate == "true"); setTlsNegotiationTimeoutSec (tlsNegotiationTimeoutSec); setTlsNegotiationTimeoutMsec (tlsNegotiationTimeoutMsec); diff --git a/sflphone-common/src/sip/sipaccount.h b/sflphone-common/src/sip/sipaccount.h index afe8f8331bbf0ba013555b4a43bbfd5f83ba72b8..3450ce135cfed3ca0fc251f00be7e219c65a5dc4 100644 --- a/sflphone-common/src/sip/sipaccount.h +++ b/sflphone-common/src/sip/sipaccount.h @@ -359,12 +359,16 @@ class SIPAccount : public Account } /** - * @return bool Tells if current transport for that - * account is set to OTHER. - */ + * @return bool Tells if current transport for that + * account is set to OTHER. + */ inline bool isStunEnabled (void) { - return (_transportType == PJSIP_TRANSPORT_START_OTHER) ? true: false; + return _stunEnabled; } + + /** + * Set wether or not stun is enabled for this account + */ inline void setStunEnabled (bool enabl) { _stunEnabled = enabl; }