| 44 QQ_ICON_SUFFIX_OFFLINE = 2, |
46 QQ_ICON_SUFFIX_OFFLINE = 2, |
| 45 QQ_ICON_SUFFIX_AWAY = 3, |
47 QQ_ICON_SUFFIX_AWAY = 3, |
| 46 }; |
48 }; |
| 47 |
49 |
| 48 /*****************************************************************************/ |
50 /*****************************************************************************/ |
| 49 static void _qq_buddy_status_dump_unclear(qq_buddy_status * s) |
51 void qq_buddy_status_dump_unclear(qq_buddy_status * s) |
| 50 { |
52 { |
| 51 GString *dump; |
53 GString *dump; |
| 52 |
54 |
| 53 g_return_if_fail(s != NULL); |
55 g_return_if_fail(s != NULL); |
| 54 |
56 |
| 55 dump = g_string_new(""); |
57 dump = g_string_new(""); |
| 56 g_string_append_printf(dump, "unclear fields for [%d]:\n", s->uid); |
58 g_string_append_printf(dump, "unclear fields for [%d]:\n", s->uid); |
| 57 g_string_append_printf(dump, "004: %02x (unknown)\n", s->unknown1); |
59 g_string_append_printf(dump, "004: %02x (unknown)\n", s->unknown1); |
| |
60 //g_string_append_printf(dump, "005-008: %09x (ip)\n", *(s->ip)); |
| |
61 g_string_append_printf(dump, "009-010: %04x (port)\n", s->port); |
| 58 g_string_append_printf(dump, "011: %02x (unknown)\n", s->unknown2); |
62 g_string_append_printf(dump, "011: %02x (unknown)\n", s->unknown2); |
| |
63 g_string_append_printf(dump, "012: %02x (status)\n", s->status); |
| |
64 g_string_append_printf(dump, "013-014: %04x (client_version)\n", s->client_version); |
| |
65 //g_string_append_printf(dump, "015-030: %s (unknown key)\n", s->unknown_key); |
| 59 gaim_debug(GAIM_DEBUG_INFO, "QQ", "Buddy status entry, %s", dump->str); |
66 gaim_debug(GAIM_DEBUG_INFO, "QQ", "Buddy status entry, %s", dump->str); |
| |
67 _qq_show_packet("Unknown key", s->unknown_key, QQ_KEY_LENGTH); |
| 60 g_string_free(dump, TRUE); |
68 g_string_free(dump, TRUE); |
| 61 } // _qq_buddy_status_dump_unclear |
69 } |
| 62 |
70 |
| 63 /*****************************************************************************/ |
71 /*****************************************************************************/ |
| |
72 // TODO: figure out what's going on with the IP region. Sometimes I get things which |
| |
73 // may be valid IP addresses, but the port number's weird, other times I get 0s. |
| |
74 // Note: I get these simultaneously on the same buddy, using different accounts to get info. |
| 64 // parse the data into qq_buddy_status |
75 // parse the data into qq_buddy_status |
| 65 gint _qq_buddy_status_read(guint8 * data, guint8 ** cursor, gint len, qq_buddy_status * s) { |
76 gint qq_buddy_status_read(guint8 * data, guint8 ** cursor, gint len, qq_buddy_status * s) { |
| 66 gint bytes; |
77 gint bytes; |
| 67 |
78 |
| 68 g_return_val_if_fail(data != NULL && *cursor != NULL && s != NULL, -1); |
79 g_return_val_if_fail(data != NULL && *cursor != NULL && s != NULL, -1); |
| 69 |
80 |
| 70 bytes = 0; |
81 bytes = 0; |
| 71 |
82 |
| 72 // 000-003: uid |
83 // 000-003: uid |
| 73 bytes += read_packet_dw(data, cursor, len, &s->uid); |
84 bytes += read_packet_dw(data, cursor, len, &s->uid); |
| 74 // 004-004: 0x01 |
85 // 004-004: 0x01 |
| 75 bytes += read_packet_b(data, cursor, len, &s->unknown1); |
86 bytes += read_packet_b(data, cursor, len, &s->unknown1); |
| |
87 // this is no longer the IP, it seems QQ (as of 2006) no longer sends |
| |
88 // the buddy's IP in this packet. all 0s |
| 76 // 005-008: ip |
89 // 005-008: ip |
| 77 s->ip = g_new0(guint8, 4); |
90 s->ip = g_new0(guint8, 4); |
| 78 bytes += read_packet_data(data, cursor, len, s->ip, 4); |
91 bytes += read_packet_data(data, cursor, len, s->ip, 4); |
| |
92 // port info is no longer here either |
| 79 // 009-010: port |
93 // 009-010: port |
| 80 bytes += read_packet_w(data, cursor, len, &s->port); |
94 bytes += read_packet_w(data, cursor, len, &s->port); |
| 81 // 011-011: 0x00 |
95 // 011-011: 0x00 |
| 82 bytes += read_packet_b(data, cursor, len, &s->unknown2); |
96 bytes += read_packet_b(data, cursor, len, &s->unknown2); |
| 83 // 012-012: status |
97 // 012-012: status |
| 173 create_packet_dw(raw_data, &cursor, misc_status); |
187 create_packet_dw(raw_data, &cursor, misc_status); |
| 174 |
188 |
| 175 qq_send_cmd(gc, QQ_CMD_CHANGE_ONLINE_STATUS, TRUE, 0, TRUE, raw_data, 5); |
189 qq_send_cmd(gc, QQ_CMD_CHANGE_ONLINE_STATUS, TRUE, 0, TRUE, raw_data, 5); |
| 176 |
190 |
| 177 g_free(raw_data); |
191 g_free(raw_data); |
| 178 } // qq_send_packet_change_status |
192 } |
| 179 |
193 |
| 180 /*****************************************************************************/ |
194 /*****************************************************************************/ |
| 181 // parse the reply packet for change_status |
195 // parse the reply packet for change_status |
| 182 void qq_process_change_status_reply(guint8 * buf, gint buf_len, GaimConnection * gc) { |
196 void qq_process_change_status_reply(guint8 * buf, gint buf_len, GaimConnection * gc) { |
| 183 qq_data *qd; |
197 qq_data *qd; |
| 226 |
240 |
| 227 if (qq_crypt(DECRYPT, buf, buf_len, qd->session_key, data, &len)) { |
241 if (qq_crypt(DECRYPT, buf, buf_len, qd->session_key, data, &len)) { |
| 228 s = g_new0(qq_buddy_status, 1); |
242 s = g_new0(qq_buddy_status, 1); |
| 229 bytes = 0; |
243 bytes = 0; |
| 230 // 000-030: qq_buddy_status; |
244 // 000-030: qq_buddy_status; |
| 231 bytes += _qq_buddy_status_read(data, &cursor, len, s); |
245 bytes += qq_buddy_status_read(data, &cursor, len, s); |
| 232 // 031-034: my uid |
246 // 031-034: my uid |
| 233 bytes += read_packet_dw(data, &cursor, len, &my_uid); |
247 bytes += read_packet_dw(data, &cursor, len, &my_uid); |
| 234 |
248 |
| 235 if (my_uid == 0 || bytes != 35) { |
249 if (my_uid == 0 || bytes != 35) { |
| 236 gaim_debug(GAIM_DEBUG_ERROR, "QQ", "my_uid == 0 || bytes(%d) != 35\n", bytes); |
250 gaim_debug(GAIM_DEBUG_ERROR, "QQ", "my_uid == 0 || bytes(%d) != 35\n", bytes); |
| 240 return; |
254 return; |
| 241 } |
255 } |
| 242 // if (QQ_DEBUG) gfhuang |
256 // if (QQ_DEBUG) gfhuang |
| 243 // _qq_buddy_status_dump_unclear(s); |
257 // _qq_buddy_status_dump_unclear(s); |
| 244 |
258 |
| 245 name = uid_to_gaim_name(s->uid); //by gfhuang |
259 name = uid_to_gaim_name(s->uid); |
| 246 b = gaim_find_buddy(gc->account, name); |
260 b = gaim_find_buddy(gc->account, name); |
| 247 g_free(name); |
261 g_free(name); |
| 248 q_bud = (b == NULL) ? NULL : (qq_buddy *) b->proto_data; |
262 q_bud = (b == NULL) ? NULL : (qq_buddy *) b->proto_data; |
| 249 if (q_bud) { |
263 if (q_bud) { |
| 250 gaim_debug(GAIM_DEBUG_INFO, "QQ", "s->uid = %d, q_bud->uid = %d\n", s->uid , q_bud->uid); |
264 gaim_debug(GAIM_DEBUG_INFO, "QQ", "s->uid = %d, q_bud->uid = %d\n", s->uid , q_bud->uid); |
| 251 if(0 != *((guint32 *)s->ip)) { //by gfhuang |
265 if(0 != *((guint32 *)s->ip)) { |
| 252 g_memmove(q_bud->ip, s->ip, 4); |
266 g_memmove(q_bud->ip, s->ip, 4); |
| 253 q_bud->port = s->port; |
267 q_bud->port = s->port; |
| 254 } |
268 } |
| 255 q_bud->status = s->status; |
269 q_bud->status = s->status; |
| 256 if(0 != s->client_version) |
270 if(0 != s->client_version) |
| 257 q_bud->client_version = s->client_version; //gfhuang |
271 q_bud->client_version = s->client_version; |
| 258 qq_update_buddy_contact(gc, q_bud); |
272 qq_update_buddy_contact(gc, q_bud); |
| 259 } |
273 } |
| 260 else |
274 else |
| 261 gaim_debug(GAIM_DEBUG_ERROR, "QQ", "got information of unknown buddy by gfhuang %d\n", s->uid); |
275 gaim_debug(GAIM_DEBUG_ERROR, "QQ", "got information of unknown buddy by gfhuang %d\n", s->uid); |
| 262 |
276 |
| 263 g_free(s->ip); |
277 g_free(s->ip); |
| 264 g_free(s->unknown_key); |
278 g_free(s->unknown_key); |
| 265 g_free(s); |
279 g_free(s); |
| 266 } else |
280 } else |
| 267 gaim_debug(GAIM_DEBUG_ERROR, "QQ", "Error decrypt buddy status change packet\n"); |
281 gaim_debug(GAIM_DEBUG_ERROR, "QQ", "Error decrypt buddy status change packet\n"); |
| 268 |
282 } |
| 269 } // qq_process_friend_change_status |
|
| 270 |
283 |
| 271 /*****************************************************************************/ |
284 /*****************************************************************************/ |
| 272 // END OF FILE |
285 // END OF FILE |