annotate libpurple/protocols/qq/group_join.c @ 23050:9a5d140400f1

patch-02-fix-multiarch
author SHiNE CsyFeK <csyfek@gmail.com>
date Tue, 24 Jun 2008 11:58:57 +0000
parents dccfd999ffe7
children 5f454b975a99
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1 /**
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2 * @file group_join.c
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
3 *
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15374
diff changeset
4 * purple
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
5 *
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15374
diff changeset
6 * Purple is the legal property of its developers, whose names are too numerous
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
7 * to list here. Please refer to the COPYRIGHT file distributed with this
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
8 * source distribution.
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
9 *
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
10 * This program is free software; you can redistribute it and/or modify
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
11 * it under the terms of the GNU General Public License as published by
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
12 * the Free Software Foundation; either version 2 of the License, or
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
13 * (at your option) any later version.
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
14 *
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
15 * This program is distributed in the hope that it will be useful,
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
18 * GNU General Public License for more details.
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
19 *
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
20 * You should have received a copy of the GNU General Public License
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
21 * along with this program; if not, write to the Free Software
19680
44b4e8bd759b The FSF changed its address a while ago; our files were out of date.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 18807
diff changeset
22 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
23 */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
24
18210
b8572b937c09 #include reorganizations to allow compiling with glib < 2.8 using the
Stu Tomlinson <stu@nosnilmot.com>
parents: 16442
diff changeset
25 #include "internal.h"
b8572b937c09 #include reorganizations to allow compiling with glib < 2.8 using the
Stu Tomlinson <stu@nosnilmot.com>
parents: 16442
diff changeset
26
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
27 #include "debug.h"
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
28 #include "notify.h"
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
29 #include "request.h"
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
30 #include "server.h"
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
31
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
32 #include "buddy_opt.h"
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
33 #include "char_conv.h"
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
34 #include "group_conv.h"
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
35 #include "group_find.h"
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
36 #include "group_free.h"
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
37 #include "group_internal.h"
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
38 #include "group_info.h"
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
39 #include "group_join.h"
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
40 #include "group_opt.h"
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
41 #include "group_network.h"
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
42 #include "group_search.h"
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
43
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
44 enum {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
45 QQ_GROUP_JOIN_OK = 0x01,
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
46 QQ_GROUP_JOIN_NEED_AUTH = 0x02,
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
47 };
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
48
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
49 static void _qq_group_exit_with_gc_and_id(gc_and_uid *g)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
50 {
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15374
diff changeset
51 PurpleConnection *gc;
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
52 guint32 internal_group_id;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
53 qq_group *group;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
54
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
55 gc = g->gc;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
56 internal_group_id = g->uid;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
57
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
58 group = qq_group_find_by_id(gc, internal_group_id, QQ_INTERNAL_ID);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
59 g_return_if_fail(group != NULL);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
60
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
61 qq_send_cmd_group_exit_group(gc, group);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
62 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
63
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
64 /* send packet to join a group without auth */
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15374
diff changeset
65 void qq_send_cmd_group_join_group(PurpleConnection *gc, qq_group *group)
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
66 {
23050
9a5d140400f1 patch-02-fix-multiarch
SHiNE CsyFeK <csyfek@gmail.com>
parents: 21570
diff changeset
67 guint8 raw_data[16] = {0};
9a5d140400f1 patch-02-fix-multiarch
SHiNE CsyFeK <csyfek@gmail.com>
parents: 21570
diff changeset
68 gint bytes = 0;
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
69
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
70 g_return_if_fail(group != NULL);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
71
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
72 if (group->my_status == QQ_GROUP_MEMBER_STATUS_NOT_MEMBER) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
73 group->my_status = QQ_GROUP_MEMBER_STATUS_APPLYING;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
74 qq_group_refresh(gc, group);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
75 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
76
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
77 switch (group->auth_type) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
78 case QQ_GROUP_AUTH_TYPE_NO_AUTH:
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
79 case QQ_GROUP_AUTH_TYPE_NEED_AUTH:
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
80 break;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
81 case QQ_GROUP_AUTH_TYPE_NO_ADD:
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15374
diff changeset
82 purple_notify_warning(gc, NULL, _("This group does not allow others to join"), NULL);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
83 return;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
84 default:
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15374
diff changeset
85 purple_debug(PURPLE_DEBUG_ERROR, "QQ", "Unknown group auth type: %d\n", group->auth_type);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
86 break;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
87 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
88
23050
9a5d140400f1 patch-02-fix-multiarch
SHiNE CsyFeK <csyfek@gmail.com>
parents: 21570
diff changeset
89 bytes = 0;
9a5d140400f1 patch-02-fix-multiarch
SHiNE CsyFeK <csyfek@gmail.com>
parents: 21570
diff changeset
90 bytes += qq_put8(raw_data + bytes, QQ_GROUP_CMD_JOIN_GROUP);
9a5d140400f1 patch-02-fix-multiarch
SHiNE CsyFeK <csyfek@gmail.com>
parents: 21570
diff changeset
91 bytes += qq_put32(raw_data + bytes, group->internal_group_id);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
92
23050
9a5d140400f1 patch-02-fix-multiarch
SHiNE CsyFeK <csyfek@gmail.com>
parents: 21570
diff changeset
93 qq_send_group_cmd(gc, group, raw_data, bytes);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
94 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
95
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
96 static void _qq_group_join_auth_with_gc_and_id(gc_and_uid *g, const gchar *reason_utf8)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
97 {
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15374
diff changeset
98 PurpleConnection *gc;
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
99 qq_group *group;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
100 guint32 internal_group_id;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
101
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
102 gc = g->gc;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
103 internal_group_id = g->uid;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
104
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
105 group = qq_group_find_by_id(gc, internal_group_id, QQ_INTERNAL_ID);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
106 if (group == NULL) {
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15374
diff changeset
107 purple_debug(PURPLE_DEBUG_ERROR, "QQ", "Can not find qq_group by internal_id: %d\n", internal_group_id);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
108 return;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
109 } else { /* everything is OK */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
110 qq_send_cmd_group_auth(gc, group, QQ_GROUP_AUTH_REQUEST_APPLY, 0, reason_utf8);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
111 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
112 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
113
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15374
diff changeset
114 static void _qq_group_join_auth(PurpleConnection *gc, qq_group *group)
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
115 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
116 gchar *msg;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
117 gc_and_uid *g;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
118 g_return_if_fail(group != NULL);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
119
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15374
diff changeset
120 purple_debug(PURPLE_DEBUG_INFO, "QQ",
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
121 "Group (internal id: %d) needs authentication\n", group->internal_group_id);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
122
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
123 msg = g_strdup_printf("Group \"%s\" needs authentication\n", group->group_name_utf8);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
124 g = g_new0(gc_and_uid, 1);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
125 g->gc = gc;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
126 g->uid = group->internal_group_id;
21570
dccfd999ffe7 merge of '76c07fcb434a2a7aa289734bb221c171a376d73b'
Evan Schoenberg <evan.s@dreskin.net>
parents: 21244
diff changeset
127 purple_request_input(gc, NULL, msg,
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
128 _("Input request here"),
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
129 _("Would you be my friend?"), TRUE, FALSE, NULL,
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
130 _("Send"),
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
131 G_CALLBACK(_qq_group_join_auth_with_gc_and_id),
16442
08db93bbd798 Added account, who, and conversation parameters to the request API calls, and updated all code to match. I can't compile the Perl module, so I'd appreciate it if someone who knows it would verify that this doesn't break Perl.
Evan Schoenberg <evan.s@dreskin.net>
parents: 15823
diff changeset
132 _("Cancel"), G_CALLBACK(qq_do_nothing_with_gc_and_uid),
08db93bbd798 Added account, who, and conversation parameters to the request API calls, and updated all code to match. I can't compile the Perl module, so I'd appreciate it if someone who knows it would verify that this doesn't break Perl.
Evan Schoenberg <evan.s@dreskin.net>
parents: 15823
diff changeset
133 purple_connection_get_account(gc), group->group_name_utf8, NULL,
21570
dccfd999ffe7 merge of '76c07fcb434a2a7aa289734bb221c171a376d73b'
Evan Schoenberg <evan.s@dreskin.net>
parents: 21244
diff changeset
134 g);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
135 g_free(msg);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
136 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
137
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15374
diff changeset
138 void qq_send_cmd_group_auth(PurpleConnection *gc, qq_group *group, guint8 opt, guint32 uid, const gchar *reason_utf8)
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
139 {
23050
9a5d140400f1 patch-02-fix-multiarch
SHiNE CsyFeK <csyfek@gmail.com>
parents: 21570
diff changeset
140 guint8 *raw_data;
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
141 gchar *reason_qq;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
142 gint bytes, data_len;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
143
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
144 g_return_if_fail(group != NULL);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
145
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
146 if (reason_utf8 == NULL || strlen(reason_utf8) == 0)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
147 reason_qq = g_strdup("");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
148 else
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
149 reason_qq = utf8_to_qq(reason_utf8, QQ_CHARSET_DEFAULT);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
150
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
151 if (opt == QQ_GROUP_AUTH_REQUEST_APPLY) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
152 group->my_status = QQ_GROUP_MEMBER_STATUS_APPLYING;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
153 qq_group_refresh(gc, group);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
154 uid = 0;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
155 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
156
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
157 data_len = 10 + strlen(reason_qq) + 1;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
158 raw_data = g_newa(guint8, data_len);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
159
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
160 bytes = 0;
23050
9a5d140400f1 patch-02-fix-multiarch
SHiNE CsyFeK <csyfek@gmail.com>
parents: 21570
diff changeset
161 bytes += qq_put8(raw_data + bytes, QQ_GROUP_CMD_JOIN_GROUP_AUTH);
9a5d140400f1 patch-02-fix-multiarch
SHiNE CsyFeK <csyfek@gmail.com>
parents: 21570
diff changeset
162 bytes += qq_put32(raw_data + bytes, group->internal_group_id);
9a5d140400f1 patch-02-fix-multiarch
SHiNE CsyFeK <csyfek@gmail.com>
parents: 21570
diff changeset
163 bytes += qq_put8(raw_data + bytes, opt);
9a5d140400f1 patch-02-fix-multiarch
SHiNE CsyFeK <csyfek@gmail.com>
parents: 21570
diff changeset
164 bytes += qq_put32(raw_data + bytes, uid);
9a5d140400f1 patch-02-fix-multiarch
SHiNE CsyFeK <csyfek@gmail.com>
parents: 21570
diff changeset
165 bytes += qq_put8(raw_data + bytes, strlen(reason_qq));
9a5d140400f1 patch-02-fix-multiarch
SHiNE CsyFeK <csyfek@gmail.com>
parents: 21570
diff changeset
166 bytes += qq_putdata(raw_data + bytes, (guint8 *) reason_qq, strlen(reason_qq));
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
167
23050
9a5d140400f1 patch-02-fix-multiarch
SHiNE CsyFeK <csyfek@gmail.com>
parents: 21570
diff changeset
168 if (bytes != data_len) {
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15374
diff changeset
169 purple_debug(PURPLE_DEBUG_ERROR, "QQ",
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
170 "Fail create packet for %s\n", qq_group_cmd_get_desc(QQ_GROUP_CMD_JOIN_GROUP_AUTH));
23050
9a5d140400f1 patch-02-fix-multiarch
SHiNE CsyFeK <csyfek@gmail.com>
parents: 21570
diff changeset
171 return;
9a5d140400f1 patch-02-fix-multiarch
SHiNE CsyFeK <csyfek@gmail.com>
parents: 21570
diff changeset
172 }
9a5d140400f1 patch-02-fix-multiarch
SHiNE CsyFeK <csyfek@gmail.com>
parents: 21570
diff changeset
173
9a5d140400f1 patch-02-fix-multiarch
SHiNE CsyFeK <csyfek@gmail.com>
parents: 21570
diff changeset
174 qq_send_group_cmd(gc, group, raw_data, data_len);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
175 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
176
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
177 /* send a packet to exit a group */
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15374
diff changeset
178 void qq_send_cmd_group_exit_group(PurpleConnection *gc, qq_group *group)
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
179 {
23050
9a5d140400f1 patch-02-fix-multiarch
SHiNE CsyFeK <csyfek@gmail.com>
parents: 21570
diff changeset
180 guint8 raw_data[16] = {0};
9a5d140400f1 patch-02-fix-multiarch
SHiNE CsyFeK <csyfek@gmail.com>
parents: 21570
diff changeset
181 gint bytes = 0;
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
182
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
183 g_return_if_fail(group != NULL);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
184
23050
9a5d140400f1 patch-02-fix-multiarch
SHiNE CsyFeK <csyfek@gmail.com>
parents: 21570
diff changeset
185 bytes += qq_put8(raw_data + bytes, QQ_GROUP_CMD_EXIT_GROUP);
9a5d140400f1 patch-02-fix-multiarch
SHiNE CsyFeK <csyfek@gmail.com>
parents: 21570
diff changeset
186 bytes += qq_put32(raw_data + bytes, group->internal_group_id);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
187
23050
9a5d140400f1 patch-02-fix-multiarch
SHiNE CsyFeK <csyfek@gmail.com>
parents: 21570
diff changeset
188 qq_send_group_cmd(gc, group, raw_data, bytes);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
189 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
190
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
191 /* If comes here, cmd is OK already */
23050
9a5d140400f1 patch-02-fix-multiarch
SHiNE CsyFeK <csyfek@gmail.com>
parents: 21570
diff changeset
192 void qq_process_group_cmd_exit_group(guint8 *data, gint len, PurpleConnection *gc)
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
193 {
23050
9a5d140400f1 patch-02-fix-multiarch
SHiNE CsyFeK <csyfek@gmail.com>
parents: 21570
diff changeset
194 gint bytes;
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
195 guint32 internal_group_id;
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15374
diff changeset
196 PurpleChat *chat;
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
197 qq_group *group;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
198 qq_data *qd;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
199
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
200 g_return_if_fail(data != NULL && len > 0);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
201 qd = (qq_data *) gc->proto_data;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
202
23050
9a5d140400f1 patch-02-fix-multiarch
SHiNE CsyFeK <csyfek@gmail.com>
parents: 21570
diff changeset
203 if (len < 4) {
9a5d140400f1 patch-02-fix-multiarch
SHiNE CsyFeK <csyfek@gmail.com>
parents: 21570
diff changeset
204 purple_debug(PURPLE_DEBUG_ERROR, "QQ",
9a5d140400f1 patch-02-fix-multiarch
SHiNE CsyFeK <csyfek@gmail.com>
parents: 21570
diff changeset
205 "Invalid exit group reply, expect %d bytes, read %d bytes\n", 4, len);
9a5d140400f1 patch-02-fix-multiarch
SHiNE CsyFeK <csyfek@gmail.com>
parents: 21570
diff changeset
206 return;
9a5d140400f1 patch-02-fix-multiarch
SHiNE CsyFeK <csyfek@gmail.com>
parents: 21570
diff changeset
207 }
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
208
23050
9a5d140400f1 patch-02-fix-multiarch
SHiNE CsyFeK <csyfek@gmail.com>
parents: 21570
diff changeset
209 bytes = 0;
9a5d140400f1 patch-02-fix-multiarch
SHiNE CsyFeK <csyfek@gmail.com>
parents: 21570
diff changeset
210 bytes += qq_get32(&internal_group_id, data + bytes);
9a5d140400f1 patch-02-fix-multiarch
SHiNE CsyFeK <csyfek@gmail.com>
parents: 21570
diff changeset
211
9a5d140400f1 patch-02-fix-multiarch
SHiNE CsyFeK <csyfek@gmail.com>
parents: 21570
diff changeset
212 group = qq_group_find_by_id(gc, internal_group_id, QQ_INTERNAL_ID);
9a5d140400f1 patch-02-fix-multiarch
SHiNE CsyFeK <csyfek@gmail.com>
parents: 21570
diff changeset
213 if (group != NULL) {
9a5d140400f1 patch-02-fix-multiarch
SHiNE CsyFeK <csyfek@gmail.com>
parents: 21570
diff changeset
214 chat = purple_blist_find_chat
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15374
diff changeset
215 (purple_connection_get_account(gc), g_strdup_printf("%d", group->external_group_id));
23050
9a5d140400f1 patch-02-fix-multiarch
SHiNE CsyFeK <csyfek@gmail.com>
parents: 21570
diff changeset
216 if (chat != NULL)
9a5d140400f1 patch-02-fix-multiarch
SHiNE CsyFeK <csyfek@gmail.com>
parents: 21570
diff changeset
217 purple_blist_remove_chat(chat);
9a5d140400f1 patch-02-fix-multiarch
SHiNE CsyFeK <csyfek@gmail.com>
parents: 21570
diff changeset
218 qq_group_delete_internal_record(qd, internal_group_id);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
219 }
23050
9a5d140400f1 patch-02-fix-multiarch
SHiNE CsyFeK <csyfek@gmail.com>
parents: 21570
diff changeset
220 purple_notify_info(gc, _("QQ Qun Operation"), _("You have successfully left the group"), NULL);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
221 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
222
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
223 /* Process the reply to group_auth subcmd */
23050
9a5d140400f1 patch-02-fix-multiarch
SHiNE CsyFeK <csyfek@gmail.com>
parents: 21570
diff changeset
224 void qq_process_group_cmd_join_group_auth(guint8 *data, gint len, PurpleConnection *gc)
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
225 {
23050
9a5d140400f1 patch-02-fix-multiarch
SHiNE CsyFeK <csyfek@gmail.com>
parents: 21570
diff changeset
226 gint bytes;
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
227 guint32 internal_group_id;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
228 qq_data *qd;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
229
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
230 g_return_if_fail(data != NULL && len > 0);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
231 qd = (qq_data *) gc->proto_data;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
232
23050
9a5d140400f1 patch-02-fix-multiarch
SHiNE CsyFeK <csyfek@gmail.com>
parents: 21570
diff changeset
233 if (len < 4) {
9a5d140400f1 patch-02-fix-multiarch
SHiNE CsyFeK <csyfek@gmail.com>
parents: 21570
diff changeset
234 purple_debug(PURPLE_DEBUG_ERROR, "QQ",
9a5d140400f1 patch-02-fix-multiarch
SHiNE CsyFeK <csyfek@gmail.com>
parents: 21570
diff changeset
235 "Invalid join group reply, expect %d bytes, read %d bytes\n", 4, len);
9a5d140400f1 patch-02-fix-multiarch
SHiNE CsyFeK <csyfek@gmail.com>
parents: 21570
diff changeset
236 return;
9a5d140400f1 patch-02-fix-multiarch
SHiNE CsyFeK <csyfek@gmail.com>
parents: 21570
diff changeset
237 }
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
238 bytes = 0;
23050
9a5d140400f1 patch-02-fix-multiarch
SHiNE CsyFeK <csyfek@gmail.com>
parents: 21570
diff changeset
239 bytes += qq_get32(&internal_group_id, data + bytes);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
240 g_return_if_fail(internal_group_id > 0);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
241
23050
9a5d140400f1 patch-02-fix-multiarch
SHiNE CsyFeK <csyfek@gmail.com>
parents: 21570
diff changeset
242 purple_notify_info(gc, _("QQ Group Auth"),
18807
b9a0b1bd321b Improve a bunch of strings in QQ
Mark Doliner <mark@kingant.net>
parents: 18210
diff changeset
243 _("Your authorization request has been accepted by the QQ server"), NULL);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
244 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
245
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
246 /* process group cmd reply "join group" */
23050
9a5d140400f1 patch-02-fix-multiarch
SHiNE CsyFeK <csyfek@gmail.com>
parents: 21570
diff changeset
247 void qq_process_group_cmd_join_group(guint8 *data, gint len, PurpleConnection *gc)
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
248 {
23050
9a5d140400f1 patch-02-fix-multiarch
SHiNE CsyFeK <csyfek@gmail.com>
parents: 21570
diff changeset
249 gint bytes;
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
250 guint32 internal_group_id;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
251 guint8 reply;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
252 qq_group *group;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
253
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
254 g_return_if_fail(data != NULL && len > 0);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
255
23050
9a5d140400f1 patch-02-fix-multiarch
SHiNE CsyFeK <csyfek@gmail.com>
parents: 21570
diff changeset
256 if (len < 5) {
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15374
diff changeset
257 purple_debug(PURPLE_DEBUG_ERROR, "QQ",
23050
9a5d140400f1 patch-02-fix-multiarch
SHiNE CsyFeK <csyfek@gmail.com>
parents: 21570
diff changeset
258 "Invalid join group reply, expect %d bytes, read %d bytes\n", 5, len);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
259 return;
23050
9a5d140400f1 patch-02-fix-multiarch
SHiNE CsyFeK <csyfek@gmail.com>
parents: 21570
diff changeset
260 }
9a5d140400f1 patch-02-fix-multiarch
SHiNE CsyFeK <csyfek@gmail.com>
parents: 21570
diff changeset
261
9a5d140400f1 patch-02-fix-multiarch
SHiNE CsyFeK <csyfek@gmail.com>
parents: 21570
diff changeset
262 bytes = 0;
9a5d140400f1 patch-02-fix-multiarch
SHiNE CsyFeK <csyfek@gmail.com>
parents: 21570
diff changeset
263 bytes += qq_get32(&internal_group_id, data + bytes);
9a5d140400f1 patch-02-fix-multiarch
SHiNE CsyFeK <csyfek@gmail.com>
parents: 21570
diff changeset
264 bytes += qq_get8(&reply, data + bytes);
9a5d140400f1 patch-02-fix-multiarch
SHiNE CsyFeK <csyfek@gmail.com>
parents: 21570
diff changeset
265
9a5d140400f1 patch-02-fix-multiarch
SHiNE CsyFeK <csyfek@gmail.com>
parents: 21570
diff changeset
266 /* join group OK */
9a5d140400f1 patch-02-fix-multiarch
SHiNE CsyFeK <csyfek@gmail.com>
parents: 21570
diff changeset
267 group = qq_group_find_by_id(gc, internal_group_id, QQ_INTERNAL_ID);
9a5d140400f1 patch-02-fix-multiarch
SHiNE CsyFeK <csyfek@gmail.com>
parents: 21570
diff changeset
268 /* need to check if group is NULL or not. */
9a5d140400f1 patch-02-fix-multiarch
SHiNE CsyFeK <csyfek@gmail.com>
parents: 21570
diff changeset
269 g_return_if_fail(group != NULL);
9a5d140400f1 patch-02-fix-multiarch
SHiNE CsyFeK <csyfek@gmail.com>
parents: 21570
diff changeset
270 switch (reply) {
9a5d140400f1 patch-02-fix-multiarch
SHiNE CsyFeK <csyfek@gmail.com>
parents: 21570
diff changeset
271 case QQ_GROUP_JOIN_OK:
9a5d140400f1 patch-02-fix-multiarch
SHiNE CsyFeK <csyfek@gmail.com>
parents: 21570
diff changeset
272 purple_debug(PURPLE_DEBUG_INFO, "QQ", "Succeed joining group \"%s\"\n", group->group_name_utf8);
9a5d140400f1 patch-02-fix-multiarch
SHiNE CsyFeK <csyfek@gmail.com>
parents: 21570
diff changeset
273 group->my_status = QQ_GROUP_MEMBER_STATUS_IS_MEMBER;
9a5d140400f1 patch-02-fix-multiarch
SHiNE CsyFeK <csyfek@gmail.com>
parents: 21570
diff changeset
274 qq_group_refresh(gc, group);
9a5d140400f1 patch-02-fix-multiarch
SHiNE CsyFeK <csyfek@gmail.com>
parents: 21570
diff changeset
275 /* this must be shown before getting online members */
9a5d140400f1 patch-02-fix-multiarch
SHiNE CsyFeK <csyfek@gmail.com>
parents: 21570
diff changeset
276 qq_group_conv_show_window(gc, group);
9a5d140400f1 patch-02-fix-multiarch
SHiNE CsyFeK <csyfek@gmail.com>
parents: 21570
diff changeset
277 qq_send_cmd_group_get_group_info(gc, group);
9a5d140400f1 patch-02-fix-multiarch
SHiNE CsyFeK <csyfek@gmail.com>
parents: 21570
diff changeset
278 break;
9a5d140400f1 patch-02-fix-multiarch
SHiNE CsyFeK <csyfek@gmail.com>
parents: 21570
diff changeset
279 case QQ_GROUP_JOIN_NEED_AUTH:
9a5d140400f1 patch-02-fix-multiarch
SHiNE CsyFeK <csyfek@gmail.com>
parents: 21570
diff changeset
280 purple_debug(PURPLE_DEBUG_INFO, "QQ",
9a5d140400f1 patch-02-fix-multiarch
SHiNE CsyFeK <csyfek@gmail.com>
parents: 21570
diff changeset
281 "Fail joining group [%d] %s, needs authentication\n",
9a5d140400f1 patch-02-fix-multiarch
SHiNE CsyFeK <csyfek@gmail.com>
parents: 21570
diff changeset
282 group->external_group_id, group->group_name_utf8);
9a5d140400f1 patch-02-fix-multiarch
SHiNE CsyFeK <csyfek@gmail.com>
parents: 21570
diff changeset
283 group->my_status = QQ_GROUP_MEMBER_STATUS_NOT_MEMBER;
9a5d140400f1 patch-02-fix-multiarch
SHiNE CsyFeK <csyfek@gmail.com>
parents: 21570
diff changeset
284 qq_group_refresh(gc, group);
9a5d140400f1 patch-02-fix-multiarch
SHiNE CsyFeK <csyfek@gmail.com>
parents: 21570
diff changeset
285 _qq_group_join_auth(gc, group);
9a5d140400f1 patch-02-fix-multiarch
SHiNE CsyFeK <csyfek@gmail.com>
parents: 21570
diff changeset
286 break;
9a5d140400f1 patch-02-fix-multiarch
SHiNE CsyFeK <csyfek@gmail.com>
parents: 21570
diff changeset
287 default:
9a5d140400f1 patch-02-fix-multiarch
SHiNE CsyFeK <csyfek@gmail.com>
parents: 21570
diff changeset
288 purple_debug(PURPLE_DEBUG_INFO, "QQ",
9a5d140400f1 patch-02-fix-multiarch
SHiNE CsyFeK <csyfek@gmail.com>
parents: 21570
diff changeset
289 "Error joining group [%d] %s, unknown reply: 0x%02x\n",
9a5d140400f1 patch-02-fix-multiarch
SHiNE CsyFeK <csyfek@gmail.com>
parents: 21570
diff changeset
290 group->external_group_id, group->group_name_utf8, reply);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
291 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
292 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
293
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
294 /* Attempt to join a group without auth */
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15374
diff changeset
295 void qq_group_join(PurpleConnection *gc, GHashTable *data)
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
296 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
297 qq_data *qd;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
298 gchar *external_group_id_ptr;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
299 guint32 external_group_id;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
300 qq_group *group;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
301
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
302 g_return_if_fail(data != NULL);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
303 qd = (qq_data *) gc->proto_data;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
304
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
305 external_group_id_ptr = g_hash_table_lookup(data, QQ_GROUP_KEY_EXTERNAL_ID);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
306 g_return_if_fail(external_group_id_ptr != NULL);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
307 errno = 0;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
308 external_group_id = strtol(external_group_id_ptr, NULL, 10);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
309 if (errno != 0) {
18807
b9a0b1bd321b Improve a bunch of strings in QQ
Mark Doliner <mark@kingant.net>
parents: 18210
diff changeset
310 purple_notify_error(gc, _("Error"),
b9a0b1bd321b Improve a bunch of strings in QQ
Mark Doliner <mark@kingant.net>
parents: 18210
diff changeset
311 _("You entered a group ID outside the acceptable range"), NULL);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
312 return;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
313 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
314
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
315 group = qq_group_find_by_id(gc, external_group_id, QQ_EXTERNAL_ID);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
316 if (group) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
317 qq_send_cmd_group_join_group(gc, group);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
318 } else {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
319 qq_set_pending_id(&qd->joining_groups, external_group_id, TRUE);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
320 qq_send_cmd_group_search_group(gc, external_group_id);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
321 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
322 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
323
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15374
diff changeset
324 void qq_group_exit(PurpleConnection *gc, GHashTable *data)
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
325 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
326 gchar *internal_group_id_ptr;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
327 guint32 internal_group_id;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
328 gc_and_uid *g;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
329
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
330 g_return_if_fail(data != NULL);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
331
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
332 internal_group_id_ptr = g_hash_table_lookup(data, "internal_group_id");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
333 internal_group_id = strtol(internal_group_id_ptr, NULL, 10);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
334
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
335 g_return_if_fail(internal_group_id > 0);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
336
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
337 g = g_new0(gc_and_uid, 1);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
338 g->gc = gc;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
339 g->uid = internal_group_id;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
340
21570
dccfd999ffe7 merge of '76c07fcb434a2a7aa289734bb221c171a376d73b'
Evan Schoenberg <evan.s@dreskin.net>
parents: 21244
diff changeset
341 purple_request_action(gc, _("QQ Qun Operation"),
18807
b9a0b1bd321b Improve a bunch of strings in QQ
Mark Doliner <mark@kingant.net>
parents: 18210
diff changeset
342 _("Are you sure you want to leave this Qun?"),
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
343 _
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
344 ("Note, if you are the creator, \nthis operation will eventually remove this Qun."),
16442
08db93bbd798 Added account, who, and conversation parameters to the request API calls, and updated all code to match. I can't compile the Perl module, so I'd appreciate it if someone who knows it would verify that this doesn't break Perl.
Evan Schoenberg <evan.s@dreskin.net>
parents: 15823
diff changeset
345 1,
08db93bbd798 Added account, who, and conversation parameters to the request API calls, and updated all code to match. I can't compile the Perl module, so I'd appreciate it if someone who knows it would verify that this doesn't break Perl.
Evan Schoenberg <evan.s@dreskin.net>
parents: 15823
diff changeset
346 purple_connection_get_account(gc), NULL, NULL,
21570
dccfd999ffe7 merge of '76c07fcb434a2a7aa289734bb221c171a376d73b'
Evan Schoenberg <evan.s@dreskin.net>
parents: 21244
diff changeset
347 g, 2, _("Cancel"),
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
348 G_CALLBACK(qq_do_nothing_with_gc_and_uid),
18807
b9a0b1bd321b Improve a bunch of strings in QQ
Mark Doliner <mark@kingant.net>
parents: 18210
diff changeset
349 _("Continue"), G_CALLBACK(_qq_group_exit_with_gc_and_id));
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
350 }