Mercurial > pidgin
comparison libpurple/protocols/qq/group_join.c @ 24117:d57928c9dd8f
2008.09.19 - ccpaging <ccpaging(at)gmail.com>
* Rewrite buddy modify info, there is a ticket for this problem
* Use ship32 to trans action code between request packet and reply packet process
author | SHiNE CsyFeK <csyfek@gmail.com> |
---|---|
date | Fri, 19 Sep 2008 14:46:41 +0000 |
parents | bcfc98c7a55f |
children | bdfcfd71449c |
comparison
equal
deleted
inserted
replaced
24116:b72816d1a131 | 24117:d57928c9dd8f |
---|---|
27 #include "debug.h" | 27 #include "debug.h" |
28 #include "notify.h" | 28 #include "notify.h" |
29 #include "request.h" | 29 #include "request.h" |
30 #include "server.h" | 30 #include "server.h" |
31 | 31 |
32 #include "buddy_opt.h" | |
33 #include "char_conv.h" | 32 #include "char_conv.h" |
34 #include "group_conv.h" | 33 #include "group_conv.h" |
35 #include "group_find.h" | 34 #include "group_find.h" |
36 #include "group_free.h" | |
37 #include "group_internal.h" | 35 #include "group_internal.h" |
38 #include "group_info.h" | 36 #include "group_info.h" |
39 #include "group_join.h" | 37 #include "group_join.h" |
40 #include "group_opt.h" | 38 #include "group_opt.h" |
41 #include "group_conv.h" | 39 #include "group_conv.h" |
49 QQ_ROOM_JOIN_OK = 0x01, | 47 QQ_ROOM_JOIN_OK = 0x01, |
50 QQ_ROOM_JOIN_NEED_AUTH = 0x02, | 48 QQ_ROOM_JOIN_NEED_AUTH = 0x02, |
51 QQ_ROOM_JOIN_DENIED = 0x03, | 49 QQ_ROOM_JOIN_DENIED = 0x03, |
52 }; | 50 }; |
53 | 51 |
54 static void _qq_group_exit_with_gc_and_id(gc_and_uid *g) | 52 static void group_quit_cb(qq_add_request *add_req) |
55 { | 53 { |
56 PurpleConnection *gc; | 54 PurpleConnection *gc; |
57 guint32 id; | 55 guint32 id; |
58 qq_group *group; | 56 qq_group *group; |
59 | 57 |
60 gc = g->gc; | 58 if (add_req->gc == NULL || add_req->uid == 0) { |
61 id = g->uid; | 59 g_free(add_req); |
60 return; | |
61 } | |
62 | |
63 gc = add_req->gc; | |
64 id = add_req->uid; | |
62 | 65 |
63 group = qq_room_search_id(gc, id); | 66 group = qq_room_search_id(gc, id); |
64 g_return_if_fail(group != NULL); | 67 if (group == NULL) { |
68 g_free(add_req); | |
69 return; | |
70 } | |
65 | 71 |
66 qq_send_room_cmd_only(gc, QQ_ROOM_CMD_QUIT, group->id); | 72 qq_send_room_cmd_only(gc, QQ_ROOM_CMD_QUIT, group->id); |
73 g_free(add_req); | |
67 } | 74 } |
68 | 75 |
69 /* send packet to join a group without auth */ | 76 /* send packet to join a group without auth */ |
70 void qq_request_room_join(PurpleConnection *gc, qq_group *group) | 77 void qq_request_room_join(PurpleConnection *gc, qq_group *group) |
71 { | 78 { |
93 } | 100 } |
94 | 101 |
95 qq_send_room_cmd_only(gc, QQ_ROOM_CMD_JOIN, group->id); | 102 qq_send_room_cmd_only(gc, QQ_ROOM_CMD_JOIN, group->id); |
96 } | 103 } |
97 | 104 |
98 static void _qq_group_join_auth_with_gc_and_id(gc_and_uid *g, const gchar *reason_utf8) | 105 static void group_join_cb(qq_add_request *add_req, const gchar *reason_utf8) |
99 { | 106 { |
100 PurpleConnection *gc; | 107 qq_group *group; |
101 qq_group *group; | 108 |
102 guint32 id; | 109 g_return_if_fail(add_req != NULL); |
103 | 110 if (add_req->gc == NULL || add_req->uid == 0) { |
104 gc = g->gc; | 111 g_free(add_req); |
105 id = g->uid; | 112 return; |
106 | 113 } |
107 group = qq_room_search_id(gc, id); | 114 |
115 group = qq_room_search_id(add_req->gc, add_req->uid); | |
108 if (group == NULL) { | 116 if (group == NULL) { |
109 purple_debug_error("QQ", "Can not find qq_group by internal_id: %d\n", id); | 117 purple_debug_error("QQ", "Can not find qq_group by internal_id: %d\n", add_req->uid); |
110 return; | 118 g_free(add_req); |
111 } else { /* everything is OK */ | 119 return; |
112 qq_send_cmd_group_auth(gc, group, QQ_ROOM_AUTH_REQUEST_APPLY, 0, reason_utf8); | 120 } |
113 } | 121 |
122 qq_send_cmd_group_auth(add_req->gc, group, QQ_ROOM_AUTH_REQUEST_APPLY, 0, reason_utf8); | |
123 g_free(add_req); | |
124 } | |
125 | |
126 void qq_group_cancel_cb(qq_add_request *add_req, const gchar *msg) | |
127 { | |
128 g_return_if_fail(add_req != NULL); | |
129 g_free(add_req); | |
114 } | 130 } |
115 | 131 |
116 static void _qq_group_join_auth(PurpleConnection *gc, qq_group *group) | 132 static void _qq_group_join_auth(PurpleConnection *gc, qq_group *group) |
117 { | 133 { |
118 gchar *msg; | 134 gchar *msg; |
119 gc_and_uid *g; | 135 qq_add_request *add_req; |
120 g_return_if_fail(group != NULL); | 136 g_return_if_fail(group != NULL); |
121 | 137 |
122 purple_debug_info("QQ", "Group (internal id: %d) needs authentication\n", group->id); | 138 purple_debug_info("QQ", "Group (internal id: %d) needs authentication\n", group->id); |
123 | 139 |
124 msg = g_strdup_printf("Group \"%s\" needs authentication\n", group->title_utf8); | 140 msg = g_strdup_printf("Group \"%s\" needs authentication\n", group->title_utf8); |
125 g = g_new0(gc_and_uid, 1); | 141 add_req = g_new0(qq_add_request, 1); |
126 g->gc = gc; | 142 add_req->gc = gc; |
127 g->uid = group->id; | 143 add_req->uid = group->id; |
128 purple_request_input(gc, NULL, msg, | 144 purple_request_input(gc, NULL, msg, |
129 _("Input request here"), | 145 _("Input request here"), |
130 _("Would you be my friend?"), TRUE, FALSE, NULL, | 146 _("Would you be my friend?"), TRUE, FALSE, NULL, |
131 _("Send"), | 147 _("Send"), |
132 G_CALLBACK(_qq_group_join_auth_with_gc_and_id), | 148 G_CALLBACK(group_join_cb), |
133 _("Cancel"), G_CALLBACK(qq_do_nothing_with_gc_and_uid), | 149 _("Cancel"), G_CALLBACK(qq_group_cancel_cb), |
134 purple_connection_get_account(gc), group->title_utf8, NULL, | 150 purple_connection_get_account(gc), group->title_utf8, NULL, |
135 g); | 151 add_req); |
136 g_free(msg); | 152 g_free(msg); |
137 } | 153 } |
138 | 154 |
139 void qq_send_cmd_group_auth(PurpleConnection *gc, qq_group *group, guint8 opt, guint32 uid, const gchar *reason_utf8) | 155 void qq_send_cmd_group_auth(PurpleConnection *gc, qq_group *group, guint8 opt, guint32 uid, const gchar *reason_utf8) |
140 { | 156 { |
306 | 322 |
307 void qq_group_exit(PurpleConnection *gc, GHashTable *data) | 323 void qq_group_exit(PurpleConnection *gc, GHashTable *data) |
308 { | 324 { |
309 gchar *id_ptr; | 325 gchar *id_ptr; |
310 guint32 id; | 326 guint32 id; |
311 gc_and_uid *g; | 327 qq_add_request *add_req; |
312 | 328 |
313 g_return_if_fail(data != NULL); | 329 g_return_if_fail(data != NULL); |
314 | 330 |
315 id_ptr = g_hash_table_lookup(data, QQ_ROOM_KEY_INTERNAL_ID); | 331 id_ptr = g_hash_table_lookup(data, QQ_ROOM_KEY_INTERNAL_ID); |
316 id = strtol(id_ptr, NULL, 10); | 332 id = strtol(id_ptr, NULL, 10); |
317 | 333 |
318 g_return_if_fail(id > 0); | 334 g_return_if_fail(id > 0); |
319 | 335 |
320 g = g_new0(gc_and_uid, 1); | 336 add_req = g_new0(qq_add_request, 1); |
321 g->gc = gc; | 337 add_req->gc = gc; |
322 g->uid = id; | 338 add_req->uid = id; |
323 | 339 |
324 purple_request_action(gc, _("QQ Qun Operation"), | 340 purple_request_action(gc, _("QQ Qun Operation"), |
325 _("Are you sure you want to leave this Qun?"), | 341 _("Are you sure you want to leave this Qun?"), |
326 _("Note, if you are the creator, \nthis operation will eventually remove this Qun."), | 342 _("Note, if you are the creator, \nthis operation will eventually remove this Qun."), |
327 1, | 343 1, |
328 purple_connection_get_account(gc), NULL, NULL, | 344 purple_connection_get_account(gc), NULL, NULL, |
329 g, 2, _("Cancel"), | 345 add_req, 2, _("Cancel"), |
330 G_CALLBACK(qq_do_nothing_with_gc_and_uid), | 346 G_CALLBACK(qq_group_cancel_cb), |
331 _("Continue"), G_CALLBACK(_qq_group_exit_with_gc_and_id)); | 347 _("Continue"), G_CALLBACK(group_quit_cb)); |
332 } | 348 } |