Mercurial > pidgin.yaz
comparison libpurple/protocols/qq/buddy_opt.c @ 24095:2a19984c0005
2008.10.27 - ccpaging <ccpaging(at)gmail.com>
* Update 'buddy_adding' protocol
author | SHiNE CsyFeK <csyfek@gmail.com> |
---|---|
date | Tue, 28 Oct 2008 16:47:06 +0000 |
parents | 7f5433ffbf8d |
children | 5ace6c024230 1aca68fe730c e35115192593 |
comparison
equal
deleted
inserted
replaced
24094:7f5433ffbf8d | 24095:2a19984c0005 |
---|---|
64 g_return_if_fail(add_req != NULL); | 64 g_return_if_fail(add_req != NULL); |
65 if (add_req->auth) g_free(add_req->auth); | 65 if (add_req->auth) g_free(add_req->auth); |
66 g_free(add_req); | 66 g_free(add_req); |
67 } | 67 } |
68 | 68 |
69 static void buddy_req_cancel_cb(qq_buddy_req *add_req, const gchar *msg) | |
70 { | |
71 g_return_if_fail(add_req != NULL); | |
72 buddy_req_free(add_req); | |
73 } | |
74 | |
69 PurpleGroup *qq_group_find_or_new(const gchar *group_name) | 75 PurpleGroup *qq_group_find_or_new(const gchar *group_name) |
70 { | 76 { |
71 PurpleGroup *g; | 77 PurpleGroup *g; |
72 | 78 |
73 g_return_val_if_fail(group_name != NULL, NULL); | 79 g_return_val_if_fail(group_name != NULL, NULL); |
232 bytes += qq_putdata(raw_data + bytes, (guint8 *)uid_str, strlen(uid_str)); | 238 bytes += qq_putdata(raw_data + bytes, (guint8 *)uid_str, strlen(uid_str)); |
233 | 239 |
234 qq_send_cmd_mess(gc, QQ_CMD_REMOVE_BUDDY, raw_data, bytes, 0, uid); | 240 qq_send_cmd_mess(gc, QQ_CMD_REMOVE_BUDDY, raw_data, bytes, 0, uid); |
235 } | 241 } |
236 | 242 |
237 void qq_request_auth_info(PurpleConnection *gc, guint8 cmd, guint16 sub_cmd, guint32 uid) | 243 void qq_request_auth_code(PurpleConnection *gc, guint8 cmd, guint16 sub_cmd, guint32 uid) |
238 { | 244 { |
239 guint8 raw_data[16]; | 245 guint8 raw_data[16]; |
240 gint bytes; | 246 gint bytes; |
241 | 247 |
242 g_return_if_fail(uid > 0); | 248 g_return_if_fail(uid > 0); |
243 bytes = 0; | 249 bytes = 0; |
244 bytes += qq_put8(raw_data + bytes, cmd); | 250 bytes += qq_put8(raw_data + bytes, cmd); |
245 bytes += qq_put16(raw_data + bytes, sub_cmd); | 251 bytes += qq_put16(raw_data + bytes, sub_cmd); |
246 bytes += qq_put32(raw_data + bytes, uid); | 252 bytes += qq_put32(raw_data + bytes, uid); |
247 | 253 |
248 qq_send_cmd_mess(gc, QQ_CMD_AUTH_INFO, raw_data, bytes, 0, uid); | 254 qq_send_cmd_mess(gc, QQ_CMD_AUTH_CODE, raw_data, bytes, 0, uid); |
249 } | 255 } |
250 | 256 |
251 void qq_process_auth_info(PurpleConnection *gc, guint8 *data, gint data_len, guint32 uid) | 257 void qq_process_auth_code(PurpleConnection *gc, guint8 *data, gint data_len, guint32 uid) |
252 { | 258 { |
253 qq_data *qd; | 259 qq_data *qd; |
254 gint bytes; | 260 gint bytes; |
255 guint8 cmd, reply; | 261 guint8 cmd, reply; |
256 guint16 sub_cmd; | 262 guint16 sub_cmd; |
257 guint8 *auth = NULL; | 263 guint8 *code = NULL; |
258 guint8 auth_len = 0; | 264 guint16 code_len = 0; |
259 | 265 |
260 g_return_if_fail(data != NULL && data_len != 0); | 266 g_return_if_fail(data != NULL && data_len != 0); |
261 g_return_if_fail(uid != 0); | 267 g_return_if_fail(uid != 0); |
262 | 268 |
263 qd = (qq_data *) gc->proto_data; | 269 qd = (qq_data *) gc->proto_data; |
264 | 270 |
265 qq_show_packet("qq_process_auth_info", data, data_len); | 271 qq_show_packet("qq_process_auth_code", data, data_len); |
266 bytes = 0; | 272 bytes = 0; |
267 bytes += qq_get8(&cmd, data + bytes); | 273 bytes += qq_get8(&cmd, data + bytes); |
268 bytes += qq_get16(&sub_cmd, data + bytes); | 274 bytes += qq_get16(&sub_cmd, data + bytes); |
269 bytes += qq_get8(&reply, data + bytes); | 275 bytes += qq_get8(&reply, data + bytes); |
270 if (bytes + 2 <= data_len) { | 276 g_return_if_fail(bytes + 2 <= data_len); |
271 bytes += 1; /* skip 1 byte, 0x00 */ | 277 |
272 bytes += qq_get8(&auth_len, data + bytes); | 278 bytes += qq_get16(&code_len, data + bytes); |
273 if (auth_len > 0) { | 279 g_return_if_fail(code_len > 0); |
274 g_return_if_fail(bytes + auth_len <= data_len); | 280 g_return_if_fail(bytes + code_len <= data_len); |
275 auth = g_newa(guint8, auth_len); | 281 code = g_newa(guint8, code_len); |
276 bytes += qq_getdata(auth, auth_len, data + bytes); | 282 bytes += qq_getdata(code, code_len, data + bytes); |
277 } | |
278 } else { | |
279 qq_show_packet("No auth info", data, data_len); | |
280 } | |
281 | 283 |
282 if (cmd == QQ_AUTH_INFO_BUDDY && sub_cmd == QQ_AUTH_INFO_REMOVE_BUDDY) { | 284 if (cmd == QQ_AUTH_INFO_BUDDY && sub_cmd == QQ_AUTH_INFO_REMOVE_BUDDY) { |
283 g_return_if_fail(auth != NULL && auth_len > 0); | 285 request_remove_buddy_ex(gc, uid, code, code_len); |
284 request_remove_buddy_ex(gc, uid, auth, auth_len); | |
285 return; | 286 return; |
286 } | 287 } |
287 if (cmd == QQ_AUTH_INFO_BUDDY && sub_cmd == QQ_AUTH_INFO_ADD_BUDDY) { | 288 if (cmd == QQ_AUTH_INFO_BUDDY && sub_cmd == QQ_AUTH_INFO_ADD_BUDDY) { |
288 add_buddy_authorize_input(gc, uid, auth, auth_len); | 289 add_buddy_authorize_input(gc, uid, code, code_len); |
289 return; | 290 return; |
290 } | 291 } |
291 purple_debug_info("QQ", "Got auth info cmd 0x%x, sub 0x%x, reply 0x%x\n", | 292 purple_debug_info("QQ", "Got auth info cmd 0x%x, sub 0x%x, reply 0x%x\n", |
292 cmd, sub_cmd, reply); | 293 cmd, sub_cmd, reply); |
293 } | 294 } |
294 | 295 |
295 #define AUHT_TYPE_QUESTION_GET 0x01 | 296 static void add_buddy_question_cb(qq_buddy_req *add_req, const gchar *text) |
296 #define AUTH_TYPE_QUESTION_SET 0x02 | 297 { |
297 #define AUTH_TYPE_QUESTION_REQUEST 0x03 | 298 g_return_if_fail(add_req != NULL); |
298 #define AUTH_TYPE_QUESTION_ANSWER 0x04 | 299 if (add_req->gc == NULL || add_req->uid == 0) { |
299 /* | 300 buddy_req_free(add_req); |
300 int EvaAddFriendAuthQuestionPacket::putBody( unsigned char * buf ) | 301 return; |
301 { | 302 } |
302 int pos = 0; | 303 |
303 buf[pos++] = m_AuthStatus; // 0x01, 0x02, 0x03 or 0x04 | 304 qq_request_question(add_req->gc, QQ_QUESTION_ANSWER, add_req->uid, NULL, text); |
304 | 305 buddy_req_free(add_req); |
305 if(m_AuthStatus == AUHT_TYPE_QUESTION_GET) { | 306 } |
306 buf[pos++] = 0x00; | 307 |
307 return pos; | 308 static void add_buddy_question_input(PurpleConnection *gc, guint32 uid, gchar *question) |
308 } | 309 { |
309 | 310 gchar *who, *msg; |
310 if(m_AuthStatus == AUTH_TYPE_QUESTION_SET){ | 311 qq_buddy_req *add_req; |
311 printf("question(%d):%s\n", m_Question.length(), m_Question.c_str()); | 312 g_return_if_fail(uid != 0); |
312 buf[pos++] = (unsigned char)(m_Question.length() & 0xff); | 313 |
313 memcpy(buf + pos, m_Question.c_str(), m_Question.length()); | 314 add_req = g_new0(qq_buddy_req, 1); |
314 pos += m_Question.length(); | 315 add_req->gc = gc; |
315 | 316 add_req->uid = uid; |
316 buf[pos++] = (unsigned char)(m_Answer.length() & 0xff); | 317 add_req->auth = NULL; |
317 printf("answer(%d):%s\n", m_Answer.length(), m_Answer.c_str()); | 318 add_req->auth_len = 0; |
318 memcpy(buf + pos, m_Answer.c_str(), m_Answer.length()); | 319 |
319 pos += m_Answer.length(); | 320 who = uid_to_purple_name(uid); |
320 | 321 msg = g_strdup_printf(_("%d needs Q&A"), uid); |
321 buf[pos++] = 0x00; | 322 purple_request_input(gc, _("Add buddy Q&A"), msg, |
322 printf("EvaAddFriendAuthQuestionPacket\n"); | 323 _("Input answer here"), |
323 for(int i=0;i<pos;i++){ | 324 NULL, |
324 if(!(i%8)) printf("\n"); | 325 TRUE, FALSE, NULL, |
325 printf("%2x ", buf[i]); | 326 _("Send"), G_CALLBACK(add_buddy_question_cb), |
326 } | 327 _("Cancel"), G_CALLBACK(buddy_req_cancel_cb), |
327 printf("\n\n"); | 328 purple_connection_get_account(gc), who, NULL, |
328 return pos; | 329 add_req); |
329 } | 330 |
330 // unknown 2 bytes, always 0x0001 | 331 g_free(msg); |
331 buf[pos++] = 0x00; | 332 g_free(who); |
332 buf[pos++] = 0x01; | 333 } |
333 | 334 |
334 *((unsigned int *)(buf + pos)) = htonl(m_AddQQNum); | 335 void qq_request_question(PurpleConnection *gc, |
335 pos+= 4; | 336 guint8 cmd, guint32 uid, const gchar *question_utf8, const gchar *answer_utf8) |
336 | 337 { |
337 if(m_AuthStatus == AUTH_TYPE_QUESTION_REQUEST) return pos; | 338 guint8 raw_data[MAX_PACKET_SIZE - 16]; |
338 | 339 gint bytes; |
339 buf[pos++] = (unsigned char)(m_Answer.length() & 0xff); | 340 |
340 memcpy(buf + pos, m_Answer.c_str(), m_Answer.length()); | 341 g_return_if_fail(uid > 0); |
341 pos += m_Answer.length(); | 342 bytes = 0; |
342 | 343 bytes += qq_put8(raw_data + bytes, cmd); |
343 return pos; | 344 if (cmd == QQ_QUESTION_GET) { |
344 } | 345 bytes += qq_put8(raw_data + bytes, 0); |
345 * | 346 qq_send_cmd_mess(gc, QQ_CMD_BUDDY_QUESTION, raw_data, bytes, 0, uid); |
346 void EvaAddFriendAuthQuestionReplyPacket::parseBody( ) | 347 return; |
347 { | 348 } |
348 printf("EvaAddFriendAuthQuestionReplyPacket\n"); | 349 if (cmd == QQ_QUESTION_SET) { |
349 for(int i=0;i<bodyLength;i++){ | 350 bytes += qq_put_vstr(raw_data + bytes, question_utf8, QQ_CHARSET_DEFAULT); |
350 if(!(i%8)) printf("\n"); | 351 bytes += qq_put_vstr(raw_data + bytes, answer_utf8, QQ_CHARSET_DEFAULT); |
351 printf("%2x ", decryptedBuf[i]); | 352 bytes += qq_put8(raw_data + bytes, 0); |
352 } | 353 qq_send_cmd_mess(gc, QQ_CMD_BUDDY_QUESTION, raw_data, bytes, 0, uid); |
353 printf("\n\n"); | 354 return; |
354 int offset = 0; | 355 } |
355 | 356 /* Unknow 2 bytes, 0x(00 01) */ |
356 m_AuthStatus = decryptedBuf[offset++]; | 357 bytes += qq_put8(raw_data + bytes, 0x00); |
357 | 358 bytes += qq_put8(raw_data + bytes, 0x01); |
358 if(m_AuthStatus == AUHT_TYPE_QUESTION_GET){ | 359 g_return_if_fail(uid != 0); |
359 m_CodeLen = decryptedBuf[offset++]; | 360 bytes += qq_put32(raw_data + bytes, uid); |
360 if(m_CodeLen){ | 361 if (cmd == QQ_QUESTION_REQUEST) { |
361 if(m_Code) delete [] m_Code; | 362 qq_send_cmd_mess(gc, QQ_CMD_BUDDY_QUESTION, raw_data, bytes, 0, uid); |
362 m_Code = new unsigned char[m_CodeLen+1]; | 363 return; |
363 memcpy(m_Code, decryptedBuf + offset, m_CodeLen); | 364 } |
364 m_Code[m_CodeLen] = 0x00; | 365 bytes += qq_put_vstr(raw_data + bytes, answer_utf8, QQ_CHARSET_DEFAULT); |
365 offset += m_CodeLen; | 366 bytes += qq_put8(raw_data + bytes, 0); |
367 qq_send_cmd_mess(gc, QQ_CMD_BUDDY_QUESTION, raw_data, bytes, 0, uid); | |
368 return; | |
369 } | |
370 | |
371 static void request_add_buddy_by_question(PurpleConnection *gc, guint32 uid, | |
372 guint8 *code, guint16 code_len) | |
373 { | |
374 guint8 raw_data[MAX_PACKET_SIZE - 16]; | |
375 gint bytes = 0; | |
376 | |
377 g_return_if_fail(uid != 0 && code_len > 0); | |
378 | |
379 bytes = 0; | |
380 bytes += qq_put8(raw_data + bytes, 0x10); | |
381 bytes += qq_put32(raw_data + bytes, uid); | |
382 bytes += qq_put16(raw_data + bytes, 0); | |
383 | |
384 bytes += qq_put8(raw_data + bytes, 0); | |
385 bytes += qq_put8(raw_data + bytes, 0); /* no auth code */ | |
386 | |
387 bytes += qq_put16(raw_data + bytes, code_len); | |
388 bytes += qq_putdata(raw_data + bytes, code, code_len); | |
389 | |
390 bytes += qq_put8(raw_data + bytes, 1); /* ALLOW ADD ME FLAG */ | |
391 bytes += qq_put8(raw_data + bytes, 0); /* group number? */ | |
392 qq_send_cmd(gc, QQ_CMD_ADD_BUDDY_AUTH_EX, raw_data, bytes); | |
393 } | |
394 | |
395 void qq_process_question(PurpleConnection *gc, guint8 *data, gint data_len, guint32 uid) | |
396 { | |
397 qq_data *qd; | |
398 gint bytes; | |
399 guint8 cmd, reply; | |
400 gchar *question, *answer; | |
401 guint16 code_len; | |
402 guint8 *code; | |
403 | |
404 g_return_if_fail(data != NULL && data_len != 0); | |
405 | |
406 qd = (qq_data *) gc->proto_data; | |
407 | |
408 qq_show_packet("qq_process_question", data, data_len); | |
409 bytes = 0; | |
410 bytes += qq_get8(&cmd, data + bytes); | |
411 if (cmd == QQ_QUESTION_GET) { | |
412 bytes += qq_get_vstr(&question, QQ_CHARSET_DEFAULT, data + bytes); | |
413 bytes += qq_get_vstr(&answer, QQ_CHARSET_DEFAULT, data + bytes); | |
414 purple_debug_info("QQ", "Get buddy adding Q&A:\n%s\n%s\n", question, answer); | |
415 g_free(question); | |
416 g_free(answer); | |
417 return; | |
418 } | |
419 if (cmd == QQ_QUESTION_SET) { | |
420 bytes += qq_get8(&reply, data + bytes); | |
421 if (reply == 0) { | |
422 purple_debug_info("QQ", "Successed setting Q&A\n"); | |
423 } else { | |
424 purple_debug_warning("QQ", "Failed setting Q&A, reply %d\n", reply); | |
366 } | 425 } |
367 | 426 return; |
368 unsigned int len = decryptedBuf[offset++]; | 427 } |
369 if(len){ | 428 |
370 char *tmp = new char [len+1]; | 429 g_return_if_fail(uid != 0); |
371 memcpy(tmp, decryptedBuf + offset, len); | 430 bytes += 2; /* skip 2 bytes, 0x(00 01)*/ |
372 tmp[len] = 0x00; | 431 if (cmd == QQ_QUESTION_REQUEST) { |
373 m_Answer = tmp; | 432 bytes += qq_get8(&reply, data + bytes); |
374 delete []tmp; | 433 if (reply == 0x01) { |
375 offset += len; | 434 purple_debug_warning("QQ", "Failed getting question, reply %d\n", reply); |
435 return; | |
376 } | 436 } |
377 return; | 437 bytes += qq_get_vstr(&question, QQ_CHARSET_DEFAULT, data + bytes); |
378 } | 438 purple_debug_info("QQ", "Get buddy question:\n%s\n", question); |
379 | 439 add_buddy_question_input(gc, uid, question); |
380 if(m_AuthStatus == AUTH_TYPE_QUESTION_SET){ | 440 g_free(question); |
381 m_ReplyCode = decryptedBuf[offset++]; // 0x00: success, (? -- 0x01: error) | 441 return; |
382 return; | 442 } |
383 } | 443 |
384 | 444 if (cmd == QQ_QUESTION_ANSWER) { |
385 offset+=2; // unknown 2 bytes, always be 0x0001 | 445 bytes += qq_get8(&reply, data + bytes); |
386 | 446 if (reply == 0x01) { |
387 m_ReplyCode = decryptedBuf[offset++]; | 447 purple_notify_error(gc, _("Add Buddy"), _("Invalid answer."), NULL); |
388 | 448 return; |
389 if(m_ReplyCode == 0x01){ | |
390 // should be error happened | |
391 return; | |
392 } | |
393 | |
394 switch(m_AuthStatus){ | |
395 case AUTH_TYPE_QUESTION_REQUEST: | |
396 m_CodeLen = decryptedBuf[offset++]; | |
397 break; | |
398 case AUTH_TYPE_QUESTION_ANSWER:{ | |
399 m_CodeLen = ntohs( *( (unsigned short *)(decryptedBuf + offset)) ); | |
400 offset+=2; | |
401 } | 449 } |
402 break; | 450 bytes += qq_get16(&code_len, data + bytes); |
403 default: | 451 g_return_if_fail(code_len > 0); |
404 fprintf(stderr, "Unknown auth status code: 0x%2x\n", m_AuthStatus); | 452 g_return_if_fail(bytes + code_len <= data_len); |
405 return; | 453 |
406 } | 454 code = g_newa(guint8, code_len); |
407 if(m_CodeLen){ | 455 bytes += qq_getdata(code, code_len, data + bytes); |
408 if(m_Code) delete [] m_Code; | 456 request_add_buddy_by_question(gc, uid, code, code_len); |
409 m_Code = new unsigned char[m_CodeLen+1]; | 457 return; |
410 memcpy(m_Code, decryptedBuf + offset, m_CodeLen); | 458 } |
411 offset += m_CodeLen; | 459 |
412 } | 460 g_return_if_reached(); |
413 | 461 } |
414 // just in case the url, give it a terminate char | |
415 if(m_AuthStatus == AUTH_TYPE_QUESTION_REQUEST || | |
416 m_AuthStatus == AUHT_TYPE_QUESTION_GET){ | |
417 m_Code[m_CodeLen] = 0x00; | |
418 m_CodeLen++; | |
419 } | |
420 } | |
421 */ | |
422 | 462 |
423 /* try to remove myself from someone's buddy list */ | 463 /* try to remove myself from someone's buddy list */ |
424 static void request_buddy_remove_me(PurpleConnection *gc, guint32 uid) | 464 static void request_buddy_remove_me(PurpleConnection *gc, guint32 uid) |
425 { | 465 { |
426 guint8 raw_data[16] = {0}; | 466 guint8 raw_data[16] = {0}; |
486 } | 526 } |
487 | 527 |
488 static void request_add_buddy_auth_ex(PurpleConnection *gc, guint32 uid, | 528 static void request_add_buddy_auth_ex(PurpleConnection *gc, guint32 uid, |
489 const gchar *text, guint8 *auth, guint8 auth_len) | 529 const gchar *text, guint8 *auth, guint8 auth_len) |
490 { | 530 { |
491 guint8 *raw_data; | 531 guint8 raw_data[MAX_PACKET_SIZE - 16]; |
492 gint bytes = 0; | 532 gint bytes = 0; |
493 gchar *msg; | 533 |
494 | 534 g_return_if_fail(uid != 0); |
495 g_return_if_fail(uid != 0); | 535 |
496 | |
497 raw_data = g_newa(guint8, QQ_MSG_IM_MAX); | |
498 bytes = 0; | 536 bytes = 0; |
499 bytes += qq_put8(raw_data + bytes, 0x02); | 537 bytes += qq_put8(raw_data + bytes, 0x02); |
500 bytes += qq_put32(raw_data + bytes, uid); | 538 bytes += qq_put32(raw_data + bytes, uid); |
501 bytes += qq_put16(raw_data + bytes, 0); | 539 bytes += qq_put16(raw_data + bytes, 0); |
502 | 540 |
506 } else { | 544 } else { |
507 bytes += qq_put8(raw_data + bytes, auth_len); | 545 bytes += qq_put8(raw_data + bytes, auth_len); |
508 bytes += qq_putdata(raw_data + bytes, auth, auth_len); | 546 bytes += qq_putdata(raw_data + bytes, auth, auth_len); |
509 } | 547 } |
510 bytes += qq_put8(raw_data + bytes, 1); /* ALLOW ADD ME FLAG */ | 548 bytes += qq_put8(raw_data + bytes, 1); /* ALLOW ADD ME FLAG */ |
511 bytes += qq_put8(raw_data + bytes, 0); /* Destination group */ | 549 bytes += qq_put8(raw_data + bytes, 0); /* group number? */ |
512 if (text == NULL) { | 550 bytes += qq_put_vstr(raw_data + bytes, text, QQ_CHARSET_DEFAULT); |
513 bytes += qq_put8(raw_data + bytes, 0); | |
514 } else { | |
515 msg = utf8_to_qq(text, QQ_CHARSET_DEFAULT); | |
516 bytes += qq_put8(raw_data + bytes, strlen(msg)); | |
517 bytes += qq_putdata(raw_data + bytes, (guint8 *)msg, strlen(msg)); | |
518 g_free(msg); | |
519 } | |
520 qq_send_cmd(gc, QQ_CMD_ADD_BUDDY_AUTH_EX, raw_data, bytes); | 551 qq_send_cmd(gc, QQ_CMD_ADD_BUDDY_AUTH_EX, raw_data, bytes); |
552 } | |
553 | |
554 void qq_process_add_buddy_auth_ex(PurpleConnection *gc, guint8 *data, gint data_len, guint32 ship32) | |
555 { | |
556 g_return_if_fail(data != NULL && data_len != 0); | |
557 | |
558 qq_show_packet("qq_process_question", data, data_len); | |
521 } | 559 } |
522 | 560 |
523 static void add_buddy_auth_cb(qq_buddy_req *add_req, const gchar *text) | 561 static void add_buddy_auth_cb(qq_buddy_req *add_req, const gchar *text) |
524 { | 562 { |
525 qq_data *qd; | 563 qq_data *qd; |
582 _("OK"), G_CALLBACK(buddy_add_deny_reason_cb), | 620 _("OK"), G_CALLBACK(buddy_add_deny_reason_cb), |
583 _("Cancel"), G_CALLBACK(buddy_add_deny_noreason_cb), | 621 _("Cancel"), G_CALLBACK(buddy_add_deny_noreason_cb), |
584 purple_connection_get_account(add_req->gc), who, NULL, | 622 purple_connection_get_account(add_req->gc), who, NULL, |
585 add_req); | 623 add_req); |
586 g_free(who); | 624 g_free(who); |
587 } | |
588 | |
589 static void buddy_req_cancel_cb(qq_buddy_req *add_req, const gchar *msg) | |
590 { | |
591 g_return_if_fail(add_req != NULL); | |
592 buddy_req_free(add_req); | |
593 } | 625 } |
594 | 626 |
595 static void add_buddy_no_auth_cb(qq_buddy_req *add_req) | 627 static void add_buddy_no_auth_cb(qq_buddy_req *add_req) |
596 { | 628 { |
597 qq_data *qd; | 629 qq_data *qd; |
853 | 885 |
854 switch (auth_type) { | 886 switch (auth_type) { |
855 case 0x00: /* no authorize */ | 887 case 0x00: /* no authorize */ |
856 break; | 888 break; |
857 case 0x01: /* authorize */ | 889 case 0x01: /* authorize */ |
858 qq_request_auth_info(gc, QQ_AUTH_INFO_BUDDY, QQ_AUTH_INFO_ADD_BUDDY, uid); | 890 qq_request_auth_code(gc, QQ_AUTH_INFO_BUDDY, QQ_AUTH_INFO_ADD_BUDDY, uid); |
859 break; | 891 break; |
860 case 0x02: /* disable */ | 892 case 0x02: /* disable */ |
861 break; | 893 break; |
862 case 0x03: /* answer question */ | 894 case 0x03: /* answer question */ |
863 //qq_request_question(gc, uid); | 895 qq_request_question(gc, QQ_QUESTION_REQUEST, uid, NULL, NULL); |
864 break; | 896 break; |
865 default: | 897 default: |
866 g_return_if_reached(); | 898 g_return_if_reached(); |
867 break; | 899 break; |
868 } | 900 } |
883 return; | 915 return; |
884 | 916 |
885 uid = purple_name_to_uid(buddy->name); | 917 uid = purple_name_to_uid(buddy->name); |
886 if (uid > 0 && uid != qd->uid) { | 918 if (uid > 0 && uid != qd->uid) { |
887 if (qd->client_version > 2005) { | 919 if (qd->client_version > 2005) { |
888 qq_request_auth_info(gc, QQ_AUTH_INFO_BUDDY, QQ_AUTH_INFO_REMOVE_BUDDY, uid); | 920 qq_request_auth_code(gc, QQ_AUTH_INFO_BUDDY, QQ_AUTH_INFO_REMOVE_BUDDY, uid); |
889 } else { | 921 } else { |
890 request_remove_buddy(gc, uid); | 922 request_remove_buddy(gc, uid); |
891 request_buddy_remove_me(gc, uid); | 923 request_buddy_remove_me(gc, uid); |
892 } | 924 } |
893 } | 925 } |
1018 | 1050 |
1019 static gint server_buddy_check_code(PurpleConnection *gc, | 1051 static gint server_buddy_check_code(PurpleConnection *gc, |
1020 gchar *from, guint8 *data, gint data_len) | 1052 gchar *from, guint8 *data, gint data_len) |
1021 { | 1053 { |
1022 gint bytes; | 1054 gint bytes; |
1055 guint16 code_len; | |
1023 guint8 *code; | 1056 guint8 *code; |
1024 guint16 code_len; | |
1025 | 1057 |
1026 g_return_val_if_fail(data != NULL && data_len > 0, 0); | 1058 g_return_val_if_fail(data != NULL && data_len > 0, 0); |
1027 | 1059 |
1028 bytes = 0; | 1060 bytes = 0; |
1029 bytes += qq_get16(&code_len, data + bytes); | 1061 bytes += qq_get16(&code_len, data + bytes); |