Mercurial > pidgin
changeset 12961:4eae108efdde
[gaim-migrate @ 15314]
A GG conference fix from Bartosz Oler. This should fix SF Bug #1395473
committer: Tailor Script <tailor@pidgin.im>
author | Richard Laager <rlaager@wiktel.com> |
---|---|
date | Fri, 20 Jan 2006 01:53:05 +0000 |
parents | cefac38bcb9f |
children | 0f64896eab01 |
files | src/protocols/gg/confer.c src/protocols/gg/gg.c src/protocols/gg/gg.h |
diffstat | 3 files changed, 46 insertions(+), 78 deletions(-) [+] |
line wrap: on
line diff
--- a/src/protocols/gg/confer.c Fri Jan 20 01:52:01 2006 +0000 +++ b/src/protocols/gg/confer.c Fri Jan 20 01:53:05 2006 +0000 @@ -47,37 +47,25 @@ GList *l; gchar *str_uin; - str_uin = g_strdup_printf("%lu", (unsigned long int)uin); - for (l = info->chats; l != NULL; l = l->next) { chat = l->data; if (g_utf8_collate(chat->name, chat_name) != 0) continue; - if (g_list_find(chat->participants, str_uin) == NULL) { - GaimBuddy *buddy; - + if (g_list_find(chat->participants, GINT_TO_POINTER(uin)) == NULL) { chat->participants = g_list_append( - chat->participants, str_uin); - - conv = ggp_confer_find_by_name(gc, chat_name); + chat->participants, GINT_TO_POINTER(uin)); - buddy = gaim_find_buddy(gaim_connection_get_account(gc), str_uin); - if (buddy != NULL) { - gaim_conv_chat_add_user(GAIM_CONV_CHAT(conv), - gaim_buddy_get_alias(buddy), NULL, - GAIM_CBFLAGS_NONE, TRUE); - } else { - gaim_conv_chat_add_user(GAIM_CONV_CHAT(conv), - str_uin, NULL, - GAIM_CBFLAGS_NONE, TRUE); - } + str_uin = g_strdup_printf("%lu", (unsigned long int)uin); + conv = ggp_confer_find_by_name(gc, chat_name); + gaim_conv_chat_add_user(GAIM_CONV_CHAT(conv), str_uin, NULL, + GAIM_CBFLAGS_NONE, TRUE); + + g_free(str_uin); } break; } - - g_free(str_uin); } /* }}} */ @@ -87,6 +75,7 @@ { GGPInfo *info = gc->proto_data; GList *l; + gchar *str_uin; for (l = info->chats; l != NULL; l = l->next) { GGPChat *chat = l->data; @@ -96,28 +85,21 @@ continue; for (i = 0; i < count; i++) { - gchar *str_uin = g_strdup_printf("%lu", (unsigned long int)recipients[i]); GaimConversation *conv; - GaimBuddy *buddy; - if (g_list_find(chat->participants, str_uin) != NULL) { - g_free(str_uin); + if (g_list_find(chat->participants, + GINT_TO_POINTER(recipients[i])) != NULL) { continue; } - chat->participants = g_list_append(chat->participants, str_uin); - conv = ggp_confer_find_by_name(gc, chat_name); + chat->participants = g_list_append(chat->participants, + GINT_TO_POINTER(recipients[i])); - buddy = gaim_find_buddy(gaim_connection_get_account(gc), str_uin); - if (buddy != NULL) { - gaim_conv_chat_add_user(GAIM_CONV_CHAT(conv), - gaim_buddy_get_alias(buddy), NULL, - GAIM_CBFLAGS_NONE, TRUE); - } else { - gaim_conv_chat_add_user(GAIM_CONV_CHAT(conv), - str_uin, NULL, - GAIM_CBFLAGS_NONE, TRUE); - } + str_uin = g_strdup_printf("%lu", (unsigned long int)recipients[i]); + conv = ggp_confer_find_by_name(gc, chat_name); + gaim_conv_chat_add_user(GAIM_CONV_CHAT(conv), + str_uin, NULL, + GAIM_CBFLAGS_NONE, TRUE); g_free(str_uin); } break; @@ -143,11 +125,11 @@ matches = 0; for (m = chat->participants; m != NULL; m = m->next) { - uin_t p = ggp_str_to_uin(m->data); + uin_t uin = GPOINTER_TO_INT(m->data); int i; for (i = 0; i < count; i++) - if (p == recipients[i]) + if (uin == recipients[i]) matches++; }
--- a/src/protocols/gg/gg.c Fri Jan 20 01:52:01 2006 +0000 +++ b/src/protocols/gg/gg.c Fri Jan 20 01:53:05 2006 +0000 @@ -25,15 +25,6 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ - -/* - * NOTES - * - * I don't like automatic updates of the buddylist stored on the server, so not - * going to implement this. Maybe some kind of option to enable/disable this - * feature. - */ - #include "internal.h" #include "plugin.h" @@ -764,22 +755,13 @@ { GGPInfo *info = gc->proto_data; GaimRequestField *field; - const GList *sel, *l; + const GList *sel; field = gaim_request_fields_get_field(fields, "name"); sel = gaim_request_field_list_get_selected(field); - gaim_debug_info("gg", "selected chat %s for buddy %s\n", - sel->data, info->tmp_buddy); - for (l = info->chats; l != NULL; l = l->next) { - GGPChat *chat = l->data; - - if (g_utf8_collate(chat->name, sel->data) == 0) { - chat->participants = g_list_append(chat->participants, - info->tmp_buddy); - break; - } - } + ggp_confer_participants_add_uin(gc, sel->data, info->tmp_buddy); + info->tmp_buddy = 0; } /* }}} */ @@ -803,8 +785,8 @@ gc = gaim_account_get_connection(gaim_buddy_get_account(buddy)); info = gc->proto_data; - /* TODO: It tmp_buddy != NULL then stop! */ - info->tmp_buddy = g_strdup(gaim_buddy_get_name(buddy)); + /* TODO: It tmp_buddy != 0 then stop! */ + info->tmp_buddy = ggp_str_to_uin(gaim_buddy_get_name(buddy)); fields = gaim_request_fields_new(); group = gaim_request_field_group_new(NULL); @@ -813,12 +795,12 @@ field = gaim_request_field_list_new("name", "Chat name"); for (l = info->chats; l != NULL; l = l->next) { GGPChat *chat = l->data; - gaim_debug_info("gg", "adding chat %s\n", chat->name); gaim_request_field_list_add(field, g_strdup(chat->name), g_strdup(chat->name)); } gaim_request_field_group_add_field(group, field); + /* TODO: s/screenname/alias/ */ msg = g_strdup_printf(_("Select a chat for buddy: %s"), gaim_buddy_get_name(buddy)); gaim_request_fields(gc, @@ -1072,18 +1054,18 @@ from = g_strdup_printf("%lu", (unsigned long int)ev->event.msg.sender); - msg = charset_convert((const char *)ev->event.msg.message, + tmp = charset_convert((const char *)ev->event.msg.message, "CP1250", "UTF-8"); - gaim_str_strip_char(msg, '\r'); - tmp = g_markup_escape_text(msg, -1); - g_free(msg); + gaim_str_strip_char(tmp, '\r'); + msg = g_markup_escape_text(tmp, -1); + g_free(tmp); gaim_debug_info("gg", "msg form (%s): %s (class = %d; rcpt_count = %d)\n", - from, tmp, ev->event.msg.msgclass, + from, msg, ev->event.msg.msgclass, ev->event.msg.recipients_count); if (ev->event.msg.recipients_count == 0) { - serv_got_im(gc, from, tmp, 0, ev->event.msg.time); + serv_got_im(gc, from, msg, 0, ev->event.msg.time); } else { const char *chat_name; int chat_id; @@ -1092,6 +1074,7 @@ chat_name = ggp_confer_find_by_participants(gc, ev->event.msg.recipients, ev->event.msg.recipients_count); + if (chat_name == NULL) { chat_name = ggp_confer_add_new(gc, NULL); serv_got_joined_chat(gc, info->chats_count, chat_name); @@ -1108,10 +1091,10 @@ buddy_name = ggp_buddy_get_name(gc, ev->event.msg.sender); serv_got_chat_in(gc, chat_id, buddy_name, - 0, msg, ev->event.msg.time); + GAIM_MESSAGE_RECV, msg, ev->event.msg.time); g_free(buddy_name); } - g_free(tmp); + g_free(msg); g_free(from); } /* }}} */ @@ -1706,6 +1689,8 @@ GGPChat *chat; char *chat_name; GList *l; + GaimConversation *conv; + GaimAccount *account = gaim_connection_get_account(gc); chat_name = g_hash_table_lookup(data, "name"); @@ -1725,7 +1710,10 @@ } ggp_confer_add_new(gc, chat_name); - serv_got_joined_chat(gc, info->chats_count, chat_name); + conv = serv_got_joined_chat(gc, info->chats_count, chat_name); + gaim_conv_chat_add_user(GAIM_CONV_CHAT(conv), + gaim_account_get_username(account), NULL, + GAIM_CBFLAGS_NONE, TRUE); } /* }}} */ @@ -1753,7 +1741,6 @@ chat = l->data; if (g_utf8_collate(chat->name, conv->name) == 0) { - gaim_debug_info("gg", "found conv!\n"); break; } @@ -1767,19 +1754,18 @@ } uins = g_new0(uin_t, g_list_length(chat->participants)); + for (l = chat->participants; l != NULL; l = l->next) { - gchar *name = l->data; - uin_t uin; + uin_t uin = GPOINTER_TO_INT(l->data); - if ((uin = ggp_str_to_uin(name)) != 0) - uins[count++] = uin; + uins[count++] = uin; } plain = gaim_unescape_html(message); msg = charset_convert(plain, "UTF-8", "CP1250"); g_free(plain); gg_send_message_confer(info->session, GG_CLASS_CHAT, count, uins, - (unsigned char *)msg); + (unsigned char *)msg); g_free(msg); g_free(uins);