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