Mercurial > pidgin
changeset 31193:1bf763879b96
2011.02.06 - flos <lonicerae(at)gmail.com>
* 'typedef struct _X {} X' cleaned
* added a check
* added some comment
author | SHiNE CsyFeK <csyfek@gmail.com> |
---|---|
date | Sun, 06 Feb 2011 06:43:26 +0000 |
parents | ab175460cea7 |
children | e2665473f5e3 |
files | libpurple/protocols/qq/file_trans.c libpurple/protocols/qq/group.h libpurple/protocols/qq/im.c libpurple/protocols/qq/qq.h libpurple/protocols/qq/qq_define.h libpurple/protocols/qq/qq_network.c libpurple/protocols/qq/qq_trans.c libpurple/protocols/qq/qq_trans.h |
diffstat | 8 files changed, 50 insertions(+), 56 deletions(-) [+] |
line wrap: on
line diff
--- a/libpurple/protocols/qq/file_trans.c Sun Feb 06 05:26:52 2011 +0000 +++ b/libpurple/protocols/qq/file_trans.c Sun Feb 06 06:43:26 2011 +0000 @@ -38,14 +38,12 @@ #include "send_file.h" #include "utils.h" -struct _qq_file_header { +typedef struct _qq_file_header { guint16 client_ver; guint8 file_key; UID sender_uid; UID receiver_uid; -}; - -typedef struct _qq_file_header qq_file_header; +} qq_file_header; static guint32 _get_file_key(guint8 seed) {
--- a/libpurple/protocols/qq/group.h Sun Feb 06 05:26:52 2011 +0000 +++ b/libpurple/protocols/qq/group.h Sun Feb 06 06:43:26 2011 +0000 @@ -40,8 +40,7 @@ QQ_ROOM_ROLE_ADMIN } qq_room_role; -typedef struct _qq_room_data qq_room_data; -struct _qq_room_data { +typedef struct _qq_room_data { /* all these will be saved when we exit Purple */ qq_room_role my_role; /* my role for this room */ guint32 id; @@ -57,7 +56,7 @@ gboolean is_got_buddies; GList *members; -}; +} qq_room_data; GList *qq_chat_info(PurpleConnection *gc); GHashTable *qq_chat_info_defaults(PurpleConnection *gc, const gchar *chat_name);
--- a/libpurple/protocols/qq/im.c Sun Feb 06 05:26:52 2011 +0000 +++ b/libpurple/protocols/qq/im.c Sun Feb 06 06:43:26 2011 +0000 @@ -67,15 +67,14 @@ QQ_NORMAL_IM_FILE_EX_NOTIFY_IP = 0x87 }; -typedef struct _qq_im_header qq_im_header; -struct _qq_im_header { +typedef struct _qq_im_header { /* this is the common part of normal_text */ guint16 version_from; UID uid_from; UID uid_to; guint8 session_md5[QQ_KEY_LENGTH]; guint16 im_type; -}; +} qq_im_header; /* read the common parts of the normal_im, * returns the bytes read if succeed, or -1 if there is any error */ @@ -93,11 +92,10 @@ return bytes; } -typedef struct _qq_emoticon qq_emoticon; -struct _qq_emoticon { +typedef struct _qq_emoticon { guint8 symbol; gchar *name; -}; +} qq_emoticon; static gboolean emoticons_is_sorted = FALSE; /* Map for purple smiley convert to qq, need qsort */
--- a/libpurple/protocols/qq/qq.h Sun Feb 06 05:26:52 2011 +0000 +++ b/libpurple/protocols/qq/qq.h Sun Feb 06 06:43:26 2011 +0000 @@ -43,22 +43,15 @@ typedef guint32 UPDCLS; typedef guint32 UID; -typedef struct _qq_data qq_data; -typedef struct _qq_buddy_data qq_buddy_data; -typedef struct _qq_interval qq_interval; -typedef struct _qq_net_stat qq_net_stat; -typedef struct _qq_login_data qq_login_data; -typedef struct _qq_captcha_data qq_captcha_data; - -struct _qq_captcha_data { +typedef struct _qq_captcha_data { guint8 *token; guint16 token_len; guint8 next_index; guint8 *data; guint16 data_len; -}; +} qq_captcha_data; -struct _qq_login_data { +typedef struct _qq_login_data { guint8 random_key[QQ_KEY_LENGTH]; /* first encrypt key generated by client */ guint8 *token; /* get from server */ guint8 token_len; @@ -71,23 +64,23 @@ guint8 *login_token; guint16 login_token_len; guint8 login_key[QQ_KEY_LENGTH]; -}; +} qq_login_data; -struct _qq_interval { +typedef struct _qq_interval { gint resend; gint keep_alive; gint update; -}; +} qq_interval; -struct _qq_net_stat { +typedef struct _qq_net_stat { glong sent; glong resend; glong lost; glong rcved; glong rcved_dup; -}; +} qq_net_stat; -struct _qq_buddy_data { +typedef struct _qq_buddy_data { UID uid; guint16 face; /* index: 0 - 299 */ guint8 age; @@ -108,7 +101,7 @@ gchar** memo; gint8 role; /* role in group, used only in group->members list */ -}; +} qq_buddy_data; typedef struct _qq_connection qq_connection; struct _qq_connection { @@ -122,7 +115,7 @@ int tcp_rxlen; }; -struct _qq_data { +typedef struct _qq_data { PurpleConnection *gc; GSList *openconns; @@ -194,6 +187,6 @@ guint32 custom; guint16 send_im_id; /* send IM sequence number */ -}; +} qq_data; #endif
--- a/libpurple/protocols/qq/qq_define.h Sun Feb 06 05:26:52 2011 +0000 +++ b/libpurple/protocols/qq/qq_define.h Sun Feb 06 06:43:26 2011 +0000 @@ -37,6 +37,7 @@ #define QQ_CLIENT_111D 0x111D /* QQ2007 */ #define QQ_CLIENT_115B 0x115B /* QQ2008 He Sui */ #define QQ_CLIENT_1663 0x1663 /* QQ2009 Release */ +#define QQ_CLIENT_1801 0x1801 /* QQ2009 International Beta1 */ const gchar *qq_get_ver_desc(gint source);
--- a/libpurple/protocols/qq/qq_network.c Sun Feb 06 05:26:52 2011 +0000 +++ b/libpurple/protocols/qq/qq_network.c Sun Feb 06 06:43:26 2011 +0000 @@ -42,11 +42,11 @@ #define QQ_DEFAULT_PORT 8000 /* set QQ_CONNECT_MAX to 1, when test reconnecting */ -#define QQ_CONNECT_MAX 3 +#define QQ_CONNECT_MAX 3 #define QQ_CONNECT_INTERVAL 2 -#define QQ_CONNECT_CHECK 5 -#define QQ_KEEP_ALIVE_INTERVAL 60 -#define QQ_TRANS_INTERVAL 10 +#define QQ_CONNECT_CHECK 5 +#define QQ_KEEP_ALIVE_INTERVAL 60 +#define QQ_TRANS_INTERVAL 10 gboolean connect_to_server(PurpleConnection *gc, gchar *server, gint port); @@ -63,6 +63,7 @@ static qq_connection *connection_create(qq_data *qd, int fd) { qq_connection *ret = g_new0(qq_connection, 1); + g_return_val_if_fail(ret != NULL, NULL); ret->fd = fd; qd->openconns = g_slist_append(qd->openconns, ret); return ret; @@ -772,9 +773,14 @@ } /* _qq_show_socket("Got login socket", source); */ + /* ok, already connected to the server */ qd->fd = source; conn = connection_create(qd, source); + g_return_if_fail( conn != NULL ); + if (qd->use_tcp) { + /* events which match "PURPLE_INPUT_READ" of + * "source" would trigger the callback function */ conn->input_handler = purple_input_add(source, PURPLE_INPUT_READ, tcp_pending, gc); } else { conn->input_handler = purple_input_add(source, PURPLE_INPUT_READ, udp_pending, gc);
--- a/libpurple/protocols/qq/qq_trans.c Sun Feb 06 05:26:52 2011 +0000 +++ b/libpurple/protocols/qq/qq_trans.c Sun Feb 06 06:43:26 2011 +0000 @@ -42,25 +42,6 @@ QQ_TRANS_IS_REPLY = 0x08 /* server command before login*/ }; -struct _qq_transaction { - guint8 flag; - guint16 seq; - guint16 cmd; - - guint8 room_cmd; - guint32 room_id; - - guint8 *data; - gint data_len; - - gint fd; - gint send_retries; - gint rcved_times; - gint scan_times; - - UPDCLS update_class; - guint32 ship32; -}; gboolean qq_trans_is_server(qq_transaction *trans) {
--- a/libpurple/protocols/qq/qq_trans.h Sun Feb 06 05:26:52 2011 +0000 +++ b/libpurple/protocols/qq/qq_trans.h Sun Feb 06 06:43:26 2011 +0000 @@ -28,7 +28,25 @@ #include <glib.h> #include "qq.h" -typedef struct _qq_transaction qq_transaction; +typedef struct _qq_transaction { + guint8 flag; + guint16 seq; + guint16 cmd; + + guint8 room_cmd; + guint32 room_id; + + guint8 *data; + gint data_len; + + gint fd; + gint send_retries; + gint rcved_times; + gint scan_times; + + UPDCLS update_class; + guint32 ship32; +} qq_transaction; qq_transaction *qq_trans_find_rcved(PurpleConnection *gc, guint16 cmd, guint16 seq); gboolean qq_trans_is_server(qq_transaction *trans) ;