soc.2009.telepathy: 1024b208: Accounts need to be added to purple afte...

sttwister at soc.pidgin.im sttwister at soc.pidgin.im
Tue Jul 21 08:55:39 EDT 2009


-----------------------------------------------------------------
Revision: 1024b208718a6cdef8baf6e8bee2607e7bca3d11
Ancestor: c1a03e89b2c35581c1566747a9615d811fb786fe
Author: sttwister at soc.pidgin.im
Date: 2009-07-21T12:52:11
Branch: im.pidgin.soc.2009.telepathy
URL: http://d.pidgin.im/viewmtn/revision/info/1024b208718a6cdef8baf6e8bee2607e7bca3d11

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

ChangeLog: 


Accounts need to be added to purple after being pulled from AccountManager,
not only created. Also, it's better to query AccountManager for new
accounts only after all the prpls have been exported.

-------------- next part --------------
============================================================
--- libpurple/protocols/telepathy/telepathy.c	cbd3bd7af7c7bb42d7826035de5f6f7f1ddd4a94
+++ libpurple/protocols/telepathy/telepathy.c	6b592bf2092386aa160d927999559a0a77320ecd
@@ -1171,6 +1171,15 @@ list_connection_managers_cb (TpConnectio
 			}
 		}
 	}
+
+	/* Get all valid accounts from AccountManager. We should only do this after all
+	 * prpls have been exported, in case there's a new account discovered that needs
+	 * the prpl to be loaded.
+	 */
+	tp_cli_dbus_properties_call_get(account_Manager, -1,
+			TP_IFACE_ACCOUNT_MANAGER, "ValidAccounts",
+			get_valid_accounts_cb, NULL, NULL, NULL);
+
 }
 
 /* TODO: Check for staticly linked module */
@@ -1201,9 +1210,6 @@ G_MODULE_EXPORT gboolean purple_init_plu
 		return FALSE;
 	}
 
-	/* the list of connection managers will be returned in list_connection_managers_cb */
-	tp_list_connection_managers(daemon, list_connection_managers_cb, NULL, NULL, NULL);
-	
 	/* Create an AccountManager interface */
 	account_Manager = tp_account_manager_new(daemon);
 
@@ -1213,11 +1219,9 @@ G_MODULE_EXPORT gboolean purple_init_plu
 		return FALSE;
 	}
 
-	/* Get all valid accounts from AccountManager */
-	tp_cli_dbus_properties_call_get(account_Manager, -1,
-			TP_IFACE_ACCOUNT_MANAGER, "ValidAccounts",
-			get_valid_accounts_cb, NULL, NULL, NULL);
-
+	/* the list of connection managers will be returned in list_connection_managers_cb */
+	tp_list_connection_managers(daemon, list_connection_managers_cb, NULL, NULL, NULL);
+	
 	if (daemon != NULL)
 		g_object_unref(daemon);
 
============================================================
--- libpurple/protocols/telepathy/telepathy_account.c	545bc3fd0207fbd4e0e8d7d61e7fc1cf1f54a520
+++ libpurple/protocols/telepathy/telepathy_account.c	eb83487f3751e5f841a6866332b58bc1006b7bec
@@ -167,6 +167,9 @@ set_account_parameters (PurpleAccount *a
 	GHashTableIter iter;
 	gpointer key, value;
 
+	purple_debug_info("telepathy", "Setting parameters for %s\n",
+			purple_account_get_username(account));
+
 	/* Loop over all parameters */
 	g_hash_table_iter_init (&iter, parameters);
 	while (g_hash_table_iter_next (&iter, &key, &value)) 
@@ -266,22 +269,25 @@ get_account_properties_cb (TpProxy *prox
 	 */
 	account = purple_accounts_find(display_name, protocol_id);
 
-	g_free(protocol_id);
-
 	if (account == NULL)
 	{
-		purple_debug_info("telepathy", "Account %s does not exist in purple-land,"
-				" creating it!\n", display_name);
+		purple_debug_info("telepathy", "Account %s (%s) does not exist in purple-land,"
+				" creating it!\n", display_name, protocol_id);
 
+		if (purple_find_prpl(protocol_id) == NULL)
+		{
+			purple_debug_warning("telepathy", "Prpl %s is not loaded for %s!\n",
+					protocol_id, display_name);
+		}
+
 		account = purple_account_new(display_name, protocol_id);
 
 		if (account == NULL)
 		{
 			purple_debug_error("telepathy", "Error creating PurpleAccount!\n");
+			g_free(protocol_id);
 			return;
 		}
-
-		purple_account_register(account);
 	}
 	else
 	{
@@ -289,10 +295,14 @@ get_account_properties_cb (TpProxy *prox
 				display_name);
 	}
 
+	g_free(protocol_id);
+
 	account_data->account = account;
 
 	purple_account_set_int(account, "tp_account_data", (int)account_data);
 
+	purple_accounts_add(account);
+
 	/* Sync the parameters with PurpleAccount's parameters */
 	set_account_parameters(account, parameters);
 }
@@ -420,6 +430,14 @@ account_added_cb (PurpleAccount *account
 
 	g_free(protocol_id);
 
+	if (purple_account_get_int(account, "tp_account_data", 0) != 0)
+	{
+		/* This account was automaticaly pulled from AccountManager by the prpl,
+		 * we should leave it alone.
+		 */
+		return;
+	}
+
 	purple_debug_info("telepathy", "Telepathy account created!\n");
 
 	plugin = purple_find_prpl(


More information about the Commits mailing list