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