Mercurial > pidgin
comparison src/protocols/gg/gg.c @ 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 | 82e918444965 |
children | c0f68043854a |
comparison
equal
deleted
inserted
replaced
12960:cefac38bcb9f | 12961:4eae108efdde |
---|---|
23 * You should have received a copy of the GNU General Public License | 23 * You should have received a copy of the GNU General Public License |
24 * along with this program; if not, write to the Free Software | 24 * along with this program; if not, write to the Free Software |
25 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | 25 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
26 */ | 26 */ |
27 | 27 |
28 | |
29 /* | |
30 * NOTES | |
31 * | |
32 * I don't like automatic updates of the buddylist stored on the server, so not | |
33 * going to implement this. Maybe some kind of option to enable/disable this | |
34 * feature. | |
35 */ | |
36 | |
37 #include "internal.h" | 28 #include "internal.h" |
38 | 29 |
39 #include "plugin.h" | 30 #include "plugin.h" |
40 #include "version.h" | 31 #include "version.h" |
41 #include "notify.h" | 32 #include "notify.h" |
762 /* static void ggp_callback_add_to_chat_ok(GaimConnection *gc, GaimRequestFields *fields) {{{ */ | 753 /* static void ggp_callback_add_to_chat_ok(GaimConnection *gc, GaimRequestFields *fields) {{{ */ |
763 static void ggp_callback_add_to_chat_ok(GaimConnection *gc, GaimRequestFields *fields) | 754 static void ggp_callback_add_to_chat_ok(GaimConnection *gc, GaimRequestFields *fields) |
764 { | 755 { |
765 GGPInfo *info = gc->proto_data; | 756 GGPInfo *info = gc->proto_data; |
766 GaimRequestField *field; | 757 GaimRequestField *field; |
767 const GList *sel, *l; | 758 const GList *sel; |
768 | 759 |
769 field = gaim_request_fields_get_field(fields, "name"); | 760 field = gaim_request_fields_get_field(fields, "name"); |
770 sel = gaim_request_field_list_get_selected(field); | 761 sel = gaim_request_field_list_get_selected(field); |
771 gaim_debug_info("gg", "selected chat %s for buddy %s\n", | 762 |
772 sel->data, info->tmp_buddy); | 763 ggp_confer_participants_add_uin(gc, sel->data, info->tmp_buddy); |
773 | 764 info->tmp_buddy = 0; |
774 for (l = info->chats; l != NULL; l = l->next) { | |
775 GGPChat *chat = l->data; | |
776 | |
777 if (g_utf8_collate(chat->name, sel->data) == 0) { | |
778 chat->participants = g_list_append(chat->participants, | |
779 info->tmp_buddy); | |
780 break; | |
781 } | |
782 } | |
783 } | 765 } |
784 /* }}} */ | 766 /* }}} */ |
785 | 767 |
786 /* | 768 /* |
787 */ | 769 */ |
801 | 783 |
802 buddy = (GaimBuddy *)node; | 784 buddy = (GaimBuddy *)node; |
803 gc = gaim_account_get_connection(gaim_buddy_get_account(buddy)); | 785 gc = gaim_account_get_connection(gaim_buddy_get_account(buddy)); |
804 info = gc->proto_data; | 786 info = gc->proto_data; |
805 | 787 |
806 /* TODO: It tmp_buddy != NULL then stop! */ | 788 /* TODO: It tmp_buddy != 0 then stop! */ |
807 info->tmp_buddy = g_strdup(gaim_buddy_get_name(buddy)); | 789 info->tmp_buddy = ggp_str_to_uin(gaim_buddy_get_name(buddy)); |
808 | 790 |
809 fields = gaim_request_fields_new(); | 791 fields = gaim_request_fields_new(); |
810 group = gaim_request_field_group_new(NULL); | 792 group = gaim_request_field_group_new(NULL); |
811 gaim_request_fields_add_group(fields, group); | 793 gaim_request_fields_add_group(fields, group); |
812 | 794 |
813 field = gaim_request_field_list_new("name", "Chat name"); | 795 field = gaim_request_field_list_new("name", "Chat name"); |
814 for (l = info->chats; l != NULL; l = l->next) { | 796 for (l = info->chats; l != NULL; l = l->next) { |
815 GGPChat *chat = l->data; | 797 GGPChat *chat = l->data; |
816 gaim_debug_info("gg", "adding chat %s\n", chat->name); | |
817 gaim_request_field_list_add(field, g_strdup(chat->name), | 798 gaim_request_field_list_add(field, g_strdup(chat->name), |
818 g_strdup(chat->name)); | 799 g_strdup(chat->name)); |
819 } | 800 } |
820 gaim_request_field_group_add_field(group, field); | 801 gaim_request_field_group_add_field(group, field); |
821 | 802 |
803 /* TODO: s/screenname/alias/ */ | |
822 msg = g_strdup_printf(_("Select a chat for buddy: %s"), | 804 msg = g_strdup_printf(_("Select a chat for buddy: %s"), |
823 gaim_buddy_get_name(buddy)); | 805 gaim_buddy_get_name(buddy)); |
824 gaim_request_fields(gc, | 806 gaim_request_fields(gc, |
825 _("Add to chat..."), | 807 _("Add to chat..."), |
826 _("Add to chat..."), | 808 _("Add to chat..."), |
1070 gchar *msg; | 1052 gchar *msg; |
1071 gchar *tmp; | 1053 gchar *tmp; |
1072 | 1054 |
1073 from = g_strdup_printf("%lu", (unsigned long int)ev->event.msg.sender); | 1055 from = g_strdup_printf("%lu", (unsigned long int)ev->event.msg.sender); |
1074 | 1056 |
1075 msg = charset_convert((const char *)ev->event.msg.message, | 1057 tmp = charset_convert((const char *)ev->event.msg.message, |
1076 "CP1250", "UTF-8"); | 1058 "CP1250", "UTF-8"); |
1077 gaim_str_strip_char(msg, '\r'); | 1059 gaim_str_strip_char(tmp, '\r'); |
1078 tmp = g_markup_escape_text(msg, -1); | 1060 msg = g_markup_escape_text(tmp, -1); |
1079 g_free(msg); | 1061 g_free(tmp); |
1080 | 1062 |
1081 gaim_debug_info("gg", "msg form (%s): %s (class = %d; rcpt_count = %d)\n", | 1063 gaim_debug_info("gg", "msg form (%s): %s (class = %d; rcpt_count = %d)\n", |
1082 from, tmp, ev->event.msg.msgclass, | 1064 from, msg, ev->event.msg.msgclass, |
1083 ev->event.msg.recipients_count); | 1065 ev->event.msg.recipients_count); |
1084 | 1066 |
1085 if (ev->event.msg.recipients_count == 0) { | 1067 if (ev->event.msg.recipients_count == 0) { |
1086 serv_got_im(gc, from, tmp, 0, ev->event.msg.time); | 1068 serv_got_im(gc, from, msg, 0, ev->event.msg.time); |
1087 } else { | 1069 } else { |
1088 const char *chat_name; | 1070 const char *chat_name; |
1089 int chat_id; | 1071 int chat_id; |
1090 char *buddy_name; | 1072 char *buddy_name; |
1091 | 1073 |
1092 chat_name = ggp_confer_find_by_participants(gc, | 1074 chat_name = ggp_confer_find_by_participants(gc, |
1093 ev->event.msg.recipients, | 1075 ev->event.msg.recipients, |
1094 ev->event.msg.recipients_count); | 1076 ev->event.msg.recipients_count); |
1077 | |
1095 if (chat_name == NULL) { | 1078 if (chat_name == NULL) { |
1096 chat_name = ggp_confer_add_new(gc, NULL); | 1079 chat_name = ggp_confer_add_new(gc, NULL); |
1097 serv_got_joined_chat(gc, info->chats_count, chat_name); | 1080 serv_got_joined_chat(gc, info->chats_count, chat_name); |
1098 | 1081 |
1099 ggp_confer_participants_add_uin(gc, chat_name, | 1082 ggp_confer_participants_add_uin(gc, chat_name, |
1106 conv = ggp_confer_find_by_name(gc, chat_name); | 1089 conv = ggp_confer_find_by_name(gc, chat_name); |
1107 chat_id = gaim_conv_chat_get_id(GAIM_CONV_CHAT(conv)); | 1090 chat_id = gaim_conv_chat_get_id(GAIM_CONV_CHAT(conv)); |
1108 | 1091 |
1109 buddy_name = ggp_buddy_get_name(gc, ev->event.msg.sender); | 1092 buddy_name = ggp_buddy_get_name(gc, ev->event.msg.sender); |
1110 serv_got_chat_in(gc, chat_id, buddy_name, | 1093 serv_got_chat_in(gc, chat_id, buddy_name, |
1111 0, msg, ev->event.msg.time); | 1094 GAIM_MESSAGE_RECV, msg, ev->event.msg.time); |
1112 g_free(buddy_name); | 1095 g_free(buddy_name); |
1113 } | 1096 } |
1114 g_free(tmp); | 1097 g_free(msg); |
1115 g_free(from); | 1098 g_free(from); |
1116 } | 1099 } |
1117 /* }}} */ | 1100 /* }}} */ |
1118 | 1101 |
1119 /* | 1102 /* |
1704 { | 1687 { |
1705 GGPInfo *info = gc->proto_data; | 1688 GGPInfo *info = gc->proto_data; |
1706 GGPChat *chat; | 1689 GGPChat *chat; |
1707 char *chat_name; | 1690 char *chat_name; |
1708 GList *l; | 1691 GList *l; |
1692 GaimConversation *conv; | |
1693 GaimAccount *account = gaim_connection_get_account(gc); | |
1709 | 1694 |
1710 chat_name = g_hash_table_lookup(data, "name"); | 1695 chat_name = g_hash_table_lookup(data, "name"); |
1711 | 1696 |
1712 if (chat_name == NULL) | 1697 if (chat_name == NULL) |
1713 return; | 1698 return; |
1723 return; | 1708 return; |
1724 } | 1709 } |
1725 } | 1710 } |
1726 | 1711 |
1727 ggp_confer_add_new(gc, chat_name); | 1712 ggp_confer_add_new(gc, chat_name); |
1728 serv_got_joined_chat(gc, info->chats_count, chat_name); | 1713 conv = serv_got_joined_chat(gc, info->chats_count, chat_name); |
1714 gaim_conv_chat_add_user(GAIM_CONV_CHAT(conv), | |
1715 gaim_account_get_username(account), NULL, | |
1716 GAIM_CBFLAGS_NONE, TRUE); | |
1729 } | 1717 } |
1730 /* }}} */ | 1718 /* }}} */ |
1731 | 1719 |
1732 /* static char *ggp_get_chat_name(GHashTable *data) { {{{ */ | 1720 /* static char *ggp_get_chat_name(GHashTable *data) { {{{ */ |
1733 static char *ggp_get_chat_name(GHashTable *data) { | 1721 static char *ggp_get_chat_name(GHashTable *data) { |
1751 | 1739 |
1752 for (l = info->chats; l != NULL; l = l->next) { | 1740 for (l = info->chats; l != NULL; l = l->next) { |
1753 chat = l->data; | 1741 chat = l->data; |
1754 | 1742 |
1755 if (g_utf8_collate(chat->name, conv->name) == 0) { | 1743 if (g_utf8_collate(chat->name, conv->name) == 0) { |
1756 gaim_debug_info("gg", "found conv!\n"); | |
1757 break; | 1744 break; |
1758 } | 1745 } |
1759 | 1746 |
1760 chat = NULL; | 1747 chat = NULL; |
1761 } | 1748 } |
1765 "ggp_chat_send: Hm... that's strange. No such chat?\n"); | 1752 "ggp_chat_send: Hm... that's strange. No such chat?\n"); |
1766 return -EINVAL; | 1753 return -EINVAL; |
1767 } | 1754 } |
1768 | 1755 |
1769 uins = g_new0(uin_t, g_list_length(chat->participants)); | 1756 uins = g_new0(uin_t, g_list_length(chat->participants)); |
1757 | |
1770 for (l = chat->participants; l != NULL; l = l->next) { | 1758 for (l = chat->participants; l != NULL; l = l->next) { |
1771 gchar *name = l->data; | 1759 uin_t uin = GPOINTER_TO_INT(l->data); |
1772 uin_t uin; | 1760 |
1773 | 1761 uins[count++] = uin; |
1774 if ((uin = ggp_str_to_uin(name)) != 0) | |
1775 uins[count++] = uin; | |
1776 } | 1762 } |
1777 | 1763 |
1778 plain = gaim_unescape_html(message); | 1764 plain = gaim_unescape_html(message); |
1779 msg = charset_convert(plain, "UTF-8", "CP1250"); | 1765 msg = charset_convert(plain, "UTF-8", "CP1250"); |
1780 g_free(plain); | 1766 g_free(plain); |
1781 gg_send_message_confer(info->session, GG_CLASS_CHAT, count, uins, | 1767 gg_send_message_confer(info->session, GG_CLASS_CHAT, count, uins, |
1782 (unsigned char *)msg); | 1768 (unsigned char *)msg); |
1783 g_free(msg); | 1769 g_free(msg); |
1784 g_free(uins); | 1770 g_free(uins); |
1785 | 1771 |
1786 serv_got_chat_in(gc, id, | 1772 serv_got_chat_in(gc, id, |
1787 gaim_account_get_username(gaim_connection_get_account(gc)), | 1773 gaim_account_get_username(gaim_connection_get_account(gc)), |