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