soc.2009.telepathy: cb4f2739: Fix accounts using prpl-telepathy by man...
sttwister at soc.pidgin.im
sttwister at soc.pidgin.im
Thu May 14 14:05:54 EDT 2009
-----------------------------------------------------------------
Revision: cb4f2739dd473754e17bc019b74dc471e8d52b17
Ancestor: 0f054951a4b82cd0c0b54e626f64cda05323d251
Author: sttwister at soc.pidgin.im
Date: 2009-05-14T18:02:39
Branch: im.pidgin.soc.2009.telepathy
URL: http://d.pidgin.im/viewmtn/revision/info/cb4f2739dd473754e17bc019b74dc471e8d52b17
Modified files:
libpurple/protocols/telepathy/telepathy.c
ChangeLog:
Fix accounts using prpl-telepathy by manually calling status_types for them.
-------------- next part --------------
============================================================
--- libpurple/protocols/telepathy/telepathy.c 53d3cd99c70661c8cab048732b7372125e3e0c67
+++ libpurple/protocols/telepathy/telepathy.c 1518e016a3a05d6da35f31feb9693357bccdbf3d
@@ -27,6 +27,7 @@
#include "internal.h"
+#include "account.h"
#include "accountopt.h"
#include "debug.h"
#include "notify.h"
@@ -350,7 +351,6 @@ telepathy_login(PurpleAccount *acct)
data->gc = gc;
purple_debug_info("telepathy", "Logging in as %s\n", acct->username);
- purple_debug_info("telepathy", "Logging in as %s\n", acct->password);
/* some protocols might not require username or password, so check them before */
if (acct->username != NULL)
@@ -686,6 +686,55 @@ add_protocol_options(PurplePlugin *plugi
}
}
+static void
+fix_protocol_accounts(PurplePlugin* plugin)
+{
+ PurpleAccount *account;
+ GList *iter;
+
+ for (iter = purple_accounts_get_all(); iter != NULL; iter = iter->next)
+ {
+ account = iter->data;
+
+ /* check if the protocol matches the account */
+ if (g_strcmp0(purple_account_get_protocol_id(account), plugin->info->id) == 0)
+ {
+ PurplePluginProtocolInfo* prpl_info;
+ PurpleStatusType *status_type;
+
+ purple_debug_info("telepathy", "Fixing account %s using %s\n",
+ purple_account_get_username(account), purple_account_get_protocol_id(account));
+
+
+ /* prpl-telepathy accounts are loaded before the prpl itself and thus some information
+ * (like status types) are invalid. We need to fix those in order to make that account work.
+ *
+ * Following code is copied from purple_account_new() in account.c
+ *
+ * FIXME: this is kinda hackish
+ */
+
+ prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(plugin);
+ if (prpl_info != NULL && prpl_info->status_types != NULL)
+ purple_account_set_status_types(account, prpl_info->status_types(account));
+
+ account->presence = purple_presence_new_for_account(account);
+
+ status_type = purple_account_get_status_type_with_primitive(account, PURPLE_STATUS_AVAILABLE);
+ if (status_type != NULL)
+ purple_presence_set_status_active(account->presence,
+ purple_status_type_get_id(status_type),
+ TRUE);
+ else
+ purple_presence_set_status_active(account->presence,
+ "offline",
+ TRUE);
+ }
+ }
+
+
+}
+
static gboolean
export_prpl(TpConnectionManager *cm,
TpConnectionManagerProtocol *protocol)
@@ -723,6 +772,9 @@ 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("");
More information about the Commits
mailing list