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