Mercurial > pidgin
annotate libgaim/protocols/qq/group_search.c @ 20382:bcba1cb6b318
Allow localization of the xmpp console plugin
author | Mark Doliner <mark@kingant.net> |
---|---|
date | Thu, 25 Jan 2007 07:32:30 +0000 |
parents | c039c920e11c |
children |
rev | line source |
---|---|
14192 | 1 /** |
15025 | 2 * @file group_search.c |
14192 | 3 * |
15025 | 4 * gaim |
14192 | 5 * |
15025 | 6 * Gaim is the legal property of its developers, whose names are too numerous |
7 * to list here. Please refer to the COPYRIGHT file distributed with this | |
8 * source distribution. | |
14192 | 9 * |
10 * This program is free software; you can redistribute it and/or modify | |
11 * it under the terms of the GNU General Public License as published by | |
12 * the Free Software Foundation; either version 2 of the License, or | |
13 * (at your option) any later version. | |
14 * | |
15 * This program is distributed in the hope that it will be useful, | |
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
18 * GNU General Public License for more details. | |
19 * | |
20 * You should have received a copy of the GNU General Public License | |
21 * along with this program; if not, write to the Free Software | |
22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
23 */ | |
24 | |
25 #include "debug.h" | |
26 | |
27 #include "char_conv.h" | |
14404 | 28 #include "group_find.h" |
14192 | 29 #include "group_free.h" |
14404 | 30 #include "group_internal.h" |
31 #include "group_join.h" | |
14192 | 32 #include "group_network.h" |
33 #include "group_search.h" | |
34 #include "utils.h" | |
35 | |
36 enum { | |
37 QQ_GROUP_SEARCH_TYPE_BY_ID = 0x01, | |
38 QQ_GROUP_SEARCH_TYPE_DEMO = 0x02 | |
39 }; | |
40 | |
41 /* send packet to search for qq_group */ | |
42 void qq_send_cmd_group_search_group(GaimConnection *gc, guint32 external_group_id) | |
43 { | |
44 guint8 *raw_data, *cursor, type; | |
45 gint bytes, data_len; | |
46 | |
47 data_len = 6; | |
48 raw_data = g_newa(guint8, data_len); | |
49 cursor = raw_data; | |
50 type = (external_group_id == 0x00000000) ? QQ_GROUP_SEARCH_TYPE_DEMO : QQ_GROUP_SEARCH_TYPE_BY_ID; | |
51 | |
52 bytes = 0; | |
53 bytes += create_packet_b(raw_data, &cursor, QQ_GROUP_CMD_SEARCH_GROUP); | |
54 bytes += create_packet_b(raw_data, &cursor, type); | |
55 bytes += create_packet_dw(raw_data, &cursor, external_group_id); | |
56 | |
57 if (bytes != data_len) | |
58 gaim_debug(GAIM_DEBUG_ERROR, "QQ", | |
59 "Fail create packet for %s\n", qq_group_cmd_get_desc(QQ_GROUP_CMD_SEARCH_GROUP)); | |
60 else | |
61 qq_send_group_cmd(gc, NULL, raw_data, data_len); | |
62 } | |
63 | |
14404 | 64 static void _qq_setup_roomlist(qq_data *qd, qq_group *group) |
65 { | |
66 GaimRoomlistRoom *room; | |
14519 | 67 gchar field[11]; |
14404 | 68 |
69 room = gaim_roomlist_room_new(GAIM_ROOMLIST_ROOMTYPE_ROOM, group->group_name_utf8, NULL); | |
14519 | 70 g_snprintf(field, sizeof(field), "%d", group->external_group_id); |
14404 | 71 gaim_roomlist_room_add_field(qd->roomlist, room, field); |
14519 | 72 g_snprintf(field, sizeof(field), "%d", group->creator_uid); |
14404 | 73 gaim_roomlist_room_add_field(qd->roomlist, room, field); |
74 gaim_roomlist_room_add_field(qd->roomlist, room, group->group_desc_utf8); | |
14519 | 75 g_snprintf(field, sizeof(field), "%d", group->internal_group_id); |
14404 | 76 gaim_roomlist_room_add_field(qd->roomlist, room, field); |
14519 | 77 g_snprintf(field, sizeof(field), "%d", group->group_type); |
14404 | 78 gaim_roomlist_room_add_field(qd->roomlist, room, field); |
14519 | 79 g_snprintf(field, sizeof(field), "%d", group->auth_type); |
14404 | 80 gaim_roomlist_room_add_field(qd->roomlist, room, field); |
14519 | 81 g_snprintf(field, sizeof(field), "%d", group->group_category); |
14404 | 82 gaim_roomlist_room_add_field(qd->roomlist, room, field); |
83 gaim_roomlist_room_add_field(qd->roomlist, room, group->group_name_utf8); | |
84 gaim_roomlist_room_add(qd->roomlist, room); | |
85 | |
86 gaim_roomlist_set_in_progress(qd->roomlist, FALSE); | |
87 } | |
88 | |
14192 | 89 /* process group cmd reply "search group" */ |
90 void qq_process_group_cmd_search_group(guint8 *data, guint8 **cursor, gint len, GaimConnection *gc) | |
91 { | |
92 guint8 search_type; | |
93 guint16 unknown; | |
14492
a85299caf0c3
[gaim-migrate @ 17211]
Richard Laager <rlaager@wiktel.com>
parents:
14404
diff
changeset
|
94 gint bytes, pascal_len; |
14192 | 95 qq_data *qd; |
96 qq_group *group; | |
14404 | 97 GSList *pending_id; |
14192 | 98 |
99 g_return_if_fail(data != NULL && len > 0); | |
100 qd = (qq_data *) gc->proto_data; | |
101 | |
14243 | 102 read_packet_b(data, cursor, len, &search_type); |
14192 | 103 group = g_newa(qq_group, 1); |
104 | |
105 /* now it starts with group_info_entry */ | |
14404 | 106 bytes = 0; |
107 bytes += read_packet_dw(data, cursor, len, &(group->internal_group_id)); | |
108 bytes += read_packet_dw(data, cursor, len, &(group->external_group_id)); | |
109 bytes += read_packet_b(data, cursor, len, &(group->group_type)); | |
110 bytes += read_packet_w(data, cursor, len, &(unknown)); | |
111 bytes += read_packet_w(data, cursor, len, &(unknown)); | |
112 bytes += read_packet_dw(data, cursor, len, &(group->creator_uid)); | |
113 bytes += read_packet_w(data, cursor, len, &(unknown)); | |
114 bytes += read_packet_w(data, cursor, len, &(unknown)); | |
115 bytes += read_packet_w(data, cursor, len, &(unknown)); | |
116 bytes += read_packet_dw(data, cursor, len, &(group->group_category)); | |
117 pascal_len = convert_as_pascal_string(*cursor, &(group->group_name_utf8), QQ_CHARSET_DEFAULT); | |
118 bytes += pascal_len; | |
119 *cursor += pascal_len; | |
120 bytes += read_packet_w(data, cursor, len, &(unknown)); | |
121 bytes += read_packet_b(data, cursor, len, &(group->auth_type)); | |
122 pascal_len = convert_as_pascal_string(*cursor, &(group->group_desc_utf8), QQ_CHARSET_DEFAULT); | |
123 bytes += pascal_len; | |
124 *cursor += pascal_len; | |
125 /* end of one qq_group */ | |
126 if(*cursor != (data + len)) { | |
14192 | 127 gaim_debug(GAIM_DEBUG_ERROR, "QQ", |
128 "group_cmd_search_group: Dangerous error! maybe protocol changed, notify developers!"); | |
129 } | |
14404 | 130 |
131 pending_id = qq_get_pending_id(qd->joining_groups, group->external_group_id); | |
132 if (pending_id != NULL) { | |
133 qq_set_pending_id(&qd->joining_groups, group->external_group_id, FALSE); | |
134 if (qq_group_find_by_id(gc, group->internal_group_id, QQ_INTERNAL_ID) == NULL) | |
135 qq_group_create_internal_record(gc, | |
136 group->internal_group_id, group->external_group_id, group->group_name_utf8); | |
137 qq_send_cmd_group_join_group(gc, group); | |
138 } else { | |
139 _qq_setup_roomlist(qd, group); | |
140 } | |
14192 | 141 } |