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