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