Mercurial > pidgin
diff src/protocols/qq/im.c @ 14021:ef8490f9e823
[gaim-migrate @ 16618]
Replaced all C++-style comments with C-style ones.
Cleaned up some comments and implemented a more consistent formatting scheme.
committer: Tailor Script <tailor@pidgin.im>
| author | Mark Huetsch <markhuetsch> |
|---|---|
| date | Wed, 02 Aug 2006 15:35:36 +0000 |
| parents | 2be9dfa9569b |
| children | 3cefea0bf4a2 |
line wrap: on
line diff
--- a/src/protocols/qq/im.c Wed Aug 02 13:37:13 2006 +0000 +++ b/src/protocols/qq/im.c Wed Aug 02 15:35:36 2006 +0000 @@ -20,71 +20,54 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -// START OF FILE -/*****************************************************************************/ -#include "conversation.h" // GaimConeversation -#include "debug.h" // gaim_debug -#include "internal.h" // strlen, _("get_text") -#include "cipher.h" // md5 functions //md5.h gfhuang -#include "notify.h" // gaim_notify_warning -#include "server.h" // serv_got_im -#include "util.h" // gaim_markup_find_tag, gaim_base16_decode +#include "conversation.h" +#include "debug.h" +#include "internal.h" +#include "cipher.h" +#include "notify.h" +#include "server.h" +#include "util.h" -#include "utils.h" // gen_ip_str -#include "packet_parse.h" // create_packet -#include "buddy_info.h" // qq_send_packet_get_info -#include "buddy_list.h" // qq_send_packet_get_buddies_online -#include "buddy_opt.h" // qq_add_buddy_by_recv_packet -#include "char_conv.h" // qq_to_utf8, qq_encode_to_gaim -#include "crypt.h" // qq_crypt -#include "group_im.h" // qq_send_packet_group_im -#include "header_info.h" // cmd alias +#include "buddy_info.h" +#include "buddy_list.h" +#include "buddy_opt.h" +#include "char_conv.h" +#include "crypt.h" +#include "group_im.h" +#include "header_info.h" #include "im.h" -#include "send_core.h" // qq_send_cmd -#include "send_core.h" // qq_data +#include "packet_parse.h" +#include "send_core.h" #include "send_file.h" +#include "utils.h" #define QQ_SEND_IM_REPLY_OK 0x00 #define DEFAULT_FONT_NAME_LEN 4 -// a debug function -void _qq_show_packet(gchar * desc, gchar * buf, gint len); +/* a debug function */ +void _qq_show_packet(gchar *desc, gchar *buf, gint len); enum { QQ_NORMAL_IM_TEXT = 0x000b, - QQ_NORMAL_IM_FILE_REQUEST_TCP = 0x0001, //gfhuang + QQ_NORMAL_IM_FILE_REQUEST_TCP = 0x0001, QQ_NORMAL_IM_FILE_APPROVE_TCP = 0x0003, QQ_NORMAL_IM_FILE_REJECT_TCP = 0x0005, QQ_NORMAL_IM_FILE_REQUEST_UDP = 0x0035, QQ_NORMAL_IM_FILE_APPROVE_UDP = 0x0037, QQ_NORMAL_IM_FILE_REJECT_UDP = 0x0039, QQ_NORMAL_IM_FILE_NOTIFY = 0x003b, - QQ_NORMAL_IM_FILE_PASV = 0x003f, // are you behind a firewall, gfhuang + QQ_NORMAL_IM_FILE_PASV = 0x003f, /* are you behind a firewall? */ QQ_NORMAL_IM_FILE_CANCEL = 0x0049, - QQ_NORMAL_IM_FILE_EX_REQUEST_UDP = 0x81, //gfhuang - QQ_NORMAL_IM_FILE_EX_REQUEST_ACCEPT = 0x83, //gfhuang - QQ_NORMAL_IM_FILE_EX_REQUEST_CANCEL = 0x85, //gfhuang - QQ_NORMAL_IM_FILE_EX_NOTIFY_IP = 0x87 //gfhuang -}; - - -enum { - QQ_RECV_SYS_IM_KICK_OUT = 0x01, + QQ_NORMAL_IM_FILE_EX_REQUEST_UDP = 0x81, + QQ_NORMAL_IM_FILE_EX_REQUEST_ACCEPT = 0x83, + QQ_NORMAL_IM_FILE_EX_REQUEST_CANCEL = 0x85, + QQ_NORMAL_IM_FILE_EX_NOTIFY_IP = 0x87 }; -/* -guint8 send_im_tail[QQ_SEND_IM_AFTER_MSG_LEN] = { - 0x00, // end of msg - 0x0a, // font attr, size=10, no bold, no italic, no underline - 0x00, // font color red 00-ff - 0x00, // font color green - 0x00, // font color blue - 0x00, // unknown - 0x86, 0x22, // encoding, 0x8622=GB, 0x0000=EN, define BIG5 support here - 0xcb, 0xce, 0xcc, 0xe5, 0x0d // font name, related, not fix length +enum { + QQ_RECV_SYS_IM_KICK_OUT = 0x01 }; -*/ typedef struct _qq_recv_im_header qq_recv_im_header; typedef struct _qq_recv_normal_im_text qq_recv_normal_im_text; @@ -92,7 +75,7 @@ typedef struct _qq_recv_normal_im_unprocessed qq_recv_normal_im_unprocessed; struct _qq_recv_normal_im_common { - // this is the common part of normal_text + /* this is the common part of normal_text */ guint16 sender_ver; guint32 sender_uid; guint32 receiver_uid; @@ -102,7 +85,7 @@ struct _qq_recv_normal_im_text { qq_recv_normal_im_common *common; - // now comes the part fo text only + /* now comes the part for text only */ guint16 msg_seq; guint32 send_time; guint8 unknown1; @@ -111,15 +94,15 @@ guint8 is_there_font_attr; guint8 unknown3[4]; guint8 msg_type; - guint8 *msg; // no fixed length, ends with 0x00 + guint8 *msg; /* no fixed length, ends with 0x00 */ guint8 *font_attr; gint font_attr_len; }; struct _qq_recv_normal_im_unprocessed { qq_recv_normal_im_common *common; - // now comes the part of unprocessed - guint8 *unknown; // no fixed length + /* now comes the part of unprocessed */ + guint8 *unknown; /* no fixed length */ gint length; }; @@ -135,9 +118,9 @@ #define QQ_SEND_IM_AFTER_MSG_HEADER_LEN 8 #define DEFAULT_FONT_NAME "\0xcb\0xce\0xcc\0xe5" -guint8 *qq_get_send_im_tail(const gchar * font_color, - const gchar * font_size, - const gchar * font_name, +guint8 *qq_get_send_im_tail(const gchar *font_color, + const gchar *font_size, + const gchar *font_name, gboolean is_bold, gboolean is_italic, gboolean is_underline, guint tail_len) { gchar *s1, *s2; @@ -178,7 +161,6 @@ * the length of odd number @_@ */ s2 = g_strdup_printf("%sH", s1); -// gaim_base16_decode(s2, &rgb); by gfhuang rgb = gaim_base16_decode(s2, NULL); g_free(s1); g_free(s2); @@ -190,12 +172,11 @@ send_im_tail[5] = 0x00; send_im_tail[6] = 0x86; - send_im_tail[7] = 0x22; // encoding, 0x8622=GB, 0x0000=EN, define BIG5 support here + send_im_tail[7] = 0x22; /* encoding, 0x8622=GB, 0x0000=EN, define BIG5 support here */ _qq_show_packet("QQ_MESG", send_im_tail, tail_len); return (guint8 *) send_im_tail; -} // qq_get_send_im_tail +} -/*****************************************************************************/ static const gchar *qq_get_recv_im_type_str(gint type) { switch (type) { @@ -220,35 +201,27 @@ case QQ_RECV_IM_REJCT_APPLY_ADD_TO_QUN: return "QQ_RECV_IM_REJCT_APPLY_ADD_TO_QUN"; case QQ_RECV_IM_TEMP_QUN_IM: - return "QQ_RECV_IM_TEMP_QUN_IM"; //gfhuang + return "QQ_RECV_IM_TEMP_QUN_IM"; case QQ_RECV_IM_QUN_IM: - return "QQ_RECV_IM_QUN_IM"; //gfhuang + return "QQ_RECV_IM_QUN_IM"; default: return "QQ_RECV_IM_UNKNOWN"; - } // switch type -} // qq_get_recv_im_type_str + } +} -/*****************************************************************************/ -// generate a md5 key using uid and session_key -gchar *_gen_session_md5(gint uid, gchar * session_key) +/* generate a md5 key using uid and session_key */ +gchar *_gen_session_md5(gint uid, gchar *session_key) { gchar *src, md5_str[QQ_KEY_LENGTH]; guint8 *cursor; -// md5_state_t ctx; //gfhuang GaimCipher *cipher; GaimCipherContext *context; - src = g_newa(gchar, 20); cursor = src; create_packet_dw(src, &cursor, uid); create_packet_data(src, &cursor, session_key, QQ_KEY_LENGTH); -/* gfhuang - md5_init(&ctx); - md5_append(&ctx, src, 20); - md5_finish(&ctx, (md5_byte_t *) md5_str); -*/ cipher = gaim_ciphers_find_cipher("md5"); context = gaim_cipher_context_new(cipher, NULL); gaim_cipher_context_append(context, src, 20); @@ -256,25 +229,24 @@ gaim_cipher_context_destroy(context); return g_memdup(md5_str, QQ_KEY_LENGTH); -} // _gen_session_md5 +} -/*****************************************************************************/ -// when we receive a message, -// we send an ACK which is the first 16 bytes of incoming packet -static void _qq_send_packet_recv_im_ack(GaimConnection * gc, guint16 seq, guint8 * data) { +/* when we receive a message, + * we send an ACK which is the first 16 bytes of incoming packet */ +static void _qq_send_packet_recv_im_ack(GaimConnection *gc, guint16 seq, guint8 *data) +{ qq_send_cmd(gc, QQ_CMD_RECV_IM, FALSE, seq, FALSE, data, 16); -} // _qq_send_packet_recv_im_ack +} -/*****************************************************************************/ -// read the common parts of the normal_im, -// returns the bytes read if succeed, or -1 if there is any error -static gint _qq_normal_im_common_read(guint8 * data, guint8 ** cursor, gint len, qq_recv_normal_im_common * common) { - +/* read the common parts of the normal_im, + * returns the bytes read if succeed, or -1 if there is any error */ +static gint _qq_normal_im_common_read(guint8 *data, guint8 **cursor, gint len, qq_recv_normal_im_common *common) +{ gint bytes; g_return_val_if_fail(data != NULL && len != 0 && common != NULL, -1); bytes = 0; - // now push data into common header + /* now push data into common header */ bytes += read_packet_w(data, cursor, len, &(common->sender_ver)); bytes += read_packet_dw(data, cursor, len, &(common->sender_uid)); bytes += read_packet_dw(data, cursor, len, &(common->receiver_uid)); @@ -285,18 +257,18 @@ bytes += read_packet_w(data, cursor, len, &(common->normal_im_type)); - if (bytes != 28) { // read common place fail + if (bytes != 28) { /* read common place fail */ gaim_debug(GAIM_DEBUG_ERROR, "QQ", "Expect 28 bytes, read %d bytes\n", bytes); return -1; - } // if bytes + } return bytes; -} // _qq_normal_im_common_read +} -/*****************************************************************************/ -// process received normal text IM +/* process received normal text IM */ static void _qq_process_recv_normal_im_text - (guint8 * data, guint8 ** cursor, gint len, qq_recv_normal_im_common * common, GaimConnection * gc) { + (guint8 *data, guint8 **cursor, gint len, qq_recv_normal_im_common *common, GaimConnection *gc) +{ guint16 gaim_msg_type; gchar *name; gchar *msg_with_gaim_smiley; @@ -307,7 +279,7 @@ g_return_if_fail(gc != NULL && gc->proto_data != NULL && common != NULL); qd = (qq_data *) gc->proto_data; - // now it is QQ_NORMAL_IM_TEXT + /* now it is QQ_NORMAL_IM_TEXT */ if (*cursor >= (data + len - 1)) { gaim_debug(GAIM_DEBUG_WARNING, "QQ", "Received normal IM text is empty\n"); return; @@ -316,36 +288,37 @@ im_text->common = common; - // push data into im_text + /* push data into im_text */ read_packet_w(data, cursor, len, &(im_text->msg_seq)); read_packet_dw(data, cursor, len, &(im_text->send_time)); read_packet_b(data, cursor, len, &(im_text->unknown1)); read_packet_b(data, cursor, len, &(im_text->sender_icon)); read_packet_data(data, cursor, len, (guint8 *) & (im_text->unknown2), 3); read_packet_b(data, cursor, len, &(im_text->is_there_font_attr)); - ////////////////////// - // from lumaqq for unknown3, gfhuang - // totalFragments = buf.get() & 255; - // fragmentSequence = buf.get() & 255; - // messageId = buf.getChar(); + /** + * from lumaqq for unknown3 + * totalFragments = buf.get() & 255; + * fragmentSequence = buf.get() & 255; + * messageId = buf.getChar(); + */ read_packet_data(data, cursor, len, (guint8 *) & (im_text->unknown3), 4); read_packet_b(data, cursor, len, &(im_text->msg_type)); - // we need to check if this is auto-reply - // QQ2003iii build 0304, returns the msg without font_attr - // even the is_there_font_attr shows 0x01, and msg does not ends with 0x00 + /* we need to check if this is auto-reply + * QQ2003iii build 0304, returns the msg without font_attr + * even the is_there_font_attr shows 0x01, and msg does not ends with 0x00 */ if (im_text->msg_type == QQ_IM_AUTO_REPLY) { - im_text->is_there_font_attr = 0x00; // indeed there is no this flag + im_text->is_there_font_attr = 0x00; /* indeed there is no this flag */ im_text->msg = g_strndup(*cursor, data + len - *cursor); - } else { // it is normal mesasge + } else { /* it is normal mesasge */ if (im_text->is_there_font_attr) { im_text->msg = g_strdup(*cursor); *cursor += strlen(im_text->msg) + 1; im_text->font_attr_len = data + len - *cursor; im_text->font_attr = g_memdup(*cursor, im_text->font_attr_len); - } else // not im_text->is_there_font_attr + } else /* not im_text->is_there_font_attr */ im_text->msg = g_strndup(*cursor, data + len - *cursor); - } // if im_text->msg_type + } /* if im_text->msg_type */ _qq_show_packet("QQ_MESG recv", data, *cursor - data); name = uid_to_gaim_name(common->sender_uid); @@ -360,9 +333,9 @@ im_text->font_attr_len, msg_with_gaim_smiley) : qq_to_utf8(msg_with_gaim_smiley, QQ_CHARSET_DEFAULT); - // send encoded to gaim, note that we use im_text->send_time, - // not the time we receive the message - // as it may have been dealyed when I am not online. + /* send encoded to gaim, note that we use im_text->send_time, + * not the time we receive the message + * as it may have been dealyed when I am not online. */ serv_got_im(gc, name, msg_utf8_encoded, gaim_msg_type, (time_t) im_text->send_time); g_free(msg_utf8_encoded); @@ -371,11 +344,10 @@ g_free(im_text->msg); if (im_text->is_there_font_attr) g_free(im_text->font_attr); -} // _qq_process_recv_normal_im_text +} -/*****************************************************************************/ -// it is a normal IM, maybe text or video request -static void _qq_process_recv_normal_im(guint8 * data, guint8 ** cursor, gint len, GaimConnection * gc) +/* it is a normal IM, maybe text or video request */ +static void _qq_process_recv_normal_im(guint8 *data, guint8 **cursor, gint len, GaimConnection *gc) { gint bytes; qq_recv_normal_im_common *common; @@ -396,7 +368,7 @@ gaim_debug (GAIM_DEBUG_ERROR, "QQ", "Fail read the common part of normal IM\n"); return; - } // if bytes + } switch (common->normal_im_type) { case QQ_NORMAL_IM_TEXT: @@ -433,7 +405,7 @@ im_unprocessed->common = common; im_unprocessed->unknown = *cursor; im_unprocessed->length = data + len - *cursor; - // a simple process here, maybe more later + /* a simple process here, maybe more later */ gaim_debug (GAIM_DEBUG_WARNING, "QQ", "Normal IM, unprocessed type [0x%04x]\n", common->normal_im_type); @@ -443,58 +415,14 @@ im_unprocessed->length)); g_free (common->session_md5); return; - } // normal_im_type + } g_free (common->session_md5); -} // qq_process_recv_normal_im - - -/* -static void _qq_process_recv_normal_im(guint8 * data, guint8 ** cursor, gint len, GaimConnection * gc) { - gint bytes; - qq_recv_normal_im_common *common; - qq_recv_normal_im_unprocessed *im_unprocessed; - - g_return_if_fail(data != NULL && len != 0); - - if (*cursor >= (data + len - 1)) { - gaim_debug(GAIM_DEBUG_WARNING, "QQ", "Received normal IM is empty\n"); - return; - } else - common = g_newa(qq_recv_normal_im_common, 1); - - bytes = _qq_normal_im_common_read(data, cursor, len, common); - if (bytes < 0) { - gaim_debug(GAIM_DEBUG_ERROR, "QQ", "Fail read the common part of normal IM\n"); - return; - } // if bytes +} - if (common->normal_im_type != QQ_NORMAL_IM_TEXT) { - im_unprocessed = g_newa(qq_recv_normal_im_unprocessed, 1); - im_unprocessed->common = common; - im_unprocessed->unknown = *cursor; - im_unprocessed->length = data + len - *cursor; - // a simple process here, maybe more later - gaim_debug(GAIM_DEBUG_WARNING, "QQ", "Normal IM, unprocessed type [0x%04x]\n", common->normal_im_type); - gaim_debug(GAIM_DEBUG_WARNING, "QQ", - "Dump unknown part.\n%s", hex_dump_to_str(im_unprocessed->unknown, im_unprocessed->length)); - g_free(common->session_md5); - return; - } else { // normal_im_type == QQ_NORMAL_IM_TEXT - gaim_debug(GAIM_DEBUG_INFO, - "QQ", - "Normal IM, text type:\n [%d] => [%d], src: %s\n", - common->sender_uid, common->receiver_uid, qq_get_source_str(common->sender_ver)); - _qq_process_recv_normal_im_text(data, cursor, len, common, gc); - } // normal_im_type - - g_free(common->session_md5); -} // qq_process_recv_normal_im -*/ - -/*****************************************************************************/ -// process im from system administrator -static void _qq_process_recv_sys_im(guint8 * data, guint8 ** cursor, gint data_len, GaimConnection * gc) { +/* process im from system administrator */ +static void _qq_process_recv_sys_im(guint8 *data, guint8 **cursor, gint data_len, GaimConnection *gc) +{ gint len; guint8 reply; gchar **segments, *msg_utf8; @@ -516,12 +444,11 @@ gaim_debug(GAIM_DEBUG_WARNING, "QQ", "We are kicked out by QQ server\n"); msg_utf8 = qq_to_utf8(segments[1], QQ_CHARSET_DEFAULT); gaim_notify_warning(gc, NULL, _("System Message"), msg_utf8); - -} // _qq_process_recv_sys_im +} -/*****************************************************************************/ -// send an IM to to_uid -void qq_send_packet_im(GaimConnection * gc, guint32 to_uid, gchar * msg, gint type) { +/* send an IM to to_uid */ +void qq_send_packet_im(GaimConnection *gc, guint32 to_uid, gchar *msg, gint type) +{ qq_data *qd; guint8 *cursor, *raw_data; guint16 client_tag, normal_im_type; @@ -594,38 +521,38 @@ cursor = raw_data; bytes = 0; - //000-003: receiver uid + /* 000-003: receiver uid */ bytes += create_packet_dw(raw_data, &cursor, qd->uid); - //004-007: sender uid + /* 004-007: sender uid */ bytes += create_packet_dw(raw_data, &cursor, to_uid); - //008-009: sender client version + /* 008-009: sender client version */ bytes += create_packet_w(raw_data, &cursor, client_tag); - //010-013: receiver uid + /* 010-013: receiver uid */ bytes += create_packet_dw(raw_data, &cursor, qd->uid); - //014-017: sender uid + /* 014-017: sender uid */ bytes += create_packet_dw(raw_data, &cursor, to_uid); - //018-033: md5 of (uid+session_key) + /* 018-033: md5 of (uid+session_key) */ bytes += create_packet_data(raw_data, &cursor, md5, 16); - //034-035: message type + /* 034-035: message type */ bytes += create_packet_w(raw_data, &cursor, normal_im_type); - //036-037: sequence number + /* 036-037: sequence number */ bytes += create_packet_w(raw_data, &cursor, qd->send_seq); - //038-041: send time + /* 038-041: send time */ bytes += create_packet_dw(raw_data, &cursor, (guint32) now); - //042-042: always 0x00 + /* 042-042: always 0x00 */ bytes += create_packet_b(raw_data, &cursor, 0x00); - //043-043: sender icon + /* 043-043: sender icon */ bytes += create_packet_b(raw_data, &cursor, qd->my_icon); - //044-046: always 0x00 + /* 044-046: always 0x00 */ bytes += create_packet_w(raw_data, &cursor, 0x0000); bytes += create_packet_b(raw_data, &cursor, 0x00); - //047-047: we use font attr + /* 047-047: we use font attr */ bytes += create_packet_b(raw_data, &cursor, 0x01); - //048-051: always 0x00 + /* 048-051: always 0x00 */ bytes += create_packet_dw(raw_data, &cursor, 0x00000000); - //052-052: text message type (normal/auto-reply) + /* 052-052: text message type (normal/auto-reply) */ bytes += create_packet_b(raw_data, &cursor, type); - //053- : msg ends with 0x00 + /* 053- : msg ends with 0x00 */ bytes += create_packet_data(raw_data, &cursor, msg_filtered, msg_len); guint8 *send_im_tail = qq_get_send_im_tail(font_color, font_size, font_name, is_bold, is_italic, is_underline, tail_len); @@ -634,7 +561,7 @@ _qq_show_packet("QQ_MESG raw", raw_data, cursor - raw_data); - if (bytes == raw_len) // create packet OK + if (bytes == raw_len) /* create packet OK */ qq_send_cmd(gc, QQ_CMD_SEND_IM, TRUE, 0, TRUE, raw_data, cursor - raw_data); else gaim_debug(GAIM_DEBUG_ERROR, "QQ", @@ -646,11 +573,10 @@ g_free(font_size); g_free(send_im_tail); g_free(msg_filtered); -} // qq_send_packet_im +} -/*****************************************************************************/ -// parse the reply to send_im -void qq_process_send_im_reply(guint8 * buf, gint buf_len, GaimConnection * gc) +/* parse the reply to send_im */ +void qq_process_send_im_reply(guint8 *buf, gint buf_len, GaimConnection *gc) { qq_data *qd; gint len; @@ -669,20 +595,18 @@ if (reply != QQ_SEND_IM_REPLY_OK) { gaim_debug(GAIM_DEBUG_WARNING, "QQ", "Send IM fail\n"); gaim_notify_error(gc, _("Server ACK"), _("Send IM fail\n"), NULL); -// serv_got_im(gc, name, "Server ACK: Send IM fail\n", GAIM_MESSAGE_ERROR, time(NULL)); } else gaim_debug(GAIM_DEBUG_INFO, "QQ", "IM ACK OK\n"); } else { gaim_debug(GAIM_DEBUG_ERROR, "QQ", "Error decrypt send im reply\n"); } - -} // qq_process_send_im_reply +} -/*****************************************************************************/ -// I receive a message, mainly it is text msg, -// but we need to proess other types (group etc) -void qq_process_recv_im(guint8 * buf, gint buf_len, guint16 seq, GaimConnection * gc) { +/* I receive a message, mainly it is text msg, + * but we need to proess other types (group etc) */ +void qq_process_recv_im(guint8 *buf, gint buf_len, guint16 seq, GaimConnection *gc) +{ qq_data *qd; gint len, bytes; guint8 *data, *cursor; @@ -696,7 +620,7 @@ data = g_newa(guint8, len); if (qq_crypt(DECRYPT, buf, buf_len, qd->session_key, data, &len)) { - if (len < 16) { // we need to ack with the first 16 bytes + if (len < 16) { /* we need to ack with the first 16 bytes */ gaim_debug(GAIM_DEBUG_ERROR, "QQ", "IM is too short\n"); return; } else @@ -708,21 +632,21 @@ bytes += read_packet_dw(data, &cursor, len, &(im_header->sender_uid)); bytes += read_packet_dw(data, &cursor, len, &(im_header->receiver_uid)); bytes += read_packet_dw(data, &cursor, len, &(im_header->server_im_seq)); - // if the message is delivered via server, it is server IP/port + /* if the message is delivered via server, it is server IP/port */ bytes += read_packet_data(data, &cursor, len, (guint8 *) & (im_header->sender_ip), 4); bytes += read_packet_w(data, &cursor, len, &(im_header->sender_port)); bytes += read_packet_w(data, &cursor, len, &(im_header->im_type)); - if (bytes != 20) { // length of im_header + if (bytes != 20) { /* length of im_header */ gaim_debug(GAIM_DEBUG_ERROR, "QQ", "Fail read recv IM header, expect 20 bytes, read %d bytes\n", bytes); return; - } // if bytes + } - if (im_header->receiver_uid != qd->uid) { // should not happen + if (im_header->receiver_uid != qd->uid) { /* should not happen */ gaim_debug(GAIM_DEBUG_ERROR, "QQ", "IM to [%d], NOT me\n", im_header->receiver_uid); return; - } // if im_header->receiver_uid + } switch (im_header->im_type) { case QQ_RECV_IM_TO_BUDDY: @@ -739,40 +663,40 @@ case QQ_RECV_IM_TEMP_QUN_IM: case QQ_RECV_IM_QUN_IM: gaim_debug(GAIM_DEBUG_INFO, "QQ", "IM from group, internal_id [%d]\n", im_header->sender_uid); - // sender_uid is in fact internal_group_id + /* sender_uid is in fact internal_group_id */ qq_process_recv_group_im(data, &cursor, len, im_header->sender_uid, gc, im_header->im_type); break; case QQ_RECV_IM_ADD_TO_QUN: gaim_debug(GAIM_DEBUG_INFO, "QQ", "IM from group, added by group internal_id [%d]\n", im_header->sender_uid); - // sender_uid is in fact internal_group_id - // we need this to create a dummy group and add to blist + /* sender_uid is in fact internal_group_id + * we need this to create a dummy group and add to blist */ qq_process_recv_group_im_been_added(data, &cursor, len, im_header->sender_uid, gc); break; case QQ_RECV_IM_DEL_FROM_QUN: gaim_debug(GAIM_DEBUG_INFO, "QQ", "IM from group, removed by group internal_ID [%d]\n", im_header->sender_uid); - // sender_uid is in fact internal_group_id + /* sender_uid is in fact internal_group_id */ qq_process_recv_group_im_been_removed(data, &cursor, len, im_header->sender_uid, gc); break; case QQ_RECV_IM_APPLY_ADD_TO_QUN: gaim_debug(GAIM_DEBUG_INFO, "QQ", "IM from group, apply to join group internal_ID [%d]\n", im_header->sender_uid); - // sender_uid is in fact internal_group_id + /* sender_uid is in fact internal_group_id */ qq_process_recv_group_im_apply_join(data, &cursor, len, im_header->sender_uid, gc); break; case QQ_RECV_IM_APPROVE_APPLY_ADD_TO_QUN: gaim_debug(GAIM_DEBUG_INFO, "QQ", "IM for group system info, approved by group internal_id [%d]\n", im_header->sender_uid); - // sender_uid is in fact internal_group_id + /* sender_uid is in fact internal_group_id */ qq_process_recv_group_im_been_approved(data, &cursor, len, im_header->sender_uid, gc); break; case QQ_RECV_IM_REJCT_APPLY_ADD_TO_QUN: gaim_debug(GAIM_DEBUG_INFO, "QQ", "IM for group system info, rejected by group internal_id [%d]\n", im_header->sender_uid); - // sender_uid is in fact internal_group_id + /* sender_uid is in fact internal_group_id */ qq_process_recv_group_im_been_rejected(data, &cursor, len, im_header->sender_uid, gc); break; case QQ_RECV_IM_SYS_NOTIFICATION: @@ -785,11 +709,8 @@ "IM from [%d], [0x%02x] %s is not processed\n", im_header->sender_uid, im_header->im_type, qq_get_recv_im_type_str(im_header->im_type)); - } // switch - } else + } + } else { gaim_debug(GAIM_DEBUG_ERROR, "QQ", "Error decrypt rev im\n"); - -} // qq_process_recv_im - -/*****************************************************************************/ -// END OF FILE + } +}
