Mercurial > pidgin.yaz
diff libpurple/protocols/qq/buddy_info.c @ 24026:25f62d21b3f8
disapproval of revision '8cebefbc6cd5d84acb69c74e69e8821f11dd225d'
author | Daniel Atallah <daniel.atallah@gmail.com> |
---|---|
date | Mon, 15 Sep 2008 03:04:07 +0000 |
parents | 147ada94a1d8 |
children | 225e0e9e1055 |
line wrap: on
line diff
--- a/libpurple/protocols/qq/buddy_info.c Thu Sep 11 13:25:07 2008 +0000 +++ b/libpurple/protocols/qq/buddy_info.c Mon Sep 15 03:04:07 2008 +0000 @@ -284,7 +284,7 @@ qd = (qq_data *) gc->proto_data; g_snprintf(uid_str, sizeof(uid_str), "%d", uid); - qq_send_cmd(gc, QQ_CMD_GET_USER_INFO, (guint8 *) uid_str, strlen(uid_str)); + qq_send_cmd(qd, QQ_CMD_GET_USER_INFO, (guint8 *) uid_str, strlen(uid_str)); query = g_new0(qq_info_query, 1); query->uid = uid; @@ -293,20 +293,6 @@ qd->info_query = g_list_append(qd->info_query, query); } -void qq_request_buddy_info(PurpleConnection *gc, guint32 uid, - gint update_class, guint32 ship32) -{ - qq_data *qd; - gchar raw_data[16] = {0}; - - g_return_if_fail(uid != 0); - - qd = (qq_data *) gc->proto_data; - g_snprintf(raw_data, sizeof(raw_data), "%d", uid); - qq_send_cmd_mess(gc, QQ_CMD_GET_USER_INFO, (guint8 *) raw_data, strlen(raw_data), - update_class, ship32); -} - /* set up the fields requesting personal information and send a get_info packet * for myself */ void qq_prepare_modify_info(PurpleConnection *gc) @@ -328,6 +314,7 @@ /* send packet to modify personal information */ static void qq_send_packet_modify_info(PurpleConnection *gc, contact_info *info) { + qq_data *qd = (qq_data *) gc->proto_data; gint bytes = 0; guint8 raw_data[MAX_PACKET_SIZE - 128] = {0}; guint8 bar; @@ -459,7 +446,7 @@ bytes += qq_put8(raw_data + bytes, bar); - qq_send_cmd(gc, QQ_CMD_UPDATE_INFO, raw_data, bytes); + qq_send_cmd(qd, QQ_CMD_UPDATE_INFO, raw_data, bytes); } @@ -710,8 +697,8 @@ data[data_len] = '\0'; if (qd->uid == atoi((gchar *) data)) { /* return should be my uid */ - purple_debug_info("QQ", "Update info ACK OK\n"); - purple_notify_info(gc, NULL, _("My information has been updated"), NULL); + purple_debug(PURPLE_DEBUG_INFO, "QQ", "Update info ACK OK\n"); + purple_notify_info(gc, NULL, _("Your information has been updated"), NULL); } } @@ -759,8 +746,8 @@ const gchar *buddy_icon_dir = qq_buddy_icon_dir(); gint prefix_len = strlen(QQ_ICON_PREFIX); gint suffix_len = strlen(QQ_ICON_SUFFIX); - gint dir_len = strlen(buddy_icon_dir); - gchar *errmsg = g_strdup_printf(_("Setting custom faces is not currently supported. Please choose an image from %s."), buddy_icon_dir); + gint dir_len = buddy_icon_dir ? strlen(buddy_icon_dir) : 0; + gchar *errmsg = g_strdup_printf(_("Setting custom faces is not currently supported. Please choose an image from %s."), buddy_icon_dir ? buddy_icon_dir : "(null)"); gboolean icon_global = purple_account_get_bool(gc->account, "use-global-buddyicon", TRUE); if (!icon_path) @@ -769,13 +756,13 @@ icon_len = strlen(icon_path) - dir_len - 1 - prefix_len - suffix_len; /* make sure we're using an appropriate icon */ - if (!(g_ascii_strncasecmp(icon_path, buddy_icon_dir, dir_len) == 0 + if (buddy_icon_dir && !(g_ascii_strncasecmp(icon_path, buddy_icon_dir, dir_len) == 0 && icon_path[dir_len] == G_DIR_SEPARATOR && g_ascii_strncasecmp(icon_path + dir_len + 1, QQ_ICON_PREFIX, prefix_len) == 0 && g_ascii_strncasecmp(icon_path + dir_len + 1 + prefix_len + icon_len, QQ_ICON_SUFFIX, suffix_len) == 0 && icon_len <= 3)) { if (icon_global) - purple_debug_error("QQ", "%s\n", errmsg); + purple_debug(PURPLE_DEBUG_ERROR, "QQ", "%s\n", errmsg); else purple_notify_error(gc, _("Invalid QQ Face"), errmsg, NULL); g_free(errmsg); @@ -788,7 +775,7 @@ /* ensure face number in proper range */ if (icon_num > QQ_FACES) { if (icon_global) - purple_debug_error("QQ", "%s\n", errmsg); + purple_debug(PURPLE_DEBUG_ERROR, "QQ", "%s\n", errmsg); else purple_notify_error(gc, _("Invalid QQ Face"), errmsg, NULL); g_free(errmsg); @@ -811,8 +798,8 @@ if ((buddy = purple_find_buddy(account, name))) old_icon_num = purple_buddy_icons_get_checksum_for_user(buddy); - if (old_icon_num == NULL || - strcmp(icon_num_str, old_icon_num)) + if ((old_icon_num == NULL || + strcmp(icon_num_str, old_icon_num)) && (qq_buddy_icon_dir() != NULL)) { gchar *icon_path; @@ -915,21 +902,19 @@ void qq_info_query_free(qq_data *qd) { - gint count; + gint i; qq_info_query *p; g_return_if_fail(qd != NULL); - count = 0; + i = 0; while (qd->info_query != NULL) { p = (qq_info_query *) (qd->info_query->data); qd->info_query = g_list_remove(qd->info_query, p); g_free(p); - count++; + i++; } - if (count > 0) { - purple_debug_info("QQ", "%d info queries are freed!\n", count); - } + purple_debug(PURPLE_DEBUG_INFO, "QQ", "%d info queries are freed!\n", i); } void qq_send_packet_get_level(PurpleConnection *gc, guint32 uid) @@ -942,10 +927,10 @@ bytes += qq_put32(buf + bytes, uid); qd = (qq_data *) gc->proto_data; - qq_send_cmd(gc, QQ_CMD_GET_LEVEL, buf, bytes); + qq_send_cmd(qd, QQ_CMD_GET_LEVEL, buf, bytes); } -void qq_request_get_buddies_levels(PurpleConnection *gc, gint update_class) +void qq_send_packet_get_buddies_levels(PurpleConnection *gc) { guint8 *buf; guint16 size; @@ -957,11 +942,12 @@ if ( qd->buddies == NULL) { return; } - /* server only reply levels for online buddies */ - size = 4 * g_list_length(qd->buddies) + 1 + 4; + /* 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_newa(guint8, size); bytes += qq_put8(buf + bytes, 0x00); - + while (NULL != node) { q_bud = (qq_buddy *) node->data; if (NULL != q_bud) { @@ -969,10 +955,7 @@ } node = node->next; } - - /* my id should be the end if included */ - bytes += qq_put32(buf + bytes, qd->uid); - qq_send_cmd_mess(gc, QQ_CMD_GET_LEVEL, buf, size, update_class, 0); + qq_send_cmd(qd, QQ_CMD_GET_LEVEL, buf, size); } void qq_process_get_level_reply(guint8 *decr_buf, gint decr_len, PurpleConnection *gc) @@ -987,9 +970,9 @@ qq_data *qd = (qq_data *) gc->proto_data; gint bytes = 0; - decr_len--; + decr_len--; if (decr_len % 12 != 0) { - purple_debug_error("QQ", + purple_debug(PURPLE_DEBUG_ERROR, "QQ", "Get levels list of abnormal length. Truncating last %d bytes.\n", decr_len % 12); decr_len -= (decr_len % 12); } @@ -997,18 +980,19 @@ bytes += 1; /* this byte seems random */ /* - purple_debug_info("QQ", "Byte one of get_level packet: %d\n", buf[0]); + purple_debug(PURPLE_DEBUG_INFO, "QQ", "Byte one of get_level packet: %d\n", buf[0]); */ for (i = 0; i < decr_len; i += 12) { bytes += qq_get32(&uid, decr_buf + bytes); bytes += qq_get32(&onlineTime, decr_buf + bytes); bytes += qq_get16(&level, decr_buf + bytes); bytes += qq_get16(&timeRemainder, decr_buf + bytes); - purple_debug_info("QQ_LEVEL", "%d, tmOnline: %d, level: %d, tmRemainder: %d\n", + purple_debug(PURPLE_DEBUG_INFO, "QQ_LEVEL", + "%d, tmOnline: %d, level: %d, tmRemainder: %d\n", uid, onlineTime, level, timeRemainder); if (uid == qd->uid) { qd->my_level = level; - purple_debug_warning("QQ", "Got my levels as %d\n", qd->my_level); + purple_debug(PURPLE_DEBUG_WARNING, "QQ", "Got my levels as %d\n", qd->my_level); continue; } @@ -1016,7 +1000,7 @@ if (purple_name == NULL) { continue; } - + b = purple_find_buddy(account, purple_name); g_free(purple_name); @@ -1024,9 +1008,10 @@ if (b != NULL) { q_bud = (qq_buddy *) b->proto_data; } - + if (q_bud == NULL) { - purple_debug_error("QQ", "Got levels of %d not in my buddy list\n", uid); + purple_debug(PURPLE_DEBUG_ERROR, "QQ", + "Got levels of %d not in my buddy list\n", uid); continue; }