Mercurial > pidgin.yaz
comparison libpurple/protocols/qq/group_search.c @ 23050:9a5d140400f1
patch-02-fix-multiarch
author | SHiNE CsyFeK <csyfek@gmail.com> |
---|---|
date | Tue, 24 Jun 2008 11:58:57 +0000 |
parents | 44b4e8bd759b |
children | 5f454b975a99 |
comparison
equal
deleted
inserted
replaced
23048:13a9b56f83b0 | 23050:9a5d140400f1 |
---|---|
41 }; | 41 }; |
42 | 42 |
43 /* send packet to search for qq_group */ | 43 /* send packet to search for qq_group */ |
44 void qq_send_cmd_group_search_group(PurpleConnection *gc, guint32 external_group_id) | 44 void qq_send_cmd_group_search_group(PurpleConnection *gc, guint32 external_group_id) |
45 { | 45 { |
46 guint8 *raw_data, *cursor, type; | 46 guint8 raw_data[16] = {0}; |
47 gint bytes, data_len; | 47 gint bytes = 0; |
48 guint8 type; | |
48 | 49 |
49 data_len = 6; | |
50 raw_data = g_newa(guint8, data_len); | |
51 cursor = raw_data; | |
52 type = (external_group_id == 0x00000000) ? QQ_GROUP_SEARCH_TYPE_DEMO : QQ_GROUP_SEARCH_TYPE_BY_ID; | 50 type = (external_group_id == 0x00000000) ? QQ_GROUP_SEARCH_TYPE_DEMO : QQ_GROUP_SEARCH_TYPE_BY_ID; |
53 | 51 |
54 bytes = 0; | 52 bytes = 0; |
55 bytes += create_packet_b(raw_data, &cursor, QQ_GROUP_CMD_SEARCH_GROUP); | 53 bytes += qq_put8(raw_data + bytes, QQ_GROUP_CMD_SEARCH_GROUP); |
56 bytes += create_packet_b(raw_data, &cursor, type); | 54 bytes += qq_put8(raw_data + bytes, type); |
57 bytes += create_packet_dw(raw_data, &cursor, external_group_id); | 55 bytes += qq_put32(raw_data + bytes, external_group_id); |
58 | 56 |
59 if (bytes != data_len) | 57 qq_send_group_cmd(gc, NULL, raw_data, bytes); |
60 purple_debug(PURPLE_DEBUG_ERROR, "QQ", | |
61 "Fail create packet for %s\n", qq_group_cmd_get_desc(QQ_GROUP_CMD_SEARCH_GROUP)); | |
62 else | |
63 qq_send_group_cmd(gc, NULL, raw_data, data_len); | |
64 } | 58 } |
65 | 59 |
66 static void _qq_setup_roomlist(qq_data *qd, qq_group *group) | 60 static void _qq_setup_roomlist(qq_data *qd, qq_group *group) |
67 { | 61 { |
68 PurpleRoomlistRoom *room; | 62 PurpleRoomlistRoom *room; |
87 | 81 |
88 purple_roomlist_set_in_progress(qd->roomlist, FALSE); | 82 purple_roomlist_set_in_progress(qd->roomlist, FALSE); |
89 } | 83 } |
90 | 84 |
91 /* process group cmd reply "search group" */ | 85 /* process group cmd reply "search group" */ |
92 void qq_process_group_cmd_search_group(guint8 *data, guint8 **cursor, gint len, PurpleConnection *gc) | 86 void qq_process_group_cmd_search_group(guint8 *data, gint len, PurpleConnection *gc) |
93 { | 87 { |
88 gint bytes; | |
94 guint8 search_type; | 89 guint8 search_type; |
95 guint16 unknown; | 90 guint16 unknown; |
96 gint bytes, pascal_len; | 91 qq_group group; |
97 qq_data *qd; | 92 qq_data *qd; |
98 qq_group *group; | |
99 GSList *pending_id; | 93 GSList *pending_id; |
100 | 94 |
101 g_return_if_fail(data != NULL && len > 0); | 95 g_return_if_fail(data != NULL && len > 0); |
102 qd = (qq_data *) gc->proto_data; | 96 qd = (qq_data *) gc->proto_data; |
103 | 97 |
104 read_packet_b(data, cursor, len, &search_type); | 98 bytes = 0; |
105 group = g_newa(qq_group, 1); | 99 bytes += qq_get8(&search_type, data + bytes); |
106 | 100 |
107 /* now it starts with group_info_entry */ | 101 /* now it starts with group_info_entry */ |
108 bytes = 0; | 102 bytes += qq_get32(&(group.internal_group_id), data + bytes); |
109 bytes += read_packet_dw(data, cursor, len, &(group->internal_group_id)); | 103 bytes += qq_get32(&(group.external_group_id), data + bytes); |
110 bytes += read_packet_dw(data, cursor, len, &(group->external_group_id)); | 104 bytes += qq_get8(&(group.group_type), data + bytes); |
111 bytes += read_packet_b(data, cursor, len, &(group->group_type)); | 105 bytes += qq_get16(&(unknown), data + bytes); |
112 bytes += read_packet_w(data, cursor, len, &(unknown)); | 106 bytes += qq_get16(&(unknown), data + bytes); |
113 bytes += read_packet_w(data, cursor, len, &(unknown)); | 107 bytes += qq_get32(&(group.creator_uid), data + bytes); |
114 bytes += read_packet_dw(data, cursor, len, &(group->creator_uid)); | 108 bytes += qq_get16(&(unknown), data + bytes); |
115 bytes += read_packet_w(data, cursor, len, &(unknown)); | 109 bytes += qq_get16(&(unknown), data + bytes); |
116 bytes += read_packet_w(data, cursor, len, &(unknown)); | 110 bytes += qq_get16(&(unknown), data + bytes); |
117 bytes += read_packet_w(data, cursor, len, &(unknown)); | 111 bytes += qq_get32(&(group.group_category), data + bytes); |
118 bytes += read_packet_dw(data, cursor, len, &(group->group_category)); | 112 bytes += convert_as_pascal_string(data + bytes, &(group.group_name_utf8), QQ_CHARSET_DEFAULT); |
119 pascal_len = convert_as_pascal_string(*cursor, &(group->group_name_utf8), QQ_CHARSET_DEFAULT); | 113 bytes += qq_get16(&(unknown), data + bytes); |
120 bytes += pascal_len; | 114 bytes += qq_get8(&(group.auth_type), data + bytes); |
121 *cursor += pascal_len; | 115 bytes += convert_as_pascal_string(data + bytes, &(group.group_desc_utf8), QQ_CHARSET_DEFAULT); |
122 bytes += read_packet_w(data, cursor, len, &(unknown)); | |
123 bytes += read_packet_b(data, cursor, len, &(group->auth_type)); | |
124 pascal_len = convert_as_pascal_string(*cursor, &(group->group_desc_utf8), QQ_CHARSET_DEFAULT); | |
125 bytes += pascal_len; | |
126 *cursor += pascal_len; | |
127 /* end of one qq_group */ | 116 /* end of one qq_group */ |
128 if(*cursor != (data + len)) { | 117 if(bytes != len) { |
129 purple_debug(PURPLE_DEBUG_ERROR, "QQ", | 118 purple_debug(PURPLE_DEBUG_ERROR, "QQ", |
130 "group_cmd_search_group: Dangerous error! maybe protocol changed, notify developers!"); | 119 "group_cmd_search_group: Dangerous error! maybe protocol changed, notify developers!"); |
131 } | 120 } |
132 | 121 |
133 pending_id = qq_get_pending_id(qd->joining_groups, group->external_group_id); | 122 pending_id = qq_get_pending_id(qd->joining_groups, group.external_group_id); |
134 if (pending_id != NULL) { | 123 if (pending_id != NULL) { |
135 qq_set_pending_id(&qd->joining_groups, group->external_group_id, FALSE); | 124 qq_set_pending_id(&qd->joining_groups, group.external_group_id, FALSE); |
136 if (qq_group_find_by_id(gc, group->internal_group_id, QQ_INTERNAL_ID) == NULL) | 125 if (qq_group_find_by_id(gc, group.internal_group_id, QQ_INTERNAL_ID) == NULL) |
137 qq_group_create_internal_record(gc, | 126 qq_group_create_internal_record(gc, |
138 group->internal_group_id, group->external_group_id, group->group_name_utf8); | 127 group.internal_group_id, group.external_group_id, group.group_name_utf8); |
139 qq_send_cmd_group_join_group(gc, group); | 128 qq_send_cmd_group_join_group(gc, &group); |
140 } else { | 129 } else { |
141 _qq_setup_roomlist(qd, group); | 130 _qq_setup_roomlist(qd, &group); |
142 } | 131 } |
143 } | 132 } |