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