diff --git a/sflphone-client-gnome/src/config/accountconfigdialog.c b/sflphone-client-gnome/src/config/accountconfigdialog.c index 7467d38fae3f6f50803742b2141d1c00402edada..33eb8177513b5e99ad562f2720441a02883f7567 100644 --- a/sflphone-client-gnome/src/config/accountconfigdialog.c +++ b/sflphone-client-gnome/src/config/accountconfigdialog.c @@ -419,9 +419,45 @@ static void use_sip_tls_cb(GtkWidget *widget, gpointer data) { if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget))) { DEBUG("Using sips"); - gtk_widget_set_sensitive(GTK_WIDGET(data), TRUE); + gtk_widget_set_sensitive(GTK_WIDGET(data), TRUE); + // Uncheck stun + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(useStunCheckBox), FALSE); + gtk_widget_set_sensitive(GTK_WIDGET(useStunCheckBox), FALSE); + gtk_widget_set_sensitive(GTK_WIDGET(sameAsLocalRadioButton), TRUE); + gtk_widget_set_sensitive(GTK_WIDGET(publishedAddrRadioButton), TRUE); + gtk_widget_hide(stunServerLabel); + gtk_widget_hide(stunServerEntry); + + + + if(!gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(sameAsLocalRadioButton))) { + gtk_widget_show(publishedAddressEntry); + gtk_widget_show(publishedPortSpinBox); + gtk_widget_show(publishedAddressLabel); + gtk_widget_show(publishedPortLabel); + } + } else { - gtk_widget_set_sensitive(GTK_WIDGET(data), FALSE); + gtk_widget_set_sensitive(GTK_WIDGET(data), FALSE); + gtk_widget_set_sensitive(GTK_WIDGET(useStunCheckBox), TRUE); + + if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(useStunCheckBox))) { + gtk_widget_set_sensitive(GTK_WIDGET(sameAsLocalRadioButton), FALSE); + gtk_widget_set_sensitive(GTK_WIDGET(publishedAddrRadioButton), FALSE); + gtk_widget_show(stunServerLabel); + gtk_widget_show(stunServerEntry); + gtk_widget_hide(publishedAddressEntry); + gtk_widget_hide(publishedPortSpinBox); + gtk_widget_hide(publishedAddressLabel); + gtk_widget_hide(publishedPortLabel); + } + else { + gtk_widget_set_sensitive(GTK_WIDGET(sameAsLocalRadioButton), TRUE); + gtk_widget_set_sensitive(GTK_WIDGET(publishedAddrRadioButton), TRUE); + gtk_widget_hide(stunServerLabel); + gtk_widget_hide(stunServerEntry); + } + } } @@ -537,24 +573,27 @@ GtkWidget * create_security_tab(account_t **a) g_signal_connect (deleteCredButton, "clicked", G_CALLBACK (delete_credential_cb), treeViewCredential); gtk_box_pack_start(GTK_BOX(hbox), deleteCredButton, FALSE, FALSE, 0); - /* SRTP Section */ + /* SRTP Section */ gnome_main_section_new_with_table (_("Security"), &frame, &table, 2, 3); - gtk_container_set_border_width (GTK_CONTAINER(table), 10); - gtk_table_set_row_spacings (GTK_TABLE(table), 10); + gtk_container_set_border_width (GTK_CONTAINER(table), 10); + gtk_table_set_row_spacings (GTK_TABLE(table), 10); gtk_table_set_col_spacings( GTK_TABLE(table), 10); gtk_box_pack_start(GTK_BOX(ret), frame, FALSE, FALSE, 0); - GtkWidget * sipTlsAdvancedButton; - sipTlsAdvancedButton = gtk_button_new_from_stock(GTK_STOCK_EDIT); + + /* TLS subsection */ + GtkWidget * sipTlsAdvancedButton; + sipTlsAdvancedButton = gtk_button_new_from_stock(GTK_STOCK_EDIT); gtk_table_attach_defaults(GTK_TABLE(table), sipTlsAdvancedButton, 2, 3, 0, 1); - gtk_widget_set_sensitive(GTK_WIDGET(sipTlsAdvancedButton), FALSE); + gtk_widget_set_sensitive(GTK_WIDGET(sipTlsAdvancedButton), FALSE); g_signal_connect(G_OBJECT(sipTlsAdvancedButton), "clicked", G_CALLBACK(show_advanced_tls_options_cb), currentAccount->properties); - useSipTlsCheckBox = gtk_check_button_new_with_mnemonic(_("Use TLS transport (sips)")); - g_signal_connect (useSipTlsCheckBox, "toggled", G_CALLBACK(use_sip_tls_cb), sipTlsAdvancedButton); - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(useSipTlsCheckBox), (g_strcmp0(curTLSEnabled, "true") == 0) ? TRUE:FALSE); - gtk_table_attach_defaults(GTK_TABLE(table), useSipTlsCheckBox, 0, 2, 0, 1); + useSipTlsCheckBox = gtk_check_button_new_with_mnemonic(_("Use TLS transport (sips)")); + g_signal_connect (useSipTlsCheckBox, "toggled", G_CALLBACK(use_sip_tls_cb), sipTlsAdvancedButton); + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(useSipTlsCheckBox), (g_strcmp0(curTLSEnabled, "true") == 0) ? TRUE:FALSE); + gtk_table_attach_defaults(GTK_TABLE(table), useSipTlsCheckBox, 0, 2, 0, 1); + /* ZRTP subsection */ label = gtk_label_new_with_mnemonic (_("SRTP key exchange")); gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5); keyExchangeCombo = gtk_combo_box_new_text(); @@ -607,12 +646,21 @@ static use_stun_cb(GtkWidget * widget, gpointer data UNUSED) gtk_widget_show(stunServerEntry); gtk_widget_set_sensitive(sameAsLocalRadioButton, FALSE); gtk_widget_set_sensitive(publishedAddrRadioButton, FALSE); + gtk_widget_hide(publishedAddressLabel); + gtk_widget_hide(publishedPortLabel); + gtk_widget_hide(publishedAddressEntry); + gtk_widget_hide(publishedPortSpinBox); } else { gtk_widget_hide(stunServerLabel); gtk_widget_hide(stunServerEntry); gtk_widget_set_sensitive(sameAsLocalRadioButton, TRUE); gtk_widget_set_sensitive(publishedAddrRadioButton, TRUE); - // sameAsLocalLabel + if(!gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(sameAsLocalRadioButton))) { + gtk_widget_show(publishedAddressLabel); + gtk_widget_show(publishedPortLabel); + gtk_widget_show(publishedAddressEntry); + gtk_widget_show(publishedPortSpinBox); + } } } @@ -781,7 +829,7 @@ GtkWidget * create_advanced_tab(account_t **a) useStunCheckBox = gtk_check_button_new_with_mnemonic(_("Using STUN")); gtk_table_attach_defaults(GTK_TABLE(table), useStunCheckBox, 0, 1, 0, 1); - gtk_toggle_button_set_active (GTK_WIDGET(useStunCheckBox), + 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); @@ -801,7 +849,7 @@ GtkWidget * create_advanced_tab(account_t **a) gtk_table_attach_defaults(GTK_TABLE(table), publishedAddrRadioButton, 0, 2, 4, 5); if(g_strcasecmp(published_sameas_local, "true") == 0) { - gtk_toggle_button_set_active (GTK_WIDGET(sameAsLocalRadioButton), TRUE); + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(sameAsLocalRadioButton), TRUE); } else { gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(publishedAddrRadioButton), TRUE); } @@ -832,14 +880,7 @@ GtkWidget * create_advanced_tab(account_t **a) 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); -/* - if ((g_strcasecmp(published_address, local_address) == 0) - && (g_strcasecmp(published_port, local_port) == 0)) { - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(sameAsLocalRadioButton), TRUE); - } else { - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(publishedAddrRadioButton), TRUE); - } -*/ + return ret; } diff --git a/sflphone-common/src/managerimpl.cpp b/sflphone-common/src/managerimpl.cpp index 98ee2d94516f5bf4b82c00f2ca1186085c066f0c..5b2f288e8e00caf92058d5f0aa8e0556887678d1 100644 --- a/sflphone-common/src/managerimpl.cpp +++ b/sflphone-common/src/managerimpl.cpp @@ -2276,6 +2276,7 @@ ManagerImpl::initConfigFile (bool load_user_value, std::string alternate) _config.addDefaultValue (std::pair<std::string, std::string> (TLS_REQUIRE_CLIENT_CERTIFICATE, TRUE_STR), IP2IP_PROFILE); _config.addDefaultValue (std::pair<std::string, std::string> (TLS_NEGOTIATION_TIMEOUT_SEC, "2"), IP2IP_PROFILE); _config.addDefaultValue (std::pair<std::string, std::string> (TLS_NEGOTIATION_TIMEOUT_MSEC, "0"), IP2IP_PROFILE); + _config.addDefaultValue (std::pair<std::string, std::string> (PUBLISHED_SAMEAS_LOCAL, TRUE_STR), IP2IP_PROFILE); _config.addDefaultValue (std::pair<std::string, std::string> (LOCAL_PORT, DEFAULT_SIP_PORT), IP2IP_PROFILE); _config.addDefaultValue (std::pair<std::string, std::string> (PUBLISHED_PORT, DEFAULT_SIP_PORT), IP2IP_PROFILE); _config.addDefaultValue (std::pair<std::string, std::string> (LOCAL_ADDRESS, DEFAULT_ADDRESS), IP2IP_PROFILE); @@ -3414,7 +3415,7 @@ ManagerImpl::setConfig (const std::string& section, const std::string& name, int void ManagerImpl::setAccountsOrder (const std::string& order) { - _debug ("Set accounts order : %s\n", order.c_str()); + _debug ("Setcreate accounts order : %s\n", order.c_str()); // Set the new config setConfig (PREFERENCES, CONFIG_ACCOUNTS_ORDER, order); } diff --git a/sflphone-common/src/sip/sipaccount.cpp b/sflphone-common/src/sip/sipaccount.cpp index 00b862ae92d33249201bc62dfde65e8a4273001d..30f73b47058ee70e114d66ca331709de4ae7b0a3 100644 --- a/sflphone-common/src/sip/sipaccount.cpp +++ b/sflphone-common/src/sip/sipaccount.cpp @@ -29,6 +29,7 @@ SIPAccount::SIPAccount (const AccountID& accountID) , _regc (NULL) , _bRegister (false) , _registrationExpire ("") + , _publishedSameasLocal(true) , _localIpAddress ("") , _publishedIpAddress ("") , _actualSessionAddress ("") diff --git a/sflphone-common/src/sip/sipaccount.h b/sflphone-common/src/sip/sipaccount.h index 8ad7451fb2b89b4ff74237e1018bc7db4ffe6c21..093decb97f92cc53655ded7f2d6c121cb7cca13a 100644 --- a/sflphone-common/src/sip/sipaccount.h +++ b/sflphone-common/src/sip/sipaccount.h @@ -143,7 +143,7 @@ class SIPAccount : public Account */ inline bool isTlsEnabled(void) { return (_transportType == PJSIP_TRANSPORT_TLS) ? true: false; } - /** + /** * @return bool Tells if current transport for that * account is set to OTHER. */ @@ -188,6 +188,21 @@ class SIPAccount : public Account */ std::string getContactHeader(const std::string& address, const std::string& port); + + /** + * Get a flag which determine the usage in sip headers of either the local + * IP address and port (_localAddress and _localPort) or to an address set + * manually (_publishedAddress and _publishedPort). + */ + bool getPublishedSameasLocal(){ return _publishedSameasLocal; } + + /** + * Set a flag which determine the usage in sip headers of either the local + * IP address and port (_localAddress and _localPort) or to an address set + * manually (_publishedAddress and _publishedPort). + */ + void setPublishedSameasLocal(bool published){ _publishedSameasLocal = published; } + /** * Get the port on which the transport/listener should use, or is * actually using. @@ -249,17 +264,17 @@ class SIPAccount : public Account */ inline pjsip_transport_type_e getTransportType(void) { return _transportType; } - inline pjsip_transport* getAccountTransport (void) { return _transport; } + inline pjsip_transport* getAccountTransport (void) { return _transport; } - inline void setAccountTransport (pjsip_transport *transport) { _transport = transport; } + inline void setAccountTransport (pjsip_transport *transport) { _transport = transport; } - inline std::string getSessionAddress () { return _actualSessionAddress; } + inline std::string getSessionAddress () { return _actualSessionAddress; } + + inline void setSessionAddress (std::string addr) { _actualSessionAddress = addr; } + + inline pj_uint16_t getSessionPort () { return _actualSessionPort; } - inline void setSessionAddress (std::string addr) { _actualSessionAddress = addr; } - - inline pj_uint16_t getSessionPort () { return _actualSessionPort; } - - inline void setSessionPort (pj_uint16_t port) { _actualSessionPort = port; } + inline void setSessionPort (pj_uint16_t port) { _actualSessionPort = port; } private: @@ -312,6 +327,10 @@ class SIPAccount : public Account // Network settings std::string _registrationExpire; + + // Flag which determine if _localIpAddress or _publishedIpAddress is used in + // sip headers + bool _publishedSameasLocal; std::string _localIpAddress; std::string _publishedIpAddress;