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