Mercurial > pidgin.yaz
comparison libpurple/protocols/qq/im.c @ 15823:32c366eeeb99
sed -ie 's/gaim/purple/g'
author | Sean Egan <seanegan@gmail.com> |
---|---|
date | Mon, 19 Mar 2007 07:01:17 +0000 |
parents | 5fe8042783c1 |
children | 85d5942e80e9 |
comparison
equal
deleted
inserted
replaced
15822:84b0f9b23ede | 15823:32c366eeeb99 |
---|---|
1 /** | 1 /** |
2 * @file im.c | 2 * @file im.c |
3 * | 3 * |
4 * gaim | 4 * purple |
5 * | 5 * |
6 * Gaim is the legal property of its developers, whose names are too numerous | 6 * Purple 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 | 7 * to list here. Please refer to the COPYRIGHT file distributed with this |
8 * source distribution. | 8 * source distribution. |
9 * | 9 * |
10 * This program is free software; you can redistribute it and/or modify | 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 | 11 * it under the terms of the GNU General Public License as published by |
155 if (is_underline) | 155 if (is_underline) |
156 send_im_tail[1] |= 0x80; | 156 send_im_tail[1] |= 0x80; |
157 | 157 |
158 if (font_color) { | 158 if (font_color) { |
159 s1 = g_strndup(font_color + 1, 6); | 159 s1 = g_strndup(font_color + 1, 6); |
160 /* Henry: maybe this is a bug of gaim, the string should have | 160 /* Henry: maybe this is a bug of purple, the string should have |
161 * the length of odd number @_@ | 161 * the length of odd number @_@ |
162 */ | 162 */ |
163 s2 = g_strdup_printf("%sH", s1); | 163 s2 = g_strdup_printf("%sH", s1); |
164 rgb = gaim_base16_decode(s2, NULL); | 164 rgb = purple_base16_decode(s2, NULL); |
165 g_free(s1); | 165 g_free(s1); |
166 g_free(s2); | 166 g_free(s2); |
167 memcpy(send_im_tail + 2, rgb, 3); | 167 memcpy(send_im_tail + 2, rgb, 3); |
168 g_free(rgb); | 168 g_free(rgb); |
169 } else { | 169 } else { |
209 } | 209 } |
210 } | 210 } |
211 | 211 |
212 /* when we receive a message, | 212 /* when we receive a message, |
213 * we send an ACK which is the first 16 bytes of incoming packet */ | 213 * we send an ACK which is the first 16 bytes of incoming packet */ |
214 static void _qq_send_packet_recv_im_ack(GaimConnection *gc, guint16 seq, guint8 *data) | 214 static void _qq_send_packet_recv_im_ack(PurpleConnection *gc, guint16 seq, guint8 *data) |
215 { | 215 { |
216 qq_send_cmd(gc, QQ_CMD_RECV_IM, FALSE, seq, FALSE, data, 16); | 216 qq_send_cmd(gc, QQ_CMD_RECV_IM, FALSE, seq, FALSE, data, 16); |
217 } | 217 } |
218 | 218 |
219 /* read the common parts of the normal_im, | 219 /* read the common parts of the normal_im, |
234 *cursor += QQ_KEY_LENGTH; | 234 *cursor += QQ_KEY_LENGTH; |
235 | 235 |
236 bytes += read_packet_w(data, cursor, len, &(common->normal_im_type)); | 236 bytes += read_packet_w(data, cursor, len, &(common->normal_im_type)); |
237 | 237 |
238 if (bytes != 28) { /* read common place fail */ | 238 if (bytes != 28) { /* read common place fail */ |
239 gaim_debug(GAIM_DEBUG_ERROR, "QQ", "Expect 28 bytes, read %d bytes\n", bytes); | 239 purple_debug(PURPLE_DEBUG_ERROR, "QQ", "Expect 28 bytes, read %d bytes\n", bytes); |
240 return -1; | 240 return -1; |
241 } | 241 } |
242 | 242 |
243 return bytes; | 243 return bytes; |
244 } | 244 } |
245 | 245 |
246 /* process received normal text IM */ | 246 /* process received normal text IM */ |
247 static void _qq_process_recv_normal_im_text | 247 static void _qq_process_recv_normal_im_text |
248 (guint8 *data, guint8 **cursor, gint len, qq_recv_normal_im_common *common, GaimConnection *gc) | 248 (guint8 *data, guint8 **cursor, gint len, qq_recv_normal_im_common *common, PurpleConnection *gc) |
249 { | 249 { |
250 guint16 gaim_msg_type; | 250 guint16 purple_msg_type; |
251 gchar *name; | 251 gchar *name; |
252 gchar *msg_with_gaim_smiley; | 252 gchar *msg_with_purple_smiley; |
253 gchar *msg_utf8_encoded; | 253 gchar *msg_utf8_encoded; |
254 qq_data *qd; | 254 qq_data *qd; |
255 qq_recv_normal_im_text *im_text; | 255 qq_recv_normal_im_text *im_text; |
256 | 256 |
257 g_return_if_fail(common != NULL); | 257 g_return_if_fail(common != NULL); |
258 qd = (qq_data *) gc->proto_data; | 258 qd = (qq_data *) gc->proto_data; |
259 | 259 |
260 /* now it is QQ_NORMAL_IM_TEXT */ | 260 /* now it is QQ_NORMAL_IM_TEXT */ |
261 if (*cursor >= (data + len - 1)) { | 261 if (*cursor >= (data + len - 1)) { |
262 gaim_debug(GAIM_DEBUG_WARNING, "QQ", "Received normal IM text is empty\n"); | 262 purple_debug(PURPLE_DEBUG_WARNING, "QQ", "Received normal IM text is empty\n"); |
263 return; | 263 return; |
264 } else | 264 } else |
265 im_text = g_newa(qq_recv_normal_im_text, 1); | 265 im_text = g_newa(qq_recv_normal_im_text, 1); |
266 | 266 |
267 im_text->common = common; | 267 im_text->common = common; |
296 } else /* not im_text->is_there_font_attr */ | 296 } else /* not im_text->is_there_font_attr */ |
297 im_text->msg = g_strndup(*(gchar **) cursor, data + len - *cursor); | 297 im_text->msg = g_strndup(*(gchar **) cursor, data + len - *cursor); |
298 } /* if im_text->msg_type */ | 298 } /* if im_text->msg_type */ |
299 _qq_show_packet("QQ_MESG recv", data, *cursor - data); | 299 _qq_show_packet("QQ_MESG recv", data, *cursor - data); |
300 | 300 |
301 name = uid_to_gaim_name(common->sender_uid); | 301 name = uid_to_purple_name(common->sender_uid); |
302 if (gaim_find_buddy(gc->account, name) == NULL) | 302 if (purple_find_buddy(gc->account, name) == NULL) |
303 qq_add_buddy_by_recv_packet(gc, common->sender_uid, FALSE, TRUE); | 303 qq_add_buddy_by_recv_packet(gc, common->sender_uid, FALSE, TRUE); |
304 | 304 |
305 gaim_msg_type = (im_text->msg_type == QQ_IM_AUTO_REPLY) ? GAIM_MESSAGE_AUTO_RESP : 0; | 305 purple_msg_type = (im_text->msg_type == QQ_IM_AUTO_REPLY) ? PURPLE_MESSAGE_AUTO_RESP : 0; |
306 | 306 |
307 msg_with_gaim_smiley = qq_smiley_to_gaim(im_text->msg); | 307 msg_with_purple_smiley = qq_smiley_to_purple(im_text->msg); |
308 msg_utf8_encoded = im_text->is_there_font_attr ? | 308 msg_utf8_encoded = im_text->is_there_font_attr ? |
309 qq_encode_to_gaim(im_text->font_attr, | 309 qq_encode_to_purple(im_text->font_attr, |
310 im_text->font_attr_len, | 310 im_text->font_attr_len, |
311 msg_with_gaim_smiley) : qq_to_utf8(msg_with_gaim_smiley, QQ_CHARSET_DEFAULT); | 311 msg_with_purple_smiley) : qq_to_utf8(msg_with_purple_smiley, QQ_CHARSET_DEFAULT); |
312 | 312 |
313 /* send encoded to gaim, note that we use im_text->send_time, | 313 /* send encoded to purple, note that we use im_text->send_time, |
314 * not the time we receive the message | 314 * not the time we receive the message |
315 * as it may have been delayed when I am not online. */ | 315 * as it may have been delayed when I am not online. */ |
316 serv_got_im(gc, name, msg_utf8_encoded, gaim_msg_type, (time_t) im_text->send_time); | 316 serv_got_im(gc, name, msg_utf8_encoded, purple_msg_type, (time_t) im_text->send_time); |
317 | 317 |
318 g_free(msg_utf8_encoded); | 318 g_free(msg_utf8_encoded); |
319 g_free(msg_with_gaim_smiley); | 319 g_free(msg_with_purple_smiley); |
320 g_free(name); | 320 g_free(name); |
321 g_free(im_text->msg); | 321 g_free(im_text->msg); |
322 if (im_text->is_there_font_attr) | 322 if (im_text->is_there_font_attr) |
323 g_free(im_text->font_attr); | 323 g_free(im_text->font_attr); |
324 } | 324 } |
325 | 325 |
326 /* it is a normal IM, maybe text or video request */ | 326 /* it is a normal IM, maybe text or video request */ |
327 static void _qq_process_recv_normal_im(guint8 *data, guint8 **cursor, gint len, GaimConnection *gc) | 327 static void _qq_process_recv_normal_im(guint8 *data, guint8 **cursor, gint len, PurpleConnection *gc) |
328 { | 328 { |
329 gint bytes; | 329 gint bytes; |
330 qq_recv_normal_im_common *common; | 330 qq_recv_normal_im_common *common; |
331 qq_recv_normal_im_unprocessed *im_unprocessed; | 331 qq_recv_normal_im_unprocessed *im_unprocessed; |
332 gchar *hex_dump; | 332 gchar *hex_dump; |
333 | 333 |
334 g_return_if_fail (data != NULL && len != 0); | 334 g_return_if_fail (data != NULL && len != 0); |
335 | 335 |
336 if (*cursor >= (data + len - 1)) { | 336 if (*cursor >= (data + len - 1)) { |
337 gaim_debug (GAIM_DEBUG_WARNING, "QQ", | 337 purple_debug (PURPLE_DEBUG_WARNING, "QQ", |
338 "Received normal IM is empty\n"); | 338 "Received normal IM is empty\n"); |
339 return; | 339 return; |
340 } | 340 } |
341 else | 341 else |
342 common = g_newa (qq_recv_normal_im_common, 1); | 342 common = g_newa (qq_recv_normal_im_common, 1); |
343 | 343 |
344 bytes = _qq_normal_im_common_read (data, cursor, len, common); | 344 bytes = _qq_normal_im_common_read (data, cursor, len, common); |
345 if (bytes < 0) { | 345 if (bytes < 0) { |
346 gaim_debug (GAIM_DEBUG_ERROR, "QQ", | 346 purple_debug (PURPLE_DEBUG_ERROR, "QQ", |
347 "Fail read the common part of normal IM\n"); | 347 "Fail read the common part of normal IM\n"); |
348 return; | 348 return; |
349 } | 349 } |
350 | 350 |
351 switch (common->normal_im_type) { | 351 switch (common->normal_im_type) { |
352 case QQ_NORMAL_IM_TEXT: | 352 case QQ_NORMAL_IM_TEXT: |
353 gaim_debug (GAIM_DEBUG_INFO, | 353 purple_debug (PURPLE_DEBUG_INFO, |
354 "QQ", | 354 "QQ", |
355 "Normal IM, text type:\n [%d] => [%d], src: %s\n", | 355 "Normal IM, text type:\n [%d] => [%d], src: %s\n", |
356 common->sender_uid, common->receiver_uid, | 356 common->sender_uid, common->receiver_uid, |
357 qq_get_source_str (common->sender_ver)); | 357 qq_get_source_str (common->sender_ver)); |
358 _qq_process_recv_normal_im_text (data, cursor, len, common, | 358 _qq_process_recv_normal_im_text (data, cursor, len, common, |
382 im_unprocessed = g_newa (qq_recv_normal_im_unprocessed, 1); | 382 im_unprocessed = g_newa (qq_recv_normal_im_unprocessed, 1); |
383 im_unprocessed->common = common; | 383 im_unprocessed->common = common; |
384 im_unprocessed->unknown = *cursor; | 384 im_unprocessed->unknown = *cursor; |
385 im_unprocessed->length = data + len - *cursor; | 385 im_unprocessed->length = data + len - *cursor; |
386 /* a simple process here, maybe more later */ | 386 /* a simple process here, maybe more later */ |
387 gaim_debug (GAIM_DEBUG_WARNING, "QQ", | 387 purple_debug (PURPLE_DEBUG_WARNING, "QQ", |
388 "Normal IM, unprocessed type [0x%04x]\n", | 388 "Normal IM, unprocessed type [0x%04x]\n", |
389 common->normal_im_type); | 389 common->normal_im_type); |
390 hex_dump = hex_dump_to_str(im_unprocessed->unknown, im_unprocessed->length); | 390 hex_dump = hex_dump_to_str(im_unprocessed->unknown, im_unprocessed->length); |
391 gaim_debug (GAIM_DEBUG_WARNING, "QQ", "Dump unknown part.\n%s", hex_dump); | 391 purple_debug (PURPLE_DEBUG_WARNING, "QQ", "Dump unknown part.\n%s", hex_dump); |
392 g_free(hex_dump); | 392 g_free(hex_dump); |
393 g_free (common->session_md5); | 393 g_free (common->session_md5); |
394 return; | 394 return; |
395 } | 395 } |
396 | 396 |
397 g_free (common->session_md5); | 397 g_free (common->session_md5); |
398 } | 398 } |
399 | 399 |
400 /* process im from system administrator */ | 400 /* process im from system administrator */ |
401 static void _qq_process_recv_sys_im(guint8 *data, guint8 **cursor, gint data_len, GaimConnection *gc) | 401 static void _qq_process_recv_sys_im(guint8 *data, guint8 **cursor, gint data_len, PurpleConnection *gc) |
402 { | 402 { |
403 gint len; | 403 gint len; |
404 guint8 reply; | 404 guint8 reply; |
405 gchar **segments, *msg_utf8; | 405 gchar **segments, *msg_utf8; |
406 | 406 |
407 g_return_if_fail(data != NULL && data_len != 0); | 407 g_return_if_fail(data != NULL && data_len != 0); |
408 | 408 |
409 if (*cursor >= (data + data_len - 1)) { | 409 if (*cursor >= (data + data_len - 1)) { |
410 gaim_debug(GAIM_DEBUG_WARNING, "QQ", "Received sys IM is empty\n"); | 410 purple_debug(PURPLE_DEBUG_WARNING, "QQ", "Received sys IM is empty\n"); |
411 return; | 411 return; |
412 } | 412 } |
413 | 413 |
414 len = data + data_len - *cursor; | 414 len = data + data_len - *cursor; |
415 | 415 |
416 if (NULL == (segments = split_data(*cursor, len, "\x2f", 2))) | 416 if (NULL == (segments = split_data(*cursor, len, "\x2f", 2))) |
417 return; | 417 return; |
418 | 418 |
419 reply = strtol(segments[0], NULL, 10); | 419 reply = strtol(segments[0], NULL, 10); |
420 if (reply == QQ_RECV_SYS_IM_KICK_OUT) | 420 if (reply == QQ_RECV_SYS_IM_KICK_OUT) |
421 gaim_debug(GAIM_DEBUG_WARNING, "QQ", "We are kicked out by QQ server\n"); | 421 purple_debug(PURPLE_DEBUG_WARNING, "QQ", "We are kicked out by QQ server\n"); |
422 msg_utf8 = qq_to_utf8(segments[1], QQ_CHARSET_DEFAULT); | 422 msg_utf8 = qq_to_utf8(segments[1], QQ_CHARSET_DEFAULT); |
423 gaim_notify_warning(gc, NULL, _("System Message"), msg_utf8); | 423 purple_notify_warning(gc, NULL, _("System Message"), msg_utf8); |
424 } | 424 } |
425 | 425 |
426 /* send an IM to to_uid */ | 426 /* send an IM to to_uid */ |
427 void qq_send_packet_im(GaimConnection *gc, guint32 to_uid, gchar *msg, gint type) | 427 void qq_send_packet_im(PurpleConnection *gc, guint32 to_uid, gchar *msg, gint type) |
428 { | 428 { |
429 qq_data *qd; | 429 qq_data *qd; |
430 guint8 *cursor, *raw_data, *send_im_tail; | 430 guint8 *cursor, *raw_data, *send_im_tail; |
431 guint16 client_tag, normal_im_type; | 431 guint16 client_tag, normal_im_type; |
432 gint msg_len, raw_len, font_name_len, tail_len, bytes; | 432 gint msg_len, raw_len, font_name_len, tail_len, bytes; |
440 qd = (qq_data *) gc->proto_data; | 440 qd = (qq_data *) gc->proto_data; |
441 client_tag = QQ_CLIENT; | 441 client_tag = QQ_CLIENT; |
442 normal_im_type = QQ_NORMAL_IM_TEXT; | 442 normal_im_type = QQ_NORMAL_IM_TEXT; |
443 | 443 |
444 last = msg; | 444 last = msg; |
445 while (gaim_markup_find_tag("font", last, &start, &end, &attribs)) { | 445 while (purple_markup_find_tag("font", last, &start, &end, &attribs)) { |
446 tmp = g_datalist_get_data(&attribs, "size"); | 446 tmp = g_datalist_get_data(&attribs, "size"); |
447 if (tmp) { | 447 if (tmp) { |
448 if (font_size) | 448 if (font_size) |
449 g_free(font_size); | 449 g_free(font_size); |
450 font_size = g_strdup(tmp); | 450 font_size = g_strdup(tmp); |
464 | 464 |
465 g_datalist_clear(&attribs); | 465 g_datalist_clear(&attribs); |
466 last = end + 1; | 466 last = end + 1; |
467 } | 467 } |
468 | 468 |
469 if (gaim_markup_find_tag("b", msg, &start, &end, &attribs)) { | 469 if (purple_markup_find_tag("b", msg, &start, &end, &attribs)) { |
470 is_bold = TRUE; | 470 is_bold = TRUE; |
471 g_datalist_clear(&attribs); | 471 g_datalist_clear(&attribs); |
472 } | 472 } |
473 | 473 |
474 if (gaim_markup_find_tag("i", msg, &start, &end, &attribs)) { | 474 if (purple_markup_find_tag("i", msg, &start, &end, &attribs)) { |
475 is_italic = TRUE; | 475 is_italic = TRUE; |
476 g_datalist_clear(&attribs); | 476 g_datalist_clear(&attribs); |
477 } | 477 } |
478 | 478 |
479 if (gaim_markup_find_tag("u", msg, &start, &end, &attribs)) { | 479 if (purple_markup_find_tag("u", msg, &start, &end, &attribs)) { |
480 is_underline = TRUE; | 480 is_underline = TRUE; |
481 g_datalist_clear(&attribs); | 481 g_datalist_clear(&attribs); |
482 } | 482 } |
483 | 483 |
484 gaim_debug(GAIM_DEBUG_INFO, "QQ_MESG", "send mesg: %s\n", msg); | 484 purple_debug(PURPLE_DEBUG_INFO, "QQ_MESG", "send mesg: %s\n", msg); |
485 msg_filtered = gaim_markup_strip_html(msg); | 485 msg_filtered = purple_markup_strip_html(msg); |
486 msg_len = strlen(msg_filtered); | 486 msg_len = strlen(msg_filtered); |
487 now = time(NULL); | 487 now = time(NULL); |
488 | 488 |
489 font_name_len = (font_name) ? strlen(font_name) : DEFAULT_FONT_NAME_LEN; | 489 font_name_len = (font_name) ? strlen(font_name) : DEFAULT_FONT_NAME_LEN; |
490 tail_len = font_name_len + QQ_SEND_IM_AFTER_MSG_HEADER_LEN + 1; | 490 tail_len = font_name_len + QQ_SEND_IM_AFTER_MSG_HEADER_LEN + 1; |
533 _qq_show_packet("QQ_MESG raw", raw_data, cursor - raw_data); | 533 _qq_show_packet("QQ_MESG raw", raw_data, cursor - raw_data); |
534 | 534 |
535 if (bytes == raw_len) /* create packet OK */ | 535 if (bytes == raw_len) /* create packet OK */ |
536 qq_send_cmd(gc, QQ_CMD_SEND_IM, TRUE, 0, TRUE, raw_data, cursor - raw_data); | 536 qq_send_cmd(gc, QQ_CMD_SEND_IM, TRUE, 0, TRUE, raw_data, cursor - raw_data); |
537 else | 537 else |
538 gaim_debug(GAIM_DEBUG_ERROR, "QQ", | 538 purple_debug(PURPLE_DEBUG_ERROR, "QQ", |
539 "Fail creating send_im packet, expect %d bytes, build %d bytes\n", raw_len, bytes); | 539 "Fail creating send_im packet, expect %d bytes, build %d bytes\n", raw_len, bytes); |
540 | 540 |
541 if (font_color) | 541 if (font_color) |
542 g_free(font_color); | 542 g_free(font_color); |
543 if (font_size) | 543 if (font_size) |
545 g_free(send_im_tail); | 545 g_free(send_im_tail); |
546 g_free(msg_filtered); | 546 g_free(msg_filtered); |
547 } | 547 } |
548 | 548 |
549 /* parse the reply to send_im */ | 549 /* parse the reply to send_im */ |
550 void qq_process_send_im_reply(guint8 *buf, gint buf_len, GaimConnection *gc) | 550 void qq_process_send_im_reply(guint8 *buf, gint buf_len, PurpleConnection *gc) |
551 { | 551 { |
552 qq_data *qd; | 552 qq_data *qd; |
553 gint len; | 553 gint len; |
554 guint8 *data, *cursor, reply; | 554 guint8 *data, *cursor, reply; |
555 | 555 |
561 | 561 |
562 if (qq_crypt(DECRYPT, buf, buf_len, qd->session_key, data, &len)) { | 562 if (qq_crypt(DECRYPT, buf, buf_len, qd->session_key, data, &len)) { |
563 cursor = data; | 563 cursor = data; |
564 read_packet_b(data, &cursor, len, &reply); | 564 read_packet_b(data, &cursor, len, &reply); |
565 if (reply != QQ_SEND_IM_REPLY_OK) { | 565 if (reply != QQ_SEND_IM_REPLY_OK) { |
566 gaim_debug(GAIM_DEBUG_WARNING, "QQ", "Send IM fail\n"); | 566 purple_debug(PURPLE_DEBUG_WARNING, "QQ", "Send IM fail\n"); |
567 gaim_notify_error(gc, _("Server ACK"), _("Send IM fail\n"), NULL); | 567 purple_notify_error(gc, _("Server ACK"), _("Send IM fail\n"), NULL); |
568 } | 568 } |
569 else | 569 else |
570 gaim_debug(GAIM_DEBUG_INFO, "QQ", "IM ACK OK\n"); | 570 purple_debug(PURPLE_DEBUG_INFO, "QQ", "IM ACK OK\n"); |
571 } else { | 571 } else { |
572 gaim_debug(GAIM_DEBUG_ERROR, "QQ", "Error decrypt send im reply\n"); | 572 purple_debug(PURPLE_DEBUG_ERROR, "QQ", "Error decrypt send im reply\n"); |
573 } | 573 } |
574 } | 574 } |
575 | 575 |
576 /* I receive a message, mainly it is text msg, | 576 /* I receive a message, mainly it is text msg, |
577 * but we need to proess other types (group etc) */ | 577 * but we need to proess other types (group etc) */ |
578 void qq_process_recv_im(guint8 *buf, gint buf_len, guint16 seq, GaimConnection *gc) | 578 void qq_process_recv_im(guint8 *buf, gint buf_len, guint16 seq, PurpleConnection *gc) |
579 { | 579 { |
580 qq_data *qd; | 580 qq_data *qd; |
581 gint len, bytes; | 581 gint len, bytes; |
582 guint8 *data, *cursor; | 582 guint8 *data, *cursor; |
583 qq_recv_im_header *im_header; | 583 qq_recv_im_header *im_header; |
588 len = buf_len; | 588 len = buf_len; |
589 data = g_newa(guint8, len); | 589 data = g_newa(guint8, len); |
590 | 590 |
591 if (qq_crypt(DECRYPT, buf, buf_len, qd->session_key, data, &len)) { | 591 if (qq_crypt(DECRYPT, buf, buf_len, qd->session_key, data, &len)) { |
592 if (len < 16) { /* we need to ack with the first 16 bytes */ | 592 if (len < 16) { /* we need to ack with the first 16 bytes */ |
593 gaim_debug(GAIM_DEBUG_ERROR, "QQ", "IM is too short\n"); | 593 purple_debug(PURPLE_DEBUG_ERROR, "QQ", "IM is too short\n"); |
594 return; | 594 return; |
595 } else | 595 } else |
596 _qq_send_packet_recv_im_ack(gc, seq, data); | 596 _qq_send_packet_recv_im_ack(gc, seq, data); |
597 | 597 |
598 cursor = data; | 598 cursor = data; |
605 bytes += read_packet_data(data, &cursor, len, (guint8 *) & (im_header->sender_ip), 4); | 605 bytes += read_packet_data(data, &cursor, len, (guint8 *) & (im_header->sender_ip), 4); |
606 bytes += read_packet_w(data, &cursor, len, &(im_header->sender_port)); | 606 bytes += read_packet_w(data, &cursor, len, &(im_header->sender_port)); |
607 bytes += read_packet_w(data, &cursor, len, &(im_header->im_type)); | 607 bytes += read_packet_w(data, &cursor, len, &(im_header->im_type)); |
608 | 608 |
609 if (bytes != 20) { /* length of im_header */ | 609 if (bytes != 20) { /* length of im_header */ |
610 gaim_debug(GAIM_DEBUG_ERROR, "QQ", | 610 purple_debug(PURPLE_DEBUG_ERROR, "QQ", |
611 "Fail read recv IM header, expect 20 bytes, read %d bytes\n", bytes); | 611 "Fail read recv IM header, expect 20 bytes, read %d bytes\n", bytes); |
612 return; | 612 return; |
613 } | 613 } |
614 | 614 |
615 if (im_header->receiver_uid != qd->uid) { /* should not happen */ | 615 if (im_header->receiver_uid != qd->uid) { /* should not happen */ |
616 gaim_debug(GAIM_DEBUG_ERROR, "QQ", "IM to [%d], NOT me\n", im_header->receiver_uid); | 616 purple_debug(PURPLE_DEBUG_ERROR, "QQ", "IM to [%d], NOT me\n", im_header->receiver_uid); |
617 return; | 617 return; |
618 } | 618 } |
619 | 619 |
620 switch (im_header->im_type) { | 620 switch (im_header->im_type) { |
621 case QQ_RECV_IM_TO_BUDDY: | 621 case QQ_RECV_IM_TO_BUDDY: |
622 gaim_debug(GAIM_DEBUG_INFO, "QQ", | 622 purple_debug(PURPLE_DEBUG_INFO, "QQ", |
623 "IM from buddy [%d], I am in his/her buddy list\n", im_header->sender_uid); | 623 "IM from buddy [%d], I am in his/her buddy list\n", im_header->sender_uid); |
624 _qq_process_recv_normal_im(data, &cursor, len, gc); | 624 _qq_process_recv_normal_im(data, &cursor, len, gc); |
625 break; | 625 break; |
626 case QQ_RECV_IM_TO_UNKNOWN: | 626 case QQ_RECV_IM_TO_UNKNOWN: |
627 gaim_debug(GAIM_DEBUG_INFO, "QQ", | 627 purple_debug(PURPLE_DEBUG_INFO, "QQ", |
628 "IM from buddy [%d], I am a stranger to him/her\n", im_header->sender_uid); | 628 "IM from buddy [%d], I am a stranger to him/her\n", im_header->sender_uid); |
629 _qq_process_recv_normal_im(data, &cursor, len, gc); | 629 _qq_process_recv_normal_im(data, &cursor, len, gc); |
630 break; | 630 break; |
631 case QQ_RECV_IM_UNKNOWN_QUN_IM: | 631 case QQ_RECV_IM_UNKNOWN_QUN_IM: |
632 case QQ_RECV_IM_TEMP_QUN_IM: | 632 case QQ_RECV_IM_TEMP_QUN_IM: |
633 case QQ_RECV_IM_QUN_IM: | 633 case QQ_RECV_IM_QUN_IM: |
634 gaim_debug(GAIM_DEBUG_INFO, "QQ", "IM from group, internal_id [%d]\n", im_header->sender_uid); | 634 purple_debug(PURPLE_DEBUG_INFO, "QQ", "IM from group, internal_id [%d]\n", im_header->sender_uid); |
635 /* sender_uid is in fact internal_group_id */ | 635 /* sender_uid is in fact internal_group_id */ |
636 qq_process_recv_group_im(data, &cursor, len, im_header->sender_uid, gc, im_header->im_type); | 636 qq_process_recv_group_im(data, &cursor, len, im_header->sender_uid, gc, im_header->im_type); |
637 break; | 637 break; |
638 case QQ_RECV_IM_ADD_TO_QUN: | 638 case QQ_RECV_IM_ADD_TO_QUN: |
639 gaim_debug(GAIM_DEBUG_INFO, "QQ", | 639 purple_debug(PURPLE_DEBUG_INFO, "QQ", |
640 "IM from group, added by group internal_id [%d]\n", im_header->sender_uid); | 640 "IM from group, added by group internal_id [%d]\n", im_header->sender_uid); |
641 /* sender_uid is in fact internal_group_id | 641 /* sender_uid is in fact internal_group_id |
642 * we need this to create a dummy group and add to blist */ | 642 * we need this to create a dummy group and add to blist */ |
643 qq_process_recv_group_im_been_added(data, &cursor, len, im_header->sender_uid, gc); | 643 qq_process_recv_group_im_been_added(data, &cursor, len, im_header->sender_uid, gc); |
644 break; | 644 break; |
645 case QQ_RECV_IM_DEL_FROM_QUN: | 645 case QQ_RECV_IM_DEL_FROM_QUN: |
646 gaim_debug(GAIM_DEBUG_INFO, "QQ", | 646 purple_debug(PURPLE_DEBUG_INFO, "QQ", |
647 "IM from group, removed by group internal_ID [%d]\n", im_header->sender_uid); | 647 "IM from group, removed by group internal_ID [%d]\n", im_header->sender_uid); |
648 /* sender_uid is in fact internal_group_id */ | 648 /* sender_uid is in fact internal_group_id */ |
649 qq_process_recv_group_im_been_removed(data, &cursor, len, im_header->sender_uid, gc); | 649 qq_process_recv_group_im_been_removed(data, &cursor, len, im_header->sender_uid, gc); |
650 break; | 650 break; |
651 case QQ_RECV_IM_APPLY_ADD_TO_QUN: | 651 case QQ_RECV_IM_APPLY_ADD_TO_QUN: |
652 gaim_debug(GAIM_DEBUG_INFO, "QQ", | 652 purple_debug(PURPLE_DEBUG_INFO, "QQ", |
653 "IM from group, apply to join group internal_ID [%d]\n", im_header->sender_uid); | 653 "IM from group, apply to join group internal_ID [%d]\n", im_header->sender_uid); |
654 /* sender_uid is in fact internal_group_id */ | 654 /* sender_uid is in fact internal_group_id */ |
655 qq_process_recv_group_im_apply_join(data, &cursor, len, im_header->sender_uid, gc); | 655 qq_process_recv_group_im_apply_join(data, &cursor, len, im_header->sender_uid, gc); |
656 break; | 656 break; |
657 case QQ_RECV_IM_APPROVE_APPLY_ADD_TO_QUN: | 657 case QQ_RECV_IM_APPROVE_APPLY_ADD_TO_QUN: |
658 gaim_debug(GAIM_DEBUG_INFO, "QQ", | 658 purple_debug(PURPLE_DEBUG_INFO, "QQ", |
659 "IM for group system info, approved by group internal_id [%d]\n", | 659 "IM for group system info, approved by group internal_id [%d]\n", |
660 im_header->sender_uid); | 660 im_header->sender_uid); |
661 /* sender_uid is in fact internal_group_id */ | 661 /* sender_uid is in fact internal_group_id */ |
662 qq_process_recv_group_im_been_approved(data, &cursor, len, im_header->sender_uid, gc); | 662 qq_process_recv_group_im_been_approved(data, &cursor, len, im_header->sender_uid, gc); |
663 break; | 663 break; |
664 case QQ_RECV_IM_REJCT_APPLY_ADD_TO_QUN: | 664 case QQ_RECV_IM_REJCT_APPLY_ADD_TO_QUN: |
665 gaim_debug(GAIM_DEBUG_INFO, "QQ", | 665 purple_debug(PURPLE_DEBUG_INFO, "QQ", |
666 "IM for group system info, rejected by group internal_id [%d]\n", | 666 "IM for group system info, rejected by group internal_id [%d]\n", |
667 im_header->sender_uid); | 667 im_header->sender_uid); |
668 /* sender_uid is in fact internal_group_id */ | 668 /* sender_uid is in fact internal_group_id */ |
669 qq_process_recv_group_im_been_rejected(data, &cursor, len, im_header->sender_uid, gc); | 669 qq_process_recv_group_im_been_rejected(data, &cursor, len, im_header->sender_uid, gc); |
670 break; | 670 break; |
671 case QQ_RECV_IM_SYS_NOTIFICATION: | 671 case QQ_RECV_IM_SYS_NOTIFICATION: |
672 gaim_debug(GAIM_DEBUG_INFO, "QQ", | 672 purple_debug(PURPLE_DEBUG_INFO, "QQ", |
673 "IM from [%d], should be a system administrator\n", im_header->sender_uid); | 673 "IM from [%d], should be a system administrator\n", im_header->sender_uid); |
674 _qq_process_recv_sys_im(data, &cursor, len, gc); | 674 _qq_process_recv_sys_im(data, &cursor, len, gc); |
675 break; | 675 break; |
676 default: | 676 default: |
677 gaim_debug(GAIM_DEBUG_WARNING, "QQ", | 677 purple_debug(PURPLE_DEBUG_WARNING, "QQ", |
678 "IM from [%d], [0x%02x] %s is not processed\n", | 678 "IM from [%d], [0x%02x] %s is not processed\n", |
679 im_header->sender_uid, | 679 im_header->sender_uid, |
680 im_header->im_type, qq_get_recv_im_type_str(im_header->im_type)); | 680 im_header->im_type, qq_get_recv_im_type_str(im_header->im_type)); |
681 } | 681 } |
682 } else { | 682 } else { |
683 gaim_debug(GAIM_DEBUG_ERROR, "QQ", "Error decrypt rev im\n"); | 683 purple_debug(PURPLE_DEBUG_ERROR, "QQ", "Error decrypt rev im\n"); |
684 } | 684 } |
685 } | 685 } |