Mercurial > pidgin
changeset 24155:3c52353b83ae
2008.10.08 - ccpaging <ccpaging(at)gmail.com>
* 20081008-1
author | SHiNE CsyFeK <csyfek@gmail.com> |
---|---|
date | Tue, 28 Oct 2008 16:29:42 +0000 |
parents | 237e5a94e11c |
children | 147f1b17b6ce |
files | libpurple/protocols/qq/ChangeLog libpurple/protocols/qq/buddy_info.c libpurple/protocols/qq/buddy_info.h libpurple/protocols/qq/group.c libpurple/protocols/qq/group.h libpurple/protocols/qq/group_free.c libpurple/protocols/qq/group_im.c libpurple/protocols/qq/group_info.c libpurple/protocols/qq/group_internal.c libpurple/protocols/qq/group_internal.h libpurple/protocols/qq/group_join.c libpurple/protocols/qq/group_join.h libpurple/protocols/qq/qq.c libpurple/protocols/qq/qq_process.c |
diffstat | 14 files changed, 81 insertions(+), 132 deletions(-) [+] |
line wrap: on
line diff
--- a/libpurple/protocols/qq/ChangeLog Wed Oct 22 15:08:30 2008 +0000 +++ b/libpurple/protocols/qq/ChangeLog Tue Oct 28 16:29:42 2008 +0000 @@ -1,3 +1,6 @@ +2008.10.08 - ccpaging <ccpaging(at)gmail.com> + * 20081008-1 + 2008.10.08 - ccpaging <ccpaging(at)gmail.com> * Update group part * Delete some meaningless functions and data
--- a/libpurple/protocols/qq/buddy_info.c Wed Oct 22 15:08:30 2008 +0000 +++ b/libpurple/protocols/qq/buddy_info.c Tue Oct 28 16:29:42 2008 +0000 @@ -232,7 +232,7 @@ } /* send packet to modify personal information */ -static void request_modify_info(PurpleConnection *gc, gchar **segments) +static void request_change_info(PurpleConnection *gc, gchar **segments) { gint bytes = 0; guint8 raw_data[MAX_PACKET_SIZE - 128] = {0}; @@ -323,7 +323,7 @@ break; } } - request_modify_info(gc, segments); + request_change_info(gc, segments); g_strfreev(segments); g_free(info_request); @@ -445,16 +445,15 @@ } /* process the reply of modify_info packet */ -void qq_process_modify_info_reply(guint8 *data, gint data_len, PurpleConnection *gc) +void qq_process_change_info(PurpleConnection *gc, guint8 *data, gint data_len) { qq_data *qd; - g_return_if_fail(data != NULL && data_len != 0); qd = (qq_data *) gc->proto_data; data[data_len] = '\0'; - if (qd->uid == atoi((gchar *) data)) { /* return should be my uid */ + if (qd->uid != atoi((gchar *) data)) { /* return should be my uid */ purple_debug_info("QQ", "Update info ACK OK\n"); qq_got_attention(gc, _("Successed changing buddy information.")); } @@ -486,6 +485,7 @@ const gchar *filename; gint index; gint face; + gchar *error; g_return_if_fail(filepath != NULL); @@ -507,7 +507,9 @@ filename = segments[index]; index = strcspn (filename, "0123456789"); if (index < 0 || index >= strlen(filename)) { - purple_debug_info("QQ", "No digital in %s\n", filename); + error = g_strdup_printf(_("Can not get face number in file name (%s)"), filename); + purple_notify_error(gc, _("QQ Buddy"), _("Failed change icon"), error); + g_free(error); return; } face = strtol(filename+index, NULL, 10); @@ -542,16 +544,15 @@ gchar *qq_get_icon_name(gint face) { - gchar *num_str, *icon_name; + gint icon; + gchar *icon_name; + icon = face / 3 + 1; if (face < 1 || face > QQ_FACES) { - num_str = g_strdup_printf("%d", 1); - } else { - num_str = g_strdup_printf("%d", face / 3 + 1); + icon = 1; } - icon_name = g_strconcat(QQ_ICON_PREFIX, num_str, QQ_ICON_SUFFIX, NULL); - g_free(num_str); - + + icon_name = g_strdup_printf("%s%d%s", QQ_ICON_PREFIX, icon, QQ_ICON_SUFFIX); return icon_name; } @@ -575,7 +576,7 @@ icon_dir = QQ_BUDDY_ICON_DIR; #endif } - icon_path = g_strconcat(icon_dir, G_DIR_SEPARATOR_S, icon_name, NULL); + icon_path = g_strdup_printf("%s%c%s", icon_dir, G_DIR_SEPARATOR, icon_name); return icon_path; } @@ -594,7 +595,9 @@ icon_name = qq_get_icon_name(face); if ((buddy = purple_find_buddy(account, who))) { icon_name_prev = purple_buddy_icons_get_checksum_for_user(buddy); - purple_debug_info("QQ", "Previous icon is %s\n", icon_name_prev); + if (icon_name_prev != NULL) { + purple_debug_info("QQ", "Previous icon is %s\n", icon_name_prev); + } } if (icon_name_prev != NULL && !strcmp(icon_name, icon_name_prev)) { purple_debug_info("QQ", "Icon is not changed\n"); @@ -700,13 +703,15 @@ #endif if (action == QQ_BUDDY_INFO_SET_ICON) { - /* send new face to server */ if (strtol(segments[QQ_INFO_FACE], NULL, 10) != qd->my_icon) { icon_name = g_strdup_printf("%d", qd->my_icon); g_free(segments[QQ_INFO_FACE]); segments[QQ_INFO_FACE] = icon_name; - request_modify_info(gc, segments); + /* Update me in buddy list */ + update_buddy_info(gc, segments); + /* send new face to server */ + request_change_info(gc, segments); } g_strfreev(segments); return;
--- a/libpurple/protocols/qq/buddy_info.h Wed Oct 22 15:08:30 2008 +0000 +++ b/libpurple/protocols/qq/buddy_info.h Tue Oct 28 16:29:42 2008 +0000 @@ -81,7 +81,7 @@ void qq_request_buddy_info(PurpleConnection *gc, guint32 uid, gint update_class, int action); void qq_set_custom_icon(PurpleConnection *gc, PurpleStoredImage *img); -void qq_process_modify_info_reply(guint8 *data, gint data_len, PurpleConnection *gc); +void qq_process_change_info(PurpleConnection *gc, guint8 *data, gint data_len); void qq_process_get_buddy_info(guint8 *data, gint data_len, guint32 action, PurpleConnection *gc); void qq_request_get_level(PurpleConnection *gc, guint32 uid);
--- a/libpurple/protocols/qq/group.c Wed Oct 22 15:08:30 2008 +0000 +++ b/libpurple/protocols/qq/group.c Tue Oct 28 16:29:42 2008 +0000 @@ -98,20 +98,8 @@ f = purple_roomlist_field_new(PURPLE_ROOMLIST_FIELD_STRING, _("Group ID"), QQ_ROOM_KEY_EXTERNAL_ID, FALSE); fields = g_list_append(fields, f); - f = purple_roomlist_field_new(PURPLE_ROOMLIST_FIELD_STRING, _("Creator"), QQ_ROOM_KEY_CREATOR_UID, FALSE); - fields = g_list_append(fields, f); - f = purple_roomlist_field_new(PURPLE_ROOMLIST_FIELD_STRING, - _("Group Description"), QQ_ROOM_KEY_DESC_UTF8, FALSE); - fields = g_list_append(fields, f); f = purple_roomlist_field_new(PURPLE_ROOMLIST_FIELD_STRING, "", QQ_ROOM_KEY_INTERNAL_ID, TRUE); fields = g_list_append(fields, f); - f = purple_roomlist_field_new(PURPLE_ROOMLIST_FIELD_STRING, "", QQ_ROOM_KEY_TYPE, TRUE); - fields = g_list_append(fields, f); - f = purple_roomlist_field_new(PURPLE_ROOMLIST_FIELD_STRING, _("Auth"), QQ_ROOM_KEY_AUTH_TYPE, TRUE); - fields = g_list_append(fields, f); - f = purple_roomlist_field_new(PURPLE_ROOMLIST_FIELD_STRING, "", QQ_ROOM_KEY_CATEGORY, TRUE); - fields = g_list_append(fields, f); - f = purple_roomlist_field_new(PURPLE_ROOMLIST_FIELD_STRING, "", QQ_ROOM_KEY_TITLE_UTF8, TRUE); fields = g_list_append(fields, f); purple_roomlist_set_fields(rl, fields);
--- a/libpurple/protocols/qq/group.h Wed Oct 22 15:08:30 2008 +0000 +++ b/libpurple/protocols/qq/group.h Tue Oct 28 16:29:42 2008 +0000 @@ -43,7 +43,6 @@ typedef struct _qq_group { /* all these will be saved when we exit Purple */ qq_room_role my_role; /* my role for this room */ - gchar *my_role_desc; /* my role description */ guint32 id; guint32 ext_id; guint8 type8; /* permanent or temporory */
--- a/libpurple/protocols/qq/group_free.c Wed Oct 22 15:08:30 2008 +0000 +++ b/libpurple/protocols/qq/group_free.c Tue Oct 28 16:29:42 2008 +0000 @@ -53,7 +53,6 @@ { g_return_if_fail(group != NULL); qq_group_free_member(group); - g_free(group->my_role_desc); g_free(group->title_utf8); g_free(group->desc_utf8); g_free(group->notice_utf8);
--- a/libpurple/protocols/qq/group_im.c Wed Oct 22 15:08:30 2008 +0000 +++ b/libpurple/protocols/qq/group_im.c Tue Oct 28 16:29:42 2008 +0000 @@ -457,7 +457,7 @@ qd = (qq_data *) gc->proto_data; -#if 0 +#if 1 qq_hex_dump(PURPLE_DEBUG_INFO, "QQ", data, data_len, "group im hex dump"); #endif memset(&packet, 0, sizeof(packet));
--- a/libpurple/protocols/qq/group_info.c Wed Oct 22 15:08:30 2008 +0000 +++ b/libpurple/protocols/qq/group_info.c Tue Oct 28 16:29:42 2008 +0000 @@ -102,6 +102,29 @@ return num; } +static gchar *get_role_desc(qq_room_role role) +{ + const char *role_desc; + switch (role) { + case QQ_ROOM_ROLE_NO: + role_desc = _("Not member"); + break; + case QQ_ROOM_ROLE_YES: + role_desc = _("Member"); + break; + case QQ_ROOM_ROLE_REQUESTING: + role_desc = _("Requesting"); + break; + case QQ_ROOM_ROLE_ADMIN: + role_desc = _("Admin"); + break; + default: + role_desc = _("Unknown"); + } + + return g_strdup(role_desc); +} + static void room_info_display(PurpleConnection *gc, qq_group *group) { PurpleNotifyUserInfo *room_info; @@ -121,7 +144,9 @@ purple_notify_user_info_add_pair(room_info, _("Creator"), utf8_value); g_free(utf8_value); - purple_notify_user_info_add_pair(room_info, _("About me"), group->my_role_desc); + utf8_value = get_role_desc(group->my_role); + purple_notify_user_info_add_pair(room_info, _("About me"), utf8_value); + g_free(utf8_value); utf8_value = g_strdup_printf(("%d"), group->category); purple_notify_user_info_add_pair(room_info, _("Category"), utf8_value);
--- a/libpurple/protocols/qq/group_internal.c Wed Oct 22 15:08:30 2008 +0000 +++ b/libpurple/protocols/qq/group_internal.c Tue Oct 28 16:29:42 2008 +0000 @@ -31,31 +31,6 @@ #include "group_internal.h" #include "utils.h" -static gchar *get_role_desc(qq_group *group) -{ - const char *role_desc; - g_return_val_if_fail(group != NULL, g_strdup("")); - - switch (group->my_role) { - case QQ_ROOM_ROLE_NO: - role_desc = _("Not member"); - break; - case QQ_ROOM_ROLE_YES: - role_desc = _("Member"); - break; - case QQ_ROOM_ROLE_REQUESTING: - role_desc = _("Requesting"); - break; - case QQ_ROOM_ROLE_ADMIN: - role_desc = _("Admin"); - break; - default: - role_desc = _("Unknown"); - } - - return g_strdup(role_desc); -} - static void add_room_to_blist(PurpleConnection *gc, qq_group *group) { GHashTable *components; @@ -83,7 +58,6 @@ group = g_new0(qq_group, 1); group->my_role = QQ_ROOM_ROLE_NO; - group->my_role_desc = get_role_desc(group); group->id = internal_id; group->ext_id = ext_id; group->type8 = 0x01; /* assume permanent Qun */ @@ -124,21 +98,12 @@ { GHashTable *components; components = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free); - g_hash_table_insert(components, g_strdup(QQ_ROOM_KEY_ROLE), g_strdup_printf("%d", group->my_role)); - group->my_role_desc = get_role_desc(group); g_hash_table_insert(components, g_strdup(QQ_ROOM_KEY_INTERNAL_ID), g_strdup_printf("%d", group->id)); g_hash_table_insert(components, g_strdup(QQ_ROOM_KEY_EXTERNAL_ID), g_strdup_printf("%d", group->ext_id)); - g_hash_table_insert(components, g_strdup(QQ_ROOM_KEY_TYPE), g_strdup_printf("%d", group->type8)); - g_hash_table_insert(components, g_strdup(QQ_ROOM_KEY_CREATOR_UID), g_strdup_printf("%d", group->creator_uid)); - g_hash_table_insert(components, - g_strdup(QQ_ROOM_KEY_CATEGORY), g_strdup_printf("%d", group->category)); - g_hash_table_insert(components, g_strdup(QQ_ROOM_KEY_AUTH_TYPE), g_strdup_printf("%d", group->auth_type)); - g_hash_table_insert(components, g_strdup(QQ_ROOM_KEY_ROLE_DESC), g_strdup(group->my_role_desc)); g_hash_table_insert(components, g_strdup(QQ_ROOM_KEY_TITLE_UTF8), g_strdup(group->title_utf8)); - g_hash_table_insert(components, g_strdup(QQ_ROOM_KEY_DESC_UTF8), g_strdup(group->desc_utf8)); return components; } @@ -158,22 +123,18 @@ qd = (qq_data *) gc->proto_data; group = g_new0(qq_group, 1); - group->my_role = - str2dec - (NULL == - g_hash_table_lookup(data, - QQ_ROOM_KEY_ROLE) ? - g_strdup_printf("%d", QQ_ROOM_ROLE_NO) : - g_hash_table_lookup(data, QQ_ROOM_KEY_ROLE)); + memset(group, 0, sizeof(qq_group)); + group->my_role = QQ_ROOM_ROLE_YES; group->id = str2dec(g_hash_table_lookup(data, QQ_ROOM_KEY_INTERNAL_ID)); group->ext_id = str2dec(g_hash_table_lookup(data, QQ_ROOM_KEY_EXTERNAL_ID)); - group->type8 = str2dec(g_hash_table_lookup(data, QQ_ROOM_KEY_TYPE)); - group->creator_uid = str2dec(g_hash_table_lookup(data, QQ_ROOM_KEY_CREATOR_UID)); - group->category = str2dec(g_hash_table_lookup(data, QQ_ROOM_KEY_CATEGORY)); - group->auth_type = str2dec(g_hash_table_lookup(data, QQ_ROOM_KEY_AUTH_TYPE)); group->title_utf8 = g_strdup(g_hash_table_lookup(data, QQ_ROOM_KEY_TITLE_UTF8)); - group->desc_utf8 = g_strdup(g_hash_table_lookup(data, QQ_ROOM_KEY_DESC_UTF8)); - group->my_role_desc = get_role_desc(group); + group->type8 = 0x01; /* assume permanent Qun */ + group->creator_uid = 10000; /* assume by QQ admin */ + group->category = 0x01; + group->auth_type = 0x02; /* assume need auth */ + group->desc_utf8 = g_strdup(""); + group->notice_utf8 = g_strdup(""); + group->members = NULL; group->is_got_buddies = FALSE; purple_debug_info("QQ", "Created room info from hashtable: %s, %d, id %d\n", @@ -206,27 +167,11 @@ if (group->title_utf8 != NULL && strlen(group->title_utf8) > 0) purple_blist_alias_chat(chat, group->title_utf8); g_hash_table_replace(chat->components, - g_strdup(QQ_ROOM_KEY_ROLE), g_strdup_printf("%d", group->my_role)); - group->my_role_desc = get_role_desc(group); - g_hash_table_replace(chat->components, - g_strdup(QQ_ROOM_KEY_ROLE_DESC), g_strdup(group->my_role_desc)); - g_hash_table_replace(chat->components, g_strdup(QQ_ROOM_KEY_INTERNAL_ID), g_strdup_printf("%d", group->id)); g_hash_table_replace(chat->components, g_strdup(QQ_ROOM_KEY_EXTERNAL_ID), g_strdup_printf("%d", group->ext_id)); g_hash_table_replace(chat->components, - g_strdup(QQ_ROOM_KEY_TYPE), g_strdup_printf("%d", group->type8)); - g_hash_table_replace(chat->components, - g_strdup(QQ_ROOM_KEY_CREATOR_UID), g_strdup_printf("%d", group->creator_uid)); - g_hash_table_replace(chat->components, - g_strdup(QQ_ROOM_KEY_CATEGORY), - g_strdup_printf("%d", group->category)); - g_hash_table_replace(chat->components, - g_strdup(QQ_ROOM_KEY_AUTH_TYPE), g_strdup_printf("%d", group->auth_type)); - g_hash_table_replace(chat->components, g_strdup(QQ_ROOM_KEY_TITLE_UTF8), g_strdup(group->title_utf8)); - g_hash_table_replace(chat->components, - g_strdup(QQ_ROOM_KEY_DESC_UTF8), g_strdup(group->desc_utf8)); }
--- a/libpurple/protocols/qq/group_internal.h Wed Oct 22 15:08:30 2008 +0000 +++ b/libpurple/protocols/qq/group_internal.h Tue Oct 28 16:29:42 2008 +0000 @@ -28,16 +28,9 @@ #include <glib.h> #include "group.h" -#define QQ_ROOM_KEY_ROLE "my_role" -#define QQ_ROOM_KEY_ROLE_DESC "my_role_desc" #define QQ_ROOM_KEY_INTERNAL_ID "id" #define QQ_ROOM_KEY_EXTERNAL_ID "ext_id" -#define QQ_ROOM_KEY_TYPE "type" -#define QQ_ROOM_KEY_CREATOR_UID "creator_uid" -#define QQ_ROOM_KEY_CATEGORY "category" -#define QQ_ROOM_KEY_AUTH_TYPE "auth_type" -#define QQ_ROOM_KEY_TITLE_UTF8 "title_utf8" -#define QQ_ROOM_KEY_DESC_UTF8 "desc_utf8" +#define QQ_ROOM_KEY_TITLE_UTF8 "title_utf8" qq_group *qq_group_create_internal_record(PurpleConnection *gc, guint32 internal_id, guint32 ext_id, gchar *group_name_utf8);
--- a/libpurple/protocols/qq/group_join.c Wed Oct 22 15:08:30 2008 +0000 +++ b/libpurple/protocols/qq/group_join.c Tue Oct 28 16:29:42 2008 +0000 @@ -345,22 +345,13 @@ qq_request_room_search(gc, ext_id, QQ_ROOM_SEARCH_FOR_JOIN); } -void qq_room_quit(PurpleConnection *gc, GHashTable *data) +void qq_room_quit(PurpleConnection *gc, guint32 room_id) { - gchar *id_ptr; - guint32 id; qq_add_request *add_req; - g_return_if_fail(data != NULL); - - id_ptr = g_hash_table_lookup(data, QQ_ROOM_KEY_INTERNAL_ID); - id = strtol(id_ptr, NULL, 10); - - g_return_if_fail(id > 0); - add_req = g_new0(qq_add_request, 1); add_req->gc = gc; - add_req->uid = id; + add_req->uid = room_id; purple_request_action(gc, _("QQ Qun Operation"), _("Quit Qun"),
--- a/libpurple/protocols/qq/group_join.h Wed Oct 22 15:08:30 2008 +0000 +++ b/libpurple/protocols/qq/group_join.h Tue Oct 28 16:29:42 2008 +0000 @@ -44,7 +44,7 @@ void qq_send_cmd_group_auth(PurpleConnection *gc, qq_group *group, guint8 opt, guint32 uid, const gchar *reason_utf8); void qq_group_join(PurpleConnection *gc, GHashTable *data); void qq_request_room_join(PurpleConnection *gc, qq_group *group); -void qq_room_quit(PurpleConnection *gc, GHashTable *data); +void qq_room_quit(PurpleConnection *gc, guint32 room_id); void qq_process_group_cmd_exit_group(guint8 *data, gint len, PurpleConnection *gc); void qq_process_group_cmd_join_group_auth(guint8 *data, gint len, PurpleConnection *gc); void qq_process_group_cmd_join_group(guint8 *data, gint len, PurpleConnection *gc);
--- a/libpurple/protocols/qq/qq.c Wed Oct 22 15:08:30 2008 +0000 +++ b/libpurple/protocols/qq/qq.c Tue Oct 28 16:29:42 2008 +0000 @@ -746,11 +746,18 @@ PurpleChat *chat = (PurpleChat *)node; PurpleConnection *gc = purple_account_get_connection(chat->account); GHashTable *components = chat -> components; + gchar *num_str; + guint32 room_id; g_return_if_fail(PURPLE_BLIST_NODE_IS_CHAT(node)); g_return_if_fail(components != NULL); - qq_room_quit(gc, components); + + num_str = g_hash_table_lookup(components, QQ_ROOM_KEY_INTERNAL_ID); + room_id = strtol(num_str, NULL, 10); + g_return_if_fail(room_id != 0); + + qq_room_quit(gc, room_id); } static void action_chat_get_info(PurpleBlistNode * node) @@ -758,24 +765,18 @@ PurpleChat *chat = (PurpleChat *)node; PurpleConnection *gc = purple_account_get_connection(chat->account); GHashTable *components = chat -> components; - gchar *uid_str; - guint32 uid; - qq_group *group; + gchar *num_str; + guint32 room_id; g_return_if_fail(PURPLE_BLIST_NODE_IS_CHAT(node)); g_return_if_fail(components != NULL); - uid_str = g_hash_table_lookup(components, QQ_ROOM_KEY_INTERNAL_ID); - uid = strtol(uid_str, NULL, 10); + num_str = g_hash_table_lookup(components, QQ_ROOM_KEY_INTERNAL_ID); + room_id = strtol(num_str, NULL, 10); + g_return_if_fail(room_id != 0); - group = qq_room_search_id(gc, uid); - if (group == NULL) { - return; - } - g_return_if_fail(group->id > 0); - - qq_send_room_cmd_mess(gc, QQ_ROOM_CMD_GET_INFO, group->id, NULL, 0, + qq_send_room_cmd_mess(gc, QQ_ROOM_CMD_GET_INFO, room_id, NULL, 0, QQ_CMD_CLASS_UPDATE_ROOM, QQ_ROOM_INFO_DISPLAY); }
--- a/libpurple/protocols/qq/qq_process.c Wed Oct 22 15:08:30 2008 +0000 +++ b/libpurple/protocols/qq/qq_process.c Tue Oct 28 16:29:42 2008 +0000 @@ -1023,7 +1023,7 @@ switch (cmd) { case QQ_CMD_UPDATE_INFO: - qq_process_modify_info_reply(data, data_len, gc); + qq_process_change_info(gc, data, data_len); break; case QQ_CMD_BUDDY_ADD_NO_AUTH: qq_process_buddy_add_no_auth(data, data_len, ship32, gc);