diff --git a/sflphone-client-gnome/src/accountlist.h b/sflphone-client-gnome/src/accountlist.h index bb96970cb827052979a15ea8b732ca27700635c3..51f3c878e71c8fcb9d829d4f2f30fdff693b2143 100644 --- a/sflphone-client-gnome/src/accountlist.h +++ b/sflphone-client-gnome/src/accountlist.h @@ -65,9 +65,10 @@ typedef enum typedef struct { gchar * accountID; - account_state_t state; + account_state_t state; + gchar * protocol_state_description; + guint * protocol_state_code; GHashTable * properties; - GHashTable * tlsSettings; GPtrArray * credential_information; } account_t; diff --git a/sflphone-client-gnome/src/actions.c b/sflphone-client-gnome/src/actions.c index 35aeb1a761328b7252ee78effcd6a98d808c73c9..25bb9b11a4b6a547adff7fb59d35a4e5cf793e41 100644 --- a/sflphone-client-gnome/src/actions.c +++ b/sflphone-client-gnome/src/actions.c @@ -186,11 +186,7 @@ sflphone_fill_account_list(gboolean toolbarInitialized) if( details == NULL ) break; a->properties = details; - - GHashTable * tlsSettings = NULL; - tlsSettings = dbus_get_tls_settings(a->accountID); - a->tlsSettings = tlsSettings; - + /* As this function might be called numberous time, we should free the * previously allocated space to avoid memory leaks. */ @@ -210,7 +206,7 @@ sflphone_fill_account_list(gboolean toolbarInitialized) g_ptr_array_add(a->credential_information, credential_information); } - gchar * status = g_hash_table_lookup(details, "Status"); + gchar * status = g_hash_table_lookup(details, REGISTRATION_STATUS); if(strcmp(status, "REGISTERED") == 0) { a->state = ACCOUNT_STATE_REGISTERED; @@ -252,6 +248,13 @@ sflphone_fill_account_list(gboolean toolbarInitialized) a->state = ACCOUNT_STATE_INVALID; } + gchar * code = NULL; + code = g_hash_table_lookup(details, REGISTRATION_STATE_CODE); + if (code != NULL) { + a->protocol_state_code = atoi(code); + } + g_free(a->protocol_state_description); + a->protocol_state_description = g_hash_table_lookup(details, REGISTRATION_STATE_DESCRIPTION); } // Prevent update being called when toolbar is not yet initialized diff --git a/sflphone-client-gnome/src/config/Makefile.am b/sflphone-client-gnome/src/config/Makefile.am index 7640d8187b9731425dd0f16835e18670cfdf9d85..2c7f3e7b613c99e0470382f03e1ee45ffd6b51be 100644 --- a/sflphone-client-gnome/src/config/Makefile.am +++ b/sflphone-client-gnome/src/config/Makefile.am @@ -4,7 +4,8 @@ noinst_LTLIBRARIES = libconfig.la libconfig_la_SOURCES = \ addressbook-config.c \ - configwindow.c \ + preferencesdialog.c \ + accountlistconfigdialog.c \ zrtpadvanceddialog.c \ tlsadvanceddialog.c \ accountwindow.c \ diff --git a/sflphone-client-gnome/src/config/accountwindow.c b/sflphone-client-gnome/src/config/accountwindow.c index e81d32da3adad19ae6bf7d499b7da0d757dcf24f..e54593ce4b1ea7653d383adc65fe4154007be83d 100644 --- a/sflphone-client-gnome/src/config/accountwindow.c +++ b/sflphone-client-gnome/src/config/accountwindow.c @@ -1025,7 +1025,7 @@ show_account_window (account_t * a) g_strdup(PUBLISHED_ADDRESS), g_strdup((gchar *)gtk_entry_get_text(GTK_ENTRY(publishedAddressEntry)))); - config_window_set_stun_visible(); + preferences_dialog_set_stun_visible(); } /* Set new credentials if any */ diff --git a/sflphone-client-gnome/src/config/accountwindow.h b/sflphone-client-gnome/src/config/accountwindow.h index c7e5e53e0b2e412855eff5247a5c4988001b6f67..50e6f760f65213b69f56b26f2d5507dc580c29fe 100644 --- a/sflphone-client-gnome/src/config/accountwindow.h +++ b/sflphone-client-gnome/src/config/accountwindow.h @@ -25,7 +25,7 @@ */ #include "utils.h" -#include "configwindow.h" +#include "preferencesdialog.h" /** * Display the main account widget diff --git a/sflphone-client-gnome/src/config/audioconf.c b/sflphone-client-gnome/src/config/audioconf.c index e4f9294bb97fea2c04f0ef1bdb21df6e4b0001b5..ce85d94dea9343190aa00e5360259c7221f3c088 100644 --- a/sflphone-client-gnome/src/config/audioconf.c +++ b/sflphone-client-gnome/src/config/audioconf.c @@ -51,7 +51,7 @@ enum { * Fills the tree list with supported codecs */ void -config_window_fill_codec_list() +preferences_dialog_fill_codec_list() { GtkListStore *codecStore; GtkTreeIter iter; @@ -84,7 +84,7 @@ config_window_fill_codec_list() * Fill store with output audio plugins */ void -config_window_fill_output_audio_plugin_list() +preferences_dialog_fill_output_audio_plugin_list() { GtkTreeIter iter; gchar** list; @@ -112,7 +112,7 @@ config_window_fill_output_audio_plugin_list() * Fill output audio device store */ void -config_window_fill_output_audio_device_list() +preferences_dialog_fill_output_audio_device_list() { GtkTreeIter iter; @@ -179,7 +179,7 @@ select_active_output_audio_device() * Fill input audio device store */ void -config_window_fill_input_audio_device_list() +preferences_dialog_fill_input_audio_device_list() { GtkTreeIter iter; @@ -611,7 +611,7 @@ GtkWidget* codecs_box() gtk_box_pack_start(GTK_BOX(buttonBox), codecMoveDownButton, FALSE, FALSE, 0); g_signal_connect(G_OBJECT(codecMoveDownButton), "clicked", G_CALLBACK(codec_move_down), codecTreeView); - config_window_fill_codec_list(); + preferences_dialog_fill_codec_list(); return ret; } @@ -667,7 +667,7 @@ GtkWidget* alsa_box() gtk_widget_show( item ); // Set choices of audio managers pluginlist = gtk_list_store_new(1, G_TYPE_STRING); - config_window_fill_output_audio_plugin_list(); + preferences_dialog_fill_output_audio_plugin_list(); plugin = gtk_combo_box_new_with_model(GTK_TREE_MODEL(pluginlist)); select_active_output_audio_plugin(); gtk_label_set_mnemonic_widget(GTK_LABEL(item), plugin); @@ -689,7 +689,7 @@ GtkWidget* alsa_box() gtk_widget_show(item); // Set choices of output devices outputlist = gtk_list_store_new(2, G_TYPE_STRING, G_TYPE_INT); - config_window_fill_output_audio_device_list(); + preferences_dialog_fill_output_audio_device_list(); output = gtk_combo_box_new_with_model(GTK_TREE_MODEL(outputlist)); select_active_output_audio_device(); gtk_label_set_mnemonic_widget(GTK_LABEL(item), output); @@ -712,7 +712,7 @@ GtkWidget* alsa_box() // Set choices of output devices inputlist = gtk_list_store_new(2, G_TYPE_STRING, G_TYPE_INT); - config_window_fill_input_audio_device_list(); + preferences_dialog_fill_input_audio_device_list(); input = gtk_combo_box_new_with_model(GTK_TREE_MODEL(inputlist)); select_active_input_audio_device(); gtk_label_set_mnemonic_widget(GTK_LABEL(item), input); diff --git a/sflphone-client-gnome/src/dbus/dbus.c b/sflphone-client-gnome/src/dbus/dbus.c index 3700b2308c1d2818dae76ee44a7ec79de4ca1243..0d39a1553fa8875513c6e15099ea01044dadfef5 100644 --- a/sflphone-client-gnome/src/dbus/dbus.c +++ b/sflphone-client-gnome/src/dbus/dbus.c @@ -24,7 +24,8 @@ #include <callmanager-glue.h> #include <configurationmanager-glue.h> #include <instance-glue.h> -#include <configwindow.h> +#include <preferencesdialog.h> +#include <accountlistconfigdialog.h> #include <mainwindow.h> #include <marshaller.h> #include <sliders.h> @@ -227,7 +228,7 @@ accounts_changed_cb (DBusGProxy *proxy UNUSED, DEBUG ("Accounts changed"); sflphone_fill_account_list(TRUE); sflphone_fill_ip2ip_profile(); - config_window_fill_account_list(); + account_list_config_dialog_fill(); // Update the status bar in case something happened // Should fix ticket #1215 @@ -328,7 +329,7 @@ sip_call_state_cb (DBusGProxy *proxy UNUSED, { callable_obj_t * c = NULL; c = calllist_get(current_calls, callID); - DEBUG("sip_call_state_cb received code %d callID %s", code, callID); + if(c != NULL) { DEBUG("sip_call_state_cb received code %d", code); sflphone_call_state_changed(c, description, code); @@ -502,11 +503,12 @@ dbus_connect () /* VOID STRING STRING INT */ dbus_g_object_register_marshaller(g_cclosure_user_marshal_VOID__STRING_STRING_INT, G_TYPE_NONE, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_INT, G_TYPE_INVALID); + dbus_g_proxy_add_signal (callManagerProxy, "sipCallStateChanged", G_TYPE_STRING, G_TYPE_STRING, G_TYPE_INT, G_TYPE_INVALID); dbus_g_proxy_connect_signal (callManagerProxy, "sipCallStateChanged", G_CALLBACK(sip_call_state_cb), NULL, NULL); - + configurationManagerProxy = dbus_g_proxy_new_for_name (connection, "org.sflphone.SFLphone", "/org/sflphone/SFLphone/ConfigurationManager", @@ -2152,34 +2154,6 @@ GHashTable* dbus_get_tls_settings_default(void) return results; } -GHashTable* dbus_get_tls_settings(const gchar * accountID) -{ - GError *error = NULL; - GHashTable *results = NULL; - - org_sflphone_SFLphone_ConfigurationManager_get_tls_settings(configurationManagerProxy, accountID, &results, &error); - if (error != NULL){ - ERROR ("Error calling org_sflphone_SFLphone_ConfigurationManager_get_tls_settings_default"); - g_error_free (error); - } - return results; -} - -void dbus_set_tls_settings (account_t *a) -{ - GError *error = NULL; - org_sflphone_SFLphone_ConfigurationManager_set_tls_settings ( - configurationManagerProxy, - a->accountID, - a->tlsSettings, - &error); - if (error) { - ERROR ("Failed to call set_tls_settings() on ConfigurationManager: %s", - error->message); - g_error_free (error); - } -} - gchar ** dbus_get_all_ip_interface(void) { GError *error = NULL; diff --git a/sflphone-client-gnome/src/dbus/dbus.h b/sflphone-client-gnome/src/dbus/dbus.h index 73305b489f35da47c06ce28d0727f57545cc4aa7..52dab180c1f77b5284d635ec628a4f5f169ff947 100644 --- a/sflphone-client-gnome/src/dbus/dbus.h +++ b/sflphone-client-gnome/src/dbus/dbus.h @@ -601,20 +601,6 @@ void dbus_set_confirm_go_clear (const callable_obj_t * c); */ gchar** dbus_get_supported_tls_method(); -/** - * CallManager - Get default values for TLS. - * @return a GHashTable object containing those default - * TLS settings. - * - */ -GHashTable* dbus_get_tls_settings_default(void); -/** - * CallManager - Get TLS settings for that account - * @return a GHashTable object containing those default - * TLS settings. - * - */ -GHashTable* dbus_get_tls_settings(const gchar * accountID); #endif diff --git a/sflphone-client-gnome/src/mainwindow.c b/sflphone-client-gnome/src/mainwindow.c index 1b7bdb8348e71dddb35f3eed7e29f38938d32b9e..71377ff085a958373eac254bb83c757abed1e055 100644 --- a/sflphone-client-gnome/src/mainwindow.c +++ b/sflphone-client-gnome/src/mainwindow.c @@ -24,7 +24,7 @@ #include <actions.h> #include <calltree.h> #include <calltab.h> -#include <configwindow.h> +#include <preferencesdialog.h> #include <dialpad.h> #include <mainwindow.h> #include <menus.h> @@ -257,7 +257,7 @@ create_main_window () if (response == GTK_RESPONSE_YES) { - show_config_window(); + show_preferences_dialog(); } #endif } diff --git a/sflphone-client-gnome/src/menus.c b/sflphone-client-gnome/src/menus.c index 76e9552c7c751053c02b15594aed7a650907e923..3556b5d4e8b9230a99351310c4d1a266d5d40585 100644 --- a/sflphone-client-gnome/src/menus.c +++ b/sflphone-client-gnome/src/menus.c @@ -20,7 +20,8 @@ #include <menus.h> #include <config.h> -#include <configwindow.h> +#include <preferencesdialog.h> +#include <accountlistconfigdialog.h> #include <dbus/dbus.h> #include <mainwindow.h> #include <assistant.h> @@ -393,13 +394,13 @@ create_call_menu() static void edit_preferences ( void * foo UNUSED) { - show_config_window(); + show_preferences_dialog(); } static void edit_accounts ( void * foo UNUSED) { - show_accounts_window(); + show_account_list_config_dialog(); } // The menu Edit/Copy should copy the current selected call's number diff --git a/sflphone-client-gnome/src/sflphone_const.h b/sflphone-client-gnome/src/sflphone_const.h index 627e4f919e50be7dd9ba2a161489f30749056841..4997eea888d8dcb5791524ae9e33f5023947b818 100644 --- a/sflphone-client-gnome/src/sflphone_const.h +++ b/sflphone-client-gnome/src/sflphone_const.h @@ -88,6 +88,10 @@ #define PUBLISHED_PORT "Account.publishedPort" #define PUBLISHED_ADDRESS "Account.publishedAddress" +#define REGISTRATION_STATUS "Status" +#define REGISTRATION_STATE_CODE "Registration.code" +#define REGISTRATION_STATE_DESCRIPTION "Registration.description" + /** * Global logger */ diff --git a/sflphone-client-gnome/src/uimanager.c b/sflphone-client-gnome/src/uimanager.c index a7bad0f178d93e5a8203f8cdedfe88facda86b0f..51ab183ac79f7365edbf1e9cfc3ce7cf5ba84383 100644 --- a/sflphone-client-gnome/src/uimanager.c +++ b/sflphone-client-gnome/src/uimanager.c @@ -19,7 +19,7 @@ #include <menus.h> #include <config.h> -#include <configwindow.h> +#include <preferencesdialog.h> #include <dbus/dbus.h> #include <mainwindow.h> #include <assistant.h> diff --git a/sflphone-common/src/account.h b/sflphone-common/src/account.h index 6a37fe01347c0a1e2be32cc978a00a77bd520a45..723efeb4c277028429922eb9f75c5d4578081a74 100644 --- a/sflphone-common/src/account.h +++ b/sflphone-common/src/account.h @@ -106,7 +106,11 @@ typedef enum RegistrationState { #define TLS_REQUIRE_CLIENT_CERTIFICATE "TLS.requireClientCertificate" #define TLS_NEGOTIATION_TIMEOUT_SEC "TLS.negotiationTimeoutSec" #define TLS_NEGOTIATION_TIMEOUT_MSEC "TLS.negotiationTimemoutMsec" - + +#define REGISTRATION_STATUS "Status" +#define REGISTRATION_STATE_CODE "Registration.code" +#define REGISTRATION_STATE_DESCRIPTION "Registration.description" + class Account{ public: @@ -162,7 +166,30 @@ class Account{ */ inline RegistrationState getRegistrationState() { return _registrationState; } + /** + * Set the registration state of the specified link + * @param state The registration state of underlying VoIPLink + */ void setRegistrationState( RegistrationState state ); + + /** + * Set the latest up-to-date state code + * for that account. These codes are + * those used in SIP and IAX (eg. 200, 500 ...) + * @param state The Code:Description state + * @return void + */ + void setRegistrationStateDetailed(std::pair<int, std::string> state) { _registrationStateDetailed = state; } + + /** + * Get the latest up-to-date state code + * for that account. These codes are + * those used in SIP and IAX (eg. 200, 500 ...) + * @param void + * @return std::pair<int, std::string> A Code:Description state + */ + std::pair<int, std::string> getRegistrationStateDetailed(void) { return _registrationStateDetailed; } + /* inline functions */ /* They should be treated like macro definitions by the C++ compiler */ @@ -233,9 +260,16 @@ class Account{ std::string _type; /* - * The registration state of the account + * The general, protocol neutral registration + * state of the account */ RegistrationState _registrationState; + + /* + * Details about the registration state. + * This is a protocol Code:Description pair. + */ + std::pair<int, std::string> _registrationStateDetailed; }; diff --git a/sflphone-common/src/dbus/callmanager-introspec.xml b/sflphone-common/src/dbus/callmanager-introspec.xml index 16384ae1edfcf36272f7e977d15a5a819d15214f..743dd70f3e1d5803e27b8cbb09ea5cbaec26fe1a 100644 --- a/sflphone-common/src/dbus/callmanager-introspec.xml +++ b/sflphone-common/src/dbus/callmanager-introspec.xml @@ -106,7 +106,13 @@ <arg type="s" name="state" direction="out"/> <arg type="i" name="code" direction="out"/> </signal> - + + <signal name="registrationStateChanged"> + <arg type="s" name="accountID" direction="out"/> + <arg type="s" name="state" direction="out"/> + <arg type="i" name="code" direction="out"/> + </signal> + <signal name="voiceMailNotify"> <arg type="s" name="accountID" direction="out"/> <arg type="i" name="count" direction="out"/> diff --git a/sflphone-common/src/managerimpl.cpp b/sflphone-common/src/managerimpl.cpp index 0f19bbd35d064ded0a3e9ee1485362a9017bf896..ff613b2300e9b9d32a0fa7118eb2cd8b070c10f5 100644 --- a/sflphone-common/src/managerimpl.cpp +++ b/sflphone-common/src/managerimpl.cpp @@ -1012,8 +1012,9 @@ ManagerImpl::startVoiceMessageNotification (const AccountID& accountId, int nb_m void ManagerImpl::connectionStatusNotification() { - if (_dbus) + if (_dbus != NULL) { _dbus->getConfigurationManager()->accountsChanged(); + } } /** @@ -2560,13 +2561,22 @@ std::map< std::string, std::string > ManagerImpl::getAccountDetails (const Accou a.insert(std::pair<std::string, std::string> (STUN_ENABLE, getConfigString(accountID, STUN_ENABLE))); a.insert(std::pair<std::string, std::string> (STUN_SERVER, getConfigString(accountID, STUN_SERVER))); - RegistrationState state; + RegistrationState state; + std::string registrationStateCode; + std::string registrationStateDescription; if (account != NULL) { - state = account->getRegistrationState(); + state = account->getRegistrationState(); + int code = account->getRegistrationStateDetailed().first; + std::stringstream out; + out << code; + registrationStateCode = out.str(); + registrationStateDescription = account->getRegistrationStateDetailed().second; } else { state = Unregistered; } - a.insert(std::pair<std::string, std::string> ("Status", mapStateNumberToString (state))); + a.insert(std::pair<std::string, std::string> (REGISTRATION_STATUS, mapStateNumberToString (state))); + a.insert(std::pair<std::string, std::string> (REGISTRATION_STATE_CODE, registrationStateCode)); + a.insert(std::pair<std::string, std::string> (REGISTRATION_STATE_DESCRIPTION, registrationStateDescription)); a.insert(std::pair<std::string, std::string> (SRTP_KEY_EXCHANGE, getConfigString(accountID, SRTP_KEY_EXCHANGE))); a.insert(std::pair<std::string, std::string> (SRTP_ENABLE, getConfigString(accountID, SRTP_ENABLE))); a.insert(std::pair<std::string, std::string> (ZRTP_DISPLAY_SAS, getConfigString(accountID, ZRTP_DISPLAY_SAS))); @@ -2697,6 +2707,7 @@ void ManagerImpl::setCredential (const std::string& accountID, const int32_t& in //TODO: tidy this up. Make a macro or inline // method to reduce the if/else mess. +// Even better, switch to XML ! void ManagerImpl::setAccountDetails (const std::string& accountID, const std::map< std::string, std::string >& details) { @@ -2810,7 +2821,6 @@ void ManagerImpl::setAccountDetails (const std::string& accountID, const std::ma if((iter = map_cpy.find(TLS_NEGOTIATION_TIMEOUT_SEC)) != map_cpy.end()) { tlsNegotiationTimeoutSec = iter->second; } if((iter = map_cpy.find(TLS_NEGOTIATION_TIMEOUT_MSEC)) != map_cpy.end()) { tlsNegotiationTimeoutMsec = iter->second; } - _debug("Enable account %s\n", accountEnable.c_str()); setConfig(accountID, HOSTNAME, hostname); setConfig(accountID, LOCAL_ADDRESS, localAddress); setConfig(accountID, PUBLISHED_ADDRESS, publishedAddress); diff --git a/sflphone-common/src/sip/sipvoiplink.cpp b/sflphone-common/src/sip/sipvoiplink.cpp index efa812bb3b056ac19fde5a1a738c7f45427cbe35..b21e4c58377b4e2a27952df2c609a4022fb8d05c 100644 --- a/sflphone-common/src/sip/sipvoiplink.cpp +++ b/sflphone-common/src/sip/sipvoiplink.cpp @@ -2478,7 +2478,9 @@ void regc_cb (struct pjsip_regc_cbparam *param) assert(param); const pj_str_t * description = pjsip_get_status_text(param->code); if (param->code) { - DBusManager::instance().getCallManager()->sipCallStateChanged(account->getAccountID(), std::string(description->ptr, description->slen), param->code); + DBusManager::instance().getCallManager()->registrationStateChanged(account->getAccountID(), std::string(description->ptr, description->slen), param->code); + std::pair<int, std::string> details(param->code, std::string(description->ptr, description->slen)); + account->setRegistrationStateDetailed(details); } if (param->status == PJ_SUCCESS) { @@ -2489,25 +2491,18 @@ void regc_cb (struct pjsip_regc_cbparam *param) _debug ("UserAgent: The error is: %d\n", param->code); switch (param->code) { - case 606: account->setRegistrationState (ErrorConfStun); break; - case 503: - case 408: account->setRegistrationState (ErrorHost); break; - case 401: - case 403: - case 404: account->setRegistrationState (ErrorAuth); break; - default: account->setRegistrationState (Error); break; @@ -2516,7 +2511,6 @@ void regc_cb (struct pjsip_regc_cbparam *param) account->setRegister (false); } else { // Registration/Unregistration is success - if (account->isRegister()) account->setRegistrationState (Registered); else {