8849
|
1 /*
|
|
2
|
|
3 silcgaim.c
|
|
4
|
|
5 Author: Pekka Riikonen <priikone@silcnet.org>
|
|
6
|
|
7 Copyright (C) 2004 Pekka Riikonen
|
|
8
|
|
9 This program is free software; you can redistribute it and/or modify
|
|
10 it under the terms of the GNU General Public License as published by
|
|
11 the Free Software Foundation; version 2 of the License.
|
|
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 */
|
|
19
|
|
20 #include "silcincludes.h"
|
|
21 #include "silcclient.h"
|
|
22 #include "silcgaim.h"
|
|
23
|
|
24 extern SilcClientOperations ops;
|
|
25 static GaimPlugin *silc_plugin = NULL;
|
|
26
|
|
27 static const char *
|
|
28 silcgaim_list_icon(GaimAccount *a, GaimBuddy *b)
|
|
29 {
|
|
30 return (const char *)"silc";
|
|
31 }
|
|
32
|
|
33 static void
|
|
34 silcgaim_list_emblems(GaimBuddy *b, char **se, char **sw,
|
|
35 char **nw, char **ne)
|
|
36 {
|
|
37 }
|
|
38
|
|
39 static GList *
|
|
40 silcgaim_away_states(GaimConnection *gc)
|
|
41 {
|
|
42 GList *st = NULL;
|
|
43
|
|
44 st = g_list_append(st, _("Online"));
|
|
45 st = g_list_append(st, _("Hyper Active"));
|
|
46 st = g_list_append(st, _("Away"));
|
|
47 st = g_list_append(st, _("Busy"));
|
|
48 st = g_list_append(st, _("Indisposed"));
|
|
49 st = g_list_append(st, _("Wake Me Up"));
|
|
50
|
|
51 return st;
|
|
52 }
|
|
53
|
|
54 static void
|
|
55 silcgaim_set_away(GaimConnection *gc, const char *state, const char *msg)
|
|
56 {
|
|
57 SilcGaim sg = gc->proto_data;
|
|
58 SilcUInt32 mode;
|
|
59 SilcBuffer idp;
|
|
60 unsigned char mb[4];
|
|
61
|
|
62 if (!state)
|
|
63 return;
|
|
64 if (!sg->conn)
|
|
65 return;
|
|
66
|
|
67 mode = sg->conn->local_entry->mode;
|
|
68 mode &= ~(SILC_UMODE_GONE |
|
|
69 SILC_UMODE_HYPER |
|
|
70 SILC_UMODE_BUSY |
|
|
71 SILC_UMODE_INDISPOSED |
|
|
72 SILC_UMODE_PAGE);
|
|
73
|
|
74 if (!strcmp(state, _("Hyper Active")))
|
|
75 mode |= SILC_UMODE_HYPER;
|
|
76 else if (!strcmp(state, _("Away")))
|
|
77 mode |= SILC_UMODE_GONE;
|
|
78 else if (!strcmp(state, _("Busy")))
|
|
79 mode |= SILC_UMODE_BUSY;
|
|
80 else if (!strcmp(state, _("Indisposed")))
|
|
81 mode |= SILC_UMODE_INDISPOSED;
|
|
82 else if (!strcmp(state, _("Wake Me Up")))
|
|
83 mode |= SILC_UMODE_PAGE;
|
|
84
|
|
85 /* Send UMODE */
|
|
86 idp = silc_id_payload_encode(sg->conn->local_id, SILC_ID_CLIENT);
|
|
87 SILC_PUT32_MSB(mode, mb);
|
|
88 silc_client_command_send(sg->client, sg->conn, SILC_COMMAND_UMODE,
|
|
89 ++sg->conn->cmd_ident, 2,
|
|
90 1, idp->data, idp->len,
|
|
91 2, mb, sizeof(mb));
|
|
92 silc_buffer_free(idp);
|
|
93 }
|
|
94
|
|
95
|
|
96 /*************************** Connection Routines *****************************/
|
|
97
|
|
98 static void
|
|
99 silcgaim_keepalive(GaimConnection *gc)
|
|
100 {
|
|
101 SilcGaim sg = gc->proto_data;
|
|
102 silc_client_send_packet(sg->client, sg->conn, SILC_PACKET_HEARTBEAT,
|
|
103 NULL, 0);
|
|
104 }
|
|
105
|
|
106 static int
|
|
107 silcgaim_scheduler(gpointer *context)
|
|
108 {
|
|
109 SilcGaim sg = (SilcGaim)context;
|
|
110 silc_client_run_one(sg->client);
|
|
111 return 1;
|
|
112 }
|
|
113
|
|
114 static void
|
|
115 silcgaim_nickname_parse(const char *nickname,
|
|
116 char **ret_nickname)
|
|
117 {
|
|
118 silc_parse_userfqdn(nickname, ret_nickname, NULL);
|
|
119 }
|
|
120
|
|
121 static void
|
|
122 silcgaim_login_connected(gpointer data, gint source, GaimInputCondition cond)
|
|
123 {
|
|
124 GaimConnection *gc = data;
|
|
125 SilcGaim sg = gc->proto_data;
|
|
126 SilcClient client = sg->client;
|
|
127 SilcClientConnection conn;
|
|
128 GaimAccount *account = sg->account;
|
|
129 SilcClientConnectionParams params;
|
|
130 const char *dfile;
|
|
131
|
|
132 if (source < 0) {
|
|
133 gaim_connection_error(gc, _("Connection failed"));
|
|
134 return;
|
|
135 }
|
|
136 if (!g_list_find(gaim_connections_get_all(), gc)) {
|
|
137 close(source);
|
|
138 g_source_remove(sg->scheduler);
|
|
139 silc_client_stop(sg->client);
|
|
140 silc_client_free(sg->client);
|
|
141 silc_free(sg);
|
|
142 return;
|
|
143 }
|
|
144
|
|
145 /* Get session detachment data, if available */
|
|
146 memset(¶ms, 0, sizeof(params));
|
|
147 dfile = silcgaim_session_file(gaim_account_get_username(sg->account));
|
|
148 params.detach_data = silc_file_readfile(dfile, ¶ms.detach_data_len);
|
|
149 if (params.detach_data)
|
|
150 params.detach_data[params.detach_data_len] = 0;
|
|
151
|
|
152 /* Add connection to SILC client library */
|
|
153 conn = silc_client_add_connection(
|
|
154 sg->client, ¶ms,
|
|
155 (char *)gaim_account_get_string(account, "server",
|
|
156 "silc.silcnet.org"),
|
|
157 gaim_account_get_int(account, "port", 706), sg);
|
|
158 if (!conn) {
|
|
159 gaim_connection_error(gc, _("Cannot initialize SILC Client connection"));
|
|
160 gc->proto_data = NULL;
|
|
161 return;
|
|
162 }
|
|
163 sg->conn = conn;
|
|
164
|
|
165 /* Progress */
|
|
166 if (params.detach_data) {
|
|
167 gaim_connection_update_progress(gc, _("Resuming session"), 2, 5);
|
|
168 sg->resuming = TRUE;
|
|
169 } else {
|
|
170 gaim_connection_update_progress(gc, _("Performing key exchange"), 2, 5);
|
|
171 }
|
|
172
|
|
173 /* Perform SILC Key Exchange. The "silc_connected" will be called
|
|
174 eventually. */
|
|
175 silc_client_start_key_exchange(sg->client, sg->conn, source);
|
|
176
|
|
177 /* Set default attributes */
|
|
178 if (!gaim_account_get_bool(account, "reject-attrs", FALSE)) {
|
|
179 SilcUInt32 mask;
|
|
180 const char *tmp;
|
|
181 #ifdef HAVE_SYS_UTSNAME_H
|
|
182 struct utsname u;
|
|
183 #endif
|
|
184
|
|
185 mask = SILC_ATTRIBUTE_MOOD_NORMAL;
|
|
186 silc_client_attribute_add(client, conn,
|
|
187 SILC_ATTRIBUTE_STATUS_MOOD,
|
|
188 SILC_32_TO_PTR(mask),
|
|
189 sizeof(SilcUInt32));
|
|
190 mask = SILC_ATTRIBUTE_CONTACT_CHAT;
|
|
191 silc_client_attribute_add(client, conn,
|
|
192 SILC_ATTRIBUTE_PREFERRED_CONTACT,
|
|
193 SILC_32_TO_PTR(mask),
|
|
194 sizeof(SilcUInt32));
|
|
195 #ifdef HAVE_SYS_UTSNAME_H
|
|
196 if (!uname(&u)) {
|
|
197 SilcAttributeObjDevice dev;
|
|
198 memset(&dev, 0, sizeof(dev));
|
|
199 dev.type = SILC_ATTRIBUTE_DEVICE_COMPUTER;
|
|
200 dev.version = u.release;
|
|
201 dev.model = u.sysname;
|
|
202 silc_client_attribute_add(client, conn,
|
|
203 SILC_ATTRIBUTE_DEVICE_INFO,
|
|
204 (void *)&dev, sizeof(dev));
|
|
205 }
|
|
206 #endif
|
|
207 #ifdef _WIN32
|
|
208 tmp = _tzname[0];
|
|
209 #else
|
|
210 tmp = tzname[0];
|
|
211 #endif
|
|
212 silc_client_attribute_add(client, conn,
|
|
213 SILC_ATTRIBUTE_TIMEZONE,
|
|
214 (void *)tmp, strlen(tmp));
|
|
215 }
|
|
216
|
|
217 silc_free(params.detach_data);
|
|
218 }
|
|
219
|
|
220 static void
|
|
221 silcgaim_login(GaimAccount *account)
|
|
222 {
|
|
223 SilcGaim sg;
|
|
224 SilcClient client;
|
|
225 SilcClientParams params;
|
|
226 GaimConnection *gc;
|
|
227
|
|
228 gc = account->gc;
|
|
229 if (!gc)
|
|
230 return;
|
|
231 gc->proto_data = NULL;
|
|
232
|
|
233 memset(¶ms, 0, sizeof(params));
|
|
234 strcat(params.nickname_format, "%n@%h%a");
|
|
235 params.nickname_parse = silcgaim_nickname_parse;
|
|
236 params.ignore_requested_attributes =
|
|
237 gaim_account_get_bool(account, "reject-attrs", FALSE);
|
|
238
|
|
239 /* Allocate SILC client */
|
|
240 client = silc_client_alloc(&ops, ¶ms, gc, NULL);
|
|
241 if (!client) {
|
|
242 gaim_connection_error(gc, _("Out of memory"));
|
|
243 return;
|
|
244 }
|
|
245
|
|
246 /* Get username, real name and local hostname for SILC library */
|
|
247 if (gaim_account_get_username(account)) {
|
|
248 client->username = strdup(gaim_account_get_username(account));
|
|
249 } else {
|
|
250 client->username = silc_get_username();
|
|
251 gaim_account_set_username(account, client->username);
|
|
252 }
|
|
253 if (gaim_account_get_user_info(account)) {
|
|
254 client->realname = strdup(gaim_account_get_user_info(account));
|
|
255 } else {
|
|
256 client->realname = silc_get_real_name();
|
|
257 gaim_account_set_user_info(account, client->realname);
|
|
258 }
|
|
259 client->hostname = silc_net_localhost();
|
|
260
|
|
261 gaim_connection_set_display_name(gc, client->username);
|
|
262
|
|
263 /* Init SILC client */
|
|
264 if (!silc_client_init(client)) {
|
|
265 gaim_connection_error(gc, ("Cannot initialize SILC protocol"));
|
|
266 return;
|
|
267 }
|
|
268
|
|
269 /* Check the ~/.silc dir and create it, and new key pair if necessary. */
|
|
270 if (!silcgaim_check_silc_dir(gc)) {
|
|
271 gaim_connection_error(gc, ("Cannot find/access ~/.silc directory"));
|
|
272 return;
|
|
273 }
|
|
274
|
|
275 /* Progress */
|
|
276 gaim_connection_update_progress(gc, _("Connecting to SILC Server"), 1, 5);
|
|
277
|
|
278 /* Load SILC key pair */
|
|
279 if (!silc_load_key_pair(gaim_prefs_get_string("/plugins/prpl/silc/pubkey"),
|
|
280 gaim_prefs_get_string("/plugins/prpl/silc/privkey"),
|
9272
|
281 (account->password == NULL) ? "" : account->password, &client->pkcs,
|
|
282 &client->public_key, &client->private_key)) {
|
8849
|
283 gaim_connection_error(gc, ("Could not load SILC key pair"));
|
|
284 return;
|
|
285 }
|
|
286
|
|
287 sg = silc_calloc(1, sizeof(*sg));
|
|
288 if (!sg)
|
|
289 return;
|
|
290 memset(sg, 0, sizeof(*sg));
|
|
291 sg->client = client;
|
|
292 sg->gc = gc;
|
|
293 sg->account = account;
|
|
294 gc->proto_data = sg;
|
|
295
|
|
296 /* Connect to the SILC server */
|
|
297 if (gaim_proxy_connect(account,
|
|
298 gaim_account_get_string(account, "server",
|
|
299 "silc.silcnet.org"),
|
|
300 gaim_account_get_int(account, "port", 706),
|
|
301 silcgaim_login_connected, gc)) {
|
|
302 gaim_connection_error(gc, ("Unable to create connection"));
|
|
303 return;
|
|
304 }
|
|
305
|
|
306 /* Schedule SILC using Glib's event loop */
|
9353
|
307 #ifndef _WIN32
|
8849
|
308 sg->scheduler = g_timeout_add(5, (GSourceFunc)silcgaim_scheduler, sg);
|
9353
|
309 #else
|
|
310 sg->scheduler = g_timeout_add(300, (GSourceFunc)silcgaim_scheduler, sg);
|
|
311 #endif
|
8849
|
312 }
|
|
313
|
|
314 static int
|
|
315 silcgaim_close_final(gpointer *context)
|
|
316 {
|
|
317 SilcGaim sg = (SilcGaim)context;
|
|
318 silc_client_stop(sg->client);
|
|
319 silc_client_free(sg->client);
|
|
320 silc_free(sg);
|
|
321 return 0;
|
|
322 }
|
|
323
|
|
324 static void
|
|
325 silcgaim_close(GaimConnection *gc)
|
|
326 {
|
9272
|
327 GList *l;
|
|
328 GaimConversation *conv;
|
8849
|
329 SilcGaim sg = gc->proto_data;
|
|
330 if (!sg)
|
|
331 return;
|
|
332
|
9272
|
333 /* Close all conversations for this connection */
|
|
334 for (l = gaim_get_conversations(); l; l = l->next)
|
|
335 {
|
|
336 conv = l->data;
|
|
337 if (gc == conv->account->gc)
|
|
338 gaim_conversation_destroy(conv);
|
|
339 }
|
8849
|
340
|
|
341 /* Send QUIT */
|
|
342 silc_client_command_call(sg->client, sg->conn, NULL,
|
9353
|
343 "QUIT", "Download Gaim: " GAIM_WEBSITE, NULL);
|
8849
|
344
|
|
345 if (sg->conn)
|
|
346 silc_client_close_connection(sg->client, sg->conn);
|
|
347
|
|
348 g_source_remove(sg->scheduler);
|
|
349 g_timeout_add(1, (GSourceFunc)silcgaim_close_final, sg);
|
|
350 }
|
|
351
|
|
352
|
|
353 /****************************** Protocol Actions *****************************/
|
|
354
|
|
355 static void
|
|
356 silcgaim_attrs_cancel(GaimConnection *gc, GaimRequestFields *fields)
|
|
357 {
|
|
358 /* Nothing */
|
|
359 }
|
|
360
|
|
361 static void
|
|
362 silcgaim_attrs_cb(GaimConnection *gc, GaimRequestFields *fields)
|
|
363 {
|
|
364 SilcGaim sg = gc->proto_data;
|
|
365 SilcClient client = sg->client;
|
|
366 SilcClientConnection conn = sg->conn;
|
|
367 GaimRequestField *f;
|
|
368 char *tmp;
|
|
369 SilcUInt32 tmp_len, mask;
|
|
370 SilcAttributeObjService service;
|
|
371 SilcAttributeObjDevice dev;
|
|
372 SilcVCardStruct vcard;
|
|
373 const char *val;
|
|
374
|
|
375 sg = gc->proto_data;
|
|
376 if (!sg)
|
|
377 return;
|
|
378
|
|
379 memset(&service, 0, sizeof(service));
|
|
380 memset(&dev, 0, sizeof(dev));
|
|
381 memset(&vcard, 0, sizeof(vcard));
|
|
382
|
|
383 silc_client_attribute_del(client, conn,
|
|
384 SILC_ATTRIBUTE_USER_INFO, NULL);
|
|
385 silc_client_attribute_del(client, conn,
|
|
386 SILC_ATTRIBUTE_SERVICE, NULL);
|
|
387 silc_client_attribute_del(client, conn,
|
|
388 SILC_ATTRIBUTE_STATUS_MOOD, NULL);
|
|
389 silc_client_attribute_del(client, conn,
|
|
390 SILC_ATTRIBUTE_STATUS_FREETEXT, NULL);
|
|
391 silc_client_attribute_del(client, conn,
|
|
392 SILC_ATTRIBUTE_STATUS_MESSAGE, NULL);
|
|
393 silc_client_attribute_del(client, conn,
|
|
394 SILC_ATTRIBUTE_PREFERRED_LANGUAGE, NULL);
|
|
395 silc_client_attribute_del(client, conn,
|
|
396 SILC_ATTRIBUTE_PREFERRED_CONTACT, NULL);
|
|
397 silc_client_attribute_del(client, conn,
|
|
398 SILC_ATTRIBUTE_TIMEZONE, NULL);
|
|
399 silc_client_attribute_del(client, conn,
|
|
400 SILC_ATTRIBUTE_GEOLOCATION, NULL);
|
|
401 silc_client_attribute_del(client, conn,
|
|
402 SILC_ATTRIBUTE_DEVICE_INFO, NULL);
|
|
403
|
|
404 /* Set mood */
|
|
405 mask = 0;
|
|
406 f = gaim_request_fields_get_field(fields, "mood_normal");
|
|
407 if (f && gaim_request_field_bool_get_value(f))
|
|
408 mask |= SILC_ATTRIBUTE_MOOD_NORMAL;
|
|
409 f = gaim_request_fields_get_field(fields, "mood_happy");
|
|
410 if (f && gaim_request_field_bool_get_value(f))
|
|
411 mask |= SILC_ATTRIBUTE_MOOD_HAPPY;
|
|
412 f = gaim_request_fields_get_field(fields, "mood_sad");
|
|
413 if (f && gaim_request_field_bool_get_value(f))
|
|
414 mask |= SILC_ATTRIBUTE_MOOD_SAD;
|
|
415 f = gaim_request_fields_get_field(fields, "mood_angry");
|
|
416 if (f && gaim_request_field_bool_get_value(f))
|
|
417 mask |= SILC_ATTRIBUTE_MOOD_ANGRY;
|
|
418 f = gaim_request_fields_get_field(fields, "mood_jealous");
|
|
419 if (f && gaim_request_field_bool_get_value(f))
|
|
420 mask |= SILC_ATTRIBUTE_MOOD_JEALOUS;
|
|
421 f = gaim_request_fields_get_field(fields, "mood_ashamed");
|
|
422 if (f && gaim_request_field_bool_get_value(f))
|
|
423 mask |= SILC_ATTRIBUTE_MOOD_ASHAMED;
|
|
424 f = gaim_request_fields_get_field(fields, "mood_invincible");
|
|
425 if (f && gaim_request_field_bool_get_value(f))
|
|
426 mask |= SILC_ATTRIBUTE_MOOD_INVINCIBLE;
|
|
427 f = gaim_request_fields_get_field(fields, "mood_inlove");
|
|
428 if (f && gaim_request_field_bool_get_value(f))
|
|
429 mask |= SILC_ATTRIBUTE_MOOD_INLOVE;
|
|
430 f = gaim_request_fields_get_field(fields, "mood_sleepy");
|
|
431 if (f && gaim_request_field_bool_get_value(f))
|
|
432 mask |= SILC_ATTRIBUTE_MOOD_SLEEPY;
|
|
433 f = gaim_request_fields_get_field(fields, "mood_bored");
|
|
434 if (f && gaim_request_field_bool_get_value(f))
|
|
435 mask |= SILC_ATTRIBUTE_MOOD_BORED;
|
|
436 f = gaim_request_fields_get_field(fields, "mood_excited");
|
|
437 if (f && gaim_request_field_bool_get_value(f))
|
|
438 mask |= SILC_ATTRIBUTE_MOOD_EXCITED;
|
|
439 f = gaim_request_fields_get_field(fields, "mood_anxious");
|
|
440 if (f && gaim_request_field_bool_get_value(f))
|
|
441 mask |= SILC_ATTRIBUTE_MOOD_ANXIOUS;
|
|
442 silc_client_attribute_add(client, conn,
|
|
443 SILC_ATTRIBUTE_STATUS_MOOD,
|
|
444 SILC_32_TO_PTR(mask),
|
|
445 sizeof(SilcUInt32));
|
|
446
|
|
447 /* Set preferred contact */
|
|
448 mask = 0;
|
|
449 f = gaim_request_fields_get_field(fields, "contact_chat");
|
|
450 if (f && gaim_request_field_bool_get_value(f))
|
|
451 mask |= SILC_ATTRIBUTE_CONTACT_CHAT;
|
|
452 f = gaim_request_fields_get_field(fields, "contact_email");
|
|
453 if (f && gaim_request_field_bool_get_value(f))
|
|
454 mask |= SILC_ATTRIBUTE_CONTACT_EMAIL;
|
|
455 f = gaim_request_fields_get_field(fields, "contact_call");
|
|
456 if (f && gaim_request_field_bool_get_value(f))
|
|
457 mask |= SILC_ATTRIBUTE_CONTACT_CALL;
|
|
458 f = gaim_request_fields_get_field(fields, "contact_sms");
|
|
459 if (f && gaim_request_field_bool_get_value(f))
|
|
460 mask |= SILC_ATTRIBUTE_CONTACT_SMS;
|
|
461 f = gaim_request_fields_get_field(fields, "contact_mms");
|
|
462 if (f && gaim_request_field_bool_get_value(f))
|
|
463 mask |= SILC_ATTRIBUTE_CONTACT_MMS;
|
|
464 f = gaim_request_fields_get_field(fields, "contact_video");
|
|
465 if (f && gaim_request_field_bool_get_value(f))
|
|
466 mask |= SILC_ATTRIBUTE_CONTACT_VIDEO;
|
|
467 if (mask)
|
|
468 silc_client_attribute_add(client, conn,
|
|
469 SILC_ATTRIBUTE_PREFERRED_CONTACT,
|
|
470 SILC_32_TO_PTR(mask),
|
|
471 sizeof(SilcUInt32));
|
|
472
|
|
473 /* Set status text */
|
|
474 val = NULL;
|
|
475 f = gaim_request_fields_get_field(fields, "status_text");
|
|
476 if (f)
|
|
477 val = gaim_request_field_string_get_value(f);
|
|
478 if (val && *val)
|
|
479 silc_client_attribute_add(client, conn,
|
|
480 SILC_ATTRIBUTE_STATUS_FREETEXT,
|
|
481 (void *)val, strlen(val));
|
|
482
|
|
483 /* Set vcard */
|
|
484 val = NULL;
|
|
485 f = gaim_request_fields_get_field(fields, "vcard");
|
|
486 if (f)
|
|
487 val = gaim_request_field_string_get_value(f);
|
|
488 if (val && *val) {
|
|
489 gaim_prefs_set_string("/plugins/prpl/silc/vcard", val);
|
|
490 gaim_prefs_sync();
|
|
491 tmp = silc_file_readfile(val, &tmp_len);
|
|
492 if (tmp) {
|
|
493 tmp[tmp_len] = 0;
|
|
494 if (silc_vcard_decode(tmp, tmp_len, &vcard))
|
|
495 silc_client_attribute_add(client, conn,
|
|
496 SILC_ATTRIBUTE_USER_INFO,
|
|
497 (void *)&vcard,
|
|
498 sizeof(vcard));
|
|
499 }
|
|
500 silc_vcard_free(&vcard);
|
|
501 silc_free(tmp);
|
|
502 }
|
|
503
|
|
504 #ifdef HAVE_SYS_UTSNAME_H
|
|
505 /* Set device info */
|
|
506 f = gaim_request_fields_get_field(fields, "device");
|
|
507 if (f && gaim_request_field_bool_get_value(f)) {
|
|
508 struct utsname u;
|
|
509 if (!uname(&u)) {
|
|
510 dev.type = SILC_ATTRIBUTE_DEVICE_COMPUTER;
|
|
511 dev.version = u.release;
|
|
512 dev.model = u.sysname;
|
|
513 silc_client_attribute_add(client, conn,
|
|
514 SILC_ATTRIBUTE_DEVICE_INFO,
|
|
515 (void *)&dev, sizeof(dev));
|
|
516 }
|
|
517 }
|
|
518 #endif
|
|
519
|
|
520 /* Set timezone */
|
|
521 val = NULL;
|
|
522 f = gaim_request_fields_get_field(fields, "timezone");
|
|
523 if (f)
|
|
524 val = gaim_request_field_string_get_value(f);
|
|
525 if (val && *val)
|
|
526 silc_client_attribute_add(client, conn,
|
|
527 SILC_ATTRIBUTE_TIMEZONE,
|
|
528 (void *)val, strlen(val));
|
|
529 }
|
|
530
|
|
531 static void
|
9015
|
532 silcgaim_attrs(GaimPluginAction *action)
|
8849
|
533 {
|
9015
|
534 GaimConnection *gc = (GaimConnection *) action->context;
|
8849
|
535 SilcGaim sg = gc->proto_data;
|
|
536 SilcClient client = sg->client;
|
|
537 SilcClientConnection conn = sg->conn;
|
|
538 GaimRequestFields *fields;
|
|
539 GaimRequestFieldGroup *g;
|
|
540 GaimRequestField *f;
|
|
541 SilcHashTable attrs;
|
|
542 SilcAttributePayload attr;
|
|
543 gboolean mnormal = TRUE, mhappy = FALSE, msad = FALSE,
|
|
544 mangry = FALSE, mjealous = FALSE, mashamed = FALSE,
|
|
545 minvincible = FALSE, minlove = FALSE, msleepy = FALSE,
|
|
546 mbored = FALSE, mexcited = FALSE, manxious = FALSE;
|
|
547 gboolean cemail = FALSE, ccall = FALSE, csms = FALSE,
|
|
548 cmms = FALSE, cchat = TRUE, cvideo = FALSE;
|
|
549 gboolean device = TRUE;
|
|
550 char status[1024];
|
|
551
|
|
552 sg = gc->proto_data;
|
|
553 if (!sg)
|
|
554 return;
|
|
555
|
|
556 memset(status, 0, sizeof(status));
|
|
557
|
|
558 attrs = silc_client_attributes_get(client, conn);
|
|
559 if (attrs) {
|
|
560 if (silc_hash_table_find(attrs,
|
|
561 SILC_32_TO_PTR(SILC_ATTRIBUTE_STATUS_MOOD),
|
|
562 NULL, (void *)&attr)) {
|
|
563 SilcUInt32 mood = 0;
|
|
564 silc_attribute_get_object(attr, &mood, sizeof(mood));
|
|
565 mnormal = !mood;
|
|
566 mhappy = (mood & SILC_ATTRIBUTE_MOOD_HAPPY);
|
|
567 msad = (mood & SILC_ATTRIBUTE_MOOD_SAD);
|
|
568 mangry = (mood & SILC_ATTRIBUTE_MOOD_ANGRY);
|
|
569 mjealous = (mood & SILC_ATTRIBUTE_MOOD_JEALOUS);
|
|
570 mashamed = (mood & SILC_ATTRIBUTE_MOOD_ASHAMED);
|
|
571 minvincible = (mood & SILC_ATTRIBUTE_MOOD_INVINCIBLE);
|
|
572 minlove = (mood & SILC_ATTRIBUTE_MOOD_INLOVE);
|
|
573 msleepy = (mood & SILC_ATTRIBUTE_MOOD_SLEEPY);
|
|
574 mbored = (mood & SILC_ATTRIBUTE_MOOD_BORED);
|
|
575 mexcited = (mood & SILC_ATTRIBUTE_MOOD_EXCITED);
|
|
576 manxious = (mood & SILC_ATTRIBUTE_MOOD_ANXIOUS);
|
|
577 }
|
|
578
|
|
579 if (silc_hash_table_find(attrs,
|
|
580 SILC_32_TO_PTR(SILC_ATTRIBUTE_PREFERRED_CONTACT),
|
|
581 NULL, (void *)&attr)) {
|
|
582 SilcUInt32 contact = 0;
|
|
583 silc_attribute_get_object(attr, &contact, sizeof(contact));
|
|
584 cemail = (contact & SILC_ATTRIBUTE_CONTACT_EMAIL);
|
|
585 ccall = (contact & SILC_ATTRIBUTE_CONTACT_CALL);
|
|
586 csms = (contact & SILC_ATTRIBUTE_CONTACT_SMS);
|
|
587 cmms = (contact & SILC_ATTRIBUTE_CONTACT_MMS);
|
|
588 cchat = (contact & SILC_ATTRIBUTE_CONTACT_CHAT);
|
|
589 cvideo = (contact & SILC_ATTRIBUTE_CONTACT_VIDEO);
|
|
590 }
|
|
591
|
|
592 if (silc_hash_table_find(attrs,
|
|
593 SILC_32_TO_PTR(SILC_ATTRIBUTE_STATUS_FREETEXT),
|
|
594 NULL, (void *)&attr))
|
|
595 silc_attribute_get_object(attr, &status, sizeof(status));
|
|
596
|
|
597 if (!silc_hash_table_find(attrs,
|
|
598 SILC_32_TO_PTR(SILC_ATTRIBUTE_DEVICE_INFO),
|
|
599 NULL, (void *)&attr))
|
|
600 device = FALSE;
|
|
601 }
|
|
602
|
|
603 fields = gaim_request_fields_new();
|
|
604
|
|
605 g = gaim_request_field_group_new(NULL);
|
|
606 f = gaim_request_field_label_new("l3", _("Your Current Mood"));
|
|
607 gaim_request_field_group_add_field(g, f);
|
|
608 f = gaim_request_field_bool_new("mood_normal", _("Normal"), mnormal);
|
|
609 gaim_request_field_group_add_field(g, f);
|
|
610 f = gaim_request_field_bool_new("mood_happy", _("Happy"), mhappy);
|
|
611 gaim_request_field_group_add_field(g, f);
|
|
612 f = gaim_request_field_bool_new("mood_sad", _("Sad"), msad);
|
|
613 gaim_request_field_group_add_field(g, f);
|
|
614 f = gaim_request_field_bool_new("mood_angry", _("Angry"), mangry);
|
|
615 gaim_request_field_group_add_field(g, f);
|
|
616 f = gaim_request_field_bool_new("mood_jealous", _("Jealous"), mjealous);
|
|
617 gaim_request_field_group_add_field(g, f);
|
|
618 f = gaim_request_field_bool_new("mood_ashamed", _("Ashamed"), mashamed);
|
|
619 gaim_request_field_group_add_field(g, f);
|
|
620 f = gaim_request_field_bool_new("mood_invincible", _("Invincible"), minvincible);
|
|
621 gaim_request_field_group_add_field(g, f);
|
|
622 f = gaim_request_field_bool_new("mood_inlove", _("In Love"), minlove);
|
|
623 gaim_request_field_group_add_field(g, f);
|
|
624 f = gaim_request_field_bool_new("mood_sleepy", _("Sleepy"), msleepy);
|
|
625 gaim_request_field_group_add_field(g, f);
|
|
626 f = gaim_request_field_bool_new("mood_bored", _("Bored"), mbored);
|
|
627 gaim_request_field_group_add_field(g, f);
|
|
628 f = gaim_request_field_bool_new("mood_excited", _("Excited"), mexcited);
|
|
629 gaim_request_field_group_add_field(g, f);
|
|
630 f = gaim_request_field_bool_new("mood_anxious", _("Anxious"), manxious);
|
|
631 gaim_request_field_group_add_field(g, f);
|
|
632
|
|
633 f = gaim_request_field_label_new("l4", _("\nYour Preferred Contact Methods"));
|
|
634 gaim_request_field_group_add_field(g, f);
|
|
635 f = gaim_request_field_bool_new("contact_chat", _("Chat"), cchat);
|
|
636 gaim_request_field_group_add_field(g, f);
|
|
637 f = gaim_request_field_bool_new("contact_email", _("Email"), cemail);
|
|
638 gaim_request_field_group_add_field(g, f);
|
|
639 f = gaim_request_field_bool_new("contact_call", _("Phone"), ccall);
|
|
640 gaim_request_field_group_add_field(g, f);
|
|
641 f = gaim_request_field_bool_new("contact_sms", _("SMS"), csms);
|
|
642 gaim_request_field_group_add_field(g, f);
|
|
643 f = gaim_request_field_bool_new("contact_mms", _("MMS"), cmms);
|
|
644 gaim_request_field_group_add_field(g, f);
|
|
645 f = gaim_request_field_bool_new("contact_video", _("Video Conferencing"), cvideo);
|
|
646 gaim_request_field_group_add_field(g, f);
|
|
647 gaim_request_fields_add_group(fields, g);
|
|
648
|
|
649 g = gaim_request_field_group_new(NULL);
|
|
650 f = gaim_request_field_string_new("status_text", _("Your Current Status"),
|
|
651 status[0] ? status : NULL, TRUE);
|
|
652 gaim_request_field_group_add_field(g, f);
|
|
653 gaim_request_fields_add_group(fields, g);
|
|
654
|
|
655 g = gaim_request_field_group_new(NULL);
|
|
656 #if 0
|
|
657 f = gaim_request_field_label_new("l2", _("Online Services"));
|
|
658 gaim_request_field_group_add_field(g, f);
|
|
659 f = gaim_request_field_bool_new("services",
|
|
660 _("Let others see what services you are using"),
|
|
661 TRUE);
|
|
662 gaim_request_field_group_add_field(g, f);
|
|
663 #endif
|
|
664 #ifdef HAVE_SYS_UTSNAME_H
|
|
665 f = gaim_request_field_bool_new("device",
|
|
666 _("Let others see what computer you are using"),
|
|
667 device);
|
|
668 gaim_request_field_group_add_field(g, f);
|
|
669 #endif
|
|
670 gaim_request_fields_add_group(fields, g);
|
|
671
|
|
672 g = gaim_request_field_group_new(NULL);
|
|
673 f = gaim_request_field_string_new("vcard", _("Your VCard File"),
|
|
674 gaim_prefs_get_string("/plugins/prpl/silc/vcard"),
|
|
675 FALSE);
|
|
676 gaim_request_field_group_add_field(g, f);
|
|
677 #ifdef _WIN32
|
|
678 f = gaim_request_field_string_new("timezone", _("Timezone"), _tzname[0], FALSE);
|
|
679 #else
|
|
680 f = gaim_request_field_string_new("timezone", _("Timezone"), tzname[0], FALSE);
|
|
681 #endif
|
|
682 gaim_request_field_group_add_field(g, f);
|
|
683 gaim_request_fields_add_group(fields, g);
|
|
684
|
|
685
|
|
686 gaim_request_fields(NULL, _("User Online Status Attributes"),
|
|
687 _("User Online Status Attributes"),
|
|
688 _("You can let other users see your online status information "
|
|
689 "and your personal information. Please fill the information "
|
|
690 "you would like other users to see about yourself."),
|
|
691 fields,
|
8906
|
692 _("OK"), G_CALLBACK(silcgaim_attrs_cb),
|
|
693 _("Cancel"), G_CALLBACK(silcgaim_attrs_cancel), gc);
|
8849
|
694 }
|
|
695
|
|
696 static void
|
9015
|
697 silcgaim_detach(GaimPluginAction *action)
|
8849
|
698 {
|
9015
|
699 GaimConnection *gc = (GaimConnection *) action->context;
|
8849
|
700 SilcGaim sg;
|
|
701
|
|
702 if (!gc)
|
|
703 return;
|
|
704 sg = gc->proto_data;
|
|
705 if (!sg)
|
|
706 return;
|
|
707
|
|
708 /* Call DETACH */
|
|
709 silc_client_command_call(sg->client, sg->conn, "DETACH");
|
|
710 sg->detaching = TRUE;
|
|
711 }
|
|
712
|
|
713 static void
|
9015
|
714 silcgaim_view_motd(GaimPluginAction *action)
|
8849
|
715 {
|
9015
|
716 GaimConnection *gc = (GaimConnection *) action->context;
|
8849
|
717 SilcGaim sg;
|
9488
|
718 char *tmp;
|
8849
|
719
|
|
720 if (!gc)
|
|
721 return;
|
|
722 sg = gc->proto_data;
|
|
723 if (!sg)
|
|
724 return;
|
|
725
|
|
726 if (!sg->motd) {
|
|
727 gaim_notify_error(
|
|
728 gc, _("Message of the Day"), _("No Message of the Day available"),
|
|
729 _("There is no Message of the Day associated with this connection"));
|
|
730 return;
|
|
731 }
|
|
732
|
9488
|
733 tmp = gaim_escape_html(sg->motd);
|
|
734 gaim_notify_formatted(gc, NULL, _("Message of the Day"), NULL,
|
|
735 tmp, NULL, NULL);
|
|
736 g_free(tmp);
|
8849
|
737 }
|
|
738
|
9272
|
739 static void
|
|
740 silcgaim_change_pass(GaimPluginAction *action)
|
|
741 {
|
|
742 GaimConnection *gc = (GaimConnection *) action->context;
|
|
743 gaim_account_request_change_password(gaim_connection_get_account(gc));
|
|
744 }
|
|
745
|
|
746 static void
|
|
747 silcgaim_change_passwd(GaimConnection *gc, const char *old, const char *new)
|
|
748 {
|
|
749 silc_change_private_key_passphrase(gaim_prefs_get_string("/plugins/prpl/silc/privkey"), old, new);
|
|
750 }
|
|
751
|
|
752 static void
|
|
753 silcgaim_show_set_info(GaimPluginAction *action)
|
|
754 {
|
|
755 GaimConnection *gc = (GaimConnection *) action->context;
|
|
756 gaim_account_request_change_user_info(gaim_connection_get_account(gc));
|
|
757 }
|
|
758
|
|
759 static void
|
|
760 silcgaim_set_info(GaimConnection *gc, const char *text)
|
|
761 {
|
|
762 }
|
|
763
|
8849
|
764 static GList *
|
9015
|
765 silcgaim_actions(GaimPlugin *plugin, gpointer context)
|
8849
|
766 {
|
9024
|
767 GaimConnection *gc = context;
|
8849
|
768 GList *list = NULL;
|
9015
|
769 GaimPluginAction *act;
|
8849
|
770
|
|
771 if (!gaim_account_get_bool(gc->account, "reject-attrs", FALSE)) {
|
9015
|
772 act = gaim_plugin_action_new(_("Online Status"),
|
|
773 silcgaim_attrs);
|
|
774 list = g_list_append(list, act);
|
8849
|
775 }
|
|
776
|
9015
|
777 act = gaim_plugin_action_new(_("Detach From Server"),
|
|
778 silcgaim_detach);
|
|
779 list = g_list_append(list, act);
|
8849
|
780
|
9015
|
781 act = gaim_plugin_action_new(_("View Message of the Day"),
|
|
782 silcgaim_view_motd);
|
|
783 list = g_list_append(list, act);
|
8849
|
784
|
9272
|
785 act = gaim_plugin_action_new(_("Change Password..."),
|
|
786 silcgaim_change_pass);
|
|
787 list = g_list_append(list, act);
|
|
788
|
|
789 act = gaim_plugin_action_new(_("Set User Info..."),
|
|
790 silcgaim_show_set_info);
|
|
791 list = g_list_append(list, act);
|
|
792
|
8849
|
793 return list;
|
|
794 }
|
|
795
|
|
796
|
|
797 /******************************* IM Routines *********************************/
|
|
798
|
|
799 typedef struct {
|
|
800 char *nick;
|
|
801 unsigned char *message;
|
|
802 SilcUInt32 message_len;
|
|
803 SilcMessageFlags flags;
|
|
804 } *SilcGaimIM;
|
|
805
|
|
806 static void
|
|
807 silcgaim_send_im_resolved(SilcClient client,
|
|
808 SilcClientConnection conn,
|
|
809 SilcClientEntry *clients,
|
|
810 SilcUInt32 clients_count,
|
|
811 void *context)
|
|
812 {
|
|
813 GaimConnection *gc = client->application;
|
|
814 SilcGaim sg = gc->proto_data;
|
|
815 SilcGaimIM im = context;
|
|
816 GaimConversation *convo;
|
|
817 char tmp[256], *nickname = NULL;
|
|
818 SilcClientEntry client_entry;
|
|
819
|
|
820 convo = gaim_find_conversation_with_account(im->nick, sg->account);
|
|
821 if (!convo)
|
|
822 return;
|
|
823
|
|
824 if (!clients)
|
|
825 goto err;
|
|
826
|
|
827 if (clients_count > 1) {
|
|
828 silc_parse_userfqdn(im->nick, &nickname, NULL);
|
|
829
|
|
830 /* Find the correct one. The im->nick might be a formatted nick
|
|
831 so this will find the correct one. */
|
|
832 clients = silc_client_get_clients_local(client, conn,
|
|
833 nickname, im->nick,
|
|
834 &clients_count);
|
|
835 if (!clients)
|
|
836 goto err;
|
|
837 client_entry = clients[0];
|
|
838 silc_free(clients);
|
|
839 } else {
|
|
840 client_entry = clients[0];
|
|
841 }
|
|
842
|
|
843 /* Send the message */
|
|
844 silc_client_send_private_message(client, conn, client_entry, im->flags,
|
|
845 im->message, im->message_len, TRUE);
|
|
846 gaim_conv_im_write(GAIM_CONV_IM(convo), conn->local_entry->nickname,
|
|
847 im->message, 0, time(NULL));
|
|
848
|
|
849 goto out;
|
|
850
|
|
851 err:
|
|
852 g_snprintf(tmp, sizeof(tmp),
|
|
853 _("User <I>%s</I> is not present in the network"), im->nick);
|
|
854 gaim_conversation_write(convo, NULL, tmp, GAIM_MESSAGE_SYSTEM, time(NULL));
|
|
855
|
|
856 out:
|
|
857 g_free(im->nick);
|
|
858 g_free(im->message);
|
|
859 silc_free(im);
|
|
860 silc_free(nickname);
|
|
861 }
|
|
862
|
|
863 static int
|
|
864 silcgaim_send_im(GaimConnection *gc, const char *who, const char *msg,
|
|
865 GaimConvImFlags flags)
|
|
866 {
|
|
867 SilcGaim sg = gc->proto_data;
|
|
868 SilcClient client = sg->client;
|
|
869 SilcClientConnection conn = sg->conn;
|
|
870 SilcClientEntry *clients;
|
|
871 SilcUInt32 clients_count, mflags;
|
|
872 char *nickname;
|
|
873 int ret;
|
|
874 gboolean sign = gaim_prefs_get_bool("/plugins/prpl/silc/sign_im");
|
|
875
|
|
876 if (!who || !msg)
|
|
877 return 0;
|
|
878
|
9353
|
879 mflags = SILC_MESSAGE_FLAG_UTF8;
|
|
880
|
|
881 if (!g_ascii_strncasecmp(msg, "/me ", 4)) {
|
|
882 msg += 4;
|
|
883 if (!msg)
|
|
884 return 0;
|
|
885 mflags |= SILC_MESSAGE_FLAG_ACTION;
|
|
886 } else if (strlen(msg) > 1 && msg[0] == '/') {
|
8849
|
887 if (!silc_client_command_call(client, conn, msg + 1))
|
|
888 gaim_notify_error(gc, ("Call Command"), _("Cannot call command"),
|
9359
|
889 _("Unknown command"));
|
8849
|
890 return 0;
|
|
891 }
|
|
892
|
9353
|
893
|
8849
|
894 if (!silc_parse_userfqdn(who, &nickname, NULL))
|
|
895 return 0;
|
|
896
|
|
897 if (sign)
|
|
898 mflags |= SILC_MESSAGE_FLAG_SIGNED;
|
|
899
|
|
900 /* Find client entry */
|
|
901 clients = silc_client_get_clients_local(client, conn, nickname, who,
|
|
902 &clients_count);
|
|
903 if (!clients) {
|
|
904 /* Resolve unknown user */
|
|
905 SilcGaimIM im = silc_calloc(1, sizeof(*im));
|
|
906 if (!im)
|
|
907 return 0;
|
|
908 im->nick = g_strdup(who);
|
|
909 im->message = g_strdup(msg);
|
|
910 im->message_len = strlen(im->message);
|
|
911 im->flags = mflags;
|
|
912 silc_client_get_clients(client, conn, nickname, NULL,
|
|
913 silcgaim_send_im_resolved, im);
|
|
914 silc_free(nickname);
|
|
915 return 0;
|
|
916 }
|
|
917
|
|
918 /* Send private message directly */
|
|
919 ret = silc_client_send_private_message(client, conn, clients[0],
|
|
920 mflags, (char *)msg,
|
|
921 strlen(msg), TRUE);
|
|
922
|
|
923 silc_free(nickname);
|
|
924 silc_free(clients);
|
|
925 return ret;
|
|
926 }
|
|
927
|
|
928
|
9030
|
929 GList *silcgaim_blist_node_menu(GaimBlistNode *node) {
|
|
930 /* split this single menu building function back into the two
|
|
931 original: one for buddies and one for chats */
|
|
932
|
|
933 if(GAIM_BLIST_NODE_IS_CHAT(node)) {
|
9038
|
934 return silcgaim_chat_menu((GaimChat *) node);
|
9030
|
935 } else if(GAIM_BLIST_NODE_IS_BUDDY(node)) {
|
|
936 return silcgaim_buddy_menu((GaimBuddy *) node);
|
|
937 } else {
|
9038
|
938 g_return_val_if_reached(NULL);
|
9353
|
939 }
|
9030
|
940 }
|
|
941
|
9272
|
942 /********************************* Commands **********************************/
|
|
943
|
|
944 static GaimCmdRet silcgaim_cmd_chat_part(GaimConversation *conv,
|
|
945 const char *cmd, char **args, char **error)
|
|
946 {
|
|
947 GaimConnection *gc;
|
9353
|
948 GaimConversation *convo;
|
9272
|
949 int id = 0;
|
|
950
|
|
951 gc = gaim_conversation_get_gc(conv);
|
9353
|
952
|
|
953 if (gc == NULL)
|
|
954 return GAIM_CMD_RET_FAILED;
|
9272
|
955
|
9353
|
956 if(args && args[0]) {
|
|
957 convo = gaim_find_conversation_with_account(args[0], gc->account);
|
|
958 } else
|
|
959 convo = conv;
|
|
960
|
9488
|
961 if (gaim_conversation_get_type(convo) != GAIM_CONV_CHAT) {
|
|
962 *error = g_strdup(_("Failed to leave channel"));
|
9353
|
963 return GAIM_CMD_RET_FAILED;
|
9488
|
964 }
|
9353
|
965
|
|
966 id = gaim_conv_chat_get_id(GAIM_CONV_CHAT(convo));
|
|
967
|
|
968 if (id == 0)
|
9272
|
969 return GAIM_CMD_RET_FAILED;
|
|
970
|
|
971 silcgaim_chat_leave(gc, id);
|
|
972
|
|
973 return GAIM_CMD_RET_OK;
|
|
974
|
|
975 }
|
|
976
|
|
977 static GaimCmdRet silcgaim_cmd_chat_topic(GaimConversation *conv,
|
|
978 const char *cmd, char **args, char **error)
|
|
979 {
|
|
980 GaimConnection *gc;
|
|
981 int id = 0;
|
9488
|
982 char *buf, *tmp;
|
|
983 const char *topic;
|
9272
|
984
|
|
985 gc = gaim_conversation_get_gc(conv);
|
|
986 id = gaim_conv_chat_get_id(GAIM_CONV_CHAT(conv));
|
|
987
|
|
988 if (gc == NULL || id == 0)
|
|
989 return GAIM_CMD_RET_FAILED;
|
|
990
|
9488
|
991 if (!args || !args[0]) {
|
|
992 topic = gaim_conv_chat_get_topic (GAIM_CONV_CHAT(conv));
|
|
993 if (topic) {
|
|
994 tmp = gaim_escape_html(topic);
|
|
995 buf = g_strdup_printf(_("current topic is: %s"), tmp);
|
|
996 g_free(tmp);
|
|
997 } else
|
|
998 buf = g_strdup(_("No topic is set"));
|
|
999 gaim_conv_chat_write(GAIM_CONV_CHAT(conv), gc->account->username, buf,
|
|
1000 GAIM_MESSAGE_SYSTEM|GAIM_MESSAGE_NO_LOG, time(NULL));
|
|
1001 g_free(buf);
|
|
1002
|
|
1003 }
|
|
1004
|
|
1005 if (args && args[0] && (strlen(args[0]) > 255)) {
|
|
1006 *error = g_strdup(_("Topic too long"));
|
|
1007 return GAIM_CMD_RET_FAILED;
|
|
1008 }
|
|
1009
|
9272
|
1010 silcgaim_chat_set_topic(gc, id, args ? args[0] : NULL);
|
|
1011
|
|
1012 return GAIM_CMD_RET_OK;
|
|
1013 }
|
|
1014
|
|
1015 static GaimCmdRet silcgaim_cmd_chat_join(GaimConversation *conv,
|
|
1016 const char *cmd, char **args, char **error)
|
|
1017 {
|
|
1018 GHashTable *comp;
|
|
1019
|
|
1020 if(!args || !args[0])
|
|
1021 return GAIM_CMD_RET_FAILED;
|
|
1022
|
|
1023 comp = g_hash_table_new_full(g_str_hash, g_str_equal, NULL, NULL);
|
|
1024
|
|
1025 g_hash_table_replace(comp, "channel", args[0]);
|
|
1026 if(args[1])
|
|
1027 g_hash_table_replace(comp, "passphrase", args[1]);
|
|
1028
|
|
1029 silcgaim_chat_join(gaim_conversation_get_gc(conv), comp);
|
|
1030
|
|
1031 g_hash_table_destroy(comp);
|
|
1032 return GAIM_CMD_RET_OK;
|
|
1033 }
|
|
1034
|
|
1035 static GaimCmdRet silcgaim_cmd_chat_list(GaimConversation *conv,
|
|
1036 const char *cmd, char **args, char **error)
|
|
1037 {
|
|
1038 GaimConnection *gc;
|
|
1039 gc = gaim_conversation_get_gc(conv);
|
|
1040 gaim_roomlist_show_with_account(gaim_connection_get_account(gc));
|
|
1041 return GAIM_CMD_RET_OK;
|
|
1042 }
|
|
1043
|
|
1044 static GaimCmdRet silcgaim_cmd_whois(GaimConversation *conv,
|
|
1045 const char *cmd, char **args, char **error)
|
|
1046 {
|
|
1047 GaimConnection *gc;
|
|
1048
|
|
1049 gc = gaim_conversation_get_gc(conv);
|
|
1050
|
|
1051 if (gc == NULL)
|
|
1052 return GAIM_CMD_RET_FAILED;
|
|
1053
|
|
1054 silcgaim_get_info(gc, args[0]);
|
|
1055
|
|
1056 return GAIM_CMD_RET_OK;
|
|
1057 }
|
|
1058
|
|
1059 static GaimCmdRet silcgaim_cmd_msg(GaimConversation *conv,
|
|
1060 const char *cmd, char **args, char **error)
|
|
1061 {
|
|
1062 int ret;
|
|
1063 GaimConnection *gc;
|
|
1064
|
|
1065 gc = gaim_conversation_get_gc(conv);
|
|
1066
|
|
1067 if (gc == NULL)
|
|
1068 return GAIM_CMD_RET_FAILED;
|
|
1069
|
|
1070 ret = silcgaim_send_im(gc, args[0], args[1], GAIM_MESSAGE_SEND);
|
|
1071
|
|
1072 if (ret)
|
|
1073 return GAIM_CMD_RET_OK;
|
|
1074 else
|
|
1075 return GAIM_CMD_RET_FAILED;
|
|
1076 }
|
|
1077
|
|
1078 static GaimCmdRet silcgaim_cmd_query(GaimConversation *conv,
|
|
1079 const char *cmd, char **args, char **error)
|
|
1080 {
|
|
1081 int ret = 1;
|
|
1082 GaimConversation *convo;
|
|
1083 GaimConnection *gc;
|
|
1084 GaimAccount *account;
|
|
1085
|
9488
|
1086 if (!args || !args[0]) {
|
|
1087 *error = g_strdup(_("You must specify a nick"));
|
9272
|
1088 return GAIM_CMD_RET_FAILED;
|
9488
|
1089 }
|
9272
|
1090
|
|
1091 gc = gaim_conversation_get_gc(conv);
|
|
1092
|
|
1093 if (gc == NULL)
|
|
1094 return GAIM_CMD_RET_FAILED;
|
|
1095
|
|
1096 account = gaim_connection_get_account(gc);
|
|
1097
|
|
1098 convo = gaim_conversation_new(GAIM_CONV_IM, account, args[0]);
|
|
1099
|
|
1100 if (args[1]) {
|
|
1101 ret = silcgaim_send_im(gc, args[0], args[1], GAIM_MESSAGE_SEND);
|
|
1102 gaim_conv_im_write(GAIM_CONV_IM(convo), gaim_connection_get_display_name(gc),
|
|
1103 args[1], GAIM_MESSAGE_SEND, time(NULL));
|
|
1104 }
|
|
1105
|
|
1106 if (ret)
|
|
1107 return GAIM_CMD_RET_OK;
|
|
1108 else
|
|
1109 return GAIM_CMD_RET_FAILED;
|
|
1110 }
|
|
1111
|
|
1112 static GaimCmdRet silcgaim_cmd_motd(GaimConversation *conv,
|
|
1113 const char *cmd, char **args, char **error)
|
|
1114 {
|
|
1115 GaimConnection *gc;
|
|
1116 SilcGaim sg;
|
9488
|
1117 char *tmp;
|
9272
|
1118
|
|
1119 gc = gaim_conversation_get_gc(conv);
|
|
1120
|
|
1121 if (gc == NULL)
|
|
1122 return GAIM_CMD_RET_FAILED;
|
|
1123
|
|
1124 sg = gc->proto_data;
|
|
1125
|
|
1126 if (sg == NULL)
|
|
1127 return GAIM_CMD_RET_FAILED;
|
|
1128
|
|
1129 if (!sg->motd) {
|
9488
|
1130 *error = g_strdup(_("There is no Message of the Day associated with this connection"));
|
9272
|
1131 return GAIM_CMD_RET_FAILED;
|
|
1132 }
|
|
1133
|
9488
|
1134 tmp = gaim_escape_html(sg->motd);
|
|
1135 gaim_notify_formatted(gc, NULL, _("Message of the Day"), NULL,
|
|
1136 tmp, NULL, NULL);
|
|
1137 g_free(tmp);
|
9272
|
1138
|
|
1139 return GAIM_CMD_RET_OK;
|
|
1140 }
|
|
1141
|
|
1142 static GaimCmdRet silcgaim_cmd_detach(GaimConversation *conv,
|
|
1143 const char *cmd, char **args, char **error)
|
|
1144 {
|
|
1145 GaimConnection *gc;
|
|
1146 SilcGaim sg;
|
|
1147
|
|
1148 gc = gaim_conversation_get_gc(conv);
|
|
1149
|
|
1150 if (gc == NULL)
|
|
1151 return GAIM_CMD_RET_FAILED;
|
|
1152
|
|
1153 sg = gc->proto_data;
|
|
1154
|
|
1155 if (sg == NULL)
|
|
1156 return GAIM_CMD_RET_FAILED;
|
|
1157
|
|
1158 silc_client_command_call(sg->client, sg->conn, "DETACH");
|
|
1159 sg->detaching = TRUE;
|
|
1160
|
|
1161 return GAIM_CMD_RET_OK;
|
|
1162 }
|
|
1163
|
9488
|
1164 static GaimCmdRet silcgaim_cmd_cmode(GaimConversation *conv,
|
|
1165 const char *cmd, char **args, char **error)
|
|
1166 {
|
|
1167 GaimConnection *gc;
|
|
1168 SilcGaim sg;
|
|
1169 SilcChannelEntry channel;
|
|
1170 char *silccmd, *silcargs, *msg, tmp[256];
|
|
1171 const char *chname;
|
|
1172
|
|
1173 gc = gaim_conversation_get_gc(conv);
|
|
1174
|
|
1175 if (gc == NULL || !args || gc->proto_data == NULL)
|
|
1176 return GAIM_CMD_RET_FAILED;
|
|
1177
|
|
1178 sg = gc->proto_data;
|
|
1179
|
|
1180 if (args[0])
|
|
1181 chname = args[0];
|
|
1182 else
|
|
1183 chname = gaim_conversation_get_name(conv);
|
|
1184
|
|
1185 if (!args[1]) {
|
|
1186 channel = silc_client_get_channel(sg->client, sg->conn,
|
|
1187 (char *)chname);
|
|
1188 if (!channel) {
|
|
1189 *error = g_strdup_printf(_("channel %s not found"), chname);
|
|
1190 return GAIM_CMD_RET_FAILED;
|
|
1191 }
|
|
1192 if (channel->mode) {
|
|
1193 silcgaim_get_chmode_string(channel->mode, tmp, sizeof(tmp));
|
|
1194 msg = g_strdup_printf(_("channel modes for %s: %s"), chname, tmp);
|
|
1195 } else {
|
|
1196 msg = g_strdup_printf(_("no channel modes are set on %s"), chname);
|
|
1197 }
|
|
1198 gaim_conv_chat_write(GAIM_CONV_CHAT(conv), "",
|
|
1199 msg, GAIM_MESSAGE_SYSTEM|GAIM_MESSAGE_NO_LOG, time(NULL));
|
|
1200 g_free(msg);
|
|
1201 return GAIM_CMD_RET_OK;
|
|
1202 }
|
|
1203
|
|
1204 silcargs = g_strjoinv(" ", args);
|
|
1205 silccmd = g_strconcat(cmd, " ", args ? silcargs : NULL, NULL);
|
|
1206 g_free(silcargs);
|
|
1207 if (!silc_client_command_call(sg->client, sg->conn, silccmd)) {
|
|
1208 g_free(silccmd);
|
|
1209 *error = g_strdup_printf(_("Failed to set cmodes for %s"), args[0]);
|
|
1210 return GAIM_CMD_RET_FAILED;
|
|
1211 }
|
|
1212 g_free(silccmd);
|
|
1213
|
|
1214 return GAIM_CMD_RET_OK;
|
|
1215 }
|
|
1216
|
9353
|
1217 static GaimCmdRet silcgaim_cmd_generic(GaimConversation *conv,
|
9272
|
1218 const char *cmd, char **args, char **error)
|
|
1219 {
|
|
1220 GaimConnection *gc;
|
|
1221 SilcGaim sg;
|
9353
|
1222 char *silccmd, *silcargs;
|
9272
|
1223
|
|
1224 gc = gaim_conversation_get_gc(conv);
|
|
1225
|
|
1226 if (gc == NULL)
|
|
1227 return GAIM_CMD_RET_FAILED;
|
|
1228
|
|
1229 sg = gc->proto_data;
|
|
1230
|
|
1231 if (sg == NULL)
|
|
1232 return GAIM_CMD_RET_FAILED;
|
|
1233
|
9353
|
1234 silcargs = g_strjoinv(" ", args);
|
|
1235 silccmd = g_strconcat(cmd, " ", args ? silcargs : NULL, NULL);
|
|
1236 g_free(silcargs);
|
|
1237 if (!silc_client_command_call(sg->client, sg->conn, silccmd)) {
|
|
1238 g_free(silccmd);
|
9488
|
1239 *error = g_strdup_printf(_("Unknown command: %s, (may be a Gaim bug)"), cmd);
|
9353
|
1240 return GAIM_CMD_RET_FAILED;
|
|
1241 }
|
|
1242 g_free(silccmd);
|
9272
|
1243
|
|
1244 return GAIM_CMD_RET_OK;
|
|
1245 }
|
|
1246
|
9359
|
1247 static GaimCmdRet silcgaim_cmd_quit(GaimConversation *conv,
|
|
1248 const char *cmd, char **args, char **error)
|
|
1249 {
|
|
1250 GaimConnection *gc;
|
|
1251 SilcGaim sg;
|
|
1252
|
|
1253 gc = gaim_conversation_get_gc(conv);
|
|
1254
|
|
1255 if (gc == NULL)
|
|
1256 return GAIM_CMD_RET_FAILED;
|
|
1257
|
|
1258 sg = gc->proto_data;
|
|
1259
|
|
1260 if (sg == NULL)
|
|
1261 return GAIM_CMD_RET_FAILED;
|
|
1262
|
|
1263 silc_client_command_call(sg->client, sg->conn, NULL,
|
|
1264 "QUIT", (args && args[0]) ? args[0] : "Download Gaim: " GAIM_WEBSITE, NULL);
|
|
1265
|
|
1266 return GAIM_CMD_RET_OK;
|
|
1267 }
|
|
1268
|
|
1269 static GaimCmdRet silcgaim_cmd_call(GaimConversation *conv,
|
|
1270 const char *cmd, char **args, char **error)
|
|
1271 {
|
|
1272 GaimConnection *gc;
|
|
1273 SilcGaim sg;
|
|
1274
|
|
1275 gc = gaim_conversation_get_gc(conv);
|
|
1276
|
|
1277 if (gc == NULL)
|
|
1278 return GAIM_CMD_RET_FAILED;
|
|
1279
|
|
1280 sg = gc->proto_data;
|
|
1281
|
|
1282 if (sg == NULL)
|
|
1283 return GAIM_CMD_RET_FAILED;
|
|
1284
|
9488
|
1285 if (!silc_client_command_call(sg->client, sg->conn, args[0])) {
|
|
1286 *error = g_strdup_printf(_("Unknown command: %s"), args[0]);
|
9359
|
1287 return GAIM_CMD_RET_FAILED;
|
9488
|
1288 }
|
9359
|
1289
|
|
1290 return GAIM_CMD_RET_OK;
|
|
1291 }
|
|
1292
|
9030
|
1293
|
8849
|
1294 /************************** Plugin Initialization ****************************/
|
|
1295
|
9272
|
1296 static void
|
|
1297 silcgaim_register_commands(void)
|
|
1298 {
|
9353
|
1299 gaim_cmd_register("part", "w", GAIM_CMD_P_PRPL,
|
|
1300 GAIM_CMD_FLAG_IM | GAIM_CMD_FLAG_CHAT |
|
|
1301 GAIM_CMD_FLAG_PRPL_ONLY | GAIM_CMD_FLAG_ALLOW_WRONG_ARGS,
|
9488
|
1302 "prpl-silc", silcgaim_cmd_chat_part, _("part [channel]: Leave the chat"));
|
9353
|
1303 gaim_cmd_register("leave", "w", GAIM_CMD_P_PRPL,
|
|
1304 GAIM_CMD_FLAG_IM | GAIM_CMD_FLAG_CHAT |
|
|
1305 GAIM_CMD_FLAG_PRPL_ONLY | GAIM_CMD_FLAG_ALLOW_WRONG_ARGS,
|
9488
|
1306 "prpl-silc", silcgaim_cmd_chat_part, _("leave [channel]: Leave the chat"));
|
9272
|
1307 gaim_cmd_register("topic", "s", GAIM_CMD_P_PRPL,
|
|
1308 GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_PRPL_ONLY |
|
|
1309 GAIM_CMD_FLAG_ALLOW_WRONG_ARGS, "prpl-silc",
|
|
1310 silcgaim_cmd_chat_topic, _("topic [<new topic>]: View or change the topic"));
|
|
1311 gaim_cmd_register("join", "ws", GAIM_CMD_P_PRPL,
|
|
1312 GAIM_CMD_FLAG_IM | GAIM_CMD_FLAG_CHAT |
|
|
1313 GAIM_CMD_FLAG_PRPL_ONLY | GAIM_CMD_FLAG_ALLOW_WRONG_ARGS,
|
|
1314 "prpl-silc", silcgaim_cmd_chat_join,
|
|
1315 _("join <channel> [<password>]: Join a chat on this network"));
|
|
1316 gaim_cmd_register("list", "", GAIM_CMD_P_PRPL,
|
|
1317 GAIM_CMD_FLAG_IM | GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_PRPL_ONLY |
|
|
1318 GAIM_CMD_FLAG_ALLOW_WRONG_ARGS, "prpl-silc",
|
|
1319 silcgaim_cmd_chat_list, _("list: List channels on this network"));
|
|
1320 gaim_cmd_register("whois", "w", GAIM_CMD_P_PRPL,
|
|
1321 GAIM_CMD_FLAG_IM | GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_PRPL_ONLY,
|
|
1322 "prpl-silc",
|
9274
|
1323 silcgaim_cmd_whois, _("whois <nick>: View nick's information"));
|
9272
|
1324 gaim_cmd_register("msg", "ws", GAIM_CMD_P_PRPL,
|
|
1325 GAIM_CMD_FLAG_IM | GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_PRPL_ONLY,
|
|
1326 "prpl-silc", silcgaim_cmd_msg,
|
|
1327 _("msg <nick> <message>: Send a private message to a user"));
|
|
1328 gaim_cmd_register("query", "ws", GAIM_CMD_P_PRPL,
|
|
1329 GAIM_CMD_FLAG_IM | GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_PRPL_ONLY |
|
|
1330 GAIM_CMD_FLAG_ALLOW_WRONG_ARGS, "prpl-silc", silcgaim_cmd_query,
|
|
1331 _("query <nick> [<message>]: Send a private message to a user"));
|
|
1332 gaim_cmd_register("motd", "", GAIM_CMD_P_PRPL,
|
|
1333 GAIM_CMD_FLAG_IM | GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_PRPL_ONLY |
|
|
1334 GAIM_CMD_FLAG_ALLOW_WRONG_ARGS, "prpl-silc", silcgaim_cmd_motd,
|
|
1335 _("motd: View the server's Message Of The Day"));
|
|
1336 gaim_cmd_register("detach", "", GAIM_CMD_P_PRPL,
|
9353
|
1337 GAIM_CMD_FLAG_IM | GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_PRPL_ONLY,
|
|
1338 "prpl-silc", silcgaim_cmd_detach,
|
9272
|
1339 _("detach: Detach this session"));
|
9359
|
1340 gaim_cmd_register("quit", "s", GAIM_CMD_P_PRPL,
|
|
1341 GAIM_CMD_FLAG_IM | GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_PRPL_ONLY |
|
|
1342 GAIM_CMD_FLAG_ALLOW_WRONG_ARGS, "prpl-silc", silcgaim_cmd_quit,
|
9488
|
1343 _("quit [message]: Disconnect from the server, with an optional message"));
|
9359
|
1344 gaim_cmd_register("call", "s", GAIM_CMD_P_PRPL,
|
|
1345 GAIM_CMD_FLAG_IM | GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_PRPL_ONLY,
|
|
1346 "prpl-silc", silcgaim_cmd_call,
|
9488
|
1347 _("call <command>: Call any silc client command"));
|
9359
|
1348 /* These below just get passed through for the silc client library to deal with */
|
|
1349 gaim_cmd_register("kill", "ws", GAIM_CMD_P_PRPL,
|
|
1350 GAIM_CMD_FLAG_IM | GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_PRPL_ONLY |
|
|
1351 GAIM_CMD_FLAG_ALLOW_WRONG_ARGS, "prpl-silc", silcgaim_cmd_generic,
|
9488
|
1352 _("kill <nick> [-pubkey|<reason>]: Kill nick"));
|
9359
|
1353 gaim_cmd_register("nick", "w", GAIM_CMD_P_PRPL,
|
|
1354 GAIM_CMD_FLAG_IM | GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_PRPL_ONLY,
|
|
1355 "prpl-silc", silcgaim_cmd_generic,
|
9488
|
1356 _("nick <newnick>: Change your nickname"));
|
|
1357 gaim_cmd_register("whowas", "ww", GAIM_CMD_P_PRPL,
|
9359
|
1358 GAIM_CMD_FLAG_IM | GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_PRPL_ONLY |
|
|
1359 GAIM_CMD_FLAG_ALLOW_WRONG_ARGS, "prpl-silc", silcgaim_cmd_generic,
|
9488
|
1360 _("whowas <nick>: View nick's information"));
|
|
1361 gaim_cmd_register("cmode", "wws", GAIM_CMD_P_PRPL,
|
|
1362 GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_PRPL_ONLY |
|
|
1363 GAIM_CMD_FLAG_ALLOW_WRONG_ARGS, "prpl-silc", silcgaim_cmd_cmode,
|
9552
|
1364 _("cmode <channel> [+|-<modes>] [arguments]: Change or display channel modes"));
|
9359
|
1365 gaim_cmd_register("cumode", "wws", GAIM_CMD_P_PRPL,
|
|
1366 GAIM_CMD_FLAG_IM | GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_PRPL_ONLY |
|
|
1367 GAIM_CMD_FLAG_ALLOW_WRONG_ARGS, "prpl-silc", silcgaim_cmd_generic,
|
9488
|
1368 _("cumode <channel> +|-<modes> <nick>: Change nick's modes on channel"));
|
9272
|
1369 gaim_cmd_register("umode", "w", GAIM_CMD_P_PRPL,
|
|
1370 GAIM_CMD_FLAG_IM | GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_PRPL_ONLY,
|
9353
|
1371 "prpl-silc", silcgaim_cmd_generic,
|
9488
|
1372 _("umode <usermodes>: Set your modes in the network"));
|
9359
|
1373 gaim_cmd_register("oper", "s", GAIM_CMD_P_PRPL,
|
|
1374 GAIM_CMD_FLAG_IM | GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_PRPL_ONLY,
|
|
1375 "prpl-silc", silcgaim_cmd_generic,
|
9488
|
1376 _("oper <nick> [-pubkey]: Get server operator privileges"));
|
9359
|
1377 gaim_cmd_register("invite", "ws", GAIM_CMD_P_PRPL,
|
|
1378 GAIM_CMD_FLAG_IM | GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_PRPL_ONLY |
|
|
1379 GAIM_CMD_FLAG_ALLOW_WRONG_ARGS, "prpl-silc", silcgaim_cmd_generic,
|
9488
|
1380 _("invite <channel> [-|+]<nick>: invite nick or add/remove from channel invite list"));
|
9359
|
1381 gaim_cmd_register("kick", "wws", GAIM_CMD_P_PRPL,
|
|
1382 GAIM_CMD_FLAG_IM | GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_PRPL_ONLY |
|
|
1383 GAIM_CMD_FLAG_ALLOW_WRONG_ARGS, "prpl-silc", silcgaim_cmd_generic,
|
9488
|
1384 _("kick <channel> <nick> [comment]: Kick client from channel"));
|
|
1385 gaim_cmd_register("info", "w", GAIM_CMD_P_PRPL,
|
9359
|
1386 GAIM_CMD_FLAG_IM | GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_PRPL_ONLY |
|
|
1387 GAIM_CMD_FLAG_ALLOW_WRONG_ARGS, "prpl-silc", silcgaim_cmd_generic,
|
9488
|
1388 _("info [server]: View server administrative details"));
|
9359
|
1389 gaim_cmd_register("ban", "ww", GAIM_CMD_P_PRPL,
|
|
1390 GAIM_CMD_FLAG_IM | GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_PRPL_ONLY |
|
|
1391 GAIM_CMD_FLAG_ALLOW_WRONG_ARGS, "prpl-silc", silcgaim_cmd_generic,
|
9488
|
1392 _("ban [<channel> +|-<nick>]: Ban client from channel"));
|
|
1393 gaim_cmd_register("getkey", "w", GAIM_CMD_P_PRPL,
|
|
1394 GAIM_CMD_FLAG_IM | GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_PRPL_ONLY,
|
|
1395 "prpl-silc", silcgaim_cmd_generic,
|
|
1396 _("getkey <nick|server>: Retrieve client's or server's public key"));
|
|
1397 gaim_cmd_register("stats", "", GAIM_CMD_P_PRPL,
|
|
1398 GAIM_CMD_FLAG_IM | GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_PRPL_ONLY,
|
|
1399 "prpl-silc", silcgaim_cmd_generic,
|
|
1400 _("stats: View server and network statistics"));
|
9359
|
1401 gaim_cmd_register("ping", "", GAIM_CMD_P_PRPL,
|
|
1402 GAIM_CMD_FLAG_IM | GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_PRPL_ONLY,
|
|
1403 "prpl-silc", silcgaim_cmd_generic,
|
9488
|
1404 _("ping: Send PING to the connected server"));
|
|
1405 #if 0 /* Gaim doesn't handle these yet */
|
|
1406 gaim_cmd_register("users", "w", GAIM_CMD_P_PRPL,
|
|
1407 GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_PRPL_ONLY,
|
|
1408 "prpl-silc", silcgaim_cmd_users,
|
|
1409 _("users <channel>: List users in channel"));
|
|
1410 gaim_cmd_register("names", "ww", GAIM_CMD_P_PRPL,
|
|
1411 GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_PRPL_ONLY |
|
|
1412 GAIM_CMD_FLAG_ALLOW_WRONG_ARGS, "prpl-silc", silcgaim_cmd_names,
|
|
1413 _("names [-count|-ops|-halfops|-voices|-normal] <channel(s)>: List specific users in channel(s)"));
|
9359
|
1414 #endif
|
9272
|
1415 }
|
|
1416
|
8849
|
1417 static GaimPluginPrefFrame *
|
|
1418 silcgaim_pref_frame(GaimPlugin *plugin)
|
|
1419 {
|
|
1420 GaimPluginPrefFrame *frame;
|
|
1421 GaimPluginPref *ppref;
|
|
1422
|
|
1423 frame = gaim_plugin_pref_frame_new();
|
|
1424
|
|
1425 ppref = gaim_plugin_pref_new_with_label(_("Instant Messages"));
|
|
1426 gaim_plugin_pref_frame_add(frame, ppref);
|
|
1427
|
|
1428 ppref = gaim_plugin_pref_new_with_name_and_label(
|
|
1429 "/plugins/prpl/silc/sign_im",
|
|
1430 _("Digitally sign all IM messages"));
|
|
1431 gaim_plugin_pref_frame_add(frame, ppref);
|
|
1432
|
|
1433 ppref = gaim_plugin_pref_new_with_name_and_label(
|
|
1434 "/plugins/prpl/silc/verify_im",
|
|
1435 _("Verify all IM message signatures"));
|
|
1436 gaim_plugin_pref_frame_add(frame, ppref);
|
|
1437
|
|
1438 ppref = gaim_plugin_pref_new_with_label(_("Channel Messages"));
|
|
1439 gaim_plugin_pref_frame_add(frame, ppref);
|
|
1440
|
|
1441 ppref = gaim_plugin_pref_new_with_name_and_label(
|
|
1442 "/plugins/prpl/silc/sign_chat",
|
|
1443 _("Digitally sign all channel messages"));
|
|
1444 gaim_plugin_pref_frame_add(frame, ppref);
|
|
1445
|
|
1446 ppref = gaim_plugin_pref_new_with_name_and_label(
|
|
1447 "/plugins/prpl/silc/verify_chat",
|
|
1448 _("Verify all channel message signatures"));
|
|
1449 gaim_plugin_pref_frame_add(frame, ppref);
|
|
1450
|
|
1451 ppref = gaim_plugin_pref_new_with_label(_("Default SILC Key Pair"));
|
|
1452 gaim_plugin_pref_frame_add(frame, ppref);
|
|
1453
|
|
1454 ppref = gaim_plugin_pref_new_with_name_and_label(
|
|
1455 "/plugins/prpl/silc/pubkey",
|
|
1456 _("SILC Public Key"));
|
|
1457 gaim_plugin_pref_frame_add(frame, ppref);
|
|
1458
|
|
1459 ppref = gaim_plugin_pref_new_with_name_and_label(
|
|
1460 "/plugins/prpl/silc/privkey",
|
|
1461 _("SILC Private Key"));
|
|
1462 gaim_plugin_pref_frame_add(frame, ppref);
|
|
1463
|
|
1464 return frame;
|
|
1465 }
|
|
1466
|
|
1467 static GaimPluginUiInfo prefs_info =
|
|
1468 {
|
|
1469 silcgaim_pref_frame,
|
|
1470 };
|
|
1471
|
|
1472 static GaimPluginProtocolInfo prpl_info =
|
|
1473 {
|
|
1474 GAIM_PRPL_API_VERSION,
|
|
1475 OPT_PROTO_CHAT_TOPIC | OPT_PROTO_UNIQUE_CHATNAME |
|
|
1476 OPT_PROTO_PASSWORD_OPTIONAL,
|
9488
|
1477 NULL, /* user_splits */
|
|
1478 NULL, /* protocol_options */
|
|
1479 NO_BUDDY_ICONS, /* icon_spec */
|
|
1480 silcgaim_list_icon, /* list_icon */
|
|
1481 silcgaim_list_emblems, /* list_emblems */
|
|
1482 silcgaim_status_text, /* status_text */
|
|
1483 silcgaim_tooltip_text, /* tooltip_text */
|
|
1484 silcgaim_away_states, /* away_states */
|
|
1485 silcgaim_blist_node_menu, /* blist_node_menu */
|
|
1486 silcgaim_chat_info, /* chat_info */
|
|
1487 silcgaim_login, /* login */
|
|
1488 silcgaim_close, /* close */
|
|
1489 silcgaim_send_im, /* send_im */
|
|
1490 silcgaim_set_info, /* set_info */
|
|
1491 NULL, /* send_typing */
|
|
1492 silcgaim_get_info, /* get_info */
|
|
1493 silcgaim_set_away, /* set_away */
|
|
1494 silcgaim_idle_set, /* set_idle */
|
|
1495 silcgaim_change_passwd, /* change_passwd */
|
|
1496 silcgaim_add_buddy, /* add_buddy */
|
|
1497 NULL, /* add_buddies */
|
|
1498 silcgaim_remove_buddy, /* remove_buddy */
|
|
1499 NULL, /* remove_buddies */
|
|
1500 NULL, /* add_permit */
|
|
1501 NULL, /* add_deny */
|
|
1502 NULL, /* rem_permit */
|
|
1503 NULL, /* rem_deny */
|
|
1504 NULL, /* set_permit_deny */
|
|
1505 NULL, /* warn */
|
|
1506 silcgaim_chat_join, /* join_chat */
|
|
1507 NULL, /* reject_chat */
|
|
1508 silcgaim_chat_invite, /* chat_invite */
|
|
1509 silcgaim_chat_leave, /* chat_leave */
|
|
1510 NULL, /* chat_whisper */
|
|
1511 silcgaim_chat_send, /* chat_send */
|
|
1512 silcgaim_keepalive, /* keepalive */
|
|
1513 NULL, /* register_user */
|
|
1514 NULL, /* get_cb_info */
|
|
1515 NULL, /* get_cb_away */
|
|
1516 NULL, /* alias_buddy */
|
|
1517 NULL, /* group_buddy */
|
|
1518 NULL, /* rename_group */
|
|
1519 NULL, /* buddy_free */
|
|
1520 NULL, /* convo_closed */
|
|
1521 NULL, /* normalize */
|
|
1522 NULL, /* set_buddy_icon */
|
|
1523 NULL, /* remove_group */
|
|
1524 NULL, /* get_cb_real_name */
|
|
1525 silcgaim_chat_set_topic, /* set_chat_topic */
|
|
1526 NULL, /* find_blist_chat */
|
|
1527 silcgaim_roomlist_get_list, /* roomlist_get_list */
|
|
1528 silcgaim_roomlist_cancel, /* roomlist_cancel */
|
|
1529 NULL, /* roomlist_expand_category */
|
|
1530 NULL, /* can_receive_file */
|
|
1531 silcgaim_ftp_send_file /* send_file */
|
8849
|
1532 };
|
|
1533
|
|
1534 static GaimPluginInfo info =
|
|
1535 {
|
|
1536 GAIM_PLUGIN_API_VERSION, /**< api_version */
|
|
1537 GAIM_PLUGIN_PROTOCOL, /**< type */
|
|
1538 NULL, /**< ui_requirement */
|
|
1539 0, /**< flags */
|
|
1540 NULL, /**< dependencies */
|
|
1541 GAIM_PRIORITY_DEFAULT, /**< priority */
|
|
1542
|
|
1543 "prpl-silc", /**< id */
|
|
1544 "SILC", /**< name */
|
|
1545 "1.0", /**< version */
|
|
1546 /** summary */
|
|
1547 N_("SILC Protocol Plugin"),
|
|
1548 /** description */
|
|
1549 N_("Secure Internet Live Conferencing (SILC) Protocol"),
|
8891
|
1550 "Pekka Riikonen", /**< author */
|
|
1551 "http://silcnet.org/", /**< homepage */
|
8849
|
1552
|
|
1553 NULL, /**< load */
|
|
1554 NULL, /**< unload */
|
|
1555 NULL, /**< destroy */
|
|
1556
|
|
1557 NULL, /**< ui_info */
|
|
1558 &prpl_info, /**< extra_info */
|
8993
|
1559 &prefs_info, /**< prefs_info */
|
9015
|
1560 silcgaim_actions
|
8849
|
1561 };
|
|
1562
|
|
1563 static void
|
|
1564 init_plugin(GaimPlugin *plugin)
|
|
1565 {
|
|
1566 GaimAccountOption *option;
|
|
1567 char tmp[256];
|
|
1568
|
|
1569 silc_plugin = plugin;
|
|
1570
|
|
1571 /* Account options */
|
|
1572 option = gaim_account_option_string_new(_("Connect server"),
|
|
1573 "server",
|
|
1574 "silc.silcnet.org");
|
|
1575 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option);
|
|
1576 option = gaim_account_option_int_new(_("Port"), "port", 706);
|
|
1577 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option);
|
|
1578
|
|
1579 option = gaim_account_option_bool_new(_("Public key authentication"),
|
|
1580 "pubkey-auth", FALSE);
|
|
1581 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option);
|
|
1582 #if 0 /* XXX Public key auth interface with explicit key pair is
|
|
1583 broken in SILC Toolkit */
|
8891
|
1584 g_snprintf(tmp, sizeof(tmp), "%s/public_key.pub", silcgaim_silcdir());
|
8849
|
1585 option = gaim_account_option_string_new(_("Public Key File"),
|
|
1586 "public-key", tmp);
|
|
1587 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option);
|
8891
|
1588 g_snprintf(tmp, sizeof(tmp), "%s/private_key.prv", silcgaim_silcdir());
|
8849
|
1589 option = gaim_account_option_string_new(_("Private Key File"),
|
|
1590 "public-key", tmp);
|
|
1591 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option);
|
|
1592 #endif
|
|
1593
|
|
1594 option = gaim_account_option_bool_new(_("Reject watching by other users"),
|
|
1595 "reject-watch", FALSE);
|
|
1596 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option);
|
|
1597 option = gaim_account_option_bool_new(_("Block invites"),
|
|
1598 "block-invites", FALSE);
|
|
1599 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option);
|
|
1600 option = gaim_account_option_bool_new(_("Block IMs without Key Exchange"),
|
|
1601 "block-ims", FALSE);
|
|
1602 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option);
|
|
1603 option = gaim_account_option_bool_new(_("Reject online status attribute requests"),
|
|
1604 "reject-attrs", FALSE);
|
|
1605 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option);
|
|
1606
|
|
1607 /* Preferences */
|
|
1608 gaim_prefs_add_none("/plugins/prpl/silc");
|
|
1609 gaim_prefs_add_bool("/plugins/prpl/silc/sign_im", FALSE);
|
|
1610 gaim_prefs_add_bool("/plugins/prpl/silc/verify_im", FALSE);
|
|
1611 gaim_prefs_add_bool("/plugins/prpl/silc/sign_chat", FALSE);
|
|
1612 gaim_prefs_add_bool("/plugins/prpl/silc/verify_chat", FALSE);
|
8891
|
1613 g_snprintf(tmp, sizeof(tmp), "%s/public_key.pub", silcgaim_silcdir());
|
8849
|
1614 gaim_prefs_add_string("/plugins/prpl/silc/pubkey", tmp);
|
8891
|
1615 g_snprintf(tmp, sizeof(tmp), "%s/private_key.prv", silcgaim_silcdir());
|
8849
|
1616 gaim_prefs_add_string("/plugins/prpl/silc/privkey", tmp);
|
|
1617 gaim_prefs_add_string("/plugins/prpl/silc/vcard", "");
|
9272
|
1618
|
|
1619 silcgaim_register_commands();
|
9353
|
1620
|
|
1621 #ifdef _WIN32
|
|
1622 silc_net_win32_init();
|
|
1623 #endif
|
|
1624
|
8849
|
1625 }
|
|
1626
|
|
1627 GAIM_INIT_PLUGIN(silc, init_plugin, info);
|