13870
|
1 /**
|
|
2 * @file qq.c The QQ2003C protocol plugin
|
|
3 *
|
|
4 * 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 #ifdef _WIN32
|
|
26 #define random rand
|
|
27 #endif
|
|
28
|
|
29 #include "debug.h"
|
|
30 #include "notify.h"
|
|
31 #include "prefs.h"
|
|
32 #include "request.h"
|
|
33 #include "accountopt.h"
|
|
34 #include "prpl.h"
|
|
35 #include "gtkroomlist.h"
|
|
36 #include "gtklog.h"
|
|
37 #include "server.h"
|
|
38 #include "util.h" /* GaimMenuAction, gaim_menu_action_new, gaim2beta2, gfhuang*/
|
|
39
|
|
40 #include "utils.h"
|
|
41 #include "buddy_info.h"
|
|
42 #include "buddy_opt.h"
|
|
43 #include "buddy_status.h"
|
|
44 #include "char_conv.h"
|
|
45 #include "group_find.h" /* qq_group_find_member_by_channel_and_nickname */
|
|
46 #include "group_im.h" /* qq_send_packet_group_im */
|
|
47 #include "group_info.h" /* qq_send_cmd_group_get_group_info */
|
|
48 #include "group_join.h" /* qq_group_join */
|
|
49 #include "group_opt.h" /* qq_group_manage_members */
|
|
50 #include "group.h" /* chat_info, etc */
|
|
51 #include "header_info.h" /* qq_get_cmd_desc */
|
|
52 #include "im.h"
|
|
53 #include "infodlg.h"
|
|
54 #include "keep_alive.h"
|
|
55 #include "ip_location.h" /* qq_ip_get_location */
|
|
56 #include "login_logout.h"
|
|
57 #include "qq_proxy.h" /* qq_connect, qq_disconnect */
|
|
58 #include "send_core.h"
|
|
59 #include "qq.h"
|
|
60 #include "send_file.h"
|
|
61 #include "version.h"
|
|
62
|
|
63 #define OPENQ_AUTHOR "Puzzlebird"
|
|
64 #define OPENQ_WEBSITE "http://openq.sourceforge.net"
|
|
65 #define QQ_TCP_QUERY_PORT "8000"
|
|
66 #define QQ_UDP_PORT "8000"
|
|
67
|
|
68 const gchar *udp_server_list[] = {
|
|
69 "sz.tencent.com", // 61.144.238.145
|
|
70 "sz2.tencent.com", // 61.144.238.146
|
|
71 "sz3.tencent.com", // 202.104.129.251
|
|
72 "sz4.tencent.com", // 202.104.129.254
|
|
73 "sz5.tencent.com", // 61.141.194.203
|
|
74 "sz6.tencent.com", // 202.104.129.252
|
|
75 "sz7.tencent.com", // 202.104.129.253
|
|
76 "202.96.170.64",
|
|
77 "64.144.238.155",
|
|
78 "202.104.129.254"
|
|
79 };
|
|
80 const gint udp_server_amount = (sizeof(udp_server_list) / sizeof(udp_server_list[0]));
|
|
81
|
|
82
|
|
83 const gchar *tcp_server_list[] = {
|
|
84 "tcpconn.tencent.com", // 218.17.209.23
|
|
85 "tcpconn2.tencent.com", // 218.18.95.153
|
|
86 "tcpconn3.tencent.com", // 218.17.209.23
|
|
87 "tcpconn4.tencent.com", // 218.18.95.153
|
|
88 };
|
|
89 const gint tcp_server_amount = (sizeof(tcp_server_list) / sizeof(tcp_server_list[0]));
|
|
90
|
|
91 /*********** Prototypes ***********/
|
|
92
|
|
93 static void _qq_login(GaimAccount * account);
|
|
94 static void _qq_close(GaimConnection * gc);
|
|
95 static const gchar *_qq_list_icon(GaimAccount * a, GaimBuddy * b);
|
|
96 static gchar *_qq_status_text(GaimBuddy *b);
|
|
97 static void _qq_tooltip_text(GaimBuddy *b, GString *tooltip, gboolean full);
|
|
98 static void _qq_list_emblems(GaimBuddy * b, const char **se, const char **sw, const char **nw, const char **ne);
|
|
99 static GList *_qq_away_states(GaimAccount *ga);
|
|
100 static void _qq_set_away(GaimAccount *account, GaimStatus *status);
|
|
101 static gint _qq_send_im(GaimConnection * gc, const gchar * who, const gchar * message, GaimMessageFlags flags);
|
|
102 static int _qq_chat_send(GaimConnection *gc, int channel, const char *message, GaimMessageFlags flags);
|
|
103 static void _qq_get_info(GaimConnection * gc, const gchar * who);
|
|
104 static void _qq_menu_get_my_info(GaimPluginAction * action);
|
|
105 //static void _qq_menu_block_buddy(GaimBlistNode * node);
|
|
106 static void _qq_menu_show_login_info(GaimPluginAction * action);
|
|
107 static void _qq_menu_show_about(GaimPluginAction * action);
|
|
108 static void _qq_menu_any_cmd_send_cb(GaimConnection * gc, GaimRequestFields * fields);
|
|
109 static void _qq_menu_any_cmd(GaimPluginAction * action);
|
|
110 static void _qq_menu_locate_ip_cb(GaimConnection * gc, GaimRequestFields * fields);
|
|
111 static void _qq_menu_locate_ip(GaimPluginAction *action);
|
|
112 static void _qq_menu_search_or_add_permanent_group(GaimPluginAction * action);
|
|
113 static void _qq_menu_create_permanent_group(GaimPluginAction * action);
|
|
114 static void _qq_menu_unsubscribe_group(GaimBlistNode * node);
|
|
115 static void _qq_menu_manage_group(GaimBlistNode * node);
|
|
116 static void _qq_menu_show_system_message(GaimPluginAction *action);
|
|
117 //static void _qq_menu_send_file(GaimBlistNode * node, gpointer ignored);
|
|
118 static GList *_qq_actions(GaimPlugin * plugin, gpointer context);
|
|
119 static GList *_qq_chat_menu(GaimBlistNode *node);
|
|
120 static GList *_qq_buddy_menu(GaimBlistNode * node);
|
|
121 static void _qq_keep_alive(GaimConnection * gc);
|
|
122 static void _qq_get_chat_buddy_info(GaimConnection * gc, gint channel, const gchar * who);
|
|
123 static gchar *_qq_get_chat_buddy_real_name(GaimConnection * gc, gint channel, const gchar * who);
|
|
124 //static GaimPluginPrefFrame *get_plugin_pref_frame(GaimPlugin * plugin);
|
|
125 static void init_plugin(GaimPlugin * plugin);
|
|
126
|
|
127 static void _qq_login(GaimAccount * account)
|
|
128 {
|
|
129 const gchar *qq_server, *qq_port;
|
|
130 qq_data *qd;
|
|
131 GaimConnection *gc;
|
|
132 GaimPresence *presence; //gfhuang
|
|
133 gboolean login_hidden, use_tcp;
|
|
134
|
|
135 g_return_if_fail(account != NULL);
|
|
136
|
|
137 gc = gaim_account_get_connection(account);
|
|
138 g_return_if_fail(gc != NULL);
|
|
139
|
|
140 gc->flags |= GAIM_CONNECTION_HTML | GAIM_CONNECTION_NO_BGCOLOR | GAIM_CONNECTION_AUTO_RESP;
|
|
141
|
|
142 qd = g_new0(qq_data, 1);
|
|
143 gc->proto_data = qd;
|
|
144
|
|
145 qq_server = gaim_account_get_string(account, "server", NULL);
|
|
146 qq_port = gaim_account_get_string(account, "port", NULL);
|
|
147 use_tcp = gaim_account_get_bool(account, "use_tcp", FALSE);
|
|
148 // login_hidden = gaim_account_get_bool(account, "hidden", FALSE); gfhuang
|
|
149 presence = gaim_account_get_presence(account);
|
|
150 login_hidden = gaim_presence_is_status_primitive_active(presence, GAIM_STATUS_INVISIBLE);
|
|
151
|
|
152 qd->use_tcp = use_tcp;
|
|
153
|
|
154 if (login_hidden) {
|
|
155 qd->login_mode = QQ_LOGIN_MODE_HIDDEN;
|
|
156 gaim_debug(GAIM_DEBUG_INFO, "QQ", "Login in hidden mode\n");
|
|
157 }
|
|
158 else {
|
|
159 qd->login_mode = QQ_LOGIN_MODE_NORMAL;
|
|
160 gaim_debug(GAIM_DEBUG_INFO, "QQ", "Login in normal mode\n");
|
|
161 }
|
|
162
|
|
163 if (qq_server == NULL || strlen(qq_server) == 0)
|
|
164 qq_server = use_tcp ?
|
|
165 tcp_server_list[random() % tcp_server_amount] : udp_server_list[random() % udp_server_amount];
|
|
166
|
|
167 if (qq_port == NULL || strtol(qq_port, NULL, 10) == 0)
|
|
168 qq_port = use_tcp ? QQ_TCP_QUERY_PORT : QQ_UDP_PORT;
|
|
169
|
|
170 gaim_connection_update_progress(gc, _("Connecting"), 0, QQ_CONNECT_STEPS);
|
|
171
|
|
172 if (qq_connect(account, qq_server, strtol(qq_port, NULL, 10), use_tcp, FALSE) < 0)
|
|
173 gaim_connection_error(gc, _("Unable to connect."));
|
|
174 }
|
|
175
|
|
176 /* directly goes for qq_disconnect */
|
|
177 static void _qq_close(GaimConnection * gc)
|
|
178 {
|
|
179 g_return_if_fail(gc != NULL);
|
|
180 qq_disconnect(gc);
|
|
181 }
|
|
182
|
|
183 /* returns the icon name for a buddy or protocol */
|
|
184 static const gchar *_qq_list_icon(GaimAccount * a, GaimBuddy * b)
|
|
185 {
|
|
186 gchar *filename;
|
|
187 qq_buddy *q_bud;
|
|
188 gchar icon_suffix;
|
|
189
|
|
190 /* do not use g_return_val_if_fail, as it is not assertion */
|
|
191 if (b == NULL || b->proto_data == NULL)
|
|
192 return "qq";
|
|
193
|
|
194 q_bud = (qq_buddy *) b->proto_data;
|
|
195 icon_suffix = get_suffix_from_status(q_bud->status);
|
|
196 filename = get_icon_name(q_bud->icon / 3 + 1, icon_suffix);
|
|
197
|
|
198 return filename;
|
|
199 }
|
|
200
|
|
201
|
|
202 /* a short status text beside buddy icon*/
|
|
203 static gchar *_qq_status_text(GaimBuddy *b)
|
|
204 {
|
|
205 qq_buddy *q_bud;
|
|
206 // gboolean show_info;
|
|
207 GString *status;
|
|
208 gchar *ret;
|
|
209
|
|
210 // show_info = gaim_prefs_get_bool("/plugins/prpl/qq/show_status_by_icon");
|
|
211 // if (!show_info)
|
|
212 // return NULL;
|
|
213
|
|
214 q_bud = (qq_buddy *) b->proto_data;
|
|
215 if (q_bud == NULL)
|
|
216 return NULL;
|
|
217
|
|
218 status = g_string_new("");
|
|
219
|
|
220 //by gfhuang
|
|
221 switch(q_bud->status) {
|
|
222 case QQ_BUDDY_OFFLINE:
|
|
223 g_string_append(status, "My Offline");
|
|
224 break;
|
|
225 case QQ_BUDDY_ONLINE_NORMAL:
|
|
226 return NULL;
|
|
227 break;
|
|
228 case QQ_BUDDY_ONLINE_OFFLINE:
|
|
229 g_string_append(status, "Online Offline");
|
|
230 break;
|
|
231 case QQ_BUDDY_ONLINE_AWAY:
|
|
232 g_string_append(status, "Away");
|
|
233 break;
|
|
234 case QQ_BUDDY_ONLINE_INVISIBLE:
|
|
235 g_string_append(status, "Invisible");
|
|
236 break;
|
|
237 default:
|
|
238 g_string_printf(status, "Unknown-%d", q_bud->status);
|
|
239 }
|
|
240 /*
|
|
241 switch (q_bud->gender) {
|
|
242 case QQ_BUDDY_GENDER_GG:
|
|
243 g_string_append(status, " GG");
|
|
244 break;
|
|
245 case QQ_BUDDY_GENDER_MM:
|
|
246 g_string_append(status, " MM");
|
|
247 break;
|
|
248 case QQ_BUDDY_GENDER_UNKNOWN:
|
|
249 g_string_append(status, "^_*");
|
|
250 break;
|
|
251 default:
|
|
252 g_string_append(status, "^_^");
|
|
253 }
|
|
254
|
|
255 g_string_append_printf(status, " Age: %d", q_bud->age);
|
|
256 g_string_append_printf(status, " Client: %04x", q_bud->client_version);
|
|
257 */
|
|
258 // having_video = q_bud->comm_flag & QQ_COMM_FLAG_VIDEO;
|
|
259 // if (having_video)
|
|
260 // g_string_append(status, " (video)");
|
|
261
|
|
262 ret = status->str;
|
|
263 g_string_free(status, FALSE);
|
|
264
|
|
265 return ret;
|
|
266 }
|
|
267
|
|
268
|
|
269 /* a floating text when mouse is on the icon, show connection status here */
|
|
270 static void _qq_tooltip_text(GaimBuddy *b, GString *tooltip, gboolean full)
|
|
271 {
|
|
272 qq_buddy *q_bud;
|
|
273 gchar *country, *country_utf8, *city, *city_utf8;
|
|
274 guint32 ip_value;
|
|
275 gchar *ip_str;
|
|
276
|
|
277 g_return_if_fail(b != NULL);
|
|
278
|
|
279 q_bud = (qq_buddy *) b->proto_data;
|
|
280 g_return_if_fail(q_bud != NULL);
|
|
281
|
|
282 // if (is_online(q_bud->status)) //disable by gfhuang
|
|
283 {
|
|
284 ip_value = ntohl(*(guint32 *) (q_bud->ip));
|
|
285 // tooltip = g_string_new(""); beta2, gfhuang
|
|
286 if (qq_ip_get_location(ip_value, &country, &city)) {
|
|
287 country_utf8 = qq_to_utf8(country, QQ_CHARSET_DEFAULT);
|
|
288 city_utf8 = qq_to_utf8(city, QQ_CHARSET_DEFAULT);
|
|
289 g_string_append_printf(tooltip, "\n%s, %s", country_utf8, city_utf8);
|
|
290 g_free(country);
|
|
291 g_free(city);
|
|
292 g_free(country_utf8);
|
|
293 g_free(city_utf8);
|
|
294 }
|
|
295 //memory leak fixed by gfhuang
|
|
296 ip_str = gen_ip_str(q_bud->ip);
|
|
297 g_string_append_printf(tooltip, "\n<b>%s Address:</b> %s:%d", (q_bud->comm_flag & QQ_COMM_FLAG_TCP_MODE)
|
|
298 ? "TCP" : "UDP", ip_str, q_bud->port);
|
|
299 g_free(ip_str);
|
|
300 //added by gfhuang
|
|
301 g_string_append_printf(tooltip, "\n<b>Age:</b> %d", q_bud->age);
|
|
302 switch (q_bud->gender) {
|
|
303 case QQ_BUDDY_GENDER_GG:
|
|
304 g_string_append(tooltip, "\n<b>Gender:</b> GG");
|
|
305 break;
|
|
306 case QQ_BUDDY_GENDER_MM:
|
|
307 g_string_append(tooltip, "\n<b>Gender:</b> MM");
|
|
308 break;
|
|
309 case QQ_BUDDY_GENDER_UNKNOWN:
|
|
310 g_string_append(tooltip, "\n<b>Gender:</b> UNKNOWN");
|
|
311 break;
|
|
312 default:
|
|
313 g_string_append_printf(tooltip, "\n<b>Gender:</b> ERROR(%d)", q_bud->gender);
|
|
314 } /* switch gender */
|
|
315 g_string_append_printf(tooltip, "\n<b>Flag:</b> %01x", q_bud->flag1);
|
|
316 g_string_append_printf(tooltip, "\n<b>CommFlag:</b> %01x", q_bud->comm_flag);
|
|
317 g_string_append_printf(tooltip, "\n<b>Client:</b> %04x", q_bud->client_version);
|
|
318 }
|
|
319 }
|
|
320
|
|
321 /* we can show tiny icons on the four corners of buddy icon, */
|
|
322 static void _qq_list_emblems(GaimBuddy * b, const char **se, const char **sw, const char **nw, const char **ne) { //add const by gfhuang
|
|
323 // each char ** are refering to filename in pixmaps/gaim/status/default/*png
|
|
324
|
|
325 qq_buddy *q_bud = b->proto_data;
|
|
326 // GaimPresence *presence;
|
|
327 const char *emblems[4] = { NULL, NULL, NULL, NULL };
|
|
328 int i = 0;
|
|
329
|
|
330 /* presence = gaim_buddy_get_presence(b);
|
|
331
|
|
332 if (!gaim_presence_is_online(presence))
|
|
333 emblems[i++] = "offline";
|
|
334 else if (gaim_presence_is_status_active(presence, "busy") ||
|
|
335 gaim_presence_is_status_active(presence, "phone"))
|
|
336 emblems[i++] = "occupied";
|
|
337 else if (!gaim_presence_is_available(presence))
|
|
338 emblems[i++] = "away";
|
|
339 */
|
|
340
|
|
341 if (q_bud == NULL)
|
|
342 {
|
|
343 emblems[0] = "offline";
|
|
344 }
|
|
345 else
|
|
346 {
|
|
347 if (q_bud->comm_flag & QQ_COMM_FLAG_QQ_MEMBER)
|
|
348 emblems[i++] = "qq_member";
|
|
349 if (q_bud->comm_flag & QQ_COMM_FLAG_BIND_MOBILE)
|
|
350 emblems[i++] = "wireless";
|
|
351 if (q_bud->comm_flag & QQ_COMM_FLAG_VIDEO)
|
|
352 emblems[i++] = "video";
|
|
353
|
|
354
|
|
355 // if (!(user->list_op & (1 << MSN_LIST_RL)))
|
|
356 // emblems[i++] = "nr";
|
|
357 }
|
|
358
|
|
359 *se = emblems[0];
|
|
360 *sw = emblems[1];
|
|
361 *nw = emblems[2];
|
|
362 *ne = emblems[3];
|
|
363
|
|
364 return;
|
|
365 }
|
|
366
|
|
367 /* QQ away status (used to initiate QQ away packet) */
|
|
368 //Rewritten by gfhuang
|
|
369 static GList *_qq_away_states(GaimAccount *ga)
|
|
370 {
|
|
371 GaimStatusType *status;
|
|
372 GList *types = NULL;
|
|
373
|
|
374 status = gaim_status_type_new_full(GAIM_STATUS_AVAILABLE,
|
|
375 "available", _("QQ: Available"), FALSE, TRUE, FALSE);
|
|
376 types = g_list_append(types, status);
|
|
377
|
|
378 status = gaim_status_type_new_full(GAIM_STATUS_AWAY,
|
|
379 "away", _("QQ: Away"), FALSE, TRUE, FALSE);
|
|
380 types = g_list_append(types, status);
|
|
381
|
|
382 status = gaim_status_type_new_full(GAIM_STATUS_INVISIBLE, /* HIDDEN, change to gaim2beta2, gfhuang */
|
|
383 "invisible", _("QQ: Invisible"), FALSE, TRUE, FALSE);
|
|
384 types = g_list_append(types, status);
|
|
385
|
|
386 status = gaim_status_type_new_full(GAIM_STATUS_OFFLINE,
|
|
387 "offline", _("QQ: Offline"), FALSE, TRUE, FALSE);
|
|
388 types = g_list_append(types, status);
|
|
389
|
|
390 return types;
|
|
391 }
|
|
392 /*
|
|
393 GList *_qq_away_states(GaimConnection * gc)
|
|
394 {
|
|
395 GList *m;
|
|
396
|
|
397 g_return_val_if_fail(gc != NULL, NULL);
|
|
398
|
|
399 m = NULL;
|
|
400 m = g_list_append(m, _("QQ: Available"));
|
|
401 m = g_list_append(m, _("QQ: Away"));
|
|
402 m = g_list_append(m, _("QQ: Invisible"));
|
|
403 m = g_list_append(m, GAIM_AWAY_CUSTOM);
|
|
404 return m;
|
|
405 }
|
|
406 */
|
|
407
|
|
408
|
|
409
|
|
410 /* initiate QQ away with proper change_status packet */
|
|
411 //void _qq_set_away(GaimConnection * gc, const char *state, const char *msg)
|
|
412 static void _qq_set_away(GaimAccount *account, GaimStatus *status)
|
|
413 {
|
|
414 // by gfhuang
|
|
415 GaimConnection *gc = gaim_account_get_connection(account);
|
|
416 const char *state = gaim_status_get_id(status);
|
|
417
|
|
418 qq_data *qd;
|
|
419
|
|
420
|
|
421 g_return_if_fail(gc != NULL && gc->proto_data != NULL);
|
|
422
|
|
423 qd = (qq_data *) gc->proto_data;
|
|
424
|
|
425 // by gfhuang
|
|
426 if(0 == strcmp(state, "available"))
|
|
427 qd->status = QQ_SELF_STATUS_AVAILABLE;
|
|
428 else if (0 == strcmp(state, "away"))
|
|
429 qd->status = QQ_SELF_STATUS_AWAY;
|
|
430 else if (0 == strcmp(state, "invisible"))
|
|
431 qd->status = QQ_SELF_STATUS_INVISIBLE;
|
|
432 else
|
|
433 qd->status = QQ_SELF_STATUS_AVAILABLE;
|
|
434
|
|
435 /* if (gc->away) { //disable by gfhuang, 1.2006
|
|
436 g_free(gc->away);
|
|
437 gc->away = NULL;
|
|
438 }
|
|
439
|
|
440 if (msg) {
|
|
441 qd->status = QQ_SELF_STATUS_CUSTOM;
|
|
442 gc->away = g_strdup(msg);
|
|
443 } else if (state) {
|
|
444 gc->away = g_strdup("");
|
|
445 if (g_ascii_strcasecmp(state, _("QQ: Available")) == 0)
|
|
446 qd->status = QQ_SELF_STATUS_AVAILABLE;
|
|
447 else if (g_ascii_strcasecmp(state, _("QQ: Away")) == 0)
|
|
448 qd->status = QQ_SELF_STATUS_AWAY;
|
|
449 else if (g_ascii_strcasecmp(state, _("QQ: Invisible")) == 0)
|
|
450 qd->status = QQ_SELF_STATUS_INVISIBLE;
|
|
451 else if (g_ascii_strcasecmp(state, GAIM_AWAY_CUSTOM) == 0) {
|
|
452 if (gc->is_idle)
|
|
453 qd->status = QQ_SELF_STATUS_IDLE;
|
|
454 else
|
|
455 qd->status = QQ_SELF_STATUS_AVAILABLE;
|
|
456 }
|
|
457 } else if (gc->is_idle)
|
|
458 qd->status = QQ_SELF_STATUS_IDLE;
|
|
459 else
|
|
460 qd->status = QQ_SELF_STATUS_AVAILABLE;
|
|
461 */
|
|
462 qq_send_packet_change_status(gc);
|
|
463 }
|
|
464
|
|
465
|
|
466 // IMPORTANT: GaimConvImFlags -> GaimMessageFlags //gfhuang
|
|
467 /* send an instance msg to a buddy */
|
|
468 static gint _qq_send_im(GaimConnection * gc, const gchar * who, const gchar * message, GaimMessageFlags flags)
|
|
469 {
|
|
470 gint type, to_uid;
|
|
471 gchar *msg, *msg_with_qq_smiley;
|
|
472 qq_data *qd;
|
|
473
|
|
474 g_return_val_if_fail(gc != NULL && gc->proto_data != NULL && who != NULL, -1);
|
|
475
|
|
476 qd = (qq_data *) gc->proto_data;
|
|
477
|
|
478 g_return_val_if_fail(strlen(message) <= QQ_MSG_IM_MAX, -E2BIG);
|
|
479
|
|
480 type = (flags == GAIM_MESSAGE_AUTO_RESP ? QQ_IM_AUTO_REPLY : QQ_IM_TEXT);
|
|
481 to_uid = gaim_name_to_uid(who);
|
|
482
|
|
483 /* if msg is to myself, bypass the network */
|
|
484 if (to_uid == qd->uid)
|
|
485 serv_got_im(gc, who, message, flags, time(NULL));
|
|
486 else {
|
|
487 msg = utf8_to_qq(message, QQ_CHARSET_DEFAULT);
|
|
488 msg_with_qq_smiley = gaim_smiley_to_qq(msg);
|
|
489 qq_send_packet_im(gc, to_uid, msg_with_qq_smiley, type);
|
|
490 g_free(msg);
|
|
491 g_free(msg_with_qq_smiley);
|
|
492 }
|
|
493
|
|
494 return 1;
|
|
495 }
|
|
496
|
|
497 /* send a chat msg to a QQ Qun */
|
|
498 static int _qq_chat_send(GaimConnection *gc, int channel, const char *message, GaimMessageFlags flags/*gfhuang*/)
|
|
499 {
|
|
500 gchar *msg, *msg_with_qq_smiley;
|
|
501 qq_group *group;
|
|
502
|
|
503 g_return_val_if_fail(gc != NULL && message != NULL, -1);
|
|
504 g_return_val_if_fail(strlen(message) <= QQ_MSG_IM_MAX, -E2BIG);
|
|
505
|
|
506 group = qq_group_find_by_channel(gc, channel);
|
|
507 g_return_val_if_fail(group != NULL, -1);
|
|
508
|
|
509 msg = utf8_to_qq(message, QQ_CHARSET_DEFAULT);
|
|
510 msg_with_qq_smiley = gaim_smiley_to_qq(msg);
|
|
511 qq_send_packet_group_im(gc, group, msg_with_qq_smiley);
|
|
512 g_free(msg);
|
|
513 g_free(msg_with_qq_smiley);
|
|
514
|
|
515 return 1;
|
|
516 }
|
|
517
|
|
518 /* send packet to get who's detailed information */
|
|
519 static void _qq_get_info(GaimConnection * gc, const gchar * who)
|
|
520 {
|
|
521 guint32 uid;
|
|
522 qq_data *qd;
|
|
523
|
|
524 g_return_if_fail(gc != NULL && gc->proto_data != NULL);
|
|
525 qd = gc->proto_data;
|
|
526 uid = gaim_name_to_uid(who);
|
|
527
|
|
528 if (uid <= 0) {
|
|
529 gaim_debug(GAIM_DEBUG_ERROR, "QQ", "Not valid QQid: %s\n", who);
|
|
530 gaim_notify_error(gc, NULL, _("Invalid name, please input in qq-xxxxxxxx format"), NULL);
|
|
531 return;
|
|
532 }
|
|
533
|
|
534 qq_send_packet_get_info(gc, uid, TRUE); /* need to show up info window */
|
|
535 }
|
|
536
|
|
537 /* get my own information */
|
|
538 static void _qq_menu_get_my_info(GaimPluginAction * action)
|
|
539 {
|
|
540 GaimConnection *gc = (GaimConnection *) action->context;
|
|
541 qq_data *qd;
|
|
542
|
|
543 g_return_if_fail(gc != NULL && gc->proto_data != NULL);
|
|
544
|
|
545 qd = (qq_data *) gc->proto_data;
|
|
546 _qq_get_info(gc, uid_to_gaim_name(qd->uid));
|
|
547 }
|
|
548
|
|
549 /* remove a buddy from my list and remove myself from his list */
|
|
550 /* TODO: re-enable this
|
|
551 static void _qq_menu_block_buddy(GaimBlistNode * node)
|
|
552 {
|
|
553 guint32 uid;
|
|
554 gc_and_uid *g;
|
|
555 GaimBuddy *buddy;
|
|
556 GaimConnection *gc;
|
|
557 // const gchar *who = param_who; gfhuang
|
|
558 const gchar *who;
|
|
559
|
|
560 g_return_if_fail(GAIM_BLIST_NODE_IS_BUDDY(node));
|
|
561
|
|
562 buddy = (GaimBuddy *) node;
|
|
563 gc = gaim_account_get_connection(buddy->account);
|
|
564 who = buddy->name;
|
|
565 g_return_if_fail(gc != NULL && who != NULL);
|
|
566
|
|
567 uid = gaim_name_to_uid(who);
|
|
568 g_return_if_fail(uid > 0);
|
|
569
|
|
570 g = g_new0(gc_and_uid, 1);
|
|
571 g->gc = gc;
|
|
572 g->uid = uid;
|
|
573
|
|
574 gaim_request_action(gc, _("Block Buddy"),
|
|
575 _("Are you sure to block this buddy?"), NULL,
|
|
576 1, g, 2,
|
|
577 _("Cancel"),
|
|
578 G_CALLBACK(qq_do_nothing_with_gc_and_uid),
|
|
579 _("Block"), G_CALLBACK(qq_block_buddy_with_gc_and_uid));
|
|
580 }
|
|
581 */
|
|
582
|
|
583 /* show a brief summary of what we get from login packet */
|
|
584 static void _qq_menu_show_login_info(GaimPluginAction * action)
|
|
585 {
|
|
586 GaimConnection *gc = (GaimConnection *) action->context;
|
|
587 qq_data *qd;
|
|
588 GString *info;
|
|
589
|
|
590 g_return_if_fail(gc != NULL && gc->proto_data != NULL);
|
|
591
|
|
592 qd = (qq_data *) gc->proto_data;
|
|
593 info = g_string_new("<html><body>\n");
|
|
594
|
|
595 g_string_append_printf(info, _("<b>Current Online</b>: %d<br>\n"), qd->all_online);
|
|
596 g_string_append_printf(info, _("<b>Last Refresh</b>: %s<br>\n"), ctime(&qd->last_get_online));
|
|
597
|
|
598 g_string_append(info, "<hr>\n");
|
|
599
|
|
600 g_string_append_printf(info, _("<b>Connection Mode</b>: %s<br>\n"), qd->use_tcp ? "TCP" : "UDP");
|
|
601 g_string_append_printf(info, _("<b>Server IP</b>: %s: %d<br>\n"), qd->server_ip, qd->server_port);
|
|
602 g_string_append_printf(info, _("<b>My Public IP</b>: %s<br>\n"), qd->my_ip);
|
|
603
|
|
604 g_string_append(info, "<hr>\n");
|
|
605 g_string_append(info, "<i>Information below may not be accurate</i><br>\n");
|
|
606
|
|
607 g_string_append_printf(info, _("<b>Login Time</b>: %s<br>\n"), ctime(&qd->login_time));
|
|
608 g_string_append_printf(info, _("<b>Last Login IP</b>: %s<br>\n"), qd->last_login_ip);
|
|
609 g_string_append_printf(info, _("<b>Last Login Time</b>: %s\n"), ctime(&qd->last_login_time));
|
|
610
|
|
611 g_string_append(info, "</body></html>");
|
|
612
|
|
613 gaim_notify_formatted(gc, NULL, _("Login Information"), NULL, info->str, NULL, NULL);
|
|
614
|
|
615 g_string_free(info, TRUE);
|
|
616 }
|
|
617
|
|
618 /* show about page about QQ plugin */
|
|
619 static void _qq_menu_show_about(GaimPluginAction * action)
|
|
620 {
|
|
621 GaimConnection *gc = (GaimConnection *) action->context;
|
|
622 qq_data *qd;
|
|
623 GString *info;
|
|
624 gchar *head;
|
|
625
|
|
626 g_return_if_fail(gc != NULL && gc->proto_data != NULL);
|
|
627
|
|
628 qd = (qq_data *) gc->proto_data;
|
|
629 info = g_string_new("<html><body>\n");
|
|
630
|
|
631 g_string_append_printf(info, _("<b>Author</b> : %s<br>\n"), OPENQ_AUTHOR);
|
|
632 g_string_append(info, "Copyright (c) 2004. All rights reserved.<br><br>\n");
|
|
633
|
|
634 g_string_append(info, _("<p><b>Code Contributors</b><br>\n"));
|
|
635 g_string_append(info, "gfhuang : patches for gaim 2.0.0beta2<br>\n");
|
|
636 g_string_append(info, "henryouly : file transfer, udp sock5 proxy and qq_show<br>\n");
|
|
637 g_string_append(info, "arfankai : fixed bugs in char_conv.c<br>\n");
|
|
638 g_string_append(info, "rakescar : provided filter for HTML tag<br>\n");
|
|
639 g_string_append(info, "yyw : improved performance on PPC linux<br>\n");
|
|
640 g_string_append(info, "lvxiang : provided ip to location original code<br><br>\n");
|
|
641
|
|
642 g_string_append(info, _("<p><b>Acknowledgement</b><br>\n"));
|
|
643 g_string_append(info, "Shufeng Tan : http://sf.net/projects/perl-oicq<br>\n");
|
|
644 g_string_append(info, "Jeff Ye : http://www.sinomac.com<br>\n");
|
|
645 g_string_append(info, "Hu Zheng : http://forlinux.yeah.net<br><br>\n");
|
|
646
|
|
647 g_string_append(info, "<p>And, my parents...\n");
|
|
648
|
|
649 g_string_append(info, "</body></html>");
|
|
650
|
|
651 head = g_strdup_printf("About QQ Plugin Ver %s", VERSION);
|
|
652 gaim_notify_formatted(gc, NULL, head, NULL, info->str, NULL, NULL);
|
|
653
|
|
654 g_free(head);
|
|
655 g_string_free(info, TRUE);
|
|
656 }
|
|
657
|
|
658 /* callback of sending any command to QQ server */
|
|
659 static void _qq_menu_any_cmd_send_cb(GaimConnection * gc, GaimRequestFields * fields)
|
|
660 {
|
|
661 GList *groups, *flds;
|
|
662 GaimRequestField *field;
|
|
663 const gchar *id, *value;
|
|
664 gchar *cmd_str, *data_str, **segments;
|
|
665 guint16 cmd;
|
|
666 guint8 *data;
|
|
667 gint i, data_len;
|
|
668
|
|
669 cmd_str = NULL;
|
|
670 data_str = NULL;
|
|
671 cmd = 0x00;
|
|
672 data = NULL;
|
|
673 data_len = 0;
|
|
674
|
|
675 for (groups = gaim_request_fields_get_groups(fields); groups; groups = groups->next) {
|
|
676 for (flds = gaim_request_field_group_get_fields(groups->data); flds; flds = flds->next) {
|
|
677 field = flds->data;
|
|
678 id = gaim_request_field_get_id(field);
|
|
679 value = gaim_request_field_string_get_value(field);
|
|
680
|
|
681 if (!g_ascii_strcasecmp(id, "cmd"))
|
|
682 cmd_str = g_strdup(value);
|
|
683 else if (!g_ascii_strcasecmp(id, "data"))
|
|
684 data_str = g_strdup(value);
|
|
685 }
|
|
686 }
|
|
687
|
|
688 if (cmd_str != NULL)
|
|
689 cmd = (guint16) strtol(cmd_str, NULL, 16);
|
|
690
|
|
691 if (data_str != NULL) {
|
|
692 if (NULL == (segments = split_data(data_str, strlen(data_str), ",", 0))) {
|
|
693 g_free(cmd_str);
|
|
694 g_free(data_str);
|
|
695 return;
|
|
696 }
|
|
697 for (data_len = 0; segments[data_len] != NULL; data_len++) {;
|
|
698 }
|
|
699 data = g_newa(guint8, data_len);
|
|
700 for (i = 0; i < data_len; i++)
|
|
701 data[i] = (guint8) strtol(segments[i], NULL, 16);
|
|
702 g_strfreev(segments);
|
|
703 }
|
|
704
|
|
705 if (cmd && data_len > 0) {
|
|
706 gaim_debug(GAIM_DEBUG_INFO, "QQ",
|
|
707 "Send Any cmd: %s, data dump\n%s", qq_get_cmd_desc(cmd), hex_dump_to_str(data, data_len));
|
|
708 qq_send_cmd(gc, cmd, TRUE, 0, TRUE, data, data_len);
|
|
709 }
|
|
710
|
|
711 g_free(cmd_str);
|
|
712 g_free(data_str);
|
|
713 }
|
|
714
|
|
715 /* send any command with data to QQ server, for testing and debuggin only */
|
|
716 static void _qq_menu_any_cmd(GaimPluginAction * action)
|
|
717 {
|
|
718 GaimConnection *gc = (GaimConnection *) action->context;
|
|
719 qq_data *qd;
|
|
720 const char *tips;
|
|
721 GaimRequestField *field;
|
|
722 GaimRequestFields *fields;
|
|
723 GaimRequestFieldGroup *group;
|
|
724
|
|
725 g_return_if_fail(gc != NULL && gc->proto_data != NULL);
|
|
726 qd = (qq_data *) gc->proto_data;
|
|
727
|
|
728 tips = _("Separate the value with \",\"\nAllow \"0x\" before each value");
|
|
729 fields = gaim_request_fields_new();
|
|
730 group = gaim_request_field_group_new(NULL);
|
|
731 gaim_request_fields_add_group(fields, group);
|
|
732
|
|
733 /* sample: 0x22 */
|
|
734 field = gaim_request_field_string_new("cmd", _("CMD Code"), NULL, FALSE);
|
|
735 gaim_request_field_group_add_field(group, field);
|
|
736 /* sample: 0x00,0x15,0xAB */
|
|
737 /* or: 00,15,AB */
|
|
738 /* the delimit is ",", allow 0x before the value */
|
|
739 field = gaim_request_field_string_new("data", _("Raw Data"), NULL, FALSE);
|
|
740 gaim_request_field_group_add_field(group, field);
|
|
741
|
|
742 gaim_request_fields(gc, _("QQ Any Command"),
|
|
743 _("Send Arbitrary Command"), tips, fields,
|
|
744 _("Send"), G_CALLBACK(_qq_menu_any_cmd_send_cb), _("Cancel"), NULL, gc);
|
|
745 }
|
|
746
|
|
747 /* added by gfhuang */
|
|
748 static void _qq_menu_locate_ip_cb(GaimConnection * gc, GaimRequestFields * fields)
|
|
749 {
|
|
750 GList *groups, *flds;
|
|
751 GaimRequestField *field;
|
|
752 const gchar *id, *value;
|
|
753 gchar *ip_str = NULL, *ip_dupstr = NULL;
|
|
754 guint8 *ip;
|
|
755 gchar *country, *country_utf8, *city, *city_utf8;
|
|
756 guint32 ip_value;
|
|
757
|
|
758 for (groups = gaim_request_fields_get_groups(fields); groups && !ip_str; groups = groups->next) {
|
|
759 for (flds = gaim_request_field_group_get_fields(groups->data); flds && !ip_str; flds = flds->next) {
|
|
760 field = flds->data;
|
|
761 id = gaim_request_field_get_id(field);
|
|
762 value = gaim_request_field_string_get_value(field);
|
|
763
|
|
764 if (!g_ascii_strcasecmp(id, "ip")) {
|
|
765 ip_str = g_strdup(value);
|
|
766 break;
|
|
767 }
|
|
768 }
|
|
769 }
|
|
770
|
|
771 if(ip_str) {
|
|
772 ip = str_ip_gen(ip_str);
|
|
773 ip_dupstr = gen_ip_str(ip);
|
|
774
|
|
775 ip_value = ntohl(*(guint32 *)ip);
|
|
776 if (qq_ip_get_location(ip_value, &country, &city)) {
|
|
777 country_utf8 = qq_to_utf8(country, QQ_CHARSET_DEFAULT);
|
|
778 city_utf8 = qq_to_utf8(city, QQ_CHARSET_DEFAULT);
|
|
779 gaim_notify_info(gc, ip_dupstr, country_utf8, city_utf8);
|
|
780 g_free(country);
|
|
781 g_free(city);
|
|
782 g_free(country_utf8);
|
|
783 g_free(city_utf8);
|
|
784 }
|
|
785 else
|
|
786 gaim_notify_info(gc, ip_dupstr, "IP not found", NULL);
|
|
787 g_free(ip);
|
|
788 g_free(ip_dupstr);
|
|
789 g_free(ip_str);
|
|
790 }
|
|
791 }
|
|
792
|
|
793 /* added by gfhuang */
|
|
794 static void _qq_menu_locate_ip(GaimPluginAction *action)
|
|
795 {
|
|
796 GaimConnection *gc = (GaimConnection *) action->context;
|
|
797 GaimRequestField *field;
|
|
798 GaimRequestFields *fields;
|
|
799 GaimRequestFieldGroup *group;
|
|
800
|
|
801 g_return_if_fail(gc != NULL);
|
|
802
|
|
803 fields = gaim_request_fields_new();
|
|
804 group = gaim_request_field_group_new(NULL);
|
|
805 gaim_request_fields_add_group(fields, group);
|
|
806
|
|
807 field = gaim_request_field_string_new("ip", _("IP Address"), NULL, FALSE);
|
|
808 gaim_request_field_group_add_field(group, field);
|
|
809
|
|
810 gaim_request_fields(gc, _("Locate an IP"),
|
|
811 _("Locate an IP address"), NULL, fields,
|
|
812 _("Check"), G_CALLBACK(_qq_menu_locate_ip_cb), _("Cancel"), NULL, gc);
|
|
813 }
|
|
814
|
|
815 static void _qq_menu_search_or_add_permanent_group(GaimPluginAction * action)
|
|
816 {
|
|
817 gaim_gtk_roomlist_dialog_show();
|
|
818 }
|
|
819
|
|
820 static void _qq_menu_create_permanent_group(GaimPluginAction * action)
|
|
821 {
|
|
822 GaimConnection *gc = (GaimConnection *) action->context;
|
|
823 g_return_if_fail(gc != NULL);
|
|
824 gaim_request_input(gc, _("Create QQ Qun"),
|
|
825 _("Input Qun name here"),
|
|
826 _("Only QQ member can create permanent Qun"),
|
|
827 "OpenQ", FALSE, FALSE, NULL,
|
|
828 _("Create"), G_CALLBACK(qq_group_create_with_name), _("Cancel"), NULL, gc);
|
|
829 }
|
|
830
|
|
831 static void _qq_menu_unsubscribe_group(GaimBlistNode * node) // by gfhuang, gpointer param_components)
|
|
832 {
|
|
833 // GaimBuddy *buddy; by gfhuang
|
|
834 GaimChat *chat = (GaimChat *)node;
|
|
835 GaimConnection *gc = gaim_account_get_connection(chat->account);
|
|
836 GHashTable *components = chat -> components;
|
|
837 // GHashTable *components = (GHashTable *) param_components;
|
|
838
|
|
839 // g_return_if_fail(GAIM_BLIST_NODE_IS_BUDDY(node)); bug! found by gfhuang
|
|
840 g_return_if_fail(GAIM_BLIST_NODE_IS_CHAT(node));
|
|
841
|
|
842 // buddy = (GaimBuddy *) node;
|
|
843 // gc = gaim_account_get_connection(buddy->account);
|
|
844
|
|
845 g_return_if_fail(gc != NULL && components != NULL);
|
|
846 qq_group_exit(gc, components);
|
|
847 }
|
|
848
|
|
849 static void _qq_menu_manage_group(GaimBlistNode * node) // by gfhuang, gpointer param_components)
|
|
850 {
|
|
851 // GaimBuddy *buddy; by gfhuang
|
|
852 GaimChat *chat = (GaimChat *)node;
|
|
853 GaimConnection *gc = gaim_account_get_connection(chat->account);
|
|
854 GHashTable *components = chat -> components;
|
|
855 // GHashTable *components = (GHashTable *) param_components;
|
|
856
|
|
857 // g_return_if_fail(GAIM_BLIST_NODE_IS_BUDDY(node)); bug! found by gfhuang
|
|
858 g_return_if_fail(GAIM_BLIST_NODE_IS_CHAT(node));
|
|
859
|
|
860 // buddy = (GaimBuddy *) node;
|
|
861 // gc = gaim_account_get_connection(buddy->account);
|
|
862
|
|
863 g_return_if_fail(gc != NULL && components != NULL);
|
|
864 qq_group_manage_group(gc, components);
|
|
865 }
|
|
866
|
|
867 static void _qq_menu_show_system_message(GaimPluginAction *action)
|
|
868 {
|
|
869 GaimConnection *gc = (GaimConnection *) action->context;
|
|
870 g_return_if_fail ( gc != NULL );
|
|
871 gaim_gtk_log_show(GAIM_LOG_IM, "systemim", gaim_connection_get_account(gc));
|
|
872 }
|
|
873
|
|
874 /* TODO: re-enable this
|
|
875 static void _qq_menu_send_file(GaimBlistNode * node, gpointer ignored)
|
|
876 {
|
|
877 GaimBuddy *buddy;
|
|
878 GaimConnection *gc;
|
|
879 qq_buddy *q_bud;
|
|
880
|
|
881 g_return_if_fail (GAIM_BLIST_NODE_IS_BUDDY (node));
|
|
882 buddy = (GaimBuddy *) node;
|
|
883 q_bud = (qq_buddy *) buddy->proto_data;
|
|
884 // if (is_online (q_bud->status)) {
|
|
885 gc = gaim_account_get_connection (buddy->account);
|
|
886 g_return_if_fail (gc != NULL && gc->proto_data != NULL);
|
|
887 qq_send_file(gc, buddy->name, NULL);
|
|
888 // }
|
|
889 }
|
|
890 */
|
|
891
|
|
892 /* protocol related menus */
|
|
893 static GList *_qq_actions(GaimPlugin * plugin, gpointer context)
|
|
894 {
|
|
895 GList *m;
|
|
896 GaimPluginAction *act;
|
|
897
|
|
898 m = NULL;
|
|
899 act = gaim_plugin_action_new(_("Modify My Information"), _qq_menu_get_my_info);
|
|
900 m = g_list_append(m, act);
|
|
901
|
|
902 act = gaim_plugin_action_new(_("Show Login Information"), _qq_menu_show_login_info);
|
|
903 m = g_list_append(m, act);
|
|
904
|
|
905 act = gaim_plugin_action_new(_("Show System Message"), _qq_menu_show_system_message);
|
|
906 m = g_list_append(m, act);
|
|
907
|
|
908 act = gaim_plugin_action_new(_("Any QQ Command"), _qq_menu_any_cmd);
|
|
909 m = g_list_append(m, act);
|
|
910
|
|
911 act = gaim_plugin_action_new(_("Qun: Search a permanent Qun"), _qq_menu_search_or_add_permanent_group);
|
|
912 m = g_list_append(m, act);
|
|
913
|
|
914 act = gaim_plugin_action_new(_("Qun: Create a permanent Qun"), _qq_menu_create_permanent_group);
|
|
915 m = g_list_append(m, act);
|
|
916
|
|
917 act = gaim_plugin_action_new(_("Locate an IP"), _qq_menu_locate_ip);
|
|
918 m = g_list_append(m, act);
|
|
919
|
|
920 act = gaim_plugin_action_new(_("About QQ Plugin"), _qq_menu_show_about);
|
|
921 m = g_list_append(m, act);
|
|
922
|
|
923 return m;
|
|
924 }
|
|
925
|
|
926 /* chat-related (QQ Qun) menu shown up with right-click */
|
|
927 static GList *_qq_chat_menu(GaimBlistNode *node) //gfhuang
|
|
928 {
|
|
929 GList *m;
|
|
930 GaimMenuAction *act;
|
|
931
|
|
932 m = NULL;
|
|
933 act = gaim_menu_action_new(_("Exit this QQ Qun"), GAIM_CALLBACK(_qq_menu_unsubscribe_group), NULL, NULL); //add NULL by gfhuang
|
|
934 m = g_list_append(m, act);
|
|
935
|
|
936 act = gaim_menu_action_new(_("Show Details"), GAIM_CALLBACK(_qq_menu_manage_group), NULL, NULL); //add NULL by gfhuang
|
|
937 m = g_list_append(m, act);
|
|
938
|
|
939 return m;
|
|
940 }
|
|
941 /* buddy-related menu shown up with right-click */
|
|
942 static GList *_qq_buddy_menu(GaimBlistNode * node)
|
|
943 {
|
|
944 GList *m;
|
|
945 /*GaimBlistNodeAction->GaimMenuAction, gaim2beta2, gfhuang*/
|
|
946 // GaimMenuAction *act;
|
|
947
|
|
948 if(GAIM_BLIST_NODE_IS_CHAT(node)) //by gfhuang
|
|
949 return _qq_chat_menu(node);
|
|
950
|
|
951 m = NULL;
|
|
952 /*gaim_blist_node_action_new -> gaim_menu_action_new, gaim2beta2, gfhuang */
|
|
953
|
|
954 /* TODO : not working, temp commented out by gfhuang
|
|
955
|
|
956 act = gaim_menu_action_new(_("Block this buddy"), GAIM_CALLBACK(_qq_menu_block_buddy), NULL, NULL); //add NULL by gfhuang
|
|
957 m = g_list_append(m, act);
|
|
958 // if (q_bud && is_online(q_bud->status)) {
|
|
959 act = gaim_menu_action_new(_("Send File"), GAIM_CALLBACK(_qq_menu_send_file), NULL, NULL); //add NULL by gfhuang
|
|
960 m = g_list_append(m, act);
|
|
961 // }
|
|
962 */
|
|
963
|
|
964 return m;
|
|
965 }
|
|
966
|
|
967
|
|
968 static void _qq_keep_alive(GaimConnection * gc)
|
|
969 {
|
|
970 qq_group *group;
|
|
971 qq_data *qd;
|
|
972 GList *list;
|
|
973
|
|
974 g_return_if_fail(gc != NULL);
|
|
975 if (NULL == (qd = (qq_data *) gc->proto_data))
|
|
976 return;
|
|
977
|
|
978 list = qd->groups;
|
|
979 while (list != NULL) {
|
|
980 group = (qq_group *) list->data;
|
|
981 if (group->my_status == QQ_GROUP_MEMBER_STATUS_IS_MEMBER ||
|
|
982 group->my_status == QQ_GROUP_MEMBER_STATUS_IS_ADMIN)
|
|
983 // no need to get info time and time again, online members enough, gfhuang
|
|
984 // qq_send_cmd_group_get_group_info(gc, group);
|
|
985 qq_send_cmd_group_get_online_member(gc, group);
|
|
986
|
|
987 list = list->next;
|
|
988 }
|
|
989
|
|
990 qq_send_packet_keep_alive(gc);
|
|
991
|
|
992 }
|
|
993
|
|
994 /* convert chat nickname to qq-uid to get this buddy info */
|
|
995 /* who is the nickname of buddy in QQ chat-room (Qun) */
|
|
996 static void _qq_get_chat_buddy_info(GaimConnection * gc, gint channel, const gchar * who)
|
|
997 {
|
|
998 gchar *gaim_name;
|
|
999 g_return_if_fail(gc != NULL && gc->proto_data != NULL && who != NULL);
|
|
1000
|
|
1001 gaim_name = qq_group_find_member_by_channel_and_nickname(gc, channel, who);
|
|
1002 if (gaim_name != NULL)
|
|
1003 _qq_get_info(gc, gaim_name);
|
|
1004
|
|
1005 }
|
|
1006
|
|
1007 /* convert chat nickname to qq-uid to invite individual IM to buddy */
|
|
1008 /* who is the nickname of buddy in QQ chat-room (Qun) */
|
|
1009 static gchar *_qq_get_chat_buddy_real_name(GaimConnection * gc, gint channel, const gchar * who)
|
|
1010 {
|
|
1011 g_return_val_if_fail(gc != NULL && gc->proto_data != NULL && who != NULL, NULL);
|
|
1012 return qq_group_find_member_by_channel_and_nickname(gc, channel, who);
|
|
1013
|
|
1014 }
|
|
1015
|
|
1016 void qq_function_not_implemented(GaimConnection * gc)
|
|
1017 {
|
|
1018 gaim_notify_warning(gc, NULL, _("This function has not be implemented yet"), _("Please wait for new version"));
|
|
1019 }
|
|
1020
|
|
1021 /*
|
|
1022 static GaimPluginPrefFrame *get_plugin_pref_frame(GaimPlugin * plugin)
|
|
1023 {
|
|
1024 GaimPluginPrefFrame *frame;
|
|
1025 GaimPluginPref *ppref;
|
|
1026
|
|
1027 frame = gaim_plugin_pref_frame_new();
|
|
1028
|
|
1029 ppref = gaim_plugin_pref_new_with_label(_("Convert IP to location"));
|
|
1030 gaim_plugin_pref_frame_add(frame, ppref);
|
|
1031
|
|
1032 ppref = gaim_plugin_pref_new_with_name_and_label("/plugins/prpl/qq/ipfile", _("IP file"));
|
|
1033 gaim_plugin_pref_frame_add(frame, ppref);
|
|
1034
|
|
1035 ppref = gaim_plugin_pref_new_with_label(_("Display Options"));
|
|
1036 gaim_plugin_pref_frame_add(frame, ppref);
|
|
1037
|
|
1038 ppref = gaim_plugin_pref_new_with_name_and_label
|
|
1039 ("/plugins/prpl/qq/show_status_by_icon", _("Show gender/age information beside buddy icons"));
|
|
1040 gaim_plugin_pref_frame_add(frame, ppref);
|
|
1041
|
|
1042 ppref = gaim_plugin_pref_new_with_name_and_label
|
|
1043 ("/plugins/prpl/qq/show_fake_video", _("Fake an video for GAIM QQ (re-login to activate)"));
|
|
1044 gaim_plugin_pref_frame_add(frame, ppref);
|
|
1045
|
|
1046 ppref = gaim_plugin_pref_new_with_label(_("System Options"));
|
|
1047 gaim_plugin_pref_frame_add(frame, ppref);
|
|
1048
|
|
1049 ppref = gaim_plugin_pref_new_with_name_and_label
|
|
1050 ("/plugins/prpl/qq/prompt_for_missing_packet", _("Prompt user for actions if there are missing packets"));
|
|
1051 gaim_plugin_pref_frame_add(frame, ppref);
|
|
1052
|
|
1053 ppref = gaim_plugin_pref_new_with_name_and_label
|
|
1054 ("/plugins/prpl/qq/prompt_group_msg_on_recv", _("Pop up Qun chat window when receive Qun message"));
|
|
1055 gaim_plugin_pref_frame_add(frame, ppref);
|
|
1056
|
|
1057 ppref = gaim_plugin_pref_new_with_name_and_label("/plugins/prpl/qq/datadir", _("OpenQ installed directory"));
|
|
1058 gaim_plugin_pref_frame_add(frame, ppref);
|
|
1059
|
|
1060 return frame;
|
|
1061 }
|
|
1062 */
|
|
1063
|
|
1064 GaimPlugin *my_protocol = NULL;
|
|
1065 static GaimPluginProtocolInfo prpl_info = {
|
|
1066 OPT_PROTO_CHAT_TOPIC | OPT_PROTO_USE_POINTSIZE,
|
|
1067 NULL, /* user_splits */
|
|
1068 NULL, /* protocol_options */
|
|
1069 NO_BUDDY_ICONS, /* icon_spec */
|
|
1070 _qq_list_icon, /* list_icon */
|
|
1071 _qq_list_emblems, /* list_emblems */
|
|
1072 _qq_status_text, /* status_text */
|
|
1073 _qq_tooltip_text, /* tooltip_text */
|
|
1074 _qq_away_states, /* away_states */
|
|
1075 _qq_buddy_menu, /* blist_node_menu */
|
|
1076 qq_chat_info, /* chat_info */
|
|
1077 NULL, /* chat_info_defaults */
|
|
1078 _qq_login, /* login */
|
|
1079 _qq_close, /* close */
|
|
1080 _qq_send_im, /* send_im */
|
|
1081 NULL, /* set_info */
|
|
1082 NULL, /* send_typing */
|
|
1083 _qq_get_info, /* get_info */
|
|
1084 _qq_set_away, /* set_away */
|
|
1085 NULL, /* set_idle */
|
|
1086 NULL, /* change_passwd */
|
|
1087 qq_add_buddy, /* add_buddy */
|
|
1088 NULL, /* add_buddies */
|
|
1089 qq_remove_buddy, /* remove_buddy */
|
|
1090 NULL, /* remove_buddies */
|
|
1091 NULL, /* add_permit */
|
|
1092 NULL, /* add_deny */
|
|
1093 NULL, /* rem_permit */
|
|
1094 NULL, /* rem_deny */
|
|
1095 NULL, /* set_permit_deny */
|
|
1096 qq_group_join, /* join_chat */
|
|
1097 NULL, /* reject chat invite */
|
|
1098 NULL, /* get_chat_name */
|
|
1099 NULL, /* chat_invite */
|
|
1100 NULL, /* chat_leave */
|
|
1101 NULL, /* chat_whisper */
|
|
1102 _qq_chat_send, /* chat_send */
|
|
1103 _qq_keep_alive, /* keepalive */
|
|
1104 NULL, /* register_user */
|
|
1105 _qq_get_chat_buddy_info, /* get_cb_info */
|
|
1106 NULL, /* get_cb_away */
|
|
1107 NULL, /* alias_buddy */
|
|
1108 NULL, /* group_buddy */
|
|
1109 NULL, /* rename_group */
|
|
1110 NULL, /* buddy_free */
|
|
1111 NULL, /* convo_closed */
|
|
1112 NULL, /* normalize */
|
|
1113 NULL, /* set_buddy_icon */
|
|
1114 NULL, /* remove_group */
|
|
1115 _qq_get_chat_buddy_real_name, /* get_cb_real_name */
|
|
1116 NULL, /* set_chat_topic */
|
|
1117 NULL, /* find_blist_chat */
|
|
1118 qq_roomlist_get_list, /* roomlist_get_list */
|
|
1119 qq_roomlist_cancel, /* roomlist_cancel */
|
|
1120 NULL, /* roomlist_expand_category */
|
|
1121 qq_can_receive_file, /* can_receive_file */
|
|
1122 qq_send_file, /* send_file */
|
|
1123 NULL, /* new xfer, by gfhuang */
|
|
1124 NULL, /* offline_message, gaim2beta2, gfhuang */
|
|
1125 NULL, /* GaimWhiteboardPrplOps, gaim2beta2, gfhuang */
|
|
1126 };
|
|
1127
|
|
1128 /*
|
|
1129 static GaimPluginUiInfo prefs_info = {
|
|
1130 get_plugin_pref_frame
|
|
1131 };
|
|
1132 */
|
|
1133
|
|
1134 static GaimPluginInfo info = {
|
|
1135 GAIM_PLUGIN_MAGIC,
|
|
1136 GAIM_MAJOR_VERSION,
|
|
1137 GAIM_MINOR_VERSION,
|
|
1138 GAIM_PLUGIN_PROTOCOL, /**< type */
|
|
1139 NULL, /**< ui_requirement */
|
|
1140 0, /**< flags */
|
|
1141 NULL, /**< dependencies */
|
|
1142 GAIM_PRIORITY_DEFAULT, /**< priority */
|
|
1143
|
|
1144 "prpl-qq", /**< id */
|
|
1145 "QQ", /**< name */
|
|
1146 VERSION, /**< version */
|
|
1147 /** summary */
|
|
1148 N_("QQ Protocol Plugin"),
|
|
1149 /** description */
|
|
1150 N_("QQ Protocol Plugin"),
|
|
1151 OPENQ_AUTHOR, /**< author */
|
|
1152 OPENQ_WEBSITE, /**< homepage */
|
|
1153
|
|
1154 NULL, /**< load */
|
|
1155 NULL, /**< unload */
|
|
1156 NULL, /**< destroy */
|
|
1157
|
|
1158 NULL, /**< ui_info */
|
|
1159 &prpl_info, /**< extra_info */
|
|
1160 NULL, /**< prefs_info */
|
|
1161 _qq_actions
|
|
1162 };
|
|
1163
|
|
1164
|
|
1165 static void init_plugin(GaimPlugin * plugin)
|
|
1166 {
|
|
1167 GaimAccountOption *option;
|
|
1168
|
|
1169 bindtextdomain(PACKAGE, LOCALEDIR);
|
|
1170 bind_textdomain_codeset(PACKAGE, "UTF-8");
|
|
1171
|
|
1172 option = gaim_account_option_bool_new(_("Login in TCP"), "use_tcp", FALSE);
|
|
1173 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option);
|
|
1174
|
|
1175 option = gaim_account_option_bool_new(_("Login Hidden"), "hidden", FALSE);
|
|
1176 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option);
|
|
1177
|
|
1178 option = gaim_account_option_string_new(_("QQ Server"), "server", NULL);
|
|
1179 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option);
|
|
1180
|
|
1181 option = gaim_account_option_string_new(_("QQ Port"), "port", NULL);
|
|
1182 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option);
|
|
1183
|
|
1184 my_protocol = plugin;
|
|
1185
|
|
1186 gaim_prefs_add_none("/plugins/prpl/qq");
|
|
1187 gaim_prefs_add_string("/plugins/prpl/qq/ipfile", "");
|
|
1188 gaim_prefs_add_bool("/plugins/prpl/qq/show_status_by_icon", TRUE);
|
|
1189 gaim_prefs_add_bool("/plugins/prpl/qq/show_fake_video", FALSE);
|
|
1190 gaim_prefs_add_string("/plugins/prpl/qq/datadir", DATADIR);
|
|
1191 gaim_prefs_add_bool("/plugins/prpl/qq/prompt_for_missing_packet", TRUE);
|
|
1192 gaim_prefs_add_bool("/plugins/prpl/qq/prompt_group_msg_on_recv", TRUE);
|
|
1193 }
|
|
1194
|
|
1195 GAIM_INIT_PLUGIN(qq, init_plugin, info);
|