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