From: <mar...@us...> - 2006-08-02 15:39:51
|
Revision: 16618 Author: markhuetsch Date: 2006-08-02 08:35:36 -0700 (Wed, 02 Aug 2006) ViewCVS: http://svn.sourceforge.net/gaim/?rev=16618&view=rev Log Message: ----------- Replaced all C++-style comments with C-style ones. Cleaned up some comments and implemented a more consistent formatting scheme. Modified Paths: -------------- trunk/src/protocols/qq/buddy_info.c trunk/src/protocols/qq/buddy_info.h trunk/src/protocols/qq/buddy_list.c trunk/src/protocols/qq/buddy_list.h trunk/src/protocols/qq/buddy_opt.c trunk/src/protocols/qq/buddy_opt.h trunk/src/protocols/qq/buddy_status.c trunk/src/protocols/qq/buddy_status.h trunk/src/protocols/qq/char_conv.c trunk/src/protocols/qq/char_conv.h trunk/src/protocols/qq/crypt.c trunk/src/protocols/qq/crypt.h trunk/src/protocols/qq/file_trans.c trunk/src/protocols/qq/file_trans.h trunk/src/protocols/qq/group.c trunk/src/protocols/qq/group.h trunk/src/protocols/qq/group_conv.c trunk/src/protocols/qq/group_conv.h trunk/src/protocols/qq/group_find.c trunk/src/protocols/qq/group_find.h trunk/src/protocols/qq/group_free.c trunk/src/protocols/qq/group_free.h trunk/src/protocols/qq/group_hash.c trunk/src/protocols/qq/group_hash.h trunk/src/protocols/qq/group_im.c trunk/src/protocols/qq/group_im.h trunk/src/protocols/qq/group_info.c trunk/src/protocols/qq/group_info.h trunk/src/protocols/qq/group_join.c trunk/src/protocols/qq/group_join.h trunk/src/protocols/qq/group_misc.c trunk/src/protocols/qq/group_misc.h trunk/src/protocols/qq/group_network.c trunk/src/protocols/qq/group_network.h trunk/src/protocols/qq/group_opt.c trunk/src/protocols/qq/group_opt.h trunk/src/protocols/qq/group_search.c trunk/src/protocols/qq/group_search.h trunk/src/protocols/qq/header_info.c trunk/src/protocols/qq/header_info.h trunk/src/protocols/qq/im.c trunk/src/protocols/qq/im.h trunk/src/protocols/qq/ip_location.c trunk/src/protocols/qq/ip_location.h trunk/src/protocols/qq/keep_alive.c trunk/src/protocols/qq/keep_alive.h trunk/src/protocols/qq/login_logout.c trunk/src/protocols/qq/login_logout.h trunk/src/protocols/qq/packet_parse.c trunk/src/protocols/qq/packet_parse.h trunk/src/protocols/qq/qq.c trunk/src/protocols/qq/qq.h trunk/src/protocols/qq/qq_proxy.c trunk/src/protocols/qq/qq_proxy.h trunk/src/protocols/qq/recv_core.c trunk/src/protocols/qq/recv_core.h trunk/src/protocols/qq/send_core.c trunk/src/protocols/qq/send_core.h trunk/src/protocols/qq/send_file.c trunk/src/protocols/qq/send_file.h trunk/src/protocols/qq/sendqueue.c trunk/src/protocols/qq/sendqueue.h trunk/src/protocols/qq/sys_msg.c trunk/src/protocols/qq/sys_msg.h trunk/src/protocols/qq/udp_proxy_s5.c trunk/src/protocols/qq/udp_proxy_s5.h trunk/src/protocols/qq/utils.c Modified: trunk/src/protocols/qq/buddy_info.c =================================================================== --- trunk/src/protocols/qq/buddy_info.c 2006-08-02 13:37:13 UTC (rev 16617) +++ trunk/src/protocols/qq/buddy_info.c 2006-08-02 15:35:36 UTC (rev 16618) @@ -20,34 +20,33 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include "internal.h" // strlen, _("get_text) -#include "debug.h" // gaim_debug -#include "notify.h" // gaim_notify -#include "request.h" // gaim_request_fields_new +#include "internal.h" +#include "debug.h" +#include "notify.h" +#include "request.h" -#include "utils.h" // uid_to_gaim_name -#include "packet_parse.h" // MAX_PACKET_SIZE -#include "buddy_info.h" // -#include "char_conv.h" // qq_to_utf8 -#include "crypt.h" // qq_crypt -#include "header_info.h" // cmd alias -#include "keep_alive.h" // qq_update_buddy_contact -#include "send_core.h" // qq_send_cmd +#include "utils.h" +#include "packet_parse.h" +#include "buddy_info.h" +#include "char_conv.h" +#include "crypt.h" +#include "header_info.h" +#include "keep_alive.h" +#include "send_core.h" -// Below is all of the information necessary to reconstruct the various -// information fields that one can set in the official client. When we need -// to know about a specific field (e.g., should "city" be a choice -// or text field?), we can simply look it up from the template. Note that -// there are a number of unidentified fields. - +/* Below is all of the information necessary to reconstruct the various + * information fields that one can set in the official client. When we need + * to know about a specific field (e.g., should "city" be a choice + * or text field?), we can simply look it up from the template. Note that + * there are a number of unidentified fields. */ typedef struct _info_field { gchar *title; - gchar *id; // used by gaim_request fields + gchar *id; /* used by gaim_request fields */ gint pos; gchar *group; - gint group_pos; // for display order in the UI - gint choice; // indicates which character array contains the choices - gboolean customizable; // whether a user can enter any text as a value, regardless of choice arrays + gint group_pos; /* for display order in the UI */ + gint choice; /* indicates which character array contains the choices */ + gboolean customizable; /* whether a user can enter any text as a value, regardless of choice arrays */ gchar *value; } info_field; @@ -89,11 +88,11 @@ { N_("Blood Type"), "blood", 34, QQ_EXTRA_INFO, 3, QQ_BLOOD, FALSE, NULL }, { "qq_show", "qq_show", 35, QQ_MISC, 15, QQ_NO_CHOICE, TRUE, NULL }, { "unknown6", "unknown6", 36, QQ_MISC, 16, QQ_NO_CHOICE, TRUE, NULL }, - { NULL, NULL, 0, NULL, 0, 0, 0, NULL } //NULL termination + { NULL, NULL, 0, NULL, 0, 0, 0, NULL } }; -//TODO: translate these arrays to their English equivalents -// and move these characters to the zh_CN po file +/* TODO: translate these arrays to their English equivalents + * and move these characters to the zh_CN po file */ static const gchar *horoscope_names[] = { "-", "水瓶座", "双鱼座", "牡羊座", "金牛座", "双子座", "巨蟹座", "狮子座", "处女座", "天秤座", @@ -159,10 +158,10 @@ occupation_names }; -/*************** info and info_field methods *****************/ +/************************ info and info_field methods ************************/ -// Given an id, return the template for that field. -// Returns NULL if the id is not found. +/* Given an id, return the template for that field. + * Returns NULL if the id is not found. */ static const info_field *info_field_get_template(const gchar *id) { const info_field *cur_field; @@ -171,7 +170,8 @@ cur_field = info_template_data; cur_id = cur_field->id; while(cur_id != NULL) { - if (g_ascii_strcasecmp(cur_id, id) == 0) return cur_field; + if (g_ascii_strcasecmp(cur_id, id) == 0) + return cur_field; cur_field++; cur_id = cur_field->id; } @@ -179,7 +179,7 @@ return NULL; } -// info_fields are compared by their group positions +/* info_fields are compared by their group positions */ static gint info_field_compare(gconstpointer a, gconstpointer b) { return ((info_field *) a)->group_pos - ((info_field *) b)->group_pos; @@ -191,9 +191,9 @@ g_free(i); } -// Parses the info_template_data above and returns a newly-allocated list -// containing the desired fields from segments. This list is ordered by -// group_pos. +/* Parses the info_template_data above and returns a newly-allocated list + * containing the desired fields from segments. This list is ordered by + * group_pos. */ static GList *info_get_group(const gchar **info, const gchar *group_name) { const info_field *cur; @@ -213,25 +213,27 @@ return group; } -// determines if the given text value and choice group require -// a lookup from the choice arrays +/* Determines if the given text value and choice group require + * a lookup from the choice arrays. */ static gboolean is_valid_index(gchar *value, gint choice) { gint len, i; if (choice == 0) return FALSE; len = strlen(value); - // the server sends us an ascii index and none of the arrays has more than 99 - // elements + /* the server sends us an ascii index and none of the arrays has more than 99 + * elements */ if (len > 3 || len == 0) return FALSE; for (i = 0; i < len; i++) - if (!g_ascii_isdigit(value[i])) return FALSE; + if (!g_ascii_isdigit(value[i])) + return FALSE; i = atoi(value); - if (i < 0 || i >= choice_sizes[choice]) return FALSE; + if (i < 0 || i >= choice_sizes[choice]) + return FALSE; return TRUE; } -// formats a field for printing +/* formats a field for printing */ static void append_field_to_str(gpointer field, gpointer str) { info_field *f; @@ -250,7 +252,7 @@ info_field_free(f); } -// formats a group of information for printing +/* formats a group of information for printing */ static void append_group_to_str(GString *str, const gchar *group_name, const gchar **info) { GList *group; @@ -262,8 +264,8 @@ g_string_append_printf(str, "<br />"); } -// takes a contact_info struct and outputs the appropriate fields in -// a printable format for our upcoming call to gaim_notify_userinfo +/* Takes a contact_info struct and outputs the appropriate fields in + * a printable format for our upcoming call to gaim_notify_userinfo. */ static GString *info_to_str(const gchar **info) { GString *info_text; @@ -272,14 +274,14 @@ append_group_to_str(info_text, QQ_MAIN_INFO, info); append_group_to_str(info_text, QQ_EXTRA_INFO, info); append_group_to_str(info_text, QQ_PERSONAL_INTRO, info); - //if (QQ_DEBUG) append_group_to_str(info_text, QQ_MISC, info); + /* append_group_to_str(info_text, QQ_MISC, info); */ return info_text; } -/*************** packets and UI management *****************/ +/************************ packets and UI management **************************/ -// send a packet to get detailed information of uid +/* send a packet to get detailed information of uid */ void qq_send_packet_get_info(GaimConnection * gc, guint32 uid, gboolean show_window) { qq_data *qd; @@ -301,8 +303,8 @@ g_free(uid_str); } -// set up the fields requesting personal information and send a get_info packet -// for myself +/* set up the fields requesting personal information and send a get_info packet + * for myself */ void qq_prepare_modify_info(GaimConnection *gc) { qq_data *qd; @@ -311,14 +313,15 @@ qd = (qq_data *) gc->proto_data; qq_send_packet_get_info(gc, qd->uid, FALSE); - // traverse backwards so we get the most recent info_query + /* traverse backwards so we get the most recent info_query */ for (ql = g_list_last(qd->info_query); ql != NULL; ql = g_list_previous(ql)) { query = ql->data; - if (query->uid == qd->uid) query->modify_info = TRUE; + if (query->uid == qd->uid) + query->modify_info = TRUE; } } -// send packet to modify personal information +/* send packet to modify personal information */ void qq_send_packet_modify_info(GaimConnection *gc, contact_info *info) { gchar *info_field[QQ_CONTACT_FIELDS]; @@ -335,7 +338,7 @@ create_packet_b(raw_data, &cursor, bar); - // important!, skip the first uid entry + /* important!, skip the first uid entry */ for (i = 1; i < QQ_CONTACT_FIELDS; i++) { create_packet_b(raw_data, &cursor, bar); create_packet_data(raw_data, &cursor, (guint8 *) info_field[i], strlen(info_field[i])); @@ -357,8 +360,8 @@ g_free(mid); } -// runs through all of the fields in the modify info UI and put -// their values into the outgoing packet +/* Runs through all of the fields in the modify info UI and puts + * their values into the outgoing packet. */ static void parse_field(gpointer field, gpointer outgoing_info) { GaimRequestField *f; @@ -370,17 +373,19 @@ segments = (gchar **) outgoing_info; id = gaim_request_field_get_id(f); ft = info_field_get_template(id); - if (ft->choice && !ft->customizable) + if (ft->choice && !ft->customizable) { value = g_strdup_printf("%d", gaim_request_field_choice_get_value(f)); - else { + } else { value = (gchar *) gaim_request_field_string_get_value(f); - if (value == NULL) value = g_strdup("-"); - else value = utf8_to_qq(value, QQ_CHARSET_DEFAULT); + if (value == NULL) + value = g_strdup("-"); + else + value = utf8_to_qq(value, QQ_CHARSET_DEFAULT); } segments[ft->pos] = value; } -// dumps the uneditable information straight into the outgoing packet +/* dumps the uneditable information straight into the outgoing packet */ static void parse_misc_field(gpointer field, gpointer outgoing_info) { info_field *f; @@ -392,8 +397,8 @@ info_field_free(f); } -// runs through all of the information fields and copies them into an -// outgoing packet, then sends that packet +/* Runs through all of the information fields and copies them into an + * outgoing packet, then sends that packet. */ static void modify_info_ok_cb(modify_info_data *mid, GaimRequestFields *fields) { GaimConnection *gc; @@ -424,9 +429,9 @@ g_free(info_field[i]); } -// Sets up the display for one group of information. This includes -// managing which fields in the UI should be textfields and -// which choices, and also mapping ints to choice values when appropriate. +/* Sets up the display for one group of information. This includes + * managing which fields in the UI should be textfields and + * which choices, and also mapping ints to choice values when appropriate. */ static void setup_group(gpointer field, gpointer group) { info_field *f; @@ -449,7 +454,9 @@ if (valid_index) { index = atoi(f->value); value = (gchar *) choices[choice][index]; - } else value = qq_to_utf8(f->value, QQ_CHARSET_DEFAULT); + } else { + value = qq_to_utf8(f->value, QQ_CHARSET_DEFAULT); + } rf = gaim_request_field_string_new(id, f->title, value, multiline); } else { index = atoi(f->value); @@ -460,12 +467,13 @@ gaim_request_field_choice_add(rf, choices[choice][j++]); } gaim_request_field_group_add_field(g, rf); - if (!valid_index) g_free(value); + if (!valid_index) + g_free(value); info_field_free(f); } -// Takes the info returned by a get_info packet for the user and sets up -// a form using those values and the info_template. +/* Takes the info returned by a get_info packet for the user and sets up + * a form using those values and the info_template. */ static void create_modify_info_dialogue(GaimConnection *gc, const gchar **info) { qq_data *qd; @@ -476,14 +484,14 @@ modify_info_data *mid; gint i; - // so we only have one dialog open at a time + /* so we only have one dialog open at a time */ qd = (qq_data *) gc->proto_data; if (!qd->modifying_info) { qd->modifying_info = TRUE; fields = gaim_request_fields_new(); - // we only care about the first 3 groups, not the miscellaneous stuff + /* we only care about the first 3 groups, not the miscellaneous stuff */ for (i = 0; i < 3; i++) { group = gaim_request_field_group_new(info_group_headers[i]); gaim_request_fields_add_group(fields, group); @@ -492,12 +500,9 @@ g_list_free(group_list); } - //set this manually here instead of generating a new template column field = gaim_request_fields_get_field(fields, "uid"); gaim_request_field_string_set_editable(field, FALSE); - //we need to pass the info that doesn't get modified as aux data - //because we'll still need it when we send the modify_info packet mid = g_new0(modify_info_data, 1); mid->gc = gc; mid->misc = info_get_group(info, info_group_headers[3]); @@ -510,7 +515,7 @@ } } -// process the reply of modify_info packet +/* process the reply of modify_info packet */ void qq_process_modify_info_reply(guint8 *buf, gint buf_len, GaimConnection *gc) { qq_data *qd; @@ -526,16 +531,16 @@ if (qq_crypt(DECRYPT, buf, buf_len, qd->session_key, data, &len)) { data[len] = '\0'; - if (qd->uid == atoi((gchar *) data)) { // return should be my uid + if (qd->uid == atoi((gchar *) data)) { /* return should be my uid */ gaim_debug(GAIM_DEBUG_INFO, "QQ", "Update info ACK OK\n"); gaim_notify_info(gc, NULL, _("Your information has been updated"), NULL); } - } else + } else { gaim_debug(GAIM_DEBUG_ERROR, "QQ", "Error decrypt modify info reply\n"); - + } } -// after getting info or modify myself, refresh the buddy list accordingly +/* after getting info or modify myself, refresh the buddy list accordingly */ void qq_refresh_buddy_and_myself(contact_info *info, GaimConnection *gc) { GaimBuddy *b; @@ -547,15 +552,15 @@ qd = (qq_data *) gc->proto_data; alias_utf8 = qq_to_utf8(info->nick, QQ_CHARSET_DEFAULT); - if (qd->uid == strtol(info->uid, NULL, 10)) { // it is me + if (qd->uid == strtol(info->uid, NULL, 10)) { /* it is me */ qd->my_icon = strtol(info->face, NULL, 10); if (alias_utf8 != NULL) gaim_account_set_alias(gc->account, alias_utf8); } - // update buddy list (including myself, if myself is the buddy) + /* update buddy list (including myself, if myself is the buddy) */ b = gaim_find_buddy(gc->account, uid_to_gaim_name(strtol(info->uid, NULL, 10))); q_bud = (b == NULL) ? NULL : (qq_buddy *) b->proto_data; - if (q_bud != NULL) { // I have this buddy + if (q_bud != NULL) { /* I have this buddy */ q_bud->age = strtol(info->age, NULL, 10); q_bud->gender = strtol(info->gender, NULL, 10); q_bud->icon = strtol(info->face, NULL, 10); @@ -566,7 +571,7 @@ g_free(alias_utf8); } -// process reply to get_info packet +/* process reply to get_info packet */ void qq_process_get_info_reply(guint8 *buf, gint buf_len, GaimConnection *gc) { gint len; @@ -595,7 +600,7 @@ qq_refresh_buddy_and_myself(info, gc); query_list = qd->info_query; - // ensure we're processing the right query + /* ensure we're processing the right query */ while (query_list) { query = (qq_info_query *) query_list->data; if (query->uid == atoi(info->uid)) { @@ -614,12 +619,12 @@ } g_strfreev(segments); - } else + } else { gaim_debug(GAIM_DEBUG_ERROR, "QQ", "Error decrypt get info reply\n"); - + } } -void qq_info_query_free(qq_data * qd) +void qq_info_query_free(qq_data *qd) { gint i; qq_info_query *p; Modified: trunk/src/protocols/qq/buddy_info.h =================================================================== --- trunk/src/protocols/qq/buddy_info.h 2006-08-02 13:37:13 UTC (rev 16617) +++ trunk/src/protocols/qq/buddy_info.h 2006-08-02 15:35:36 UTC (rev 16618) @@ -20,15 +20,13 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -// START OF FILE -/*****************************************************************************/ #ifndef _QQ_BUDDY_INFO_H_ #define _QQ_BUDDY_INFO_H_ #include <glib.h> -#include "connection.h" // GaimConnection -#include "buddy_opt.h" // gc_and_uid -#include "qq.h" // qq_data +#include "connection.h" +#include "buddy_opt.h" +#include "qq.h" #define QQ_COMM_FLAG_QQ_MEMBER 0x02 #define QQ_COMM_FLAG_TCP_MODE 0x10 @@ -41,56 +39,56 @@ #define QQ_BUDDY_GENDER_UNKNOWN 0xff typedef struct _contact_info { - gchar *uid; //0 - gchar *nick; //1 - gchar *country; //2 - gchar *province; //3 - gchar *zipcode; //4 - gchar *address; //5 - gchar *tel; //6 - gchar *age; //7 - gchar *gender; //8 - gchar *name; //9 - gchar *email; //10 - gchar *pager_sn; //11 - gchar *pager_num; //12 - gchar *pager_sp; //13 - gchar *pager_base_num; //14 - gchar *pager_type; //15 - gchar *occupation; //16 - gchar *homepage; //17 - gchar *auth_type; //18 - gchar *unknown1; //19 - gchar *unknown2; //20 - gchar *face; //21 - gchar *hp_num; //22 - gchar *hp_type; //23 - gchar *intro; //24 - gchar *city; //25 - gchar *unknown3; //26 - gchar *unknown4; //27 - gchar *unknown5; //28 - gchar *is_open_hp; //29 - gchar *is_open_contact; //30 - gchar *college; //31 - gchar *horoscope; //32 - gchar *zodiac; //33 sheng xiao - gchar *blood; //34 - gchar *qq_show; //35 - gchar *unknown6; //36, always 0x2D + gchar *uid; + gchar *nick; + gchar *country; + gchar *province; + gchar *zipcode; + gchar *address; + gchar *tel; + gchar *age; + gchar *gender; + gchar *name; + gchar *email; + gchar *pager_sn; + gchar *pager_num; + gchar *pager_sp; + gchar *pager_base_num; + gchar *pager_type; + gchar *occupation; + gchar *homepage; + gchar *auth_type; + gchar *unknown1; + gchar *unknown2; + gchar *face; + gchar *hp_num; + gchar *hp_type; + gchar *intro; + gchar *city; + gchar *unknown3; + gchar *unknown4; + gchar *unknown5; + gchar *is_open_hp; + gchar *is_open_contact; + gchar *college; + gchar *horoscope; + gchar *zodiac; + gchar *blood; + gchar *qq_show; + gchar *unknown6; /* always 0x2D */ } contact_info; -// There is no user id stored in the reply packet for information query -// we have to manually store the query, so that we know the query source +/* There is no user id stored in the reply packet for information query + * we have to manually store the query, so that we know the query source */ typedef struct _qq_info_query { guint32 uid; gboolean show_window; gboolean modify_info; } qq_info_query; -// We get an info packet on ourselves before we modify our information. -// Even though not all of the information is currently modifiable, it still -// all needs to be there when we send out the modify info packet +/* We get an info packet on ourselves before we modify our information. + * Even though not all of the information is currently modifiable, it still + * all needs to be there when we send out the modify info packet */ typedef struct _modify_info_data { GaimConnection *gc; GList *misc, *node; Modified: trunk/src/protocols/qq/buddy_list.c =================================================================== --- trunk/src/protocols/qq/buddy_list.c 2006-08-02 13:37:13 UTC (rev 16617) +++ trunk/src/protocols/qq/buddy_list.c 2006-08-02 15:35:36 UTC (rev 16618) @@ -20,32 +20,30 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -// START OF FILE -/*****************************************************************************/ -#include <string.h> // g_memmove, memmove -#include "debug.h" // gaim_debug +#include <string.h> +#include "debug.h" -#include "notify.h" // gaim_notify -#include "utils.h" // get_ip_str -#include "packet_parse.h" // create_packet, read_packet +#include "notify.h" +#include "utils.h" +#include "packet_parse.h" #include "buddy_list.h" -#include "buddy_status.h" // qq_buddy_status -#include "buddy_opt.h" // qq_add_buddy_by_recv_packet -#include "char_conv.h" // qq_to_utf8 -#include "crypt.h" // qq_crypt -#include "header_info.h" // cmd alias -#include "keep_alive.h" // qq_refresh_all_buddy_status -#include "send_core.h" // qq_send_cmd -#include "qq.h" // qq_data -#include "group.h" // qq_group, by gfhuang -#include "group_find.h" // qq_group_find -#include "group_hash.h" //qq_group_create_by_id -#include "group_info.h" //qq_send_cmd_group_get_group_info +#include "buddy_status.h" +#include "buddy_opt.h" +#include "char_conv.h" +#include "crypt.h" +#include "header_info.h" +#include "keep_alive.h" +#include "send_core.h" +#include "qq.h" +#include "group.h" +#include "group_find.h" +#include "group_hash.h" +#include "group_info.h" #include "qq_proxy.h" #define QQ_GET_ONLINE_BUDDY_02 0x02 -#define QQ_GET_ONLINE_BUDDY_03 0x03 // unknown function +#define QQ_GET_ONLINE_BUDDY_03 0x03 /* unknown function */ #define QQ_ONLINE_BUDDY_ENTRY_LEN 38 @@ -55,12 +53,11 @@ guint8 flag1; guint8 comm_flag; guint16 unknown2; - guint8 ending; //0x00 + guint8 ending; /* 0x00 */ } qq_friends_online_entry; -/*****************************************************************************/ -// get a list of online_buddies -void qq_send_packet_get_buddies_online(GaimConnection * gc, guint8 position) +/* get a list of online_buddies */ +void qq_send_packet_get_buddies_online(GaimConnection *gc, guint8 position) { qq_data *qd; guint8 *raw_data, *cursor; @@ -71,27 +68,25 @@ raw_data = g_newa(guint8, 5); cursor = raw_data; - // 000-000 get online friends cmd - // only 0x02 and 0x03 returns info from server, other valuse all return 0xff - // I can also only send the first byte (0x02, or 0x03) - // and the result is the same + /* 000-000 get online friends cmd + * only 0x02 and 0x03 returns info from server, other valuse all return 0xff + * I can also only send the first byte (0x02, or 0x03) + * and the result is the same */ create_packet_b(raw_data, &cursor, QQ_GET_ONLINE_BUDDY_02); - // 001-001 seems it supports 255 online buddies at most + /* 001-001 seems it supports 255 online buddies at most */ create_packet_b(raw_data, &cursor, position); - // 002-002 + /* 002-002 */ create_packet_b(raw_data, &cursor, 0x00); - // 003-004 + /* 003-004 */ create_packet_w(raw_data, &cursor, 0x0000); qq_send_cmd(gc, QQ_CMD_GET_FRIENDS_ONLINE, TRUE, 0, TRUE, raw_data, 5); qd->last_get_online = time(NULL); +} -} // qq_send_packet_get_buddies_online - -/*****************************************************************************/ -// position starts with 0x0000, -// server may return a position tag if list is too long for one packet -void qq_send_packet_get_buddies_list(GaimConnection * gc, guint16 position) +/* position starts with 0x0000, + * server may return a position tag if list is too long for one packet */ +void qq_send_packet_get_buddies_list(GaimConnection *gc, guint16 position) { guint8 *raw_data, *cursor; gint data_len; @@ -101,20 +96,19 @@ data_len = 3; raw_data = g_newa(guint8, data_len); cursor = raw_data; - // 000-001 starting position, can manually specify + /* 000-001 starting position, can manually specify */ create_packet_w(raw_data, &cursor, position); - // before Mar 18, 2004, any value can work, and we sent 00 - // I do not know what data QQ server is expecting, as QQ2003iii 0304 itself - // even can sending packets 00 and get no response. - // Now I tested that 00,00,00,00,00,01 work perfectly - // March 22, fount the 00,00,00 starts to work as well + /* before Mar 18, 2004, any value can work, and we sent 00 + * I do not know what data QQ server is expecting, as QQ2003iii 0304 itself + * even can sending packets 00 and get no response. + * Now I tested that 00,00,00,00,00,01 work perfectly + * March 22, found the 00,00,00 starts to work as well */ create_packet_b(raw_data, &cursor, 0x00); qq_send_cmd(gc, QQ_CMD_GET_FRIENDS_LIST, TRUE, 0, TRUE, raw_data, data_len); +} -} // qq_send_packet_get_buddies_list - -// get all list, buddies & Quns with groupsid support, written by gfhuang +/* get all list, buddies & Quns with groupsid support */ void qq_send_packet_get_all_list_with_group(GaimConnection *gc, guint32 position) { guint8 *raw_data, *cursor; @@ -125,19 +119,18 @@ data_len = 10; raw_data = g_newa(guint8, data_len); cursor = raw_data; - // 0x01 download, 0x02, upload + /* 0x01 download, 0x02, upload */ create_packet_b(raw_data, &cursor, 0x01); - //unknown 0x02 + /* unknown 0x02 */ create_packet_b(raw_data, &cursor, 0x02); - //unknown 00 00 00 00 + /* unknown 00 00 00 00 */ create_packet_dw(raw_data, &cursor, 0x00000000); create_packet_dw(raw_data, &cursor, position); qq_send_cmd(gc, QQ_CMD_GET_ALL_LIST_WITH_GROUP, TRUE, 0, TRUE, raw_data, data_len); } -/*****************************************************************************/ -static void _qq_buddies_online_reply_dump_unclear(qq_friends_online_entry * fe) +static void _qq_buddies_online_reply_dump_unclear(qq_friends_online_entry *fe) { GString *dump; @@ -154,12 +147,11 @@ gaim_debug(GAIM_DEBUG_INFO, "QQ", "Online buddy entry, %s", dump->str); g_string_free(dump, TRUE); -} // _qq_buddies_online_reply_dump_unknown +} -/*****************************************************************************/ -// process the reply packet for get_buddies_online packet -void qq_process_get_buddies_online_reply(guint8 * buf, gint buf_len, GaimConnection * gc) { - +/* process the reply packet for get_buddies_online packet */ +void qq_process_get_buddies_online_reply(guint8 *buf, gint buf_len, GaimConnection *gc) +{ qq_data *qd; gint len, bytes; guint8 *data, *cursor, position; @@ -187,57 +179,59 @@ fe->s = g_newa(qq_buddy_status, 1); while (cursor < (data + len)) { - // based on one online buddy entry + /* based on one online buddy entry */ bytes = 0; - // 000-030 qq_buddy_status + /* 000-030 qq_buddy_status */ bytes += qq_buddy_status_read(data, &cursor, len, fe->s); - // 031-032: unknown4 + /* 031-032: unknown4 */ bytes += read_packet_w(data, &cursor, len, &fe->unknown1); - // 033-033: flag1 + /* 033-033: flag1 */ bytes += read_packet_b(data, &cursor, len, &fe->flag1); - // 034-034: comm_flag + /* 034-034: comm_flag */ bytes += read_packet_b(data, &cursor, len, &fe->comm_flag); - // 035-036: + /* 035-036: */ bytes += read_packet_w(data, &cursor, len, &fe->unknown2); - // 037-037: - bytes += read_packet_b(data, &cursor, len, &fe->ending); // 0x00 + /* 037-037: */ + bytes += read_packet_b(data, &cursor, len, &fe->ending); /* 0x00 */ if (fe->s->uid == 0 || bytes != QQ_ONLINE_BUDDY_ENTRY_LEN) { - gaim_debug(GAIM_DEBUG_ERROR, "QQ", "uid=0 or entry complete len(%d) != %d", bytes, QQ_ONLINE_BUDDY_ENTRY_LEN); + gaim_debug(GAIM_DEBUG_ERROR, "QQ", + "uid=0 or entry complete len(%d) != %d", + bytes, QQ_ONLINE_BUDDY_ENTRY_LEN); g_free(fe->s->ip); g_free(fe->s->unknown_key); continue; - } // check if it is a valid entry + } /* check if it is a valid entry */ if (QQ_DEBUG) _qq_buddies_online_reply_dump_unclear(fe); - // update buddy information + /* update buddy information */ b = gaim_find_buddy(gaim_connection_get_account(gc), uid_to_gaim_name(fe->s->uid)); q_bud = (b == NULL) ? NULL : (qq_buddy *) b->proto_data; - if (q_bud != NULL) { // we find one and update qq_buddy + if (q_bud != NULL) { /* we find one and update qq_buddy */ if(0 != fe->s->client_version) - q_bud->client_version = fe->s->client_version; //by gfhuang - // if(0 != *((guint32 *)fe->s->ip)) { // by gfhuang - g_memmove(q_bud->ip, fe->s->ip, 4); - q_bud->port = fe->s->port; - // } + q_bud->client_version = fe->s->client_version; + g_memmove(q_bud->ip, fe->s->ip, 4); + q_bud->port = fe->s->port; q_bud->status = fe->s->status; q_bud->flag1 = fe->flag1; q_bud->comm_flag = fe->comm_flag; qq_update_buddy_contact(gc, q_bud); - } // if q_bud + } else { - gaim_debug(GAIM_DEBUG_ERROR, "QQ", "Got an online buddy %d, but not in my buddy list", fe->s->uid); + gaim_debug(GAIM_DEBUG_ERROR, "QQ", + "Got an online buddy %d, but not in my buddy list", fe->s->uid); } g_free(fe->s->ip); g_free(fe->s->unknown_key); - } // while cursor + } if(cursor > (data + len)) { - gaim_debug(GAIM_DEBUG_ERROR, "QQ", "qq_process_get_buddies_online_reply: Dangerous error! maybe protocal changed, notify me!"); + gaim_debug(GAIM_DEBUG_ERROR, "QQ", + "qq_process_get_buddies_online_reply: Dangerous error! maybe protocol changed, notify developers!"); } if (position != QQ_FRIENDS_ONLINE_POSITION_END) { @@ -245,17 +239,18 @@ qq_send_packet_get_buddies_online(gc, position); } - else + else { qq_refresh_all_buddy_status(gc); + } - } else + } else { gaim_debug(GAIM_DEBUG_ERROR, "QQ", "Error decrypt buddies online"); + } +} -} // qq_process_get_buddies_online_reply - -/*****************************************************************************/ -// process reply for get_buddies_list -void qq_process_get_buddies_list_reply(guint8 * buf, gint buf_len, GaimConnection * gc) { +/* process reply for get_buddies_list */ +void qq_process_get_buddies_list_reply(guint8 *buf, gint buf_len, GaimConnection *gc) +{ qq_data *qd; qq_buddy *q_bud; gint len, bytes, bytes_expected, i; @@ -274,20 +269,20 @@ if (qq_crypt(DECRYPT, buf, buf_len, qd->session_key, data, &len)) { read_packet_w(data, &cursor, len, &position); - // the following data is buddy list in this packet + /* the following data is buddy list in this packet */ i = 0; while (cursor < (data + len)) { q_bud = g_new0(qq_buddy, 1); bytes = 0; - // 000-003: uid + /* 000-003: uid */ bytes += read_packet_dw(data, &cursor, len, &q_bud->uid); - // 004-004: 0xff if buddy is self, 0x00 otherwise + /* 004-004: 0xff if buddy is self, 0x00 otherwise */ bytes += read_packet_b(data, &cursor, len, &bar); - // 005-005: icon index (1-255) + /* 005-005: icon index (1-255) */ bytes += read_packet_b(data, &cursor, len, &q_bud->icon); - // 006-006: age + /* 006-006: age */ bytes += read_packet_b(data, &cursor, len, &q_bud->age); - // 007-007: gender + /* 007-007: gender */ bytes += read_packet_b(data, &cursor, len, &q_bud->gender); pascal_len = convert_as_pascal_string(cursor, &q_bud->nickname, QQ_CHARSET_DEFAULT); cursor += pascal_len; @@ -313,13 +308,15 @@ g_free(q_bud->nickname); g_free(q_bud); continue; - } else + } else { i++; + } - if (QQ_DEBUG) + if (QQ_DEBUG) { gaim_debug(GAIM_DEBUG_INFO, "QQ", "buddy [%09d]: flag1=0x%02x, comm_flag=0x%02x\n", q_bud->uid, q_bud->flag1, q_bud->comm_flag); + } name = uid_to_gaim_name(q_bud->uid); b = gaim_find_buddy(gc->account, name); @@ -331,25 +328,24 @@ b->proto_data = q_bud; qd->buddies = g_list_append(qd->buddies, q_bud); qq_update_buddy_contact(gc, q_bud); - } // while cursor + } if(cursor > (data + len)) { - gaim_debug(GAIM_DEBUG_ERROR, "QQ", "qq_process_get_buddies_list_reply: Dangerous error! maybe protocal changed, notify me!"); + gaim_debug(GAIM_DEBUG_ERROR, "QQ", + "qq_process_get_buddies_list_reply: Dangerous error! maybe protocol changed, notify developers!"); } if (position == QQ_FRIENDS_LIST_POSITION_END) { gaim_debug(GAIM_DEBUG_INFO, "QQ", "Get friends list done, %d buddies\n", i); qq_send_packet_get_buddies_online(gc, QQ_FRIENDS_ONLINE_POSITION_START); - } else + } else { qq_send_packet_get_buddies_list(gc, position); - - } else + } + } else { gaim_debug(GAIM_DEBUG_ERROR, "QQ", "Error decrypt buddies list"); + } +} -} // qq_process_get_buddies_list_reply - - -// written by gfhuang -void qq_process_get_all_list_with_group_reply(guint8 * buf, gint buf_len, GaimConnection * gc) +void qq_process_get_all_list_with_group_reply(guint8 *buf, gint buf_len, GaimConnection *gc) { qq_data *qd; gint len, i, j; @@ -377,27 +373,28 @@ g_return_if_fail(sub_cmd == 0x01); read_packet_b(data, &cursor, len, &reply_code); if(0 != reply_code) { - gaim_debug(GAIM_DEBUG_WARNING, "QQ", "Get all list with group reply, reply_code(%d) is not zero", reply_code); + gaim_debug(GAIM_DEBUG_WARNING, "QQ", + "Get all list with group reply, reply_code(%d) is not zero", reply_code); } read_packet_dw(data, &cursor, len, &unknown); read_packet_dw(data, &cursor, len, &position); - // the following data is all list in this packet + /* the following data is all list in this packet */ i = 0; j = 0; while (cursor < (data + len)) { - // 00-03: uid + /* 00-03: uid */ read_packet_dw(data, &cursor, len, &uid); - // 04: type 0x1:buddy 0x4:Qun + /* 04: type 0x1:buddy 0x4:Qun */ read_packet_b(data, &cursor, len, &type); - // 05: groupid*4 + /* 05: groupid*4 */ read_packet_b(data, &cursor, len, &groupid); - groupid >>= 2; // these 2 bits might not be 0, faint! + groupid >>= 2; /* these 2 bits might not be 0, faint! */ if (uid == 0 || (type != 0x1 && type != 0x4)) { gaim_debug(GAIM_DEBUG_WARNING, "QQ", "Buddy entry, uid=%d, type=%d", uid, type); continue; } - if(0x1 == type) { // a buddy + if(0x1 == type) { /* a buddy */ name = uid_to_gaim_name(uid); b = gaim_find_buddy(gc->account, name); g_free(name); @@ -408,23 +405,23 @@ } else { q_bud = NULL; - b->proto_data = q_bud; //wrong !!!! + b->proto_data = q_bud; /* wrong !!!! */ } qd->buddies = g_list_append(qd->buddies, q_bud); qq_update_buddy_contact(gc, q_bud); ++i; - } - else { //a group - group = qq_group_find_by_internal_group_id(gc, uid); + } else { /* a group */ + group = qq_group_find_by_internal_group_id(gc, uid); if(group == NULL) { - /* not working, gfhuang + /* not working group = qq_group_create_by_id(gc, uid, 0); qq_send_cmd_group_get_group_info(gc, group); */ - gaim_debug(GAIM_DEBUG_ERROR, "QQ", "Get a Qun with internel group %d\n", uid); - gaim_notify_info(gc, _("QQ Qun Operation"), _("Find one Qun in the server list, but i don't know its external id, please re-rejoin it manually"), NULL); - } - else { + gaim_debug(GAIM_DEBUG_ERROR, "QQ", + "Get a Qun with internal group %d\n", uid); + gaim_notify_info(gc, _("QQ Qun Operation"), + _("Find one Qun in the server list, but i don't know its external id, please re-rejoin it manually"), NULL); + } else { group->my_status = QQ_GROUP_MEMBER_STATUS_IS_MEMBER; qq_group_refresh(gc, group); qq_send_cmd_group_get_group_info(gc, group); @@ -433,12 +430,11 @@ } } if(cursor > (data + len)) { - gaim_debug(GAIM_DEBUG_ERROR, "QQ", "qq_process_get_all_list_with_group_reply: Dangerous error! maybe protocal changed, notify me!"); + gaim_debug(GAIM_DEBUG_ERROR, "QQ", + "qq_process_get_all_list_with_group_reply: Dangerous error! maybe protocol changed, notify developers!"); } - gaim_debug(GAIM_DEBUG_INFO, "QQ", "Get all list done, %d buddies and %d Quns\n", i, j); - } else + gaim_debug(GAIM_DEBUG_INFO, "QQ", "Get all list done, %d buddies and %d Quns\n", i, j); + } else { gaim_debug(GAIM_DEBUG_ERROR, "QQ", "Error decrypt all list with group"); - + } } -/*****************************************************************************/ -// END OF FILE Modified: trunk/src/protocols/qq/buddy_list.h =================================================================== --- trunk/src/protocols/qq/buddy_list.h 2006-08-02 13:37:13 UTC (rev 16617) +++ trunk/src/protocols/qq/buddy_list.h 2006-08-02 15:35:36 UTC (rev 16618) @@ -20,28 +20,22 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -// START OF FILE -/*****************************************************************************/ #ifndef _QQ_BUDDY_LIST_H_ #define _QQ_BUDDY_LIST_H_ #include <glib.h> -#include "connection.h" // GaimConnection +#include "connection.h" #define QQ_FRIENDS_LIST_POSITION_START 0x0000 #define QQ_FRIENDS_LIST_POSITION_END 0xffff #define QQ_FRIENDS_ONLINE_POSITION_START 0x00 #define QQ_FRIENDS_ONLINE_POSITION_END 0xff -void qq_send_packet_get_buddies_online(GaimConnection * gc, guint8 position); -void qq_process_get_buddies_online_reply(guint8 * buf, gint buf_len, GaimConnection * gc); -void qq_send_packet_get_buddies_list(GaimConnection * gc, guint16 position); -void qq_process_get_buddies_list_reply(guint8 * buf, gint buf_len, GaimConnection * gc); +void qq_send_packet_get_buddies_online(GaimConnection *gc, guint8 position); +void qq_process_get_buddies_online_reply(guint8 *buf, gint buf_len, GaimConnection *gc); +void qq_send_packet_get_buddies_list(GaimConnection *gc, guint16 position); +void qq_process_get_buddies_list_reply(guint8 *buf, gint buf_len, GaimConnection *gc); +void qq_send_packet_get_all_list_with_group(GaimConnection *gc, guint32 position); +void qq_process_get_all_list_with_group_reply(guint8 *buf, gint buf_len, GaimConnection *gc); -//added by gfhuang -void qq_send_packet_get_all_list_with_group(GaimConnection * gc, guint32 position); -void qq_process_get_all_list_with_group_reply(guint8 * buf, gint buf_len, GaimConnection * gc); - #endif -/*****************************************************************************/ -// END OF FILE Modified: trunk/src/protocols/qq/buddy_opt.c =================================================================== --- trunk/src/protocols/qq/buddy_opt.c 2006-08-02 13:37:13 UTC (rev 16617) +++ trunk/src/protocols/qq/buddy_opt.c 2006-08-02 15:35:36 UTC (rev 16618) @@ -20,24 +20,22 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -// START OF FILE -/*****************************************************************************/ -#include "debug.h" // gaim_debug -#include "internal.h" // strlen, _("get_text") -#include "notify.h" // gaim_notify -#include "request.h" // gaim_request_input +#include "debug.h" +#include "internal.h" +#include "notify.h" +#include "request.h" -#include "utils.h" // uid_to_gaim_name, gaim_name_to_uid -#include "packet_parse.h" // create_packet, read_packet -#include "buddy_info.h" // qq_send_packet_get_info -#include "buddy_list.h" // qq_send_packet_get_buddies_online +#include "buddy_info.h" +#include "buddy_list.h" #include "buddy_opt.h" -#include "char_conv.h" // qq_to_utf8 -#include "crypt.h" // qq_crypt -#include "header_info.h" // cmd alias -#include "keep_alive.h" // qq_update_buddy_contact -#include "im.h" // QQ_MSG_IM_MAX -#include "send_core.h" // qq_send_cmd +#include "char_conv.h" +#include "crypt.h" +#include "header_info.h" +#include "im.h" +#include "keep_alive.h" +#include "packet_parse.h" +#include "send_core.h" +#include "utils.h" #define GAIM_GROUP_QQ_FORMAT "QQ (%s)" #define GAIM_GROUP_QQ_UNKNOWN "QQ Unknown" @@ -45,12 +43,12 @@ #define QQ_REMOVE_BUDDY_REPLY_OK 0x00 #define QQ_REMOVE_SELF_REPLY_OK 0x00 -#define QQ_ADD_BUDDY_AUTH_REPLY_OK 0x30 // ASCii value of "0" +#define QQ_ADD_BUDDY_AUTH_REPLY_OK 0x30 /* ASCII value of "0" */ enum { - QQ_MY_AUTH_APPROVE = 0x30, // ASCii value of "0" - QQ_MY_AUTH_REJECT = 0x31, // ASCii value of "1" - QQ_MY_AUTH_REQUEST = 0x32, // ASCii value of "2" + QQ_MY_AUTH_APPROVE = 0x30, /* ASCII value of "0" */ + QQ_MY_AUTH_REJECT = 0x31, /* ASCII value of "1" */ + QQ_MY_AUTH_REQUEST = 0x32, /* ASCII value of "2" */ }; typedef struct _qq_add_buddy_request { @@ -58,9 +56,8 @@ guint16 seq; } qq_add_buddy_request; -/*****************************************************************************/ -// send packet to remove a buddy from my buddy list -static void _qq_send_packet_remove_buddy(GaimConnection * gc, guint32 uid) +/* send packet to remove a buddy from my buddy list */ +static void _qq_send_packet_remove_buddy(GaimConnection *gc, guint32 uid) { gchar *uid_str; @@ -70,11 +67,10 @@ qq_send_cmd(gc, QQ_CMD_DEL_FRIEND, TRUE, 0, TRUE, uid_str, strlen(uid_str)); g_free(uid_str); -} // _qq_send_packet_remove_buddy +} -/*****************************************************************************/ -// try to remove myself from someone's buddy list -static void _qq_send_packet_remove_self_from(GaimConnection * gc, guint32 uid) +/* try to remove myself from someone's buddy list */ +static void _qq_send_packet_remove_self_from(GaimConnection *gc, guint32 uid) { guint8 *raw_data, *cursor; @@ -85,12 +81,10 @@ create_packet_dw(raw_data, &cursor, uid); qq_send_cmd(gc, QQ_CMD_REMOVE_SELF, TRUE, 0, TRUE, raw_data, 4); +} -} // _qq_send_packet_add_buddy - -/*****************************************************************************/ -// try to add a buddy without authentication -static void _qq_send_packet_add_buddy(GaimConnection * gc, guint32 uid) +/* try to add a buddy without authentication */ +static void _qq_send_packet_add_buddy(GaimConnection *gc, guint32 uid) { qq_data *qd; qq_add_buddy_request *req; @@ -98,22 +92,21 @@ g_return_if_fail(gc != NULL && gc->proto_data != NULL && uid > 0); - // we need to send the ascii code of this uid to qq server + /* we need to send the ascii code of this uid to qq server */ uid_str = g_strdup_printf("%d", uid); qq_send_cmd(gc, QQ_CMD_ADD_FRIEND_WO_AUTH, TRUE, 0, TRUE, uid_str, strlen(uid_str)); g_free(uid_str); - // must be set after sending packet to get the correct send_seq + /* must be set after sending packet to get the correct send_seq */ qd = (qq_data *) gc->proto_data; req = g_new0(qq_add_buddy_request, 1); req->seq = qd->send_seq; req->uid = uid; qd->add_buddy_request = g_list_append(qd->add_buddy_request, req); -} // _qq_send_packet_add_buddy +} -/*****************************************************************************/ -// this buddy needs authentication, text conversion is done at lowest level -static void _qq_send_packet_buddy_auth(GaimConnection * gc, guint32 uid, const gchar response, const gchar * text) +/* this buddy needs authentication, text conversion is done at lowest level */ +static void _qq_send_packet_buddy_auth(GaimConnection *gc, guint32 uid, const gchar response, const gchar *text) { gchar *text_qq, *uid_str; guint8 bar, *cursor, *raw_data; @@ -138,11 +131,10 @@ qq_send_cmd(gc, QQ_CMD_BUDDY_AUTH, TRUE, 0, TRUE, raw_data, cursor - raw_data); g_free(uid_str); -} // _qq_send_packet_buddy_auth +} - -/*****************************************************************************/ -static void _qq_send_packet_add_buddy_auth_with_gc_and_uid(gc_and_uid * g, const gchar * text) { +static void _qq_send_packet_add_buddy_auth_with_gc_and_uid(gc_and_uid *g, const gchar *text) +{ GaimConnection *gc; guint32 uid; g_return_if_fail(g != NULL); @@ -153,11 +145,10 @@ _qq_send_packet_buddy_auth(gc, uid, QQ_MY_AUTH_REQUEST, text); g_free(g); -} // qq_send_packet_add_buddy_auth +} -/*****************************************************************************/ -// the real packet to reject and request is sent from here -static void _qq_reject_add_request_real(gc_and_uid * g, const gchar * reason) +/* the real packet to reject and request is sent from here */ +static void _qq_reject_add_request_real(gc_and_uid *g, const gchar *reason) { gint uid; GaimConnection *gc; @@ -170,11 +161,10 @@ _qq_send_packet_buddy_auth(gc, uid, QQ_MY_AUTH_REJECT, reason); g_free(g); -} // _qq_reject_add_request_real +} -/*****************************************************************************/ -// we approve other's request of adding me as friend -void qq_approve_add_request_with_gc_and_uid(gc_and_uid * g) +/* we approve other's request of adding me as friend */ +void qq_approve_add_request_with_gc_and_uid(gc_and_uid *g) { gint uid; GaimConnection *gc; @@ -187,17 +177,15 @@ _qq_send_packet_buddy_auth(gc, uid, QQ_MY_AUTH_APPROVE, NULL); g_free(g); -} // qq_approve_add_request_with_gc_and_uid +} -/*****************************************************************************/ -void qq_do_nothing_with_gc_and_uid(gc_and_uid * g, const gchar * msg) +void qq_do_nothing_with_gc_and_uid(gc_and_uid *g, const gchar *msg) { g_free(g); -} // qq_do_nothing_with_gc_and_uid +} -/*****************************************************************************/ -// we reject other's request of adding me as friend -void qq_reject_add_request_with_gc_and_uid(gc_and_uid * g) +/* we reject other's request of adding me as friend */ +void qq_reject_add_request_with_gc_and_uid(gc_and_uid *g) { gint uid; gchar *msg1, *msg2; @@ -222,11 +210,9 @@ gaim_request_input(gc, _("Reject request"), msg1, msg2, _("Sorry, you are not my type..."), TRUE, FALSE, NULL, _("Reject"), G_CALLBACK(_qq_reject_add_request_real), _("Cancel"), NULL, g2); +} -} // qq_reject_add_request_with_gc_and_uid - -/*****************************************************************************/ -void qq_add_buddy_with_gc_and_uid(gc_and_uid * g) +void qq_add_buddy_with_gc_and_uid(gc_and_uid *g) { gint uid; GaimConnection *gc; @@ -239,10 +225,9 @@ _qq_send_packet_add_buddy(gc, uid); g_free(g); -} // qq_add_buddy_with_gc_and_uid +} -/*****************************************************************************/ -void qq_block_buddy_with_gc_and_uid(gc_and_uid * g) +void qq_block_buddy_with_gc_and_uid(gc_and_uid *g) { guint32 uid; GaimConnection *gc; @@ -260,12 +245,11 @@ qq_remove_buddy(gc, &buddy, &group); _qq_send_packet_remove_self_from(gc, uid); +} -} // qq_block_buddy_with_gc_and_uid - -/*****************************************************************************/ -// process reply to add_buddy_auth request -void qq_process_add_buddy_auth_reply(guint8 * buf, gint buf_len, GaimConnection * gc) { +/* process reply to add_buddy_auth request */ +void qq_process_add_buddy_auth_reply(guint8 *buf, gint buf_len, GaimConnection *gc) +{ qq_data *qd; gint len; guint8 *data, *cursor, reply; @@ -288,16 +272,17 @@ msg_utf8 = qq_to_utf8(segments[1], QQ_CHARSET_DEFAULT); gaim_notify_error(gc, NULL, _("Add buddy with auth request fails"), msg_utf8); g_free(msg_utf8); - } else + } else { gaim_debug(GAIM_DEBUG_INFO, "QQ", "Add buddy with auth request OK\n"); - } else + } + } else { gaim_debug(GAIM_DEBUG_ERROR, "QQ", "Error decrypt add buddy with auth reply\n"); + } +} -} // qq_process_add_buddy_auth_reply - -/*****************************************************************************/ -// process the server reply for my request to remove a buddy -void qq_process_remove_buddy_reply(guint8 * buf, gint buf_len, GaimConnection * gc) { +/* process the server reply for my request to remove a buddy */ +void qq_process_remove_buddy_reply(guint8 *buf, gint buf_len, GaimConnection *gc) +{ qq_data *qd; gint len; guint8 *data, *cursor, reply; @@ -312,22 +297,21 @@ if (qq_crypt(DECRYPT, buf, buf_len, qd->session_key, data, &len)) { cursor = data; read_packet_b(data, &cursor, len, &reply); - if (reply != QQ_REMOVE_BUDDY_REPLY_OK) - // there is no reason return from server + if (reply != QQ_REMOVE_BUDDY_REPLY_OK) { + /* there is no reason return from server */ gaim_debug(GAIM_DEBUG_WARNING, "QQ", "Remove buddy fails\n"); - else { // if reply + } else { /* if reply */ gaim_debug(GAIM_DEBUG_INFO, "QQ", "Remove buddy OK\n"); gaim_notify_info(gc, NULL, _("You have successfully removed a buddy"), NULL); } - } else + } else { gaim_debug(GAIM_DEBUG_ERROR, "QQ", "Error decrypt remove buddy reply\n"); + } +} -} // qq_process_remove_buddy_reply - - -/*****************************************************************************/ -// process the server reply for my request to remove myself from a buddy -void qq_process_remove_self_reply(guint8 * buf, gint buf_len, GaimConnection * gc) { +/* process the server reply for my request to remove myself from a buddy */ +void qq_process_remove_self_reply(guint8 *buf, gint buf_len, GaimConnection *gc) +{ qq_data *qd; gint len; guint8 *data, *cursor, reply; @@ -343,19 +327,19 @@ cursor = data; read_packet_b(data, &cursor, len, &reply); if (reply != QQ_REMOVE_SELF_REPLY_OK) - // there is no reason return from server + /* there is no reason return from server */ gaim_debug(GAIM_DEBUG_WARNING, "QQ", "Remove self fails\n"); - else { // if reply + else { /* if reply */ gaim_debug(GAIM_DEBUG_INFO, "QQ", "Remove self from a buddy OK\n"); gaim_notify_info(gc, NULL, _("You have successfully removed yourself from a buddy"), NULL); } - } else + } else { gaim_debug(GAIM_DEBUG_ERROR, "QQ", "Error decrypt remove self reply\n"); + } +} -} // qq_process_remove_buddy_reply - -/*****************************************************************************/ -void qq_process_add_buddy_reply(guint8 * buf, gint buf_len, guint16 seq, GaimConnection * gc) { +void qq_process_add_buddy_reply(guint8 *buf, gint buf_len, guint16 seq, GaimConnection *gc) +{ qq_data *qd; gint len, for_uid; gchar *msg, *data, **segments, *uid, *reply; @@ -374,20 +358,21 @@ list = qd->add_buddy_request; while (list != NULL) { req = (qq_add_buddy_request *) list->data; - if (req->seq == seq) { // reply to this + if (req->seq == seq) { /* reply to this */ for_uid = req->uid; qd->add_buddy_request = g_list_remove(qd->add_buddy_request, qd->add_buddy_request->data); g_free(req); break; } list = list->next; - } // while list + } - if (for_uid == 0) { // we have no record for this + if (for_uid == 0) { /* we have no record for this */ gaim_debug(GAIM_DEBUG_ERROR, "QQ", "We have no record for add buddy reply [%d], discard\n", seq); return; - } else + } else { gaim_debug(GAIM_DEBUG_INFO, "QQ", "Add buddy reply [%d] is for id [%d]\n", seq, for_uid); + } data = g_newa(guint8, len); @@ -396,13 +381,13 @@ return; uid = segments[0]; reply = segments[1]; - if (strtol(uid, NULL, 10) != qd->uid) { // should not happen + if (strtol(uid, NULL, 10) != qd->uid) { /* should not happen */ gaim_debug(GAIM_DEBUG_ERROR, "QQ", "Add buddy reply is to [%s], not me!", uid); g_strfreev(segments); return; - } // if uid + } - if (strtol(reply, NULL, 10) > 0) { // need auth + if (strtol(reply, NULL, 10) > 0) { /* need auth */ gaim_debug(GAIM_DEBUG_WARNING, "QQ", "Add buddy attempt fails, need authentication\n"); b = gaim_find_buddy(gc->account, uid_to_gaim_name(for_uid)); if (b != NULL) @@ -419,20 +404,19 @@ (_qq_send_packet_add_buddy_auth_with_gc_and_uid), _("Cancel"), G_CALLBACK(qq_do_nothing_with_gc_and_uid), g); g_free(msg); - } else { // add OK + } else { /* add OK */ qq_add_buddy_by_recv_packet(gc, for_uid, TRUE, TRUE); msg = g_strdup_printf(_("You have added %d in buddy list"), for_uid); gaim_notify_info(gc, NULL, msg, NULL); g_free(msg); - } // if reply + } g_strfreev(segments); - } else + } else { gaim_debug(GAIM_DEBUG_ERROR, "QQ", "Error decrypt add buddy reply\n"); + } +} -} // qq_process_add_buddy_reply - -/*****************************************************************************/ -GaimGroup *qq_get_gaim_group(const gchar * group_name) +GaimGroup *qq_get_gaim_group(const gchar *group_name) { GaimGroup *g; @@ -443,15 +427,15 @@ g = gaim_group_new(group_name); gaim_blist_add_group(g, NULL); gaim_debug(GAIM_DEBUG_WARNING, "QQ", "Add new group: %s\n", group_name); - } // if (g == NULL) + } return g; -} // qq_get_gaim_group +} -/*****************************************************************************/ -// we add new buddy, if the received packet is from someone not in my list -// return the GaimBuddy that is just created -GaimBuddy *qq_add_buddy_by_recv_packet(GaimConnection * gc, guint32 uid, gboolean is_known, gboolean create) { +/* we add new buddy, if the received packet is from someone not in my list + * return the GaimBuddy that is just created */ +GaimBuddy *qq_add_buddy_by_recv_packet(GaimConnection *gc, guint32 uid, gboolean is_known, gboolean create) +{ GaimAccount *a; GaimBuddy *b; GaimGroup *g; @@ -472,8 +456,8 @@ name = uid_to_gaim_name(uid); b = gaim_find_buddy(gc->account, name); - // remove old, we can not simply return here - // because there might be old local copy of this buddy + /* remove old, we can not simply return here + * because there might be old local copy of this buddy */ if (b != NULL) gaim_blist_remove_buddy(b); @@ -488,7 +472,7 @@ qd->buddies = g_list_append(qd->buddies, q_bud); qq_send_packet_get_info(gc, q_bud->uid, FALSE); qq_send_packet_get_buddies_online(gc, QQ_FRIENDS_ONLINE_POSITION_START); - } // if !create + } gaim_blist_add_buddy(b, NULL, g, NULL); gaim_debug(GAIM_DEBUG_WARNING, "QQ", "Add new buddy: [%s]\n", name); @@ -497,14 +481,14 @@ g_free(group_name); return b; -} // qq_add_buddy_by_recv_packet +} -/*****************************************************************************/ -// add a buddy and send packet to QQ server -// note that when gaim load local cached buddy list into its blist -// it also calls this funtion, so we have to -// define qd->logged_in=TRUE AFTER serv_finish_login(gc) -void qq_add_buddy(GaimConnection * gc, GaimBuddy * buddy, GaimGroup * group) { +/* add a buddy and send packet to QQ server + * note that when gaim load local cached buddy list into its blist + * it also calls this funtion, so we have to + * define qd->logged_in=TRUE AFTER serv_finish_login(gc) */ +void qq_add_buddy(GaimConnection *gc, GaimBuddy *buddy, GaimGroup *group) +{ qq_data *qd; guint32 uid; GaimBuddy *b; @@ -513,7 +497,7 @@ qd = (qq_data *) gc->proto_data; if (!qd->logged_in) - return; // IMPORTANT ! + return; /* IMPORTANT ! */ uid = gaim_name_to_uid(buddy->name); if (uid > 0) @@ -526,11 +510,11 @@ _("QQid Error"), _("Invalid QQid, to add buddy 1234567, \nyou should input qq-1234567")); } -} // _qq_add_buddy +} -/*****************************************************************************/ -// remove a buddy and send packet to QQ server accordingly -void qq_remove_buddy(GaimConnection * gc, GaimBuddy * buddy, GaimGroup * group) { +/* remove a buddy and send packet to QQ server accordingly */ +void qq_remove_buddy(GaimConnection *gc, GaimBuddy *buddy, GaimGroup *group) +{ qq_data *qd; GaimBuddy *b; qq_buddy *q_bud; @@ -554,18 +538,16 @@ qd->buddies = g_list_remove(qd->buddies, q_bud); else gaim_debug(GAIM_DEBUG_WARNING, "QQ", "We have no qq_buddy record for %s\n", buddy->name); - // remove buddy on blist, this does not trigger qq_remove_buddy again - // do this only if the request comes from block request, - // otherwise gaim segmentation fault - if (g_ascii_strcasecmp(group->name, GAIM_GROUP_QQ_BLOCKED) - == 0) + /* remove buddy on blist, this does not trigger qq_remove_buddy again + * do this only if the request comes from block request, + * otherwise gaim segmentation fault */ + if (g_ascii_strcasecmp(group->name, GAIM_GROUP_QQ_BLOCKED) == 0) gaim_blist_remove_buddy(b); - } // if b != NULL -} // _qq_remove_buddy + } +} -/*****************************************************************************/ -// free add buddy request queue -void qq_add_buddy_request_free(qq_data * qd) +/* free add buddy request queue */ +void qq_add_buddy_request_free(qq_data *qd) { gint i; qq_add_buddy_request *p; @@ -580,11 +562,10 @@ i++; } gaim_debug(GAIM_DEBUG_INFO, "QQ", "%d add buddy requests are freed!\n", i); -} // qq_add_buddy_request_free +} -/*****************************************************************************/ -// free up all qq_buddy -void qq_buddies_list_free(GaimAccount *account, qq_data * qd) +/* free up all qq_buddy */ +void qq_buddies_list_free(GaimAccount *account, qq_data *qd) { gint i; qq_buddy *p; @@ -597,21 +578,16 @@ while (qd->buddies) { p = (qq_buddy *) (qd->buddies->data); qd->buddies = g_list_remove(qd->buddies, p); - // added by gfhuang, for relogin crash bug name = uid_to_gaim_name(p->uid); b = gaim_find_buddy(account, name); - if(b != NULL) b->proto_data = NULL; - else { + if(b != NULL) + b->proto_data = NULL; + else gaim_debug(GAIM_DEBUG_INFO, "QQ", "qq_buddy %s not found in gaim proto_data\n", name); - } g_free(name); g_free(p); i++; } gaim_debug(GAIM_DEBUG_INFO, "QQ", "%d qq_buddy structures are freed!\n", i); - -} // qq_buddies_list_free - -/*****************************************************************************/ -// END OF FILE +} Modified: trunk/src/protocols/qq/buddy_opt.h =================================================================== --- trunk/src/protocols/qq/buddy_opt.h 2006-08-02 13:37:13 UTC (rev 16617) +++ trunk/src/protocols/qq/buddy_opt.h 2006-08-02 15:35:36 UTC (rev 16618) @@ -20,15 +20,13 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -// START OF FILE -/*****************************************************************************/ #ifndef _QQ_BUDDY_OPT_H_ #define _QQ_BUDDY_OPT_H_ #include <glib.h> -#include "connection.h" // GaimConnection +#include "connection.h" -#include "qq.h" // qq_buddy +#include "qq.h" typedef struct _gc_and_uid gc_and_uid; @@ -37,29 +35,26 @@ GaimConnection *gc; }; -void qq_approve_add_request_with_gc_and_uid(gc_and_uid * g); +void qq_approve_add_request_with_gc_and_uid(gc_and_uid *g); +void qq_reject_add_request_with_gc_and_uid(gc_and_uid *g); -void qq_reject_add_request_with_gc_and_uid(gc_and_uid * g); +void qq_add_buddy_with_gc_and_uid(gc_and_uid *g); +void qq_block_buddy_with_gc_and_uid(gc_and_uid *g); -void qq_add_buddy_wi... [truncated message content] |