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