Mercurial > pidgin.yaz
comparison libpurple/protocols/qq/group_search.c @ 23753:5f454b975a99
2008.08.10 - csyfek <csyfek(at)gmail.com>
* Commit to Pidgin
2008.08.06 - ccpaging <ecc_hy(at)hotmail.com>
* Rename names of variables, Group, to Room
* Functions of group_network merged into qq_network and qq_process
* Canceled managing glist of group packet, add sub_cmdd and room_id to transaction
* Fixed error of demo group:
If 'room list' and 'room infor' are not setup, response received from server will emits
'room_id = 0' packet.
2008.08.04 - ccpaging <ecc_hy(at)hotmail.com>
* Use new crypt/decrypt functions
* Rename crypt.c/h to qq_crypt.c/h
* Clean code of decrypt functions
* Fixed decryption failure
2008.08.04 - csyfek <csyfek(at)gmail.com>
* Update AUTHORS
author | SHiNE CsyFeK <csyfek@gmail.com> |
---|---|
date | Sun, 10 Aug 2008 04:32:14 +0000 |
parents | 9a5d140400f1 |
children | 967344bc404d |
comparison
equal
deleted
inserted
replaced
23748:107166bb2a64 | 23753:5f454b975a99 |
---|---|
29 #include "char_conv.h" | 29 #include "char_conv.h" |
30 #include "group_find.h" | 30 #include "group_find.h" |
31 #include "group_free.h" | 31 #include "group_free.h" |
32 #include "group_internal.h" | 32 #include "group_internal.h" |
33 #include "group_join.h" | 33 #include "group_join.h" |
34 #include "group_network.h" | |
35 #include "group_search.h" | 34 #include "group_search.h" |
36 #include "utils.h" | 35 #include "utils.h" |
36 #include "header_info.h" | |
37 #include "packet_parse.h" | |
38 #include "qq_network.h" | |
37 | 39 |
38 enum { | 40 enum { |
39 QQ_GROUP_SEARCH_TYPE_BY_ID = 0x01, | 41 QQ_GROUP_SEARCH_TYPE_BY_ID = 0x01, |
40 QQ_GROUP_SEARCH_TYPE_DEMO = 0x02 | 42 QQ_GROUP_SEARCH_TYPE_DEMO = 0x02 |
41 }; | 43 }; |
42 | 44 |
43 /* send packet to search for qq_group */ | 45 /* send packet to search for qq_group */ |
44 void qq_send_cmd_group_search_group(PurpleConnection *gc, guint32 external_group_id) | 46 void qq_send_cmd_group_search_group(PurpleConnection *gc, guint32 ext_id) |
45 { | 47 { |
46 guint8 raw_data[16] = {0}; | 48 guint8 raw_data[16] = {0}; |
47 gint bytes = 0; | 49 gint bytes = 0; |
48 guint8 type; | 50 guint8 type; |
49 | 51 |
50 type = (external_group_id == 0x00000000) ? QQ_GROUP_SEARCH_TYPE_DEMO : QQ_GROUP_SEARCH_TYPE_BY_ID; | 52 type = (ext_id == 0x00000000) ? QQ_GROUP_SEARCH_TYPE_DEMO : QQ_GROUP_SEARCH_TYPE_BY_ID; |
51 | 53 |
52 bytes = 0; | 54 bytes = 0; |
53 bytes += qq_put8(raw_data + bytes, QQ_GROUP_CMD_SEARCH_GROUP); | |
54 bytes += qq_put8(raw_data + bytes, type); | 55 bytes += qq_put8(raw_data + bytes, type); |
55 bytes += qq_put32(raw_data + bytes, external_group_id); | 56 bytes += qq_put32(raw_data + bytes, ext_id); |
56 | 57 |
57 qq_send_group_cmd(gc, NULL, raw_data, bytes); | 58 qq_send_room_cmd_noid(gc, QQ_ROOM_CMD_SEARCH, raw_data, bytes); |
58 } | 59 } |
59 | 60 |
60 static void _qq_setup_roomlist(qq_data *qd, qq_group *group) | 61 static void _qq_setup_roomlist(qq_data *qd, qq_group *group) |
61 { | 62 { |
62 PurpleRoomlistRoom *room; | 63 PurpleRoomlistRoom *room; |
63 gchar field[11]; | 64 gchar field[11]; |
64 | 65 |
65 room = purple_roomlist_room_new(PURPLE_ROOMLIST_ROOMTYPE_ROOM, group->group_name_utf8, NULL); | 66 room = purple_roomlist_room_new(PURPLE_ROOMLIST_ROOMTYPE_ROOM, group->group_name_utf8, NULL); |
66 g_snprintf(field, sizeof(field), "%d", group->external_group_id); | 67 g_snprintf(field, sizeof(field), "%d", group->ext_id); |
67 purple_roomlist_room_add_field(qd->roomlist, room, field); | 68 purple_roomlist_room_add_field(qd->roomlist, room, field); |
68 g_snprintf(field, sizeof(field), "%d", group->creator_uid); | 69 g_snprintf(field, sizeof(field), "%d", group->creator_uid); |
69 purple_roomlist_room_add_field(qd->roomlist, room, field); | 70 purple_roomlist_room_add_field(qd->roomlist, room, field); |
70 purple_roomlist_room_add_field(qd->roomlist, room, group->group_desc_utf8); | 71 purple_roomlist_room_add_field(qd->roomlist, room, group->group_desc_utf8); |
71 g_snprintf(field, sizeof(field), "%d", group->internal_group_id); | 72 g_snprintf(field, sizeof(field), "%d", group->id); |
72 purple_roomlist_room_add_field(qd->roomlist, room, field); | 73 purple_roomlist_room_add_field(qd->roomlist, room, field); |
73 g_snprintf(field, sizeof(field), "%d", group->group_type); | 74 g_snprintf(field, sizeof(field), "%d", group->type8); |
74 purple_roomlist_room_add_field(qd->roomlist, room, field); | 75 purple_roomlist_room_add_field(qd->roomlist, room, field); |
75 g_snprintf(field, sizeof(field), "%d", group->auth_type); | 76 g_snprintf(field, sizeof(field), "%d", group->auth_type); |
76 purple_roomlist_room_add_field(qd->roomlist, room, field); | 77 purple_roomlist_room_add_field(qd->roomlist, room, field); |
77 g_snprintf(field, sizeof(field), "%d", group->group_category); | 78 g_snprintf(field, sizeof(field), "%d", group->group_category); |
78 purple_roomlist_room_add_field(qd->roomlist, room, field); | 79 purple_roomlist_room_add_field(qd->roomlist, room, field); |
97 | 98 |
98 bytes = 0; | 99 bytes = 0; |
99 bytes += qq_get8(&search_type, data + bytes); | 100 bytes += qq_get8(&search_type, data + bytes); |
100 | 101 |
101 /* now it starts with group_info_entry */ | 102 /* now it starts with group_info_entry */ |
102 bytes += qq_get32(&(group.internal_group_id), data + bytes); | 103 bytes += qq_get32(&(group.id), data + bytes); |
103 bytes += qq_get32(&(group.external_group_id), data + bytes); | 104 bytes += qq_get32(&(group.ext_id), data + bytes); |
104 bytes += qq_get8(&(group.group_type), data + bytes); | 105 bytes += qq_get8(&(group.type8), data + bytes); |
105 bytes += qq_get16(&(unknown), data + bytes); | 106 bytes += qq_get16(&(unknown), data + bytes); |
106 bytes += qq_get16(&(unknown), data + bytes); | 107 bytes += qq_get16(&(unknown), data + bytes); |
107 bytes += qq_get32(&(group.creator_uid), data + bytes); | 108 bytes += qq_get32(&(group.creator_uid), data + bytes); |
108 bytes += qq_get16(&(unknown), data + bytes); | 109 bytes += qq_get16(&(unknown), data + bytes); |
109 bytes += qq_get16(&(unknown), data + bytes); | 110 bytes += qq_get16(&(unknown), data + bytes); |
117 if(bytes != len) { | 118 if(bytes != len) { |
118 purple_debug(PURPLE_DEBUG_ERROR, "QQ", | 119 purple_debug(PURPLE_DEBUG_ERROR, "QQ", |
119 "group_cmd_search_group: Dangerous error! maybe protocol changed, notify developers!"); | 120 "group_cmd_search_group: Dangerous error! maybe protocol changed, notify developers!"); |
120 } | 121 } |
121 | 122 |
122 pending_id = qq_get_pending_id(qd->joining_groups, group.external_group_id); | 123 pending_id = qq_get_pending_id(qd->joining_groups, group.ext_id); |
123 if (pending_id != NULL) { | 124 if (pending_id != NULL) { |
124 qq_set_pending_id(&qd->joining_groups, group.external_group_id, FALSE); | 125 qq_set_pending_id(&qd->joining_groups, group.ext_id, FALSE); |
125 if (qq_group_find_by_id(gc, group.internal_group_id, QQ_INTERNAL_ID) == NULL) | 126 if (qq_room_search_id(gc, group.id) == NULL) |
126 qq_group_create_internal_record(gc, | 127 qq_group_create_internal_record(gc, |
127 group.internal_group_id, group.external_group_id, group.group_name_utf8); | 128 group.id, group.ext_id, group.group_name_utf8); |
128 qq_send_cmd_group_join_group(gc, &group); | 129 qq_send_cmd_group_join_group(gc, &group); |
129 } else { | 130 } else { |
130 _qq_setup_roomlist(qd, &group); | 131 _qq_setup_roomlist(qd, &group); |
131 } | 132 } |
132 } | 133 } |