Mercurial > pidgin
diff src/protocols/qq/keep_alive.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 | 983fd420e86b |
| children | 32a71e64ceae |
line wrap: on
line diff
--- a/src/protocols/qq/keep_alive.c Wed Aug 02 13:37:13 2006 +0000 +++ b/src/protocols/qq/keep_alive.c Wed Aug 02 15:35:36 2006 +0000 @@ -26,25 +26,22 @@ * Puzzlebird, Nov-Dec 2002 */ -// START OF FILE -/*****************************************************************************/ -#include "debug.h" // gaim_debug -#include "server.h" // serv_got_update +#include "debug.h" +#include "server.h" -#include "utils.h" // uid_to_gaim_name -#include "packet_parse.h" // create_packet -#include "buddy_list.h" // qq_send_packet_get_buddies_online -#include "buddy_status.h" // QQ_BUDDY_ONLINE_NORMAL -#include "crypt.h" // qq_crypt -#include "header_info.h" // cmd alias +#include "buddy_list.h" +#include "buddy_status.h" +#include "crypt.h" +#include "header_info.h" #include "keep_alive.h" -#include "send_core.h" // qq_send_cmd - -#define QQ_UPDATE_ONLINE_INTERVAL 300 // in sec +#include "packet_parse.h" +#include "send_core.h" +#include "utils.h" -/*****************************************************************************/ -// send keep-alive packet to QQ server (it is a heart-beat) -void qq_send_packet_keep_alive(GaimConnection * gc) +#define QQ_UPDATE_ONLINE_INTERVAL 300 /* in sec */ + +/* send keep-alive packet to QQ server (it is a heart-beat) */ +void qq_send_packet_keep_alive(GaimConnection *gc) { qq_data *qd; guint8 *raw_data, *cursor; @@ -55,21 +52,19 @@ raw_data = g_newa(guint8, 4); cursor = raw_data; - // In fact, we can send whatever we like to server - // with this command, server return the same result including - // the amount of online QQ users, my ip and port + /* In fact, we can send whatever we like to server + * with this command, server return the same result including + * the amount of online QQ users, my ip and port */ create_packet_dw(raw_data, &cursor, qd->uid); qq_send_cmd(gc, QQ_CMD_KEEP_ALIVE, TRUE, 0, TRUE, raw_data, 4); - -} // qq_send_packet_keep_alive +} -/*****************************************************************************/ -// parse the return of keep-alive packet, it includes some system information -void qq_process_keep_alive_reply(guint8 * buf, gint buf_len, GaimConnection * gc) { +/* parse the return of keep-alive packet, it includes some system information */ +void qq_process_keep_alive_reply(guint8 * buf, gint buf_len, GaimConnection *gc) { qq_data *qd; gint len; - gchar *data, **segments; // the returns are gchar, no need guint8 + gchar *data, **segments; /* the returns are gchar, no need guint8 */ g_return_if_fail(gc != NULL && gc->proto_data != NULL); g_return_if_fail(buf != NULL && buf_len != 0); @@ -79,11 +74,12 @@ data = g_newa(guint8, len); if (qq_crypt(DECRYPT, buf, buf_len, qd->session_key, data, &len)) { - if (NULL == (segments = split_data(data, len, "\x1f", 6 /* 5->6, protocal changed by gfhuang*, the last one is 60, don't know what it is */))) + /* the last one is 60, don't know what it is */ + if (NULL == (segments = split_data(data, len, "\x1f", 6))) return; - // segments[0] and segment[1] are all 0x30 ("0") + /* segments[0] and segment[1] are all 0x30 ("0") */ qd->all_online = strtol(segments[2], NULL, 10); - if(0 == qd->all_online) //added by gfhuang + if(0 == qd->all_online) gaim_connection_error(gc, _("Keep alive error, seems connection lost!")); g_free(qd->my_ip); qd->my_ip = g_strdup(segments[3]); @@ -92,17 +88,15 @@ } else gaim_debug(GAIM_DEBUG_ERROR, "QQ", "Error decrypt keep alive reply\n"); - // we refresh buddies's online status periodically - // qd->lasat_get_online is updated when setting get_buddies_online packet + /* we refresh buddies's online status periodically */ + /* qd->lasat_get_online is updated when setting get_buddies_online packet */ if ((time(NULL) - qd->last_get_online) >= QQ_UPDATE_ONLINE_INTERVAL) qq_send_packet_get_buddies_online(gc, QQ_FRIENDS_ONLINE_POSITION_START); - -} // qq_process_keep_alive_reply +} -/*****************************************************************************/ -// refresh all buddies online/offline, -// after receiving reply for get_buddies_online packet -void qq_refresh_all_buddy_status(GaimConnection * gc) +/* refresh all buddies online/offline, + * after receiving reply for get_buddies_online packet */ +void qq_refresh_all_buddy_status(GaimConnection *gc) { time_t now; GList *list; @@ -119,19 +113,17 @@ while (list != NULL) { q_bud = (qq_buddy *) list->data; if (q_bud != NULL && now > q_bud->last_refresh + QQ_UPDATE_ONLINE_INTERVAL - && q_bud->status != QQ_BUDDY_ONLINE_INVISIBLE) { // by gfhuang + && q_bud->status != QQ_BUDDY_ONLINE_INVISIBLE) { q_bud->status = QQ_BUDDY_ONLINE_OFFLINE; qq_update_buddy_contact(gc, q_bud); } list = list->next; - } // while -} // qq_refresh_all_buddy_status + } +} -/*****************************************************************************/ -void qq_update_buddy_contact(GaimConnection * gc, qq_buddy * q_bud) +void qq_update_buddy_contact(GaimConnection *gc, qq_buddy *q_bud) { gchar *name; -// gboolean online; GaimBuddy *bud; g_return_if_fail(gc != NULL && q_bud != NULL); @@ -140,12 +132,12 @@ g_return_if_fail(bud != NULL); if (bud != NULL) { - gaim_blist_server_alias_buddy(bud, q_bud->nickname); //server by gfhuang + gaim_blist_server_alias_buddy(bud, q_bud->nickname); /* server */ q_bud->last_refresh = time(NULL); - // gaim support signon and idle time - // but it is not much useful for QQ, I do not use them it -// serv_got_update(gc, name, online, 0, q_bud->signon, q_bud->idle, bud->uc); //disable by gfhuang + /* gaim supports signon and idle time + * but it is not much use for QQ, I do not use them */ + /* serv_got_update(gc, name, online, 0, q_bud->signon, q_bud->idle, bud->uc); */ char *status_id = "available"; switch(q_bud->status) { case QQ_BUDDY_OFFLINE: @@ -170,13 +162,10 @@ } gaim_debug(GAIM_DEBUG_INFO, "QQ", "set buddy %d to %s\n", q_bud->uid, status_id); gaim_prpl_got_user_status(gc->account, name, status_id, NULL); - } // if bud - else + } else { gaim_debug(GAIM_DEBUG_ERROR, "QQ", "unknown buddy by gfhuang: %d\n", q_bud->uid); + } gaim_debug(GAIM_DEBUG_INFO, "QQ", "qq_update_buddy_contact, client=%04x\n", q_bud->client_version); g_free(name); -} // qq_update_buddy_contact - -/*****************************************************************************/ -// END OF FILE +}
