soc.2009.telepathy: a92f1001: Accounts now properly autoconnect on sta...

sttwister at gmail.com sttwister at gmail.com
Mon Aug 10 09:00:52 EDT 2009


-----------------------------------------------------------------
Revision: a92f10018eb69f241432296b5567608b079ee660
Ancestor: f6ded69b290ec2b9f12f4b74f39ec2d370024bb3
Author: sttwister at gmail.com
Date: 2009-08-10T12:55:21
Branch: im.pidgin.soc.2009.telepathy
URL: http://d.pidgin.im/viewmtn/revision/info/a92f10018eb69f241432296b5567608b079ee660

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

ChangeLog: 

Accounts now properly autoconnect on startup

-------------- next part --------------
============================================================
--- libpurple/protocols/telepathy/telepathy.c	2a0862fd5c81fd7fc167ab27a60d3365b754db8d
+++ libpurple/protocols/telepathy/telepathy.c	4f0c44a80e2e23115d2816e131585375a325ae25
@@ -32,6 +32,7 @@
 
 #include "account.h"
 #include "accountopt.h"
+#include "core.h"
 #include "debug.h"
 #include "notify.h"
 #include "plugin.h"
@@ -1117,12 +1118,12 @@ export_prpl(TpConnectionManager *cm,
 	/* add the options */
 	add_protocol_options(plugin, protocol);
 
-	/* fix accounts using the current protocol */
-	fix_protocol_accounts(plugin);
-
 	/* this is needed because the plugins are only added to the load queue. FIXME perhaps? */
 	purple_plugins_probe("");
 
+	/* fix accounts using the current protocol */
+	fix_protocol_accounts(plugin);
+
 	return TRUE;
 }
 
============================================================
--- libpurple/protocols/telepathy/telepathy_account.c	abd924a270d877a1a06f28becf54b3d28e29c008
+++ libpurple/protocols/telepathy/telepathy_account.c	86f6c83115195170cb5d1d028f442360cc7b3984
@@ -36,7 +36,8 @@ account_properties_changed (telepathy_ac
 
 void
 account_properties_changed (telepathy_account *account_data,
-                            GHashTable *properties)
+                            GHashTable *properties,
+			    gboolean first_time)
 {
 	GHashTableIter iter;
 	gpointer key, val;
@@ -66,7 +67,14 @@ account_properties_changed (telepathy_ac
 		else if (g_strcmp0(key, "Enabled") == 0)
 		{
 			PurpleAccount *acct = account_data->account;
+			gboolean enabled = g_value_get_boolean(value);
 
+			/* We don't want to disable the account on initialisation
+			 * because the UI might want to auto-connect the account
+			 */
+			if (first_time && !enabled)
+				return;
+
 			purple_account_set_enabled(acct, purple_core_get_ui(),
 				g_value_get_boolean(value));
 		}
@@ -349,7 +357,10 @@ get_account_properties_cb (TpProxy *prox
 	/* Sync the parameters with PurpleAccount's parameters */
 	set_account_parameters(account, parameters);
 
-	account_properties_changed(account_data, out_Properties);
+	account_properties_changed(account_data, out_Properties, TRUE);
+
+	if (purple_account_get_enabled(account, purple_core_get_ui()))
+		purple_account_connect(account);
 }
 
 static void
@@ -443,7 +454,7 @@ account_get_all_cb (TpProxy *proxy,
 	tp_g_hash_table_update(account_data->properties, out_Properties,
 			(GBoxedCopyFunc)g_strdup, (GBoxedCopyFunc)tp_g_value_slice_dup);
 
-	account_properties_changed(account_data, out_Properties);
+	account_properties_changed(account_data, out_Properties, TRUE);
 
 }
 
@@ -470,7 +481,7 @@ account_property_changed_cb (TpAccount *
 	tp_g_hash_table_update(account_data->properties, arg_Properties,
 			(GBoxedCopyFunc)g_strdup, (GBoxedCopyFunc)tp_g_value_slice_dup);
 
-	account_properties_changed(account_data, arg_Properties);
+	account_properties_changed(account_data, arg_Properties, FALSE);
 }
 
 static void
============================================================
--- libpurple/protocols/telepathy/telepathy_account.h	84770e42ae150b7c6b4f3ee6905cef3968fc910b
+++ libpurple/protocols/telepathy/telepathy_account.h	842b74463d8921742f00d1f67e62ef0c7b256453
@@ -43,7 +43,8 @@ account_properties_changed (telepathy_ac
 
 void
 account_properties_changed (telepathy_account *account_data,
-                            GHashTable *properties);
+                            GHashTable *properties,
+                            gboolean first_time);
 
 void
 update_parameters_cb (TpAccount *proxy,


More information about the Commits mailing list