Mercurial > pidgin
annotate src/protocols/silc/silc.c @ 13545:cfc2f7fcb3dd
[gaim-migrate @ 15922]
Way more changes that I initially thought I was going to make. I apologize
for the commit message spam. These changes bring a lot of consistency to
our capitalization and punctuation, especially of words like "e-mail".
For reference, I've used these rules (after discussing in #gaim):
e-mail, a case of two words joined:
"e-mail" - in the middle of a sentence caps context
"E-mail" - start of text in a sentence caps context
"E-Mail" - in a header (title) caps context
re-enable, a single word, would be:
"re-enable", "Re-enable", and "Re-enable" (respectively)
The reason this changeset exploded is that, as I went through and verified
these changes, I realized we were using improper capitalization (e.g. header
instead of sentence) in a number of dialogs. I fixed a number of these
cases before, and this corrects another pile.
This looks like I've made a LOT of work for the translators, but the impact
is significantly mitigated by three factors: 1) Many of these changes use
strings that already exist, or change one string in many places. 2) I've
used sed to correct the .po files where possible. 3) The actual changes
are extremely trivial.
committer: Tailor Script <tailor@pidgin.im>
author | Richard Laager <rlaager@wiktel.com> |
---|---|
date | Tue, 21 Mar 2006 04:32:45 +0000 |
parents | 0a3c968b07dc |
children | 2c84df43f126 |
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; | |
9353 | 1250 GaimConversation *convo; |
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 |
9353 | 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 } else |
1262 convo = conv; | |
1263 | |
1264 id = gaim_conv_chat_get_id(GAIM_CONV_CHAT(convo)); | |
1265 | |
1266 if (id == 0) | |
9272 | 1267 return GAIM_CMD_RET_FAILED; |
1268 | |
1269 silcgaim_chat_leave(gc, id); | |
1270 | |
1271 return GAIM_CMD_RET_OK; | |
1272 | |
1273 } | |
1274 | |
1275 static GaimCmdRet silcgaim_cmd_chat_topic(GaimConversation *conv, | |
9597 | 1276 const char *cmd, char **args, char **error, void *data) |
9272 | 1277 { |
1278 GaimConnection *gc; | |
1279 int id = 0; | |
9762 | 1280 char *buf, *tmp, *tmp2; |
9488 | 1281 const char *topic; |
9272 | 1282 |
1283 gc = gaim_conversation_get_gc(conv); | |
1284 id = gaim_conv_chat_get_id(GAIM_CONV_CHAT(conv)); | |
1285 | |
1286 if (gc == NULL || id == 0) | |
1287 return GAIM_CMD_RET_FAILED; | |
1288 | |
9488 | 1289 if (!args || !args[0]) { |
1290 topic = gaim_conv_chat_get_topic (GAIM_CONV_CHAT(conv)); | |
1291 if (topic) { | |
10732
c4cb90065e1d
[gaim-migrate @ 12334]
Luke Schierer <lschiere@pidgin.im>
parents:
10547
diff
changeset
|
1292 tmp = g_markup_escape_text(topic, -1); |
9762 | 1293 tmp2 = gaim_markup_linkify(tmp); |
1294 buf = g_strdup_printf(_("current topic is: %s"), tmp2); | |
9488 | 1295 g_free(tmp); |
9762 | 1296 g_free(tmp2); |
9488 | 1297 } else |
1298 buf = g_strdup(_("No topic is set")); | |
1299 gaim_conv_chat_write(GAIM_CONV_CHAT(conv), gc->account->username, buf, | |
1300 GAIM_MESSAGE_SYSTEM|GAIM_MESSAGE_NO_LOG, time(NULL)); | |
1301 g_free(buf); | |
1302 | |
1303 } | |
1304 | |
1305 if (args && args[0] && (strlen(args[0]) > 255)) { | |
1306 *error = g_strdup(_("Topic too long")); | |
1307 return GAIM_CMD_RET_FAILED; | |
1308 } | |
1309 | |
9272 | 1310 silcgaim_chat_set_topic(gc, id, args ? args[0] : NULL); |
1311 | |
1312 return GAIM_CMD_RET_OK; | |
1313 } | |
1314 | |
1315 static GaimCmdRet silcgaim_cmd_chat_join(GaimConversation *conv, | |
9597 | 1316 const char *cmd, char **args, char **error, void *data) |
9272 | 1317 { |
1318 GHashTable *comp; | |
1319 | |
1320 if(!args || !args[0]) | |
1321 return GAIM_CMD_RET_FAILED; | |
1322 | |
1323 comp = g_hash_table_new_full(g_str_hash, g_str_equal, NULL, NULL); | |
1324 | |
1325 g_hash_table_replace(comp, "channel", args[0]); | |
1326 if(args[1]) | |
1327 g_hash_table_replace(comp, "passphrase", args[1]); | |
1328 | |
1329 silcgaim_chat_join(gaim_conversation_get_gc(conv), comp); | |
1330 | |
1331 g_hash_table_destroy(comp); | |
1332 return GAIM_CMD_RET_OK; | |
1333 } | |
1334 | |
1335 static GaimCmdRet silcgaim_cmd_chat_list(GaimConversation *conv, | |
9597 | 1336 const char *cmd, char **args, char **error, void *data) |
9272 | 1337 { |
1338 GaimConnection *gc; | |
1339 gc = gaim_conversation_get_gc(conv); | |
1340 gaim_roomlist_show_with_account(gaim_connection_get_account(gc)); | |
1341 return GAIM_CMD_RET_OK; | |
1342 } | |
1343 | |
1344 static GaimCmdRet silcgaim_cmd_whois(GaimConversation *conv, | |
9597 | 1345 const char *cmd, char **args, char **error, void *data) |
9272 | 1346 { |
1347 GaimConnection *gc; | |
1348 | |
1349 gc = gaim_conversation_get_gc(conv); | |
1350 | |
1351 if (gc == NULL) | |
1352 return GAIM_CMD_RET_FAILED; | |
1353 | |
1354 silcgaim_get_info(gc, args[0]); | |
1355 | |
1356 return GAIM_CMD_RET_OK; | |
1357 } | |
1358 | |
1359 static GaimCmdRet silcgaim_cmd_msg(GaimConversation *conv, | |
9597 | 1360 const char *cmd, char **args, char **error, void *data) |
9272 | 1361 { |
1362 int ret; | |
1363 GaimConnection *gc; | |
1364 | |
1365 gc = gaim_conversation_get_gc(conv); | |
1366 | |
1367 if (gc == NULL) | |
1368 return GAIM_CMD_RET_FAILED; | |
1369 | |
1370 ret = silcgaim_send_im(gc, args[0], args[1], GAIM_MESSAGE_SEND); | |
1371 | |
1372 if (ret) | |
1373 return GAIM_CMD_RET_OK; | |
1374 else | |
1375 return GAIM_CMD_RET_FAILED; | |
1376 } | |
1377 | |
1378 static GaimCmdRet silcgaim_cmd_query(GaimConversation *conv, | |
9597 | 1379 const char *cmd, char **args, char **error, void *data) |
9272 | 1380 { |
1381 int ret = 1; | |
1382 GaimConversation *convo; | |
1383 GaimConnection *gc; | |
1384 GaimAccount *account; | |
1385 | |
9488 | 1386 if (!args || !args[0]) { |
1387 *error = g_strdup(_("You must specify a nick")); | |
9272 | 1388 return GAIM_CMD_RET_FAILED; |
9488 | 1389 } |
9272 | 1390 |
1391 gc = gaim_conversation_get_gc(conv); | |
1392 | |
1393 if (gc == NULL) | |
1394 return GAIM_CMD_RET_FAILED; | |
1395 | |
1396 account = gaim_connection_get_account(gc); | |
1397 | |
11338 | 1398 convo = gaim_conversation_new(GAIM_CONV_TYPE_IM, account, args[0]); |
9272 | 1399 |
1400 if (args[1]) { | |
1401 ret = silcgaim_send_im(gc, args[0], args[1], GAIM_MESSAGE_SEND); | |
1402 gaim_conv_im_write(GAIM_CONV_IM(convo), gaim_connection_get_display_name(gc), | |
1403 args[1], GAIM_MESSAGE_SEND, time(NULL)); | |
1404 } | |
1405 | |
1406 if (ret) | |
1407 return GAIM_CMD_RET_OK; | |
1408 else | |
1409 return GAIM_CMD_RET_FAILED; | |
1410 } | |
1411 | |
1412 static GaimCmdRet silcgaim_cmd_motd(GaimConversation *conv, | |
9597 | 1413 const char *cmd, char **args, char **error, void *data) |
9272 | 1414 { |
1415 GaimConnection *gc; | |
1416 SilcGaim sg; | |
9488 | 1417 char *tmp; |
9272 | 1418 |
1419 gc = gaim_conversation_get_gc(conv); | |
1420 | |
1421 if (gc == NULL) | |
1422 return GAIM_CMD_RET_FAILED; | |
1423 | |
1424 sg = gc->proto_data; | |
1425 | |
1426 if (sg == NULL) | |
1427 return GAIM_CMD_RET_FAILED; | |
1428 | |
1429 if (!sg->motd) { | |
9488 | 1430 *error = g_strdup(_("There is no Message of the Day associated with this connection")); |
9272 | 1431 return GAIM_CMD_RET_FAILED; |
1432 } | |
1433 | |
10732
c4cb90065e1d
[gaim-migrate @ 12334]
Luke Schierer <lschiere@pidgin.im>
parents:
10547
diff
changeset
|
1434 tmp = g_markup_escape_text(sg->motd, -1); |
9488 | 1435 gaim_notify_formatted(gc, NULL, _("Message of the Day"), NULL, |
1436 tmp, NULL, NULL); | |
1437 g_free(tmp); | |
9272 | 1438 |
1439 return GAIM_CMD_RET_OK; | |
1440 } | |
1441 | |
1442 static GaimCmdRet silcgaim_cmd_detach(GaimConversation *conv, | |
9597 | 1443 const char *cmd, char **args, char **error, void *data) |
9272 | 1444 { |
1445 GaimConnection *gc; | |
1446 SilcGaim sg; | |
1447 | |
1448 gc = gaim_conversation_get_gc(conv); | |
1449 | |
1450 if (gc == NULL) | |
1451 return GAIM_CMD_RET_FAILED; | |
1452 | |
1453 sg = gc->proto_data; | |
1454 | |
1455 if (sg == NULL) | |
1456 return GAIM_CMD_RET_FAILED; | |
1457 | |
1458 silc_client_command_call(sg->client, sg->conn, "DETACH"); | |
1459 sg->detaching = TRUE; | |
1460 | |
1461 return GAIM_CMD_RET_OK; | |
1462 } | |
1463 | |
9488 | 1464 static GaimCmdRet silcgaim_cmd_cmode(GaimConversation *conv, |
9597 | 1465 const char *cmd, char **args, char **error, void *data) |
9488 | 1466 { |
1467 GaimConnection *gc; | |
1468 SilcGaim sg; | |
1469 SilcChannelEntry channel; | |
1470 char *silccmd, *silcargs, *msg, tmp[256]; | |
1471 const char *chname; | |
1472 | |
1473 gc = gaim_conversation_get_gc(conv); | |
1474 | |
1475 if (gc == NULL || !args || gc->proto_data == NULL) | |
1476 return GAIM_CMD_RET_FAILED; | |
1477 | |
1478 sg = gc->proto_data; | |
1479 | |
1480 if (args[0]) | |
1481 chname = args[0]; | |
1482 else | |
1483 chname = gaim_conversation_get_name(conv); | |
1484 | |
1485 if (!args[1]) { | |
1486 channel = silc_client_get_channel(sg->client, sg->conn, | |
1487 (char *)chname); | |
1488 if (!channel) { | |
1489 *error = g_strdup_printf(_("channel %s not found"), chname); | |
1490 return GAIM_CMD_RET_FAILED; | |
1491 } | |
1492 if (channel->mode) { | |
1493 silcgaim_get_chmode_string(channel->mode, tmp, sizeof(tmp)); | |
1494 msg = g_strdup_printf(_("channel modes for %s: %s"), chname, tmp); | |
1495 } else { | |
1496 msg = g_strdup_printf(_("no channel modes are set on %s"), chname); | |
1497 } | |
1498 gaim_conv_chat_write(GAIM_CONV_CHAT(conv), "", | |
1499 msg, GAIM_MESSAGE_SYSTEM|GAIM_MESSAGE_NO_LOG, time(NULL)); | |
1500 g_free(msg); | |
1501 return GAIM_CMD_RET_OK; | |
1502 } | |
1503 | |
1504 silcargs = g_strjoinv(" ", args); | |
1505 silccmd = g_strconcat(cmd, " ", args ? silcargs : NULL, NULL); | |
1506 g_free(silcargs); | |
1507 if (!silc_client_command_call(sg->client, sg->conn, silccmd)) { | |
1508 g_free(silccmd); | |
1509 *error = g_strdup_printf(_("Failed to set cmodes for %s"), args[0]); | |
1510 return GAIM_CMD_RET_FAILED; | |
1511 } | |
1512 g_free(silccmd); | |
1513 | |
1514 return GAIM_CMD_RET_OK; | |
1515 } | |
1516 | |
9353 | 1517 static GaimCmdRet silcgaim_cmd_generic(GaimConversation *conv, |
9597 | 1518 const char *cmd, char **args, char **error, void *data) |
9272 | 1519 { |
1520 GaimConnection *gc; | |
1521 SilcGaim sg; | |
9353 | 1522 char *silccmd, *silcargs; |
9272 | 1523 |
1524 gc = gaim_conversation_get_gc(conv); | |
1525 | |
1526 if (gc == NULL) | |
1527 return GAIM_CMD_RET_FAILED; | |
1528 | |
1529 sg = gc->proto_data; | |
1530 | |
1531 if (sg == NULL) | |
1532 return GAIM_CMD_RET_FAILED; | |
1533 | |
9353 | 1534 silcargs = g_strjoinv(" ", args); |
1535 silccmd = g_strconcat(cmd, " ", args ? silcargs : NULL, NULL); | |
1536 g_free(silcargs); | |
1537 if (!silc_client_command_call(sg->client, sg->conn, silccmd)) { | |
1538 g_free(silccmd); | |
9488 | 1539 *error = g_strdup_printf(_("Unknown command: %s, (may be a Gaim bug)"), cmd); |
9353 | 1540 return GAIM_CMD_RET_FAILED; |
1541 } | |
1542 g_free(silccmd); | |
9272 | 1543 |
1544 return GAIM_CMD_RET_OK; | |
1545 } | |
1546 | |
9359 | 1547 static GaimCmdRet silcgaim_cmd_quit(GaimConversation *conv, |
9597 | 1548 const char *cmd, char **args, char **error, void *data) |
9359 | 1549 { |
1550 GaimConnection *gc; | |
1551 SilcGaim sg; | |
1552 | |
1553 gc = gaim_conversation_get_gc(conv); | |
1554 | |
1555 if (gc == NULL) | |
1556 return GAIM_CMD_RET_FAILED; | |
1557 | |
1558 sg = gc->proto_data; | |
1559 | |
1560 if (sg == NULL) | |
1561 return GAIM_CMD_RET_FAILED; | |
1562 | |
1563 silc_client_command_call(sg->client, sg->conn, NULL, | |
1564 "QUIT", (args && args[0]) ? args[0] : "Download Gaim: " GAIM_WEBSITE, NULL); | |
1565 | |
1566 return GAIM_CMD_RET_OK; | |
1567 } | |
1568 | |
1569 static GaimCmdRet silcgaim_cmd_call(GaimConversation *conv, | |
9597 | 1570 const char *cmd, char **args, char **error, void *data) |
9359 | 1571 { |
1572 GaimConnection *gc; | |
1573 SilcGaim sg; | |
1574 | |
1575 gc = gaim_conversation_get_gc(conv); | |
1576 | |
1577 if (gc == NULL) | |
1578 return GAIM_CMD_RET_FAILED; | |
1579 | |
1580 sg = gc->proto_data; | |
1581 | |
1582 if (sg == NULL) | |
1583 return GAIM_CMD_RET_FAILED; | |
1584 | |
9488 | 1585 if (!silc_client_command_call(sg->client, sg->conn, args[0])) { |
1586 *error = g_strdup_printf(_("Unknown command: %s"), args[0]); | |
9359 | 1587 return GAIM_CMD_RET_FAILED; |
9488 | 1588 } |
9359 | 1589 |
1590 return GAIM_CMD_RET_OK; | |
1591 } | |
1592 | |
9030 | 1593 |
8849 | 1594 /************************** Plugin Initialization ****************************/ |
1595 | |
9272 | 1596 static void |
1597 silcgaim_register_commands(void) | |
1598 { | |
9353 | 1599 gaim_cmd_register("part", "w", GAIM_CMD_P_PRPL, |
1600 GAIM_CMD_FLAG_IM | GAIM_CMD_FLAG_CHAT | | |
1601 GAIM_CMD_FLAG_PRPL_ONLY | GAIM_CMD_FLAG_ALLOW_WRONG_ARGS, | |
9597 | 1602 "prpl-silc", silcgaim_cmd_chat_part, _("part [channel]: Leave the chat"), NULL); |
9353 | 1603 gaim_cmd_register("leave", "w", GAIM_CMD_P_PRPL, |
1604 GAIM_CMD_FLAG_IM | GAIM_CMD_FLAG_CHAT | | |
1605 GAIM_CMD_FLAG_PRPL_ONLY | GAIM_CMD_FLAG_ALLOW_WRONG_ARGS, | |
9597 | 1606 "prpl-silc", silcgaim_cmd_chat_part, _("leave [channel]: Leave the chat"), NULL); |
9272 | 1607 gaim_cmd_register("topic", "s", GAIM_CMD_P_PRPL, |
1608 GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_PRPL_ONLY | | |
1609 GAIM_CMD_FLAG_ALLOW_WRONG_ARGS, "prpl-silc", | |
9597 | 1610 silcgaim_cmd_chat_topic, _("topic [<new topic>]: View or change the topic"), NULL); |
9272 | 1611 gaim_cmd_register("join", "ws", GAIM_CMD_P_PRPL, |
1612 GAIM_CMD_FLAG_IM | GAIM_CMD_FLAG_CHAT | | |
1613 GAIM_CMD_FLAG_PRPL_ONLY | GAIM_CMD_FLAG_ALLOW_WRONG_ARGS, | |
1614 "prpl-silc", silcgaim_cmd_chat_join, | |
9597 | 1615 _("join <channel> [<password>]: Join a chat on this network"), NULL); |
9272 | 1616 gaim_cmd_register("list", "", GAIM_CMD_P_PRPL, |
1617 GAIM_CMD_FLAG_IM | GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_PRPL_ONLY | | |
1618 GAIM_CMD_FLAG_ALLOW_WRONG_ARGS, "prpl-silc", | |
9597 | 1619 silcgaim_cmd_chat_list, _("list: List channels on this network"), NULL); |
9272 | 1620 gaim_cmd_register("whois", "w", GAIM_CMD_P_PRPL, |
1621 GAIM_CMD_FLAG_IM | GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_PRPL_ONLY, | |
1622 "prpl-silc", | |
9597 | 1623 silcgaim_cmd_whois, _("whois <nick>: View nick's information"), NULL); |
9272 | 1624 gaim_cmd_register("msg", "ws", GAIM_CMD_P_PRPL, |
1625 GAIM_CMD_FLAG_IM | GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_PRPL_ONLY, | |
1626 "prpl-silc", silcgaim_cmd_msg, | |
9597 | 1627 _("msg <nick> <message>: Send a private message to a user"), NULL); |
9272 | 1628 gaim_cmd_register("query", "ws", GAIM_CMD_P_PRPL, |
1629 GAIM_CMD_FLAG_IM | GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_PRPL_ONLY | | |
1630 GAIM_CMD_FLAG_ALLOW_WRONG_ARGS, "prpl-silc", silcgaim_cmd_query, | |
9597 | 1631 _("query <nick> [<message>]: Send a private message to a user"), NULL); |
9272 | 1632 gaim_cmd_register("motd", "", GAIM_CMD_P_PRPL, |
1633 GAIM_CMD_FLAG_IM | GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_PRPL_ONLY | | |
1634 GAIM_CMD_FLAG_ALLOW_WRONG_ARGS, "prpl-silc", silcgaim_cmd_motd, | |
9597 | 1635 _("motd: View the server's Message Of The Day"), NULL); |
9272 | 1636 gaim_cmd_register("detach", "", GAIM_CMD_P_PRPL, |
9353 | 1637 GAIM_CMD_FLAG_IM | GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_PRPL_ONLY, |
1638 "prpl-silc", silcgaim_cmd_detach, | |
9597 | 1639 _("detach: Detach this session"), NULL); |
9359 | 1640 gaim_cmd_register("quit", "s", GAIM_CMD_P_PRPL, |
1641 GAIM_CMD_FLAG_IM | GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_PRPL_ONLY | | |
1642 GAIM_CMD_FLAG_ALLOW_WRONG_ARGS, "prpl-silc", silcgaim_cmd_quit, | |
9597 | 1643 _("quit [message]: Disconnect from the server, with an optional message"), NULL); |
9359 | 1644 gaim_cmd_register("call", "s", GAIM_CMD_P_PRPL, |
1645 GAIM_CMD_FLAG_IM | GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_PRPL_ONLY, | |
1646 "prpl-silc", silcgaim_cmd_call, | |
9597 | 1647 _("call <command>: Call any silc client command"), NULL); |
1648 /* These below just get passed through for the silc client library to deal | |
1649 * with */ | |
9359 | 1650 gaim_cmd_register("kill", "ws", GAIM_CMD_P_PRPL, |
1651 GAIM_CMD_FLAG_IM | GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_PRPL_ONLY | | |
1652 GAIM_CMD_FLAG_ALLOW_WRONG_ARGS, "prpl-silc", silcgaim_cmd_generic, | |
9597 | 1653 _("kill <nick> [-pubkey|<reason>]: Kill nick"), NULL); |
9359 | 1654 gaim_cmd_register("nick", "w", GAIM_CMD_P_PRPL, |
1655 GAIM_CMD_FLAG_IM | GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_PRPL_ONLY, | |
1656 "prpl-silc", silcgaim_cmd_generic, | |
9597 | 1657 _("nick <newnick>: Change your nickname"), NULL); |
9488 | 1658 gaim_cmd_register("whowas", "ww", GAIM_CMD_P_PRPL, |
9359 | 1659 GAIM_CMD_FLAG_IM | GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_PRPL_ONLY | |
1660 GAIM_CMD_FLAG_ALLOW_WRONG_ARGS, "prpl-silc", silcgaim_cmd_generic, | |
9597 | 1661 _("whowas <nick>: View nick's information"), NULL); |
9488 | 1662 gaim_cmd_register("cmode", "wws", GAIM_CMD_P_PRPL, |
1663 GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_PRPL_ONLY | | |
1664 GAIM_CMD_FLAG_ALLOW_WRONG_ARGS, "prpl-silc", silcgaim_cmd_cmode, | |
9597 | 1665 _("cmode <channel> [+|-<modes>] [arguments]: Change or display channel modes"), NULL); |
9359 | 1666 gaim_cmd_register("cumode", "wws", GAIM_CMD_P_PRPL, |
1667 GAIM_CMD_FLAG_IM | GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_PRPL_ONLY | | |
1668 GAIM_CMD_FLAG_ALLOW_WRONG_ARGS, "prpl-silc", silcgaim_cmd_generic, | |
9597 | 1669 _("cumode <channel> +|-<modes> <nick>: Change nick's modes on channel"), NULL); |
9272 | 1670 gaim_cmd_register("umode", "w", GAIM_CMD_P_PRPL, |
1671 GAIM_CMD_FLAG_IM | GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_PRPL_ONLY, | |
9353 | 1672 "prpl-silc", silcgaim_cmd_generic, |
9597 | 1673 _("umode <usermodes>: Set your modes in the network"), NULL); |
9359 | 1674 gaim_cmd_register("oper", "s", GAIM_CMD_P_PRPL, |
1675 GAIM_CMD_FLAG_IM | GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_PRPL_ONLY, | |
1676 "prpl-silc", silcgaim_cmd_generic, | |
9597 | 1677 _("oper <nick> [-pubkey]: Get server operator privileges"), NULL); |
9359 | 1678 gaim_cmd_register("invite", "ws", GAIM_CMD_P_PRPL, |
1679 GAIM_CMD_FLAG_IM | GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_PRPL_ONLY | | |
1680 GAIM_CMD_FLAG_ALLOW_WRONG_ARGS, "prpl-silc", silcgaim_cmd_generic, | |
9597 | 1681 _("invite <channel> [-|+]<nick>: invite nick or add/remove from channel invite list"), NULL); |
9359 | 1682 gaim_cmd_register("kick", "wws", GAIM_CMD_P_PRPL, |
1683 GAIM_CMD_FLAG_IM | GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_PRPL_ONLY | | |
1684 GAIM_CMD_FLAG_ALLOW_WRONG_ARGS, "prpl-silc", silcgaim_cmd_generic, | |
9597 | 1685 _("kick <channel> <nick> [comment]: Kick client from channel"), NULL); |
9488 | 1686 gaim_cmd_register("info", "w", GAIM_CMD_P_PRPL, |
9359 | 1687 GAIM_CMD_FLAG_IM | GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_PRPL_ONLY | |
1688 GAIM_CMD_FLAG_ALLOW_WRONG_ARGS, "prpl-silc", silcgaim_cmd_generic, | |
9597 | 1689 _("info [server]: View server administrative details"), NULL); |
9359 | 1690 gaim_cmd_register("ban", "ww", GAIM_CMD_P_PRPL, |
1691 GAIM_CMD_FLAG_IM | GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_PRPL_ONLY | | |
1692 GAIM_CMD_FLAG_ALLOW_WRONG_ARGS, "prpl-silc", silcgaim_cmd_generic, | |
9597 | 1693 _("ban [<channel> +|-<nick>]: Ban client from channel"), NULL); |
9488 | 1694 gaim_cmd_register("getkey", "w", GAIM_CMD_P_PRPL, |
1695 GAIM_CMD_FLAG_IM | GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_PRPL_ONLY, | |
1696 "prpl-silc", silcgaim_cmd_generic, | |
9597 | 1697 _("getkey <nick|server>: Retrieve client's or server's public key"), NULL); |
9488 | 1698 gaim_cmd_register("stats", "", GAIM_CMD_P_PRPL, |
1699 GAIM_CMD_FLAG_IM | GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_PRPL_ONLY, | |
1700 "prpl-silc", silcgaim_cmd_generic, | |
9597 | 1701 _("stats: View server and network statistics"), NULL); |
9359 | 1702 gaim_cmd_register("ping", "", GAIM_CMD_P_PRPL, |
1703 GAIM_CMD_FLAG_IM | GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_PRPL_ONLY, | |
1704 "prpl-silc", silcgaim_cmd_generic, | |
9597 | 1705 _("ping: Send PING to the connected server"), NULL); |
9488 | 1706 #if 0 /* Gaim doesn't handle these yet */ |
1707 gaim_cmd_register("users", "w", GAIM_CMD_P_PRPL, | |
1708 GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_PRPL_ONLY, | |
1709 "prpl-silc", silcgaim_cmd_users, | |
1710 _("users <channel>: List users in channel")); | |
1711 gaim_cmd_register("names", "ww", GAIM_CMD_P_PRPL, | |
1712 GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_PRPL_ONLY | | |
1713 GAIM_CMD_FLAG_ALLOW_WRONG_ARGS, "prpl-silc", silcgaim_cmd_names, | |
1714 _("names [-count|-ops|-halfops|-voices|-normal] <channel(s)>: List specific users in channel(s)")); | |
9359 | 1715 #endif |
9272 | 1716 } |
1717 | |
12058 | 1718 static GaimWhiteboardPrplOps silcgaim_wb_ops = |
1719 { | |
1720 silcgaim_wb_start, | |
1721 silcgaim_wb_end, | |
1722 silcgaim_wb_get_dimensions, | |
1723 silcgaim_wb_set_dimensions, | |
1724 silcgaim_wb_get_brush, | |
1725 silcgaim_wb_set_brush, | |
1726 silcgaim_wb_send, | |
1727 silcgaim_wb_clear, | |
1728 }; | |
1729 | |
8849 | 1730 static GaimPluginProtocolInfo prpl_info = |
1731 { | |
12217 | 1732 #ifdef HAVE_SILCMIME_H |
1733 OPT_PROTO_CHAT_TOPIC | OPT_PROTO_UNIQUE_CHATNAME | | |
1734 OPT_PROTO_PASSWORD_OPTIONAL | OPT_PROTO_IM_IMAGE, | |
1735 #else | |
8849 | 1736 OPT_PROTO_CHAT_TOPIC | OPT_PROTO_UNIQUE_CHATNAME | |
1737 OPT_PROTO_PASSWORD_OPTIONAL, | |
12217 | 1738 #endif |
9488 | 1739 NULL, /* user_splits */ |
1740 NULL, /* protocol_options */ | |
12761 | 1741 #ifdef SILC_ATTRIBUTE_USER_ICON |
1742 {"jpeg,gif,png,bmp", 0, 0, 96, 96, GAIM_ICON_SCALE_DISPLAY}, /* icon_spec */ | |
1743 #else | |
1744 NO_BUDDY_ICONS, | |
1745 #endif | |
9488 | 1746 silcgaim_list_icon, /* list_icon */ |
1747 silcgaim_list_emblems, /* list_emblems */ | |
1748 silcgaim_status_text, /* status_text */ | |
1749 silcgaim_tooltip_text, /* tooltip_text */ | |
1750 silcgaim_away_states, /* away_states */ | |
1751 silcgaim_blist_node_menu, /* blist_node_menu */ | |
1752 silcgaim_chat_info, /* chat_info */ | |
9754 | 1753 silcgaim_chat_info_defaults,/* chat_info_defaults */ |
9488 | 1754 silcgaim_login, /* login */ |
1755 silcgaim_close, /* close */ | |
1756 silcgaim_send_im, /* send_im */ | |
1757 silcgaim_set_info, /* set_info */ | |
1758 NULL, /* send_typing */ | |
1759 silcgaim_get_info, /* get_info */ | |
9968 | 1760 silcgaim_set_status, /* set_status */ |
9488 | 1761 silcgaim_idle_set, /* set_idle */ |
1762 silcgaim_change_passwd, /* change_passwd */ | |
1763 silcgaim_add_buddy, /* add_buddy */ | |
10869 | 1764 NULL, /* add_buddies */ |
9488 | 1765 silcgaim_remove_buddy, /* remove_buddy */ |
1766 NULL, /* remove_buddies */ | |
1767 NULL, /* add_permit */ | |
1768 NULL, /* add_deny */ | |
1769 NULL, /* rem_permit */ | |
1770 NULL, /* rem_deny */ | |
1771 NULL, /* set_permit_deny */ | |
1772 silcgaim_chat_join, /* join_chat */ | |
1773 NULL, /* reject_chat */ | |
9917 | 1774 silcgaim_get_chat_name, /* get_chat_name */ |
9488 | 1775 silcgaim_chat_invite, /* chat_invite */ |
1776 silcgaim_chat_leave, /* chat_leave */ | |
1777 NULL, /* chat_whisper */ | |
1778 silcgaim_chat_send, /* chat_send */ | |
1779 silcgaim_keepalive, /* keepalive */ | |
1780 NULL, /* register_user */ | |
1781 NULL, /* get_cb_info */ | |
1782 NULL, /* get_cb_away */ | |
1783 NULL, /* alias_buddy */ | |
1784 NULL, /* group_buddy */ | |
1785 NULL, /* rename_group */ | |
1786 NULL, /* buddy_free */ | |
1787 NULL, /* convo_closed */ | |
1788 NULL, /* normalize */ | |
12761 | 1789 #ifdef SILC_ATTRIBUTE_USER_ICON |
1790 silcgaim_buddy_set_icon, /* set_buddy_icon */ | |
1791 #else | |
1792 NULL, | |
1793 #endif | |
9488 | 1794 NULL, /* remove_group */ |
1795 NULL, /* get_cb_real_name */ | |
1796 silcgaim_chat_set_topic, /* set_chat_topic */ | |
1797 NULL, /* find_blist_chat */ | |
1798 silcgaim_roomlist_get_list, /* roomlist_get_list */ | |
1799 silcgaim_roomlist_cancel, /* roomlist_cancel */ | |
1800 NULL, /* roomlist_expand_category */ | |
1801 NULL, /* can_receive_file */ | |
12058 | 1802 silcgaim_ftp_send_file, /* send_file */ |
12143
cbebda5f019c
[gaim-migrate @ 14444]
Richard Laager <rlaager@wiktel.com>
parents:
12130
diff
changeset
|
1803 silcgaim_ftp_new_xfer, /* new_xfer */ |
12645
fc28451f5d96
[gaim-migrate @ 14983]
Richard Laager <rlaager@wiktel.com>
parents:
12600
diff
changeset
|
1804 NULL, /* offline_message */ |
12600
e856f985a0b9
[gaim-migrate @ 14934]
Richard Laager <rlaager@wiktel.com>
parents:
12595
diff
changeset
|
1805 &silcgaim_wb_ops, /* whiteboard_prpl_ops */ |
8849 | 1806 }; |
1807 | |
1808 static GaimPluginInfo info = | |
1809 { | |
9943 | 1810 GAIM_PLUGIN_MAGIC, |
1811 GAIM_MAJOR_VERSION, | |
1812 GAIM_MINOR_VERSION, | |
8849 | 1813 GAIM_PLUGIN_PROTOCOL, /**< type */ |
1814 NULL, /**< ui_requirement */ | |
1815 0, /**< flags */ | |
1816 NULL, /**< dependencies */ | |
1817 GAIM_PRIORITY_DEFAULT, /**< priority */ | |
1818 | |
1819 "prpl-silc", /**< id */ | |
1820 "SILC", /**< name */ | |
1821 "1.0", /**< version */ | |
1822 /** summary */ | |
1823 N_("SILC Protocol Plugin"), | |
1824 /** description */ | |
1825 N_("Secure Internet Live Conferencing (SILC) Protocol"), | |
8891 | 1826 "Pekka Riikonen", /**< author */ |
1827 "http://silcnet.org/", /**< homepage */ | |
8849 | 1828 |
1829 NULL, /**< load */ | |
1830 NULL, /**< unload */ | |
1831 NULL, /**< destroy */ | |
1832 | |
1833 NULL, /**< ui_info */ | |
1834 &prpl_info, /**< extra_info */ | |
12167 | 1835 NULL, /**< prefs_info */ |
9015 | 1836 silcgaim_actions |
8849 | 1837 }; |
1838 | |
1839 static void | |
1840 init_plugin(GaimPlugin *plugin) | |
1841 { | |
1842 GaimAccountOption *option; | |
10825 | 1843 GaimAccountUserSplit *split; |
8849 | 1844 char tmp[256]; |
12217 | 1845 int i; |
1846 GaimKeyValuePair *kvp; | |
1847 GList *list = NULL; | |
8849 | 1848 |
1849 silc_plugin = plugin; | |
1850 | |
10825 | 1851 split = gaim_account_user_split_new(_("Network"), "silcnet.org", '@'); |
1852 prpl_info.user_splits = g_list_append(prpl_info.user_splits, split); | |
1853 | |
8849 | 1854 /* Account options */ |
1855 option = gaim_account_option_string_new(_("Connect server"), | |
1856 "server", | |
1857 "silc.silcnet.org"); | |
1858 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); | |
1859 option = gaim_account_option_int_new(_("Port"), "port", 706); | |
1860 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); | |
10825 | 1861 g_snprintf(tmp, sizeof(tmp), "%s" G_DIR_SEPARATOR_S "public_key.pub", silcgaim_silcdir()); |
1862 option = gaim_account_option_string_new(_("Public Key file"), | |
1863 "public-key", tmp); | |
1864 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); | |
1865 g_snprintf(tmp, sizeof(tmp), "%s" G_DIR_SEPARATOR_S "private_key.prv", silcgaim_silcdir()); | |
1866 option = gaim_account_option_string_new(_("Private Key file"), | |
1867 "private-key", tmp); | |
1868 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); | |
12217 | 1869 |
1870 for (i = 0; silc_default_ciphers[i].name; i++) { | |
1871 kvp = silc_calloc(1, sizeof(*kvp)); | |
1872 kvp->key = strdup(silc_default_ciphers[i].name); | |
1873 kvp->value = strdup(silc_default_ciphers[i].name); | |
1874 list = g_list_append(list, kvp); | |
1875 } | |
1876 option = gaim_account_option_list_new(_("Cipher"), "cipher", list); | |
1877 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); | |
1878 | |
1879 list = NULL; | |
1880 for (i = 0; silc_default_hmacs[i].name; i++) { | |
1881 kvp = silc_calloc(1, sizeof(*kvp)); | |
1882 kvp->key = strdup(silc_default_hmacs[i].name); | |
1883 kvp->value = strdup(silc_default_hmacs[i].name); | |
1884 list = g_list_append(list, kvp); | |
1885 } | |
1886 option = gaim_account_option_list_new(_("HMAC"), "hmac", list); | |
1887 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); | |
1888 | |
8849 | 1889 option = gaim_account_option_bool_new(_("Public key authentication"), |
1890 "pubkey-auth", FALSE); | |
1891 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); | |
1892 option = gaim_account_option_bool_new(_("Reject watching by other users"), | |
1893 "reject-watch", FALSE); | |
1894 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); | |
1895 option = gaim_account_option_bool_new(_("Block invites"), | |
1896 "block-invites", FALSE); | |
1897 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); | |
1898 option = gaim_account_option_bool_new(_("Block IMs without Key Exchange"), | |
1899 "block-ims", FALSE); | |
1900 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); | |
1901 option = gaim_account_option_bool_new(_("Reject online status attribute requests"), | |
1902 "reject-attrs", FALSE); | |
1903 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); | |
12167 | 1904 option = gaim_account_option_bool_new(_("Block messages to whiteboard"), |
1905 "block-wb", FALSE); | |
1906 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); | |
1907 option = gaim_account_option_bool_new(_("Automatically open whiteboard"), | |
1908 "open-wb", FALSE); | |
1909 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); | |
1910 option = gaim_account_option_bool_new(_("Digitally sign and verify all messages"), | |
1911 "sign-verify", FALSE); | |
1912 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); | |
8849 | 1913 |
12167 | 1914 gaim_prefs_remove("/plugins/prpl/silc"); |
9272 | 1915 |
1916 silcgaim_register_commands(); | |
9353 | 1917 |
1918 #ifdef _WIN32 | |
1919 silc_net_win32_init(); | |
1920 #endif | |
8849 | 1921 } |
1922 | |
1923 GAIM_INIT_PLUGIN(silc, init_plugin, info); |