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 // START OF FILE
|
|
24 /*****************************************************************************/
|
|
25 #include "internal.h"
|
|
26
|
|
27 #include "debug.h" // gaim_debug
|
|
28 #include "prpl.h" // struct proto_chat_entry
|
|
29 #include "request.h" // gaim_request_input
|
|
30
|
|
31 #include "utils.h" // qq_string_to_dec_value
|
|
32 #include "group_hash.h" // QQ_GROUP_KEY_EXTERNAL_ID
|
|
33 #include "group_info.h" // qq_send_cmd_group_get_group_info
|
|
34 #include "group_search.h" // qq_send_cmd_group_search_group
|
|
35
|
|
36 #include "group.h"
|
|
37
|
|
38 /*****************************************************************************/
|
|
39 static void _qq_group_search_callback(GaimConnection * gc, const gchar * input)
|
|
40 {
|
|
41 guint32 external_group_id;
|
|
42
|
|
43 g_return_if_fail(gc != NULL && input != NULL);
|
|
44 external_group_id = qq_string_to_dec_value(input);
|
|
45 // 0x00000000 means search for demo group
|
|
46 qq_send_cmd_group_search_group(gc, external_group_id);
|
|
47 } // _qq_group_search_callback
|
|
48
|
|
49 /*****************************************************************************/
|
|
50 // This is needed for GaimChat node to be valid
|
|
51 GList *qq_chat_info(GaimConnection * gc)
|
|
52 {
|
|
53 GList *m;
|
|
54 struct proto_chat_entry *pce;
|
|
55
|
|
56 m = NULL;
|
|
57
|
|
58 pce = g_new0(struct proto_chat_entry, 1);
|
|
59 pce->label = _("ID: ");
|
|
60 pce->identifier = QQ_GROUP_KEY_EXTERNAL_ID;
|
|
61 m = g_list_append(m, pce);
|
|
62
|
|
63 pce = g_new0(struct proto_chat_entry, 1);
|
|
64 pce->label = _("Admin: ");
|
|
65 pce->identifier = QQ_GROUP_KEY_CREATOR_UID;
|
|
66 m = g_list_append(m, pce);
|
|
67
|
|
68 pce = g_new0(struct proto_chat_entry, 1);
|
|
69 pce->label = _("Status: ");
|
|
70 pce->identifier = QQ_GROUP_KEY_MEMBER_STATUS_DESC;
|
|
71 m = g_list_append(m, pce);
|
|
72
|
|
73 return m;
|
|
74 } // qq_chat_info
|
|
75
|
|
76 /*****************************************************************************/
|
|
77 // get a list of qq groups
|
|
78 GaimRoomlist *qq_roomlist_get_list(GaimConnection * gc)
|
|
79 {
|
|
80 GList *fields;
|
|
81 qq_data *qd;
|
|
82 GaimRoomlist *rl;
|
|
83 GaimRoomlistField *f;
|
|
84
|
|
85 g_return_val_if_fail(gc != NULL && gc->proto_data != NULL, NULL);
|
|
86 qd = (qq_data *) gc->proto_data;
|
|
87
|
|
88 fields = NULL;
|
|
89 rl = gaim_roomlist_new(gaim_connection_get_account(gc));
|
|
90 qd->roomlist = rl;
|
|
91
|
|
92 f = gaim_roomlist_field_new(GAIM_ROOMLIST_FIELD_STRING, _("Group ID"), QQ_GROUP_KEY_EXTERNAL_ID, FALSE);
|
|
93 fields = g_list_append(fields, f);
|
|
94 f = gaim_roomlist_field_new(GAIM_ROOMLIST_FIELD_STRING, _("Creator"), QQ_GROUP_KEY_CREATOR_UID, FALSE);
|
|
95 fields = g_list_append(fields, f);
|
|
96 f = gaim_roomlist_field_new(GAIM_ROOMLIST_FIELD_STRING,
|
|
97 _("Group Description"), QQ_GROUP_KEY_GROUP_DESC_UTF8, FALSE);
|
|
98 fields = g_list_append(fields, f);
|
|
99 f = gaim_roomlist_field_new(GAIM_ROOMLIST_FIELD_STRING, "", QQ_GROUP_KEY_INTERNAL_ID, TRUE);
|
|
100 fields = g_list_append(fields, f);
|
|
101 f = gaim_roomlist_field_new(GAIM_ROOMLIST_FIELD_STRING, "", QQ_GROUP_KEY_GROUP_TYPE, TRUE);
|
|
102 fields = g_list_append(fields, f);
|
|
103 f = gaim_roomlist_field_new(GAIM_ROOMLIST_FIELD_STRING, _("Auth"), QQ_GROUP_KEY_AUTH_TYPE, TRUE);
|
|
104 fields = g_list_append(fields, f);
|
|
105 f = gaim_roomlist_field_new(GAIM_ROOMLIST_FIELD_STRING, "", QQ_GROUP_KEY_GROUP_CATEGORY, TRUE);
|
|
106 fields = g_list_append(fields, f);
|
|
107 f = gaim_roomlist_field_new(GAIM_ROOMLIST_FIELD_STRING, "", QQ_GROUP_KEY_GROUP_NAME_UTF8, TRUE);
|
|
108
|
|
109 fields = g_list_append(fields, f);
|
|
110 gaim_roomlist_set_fields(rl, fields);
|
|
111 gaim_roomlist_set_in_progress(qd->roomlist, TRUE);
|
|
112
|
|
113 gaim_request_input(gc, _("QQ Qun"),
|
|
114 _("Please input external group ID"),
|
|
115 _
|
|
116 ("You can only search for permanent QQ group\nInput 0 or leave it blank to search for demo groups"),
|
|
117 NULL, FALSE, FALSE, NULL, _("Search"),
|
|
118 G_CALLBACK(_qq_group_search_callback), _("Cancel"), NULL, gc);
|
|
119
|
|
120 return qd->roomlist;
|
|
121 } // qq_roomlist_get_list
|
|
122
|
|
123 /*****************************************************************************/
|
|
124 // free roomlist space, I have no idea when this one is called ...
|
|
125 void qq_roomlist_cancel(GaimRoomlist * list)
|
|
126 {
|
|
127 qq_data *qd;
|
|
128 GaimConnection *gc;
|
|
129
|
|
130 g_return_if_fail(list != NULL);
|
|
131 gc = gaim_account_get_connection(list->account);
|
|
132
|
|
133 g_return_if_fail(gc != NULL && gc->proto_data != NULL);
|
|
134 qd = (qq_data *) gc->proto_data;
|
|
135
|
|
136 gaim_roomlist_set_in_progress(list, FALSE);
|
|
137 gaim_roomlist_unref(list);
|
|
138 } // qq_roomlist_cancel
|
|
139
|
|
140 /*****************************************************************************/
|
|
141 // this should be called upon signin, even we did not open group chat window
|
|
142 void qq_group_init(GaimConnection * gc)
|
|
143 {
|
|
144 gint i;
|
|
145 GaimAccount *account;
|
|
146 GaimChat *chat;
|
|
147 GaimGroup *gaim_group;
|
|
148 GaimBlistNode *node;
|
|
149 qq_group *group;
|
|
150
|
|
151 g_return_if_fail(gc != NULL);
|
|
152 account = gaim_connection_get_account(gc);
|
|
153
|
|
154
|
|
155 gaim_group = gaim_find_group(GAIM_GROUP_QQ_QUN);
|
|
156 if (gaim_group == NULL) {
|
|
157 gaim_debug(GAIM_DEBUG_INFO, "QQ", "We have no QQ Qun\n");
|
|
158 return;
|
|
159 } // if group
|
|
160
|
|
161 i = 0;
|
|
162 for (node = ((GaimBlistNode *) gaim_group)->child; node != NULL; node = node->next)
|
|
163 if (GAIM_BLIST_NODE_IS_CHAT(node)) { // got one
|
|
164 chat = (GaimChat *) node;
|
|
165 if (account != chat->account)
|
|
166 continue; // very important here !
|
|
167 group = qq_group_from_hashtable(gc, chat->components);
|
|
168 if (group != NULL) {
|
|
169 i++;
|
|
170 qq_send_cmd_group_get_group_info(gc, group); // get group info and members
|
|
171 } // if group
|
|
172 } // if is chat
|
|
173
|
|
174 gaim_debug(GAIM_DEBUG_INFO, "QQ", "Load %d QQ Qun configurations\n", i);
|
|
175
|
|
176 } // qq_group_init
|
|
177
|
|
178 /*****************************************************************************/
|
|
179 // END OF FILE
|