Commit 4d0e4398 authored by pierre-luc's avatar pierre-luc

[#2034] Status bar added to account window to better reflect the registration

state.
Signed-off-by: default avatarpierre-luc <pierre-luc.bacon@savoirfairelinux.com>
parent f3966c14
......@@ -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;
......
......@@ -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
......
......@@ -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 \
......
......@@ -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 */
......
......@@ -25,7 +25,7 @@
*/
#include "utils.h"
#include "configwindow.h"
#include "preferencesdialog.h"
/**
* Display the main account widget
......
......@@ -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);
......
......@@ -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;
......
......@@ -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
......@@ -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
}
......
......@@ -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
......
......@@ -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
*/
......
......@@ -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>
......
......@@ -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;
};
......
......@@ -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"/>
......
......@@ -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);
......
......@@ -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 {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment