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