From a4cf79fe9f445774b1de80ddd335823319223622 Mon Sep 17 00:00:00 2001
From: Tristan Matthews <tristan.matthews@savoirfairelinux.com>
Date: Wed, 28 Mar 2012 16:06:27 -0400
Subject: [PATCH] * #9490: update account status appropriately in
 accountlistconfigdialog

---
 gnome/src/accountlist.c                    |  2 ++
 gnome/src/accountlist.h                    |  2 ++
 gnome/src/actions.c                        |  2 ++
 gnome/src/config/accountlistconfigdialog.c | 29 ++++++++++++++++++----
 4 files changed, 30 insertions(+), 5 deletions(-)

diff --git a/gnome/src/accountlist.c b/gnome/src/accountlist.c
index 1742c6e092..4e9d545df2 100644
--- a/gnome/src/accountlist.c
+++ b/gnome/src/accountlist.c
@@ -165,6 +165,8 @@ const gchar * account_state_name(account_state_t s)
             return _("Stun configuration error");
         case ACCOUNT_STATE_ERROR_EXIST_STUN:
             return _("Stun server invalid");
+        case ACCOUNT_STATE_IP2IP_READY:
+            return _("Ready");
         default:
             return _("Invalid");
     }
diff --git a/gnome/src/accountlist.h b/gnome/src/accountlist.h
index 85903ce596..3f93f9660b 100644
--- a/gnome/src/accountlist.h
+++ b/gnome/src/accountlist.h
@@ -59,6 +59,8 @@ typedef enum {
     ACCOUNT_STATE_ERROR_EXIST_STUN,
     /** Stun server configuration error. The account is not registered */
     ACCOUNT_STATE_ERROR_CONF_STUN,
+    /** IP2IP Account is always ready */
+    ACCOUNT_STATE_IP2IP_READY,
     /** Invalid state */
     ACCOUNT_STATE_INVALID
 } account_state_t;
diff --git a/gnome/src/actions.c b/gnome/src/actions.c
index ad1ab48106..d74a398770 100644
--- a/gnome/src/actions.c
+++ b/gnome/src/actions.c
@@ -237,6 +237,8 @@ void sflphone_fill_account_list(void)
             acc->state = ACCOUNT_STATE_ERROR_CONF_STUN;
         else if (g_strcmp0(status , "ERROR_EXIST_STUN") == 0)
             acc->state = ACCOUNT_STATE_ERROR_EXIST_STUN;
+        else if (g_strcmp0(status , "ACCOUNT_STATE_IP2IP_READY") == 0)
+            acc->state = ACCOUNT_STATE_IP2IP_READY;
         else
             acc->state = ACCOUNT_STATE_INVALID;
 
diff --git a/gnome/src/config/accountlistconfigdialog.c b/gnome/src/config/accountlistconfigdialog.c
index 3f8b76f26d..7def1e1925 100644
--- a/gnome/src/config/accountlistconfigdialog.c
+++ b/gnome/src/config/accountlistconfigdialog.c
@@ -130,11 +130,12 @@ static void account_store_add(GtkTreeIter *iter, account_t *account)
     const gchar *enabled = account_lookup(account, ACCOUNT_ENABLED);
     const gchar *type = account_lookup(account, ACCOUNT_TYPE);
     DEBUG("Config: Adding account: Account is enabled :%s", enabled);
+    const gchar *state_name = account_state_name(account->state);
 
-    gtk_list_store_set(account_store, iter, COLUMN_ACCOUNT_ALIAS,
-                       account_lookup(account, ACCOUNT_ALIAS),
+    gtk_list_store_set(account_store, iter,
+                       COLUMN_ACCOUNT_ALIAS, account_lookup(account, ACCOUNT_ALIAS),
                        COLUMN_ACCOUNT_TYPE, type,
-                       COLUMN_ACCOUNT_STATUS, account_state_name(account->state),
+                       COLUMN_ACCOUNT_STATUS, state_name,
                        COLUMN_ACCOUNT_ACTIVE, utf8_case_equal(enabled, "true"),
                        COLUMN_ACCOUNT_ID, account->accountID, -1);
 }
@@ -150,6 +151,7 @@ void account_store_fill()
 
     // IP2IP account must be first
     account_t *ip2ip = account_list_get_by_id(IP2IP_PROFILE);
+    ip2ip->state = ACCOUNT_STATE_IP2IP_READY;
     RETURN_IF_NULL(ip2ip, "Could not find IP2IP account");
 
     GtkTreeIter iter;
@@ -551,10 +553,12 @@ void update_account_list_status_bar(account_t *account)
         return;
 
     /* Update status bar about current registration state */
-    gtk_statusbar_pop(GTK_STATUSBAR(account_list_status_bar), CONTEXT_ID_REGISTRATION);
+    gtk_statusbar_pop(GTK_STATUSBAR(account_list_status_bar),
+                      CONTEXT_ID_REGISTRATION);
 
     const gchar *state_name = account_state_name(account->state);
-    if (account->protocol_state_description != NULL && account->protocol_state_code != 0) {
+    if (account->protocol_state_description != NULL &&
+        account->protocol_state_code != 0) {
 
         gchar * response = g_strdup_printf(_("Server returned \"%s\" (%d)"),
                                            account->protocol_state_description,
@@ -569,6 +573,21 @@ void update_account_list_status_bar(account_t *account)
         gtk_statusbar_push(GTK_STATUSBAR(account_list_status_bar),
                            CONTEXT_ID_REGISTRATION, state_name);
     }
+    GtkTreeModel *model = GTK_TREE_MODEL(account_store);
+    GtkTreeIter iter;
+    gboolean looking = gtk_tree_model_get_iter_first(model, &iter);
+    while (looking) {
+        gchar *id;
+        gtk_tree_model_get(model, &iter, COLUMN_ACCOUNT_ID, &id, -1);
+        if (g_strcmp0(id, account->accountID) == 0) {
+            gtk_list_store_set(account_store, &iter, COLUMN_ACCOUNT_STATUS,
+                               state_name, -1);
+            looking = FALSE;
+        } else {
+            looking = gtk_tree_model_iter_next(model, &iter);
+        }
+        g_free(id);
+    }
 }
 
 void show_account_list_config_dialog(void)
-- 
GitLab