void qq_process_add_buddy_touch( PurpleConnection *gc, guint8 *data, gint data_len, qq_buddy_opt_req *opt_req ) { qq_data *qd; gint bytes; guint32 dest_uid; guint8 reply; g_return_if_fail(data != NULL && data_len >= 5); g_return_if_fail(opt_req && opt_req->uid != 0); qd = (qq_data *) gc->proto_data; purple_debug_info("QQ", "Process buddy add no auth for id [%u]\n", opt_req->uid); qq_show_packet("buddy_add_no_auth_ex", data, data_len); bytes = 0; bytes += qq_get32(&dest_uid, data + bytes); bytes += qq_get8(&reply, data + bytes); g_return_if_fail(dest_uid == opt_req->uid); if (reply == 0x99) { purple_debug_info("QQ", "Successfully added buddy %u\n", opt_req->uid); qq_buddy_find_or_new(gc, opt_req->uid, opt_req->group_id); qq_request_get_buddy_info(gc, opt_req->uid, 0, 0); qq_request_get_level(gc, opt_req->uid); qq_request_get_buddies_online(gc, 0, 0); return; } if (reply != 0) { purple_debug_info("QQ", "Failed adding buddy %u, Unknown reply 0x%02X\n", opt_req->uid, reply); } /* need auth */ g_return_if_fail(data_len > bytes); bytes += qq_get8(&opt_req->auth_type, data + bytes); purple_debug_warning("QQ", "Adding buddy needs authorize 0x%02X\n", opt_req->auth_type); switch (opt_req->auth_type) { case 0x00: /* no authorize */ case 0x01: /* authorize */ qq_request_auth_token(gc, QQ_AUTH_INFO_BUDDY, QQ_AUTH_INFO_ADD_BUDDY, 0, opt_req); break; case 0x02: /* disable */ break; case 0x03: /* answer question */ qq_request_question(gc, QQ_QUESTION_REQUEST, opt_req->uid, NULL, NULL); break; case 0x04: /* deny! */ break; default: g_return_if_reached(); break; } return; }
static void add_buddy_question_cb(qq_buddy_req *add_req, const gchar *text) { g_return_if_fail(add_req != NULL); if (add_req->gc == NULL || add_req->uid == 0) { buddy_req_free(add_req); return; } qq_request_question(add_req->gc, QQ_QUESTION_ANSWER, add_req->uid, NULL, text); buddy_req_free(add_req); }
void qq_process_add_buddy_no_auth_ex(PurpleConnection *gc, guint8 *data, gint data_len, guint32 uid) { qq_data *qd; gint bytes; guint32 dest_uid; guint8 reply; guint8 auth_type; g_return_if_fail(data != NULL && data_len >= 5); g_return_if_fail(uid != 0); qd = (qq_data *) gc->proto_data; purple_debug_info("QQ", "Process buddy add no auth for id [%u]\n", uid); qq_show_packet("buddy_add_no_auth_ex", data, data_len); bytes = 0; bytes += qq_get32(&dest_uid, data + bytes); bytes += qq_get8(&reply, data + bytes); g_return_if_fail(dest_uid == uid); if (reply == 0x99) { purple_debug_info("QQ", "Successed adding buddy %u\n", uid); qq_buddy_find_or_new(gc, uid); qq_request_buddy_info(gc, uid, 0, 0); if (qd->client_version >= 2007) { qq_request_get_level_2007(gc, uid); } else { qq_request_get_level(gc, uid); } qq_request_get_buddies_online(gc, 0, 0); return; } if (reply != 0) { purple_debug_info("QQ", "Failed adding buddy %u, Unknow reply 0x%02X\n", uid, reply); } /* need auth */ g_return_if_fail(data_len > bytes); bytes += qq_get8(&auth_type, data + bytes); purple_debug_warning("QQ", "Adding buddy needs authorize 0x%02X\n", auth_type); switch (auth_type) { case 0x00: /* no authorize */ break; case 0x01: /* authorize */ qq_request_auth_code(gc, QQ_AUTH_INFO_BUDDY, QQ_AUTH_INFO_ADD_BUDDY, uid); break; case 0x02: /* disable */ break; case 0x03: /* answer question */ qq_request_question(gc, QQ_QUESTION_REQUEST, uid, NULL, NULL); break; default: g_return_if_reached(); break; } return; }