From 5c7d6473fd1f789c00140ae186865b003d52b1e8 Mon Sep 17 00:00:00 2001
From: Alexandre Savard <alexandre.savard@savoirfairelinux.net>
Date: Fri, 29 May 2009 11:26:14 -0400
Subject: [PATCH] [#1430] Bring account changed signal/callback back to normal

---
 sflphone-client-gnome/src/actions.c           | 78 -------------------
 .../src/config/configwindow.c                 |  4 +-
 sflphone-client-gnome/src/dbus/dbus.c         | 22 +-----
 sflphone-common/src/account.cpp               |  6 +-
 .../dbus/configurationmanager-introspec.xml   |  1 -
 sflphone-common/src/managerimpl.cpp           | 10 +--
 sflphone-common/src/managerimpl.h             |  2 +-
 7 files changed, 14 insertions(+), 109 deletions(-)

diff --git a/sflphone-client-gnome/src/actions.c b/sflphone-client-gnome/src/actions.c
index 29a7583019..120024a7c3 100644
--- a/sflphone-client-gnome/src/actions.c
+++ b/sflphone-client-gnome/src/actions.c
@@ -222,84 +222,6 @@ sflphone_fill_account_list(gboolean toolbarInitialized)
         toolbar_update_buttons();
 }
 
-void
-sflphone_update_account_info( gchar* accountID, gboolean toolbarInitialized)
-{
-   
-        account_t  * a;
-	account_t  * previous;
-	GHashTable * details;
-	gchar *status;
-	guint pos;
-
-	DEBUG("sflphone_update_account_info for id %s\n", accountID);
-
-	// get the accout by id to retreive its position
-        previous = account_list_get_by_id(accountID);
-
-	// store the position of the account
-	pos = account_list_get_position (previous); 
-
-	// Remove the account from the list
-	account_list_remove (accountID);
-
-	a = g_new0 (account_t, 1);
-	a->accountID = g_strdup(accountID);
-        details = (GHashTable *) dbus_account_details(a->accountID);
-        // if( details == NULL )
-	// break;
-        a->properties = details;
-
-        status = g_hash_table_lookup(details, "Status");
-        if(strcmp(status, "REGISTERED") == 0)
-        {
-            a->state = ACCOUNT_STATE_REGISTERED;
-        }
-        else if(strcmp(status, "UNREGISTERED") == 0)
-        {
-            a->state = ACCOUNT_STATE_UNREGISTERED;
-        }
-        else if(strcmp(status, "TRYING") == 0)
-        {
-            a->state = ACCOUNT_STATE_TRYING;
-        }
-        else if(strcmp(status, "ERROR") == 0)
-        {
-            a->state = ACCOUNT_STATE_ERROR;
-        }
-        else if(strcmp( status , "ERROR_AUTH") == 0 )
-        {
-            a->state = ACCOUNT_STATE_ERROR_AUTH;
-        }
-        else if(strcmp( status , "ERROR_NETWORK") == 0 )
-        {
-            a->state = ACCOUNT_STATE_ERROR_NETWORK;
-        }
-        else if(strcmp( status , "ERROR_HOST") == 0 )
-        {
-            a->state = ACCOUNT_STATE_ERROR_HOST;
-        }
-        else if(strcmp( status , "ERROR_CONF_STUN") == 0 )
-        {
-            a->state = ACCOUNT_STATE_ERROR_CONF_STUN;
-        }
-        else if(strcmp( status , "ERROR_EXIST_STUN") == 0 )
-        {
-            a->state = ACCOUNT_STATE_ERROR_EXIST_STUN;
-        }
-        else
-        {
-            a->state = ACCOUNT_STATE_INVALID;
-        }
-
-    	// Add it again with the refreshed information
-	account_list_add_at_nth(a,pos);
-
-    // Prevent update being called when toolbar is not yet initialized
-    if(toolbarInitialized)
-        toolbar_update_buttons();
-}
-
 gboolean sflphone_init()
 {
     if(!dbus_connect ()){
diff --git a/sflphone-client-gnome/src/config/configwindow.c b/sflphone-client-gnome/src/config/configwindow.c
index c00198aafa..983cb2e207 100644
--- a/sflphone-client-gnome/src/config/configwindow.c
+++ b/sflphone-client-gnome/src/config/configwindow.c
@@ -85,7 +85,7 @@ GtkWidget * widg;
     void
 config_window_fill_account_list()
 {
-    DEBUG("config_window_fill_account_list\n");
+    
     if(accDialogOpen)
     {
         GtkTreeIter iter;
@@ -95,7 +95,7 @@ config_window_fill_account_list()
         for(i = 0; i < account_list_get_size(); i++)
         {
             account_t * a = account_list_get_nth (i);
-	    // DEBUG("config_window_fill_account_list id %s\n",a->accountID);
+	    
             if (a)
             {
 
diff --git a/sflphone-client-gnome/src/dbus/dbus.c b/sflphone-client-gnome/src/dbus/dbus.c
index 5546378e80..a5eeb37807 100644
--- a/sflphone-client-gnome/src/dbus/dbus.c
+++ b/sflphone-client-gnome/src/dbus/dbus.c
@@ -175,27 +175,13 @@ call_state_cb (DBusGProxy *proxy UNUSED,
   }
 }
 
-/*
-static void
-accounts_changed_cb (DBusGProxy *proxy UNUSED,
-		     const gchar* accountID,
-                     void * foo  UNUSED )
-{
-  DEBUG ("Accounts changed");
-  // sflphone_fill_account_list(TRUE);
-  sflphone_update_account_info(accountID, TRUE);
-  config_window_fill_account_list();
-}
-*/
 
 static void
-accounts_changed_cb(DBusGProxy *proxy UNUSED,
-		     const gchar* accountID,
+accounts_changed_cb (DBusGProxy *proxy UNUSED,
                      void * foo  UNUSED )
 {
   DEBUG ("Accounts changed");
-  // sflphone_fill_account_list(TRUE);
-  sflphone_update_account_info(accountID, TRUE);
+  sflphone_fill_account_list(TRUE);
   config_window_fill_account_list();
 }
 
@@ -335,10 +321,8 @@ dbus_connect ()
     return FALSE;
   }
   DEBUG ("DBus connected to ConfigurationManager");
-  dbus_g_object_register_marshaller(g_cclosure_user_marshal_VOID__STRING,
-    G_TYPE_NONE, G_TYPE_STRING, G_TYPE_INVALID);
   dbus_g_proxy_add_signal (configurationManagerProxy,
-			   "accountsChanged", G_TYPE_STRING, G_TYPE_INVALID);
+			   "accountsChanged", G_TYPE_INVALID);
   dbus_g_proxy_connect_signal (configurationManagerProxy,
     "accountsChanged", G_CALLBACK(accounts_changed_cb), NULL, NULL);
 
diff --git a/sflphone-common/src/account.cpp b/sflphone-common/src/account.cpp
index 85eea08605..34b96eed45 100644
--- a/sflphone-common/src/account.cpp
+++ b/sflphone-common/src/account.cpp
@@ -49,11 +49,11 @@ void Account::loadConfig()
 
 void Account::setRegistrationState( RegistrationState state ) { 
     
-  if (state != _registrationState) {
+    if (state != _registrationState) {
 	_debug("Account::setRegistrationState\n");
         _registrationState = state; 
 
 	// Notify the client
-	Manager::instance().connectionStatusNotification( _accountID );
-	}
+	Manager::instance().connectionStatusNotification();
+    }
 }
diff --git a/sflphone-common/src/dbus/configurationmanager-introspec.xml b/sflphone-common/src/dbus/configurationmanager-introspec.xml
index 429c358f7e..6709c772d1 100644
--- a/sflphone-common/src/dbus/configurationmanager-introspec.xml
+++ b/sflphone-common/src/dbus/configurationmanager-introspec.xml
@@ -313,7 +313,6 @@
 -->    
 
     <signal name="accountsChanged">
-      <arg type="s" name="accountID" direction="out" />
     </signal>  
 
     <signal name="errorAlert">
diff --git a/sflphone-common/src/managerimpl.cpp b/sflphone-common/src/managerimpl.cpp
index ea153e1311..0af3b49523 100644
--- a/sflphone-common/src/managerimpl.cpp
+++ b/sflphone-common/src/managerimpl.cpp
@@ -884,10 +884,10 @@ ManagerImpl::startVoiceMessageNotification(const AccountID& accountId, int nb_ms
   if (_dbus) _dbus->getCallManager()->voiceMailNotify(accountId, nb_msg) ;
 }
 
-void ManagerImpl::connectionStatusNotification( const AccountID& accountID )
+void ManagerImpl::connectionStatusNotification()
 {
     if (_dbus)
-        _dbus->getConfigurationManager()->accountsChanged(accountID);
+        _dbus->getConfigurationManager()->accountsChanged();
 }
 
 /**
@@ -2288,7 +2288,7 @@ void ManagerImpl::setAccountDetails( const std::string& accountID, const std::ma
         acc->unregisterVoIPLink();
 
     // Update account details to the client side
-    if (_dbus) _dbus->getConfigurationManager()->accountsChanged(accountID);
+    if (_dbus) _dbus->getConfigurationManager()->accountsChanged();
 
 }
 
@@ -2361,7 +2361,7 @@ ManagerImpl::addAccount(const std::map< std::string, std::string >& details)
 
     saveConfig();
 
-    if (_dbus) _dbus->getConfigurationManager()->accountsChanged(newAccountID);
+    if (_dbus) _dbus->getConfigurationManager()->accountsChanged();
     return newAccountID;
 }
 
@@ -2382,7 +2382,7 @@ ManagerImpl::removeAccount(const AccountID& accountID)
   saveConfig();
 
   _debug("REMOVE ACCOUNT\n");
-  if (_dbus) _dbus->getConfigurationManager()->accountsChanged(accountID);
+  if (_dbus) _dbus->getConfigurationManager()->accountsChanged();
 }
 
 // ACCOUNT handling
diff --git a/sflphone-common/src/managerimpl.h b/sflphone-common/src/managerimpl.h
index ad5d1a881c..10caf62b48 100644
--- a/sflphone-common/src/managerimpl.h
+++ b/sflphone-common/src/managerimpl.h
@@ -263,7 +263,7 @@ class ManagerImpl {
     /**
      * Notify the client through DBus that registration state has been updated
      */
-    void connectionStatusNotification(const AccountID& accountID);
+    void connectionStatusNotification(void);
 
     /**
      * ConfigurationManager - Send registration request
-- 
GitLab