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