From 29ec0dbac392448e00d407ef22583b4165516a31 Mon Sep 17 00:00:00 2001 From: Debarshi Ray Date: Wed, 11 May 2011 20:29:52 +0300 Subject: [PATCH] Put the role played by the target nick in a channel as vCard parameter Fixes: https://bugs.freedesktop.org/34796 --- src/idle-contact-info.c | 19 +++++++++++++++++-- 1 files changed, 17 insertions(+), 2 deletions(-) diff --git a/src/idle-contact-info.c b/src/idle-contact-info.c index 1bff856..90247fd 100644 --- a/src/idle-contact-info.c +++ b/src/idle-contact-info.c @@ -26,6 +26,7 @@ #define IDLE_DEBUG_FLAG IDLE_DEBUG_CONNECTION #include "idle-debug.h" +#include "idle-muc-channel.h" #include "idle-parser.h" typedef struct _ContactInfoRequest ContactInfoRequest; @@ -58,6 +59,11 @@ static void _insert_contact_field(GPtrArray *contact_info, const gchar *field_na G_TYPE_INVALID)); } +static gboolean _is_channel_typechar(gchar c) +{ + return (c == '#') || (c == '!') || (c == '&') || (c == '+'); +} + static ContactInfoRequest * _get_matching_request(IdleConnection *conn, GValueArray *args) { ContactInfoRequest *request; TpHandle handle = g_value_get_uint(g_value_array_get_nth(args, 0)); @@ -296,8 +302,17 @@ static IdleParserHandlerResult _whois_channels_handler(IdleParser *parser, IdleP channelsv = g_strsplit(channels, " ", -1); for (i = 0; channelsv[i] != NULL; i++) { - field_values[0] = channelsv[i]; - _insert_contact_field(request->contact_info, "x-irc-channel", NULL, field_values); + const gchar *channel = channelsv[i]; + const gchar *field_params[2] = {NULL, NULL}; + + if (idle_muc_channel_is_modechar(channel[0]) && _is_channel_typechar(channel[1])) { + field_params[0] = g_strdup_printf("role=%c", channel[0]); + channel++; + } + + field_values[0] = channel; + _insert_contact_field(request->contact_info, "x-irc-channel", field_params, field_values); + g_free((gpointer) field_params[0]); } g_strfreev(channelsv); -- 1.7.4.4