Mercurial > pidgin
annotate src/protocols/silc/silc.c @ 10867:5727afad0fb8
[gaim-migrate @ 12553]
sf patch #991208, from Arun A Tharuvai
"Here's a patch, against current CVS, to build and
compile zephyr on Windows, with, or without Kerberos 4
Authentication.
In order to be built (and run) with Kerberos 4
authentication, the Kerberos for Windows SDK (version
2.6.3 is the current version) (licensed under the MIT
license) and runtimes, both available from
http://web.mit.edu/kerberos/www/dist/index.html#KFW2.6.3
Also, USE_KRB4 should be set to true in the attached
Makefile.mingw
As on the UNIX side, an external 'zhm' binary needs to run
for zephyr to work. Source and a win32 executable
(using code from gaim's libzephyr, and also MIT's
zephyr distribution), can be found at
http://web.mit.edu/aatharuv/www/zhm-windows.html"
I decided not to make zephyr compiled by default in Windows.
If you want to compile it, I think you you can modify the root
Makefile.mingw or cd to the src/protocols/zephyr/ directory
and run "make -f Makefile.mingw" using make from mingw
committer: Tailor Script <tailor@pidgin.im>
author | Mark Doliner <mark@kingant.net> |
---|---|
date | Mon, 25 Apr 2005 01:53:01 +0000 |
parents | cb625efd1071 |
children | 3e43c132f151 |
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" |
8849 | 24 |
25 extern SilcClientOperations ops; | |
26 static GaimPlugin *silc_plugin = NULL; | |
27 | |
28 static const char * | |
29 silcgaim_list_icon(GaimAccount *a, GaimBuddy *b) | |
30 { | |
31 return (const char *)"silc"; | |
32 } | |
33 | |
34 static void | |
9968 | 35 silcgaim_list_emblems(GaimBuddy *b, const char **se, const char **sw, |
36 const char **nw, const char **ne) | |
8849 | 37 { |
38 } | |
39 | |
40 static GList * | |
9968 | 41 silcgaim_away_states(GaimAccount *account) |
8849 | 42 { |
9968 | 43 GaimStatusType *type; |
44 GList *types = NULL; | |
8849 | 45 |
10801 | 46 type = gaim_status_type_new_full(GAIM_STATUS_OFFLINE, SILCGAIM_STATUS_ID_OFFLINE, _("Offline"), FALSE, FALSE, FALSE); |
9968 | 47 types = g_list_append(types, type); |
10801 | 48 type = gaim_status_type_new_full(GAIM_STATUS_ONLINE, SILCGAIM_STATUS_ID_ONLINE, _("Online"), FALSE, FALSE, FALSE); |
49 types = g_list_append(types, type); | |
50 type = gaim_status_type_new_full(GAIM_STATUS_AVAILABLE, SILCGAIM_STATUS_ID_AVAILABLE, _("Available"), FALSE, TRUE, FALSE); | |
9968 | 51 types = g_list_append(types, type); |
10050 | 52 type = gaim_status_type_new_full(GAIM_STATUS_AVAILABLE, SILCGAIM_STATUS_ID_HYPER, _("Hyper Active"), FALSE, TRUE, FALSE); |
9968 | 53 types = g_list_append(types, type); |
10050 | 54 type = gaim_status_type_new_full(GAIM_STATUS_AWAY, SILCGAIM_STATUS_ID_AWAY, _("Away"), FALSE, TRUE, FALSE); |
9968 | 55 types = g_list_append(types, type); |
10050 | 56 type = gaim_status_type_new_full(GAIM_STATUS_AWAY, SILCGAIM_STATUS_ID_BUSY, _("Busy"), FALSE, TRUE, FALSE); |
9968 | 57 types = g_list_append(types, type); |
10050 | 58 type = gaim_status_type_new_full(GAIM_STATUS_AWAY, SILCGAIM_STATUS_ID_INDISPOSED, _("Indisposed"), FALSE, TRUE, FALSE); |
9968 | 59 types = g_list_append(types, type); |
10050 | 60 type = gaim_status_type_new_full(GAIM_STATUS_AWAY, SILCGAIM_STATUS_ID_PAGE, _("Wake Me Up"), FALSE, TRUE, FALSE); |
9968 | 61 types = g_list_append(types, type); |
8849 | 62 |
9968 | 63 return types; |
8849 | 64 } |
65 | |
66 static void | |
9968 | 67 silcgaim_set_status(GaimAccount *account, GaimStatus *status) |
8849 | 68 { |
9968 | 69 GaimConnection *gc = gaim_account_get_connection(account); |
10801 | 70 SilcGaim sg = NULL; |
8849 | 71 SilcUInt32 mode; |
72 SilcBuffer idp; | |
73 unsigned char mb[4]; | |
9968 | 74 const char *state; |
8849 | 75 |
10801 | 76 if (gc != NULL) |
77 sg = gc->proto_data; | |
78 | |
79 if (status == NULL) | |
80 return; | |
81 | |
82 state = gaim_status_get_id(status); | |
10225 | 83 |
10801 | 84 if (state == NULL) |
85 return; | |
10225 | 86 |
10801 | 87 if (strcmp(state, "offline") && !gc) { |
88 gaim_account_connect(account); | |
89 return; | |
10802 | 90 } else if (!strcmp(state, "offline")) { |
91 return; | |
10801 | 92 } |
93 | |
94 if ((sg == NULL) || (sg->conn == NULL)) | |
8849 | 95 return; |
96 | |
97 mode = sg->conn->local_entry->mode; | |
98 mode &= ~(SILC_UMODE_GONE | | |
99 SILC_UMODE_HYPER | | |
100 SILC_UMODE_BUSY | | |
101 SILC_UMODE_INDISPOSED | | |
102 SILC_UMODE_PAGE); | |
103 | |
9968 | 104 if (!strcmp(state, "hyper")) |
8849 | 105 mode |= SILC_UMODE_HYPER; |
9968 | 106 else if (!strcmp(state, "away")) |
8849 | 107 mode |= SILC_UMODE_GONE; |
9968 | 108 else if (!strcmp(state, "busy")) |
8849 | 109 mode |= SILC_UMODE_BUSY; |
9968 | 110 else if (!strcmp(state, "indisposed")) |
8849 | 111 mode |= SILC_UMODE_INDISPOSED; |
9968 | 112 else if (!strcmp(state, "page")) |
8849 | 113 mode |= SILC_UMODE_PAGE; |
114 | |
115 /* Send UMODE */ | |
116 idp = silc_id_payload_encode(sg->conn->local_id, SILC_ID_CLIENT); | |
117 SILC_PUT32_MSB(mode, mb); | |
118 silc_client_command_send(sg->client, sg->conn, SILC_COMMAND_UMODE, | |
119 ++sg->conn->cmd_ident, 2, | |
120 1, idp->data, idp->len, | |
121 2, mb, sizeof(mb)); | |
122 silc_buffer_free(idp); | |
123 } | |
124 | |
125 | |
126 /*************************** Connection Routines *****************************/ | |
127 | |
128 static void | |
129 silcgaim_keepalive(GaimConnection *gc) | |
130 { | |
131 SilcGaim sg = gc->proto_data; | |
132 silc_client_send_packet(sg->client, sg->conn, SILC_PACKET_HEARTBEAT, | |
133 NULL, 0); | |
134 } | |
135 | |
136 static int | |
137 silcgaim_scheduler(gpointer *context) | |
138 { | |
139 SilcGaim sg = (SilcGaim)context; | |
140 silc_client_run_one(sg->client); | |
141 return 1; | |
142 } | |
143 | |
144 static void | |
145 silcgaim_nickname_parse(const char *nickname, | |
146 char **ret_nickname) | |
147 { | |
148 silc_parse_userfqdn(nickname, ret_nickname, NULL); | |
149 } | |
150 | |
151 static void | |
152 silcgaim_login_connected(gpointer data, gint source, GaimInputCondition cond) | |
153 { | |
154 GaimConnection *gc = data; | |
155 SilcGaim sg = gc->proto_data; | |
9732 | 156 SilcClient client; |
8849 | 157 SilcClientConnection conn; |
158 GaimAccount *account = sg->account; | |
159 SilcClientConnectionParams params; | |
160 const char *dfile; | |
161 | |
162 if (source < 0) { | |
163 gaim_connection_error(gc, _("Connection failed")); | |
164 return; | |
165 } | |
9732 | 166 |
167 if (sg == NULL) | |
168 return; | |
169 | |
170 client = sg->client; | |
171 | |
8849 | 172 if (!g_list_find(gaim_connections_get_all(), gc)) { |
173 close(source); | |
174 g_source_remove(sg->scheduler); | |
175 silc_client_stop(sg->client); | |
176 silc_client_free(sg->client); | |
177 silc_free(sg); | |
178 return; | |
179 } | |
180 | |
181 /* Get session detachment data, if available */ | |
182 memset(¶ms, 0, sizeof(params)); | |
183 dfile = silcgaim_session_file(gaim_account_get_username(sg->account)); | |
184 params.detach_data = silc_file_readfile(dfile, ¶ms.detach_data_len); | |
185 if (params.detach_data) | |
186 params.detach_data[params.detach_data_len] = 0; | |
187 | |
188 /* Add connection to SILC client library */ | |
189 conn = silc_client_add_connection( | |
190 sg->client, ¶ms, | |
191 (char *)gaim_account_get_string(account, "server", | |
192 "silc.silcnet.org"), | |
193 gaim_account_get_int(account, "port", 706), sg); | |
194 if (!conn) { | |
195 gaim_connection_error(gc, _("Cannot initialize SILC Client connection")); | |
196 gc->proto_data = NULL; | |
197 return; | |
198 } | |
199 sg->conn = conn; | |
200 | |
201 /* Progress */ | |
202 if (params.detach_data) { | |
203 gaim_connection_update_progress(gc, _("Resuming session"), 2, 5); | |
204 sg->resuming = TRUE; | |
205 } else { | |
206 gaim_connection_update_progress(gc, _("Performing key exchange"), 2, 5); | |
207 } | |
208 | |
209 /* Perform SILC Key Exchange. The "silc_connected" will be called | |
210 eventually. */ | |
211 silc_client_start_key_exchange(sg->client, sg->conn, source); | |
212 | |
213 /* Set default attributes */ | |
214 if (!gaim_account_get_bool(account, "reject-attrs", FALSE)) { | |
215 SilcUInt32 mask; | |
216 const char *tmp; | |
217 #ifdef HAVE_SYS_UTSNAME_H | |
218 struct utsname u; | |
219 #endif | |
220 | |
221 mask = SILC_ATTRIBUTE_MOOD_NORMAL; | |
222 silc_client_attribute_add(client, conn, | |
223 SILC_ATTRIBUTE_STATUS_MOOD, | |
224 SILC_32_TO_PTR(mask), | |
225 sizeof(SilcUInt32)); | |
226 mask = SILC_ATTRIBUTE_CONTACT_CHAT; | |
227 silc_client_attribute_add(client, conn, | |
228 SILC_ATTRIBUTE_PREFERRED_CONTACT, | |
229 SILC_32_TO_PTR(mask), | |
230 sizeof(SilcUInt32)); | |
231 #ifdef HAVE_SYS_UTSNAME_H | |
232 if (!uname(&u)) { | |
233 SilcAttributeObjDevice dev; | |
234 memset(&dev, 0, sizeof(dev)); | |
235 dev.type = SILC_ATTRIBUTE_DEVICE_COMPUTER; | |
236 dev.version = u.release; | |
237 dev.model = u.sysname; | |
238 silc_client_attribute_add(client, conn, | |
239 SILC_ATTRIBUTE_DEVICE_INFO, | |
240 (void *)&dev, sizeof(dev)); | |
241 } | |
242 #endif | |
243 #ifdef _WIN32 | |
244 tmp = _tzname[0]; | |
245 #else | |
246 tmp = tzname[0]; | |
247 #endif | |
248 silc_client_attribute_add(client, conn, | |
249 SILC_ATTRIBUTE_TIMEZONE, | |
250 (void *)tmp, strlen(tmp)); | |
251 } | |
252 | |
253 silc_free(params.detach_data); | |
254 } | |
255 | |
256 static void | |
10401 | 257 silcgaim_login(GaimAccount *account, GaimStatus *status) |
8849 | 258 { |
259 SilcGaim sg; | |
260 SilcClient client; | |
261 SilcClientParams params; | |
262 GaimConnection *gc; | |
10825 | 263 char pkd[256], prd[256]; |
8849 | 264 |
265 gc = account->gc; | |
266 if (!gc) | |
267 return; | |
268 gc->proto_data = NULL; | |
269 | |
270 memset(¶ms, 0, sizeof(params)); | |
271 strcat(params.nickname_format, "%n@%h%a"); | |
272 params.nickname_parse = silcgaim_nickname_parse; | |
273 params.ignore_requested_attributes = | |
274 gaim_account_get_bool(account, "reject-attrs", FALSE); | |
275 | |
276 /* Allocate SILC client */ | |
277 client = silc_client_alloc(&ops, ¶ms, gc, NULL); | |
278 if (!client) { | |
279 gaim_connection_error(gc, _("Out of memory")); | |
280 return; | |
281 } | |
282 | |
283 /* Get username, real name and local hostname for SILC library */ | |
284 if (gaim_account_get_username(account)) { | |
10825 | 285 const char *u = gaim_account_get_username(account); |
286 char **up = g_strsplit(u, "@", 2); | |
287 client->username = strdup(up[0]); | |
288 g_strfreev(up); | |
8849 | 289 } else { |
290 client->username = silc_get_username(); | |
291 gaim_account_set_username(account, client->username); | |
292 } | |
293 if (gaim_account_get_user_info(account)) { | |
294 client->realname = strdup(gaim_account_get_user_info(account)); | |
295 } else { | |
296 client->realname = silc_get_real_name(); | |
297 gaim_account_set_user_info(account, client->realname); | |
298 } | |
299 client->hostname = silc_net_localhost(); | |
300 | |
301 gaim_connection_set_display_name(gc, client->username); | |
302 | |
303 /* Init SILC client */ | |
304 if (!silc_client_init(client)) { | |
305 gaim_connection_error(gc, ("Cannot initialize SILC protocol")); | |
306 return; | |
307 } | |
308 | |
309 /* Check the ~/.silc dir and create it, and new key pair if necessary. */ | |
310 if (!silcgaim_check_silc_dir(gc)) { | |
311 gaim_connection_error(gc, ("Cannot find/access ~/.silc directory")); | |
312 return; | |
313 } | |
314 | |
315 /* Progress */ | |
316 gaim_connection_update_progress(gc, _("Connecting to SILC Server"), 1, 5); | |
317 | |
318 /* Load SILC key pair */ | |
10825 | 319 g_snprintf(pkd, sizeof(prd), "%s" G_DIR_SEPARATOR_S "public_key.pub", silcgaim_silcdir()); |
320 g_snprintf(prd, sizeof(prd), "%s" G_DIR_SEPARATOR_S "private_key.pub", silcgaim_silcdir()); | |
321 if (!silc_load_key_pair((char *)gaim_account_get_string(account, "public-key", prd), | |
322 (char *)gaim_account_get_string(account, "private-key", prd), | |
10751 | 323 (gc->password == NULL) ? "" : gc->password, &client->pkcs, |
9272 | 324 &client->public_key, &client->private_key)) { |
8849 | 325 gaim_connection_error(gc, ("Could not load SILC key pair")); |
326 return; | |
327 } | |
328 | |
329 sg = silc_calloc(1, sizeof(*sg)); | |
330 if (!sg) | |
331 return; | |
332 memset(sg, 0, sizeof(*sg)); | |
333 sg->client = client; | |
334 sg->gc = gc; | |
335 sg->account = account; | |
336 gc->proto_data = sg; | |
337 | |
338 /* Connect to the SILC server */ | |
339 if (gaim_proxy_connect(account, | |
340 gaim_account_get_string(account, "server", | |
341 "silc.silcnet.org"), | |
342 gaim_account_get_int(account, "port", 706), | |
343 silcgaim_login_connected, gc)) { | |
344 gaim_connection_error(gc, ("Unable to create connection")); | |
345 return; | |
346 } | |
347 | |
348 /* Schedule SILC using Glib's event loop */ | |
9353 | 349 #ifndef _WIN32 |
8849 | 350 sg->scheduler = g_timeout_add(5, (GSourceFunc)silcgaim_scheduler, sg); |
9353 | 351 #else |
352 sg->scheduler = g_timeout_add(300, (GSourceFunc)silcgaim_scheduler, sg); | |
353 #endif | |
8849 | 354 } |
355 | |
356 static int | |
357 silcgaim_close_final(gpointer *context) | |
358 { | |
359 SilcGaim sg = (SilcGaim)context; | |
360 silc_client_stop(sg->client); | |
361 silc_client_free(sg->client); | |
362 silc_free(sg); | |
363 return 0; | |
364 } | |
365 | |
366 static void | |
367 silcgaim_close(GaimConnection *gc) | |
368 { | |
369 SilcGaim sg = gc->proto_data; | |
370 | |
10547 | 371 g_return_if_fail(sg != NULL); |
8849 | 372 |
373 /* Send QUIT */ | |
374 silc_client_command_call(sg->client, sg->conn, NULL, | |
9353 | 375 "QUIT", "Download Gaim: " GAIM_WEBSITE, NULL); |
8849 | 376 |
377 if (sg->conn) | |
378 silc_client_close_connection(sg->client, sg->conn); | |
379 | |
380 g_source_remove(sg->scheduler); | |
381 g_timeout_add(1, (GSourceFunc)silcgaim_close_final, sg); | |
382 } | |
383 | |
384 | |
385 /****************************** Protocol Actions *****************************/ | |
386 | |
387 static void | |
388 silcgaim_attrs_cancel(GaimConnection *gc, GaimRequestFields *fields) | |
389 { | |
390 /* Nothing */ | |
391 } | |
392 | |
393 static void | |
394 silcgaim_attrs_cb(GaimConnection *gc, GaimRequestFields *fields) | |
395 { | |
396 SilcGaim sg = gc->proto_data; | |
397 SilcClient client = sg->client; | |
398 SilcClientConnection conn = sg->conn; | |
399 GaimRequestField *f; | |
400 char *tmp; | |
401 SilcUInt32 tmp_len, mask; | |
402 SilcAttributeObjService service; | |
403 SilcAttributeObjDevice dev; | |
404 SilcVCardStruct vcard; | |
405 const char *val; | |
406 | |
407 sg = gc->proto_data; | |
408 if (!sg) | |
409 return; | |
410 | |
411 memset(&service, 0, sizeof(service)); | |
412 memset(&dev, 0, sizeof(dev)); | |
413 memset(&vcard, 0, sizeof(vcard)); | |
414 | |
415 silc_client_attribute_del(client, conn, | |
416 SILC_ATTRIBUTE_USER_INFO, NULL); | |
417 silc_client_attribute_del(client, conn, | |
418 SILC_ATTRIBUTE_SERVICE, NULL); | |
419 silc_client_attribute_del(client, conn, | |
420 SILC_ATTRIBUTE_STATUS_MOOD, NULL); | |
421 silc_client_attribute_del(client, conn, | |
422 SILC_ATTRIBUTE_STATUS_FREETEXT, NULL); | |
423 silc_client_attribute_del(client, conn, | |
424 SILC_ATTRIBUTE_STATUS_MESSAGE, NULL); | |
425 silc_client_attribute_del(client, conn, | |
426 SILC_ATTRIBUTE_PREFERRED_LANGUAGE, NULL); | |
427 silc_client_attribute_del(client, conn, | |
428 SILC_ATTRIBUTE_PREFERRED_CONTACT, NULL); | |
429 silc_client_attribute_del(client, conn, | |
430 SILC_ATTRIBUTE_TIMEZONE, NULL); | |
431 silc_client_attribute_del(client, conn, | |
432 SILC_ATTRIBUTE_GEOLOCATION, NULL); | |
433 silc_client_attribute_del(client, conn, | |
434 SILC_ATTRIBUTE_DEVICE_INFO, NULL); | |
435 | |
436 /* Set mood */ | |
437 mask = 0; | |
438 f = gaim_request_fields_get_field(fields, "mood_normal"); | |
439 if (f && gaim_request_field_bool_get_value(f)) | |
440 mask |= SILC_ATTRIBUTE_MOOD_NORMAL; | |
441 f = gaim_request_fields_get_field(fields, "mood_happy"); | |
442 if (f && gaim_request_field_bool_get_value(f)) | |
443 mask |= SILC_ATTRIBUTE_MOOD_HAPPY; | |
444 f = gaim_request_fields_get_field(fields, "mood_sad"); | |
445 if (f && gaim_request_field_bool_get_value(f)) | |
446 mask |= SILC_ATTRIBUTE_MOOD_SAD; | |
447 f = gaim_request_fields_get_field(fields, "mood_angry"); | |
448 if (f && gaim_request_field_bool_get_value(f)) | |
449 mask |= SILC_ATTRIBUTE_MOOD_ANGRY; | |
450 f = gaim_request_fields_get_field(fields, "mood_jealous"); | |
451 if (f && gaim_request_field_bool_get_value(f)) | |
452 mask |= SILC_ATTRIBUTE_MOOD_JEALOUS; | |
453 f = gaim_request_fields_get_field(fields, "mood_ashamed"); | |
454 if (f && gaim_request_field_bool_get_value(f)) | |
455 mask |= SILC_ATTRIBUTE_MOOD_ASHAMED; | |
456 f = gaim_request_fields_get_field(fields, "mood_invincible"); | |
457 if (f && gaim_request_field_bool_get_value(f)) | |
458 mask |= SILC_ATTRIBUTE_MOOD_INVINCIBLE; | |
459 f = gaim_request_fields_get_field(fields, "mood_inlove"); | |
460 if (f && gaim_request_field_bool_get_value(f)) | |
461 mask |= SILC_ATTRIBUTE_MOOD_INLOVE; | |
462 f = gaim_request_fields_get_field(fields, "mood_sleepy"); | |
463 if (f && gaim_request_field_bool_get_value(f)) | |
464 mask |= SILC_ATTRIBUTE_MOOD_SLEEPY; | |
465 f = gaim_request_fields_get_field(fields, "mood_bored"); | |
466 if (f && gaim_request_field_bool_get_value(f)) | |
467 mask |= SILC_ATTRIBUTE_MOOD_BORED; | |
468 f = gaim_request_fields_get_field(fields, "mood_excited"); | |
469 if (f && gaim_request_field_bool_get_value(f)) | |
470 mask |= SILC_ATTRIBUTE_MOOD_EXCITED; | |
471 f = gaim_request_fields_get_field(fields, "mood_anxious"); | |
472 if (f && gaim_request_field_bool_get_value(f)) | |
473 mask |= SILC_ATTRIBUTE_MOOD_ANXIOUS; | |
474 silc_client_attribute_add(client, conn, | |
475 SILC_ATTRIBUTE_STATUS_MOOD, | |
476 SILC_32_TO_PTR(mask), | |
477 sizeof(SilcUInt32)); | |
478 | |
479 /* Set preferred contact */ | |
480 mask = 0; | |
481 f = gaim_request_fields_get_field(fields, "contact_chat"); | |
482 if (f && gaim_request_field_bool_get_value(f)) | |
483 mask |= SILC_ATTRIBUTE_CONTACT_CHAT; | |
484 f = gaim_request_fields_get_field(fields, "contact_email"); | |
485 if (f && gaim_request_field_bool_get_value(f)) | |
486 mask |= SILC_ATTRIBUTE_CONTACT_EMAIL; | |
487 f = gaim_request_fields_get_field(fields, "contact_call"); | |
488 if (f && gaim_request_field_bool_get_value(f)) | |
489 mask |= SILC_ATTRIBUTE_CONTACT_CALL; | |
490 f = gaim_request_fields_get_field(fields, "contact_sms"); | |
491 if (f && gaim_request_field_bool_get_value(f)) | |
492 mask |= SILC_ATTRIBUTE_CONTACT_SMS; | |
493 f = gaim_request_fields_get_field(fields, "contact_mms"); | |
494 if (f && gaim_request_field_bool_get_value(f)) | |
495 mask |= SILC_ATTRIBUTE_CONTACT_MMS; | |
496 f = gaim_request_fields_get_field(fields, "contact_video"); | |
497 if (f && gaim_request_field_bool_get_value(f)) | |
498 mask |= SILC_ATTRIBUTE_CONTACT_VIDEO; | |
499 if (mask) | |
500 silc_client_attribute_add(client, conn, | |
501 SILC_ATTRIBUTE_PREFERRED_CONTACT, | |
502 SILC_32_TO_PTR(mask), | |
503 sizeof(SilcUInt32)); | |
504 | |
505 /* Set status text */ | |
506 val = NULL; | |
507 f = gaim_request_fields_get_field(fields, "status_text"); | |
508 if (f) | |
509 val = gaim_request_field_string_get_value(f); | |
510 if (val && *val) | |
511 silc_client_attribute_add(client, conn, | |
512 SILC_ATTRIBUTE_STATUS_FREETEXT, | |
513 (void *)val, strlen(val)); | |
514 | |
515 /* Set vcard */ | |
516 val = NULL; | |
517 f = gaim_request_fields_get_field(fields, "vcard"); | |
518 if (f) | |
519 val = gaim_request_field_string_get_value(f); | |
520 if (val && *val) { | |
521 gaim_prefs_set_string("/plugins/prpl/silc/vcard", val); | |
522 tmp = silc_file_readfile(val, &tmp_len); | |
523 if (tmp) { | |
524 tmp[tmp_len] = 0; | |
525 if (silc_vcard_decode(tmp, tmp_len, &vcard)) | |
526 silc_client_attribute_add(client, conn, | |
527 SILC_ATTRIBUTE_USER_INFO, | |
528 (void *)&vcard, | |
529 sizeof(vcard)); | |
530 } | |
531 silc_vcard_free(&vcard); | |
532 silc_free(tmp); | |
533 } | |
534 | |
535 #ifdef HAVE_SYS_UTSNAME_H | |
536 /* Set device info */ | |
537 f = gaim_request_fields_get_field(fields, "device"); | |
538 if (f && gaim_request_field_bool_get_value(f)) { | |
539 struct utsname u; | |
540 if (!uname(&u)) { | |
541 dev.type = SILC_ATTRIBUTE_DEVICE_COMPUTER; | |
542 dev.version = u.release; | |
543 dev.model = u.sysname; | |
544 silc_client_attribute_add(client, conn, | |
545 SILC_ATTRIBUTE_DEVICE_INFO, | |
546 (void *)&dev, sizeof(dev)); | |
547 } | |
548 } | |
549 #endif | |
550 | |
551 /* Set timezone */ | |
552 val = NULL; | |
553 f = gaim_request_fields_get_field(fields, "timezone"); | |
554 if (f) | |
555 val = gaim_request_field_string_get_value(f); | |
556 if (val && *val) | |
557 silc_client_attribute_add(client, conn, | |
558 SILC_ATTRIBUTE_TIMEZONE, | |
559 (void *)val, strlen(val)); | |
560 } | |
561 | |
562 static void | |
9015 | 563 silcgaim_attrs(GaimPluginAction *action) |
8849 | 564 { |
9015 | 565 GaimConnection *gc = (GaimConnection *) action->context; |
8849 | 566 SilcGaim sg = gc->proto_data; |
567 SilcClient client = sg->client; | |
568 SilcClientConnection conn = sg->conn; | |
569 GaimRequestFields *fields; | |
570 GaimRequestFieldGroup *g; | |
571 GaimRequestField *f; | |
572 SilcHashTable attrs; | |
573 SilcAttributePayload attr; | |
574 gboolean mnormal = TRUE, mhappy = FALSE, msad = FALSE, | |
575 mangry = FALSE, mjealous = FALSE, mashamed = FALSE, | |
576 minvincible = FALSE, minlove = FALSE, msleepy = FALSE, | |
577 mbored = FALSE, mexcited = FALSE, manxious = FALSE; | |
578 gboolean cemail = FALSE, ccall = FALSE, csms = FALSE, | |
579 cmms = FALSE, cchat = TRUE, cvideo = FALSE; | |
580 gboolean device = TRUE; | |
581 char status[1024]; | |
582 | |
583 sg = gc->proto_data; | |
584 if (!sg) | |
585 return; | |
586 | |
587 memset(status, 0, sizeof(status)); | |
588 | |
589 attrs = silc_client_attributes_get(client, conn); | |
590 if (attrs) { | |
591 if (silc_hash_table_find(attrs, | |
592 SILC_32_TO_PTR(SILC_ATTRIBUTE_STATUS_MOOD), | |
593 NULL, (void *)&attr)) { | |
594 SilcUInt32 mood = 0; | |
595 silc_attribute_get_object(attr, &mood, sizeof(mood)); | |
596 mnormal = !mood; | |
597 mhappy = (mood & SILC_ATTRIBUTE_MOOD_HAPPY); | |
598 msad = (mood & SILC_ATTRIBUTE_MOOD_SAD); | |
599 mangry = (mood & SILC_ATTRIBUTE_MOOD_ANGRY); | |
600 mjealous = (mood & SILC_ATTRIBUTE_MOOD_JEALOUS); | |
601 mashamed = (mood & SILC_ATTRIBUTE_MOOD_ASHAMED); | |
602 minvincible = (mood & SILC_ATTRIBUTE_MOOD_INVINCIBLE); | |
603 minlove = (mood & SILC_ATTRIBUTE_MOOD_INLOVE); | |
604 msleepy = (mood & SILC_ATTRIBUTE_MOOD_SLEEPY); | |
605 mbored = (mood & SILC_ATTRIBUTE_MOOD_BORED); | |
606 mexcited = (mood & SILC_ATTRIBUTE_MOOD_EXCITED); | |
607 manxious = (mood & SILC_ATTRIBUTE_MOOD_ANXIOUS); | |
608 } | |
609 | |
610 if (silc_hash_table_find(attrs, | |
611 SILC_32_TO_PTR(SILC_ATTRIBUTE_PREFERRED_CONTACT), | |
612 NULL, (void *)&attr)) { | |
613 SilcUInt32 contact = 0; | |
614 silc_attribute_get_object(attr, &contact, sizeof(contact)); | |
615 cemail = (contact & SILC_ATTRIBUTE_CONTACT_EMAIL); | |
616 ccall = (contact & SILC_ATTRIBUTE_CONTACT_CALL); | |
617 csms = (contact & SILC_ATTRIBUTE_CONTACT_SMS); | |
618 cmms = (contact & SILC_ATTRIBUTE_CONTACT_MMS); | |
619 cchat = (contact & SILC_ATTRIBUTE_CONTACT_CHAT); | |
620 cvideo = (contact & SILC_ATTRIBUTE_CONTACT_VIDEO); | |
621 } | |
622 | |
623 if (silc_hash_table_find(attrs, | |
624 SILC_32_TO_PTR(SILC_ATTRIBUTE_STATUS_FREETEXT), | |
625 NULL, (void *)&attr)) | |
626 silc_attribute_get_object(attr, &status, sizeof(status)); | |
627 | |
628 if (!silc_hash_table_find(attrs, | |
629 SILC_32_TO_PTR(SILC_ATTRIBUTE_DEVICE_INFO), | |
630 NULL, (void *)&attr)) | |
631 device = FALSE; | |
632 } | |
633 | |
634 fields = gaim_request_fields_new(); | |
635 | |
636 g = gaim_request_field_group_new(NULL); | |
637 f = gaim_request_field_label_new("l3", _("Your Current Mood")); | |
638 gaim_request_field_group_add_field(g, f); | |
639 f = gaim_request_field_bool_new("mood_normal", _("Normal"), mnormal); | |
640 gaim_request_field_group_add_field(g, f); | |
641 f = gaim_request_field_bool_new("mood_happy", _("Happy"), mhappy); | |
642 gaim_request_field_group_add_field(g, f); | |
643 f = gaim_request_field_bool_new("mood_sad", _("Sad"), msad); | |
644 gaim_request_field_group_add_field(g, f); | |
645 f = gaim_request_field_bool_new("mood_angry", _("Angry"), mangry); | |
646 gaim_request_field_group_add_field(g, f); | |
647 f = gaim_request_field_bool_new("mood_jealous", _("Jealous"), mjealous); | |
648 gaim_request_field_group_add_field(g, f); | |
649 f = gaim_request_field_bool_new("mood_ashamed", _("Ashamed"), mashamed); | |
650 gaim_request_field_group_add_field(g, f); | |
651 f = gaim_request_field_bool_new("mood_invincible", _("Invincible"), minvincible); | |
652 gaim_request_field_group_add_field(g, f); | |
653 f = gaim_request_field_bool_new("mood_inlove", _("In Love"), minlove); | |
654 gaim_request_field_group_add_field(g, f); | |
655 f = gaim_request_field_bool_new("mood_sleepy", _("Sleepy"), msleepy); | |
656 gaim_request_field_group_add_field(g, f); | |
657 f = gaim_request_field_bool_new("mood_bored", _("Bored"), mbored); | |
658 gaim_request_field_group_add_field(g, f); | |
659 f = gaim_request_field_bool_new("mood_excited", _("Excited"), mexcited); | |
660 gaim_request_field_group_add_field(g, f); | |
661 f = gaim_request_field_bool_new("mood_anxious", _("Anxious"), manxious); | |
662 gaim_request_field_group_add_field(g, f); | |
663 | |
664 f = gaim_request_field_label_new("l4", _("\nYour Preferred Contact Methods")); | |
665 gaim_request_field_group_add_field(g, f); | |
666 f = gaim_request_field_bool_new("contact_chat", _("Chat"), cchat); | |
667 gaim_request_field_group_add_field(g, f); | |
668 f = gaim_request_field_bool_new("contact_email", _("Email"), cemail); | |
669 gaim_request_field_group_add_field(g, f); | |
670 f = gaim_request_field_bool_new("contact_call", _("Phone"), ccall); | |
671 gaim_request_field_group_add_field(g, f); | |
672 f = gaim_request_field_bool_new("contact_sms", _("SMS"), csms); | |
673 gaim_request_field_group_add_field(g, f); | |
674 f = gaim_request_field_bool_new("contact_mms", _("MMS"), cmms); | |
675 gaim_request_field_group_add_field(g, f); | |
676 f = gaim_request_field_bool_new("contact_video", _("Video Conferencing"), cvideo); | |
677 gaim_request_field_group_add_field(g, f); | |
678 gaim_request_fields_add_group(fields, g); | |
679 | |
680 g = gaim_request_field_group_new(NULL); | |
681 f = gaim_request_field_string_new("status_text", _("Your Current Status"), | |
682 status[0] ? status : NULL, TRUE); | |
683 gaim_request_field_group_add_field(g, f); | |
684 gaim_request_fields_add_group(fields, g); | |
685 | |
686 g = gaim_request_field_group_new(NULL); | |
687 #if 0 | |
688 f = gaim_request_field_label_new("l2", _("Online Services")); | |
689 gaim_request_field_group_add_field(g, f); | |
690 f = gaim_request_field_bool_new("services", | |
691 _("Let others see what services you are using"), | |
692 TRUE); | |
693 gaim_request_field_group_add_field(g, f); | |
694 #endif | |
695 #ifdef HAVE_SYS_UTSNAME_H | |
696 f = gaim_request_field_bool_new("device", | |
697 _("Let others see what computer you are using"), | |
698 device); | |
699 gaim_request_field_group_add_field(g, f); | |
700 #endif | |
701 gaim_request_fields_add_group(fields, g); | |
702 | |
703 g = gaim_request_field_group_new(NULL); | |
704 f = gaim_request_field_string_new("vcard", _("Your VCard File"), | |
705 gaim_prefs_get_string("/plugins/prpl/silc/vcard"), | |
706 FALSE); | |
707 gaim_request_field_group_add_field(g, f); | |
708 #ifdef _WIN32 | |
709 f = gaim_request_field_string_new("timezone", _("Timezone"), _tzname[0], FALSE); | |
710 #else | |
711 f = gaim_request_field_string_new("timezone", _("Timezone"), tzname[0], FALSE); | |
712 #endif | |
713 gaim_request_field_group_add_field(g, f); | |
714 gaim_request_fields_add_group(fields, g); | |
715 | |
716 | |
717 gaim_request_fields(NULL, _("User Online Status Attributes"), | |
718 _("User Online Status Attributes"), | |
719 _("You can let other users see your online status information " | |
720 "and your personal information. Please fill the information " | |
721 "you would like other users to see about yourself."), | |
722 fields, | |
8906 | 723 _("OK"), G_CALLBACK(silcgaim_attrs_cb), |
724 _("Cancel"), G_CALLBACK(silcgaim_attrs_cancel), gc); | |
8849 | 725 } |
726 | |
727 static void | |
9015 | 728 silcgaim_detach(GaimPluginAction *action) |
8849 | 729 { |
9015 | 730 GaimConnection *gc = (GaimConnection *) action->context; |
8849 | 731 SilcGaim sg; |
732 | |
733 if (!gc) | |
734 return; | |
735 sg = gc->proto_data; | |
736 if (!sg) | |
737 return; | |
738 | |
739 /* Call DETACH */ | |
740 silc_client_command_call(sg->client, sg->conn, "DETACH"); | |
741 sg->detaching = TRUE; | |
742 } | |
743 | |
744 static void | |
9015 | 745 silcgaim_view_motd(GaimPluginAction *action) |
8849 | 746 { |
9015 | 747 GaimConnection *gc = (GaimConnection *) action->context; |
8849 | 748 SilcGaim sg; |
9488 | 749 char *tmp; |
8849 | 750 |
751 if (!gc) | |
752 return; | |
753 sg = gc->proto_data; | |
754 if (!sg) | |
755 return; | |
756 | |
757 if (!sg->motd) { | |
758 gaim_notify_error( | |
759 gc, _("Message of the Day"), _("No Message of the Day available"), | |
760 _("There is no Message of the Day associated with this connection")); | |
761 return; | |
762 } | |
763 | |
10732
c4cb90065e1d
[gaim-migrate @ 12334]
Luke Schierer <lschiere@pidgin.im>
parents:
10547
diff
changeset
|
764 tmp = g_markup_escape_text(sg->motd, -1); |
9488 | 765 gaim_notify_formatted(gc, NULL, _("Message of the Day"), NULL, |
766 tmp, NULL, NULL); | |
767 g_free(tmp); | |
8849 | 768 } |
769 | |
9272 | 770 static void |
771 silcgaim_change_pass(GaimPluginAction *action) | |
772 { | |
773 GaimConnection *gc = (GaimConnection *) action->context; | |
774 gaim_account_request_change_password(gaim_connection_get_account(gc)); | |
775 } | |
776 | |
777 static void | |
778 silcgaim_change_passwd(GaimConnection *gc, const char *old, const char *new) | |
779 { | |
10825 | 780 char prd[256]; |
781 g_snprintf(prd, sizeof(prd), "%s" G_DIR_SEPARATOR_S "private_key.pub", silcgaim_silcdir()); | |
782 silc_change_private_key_passphrase(gaim_account_get_string(gc->account, | |
783 "private-key", | |
784 prd), old, new); | |
9272 | 785 } |
786 | |
787 static void | |
788 silcgaim_show_set_info(GaimPluginAction *action) | |
789 { | |
790 GaimConnection *gc = (GaimConnection *) action->context; | |
791 gaim_account_request_change_user_info(gaim_connection_get_account(gc)); | |
792 } | |
793 | |
794 static void | |
795 silcgaim_set_info(GaimConnection *gc, const char *text) | |
796 { | |
797 } | |
798 | |
8849 | 799 static GList * |
9015 | 800 silcgaim_actions(GaimPlugin *plugin, gpointer context) |
8849 | 801 { |
9024 | 802 GaimConnection *gc = context; |
8849 | 803 GList *list = NULL; |
9015 | 804 GaimPluginAction *act; |
8849 | 805 |
806 if (!gaim_account_get_bool(gc->account, "reject-attrs", FALSE)) { | |
9015 | 807 act = gaim_plugin_action_new(_("Online Status"), |
808 silcgaim_attrs); | |
809 list = g_list_append(list, act); | |
8849 | 810 } |
811 | |
9015 | 812 act = gaim_plugin_action_new(_("Detach From Server"), |
813 silcgaim_detach); | |
814 list = g_list_append(list, act); | |
8849 | 815 |
9015 | 816 act = gaim_plugin_action_new(_("View Message of the Day"), |
817 silcgaim_view_motd); | |
818 list = g_list_append(list, act); | |
8849 | 819 |
9272 | 820 act = gaim_plugin_action_new(_("Change Password..."), |
821 silcgaim_change_pass); | |
822 list = g_list_append(list, act); | |
823 | |
824 act = gaim_plugin_action_new(_("Set User Info..."), | |
825 silcgaim_show_set_info); | |
826 list = g_list_append(list, act); | |
827 | |
8849 | 828 return list; |
829 } | |
830 | |
831 | |
832 /******************************* IM Routines *********************************/ | |
833 | |
834 typedef struct { | |
835 char *nick; | |
836 unsigned char *message; | |
837 SilcUInt32 message_len; | |
838 SilcMessageFlags flags; | |
839 } *SilcGaimIM; | |
840 | |
841 static void | |
842 silcgaim_send_im_resolved(SilcClient client, | |
843 SilcClientConnection conn, | |
844 SilcClientEntry *clients, | |
845 SilcUInt32 clients_count, | |
846 void *context) | |
847 { | |
848 GaimConnection *gc = client->application; | |
849 SilcGaim sg = gc->proto_data; | |
850 SilcGaimIM im = context; | |
851 GaimConversation *convo; | |
852 char tmp[256], *nickname = NULL; | |
853 SilcClientEntry client_entry; | |
854 | |
10246 | 855 convo = gaim_find_conversation_with_account(GAIM_CONV_IM, im->nick, |
856 sg->account); | |
8849 | 857 if (!convo) |
858 return; | |
859 | |
860 if (!clients) | |
861 goto err; | |
862 | |
863 if (clients_count > 1) { | |
864 silc_parse_userfqdn(im->nick, &nickname, NULL); | |
865 | |
866 /* Find the correct one. The im->nick might be a formatted nick | |
867 so this will find the correct one. */ | |
868 clients = silc_client_get_clients_local(client, conn, | |
869 nickname, im->nick, | |
870 &clients_count); | |
871 if (!clients) | |
872 goto err; | |
873 client_entry = clients[0]; | |
874 silc_free(clients); | |
875 } else { | |
876 client_entry = clients[0]; | |
877 } | |
878 | |
879 /* Send the message */ | |
880 silc_client_send_private_message(client, conn, client_entry, im->flags, | |
881 im->message, im->message_len, TRUE); | |
882 gaim_conv_im_write(GAIM_CONV_IM(convo), conn->local_entry->nickname, | |
883 im->message, 0, time(NULL)); | |
884 | |
885 goto out; | |
886 | |
887 err: | |
888 g_snprintf(tmp, sizeof(tmp), | |
889 _("User <I>%s</I> is not present in the network"), im->nick); | |
890 gaim_conversation_write(convo, NULL, tmp, GAIM_MESSAGE_SYSTEM, time(NULL)); | |
891 | |
892 out: | |
893 g_free(im->nick); | |
894 g_free(im->message); | |
895 silc_free(im); | |
896 silc_free(nickname); | |
897 } | |
898 | |
899 static int | |
900 silcgaim_send_im(GaimConnection *gc, const char *who, const char *msg, | |
901 GaimConvImFlags flags) | |
902 { | |
903 SilcGaim sg = gc->proto_data; | |
904 SilcClient client = sg->client; | |
905 SilcClientConnection conn = sg->conn; | |
906 SilcClientEntry *clients; | |
907 SilcUInt32 clients_count, mflags; | |
908 char *nickname; | |
909 int ret; | |
910 gboolean sign = gaim_prefs_get_bool("/plugins/prpl/silc/sign_im"); | |
911 | |
912 if (!who || !msg) | |
913 return 0; | |
914 | |
9353 | 915 mflags = SILC_MESSAGE_FLAG_UTF8; |
916 | |
917 if (!g_ascii_strncasecmp(msg, "/me ", 4)) { | |
918 msg += 4; | |
919 if (!msg) | |
920 return 0; | |
921 mflags |= SILC_MESSAGE_FLAG_ACTION; | |
922 } else if (strlen(msg) > 1 && msg[0] == '/') { | |
8849 | 923 if (!silc_client_command_call(client, conn, msg + 1)) |
924 gaim_notify_error(gc, ("Call Command"), _("Cannot call command"), | |
9359 | 925 _("Unknown command")); |
8849 | 926 return 0; |
927 } | |
928 | |
9353 | 929 |
8849 | 930 if (!silc_parse_userfqdn(who, &nickname, NULL)) |
931 return 0; | |
932 | |
933 if (sign) | |
934 mflags |= SILC_MESSAGE_FLAG_SIGNED; | |
935 | |
936 /* Find client entry */ | |
937 clients = silc_client_get_clients_local(client, conn, nickname, who, | |
938 &clients_count); | |
939 if (!clients) { | |
940 /* Resolve unknown user */ | |
941 SilcGaimIM im = silc_calloc(1, sizeof(*im)); | |
942 if (!im) | |
943 return 0; | |
944 im->nick = g_strdup(who); | |
945 im->message = g_strdup(msg); | |
946 im->message_len = strlen(im->message); | |
947 im->flags = mflags; | |
948 silc_client_get_clients(client, conn, nickname, NULL, | |
949 silcgaim_send_im_resolved, im); | |
950 silc_free(nickname); | |
951 return 0; | |
952 } | |
953 | |
954 /* Send private message directly */ | |
955 ret = silc_client_send_private_message(client, conn, clients[0], | |
956 mflags, (char *)msg, | |
957 strlen(msg), TRUE); | |
958 | |
959 silc_free(nickname); | |
960 silc_free(clients); | |
961 return ret; | |
962 } | |
963 | |
964 | |
9030 | 965 GList *silcgaim_blist_node_menu(GaimBlistNode *node) { |
966 /* split this single menu building function back into the two | |
967 original: one for buddies and one for chats */ | |
968 | |
969 if(GAIM_BLIST_NODE_IS_CHAT(node)) { | |
9038 | 970 return silcgaim_chat_menu((GaimChat *) node); |
9030 | 971 } else if(GAIM_BLIST_NODE_IS_BUDDY(node)) { |
972 return silcgaim_buddy_menu((GaimBuddy *) node); | |
973 } else { | |
9038 | 974 g_return_val_if_reached(NULL); |
9353 | 975 } |
9030 | 976 } |
977 | |
9272 | 978 /********************************* Commands **********************************/ |
979 | |
980 static GaimCmdRet silcgaim_cmd_chat_part(GaimConversation *conv, | |
9597 | 981 const char *cmd, char **args, char **error, void *data) |
9272 | 982 { |
983 GaimConnection *gc; | |
9353 | 984 GaimConversation *convo; |
9272 | 985 int id = 0; |
986 | |
987 gc = gaim_conversation_get_gc(conv); | |
9353 | 988 |
989 if (gc == NULL) | |
990 return GAIM_CMD_RET_FAILED; | |
9272 | 991 |
9353 | 992 if(args && args[0]) { |
10246 | 993 convo = gaim_find_conversation_with_account(GAIM_CONV_CHAT, args[0], |
994 gc->account); | |
9353 | 995 } else |
996 convo = conv; | |
997 | |
998 id = gaim_conv_chat_get_id(GAIM_CONV_CHAT(convo)); | |
999 | |
1000 if (id == 0) | |
9272 | 1001 return GAIM_CMD_RET_FAILED; |
1002 | |
1003 silcgaim_chat_leave(gc, id); | |
1004 | |
1005 return GAIM_CMD_RET_OK; | |
1006 | |
1007 } | |
1008 | |
1009 static GaimCmdRet silcgaim_cmd_chat_topic(GaimConversation *conv, | |
9597 | 1010 const char *cmd, char **args, char **error, void *data) |
9272 | 1011 { |
1012 GaimConnection *gc; | |
1013 int id = 0; | |
9762 | 1014 char *buf, *tmp, *tmp2; |
9488 | 1015 const char *topic; |
9272 | 1016 |
1017 gc = gaim_conversation_get_gc(conv); | |
1018 id = gaim_conv_chat_get_id(GAIM_CONV_CHAT(conv)); | |
1019 | |
1020 if (gc == NULL || id == 0) | |
1021 return GAIM_CMD_RET_FAILED; | |
1022 | |
9488 | 1023 if (!args || !args[0]) { |
1024 topic = gaim_conv_chat_get_topic (GAIM_CONV_CHAT(conv)); | |
1025 if (topic) { | |
10732
c4cb90065e1d
[gaim-migrate @ 12334]
Luke Schierer <lschiere@pidgin.im>
parents:
10547
diff
changeset
|
1026 tmp = g_markup_escape_text(topic, -1); |
9762 | 1027 tmp2 = gaim_markup_linkify(tmp); |
1028 buf = g_strdup_printf(_("current topic is: %s"), tmp2); | |
9488 | 1029 g_free(tmp); |
9762 | 1030 g_free(tmp2); |
9488 | 1031 } else |
1032 buf = g_strdup(_("No topic is set")); | |
1033 gaim_conv_chat_write(GAIM_CONV_CHAT(conv), gc->account->username, buf, | |
1034 GAIM_MESSAGE_SYSTEM|GAIM_MESSAGE_NO_LOG, time(NULL)); | |
1035 g_free(buf); | |
1036 | |
1037 } | |
1038 | |
1039 if (args && args[0] && (strlen(args[0]) > 255)) { | |
1040 *error = g_strdup(_("Topic too long")); | |
1041 return GAIM_CMD_RET_FAILED; | |
1042 } | |
1043 | |
9272 | 1044 silcgaim_chat_set_topic(gc, id, args ? args[0] : NULL); |
1045 | |
1046 return GAIM_CMD_RET_OK; | |
1047 } | |
1048 | |
1049 static GaimCmdRet silcgaim_cmd_chat_join(GaimConversation *conv, | |
9597 | 1050 const char *cmd, char **args, char **error, void *data) |
9272 | 1051 { |
1052 GHashTable *comp; | |
1053 | |
1054 if(!args || !args[0]) | |
1055 return GAIM_CMD_RET_FAILED; | |
1056 | |
1057 comp = g_hash_table_new_full(g_str_hash, g_str_equal, NULL, NULL); | |
1058 | |
1059 g_hash_table_replace(comp, "channel", args[0]); | |
1060 if(args[1]) | |
1061 g_hash_table_replace(comp, "passphrase", args[1]); | |
1062 | |
1063 silcgaim_chat_join(gaim_conversation_get_gc(conv), comp); | |
1064 | |
1065 g_hash_table_destroy(comp); | |
1066 return GAIM_CMD_RET_OK; | |
1067 } | |
1068 | |
1069 static GaimCmdRet silcgaim_cmd_chat_list(GaimConversation *conv, | |
9597 | 1070 const char *cmd, char **args, char **error, void *data) |
9272 | 1071 { |
1072 GaimConnection *gc; | |
1073 gc = gaim_conversation_get_gc(conv); | |
1074 gaim_roomlist_show_with_account(gaim_connection_get_account(gc)); | |
1075 return GAIM_CMD_RET_OK; | |
1076 } | |
1077 | |
1078 static GaimCmdRet silcgaim_cmd_whois(GaimConversation *conv, | |
9597 | 1079 const char *cmd, char **args, char **error, void *data) |
9272 | 1080 { |
1081 GaimConnection *gc; | |
1082 | |
1083 gc = gaim_conversation_get_gc(conv); | |
1084 | |
1085 if (gc == NULL) | |
1086 return GAIM_CMD_RET_FAILED; | |
1087 | |
1088 silcgaim_get_info(gc, args[0]); | |
1089 | |
1090 return GAIM_CMD_RET_OK; | |
1091 } | |
1092 | |
1093 static GaimCmdRet silcgaim_cmd_msg(GaimConversation *conv, | |
9597 | 1094 const char *cmd, char **args, char **error, void *data) |
9272 | 1095 { |
1096 int ret; | |
1097 GaimConnection *gc; | |
1098 | |
1099 gc = gaim_conversation_get_gc(conv); | |
1100 | |
1101 if (gc == NULL) | |
1102 return GAIM_CMD_RET_FAILED; | |
1103 | |
1104 ret = silcgaim_send_im(gc, args[0], args[1], GAIM_MESSAGE_SEND); | |
1105 | |
1106 if (ret) | |
1107 return GAIM_CMD_RET_OK; | |
1108 else | |
1109 return GAIM_CMD_RET_FAILED; | |
1110 } | |
1111 | |
1112 static GaimCmdRet silcgaim_cmd_query(GaimConversation *conv, | |
9597 | 1113 const char *cmd, char **args, char **error, void *data) |
9272 | 1114 { |
1115 int ret = 1; | |
1116 GaimConversation *convo; | |
1117 GaimConnection *gc; | |
1118 GaimAccount *account; | |
1119 | |
9488 | 1120 if (!args || !args[0]) { |
1121 *error = g_strdup(_("You must specify a nick")); | |
9272 | 1122 return GAIM_CMD_RET_FAILED; |
9488 | 1123 } |
9272 | 1124 |
1125 gc = gaim_conversation_get_gc(conv); | |
1126 | |
1127 if (gc == NULL) | |
1128 return GAIM_CMD_RET_FAILED; | |
1129 | |
1130 account = gaim_connection_get_account(gc); | |
1131 | |
1132 convo = gaim_conversation_new(GAIM_CONV_IM, account, args[0]); | |
1133 | |
1134 if (args[1]) { | |
1135 ret = silcgaim_send_im(gc, args[0], args[1], GAIM_MESSAGE_SEND); | |
1136 gaim_conv_im_write(GAIM_CONV_IM(convo), gaim_connection_get_display_name(gc), | |
1137 args[1], GAIM_MESSAGE_SEND, time(NULL)); | |
1138 } | |
1139 | |
1140 if (ret) | |
1141 return GAIM_CMD_RET_OK; | |
1142 else | |
1143 return GAIM_CMD_RET_FAILED; | |
1144 } | |
1145 | |
1146 static GaimCmdRet silcgaim_cmd_motd(GaimConversation *conv, | |
9597 | 1147 const char *cmd, char **args, char **error, void *data) |
9272 | 1148 { |
1149 GaimConnection *gc; | |
1150 SilcGaim sg; | |
9488 | 1151 char *tmp; |
9272 | 1152 |
1153 gc = gaim_conversation_get_gc(conv); | |
1154 | |
1155 if (gc == NULL) | |
1156 return GAIM_CMD_RET_FAILED; | |
1157 | |
1158 sg = gc->proto_data; | |
1159 | |
1160 if (sg == NULL) | |
1161 return GAIM_CMD_RET_FAILED; | |
1162 | |
1163 if (!sg->motd) { | |
9488 | 1164 *error = g_strdup(_("There is no Message of the Day associated with this connection")); |
9272 | 1165 return GAIM_CMD_RET_FAILED; |
1166 } | |
1167 | |
10732
c4cb90065e1d
[gaim-migrate @ 12334]
Luke Schierer <lschiere@pidgin.im>
parents:
10547
diff
changeset
|
1168 tmp = g_markup_escape_text(sg->motd, -1); |
9488 | 1169 gaim_notify_formatted(gc, NULL, _("Message of the Day"), NULL, |
1170 tmp, NULL, NULL); | |
1171 g_free(tmp); | |
9272 | 1172 |
1173 return GAIM_CMD_RET_OK; | |
1174 } | |
1175 | |
1176 static GaimCmdRet silcgaim_cmd_detach(GaimConversation *conv, | |
9597 | 1177 const char *cmd, char **args, char **error, void *data) |
9272 | 1178 { |
1179 GaimConnection *gc; | |
1180 SilcGaim sg; | |
1181 | |
1182 gc = gaim_conversation_get_gc(conv); | |
1183 | |
1184 if (gc == NULL) | |
1185 return GAIM_CMD_RET_FAILED; | |
1186 | |
1187 sg = gc->proto_data; | |
1188 | |
1189 if (sg == NULL) | |
1190 return GAIM_CMD_RET_FAILED; | |
1191 | |
1192 silc_client_command_call(sg->client, sg->conn, "DETACH"); | |
1193 sg->detaching = TRUE; | |
1194 | |
1195 return GAIM_CMD_RET_OK; | |
1196 } | |
1197 | |
9488 | 1198 static GaimCmdRet silcgaim_cmd_cmode(GaimConversation *conv, |
9597 | 1199 const char *cmd, char **args, char **error, void *data) |
9488 | 1200 { |
1201 GaimConnection *gc; | |
1202 SilcGaim sg; | |
1203 SilcChannelEntry channel; | |
1204 char *silccmd, *silcargs, *msg, tmp[256]; | |
1205 const char *chname; | |
1206 | |
1207 gc = gaim_conversation_get_gc(conv); | |
1208 | |
1209 if (gc == NULL || !args || gc->proto_data == NULL) | |
1210 return GAIM_CMD_RET_FAILED; | |
1211 | |
1212 sg = gc->proto_data; | |
1213 | |
1214 if (args[0]) | |
1215 chname = args[0]; | |
1216 else | |
1217 chname = gaim_conversation_get_name(conv); | |
1218 | |
1219 if (!args[1]) { | |
1220 channel = silc_client_get_channel(sg->client, sg->conn, | |
1221 (char *)chname); | |
1222 if (!channel) { | |
1223 *error = g_strdup_printf(_("channel %s not found"), chname); | |
1224 return GAIM_CMD_RET_FAILED; | |
1225 } | |
1226 if (channel->mode) { | |
1227 silcgaim_get_chmode_string(channel->mode, tmp, sizeof(tmp)); | |
1228 msg = g_strdup_printf(_("channel modes for %s: %s"), chname, tmp); | |
1229 } else { | |
1230 msg = g_strdup_printf(_("no channel modes are set on %s"), chname); | |
1231 } | |
1232 gaim_conv_chat_write(GAIM_CONV_CHAT(conv), "", | |
1233 msg, GAIM_MESSAGE_SYSTEM|GAIM_MESSAGE_NO_LOG, time(NULL)); | |
1234 g_free(msg); | |
1235 return GAIM_CMD_RET_OK; | |
1236 } | |
1237 | |
1238 silcargs = g_strjoinv(" ", args); | |
1239 silccmd = g_strconcat(cmd, " ", args ? silcargs : NULL, NULL); | |
1240 g_free(silcargs); | |
1241 if (!silc_client_command_call(sg->client, sg->conn, silccmd)) { | |
1242 g_free(silccmd); | |
1243 *error = g_strdup_printf(_("Failed to set cmodes for %s"), args[0]); | |
1244 return GAIM_CMD_RET_FAILED; | |
1245 } | |
1246 g_free(silccmd); | |
1247 | |
1248 return GAIM_CMD_RET_OK; | |
1249 } | |
1250 | |
9353 | 1251 static GaimCmdRet silcgaim_cmd_generic(GaimConversation *conv, |
9597 | 1252 const char *cmd, char **args, char **error, void *data) |
9272 | 1253 { |
1254 GaimConnection *gc; | |
1255 SilcGaim sg; | |
9353 | 1256 char *silccmd, *silcargs; |
9272 | 1257 |
1258 gc = gaim_conversation_get_gc(conv); | |
1259 | |
1260 if (gc == NULL) | |
1261 return GAIM_CMD_RET_FAILED; | |
1262 | |
1263 sg = gc->proto_data; | |
1264 | |
1265 if (sg == NULL) | |
1266 return GAIM_CMD_RET_FAILED; | |
1267 | |
9353 | 1268 silcargs = g_strjoinv(" ", args); |
1269 silccmd = g_strconcat(cmd, " ", args ? silcargs : NULL, NULL); | |
1270 g_free(silcargs); | |
1271 if (!silc_client_command_call(sg->client, sg->conn, silccmd)) { | |
1272 g_free(silccmd); | |
9488 | 1273 *error = g_strdup_printf(_("Unknown command: %s, (may be a Gaim bug)"), cmd); |
9353 | 1274 return GAIM_CMD_RET_FAILED; |
1275 } | |
1276 g_free(silccmd); | |
9272 | 1277 |
1278 return GAIM_CMD_RET_OK; | |
1279 } | |
1280 | |
9359 | 1281 static GaimCmdRet silcgaim_cmd_quit(GaimConversation *conv, |
9597 | 1282 const char *cmd, char **args, char **error, void *data) |
9359 | 1283 { |
1284 GaimConnection *gc; | |
1285 SilcGaim sg; | |
1286 | |
1287 gc = gaim_conversation_get_gc(conv); | |
1288 | |
1289 if (gc == NULL) | |
1290 return GAIM_CMD_RET_FAILED; | |
1291 | |
1292 sg = gc->proto_data; | |
1293 | |
1294 if (sg == NULL) | |
1295 return GAIM_CMD_RET_FAILED; | |
1296 | |
1297 silc_client_command_call(sg->client, sg->conn, NULL, | |
1298 "QUIT", (args && args[0]) ? args[0] : "Download Gaim: " GAIM_WEBSITE, NULL); | |
1299 | |
1300 return GAIM_CMD_RET_OK; | |
1301 } | |
1302 | |
1303 static GaimCmdRet silcgaim_cmd_call(GaimConversation *conv, | |
9597 | 1304 const char *cmd, char **args, char **error, void *data) |
9359 | 1305 { |
1306 GaimConnection *gc; | |
1307 SilcGaim sg; | |
1308 | |
1309 gc = gaim_conversation_get_gc(conv); | |
1310 | |
1311 if (gc == NULL) | |
1312 return GAIM_CMD_RET_FAILED; | |
1313 | |
1314 sg = gc->proto_data; | |
1315 | |
1316 if (sg == NULL) | |
1317 return GAIM_CMD_RET_FAILED; | |
1318 | |
9488 | 1319 if (!silc_client_command_call(sg->client, sg->conn, args[0])) { |
1320 *error = g_strdup_printf(_("Unknown command: %s"), args[0]); | |
9359 | 1321 return GAIM_CMD_RET_FAILED; |
9488 | 1322 } |
9359 | 1323 |
1324 return GAIM_CMD_RET_OK; | |
1325 } | |
1326 | |
9030 | 1327 |
8849 | 1328 /************************** Plugin Initialization ****************************/ |
1329 | |
9272 | 1330 static void |
1331 silcgaim_register_commands(void) | |
1332 { | |
9353 | 1333 gaim_cmd_register("part", "w", GAIM_CMD_P_PRPL, |
1334 GAIM_CMD_FLAG_IM | GAIM_CMD_FLAG_CHAT | | |
1335 GAIM_CMD_FLAG_PRPL_ONLY | GAIM_CMD_FLAG_ALLOW_WRONG_ARGS, | |
9597 | 1336 "prpl-silc", silcgaim_cmd_chat_part, _("part [channel]: Leave the chat"), NULL); |
9353 | 1337 gaim_cmd_register("leave", "w", GAIM_CMD_P_PRPL, |
1338 GAIM_CMD_FLAG_IM | GAIM_CMD_FLAG_CHAT | | |
1339 GAIM_CMD_FLAG_PRPL_ONLY | GAIM_CMD_FLAG_ALLOW_WRONG_ARGS, | |
9597 | 1340 "prpl-silc", silcgaim_cmd_chat_part, _("leave [channel]: Leave the chat"), NULL); |
9272 | 1341 gaim_cmd_register("topic", "s", GAIM_CMD_P_PRPL, |
1342 GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_PRPL_ONLY | | |
1343 GAIM_CMD_FLAG_ALLOW_WRONG_ARGS, "prpl-silc", | |
9597 | 1344 silcgaim_cmd_chat_topic, _("topic [<new topic>]: View or change the topic"), NULL); |
9272 | 1345 gaim_cmd_register("join", "ws", GAIM_CMD_P_PRPL, |
1346 GAIM_CMD_FLAG_IM | GAIM_CMD_FLAG_CHAT | | |
1347 GAIM_CMD_FLAG_PRPL_ONLY | GAIM_CMD_FLAG_ALLOW_WRONG_ARGS, | |
1348 "prpl-silc", silcgaim_cmd_chat_join, | |
9597 | 1349 _("join <channel> [<password>]: Join a chat on this network"), NULL); |
9272 | 1350 gaim_cmd_register("list", "", GAIM_CMD_P_PRPL, |
1351 GAIM_CMD_FLAG_IM | GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_PRPL_ONLY | | |
1352 GAIM_CMD_FLAG_ALLOW_WRONG_ARGS, "prpl-silc", | |
9597 | 1353 silcgaim_cmd_chat_list, _("list: List channels on this network"), NULL); |
9272 | 1354 gaim_cmd_register("whois", "w", GAIM_CMD_P_PRPL, |
1355 GAIM_CMD_FLAG_IM | GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_PRPL_ONLY, | |
1356 "prpl-silc", | |
9597 | 1357 silcgaim_cmd_whois, _("whois <nick>: View nick's information"), NULL); |
9272 | 1358 gaim_cmd_register("msg", "ws", GAIM_CMD_P_PRPL, |
1359 GAIM_CMD_FLAG_IM | GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_PRPL_ONLY, | |
1360 "prpl-silc", silcgaim_cmd_msg, | |
9597 | 1361 _("msg <nick> <message>: Send a private message to a user"), NULL); |
9272 | 1362 gaim_cmd_register("query", "ws", GAIM_CMD_P_PRPL, |
1363 GAIM_CMD_FLAG_IM | GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_PRPL_ONLY | | |
1364 GAIM_CMD_FLAG_ALLOW_WRONG_ARGS, "prpl-silc", silcgaim_cmd_query, | |
9597 | 1365 _("query <nick> [<message>]: Send a private message to a user"), NULL); |
9272 | 1366 gaim_cmd_register("motd", "", GAIM_CMD_P_PRPL, |
1367 GAIM_CMD_FLAG_IM | GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_PRPL_ONLY | | |
1368 GAIM_CMD_FLAG_ALLOW_WRONG_ARGS, "prpl-silc", silcgaim_cmd_motd, | |
9597 | 1369 _("motd: View the server's Message Of The Day"), NULL); |
9272 | 1370 gaim_cmd_register("detach", "", GAIM_CMD_P_PRPL, |
9353 | 1371 GAIM_CMD_FLAG_IM | GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_PRPL_ONLY, |
1372 "prpl-silc", silcgaim_cmd_detach, | |
9597 | 1373 _("detach: Detach this session"), NULL); |
9359 | 1374 gaim_cmd_register("quit", "s", GAIM_CMD_P_PRPL, |
1375 GAIM_CMD_FLAG_IM | GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_PRPL_ONLY | | |
1376 GAIM_CMD_FLAG_ALLOW_WRONG_ARGS, "prpl-silc", silcgaim_cmd_quit, | |
9597 | 1377 _("quit [message]: Disconnect from the server, with an optional message"), NULL); |
9359 | 1378 gaim_cmd_register("call", "s", GAIM_CMD_P_PRPL, |
1379 GAIM_CMD_FLAG_IM | GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_PRPL_ONLY, | |
1380 "prpl-silc", silcgaim_cmd_call, | |
9597 | 1381 _("call <command>: Call any silc client command"), NULL); |
1382 /* These below just get passed through for the silc client library to deal | |
1383 * with */ | |
9359 | 1384 gaim_cmd_register("kill", "ws", GAIM_CMD_P_PRPL, |
1385 GAIM_CMD_FLAG_IM | GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_PRPL_ONLY | | |
1386 GAIM_CMD_FLAG_ALLOW_WRONG_ARGS, "prpl-silc", silcgaim_cmd_generic, | |
9597 | 1387 _("kill <nick> [-pubkey|<reason>]: Kill nick"), NULL); |
9359 | 1388 gaim_cmd_register("nick", "w", GAIM_CMD_P_PRPL, |
1389 GAIM_CMD_FLAG_IM | GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_PRPL_ONLY, | |
1390 "prpl-silc", silcgaim_cmd_generic, | |
9597 | 1391 _("nick <newnick>: Change your nickname"), NULL); |
9488 | 1392 gaim_cmd_register("whowas", "ww", GAIM_CMD_P_PRPL, |
9359 | 1393 GAIM_CMD_FLAG_IM | GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_PRPL_ONLY | |
1394 GAIM_CMD_FLAG_ALLOW_WRONG_ARGS, "prpl-silc", silcgaim_cmd_generic, | |
9597 | 1395 _("whowas <nick>: View nick's information"), NULL); |
9488 | 1396 gaim_cmd_register("cmode", "wws", GAIM_CMD_P_PRPL, |
1397 GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_PRPL_ONLY | | |
1398 GAIM_CMD_FLAG_ALLOW_WRONG_ARGS, "prpl-silc", silcgaim_cmd_cmode, | |
9597 | 1399 _("cmode <channel> [+|-<modes>] [arguments]: Change or display channel modes"), NULL); |
9359 | 1400 gaim_cmd_register("cumode", "wws", GAIM_CMD_P_PRPL, |
1401 GAIM_CMD_FLAG_IM | GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_PRPL_ONLY | | |
1402 GAIM_CMD_FLAG_ALLOW_WRONG_ARGS, "prpl-silc", silcgaim_cmd_generic, | |
9597 | 1403 _("cumode <channel> +|-<modes> <nick>: Change nick's modes on channel"), NULL); |
9272 | 1404 gaim_cmd_register("umode", "w", GAIM_CMD_P_PRPL, |
1405 GAIM_CMD_FLAG_IM | GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_PRPL_ONLY, | |
9353 | 1406 "prpl-silc", silcgaim_cmd_generic, |
9597 | 1407 _("umode <usermodes>: Set your modes in the network"), NULL); |
9359 | 1408 gaim_cmd_register("oper", "s", GAIM_CMD_P_PRPL, |
1409 GAIM_CMD_FLAG_IM | GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_PRPL_ONLY, | |
1410 "prpl-silc", silcgaim_cmd_generic, | |
9597 | 1411 _("oper <nick> [-pubkey]: Get server operator privileges"), NULL); |
9359 | 1412 gaim_cmd_register("invite", "ws", GAIM_CMD_P_PRPL, |
1413 GAIM_CMD_FLAG_IM | GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_PRPL_ONLY | | |
1414 GAIM_CMD_FLAG_ALLOW_WRONG_ARGS, "prpl-silc", silcgaim_cmd_generic, | |
9597 | 1415 _("invite <channel> [-|+]<nick>: invite nick or add/remove from channel invite list"), NULL); |
9359 | 1416 gaim_cmd_register("kick", "wws", GAIM_CMD_P_PRPL, |
1417 GAIM_CMD_FLAG_IM | GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_PRPL_ONLY | | |
1418 GAIM_CMD_FLAG_ALLOW_WRONG_ARGS, "prpl-silc", silcgaim_cmd_generic, | |
9597 | 1419 _("kick <channel> <nick> [comment]: Kick client from channel"), NULL); |
9488 | 1420 gaim_cmd_register("info", "w", GAIM_CMD_P_PRPL, |
9359 | 1421 GAIM_CMD_FLAG_IM | GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_PRPL_ONLY | |
1422 GAIM_CMD_FLAG_ALLOW_WRONG_ARGS, "prpl-silc", silcgaim_cmd_generic, | |
9597 | 1423 _("info [server]: View server administrative details"), NULL); |
9359 | 1424 gaim_cmd_register("ban", "ww", GAIM_CMD_P_PRPL, |
1425 GAIM_CMD_FLAG_IM | GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_PRPL_ONLY | | |
1426 GAIM_CMD_FLAG_ALLOW_WRONG_ARGS, "prpl-silc", silcgaim_cmd_generic, | |
9597 | 1427 _("ban [<channel> +|-<nick>]: Ban client from channel"), NULL); |
9488 | 1428 gaim_cmd_register("getkey", "w", GAIM_CMD_P_PRPL, |
1429 GAIM_CMD_FLAG_IM | GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_PRPL_ONLY, | |
1430 "prpl-silc", silcgaim_cmd_generic, | |
9597 | 1431 _("getkey <nick|server>: Retrieve client's or server's public key"), NULL); |
9488 | 1432 gaim_cmd_register("stats", "", GAIM_CMD_P_PRPL, |
1433 GAIM_CMD_FLAG_IM | GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_PRPL_ONLY, | |
1434 "prpl-silc", silcgaim_cmd_generic, | |
9597 | 1435 _("stats: View server and network statistics"), NULL); |
9359 | 1436 gaim_cmd_register("ping", "", GAIM_CMD_P_PRPL, |
1437 GAIM_CMD_FLAG_IM | GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_PRPL_ONLY, | |
1438 "prpl-silc", silcgaim_cmd_generic, | |
9597 | 1439 _("ping: Send PING to the connected server"), NULL); |
9488 | 1440 #if 0 /* Gaim doesn't handle these yet */ |
1441 gaim_cmd_register("users", "w", GAIM_CMD_P_PRPL, | |
1442 GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_PRPL_ONLY, | |
1443 "prpl-silc", silcgaim_cmd_users, | |
1444 _("users <channel>: List users in channel")); | |
1445 gaim_cmd_register("names", "ww", GAIM_CMD_P_PRPL, | |
1446 GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_PRPL_ONLY | | |
1447 GAIM_CMD_FLAG_ALLOW_WRONG_ARGS, "prpl-silc", silcgaim_cmd_names, | |
1448 _("names [-count|-ops|-halfops|-voices|-normal] <channel(s)>: List specific users in channel(s)")); | |
9359 | 1449 #endif |
9272 | 1450 } |
1451 | |
8849 | 1452 static GaimPluginPrefFrame * |
1453 silcgaim_pref_frame(GaimPlugin *plugin) | |
1454 { | |
1455 GaimPluginPrefFrame *frame; | |
1456 GaimPluginPref *ppref; | |
1457 | |
1458 frame = gaim_plugin_pref_frame_new(); | |
1459 | |
1460 ppref = gaim_plugin_pref_new_with_label(_("Instant Messages")); | |
1461 gaim_plugin_pref_frame_add(frame, ppref); | |
1462 | |
1463 ppref = gaim_plugin_pref_new_with_name_and_label( | |
1464 "/plugins/prpl/silc/sign_im", | |
1465 _("Digitally sign all IM messages")); | |
1466 gaim_plugin_pref_frame_add(frame, ppref); | |
1467 | |
1468 ppref = gaim_plugin_pref_new_with_name_and_label( | |
1469 "/plugins/prpl/silc/verify_im", | |
1470 _("Verify all IM message signatures")); | |
1471 gaim_plugin_pref_frame_add(frame, ppref); | |
1472 | |
1473 ppref = gaim_plugin_pref_new_with_label(_("Channel Messages")); | |
1474 gaim_plugin_pref_frame_add(frame, ppref); | |
1475 | |
1476 ppref = gaim_plugin_pref_new_with_name_and_label( | |
1477 "/plugins/prpl/silc/sign_chat", | |
1478 _("Digitally sign all channel messages")); | |
1479 gaim_plugin_pref_frame_add(frame, ppref); | |
1480 | |
1481 ppref = gaim_plugin_pref_new_with_name_and_label( | |
1482 "/plugins/prpl/silc/verify_chat", | |
1483 _("Verify all channel message signatures")); | |
1484 gaim_plugin_pref_frame_add(frame, ppref); | |
1485 | |
1486 return frame; | |
1487 } | |
1488 | |
1489 static GaimPluginUiInfo prefs_info = | |
1490 { | |
1491 silcgaim_pref_frame, | |
1492 }; | |
1493 | |
1494 static GaimPluginProtocolInfo prpl_info = | |
1495 { | |
1496 OPT_PROTO_CHAT_TOPIC | OPT_PROTO_UNIQUE_CHATNAME | | |
1497 OPT_PROTO_PASSWORD_OPTIONAL, | |
9488 | 1498 NULL, /* user_splits */ |
1499 NULL, /* protocol_options */ | |
1500 NO_BUDDY_ICONS, /* icon_spec */ | |
1501 silcgaim_list_icon, /* list_icon */ | |
1502 silcgaim_list_emblems, /* list_emblems */ | |
1503 silcgaim_status_text, /* status_text */ | |
1504 silcgaim_tooltip_text, /* tooltip_text */ | |
1505 silcgaim_away_states, /* away_states */ | |
1506 silcgaim_blist_node_menu, /* blist_node_menu */ | |
1507 silcgaim_chat_info, /* chat_info */ | |
9754 | 1508 silcgaim_chat_info_defaults,/* chat_info_defaults */ |
9488 | 1509 silcgaim_login, /* login */ |
1510 silcgaim_close, /* close */ | |
1511 silcgaim_send_im, /* send_im */ | |
1512 silcgaim_set_info, /* set_info */ | |
1513 NULL, /* send_typing */ | |
1514 silcgaim_get_info, /* get_info */ | |
9968 | 1515 silcgaim_set_status, /* set_status */ |
9488 | 1516 silcgaim_idle_set, /* set_idle */ |
1517 silcgaim_change_passwd, /* change_passwd */ | |
1518 silcgaim_add_buddy, /* add_buddy */ | |
10341 | 1519 silcgaim_add_buddies, /* add_buddies */ |
9488 | 1520 silcgaim_remove_buddy, /* remove_buddy */ |
1521 NULL, /* remove_buddies */ | |
1522 NULL, /* add_permit */ | |
1523 NULL, /* add_deny */ | |
1524 NULL, /* rem_permit */ | |
1525 NULL, /* rem_deny */ | |
1526 NULL, /* set_permit_deny */ | |
1527 NULL, /* warn */ | |
1528 silcgaim_chat_join, /* join_chat */ | |
1529 NULL, /* reject_chat */ | |
9917 | 1530 silcgaim_get_chat_name, /* get_chat_name */ |
9488 | 1531 silcgaim_chat_invite, /* chat_invite */ |
1532 silcgaim_chat_leave, /* chat_leave */ | |
1533 NULL, /* chat_whisper */ | |
1534 silcgaim_chat_send, /* chat_send */ | |
1535 silcgaim_keepalive, /* keepalive */ | |
1536 NULL, /* register_user */ | |
1537 NULL, /* get_cb_info */ | |
1538 NULL, /* get_cb_away */ | |
1539 NULL, /* alias_buddy */ | |
1540 NULL, /* group_buddy */ | |
1541 NULL, /* rename_group */ | |
1542 NULL, /* buddy_free */ | |
1543 NULL, /* convo_closed */ | |
1544 NULL, /* normalize */ | |
1545 NULL, /* set_buddy_icon */ | |
1546 NULL, /* remove_group */ | |
1547 NULL, /* get_cb_real_name */ | |
1548 silcgaim_chat_set_topic, /* set_chat_topic */ | |
1549 NULL, /* find_blist_chat */ | |
1550 silcgaim_roomlist_get_list, /* roomlist_get_list */ | |
1551 silcgaim_roomlist_cancel, /* roomlist_cancel */ | |
1552 NULL, /* roomlist_expand_category */ | |
1553 NULL, /* can_receive_file */ | |
1554 silcgaim_ftp_send_file /* send_file */ | |
8849 | 1555 }; |
1556 | |
1557 static GaimPluginInfo info = | |
1558 { | |
9943 | 1559 GAIM_PLUGIN_MAGIC, |
1560 GAIM_MAJOR_VERSION, | |
1561 GAIM_MINOR_VERSION, | |
8849 | 1562 GAIM_PLUGIN_PROTOCOL, /**< type */ |
1563 NULL, /**< ui_requirement */ | |
1564 0, /**< flags */ | |
1565 NULL, /**< dependencies */ | |
1566 GAIM_PRIORITY_DEFAULT, /**< priority */ | |
1567 | |
1568 "prpl-silc", /**< id */ | |
1569 "SILC", /**< name */ | |
1570 "1.0", /**< version */ | |
1571 /** summary */ | |
1572 N_("SILC Protocol Plugin"), | |
1573 /** description */ | |
1574 N_("Secure Internet Live Conferencing (SILC) Protocol"), | |
8891 | 1575 "Pekka Riikonen", /**< author */ |
1576 "http://silcnet.org/", /**< homepage */ | |
8849 | 1577 |
1578 NULL, /**< load */ | |
1579 NULL, /**< unload */ | |
1580 NULL, /**< destroy */ | |
1581 | |
1582 NULL, /**< ui_info */ | |
1583 &prpl_info, /**< extra_info */ | |
8993 | 1584 &prefs_info, /**< prefs_info */ |
9015 | 1585 silcgaim_actions |
8849 | 1586 }; |
1587 | |
1588 static void | |
1589 init_plugin(GaimPlugin *plugin) | |
1590 { | |
1591 GaimAccountOption *option; | |
10825 | 1592 GaimAccountUserSplit *split; |
8849 | 1593 char tmp[256]; |
1594 | |
1595 silc_plugin = plugin; | |
1596 | |
10825 | 1597 split = gaim_account_user_split_new(_("Network"), "silcnet.org", '@'); |
1598 prpl_info.user_splits = g_list_append(prpl_info.user_splits, split); | |
1599 | |
8849 | 1600 /* Account options */ |
1601 option = gaim_account_option_string_new(_("Connect server"), | |
1602 "server", | |
1603 "silc.silcnet.org"); | |
1604 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); | |
1605 option = gaim_account_option_int_new(_("Port"), "port", 706); | |
1606 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); | |
10825 | 1607 g_snprintf(tmp, sizeof(tmp), "%s" G_DIR_SEPARATOR_S "public_key.pub", silcgaim_silcdir()); |
1608 option = gaim_account_option_string_new(_("Public Key file"), | |
1609 "public-key", tmp); | |
1610 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); | |
1611 g_snprintf(tmp, sizeof(tmp), "%s" G_DIR_SEPARATOR_S "private_key.prv", silcgaim_silcdir()); | |
1612 option = gaim_account_option_string_new(_("Private Key file"), | |
1613 "private-key", tmp); | |
1614 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); | |
8849 | 1615 option = gaim_account_option_bool_new(_("Public key authentication"), |
1616 "pubkey-auth", FALSE); | |
1617 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); | |
1618 | |
1619 option = gaim_account_option_bool_new(_("Reject watching by other users"), | |
1620 "reject-watch", FALSE); | |
1621 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); | |
1622 option = gaim_account_option_bool_new(_("Block invites"), | |
1623 "block-invites", FALSE); | |
1624 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); | |
1625 option = gaim_account_option_bool_new(_("Block IMs without Key Exchange"), | |
1626 "block-ims", FALSE); | |
1627 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); | |
1628 option = gaim_account_option_bool_new(_("Reject online status attribute requests"), | |
1629 "reject-attrs", FALSE); | |
1630 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); | |
1631 | |
1632 /* Preferences */ | |
1633 gaim_prefs_add_none("/plugins/prpl/silc"); | |
1634 gaim_prefs_add_bool("/plugins/prpl/silc/sign_im", FALSE); | |
1635 gaim_prefs_add_bool("/plugins/prpl/silc/verify_im", FALSE); | |
1636 gaim_prefs_add_bool("/plugins/prpl/silc/sign_chat", FALSE); | |
1637 gaim_prefs_add_bool("/plugins/prpl/silc/verify_chat", FALSE); | |
1638 gaim_prefs_add_string("/plugins/prpl/silc/vcard", ""); | |
9272 | 1639 |
1640 silcgaim_register_commands(); | |
9353 | 1641 |
1642 #ifdef _WIN32 | |
1643 silc_net_win32_init(); | |
1644 #endif | |
1645 | |
8849 | 1646 } |
1647 | |
1648 GAIM_INIT_PLUGIN(silc, init_plugin, info); |