# HG changeset patch # User Mark Huetsch # Date 1168377418 0 # Node ID e9db26a103eb61c198f9e001d4dbad220f99e54f # Parent 78ff267f50e3007143e78ea119972ca88f36517e [gaim-migrate @ 18097] Keep track of my level. Don't send an empty get_levels packet when we don't have any buddies because the server won't ack it. Refreshing buddy levels every 10 minutes is overki ll, don't do it. committer: Tailor Script diff -r 78ff267f50e3 -r e9db26a103eb libgaim/protocols/qq/buddy_info.c --- a/libgaim/protocols/qq/buddy_info.c Tue Jan 09 01:54:32 2007 +0000 +++ b/libgaim/protocols/qq/buddy_info.c Tue Jan 09 21:16:58 2007 +0000 @@ -745,27 +745,29 @@ { guint8 *buf, *tmp, size; qq_buddy *q_bud; - GList *node; qq_data *qd = (qq_data *) gc->proto_data; + GList *node = qd->buddies; - /* server only sends back levels for online buddies, no point - * in asking for anyone else */ - size = 4*g_list_length(qd->buddies) + 1; - buf = g_new0(guint8, size); - tmp = buf + 1; + if (qd->buddies) { + /* server only sends back levels for online buddies, no point + * in asking for anyone else */ + size = 4*g_list_length(qd->buddies) + 1; + buf = g_new0(guint8, size); + tmp = buf + 1; - for (node = qd->buddies; node != NULL; node = node->next) { - guint32 tmp4; - q_bud = (qq_buddy *) node->data; - if (q_bud != NULL) { - tmp4 = g_htonl(q_bud->uid); - memcpy(tmp, &tmp4, 4); - tmp += 4; + while (node != NULL) { + guint32 tmp4; + q_bud = (qq_buddy *) node->data; + if (q_bud != NULL) { + tmp4 = g_htonl(q_bud->uid); + memcpy(tmp, &tmp4, 4); + tmp += 4; + } + node = node->next; } + qq_send_cmd(gc, QQ_CMD_GET_LEVEL, TRUE, 0, TRUE, buf, size); + g_free(buf); } - qq_send_cmd(gc, QQ_CMD_GET_LEVEL, TRUE, 0, TRUE, buf, size); - qd->last_get_levels = time(NULL); - g_free(buf); } void qq_process_get_level_reply(guint8 *buf, gint buf_len, GaimConnection *gc) @@ -815,10 +817,15 @@ b = gaim_find_buddy(account, gaim_name); q_bud = (b == NULL) ? NULL : (qq_buddy *) b->proto_data; - if (q_bud != NULL) { - q_bud->onlineTime = onlineTime; - q_bud->level = level; - q_bud->timeRemainder = timeRemainder; + if (q_bud != NULL || uid == qd->uid) { + if (q_bud) { + q_bud->onlineTime = onlineTime; + q_bud->level = level; + q_bud->timeRemainder = timeRemainder; + } + if (uid == qd->uid) { + qd->my_level = level; + } } else { gaim_debug(GAIM_DEBUG_ERROR, "QQ", "Got an online buddy %d, but not in my buddy list\n", uid); diff -r 78ff267f50e3 -r e9db26a103eb libgaim/protocols/qq/keep_alive.c --- a/libgaim/protocols/qq/keep_alive.c Tue Jan 09 01:54:32 2007 +0000 +++ b/libgaim/protocols/qq/keep_alive.c Tue Jan 09 21:16:58 2007 +0000 @@ -42,7 +42,6 @@ #include "utils.h" #define QQ_UPDATE_ONLINE_INTERVAL 300 /* in sec */ -#define QQ_UPDATE_LEVELS_INTERVAL 600 /* in sec */ /* send keep-alive packet to QQ server (it is a heart-beat) */ void qq_send_packet_keep_alive(GaimConnection *gc) @@ -95,8 +94,6 @@ /* qd->last_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); - if ((time(NULL) - qd->last_get_levels) >= QQ_UPDATE_LEVELS_INTERVAL) - qq_send_packet_get_buddies_levels(gc); } /* refresh all buddies online/offline, diff -r 78ff267f50e3 -r e9db26a103eb libgaim/protocols/qq/login_logout.c --- a/libgaim/protocols/qq/login_logout.c Tue Jan 09 01:54:32 2007 +0000 +++ b/libgaim/protocols/qq/login_logout.c Tue Jan 09 21:16:58 2007 +0000 @@ -230,6 +230,8 @@ /* Now goes on updating my icon/nickname, not showing info_window */ qd->modifying_face = FALSE; qq_send_packet_get_info(gc, qd->uid, FALSE); + /* grab my level */ + qq_send_packet_get_level(gc, qd->uid); qq_send_packet_change_status(gc); diff -r 78ff267f50e3 -r e9db26a103eb libgaim/protocols/qq/qq.h --- a/libgaim/protocols/qq/qq.h Tue Jan 09 01:54:32 2007 +0000 +++ b/libgaim/protocols/qq/qq.h Tue Jan 09 21:16:58 2007 +0000 @@ -95,9 +95,9 @@ gchar *my_ip; /* my ip address detected by server */ guint16 my_port; /* my port detected by server */ guint16 my_icon; /* my icon index */ + guint16 my_level; /* my level */ guint32 all_online; /* the number of online QQ users */ time_t last_get_online; /* last time send get_friends_online packet */ - time_t last_get_levels; /* last time send get_buddies_levels packet */ guint8 window[1 << 13]; /* check up for duplicated packet */ gint sendqueue_timeout;