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