Mercurial > pidgin.yaz
diff libpurple/protocols/qq/buddy_opt.c @ 23753:5f454b975a99
2008.08.10 - csyfek <csyfek(at)gmail.com>
* Commit to Pidgin
2008.08.06 - ccpaging <ecc_hy(at)hotmail.com>
* Rename names of variables, Group, to Room
* Functions of group_network merged into qq_network and qq_process
* Canceled managing glist of group packet, add sub_cmdd and room_id to transaction
* Fixed error of demo group:
If 'room list' and 'room infor' are not setup, response received from server will emits
'room_id = 0' packet.
2008.08.04 - ccpaging <ecc_hy(at)hotmail.com>
* Use new crypt/decrypt functions
* Rename crypt.c/h to qq_crypt.c/h
* Clean code of decrypt functions
* Fixed decryption failure
2008.08.04 - csyfek <csyfek(at)gmail.com>
* Update AUTHORS
author | SHiNE CsyFeK <csyfek@gmail.com> |
---|---|
date | Sun, 10 Aug 2008 04:32:14 +0000 |
parents | 1c50f12b1c52 |
children | 967344bc404d |
line wrap: on
line diff
--- a/libpurple/protocols/qq/buddy_opt.c Sat Aug 09 23:23:48 2008 +0000 +++ b/libpurple/protocols/qq/buddy_opt.c Sun Aug 10 04:32:14 2008 +0000 @@ -31,7 +31,6 @@ #include "buddy_list.h" #include "buddy_opt.h" #include "char_conv.h" -#include "crypt.h" #include "header_info.h" #include "im.h" #include "qq_base.h" @@ -252,29 +251,18 @@ } /* process reply to add_buddy_auth request */ -void qq_process_add_buddy_auth_reply(guint8 *buf, gint buf_len, PurpleConnection *gc) +void qq_process_add_buddy_auth_reply(guint8 *data, gint data_len, PurpleConnection *gc) { qq_data *qd; - gint len; - gint bytes = 0; - guint8 *data, reply; gchar **segments, *msg_utf8; - g_return_if_fail(buf != NULL && buf_len != 0); + g_return_if_fail(data != NULL && data_len != 0); qd = (qq_data *) gc->proto_data; - len = buf_len; - data = g_newa(guint8, len); - if (!qq_decrypt(buf, buf_len, qd->session_key, data, &len)) { - purple_debug(PURPLE_DEBUG_ERROR, "QQ", "Error decrypt add buddy with auth reply\n"); - } - - bytes += qq_get8(&reply, data + bytes); - - if (reply != QQ_ADD_BUDDY_AUTH_REPLY_OK) { + if (data[0] != QQ_ADD_BUDDY_AUTH_REPLY_OK) { purple_debug(PURPLE_DEBUG_WARNING, "QQ", "Add buddy with auth request failed\n"); - if (NULL == (segments = split_data(data, len, "\x1f", 2))) { + if (NULL == (segments = split_data(data, data_len, "\x1f", 2))) { return; } msg_utf8 = qq_to_utf8(segments[1], QQ_CHARSET_DEFAULT); @@ -286,26 +274,15 @@ } /* process the server reply for my request to remove a buddy */ -void qq_process_remove_buddy_reply(guint8 *buf, gint buf_len, PurpleConnection *gc) +void qq_process_remove_buddy_reply(guint8 *data, gint data_len, PurpleConnection *gc) { qq_data *qd; - gint len; - gint bytes = 0; - guint8 *data, reply; - g_return_if_fail(buf != NULL && buf_len != 0); + g_return_if_fail(data != NULL && data_len != 0); qd = (qq_data *) gc->proto_data; - len = buf_len; - data = g_newa(guint8, len); - if (!qq_decrypt(buf, buf_len, qd->session_key, data, &len)) { - purple_debug(PURPLE_DEBUG_ERROR, "QQ", "Error decrypt remove buddy reply\n"); - } - - bytes += qq_get8(&reply, data + bytes); - - if (reply != QQ_REMOVE_BUDDY_REPLY_OK) { + if (data[0] != QQ_REMOVE_BUDDY_REPLY_OK) { /* there is no reason return from server */ purple_debug(PURPLE_DEBUG_WARNING, "QQ", "Remove buddy fails\n"); } else { /* if reply */ @@ -316,26 +293,15 @@ } /* process the server reply for my request to remove myself from a buddy */ -void qq_process_remove_self_reply(guint8 *buf, gint buf_len, PurpleConnection *gc) +void qq_process_remove_self_reply(guint8 *data, gint data_len, PurpleConnection *gc) { qq_data *qd; - gint len; - gint bytes = 0; - guint8 *data, reply; - g_return_if_fail(buf != NULL && buf_len != 0); + g_return_if_fail(data != NULL && data_len != 0); qd = (qq_data *) gc->proto_data; - len = buf_len; - data = g_newa(guint8, len); - if (!qq_decrypt(buf, buf_len, qd->session_key, data, &len)) { - purple_debug(PURPLE_DEBUG_ERROR, "QQ", "Error decrypt remove self reply\n"); - } - - bytes += qq_get8(&reply, data + bytes); - - if (reply != QQ_REMOVE_SELF_REPLY_OK) { + if (data[0] != QQ_REMOVE_SELF_REPLY_OK) { /* there is no reason return from server */ purple_debug(PURPLE_DEBUG_WARNING, "QQ", "Remove self fails\n"); } else { /* if reply */ @@ -345,23 +311,21 @@ } } -void qq_process_add_buddy_reply(guint8 *buf, gint buf_len, guint16 seq, PurpleConnection *gc) +void qq_process_add_buddy_reply(guint8 *data, gint data_len, guint16 seq, PurpleConnection *gc) { qq_data *qd; - gint len, for_uid; + gint for_uid; gchar *msg, **segments, *uid, *reply; - guint8 *data; GList *list; PurpleBuddy *b; gc_and_uid *g; qq_add_buddy_request *req; gchar *nombre; - g_return_if_fail(buf != NULL && buf_len != 0); + g_return_if_fail(data != NULL && data_len != 0); for_uid = 0; qd = (qq_data *) gc->proto_data; - len = buf_len; list = qd->add_buddy_request; while (list != NULL) { @@ -382,50 +346,45 @@ purple_debug(PURPLE_DEBUG_INFO, "QQ", "Add buddy reply [%d] is for id [%d]\n", seq, for_uid); } - data = g_newa(guint8, len); - - if (qq_decrypt(buf, buf_len, qd->session_key, data, &len)) { - if (NULL == (segments = split_data(data, len, "\x1f", 2))) - return; - uid = segments[0]; - reply = segments[1]; - if (strtol(uid, NULL, 10) != qd->uid) { /* should not happen */ - purple_debug(PURPLE_DEBUG_ERROR, "QQ", "Add buddy reply is to [%s], not me!", uid); - g_strfreev(segments); - return; - } + if (NULL == (segments = split_data(data, data_len, "\x1f", 2))) + return; + + uid = segments[0]; + reply = segments[1]; + if (strtol(uid, NULL, 10) != qd->uid) { /* should not happen */ + purple_debug(PURPLE_DEBUG_ERROR, "QQ", "Add buddy reply is to [%s], not me!", uid); + g_strfreev(segments); + return; + } - if (strtol(reply, NULL, 10) > 0) { /* need auth */ - purple_debug(PURPLE_DEBUG_WARNING, "QQ", "Add buddy attempt fails, need authentication\n"); - nombre = uid_to_purple_name(for_uid); - b = purple_find_buddy(gc->account, nombre); - if (b != NULL) - purple_blist_remove_buddy(b); - g = g_new0(gc_and_uid, 1); - g->gc = gc; - g->uid = for_uid; - msg = g_strdup_printf(_("User %d needs authentication"), for_uid); - purple_request_input(gc, NULL, msg, - _("Input request here"), /* TODO: Awkward string to fix post string freeze - standardize auth dialogues? -evands */ - _("Would you be my friend?"), - TRUE, FALSE, NULL, _("Send"), - G_CALLBACK - (_qq_send_packet_add_buddy_auth_with_gc_and_uid), - _("Cancel"), G_CALLBACK(qq_do_nothing_with_gc_and_uid), - purple_connection_get_account(gc), nombre, NULL, - g); - g_free(msg); - g_free(nombre); - } else { /* add OK */ - qq_add_buddy_by_recv_packet(gc, for_uid, TRUE, TRUE); - msg = g_strdup_printf(_("You have added %d to buddy list"), for_uid); - purple_notify_info(gc, NULL, msg, NULL); - g_free(msg); - } - g_strfreev(segments); - } else { - purple_debug(PURPLE_DEBUG_ERROR, "QQ", "Error decrypt add buddy reply\n"); + if (strtol(reply, NULL, 10) > 0) { /* need auth */ + purple_debug(PURPLE_DEBUG_WARNING, "QQ", "Add buddy attempt fails, need authentication\n"); + nombre = uid_to_purple_name(for_uid); + b = purple_find_buddy(gc->account, nombre); + if (b != NULL) + purple_blist_remove_buddy(b); + g = g_new0(gc_and_uid, 1); + g->gc = gc; + g->uid = for_uid; + msg = g_strdup_printf(_("User %d needs authentication"), for_uid); + purple_request_input(gc, NULL, msg, + _("Input request here"), /* TODO: Awkward string to fix post string freeze - standardize auth dialogues? -evands */ + _("Would you be my friend?"), + TRUE, FALSE, NULL, _("Send"), + G_CALLBACK + (_qq_send_packet_add_buddy_auth_with_gc_and_uid), + _("Cancel"), G_CALLBACK(qq_do_nothing_with_gc_and_uid), + purple_connection_get_account(gc), nombre, NULL, + g); + g_free(msg); + g_free(nombre); + } else { /* add OK */ + qq_add_buddy_by_recv_packet(gc, for_uid, TRUE, TRUE); + msg = g_strdup_printf(_("You have added %d to buddy list"), for_uid); + purple_notify_info(gc, NULL, msg, NULL); + g_free(msg); } + g_strfreev(segments); } PurpleGroup *qq_get_purple_group(const gchar *group_name)