Mercurial > pidgin
diff src/protocols/irc/msgs.c @ 9554:8b2451878e26
[gaim-migrate @ 10387]
" This patch adds chat user status icons (voice / halfop
/ op / founder) to chats
There's a screenshot here, showing ops, voices and
ignored ops and voices
http://nosnilmot.com/gaim/chatusers.png
This required some changes in how the core stores the
list of users in chats to be able to store the status
too, which are detailed below.
I also fixed up some memory leaks as I came across them
(string values returned by gtk_tree_model_get() not
being g_free()'d) and a minor bug in signals-test.c
Conversation API:
Changed:
gaim_conv_chat_add_user() (added flags parameter)
gaim_conv_chat_add_users() now (added GList of flags
parameter)
gaim_conv_chat_get_users() now returns a GList of
GaimChatBuddy's
gaim_conv_chat_set_users() now expects a GList of
GaimChatBuddy's
Added:
gaim_conv_chat_set_user_flags()
gaim_conv_chat_get_user_flags()
gaim_conv_chat_find_user()
gaim_conv_chat_cb_new()
gaim_conv_chat_cb_find()
gaim_conv_chat_cb_destroy()
gaim_conv_chat_cb_get_name()
Conversation UI ops:
added: chat_update_user()
Signals:
Changed: chat-buddy-joining & chat-buddy-joined now
include the user's flags
Added: chat-buddy-flags for when user's flags change
Added:
gaim_marshal_VOID__POINTER_POINTER_POINTER_UINT_UINT
(required for the new chat-buddy-flags signal)
Protocol Plugins:
All updated to work with above changes (obviously)
User flags support added to IRC, Jabber and SILC
New Files:
pixmaps/status/default/ voice.svg halfop.svg op.svg
founder.svg
" --Stu Tomlinson
committer: Tailor Script <tailor@pidgin.im>
| author | Luke Schierer <lschiere@pidgin.im> |
|---|---|
| date | Sat, 17 Jul 2004 18:11:12 +0000 |
| parents | 6c24a6f07256 |
| children | f1137cf462d8 |
line wrap: on
line diff
--- a/src/protocols/irc/msgs.c Sat Jul 17 17:08:24 2004 +0000 +++ b/src/protocols/irc/msgs.c Sat Jul 17 18:11:12 2004 +0000 @@ -56,10 +56,9 @@ static void irc_chat_remove_buddy(GaimConversation *convo, char *data[2]) { - GList *users = gaim_conv_chat_get_users(GAIM_CONV_CHAT(convo)); char *message = g_strdup_printf("quit: %s", data[1]); - if (g_list_find_custom(users, data[0], (GCompareFunc)(strcmp))) + if (gaim_conv_chat_find_user(GAIM_CONV_CHAT(convo), data[0])) gaim_conv_chat_remove_user(GAIM_CONV_CHAT(convo), data[0], message); g_free(message); @@ -332,15 +331,26 @@ irc->nameconv = NULL; } else { GList *users = NULL; + GList *flags = NULL; while (*cur) { + GaimConvChatBuddyFlags f = GAIM_CBFLAGS_NONE; end = strchr(cur, ' '); if (!end) end = cur + strlen(cur); - if (*cur == '@' || *cur == '%' || *cur == '+') + if (*cur == '@') { + f = GAIM_CBFLAGS_OP; cur++; + } else if (*cur == '%') { + f = GAIM_CBFLAGS_HALFOP; + cur++; + } else if(*cur == '+') { + f = GAIM_CBFLAGS_VOICE; + cur++; + } tmp = g_strndup(cur, end - cur); users = g_list_append(users, tmp); + flags = g_list_append(flags, GINT_TO_POINTER(f)); cur = end; if (*cur) cur++; @@ -349,12 +359,13 @@ if (users != NULL) { GList *l; - gaim_conv_chat_add_users(GAIM_CONV_CHAT(convo), users); + gaim_conv_chat_add_users(GAIM_CONV_CHAT(convo), users, flags); for (l = users; l != NULL; l = l->next) g_free(l->data); g_list_free(users); + g_list_free(flags); } } g_free(names); @@ -574,7 +585,7 @@ } userhost = irc_mask_userhost(from); - gaim_conv_chat_add_user(GAIM_CONV_CHAT(convo), nick, userhost); + gaim_conv_chat_add_user(GAIM_CONV_CHAT(convo), nick, userhost, GAIM_CBFLAGS_NONE); if ((ib = g_hash_table_lookup(irc->buddies, nick)) != NULL) { ib->flag = TRUE; @@ -632,6 +643,45 @@ buf = g_strdup_printf(_("mode (%s %s) by %s"), args[1], args[2] ? args[2] : "", nick); gaim_conv_chat_write(GAIM_CONV_CHAT(convo), args[0], buf, GAIM_MESSAGE_SYSTEM|GAIM_MESSAGE_NO_LOG, time(NULL)); g_free(buf); + if(args[2]) { + GaimConvChatBuddyFlags newflag, flags; + char *mcur, *cur, *end, *user; + gboolean add = FALSE; + mcur = args[1]; + cur = args[2]; + while (*cur && *mcur) { + if ((*mcur == '+') || (*mcur == '-')) { + add = (*mcur == '+') ? TRUE : FALSE; + mcur++; + continue; + } + end = strchr(cur, ' '); + if (!end) + end = cur + strlen(cur); + user = g_strndup(cur, end - cur); + flags = gaim_conv_chat_user_get_flags(GAIM_CONV_CHAT(convo), user); + newflag = GAIM_CBFLAGS_NONE; + if (*mcur == 'o') + newflag = GAIM_CBFLAGS_OP; + else if (*mcur =='h') + newflag = GAIM_CBFLAGS_HALFOP; + else if (*mcur == 'v') + newflag = GAIM_CBFLAGS_VOICE; + if (newflag) { + if (add) + flags |= newflag; + else + flags &= ~newflag; + gaim_conv_chat_user_set_flags(GAIM_CONV_CHAT(convo), user, flags); + } + g_free(user); + cur = end; + if (*cur) + cur++; + if (*mcur) + mcur++; + } + } } else { /* User */ } g_free(nick); @@ -655,18 +705,7 @@ while (chats) { GaimConvChat *chat = GAIM_CONV_CHAT(chats->data); - GList *users = gaim_conv_chat_get_users(chat); - - while (users) { - char *user = users->data; - - if (!strcmp(nick, user)) { - gaim_conv_chat_rename_user(chat, user, args[0]); - users = gaim_conv_chat_get_users(chat); - break; - } - users = users->next; - } + gaim_conv_chat_rename_user(chat, nick, args[0]); chats = chats->next; } g_free(nick);
