Mercurial > pidgin
comparison libpurple/protocols/qq/buddy_opt.c @ 31191:4deef745de87
2010.01.23 - flos <lonicerae(at)gmail.com>
* added an option to force incoming message in chat room to use a default font instead of the font in message itself
2010.01.18 - flos <lonicerae(at)gmail.com>
* added type 'UPDCLS' and 'UID' for implementing business logic layer
2010.01.13 - ccpaging <ccpaging(at)gmail.com>
* qq2009-1 patch from ccpaging
author | SHiNE CsyFeK <csyfek@gmail.com> |
---|---|
date | Sun, 06 Feb 2011 05:23:22 +0000 |
parents | a8cc50c2279f |
children |
comparison
equal
deleted
inserted
replaced
31190:f0e6aaf942f8 | 31191:4deef745de87 |
---|---|
49 QQ_MY_AUTH_REQUEST = 0x32 /* ASCII value of "2" */ | 49 QQ_MY_AUTH_REQUEST = 0x32 /* ASCII value of "2" */ |
50 }; | 50 }; |
51 | 51 |
52 typedef struct _qq_buddy_req { | 52 typedef struct _qq_buddy_req { |
53 PurpleConnection *gc; | 53 PurpleConnection *gc; |
54 guint32 uid; | 54 UID uid; |
55 guint8 *auth; | 55 guint8 *auth; |
56 guint8 auth_len; | 56 guint8 auth_len; |
57 } qq_buddy_req; | 57 } qq_buddy_req; |
58 | 58 |
59 void add_buddy_authorize_input(PurpleConnection *gc, guint32 uid, | 59 void add_buddy_authorize_input(PurpleConnection *gc, UID uid, |
60 guint8 *auth, guint8 auth_len); | 60 guint8 *auth, guint8 auth_len); |
61 | 61 |
62 static void buddy_req_free(qq_buddy_req *add_req) | 62 static void buddy_req_free(qq_buddy_req *add_req) |
63 { | 63 { |
64 g_return_if_fail(add_req != NULL); | 64 g_return_if_fail(add_req != NULL); |
86 } | 86 } |
87 | 87 |
88 return g; | 88 return g; |
89 } | 89 } |
90 | 90 |
91 static qq_buddy_data *qq_buddy_data_new(guint32 uid) | 91 static qq_buddy_data *qq_buddy_data_new(UID uid) |
92 { | 92 { |
93 qq_buddy_data *bd = g_new0(qq_buddy_data, 1); | 93 qq_buddy_data *bd = g_new0(qq_buddy_data, 1); |
94 memset(bd, 0, sizeof(qq_buddy_data)); | 94 memset(bd, 0, sizeof(qq_buddy_data)); |
95 bd->uid = uid; | 95 bd->uid = uid; |
96 bd->status = QQ_BUDDY_OFFLINE; | 96 bd->status = QQ_BUDDY_OFFLINE; |
97 return bd; | 97 return bd; |
98 } | 98 } |
99 | 99 |
100 qq_buddy_data *qq_buddy_data_find(PurpleConnection *gc, guint32 uid) | 100 qq_buddy_data *qq_buddy_data_find(PurpleConnection *gc, UID uid) |
101 { | 101 { |
102 gchar *who; | 102 gchar *who; |
103 PurpleBuddy *buddy; | 103 PurpleBuddy *buddy; |
104 qq_buddy_data *bd; | 104 qq_buddy_data *bd; |
105 | 105 |
129 if (bd->nickname) g_free(bd->nickname); | 129 if (bd->nickname) g_free(bd->nickname); |
130 g_free(bd); | 130 g_free(bd); |
131 } | 131 } |
132 | 132 |
133 /* create purple buddy without data and display with no-auth icon */ | 133 /* create purple buddy without data and display with no-auth icon */ |
134 PurpleBuddy *qq_buddy_new(PurpleConnection *gc, guint32 uid) | 134 PurpleBuddy *qq_buddy_new(PurpleConnection *gc, UID uid) |
135 { | 135 { |
136 PurpleBuddy *buddy; | 136 PurpleBuddy *buddy; |
137 PurpleGroup *group; | 137 PurpleGroup *group; |
138 gchar *who; | 138 gchar *who; |
139 gchar *group_name; | 139 gchar *group_name; |
173 } | 173 } |
174 purple_buddy_set_protocol_data(buddy, NULL); | 174 purple_buddy_set_protocol_data(buddy, NULL); |
175 purple_blist_remove_buddy(buddy); | 175 purple_blist_remove_buddy(buddy); |
176 } | 176 } |
177 | 177 |
178 PurpleBuddy *qq_buddy_find(PurpleConnection *gc, guint32 uid) | 178 PurpleBuddy *qq_buddy_find(PurpleConnection *gc, UID uid) |
179 { | 179 { |
180 PurpleBuddy *buddy; | 180 PurpleBuddy *buddy; |
181 gchar *who; | 181 gchar *who; |
182 | 182 |
183 g_return_val_if_fail(gc->account != NULL && uid != 0, NULL); | 183 g_return_val_if_fail(gc->account != NULL && uid != 0, NULL); |
186 buddy = purple_find_buddy(gc->account, who); | 186 buddy = purple_find_buddy(gc->account, who); |
187 g_free(who); | 187 g_free(who); |
188 return buddy; | 188 return buddy; |
189 } | 189 } |
190 | 190 |
191 PurpleBuddy *qq_buddy_find_or_new(PurpleConnection *gc, guint32 uid) | 191 PurpleBuddy *qq_buddy_find_or_new(PurpleConnection *gc, UID uid) |
192 { | 192 { |
193 PurpleBuddy *buddy; | 193 PurpleBuddy *buddy; |
194 qq_buddy_data *bd; | 194 qq_buddy_data *bd; |
195 | 195 |
196 g_return_val_if_fail(gc->account != NULL && uid != 0, NULL); | 196 g_return_val_if_fail(gc->account != NULL && uid != 0, NULL); |
211 purple_buddy_set_protocol_data(buddy, bd); | 211 purple_buddy_set_protocol_data(buddy, bd); |
212 return buddy; | 212 return buddy; |
213 } | 213 } |
214 | 214 |
215 /* send packet to remove a buddy from my buddy list */ | 215 /* send packet to remove a buddy from my buddy list */ |
216 static void request_remove_buddy(PurpleConnection *gc, guint32 uid) | 216 static void request_remove_buddy(PurpleConnection *gc, UID uid) |
217 { | 217 { |
218 gchar uid_str[11]; | 218 gchar uid_str[11]; |
219 gint bytes; | 219 gint bytes; |
220 | 220 |
221 g_return_if_fail(uid > 0); | 221 g_return_if_fail(uid > 0); |
224 bytes = strlen(uid_str); | 224 bytes = strlen(uid_str); |
225 qq_send_cmd_mess(gc, QQ_CMD_REMOVE_BUDDY, (guint8 *) uid_str, bytes, 0, uid); | 225 qq_send_cmd_mess(gc, QQ_CMD_REMOVE_BUDDY, (guint8 *) uid_str, bytes, 0, uid); |
226 } | 226 } |
227 | 227 |
228 static void request_remove_buddy_ex(PurpleConnection *gc, | 228 static void request_remove_buddy_ex(PurpleConnection *gc, |
229 guint32 uid, guint8 *auth, guint8 auth_len) | 229 UID uid, guint8 *auth, guint8 auth_len) |
230 { | 230 { |
231 gint bytes; | 231 gint bytes; |
232 guint8 *raw_data; | 232 guint8 *raw_data; |
233 gchar uid_str[16]; | 233 gchar uid_str[16]; |
234 | 234 |
244 bytes += qq_putdata(raw_data + bytes, (guint8 *)uid_str, strlen(uid_str)); | 244 bytes += qq_putdata(raw_data + bytes, (guint8 *)uid_str, strlen(uid_str)); |
245 | 245 |
246 qq_send_cmd_mess(gc, QQ_CMD_REMOVE_BUDDY, raw_data, bytes, 0, uid); | 246 qq_send_cmd_mess(gc, QQ_CMD_REMOVE_BUDDY, raw_data, bytes, 0, uid); |
247 } | 247 } |
248 | 248 |
249 void qq_request_auth_code(PurpleConnection *gc, guint8 cmd, guint16 sub_cmd, guint32 uid) | 249 void qq_request_auth_code(PurpleConnection *gc, guint8 cmd, guint16 sub_cmd, UID uid) |
250 { | 250 { |
251 guint8 raw_data[16]; | 251 guint8 raw_data[16]; |
252 gint bytes; | 252 gint bytes; |
253 | 253 |
254 g_return_if_fail(uid > 0); | 254 g_return_if_fail(uid > 0); |
258 bytes += qq_put32(raw_data + bytes, uid); | 258 bytes += qq_put32(raw_data + bytes, uid); |
259 | 259 |
260 qq_send_cmd_mess(gc, QQ_CMD_AUTH_CODE, raw_data, bytes, 0, uid); | 260 qq_send_cmd_mess(gc, QQ_CMD_AUTH_CODE, raw_data, bytes, 0, uid); |
261 } | 261 } |
262 | 262 |
263 void qq_process_auth_code(PurpleConnection *gc, guint8 *data, gint data_len, guint32 uid) | 263 void qq_process_auth_code(PurpleConnection *gc, guint8 *data, gint data_len, UID uid) |
264 { | 264 { |
265 gint bytes; | 265 gint bytes; |
266 guint8 cmd, reply; | 266 guint8 cmd, reply; |
267 guint16 sub_cmd; | 267 guint16 sub_cmd; |
268 guint8 *code = NULL; | 268 guint8 *code = NULL; |
306 | 306 |
307 qq_request_question(add_req->gc, QQ_QUESTION_ANSWER, add_req->uid, NULL, text); | 307 qq_request_question(add_req->gc, QQ_QUESTION_ANSWER, add_req->uid, NULL, text); |
308 buddy_req_free(add_req); | 308 buddy_req_free(add_req); |
309 } | 309 } |
310 | 310 |
311 static void add_buddy_question_input(PurpleConnection *gc, guint32 uid, gchar *question) | 311 static void add_buddy_question_input(PurpleConnection *gc, UID uid, gchar *question) |
312 { | 312 { |
313 gchar *who, *msg; | 313 gchar *who, *msg; |
314 qq_buddy_req *add_req; | 314 qq_buddy_req *add_req; |
315 g_return_if_fail(uid != 0); | 315 g_return_if_fail(uid != 0); |
316 | 316 |
334 g_free(msg); | 334 g_free(msg); |
335 g_free(who); | 335 g_free(who); |
336 } | 336 } |
337 | 337 |
338 void qq_request_question(PurpleConnection *gc, | 338 void qq_request_question(PurpleConnection *gc, |
339 guint8 cmd, guint32 uid, const gchar *question_utf8, const gchar *answer_utf8) | 339 guint8 cmd, UID uid, const gchar *question_utf8, const gchar *answer_utf8) |
340 { | 340 { |
341 guint8 raw_data[MAX_PACKET_SIZE - 16]; | 341 guint8 raw_data[MAX_PACKET_SIZE - 16]; |
342 gint bytes; | 342 gint bytes; |
343 | 343 |
344 g_return_if_fail(uid > 0); | 344 g_return_if_fail(uid > 0); |
369 bytes += qq_put8(raw_data + bytes, 0); | 369 bytes += qq_put8(raw_data + bytes, 0); |
370 qq_send_cmd_mess(gc, QQ_CMD_BUDDY_QUESTION, raw_data, bytes, 0, uid); | 370 qq_send_cmd_mess(gc, QQ_CMD_BUDDY_QUESTION, raw_data, bytes, 0, uid); |
371 return; | 371 return; |
372 } | 372 } |
373 | 373 |
374 static void request_add_buddy_by_question(PurpleConnection *gc, guint32 uid, | 374 static void request_add_buddy_by_question(PurpleConnection *gc, UID uid, |
375 guint8 *code, guint16 code_len) | 375 guint8 *code, guint16 code_len) |
376 { | 376 { |
377 guint8 raw_data[MAX_PACKET_SIZE - 16]; | 377 guint8 raw_data[MAX_PACKET_SIZE - 16]; |
378 gint bytes = 0; | 378 gint bytes = 0; |
379 | 379 |
393 bytes += qq_put8(raw_data + bytes, 1); /* ALLOW ADD ME FLAG */ | 393 bytes += qq_put8(raw_data + bytes, 1); /* ALLOW ADD ME FLAG */ |
394 bytes += qq_put8(raw_data + bytes, 0); /* group number? */ | 394 bytes += qq_put8(raw_data + bytes, 0); /* group number? */ |
395 qq_send_cmd(gc, QQ_CMD_ADD_BUDDY_AUTH_EX, raw_data, bytes); | 395 qq_send_cmd(gc, QQ_CMD_ADD_BUDDY_AUTH_EX, raw_data, bytes); |
396 } | 396 } |
397 | 397 |
398 void qq_process_question(PurpleConnection *gc, guint8 *data, gint data_len, guint32 uid) | 398 void qq_process_question(PurpleConnection *gc, guint8 *data, gint data_len, UID uid) |
399 { | 399 { |
400 gint bytes; | 400 gint bytes; |
401 guint8 cmd, reply; | 401 guint8 cmd, reply; |
402 gchar *question, *answer; | 402 gchar *question, *answer; |
403 guint16 code_len; | 403 guint16 code_len; |
459 | 459 |
460 g_return_if_reached(); | 460 g_return_if_reached(); |
461 } | 461 } |
462 | 462 |
463 /* try to remove myself from someone's buddy list */ | 463 /* try to remove myself from someone's buddy list */ |
464 static void request_buddy_remove_me(PurpleConnection *gc, guint32 uid) | 464 static void request_buddy_remove_me(PurpleConnection *gc, UID uid) |
465 { | 465 { |
466 guint8 raw_data[16] = {0}; | 466 guint8 raw_data[16] = {0}; |
467 gint bytes = 0; | 467 gint bytes = 0; |
468 | 468 |
469 g_return_if_fail(uid > 0); | 469 g_return_if_fail(uid > 0); |
472 | 472 |
473 qq_send_cmd_mess(gc, QQ_CMD_REMOVE_ME, raw_data, bytes, 0, uid); | 473 qq_send_cmd_mess(gc, QQ_CMD_REMOVE_ME, raw_data, bytes, 0, uid); |
474 } | 474 } |
475 | 475 |
476 /* try to add a buddy without authentication */ | 476 /* try to add a buddy without authentication */ |
477 static void request_add_buddy_no_auth(PurpleConnection *gc, guint32 uid) | 477 static void request_add_buddy_no_auth(PurpleConnection *gc, UID uid) |
478 { | 478 { |
479 gchar uid_str[11]; | 479 gchar uid_str[11]; |
480 | 480 |
481 g_return_if_fail(uid > 0); | 481 g_return_if_fail(uid > 0); |
482 | 482 |
484 g_snprintf(uid_str, sizeof(uid_str), "%u", uid); | 484 g_snprintf(uid_str, sizeof(uid_str), "%u", uid); |
485 qq_send_cmd_mess(gc, QQ_CMD_ADD_BUDDY_NO_AUTH, | 485 qq_send_cmd_mess(gc, QQ_CMD_ADD_BUDDY_NO_AUTH, |
486 (guint8 *) uid_str, strlen(uid_str), 0, uid); | 486 (guint8 *) uid_str, strlen(uid_str), 0, uid); |
487 } | 487 } |
488 | 488 |
489 static void request_add_buddy_no_auth_ex(PurpleConnection *gc, guint32 uid) | 489 static void request_add_buddy_no_auth_ex(PurpleConnection *gc, UID uid) |
490 { | 490 { |
491 guint bytes; | 491 guint bytes; |
492 guint8 raw_data[16]; | 492 guint8 raw_data[16]; |
493 | 493 |
494 g_return_if_fail(uid != 0); | 494 g_return_if_fail(uid != 0); |
497 bytes += qq_put32(raw_data + bytes, uid); | 497 bytes += qq_put32(raw_data + bytes, uid); |
498 qq_send_cmd_mess(gc, QQ_CMD_ADD_BUDDY_NO_AUTH_EX, raw_data, bytes, 0, uid); | 498 qq_send_cmd_mess(gc, QQ_CMD_ADD_BUDDY_NO_AUTH_EX, raw_data, bytes, 0, uid); |
499 } | 499 } |
500 | 500 |
501 /* this buddy needs authentication, text conversion is done at lowest level */ | 501 /* this buddy needs authentication, text conversion is done at lowest level */ |
502 static void request_add_buddy_auth(PurpleConnection *gc, guint32 uid, const gchar response, const gchar *text) | 502 static void request_add_buddy_auth(PurpleConnection *gc, UID uid, const gchar response, const gchar *text) |
503 { | 503 { |
504 guint8 raw_data[MAX_PACKET_SIZE - 16]; | 504 guint8 raw_data[MAX_PACKET_SIZE - 16]; |
505 gint bytes; | 505 gint bytes; |
506 gchar *msg, uid_str[11]; | 506 gchar *msg, uid_str[11]; |
507 guint8 bar; | 507 guint8 bar; |
524 } | 524 } |
525 | 525 |
526 qq_send_cmd(gc, QQ_CMD_ADD_BUDDY_AUTH, raw_data, bytes); | 526 qq_send_cmd(gc, QQ_CMD_ADD_BUDDY_AUTH, raw_data, bytes); |
527 } | 527 } |
528 | 528 |
529 static void request_add_buddy_auth_ex(PurpleConnection *gc, guint32 uid, | 529 static void request_add_buddy_auth_ex(PurpleConnection *gc, UID uid, |
530 const gchar *text, guint8 *auth, guint8 auth_len) | 530 const gchar *text, guint8 *auth, guint8 auth_len) |
531 { | 531 { |
532 guint8 raw_data[MAX_PACKET_SIZE - 16]; | 532 guint8 raw_data[MAX_PACKET_SIZE - 16]; |
533 gint bytes = 0; | 533 gint bytes = 0; |
534 | 534 |
641 request_add_buddy_no_auth(add_req->gc, add_req->uid); | 641 request_add_buddy_no_auth(add_req->gc, add_req->uid); |
642 } | 642 } |
643 buddy_req_free(add_req); | 643 buddy_req_free(add_req); |
644 } | 644 } |
645 | 645 |
646 void add_buddy_authorize_input(PurpleConnection *gc, guint32 uid, | 646 void add_buddy_authorize_input(PurpleConnection *gc, UID uid, |
647 guint8 *auth, guint8 auth_len) | 647 guint8 *auth, guint8 auth_len) |
648 { | 648 { |
649 gchar *who, *msg; | 649 gchar *who, *msg; |
650 qq_buddy_req *add_req; | 650 qq_buddy_req *add_req; |
651 g_return_if_fail(uid != 0); | 651 g_return_if_fail(uid != 0); |
681 * it also calls this funtion, so we have to | 681 * it also calls this funtion, so we have to |
682 * define qd->is_login=TRUE AFTER LOGIN */ | 682 * define qd->is_login=TRUE AFTER LOGIN */ |
683 void qq_add_buddy(PurpleConnection *gc, PurpleBuddy *buddy, PurpleGroup *group) | 683 void qq_add_buddy(PurpleConnection *gc, PurpleBuddy *buddy, PurpleGroup *group) |
684 { | 684 { |
685 qq_data *qd; | 685 qq_data *qd; |
686 guint32 uid; | 686 UID uid; |
687 | 687 |
688 g_return_if_fail(NULL != gc && NULL != gc->proto_data); | 688 g_return_if_fail(NULL != gc && NULL != gc->proto_data); |
689 g_return_if_fail(buddy != NULL); | 689 g_return_if_fail(buddy != NULL); |
690 | 690 |
691 qd = (qq_data *) gc->proto_data; | 691 qd = (qq_data *) gc->proto_data; |
731 purple_notify_error(gc, _("QQ Buddy"), _("Failed sending authorize"), msg_utf8); | 731 purple_notify_error(gc, _("QQ Buddy"), _("Failed sending authorize"), msg_utf8); |
732 g_free(msg_utf8); | 732 g_free(msg_utf8); |
733 } | 733 } |
734 | 734 |
735 /* process the server reply for my request to remove a buddy */ | 735 /* process the server reply for my request to remove a buddy */ |
736 void qq_process_remove_buddy(PurpleConnection *gc, guint8 *data, gint data_len, guint32 uid) | 736 void qq_process_remove_buddy(PurpleConnection *gc, guint8 *data, gint data_len, UID uid) |
737 { | 737 { |
738 PurpleBuddy *buddy = NULL; | 738 PurpleBuddy *buddy = NULL; |
739 gchar *msg; | 739 gchar *msg; |
740 | 740 |
741 g_return_if_fail(data != NULL && data_len != 0); | 741 g_return_if_fail(data != NULL && data_len != 0); |
754 qq_buddy_free(buddy); | 754 qq_buddy_free(buddy); |
755 } | 755 } |
756 } | 756 } |
757 | 757 |
758 /* process the server reply for my request to remove myself from a buddy */ | 758 /* process the server reply for my request to remove myself from a buddy */ |
759 void qq_process_buddy_remove_me(PurpleConnection *gc, guint8 *data, gint data_len, guint32 uid) | 759 void qq_process_buddy_remove_me(PurpleConnection *gc, guint8 *data, gint data_len, UID uid) |
760 { | 760 { |
761 gchar *msg; | 761 gchar *msg; |
762 | 762 |
763 g_return_if_fail(data != NULL && data_len != 0); | 763 g_return_if_fail(data != NULL && data_len != 0); |
764 | 764 |
770 purple_notify_info(gc, _("QQ Buddy"), msg, NULL); | 770 purple_notify_info(gc, _("QQ Buddy"), msg, NULL); |
771 g_free(msg); | 771 g_free(msg); |
772 } | 772 } |
773 | 773 |
774 void qq_process_add_buddy_no_auth(PurpleConnection *gc, | 774 void qq_process_add_buddy_no_auth(PurpleConnection *gc, |
775 guint8 *data, gint data_len, guint32 uid) | 775 guint8 *data, gint data_len, UID uid) |
776 { | 776 { |
777 qq_data *qd; | 777 qq_data *qd; |
778 gchar **segments; | 778 gchar **segments; |
779 gchar *dest_uid, *reply; | 779 gchar *dest_uid, *reply; |
780 PurpleBuddy *buddy; | 780 PurpleBuddy *buddy; |
832 add_buddy_authorize_input(gc, uid, NULL, 0); | 832 add_buddy_authorize_input(gc, uid, NULL, 0); |
833 g_strfreev(segments); | 833 g_strfreev(segments); |
834 } | 834 } |
835 | 835 |
836 void qq_process_add_buddy_no_auth_ex(PurpleConnection *gc, | 836 void qq_process_add_buddy_no_auth_ex(PurpleConnection *gc, |
837 guint8 *data, gint data_len, guint32 uid) | 837 guint8 *data, gint data_len, UID uid) |
838 { | 838 { |
839 qq_data *qd; | 839 qq_data *qd; |
840 gint bytes; | 840 gint bytes; |
841 guint32 dest_uid; | 841 UID dest_uid; |
842 guint8 reply; | 842 guint8 reply; |
843 guint8 auth_type; | 843 guint8 auth_type; |
844 | 844 |
845 g_return_if_fail(data != NULL && data_len >= 5); | 845 g_return_if_fail(data != NULL && data_len >= 5); |
846 g_return_if_fail(uid != 0); | 846 g_return_if_fail(uid != 0); |
901 /* remove a buddy and send packet to QQ server accordingly */ | 901 /* remove a buddy and send packet to QQ server accordingly */ |
902 void qq_remove_buddy(PurpleConnection *gc, PurpleBuddy *buddy, PurpleGroup *group) | 902 void qq_remove_buddy(PurpleConnection *gc, PurpleBuddy *buddy, PurpleGroup *group) |
903 { | 903 { |
904 qq_data *qd; | 904 qq_data *qd; |
905 qq_buddy_data *bd; | 905 qq_buddy_data *bd; |
906 guint32 uid; | 906 UID uid; |
907 | 907 |
908 g_return_if_fail(gc != NULL && gc->proto_data != NULL); | 908 g_return_if_fail(gc != NULL && gc->proto_data != NULL); |
909 g_return_if_fail(buddy != NULL); | 909 g_return_if_fail(buddy != NULL); |
910 | 910 |
911 qd = (qq_data *) gc->proto_data; | 911 qd = (qq_data *) gc->proto_data; |
931 | 931 |
932 /* Do not call purple_blist_remove_buddy, | 932 /* Do not call purple_blist_remove_buddy, |
933 * otherwise purple segmentation fault */ | 933 * otherwise purple segmentation fault */ |
934 } | 934 } |
935 | 935 |
936 static void buddy_add_input(PurpleConnection *gc, guint32 uid, gchar *reason) | 936 static void buddy_add_input(PurpleConnection *gc, UID uid, gchar *reason) |
937 { | 937 { |
938 PurpleAccount *account = purple_connection_get_account(gc); | 938 PurpleAccount *account = purple_connection_get_account(gc); |
939 qq_buddy_req *add_req; | 939 qq_buddy_req *add_req; |
940 gchar *who; | 940 gchar *who; |
941 | 941 |
965 | 965 |
966 /* someone wants to add you to his buddy list */ | 966 /* someone wants to add you to his buddy list */ |
967 static void server_buddy_add_request(PurpleConnection *gc, gchar *from, gchar *to, | 967 static void server_buddy_add_request(PurpleConnection *gc, gchar *from, gchar *to, |
968 guint8 *data, gint data_len) | 968 guint8 *data, gint data_len) |
969 { | 969 { |
970 guint32 uid; | 970 UID uid; |
971 gchar *msg, *reason; | 971 gchar *msg, *reason; |
972 | 972 |
973 g_return_if_fail(from != NULL && to != NULL); | 973 g_return_if_fail(from != NULL && to != NULL); |
974 uid = strtoul(from, NULL, 10); | 974 uid = strtoul(from, NULL, 10); |
975 g_return_if_fail(uid != 0); | 975 g_return_if_fail(uid != 0); |
994 void qq_process_buddy_check_code(PurpleConnection *gc, guint8 *data, gint data_len) | 994 void qq_process_buddy_check_code(PurpleConnection *gc, guint8 *data, gint data_len) |
995 { | 995 { |
996 gint bytes; | 996 gint bytes; |
997 guint8 cmd; | 997 guint8 cmd; |
998 guint8 reply; | 998 guint8 reply; |
999 guint32 uid; | 999 UID uid; |
1000 guint16 flag1, flag2; | 1000 guint16 flag1, flag2; |
1001 | 1001 |
1002 g_return_if_fail(data != NULL && data_len >= 5); | 1002 g_return_if_fail(data != NULL && data_len >= 5); |
1003 | 1003 |
1004 qq_show_packet("buddy_check_code", data, data_len); | 1004 qq_show_packet("buddy_check_code", data, data_len); |
1024 static void request_buddy_check_code(PurpleConnection *gc, | 1024 static void request_buddy_check_code(PurpleConnection *gc, |
1025 gchar *from, guint8 *code, gint code_len) | 1025 gchar *from, guint8 *code, gint code_len) |
1026 { | 1026 { |
1027 guint8 *raw_data; | 1027 guint8 *raw_data; |
1028 gint bytes; | 1028 gint bytes; |
1029 guint32 uid; | 1029 UID uid; |
1030 | 1030 |
1031 g_return_if_fail(code != NULL && code_len > 0 && from != NULL); | 1031 g_return_if_fail(code != NULL && code_len > 0 && from != NULL); |
1032 | 1032 |
1033 uid = strtoul(from, NULL, 10); | 1033 uid = strtoul(from, NULL, 10); |
1034 raw_data = g_newa(guint8, code_len + 16); | 1034 raw_data = g_newa(guint8, code_len + 16); |
1071 | 1071 |
1072 static void server_buddy_add_request_ex(PurpleConnection *gc, gchar *from, gchar *to, | 1072 static void server_buddy_add_request_ex(PurpleConnection *gc, gchar *from, gchar *to, |
1073 guint8 *data, gint data_len) | 1073 guint8 *data, gint data_len) |
1074 { | 1074 { |
1075 gint bytes; | 1075 gint bytes; |
1076 guint32 uid; | 1076 UID uid; |
1077 gchar *msg; | 1077 gchar *msg; |
1078 guint8 allow_reverse; | 1078 guint8 allow_reverse; |
1079 | 1079 |
1080 g_return_if_fail(from != NULL && to != NULL); | 1080 g_return_if_fail(from != NULL && to != NULL); |
1081 g_return_if_fail(data != NULL && data_len >= 3); | 1081 g_return_if_fail(data != NULL && data_len >= 3); |
1101 static void server_buddy_added(PurpleConnection *gc, gchar *from, gchar *to, | 1101 static void server_buddy_added(PurpleConnection *gc, gchar *from, gchar *to, |
1102 guint8 *data, gint data_len) | 1102 guint8 *data, gint data_len) |
1103 { | 1103 { |
1104 PurpleAccount *account = purple_connection_get_account(gc); | 1104 PurpleAccount *account = purple_connection_get_account(gc); |
1105 PurpleBuddy *buddy; | 1105 PurpleBuddy *buddy; |
1106 guint32 uid; | 1106 UID uid; |
1107 qq_buddy_req *add_req; | 1107 qq_buddy_req *add_req; |
1108 gchar *who; | 1108 gchar *who; |
1109 gchar *primary; | 1109 gchar *primary; |
1110 | 1110 |
1111 g_return_if_fail(from != NULL && to != NULL); | 1111 g_return_if_fail(from != NULL && to != NULL); |
1175 static void server_buddy_added_me(PurpleConnection *gc, gchar *from, gchar *to, | 1175 static void server_buddy_added_me(PurpleConnection *gc, gchar *from, gchar *to, |
1176 guint8 *data, gint data_len) | 1176 guint8 *data, gint data_len) |
1177 { | 1177 { |
1178 PurpleAccount *account = purple_connection_get_account(gc); | 1178 PurpleAccount *account = purple_connection_get_account(gc); |
1179 qq_data *qd; | 1179 qq_data *qd; |
1180 guint32 uid; | 1180 UID uid; |
1181 | 1181 |
1182 g_return_if_fail(from != NULL && to != NULL); | 1182 g_return_if_fail(from != NULL && to != NULL); |
1183 | 1183 |
1184 qd = (qq_data *) gc->proto_data; | 1184 qd = (qq_data *) gc->proto_data; |
1185 | 1185 |
1202 | 1202 |
1203 /* you are rejected by the person */ | 1203 /* you are rejected by the person */ |
1204 static void server_buddy_rejected_me(PurpleConnection *gc, gchar *from, gchar *to, | 1204 static void server_buddy_rejected_me(PurpleConnection *gc, gchar *from, gchar *to, |
1205 guint8 *data, gint data_len) | 1205 guint8 *data, gint data_len) |
1206 { | 1206 { |
1207 guint32 uid; | 1207 UID uid; |
1208 PurpleBuddy *buddy; | 1208 PurpleBuddy *buddy; |
1209 gchar *msg, *msg_utf8; | 1209 gchar *msg, *msg_utf8; |
1210 gint bytes; | 1210 gint bytes; |
1211 gchar **segments; | 1211 gchar **segments; |
1212 gchar *primary, *secondary; | 1212 gchar *primary, *secondary; |