Mercurial > pidgin.yaz
comparison libpurple/protocols/qq/group_opt.c @ 24092:7c0a56c5fea0
2008.10.14 - ccpaging <ccpaging(at)gmail.com>
* 2007 remove buddy ok
* Removed group_search.c/h
author | SHiNE CsyFeK <csyfek@gmail.com> |
---|---|
date | Tue, 28 Oct 2008 16:44:09 +0000 |
parents | 9be95f0b9472 |
children | 2a19984c0005 |
comparison
equal
deleted
inserted
replaced
24091:d35672443baa | 24092:7c0a56c5fea0 |
---|---|
81 { | 81 { |
82 if (add_req != NULL) | 82 if (add_req != NULL) |
83 g_free(add_req); | 83 g_free(add_req); |
84 } | 84 } |
85 | 85 |
86 static void member_join_reject_send_cb(qq_room_req *add_req, gchar *msg_utf8) | 86 static void member_join_authorize_cb(gpointer data) |
87 { | 87 { |
88 qq_room_data *rmd; | 88 qq_room_req *add_req = (qq_room_req *)data; |
89 g_return_if_fail(add_req != NULL && add_req->gc != NULL && add_req->id > 0 && add_req->member > 0); | 89 qq_room_data *rmd; |
90 rmd = qq_room_data_find(add_req->gc, add_req->id); | 90 g_return_if_fail(add_req != NULL && add_req->gc != NULL); |
91 g_return_if_fail(rmd != NULL); | 91 g_return_if_fail(add_req->id > 0 && add_req->member > 0); |
92 qq_send_cmd_group_auth(add_req->gc, rmd, QQ_ROOM_AUTH_REQUEST_REJECT, add_req->member, msg_utf8); | |
93 g_free(add_req); | |
94 } | |
95 | |
96 static void member_join_reject_cb(qq_room_req *add_req) | |
97 { | |
98 gchar *msg1, *msg2, *who; | |
99 g_return_if_fail(add_req != NULL && add_req->gc != NULL && add_req->member > 0); | |
100 | |
101 msg1 = g_strdup_printf(_("You rejected %d's request"), add_req->member); | |
102 msg2 = g_strdup(_("Message:")); | |
103 | |
104 who = uid_to_purple_name(add_req->member); | |
105 purple_request_input(add_req->gc, /* title */ NULL, msg1, msg2, | |
106 _("Sorry, you are not my style..."), /* multiline */ TRUE, /* masked */ FALSE, | |
107 /* hint */ NULL, | |
108 _("Send"), G_CALLBACK(member_join_reject_send_cb), | |
109 _("Cancel"), G_CALLBACK(room_req_cancel_cb), | |
110 purple_connection_get_account(add_req->gc), who, NULL, | |
111 add_req); | |
112 | |
113 g_free(msg1); | |
114 g_free(msg2); | |
115 g_free(who); | |
116 } | |
117 | |
118 static void member_join_authorize_cb(qq_room_req *add_req) | |
119 { | |
120 qq_room_data *rmd; | |
121 g_return_if_fail(add_req != NULL && add_req->gc != NULL && add_req->id > 0 && add_req->member > 0); | |
122 rmd = qq_room_data_find(add_req->gc, add_req->id); | 92 rmd = qq_room_data_find(add_req->gc, add_req->id); |
123 g_return_if_fail(rmd != NULL); | 93 g_return_if_fail(rmd != NULL); |
124 | 94 |
125 qq_send_cmd_group_auth(add_req->gc, rmd, QQ_ROOM_AUTH_REQUEST_APPROVE, add_req->member, ""); | 95 qq_send_cmd_group_auth(add_req->gc, rmd, QQ_ROOM_AUTH_REQUEST_APPROVE, add_req->member, ""); |
126 qq_room_buddy_find_or_new(add_req->gc, rmd, add_req->member); | 96 qq_room_buddy_find_or_new(add_req->gc, rmd, add_req->member); |
127 g_free(add_req); | 97 g_free(add_req); |
128 } | 98 } |
129 | 99 |
130 static void member_join_search_cb(qq_room_req *add_req) | 100 static void member_join_deny_reason_cb(qq_room_req *add_req, gchar *msg_utf8) |
131 { | 101 { |
132 g_return_if_fail(add_req != NULL && add_req->gc != NULL && add_req->member > 0); | 102 qq_room_data *rmd; |
133 | 103 g_return_if_fail(add_req != NULL && add_req->gc != NULL); |
134 qq_request_buddy_info(add_req->gc, add_req->member, 0, QQ_BUDDY_INFO_DISPLAY); | 104 g_return_if_fail(add_req->id > 0 && add_req->member > 0); |
135 purple_request_action(add_req->gc, NULL, _("Do you want to approve the request?"), "", | 105 rmd = qq_room_data_find(add_req->gc, add_req->id); |
136 PURPLE_DEFAULT_ACTION_NONE, | 106 g_return_if_fail(rmd != NULL); |
137 purple_connection_get_account(add_req->gc), NULL, NULL, | 107 qq_send_cmd_group_auth(add_req->gc, rmd, QQ_ROOM_AUTH_REQUEST_REJECT, add_req->member, msg_utf8); |
138 add_req, 2, | 108 g_free(add_req); |
139 _("Reject"), G_CALLBACK(member_join_reject_cb), | 109 } |
140 _("Approve"), G_CALLBACK(member_join_authorize_cb)); | 110 |
111 static void member_join_deny_noreason_cb(qq_room_req *add_req, gchar *msg_utf8) | |
112 { | |
113 member_join_deny_reason_cb(add_req, NULL); | |
114 } | |
115 | |
116 static void member_join_deny_cb(gpointer data) | |
117 { | |
118 qq_room_req *add_req = (qq_room_req *)data; | |
119 gchar *who; | |
120 g_return_if_fail(add_req != NULL && add_req->gc != NULL); | |
121 g_return_if_fail(add_req->id > 0 && add_req->member > 0); | |
122 | |
123 who = uid_to_purple_name(add_req->member); | |
124 purple_request_input(add_req->gc, NULL, _("Authorization denied message:"), | |
125 NULL, _("Sorry, you are not our style ..."), TRUE, FALSE, NULL, | |
126 _("OK"), G_CALLBACK(member_join_deny_reason_cb), | |
127 _("Cancel"), G_CALLBACK(member_join_deny_noreason_cb), | |
128 purple_connection_get_account(add_req->gc), who, NULL, | |
129 add_req); | |
130 g_free(who); | |
141 } | 131 } |
142 | 132 |
143 void qq_group_modify_members(PurpleConnection *gc, qq_room_data *rmd, guint32 *new_members) | 133 void qq_group_modify_members(PurpleConnection *gc, qq_room_data *rmd, guint32 *new_members) |
144 { | 134 { |
145 guint32 *old_members, *del_members, *add_members; | 135 guint32 *old_members, *del_members, *add_members; |
423 /* receive an application to join the group */ | 413 /* receive an application to join the group */ |
424 void qq_process_room_buddy_request_join(guint8 *data, gint len, guint32 id, PurpleConnection *gc) | 414 void qq_process_room_buddy_request_join(guint8 *data, gint len, guint32 id, PurpleConnection *gc) |
425 { | 415 { |
426 guint32 ext_id, member_id; | 416 guint32 ext_id, member_id; |
427 guint8 type8; | 417 guint8 type8; |
428 gchar *reason_utf8, *msg, *reason; | 418 gchar *msg, *reason; |
429 qq_room_req *add_req; | 419 qq_room_req *add_req; |
430 gchar *who; | 420 gchar *who; |
431 gint bytes = 0; | 421 gint bytes = 0; |
432 qq_room_data *rmd; | 422 qq_room_data *rmd; |
433 time_t now = time(NULL); | 423 time_t now = time(NULL); |
440 bytes += qq_get8(&type8, data + bytes); | 430 bytes += qq_get8(&type8, data + bytes); |
441 bytes += qq_get32(&member_id, data + bytes); | 431 bytes += qq_get32(&member_id, data + bytes); |
442 | 432 |
443 g_return_if_fail(ext_id > 0 && member_id > 0); | 433 g_return_if_fail(ext_id > 0 && member_id > 0); |
444 | 434 |
445 bytes += qq_get_vstr(&reason_utf8, QQ_CHARSET_DEFAULT, data + bytes); | 435 bytes += qq_get_vstr(&reason, QQ_CHARSET_DEFAULT, data + bytes); |
446 | 436 |
447 add_req = g_new0(qq_room_req, 1); | 437 add_req = g_new0(qq_room_req, 1); |
448 add_req->gc = gc; | 438 add_req->gc = gc; |
449 add_req->id = id; | 439 add_req->id = id; |
450 add_req->member = member_id; | 440 add_req->member = member_id; |
454 rmd = qq_room_data_find(gc, id); | 444 rmd = qq_room_data_find(gc, id); |
455 g_return_if_fail(rmd != NULL); | 445 g_return_if_fail(rmd != NULL); |
456 if (qq_room_buddy_find(rmd, member_id)) { | 446 if (qq_room_buddy_find(rmd, member_id)) { |
457 purple_debug_info("QQ", "Approve join, buddy joined before\n"); | 447 purple_debug_info("QQ", "Approve join, buddy joined before\n"); |
458 msg = g_strdup_printf(_("%d requested to join Qun %d for %s"), | 448 msg = g_strdup_printf(_("%d requested to join Qun %d for %s"), |
459 member_id, ext_id, reason_utf8); | 449 member_id, ext_id, reason); |
460 qq_room_got_chat_in(gc, id, 0, msg, now); | 450 qq_room_got_chat_in(gc, id, 0, msg, now); |
461 qq_send_cmd_group_auth(gc, rmd, QQ_ROOM_AUTH_REQUEST_APPROVE, member_id, ""); | 451 qq_send_cmd_group_auth(gc, rmd, QQ_ROOM_AUTH_REQUEST_APPROVE, member_id, ""); |
462 g_free(msg); | 452 g_free(msg); |
463 g_free(reason_utf8); | 453 g_free(reason); |
464 return; | 454 return; |
465 } | 455 } |
466 | 456 |
457 if (purple_prefs_get_bool("/plugins/prpl/qq/auto_get_authorize_info")) { | |
458 qq_request_buddy_info(gc, member_id, 0, QQ_BUDDY_INFO_DISPLAY); | |
459 } | |
467 who = uid_to_purple_name(member_id); | 460 who = uid_to_purple_name(member_id); |
468 msg = g_strdup_printf(_("%d request to join Qun %d"), member_id, ext_id); | 461 msg = g_strdup_printf(_("%d request to join Qun %d"), member_id, ext_id); |
469 reason = g_strdup_printf(_("Message: %s"), reason_utf8); | |
470 | 462 |
471 purple_request_action(gc, _("QQ Qun Operation"), | 463 purple_request_action(gc, _("QQ Qun Operation"), |
472 msg, reason, | 464 msg, reason, |
473 PURPLE_DEFAULT_ACTION_NONE, | 465 PURPLE_DEFAULT_ACTION_NONE, |
474 purple_connection_get_account(gc), who, NULL, | 466 purple_connection_get_account(gc), who, NULL, |
475 add_req, 3, | 467 add_req, 2, |
476 _("Approve"), | 468 _("Deny"), G_CALLBACK(member_join_deny_cb), |
477 G_CALLBACK | 469 _("Authorize"), G_CALLBACK(member_join_authorize_cb)); |
478 (member_join_authorize_cb), | |
479 _("Reject"), | |
480 G_CALLBACK | |
481 (member_join_reject_cb), | |
482 _("Search"), G_CALLBACK(member_join_search_cb)); | |
483 | 470 |
484 g_free(who); | 471 g_free(who); |
485 g_free(msg); | 472 g_free(msg); |
486 g_free(reason); | 473 g_free(reason); |
487 g_free(reason_utf8); | 474 g_free(reason); |
488 } | 475 } |
489 | 476 |
490 /* the request to join a group is rejected */ | 477 /* the request to join a group is rejected */ |
491 void qq_process_room_buddy_rejected(guint8 *data, gint len, guint32 id, PurpleConnection *gc) | 478 void qq_process_room_buddy_rejected(guint8 *data, gint len, guint32 id, PurpleConnection *gc) |
492 { | 479 { |