pidgin: 69fe7229: 20080717-05-1-fix-keep-alive ccpaging <e...
csyfek at gmail.com
csyfek at gmail.com
Thu Jul 17 11:20:51 EDT 2008
-----------------------------------------------------------------
Revision: 69fe72292fbbcc2a86b3bcc305e11608002ec176
Ancestor: 7bb9ee4f51b9f32e2764aa3a6dcd765b2af2e7f6
Author: csyfek at gmail.com
Date: 2008-07-17T15:12:42
Branch: im.pidgin.pidgin
URL: http://d.pidgin.im/viewmtn/revision/info/69fe72292fbbcc2a86b3bcc305e11608002ec176
Modified files:
libpurple/protocols/qq/AUTHORS
libpurple/protocols/qq/ChangeLog
libpurple/protocols/qq/buddy_info.c
libpurple/protocols/qq/buddy_list.c
libpurple/protocols/qq/buddy_status.c
libpurple/protocols/qq/char_conv.c
libpurple/protocols/qq/char_conv.h
libpurple/protocols/qq/group_conv.c
libpurple/protocols/qq/group_free.c
libpurple/protocols/qq/group_info.c
libpurple/protocols/qq/group_internal.c
libpurple/protocols/qq/qq.c
libpurple/protocols/qq/qq_network.c
libpurple/protocols/qq/qq_trans.c
libpurple/protocols/qq/qq_trans.h
libpurple/protocols/qq/send_file.c
ChangeLog:
20080717-05-1-fix-keep-alive ccpaging <ecc_hy(at)hotmail.com>
* Fixed: Always lost connection. Now send keep alive packet in every 30 seconds
* Minor fix for debug information
* Filter \r\n and replace with SPCAE in group notive
* Fixed a memory leak
Tickets:
Fixes #4024.
-------------- next part --------------
============================================================
--- libpurple/protocols/qq/AUTHORS a7cd1db3e79e2eb577c783c684bd54061553c4cc
+++ libpurple/protocols/qq/AUTHORS c46c7dfe83578267955d8b41cb3a2e3df7c44577
@@ -16,7 +16,7 @@ Lovely Patch Writers
Lovely Patch Writers
=====
-Gnap.An : message displaying, documentation
+gnap : message displaying, documentation
manphiz : qun processing
moo : qun processing
Coly Li : qun processing
@@ -32,4 +32,4 @@ LumaQQ Team
rlaager at pidgin.im
OpenQ Team
LumaQQ Team
+OpenQ Google Group
-OpenQ at GoogleGroup
============================================================
--- libpurple/protocols/qq/ChangeLog eb16c476d9e3f03d5c027d23ffb00027c0cf33b7
+++ libpurple/protocols/qq/ChangeLog 73a8bc69881e60328d0e872cd5a55257665a6483
@@ -1,3 +1,11 @@
+2008.07.12 - ccpaging <ecc_hy(at)hotmail.com>
+ * Fixed: Always lost connection. Now send keep alive packet in every 30 seconds
+ * Minor fix for debug information
+ * Filter \r\n and replace with SPCAE in group notive
+ * Fixed a memory leak
+ * Tickets:
+ * Fixes #4024.
+
2008.06.29 - csyfek <csyfek(at)gmail.com>
* Minor bug fix
* Add some doxygen syntax for preparing development documentation
============================================================
--- libpurple/protocols/qq/buddy_info.c 504fbb2f1055b3d5f890990f0b85351596e51722
+++ libpurple/protocols/qq/buddy_info.c 3cff03ecf256f61a931ead954f452c2b137d0a89
@@ -208,8 +208,8 @@ static gboolean append_field_value(Purpl
return FALSE;
}
- static PurpleNotifyUserInfo *
-info_to_notify_user_info(const contact_info *info)
+static PurpleNotifyUserInfo *
+ info_to_notify_user_info(const contact_info *info)
{
PurpleNotifyUserInfo *user_info = purple_notify_user_info_new();
const gchar *intro;
@@ -826,7 +826,8 @@ static void qq_refresh_buddy_and_myself(
PurpleBuddy *b;
qq_data *qd;
qq_buddy *q_bud;
- gchar *alias_utf8, *purple_name;
+ gchar *alias_utf8;
+ gchar *purple_name;
PurpleAccount *account = purple_connection_get_account(gc);
qd = (qq_data *) gc->proto_data;
@@ -1009,7 +1010,7 @@ void qq_process_get_level_reply(guint8 *
bytes += qq_get16(&level, decr_buf + bytes);
bytes += qq_get16(&timeRemainder, decr_buf + bytes);
purple_debug(PURPLE_DEBUG_INFO, "QQ",
- "Level packet entry:\nuid: %d\nonlineTime: %d\nlevel: %d\ntimeRemainder: %d\n",
+ "Level uid: %d, onlineTime: %d, level: %d, timeRemainder: %d\n",
uid, onlineTime, level, timeRemainder);
purple_name = uid_to_purple_name(uid);
b = purple_find_buddy(account, purple_name);
============================================================
--- libpurple/protocols/qq/buddy_list.c 2947ad8ba369c38260acf0225e1a10c6114acdc8
+++ libpurple/protocols/qq/buddy_list.c 906b0927b04501015c5124a010240d4b5f857f04
@@ -234,12 +234,11 @@ void qq_process_get_buddies_online_reply
"qq_process_get_buddies_online_reply: Dangerous error! maybe protocol changed, notify developers!\n");
}
- if (position != QQ_FRIENDS_ONLINE_POSITION_END) {
- purple_debug(PURPLE_DEBUG_INFO, "QQ", "Received %d online buddies, nextposition=%u\n",
- count, (guint) position);
- if (position != QQ_FRIENDS_ONLINE_POSITION_START) {
- purple_debug(PURPLE_DEBUG_INFO, "QQ", "Requesting for more online buddies\n");
- }
+ purple_debug(PURPLE_DEBUG_INFO, "QQ", "Received %d online buddies, nextposition=%u\n",
+ count, (guint) position);
+ if (position != QQ_FRIENDS_ONLINE_POSITION_END
+ && position != QQ_FRIENDS_ONLINE_POSITION_START) {
+ purple_debug(PURPLE_DEBUG_INFO, "QQ", "Requesting for more online buddies\n");
qq_send_packet_get_buddies_online(gc, position);
} else {
purple_debug(PURPLE_DEBUG_INFO, "QQ", "All online buddies received\n");
@@ -318,8 +317,8 @@ void qq_process_get_buddies_list_reply(g
if (QQ_DEBUG) {
purple_debug(PURPLE_DEBUG_INFO, "QQ",
- "buddy [%09d]: flag1=0x%02x, comm_flag=0x%02x\n",
- q_bud->uid, q_bud->flag1, q_bud->comm_flag);
+ "buddy [%09d]: flag1=0x%02x, comm_flag=0x%02x, nick=%s\n",
+ q_bud->uid, q_bud->flag1, q_bud->comm_flag, q_bud->nickname);
}
name = uid_to_purple_name(q_bud->uid);
@@ -432,7 +431,9 @@ void qq_process_get_all_list_with_group_
purple_debug(PURPLE_DEBUG_INFO, "QQ", "Get all list done, %d buddies and %d Quns\n", i, j);
purple_debug(PURPLE_DEBUG_INFO, "QQ", "Received %d buddies and %d groups, nextposition=%u\n", i, j, (guint) position);
- if (position != QQ_FRIENDS_ALL_LIST_POSITION_START && position != QQ_FRIENDS_ALL_LIST_POSITION_START) {
+
+ if (position != QQ_FRIENDS_ALL_LIST_POSITION_START
+ && position != QQ_FRIENDS_ALL_LIST_POSITION_END) {
purple_debug(PURPLE_DEBUG_INFO, "QQ", "Requesting for more buddies and groups\n");
qq_send_packet_get_all_list_with_group(gc, position);
} else {
============================================================
--- libpurple/protocols/qq/buddy_status.c 515b95f95274e31f9956938e55f12998ebc0e9fc
+++ libpurple/protocols/qq/buddy_status.c 95284f43ad9a812df08ae0cc585c690dffdbea22
@@ -205,7 +205,9 @@ void qq_process_change_status_reply(guin
b = purple_find_buddy(gc->account, name);
g_free(name);
q_bud = (b == NULL) ? NULL : (qq_buddy *) b->proto_data;
- qq_update_buddy_contact(gc, q_bud);
+ if (q_bud != NULL) {
+ qq_update_buddy_contact(gc, q_bud);
+ }
}
}
============================================================
--- libpurple/protocols/qq/char_conv.c ac1eabef8b90f8a8f84bf1e685c04552a9172c37
+++ libpurple/protocols/qq/char_conv.c 316f649d60fd1d167e8c038238600efa2ee39e88
@@ -123,10 +123,7 @@ static gchar *_my_convert(const gchar *s
return g_strdup(QQ_NULL_MSG);
}
-/**
- * @brief æè¾å
¥ä½ä¸ºä¸ä¸ªpascalå符串并è¿åä¸ä¸ªç¨UFT-8转æ¢çc-å符串.\n
- * è¿å已读å
¥çåèæ°,æè
å½éå°é误æ¶è¿å-1.该å®æ转æ¢çUTF-8å符串被ä¿åå°retä¸
- *
+/*
* take the input as a pascal string and return a converted c-string in UTF-8
* returns the number of bytes read, return -1 if fatal error
* the converted UTF-8 will be saved in ret
@@ -281,3 +278,17 @@ gchar *purple_smiley_to_qq(gchar *text)
g_string_free(converted, FALSE);
return ret;
}
+
+void qq_filter_str(gchar *str) {
+ gchar *temp;
+ if (str == NULL) {
+ return;
+ }
+
+ for (temp = str; *temp != 0; temp++) {
+ if (*temp == '\r' || *temp == '\n') *temp = 0x20;
+ }
+ g_strstrip(str);
+}
+
+
============================================================
--- libpurple/protocols/qq/char_conv.h 8b33a04658fce7e31e2801fe57c2f609b64c3c93
+++ libpurple/protocols/qq/char_conv.h c982dd5edde48bc1ff655d59a9c762b9fd162fde
@@ -40,5 +40,5 @@ gchar *qq_im_filter_html(const gchar *te
gchar *qq_encode_to_purple(guint8 *font_attr_data, gint len, const gchar *msg);
gchar *qq_im_filter_html(const gchar *text);
-
+void qq_filter_str(gchar *str);
#endif
============================================================
--- libpurple/protocols/qq/group_conv.c 8b1eca3dc78407f91ff817f6706a1ae9615c61a7
+++ libpurple/protocols/qq/group_conv.c 06a153c6094980988b32679ba7b6f872810ee7e9
@@ -99,7 +99,9 @@ void qq_group_conv_refresh_online_member
list = list->next;
}
- purple_conv_chat_add_users(PURPLE_CONV_CHAT(conv), names, NULL, flags, FALSE);
+ if (names != NULL && flags != NULL) {
+ purple_conv_chat_add_users(PURPLE_CONV_CHAT(conv), names, NULL, flags, FALSE);
+ }
}
/* clean up names */
while (names != NULL) {
============================================================
--- libpurple/protocols/qq/group_free.c 34a94a81da2e4f7d1fa64359e26ded3719f0a0db
+++ libpurple/protocols/qq/group_free.c a6e02a48de11d2ecd297a223947daa62a5e5531c
@@ -55,8 +55,10 @@ void qq_group_free(qq_group *group)
{
g_return_if_fail(group != NULL);
qq_group_free_member(group);
+ g_free(group->my_status_desc);
g_free(group->group_name_utf8);
g_free(group->group_desc_utf8);
+ g_free(group->notice_utf8);
g_free(group);
}
============================================================
--- libpurple/protocols/qq/group_info.c fb1b7bc15297840b41f1c1e120e2b3dd4788c5ab
+++ libpurple/protocols/qq/group_info.c c5dbfee778718acbbeac596e79d5f23bc86e99be
@@ -87,7 +87,7 @@ void qq_send_cmd_group_get_online_member
/* only get online members when conversation window is on */
if (NULL == purple_find_conversation_with_account(PURPLE_CONV_TYPE_CHAT,group->group_name_utf8, purple_connection_get_account(gc))) {
purple_debug(PURPLE_DEBUG_WARNING, "QQ",
- "Conv windows for \"%s\" is not on, do not get online members\n", group->group_name_utf8);
+ "Conversation for \"%s\" is not open, ignore to get online members\n", group->group_name_utf8);
return;
}
@@ -141,9 +141,6 @@ void qq_send_cmd_group_get_members_info(
qq_send_group_cmd(gc, group, raw_data, bytes);
}
-/**
- * @brief å¤ç群信æ¯.å½å群信æ¯çå¤çè¿ä¸å®å,ç±äºçæ¬çä¸å导è´åè®®ç解读æå·®å¼.
- */
void qq_process_group_cmd_get_group_info(guint8 *data, gint len, PurpleConnection *gc)
{
qq_group *group;
@@ -157,6 +154,7 @@ void qq_process_group_cmd_get_group_info
guint32 unknown4;
guint8 unknown1;
gint bytes, num;
+ gchar *notice;
g_return_if_fail(data != NULL && len > 0);
qd = (qq_data *) gc->proto_data;
@@ -186,22 +184,20 @@ void qq_process_group_cmd_get_group_info
bytes += qq_get32(&(group->group_category), data + bytes);
bytes += qq_get16(&max_members, data + bytes);
bytes += qq_get8(&unknown1, data + bytes);
- /* XXX
- * the following, while Eva:
+ /* the following, while Eva:
* 4(unk), 4(verID), 1(nameLen), nameLen(qunNameContent), 1(0x00),
* 2(qunNoticeLen), qunNoticeLen(qunNoticeContent, 1(qunDescLen),
* qunDestLen(qunDestcontent)) */
bytes += qq_get8(&unknown1, data + bytes);
- purple_debug(PURPLE_DEBUG_INFO, "QQ", "type=%u creatorid=%u category=%u\n",
- group->group_type, group->creator_uid, group->group_category);
- purple_debug(PURPLE_DEBUG_INFO, "QQ", "maxmembers=%u", max_members);
+ purple_debug(PURPLE_DEBUG_INFO, "QQ", "type=%u creatorid=%u category=%u maxmembers=%u\n",
+ group->group_type, group->creator_uid, group->group_category, max_members);
/* strlen + <str content> */
bytes += convert_as_pascal_string(data + bytes, &(group->group_name_utf8), QQ_CHARSET_DEFAULT);
purple_debug(PURPLE_DEBUG_INFO, "QQ", "group \"%s\"\n", group->group_name_utf8);
bytes += qq_get16(&unknown, data + bytes); /* 0x0000 */
- bytes += convert_as_pascal_string(data + bytes, &(group->notice_utf8), QQ_CHARSET_DEFAULT);
- purple_debug(PURPLE_DEBUG_INFO, "QQ", "notice \"%s\"\n", group->notice_utf8);
+ bytes += convert_as_pascal_string(data + bytes, ¬ice, QQ_CHARSET_DEFAULT);
+ purple_debug(PURPLE_DEBUG_INFO, "QQ", "notice \"%s\"\n", notice);
bytes += convert_as_pascal_string(data + bytes, &(group->group_desc_utf8), QQ_CHARSET_DEFAULT);
purple_debug(PURPLE_DEBUG_INFO, "QQ", "group_desc \"%s\"\n", group->group_desc_utf8);
@@ -235,11 +231,16 @@ void qq_process_group_cmd_get_group_info
group->group_name_utf8, purple_connection_get_account(gc));
if(NULL == purple_conv) {
purple_debug(PURPLE_DEBUG_WARNING, "QQ",
- "Conv windows for \"%s\" is not on, do not set topic\n", group->group_name_utf8);
+ "Conversation for \"%s\" is not open, do not set topic\n", group->group_name_utf8);
+ return;
}
- else {
- purple_conv_chat_set_topic(PURPLE_CONV_CHAT(purple_conv), NULL, group->notice_utf8);
- }
+
+ /* filter \r\n in notice */
+ qq_filter_str(notice);
+ group->notice_utf8 = strdup(notice);
+ g_free(notice);
+
+ purple_conv_chat_set_topic(PURPLE_CONV_CHAT(purple_conv), NULL, group->notice_utf8);
}
void qq_process_group_cmd_get_online_members(guint8 *data, gint len, PurpleConnection *gc)
@@ -296,6 +297,7 @@ void qq_process_group_cmd_get_members_in
guint16 unknown;
qq_group *group;
qq_buddy *member;
+ gchar *nick;
g_return_if_fail(data != NULL && len > 0);
@@ -318,11 +320,24 @@ void qq_process_group_cmd_get_members_in
bytes += qq_get16(&(member->face), data + bytes);
bytes += qq_get8(&(member->age), data + bytes);
bytes += qq_get8(&(member->gender), data + bytes);
- bytes += convert_as_pascal_string(data + bytes, &(member->nickname), QQ_CHARSET_DEFAULT);
+ bytes += convert_as_pascal_string(data + bytes, &nick, QQ_CHARSET_DEFAULT);
bytes += qq_get16(&unknown, data + bytes);
bytes += qq_get8(&(member->flag1), data + bytes);
bytes += qq_get8(&(member->comm_flag), data + bytes);
+ /* filter \r\n in nick */
+ qq_filter_str(nick);
+ member->nickname = g_strdup(nick);
+ g_free(nick);
+
+ /*
+ if (QQ_DEBUG) {
+ purple_debug(PURPLE_DEBUG_INFO, "QQ",
+ "member [%09d]: flag1=0x%02x, comm_flag=0x%02x, nick=%s\n",
+ member_uid, member->flag1, member->comm_flag, member->nickname);
+ }
+ */
+
member->last_refresh = time(NULL);
}
if(bytes > len) {
============================================================
--- libpurple/protocols/qq/group_internal.c ec87192a0c342c45a2add0075f5db38309f48b50
+++ libpurple/protocols/qq/group_internal.c 7557c6350e61dd1dc126cacd99c232e4bd820d8a
@@ -230,9 +230,7 @@ void qq_set_pending_id(GSList **list, gu
*list = g_slist_remove(*list, GINT_TO_POINTER(id));
}
-/**
- * @brief Return the location of id in list, or NULL if not found (è¿åidå¨é¾è¡¨ä¸çä½ç½®,没ææ¾å°åè¿åNULL)
- */
+/* Return the location of id in list, or NULL if not found */
GSList *qq_get_pending_id(GSList *list, guint32 id)
{
return g_slist_find(list, GINT_TO_POINTER(id));
============================================================
--- libpurple/protocols/qq/qq.c eafe3b1975ca1d7d1bbbac63e0d0d95f709de8cb
+++ libpurple/protocols/qq/qq.c ec0c1145646c14c17ea491407e2cc6ac75adac39
@@ -749,7 +749,6 @@ static PurplePluginProtocolInfo prpl_inf
NULL,
NULL,
NULL,
- sizeof(PurplePluginProtocolInfo), /* struct_size */
NULL
};
============================================================
--- libpurple/protocols/qq/qq_network.c 4ddd81310ea1c6ad22702fc19e5b75d74a58d293
+++ libpurple/protocols/qq/qq_network.c 6ad4cae7efb0f7cd017ebc0ac3beebbf0c90570f
@@ -189,13 +189,13 @@ static gboolean packet_is_dup(qq_data *q
return FALSE; /* set mask */
}
-static gboolean packet_check_ack(qq_data *qd, guint16 seq)
+static gboolean packet_check_ack(qq_data *qd, guint16 cmd, guint16 seq)
{
gpointer trans;
g_return_val_if_fail(qd != NULL, FALSE);
- trans = qq_send_trans_find(qd, seq);
+ trans = qq_send_trans_find(qd, cmd, seq);
if (trans == NULL) {
return FALSE;
}
@@ -360,7 +360,7 @@ static void packet_process(PurpleConnect
/* ack packet, we need to update send tranactions */
/* we do not check duplication for server ack */
- is_reply = packet_check_ack(qd, seq);
+ is_reply = packet_check_ack(qd, cmd, seq);
if ( !is_reply ) {
if ( !qd->logged_in ) {
/* packets before login */
@@ -460,7 +460,10 @@ static void tcp_pending(gpointer data, g
return;
}
- gc->last_received = time(NULL);
+ /* keep alive will be sent in 30 seconds since last_receive
+ * QQ need a keep alive packet in every 60 seconds
+ gc->last_received = time(NULL);
+ */
purple_debug(PURPLE_DEBUG_INFO, "TCP_PENDING",
"Read %d bytes from socket, rxlen is %d\n", buf_len, qd->tcp_rxlen);
qd->tcp_rxqueue = g_realloc(qd->tcp_rxqueue, buf_len + qd->tcp_rxlen);
@@ -565,7 +568,10 @@ static void udp_pending(gpointer data, g
return;
}
- gc->last_received = time(NULL);
+ /* keep alive will be sent in 30 seconds since last_receive
+ * QQ need a keep alive packet in every 60 seconds
+ gc->last_received = time(NULL);
+ */
if (buf_len < QQ_UDP_HEADER_LENGTH) {
if (buf[0] != QQ_PACKET_TAG || buf[buf_len - 1] != QQ_PACKET_TAIL) {
@@ -1240,7 +1246,6 @@ gint qq_send_cmd_detail(qq_data *qd, gui
}
if (QQ_DEBUG) {
- qq_show_packet("QQ_SEND_CMD", buf, buf_len);
purple_debug(PURPLE_DEBUG_INFO, "QQ",
"<== [%05d], %s, total %d bytes is sent %d\n",
seq, qq_get_cmd_desc(cmd), buf_len, bytes_sent);
============================================================
--- libpurple/protocols/qq/qq_trans.c f88e7f28beaef9d40a60caac32d0eac9ab81730f
+++ libpurple/protocols/qq/qq_trans.c c7e1d07b62f30ee8f95051c33568438fbd31ceb8
@@ -83,7 +83,7 @@ void qq_send_trans_remove(qq_data *qd, g
g_free(trans);
}
-gpointer qq_send_trans_find(qq_data *qd, guint16 seq)
+gpointer qq_send_trans_find(qq_data *qd, guint16 cmd, guint16 seq)
{
GList *curr;
GList *next;
@@ -93,7 +93,7 @@ gpointer qq_send_trans_find(qq_data *qd,
while(curr) {
next = curr->next;
trans = (transaction *) (curr->data);
- if(trans->seq == seq) {
+ if(trans->cmd == cmd && trans->seq == seq) {
return trans;
}
curr = next;
============================================================
--- libpurple/protocols/qq/qq_trans.h 80f8f5efcf8181555ed864d4a9cf3ebcf93154c2
+++ libpurple/protocols/qq/qq_trans.h c385d8b826f9efcbe8b48e9d0cef782be95dfc96
@@ -30,7 +30,7 @@ void qq_send_trans_remove(qq_data *qd, g
void qq_send_trans_append(qq_data *qd, guint8 *buf, gint bus_len, guint16 cmd, guint16 seq);
void qq_send_trans_remove(qq_data *qd, gpointer data);
-gpointer qq_send_trans_find(qq_data *qd, guint16 seq);
+gpointer qq_send_trans_find(qq_data *qd, guint16 cmd, guint16 seq);
void qq_send_trans_remove_all(qq_data *qd);
gint qq_send_trans_scan(qq_data *qd, gint *start, guint8 *buf, gint maxlen, guint16 *cmd, gint *retries);
============================================================
--- libpurple/protocols/qq/send_file.c 36ad098272b3bf1e68d125e2896f08ad46adf9f4
+++ libpurple/protocols/qq/send_file.c d11d0018e84e3afb67be3475bd9c19ea974711ca
@@ -156,7 +156,7 @@ static void _qq_xfer_recv_packet(gpointe
gint size;
/* FIXME: It seems that the transfer never use a packet
* larger than 1500 bytes, so if it happened to be a
- * larger packet, either error occurred or protocol should
+ * larger packet, either error occured or protocol should
* be modified
*/
ft_info *info;
More information about the Commits
mailing list