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