]> git.0d.be Git - empathy.git/commitdiff
handle presence changes
authorFelix Kaser <f.kaser@gmx.net>
Tue, 8 Dec 2009 17:50:55 +0000 (18:50 +0100)
committerFelix Kaser <f.kaser@gmx.net>
Tue, 15 Dec 2009 12:52:45 +0000 (13:52 +0100)
some refactoring was neccesary to handl correctly the presence changes. all information about the connection status and reason and presence are gathered explicitly in update_status_infobar and not passed by the callbacks.

src/empathy-accounts-dialog.c

index ad5156ba946f5588ac2ad2c3e58c12f461d4754e..b0bc79d6a8dfdcab8720bb13437016b3d40fcf28 100644 (file)
@@ -174,12 +174,15 @@ accounts_dialog_update_name_label (EmpathyAccountsDialog *dialog,
 
 static void
 accounts_dialog_update_status_infobar (EmpathyAccountsDialog *dialog,
-    TpAccount *account, guint status, guint reason)
+    TpAccount *account)
 {
   EmpathyAccountsDialogPriv *priv = GET_PRIV (dialog);
   const gchar               *message;
+  guint                     status;
+  guint                     reason;
   guint                     presence;
 
+  status = tp_account_get_connection_status (account, &reason);
   presence = tp_account_get_current_presence (account, NULL, NULL);
 
   gtk_image_set_from_icon_name (GTK_IMAGE (priv->image_status),
@@ -357,8 +360,6 @@ account_dialog_create_settings_widget (EmpathyAccountsDialog *dialog,
 {
   EmpathyAccountsDialogPriv *priv = GET_PRIV (dialog);
   gchar                     *icon_name;
-  guint                     status;
-  guint                     reason;
   TpAccount                 *account;
 
   priv->setting_widget_object =
@@ -398,9 +399,7 @@ account_dialog_create_settings_widget (EmpathyAccountsDialog *dialog,
       empathy_account_settings_get_display_name (settings));
 
   account = empathy_account_settings_get_account (settings);
-
-  status = tp_account_get_connection_status (account, &reason);
-  accounts_dialog_update_status_infobar (dialog, account, status, reason);
+  accounts_dialog_update_status_infobar (dialog, account);
 }
 
 static void
@@ -1258,7 +1257,7 @@ accounts_dialog_connection_changed_cb (TpAccount *account,
   EmpathyAccountsDialogPriv *priv = GET_PRIV (dialog);
 
   /* Update the status-infobar in the details view*/
-  accounts_dialog_update_status_infobar (dialog, account, current, reason);
+  accounts_dialog_update_status_infobar (dialog, account);
 
   /* Update the status in the model */
   model = gtk_tree_view_get_model (GTK_TREE_VIEW (priv->treeview));
@@ -1290,6 +1289,17 @@ accounts_dialog_connection_changed_cb (TpAccount *account,
         dialog);
 }
 
+static void
+accounts_dialog_presence_changed_cb (TpAccount *account,
+    guint presence,
+    gchar *status,
+    gchar *status_message,
+    EmpathyAccountsDialog *dialog)
+{
+  /* Update the status-infobar in the details view*/
+  accounts_dialog_update_status_infobar (dialog, account);
+}
+
 static void
 accounts_dialog_account_display_name_changed_cb (TpAccount *account,
   GParamSpec *pspec,
@@ -1424,9 +1434,7 @@ enable_or_disable_account (EmpathyAccountsDialog *dialog,
 
   /* Update the status-infobar in the details view when disabling*/
   if (!enabled)
-    accounts_dialog_update_status_infobar (dialog, account,
-        TP_CONNECTION_STATUS_DISCONNECTED,
-        TP_CONNECTION_STATUS_REASON_NONE_SPECIFIED);
+    accounts_dialog_update_status_infobar (dialog, account);
 
   DEBUG ("Account %s is now %s",
       tp_account_get_display_name (account),
@@ -1653,6 +1661,8 @@ accounts_dialog_accounts_setup (EmpathyAccountsDialog *dialog)
 
       empathy_signal_connect_weak (l->data, "status-changed",
           G_CALLBACK (accounts_dialog_connection_changed_cb), G_OBJECT (dialog));
+      empathy_signal_connect_weak (l->data, "presence-changed",
+          G_CALLBACK (accounts_dialog_presence_changed_cb), G_OBJECT (dialog));
     }
   g_list_free (accounts);