comparison src/protocols/yahoo/yahoochat.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 3aa848ccf986
children d39eecc24a59
comparison
equal deleted inserted replaced
9553:8a64666476e6 9554:8b2451878e26
67 yahoo_send_packet(yd, pkt); 67 yahoo_send_packet(yd, pkt);
68 68
69 yahoo_packet_free(pkt); 69 yahoo_packet_free(pkt);
70 } 70 }
71 71
72 static gint _mystrcmpwrapper(gconstpointer a, gconstpointer b)
73 {
74 return strcmp(a, b);
75 }
76
77 /* this is slow, and different from the gaim_* version in that it (hopefully) won't add a user twice */ 72 /* this is slow, and different from the gaim_* version in that it (hopefully) won't add a user twice */
78 void yahoo_chat_add_users(GaimConvChat *chat, GList *newusers) 73 void yahoo_chat_add_users(GaimConvChat *chat, GList *newusers)
79 { 74 {
80 GList *users, *i, *j; 75 GList *i;
81
82 users = gaim_conv_chat_get_users(chat);
83 76
84 for (i = newusers; i; i = i->next) { 77 for (i = newusers; i; i = i->next) {
85 j = g_list_find_custom(users, i->data, _mystrcmpwrapper); 78 if (gaim_conv_chat_find_user(chat, i->data))
86 if (j)
87 continue; 79 continue;
88 gaim_conv_chat_add_user(chat, i->data, NULL); 80 gaim_conv_chat_add_user(chat, i->data, NULL, GAIM_CBFLAGS_NONE);
89 } 81 }
90 } 82 }
91 83
92 void yahoo_chat_add_user(GaimConvChat *chat, const char *user, const char *reason) 84 void yahoo_chat_add_user(GaimConvChat *chat, const char *user, const char *reason)
93 { 85 {
94 GList *users; 86 if (gaim_conv_chat_find_user(chat, user))
95 87 return;
96 users = gaim_conv_chat_get_users(chat); 88
97 89 gaim_conv_chat_add_user(chat, user, reason, GAIM_CBFLAGS_NONE);
98 if ((g_list_find_custom(users, user, _mystrcmpwrapper)))
99 return;
100
101 gaim_conv_chat_add_user(chat, user, reason);
102 } 90 }
103 91
104 static GaimConversation *yahoo_find_conference(GaimConnection *gc, const char *name) 92 static GaimConversation *yahoo_find_conference(GaimConnection *gc, const char *name)
105 { 93 {
106 struct yahoo_data *yd; 94 struct yahoo_data *yd;
411 c = gaim_find_chat(gc, YAHOO_CHAT_ID); 399 c = gaim_find_chat(gc, YAHOO_CHAT_ID);
412 400
413 if (room && (!c || gaim_conv_chat_has_left(GAIM_CONV_CHAT(c))) && members && 401 if (room && (!c || gaim_conv_chat_has_left(GAIM_CONV_CHAT(c))) && members &&
414 ((g_list_length(members) > 1) || 402 ((g_list_length(members) > 1) ||
415 !g_ascii_strcasecmp(members->data, gaim_connection_get_display_name(gc)))) { 403 !g_ascii_strcasecmp(members->data, gaim_connection_get_display_name(gc)))) {
404 int i;
405 GList *flags = NULL;
406 for (i = 0; i < g_list_length(members); i++)
407 flags = g_list_append(flags, GINT_TO_POINTER(GAIM_CBFLAGS_NONE));
416 if (c && gaim_conv_chat_has_left(GAIM_CONV_CHAT(c))) { 408 if (c && gaim_conv_chat_has_left(GAIM_CONV_CHAT(c))) {
417 /* this might be a hack, but oh well, it should nicely */ 409 /* this might be a hack, but oh well, it should nicely */
418 char *tmpmsg; 410 char *tmpmsg;
419 411
420 gaim_conversation_set_name(c, room); 412 gaim_conversation_set_name(c, room);
422 c = serv_got_joined_chat(gc, YAHOO_CHAT_ID, room); 414 c = serv_got_joined_chat(gc, YAHOO_CHAT_ID, room);
423 if (topic) 415 if (topic)
424 gaim_conv_chat_set_topic(GAIM_CONV_CHAT(c), NULL, topic); 416 gaim_conv_chat_set_topic(GAIM_CONV_CHAT(c), NULL, topic);
425 yd->in_chat = 1; 417 yd->in_chat = 1;
426 yd->chat_name = g_strdup(room); 418 yd->chat_name = g_strdup(room);
427 gaim_conv_chat_add_users(GAIM_CONV_CHAT(c), members); 419 gaim_conv_chat_add_users(GAIM_CONV_CHAT(c), members, flags);
428 420
429 tmpmsg = g_strdup_printf(_("You are now chatting in %s."), room); 421 tmpmsg = g_strdup_printf(_("You are now chatting in %s."), room);
430 gaim_conv_chat_write(GAIM_CONV_CHAT(c), "", tmpmsg, GAIM_MESSAGE_SYSTEM, time(NULL)); 422 gaim_conv_chat_write(GAIM_CONV_CHAT(c), "", tmpmsg, GAIM_MESSAGE_SYSTEM, time(NULL));
431 g_free(tmpmsg); 423 g_free(tmpmsg);
432 } else { 424 } else {
433 c = serv_got_joined_chat(gc, YAHOO_CHAT_ID, room); 425 c = serv_got_joined_chat(gc, YAHOO_CHAT_ID, room);
434 if (topic) 426 if (topic)
435 gaim_conv_chat_set_topic(GAIM_CONV_CHAT(c), NULL, topic); 427 gaim_conv_chat_set_topic(GAIM_CONV_CHAT(c), NULL, topic);
436 yd->in_chat = 1; 428 yd->in_chat = 1;
437 yd->chat_name = g_strdup(room); 429 yd->chat_name = g_strdup(room);
438 gaim_conv_chat_add_users(GAIM_CONV_CHAT(c), members); 430 gaim_conv_chat_add_users(GAIM_CONV_CHAT(c), members, flags);
439 } 431 }
440 } else if (c) { 432 } else if (c) {
441 yahoo_chat_add_users(GAIM_CONV_CHAT(c), members); 433 yahoo_chat_add_users(GAIM_CONV_CHAT(c), members);
442 } 434 }
443 435
598 590
599 pkt = yahoo_packet_new(YAHOO_SERVICE_CONFLOGOFF, YAHOO_STATUS_AVAILABLE, 0); 591 pkt = yahoo_packet_new(YAHOO_SERVICE_CONFLOGOFF, YAHOO_STATUS_AVAILABLE, 0);
600 592
601 yahoo_packet_hash(pkt, 1, dn); 593 yahoo_packet_hash(pkt, 1, dn);
602 for (w = who; w; w = w->next) { 594 for (w = who; w; w = w->next) {
603 yahoo_packet_hash(pkt, 3, (char *)w->data); 595 const char *name = gaim_conv_chat_cb_get_name(w->data);
596 yahoo_packet_hash(pkt, 3, name);
604 } 597 }
605 598
606 yahoo_packet_hash(pkt, 57, room); 599 yahoo_packet_hash(pkt, 57, room);
607 600
608 yahoo_send_packet(yd, pkt); 601 yahoo_send_packet(yd, pkt);
624 617
625 618
626 pkt = yahoo_packet_new(YAHOO_SERVICE_CONFMSG, YAHOO_STATUS_AVAILABLE, 0); 619 pkt = yahoo_packet_new(YAHOO_SERVICE_CONFMSG, YAHOO_STATUS_AVAILABLE, 0);
627 620
628 yahoo_packet_hash(pkt, 1, dn); 621 yahoo_packet_hash(pkt, 1, dn);
629 for (who = members; who; who = who->next) 622 for (who = members; who; who = who->next) {
630 yahoo_packet_hash(pkt, 53, (char *)who->data); 623 const char *name = gaim_conv_chat_cb_get_name(who->data);
624 yahoo_packet_hash(pkt, 53, name);
625 }
631 yahoo_packet_hash(pkt, 57, room); 626 yahoo_packet_hash(pkt, 57, room);
632 yahoo_packet_hash(pkt, 14, msg2); 627 yahoo_packet_hash(pkt, 14, msg2);
633 if (utf8) 628 if (utf8)
634 yahoo_packet_hash(pkt, 97, "1"); /* utf-8 */ 629 yahoo_packet_hash(pkt, 97, "1"); /* utf-8 */
635 630
661 if (memarr) { 656 if (memarr) {
662 for(i = 0 ; memarr[i]; i++) { 657 for(i = 0 ; memarr[i]; i++) {
663 if (!strcmp(memarr[i], "") || !strcmp(memarr[i], dn)) 658 if (!strcmp(memarr[i], "") || !strcmp(memarr[i], dn))
664 continue; 659 continue;
665 yahoo_packet_hash(pkt, 3, memarr[i]); 660 yahoo_packet_hash(pkt, 3, memarr[i]);
666 gaim_conv_chat_add_user(GAIM_CONV_CHAT(c), memarr[i], NULL); 661 gaim_conv_chat_add_user(GAIM_CONV_CHAT(c), memarr[i], NULL, GAIM_CBFLAGS_NONE);
667 } 662 }
668 } 663 }
669 yahoo_send_packet(yd, pkt); 664 yahoo_send_packet(yd, pkt);
670 665
671 yahoo_packet_free(pkt); 666 yahoo_packet_free(pkt);
693 yahoo_packet_hash(pkt, 51, buddy); 688 yahoo_packet_hash(pkt, 51, buddy);
694 yahoo_packet_hash(pkt, 57, room); 689 yahoo_packet_hash(pkt, 57, room);
695 yahoo_packet_hash(pkt, 58, msg?msg2:""); 690 yahoo_packet_hash(pkt, 58, msg?msg2:"");
696 yahoo_packet_hash(pkt, 13, "0"); 691 yahoo_packet_hash(pkt, 13, "0");
697 for(; members; members = members->next) { 692 for(; members; members = members->next) {
698 if (!strcmp(members->data, dn)) 693 const char *name = gaim_conv_chat_cb_get_name(members->data);
694 if (!strcmp(name, dn))
699 continue; 695 continue;
700 yahoo_packet_hash(pkt, 52, (char *)members->data); 696 yahoo_packet_hash(pkt, 52, name);
701 yahoo_packet_hash(pkt, 53, (char *)members->data); 697 yahoo_packet_hash(pkt, 53, name);
702 } 698 }
703 yahoo_send_packet(yd, pkt); 699 yahoo_send_packet(yd, pkt);
704 700
705 yahoo_packet_free(pkt); 701 yahoo_packet_free(pkt);
706 if (msg) 702 if (msg)