From 87872c712535013cbba81653021a41091a9ed7f2 Mon Sep 17 00:00:00 2001 From: dequis Date: Mon, 28 Nov 2016 02:52:22 -0300 Subject: purple: Use roomlist_room_serialize, fixes joining jabber chats The room names in 'chat list' were missing the server part. Jabber is the only prpl which implements this method as far as I can see, and it's needed to get the full name. --- protocols/purple/purple.c | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) (limited to 'protocols/purple') diff --git a/protocols/purple/purple.c b/protocols/purple/purple.c index c7123798..8b3b8c7c 100644 --- a/protocols/purple/purple.c +++ b/protocols/purple/purple.c @@ -1386,16 +1386,30 @@ static void prplcb_roomlist_set_fields(PurpleRoomlist *list, GList *fields) } } +static char *prplcb_roomlist_get_room_name(PurpleRoomlist *list, PurpleRoomlistRoom *room) +{ + struct im_connection *ic = purple_ic_by_pa(list->account); + struct purple_data *pd = ic->proto_data; + PurplePlugin *prpl = purple_plugins_find_with_id(pd->account->protocol_id); + PurplePluginProtocolInfo *pi = prpl->info->extra_info; + + if (pi && pi->roomlist_room_serialize) { + return pi->roomlist_room_serialize(room); + } else { + return g_strdup(purple_roomlist_room_get_name(room)); + } +} + static void prplcb_roomlist_add_room(PurpleRoomlist *list, PurpleRoomlistRoom *room) { bee_chat_info_t *ci; - const char *title; + char *title; const char *topic; GList *fields; struct purple_roomlist_data *rld = list->ui_data; fields = purple_roomlist_room_get_fields(room); - title = purple_roomlist_room_get_name(room); + title = prplcb_roomlist_get_room_name(list, room); if (rld->topic >= 0) { topic = g_list_nth_data(fields, rld->topic); @@ -1404,7 +1418,7 @@ static void prplcb_roomlist_add_room(PurpleRoomlist *list, PurpleRoomlistRoom *r } ci = g_new(bee_chat_info_t, 1); - ci->title = g_strdup(title); + ci->title = title; ci->topic = g_strdup(topic); rld->chats = g_slist_prepend(rld->chats, ci); } -- cgit v1.2.3 From 6d212f401cf7eeb3eabe315e610578f5aac74607 Mon Sep 17 00:00:00 2001 From: dequis Date: Sun, 25 Dec 2016 20:41:13 -0300 Subject: purple: include purple plugins in the 'plugins' command list --- protocols/purple/purple.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'protocols/purple') diff --git a/protocols/purple/purple.c b/protocols/purple/purple.c index 8b3b8c7c..49c1ee7c 100644 --- a/protocols/purple/purple.c +++ b/protocols/purple/purple.c @@ -1640,6 +1640,10 @@ static void purple_ui_init() } } +/* borrowing this semi-private function + * TODO: figure out a better interface later (famous last words) */ +gboolean plugin_info_add(struct plugin_info *info); + void purple_initmodule() { struct prpl funcs; @@ -1740,6 +1744,7 @@ void purple_initmodule() PurplePlugin *prot = prots->data; PurplePluginProtocolInfo *pi = prot->info->extra_info; struct prpl *ret; + struct plugin_info *info; /* If we already have this one (as a native module), don't add a libpurple duplicate. */ @@ -1774,6 +1779,16 @@ void purple_initmodule() ret->data = NULL; register_protocol(ret); } + + info = g_new0(struct plugin_info, 1); + info->abiver = BITLBEE_ABI_VERSION_CODE; + info->name = ret->name; + info->version = prot->info->version; + info->description = prot->info->description; + info->author = prot->info->author; + info->url = prot->info->homepage; + + plugin_info_add(info); } g_string_append(help, "\n\nFor used protocols, more information about available " -- cgit v1.2.3 From 59ccef5cc9f1ed67112248c20649ce8005188173 Mon Sep 17 00:00:00 2001 From: dequis Date: Sun, 25 Dec 2016 21:13:57 -0300 Subject: purple: Call imcb_buddy_nick_change() on a few whitelisted plugins The whitelist includes hangouts, funyahoo and icq. These plugins tend to have numeric or meaningless usernames. With this change, users don't have to do 'ac whatever set nick_format %full_name' anymore. Just sugar. --- protocols/purple/bpurple.h | 4 ++++ protocols/purple/purple.c | 40 ++++++++++++++++++++++++++++++++++++---- 2 files changed, 40 insertions(+), 4 deletions(-) (limited to 'protocols/purple') diff --git a/protocols/purple/bpurple.h b/protocols/purple/bpurple.h index 81be2575..9b34cdff 100644 --- a/protocols/purple/bpurple.h +++ b/protocols/purple/bpurple.h @@ -6,6 +6,8 @@ #define PURPLE_REQUEST_HANDLE "purple_request" +#define PURPLE_OPT_SHOULD_SET_NICK 1 + struct purple_data { PurpleAccount *account; @@ -14,6 +16,8 @@ struct purple_data guint next_request_id; char *chat_list_server; GSList *filetransfers; + + int flags; }; #endif /* !BPURPLE_H */ diff --git a/protocols/purple/purple.c b/protocols/purple/purple.c index 49c1ee7c..9e0dc57e 100644 --- a/protocols/purple/purple.c +++ b/protocols/purple/purple.c @@ -113,6 +113,29 @@ static char *purple_get_account_prpl_id(account_t *acc) return acc->prpl->data; } +static gboolean purple_account_should_set_nick(account_t *acc) +{ + /* whitelist of protocols that tend to have numeric or meaningless usernames, and should + * always offer the 'alias' as a nick. this is just so that users don't have to do + * 'account whatever set nick_format %full_name' + */ + char *whitelist[] = { + "prpl-hangouts", + "prpl-eionrobb-funyahoo-plusplus", + "prpl-icq", + NULL, + }; + char **p; + + for (p = whitelist; *p; p++) { + if (g_strcmp0(acc->prpl->data, *p) == 0) { + return TRUE; + } + } + + return FALSE; +} + static void purple_init(account_t *acc) { char *prpl_id = purple_get_account_prpl_id(acc); @@ -367,6 +390,10 @@ static void purple_login(account_t *acc) purple_account_set_password(pd->account, acc->pass); purple_sync_settings(acc, pd->account); + if (purple_account_should_set_nick(acc)) { + pd->flags = PURPLE_OPT_SHOULD_SET_NICK; + } + purple_account_set_enabled(pd->account, "BitlBee", TRUE); if (set_getbool(&acc->set, "mail_notifications") && set_getstr(&acc->set, "mail_notifications_handle")) { @@ -902,17 +929,22 @@ static void prplcb_blist_update(PurpleBuddyList *list, PurpleBlistNode *node) PurpleBuddy *bud = (PurpleBuddy *) node; PurpleGroup *group = purple_buddy_get_group(bud); struct im_connection *ic = purple_ic_by_pa(bud->account); + struct purple_data *pd = ic->proto_data; PurpleStatus *as; int flags = 0; + char *alias = NULL; if (ic == NULL) { return; } - if (bud->server_alias) { - imcb_rename_buddy(ic, bud->name, bud->server_alias); - } else if (bud->alias) { - imcb_rename_buddy(ic, bud->name, bud->alias); + alias = bud->server_alias ? : bud->alias; + + if (alias) { + imcb_rename_buddy(ic, bud->name, alias); + if (pd->flags & PURPLE_OPT_SHOULD_SET_NICK) { + imcb_buddy_nick_change(ic, bud->name, alias); + } } if (group) { -- cgit v1.2.3