8849
|
1 /*
|
|
2
|
|
3 silcgaim.c
|
|
4
|
|
5 Author: Pekka Riikonen <priikone@silcnet.org>
|
|
6
|
|
7 Copyright (C) 2004 Pekka Riikonen
|
|
8
|
|
9 This program is free software; you can redistribute it and/or modify
|
|
10 it under the terms of the GNU General Public License as published by
|
|
11 the Free Software Foundation; version 2 of the License.
|
|
12
|
|
13 This program is distributed in the hope that it will be useful,
|
|
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
16 GNU General Public License for more details.
|
|
17
|
|
18 */
|
|
19
|
|
20 #include "silcincludes.h"
|
|
21 #include "silcclient.h"
|
|
22 #include "silcgaim.h"
|
|
23
|
|
24 extern SilcClientOperations ops;
|
|
25 static GaimPlugin *silc_plugin = NULL;
|
|
26
|
|
27 static const char *
|
|
28 silcgaim_list_icon(GaimAccount *a, GaimBuddy *b)
|
|
29 {
|
|
30 return (const char *)"silc";
|
|
31 }
|
|
32
|
|
33 static void
|
|
34 silcgaim_list_emblems(GaimBuddy *b, char **se, char **sw,
|
|
35 char **nw, char **ne)
|
|
36 {
|
|
37 }
|
|
38
|
|
39 static GList *
|
|
40 silcgaim_away_states(GaimConnection *gc)
|
|
41 {
|
|
42 GList *st = NULL;
|
|
43
|
|
44 st = g_list_append(st, _("Online"));
|
|
45 st = g_list_append(st, _("Hyper Active"));
|
|
46 st = g_list_append(st, _("Away"));
|
|
47 st = g_list_append(st, _("Busy"));
|
|
48 st = g_list_append(st, _("Indisposed"));
|
|
49 st = g_list_append(st, _("Wake Me Up"));
|
|
50
|
|
51 return st;
|
|
52 }
|
|
53
|
|
54 static void
|
|
55 silcgaim_set_away(GaimConnection *gc, const char *state, const char *msg)
|
|
56 {
|
|
57 SilcGaim sg = gc->proto_data;
|
|
58 SilcUInt32 mode;
|
|
59 SilcBuffer idp;
|
|
60 unsigned char mb[4];
|
|
61
|
|
62 if (!state)
|
|
63 return;
|
|
64 if (!sg->conn)
|
|
65 return;
|
|
66
|
|
67 mode = sg->conn->local_entry->mode;
|
|
68 mode &= ~(SILC_UMODE_GONE |
|
|
69 SILC_UMODE_HYPER |
|
|
70 SILC_UMODE_BUSY |
|
|
71 SILC_UMODE_INDISPOSED |
|
|
72 SILC_UMODE_PAGE);
|
|
73
|
|
74 if (!strcmp(state, _("Hyper Active")))
|
|
75 mode |= SILC_UMODE_HYPER;
|
|
76 else if (!strcmp(state, _("Away")))
|
|
77 mode |= SILC_UMODE_GONE;
|
|
78 else if (!strcmp(state, _("Busy")))
|
|
79 mode |= SILC_UMODE_BUSY;
|
|
80 else if (!strcmp(state, _("Indisposed")))
|
|
81 mode |= SILC_UMODE_INDISPOSED;
|
|
82 else if (!strcmp(state, _("Wake Me Up")))
|
|
83 mode |= SILC_UMODE_PAGE;
|
|
84
|
|
85 /* Send UMODE */
|
|
86 idp = silc_id_payload_encode(sg->conn->local_id, SILC_ID_CLIENT);
|
|
87 SILC_PUT32_MSB(mode, mb);
|
|
88 silc_client_command_send(sg->client, sg->conn, SILC_COMMAND_UMODE,
|
|
89 ++sg->conn->cmd_ident, 2,
|
|
90 1, idp->data, idp->len,
|
|
91 2, mb, sizeof(mb));
|
|
92 silc_buffer_free(idp);
|
|
93 }
|
|
94
|
|
95
|
|
96 /*************************** Connection Routines *****************************/
|
|
97
|
|
98 static void
|
|
99 silcgaim_keepalive(GaimConnection *gc)
|
|
100 {
|
|
101 SilcGaim sg = gc->proto_data;
|
|
102 silc_client_send_packet(sg->client, sg->conn, SILC_PACKET_HEARTBEAT,
|
|
103 NULL, 0);
|
|
104 }
|
|
105
|
|
106 static int
|
|
107 silcgaim_scheduler(gpointer *context)
|
|
108 {
|
|
109 SilcGaim sg = (SilcGaim)context;
|
|
110 silc_client_run_one(sg->client);
|
|
111 return 1;
|
|
112 }
|
|
113
|
|
114 static void
|
|
115 silcgaim_nickname_parse(const char *nickname,
|
|
116 char **ret_nickname)
|
|
117 {
|
|
118 silc_parse_userfqdn(nickname, ret_nickname, NULL);
|
|
119 }
|
|
120
|
|
121 static void
|
|
122 silcgaim_login_connected(gpointer data, gint source, GaimInputCondition cond)
|
|
123 {
|
|
124 GaimConnection *gc = data;
|
|
125 SilcGaim sg = gc->proto_data;
|
|
126 SilcClient client = sg->client;
|
|
127 SilcClientConnection conn;
|
|
128 GaimAccount *account = sg->account;
|
|
129 SilcClientConnectionParams params;
|
|
130 const char *dfile;
|
|
131
|
|
132 if (source < 0) {
|
|
133 gaim_connection_error(gc, _("Connection failed"));
|
|
134 return;
|
|
135 }
|
|
136 if (!g_list_find(gaim_connections_get_all(), gc)) {
|
|
137 close(source);
|
|
138 g_source_remove(sg->scheduler);
|
|
139 silc_client_stop(sg->client);
|
|
140 silc_client_free(sg->client);
|
|
141 silc_free(sg);
|
|
142 return;
|
|
143 }
|
|
144
|
|
145 /* Get session detachment data, if available */
|
|
146 memset(¶ms, 0, sizeof(params));
|
|
147 dfile = silcgaim_session_file(gaim_account_get_username(sg->account));
|
|
148 params.detach_data = silc_file_readfile(dfile, ¶ms.detach_data_len);
|
|
149 if (params.detach_data)
|
|
150 params.detach_data[params.detach_data_len] = 0;
|
|
151
|
|
152 /* Add connection to SILC client library */
|
|
153 conn = silc_client_add_connection(
|
|
154 sg->client, ¶ms,
|
|
155 (char *)gaim_account_get_string(account, "server",
|
|
156 "silc.silcnet.org"),
|
|
157 gaim_account_get_int(account, "port", 706), sg);
|
|
158 if (!conn) {
|
|
159 gaim_connection_error(gc, _("Cannot initialize SILC Client connection"));
|
|
160 gc->proto_data = NULL;
|
|
161 return;
|
|
162 }
|
|
163 sg->conn = conn;
|
|
164
|
|
165 /* Progress */
|
|
166 if (params.detach_data) {
|
|
167 gaim_connection_update_progress(gc, _("Resuming session"), 2, 5);
|
|
168 sg->resuming = TRUE;
|
|
169 } else {
|
|
170 gaim_connection_update_progress(gc, _("Performing key exchange"), 2, 5);
|
|
171 }
|
|
172
|
|
173 /* Perform SILC Key Exchange. The "silc_connected" will be called
|
|
174 eventually. */
|
|
175 silc_client_start_key_exchange(sg->client, sg->conn, source);
|
|
176
|
|
177 /* Set default attributes */
|
|
178 if (!gaim_account_get_bool(account, "reject-attrs", FALSE)) {
|
|
179 SilcUInt32 mask;
|
|
180 const char *tmp;
|
|
181 #ifdef HAVE_SYS_UTSNAME_H
|
|
182 struct utsname u;
|
|
183 #endif
|
|
184
|
|
185 mask = SILC_ATTRIBUTE_MOOD_NORMAL;
|
|
186 silc_client_attribute_add(client, conn,
|
|
187 SILC_ATTRIBUTE_STATUS_MOOD,
|
|
188 SILC_32_TO_PTR(mask),
|
|
189 sizeof(SilcUInt32));
|
|
190 mask = SILC_ATTRIBUTE_CONTACT_CHAT;
|
|
191 silc_client_attribute_add(client, conn,
|
|
192 SILC_ATTRIBUTE_PREFERRED_CONTACT,
|
|
193 SILC_32_TO_PTR(mask),
|
|
194 sizeof(SilcUInt32));
|
|
195 #ifdef HAVE_SYS_UTSNAME_H
|
|
196 if (!uname(&u)) {
|
|
197 SilcAttributeObjDevice dev;
|
|
198 memset(&dev, 0, sizeof(dev));
|
|
199 dev.type = SILC_ATTRIBUTE_DEVICE_COMPUTER;
|
|
200 dev.version = u.release;
|
|
201 dev.model = u.sysname;
|
|
202 silc_client_attribute_add(client, conn,
|
|
203 SILC_ATTRIBUTE_DEVICE_INFO,
|
|
204 (void *)&dev, sizeof(dev));
|
|
205 }
|
|
206 #endif
|
|
207 #ifdef _WIN32
|
|
208 tmp = _tzname[0];
|
|
209 #else
|
|
210 tmp = tzname[0];
|
|
211 #endif
|
|
212 silc_client_attribute_add(client, conn,
|
|
213 SILC_ATTRIBUTE_TIMEZONE,
|
|
214 (void *)tmp, strlen(tmp));
|
|
215 }
|
|
216
|
|
217 silc_free(params.detach_data);
|
|
218 }
|
|
219
|
|
220 static void
|
|
221 silcgaim_login(GaimAccount *account)
|
|
222 {
|
|
223 SilcGaim sg;
|
|
224 SilcClient client;
|
|
225 SilcClientParams params;
|
|
226 GaimConnection *gc;
|
|
227
|
|
228 gc = account->gc;
|
|
229 if (!gc)
|
|
230 return;
|
|
231 gc->proto_data = NULL;
|
|
232
|
|
233 memset(¶ms, 0, sizeof(params));
|
|
234 strcat(params.nickname_format, "%n@%h%a");
|
|
235 params.nickname_parse = silcgaim_nickname_parse;
|
|
236 params.ignore_requested_attributes =
|
|
237 gaim_account_get_bool(account, "reject-attrs", FALSE);
|
|
238
|
|
239 /* Allocate SILC client */
|
|
240 client = silc_client_alloc(&ops, ¶ms, gc, NULL);
|
|
241 if (!client) {
|
|
242 gaim_connection_error(gc, _("Out of memory"));
|
|
243 return;
|
|
244 }
|
|
245
|
|
246 /* Get username, real name and local hostname for SILC library */
|
|
247 if (gaim_account_get_username(account)) {
|
|
248 client->username = strdup(gaim_account_get_username(account));
|
|
249 } else {
|
|
250 client->username = silc_get_username();
|
|
251 gaim_account_set_username(account, client->username);
|
|
252 }
|
|
253 if (gaim_account_get_user_info(account)) {
|
|
254 client->realname = strdup(gaim_account_get_user_info(account));
|
|
255 } else {
|
|
256 client->realname = silc_get_real_name();
|
|
257 gaim_account_set_user_info(account, client->realname);
|
|
258 }
|
|
259 client->hostname = silc_net_localhost();
|
|
260
|
|
261 gaim_connection_set_display_name(gc, client->username);
|
|
262
|
|
263 /* Init SILC client */
|
|
264 if (!silc_client_init(client)) {
|
|
265 gaim_connection_error(gc, ("Cannot initialize SILC protocol"));
|
|
266 return;
|
|
267 }
|
|
268
|
|
269 /* Check the ~/.silc dir and create it, and new key pair if necessary. */
|
|
270 if (!silcgaim_check_silc_dir(gc)) {
|
|
271 gaim_connection_error(gc, ("Cannot find/access ~/.silc directory"));
|
|
272 return;
|
|
273 }
|
|
274
|
|
275 /* Progress */
|
|
276 gaim_connection_update_progress(gc, _("Connecting to SILC Server"), 1, 5);
|
|
277
|
|
278 /* Load SILC key pair */
|
|
279 if (!silc_load_key_pair(gaim_prefs_get_string("/plugins/prpl/silc/pubkey"),
|
|
280 gaim_prefs_get_string("/plugins/prpl/silc/privkey"),
|
|
281 "", &client->pkcs, &client->public_key,
|
|
282 &client->private_key)) {
|
|
283 gaim_connection_error(gc, ("Could not load SILC key pair"));
|
|
284 return;
|
|
285 }
|
|
286
|
|
287 sg = silc_calloc(1, sizeof(*sg));
|
|
288 if (!sg)
|
|
289 return;
|
|
290 memset(sg, 0, sizeof(*sg));
|
|
291 sg->client = client;
|
|
292 sg->gc = gc;
|
|
293 sg->account = account;
|
|
294 gc->proto_data = sg;
|
|
295
|
|
296 /* Connect to the SILC server */
|
|
297 if (gaim_proxy_connect(account,
|
|
298 gaim_account_get_string(account, "server",
|
|
299 "silc.silcnet.org"),
|
|
300 gaim_account_get_int(account, "port", 706),
|
|
301 silcgaim_login_connected, gc)) {
|
|
302 gaim_connection_error(gc, ("Unable to create connection"));
|
|
303 return;
|
|
304 }
|
|
305
|
|
306 /* Schedule SILC using Glib's event loop */
|
|
307 sg->scheduler = g_timeout_add(5, (GSourceFunc)silcgaim_scheduler, sg);
|
|
308 }
|
|
309
|
|
310 static int
|
|
311 silcgaim_close_final(gpointer *context)
|
|
312 {
|
|
313 SilcGaim sg = (SilcGaim)context;
|
|
314 silc_client_stop(sg->client);
|
|
315 silc_client_free(sg->client);
|
|
316 silc_free(sg);
|
|
317 return 0;
|
|
318 }
|
|
319
|
|
320 static void
|
|
321 silcgaim_close_convos(GaimConversation *convo)
|
|
322 {
|
|
323 if (convo)
|
|
324 gaim_conversation_destroy(convo);
|
|
325 }
|
|
326
|
|
327 static void
|
|
328 silcgaim_close(GaimConnection *gc)
|
|
329 {
|
|
330 SilcGaim sg = gc->proto_data;
|
|
331 if (!sg)
|
|
332 return;
|
|
333
|
|
334 /* Close all conversations */
|
|
335 gaim_conversation_foreach(silcgaim_close_convos);
|
|
336
|
|
337 /* Send QUIT */
|
|
338 silc_client_command_call(sg->client, sg->conn, NULL,
|
|
339 "QUIT", "Leaving", NULL);
|
|
340
|
|
341 if (sg->conn)
|
|
342 silc_client_close_connection(sg->client, sg->conn);
|
|
343
|
|
344 g_source_remove(sg->scheduler);
|
|
345 g_timeout_add(1, (GSourceFunc)silcgaim_close_final, sg);
|
|
346 }
|
|
347
|
|
348
|
|
349 /****************************** Protocol Actions *****************************/
|
|
350
|
|
351 static void
|
|
352 silcgaim_attrs_cancel(GaimConnection *gc, GaimRequestFields *fields)
|
|
353 {
|
|
354 /* Nothing */
|
|
355 }
|
|
356
|
|
357 static void
|
|
358 silcgaim_attrs_cb(GaimConnection *gc, GaimRequestFields *fields)
|
|
359 {
|
|
360 SilcGaim sg = gc->proto_data;
|
|
361 SilcClient client = sg->client;
|
|
362 SilcClientConnection conn = sg->conn;
|
|
363 GaimRequestField *f;
|
|
364 char *tmp;
|
|
365 SilcUInt32 tmp_len, mask;
|
|
366 SilcAttributeObjService service;
|
|
367 SilcAttributeObjDevice dev;
|
|
368 SilcVCardStruct vcard;
|
|
369 const char *val;
|
|
370
|
|
371 sg = gc->proto_data;
|
|
372 if (!sg)
|
|
373 return;
|
|
374
|
|
375 memset(&service, 0, sizeof(service));
|
|
376 memset(&dev, 0, sizeof(dev));
|
|
377 memset(&vcard, 0, sizeof(vcard));
|
|
378
|
|
379 silc_client_attribute_del(client, conn,
|
|
380 SILC_ATTRIBUTE_USER_INFO, NULL);
|
|
381 silc_client_attribute_del(client, conn,
|
|
382 SILC_ATTRIBUTE_SERVICE, NULL);
|
|
383 silc_client_attribute_del(client, conn,
|
|
384 SILC_ATTRIBUTE_STATUS_MOOD, NULL);
|
|
385 silc_client_attribute_del(client, conn,
|
|
386 SILC_ATTRIBUTE_STATUS_FREETEXT, NULL);
|
|
387 silc_client_attribute_del(client, conn,
|
|
388 SILC_ATTRIBUTE_STATUS_MESSAGE, NULL);
|
|
389 silc_client_attribute_del(client, conn,
|
|
390 SILC_ATTRIBUTE_PREFERRED_LANGUAGE, NULL);
|
|
391 silc_client_attribute_del(client, conn,
|
|
392 SILC_ATTRIBUTE_PREFERRED_CONTACT, NULL);
|
|
393 silc_client_attribute_del(client, conn,
|
|
394 SILC_ATTRIBUTE_TIMEZONE, NULL);
|
|
395 silc_client_attribute_del(client, conn,
|
|
396 SILC_ATTRIBUTE_GEOLOCATION, NULL);
|
|
397 silc_client_attribute_del(client, conn,
|
|
398 SILC_ATTRIBUTE_DEVICE_INFO, NULL);
|
|
399
|
|
400 /* Set mood */
|
|
401 mask = 0;
|
|
402 f = gaim_request_fields_get_field(fields, "mood_normal");
|
|
403 if (f && gaim_request_field_bool_get_value(f))
|
|
404 mask |= SILC_ATTRIBUTE_MOOD_NORMAL;
|
|
405 f = gaim_request_fields_get_field(fields, "mood_happy");
|
|
406 if (f && gaim_request_field_bool_get_value(f))
|
|
407 mask |= SILC_ATTRIBUTE_MOOD_HAPPY;
|
|
408 f = gaim_request_fields_get_field(fields, "mood_sad");
|
|
409 if (f && gaim_request_field_bool_get_value(f))
|
|
410 mask |= SILC_ATTRIBUTE_MOOD_SAD;
|
|
411 f = gaim_request_fields_get_field(fields, "mood_angry");
|
|
412 if (f && gaim_request_field_bool_get_value(f))
|
|
413 mask |= SILC_ATTRIBUTE_MOOD_ANGRY;
|
|
414 f = gaim_request_fields_get_field(fields, "mood_jealous");
|
|
415 if (f && gaim_request_field_bool_get_value(f))
|
|
416 mask |= SILC_ATTRIBUTE_MOOD_JEALOUS;
|
|
417 f = gaim_request_fields_get_field(fields, "mood_ashamed");
|
|
418 if (f && gaim_request_field_bool_get_value(f))
|
|
419 mask |= SILC_ATTRIBUTE_MOOD_ASHAMED;
|
|
420 f = gaim_request_fields_get_field(fields, "mood_invincible");
|
|
421 if (f && gaim_request_field_bool_get_value(f))
|
|
422 mask |= SILC_ATTRIBUTE_MOOD_INVINCIBLE;
|
|
423 f = gaim_request_fields_get_field(fields, "mood_inlove");
|
|
424 if (f && gaim_request_field_bool_get_value(f))
|
|
425 mask |= SILC_ATTRIBUTE_MOOD_INLOVE;
|
|
426 f = gaim_request_fields_get_field(fields, "mood_sleepy");
|
|
427 if (f && gaim_request_field_bool_get_value(f))
|
|
428 mask |= SILC_ATTRIBUTE_MOOD_SLEEPY;
|
|
429 f = gaim_request_fields_get_field(fields, "mood_bored");
|
|
430 if (f && gaim_request_field_bool_get_value(f))
|
|
431 mask |= SILC_ATTRIBUTE_MOOD_BORED;
|
|
432 f = gaim_request_fields_get_field(fields, "mood_excited");
|
|
433 if (f && gaim_request_field_bool_get_value(f))
|
|
434 mask |= SILC_ATTRIBUTE_MOOD_EXCITED;
|
|
435 f = gaim_request_fields_get_field(fields, "mood_anxious");
|
|
436 if (f && gaim_request_field_bool_get_value(f))
|
|
437 mask |= SILC_ATTRIBUTE_MOOD_ANXIOUS;
|
|
438 silc_client_attribute_add(client, conn,
|
|
439 SILC_ATTRIBUTE_STATUS_MOOD,
|
|
440 SILC_32_TO_PTR(mask),
|
|
441 sizeof(SilcUInt32));
|
|
442
|
|
443 /* Set preferred contact */
|
|
444 mask = 0;
|
|
445 f = gaim_request_fields_get_field(fields, "contact_chat");
|
|
446 if (f && gaim_request_field_bool_get_value(f))
|
|
447 mask |= SILC_ATTRIBUTE_CONTACT_CHAT;
|
|
448 f = gaim_request_fields_get_field(fields, "contact_email");
|
|
449 if (f && gaim_request_field_bool_get_value(f))
|
|
450 mask |= SILC_ATTRIBUTE_CONTACT_EMAIL;
|
|
451 f = gaim_request_fields_get_field(fields, "contact_call");
|
|
452 if (f && gaim_request_field_bool_get_value(f))
|
|
453 mask |= SILC_ATTRIBUTE_CONTACT_CALL;
|
|
454 f = gaim_request_fields_get_field(fields, "contact_sms");
|
|
455 if (f && gaim_request_field_bool_get_value(f))
|
|
456 mask |= SILC_ATTRIBUTE_CONTACT_SMS;
|
|
457 f = gaim_request_fields_get_field(fields, "contact_mms");
|
|
458 if (f && gaim_request_field_bool_get_value(f))
|
|
459 mask |= SILC_ATTRIBUTE_CONTACT_MMS;
|
|
460 f = gaim_request_fields_get_field(fields, "contact_video");
|
|
461 if (f && gaim_request_field_bool_get_value(f))
|
|
462 mask |= SILC_ATTRIBUTE_CONTACT_VIDEO;
|
|
463 if (mask)
|
|
464 silc_client_attribute_add(client, conn,
|
|
465 SILC_ATTRIBUTE_PREFERRED_CONTACT,
|
|
466 SILC_32_TO_PTR(mask),
|
|
467 sizeof(SilcUInt32));
|
|
468
|
|
469 /* Set status text */
|
|
470 val = NULL;
|
|
471 f = gaim_request_fields_get_field(fields, "status_text");
|
|
472 if (f)
|
|
473 val = gaim_request_field_string_get_value(f);
|
|
474 if (val && *val)
|
|
475 silc_client_attribute_add(client, conn,
|
|
476 SILC_ATTRIBUTE_STATUS_FREETEXT,
|
|
477 (void *)val, strlen(val));
|
|
478
|
|
479 /* Set vcard */
|
|
480 val = NULL;
|
|
481 f = gaim_request_fields_get_field(fields, "vcard");
|
|
482 if (f)
|
|
483 val = gaim_request_field_string_get_value(f);
|
|
484 if (val && *val) {
|
|
485 gaim_prefs_set_string("/plugins/prpl/silc/vcard", val);
|
|
486 gaim_prefs_sync();
|
|
487 tmp = silc_file_readfile(val, &tmp_len);
|
|
488 if (tmp) {
|
|
489 tmp[tmp_len] = 0;
|
|
490 if (silc_vcard_decode(tmp, tmp_len, &vcard))
|
|
491 silc_client_attribute_add(client, conn,
|
|
492 SILC_ATTRIBUTE_USER_INFO,
|
|
493 (void *)&vcard,
|
|
494 sizeof(vcard));
|
|
495 }
|
|
496 silc_vcard_free(&vcard);
|
|
497 silc_free(tmp);
|
|
498 }
|
|
499
|
|
500 #ifdef HAVE_SYS_UTSNAME_H
|
|
501 /* Set device info */
|
|
502 f = gaim_request_fields_get_field(fields, "device");
|
|
503 if (f && gaim_request_field_bool_get_value(f)) {
|
|
504 struct utsname u;
|
|
505 if (!uname(&u)) {
|
|
506 dev.type = SILC_ATTRIBUTE_DEVICE_COMPUTER;
|
|
507 dev.version = u.release;
|
|
508 dev.model = u.sysname;
|
|
509 silc_client_attribute_add(client, conn,
|
|
510 SILC_ATTRIBUTE_DEVICE_INFO,
|
|
511 (void *)&dev, sizeof(dev));
|
|
512 }
|
|
513 }
|
|
514 #endif
|
|
515
|
|
516 /* Set timezone */
|
|
517 val = NULL;
|
|
518 f = gaim_request_fields_get_field(fields, "timezone");
|
|
519 if (f)
|
|
520 val = gaim_request_field_string_get_value(f);
|
|
521 if (val && *val)
|
|
522 silc_client_attribute_add(client, conn,
|
|
523 SILC_ATTRIBUTE_TIMEZONE,
|
|
524 (void *)val, strlen(val));
|
|
525 }
|
|
526
|
|
527 static void
|
9015
|
528 silcgaim_attrs(GaimPluginAction *action)
|
8849
|
529 {
|
9015
|
530 GaimConnection *gc = (GaimConnection *) action->context;
|
8849
|
531 SilcGaim sg = gc->proto_data;
|
|
532 SilcClient client = sg->client;
|
|
533 SilcClientConnection conn = sg->conn;
|
|
534 GaimRequestFields *fields;
|
|
535 GaimRequestFieldGroup *g;
|
|
536 GaimRequestField *f;
|
|
537 SilcHashTable attrs;
|
|
538 SilcAttributePayload attr;
|
|
539 gboolean mnormal = TRUE, mhappy = FALSE, msad = FALSE,
|
|
540 mangry = FALSE, mjealous = FALSE, mashamed = FALSE,
|
|
541 minvincible = FALSE, minlove = FALSE, msleepy = FALSE,
|
|
542 mbored = FALSE, mexcited = FALSE, manxious = FALSE;
|
|
543 gboolean cemail = FALSE, ccall = FALSE, csms = FALSE,
|
|
544 cmms = FALSE, cchat = TRUE, cvideo = FALSE;
|
|
545 gboolean device = TRUE;
|
|
546 char status[1024];
|
|
547
|
|
548 sg = gc->proto_data;
|
|
549 if (!sg)
|
|
550 return;
|
|
551
|
|
552 memset(status, 0, sizeof(status));
|
|
553
|
|
554 attrs = silc_client_attributes_get(client, conn);
|
|
555 if (attrs) {
|
|
556 if (silc_hash_table_find(attrs,
|
|
557 SILC_32_TO_PTR(SILC_ATTRIBUTE_STATUS_MOOD),
|
|
558 NULL, (void *)&attr)) {
|
|
559 SilcUInt32 mood = 0;
|
|
560 silc_attribute_get_object(attr, &mood, sizeof(mood));
|
|
561 mnormal = !mood;
|
|
562 mhappy = (mood & SILC_ATTRIBUTE_MOOD_HAPPY);
|
|
563 msad = (mood & SILC_ATTRIBUTE_MOOD_SAD);
|
|
564 mangry = (mood & SILC_ATTRIBUTE_MOOD_ANGRY);
|
|
565 mjealous = (mood & SILC_ATTRIBUTE_MOOD_JEALOUS);
|
|
566 mashamed = (mood & SILC_ATTRIBUTE_MOOD_ASHAMED);
|
|
567 minvincible = (mood & SILC_ATTRIBUTE_MOOD_INVINCIBLE);
|
|
568 minlove = (mood & SILC_ATTRIBUTE_MOOD_INLOVE);
|
|
569 msleepy = (mood & SILC_ATTRIBUTE_MOOD_SLEEPY);
|
|
570 mbored = (mood & SILC_ATTRIBUTE_MOOD_BORED);
|
|
571 mexcited = (mood & SILC_ATTRIBUTE_MOOD_EXCITED);
|
|
572 manxious = (mood & SILC_ATTRIBUTE_MOOD_ANXIOUS);
|
|
573 }
|
|
574
|
|
575 if (silc_hash_table_find(attrs,
|
|
576 SILC_32_TO_PTR(SILC_ATTRIBUTE_PREFERRED_CONTACT),
|
|
577 NULL, (void *)&attr)) {
|
|
578 SilcUInt32 contact = 0;
|
|
579 silc_attribute_get_object(attr, &contact, sizeof(contact));
|
|
580 cemail = (contact & SILC_ATTRIBUTE_CONTACT_EMAIL);
|
|
581 ccall = (contact & SILC_ATTRIBUTE_CONTACT_CALL);
|
|
582 csms = (contact & SILC_ATTRIBUTE_CONTACT_SMS);
|
|
583 cmms = (contact & SILC_ATTRIBUTE_CONTACT_MMS);
|
|
584 cchat = (contact & SILC_ATTRIBUTE_CONTACT_CHAT);
|
|
585 cvideo = (contact & SILC_ATTRIBUTE_CONTACT_VIDEO);
|
|
586 }
|
|
587
|
|
588 if (silc_hash_table_find(attrs,
|
|
589 SILC_32_TO_PTR(SILC_ATTRIBUTE_STATUS_FREETEXT),
|
|
590 NULL, (void *)&attr))
|
|
591 silc_attribute_get_object(attr, &status, sizeof(status));
|
|
592
|
|
593 if (!silc_hash_table_find(attrs,
|
|
594 SILC_32_TO_PTR(SILC_ATTRIBUTE_DEVICE_INFO),
|
|
595 NULL, (void *)&attr))
|
|
596 device = FALSE;
|
|
597 }
|
|
598
|
|
599 fields = gaim_request_fields_new();
|
|
600
|
|
601 g = gaim_request_field_group_new(NULL);
|
|
602 f = gaim_request_field_label_new("l3", _("Your Current Mood"));
|
|
603 gaim_request_field_group_add_field(g, f);
|
|
604 f = gaim_request_field_bool_new("mood_normal", _("Normal"), mnormal);
|
|
605 gaim_request_field_group_add_field(g, f);
|
|
606 f = gaim_request_field_bool_new("mood_happy", _("Happy"), mhappy);
|
|
607 gaim_request_field_group_add_field(g, f);
|
|
608 f = gaim_request_field_bool_new("mood_sad", _("Sad"), msad);
|
|
609 gaim_request_field_group_add_field(g, f);
|
|
610 f = gaim_request_field_bool_new("mood_angry", _("Angry"), mangry);
|
|
611 gaim_request_field_group_add_field(g, f);
|
|
612 f = gaim_request_field_bool_new("mood_jealous", _("Jealous"), mjealous);
|
|
613 gaim_request_field_group_add_field(g, f);
|
|
614 f = gaim_request_field_bool_new("mood_ashamed", _("Ashamed"), mashamed);
|
|
615 gaim_request_field_group_add_field(g, f);
|
|
616 f = gaim_request_field_bool_new("mood_invincible", _("Invincible"), minvincible);
|
|
617 gaim_request_field_group_add_field(g, f);
|
|
618 f = gaim_request_field_bool_new("mood_inlove", _("In Love"), minlove);
|
|
619 gaim_request_field_group_add_field(g, f);
|
|
620 f = gaim_request_field_bool_new("mood_sleepy", _("Sleepy"), msleepy);
|
|
621 gaim_request_field_group_add_field(g, f);
|
|
622 f = gaim_request_field_bool_new("mood_bored", _("Bored"), mbored);
|
|
623 gaim_request_field_group_add_field(g, f);
|
|
624 f = gaim_request_field_bool_new("mood_excited", _("Excited"), mexcited);
|
|
625 gaim_request_field_group_add_field(g, f);
|
|
626 f = gaim_request_field_bool_new("mood_anxious", _("Anxious"), manxious);
|
|
627 gaim_request_field_group_add_field(g, f);
|
|
628
|
|
629 f = gaim_request_field_label_new("l4", _("\nYour Preferred Contact Methods"));
|
|
630 gaim_request_field_group_add_field(g, f);
|
|
631 f = gaim_request_field_bool_new("contact_chat", _("Chat"), cchat);
|
|
632 gaim_request_field_group_add_field(g, f);
|
|
633 f = gaim_request_field_bool_new("contact_email", _("Email"), cemail);
|
|
634 gaim_request_field_group_add_field(g, f);
|
|
635 f = gaim_request_field_bool_new("contact_call", _("Phone"), ccall);
|
|
636 gaim_request_field_group_add_field(g, f);
|
|
637 f = gaim_request_field_bool_new("contact_sms", _("SMS"), csms);
|
|
638 gaim_request_field_group_add_field(g, f);
|
|
639 f = gaim_request_field_bool_new("contact_mms", _("MMS"), cmms);
|
|
640 gaim_request_field_group_add_field(g, f);
|
|
641 f = gaim_request_field_bool_new("contact_video", _("Video Conferencing"), cvideo);
|
|
642 gaim_request_field_group_add_field(g, f);
|
|
643 gaim_request_fields_add_group(fields, g);
|
|
644
|
|
645 g = gaim_request_field_group_new(NULL);
|
|
646 f = gaim_request_field_string_new("status_text", _("Your Current Status"),
|
|
647 status[0] ? status : NULL, TRUE);
|
|
648 gaim_request_field_group_add_field(g, f);
|
|
649 gaim_request_fields_add_group(fields, g);
|
|
650
|
|
651 g = gaim_request_field_group_new(NULL);
|
|
652 #if 0
|
|
653 f = gaim_request_field_label_new("l2", _("Online Services"));
|
|
654 gaim_request_field_group_add_field(g, f);
|
|
655 f = gaim_request_field_bool_new("services",
|
|
656 _("Let others see what services you are using"),
|
|
657 TRUE);
|
|
658 gaim_request_field_group_add_field(g, f);
|
|
659 #endif
|
|
660 #ifdef HAVE_SYS_UTSNAME_H
|
|
661 f = gaim_request_field_bool_new("device",
|
|
662 _("Let others see what computer you are using"),
|
|
663 device);
|
|
664 gaim_request_field_group_add_field(g, f);
|
|
665 #endif
|
|
666 gaim_request_fields_add_group(fields, g);
|
|
667
|
|
668 g = gaim_request_field_group_new(NULL);
|
|
669 f = gaim_request_field_string_new("vcard", _("Your VCard File"),
|
|
670 gaim_prefs_get_string("/plugins/prpl/silc/vcard"),
|
|
671 FALSE);
|
|
672 gaim_request_field_group_add_field(g, f);
|
|
673 #ifdef _WIN32
|
|
674 f = gaim_request_field_string_new("timezone", _("Timezone"), _tzname[0], FALSE);
|
|
675 #else
|
|
676 f = gaim_request_field_string_new("timezone", _("Timezone"), tzname[0], FALSE);
|
|
677 #endif
|
|
678 gaim_request_field_group_add_field(g, f);
|
|
679 gaim_request_fields_add_group(fields, g);
|
|
680
|
|
681
|
|
682 gaim_request_fields(NULL, _("User Online Status Attributes"),
|
|
683 _("User Online Status Attributes"),
|
|
684 _("You can let other users see your online status information "
|
|
685 "and your personal information. Please fill the information "
|
|
686 "you would like other users to see about yourself."),
|
|
687 fields,
|
8906
|
688 _("OK"), G_CALLBACK(silcgaim_attrs_cb),
|
|
689 _("Cancel"), G_CALLBACK(silcgaim_attrs_cancel), gc);
|
8849
|
690 }
|
|
691
|
|
692 static void
|
9015
|
693 silcgaim_detach(GaimPluginAction *action)
|
8849
|
694 {
|
9015
|
695 GaimConnection *gc = (GaimConnection *) action->context;
|
8849
|
696 SilcGaim sg;
|
|
697
|
|
698 if (!gc)
|
|
699 return;
|
|
700 sg = gc->proto_data;
|
|
701 if (!sg)
|
|
702 return;
|
|
703
|
|
704 /* Call DETACH */
|
|
705 silc_client_command_call(sg->client, sg->conn, "DETACH");
|
|
706 sg->detaching = TRUE;
|
|
707 }
|
|
708
|
|
709 static void
|
9015
|
710 silcgaim_view_motd(GaimPluginAction *action)
|
8849
|
711 {
|
9015
|
712 GaimConnection *gc = (GaimConnection *) action->context;
|
8849
|
713 SilcGaim sg;
|
|
714
|
|
715 if (!gc)
|
|
716 return;
|
|
717 sg = gc->proto_data;
|
|
718 if (!sg)
|
|
719 return;
|
|
720
|
|
721 if (!sg->motd) {
|
|
722 gaim_notify_error(
|
|
723 gc, _("Message of the Day"), _("No Message of the Day available"),
|
|
724 _("There is no Message of the Day associated with this connection"));
|
|
725 return;
|
|
726 }
|
|
727
|
9039
|
728 gaim_notify_formatted(gc, _("Message of the Day"), _("Message of the Day"), NULL,
|
8849
|
729 sg->motd, NULL, NULL);
|
|
730 }
|
|
731
|
|
732 static GList *
|
9015
|
733 silcgaim_actions(GaimPlugin *plugin, gpointer context)
|
8849
|
734 {
|
9024
|
735 GaimConnection *gc = context;
|
8849
|
736 GList *list = NULL;
|
9015
|
737 GaimPluginAction *act;
|
8849
|
738
|
|
739 if (!gaim_account_get_bool(gc->account, "reject-attrs", FALSE)) {
|
9015
|
740 act = gaim_plugin_action_new(_("Online Status"),
|
|
741 silcgaim_attrs);
|
|
742 list = g_list_append(list, act);
|
8849
|
743 }
|
|
744
|
9015
|
745 act = gaim_plugin_action_new(_("Detach From Server"),
|
|
746 silcgaim_detach);
|
|
747 list = g_list_append(list, act);
|
8849
|
748
|
9015
|
749 act = gaim_plugin_action_new(_("View Message of the Day"),
|
|
750 silcgaim_view_motd);
|
|
751 list = g_list_append(list, act);
|
8849
|
752
|
|
753 return list;
|
|
754 }
|
|
755
|
|
756
|
|
757 /******************************* IM Routines *********************************/
|
|
758
|
|
759 typedef struct {
|
|
760 char *nick;
|
|
761 unsigned char *message;
|
|
762 SilcUInt32 message_len;
|
|
763 SilcMessageFlags flags;
|
|
764 } *SilcGaimIM;
|
|
765
|
|
766 static void
|
|
767 silcgaim_send_im_resolved(SilcClient client,
|
|
768 SilcClientConnection conn,
|
|
769 SilcClientEntry *clients,
|
|
770 SilcUInt32 clients_count,
|
|
771 void *context)
|
|
772 {
|
|
773 GaimConnection *gc = client->application;
|
|
774 SilcGaim sg = gc->proto_data;
|
|
775 SilcGaimIM im = context;
|
|
776 GaimConversation *convo;
|
|
777 char tmp[256], *nickname = NULL;
|
|
778 SilcClientEntry client_entry;
|
|
779
|
|
780 convo = gaim_find_conversation_with_account(im->nick, sg->account);
|
|
781 if (!convo)
|
|
782 return;
|
|
783
|
|
784 if (!clients)
|
|
785 goto err;
|
|
786
|
|
787 if (clients_count > 1) {
|
|
788 silc_parse_userfqdn(im->nick, &nickname, NULL);
|
|
789
|
|
790 /* Find the correct one. The im->nick might be a formatted nick
|
|
791 so this will find the correct one. */
|
|
792 clients = silc_client_get_clients_local(client, conn,
|
|
793 nickname, im->nick,
|
|
794 &clients_count);
|
|
795 if (!clients)
|
|
796 goto err;
|
|
797 client_entry = clients[0];
|
|
798 silc_free(clients);
|
|
799 } else {
|
|
800 client_entry = clients[0];
|
|
801 }
|
|
802
|
|
803 /* Send the message */
|
|
804 silc_client_send_private_message(client, conn, client_entry, im->flags,
|
|
805 im->message, im->message_len, TRUE);
|
|
806 gaim_conv_im_write(GAIM_CONV_IM(convo), conn->local_entry->nickname,
|
|
807 im->message, 0, time(NULL));
|
|
808
|
|
809 goto out;
|
|
810
|
|
811 err:
|
|
812 g_snprintf(tmp, sizeof(tmp),
|
|
813 _("User <I>%s</I> is not present in the network"), im->nick);
|
|
814 gaim_conversation_write(convo, NULL, tmp, GAIM_MESSAGE_SYSTEM, time(NULL));
|
|
815
|
|
816 out:
|
|
817 g_free(im->nick);
|
|
818 g_free(im->message);
|
|
819 silc_free(im);
|
|
820 silc_free(nickname);
|
|
821 }
|
|
822
|
|
823 static int
|
|
824 silcgaim_send_im(GaimConnection *gc, const char *who, const char *msg,
|
|
825 GaimConvImFlags flags)
|
|
826 {
|
|
827 SilcGaim sg = gc->proto_data;
|
|
828 SilcClient client = sg->client;
|
|
829 SilcClientConnection conn = sg->conn;
|
|
830 SilcClientEntry *clients;
|
|
831 SilcUInt32 clients_count, mflags;
|
|
832 char *nickname;
|
|
833 int ret;
|
|
834 gboolean sign = gaim_prefs_get_bool("/plugins/prpl/silc/sign_im");
|
|
835
|
|
836 if (!who || !msg)
|
|
837 return 0;
|
|
838
|
|
839 /* See if command */
|
|
840 if (strlen(msg) > 1 && msg[0] == '/') {
|
|
841 if (!silc_client_command_call(client, conn, msg + 1))
|
|
842 gaim_notify_error(gc, ("Call Command"), _("Cannot call command"),
|
|
843 _("Unknown command"));
|
|
844 return 0;
|
|
845 }
|
|
846
|
|
847 if (!silc_parse_userfqdn(who, &nickname, NULL))
|
|
848 return 0;
|
|
849
|
|
850 mflags = SILC_MESSAGE_FLAG_UTF8;
|
|
851 if (sign)
|
|
852 mflags |= SILC_MESSAGE_FLAG_SIGNED;
|
|
853
|
|
854 /* Find client entry */
|
|
855 clients = silc_client_get_clients_local(client, conn, nickname, who,
|
|
856 &clients_count);
|
|
857 if (!clients) {
|
|
858 /* Resolve unknown user */
|
|
859 SilcGaimIM im = silc_calloc(1, sizeof(*im));
|
|
860 if (!im)
|
|
861 return 0;
|
|
862 im->nick = g_strdup(who);
|
|
863 im->message = g_strdup(msg);
|
|
864 im->message_len = strlen(im->message);
|
|
865 im->flags = mflags;
|
|
866 silc_client_get_clients(client, conn, nickname, NULL,
|
|
867 silcgaim_send_im_resolved, im);
|
|
868 silc_free(nickname);
|
|
869 return 0;
|
|
870 }
|
|
871
|
|
872 /* Send private message directly */
|
|
873 ret = silc_client_send_private_message(client, conn, clients[0],
|
|
874 mflags, (char *)msg,
|
|
875 strlen(msg), TRUE);
|
|
876
|
|
877 silc_free(nickname);
|
|
878 silc_free(clients);
|
|
879 return ret;
|
|
880 }
|
|
881
|
|
882
|
9030
|
883 GList *silcgaim_blist_node_menu(GaimBlistNode *node) {
|
|
884 /* split this single menu building function back into the two
|
|
885 original: one for buddies and one for chats */
|
|
886
|
|
887 if(GAIM_BLIST_NODE_IS_CHAT(node)) {
|
9038
|
888 return silcgaim_chat_menu((GaimChat *) node);
|
9030
|
889 } else if(GAIM_BLIST_NODE_IS_BUDDY(node)) {
|
|
890 return silcgaim_buddy_menu((GaimBuddy *) node);
|
|
891 } else {
|
9038
|
892 g_return_val_if_reached(NULL);
|
9030
|
893 }
|
|
894 }
|
|
895
|
|
896
|
8849
|
897 /************************** Plugin Initialization ****************************/
|
|
898
|
|
899 static GaimPluginPrefFrame *
|
|
900 silcgaim_pref_frame(GaimPlugin *plugin)
|
|
901 {
|
|
902 GaimPluginPrefFrame *frame;
|
|
903 GaimPluginPref *ppref;
|
|
904
|
|
905 frame = gaim_plugin_pref_frame_new();
|
|
906
|
|
907 ppref = gaim_plugin_pref_new_with_label(_("Instant Messages"));
|
|
908 gaim_plugin_pref_frame_add(frame, ppref);
|
|
909
|
|
910 ppref = gaim_plugin_pref_new_with_name_and_label(
|
|
911 "/plugins/prpl/silc/sign_im",
|
|
912 _("Digitally sign all IM messages"));
|
|
913 gaim_plugin_pref_frame_add(frame, ppref);
|
|
914
|
|
915 ppref = gaim_plugin_pref_new_with_name_and_label(
|
|
916 "/plugins/prpl/silc/verify_im",
|
|
917 _("Verify all IM message signatures"));
|
|
918 gaim_plugin_pref_frame_add(frame, ppref);
|
|
919
|
|
920 ppref = gaim_plugin_pref_new_with_label(_("Channel Messages"));
|
|
921 gaim_plugin_pref_frame_add(frame, ppref);
|
|
922
|
|
923 ppref = gaim_plugin_pref_new_with_name_and_label(
|
|
924 "/plugins/prpl/silc/sign_chat",
|
|
925 _("Digitally sign all channel messages"));
|
|
926 gaim_plugin_pref_frame_add(frame, ppref);
|
|
927
|
|
928 ppref = gaim_plugin_pref_new_with_name_and_label(
|
|
929 "/plugins/prpl/silc/verify_chat",
|
|
930 _("Verify all channel message signatures"));
|
|
931 gaim_plugin_pref_frame_add(frame, ppref);
|
|
932
|
|
933 ppref = gaim_plugin_pref_new_with_label(_("Default SILC Key Pair"));
|
|
934 gaim_plugin_pref_frame_add(frame, ppref);
|
|
935
|
|
936 ppref = gaim_plugin_pref_new_with_name_and_label(
|
|
937 "/plugins/prpl/silc/pubkey",
|
|
938 _("SILC Public Key"));
|
|
939 gaim_plugin_pref_frame_add(frame, ppref);
|
|
940
|
|
941 ppref = gaim_plugin_pref_new_with_name_and_label(
|
|
942 "/plugins/prpl/silc/privkey",
|
|
943 _("SILC Private Key"));
|
|
944 gaim_plugin_pref_frame_add(frame, ppref);
|
|
945
|
|
946 return frame;
|
|
947 }
|
|
948
|
|
949 static GaimPluginUiInfo prefs_info =
|
|
950 {
|
|
951 silcgaim_pref_frame,
|
|
952 };
|
|
953
|
|
954 static GaimPluginProtocolInfo prpl_info =
|
|
955 {
|
|
956 GAIM_PRPL_API_VERSION,
|
|
957 OPT_PROTO_CHAT_TOPIC | OPT_PROTO_UNIQUE_CHATNAME |
|
|
958 OPT_PROTO_PASSWORD_OPTIONAL,
|
|
959 NULL,
|
|
960 NULL,
|
|
961 silcgaim_list_icon,
|
|
962 silcgaim_list_emblems,
|
|
963 silcgaim_status_text,
|
|
964 silcgaim_tooltip_text,
|
|
965 silcgaim_away_states,
|
9030
|
966 silcgaim_blist_node_menu,
|
8849
|
967 silcgaim_chat_info,
|
|
968 silcgaim_login,
|
|
969 silcgaim_close,
|
|
970 silcgaim_send_im,
|
|
971 NULL,
|
|
972 NULL,
|
|
973 silcgaim_get_info,
|
|
974 silcgaim_set_away,
|
|
975 silcgaim_idle_set,
|
|
976 NULL,
|
|
977 silcgaim_add_buddy,
|
|
978 silcgaim_add_buddies,
|
|
979 silcgaim_remove_buddy,
|
|
980 NULL,
|
|
981 NULL,
|
|
982 NULL,
|
|
983 NULL,
|
|
984 NULL,
|
|
985 NULL,
|
|
986 NULL,
|
|
987 silcgaim_chat_join,
|
|
988 NULL,
|
|
989 silcgaim_chat_invite,
|
|
990 silcgaim_chat_leave,
|
|
991 NULL,
|
|
992 silcgaim_chat_send,
|
|
993 silcgaim_keepalive,
|
|
994 NULL,
|
|
995 NULL,
|
|
996 NULL,
|
|
997 NULL,
|
|
998 NULL,
|
|
999 NULL,
|
|
1000 NULL,
|
|
1001 NULL,
|
|
1002 NULL,
|
|
1003 NULL,
|
|
1004 NULL,
|
|
1005 NULL,
|
|
1006 silcgaim_chat_set_topic,
|
|
1007 NULL,
|
|
1008 silcgaim_roomlist_get_list,
|
|
1009 silcgaim_roomlist_cancel,
|
9030
|
1010 NULL
|
8849
|
1011 };
|
|
1012
|
|
1013 static GaimPluginInfo info =
|
|
1014 {
|
|
1015 GAIM_PLUGIN_API_VERSION, /**< api_version */
|
|
1016 GAIM_PLUGIN_PROTOCOL, /**< type */
|
|
1017 NULL, /**< ui_requirement */
|
|
1018 0, /**< flags */
|
|
1019 NULL, /**< dependencies */
|
|
1020 GAIM_PRIORITY_DEFAULT, /**< priority */
|
|
1021
|
|
1022 "prpl-silc", /**< id */
|
|
1023 "SILC", /**< name */
|
|
1024 "1.0", /**< version */
|
|
1025 /** summary */
|
|
1026 N_("SILC Protocol Plugin"),
|
|
1027 /** description */
|
|
1028 N_("Secure Internet Live Conferencing (SILC) Protocol"),
|
8891
|
1029 "Pekka Riikonen", /**< author */
|
|
1030 "http://silcnet.org/", /**< homepage */
|
8849
|
1031
|
|
1032 NULL, /**< load */
|
|
1033 NULL, /**< unload */
|
|
1034 NULL, /**< destroy */
|
|
1035
|
|
1036 NULL, /**< ui_info */
|
|
1037 &prpl_info, /**< extra_info */
|
8993
|
1038 &prefs_info, /**< prefs_info */
|
9015
|
1039 silcgaim_actions
|
8849
|
1040 };
|
|
1041
|
|
1042 static void
|
|
1043 init_plugin(GaimPlugin *plugin)
|
|
1044 {
|
|
1045 GaimAccountOption *option;
|
|
1046 char tmp[256];
|
|
1047
|
|
1048 silc_plugin = plugin;
|
|
1049
|
|
1050 /* Account options */
|
|
1051 option = gaim_account_option_string_new(_("Connect server"),
|
|
1052 "server",
|
|
1053 "silc.silcnet.org");
|
|
1054 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option);
|
|
1055 option = gaim_account_option_int_new(_("Port"), "port", 706);
|
|
1056 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option);
|
|
1057
|
|
1058 option = gaim_account_option_bool_new(_("Public key authentication"),
|
|
1059 "pubkey-auth", FALSE);
|
|
1060 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option);
|
|
1061 #if 0 /* XXX Public key auth interface with explicit key pair is
|
|
1062 broken in SILC Toolkit */
|
8891
|
1063 g_snprintf(tmp, sizeof(tmp), "%s/public_key.pub", silcgaim_silcdir());
|
8849
|
1064 option = gaim_account_option_string_new(_("Public Key File"),
|
|
1065 "public-key", tmp);
|
|
1066 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option);
|
8891
|
1067 g_snprintf(tmp, sizeof(tmp), "%s/private_key.prv", silcgaim_silcdir());
|
8849
|
1068 option = gaim_account_option_string_new(_("Private Key File"),
|
|
1069 "public-key", tmp);
|
|
1070 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option);
|
|
1071 #endif
|
|
1072
|
|
1073 option = gaim_account_option_bool_new(_("Reject watching by other users"),
|
|
1074 "reject-watch", FALSE);
|
|
1075 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option);
|
|
1076 option = gaim_account_option_bool_new(_("Block invites"),
|
|
1077 "block-invites", FALSE);
|
|
1078 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option);
|
|
1079 option = gaim_account_option_bool_new(_("Block IMs without Key Exchange"),
|
|
1080 "block-ims", FALSE);
|
|
1081 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option);
|
|
1082 option = gaim_account_option_bool_new(_("Reject online status attribute requests"),
|
|
1083 "reject-attrs", FALSE);
|
|
1084 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option);
|
|
1085
|
|
1086 /* Preferences */
|
|
1087 gaim_prefs_add_none("/plugins/prpl/silc");
|
|
1088 gaim_prefs_add_bool("/plugins/prpl/silc/sign_im", FALSE);
|
|
1089 gaim_prefs_add_bool("/plugins/prpl/silc/verify_im", FALSE);
|
|
1090 gaim_prefs_add_bool("/plugins/prpl/silc/sign_chat", FALSE);
|
|
1091 gaim_prefs_add_bool("/plugins/prpl/silc/verify_chat", FALSE);
|
8891
|
1092 g_snprintf(tmp, sizeof(tmp), "%s/public_key.pub", silcgaim_silcdir());
|
8849
|
1093 gaim_prefs_add_string("/plugins/prpl/silc/pubkey", tmp);
|
8891
|
1094 g_snprintf(tmp, sizeof(tmp), "%s/private_key.prv", silcgaim_silcdir());
|
8849
|
1095 gaim_prefs_add_string("/plugins/prpl/silc/privkey", tmp);
|
|
1096 gaim_prefs_add_string("/plugins/prpl/silc/vcard", "");
|
|
1097 }
|
|
1098
|
|
1099 GAIM_INIT_PLUGIN(silc, init_plugin, info);
|