telepathy-mission-control: McpAccountStorage: add signal to request an account reconnection

Xavier Claessens xclaesse at kemper.freedesktop.org
Wed Sep 5 03:57:33 PDT 2012


Module: telepathy-mission-control
Branch: master
Commit: 80e392f2253fd9624b7a3862c6faeaf698905118
URL:    http://cgit.freedesktop.org/telepathy/telepathy-mission-control/commit/?id=80e392f2253fd9624b7a3862c6faeaf698905118

Author: Xavier Claessens <xavier.claessens at collabora.co.uk>
Date:   Wed Sep  5 12:07:56 2012 +0200

McpAccountStorage: add signal to request an account reconnection

---

 mission-control-plugins/account-storage.c |   28 ++++++++++++++++++++++++++++
 mission-control-plugins/account-storage.h |    2 ++
 src/mcd-account-manager.c                 |   25 +++++++++++++++++++++++++
 3 files changed, 55 insertions(+), 0 deletions(-)

diff --git a/mission-control-plugins/account-storage.c b/mission-control-plugins/account-storage.c
index 1673cf2..050914c 100644
--- a/mission-control-plugins/account-storage.c
+++ b/mission-control-plugins/account-storage.c
@@ -104,6 +104,7 @@ enum
   TOGGLED,
   DELETED,
   ALTERED_ONE,
+  RECONNECT,
   NO_SIGNAL
 };
 
@@ -197,6 +198,19 @@ class_init (gpointer klass,
       _mcp_marshal_VOID__STRING_BOOLEAN, G_TYPE_NONE,
       2, G_TYPE_STRING, G_TYPE_BOOLEAN);
 
+  /**
+   * McpAccountStorage::reconnect
+   * @account: the unique name of the account to reconnect
+   *
+   * emitted if an external entity modified important parameters of the
+   * account and a reconnection is required in order to apply them.
+   *
+   * Should not be fired until mcp_account_storage_ready() has been called
+   **/
+  signals[RECONNECT] = g_signal_new ("reconnect",
+      type, G_SIGNAL_RUN_LAST, 0, NULL, NULL,
+      g_cclosure_marshal_VOID__STRING, G_TYPE_NONE,
+      1, G_TYPE_STRING);
 }
 
 GType
@@ -865,3 +879,17 @@ mcp_account_storage_emit_toggled (McpAccountStorage *storage,
 {
   g_signal_emit (storage, signals[TOGGLED], 0, account, enabled);
 }
+
+/**
+ * mcp_account_storage_emit_reconnect:
+ * @storage: an #McpAccountStorage instance
+ * @account: the unique name of the account to reconnect
+ *
+ * Emits ::reconnect signal
+ */
+void
+mcp_account_storage_emit_reconnect (McpAccountStorage *storage,
+    const gchar *account)
+{
+  g_signal_emit (storage, signals[RECONNECT], 0, account);
+}
diff --git a/mission-control-plugins/account-storage.h b/mission-control-plugins/account-storage.h
index 68469c6..ee1c65a 100644
--- a/mission-control-plugins/account-storage.h
+++ b/mission-control-plugins/account-storage.h
@@ -232,6 +232,8 @@ void mcp_account_storage_emit_deleted (McpAccountStorage *storage,
 void mcp_account_storage_emit_toggled (McpAccountStorage *storage,
     const gchar *account,
     gboolean enabled);
+void mcp_account_storage_emit_reconnect (McpAccountStorage *storage,
+    const gchar *account);
 
 G_END_DECLS
 
diff --git a/src/mcd-account-manager.c b/src/mcd-account-manager.c
index 17f2e3f..b023b42 100644
--- a/src/mcd-account-manager.c
+++ b/src/mcd-account-manager.c
@@ -411,6 +411,30 @@ toggled_cb (GObject *plugin, const gchar *name, gboolean on, gpointer data)
 }
 
 static void
+reconnect_cb (GObject *plugin, const gchar *name, gpointer data)
+{
+  McpAccountStorage *storage_plugin = MCP_ACCOUNT_STORAGE (plugin);
+  McdAccountManager *manager = MCD_ACCOUNT_MANAGER (data);
+  McdAccount *account = NULL;
+
+  account = mcd_account_manager_lookup_account (manager, name);
+
+  DEBUG ("%s plugin request %s reconnection",
+      mcp_account_storage_name (storage_plugin), name);
+
+  if (account == NULL)
+    {
+      g_warning ("%s: Unknown account %s from %s plugin",
+          G_STRFUNC, name, mcp_account_storage_name (storage_plugin));
+      return;
+    }
+
+  /* Storage ask to reconnect when important parameters changed, which is an
+   * user action. */
+  _mcd_account_reconnect (account, TRUE);
+}
+
+static void
 _mcd_account_delete_cb (McdAccount *account, const GError *error, gpointer data)
 {
     /* no need to do anything other than release the account ref, which *
@@ -1593,6 +1617,7 @@ mcd_account_manager_init (McdAccountManager *account_manager)
         { "toggled", G_CALLBACK (toggled_cb) },
         { "deleted", G_CALLBACK (deleted_cb) },
         { "altered-one", G_CALLBACK (altered_one_cb) },
+        { "reconnect", G_CALLBACK (reconnect_cb) },
         { NULL, NULL } };
 
     DEBUG ("");



More information about the telepathy-commits mailing list