13870
|
1 /**
|
|
2 * The QQ2003C protocol plugin
|
|
3 *
|
|
4 * for gaim
|
|
5 *
|
|
6 * Copyright (C) 2004 Puzzlebird
|
|
7 *
|
|
8 * This program is free software; you can redistribute it and/or modify
|
|
9 * it under the terms of the GNU General Public License as published by
|
|
10 * the Free Software Foundation; either version 2 of the License, or
|
|
11 * (at your option) any later version.
|
|
12 *
|
|
13 * This program is distributed in the hope that it will be useful,
|
|
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
16 * GNU General Public License for more details.
|
|
17 *
|
|
18 * You should have received a copy of the GNU General Public License
|
|
19 * along with this program; if not, write to the Free Software
|
|
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
21 */
|
|
22
|
|
23 #include "internal.h"
|
|
24
|
14021
|
25 #include "debug.h"
|
|
26 #include "prpl.h"
|
|
27 #include "request.h"
|
13870
|
28
|
14021
|
29 #include "group_hash.h"
|
|
30 #include "group_info.h"
|
|
31 #include "group_search.h"
|
|
32 #include "utils.h"
|
13870
|
33
|
|
34 #include "group.h"
|
|
35
|
14021
|
36 static void _qq_group_search_callback(GaimConnection *gc, const gchar *input)
|
13870
|
37 {
|
|
38 guint32 external_group_id;
|
|
39
|
|
40 g_return_if_fail(gc != NULL && input != NULL);
|
|
41 external_group_id = qq_string_to_dec_value(input);
|
14021
|
42 /* 0x00000000 means search for demo group */
|
13870
|
43 qq_send_cmd_group_search_group(gc, external_group_id);
|
14021
|
44 }
|
13870
|
45
|
14021
|
46 /* This is needed for GaimChat node to be valid */
|
|
47 GList *qq_chat_info(GaimConnection *gc)
|
13870
|
48 {
|
|
49 GList *m;
|
|
50 struct proto_chat_entry *pce;
|
|
51
|
|
52 m = NULL;
|
|
53
|
|
54 pce = g_new0(struct proto_chat_entry, 1);
|
|
55 pce->label = _("ID: ");
|
|
56 pce->identifier = QQ_GROUP_KEY_EXTERNAL_ID;
|
|
57 m = g_list_append(m, pce);
|
|
58
|
|
59 pce = g_new0(struct proto_chat_entry, 1);
|
|
60 pce->label = _("Admin: ");
|
|
61 pce->identifier = QQ_GROUP_KEY_CREATOR_UID;
|
|
62 m = g_list_append(m, pce);
|
|
63
|
|
64 pce = g_new0(struct proto_chat_entry, 1);
|
|
65 pce->label = _("Status: ");
|
|
66 pce->identifier = QQ_GROUP_KEY_MEMBER_STATUS_DESC;
|
|
67 m = g_list_append(m, pce);
|
|
68
|
|
69 return m;
|
14021
|
70 }
|
13870
|
71
|
14021
|
72 /* get a list of qq groups */
|
|
73 GaimRoomlist *qq_roomlist_get_list(GaimConnection *gc)
|
13870
|
74 {
|
|
75 GList *fields;
|
|
76 qq_data *qd;
|
|
77 GaimRoomlist *rl;
|
|
78 GaimRoomlistField *f;
|
|
79
|
|
80 g_return_val_if_fail(gc != NULL && gc->proto_data != NULL, NULL);
|
|
81 qd = (qq_data *) gc->proto_data;
|
|
82
|
|
83 fields = NULL;
|
|
84 rl = gaim_roomlist_new(gaim_connection_get_account(gc));
|
|
85 qd->roomlist = rl;
|
|
86
|
|
87 f = gaim_roomlist_field_new(GAIM_ROOMLIST_FIELD_STRING, _("Group ID"), QQ_GROUP_KEY_EXTERNAL_ID, FALSE);
|
|
88 fields = g_list_append(fields, f);
|
|
89 f = gaim_roomlist_field_new(GAIM_ROOMLIST_FIELD_STRING, _("Creator"), QQ_GROUP_KEY_CREATOR_UID, FALSE);
|
|
90 fields = g_list_append(fields, f);
|
|
91 f = gaim_roomlist_field_new(GAIM_ROOMLIST_FIELD_STRING,
|
|
92 _("Group Description"), QQ_GROUP_KEY_GROUP_DESC_UTF8, FALSE);
|
|
93 fields = g_list_append(fields, f);
|
|
94 f = gaim_roomlist_field_new(GAIM_ROOMLIST_FIELD_STRING, "", QQ_GROUP_KEY_INTERNAL_ID, TRUE);
|
|
95 fields = g_list_append(fields, f);
|
|
96 f = gaim_roomlist_field_new(GAIM_ROOMLIST_FIELD_STRING, "", QQ_GROUP_KEY_GROUP_TYPE, TRUE);
|
|
97 fields = g_list_append(fields, f);
|
|
98 f = gaim_roomlist_field_new(GAIM_ROOMLIST_FIELD_STRING, _("Auth"), QQ_GROUP_KEY_AUTH_TYPE, TRUE);
|
|
99 fields = g_list_append(fields, f);
|
|
100 f = gaim_roomlist_field_new(GAIM_ROOMLIST_FIELD_STRING, "", QQ_GROUP_KEY_GROUP_CATEGORY, TRUE);
|
|
101 fields = g_list_append(fields, f);
|
|
102 f = gaim_roomlist_field_new(GAIM_ROOMLIST_FIELD_STRING, "", QQ_GROUP_KEY_GROUP_NAME_UTF8, TRUE);
|
|
103
|
|
104 fields = g_list_append(fields, f);
|
|
105 gaim_roomlist_set_fields(rl, fields);
|
|
106 gaim_roomlist_set_in_progress(qd->roomlist, TRUE);
|
|
107
|
|
108 gaim_request_input(gc, _("QQ Qun"),
|
|
109 _("Please input external group ID"),
|
14021
|
110 _("You can only search for permanent QQ group\nInput 0 or leave it blank to search for demo groups"),
|
13870
|
111 NULL, FALSE, FALSE, NULL, _("Search"),
|
|
112 G_CALLBACK(_qq_group_search_callback), _("Cancel"), NULL, gc);
|
|
113
|
|
114 return qd->roomlist;
|
14021
|
115 }
|
13870
|
116
|
14021
|
117 /* free roomlist space, I have no idea when this one is called ... */
|
|
118 void qq_roomlist_cancel(GaimRoomlist *list)
|
13870
|
119 {
|
|
120 qq_data *qd;
|
|
121 GaimConnection *gc;
|
|
122
|
|
123 g_return_if_fail(list != NULL);
|
|
124 gc = gaim_account_get_connection(list->account);
|
|
125
|
|
126 g_return_if_fail(gc != NULL && gc->proto_data != NULL);
|
|
127 qd = (qq_data *) gc->proto_data;
|
|
128
|
|
129 gaim_roomlist_set_in_progress(list, FALSE);
|
|
130 gaim_roomlist_unref(list);
|
14021
|
131 }
|
13870
|
132
|
14021
|
133 /* this should be called upon signin, even when we did not open group chat window */
|
|
134 void qq_group_init(GaimConnection *gc)
|
13870
|
135 {
|
|
136 gint i;
|
|
137 GaimAccount *account;
|
|
138 GaimChat *chat;
|
|
139 GaimGroup *gaim_group;
|
|
140 GaimBlistNode *node;
|
|
141 qq_group *group;
|
|
142
|
|
143 g_return_if_fail(gc != NULL);
|
|
144 account = gaim_connection_get_account(gc);
|
|
145
|
|
146
|
|
147 gaim_group = gaim_find_group(GAIM_GROUP_QQ_QUN);
|
|
148 if (gaim_group == NULL) {
|
|
149 gaim_debug(GAIM_DEBUG_INFO, "QQ", "We have no QQ Qun\n");
|
|
150 return;
|
14021
|
151 }
|
13870
|
152
|
|
153 i = 0;
|
|
154 for (node = ((GaimBlistNode *) gaim_group)->child; node != NULL; node = node->next)
|
14021
|
155 if (GAIM_BLIST_NODE_IS_CHAT(node)) { /* got one */
|
13870
|
156 chat = (GaimChat *) node;
|
|
157 if (account != chat->account)
|
14021
|
158 continue; /* very important here ! */
|
13870
|
159 group = qq_group_from_hashtable(gc, chat->components);
|
|
160 if (group != NULL) {
|
|
161 i++;
|
14021
|
162 qq_send_cmd_group_get_group_info(gc, group); /* get group info and members */
|
|
163 }
|
|
164 }
|
13870
|
165
|
|
166 gaim_debug(GAIM_DEBUG_INFO, "QQ", "Load %d QQ Qun configurations\n", i);
|
14021
|
167 }
|