Mon, 26 Jul 2004 03:27:03 +0000
[gaim-migrate @ 10440]
denyri added a void *data argument to most of the command related
functions. This makes it easier for language binding and such.
| 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; |
|
9488
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
718 | char *tmp; |
| 8849 | 719 | |
| 720 | if (!gc) | |
| 721 | return; | |
| 722 | sg = gc->proto_data; | |
| 723 | if (!sg) | |
| 724 | return; | |
| 725 | ||
| 726 | if (!sg->motd) { | |
| 727 | gaim_notify_error( | |
| 728 | gc, _("Message of the Day"), _("No Message of the Day available"), | |
| 729 | _("There is no Message of the Day associated with this connection")); | |
| 730 | return; | |
| 731 | } | |
| 732 | ||
|
9488
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
733 | tmp = gaim_escape_html(sg->motd); |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
734 | gaim_notify_formatted(gc, NULL, _("Message of the Day"), NULL, |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
735 | tmp, NULL, NULL); |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
736 | g_free(tmp); |
| 8849 | 737 | } |
| 738 | ||
| 9272 | 739 | static void |
| 740 | silcgaim_change_pass(GaimPluginAction *action) | |
| 741 | { | |
| 742 | GaimConnection *gc = (GaimConnection *) action->context; | |
| 743 | gaim_account_request_change_password(gaim_connection_get_account(gc)); | |
| 744 | } | |
| 745 | ||
| 746 | static void | |
| 747 | silcgaim_change_passwd(GaimConnection *gc, const char *old, const char *new) | |
| 748 | { | |
| 749 | silc_change_private_key_passphrase(gaim_prefs_get_string("/plugins/prpl/silc/privkey"), old, new); | |
| 750 | } | |
| 751 | ||
| 752 | static void | |
| 753 | silcgaim_show_set_info(GaimPluginAction *action) | |
| 754 | { | |
| 755 | GaimConnection *gc = (GaimConnection *) action->context; | |
| 756 | gaim_account_request_change_user_info(gaim_connection_get_account(gc)); | |
| 757 | } | |
| 758 | ||
| 759 | static void | |
| 760 | silcgaim_set_info(GaimConnection *gc, const char *text) | |
| 761 | { | |
| 762 | } | |
| 763 | ||
| 8849 | 764 | static GList * |
|
9015
3c27e9074fa2
[gaim-migrate @ 9791]
Christopher O'Brien <siege@pidgin.im>
parents:
8993
diff
changeset
|
765 | silcgaim_actions(GaimPlugin *plugin, gpointer context) |
| 8849 | 766 | { |
| 9024 | 767 | GaimConnection *gc = context; |
| 8849 | 768 | GList *list = NULL; |
|
9015
3c27e9074fa2
[gaim-migrate @ 9791]
Christopher O'Brien <siege@pidgin.im>
parents:
8993
diff
changeset
|
769 | GaimPluginAction *act; |
| 8849 | 770 | |
| 771 | 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
|
772 | act = gaim_plugin_action_new(_("Online Status"), |
|
3c27e9074fa2
[gaim-migrate @ 9791]
Christopher O'Brien <siege@pidgin.im>
parents:
8993
diff
changeset
|
773 | silcgaim_attrs); |
|
3c27e9074fa2
[gaim-migrate @ 9791]
Christopher O'Brien <siege@pidgin.im>
parents:
8993
diff
changeset
|
774 | list = g_list_append(list, act); |
| 8849 | 775 | } |
| 776 | ||
|
9015
3c27e9074fa2
[gaim-migrate @ 9791]
Christopher O'Brien <siege@pidgin.im>
parents:
8993
diff
changeset
|
777 | act = gaim_plugin_action_new(_("Detach From Server"), |
|
3c27e9074fa2
[gaim-migrate @ 9791]
Christopher O'Brien <siege@pidgin.im>
parents:
8993
diff
changeset
|
778 | silcgaim_detach); |
|
3c27e9074fa2
[gaim-migrate @ 9791]
Christopher O'Brien <siege@pidgin.im>
parents:
8993
diff
changeset
|
779 | list = g_list_append(list, act); |
| 8849 | 780 | |
|
9015
3c27e9074fa2
[gaim-migrate @ 9791]
Christopher O'Brien <siege@pidgin.im>
parents:
8993
diff
changeset
|
781 | act = gaim_plugin_action_new(_("View Message of the Day"), |
|
3c27e9074fa2
[gaim-migrate @ 9791]
Christopher O'Brien <siege@pidgin.im>
parents:
8993
diff
changeset
|
782 | silcgaim_view_motd); |
|
3c27e9074fa2
[gaim-migrate @ 9791]
Christopher O'Brien <siege@pidgin.im>
parents:
8993
diff
changeset
|
783 | list = g_list_append(list, act); |
| 8849 | 784 | |
| 9272 | 785 | act = gaim_plugin_action_new(_("Change Password..."), |
| 786 | silcgaim_change_pass); | |
| 787 | list = g_list_append(list, act); | |
| 788 | ||
| 789 | act = gaim_plugin_action_new(_("Set User Info..."), | |
| 790 | silcgaim_show_set_info); | |
| 791 | list = g_list_append(list, act); | |
| 792 | ||
| 8849 | 793 | return list; |
| 794 | } | |
| 795 | ||
| 796 | ||
| 797 | /******************************* IM Routines *********************************/ | |
| 798 | ||
| 799 | typedef struct { | |
| 800 | char *nick; | |
| 801 | unsigned char *message; | |
| 802 | SilcUInt32 message_len; | |
| 803 | SilcMessageFlags flags; | |
| 804 | } *SilcGaimIM; | |
| 805 | ||
| 806 | static void | |
| 807 | silcgaim_send_im_resolved(SilcClient client, | |
| 808 | SilcClientConnection conn, | |
| 809 | SilcClientEntry *clients, | |
| 810 | SilcUInt32 clients_count, | |
| 811 | void *context) | |
| 812 | { | |
| 813 | GaimConnection *gc = client->application; | |
| 814 | SilcGaim sg = gc->proto_data; | |
| 815 | SilcGaimIM im = context; | |
| 816 | GaimConversation *convo; | |
| 817 | char tmp[256], *nickname = NULL; | |
| 818 | SilcClientEntry client_entry; | |
| 819 | ||
| 820 | convo = gaim_find_conversation_with_account(im->nick, sg->account); | |
| 821 | if (!convo) | |
| 822 | return; | |
| 823 | ||
| 824 | if (!clients) | |
| 825 | goto err; | |
| 826 | ||
| 827 | if (clients_count > 1) { | |
| 828 | silc_parse_userfqdn(im->nick, &nickname, NULL); | |
| 829 | ||
| 830 | /* Find the correct one. The im->nick might be a formatted nick | |
| 831 | so this will find the correct one. */ | |
| 832 | clients = silc_client_get_clients_local(client, conn, | |
| 833 | nickname, im->nick, | |
| 834 | &clients_count); | |
| 835 | if (!clients) | |
| 836 | goto err; | |
| 837 | client_entry = clients[0]; | |
| 838 | silc_free(clients); | |
| 839 | } else { | |
| 840 | client_entry = clients[0]; | |
| 841 | } | |
| 842 | ||
| 843 | /* Send the message */ | |
| 844 | silc_client_send_private_message(client, conn, client_entry, im->flags, | |
| 845 | im->message, im->message_len, TRUE); | |
| 846 | gaim_conv_im_write(GAIM_CONV_IM(convo), conn->local_entry->nickname, | |
| 847 | im->message, 0, time(NULL)); | |
| 848 | ||
| 849 | goto out; | |
| 850 | ||
| 851 | err: | |
| 852 | g_snprintf(tmp, sizeof(tmp), | |
| 853 | _("User <I>%s</I> is not present in the network"), im->nick); | |
| 854 | gaim_conversation_write(convo, NULL, tmp, GAIM_MESSAGE_SYSTEM, time(NULL)); | |
| 855 | ||
| 856 | out: | |
| 857 | g_free(im->nick); | |
| 858 | g_free(im->message); | |
| 859 | silc_free(im); | |
| 860 | silc_free(nickname); | |
| 861 | } | |
| 862 | ||
| 863 | static int | |
| 864 | silcgaim_send_im(GaimConnection *gc, const char *who, const char *msg, | |
| 865 | GaimConvImFlags flags) | |
| 866 | { | |
| 867 | SilcGaim sg = gc->proto_data; | |
| 868 | SilcClient client = sg->client; | |
| 869 | SilcClientConnection conn = sg->conn; | |
| 870 | SilcClientEntry *clients; | |
| 871 | SilcUInt32 clients_count, mflags; | |
| 872 | char *nickname; | |
| 873 | int ret; | |
| 874 | gboolean sign = gaim_prefs_get_bool("/plugins/prpl/silc/sign_im"); | |
| 875 | ||
| 876 | if (!who || !msg) | |
| 877 | return 0; | |
| 878 | ||
|
9353
ff6546387358
[gaim-migrate @ 10161]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9308
diff
changeset
|
879 | mflags = SILC_MESSAGE_FLAG_UTF8; |
|
ff6546387358
[gaim-migrate @ 10161]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9308
diff
changeset
|
880 | |
|
ff6546387358
[gaim-migrate @ 10161]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9308
diff
changeset
|
881 | if (!g_ascii_strncasecmp(msg, "/me ", 4)) { |
|
ff6546387358
[gaim-migrate @ 10161]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9308
diff
changeset
|
882 | msg += 4; |
|
ff6546387358
[gaim-migrate @ 10161]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9308
diff
changeset
|
883 | if (!msg) |
|
ff6546387358
[gaim-migrate @ 10161]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9308
diff
changeset
|
884 | return 0; |
|
ff6546387358
[gaim-migrate @ 10161]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9308
diff
changeset
|
885 | mflags |= SILC_MESSAGE_FLAG_ACTION; |
|
ff6546387358
[gaim-migrate @ 10161]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9308
diff
changeset
|
886 | } else if (strlen(msg) > 1 && msg[0] == '/') { |
| 8849 | 887 | if (!silc_client_command_call(client, conn, msg + 1)) |
| 888 | gaim_notify_error(gc, ("Call Command"), _("Cannot call command"), | |
|
9359
89c40efa7f7b
[gaim-migrate @ 10167]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9353
diff
changeset
|
889 | _("Unknown command")); |
| 8849 | 890 | return 0; |
| 891 | } | |
| 892 | ||
|
9353
ff6546387358
[gaim-migrate @ 10161]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9308
diff
changeset
|
893 | |
| 8849 | 894 | if (!silc_parse_userfqdn(who, &nickname, NULL)) |
| 895 | return 0; | |
| 896 | ||
| 897 | if (sign) | |
| 898 | mflags |= SILC_MESSAGE_FLAG_SIGNED; | |
| 899 | ||
| 900 | /* Find client entry */ | |
| 901 | clients = silc_client_get_clients_local(client, conn, nickname, who, | |
| 902 | &clients_count); | |
| 903 | if (!clients) { | |
| 904 | /* Resolve unknown user */ | |
| 905 | SilcGaimIM im = silc_calloc(1, sizeof(*im)); | |
| 906 | if (!im) | |
| 907 | return 0; | |
| 908 | im->nick = g_strdup(who); | |
| 909 | im->message = g_strdup(msg); | |
| 910 | im->message_len = strlen(im->message); | |
| 911 | im->flags = mflags; | |
| 912 | silc_client_get_clients(client, conn, nickname, NULL, | |
| 913 | silcgaim_send_im_resolved, im); | |
| 914 | silc_free(nickname); | |
| 915 | return 0; | |
| 916 | } | |
| 917 | ||
| 918 | /* Send private message directly */ | |
| 919 | ret = silc_client_send_private_message(client, conn, clients[0], | |
| 920 | mflags, (char *)msg, | |
| 921 | strlen(msg), TRUE); | |
| 922 | ||
| 923 | silc_free(nickname); | |
| 924 | silc_free(clients); | |
| 925 | return ret; | |
| 926 | } | |
| 927 | ||
| 928 | ||
|
9030
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
9024
diff
changeset
|
929 | GList *silcgaim_blist_node_menu(GaimBlistNode *node) { |
|
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
9024
diff
changeset
|
930 | /* split this single menu building function back into the two |
|
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
9024
diff
changeset
|
931 | original: one for buddies and one for chats */ |
|
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
9024
diff
changeset
|
932 | |
|
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
9024
diff
changeset
|
933 | if(GAIM_BLIST_NODE_IS_CHAT(node)) { |
| 9038 | 934 | return silcgaim_chat_menu((GaimChat *) node); |
|
9030
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
9024
diff
changeset
|
935 | } else if(GAIM_BLIST_NODE_IS_BUDDY(node)) { |
|
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
9024
diff
changeset
|
936 | return silcgaim_buddy_menu((GaimBuddy *) node); |
|
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
9024
diff
changeset
|
937 | } else { |
| 9038 | 938 | g_return_val_if_reached(NULL); |
|
9353
ff6546387358
[gaim-migrate @ 10161]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9308
diff
changeset
|
939 | } |
|
9030
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
9024
diff
changeset
|
940 | } |
|
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
9024
diff
changeset
|
941 | |
| 9272 | 942 | /********************************* Commands **********************************/ |
| 943 | ||
| 944 | static GaimCmdRet silcgaim_cmd_chat_part(GaimConversation *conv, | |
| 9597 | 945 | const char *cmd, char **args, char **error, void *data) |
| 9272 | 946 | { |
| 947 | GaimConnection *gc; | |
|
9353
ff6546387358
[gaim-migrate @ 10161]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9308
diff
changeset
|
948 | GaimConversation *convo; |
| 9272 | 949 | int id = 0; |
| 950 | ||
| 951 | gc = gaim_conversation_get_gc(conv); | |
|
9353
ff6546387358
[gaim-migrate @ 10161]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9308
diff
changeset
|
952 | |
|
ff6546387358
[gaim-migrate @ 10161]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9308
diff
changeset
|
953 | if (gc == NULL) |
|
ff6546387358
[gaim-migrate @ 10161]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9308
diff
changeset
|
954 | return GAIM_CMD_RET_FAILED; |
| 9272 | 955 | |
|
9353
ff6546387358
[gaim-migrate @ 10161]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9308
diff
changeset
|
956 | if(args && args[0]) { |
|
ff6546387358
[gaim-migrate @ 10161]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9308
diff
changeset
|
957 | convo = gaim_find_conversation_with_account(args[0], gc->account); |
|
ff6546387358
[gaim-migrate @ 10161]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9308
diff
changeset
|
958 | } else |
|
ff6546387358
[gaim-migrate @ 10161]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9308
diff
changeset
|
959 | convo = conv; |
|
ff6546387358
[gaim-migrate @ 10161]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9308
diff
changeset
|
960 | |
|
9488
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
961 | if (gaim_conversation_get_type(convo) != GAIM_CONV_CHAT) { |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
962 | *error = g_strdup(_("Failed to leave channel")); |
|
9353
ff6546387358
[gaim-migrate @ 10161]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9308
diff
changeset
|
963 | return GAIM_CMD_RET_FAILED; |
|
9488
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
964 | } |
|
9353
ff6546387358
[gaim-migrate @ 10161]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9308
diff
changeset
|
965 | |
|
ff6546387358
[gaim-migrate @ 10161]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9308
diff
changeset
|
966 | id = gaim_conv_chat_get_id(GAIM_CONV_CHAT(convo)); |
|
ff6546387358
[gaim-migrate @ 10161]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9308
diff
changeset
|
967 | |
|
ff6546387358
[gaim-migrate @ 10161]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9308
diff
changeset
|
968 | if (id == 0) |
| 9272 | 969 | return GAIM_CMD_RET_FAILED; |
| 970 | ||
| 971 | silcgaim_chat_leave(gc, id); | |
| 972 | ||
| 973 | return GAIM_CMD_RET_OK; | |
| 974 | ||
| 975 | } | |
| 976 | ||
| 977 | static GaimCmdRet silcgaim_cmd_chat_topic(GaimConversation *conv, | |
| 9597 | 978 | const char *cmd, char **args, char **error, void *data) |
| 9272 | 979 | { |
| 980 | GaimConnection *gc; | |
| 981 | int id = 0; | |
|
9488
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
982 | char *buf, *tmp; |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
983 | const char *topic; |
| 9272 | 984 | |
| 985 | gc = gaim_conversation_get_gc(conv); | |
| 986 | id = gaim_conv_chat_get_id(GAIM_CONV_CHAT(conv)); | |
| 987 | ||
| 988 | if (gc == NULL || id == 0) | |
| 989 | return GAIM_CMD_RET_FAILED; | |
| 990 | ||
|
9488
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
991 | if (!args || !args[0]) { |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
992 | topic = gaim_conv_chat_get_topic (GAIM_CONV_CHAT(conv)); |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
993 | if (topic) { |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
994 | tmp = gaim_escape_html(topic); |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
995 | buf = g_strdup_printf(_("current topic is: %s"), tmp); |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
996 | g_free(tmp); |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
997 | } else |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
998 | buf = g_strdup(_("No topic is set")); |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
999 | gaim_conv_chat_write(GAIM_CONV_CHAT(conv), gc->account->username, buf, |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1000 | GAIM_MESSAGE_SYSTEM|GAIM_MESSAGE_NO_LOG, time(NULL)); |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1001 | g_free(buf); |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1002 | |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1003 | } |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1004 | |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1005 | if (args && args[0] && (strlen(args[0]) > 255)) { |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1006 | *error = g_strdup(_("Topic too long")); |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1007 | return GAIM_CMD_RET_FAILED; |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1008 | } |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1009 | |
| 9272 | 1010 | silcgaim_chat_set_topic(gc, id, args ? args[0] : NULL); |
| 1011 | ||
| 1012 | return GAIM_CMD_RET_OK; | |
| 1013 | } | |
| 1014 | ||
| 1015 | static GaimCmdRet silcgaim_cmd_chat_join(GaimConversation *conv, | |
| 9597 | 1016 | const char *cmd, char **args, char **error, void *data) |
| 9272 | 1017 | { |
| 1018 | GHashTable *comp; | |
| 1019 | ||
| 1020 | if(!args || !args[0]) | |
| 1021 | return GAIM_CMD_RET_FAILED; | |
| 1022 | ||
| 1023 | comp = g_hash_table_new_full(g_str_hash, g_str_equal, NULL, NULL); | |
| 1024 | ||
| 1025 | g_hash_table_replace(comp, "channel", args[0]); | |
| 1026 | if(args[1]) | |
| 1027 | g_hash_table_replace(comp, "passphrase", args[1]); | |
| 1028 | ||
| 1029 | silcgaim_chat_join(gaim_conversation_get_gc(conv), comp); | |
| 1030 | ||
| 1031 | g_hash_table_destroy(comp); | |
| 1032 | return GAIM_CMD_RET_OK; | |
| 1033 | } | |
| 1034 | ||
| 1035 | static GaimCmdRet silcgaim_cmd_chat_list(GaimConversation *conv, | |
| 9597 | 1036 | const char *cmd, char **args, char **error, void *data) |
| 9272 | 1037 | { |
| 1038 | GaimConnection *gc; | |
| 1039 | gc = gaim_conversation_get_gc(conv); | |
| 1040 | gaim_roomlist_show_with_account(gaim_connection_get_account(gc)); | |
| 1041 | return GAIM_CMD_RET_OK; | |
| 1042 | } | |
| 1043 | ||
| 1044 | static GaimCmdRet silcgaim_cmd_whois(GaimConversation *conv, | |
| 9597 | 1045 | const char *cmd, char **args, char **error, void *data) |
| 9272 | 1046 | { |
| 1047 | GaimConnection *gc; | |
| 1048 | ||
| 1049 | gc = gaim_conversation_get_gc(conv); | |
| 1050 | ||
| 1051 | if (gc == NULL) | |
| 1052 | return GAIM_CMD_RET_FAILED; | |
| 1053 | ||
| 1054 | silcgaim_get_info(gc, args[0]); | |
| 1055 | ||
| 1056 | return GAIM_CMD_RET_OK; | |
| 1057 | } | |
| 1058 | ||
| 1059 | static GaimCmdRet silcgaim_cmd_msg(GaimConversation *conv, | |
| 9597 | 1060 | const char *cmd, char **args, char **error, void *data) |
| 9272 | 1061 | { |
| 1062 | int ret; | |
| 1063 | GaimConnection *gc; | |
| 1064 | ||
| 1065 | gc = gaim_conversation_get_gc(conv); | |
| 1066 | ||
| 1067 | if (gc == NULL) | |
| 1068 | return GAIM_CMD_RET_FAILED; | |
| 1069 | ||
| 1070 | ret = silcgaim_send_im(gc, args[0], args[1], GAIM_MESSAGE_SEND); | |
| 1071 | ||
| 1072 | if (ret) | |
| 1073 | return GAIM_CMD_RET_OK; | |
| 1074 | else | |
| 1075 | return GAIM_CMD_RET_FAILED; | |
| 1076 | } | |
| 1077 | ||
| 1078 | static GaimCmdRet silcgaim_cmd_query(GaimConversation *conv, | |
| 9597 | 1079 | const char *cmd, char **args, char **error, void *data) |
| 9272 | 1080 | { |
| 1081 | int ret = 1; | |
| 1082 | GaimConversation *convo; | |
| 1083 | GaimConnection *gc; | |
| 1084 | GaimAccount *account; | |
| 1085 | ||
|
9488
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1086 | if (!args || !args[0]) { |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1087 | *error = g_strdup(_("You must specify a nick")); |
| 9272 | 1088 | return GAIM_CMD_RET_FAILED; |
|
9488
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1089 | } |
| 9272 | 1090 | |
| 1091 | gc = gaim_conversation_get_gc(conv); | |
| 1092 | ||
| 1093 | if (gc == NULL) | |
| 1094 | return GAIM_CMD_RET_FAILED; | |
| 1095 | ||
| 1096 | account = gaim_connection_get_account(gc); | |
| 1097 | ||
| 1098 | convo = gaim_conversation_new(GAIM_CONV_IM, account, args[0]); | |
| 1099 | ||
| 1100 | if (args[1]) { | |
| 1101 | ret = silcgaim_send_im(gc, args[0], args[1], GAIM_MESSAGE_SEND); | |
| 1102 | gaim_conv_im_write(GAIM_CONV_IM(convo), gaim_connection_get_display_name(gc), | |
| 1103 | args[1], GAIM_MESSAGE_SEND, time(NULL)); | |
| 1104 | } | |
| 1105 | ||
| 1106 | if (ret) | |
| 1107 | return GAIM_CMD_RET_OK; | |
| 1108 | else | |
| 1109 | return GAIM_CMD_RET_FAILED; | |
| 1110 | } | |
| 1111 | ||
| 1112 | static GaimCmdRet silcgaim_cmd_motd(GaimConversation *conv, | |
| 9597 | 1113 | const char *cmd, char **args, char **error, void *data) |
| 9272 | 1114 | { |
| 1115 | GaimConnection *gc; | |
| 1116 | SilcGaim sg; | |
|
9488
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1117 | char *tmp; |
| 9272 | 1118 | |
| 1119 | gc = gaim_conversation_get_gc(conv); | |
| 1120 | ||
| 1121 | if (gc == NULL) | |
| 1122 | return GAIM_CMD_RET_FAILED; | |
| 1123 | ||
| 1124 | sg = gc->proto_data; | |
| 1125 | ||
| 1126 | if (sg == NULL) | |
| 1127 | return GAIM_CMD_RET_FAILED; | |
| 1128 | ||
| 1129 | if (!sg->motd) { | |
|
9488
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1130 | *error = g_strdup(_("There is no Message of the Day associated with this connection")); |
| 9272 | 1131 | return GAIM_CMD_RET_FAILED; |
| 1132 | } | |
| 1133 | ||
|
9488
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1134 | tmp = gaim_escape_html(sg->motd); |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1135 | gaim_notify_formatted(gc, NULL, _("Message of the Day"), NULL, |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1136 | tmp, NULL, NULL); |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1137 | g_free(tmp); |
| 9272 | 1138 | |
| 1139 | return GAIM_CMD_RET_OK; | |
| 1140 | } | |
| 1141 | ||
| 1142 | static GaimCmdRet silcgaim_cmd_detach(GaimConversation *conv, | |
| 9597 | 1143 | const char *cmd, char **args, char **error, void *data) |
| 9272 | 1144 | { |
| 1145 | GaimConnection *gc; | |
| 1146 | SilcGaim sg; | |
| 1147 | ||
| 1148 | gc = gaim_conversation_get_gc(conv); | |
| 1149 | ||
| 1150 | if (gc == NULL) | |
| 1151 | return GAIM_CMD_RET_FAILED; | |
| 1152 | ||
| 1153 | sg = gc->proto_data; | |
| 1154 | ||
| 1155 | if (sg == NULL) | |
| 1156 | return GAIM_CMD_RET_FAILED; | |
| 1157 | ||
| 1158 | silc_client_command_call(sg->client, sg->conn, "DETACH"); | |
| 1159 | sg->detaching = TRUE; | |
| 1160 | ||
| 1161 | return GAIM_CMD_RET_OK; | |
| 1162 | } | |
| 1163 | ||
|
9488
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1164 | static GaimCmdRet silcgaim_cmd_cmode(GaimConversation *conv, |
| 9597 | 1165 | const char *cmd, char **args, char **error, void *data) |
|
9488
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1166 | { |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1167 | GaimConnection *gc; |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1168 | SilcGaim sg; |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1169 | SilcChannelEntry channel; |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1170 | char *silccmd, *silcargs, *msg, tmp[256]; |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1171 | const char *chname; |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1172 | |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1173 | gc = gaim_conversation_get_gc(conv); |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1174 | |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1175 | if (gc == NULL || !args || gc->proto_data == NULL) |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1176 | return GAIM_CMD_RET_FAILED; |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1177 | |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1178 | sg = gc->proto_data; |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1179 | |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1180 | if (args[0]) |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1181 | chname = args[0]; |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1182 | else |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1183 | chname = gaim_conversation_get_name(conv); |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1184 | |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1185 | if (!args[1]) { |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1186 | channel = silc_client_get_channel(sg->client, sg->conn, |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1187 | (char *)chname); |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1188 | if (!channel) { |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1189 | *error = g_strdup_printf(_("channel %s not found"), chname); |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1190 | return GAIM_CMD_RET_FAILED; |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1191 | } |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1192 | if (channel->mode) { |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1193 | silcgaim_get_chmode_string(channel->mode, tmp, sizeof(tmp)); |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1194 | msg = g_strdup_printf(_("channel modes for %s: %s"), chname, tmp); |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1195 | } else { |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1196 | msg = g_strdup_printf(_("no channel modes are set on %s"), chname); |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1197 | } |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1198 | gaim_conv_chat_write(GAIM_CONV_CHAT(conv), "", |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1199 | msg, GAIM_MESSAGE_SYSTEM|GAIM_MESSAGE_NO_LOG, time(NULL)); |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1200 | g_free(msg); |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1201 | return GAIM_CMD_RET_OK; |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1202 | } |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1203 | |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1204 | silcargs = g_strjoinv(" ", args); |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1205 | silccmd = g_strconcat(cmd, " ", args ? silcargs : NULL, NULL); |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1206 | g_free(silcargs); |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1207 | if (!silc_client_command_call(sg->client, sg->conn, silccmd)) { |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1208 | g_free(silccmd); |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1209 | *error = g_strdup_printf(_("Failed to set cmodes for %s"), args[0]); |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1210 | return GAIM_CMD_RET_FAILED; |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1211 | } |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1212 | g_free(silccmd); |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1213 | |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1214 | return GAIM_CMD_RET_OK; |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1215 | } |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1216 | |
|
9353
ff6546387358
[gaim-migrate @ 10161]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9308
diff
changeset
|
1217 | static GaimCmdRet silcgaim_cmd_generic(GaimConversation *conv, |
| 9597 | 1218 | const char *cmd, char **args, char **error, void *data) |
| 9272 | 1219 | { |
| 1220 | GaimConnection *gc; | |
| 1221 | SilcGaim sg; | |
|
9353
ff6546387358
[gaim-migrate @ 10161]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9308
diff
changeset
|
1222 | char *silccmd, *silcargs; |
| 9272 | 1223 | |
| 1224 | gc = gaim_conversation_get_gc(conv); | |
| 1225 | ||
| 1226 | if (gc == NULL) | |
| 1227 | return GAIM_CMD_RET_FAILED; | |
| 1228 | ||
| 1229 | sg = gc->proto_data; | |
| 1230 | ||
| 1231 | if (sg == NULL) | |
| 1232 | return GAIM_CMD_RET_FAILED; | |
| 1233 | ||
|
9353
ff6546387358
[gaim-migrate @ 10161]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9308
diff
changeset
|
1234 | silcargs = g_strjoinv(" ", args); |
|
ff6546387358
[gaim-migrate @ 10161]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9308
diff
changeset
|
1235 | silccmd = g_strconcat(cmd, " ", args ? silcargs : NULL, NULL); |
|
ff6546387358
[gaim-migrate @ 10161]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9308
diff
changeset
|
1236 | g_free(silcargs); |
|
ff6546387358
[gaim-migrate @ 10161]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9308
diff
changeset
|
1237 | if (!silc_client_command_call(sg->client, sg->conn, silccmd)) { |
|
ff6546387358
[gaim-migrate @ 10161]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9308
diff
changeset
|
1238 | g_free(silccmd); |
|
9488
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1239 | *error = g_strdup_printf(_("Unknown command: %s, (may be a Gaim bug)"), cmd); |
|
9353
ff6546387358
[gaim-migrate @ 10161]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9308
diff
changeset
|
1240 | return GAIM_CMD_RET_FAILED; |
|
ff6546387358
[gaim-migrate @ 10161]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9308
diff
changeset
|
1241 | } |
|
ff6546387358
[gaim-migrate @ 10161]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9308
diff
changeset
|
1242 | g_free(silccmd); |
| 9272 | 1243 | |
| 1244 | return GAIM_CMD_RET_OK; | |
| 1245 | } | |
| 1246 | ||
|
9359
89c40efa7f7b
[gaim-migrate @ 10167]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9353
diff
changeset
|
1247 | static GaimCmdRet silcgaim_cmd_quit(GaimConversation *conv, |
| 9597 | 1248 | const char *cmd, char **args, char **error, void *data) |
|
9359
89c40efa7f7b
[gaim-migrate @ 10167]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9353
diff
changeset
|
1249 | { |
|
89c40efa7f7b
[gaim-migrate @ 10167]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9353
diff
changeset
|
1250 | GaimConnection *gc; |
|
89c40efa7f7b
[gaim-migrate @ 10167]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9353
diff
changeset
|
1251 | SilcGaim sg; |
|
89c40efa7f7b
[gaim-migrate @ 10167]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9353
diff
changeset
|
1252 | |
|
89c40efa7f7b
[gaim-migrate @ 10167]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9353
diff
changeset
|
1253 | gc = gaim_conversation_get_gc(conv); |
|
89c40efa7f7b
[gaim-migrate @ 10167]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9353
diff
changeset
|
1254 | |
|
89c40efa7f7b
[gaim-migrate @ 10167]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9353
diff
changeset
|
1255 | if (gc == NULL) |
|
89c40efa7f7b
[gaim-migrate @ 10167]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9353
diff
changeset
|
1256 | return GAIM_CMD_RET_FAILED; |
|
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 | sg = gc->proto_data; |
|
89c40efa7f7b
[gaim-migrate @ 10167]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9353
diff
changeset
|
1259 | |
|
89c40efa7f7b
[gaim-migrate @ 10167]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9353
diff
changeset
|
1260 | if (sg == NULL) |
|
89c40efa7f7b
[gaim-migrate @ 10167]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9353
diff
changeset
|
1261 | return GAIM_CMD_RET_FAILED; |
|
89c40efa7f7b
[gaim-migrate @ 10167]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9353
diff
changeset
|
1262 | |
|
89c40efa7f7b
[gaim-migrate @ 10167]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9353
diff
changeset
|
1263 | silc_client_command_call(sg->client, sg->conn, NULL, |
|
89c40efa7f7b
[gaim-migrate @ 10167]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9353
diff
changeset
|
1264 | "QUIT", (args && args[0]) ? args[0] : "Download Gaim: " GAIM_WEBSITE, NULL); |
|
89c40efa7f7b
[gaim-migrate @ 10167]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9353
diff
changeset
|
1265 | |
|
89c40efa7f7b
[gaim-migrate @ 10167]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9353
diff
changeset
|
1266 | return GAIM_CMD_RET_OK; |
|
89c40efa7f7b
[gaim-migrate @ 10167]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9353
diff
changeset
|
1267 | } |
|
89c40efa7f7b
[gaim-migrate @ 10167]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9353
diff
changeset
|
1268 | |
|
89c40efa7f7b
[gaim-migrate @ 10167]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9353
diff
changeset
|
1269 | static GaimCmdRet silcgaim_cmd_call(GaimConversation *conv, |
| 9597 | 1270 | const char *cmd, char **args, char **error, void *data) |
|
9359
89c40efa7f7b
[gaim-migrate @ 10167]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9353
diff
changeset
|
1271 | { |
|
89c40efa7f7b
[gaim-migrate @ 10167]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9353
diff
changeset
|
1272 | GaimConnection *gc; |
|
89c40efa7f7b
[gaim-migrate @ 10167]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9353
diff
changeset
|
1273 | SilcGaim sg; |
|
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 | gc = gaim_conversation_get_gc(conv); |
|
89c40efa7f7b
[gaim-migrate @ 10167]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9353
diff
changeset
|
1276 | |
|
89c40efa7f7b
[gaim-migrate @ 10167]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9353
diff
changeset
|
1277 | if (gc == NULL) |
|
89c40efa7f7b
[gaim-migrate @ 10167]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9353
diff
changeset
|
1278 | return GAIM_CMD_RET_FAILED; |
|
89c40efa7f7b
[gaim-migrate @ 10167]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9353
diff
changeset
|
1279 | |
|
89c40efa7f7b
[gaim-migrate @ 10167]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9353
diff
changeset
|
1280 | sg = gc->proto_data; |
|
89c40efa7f7b
[gaim-migrate @ 10167]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9353
diff
changeset
|
1281 | |
|
89c40efa7f7b
[gaim-migrate @ 10167]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9353
diff
changeset
|
1282 | if (sg == NULL) |
|
89c40efa7f7b
[gaim-migrate @ 10167]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9353
diff
changeset
|
1283 | return GAIM_CMD_RET_FAILED; |
|
89c40efa7f7b
[gaim-migrate @ 10167]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9353
diff
changeset
|
1284 | |
|
9488
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1285 | if (!silc_client_command_call(sg->client, sg->conn, args[0])) { |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1286 | *error = g_strdup_printf(_("Unknown command: %s"), args[0]); |
|
9359
89c40efa7f7b
[gaim-migrate @ 10167]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9353
diff
changeset
|
1287 | return GAIM_CMD_RET_FAILED; |
|
9488
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1288 | } |
|
9359
89c40efa7f7b
[gaim-migrate @ 10167]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9353
diff
changeset
|
1289 | |
|
89c40efa7f7b
[gaim-migrate @ 10167]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9353
diff
changeset
|
1290 | return GAIM_CMD_RET_OK; |
|
89c40efa7f7b
[gaim-migrate @ 10167]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9353
diff
changeset
|
1291 | } |
|
89c40efa7f7b
[gaim-migrate @ 10167]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9353
diff
changeset
|
1292 | |
|
9030
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
9024
diff
changeset
|
1293 | |
| 8849 | 1294 | /************************** Plugin Initialization ****************************/ |
| 1295 | ||
| 9272 | 1296 | static void |
| 1297 | silcgaim_register_commands(void) | |
| 1298 | { | |
|
9353
ff6546387358
[gaim-migrate @ 10161]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9308
diff
changeset
|
1299 | gaim_cmd_register("part", "w", GAIM_CMD_P_PRPL, |
|
ff6546387358
[gaim-migrate @ 10161]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9308
diff
changeset
|
1300 | GAIM_CMD_FLAG_IM | GAIM_CMD_FLAG_CHAT | |
|
ff6546387358
[gaim-migrate @ 10161]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9308
diff
changeset
|
1301 | GAIM_CMD_FLAG_PRPL_ONLY | GAIM_CMD_FLAG_ALLOW_WRONG_ARGS, |
| 9597 | 1302 | "prpl-silc", silcgaim_cmd_chat_part, _("part [channel]: Leave the chat"), NULL); |
|
9353
ff6546387358
[gaim-migrate @ 10161]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9308
diff
changeset
|
1303 | gaim_cmd_register("leave", "w", GAIM_CMD_P_PRPL, |
|
ff6546387358
[gaim-migrate @ 10161]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9308
diff
changeset
|
1304 | GAIM_CMD_FLAG_IM | GAIM_CMD_FLAG_CHAT | |
|
ff6546387358
[gaim-migrate @ 10161]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9308
diff
changeset
|
1305 | GAIM_CMD_FLAG_PRPL_ONLY | GAIM_CMD_FLAG_ALLOW_WRONG_ARGS, |
| 9597 | 1306 | "prpl-silc", silcgaim_cmd_chat_part, _("leave [channel]: Leave the chat"), NULL); |
| 9272 | 1307 | gaim_cmd_register("topic", "s", GAIM_CMD_P_PRPL, |
| 1308 | GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_PRPL_ONLY | | |
| 1309 | GAIM_CMD_FLAG_ALLOW_WRONG_ARGS, "prpl-silc", | |
| 9597 | 1310 | silcgaim_cmd_chat_topic, _("topic [<new topic>]: View or change the topic"), NULL); |
| 9272 | 1311 | gaim_cmd_register("join", "ws", GAIM_CMD_P_PRPL, |
| 1312 | GAIM_CMD_FLAG_IM | GAIM_CMD_FLAG_CHAT | | |
| 1313 | GAIM_CMD_FLAG_PRPL_ONLY | GAIM_CMD_FLAG_ALLOW_WRONG_ARGS, | |
| 1314 | "prpl-silc", silcgaim_cmd_chat_join, | |
| 9597 | 1315 | _("join <channel> [<password>]: Join a chat on this network"), NULL); |
| 9272 | 1316 | gaim_cmd_register("list", "", GAIM_CMD_P_PRPL, |
| 1317 | GAIM_CMD_FLAG_IM | GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_PRPL_ONLY | | |
| 1318 | GAIM_CMD_FLAG_ALLOW_WRONG_ARGS, "prpl-silc", | |
| 9597 | 1319 | silcgaim_cmd_chat_list, _("list: List channels on this network"), NULL); |
| 9272 | 1320 | gaim_cmd_register("whois", "w", GAIM_CMD_P_PRPL, |
| 1321 | GAIM_CMD_FLAG_IM | GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_PRPL_ONLY, | |
| 1322 | "prpl-silc", | |
| 9597 | 1323 | silcgaim_cmd_whois, _("whois <nick>: View nick's information"), NULL); |
| 9272 | 1324 | gaim_cmd_register("msg", "ws", GAIM_CMD_P_PRPL, |
| 1325 | GAIM_CMD_FLAG_IM | GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_PRPL_ONLY, | |
| 1326 | "prpl-silc", silcgaim_cmd_msg, | |
| 9597 | 1327 | _("msg <nick> <message>: Send a private message to a user"), NULL); |
| 9272 | 1328 | gaim_cmd_register("query", "ws", GAIM_CMD_P_PRPL, |
| 1329 | GAIM_CMD_FLAG_IM | GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_PRPL_ONLY | | |
| 1330 | GAIM_CMD_FLAG_ALLOW_WRONG_ARGS, "prpl-silc", silcgaim_cmd_query, | |
| 9597 | 1331 | _("query <nick> [<message>]: Send a private message to a user"), NULL); |
| 9272 | 1332 | gaim_cmd_register("motd", "", GAIM_CMD_P_PRPL, |
| 1333 | GAIM_CMD_FLAG_IM | GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_PRPL_ONLY | | |
| 1334 | GAIM_CMD_FLAG_ALLOW_WRONG_ARGS, "prpl-silc", silcgaim_cmd_motd, | |
| 9597 | 1335 | _("motd: View the server's Message Of The Day"), NULL); |
| 9272 | 1336 | gaim_cmd_register("detach", "", GAIM_CMD_P_PRPL, |
|
9353
ff6546387358
[gaim-migrate @ 10161]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9308
diff
changeset
|
1337 | 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
|
1338 | "prpl-silc", silcgaim_cmd_detach, |
| 9597 | 1339 | _("detach: Detach this session"), NULL); |
|
9359
89c40efa7f7b
[gaim-migrate @ 10167]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9353
diff
changeset
|
1340 | gaim_cmd_register("quit", "s", GAIM_CMD_P_PRPL, |
|
89c40efa7f7b
[gaim-migrate @ 10167]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9353
diff
changeset
|
1341 | 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
|
1342 | GAIM_CMD_FLAG_ALLOW_WRONG_ARGS, "prpl-silc", silcgaim_cmd_quit, |
| 9597 | 1343 | _("quit [message]: Disconnect from the server, with an optional message"), NULL); |
|
9359
89c40efa7f7b
[gaim-migrate @ 10167]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9353
diff
changeset
|
1344 | gaim_cmd_register("call", "s", GAIM_CMD_P_PRPL, |
|
89c40efa7f7b
[gaim-migrate @ 10167]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9353
diff
changeset
|
1345 | 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
|
1346 | "prpl-silc", silcgaim_cmd_call, |
| 9597 | 1347 | _("call <command>: Call any silc client command"), NULL); |
| 1348 | /* These below just get passed through for the silc client library to deal | |
| 1349 | * with */ | |
|
9359
89c40efa7f7b
[gaim-migrate @ 10167]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9353
diff
changeset
|
1350 | gaim_cmd_register("kill", "ws", GAIM_CMD_P_PRPL, |
|
89c40efa7f7b
[gaim-migrate @ 10167]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9353
diff
changeset
|
1351 | 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
|
1352 | GAIM_CMD_FLAG_ALLOW_WRONG_ARGS, "prpl-silc", silcgaim_cmd_generic, |
| 9597 | 1353 | _("kill <nick> [-pubkey|<reason>]: Kill nick"), NULL); |
|
9359
89c40efa7f7b
[gaim-migrate @ 10167]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9353
diff
changeset
|
1354 | gaim_cmd_register("nick", "w", GAIM_CMD_P_PRPL, |
|
89c40efa7f7b
[gaim-migrate @ 10167]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9353
diff
changeset
|
1355 | 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
|
1356 | "prpl-silc", silcgaim_cmd_generic, |
| 9597 | 1357 | _("nick <newnick>: Change your nickname"), NULL); |
|
9488
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1358 | gaim_cmd_register("whowas", "ww", GAIM_CMD_P_PRPL, |
|
9359
89c40efa7f7b
[gaim-migrate @ 10167]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9353
diff
changeset
|
1359 | 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
|
1360 | GAIM_CMD_FLAG_ALLOW_WRONG_ARGS, "prpl-silc", silcgaim_cmd_generic, |
| 9597 | 1361 | _("whowas <nick>: View nick's information"), NULL); |
|
9488
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1362 | gaim_cmd_register("cmode", "wws", GAIM_CMD_P_PRPL, |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1363 | GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_PRPL_ONLY | |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1364 | GAIM_CMD_FLAG_ALLOW_WRONG_ARGS, "prpl-silc", silcgaim_cmd_cmode, |
| 9597 | 1365 | _("cmode <channel> [+|-<modes>] [arguments]: Change or display channel modes"), NULL); |
|
9359
89c40efa7f7b
[gaim-migrate @ 10167]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9353
diff
changeset
|
1366 | gaim_cmd_register("cumode", "wws", GAIM_CMD_P_PRPL, |
|
89c40efa7f7b
[gaim-migrate @ 10167]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9353
diff
changeset
|
1367 | 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
|
1368 | GAIM_CMD_FLAG_ALLOW_WRONG_ARGS, "prpl-silc", silcgaim_cmd_generic, |
| 9597 | 1369 | _("cumode <channel> +|-<modes> <nick>: Change nick's modes on channel"), NULL); |
| 9272 | 1370 | gaim_cmd_register("umode", "w", GAIM_CMD_P_PRPL, |
| 1371 | 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
|
1372 | "prpl-silc", silcgaim_cmd_generic, |
| 9597 | 1373 | _("umode <usermodes>: Set your modes in the network"), NULL); |
|
9359
89c40efa7f7b
[gaim-migrate @ 10167]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9353
diff
changeset
|
1374 | gaim_cmd_register("oper", "s", GAIM_CMD_P_PRPL, |
|
89c40efa7f7b
[gaim-migrate @ 10167]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9353
diff
changeset
|
1375 | 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
|
1376 | "prpl-silc", silcgaim_cmd_generic, |
| 9597 | 1377 | _("oper <nick> [-pubkey]: Get server operator privileges"), NULL); |
|
9359
89c40efa7f7b
[gaim-migrate @ 10167]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9353
diff
changeset
|
1378 | gaim_cmd_register("invite", "ws", GAIM_CMD_P_PRPL, |
|
89c40efa7f7b
[gaim-migrate @ 10167]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9353
diff
changeset
|
1379 | 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
|
1380 | GAIM_CMD_FLAG_ALLOW_WRONG_ARGS, "prpl-silc", silcgaim_cmd_generic, |
| 9597 | 1381 | _("invite <channel> [-|+]<nick>: invite nick or add/remove from channel invite list"), NULL); |
|
9359
89c40efa7f7b
[gaim-migrate @ 10167]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9353
diff
changeset
|
1382 | gaim_cmd_register("kick", "wws", GAIM_CMD_P_PRPL, |
|
89c40efa7f7b
[gaim-migrate @ 10167]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9353
diff
changeset
|
1383 | 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
|
1384 | GAIM_CMD_FLAG_ALLOW_WRONG_ARGS, "prpl-silc", silcgaim_cmd_generic, |
| 9597 | 1385 | _("kick <channel> <nick> [comment]: Kick client from channel"), NULL); |
|
9488
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1386 | gaim_cmd_register("info", "w", GAIM_CMD_P_PRPL, |
|
9359
89c40efa7f7b
[gaim-migrate @ 10167]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9353
diff
changeset
|
1387 | 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
|
1388 | GAIM_CMD_FLAG_ALLOW_WRONG_ARGS, "prpl-silc", silcgaim_cmd_generic, |
| 9597 | 1389 | _("info [server]: View server administrative details"), NULL); |
|
9359
89c40efa7f7b
[gaim-migrate @ 10167]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9353
diff
changeset
|
1390 | gaim_cmd_register("ban", "ww", GAIM_CMD_P_PRPL, |
|
89c40efa7f7b
[gaim-migrate @ 10167]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9353
diff
changeset
|
1391 | 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
|
1392 | GAIM_CMD_FLAG_ALLOW_WRONG_ARGS, "prpl-silc", silcgaim_cmd_generic, |
| 9597 | 1393 | _("ban [<channel> +|-<nick>]: Ban client from channel"), NULL); |
|
9488
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1394 | gaim_cmd_register("getkey", "w", GAIM_CMD_P_PRPL, |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1395 | GAIM_CMD_FLAG_IM | GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_PRPL_ONLY, |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1396 | "prpl-silc", silcgaim_cmd_generic, |
| 9597 | 1397 | _("getkey <nick|server>: Retrieve client's or server's public key"), NULL); |
|
9488
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1398 | gaim_cmd_register("stats", "", GAIM_CMD_P_PRPL, |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1399 | GAIM_CMD_FLAG_IM | GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_PRPL_ONLY, |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1400 | "prpl-silc", silcgaim_cmd_generic, |
| 9597 | 1401 | _("stats: View server and network statistics"), NULL); |
|
9359
89c40efa7f7b
[gaim-migrate @ 10167]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9353
diff
changeset
|
1402 | gaim_cmd_register("ping", "", GAIM_CMD_P_PRPL, |
|
89c40efa7f7b
[gaim-migrate @ 10167]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9353
diff
changeset
|
1403 | 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
|
1404 | "prpl-silc", silcgaim_cmd_generic, |
| 9597 | 1405 | _("ping: Send PING to the connected server"), NULL); |
|
9488
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1406 | #if 0 /* Gaim doesn't handle these yet */ |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1407 | gaim_cmd_register("users", "w", GAIM_CMD_P_PRPL, |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1408 | GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_PRPL_ONLY, |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1409 | "prpl-silc", silcgaim_cmd_users, |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1410 | _("users <channel>: List users in channel")); |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1411 | gaim_cmd_register("names", "ww", GAIM_CMD_P_PRPL, |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1412 | GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_PRPL_ONLY | |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1413 | GAIM_CMD_FLAG_ALLOW_WRONG_ARGS, "prpl-silc", silcgaim_cmd_names, |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1414 | _("names [-count|-ops|-halfops|-voices|-normal] <channel(s)>: List specific users in channel(s)")); |
|
9359
89c40efa7f7b
[gaim-migrate @ 10167]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9353
diff
changeset
|
1415 | #endif |
| 9272 | 1416 | } |
| 1417 | ||
| 8849 | 1418 | static GaimPluginPrefFrame * |
| 1419 | silcgaim_pref_frame(GaimPlugin *plugin) | |
| 1420 | { | |
| 1421 | GaimPluginPrefFrame *frame; | |
| 1422 | GaimPluginPref *ppref; | |
| 1423 | ||
| 1424 | frame = gaim_plugin_pref_frame_new(); | |
| 1425 | ||
| 1426 | ppref = gaim_plugin_pref_new_with_label(_("Instant Messages")); | |
| 1427 | gaim_plugin_pref_frame_add(frame, ppref); | |
| 1428 | ||
| 1429 | ppref = gaim_plugin_pref_new_with_name_and_label( | |
| 1430 | "/plugins/prpl/silc/sign_im", | |
| 1431 | _("Digitally sign all IM messages")); | |
| 1432 | gaim_plugin_pref_frame_add(frame, ppref); | |
| 1433 | ||
| 1434 | ppref = gaim_plugin_pref_new_with_name_and_label( | |
| 1435 | "/plugins/prpl/silc/verify_im", | |
| 1436 | _("Verify all IM message signatures")); | |
| 1437 | gaim_plugin_pref_frame_add(frame, ppref); | |
| 1438 | ||
| 1439 | ppref = gaim_plugin_pref_new_with_label(_("Channel Messages")); | |
| 1440 | gaim_plugin_pref_frame_add(frame, ppref); | |
| 1441 | ||
| 1442 | ppref = gaim_plugin_pref_new_with_name_and_label( | |
| 1443 | "/plugins/prpl/silc/sign_chat", | |
| 1444 | _("Digitally sign all channel messages")); | |
| 1445 | gaim_plugin_pref_frame_add(frame, ppref); | |
| 1446 | ||
| 1447 | ppref = gaim_plugin_pref_new_with_name_and_label( | |
| 1448 | "/plugins/prpl/silc/verify_chat", | |
| 1449 | _("Verify all channel message signatures")); | |
| 1450 | gaim_plugin_pref_frame_add(frame, ppref); | |
| 1451 | ||
| 1452 | ppref = gaim_plugin_pref_new_with_label(_("Default SILC Key Pair")); | |
| 1453 | gaim_plugin_pref_frame_add(frame, ppref); | |
| 1454 | ||
| 1455 | ppref = gaim_plugin_pref_new_with_name_and_label( | |
| 1456 | "/plugins/prpl/silc/pubkey", | |
| 1457 | _("SILC Public Key")); | |
| 1458 | gaim_plugin_pref_frame_add(frame, ppref); | |
| 1459 | ||
| 1460 | ppref = gaim_plugin_pref_new_with_name_and_label( | |
| 1461 | "/plugins/prpl/silc/privkey", | |
| 1462 | _("SILC Private Key")); | |
| 1463 | gaim_plugin_pref_frame_add(frame, ppref); | |
| 1464 | ||
| 1465 | return frame; | |
| 1466 | } | |
| 1467 | ||
| 1468 | static GaimPluginUiInfo prefs_info = | |
| 1469 | { | |
| 1470 | silcgaim_pref_frame, | |
| 1471 | }; | |
| 1472 | ||
| 1473 | static GaimPluginProtocolInfo prpl_info = | |
| 1474 | { | |
| 1475 | GAIM_PRPL_API_VERSION, | |
| 1476 | OPT_PROTO_CHAT_TOPIC | OPT_PROTO_UNIQUE_CHATNAME | | |
| 1477 | OPT_PROTO_PASSWORD_OPTIONAL, | |
|
9488
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1478 | NULL, /* user_splits */ |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1479 | NULL, /* protocol_options */ |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1480 | NO_BUDDY_ICONS, /* icon_spec */ |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1481 | silcgaim_list_icon, /* list_icon */ |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1482 | silcgaim_list_emblems, /* list_emblems */ |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1483 | silcgaim_status_text, /* status_text */ |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1484 | silcgaim_tooltip_text, /* tooltip_text */ |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1485 | silcgaim_away_states, /* away_states */ |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1486 | silcgaim_blist_node_menu, /* blist_node_menu */ |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1487 | silcgaim_chat_info, /* chat_info */ |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1488 | silcgaim_login, /* login */ |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1489 | silcgaim_close, /* close */ |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1490 | silcgaim_send_im, /* send_im */ |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1491 | silcgaim_set_info, /* set_info */ |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1492 | NULL, /* send_typing */ |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1493 | silcgaim_get_info, /* get_info */ |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1494 | silcgaim_set_away, /* set_away */ |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1495 | silcgaim_idle_set, /* set_idle */ |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1496 | silcgaim_change_passwd, /* change_passwd */ |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1497 | silcgaim_add_buddy, /* add_buddy */ |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1498 | NULL, /* add_buddies */ |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1499 | silcgaim_remove_buddy, /* remove_buddy */ |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1500 | NULL, /* remove_buddies */ |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1501 | NULL, /* add_permit */ |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1502 | NULL, /* add_deny */ |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1503 | NULL, /* rem_permit */ |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1504 | NULL, /* rem_deny */ |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1505 | NULL, /* set_permit_deny */ |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1506 | NULL, /* warn */ |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1507 | silcgaim_chat_join, /* join_chat */ |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1508 | NULL, /* reject_chat */ |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1509 | silcgaim_chat_invite, /* chat_invite */ |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1510 | silcgaim_chat_leave, /* chat_leave */ |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1511 | NULL, /* chat_whisper */ |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1512 | silcgaim_chat_send, /* chat_send */ |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1513 | silcgaim_keepalive, /* keepalive */ |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1514 | NULL, /* register_user */ |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1515 | NULL, /* get_cb_info */ |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1516 | NULL, /* get_cb_away */ |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1517 | NULL, /* alias_buddy */ |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1518 | NULL, /* group_buddy */ |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1519 | NULL, /* rename_group */ |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1520 | NULL, /* buddy_free */ |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1521 | NULL, /* convo_closed */ |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1522 | NULL, /* normalize */ |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1523 | NULL, /* set_buddy_icon */ |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1524 | NULL, /* remove_group */ |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1525 | NULL, /* get_cb_real_name */ |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1526 | silcgaim_chat_set_topic, /* set_chat_topic */ |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1527 | NULL, /* find_blist_chat */ |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1528 | silcgaim_roomlist_get_list, /* roomlist_get_list */ |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1529 | silcgaim_roomlist_cancel, /* roomlist_cancel */ |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1530 | NULL, /* roomlist_expand_category */ |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1531 | NULL, /* can_receive_file */ |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1532 | silcgaim_ftp_send_file /* send_file */ |
| 8849 | 1533 | }; |
| 1534 | ||
| 1535 | static GaimPluginInfo info = | |
| 1536 | { | |
| 1537 | GAIM_PLUGIN_API_VERSION, /**< api_version */ | |
| 1538 | GAIM_PLUGIN_PROTOCOL, /**< type */ | |
| 1539 | NULL, /**< ui_requirement */ | |
| 1540 | 0, /**< flags */ | |
| 1541 | NULL, /**< dependencies */ | |
| 1542 | GAIM_PRIORITY_DEFAULT, /**< priority */ | |
| 1543 | ||
| 1544 | "prpl-silc", /**< id */ | |
| 1545 | "SILC", /**< name */ | |
| 1546 | "1.0", /**< version */ | |
| 1547 | /** summary */ | |
| 1548 | N_("SILC Protocol Plugin"), | |
| 1549 | /** description */ | |
| 1550 | N_("Secure Internet Live Conferencing (SILC) Protocol"), | |
| 8891 | 1551 | "Pekka Riikonen", /**< author */ |
| 1552 | "http://silcnet.org/", /**< homepage */ | |
| 8849 | 1553 | |
| 1554 | NULL, /**< load */ | |
| 1555 | NULL, /**< unload */ | |
| 1556 | NULL, /**< destroy */ | |
| 1557 | ||
| 1558 | NULL, /**< ui_info */ | |
| 1559 | &prpl_info, /**< extra_info */ | |
| 8993 | 1560 | &prefs_info, /**< prefs_info */ |
|
9015
3c27e9074fa2
[gaim-migrate @ 9791]
Christopher O'Brien <siege@pidgin.im>
parents:
8993
diff
changeset
|
1561 | silcgaim_actions |
| 8849 | 1562 | }; |
| 1563 | ||
| 1564 | static void | |
| 1565 | init_plugin(GaimPlugin *plugin) | |
| 1566 | { | |
| 1567 | GaimAccountOption *option; | |
| 1568 | char tmp[256]; | |
| 1569 | ||
| 1570 | silc_plugin = plugin; | |
| 1571 | ||
| 1572 | /* Account options */ | |
| 1573 | option = gaim_account_option_string_new(_("Connect server"), | |
| 1574 | "server", | |
| 1575 | "silc.silcnet.org"); | |
| 1576 | prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); | |
| 1577 | option = gaim_account_option_int_new(_("Port"), "port", 706); | |
| 1578 | prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); | |
| 1579 | ||
| 1580 | option = gaim_account_option_bool_new(_("Public key authentication"), | |
| 1581 | "pubkey-auth", FALSE); | |
| 1582 | prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); | |
| 1583 | #if 0 /* XXX Public key auth interface with explicit key pair is | |
| 1584 | broken in SILC Toolkit */ | |
| 8891 | 1585 | g_snprintf(tmp, sizeof(tmp), "%s/public_key.pub", silcgaim_silcdir()); |
| 8849 | 1586 | option = gaim_account_option_string_new(_("Public Key File"), |
| 1587 | "public-key", tmp); | |
| 1588 | prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); | |
| 8891 | 1589 | g_snprintf(tmp, sizeof(tmp), "%s/private_key.prv", silcgaim_silcdir()); |
| 8849 | 1590 | option = gaim_account_option_string_new(_("Private Key File"), |
| 1591 | "public-key", tmp); | |
| 1592 | prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); | |
| 1593 | #endif | |
| 1594 | ||
| 1595 | option = gaim_account_option_bool_new(_("Reject watching by other users"), | |
| 1596 | "reject-watch", FALSE); | |
| 1597 | prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); | |
| 1598 | option = gaim_account_option_bool_new(_("Block invites"), | |
| 1599 | "block-invites", FALSE); | |
| 1600 | prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); | |
| 1601 | option = gaim_account_option_bool_new(_("Block IMs without Key Exchange"), | |
| 1602 | "block-ims", FALSE); | |
| 1603 | prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); | |
| 1604 | option = gaim_account_option_bool_new(_("Reject online status attribute requests"), | |
| 1605 | "reject-attrs", FALSE); | |
| 1606 | prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); | |
| 1607 | ||
| 1608 | /* Preferences */ | |
| 1609 | gaim_prefs_add_none("/plugins/prpl/silc"); | |
| 1610 | gaim_prefs_add_bool("/plugins/prpl/silc/sign_im", FALSE); | |
| 1611 | gaim_prefs_add_bool("/plugins/prpl/silc/verify_im", FALSE); | |
| 1612 | gaim_prefs_add_bool("/plugins/prpl/silc/sign_chat", FALSE); | |
| 1613 | gaim_prefs_add_bool("/plugins/prpl/silc/verify_chat", FALSE); | |
| 8891 | 1614 | g_snprintf(tmp, sizeof(tmp), "%s/public_key.pub", silcgaim_silcdir()); |
| 8849 | 1615 | gaim_prefs_add_string("/plugins/prpl/silc/pubkey", tmp); |
| 8891 | 1616 | g_snprintf(tmp, sizeof(tmp), "%s/private_key.prv", silcgaim_silcdir()); |
| 8849 | 1617 | gaim_prefs_add_string("/plugins/prpl/silc/privkey", tmp); |
| 1618 | gaim_prefs_add_string("/plugins/prpl/silc/vcard", ""); | |
| 9272 | 1619 | |
| 1620 | silcgaim_register_commands(); | |
|
9353
ff6546387358
[gaim-migrate @ 10161]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9308
diff
changeset
|
1621 | |
|
ff6546387358
[gaim-migrate @ 10161]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9308
diff
changeset
|
1622 | #ifdef _WIN32 |
|
ff6546387358
[gaim-migrate @ 10161]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9308
diff
changeset
|
1623 | silc_net_win32_init(); |
|
ff6546387358
[gaim-migrate @ 10161]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9308
diff
changeset
|
1624 | #endif |
|
ff6546387358
[gaim-migrate @ 10161]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9308
diff
changeset
|
1625 | |
| 8849 | 1626 | } |
| 1627 | ||
| 1628 | GAIM_INIT_PLUGIN(silc, init_plugin, info); |