void qq_request_question(PurpleConnection *gc, guint8 cmd, guint32 uid, const gchar *question_utf8, const gchar *answer_utf8) { guint8 raw_data[MAX_PACKET_SIZE - 16]; gint bytes; g_return_if_fail(uid > 0); bytes = 0; bytes += qq_put8(raw_data + bytes, cmd); if (cmd == QQ_QUESTION_GET) { bytes += qq_put8(raw_data + bytes, 0); qq_send_cmd_mess(gc, QQ_CMD_BUDDY_QUESTION, raw_data, bytes, 0, uid); return; } if (cmd == QQ_QUESTION_SET) { bytes += qq_put_vstr(raw_data + bytes, question_utf8, QQ_CHARSET_DEFAULT); bytes += qq_put_vstr(raw_data + bytes, answer_utf8, QQ_CHARSET_DEFAULT); bytes += qq_put8(raw_data + bytes, 0); qq_send_cmd_mess(gc, QQ_CMD_BUDDY_QUESTION, raw_data, bytes, 0, uid); return; } /* Unknow 2 bytes, 0x(00 01) */ bytes += qq_put8(raw_data + bytes, 0x00); bytes += qq_put8(raw_data + bytes, 0x01); g_return_if_fail(uid != 0); bytes += qq_put32(raw_data + bytes, uid); if (cmd == QQ_QUESTION_REQUEST) { qq_send_cmd_mess(gc, QQ_CMD_BUDDY_QUESTION, raw_data, bytes, 0, uid); return; } bytes += qq_put_vstr(raw_data + bytes, answer_utf8, QQ_CHARSET_DEFAULT); bytes += qq_put8(raw_data + bytes, 0); qq_send_cmd_mess(gc, QQ_CMD_BUDDY_QUESTION, raw_data, bytes, 0, uid); return; }
void qq_request_get_buddies_level(PurpleConnection *gc, guint32 update_class) { qq_data *qd = (qq_data *) gc->proto_data; PurpleBuddy *buddy; qq_buddy_data *bd; guint8 *buf; GSList *buddies, *it; gint bytes; /* server only reply levels for online buddies */ buf = g_newa(guint8, MAX_PACKET_SIZE); bytes = 0; bytes += qq_put8(buf + bytes, 0x00); buddies = purple_find_buddies(purple_connection_get_account(gc), NULL); for (it = buddies; it; it = it->next) { buddy = it->data; if (buddy == NULL) continue; if (buddy->proto_data == NULL) continue; bd = (qq_buddy_data *)buddy->proto_data; if (bd->uid == 0) continue; /* keep me as end of packet*/ if (bd->uid == qd->uid) continue; bytes += qq_put32(buf + bytes, bd->uid); } bytes += qq_put32(buf + bytes, qd->uid); qq_send_cmd_mess(gc, QQ_CMD_GET_LEVEL, buf, bytes, update_class, 0); }
static void request_add_buddy_no_auth_ex(PurpleConnection *gc, guint32 uid) { guint bytes; guint8 raw_data[16]; g_return_if_fail(uid != 0); bytes = 0; bytes += qq_put32(raw_data + bytes, uid); qq_send_cmd_mess(gc, QQ_CMD_ADD_BUDDY_NO_AUTH_EX, raw_data, bytes, 0, uid); }
/* try to add a buddy without authentication */ static void request_add_buddy_no_auth(PurpleConnection *gc, guint32 uid) { gchar uid_str[11]; g_return_if_fail(uid > 0); /* we need to send the ascii code of this uid to qq server */ g_snprintf(uid_str, sizeof(uid_str), "%u", uid); qq_send_cmd_mess(gc, QQ_CMD_ADD_BUDDY_NO_AUTH, (guint8 *) uid_str, strlen(uid_str), 0, uid); }
/* try to remove myself from someone's buddy list */ static void request_buddy_remove_me(PurpleConnection *gc, guint32 uid) { guint8 raw_data[16] = {0}; gint bytes = 0; g_return_if_fail(uid > 0); bytes += qq_put32(raw_data + bytes, uid); qq_send_cmd_mess(gc, QQ_CMD_REMOVE_ME, raw_data, bytes, 0, uid); }
/* send packet to remove a buddy from my buddy list */ static void request_remove_buddy(PurpleConnection *gc, guint32 uid) { gchar uid_str[11]; gint bytes; g_return_if_fail(uid > 0); g_snprintf(uid_str, sizeof(uid_str), "%u", uid); bytes = strlen(uid_str); qq_send_cmd_mess(gc, QQ_CMD_REMOVE_BUDDY, (guint8 *) uid_str, bytes, 0, uid); }
/* try to add a buddy without authentication */ static void qq_request_add_buddy_touch(PurpleConnection *gc, qq_buddy_opt_req *opt_req) { guint bytes; guint8 raw_data[16]; g_return_if_fail(opt_req && opt_req->uid > 0); bytes = 0; bytes += qq_put32(raw_data + bytes, opt_req->uid); qq_send_cmd_mess(gc, QQ_CMD_ADD_BUDDY_TOUCH, raw_data, bytes, 0, (guintptr)opt_req); }
void qq_request_auth_code(PurpleConnection *gc, guint8 cmd, guint16 sub_cmd, guint32 uid) { guint8 raw_data[16]; gint bytes; g_return_if_fail(uid > 0); bytes = 0; bytes += qq_put8(raw_data + bytes, cmd); bytes += qq_put16(raw_data + bytes, sub_cmd); bytes += qq_put32(raw_data + bytes, uid); qq_send_cmd_mess(gc, QQ_CMD_AUTH_CODE, raw_data, bytes, 0, uid); }
void qq_request_buddy_info(PurpleConnection *gc, guint32 uid, guint32 update_class, int action) { 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), "%u", uid); qq_send_cmd_mess(gc, QQ_CMD_GET_BUDDY_INFO, (guint8 *) raw_data, strlen(raw_data), update_class, action); }
void qq_request_search_uid(PurpleConnection *gc, qq_buddy_opt_req *opt_req) { guint8 raw_data[8]; gint bytes; g_return_if_fail(opt_req && opt_req->uid > 0); bytes = 0; bytes += qq_put8(raw_data + bytes, 0x03); bytes += qq_put32(raw_data + bytes, opt_req->uid); qq_send_cmd_mess(gc, QQ_CMD_SEARCH_UID, raw_data, bytes, 0, (guintptr)opt_req); }
/* request buddy memo */ void qq_request_buddy_memo(PurpleConnection *gc, guint32 bd_uid, guint32 update_class, guint32 action) { guint8 raw_data[16] = {0}; gint bytes; purple_debug_info("QQ", "qq_request_buddy_memo, buddy uid=%u, update_class=%u\n", bd_uid, update_class); g_return_if_fail(NULL != gc); /* '0' is ok g_return_if_fail(uid != 0); */ bytes = 0; bytes += qq_put8(raw_data+bytes, QQ_BUDDY_MEMO_GET); bytes += qq_put32(raw_data+bytes, bd_uid); /* qq_show_packet("MEMO REQUEST", raw_data, bytes); */ qq_send_cmd_mess(gc, QQ_CMD_BUDDY_MEMO, (guint8*)raw_data, bytes, update_class, action); }
static void request_remove_buddy_ex(PurpleConnection *gc, guint32 uid, guint8 *auth, guint8 auth_len) { gint bytes; guint8 *raw_data; gchar uid_str[16]; g_return_if_fail(uid != 0); g_return_if_fail(auth != NULL && auth_len > 0); raw_data = g_newa(guint8, auth_len + sizeof(uid_str) ); bytes = 0; bytes += qq_put8(raw_data + bytes, auth_len); bytes += qq_putdata(raw_data + bytes, auth, auth_len); g_snprintf(uid_str, sizeof(uid_str), "%u", uid); bytes += qq_putdata(raw_data + bytes, (guint8 *)uid_str, strlen(uid_str)); qq_send_cmd_mess(gc, QQ_CMD_REMOVE_BUDDY, raw_data, bytes, 0, uid); }
void qq_request_auth_token( PurpleConnection *gc, guint8 cmd, guint16 sub_cmd, guint32 dataptr2ship, qq_buddy_opt_req *opt_req ) { guint8 raw_data[128]; gint bytes; g_return_if_fail(opt_req && opt_req->uid > 0); bytes = 0; bytes += qq_put8(raw_data + bytes, cmd); bytes += qq_put16(raw_data + bytes, sub_cmd); bytes += qq_put32(raw_data + bytes, opt_req->uid); if (opt_req->captcha_input && opt_req->session) { bytes += qq_put_vstr(raw_data+bytes, opt_req->captcha_input, sizeof(guint16), NULL); bytes += qq_put16(raw_data+bytes, opt_req->session_len); bytes += qq_putdata(raw_data+bytes, opt_req->session, opt_req->session_len); } qq_send_cmd_mess(gc, QQ_CMD_AUTH_TOKEN, raw_data, bytes, dataptr2ship, (guintptr)opt_req); }
/* send packet to remove a buddy from my buddy list */ static void qq_request_remove_buddy(PurpleConnection *gc, qq_buddy_opt_req *opt_req) { gint bytes; guint8 *raw_data; gchar * uid_str; g_return_if_fail(opt_req && opt_req->uid != 0); g_return_if_fail(opt_req->auth != NULL && opt_req->auth_len > 0); raw_data = g_newa(guint8, opt_req->auth_len + sizeof(uid_str)); bytes = 0; bytes += qq_put8(raw_data + bytes, opt_req->auth_len); bytes += qq_putdata(raw_data + bytes, opt_req->auth, opt_req->auth_len); uid_str = uid_to_purple_name(opt_req->uid); bytes += qq_putdata(raw_data + bytes, (guint8 *)uid_str, strlen(uid_str)); g_free(uid_str); qq_send_cmd_mess(gc, QQ_CMD_REMOVE_BUDDY, raw_data, bytes, 0, opt_req->uid); buddy_opt_req_free(opt_req); }
void qq_request_add_buddy_post(PurpleConnection *gc, qq_buddy_opt_req *opt_req, const gchar *text) { static guint8 fill1[] = { 0x00, 0x0A, 0x00, 0x01, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; static guint8 fill2[] = { 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; guint8 raw_data[256]; gint bytes = 0; guint8 cmd; g_return_if_fail(opt_req && opt_req->uid!= 0); switch (opt_req->auth_type) { case 0x01: //auth cmd = 0x02; break; case 0x02: //question cmd = 0x10; break; case 0x00: //no_auth case 0x03: //approve and add case 0x04: //approve case 0x05: //reject cmd = opt_req->auth_type; break; } bytes = 0; bytes += qq_put8(raw_data + bytes, cmd); bytes += qq_put32(raw_data + bytes, opt_req->uid); if (cmd == 0x03 || cmd == 0x04 || cmd == 0x05) { bytes += qq_put16(raw_data + bytes, 0); } else { if (opt_req->no_auth && opt_req->no_auth_len > 0) { bytes += qq_put16(raw_data + bytes, opt_req->no_auth_len); bytes += qq_putdata(raw_data + bytes, opt_req->no_auth, opt_req->no_auth_len); } else bytes += qq_put16(raw_data + bytes, 0); if (opt_req->auth == NULL || opt_req->auth_len <= 0) { bytes += qq_put16(raw_data + bytes, 0); } else { bytes += qq_put16(raw_data + bytes, opt_req->auth_len); bytes += qq_putdata(raw_data + bytes, opt_req->auth, opt_req->auth_len); } bytes += qq_put8(raw_data + bytes, 1); /* ALLOW ADD ME FLAG */ } bytes += qq_put8(raw_data + bytes, opt_req->group_id); /* group number */ if (text) { bytes += qq_put8(raw_data + bytes, strlen(text)); bytes += qq_putdata(raw_data + bytes, (guint8 *)text, strlen(text)); } if (cmd == 0x03 || cmd == 0x04 || cmd == 0x05) bytes += qq_putdata(raw_data + bytes, fill2, sizeof(fill2)); else bytes += qq_putdata(raw_data + bytes, fill1, sizeof(fill1)); qq_send_cmd_mess(gc, QQ_CMD_ADD_BUDDY_POST, raw_data, bytes, 0, opt_req->auth_type); buddy_opt_req_free(opt_req); }