soc.2009.telepathy: c1a03e89: Remove accounts from AccountManager when...

sttwister at soc.pidgin.im sttwister at soc.pidgin.im
Tue Jul 21 08:05:50 EDT 2009


-----------------------------------------------------------------
Revision: c1a03e89b2c35581c1566747a9615d811fb786fe
Ancestor: d40017533a56d5a18ef506bd35894236350f1088
Author: sttwister at soc.pidgin.im
Date: 2009-07-21T12:00:58
Branch: im.pidgin.soc.2009.telepathy
URL: http://d.pidgin.im/viewmtn/revision/info/c1a03e89b2c35581c1566747a9615d811fb786fe

Modified files:
        libpurple/protocols/telepathy/telepathy_account.c

ChangeLog: 

Remove accounts from AccountManager when they are removed from purple

-------------- next part --------------
============================================================
--- libpurple/protocols/telepathy/telepathy_account.c	7ca3726df7ee1a1ebdc330c03a9f8e905710d844
+++ libpurple/protocols/telepathy/telepathy_account.c	545bc3fd0207fbd4e0e8d7d61e7fc1cf1f54a520
@@ -313,6 +313,8 @@ account_modified_cb (PurpleAccount *acco
 		return;
 	}
 
+	purple_debug_info("telepathy", "Account modified!\n");
+
 	/* We need to find the plugin of this account in order to have access to the
 	 * Connection Manager proxy and the protocol parameters.
 	 */
@@ -454,6 +456,42 @@ account_added_cb (PurpleAccount *account
 
 }
 
+static void
+remove_account_cb (TpAccount *proxy,
+                   const GError *error,
+                   gpointer user_data,
+                   GObject *weak_object)
+{
+	if (error != NULL)
+	{
+		purple_debug_error("telepathy", "Remove error: %s\n", error->message);
+		return;
+	}
+
+	purple_debug_info("telepathy", "Remove succeeded!\n");
+}
+
+static void
+account_removed_cb (PurpleAccount *account,
+                    gpointer user_data)
+{
+	telepathy_account *account_data;
+
+	purple_debug_info("telepathy", "Account removed!\n");
+
+	account_data = (telepathy_account*)purple_account_get_int(
+			account, "tp_account_data", 0);
+
+	if (account_data != NULL)
+	{
+		purple_account_set_int(account, "tp_account_data", 0);
+
+		tp_cli_account_call_remove(account_data->tp_account, -1,
+				remove_account_cb, account_data,
+				NULL, NULL);
+	}
+}
+
 void
 get_valid_accounts_cb (TpProxy *proxy,
                        const GValue *out_Value,
@@ -537,6 +575,12 @@ get_valid_accounts_cb (TpProxy *proxy,
 		purple_accounts_get_handle(),
 		PURPLE_CALLBACK(account_added_cb),
 		NULL);
+
+	purple_signal_connect(purple_accounts_get_handle(), "account-removed",
+		purple_accounts_get_handle(),
+		PURPLE_CALLBACK(account_removed_cb),
+		NULL);
+
 	if (daemon)
 		g_object_unref(daemon);
 


More information about the Commits mailing list