aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordequis <dx@dxzone.com.ar>2016-10-30 21:38:32 -0300
committerdequis <dx@dxzone.com.ar>2016-10-30 21:38:32 -0300
commit50988d1f5048cc1ca1f8b3af77eb3ad6f909c1c0 (patch)
tree2acac59db8355ea7e80f740eb3a3a0404a99d76c
parentc94e20896107533058d7eae53d5244b10edc97f6 (diff)
purple: fix icq login when the protocol name is "oscar"
Which happens when moving from non-purple to purple. Fixes trac ticket 1269 Since "oscar" doesn't exist in purple, the old code called register_protocol() to associate oscar with prpl-aim, which meant that aim accounts migrated seamlessly to purple but icq accounts broke silently, throwing incorrect password errors. Now the oscar protocol is special-cased to return prpl-aim or prpl-icq depending on the first character of the username, which is the same thing the built-in oscar protocol does.
-rw-r--r--protocols/purple/purple.c21
1 files changed, 17 insertions, 4 deletions
diff --git a/protocols/purple/purple.c b/protocols/purple/purple.c
index 71b495db..c40efa0b 100644
--- a/protocols/purple/purple.c
+++ b/protocols/purple/purple.c
@@ -100,9 +100,21 @@ static gboolean purple_menu_cmp(const char *a, const char *b)
return (*a == '\0' && *b == '\0');
}
+static char *purple_get_account_prpl_id(account_t *acc)
+{
+ /* "oscar" is how non-purple bitlbee calls it,
+ * and it might be icq or aim, depending on the username */
+ if (g_strcmp0(acc->prpl->name, "oscar") == 0) {
+ return (g_ascii_isdigit(acc->user[0])) ? "prpl-icq" : "prpl-aim";
+ }
+
+ return acc->prpl->data;
+}
+
static void purple_init(account_t *acc)
{
- PurplePlugin *prpl = purple_plugins_find_with_id((char *) acc->prpl->data);
+ char *prpl_id = purple_get_account_prpl_id(acc);
+ PurplePlugin *prpl = purple_plugins_find_with_id(prpl_id);
PurplePluginProtocolInfo *pi = prpl->info->extra_info;
PurpleAccount *pa;
GList *i, *st;
@@ -268,7 +280,7 @@ static void purple_init(account_t *acc)
/* Go through all away states to figure out if away/status messages
are possible. */
- pa = purple_account_new(acc->user, (char *) acc->prpl->data);
+ pa = purple_account_new(acc->user, prpl_id);
for (st = purple_account_get_status_types(pa); st; st = st->next) {
PurpleStatusPrimitive prim = purple_status_type_get_primitive(st->data);
@@ -346,7 +358,7 @@ static void purple_login(account_t *acc)
purple_connections = g_slist_prepend(purple_connections, ic);
ic->proto_data = pd = g_new0(struct purple_data, 1);
- pd->account = purple_account_new(acc->user, (char *) acc->prpl->data);
+ pd->account = purple_account_new(acc->user, purple_get_account_prpl_id(acc));
pd->input_requests = g_hash_table_new_full(g_direct_hash, g_direct_equal,
NULL, g_free);
pd->next_request_id = 0;
@@ -1708,7 +1720,8 @@ void purple_initmodule()
if (g_strcasecmp(prot->info->id, "prpl-aim") == 0) {
ret = g_memdup(&funcs, sizeof(funcs));
ret->name = "oscar";
- ret->data = prot->info->id;
+ /* purple_get_account_prpl_id() determines the actual protocol ID (icq/aim) */
+ ret->data = NULL;
register_protocol(ret);
}
}