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;
|
|
97 gboolean login_hidden, use_tcp;
|
|
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 login_hidden = gaim_presence_is_status_primitive_active(presence, GAIM_STATUS_INVISIBLE);
|
|
115
|
|
116 qd->use_tcp = use_tcp;
|
|
117
|
|
118 if (login_hidden) {
|
|
119 qd->login_mode = QQ_LOGIN_MODE_HIDDEN;
|
|
120 gaim_debug(GAIM_DEBUG_INFO, "QQ", "Login in hidden mode\n");
|
|
121 } else {
|
|
122 qd->login_mode = QQ_LOGIN_MODE_NORMAL;
|
|
123 gaim_debug(GAIM_DEBUG_INFO, "QQ", "Login in normal mode\n");
|
|
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 */
|
|
261 if (q_bud->status == QQ_BUDDY_ONLINE_AWAY || q_bud->status == QQ_SELF_STATUS_AWAY)
|
|
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 const char *state = gaim_status_get_id(status);
|
|
310
|
|
311 qq_data *qd;
|
|
312
|
|
313
|
|
314 g_return_if_fail(gc != NULL && gc->proto_data != NULL);
|
|
315
|
|
316 qd = (qq_data *) gc->proto_data;
|
|
317
|
|
318 if(0 == strcmp(state, "available"))
|
|
319 qd->status = QQ_SELF_STATUS_AVAILABLE;
|
|
320 else if (0 == strcmp(state, "away"))
|
|
321 qd->status = QQ_SELF_STATUS_AWAY;
|
|
322 else if (0 == strcmp(state, "invisible"))
|
|
323 qd->status = QQ_SELF_STATUS_INVISIBLE;
|
|
324 else
|
|
325 qd->status = QQ_SELF_STATUS_AVAILABLE;
|
|
326
|
|
327 qq_send_packet_change_status(gc);
|
|
328 }
|
|
329
|
|
330 /* IMPORTANT: GaimConvImFlags -> GaimMessageFlags */
|
|
331 /* send an instant msg to a buddy */
|
|
332 static gint _qq_send_im(GaimConnection *gc, const gchar *who, const gchar *message, GaimMessageFlags flags)
|
|
333 {
|
|
334 gint type, to_uid;
|
|
335 gchar *msg, *msg_with_qq_smiley;
|
|
336 qq_data *qd;
|
|
337
|
|
338 g_return_val_if_fail(gc != NULL && gc->proto_data != NULL && who != NULL, -1);
|
|
339
|
|
340 qd = (qq_data *) gc->proto_data;
|
|
341
|
|
342 g_return_val_if_fail(strlen(message) <= QQ_MSG_IM_MAX, -E2BIG);
|
|
343
|
|
344 type = (flags == GAIM_MESSAGE_AUTO_RESP ? QQ_IM_AUTO_REPLY : QQ_IM_TEXT);
|
|
345 to_uid = gaim_name_to_uid(who);
|
|
346
|
|
347 /* if msg is to myself, bypass the network */
|
|
348 if (to_uid == qd->uid) {
|
|
349 serv_got_im(gc, who, message, flags, time(NULL));
|
|
350 } else {
|
|
351 msg = utf8_to_qq(message, QQ_CHARSET_DEFAULT);
|
|
352 msg_with_qq_smiley = gaim_smiley_to_qq(msg);
|
|
353 qq_send_packet_im(gc, to_uid, msg_with_qq_smiley, type);
|
|
354 g_free(msg);
|
|
355 g_free(msg_with_qq_smiley);
|
|
356 }
|
|
357
|
|
358 return 1;
|
|
359 }
|
|
360
|
|
361 /* send a chat msg to a QQ Qun */
|
|
362 static int _qq_chat_send(GaimConnection *gc, int channel, const char *message, GaimMessageFlags flags)
|
|
363 {
|
|
364 gchar *msg, *msg_with_qq_smiley;
|
|
365 qq_group *group;
|
|
366
|
|
367 g_return_val_if_fail(gc != NULL && message != NULL, -1);
|
|
368 g_return_val_if_fail(strlen(message) <= QQ_MSG_IM_MAX, -E2BIG);
|
|
369
|
|
370 group = qq_group_find_by_channel(gc, channel);
|
|
371 g_return_val_if_fail(group != NULL, -1);
|
|
372
|
|
373 msg = utf8_to_qq(message, QQ_CHARSET_DEFAULT);
|
|
374 msg_with_qq_smiley = gaim_smiley_to_qq(msg);
|
|
375 qq_send_packet_group_im(gc, group, msg_with_qq_smiley);
|
|
376 g_free(msg);
|
|
377 g_free(msg_with_qq_smiley);
|
|
378
|
|
379 return 1;
|
|
380 }
|
|
381
|
|
382 /* send packet to get who's detailed information */
|
|
383 static void _qq_get_info(GaimConnection *gc, const gchar *who)
|
|
384 {
|
|
385 guint32 uid;
|
|
386 qq_data *qd;
|
|
387
|
|
388 g_return_if_fail(gc != NULL && gc->proto_data != NULL);
|
|
389 qd = gc->proto_data;
|
|
390 uid = gaim_name_to_uid(who);
|
|
391
|
|
392 if (uid <= 0) {
|
|
393 gaim_debug(GAIM_DEBUG_ERROR, "QQ", "Not valid QQid: %s\n", who);
|
|
394 gaim_notify_error(gc, NULL, _("Invalid name, please input in qq-xxxxxxxx format"), NULL);
|
|
395 return;
|
|
396 }
|
|
397
|
|
398 qq_send_packet_get_info(gc, uid, TRUE);
|
|
399 }
|
|
400
|
|
401 /* get my own information */
|
|
402 static void _qq_menu_modify_my_info(GaimPluginAction *action)
|
|
403 {
|
|
404 GaimConnection *gc = (GaimConnection *) action->context;
|
|
405 qq_data *qd;
|
|
406
|
|
407 g_return_if_fail(gc != NULL && gc->proto_data != NULL);
|
|
408
|
|
409 qd = (qq_data *) gc->proto_data;
|
|
410 qq_prepare_modify_info(gc);
|
|
411 }
|
|
412
|
14265
|
413 static void _qq_change_face_cb(GaimConnection *gc, GaimRequestFields *fields)
|
|
414 {
|
|
415 qq_data *qd;
|
|
416 GaimRequestField *field;
|
|
417 gint suffix;
|
|
418
|
|
419 g_return_if_fail(gc != NULL && gc->proto_data != NULL);
|
|
420 qd = (qq_data *) gc->proto_data;
|
|
421
|
|
422 field = gaim_request_fields_get_field(fields, "face_num");
|
|
423 suffix = get_icon_offset_from_self_status(qd->status);
|
|
424 qd->my_icon = gaim_request_field_choice_get_value(field) * 3 + suffix;
|
|
425 qd->modifying_face = TRUE;
|
|
426 qq_send_packet_get_info(gc, qd->uid, FALSE);
|
|
427 }
|
|
428
|
|
429 static void _qq_add_face_choice(GaimRequestFieldGroup *group, gint face_num)
|
|
430 {
|
|
431 GaimRequestField *field;
|
|
432 struct stat img_stat;
|
|
433 FILE *file;
|
|
434 gchar *filename, *prefix, *img_data, *face;
|
|
435 gint size;
|
|
436
|
|
437 face = g_strdup_printf("qq_%i.png", face_num);
|
|
438 prefix = br_extract_prefix(DATADIR);
|
|
439 filename = g_build_filename(prefix, "share","pixmaps",
|
|
440 "gaim","status","default", face, NULL);
|
|
441 g_free(face);
|
|
442 face = g_strdup_printf("%i", face_num);
|
|
443 stat(filename, &img_stat);
|
|
444 file = g_fopen(filename, "rb");
|
|
445 if (file) {
|
|
446 img_data = g_malloc(img_stat.st_size);
|
|
447 size = fread(img_data, 1, img_stat.st_size, file);
|
|
448
|
|
449 field = gaim_request_field_image_new(face, face, img_data, size);
|
|
450 gaim_request_field_group_add_field(group, field);
|
|
451
|
|
452 g_free(img_data);
|
|
453 fclose(file);
|
|
454 }
|
|
455 g_free(face);
|
|
456 g_free(prefix);
|
|
457 }
|
|
458
|
14268
|
459 /* Change your status icon (face) */
|
14265
|
460 static void _qq_menu_change_face(GaimPluginAction *action)
|
|
461 {
|
|
462 GaimConnection *gc = (GaimConnection *) action->context;
|
|
463 qq_data *qd = (qq_data *) gc->proto_data;
|
|
464 GaimRequestFields *fields;
|
|
465 GaimRequestFieldGroup *group;
|
|
466 GaimRequestField *field;
|
|
467 gchar *label;
|
|
468 gint i;
|
|
469
|
|
470 fields = gaim_request_fields_new();
|
|
471 group = gaim_request_field_group_new(_("Selection"));
|
|
472 gaim_request_fields_add_group(fields, group);
|
|
473 field = gaim_request_field_choice_new("face_num",
|
|
474 _("Select a number"), qd->my_icon / 3);
|
|
475 for(i = 1; i <= QQ_FACES; i++) {
|
|
476 label = g_strdup_printf("%i", i);
|
|
477 gaim_request_field_choice_add(field, label);
|
|
478 g_free(label);
|
|
479 }
|
|
480 gaim_request_field_group_add_field(group, field);
|
|
481 group = gaim_request_field_group_new(_("Faces"));
|
|
482 gaim_request_fields_add_group(fields, group);
|
|
483 for(i = 1; i <= QQ_FACES; i++)
|
|
484 _qq_add_face_choice(group, i);
|
|
485
|
|
486 gaim_request_fields(gc, _("Change Your QQ Face"),
|
|
487 _("Change Face"), NULL, fields,
|
|
488 _("Update"), G_CALLBACK(_qq_change_face_cb),
|
|
489 _("Cancel"), NULL,
|
|
490 gc);
|
|
491 }
|
|
492
|
14192
|
493 static void _qq_menu_change_password(GaimPluginAction *action)
|
|
494 {
|
|
495 gaim_notify_uri(NULL, "https://password.qq.com");
|
|
496 }
|
|
497
|
|
498 /* remove a buddy from my list and remove myself from his list */
|
|
499 /* TODO: re-enable this
|
|
500 static void _qq_menu_block_buddy(GaimBlistNode * node)
|
|
501 {
|
|
502 guint32 uid;
|
|
503 gc_and_uid *g;
|
|
504 GaimBuddy *buddy;
|
|
505 GaimConnection *gc;
|
|
506 // const gchar *who = param_who; gfhuang
|
|
507 const gchar *who;
|
|
508
|
|
509 g_return_if_fail(GAIM_BLIST_NODE_IS_BUDDY(node));
|
|
510
|
|
511 buddy = (GaimBuddy *) node;
|
|
512 gc = gaim_account_get_connection(buddy->account);
|
|
513 who = buddy->name;
|
|
514 g_return_if_fail(gc != NULL && who != NULL);
|
|
515
|
|
516 uid = gaim_name_to_uid(who);
|
|
517 g_return_if_fail(uid > 0);
|
|
518
|
|
519 g = g_new0(gc_and_uid, 1);
|
|
520 g->gc = gc;
|
|
521 g->uid = uid;
|
|
522
|
|
523 gaim_request_action(gc, _("Block Buddy"),
|
|
524 _("Are you sure to block this buddy?"), NULL,
|
|
525 1, g, 2,
|
|
526 _("Cancel"),
|
|
527 G_CALLBACK(qq_do_nothing_with_gc_and_uid),
|
|
528 _("Block"), G_CALLBACK(qq_block_buddy_with_gc_and_uid));
|
|
529 }
|
|
530 */
|
|
531
|
|
532 /* show a brief summary of what we get from login packet */
|
|
533 static void _qq_menu_show_login_info(GaimPluginAction *action)
|
|
534 {
|
|
535 GaimConnection *gc = (GaimConnection *) action->context;
|
|
536 qq_data *qd;
|
|
537 GString *info;
|
|
538
|
|
539 g_return_if_fail(gc != NULL && gc->proto_data != NULL);
|
|
540
|
|
541 qd = (qq_data *) gc->proto_data;
|
|
542 info = g_string_new("<html><body>\n");
|
|
543
|
|
544 g_string_append_printf(info, _("<b>Current Online</b>: %d<br>\n"), qd->all_online);
|
|
545 g_string_append_printf(info, _("<b>Last Refresh</b>: %s<br>\n"), ctime(&qd->last_get_online));
|
|
546
|
|
547 g_string_append(info, "<hr>\n");
|
|
548
|
|
549 g_string_append_printf(info, _("<b>Connection Mode</b>: %s<br>\n"), qd->use_tcp ? "TCP" : "UDP");
|
|
550 g_string_append_printf(info, _("<b>Server IP</b>: %s: %d<br>\n"), qd->server_ip, qd->server_port);
|
|
551 g_string_append_printf(info, _("<b>My Public IP</b>: %s<br>\n"), qd->my_ip);
|
|
552
|
|
553 g_string_append(info, "<hr>\n");
|
|
554 g_string_append(info, "<i>Information below may not be accurate</i><br>\n");
|
|
555
|
|
556 g_string_append_printf(info, _("<b>Login Time</b>: %s<br>\n"), ctime(&qd->login_time));
|
|
557 g_string_append_printf(info, _("<b>Last Login IP</b>: %s<br>\n"), qd->last_login_ip);
|
|
558 g_string_append_printf(info, _("<b>Last Login Time</b>: %s\n"), ctime(&qd->last_login_time));
|
|
559
|
|
560 g_string_append(info, "</body></html>");
|
|
561
|
|
562 gaim_notify_formatted(gc, NULL, _("Login Information"), NULL, info->str, NULL, NULL);
|
|
563
|
|
564 g_string_free(info, TRUE);
|
|
565 }
|
|
566
|
14242
|
567 /*
|
14192
|
568 static void _qq_menu_search_or_add_permanent_group(GaimPluginAction *action)
|
|
569 {
|
|
570 gaim_roomlist_show_with_account(NULL);
|
|
571 }
|
14242
|
572 */
|
14192
|
573
|
|
574 /*
|
|
575 static void _qq_menu_create_permanent_group(GaimPluginAction * action)
|
|
576 {
|
|
577 GaimConnection *gc = (GaimConnection *) action->context;
|
|
578 g_return_if_fail(gc != NULL);
|
|
579 gaim_request_input(gc, _("Create QQ Qun"),
|
|
580 _("Input Qun name here"),
|
|
581 _("Only QQ member can create permanent Qun"),
|
|
582 "OpenQ", FALSE, FALSE, NULL,
|
|
583 _("Create"), G_CALLBACK(qq_group_create_with_name), _("Cancel"), NULL, gc);
|
|
584 }
|
|
585 */
|
|
586
|
|
587 /* XXX re-enable this
|
|
588 static void _qq_menu_unsubscribe_group(GaimBlistNode * node)
|
|
589 {
|
|
590 GaimChat *chat = (GaimChat *)node;
|
|
591 GaimConnection *gc = gaim_account_get_connection(chat->account);
|
|
592 GHashTable *components = chat -> components;
|
|
593
|
|
594 g_return_if_fail(GAIM_BLIST_NODE_IS_CHAT(node));
|
|
595
|
|
596 g_return_if_fail(gc != NULL && components != NULL);
|
|
597 qq_group_exit(gc, components);
|
|
598 }
|
|
599
|
|
600 // XXX re-enable this
|
|
601 static void _qq_menu_manage_group(GaimBlistNode * node)
|
|
602 {
|
|
603 GaimChat *chat = (GaimChat *)node;
|
|
604 GaimConnection *gc = gaim_account_get_connection(chat->account);
|
|
605 GHashTable *components = chat -> components;
|
|
606
|
|
607 g_return_if_fail(GAIM_BLIST_NODE_IS_CHAT(node));
|
|
608
|
|
609 g_return_if_fail(gc != NULL && components != NULL);
|
|
610 qq_group_manage_group(gc, components);
|
|
611 }
|
|
612 */
|
|
613
|
|
614 /*
|
|
615 static void _qq_menu_show_system_message(GaimPluginAction *action)
|
|
616 {
|
|
617 GaimConnection *gc = (GaimConnection *) action->context;
|
|
618 g_return_if_fail ( gc != NULL );
|
|
619 gaim_gtk_log_show(GAIM_LOG_IM, "systemim", gaim_connection_get_account(gc));
|
|
620 }
|
|
621 */
|
|
622
|
|
623 /* TODO: re-enable this
|
|
624 static void _qq_menu_send_file(GaimBlistNode * node, gpointer ignored)
|
|
625 {
|
|
626 GaimBuddy *buddy;
|
|
627 GaimConnection *gc;
|
|
628 qq_buddy *q_bud;
|
|
629
|
|
630 g_return_if_fail (GAIM_BLIST_NODE_IS_BUDDY (node));
|
|
631 buddy = (GaimBuddy *) node;
|
|
632 q_bud = (qq_buddy *) buddy->proto_data;
|
|
633 // if (is_online (q_bud->status)) {
|
|
634 gc = gaim_account_get_connection (buddy->account);
|
|
635 g_return_if_fail (gc != NULL && gc->proto_data != NULL);
|
|
636 qq_send_file(gc, buddy->name, NULL);
|
|
637 // }
|
|
638 }
|
|
639 */
|
|
640
|
14237
|
641 /* attempt to output the value and byte length of a given field */
|
|
642 /*
|
14192
|
643 static gboolean _qq_parse_custom_packet_field(GaimRequestFields *fields,
|
14237
|
644 const gchar *id, guint8 **value, gint *len, gboolean allow_null)
|
14192
|
645 {
|
|
646 GaimRequestField *field;
|
|
647 const gchar *str;
|
14237
|
648 gint i;
|
14192
|
649 gboolean success;
|
|
650
|
|
651 success = FALSE;
|
|
652 field = gaim_request_fields_get_field(fields, id);
|
|
653 str = gaim_request_field_string_get_value(field);
|
14237
|
654 if (!str && allow_null) {
|
|
655 return TRUE;
|
|
656 } else if (str) {
|
14192
|
657 success = TRUE;
|
|
658 if (strcmp(id, "uid") != 0) {
|
14237
|
659 *value = hex_str_to_bytes(str, len);
|
|
660 if (!*value)
|
14192
|
661 success = FALSE;
|
|
662 } else {
|
|
663 for (i = 0; i < strlen(str); i++) {
|
|
664 if (!g_ascii_isdigit(str[i])) {
|
|
665 success = FALSE;
|
|
666 break;
|
|
667 }
|
|
668 }
|
|
669 if (success) {
|
|
670 *(guint32 *) value = strtoul(str, NULL, 10);
|
|
671 if (errno == ERANGE)
|
|
672 success = FALSE;
|
|
673 }
|
|
674 }
|
|
675 }
|
|
676 if (!success)
|
|
677 gaim_debug(GAIM_DEBUG_ERROR, "QQ", "Invalid entry: %s\n", id);
|
|
678 return success;
|
|
679 }
|
14237
|
680 */
|
14192
|
681
|
14237
|
682 /* attempt to output the field values and body length */
|
|
683 /*
|
14192
|
684 static gboolean _qq_parse_custom_packet_fields(GaimRequestFields *fields,
|
|
685 guint8 **client, guint8 **cmd, guint8 **seq, guint32 *uid,
|
14237
|
686 guint8 **body, guint8 **key, gint *body_len)
|
14192
|
687 {
|
14237
|
688 gint len;
|
14192
|
689 gboolean success;
|
|
690
|
14237
|
691 success = FALSE;
|
|
692 *client = *cmd = *seq = *body = *key = NULL;
|
|
693 *uid = *body_len = 0;
|
|
694 if ((_qq_parse_custom_packet_field(fields, "client", client, &len, FALSE)
|
|
695 && len == 2
|
|
696 && _qq_parse_custom_packet_field(fields, "cmd", cmd, &len, FALSE)
|
|
697 && len == 2
|
|
698 && _qq_parse_custom_packet_field(fields, "uid", (guint8 **) uid, &len, FALSE)
|
|
699 && _qq_parse_custom_packet_field(fields, "seq", seq, &len, FALSE)
|
|
700 && len == 2
|
|
701 && _qq_parse_custom_packet_field(fields, "body", body, body_len, TRUE))) {
|
|
702 if (*body_len > MAX_PACKET_SIZE / 8) {
|
|
703 g_free(*client);
|
|
704 g_free(*cmd);
|
|
705 g_free(*seq);
|
|
706 g_free(*body);
|
|
707 return FALSE;
|
|
708 }
|
|
709 if (!gaim_request_fields_get_bool(fields, "encrypt"))
|
|
710 return TRUE;
|
|
711 else
|
|
712 success = _qq_parse_custom_packet_field(fields,
|
|
713 "key", key, &len, FALSE)
|
|
714 && len == 16
|
|
715 && *body_len > 0;
|
|
716 }
|
|
717 if (!success) {
|
14192
|
718 if (*client)
|
|
719 g_free(*client);
|
|
720 if (*cmd)
|
|
721 g_free(*cmd);
|
|
722 if (*seq)
|
|
723 g_free(*seq);
|
14237
|
724 if (*key)
|
|
725 g_free(*key);
|
|
726 return FALSE;
|
14192
|
727 }
|
14237
|
728 return TRUE;
|
14192
|
729 }
|
14237
|
730 */
|
14192
|
731
|
14237
|
732 /* parses the request fields and attempts to send the packet */
|
|
733 /*
|
14192
|
734 static void _qq_send_custom_packet_cb(GaimConnection *gc, GaimRequestFields *fields)
|
|
735 {
|
|
736 guint32 uid;
|
14237
|
737 guint8 *buf, *client, *cmd, *seq, *body, *encr_body, *key, *cursor;
|
|
738 gint bytes, len, encr_len;
|
14192
|
739 qq_data *qd;
|
|
740 gboolean success;
|
|
741
|
|
742 qd = (qq_data *) gc->proto_data;
|
|
743
|
|
744 success = _qq_parse_custom_packet_fields(fields, &client, &cmd,
|
14237
|
745 &seq, &uid, &body, &key, &len);
|
14192
|
746 if (!success) {
|
14237
|
747 gaim_notify_error(gc, _("Error"), _("Invalid entry"), NULL);
|
14192
|
748 return;
|
|
749 }
|
|
750
|
|
751 bytes = 0;
|
|
752 buf = g_newa(guint8, MAX_PACKET_SIZE);
|
|
753 cursor = buf;
|
14237
|
754 */
|
14192
|
755 /* QQ TCP packet has two bytes in the beginning to define packet length
|
|
756 * so I leave room here for size */
|
14237
|
757 /*
|
14192
|
758 if (qd->use_tcp)
|
|
759 bytes += create_packet_w(buf, &cursor, 0x0000);
|
|
760 bytes += create_packet_b(buf, &cursor, QQ_PACKET_TAG);
|
|
761 bytes += create_packet_w(buf, &cursor, *(guint16 *) client);
|
|
762 bytes += create_packet_w(buf, &cursor, *(guint16 *) cmd);
|
|
763 bytes += create_packet_w(buf, &cursor, *(guint16 *) seq);
|
|
764 bytes += create_packet_dw(buf, &cursor, uid);
|
|
765 if (body) {
|
14237
|
766 if (gaim_request_fields_get_bool(fields, "encrypt")) {
|
|
767 if (gaim_request_fields_get_bool(fields, "prepend"))
|
|
768 bytes += create_packet_data(buf, &cursor, key, 16);
|
|
769 encr_body = g_newa(guint8, MAX_PACKET_SIZE);
|
|
770 qq_crypt(ENCRYPT, body, len, key, encr_body, &encr_len);
|
|
771 bytes += create_packet_data(buf, &cursor, encr_body, encr_len);
|
|
772 g_free(key);
|
|
773 } else {
|
|
774 bytes += create_packet_data(buf, &cursor, body, len);
|
|
775 }
|
|
776
|
14192
|
777 g_free(body);
|
|
778 }
|
|
779 bytes += create_packet_b(buf, &cursor, QQ_PACKET_TAIL);
|
|
780
|
|
781 gaim_debug(GAIM_DEBUG_INFO, "QQ", "Custom packet of length %i\n", bytes);
|
|
782 _qq_show_packet("Outgoing custom packet", buf, bytes);
|
|
783
|
|
784 _qq_send_packet(gc, buf, bytes, *(guint16 *) cmd);
|
|
785 g_free(client);
|
|
786 g_free(cmd);
|
|
787 g_free(seq);
|
|
788 }
|
14237
|
789 */
|
14192
|
790
|
|
791 /* send a custom packet to the server - for protocol testing */
|
14237
|
792 /*
|
14192
|
793 static void _qq_menu_send_custom_packet(GaimPluginAction *action)
|
|
794 {
|
|
795 GaimConnection *gc;
|
|
796 GaimRequestFields *fields;
|
|
797 GaimRequestFieldGroup *group;
|
|
798 GaimRequestField *field;
|
|
799 gchar *tmp;
|
|
800 qq_data *qd;
|
|
801
|
|
802 gc = (GaimConnection *) action->context;
|
|
803 qd = (qq_data *) gc->proto_data;
|
|
804 g_return_if_fail(gc != NULL && qd != NULL);
|
|
805
|
|
806 fields = gaim_request_fields_new();
|
14237
|
807 group = gaim_request_field_group_new(_("Basic Elements"));
|
14192
|
808 gaim_request_fields_add_group(fields, group);
|
|
809 tmp = g_strdup_printf("%04X", QQ_CLIENT);
|
|
810 field = gaim_request_field_string_new("client", _("Client (hex)"), tmp, FALSE);
|
|
811 g_free(tmp);
|
|
812 gaim_request_field_group_add_field(group, field);
|
|
813 field = gaim_request_field_string_new("cmd", _("Command (hex)"), "0000", FALSE);
|
|
814 gaim_request_field_group_add_field(group, field);
|
|
815 field = gaim_request_field_string_new("seq", _("Sequence (hex)"), "0000", FALSE);
|
|
816 gaim_request_field_group_add_field(group, field);
|
|
817 tmp = g_strdup_printf("%u", qd->uid);
|
|
818 field = gaim_request_field_string_new("uid", _("QQ Number (decimal)"), tmp, FALSE);
|
|
819 g_free(tmp);
|
|
820 gaim_request_field_group_add_field(group, field);
|
14237
|
821 field = gaim_request_field_string_new("body", _("Body (hex)"), NULL, TRUE);
|
|
822 gaim_request_field_group_add_field(group, field);
|
|
823 group = gaim_request_field_group_new(_("Encryption"));
|
|
824 gaim_request_fields_add_group(fields, group);
|
|
825 field = gaim_request_field_bool_new("encrypt", _("Encrypt Packet Body"), FALSE);
|
14192
|
826 gaim_request_field_group_add_field(group, field);
|
14237
|
827 field = gaim_request_field_bool_new("prepend", _("Prepend Key to Body"), FALSE);
|
|
828 gaim_request_field_group_add_field(group, field);
|
|
829 field = gaim_request_field_string_new("key", _("Encryption Key (hex)"), NULL, FALSE);
|
|
830 gaim_request_field_group_add_field(group, field);
|
|
831
|
14192
|
832
|
|
833 gaim_request_fields(gc, _("Send a custom packet"),
|
|
834 _("Send a custom packet"), NULL, fields,
|
|
835 _("Send"), G_CALLBACK(_qq_send_custom_packet_cb),
|
|
836 _("Cancel"), NULL,
|
|
837 gc);
|
|
838 }
|
14237
|
839 */
|
14192
|
840
|
|
841 /* protocol related menus */
|
|
842 static GList *_qq_actions(GaimPlugin *plugin, gpointer context)
|
|
843 {
|
|
844 GList *m;
|
|
845 GaimPluginAction *act;
|
|
846
|
|
847 m = NULL;
|
|
848 act = gaim_plugin_action_new(_("Modify My Information"), _qq_menu_modify_my_info);
|
|
849 m = g_list_append(m, act);
|
|
850
|
14265
|
851 act = gaim_plugin_action_new(_("Change My Face"), _qq_menu_change_face);
|
|
852 m = g_list_append(m, act);
|
|
853
|
14192
|
854 act = gaim_plugin_action_new(_("Change Password"), _qq_menu_change_password);
|
|
855 m = g_list_append(m, act);
|
|
856
|
|
857 act = gaim_plugin_action_new(_("Show Login Information"), _qq_menu_show_login_info);
|
|
858 m = g_list_append(m, act);
|
|
859
|
14237
|
860 /*
|
14192
|
861 act = gaim_plugin_action_new(_("Send Custom Packet"), _qq_menu_send_custom_packet);
|
|
862 m = g_list_append(m, act);
|
14237
|
863 */
|
14192
|
864
|
|
865 /* XXX consider re-enabling this
|
|
866 act = gaim_plugin_action_new(_("Show System Message"), _qq_menu_show_system_message);
|
|
867 m = g_list_append(m, act);
|
|
868 */
|
|
869
|
|
870 /*
|
|
871 act = gaim_plugin_action_new(_("Qun: Search a permanent Qun"), _qq_menu_search_or_add_permanent_group);
|
|
872 m = g_list_append(m, act);
|
|
873
|
|
874 act = gaim_plugin_action_new(_("Qun: Create a permanent Qun"), _qq_menu_create_permanent_group);
|
|
875 m = g_list_append(m, act);
|
|
876 */
|
|
877
|
|
878 return m;
|
|
879 }
|
|
880
|
|
881 /* chat-related (QQ Qun) menu shown up with right-click */
|
14268
|
882 /* TODO re-enable this
|
14192
|
883 static GList *_qq_chat_menu(GaimBlistNode *node)
|
|
884 {
|
|
885 GList *m;
|
|
886 GaimMenuAction *act;
|
|
887
|
|
888 m = NULL;
|
|
889 act = gaim_menu_action_new(_("Exit this QQ Qun"), GAIM_CALLBACK(_qq_menu_unsubscribe_group), NULL, NULL);
|
|
890 m = g_list_append(m, act);
|
|
891
|
|
892 act = gaim_menu_action_new(_("Show Details"), GAIM_CALLBACK(_qq_menu_manage_group), NULL, NULL);
|
|
893 m = g_list_append(m, act);
|
|
894
|
|
895 return m;
|
|
896 }
|
|
897 */
|
|
898 /* buddy-related menu shown up with right-click */
|
14268
|
899 /* TODO re-enable this
|
14192
|
900 static GList *_qq_buddy_menu(GaimBlistNode * node)
|
|
901 {
|
|
902 GList *m;
|
|
903
|
|
904 if(GAIM_BLIST_NODE_IS_CHAT(node))
|
|
905 return _qq_chat_menu(node);
|
|
906
|
|
907 m = NULL;
|
|
908 */
|
|
909 /* TODO : not working, temp commented out by gfhuang
|
|
910
|
|
911 act = gaim_menu_action_new(_("Block this buddy"), GAIM_CALLBACK(_qq_menu_block_buddy), NULL, NULL); //add NULL by gfhuang
|
|
912 m = g_list_append(m, act);
|
|
913 // if (q_bud && is_online(q_bud->status)) {
|
|
914 act = gaim_menu_action_new(_("Send File"), GAIM_CALLBACK(_qq_menu_send_file), NULL, NULL); //add NULL by gfhuang
|
|
915 m = g_list_append(m, act);
|
|
916 // }
|
|
917 */
|
|
918 /*
|
|
919 return m;
|
|
920 }
|
|
921 */
|
|
922
|
|
923
|
|
924 static void _qq_keep_alive(GaimConnection *gc)
|
|
925 {
|
|
926 qq_group *group;
|
|
927 qq_data *qd;
|
|
928 GList *list;
|
|
929
|
|
930 g_return_if_fail(gc != NULL);
|
|
931 if (NULL == (qd = (qq_data *) gc->proto_data))
|
|
932 return;
|
|
933
|
|
934 list = qd->groups;
|
|
935 while (list != NULL) {
|
|
936 group = (qq_group *) list->data;
|
|
937 if (group->my_status == QQ_GROUP_MEMBER_STATUS_IS_MEMBER ||
|
|
938 group->my_status == QQ_GROUP_MEMBER_STATUS_IS_ADMIN)
|
|
939 /* no need to get info time and time again, online members enough */
|
|
940 qq_send_cmd_group_get_online_member(gc, group);
|
|
941
|
|
942 list = list->next;
|
|
943 }
|
|
944
|
|
945 qq_send_packet_keep_alive(gc);
|
|
946
|
|
947 }
|
|
948
|
|
949 /* convert chat nickname to qq-uid to get this buddy info */
|
|
950 /* who is the nickname of buddy in QQ chat-room (Qun) */
|
|
951 static void _qq_get_chat_buddy_info(GaimConnection *gc, gint channel, const gchar *who)
|
|
952 {
|
|
953 gchar *gaim_name;
|
|
954 g_return_if_fail(gc != NULL && gc->proto_data != NULL && who != NULL);
|
|
955
|
|
956 gaim_name = qq_group_find_member_by_channel_and_nickname(gc, channel, who);
|
|
957 if (gaim_name != NULL)
|
|
958 _qq_get_info(gc, gaim_name);
|
|
959 }
|
|
960
|
|
961 /* convert chat nickname to qq-uid to invite individual IM to buddy */
|
|
962 /* who is the nickname of buddy in QQ chat-room (Qun) */
|
|
963 static gchar *_qq_get_chat_buddy_real_name(GaimConnection *gc, gint channel, const gchar *who)
|
|
964 {
|
|
965 g_return_val_if_fail(gc != NULL && gc->proto_data != NULL && who != NULL, NULL);
|
|
966 return qq_group_find_member_by_channel_and_nickname(gc, channel, who);
|
|
967 }
|
|
968
|
|
969 void qq_function_not_implemented(GaimConnection *gc)
|
|
970 {
|
|
971 gaim_notify_warning(gc, NULL,
|
|
972 _("This function has not be implemented yet"), _("Please wait for new version"));
|
|
973 }
|
|
974
|
|
975 GaimPlugin *my_protocol = NULL;
|
|
976 static GaimPluginProtocolInfo prpl_info = {
|
|
977 OPT_PROTO_CHAT_TOPIC | OPT_PROTO_USE_POINTSIZE,
|
|
978 NULL, /* user_splits */
|
|
979 NULL, /* protocol_options */
|
|
980 NO_BUDDY_ICONS, /* icon_spec */
|
|
981 _qq_list_icon, /* list_icon */
|
|
982 _qq_list_emblems, /* list_emblems */
|
|
983 _qq_status_text, /* status_text */
|
|
984 _qq_tooltip_text, /* tooltip_text */
|
|
985 _qq_away_states, /* away_states */
|
|
986 NULL, /* blist_node_menu */
|
|
987 qq_chat_info, /* chat_info */
|
|
988 NULL, /* chat_info_defaults */
|
|
989 _qq_login, /* login */
|
|
990 _qq_close, /* close */
|
|
991 _qq_send_im, /* send_im */
|
|
992 NULL, /* set_info */
|
|
993 NULL, /* send_typing */
|
|
994 _qq_get_info, /* get_info */
|
|
995 _qq_set_away, /* set_away */
|
|
996 NULL, /* set_idle */
|
|
997 NULL, /* change_passwd */
|
|
998 qq_add_buddy, /* add_buddy */
|
|
999 NULL, /* add_buddies */
|
|
1000 qq_remove_buddy, /* remove_buddy */
|
|
1001 NULL, /* remove_buddies */
|
|
1002 NULL, /* add_permit */
|
|
1003 NULL, /* add_deny */
|
|
1004 NULL, /* rem_permit */
|
|
1005 NULL, /* rem_deny */
|
|
1006 NULL, /* set_permit_deny */
|
|
1007 qq_group_join, /* join_chat */
|
|
1008 NULL, /* reject chat invite */
|
|
1009 NULL, /* get_chat_name */
|
|
1010 NULL, /* chat_invite */
|
|
1011 NULL, /* chat_leave */
|
|
1012 NULL, /* chat_whisper */
|
|
1013 _qq_chat_send, /* chat_send */
|
|
1014 _qq_keep_alive, /* keepalive */
|
|
1015 NULL, /* register_user */
|
|
1016 _qq_get_chat_buddy_info, /* get_cb_info */
|
|
1017 NULL, /* get_cb_away */
|
|
1018 NULL, /* alias_buddy */
|
|
1019 NULL, /* group_buddy */
|
|
1020 NULL, /* rename_group */
|
|
1021 NULL, /* buddy_free */
|
|
1022 NULL, /* convo_closed */
|
|
1023 NULL, /* normalize */
|
|
1024 NULL, /* set_buddy_icon */
|
|
1025 NULL, /* remove_group */
|
|
1026 _qq_get_chat_buddy_real_name, /* get_cb_real_name */
|
|
1027 NULL, /* set_chat_topic */
|
|
1028 NULL, /* find_blist_chat */
|
|
1029 qq_roomlist_get_list, /* roomlist_get_list */
|
|
1030 qq_roomlist_cancel, /* roomlist_cancel */
|
|
1031 NULL, /* roomlist_expand_category */
|
|
1032 NULL, /* can_receive_file */
|
|
1033 qq_send_file, /* send_file */
|
|
1034 NULL, /* new xfer */
|
|
1035 NULL, /* offline_message */
|
|
1036 NULL, /* GaimWhiteboardPrplOps */
|
|
1037 };
|
|
1038
|
|
1039 static GaimPluginInfo info = {
|
|
1040 GAIM_PLUGIN_MAGIC,
|
|
1041 GAIM_MAJOR_VERSION,
|
|
1042 GAIM_MINOR_VERSION,
|
|
1043 GAIM_PLUGIN_PROTOCOL, /**< type */
|
|
1044 NULL, /**< ui_requirement */
|
|
1045 0, /**< flags */
|
|
1046 NULL, /**< dependencies */
|
|
1047 GAIM_PRIORITY_DEFAULT, /**< priority */
|
|
1048
|
|
1049 "prpl-qq", /**< id */
|
|
1050 "QQ", /**< name */
|
|
1051 VERSION, /**< version */
|
|
1052 /** summary */
|
|
1053 N_("QQ Protocol Plugin"),
|
|
1054 /** description */
|
|
1055 N_("QQ Protocol Plugin"),
|
|
1056 OPENQ_AUTHOR, /**< author */
|
|
1057 OPENQ_WEBSITE, /**< homepage */
|
|
1058
|
|
1059 NULL, /**< load */
|
|
1060 NULL, /**< unload */
|
|
1061 NULL, /**< destroy */
|
|
1062
|
|
1063 NULL, /**< ui_info */
|
|
1064 &prpl_info, /**< extra_info */
|
|
1065 NULL, /**< prefs_info */
|
|
1066 _qq_actions
|
|
1067 };
|
|
1068
|
|
1069
|
|
1070 static void init_plugin(GaimPlugin *plugin)
|
|
1071 {
|
|
1072 GaimAccountOption *option;
|
|
1073
|
|
1074 option = gaim_account_option_bool_new(_("Login in TCP"), "use_tcp", FALSE);
|
|
1075 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option);
|
|
1076
|
|
1077 option = gaim_account_option_bool_new(_("Login Hidden"), "hidden", FALSE);
|
|
1078 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option);
|
|
1079
|
|
1080 option = gaim_account_option_string_new(_("QQ Server"), "server", NULL);
|
|
1081 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option);
|
|
1082
|
|
1083 option = gaim_account_option_string_new(_("QQ Port"), "port", NULL);
|
|
1084 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option);
|
|
1085
|
|
1086 my_protocol = plugin;
|
|
1087
|
|
1088 gaim_prefs_add_none("/plugins/prpl/qq");
|
|
1089 gaim_prefs_add_bool("/plugins/prpl/qq/show_status_by_icon", TRUE);
|
|
1090 gaim_prefs_add_bool("/plugins/prpl/qq/show_fake_video", FALSE);
|
|
1091 gaim_prefs_add_bool("/plugins/prpl/qq/prompt_for_missing_packet", TRUE);
|
|
1092 gaim_prefs_add_bool("/plugins/prpl/qq/prompt_group_msg_on_recv", TRUE);
|
|
1093 }
|
|
1094
|
|
1095 GAIM_INIT_PLUGIN(qq, init_plugin, info);
|