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