Mercurial > pidgin.yaz
comparison libpurple/protocols/qq/buddy_opt.c @ 24090:9be95f0b9472
2008.10.10 - ccpaging <ccpaging(at)gmail.com>
* Keep group_search.c/h for later use
* Update 'group'
author | SHiNE CsyFeK <csyfek@gmail.com> |
---|---|
date | Tue, 28 Oct 2008 16:40:56 +0000 |
parents | 818ab62006f5 |
children | d35672443baa |
comparison
equal
deleted
inserted
replaced
24089:b6f09c1c79ce | 24090:9be95f0b9472 |
---|---|
50 QQ_MY_AUTH_APPROVE = 0x30, /* ASCII value of "0" */ | 50 QQ_MY_AUTH_APPROVE = 0x30, /* ASCII value of "0" */ |
51 QQ_MY_AUTH_REJECT = 0x31, /* ASCII value of "1" */ | 51 QQ_MY_AUTH_REJECT = 0x31, /* ASCII value of "1" */ |
52 QQ_MY_AUTH_REQUEST = 0x32, /* ASCII value of "2" */ | 52 QQ_MY_AUTH_REQUEST = 0x32, /* ASCII value of "2" */ |
53 }; | 53 }; |
54 | 54 |
55 typedef struct _qq_buddy_req { | |
56 guint32 uid; | |
57 PurpleConnection *gc; | |
58 } qq_buddy_req; | |
59 | |
55 /* send packet to remove a buddy from my buddy list */ | 60 /* send packet to remove a buddy from my buddy list */ |
56 static void request_buddy_remove(PurpleConnection *gc, guint32 uid) | 61 static void request_buddy_remove(PurpleConnection *gc, guint32 uid) |
57 { | 62 { |
58 gchar uid_str[11]; | 63 gchar uid_str[11]; |
59 | 64 |
114 } | 119 } |
115 | 120 |
116 qq_send_cmd(gc, QQ_CMD_BUDDY_ADD_AUTH, raw_data, bytes); | 121 qq_send_cmd(gc, QQ_CMD_BUDDY_ADD_AUTH, raw_data, bytes); |
117 } | 122 } |
118 | 123 |
119 static void request_buddy_add_auth_cb(qq_add_request *add_req, const gchar *text) | 124 static void request_buddy_add_auth_cb(qq_buddy_req *add_req, const gchar *text) |
120 { | 125 { |
121 g_return_if_fail(add_req != NULL); | 126 g_return_if_fail(add_req != NULL); |
122 if (add_req->gc == NULL || add_req->uid == 0) { | 127 if (add_req->gc == NULL || add_req->uid == 0) { |
123 g_free(add_req); | 128 g_free(add_req); |
124 return; | 129 return; |
127 request_buddy_auth(add_req->gc, add_req->uid, QQ_MY_AUTH_REQUEST, text); | 132 request_buddy_auth(add_req->gc, add_req->uid, QQ_MY_AUTH_REQUEST, text); |
128 g_free(add_req); | 133 g_free(add_req); |
129 } | 134 } |
130 | 135 |
131 /* the real packet to reject and request is sent from here */ | 136 /* the real packet to reject and request is sent from here */ |
132 static void buddy_add_deny_reason_cb(qq_add_request *add_req, const gchar *reason) | 137 static void buddy_add_deny_reason_cb(qq_buddy_req *add_req, const gchar *reason) |
133 { | 138 { |
134 g_return_if_fail(add_req != NULL); | 139 g_return_if_fail(add_req != NULL); |
135 if (add_req->gc == NULL || add_req->uid == 0) { | 140 if (add_req->gc == NULL || add_req->uid == 0) { |
136 g_free(add_req); | 141 g_free(add_req); |
137 return; | 142 return; |
140 request_buddy_auth(add_req->gc, add_req->uid, QQ_MY_AUTH_REJECT, reason); | 145 request_buddy_auth(add_req->gc, add_req->uid, QQ_MY_AUTH_REJECT, reason); |
141 g_free(add_req); | 146 g_free(add_req); |
142 } | 147 } |
143 | 148 |
144 /* we approve other's request of adding me as friend */ | 149 /* we approve other's request of adding me as friend */ |
145 static void buddy_add_authorize_cb(qq_add_request *add_req) | 150 static void buddy_add_authorize_cb(qq_buddy_req *add_req) |
146 { | 151 { |
147 g_return_if_fail(add_req != NULL); | 152 g_return_if_fail(add_req != NULL); |
148 if (add_req->gc == NULL || add_req->uid != 0) { | 153 if (add_req->gc == NULL || add_req->uid != 0) { |
149 g_free(add_req); | 154 g_free(add_req); |
150 return; | 155 return; |
153 request_buddy_auth(add_req->gc, add_req->uid, QQ_MY_AUTH_APPROVE, NULL); | 158 request_buddy_auth(add_req->gc, add_req->uid, QQ_MY_AUTH_APPROVE, NULL); |
154 g_free(add_req); | 159 g_free(add_req); |
155 } | 160 } |
156 | 161 |
157 /* we reject other's request of adding me as friend */ | 162 /* we reject other's request of adding me as friend */ |
158 static void buddy_add_deny_cb(qq_add_request *add_req) | 163 static void buddy_add_deny_cb(qq_buddy_req *add_req) |
159 { | 164 { |
160 gint uid; | 165 gint uid; |
161 gchar *msg1, *msg2; | 166 gchar *msg1, *msg2; |
162 PurpleConnection *gc; | 167 PurpleConnection *gc; |
163 gchar *purple_name; | 168 gchar *purple_name; |
182 add_req); | 187 add_req); |
183 g_free(purple_name); | 188 g_free(purple_name); |
184 } | 189 } |
185 | 190 |
186 /* suggested by rakescar@linuxsir, can still approve after search */ | 191 /* suggested by rakescar@linuxsir, can still approve after search */ |
187 static void buddy_add_check_info_cb(qq_add_request *add_req) | 192 static void buddy_add_check_info_cb(qq_buddy_req *add_req) |
188 { | 193 { |
189 PurpleConnection *gc; | 194 PurpleConnection *gc; |
190 guint32 uid; | 195 guint32 uid; |
191 gchar *purple_name; | 196 gchar *purple_name; |
192 | 197 |
265 | 270 |
266 purple_debug_info("QQ", "Add unknow buddy %d\n", uid); | 271 purple_debug_info("QQ", "Add unknow buddy %d\n", uid); |
267 request_buddy_add_no_auth(gc, uid); | 272 request_buddy_add_no_auth(gc, uid); |
268 } | 273 } |
269 | 274 |
270 static void buddy_cancel_cb(qq_add_request *add_req, const gchar *msg) | 275 static void buddy_cancel_cb(qq_buddy_req *add_req, const gchar *msg) |
271 { | 276 { |
272 g_return_if_fail(add_req != NULL); | 277 g_return_if_fail(add_req != NULL); |
273 g_free(add_req); | 278 g_free(add_req); |
274 } | 279 } |
275 | 280 |
276 static void buddy_add_no_auth_cb(qq_add_request *add_req) | 281 static void buddy_add_no_auth_cb(qq_buddy_req *add_req) |
277 { | 282 { |
278 g_return_if_fail(add_req != NULL); | 283 g_return_if_fail(add_req != NULL); |
279 if (add_req->gc == NULL || add_req->uid == 0) { | 284 if (add_req->gc == NULL || add_req->uid == 0) { |
280 g_free(add_req); | 285 g_free(add_req); |
281 return; | 286 return; |
283 | 288 |
284 request_buddy_add_no_auth(add_req->gc, add_req->uid); | 289 request_buddy_add_no_auth(add_req->gc, add_req->uid); |
285 g_free(add_req); | 290 g_free(add_req); |
286 } | 291 } |
287 | 292 |
288 static void buddy_remove_both_cb(qq_add_request *add_req) | 293 static void buddy_remove_both_cb(qq_buddy_req *add_req) |
289 { | 294 { |
290 PurpleConnection *gc; | 295 PurpleConnection *gc; |
291 qq_data *qd; | 296 qq_data *qd; |
292 gchar *purple_name; | 297 gchar *purple_name; |
293 PurpleBuddy *buddy; | 298 PurpleBuddy *buddy; |
327 void qq_remove_buddy_and_me(PurpleBlistNode * node) | 332 void qq_remove_buddy_and_me(PurpleBlistNode * node) |
328 { | 333 { |
329 PurpleConnection *gc; | 334 PurpleConnection *gc; |
330 qq_data *qd; | 335 qq_data *qd; |
331 guint32 uid; | 336 guint32 uid; |
332 qq_add_request *add_req; | 337 qq_buddy_req *add_req; |
333 PurpleBuddy *buddy; | 338 PurpleBuddy *buddy; |
334 const gchar *who; | 339 const gchar *who; |
335 | 340 |
336 g_return_if_fail(PURPLE_BLIST_NODE_IS_BUDDY(node)); | 341 g_return_if_fail(PURPLE_BLIST_NODE_IS_BUDDY(node)); |
337 | 342 |
349 | 354 |
350 if (uid == qd->uid) { | 355 if (uid == qd->uid) { |
351 return; | 356 return; |
352 } | 357 } |
353 | 358 |
354 add_req = g_new0(qq_add_request, 1); | 359 add_req = g_new0(qq_buddy_req, 1); |
355 add_req->gc = gc; | 360 add_req->gc = gc; |
356 add_req->uid = uid; | 361 add_req->uid = uid; |
357 | 362 |
358 purple_request_action(gc, _("Block Buddy"), | 363 purple_request_action(gc, _("Block Buddy"), |
359 "Are you sure you want to block this buddy?", | 364 "Are you sure you want to block this buddy?", |
427 void qq_process_buddy_add_no_auth(guint8 *data, gint data_len, guint32 uid, PurpleConnection *gc) | 432 void qq_process_buddy_add_no_auth(guint8 *data, gint data_len, guint32 uid, PurpleConnection *gc) |
428 { | 433 { |
429 qq_data *qd; | 434 qq_data *qd; |
430 gchar *msg, **segments, *dest_uid, *reply; | 435 gchar *msg, **segments, *dest_uid, *reply; |
431 PurpleBuddy *b; | 436 PurpleBuddy *b; |
432 qq_add_request *add_req; | 437 qq_buddy_req *add_req; |
433 gchar *nombre; | 438 gchar *nombre; |
434 | 439 |
435 g_return_if_fail(data != NULL && data_len != 0); | 440 g_return_if_fail(data != NULL && data_len != 0); |
436 | 441 |
437 qd = (qq_data *) gc->proto_data; | 442 qd = (qq_data *) gc->proto_data; |
458 purple_debug_warning("QQ", "Add buddy attempt fails, need authentication\n"); | 463 purple_debug_warning("QQ", "Add buddy attempt fails, need authentication\n"); |
459 nombre = uid_to_purple_name(uid); | 464 nombre = uid_to_purple_name(uid); |
460 b = purple_find_buddy(gc->account, nombre); | 465 b = purple_find_buddy(gc->account, nombre); |
461 if (b != NULL) | 466 if (b != NULL) |
462 purple_blist_remove_buddy(b); | 467 purple_blist_remove_buddy(b); |
463 add_req = g_new0(qq_add_request, 1); | 468 add_req = g_new0(qq_buddy_req, 1); |
464 add_req->gc = gc; | 469 add_req->gc = gc; |
465 add_req->uid = uid; | 470 add_req->uid = uid; |
466 msg = g_strdup_printf(_("%d needs authentication"), uid); | 471 msg = g_strdup_printf(_("%d needs authentication"), uid); |
467 purple_request_input(gc, NULL, msg, | 472 purple_request_input(gc, NULL, msg, |
468 _("Input request here"), /* TODO: Awkward string to fix post string freeze - standardize auth dialogues? -evands */ | 473 _("Input request here"), /* TODO: Awkward string to fix post string freeze - standardize auth dialogues? -evands */ |
645 /* someone wants to add you to his buddy list */ | 650 /* someone wants to add you to his buddy list */ |
646 static void server_buddy_add_request(PurpleConnection *gc, gchar *from, gchar *to, gchar *msg_utf8) | 651 static void server_buddy_add_request(PurpleConnection *gc, gchar *from, gchar *to, gchar *msg_utf8) |
647 { | 652 { |
648 gchar *message, *reason; | 653 gchar *message, *reason; |
649 guint32 uid; | 654 guint32 uid; |
650 qq_add_request *g, *g2; | 655 qq_buddy_req *g, *g2; |
651 PurpleBuddy *b; | 656 PurpleBuddy *b; |
652 gchar *name; | 657 gchar *name; |
653 | 658 |
654 g_return_if_fail(from != NULL && to != NULL); | 659 g_return_if_fail(from != NULL && to != NULL); |
655 | 660 |
656 uid = strtol(from, NULL, 10); | 661 uid = strtol(from, NULL, 10); |
657 g = g_new0(qq_add_request, 1); | 662 g = g_new0(qq_buddy_req, 1); |
658 g->gc = gc; | 663 g->gc = gc; |
659 g->uid = uid; | 664 g->uid = uid; |
660 | 665 |
661 name = uid_to_purple_name(uid); | 666 name = uid_to_purple_name(uid); |
662 | 667 |
678 g_free(reason); | 683 g_free(reason); |
679 | 684 |
680 /* XXX: Is this needed once the above goes through purple_account_request_authorization()? */ | 685 /* XXX: Is this needed once the above goes through purple_account_request_authorization()? */ |
681 b = purple_find_buddy(gc->account, name); | 686 b = purple_find_buddy(gc->account, name); |
682 if (b == NULL) { /* the person is not in my list */ | 687 if (b == NULL) { /* the person is not in my list */ |
683 g2 = g_new0(qq_add_request, 1); | 688 g2 = g_new0(qq_buddy_req, 1); |
684 g2->gc = gc; | 689 g2->gc = gc; |
685 g2->uid = strtol(from, NULL, 10); | 690 g2->uid = strtol(from, NULL, 10); |
686 message = g_strdup_printf(_("%s is not in buddy list"), from); | 691 message = g_strdup_printf(_("%s is not in buddy list"), from); |
687 purple_request_action(gc, NULL, message, | 692 purple_request_action(gc, NULL, message, |
688 _("Would you add?"), PURPLE_DEFAULT_ACTION_NONE, | 693 _("Would you add?"), PURPLE_DEFAULT_ACTION_NONE, |
701 static void server_buddy_added(PurpleConnection *gc, gchar *from, gchar *to, gchar *msg_utf8) | 706 static void server_buddy_added(PurpleConnection *gc, gchar *from, gchar *to, gchar *msg_utf8) |
702 { | 707 { |
703 gchar *message; | 708 gchar *message; |
704 PurpleBuddy *b; | 709 PurpleBuddy *b; |
705 guint32 uid; | 710 guint32 uid; |
706 qq_add_request *add_req; | 711 qq_buddy_req *add_req; |
707 gchar *name; | 712 gchar *name; |
708 | 713 |
709 g_return_if_fail(from != NULL && to != NULL); | 714 g_return_if_fail(from != NULL && to != NULL); |
710 | 715 |
711 uid = strtol(from, NULL, 10); | 716 uid = strtol(from, NULL, 10); |
712 name = uid_to_purple_name(uid); | 717 name = uid_to_purple_name(uid); |
713 b = purple_find_buddy(gc->account, name); | 718 b = purple_find_buddy(gc->account, name); |
714 | 719 |
715 if (b == NULL) { /* the person is not in my list */ | 720 if (b == NULL) { /* the person is not in my list */ |
716 add_req = g_new0(qq_add_request, 1); | 721 add_req = g_new0(qq_buddy_req, 1); |
717 add_req->gc = gc; | 722 add_req->gc = gc; |
718 add_req->uid = uid; /* only need to get value */ | 723 add_req->uid = uid; /* only need to get value */ |
719 message = g_strdup_printf(_("You have been added by %s"), from); | 724 message = g_strdup_printf(_("You have been added by %s"), from); |
720 purple_request_action(gc, NULL, message, | 725 purple_request_action(gc, NULL, message, |
721 _("Would you like to add him?"), | 726 _("Would you like to add him?"), |