Thu, 01 Jul 2004 15:57:38 +0000
[gaim-migrate @ 10256]
this patch had some little discussion, so the original comments about it
don't make too much sense now.
it makes the log viewwer further collapse things into months for things
older than the current month. for relatively short logs this might not be
wonderful, but it should help with very long logs. see patch #963827
oh and thanks to Cole Kowalski for this
committer: Luke Schierer <lschiere@pidgin.im>
| 8849 | 1 | /* |
| 2 | ||
| 3 | silcgaim_chat.c | |
| 4 | ||
| 5 | Author: Pekka Riikonen <priikone@silcnet.org> | |
| 6 | ||
| 7 | Copyright (C) 2004 Pekka Riikonen | |
| 8 | ||
| 9 | This program is free software; you can redistribute it and/or modify | |
| 10 | it under the terms of the GNU General Public License as published by | |
| 11 | the Free Software Foundation; version 2 of the License. | |
| 12 | ||
| 13 | This program is distributed in the hope that it will be useful, | |
| 14 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 16 | GNU General Public License for more details. | |
| 17 | ||
| 18 | */ | |
| 19 | ||
| 20 | #include "silcincludes.h" | |
| 21 | #include "silcclient.h" | |
| 22 | #include "silcgaim.h" | |
| 23 | ||
| 24 | /***************************** Channel Routines ******************************/ | |
| 25 | ||
| 26 | GList *silcgaim_chat_info(GaimConnection *gc) | |
| 27 | { | |
| 28 | GList *ci = NULL; | |
| 29 | struct proto_chat_entry *pce; | |
| 30 | ||
| 31 | pce = g_new0(struct proto_chat_entry, 1); | |
| 32 | pce->label = _("_Channel:"); | |
| 33 | pce->identifier = "channel"; | |
| 34 | ci = g_list_append(ci, pce); | |
| 35 | ||
| 36 | pce = g_new0(struct proto_chat_entry, 1); | |
| 37 | pce->label = _("_Passphrase:"); | |
| 38 | pce->identifier = "passphrase"; | |
| 39 | pce->secret = TRUE; | |
| 40 | ci = g_list_append(ci, pce); | |
| 41 | ||
| 42 | return ci; | |
| 43 | } | |
| 44 | ||
| 45 | static void | |
| 9038 | 46 | silcgaim_chat_getinfo(GaimConnection *gc, GHashTable *components); |
| 8849 | 47 | |
| 48 | static void | |
| 49 | silcgaim_chat_getinfo_res(SilcClient client, | |
| 50 | SilcClientConnection conn, | |
| 51 | SilcChannelEntry *channels, | |
| 52 | SilcUInt32 channels_count, | |
| 53 | void *context) | |
| 54 | { | |
| 55 | GHashTable *components = context; | |
| 56 | GaimConnection *gc = client->application; | |
| 57 | const char *chname; | |
| 58 | char tmp[256]; | |
| 59 | ||
| 60 | chname = g_hash_table_lookup(components, "channel"); | |
| 61 | if (!chname) | |
| 62 | return; | |
| 63 | ||
| 64 | if (!channels) { | |
| 65 | g_snprintf(tmp, sizeof(tmp), | |
| 66 | _("Channel %s does not exist in the network"), chname); | |
| 67 | gaim_notify_error(gc, _("Channel Information"), | |
| 68 | _("Cannot get channel information"), tmp); | |
| 69 | return; | |
| 70 | } | |
| 71 | ||
| 72 | silcgaim_chat_getinfo(gc, components); | |
| 73 | } | |
| 74 | ||
| 9038 | 75 | |
| 8849 | 76 | static void |
| 9038 | 77 | silcgaim_chat_getinfo(GaimConnection *gc, GHashTable *components) |
| 8849 | 78 | { |
| 9038 | 79 | SilcGaim sg = gc->proto_data; |
| 8849 | 80 | const char *chname; |
| 81 | char *buf, tmp[256]; | |
| 82 | GString *s; | |
| 83 | SilcChannelEntry channel; | |
| 84 | SilcHashTableList htl; | |
| 85 | SilcChannelUser chu; | |
| 86 | ||
| 9038 | 87 | if (!components) |
| 88 | return; | |
| 8849 | 89 | |
| 9038 | 90 | chname = g_hash_table_lookup(components, "channel"); |
| 8849 | 91 | if (!chname) |
| 92 | return; | |
| 93 | channel = silc_client_get_channel(sg->client, sg->conn, | |
| 94 | (char *)chname); | |
| 95 | if (!channel) { | |
| 96 | silc_client_get_channel_resolve(sg->client, sg->conn, | |
| 97 | (char *)chname, | |
| 98 | silcgaim_chat_getinfo_res, | |
| 9038 | 99 | components); |
| 8849 | 100 | return; |
| 101 | } | |
| 102 | ||
| 103 | s = g_string_new(""); | |
| 9275 | 104 | g_string_append_printf(s, _("Channel Name:\t\t%s\n"), channel->channel_name); |
| 8849 | 105 | if (channel->user_list && silc_hash_table_count(channel->user_list)) |
| 9275 | 106 | g_string_append_printf(s, _("User Count:\t\t%d\n"), |
| 8849 | 107 | (int)silc_hash_table_count(channel->user_list)); |
| 108 | ||
| 109 | silc_hash_table_list(channel->user_list, &htl); | |
| 110 | while (silc_hash_table_get(&htl, NULL, (void *)&chu)) { | |
| 111 | if (chu->mode & SILC_CHANNEL_UMODE_CHANFO) { | |
| 9275 | 112 | g_string_append_printf(s, _("Channel Founder:\t%s\n"), |
| 8849 | 113 | chu->client->nickname); |
| 114 | break; | |
| 115 | } | |
| 116 | } | |
| 117 | silc_hash_table_list_reset(&htl); | |
| 118 | ||
| 119 | if (channel->channel_key) | |
| 9275 | 120 | g_string_append_printf(s, _("Channel Cipher:\t\t%s\n"), |
| 8849 | 121 | silc_cipher_get_name(channel->channel_key)); |
| 122 | if (channel->hmac) | |
| 9275 | 123 | g_string_append_printf(s, _("Channel HMAC:\t\t%s\n"), |
| 8849 | 124 | silc_hmac_get_name(channel->hmac)); |
| 125 | ||
| 126 | if (channel->topic) | |
| 9275 | 127 | g_string_append_printf(s, _("\nChannel Topic:\n\t%s\n"), channel->topic); |
| 8849 | 128 | |
| 129 | if (channel->mode) { | |
| 9275 | 130 | g_string_append_printf(s, _("\nChannel Modes:\n")); |
| 8849 | 131 | silcgaim_get_chmode_string(channel->mode, tmp, sizeof(tmp)); |
| 132 | g_string_append_printf(s, tmp); | |
| 133 | g_string_append_printf(s, "\n"); | |
| 134 | } | |
| 135 | ||
| 136 | if (channel->founder_key) { | |
| 137 | char *fingerprint, *babbleprint; | |
| 138 | unsigned char *pk; | |
| 139 | SilcUInt32 pk_len; | |
| 140 | pk = silc_pkcs_public_key_encode(channel->founder_key, &pk_len); | |
| 141 | fingerprint = silc_hash_fingerprint(NULL, pk, pk_len); | |
| 142 | babbleprint = silc_hash_babbleprint(NULL, pk, pk_len); | |
| 143 | ||
| 9275 | 144 | g_string_append_printf(s, _("\nFounder Key Fingerprint:\n%s\n\n"), fingerprint); |
| 145 | g_string_append_printf(s, _("Founder Key Babbleprint:\n%s"), babbleprint); | |
| 8849 | 146 | |
| 147 | silc_free(fingerprint); | |
| 148 | silc_free(babbleprint); | |
| 149 | silc_free(pk); | |
| 150 | } | |
| 151 | ||
| 152 | buf = g_string_free(s, FALSE); | |
| 153 | gaim_notify_message(NULL, GAIM_NOTIFY_MSG_INFO, | |
| 154 | _("Channel Information"), | |
| 155 | _("Channel Information"), | |
| 156 | buf, NULL, NULL); | |
| 157 | g_free(buf); | |
| 158 | } | |
| 159 | ||
| 160 | ||
| 9038 | 161 | static void |
| 162 | silcgaim_chat_getinfo_menu(GaimBlistNode *node, gpointer data) | |
| 163 | { | |
| 9272 | 164 | GaimChat *chat = (GaimChat *)node; |
| 165 | silcgaim_chat_getinfo(chat->account->gc, chat->components); | |
| 9038 | 166 | } |
| 167 | ||
| 168 | ||
| 8849 | 169 | #if 0 /* XXX For now these are not implemented. We need better |
| 170 | listview dialog from Gaim for these. */ | |
| 171 | /************************** Channel Invite List ******************************/ | |
| 172 | ||
| 173 | static void | |
|
9030
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8891
diff
changeset
|
174 | silcgaim_chat_invitelist(GaimBlistNode *node, gpointer data); |
| 8849 | 175 | { |
| 176 | ||
| 177 | } | |
| 178 | ||
| 179 | ||
| 180 | /**************************** Channel Ban List *******************************/ | |
| 181 | ||
| 182 | static void | |
|
9030
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8891
diff
changeset
|
183 | silcgaim_chat_banlist(GaimBlistNode *node, gpointer data); |
| 8849 | 184 | { |
| 185 | ||
| 186 | } | |
| 187 | #endif | |
| 188 | ||
| 189 | ||
| 190 | /************************* Channel Authentication ****************************/ | |
| 191 | ||
| 192 | typedef struct { | |
| 193 | SilcGaim sg; | |
| 194 | SilcChannelEntry channel; | |
| 195 | GaimChat *c; | |
| 196 | SilcBuffer pubkeys; | |
| 197 | } *SilcGaimChauth; | |
| 198 | ||
| 199 | static void | |
| 200 | silcgaim_chat_chpk_add(void *user_data, const char *name) | |
| 201 | { | |
| 202 | SilcGaimChauth sgc = (SilcGaimChauth)user_data; | |
| 203 | SilcGaim sg = sgc->sg; | |
| 204 | SilcClient client = sg->client; | |
| 205 | SilcClientConnection conn = sg->conn; | |
| 206 | SilcPublicKey public_key; | |
| 207 | SilcBuffer chpks, pk, chidp; | |
| 208 | unsigned char mode[4]; | |
| 209 | SilcUInt32 m; | |
| 210 | ||
| 211 | /* Load the public key */ | |
| 212 | if (!silc_pkcs_load_public_key(name, &public_key, SILC_PKCS_FILE_PEM) && | |
| 213 | !silc_pkcs_load_public_key(name, &public_key, SILC_PKCS_FILE_BIN)) { | |
| 214 | silcgaim_chat_chauth_show(sgc->sg, sgc->channel, sgc->pubkeys); | |
| 215 | silc_buffer_free(sgc->pubkeys); | |
| 216 | silc_free(sgc); | |
| 217 | gaim_notify_error(client->application, | |
| 218 | _("Add Channel Public Key"), | |
| 219 | _("Could not load public key"), NULL); | |
| 220 | return; | |
| 221 | } | |
| 222 | ||
| 223 | pk = silc_pkcs_public_key_payload_encode(public_key); | |
| 224 | chpks = silc_buffer_alloc_size(2); | |
| 225 | SILC_PUT16_MSB(1, chpks->head); | |
| 226 | chpks = silc_argument_payload_encode_one(chpks, pk->data, | |
| 227 | pk->len, 0x00); | |
| 228 | silc_buffer_free(pk); | |
| 229 | ||
| 230 | m = sgc->channel->mode; | |
| 231 | m |= SILC_CHANNEL_MODE_CHANNEL_AUTH; | |
| 232 | ||
| 233 | /* Send CMODE */ | |
| 234 | SILC_PUT32_MSB(m, mode); | |
| 235 | chidp = silc_id_payload_encode(sgc->channel->id, SILC_ID_CHANNEL); | |
| 236 | silc_client_command_send(client, conn, SILC_COMMAND_CMODE, | |
| 237 | ++conn->cmd_ident, 3, | |
| 238 | 1, chidp->data, chidp->len, | |
| 239 | 2, mode, sizeof(mode), | |
| 240 | 9, chpks->data, chpks->len); | |
| 241 | silc_buffer_free(chpks); | |
| 242 | silc_buffer_free(chidp); | |
| 243 | silc_buffer_free(sgc->pubkeys); | |
| 244 | silc_free(sgc); | |
| 245 | } | |
| 246 | ||
| 247 | static void | |
| 248 | silcgaim_chat_chpk_cancel(void *user_data, const char *name) | |
| 249 | { | |
| 250 | SilcGaimChauth sgc = (SilcGaimChauth)user_data; | |
| 251 | silcgaim_chat_chauth_show(sgc->sg, sgc->channel, sgc->pubkeys); | |
| 252 | silc_buffer_free(sgc->pubkeys); | |
| 253 | silc_free(sgc); | |
| 254 | } | |
| 255 | ||
| 256 | static void | |
| 257 | silcgaim_chat_chpk_cb(SilcGaimChauth sgc, GaimRequestFields *fields) | |
| 258 | { | |
| 259 | SilcGaim sg = sgc->sg; | |
| 260 | SilcClient client = sg->client; | |
| 261 | SilcClientConnection conn = sg->conn; | |
| 262 | GaimRequestField *f; | |
| 263 | const GList *list; | |
| 264 | SilcPublicKey public_key; | |
| 265 | SilcBuffer chpks, pk, chidp; | |
| 266 | SilcUInt16 c = 0, ct; | |
| 267 | unsigned char mode[4]; | |
| 268 | SilcUInt32 m; | |
| 269 | ||
| 270 | f = gaim_request_fields_get_field(fields, "list"); | |
| 271 | if (!gaim_request_field_list_get_selected(f)) { | |
| 272 | /* Add new public key */ | |
| 8877 | 273 | gaim_request_file(NULL, _("Open Public Key..."), "", |
| 8849 | 274 | G_CALLBACK(silcgaim_chat_chpk_add), |
| 275 | G_CALLBACK(silcgaim_chat_chpk_cancel), sgc); | |
| 276 | return; | |
| 277 | } | |
| 278 | ||
| 279 | list = gaim_request_field_list_get_items(f); | |
| 280 | chpks = silc_buffer_alloc_size(2); | |
| 281 | ||
| 282 | for (ct = 0; list; list = list->next, ct++) { | |
| 283 | public_key = gaim_request_field_list_get_data(f, list->data); | |
| 284 | if (gaim_request_field_list_is_selected(f, list->data)) { | |
| 285 | /* Delete this public key */ | |
| 286 | pk = silc_pkcs_public_key_payload_encode(public_key); | |
| 287 | chpks = silc_argument_payload_encode_one(chpks, pk->data, | |
| 288 | pk->len, 0x01); | |
| 289 | silc_buffer_free(pk); | |
| 290 | c++; | |
| 291 | } | |
| 292 | silc_pkcs_public_key_free(public_key); | |
| 293 | } | |
| 294 | if (!c) { | |
| 295 | silc_buffer_free(chpks); | |
| 296 | return; | |
| 297 | } | |
| 298 | SILC_PUT16_MSB(c, chpks->head); | |
| 299 | ||
| 300 | m = sgc->channel->mode; | |
| 301 | if (ct == c) | |
| 302 | m &= ~SILC_CHANNEL_MODE_CHANNEL_AUTH; | |
| 303 | ||
| 304 | /* Send CMODE */ | |
| 305 | SILC_PUT32_MSB(m, mode); | |
| 306 | chidp = silc_id_payload_encode(sgc->channel->id, SILC_ID_CHANNEL); | |
| 307 | silc_client_command_send(client, conn, SILC_COMMAND_CMODE, | |
| 308 | ++conn->cmd_ident, 3, | |
| 309 | 1, chidp->data, chidp->len, | |
| 310 | 2, mode, sizeof(mode), | |
| 311 | 9, chpks->data, chpks->len); | |
| 312 | silc_buffer_free(chpks); | |
| 313 | silc_buffer_free(chidp); | |
| 314 | silc_buffer_free(sgc->pubkeys); | |
| 315 | silc_free(sgc); | |
| 316 | } | |
| 317 | ||
| 318 | static void | |
| 319 | silcgaim_chat_chauth_ok(SilcGaimChauth sgc, GaimRequestFields *fields) | |
| 320 | { | |
| 321 | SilcGaim sg = sgc->sg; | |
| 322 | GaimRequestField *f; | |
| 323 | const char *curpass, *val; | |
| 324 | int set; | |
| 325 | ||
| 326 | f = gaim_request_fields_get_field(fields, "passphrase"); | |
| 327 | val = gaim_request_field_string_get_value(f); | |
| 328 | curpass = gaim_blist_node_get_string((GaimBlistNode *)sgc->c, "passphrase"); | |
| 329 | ||
| 330 | if (!val && curpass) | |
| 331 | set = 0; | |
| 332 | else if (val && !curpass) | |
| 333 | set = 1; | |
| 334 | else if (val && curpass && strcmp(val, curpass)) | |
| 335 | set = 1; | |
| 336 | else | |
| 337 | set = -1; | |
| 338 | ||
| 339 | if (set == 1) { | |
| 340 | silc_client_command_call(sg->client, sg->conn, NULL, "CMODE", | |
| 341 | sgc->channel->channel_name, "+a", val, NULL); | |
| 342 | gaim_blist_node_set_string((GaimBlistNode *)sgc->c, "passphrase", val); | |
| 343 | } else if (set == 0) { | |
| 344 | silc_client_command_call(sg->client, sg->conn, NULL, "CMODE", | |
| 345 | sgc->channel->channel_name, "-a", NULL); | |
| 346 | gaim_blist_node_remove_setting((GaimBlistNode *)sgc->c, "passphrase"); | |
| 347 | } | |
| 348 | ||
| 349 | silc_buffer_free(sgc->pubkeys); | |
| 350 | silc_free(sgc); | |
| 351 | } | |
| 352 | ||
| 353 | void silcgaim_chat_chauth_show(SilcGaim sg, SilcChannelEntry channel, | |
| 354 | SilcBuffer channel_pubkeys) | |
| 355 | { | |
| 356 | SilcUInt16 argc; | |
| 357 | SilcArgumentPayload chpks; | |
| 358 | unsigned char *pk; | |
| 359 | SilcUInt32 pk_len, type; | |
| 360 | char *fingerprint, *babbleprint; | |
| 361 | SilcPublicKey pubkey; | |
| 362 | SilcPublicKeyIdentifier ident; | |
| 363 | char tmp2[1024], t[512]; | |
| 364 | GaimRequestFields *fields; | |
| 365 | GaimRequestFieldGroup *g; | |
| 366 | GaimRequestField *f; | |
| 367 | SilcGaimChauth sgc; | |
| 368 | const char *curpass = NULL; | |
| 369 | ||
| 370 | sgc = silc_calloc(1, sizeof(*sgc)); | |
| 371 | if (!sgc) | |
| 372 | return; | |
| 373 | sgc->sg = sg; | |
| 374 | sgc->channel = channel; | |
| 375 | ||
| 376 | fields = gaim_request_fields_new(); | |
| 377 | ||
| 378 | if (sgc->c) | |
| 379 | curpass = gaim_blist_node_get_string((GaimBlistNode *)sgc->c, "passphrase"); | |
| 380 | ||
| 381 | g = gaim_request_field_group_new(NULL); | |
| 382 | f = gaim_request_field_string_new("passphrase", _("Channel Passphrase"), | |
| 383 | curpass, FALSE); | |
| 384 | gaim_request_field_string_set_masked(f, TRUE); | |
| 385 | gaim_request_field_group_add_field(g, f); | |
| 386 | gaim_request_fields_add_group(fields, g); | |
| 387 | ||
| 388 | g = gaim_request_field_group_new(NULL); | |
| 389 | f = gaim_request_field_label_new("l1", _("Channel Public Keys List")); | |
| 390 | gaim_request_field_group_add_field(g, f); | |
| 391 | gaim_request_fields_add_group(fields, g); | |
| 392 | ||
| 393 | g_snprintf(t, sizeof(t), | |
| 394 | _("Channel authentication is used to secure the channel from " | |
| 395 | "unauthorized access. The authentication may be based on " | |
| 396 | "passphrase and digital signatures. If passphrase is set, it " | |
| 397 | "is required to be able to join. If channel public keys are set " | |
| 398 | "then only users whose public keys are listed are able to join.")); | |
| 399 | ||
| 400 | if (!channel_pubkeys) { | |
| 401 | f = gaim_request_field_list_new("list", NULL); | |
| 402 | gaim_request_field_group_add_field(g, f); | |
| 403 | gaim_request_fields(NULL, _("Channel Authentication"), | |
| 404 | _("Channel Authentication"), t, fields, | |
| 9275 | 405 | _("Add / Remove"), G_CALLBACK(silcgaim_chat_chpk_cb), |
| 406 | _("OK"), G_CALLBACK(silcgaim_chat_chauth_ok), sgc); | |
| 8849 | 407 | return; |
| 408 | } | |
| 409 | sgc->pubkeys = silc_buffer_copy(channel_pubkeys); | |
| 410 | ||
| 411 | g = gaim_request_field_group_new(NULL); | |
| 412 | f = gaim_request_field_list_new("list", NULL); | |
| 413 | gaim_request_field_group_add_field(g, f); | |
| 414 | gaim_request_fields_add_group(fields, g); | |
| 415 | ||
| 416 | SILC_GET16_MSB(argc, channel_pubkeys->data); | |
| 417 | chpks = silc_argument_payload_parse(channel_pubkeys->data + 2, | |
| 418 | channel_pubkeys->len - 2, argc); | |
| 419 | if (!chpks) | |
| 420 | return; | |
| 421 | ||
| 422 | pk = silc_argument_get_first_arg(chpks, &type, &pk_len); | |
| 423 | while (pk) { | |
| 424 | fingerprint = silc_hash_fingerprint(NULL, pk + 4, pk_len - 4); | |
| 425 | babbleprint = silc_hash_babbleprint(NULL, pk + 4, pk_len - 4); | |
| 426 | silc_pkcs_public_key_payload_decode(pk, pk_len, &pubkey); | |
| 427 | ident = silc_pkcs_decode_identifier(pubkey->identifier); | |
| 428 | ||
| 429 | g_snprintf(tmp2, sizeof(tmp2), "%s\n %s\n %s", | |
| 430 | ident->realname ? ident->realname : ident->username ? | |
| 431 | ident->username : "", fingerprint, babbleprint); | |
| 432 | gaim_request_field_list_add(f, tmp2, pubkey); | |
| 433 | ||
| 434 | silc_free(fingerprint); | |
| 435 | silc_free(babbleprint); | |
| 436 | silc_pkcs_free_identifier(ident); | |
| 437 | pk = silc_argument_get_next_arg(chpks, &type, &pk_len); | |
| 438 | } | |
| 439 | ||
| 440 | gaim_request_field_list_set_multi_select(f, FALSE); | |
| 441 | gaim_request_fields(NULL, _("Channel Authentication"), | |
| 442 | _("Channel Authentication"), t, fields, | |
| 9275 | 443 | _("Add / Remove"), G_CALLBACK(silcgaim_chat_chpk_cb), |
| 444 | _("OK"), G_CALLBACK(silcgaim_chat_chauth_ok), sgc); | |
| 8849 | 445 | |
| 446 | silc_argument_payload_free(chpks); | |
| 447 | } | |
| 448 | ||
| 449 | static void | |
|
9030
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8891
diff
changeset
|
450 | silcgaim_chat_chauth(GaimBlistNode *node, gpointer data) |
| 8849 | 451 | { |
|
9030
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8891
diff
changeset
|
452 | GaimChat *chat; |
|
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8891
diff
changeset
|
453 | GaimConnection *gc; |
|
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8891
diff
changeset
|
454 | SilcGaim sg; |
|
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8891
diff
changeset
|
455 | |
|
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8891
diff
changeset
|
456 | g_return_if_fail(GAIM_BLIST_NODE_IS_CHAT(node)); |
|
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8891
diff
changeset
|
457 | |
|
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8891
diff
changeset
|
458 | chat = (GaimChat *) node; |
|
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8891
diff
changeset
|
459 | gc = gaim_account_get_connection(chat->account); |
|
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8891
diff
changeset
|
460 | sg = gc->proto_data; |
|
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8891
diff
changeset
|
461 | |
| 8849 | 462 | silc_client_command_call(sg->client, sg->conn, NULL, "CMODE", |
|
9030
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8891
diff
changeset
|
463 | g_hash_table_lookup(chat->components, "channel"), |
| 8849 | 464 | "+C", NULL); |
| 465 | } | |
| 466 | ||
| 467 | ||
| 468 | /************************** Channel Private Groups **************************/ | |
| 469 | ||
| 470 | /* Private groups are "virtual" channels. They are groups inside a channel. | |
| 471 | This is implemented by using channel private keys. By knowing a channel | |
| 472 | private key user becomes part of that group and is able to talk on that | |
| 473 | group. Other users, on the same channel, won't be able to see the | |
| 474 | messages of that group. It is possible to have multiple groups inside | |
| 475 | a channel - and thus having multiple private keys on the channel. */ | |
| 476 | ||
| 477 | typedef struct { | |
| 478 | SilcGaim sg; | |
| 479 | GaimChat *c; | |
| 480 | const char *channel; | |
| 481 | } *SilcGaimCharPrv; | |
| 482 | ||
| 483 | static void | |
| 484 | silcgaim_chat_prv_add(SilcGaimCharPrv p, GaimRequestFields *fields) | |
| 485 | { | |
| 486 | SilcGaim sg = p->sg; | |
| 487 | char tmp[512]; | |
| 488 | GaimRequestField *f; | |
| 489 | const char *name, *passphrase, *alias; | |
| 490 | GHashTable *comp; | |
| 491 | GaimGroup *g; | |
| 492 | GaimChat *cn; | |
| 493 | ||
| 494 | f = gaim_request_fields_get_field(fields, "name"); | |
| 495 | name = gaim_request_field_string_get_value(f); | |
| 496 | if (!name) { | |
| 497 | silc_free(p); | |
| 498 | return; | |
| 499 | } | |
| 500 | f = gaim_request_fields_get_field(fields, "passphrase"); | |
| 501 | passphrase = gaim_request_field_string_get_value(f); | |
| 502 | f = gaim_request_fields_get_field(fields, "alias"); | |
| 503 | alias = gaim_request_field_string_get_value(f); | |
| 504 | ||
| 505 | /* Add private group to buddy list */ | |
| 506 | g_snprintf(tmp, sizeof(tmp), "%s [Private Group]", name); | |
| 507 | comp = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free); | |
| 508 | g_hash_table_replace(comp, g_strdup("channel"), g_strdup(tmp)); | |
| 509 | g_hash_table_replace(comp, g_strdup("passphrase"), g_strdup(passphrase)); | |
| 510 | ||
| 511 | cn = gaim_chat_new(sg->account, alias, comp); | |
| 512 | g = (GaimGroup *)p->c->node.parent; | |
| 513 | gaim_blist_add_chat(cn, g, (GaimBlistNode *)p->c); | |
| 514 | ||
| 515 | /* Associate to a real channel */ | |
| 516 | gaim_blist_node_set_string((GaimBlistNode *)cn, "parentch", p->channel); | |
| 517 | ||
| 518 | /* Join the group */ | |
| 519 | silcgaim_chat_join(sg->gc, comp); | |
| 520 | ||
| 521 | silc_free(p); | |
| 522 | } | |
| 523 | ||
| 524 | static void | |
| 525 | silcgaim_chat_prv_cancel(SilcGaimCharPrv p, GaimRequestFields *fields) | |
| 526 | { | |
| 527 | silc_free(p); | |
| 528 | } | |
| 529 | ||
| 530 | static void | |
|
9030
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8891
diff
changeset
|
531 | silcgaim_chat_prv(GaimBlistNode *node, gpointer data) |
| 8849 | 532 | { |
|
9030
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8891
diff
changeset
|
533 | GaimChat *chat; |
|
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8891
diff
changeset
|
534 | GaimConnection *gc; |
|
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8891
diff
changeset
|
535 | SilcGaim sg; |
|
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8891
diff
changeset
|
536 | |
| 8849 | 537 | SilcGaimCharPrv p; |
| 538 | GaimRequestFields *fields; | |
| 539 | GaimRequestFieldGroup *g; | |
| 540 | GaimRequestField *f; | |
| 541 | char tmp[512]; | |
| 542 | ||
|
9030
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8891
diff
changeset
|
543 | g_return_if_fail(GAIM_BLIST_NODE_IS_CHAT(node)); |
|
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8891
diff
changeset
|
544 | |
|
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8891
diff
changeset
|
545 | chat = (GaimChat *) node; |
|
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8891
diff
changeset
|
546 | gc = gaim_account_get_connection(chat->account); |
|
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8891
diff
changeset
|
547 | sg = gc->proto_data; |
|
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8891
diff
changeset
|
548 | |
| 8849 | 549 | p = silc_calloc(1, sizeof(*p)); |
| 550 | if (!p) | |
| 551 | return; | |
| 552 | p->sg = sg; | |
| 553 | ||
|
9030
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8891
diff
changeset
|
554 | p->channel = g_hash_table_lookup(chat->components, "channel"); |
| 8849 | 555 | p->c = gaim_blist_find_chat(sg->account, p->channel); |
| 556 | ||
| 557 | fields = gaim_request_fields_new(); | |
| 558 | ||
| 559 | g = gaim_request_field_group_new(NULL); | |
| 560 | f = gaim_request_field_string_new("name", _("Group Name"), | |
| 561 | NULL, FALSE); | |
| 562 | gaim_request_field_group_add_field(g, f); | |
| 563 | ||
| 564 | f = gaim_request_field_string_new("passphrase", _("Passphrase"), | |
| 565 | NULL, FALSE); | |
| 566 | gaim_request_field_string_set_masked(f, TRUE); | |
| 567 | gaim_request_field_group_add_field(g, f); | |
| 568 | ||
| 569 | f = gaim_request_field_string_new("alias", _("Alias"), | |
| 570 | NULL, FALSE); | |
| 571 | gaim_request_field_group_add_field(g, f); | |
| 572 | gaim_request_fields_add_group(fields, g); | |
| 573 | ||
| 574 | g_snprintf(tmp, sizeof(tmp), | |
| 575 | _("Please enter the %s channel private group name and passphrase."), | |
| 576 | p->channel); | |
| 577 | gaim_request_fields(NULL, _("Add Channel Private Group"), NULL, tmp, fields, | |
| 9275 | 578 | _("Add"), G_CALLBACK(silcgaim_chat_prv_add), |
| 579 | _("Cancel"), G_CALLBACK(silcgaim_chat_prv_cancel), p); | |
| 8849 | 580 | } |
| 581 | ||
| 582 | ||
| 583 | /****************************** Channel Modes ********************************/ | |
| 584 | ||
| 585 | static void | |
|
9030
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8891
diff
changeset
|
586 | silcgaim_chat_permanent_reset(GaimBlistNode *node, gpointer data) |
| 8849 | 587 | { |
|
9030
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8891
diff
changeset
|
588 | GaimChat *chat; |
|
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8891
diff
changeset
|
589 | GaimConnection *gc; |
|
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8891
diff
changeset
|
590 | SilcGaim sg; |
|
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8891
diff
changeset
|
591 | |
|
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8891
diff
changeset
|
592 | g_return_if_fail(GAIM_BLIST_NODE_IS_CHAT(node)); |
|
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8891
diff
changeset
|
593 | |
|
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8891
diff
changeset
|
594 | chat = (GaimChat *) node; |
|
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8891
diff
changeset
|
595 | gc = gaim_account_get_connection(chat->account); |
|
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8891
diff
changeset
|
596 | sg = gc->proto_data; |
|
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8891
diff
changeset
|
597 | |
| 8849 | 598 | silc_client_command_call(sg->client, sg->conn, NULL, "CMODE", |
|
9030
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8891
diff
changeset
|
599 | g_hash_table_lookup(chat->components, "channel"), |
| 8849 | 600 | "-f", NULL); |
| 601 | } | |
| 602 | ||
| 603 | static void | |
|
9030
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8891
diff
changeset
|
604 | silcgaim_chat_permanent(GaimBlistNode *node, gpointer data) |
| 8849 | 605 | { |
|
9030
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8891
diff
changeset
|
606 | GaimChat *chat; |
|
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8891
diff
changeset
|
607 | GaimConnection *gc; |
|
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8891
diff
changeset
|
608 | SilcGaim sg; |
| 8849 | 609 | const char *channel; |
| 610 | ||
|
9030
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8891
diff
changeset
|
611 | g_return_if_fail(GAIM_BLIST_NODE_IS_CHAT(node)); |
|
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8891
diff
changeset
|
612 | |
|
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8891
diff
changeset
|
613 | chat = (GaimChat *) node; |
|
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8891
diff
changeset
|
614 | gc = gaim_account_get_connection(chat->account); |
|
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8891
diff
changeset
|
615 | sg = gc->proto_data; |
|
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8891
diff
changeset
|
616 | |
| 8849 | 617 | if (!sg->conn) |
| 618 | return; | |
| 619 | ||
| 620 | /* XXX we should have ability to define which founder | |
| 621 | key to use. Now we use the user's own public key | |
| 622 | (default key). */ | |
| 623 | ||
| 624 | /* Call CMODE */ | |
|
9030
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8891
diff
changeset
|
625 | channel = g_hash_table_lookup(chat->components, "channel"); |
| 8849 | 626 | silc_client_command_call(sg->client, sg->conn, NULL, "CMODE", channel, |
| 627 | "+f", NULL); | |
| 628 | } | |
| 629 | ||
| 630 | typedef struct { | |
| 631 | SilcGaim sg; | |
| 632 | const char *channel; | |
| 633 | } *SilcGaimChatInput; | |
| 634 | ||
| 635 | static void | |
| 636 | silcgaim_chat_ulimit_cb(SilcGaimChatInput s, const char *limit) | |
| 637 | { | |
| 638 | SilcChannelEntry channel; | |
| 639 | int ulimit = 0; | |
| 640 | ||
| 641 | channel = silc_client_get_channel(s->sg->client, s->sg->conn, | |
| 642 | (char *)s->channel); | |
| 643 | if (!channel) | |
| 644 | return; | |
| 645 | if (limit) | |
| 646 | ulimit = atoi(limit); | |
| 647 | ||
| 648 | if (!limit || !(*limit) || *limit == '0') { | |
| 649 | if (limit && ulimit == channel->user_limit) { | |
| 650 | silc_free(s); | |
| 651 | return; | |
| 652 | } | |
| 653 | silc_client_command_call(s->sg->client, s->sg->conn, NULL, "CMODE", | |
| 654 | s->channel, "-l", NULL); | |
| 655 | ||
| 656 | silc_free(s); | |
| 657 | return; | |
| 658 | } | |
| 659 | ||
| 660 | if (ulimit == channel->user_limit) { | |
| 661 | silc_free(s); | |
| 662 | return; | |
| 663 | } | |
| 664 | ||
| 665 | /* Call CMODE */ | |
| 666 | silc_client_command_call(s->sg->client, s->sg->conn, NULL, "CMODE", | |
| 667 | s->channel, "+l", limit, NULL); | |
| 668 | ||
| 669 | silc_free(s); | |
| 670 | } | |
| 671 | ||
| 672 | static void | |
|
9030
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8891
diff
changeset
|
673 | silcgaim_chat_ulimit(GaimBlistNode *node, gpointer data) |
| 8849 | 674 | { |
|
9030
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8891
diff
changeset
|
675 | GaimChat *chat; |
|
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8891
diff
changeset
|
676 | GaimConnection *gc; |
|
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8891
diff
changeset
|
677 | SilcGaim sg; |
|
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8891
diff
changeset
|
678 | |
| 8849 | 679 | SilcGaimChatInput s; |
| 680 | SilcChannelEntry channel; | |
| 681 | const char *ch; | |
| 682 | char tmp[32]; | |
| 683 | ||
|
9030
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8891
diff
changeset
|
684 | g_return_if_fail(GAIM_BLIST_NODE_IS_CHAT(node)); |
|
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8891
diff
changeset
|
685 | |
|
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8891
diff
changeset
|
686 | chat = (GaimChat *) node; |
|
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8891
diff
changeset
|
687 | gc = gaim_account_get_connection(chat->account); |
|
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8891
diff
changeset
|
688 | sg = gc->proto_data; |
|
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8891
diff
changeset
|
689 | |
| 8849 | 690 | if (!sg->conn) |
| 691 | return; | |
| 692 | ||
|
9030
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8891
diff
changeset
|
693 | ch = g_strdup(g_hash_table_lookup(chat->components, "channel")); |
| 8849 | 694 | channel = silc_client_get_channel(sg->client, sg->conn, (char *)ch); |
| 695 | if (!channel) | |
| 696 | return; | |
| 697 | ||
| 698 | s = silc_calloc(1, sizeof(*s)); | |
| 699 | if (!s) | |
| 700 | return; | |
| 701 | s->channel = ch; | |
| 702 | s->sg = sg; | |
| 703 | g_snprintf(tmp, sizeof(tmp), "%d", (int)channel->user_limit); | |
| 704 | gaim_request_input(NULL, _("User Limit"), NULL, | |
| 705 | _("Set user limit on channel. Set to zero to reset user limit."), | |
| 706 | tmp, FALSE, FALSE, NULL, | |
| 707 | _("OK"), G_CALLBACK(silcgaim_chat_ulimit_cb), | |
| 708 | _("Cancel"), G_CALLBACK(silcgaim_chat_ulimit_cb), s); | |
| 709 | } | |
| 710 | ||
| 711 | static void | |
|
9030
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8891
diff
changeset
|
712 | silcgaim_chat_resettopic(GaimBlistNode *node, gpointer data) |
| 8849 | 713 | { |
|
9030
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8891
diff
changeset
|
714 | GaimChat *chat; |
|
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8891
diff
changeset
|
715 | GaimConnection *gc; |
|
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8891
diff
changeset
|
716 | SilcGaim sg; |
|
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8891
diff
changeset
|
717 | |
|
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8891
diff
changeset
|
718 | g_return_if_fail(GAIM_BLIST_NODE_IS_CHAT(node)); |
|
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8891
diff
changeset
|
719 | |
|
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8891
diff
changeset
|
720 | chat = (GaimChat *) node; |
|
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8891
diff
changeset
|
721 | gc = gaim_account_get_connection(chat->account); |
|
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8891
diff
changeset
|
722 | sg = gc->proto_data; |
|
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8891
diff
changeset
|
723 | |
| 8849 | 724 | silc_client_command_call(sg->client, sg->conn, NULL, "CMODE", |
|
9030
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8891
diff
changeset
|
725 | g_hash_table_lookup(chat->components, "channel"), |
| 8849 | 726 | "-t", NULL); |
| 727 | } | |
| 728 | ||
| 729 | static void | |
|
9030
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8891
diff
changeset
|
730 | silcgaim_chat_settopic(GaimBlistNode *node, gpointer data) |
| 8849 | 731 | { |
|
9030
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8891
diff
changeset
|
732 | GaimChat *chat; |
|
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8891
diff
changeset
|
733 | GaimConnection *gc; |
|
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8891
diff
changeset
|
734 | SilcGaim sg; |
|
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8891
diff
changeset
|
735 | |
|
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8891
diff
changeset
|
736 | g_return_if_fail(GAIM_BLIST_NODE_IS_CHAT(node)); |
|
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8891
diff
changeset
|
737 | |
|
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8891
diff
changeset
|
738 | chat = (GaimChat *) node; |
|
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8891
diff
changeset
|
739 | gc = gaim_account_get_connection(chat->account); |
|
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8891
diff
changeset
|
740 | sg = gc->proto_data; |
|
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8891
diff
changeset
|
741 | |
| 8849 | 742 | silc_client_command_call(sg->client, sg->conn, NULL, "CMODE", |
|
9030
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8891
diff
changeset
|
743 | g_hash_table_lookup(chat->components, "channel"), |
| 8849 | 744 | "+t", NULL); |
| 745 | } | |
| 746 | ||
| 747 | static void | |
|
9030
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8891
diff
changeset
|
748 | silcgaim_chat_resetprivate(GaimBlistNode *node, gpointer data) |
| 8849 | 749 | { |
|
9030
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8891
diff
changeset
|
750 | GaimChat *chat; |
|
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8891
diff
changeset
|
751 | GaimConnection *gc; |
|
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8891
diff
changeset
|
752 | SilcGaim sg; |
|
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8891
diff
changeset
|
753 | |
|
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8891
diff
changeset
|
754 | g_return_if_fail(GAIM_BLIST_NODE_IS_CHAT(node)); |
|
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8891
diff
changeset
|
755 | |
|
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8891
diff
changeset
|
756 | chat = (GaimChat *) node; |
|
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8891
diff
changeset
|
757 | gc = gaim_account_get_connection(chat->account); |
|
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8891
diff
changeset
|
758 | sg = gc->proto_data; |
|
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8891
diff
changeset
|
759 | |
| 8849 | 760 | silc_client_command_call(sg->client, sg->conn, NULL, "CMODE", |
|
9030
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8891
diff
changeset
|
761 | g_hash_table_lookup(chat->components, "channel"), |
| 8849 | 762 | "-p", NULL); |
| 763 | } | |
| 764 | ||
| 765 | static void | |
|
9030
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8891
diff
changeset
|
766 | silcgaim_chat_setprivate(GaimBlistNode *node, gpointer data) |
| 8849 | 767 | { |
|
9030
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8891
diff
changeset
|
768 | GaimChat *chat; |
|
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8891
diff
changeset
|
769 | GaimConnection *gc; |
|
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8891
diff
changeset
|
770 | SilcGaim sg; |
|
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8891
diff
changeset
|
771 | |
|
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8891
diff
changeset
|
772 | g_return_if_fail(GAIM_BLIST_NODE_IS_CHAT(node)); |
|
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8891
diff
changeset
|
773 | |
|
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8891
diff
changeset
|
774 | chat = (GaimChat *) node; |
|
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8891
diff
changeset
|
775 | gc = gaim_account_get_connection(chat->account); |
|
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8891
diff
changeset
|
776 | sg = gc->proto_data; |
|
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8891
diff
changeset
|
777 | |
| 8849 | 778 | silc_client_command_call(sg->client, sg->conn, NULL, "CMODE", |
|
9030
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8891
diff
changeset
|
779 | g_hash_table_lookup(chat->components, "channel"), |
| 8849 | 780 | "+p", NULL); |
| 781 | } | |
| 782 | ||
| 783 | static void | |
|
9030
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8891
diff
changeset
|
784 | silcgaim_chat_resetsecret(GaimBlistNode *node, gpointer data) |
| 8849 | 785 | { |
|
9030
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8891
diff
changeset
|
786 | GaimChat *chat; |
|
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8891
diff
changeset
|
787 | GaimConnection *gc; |
|
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8891
diff
changeset
|
788 | SilcGaim sg; |
|
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8891
diff
changeset
|
789 | |
|
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8891
diff
changeset
|
790 | g_return_if_fail(GAIM_BLIST_NODE_IS_CHAT(node)); |
|
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8891
diff
changeset
|
791 | |
|
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8891
diff
changeset
|
792 | chat = (GaimChat *) node; |
|
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8891
diff
changeset
|
793 | gc = gaim_account_get_connection(chat->account); |
|
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8891
diff
changeset
|
794 | sg = gc->proto_data; |
|
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8891
diff
changeset
|
795 | |
| 8849 | 796 | silc_client_command_call(sg->client, sg->conn, NULL, "CMODE", |
|
9030
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8891
diff
changeset
|
797 | g_hash_table_lookup(chat->components, "channel"), |
| 8849 | 798 | "-s", NULL); |
| 799 | } | |
| 800 | ||
| 801 | static void | |
|
9030
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8891
diff
changeset
|
802 | silcgaim_chat_setsecret(GaimBlistNode *node, gpointer data) |
| 8849 | 803 | { |
|
9030
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8891
diff
changeset
|
804 | GaimChat *chat; |
|
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8891
diff
changeset
|
805 | GaimConnection *gc; |
|
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8891
diff
changeset
|
806 | SilcGaim sg; |
|
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8891
diff
changeset
|
807 | |
|
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8891
diff
changeset
|
808 | g_return_if_fail(GAIM_BLIST_NODE_IS_CHAT(node)); |
|
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8891
diff
changeset
|
809 | |
|
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8891
diff
changeset
|
810 | chat = (GaimChat *) node; |
|
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8891
diff
changeset
|
811 | gc = gaim_account_get_connection(chat->account); |
|
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8891
diff
changeset
|
812 | sg = gc->proto_data; |
|
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8891
diff
changeset
|
813 | |
| 8849 | 814 | silc_client_command_call(sg->client, sg->conn, NULL, "CMODE", |
|
9030
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8891
diff
changeset
|
815 | g_hash_table_lookup(chat->components, "channel"), |
| 8849 | 816 | "+s", NULL); |
| 817 | } | |
| 818 | ||
|
9030
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8891
diff
changeset
|
819 | GList *silcgaim_chat_menu(GaimChat *chat) |
| 8849 | 820 | { |
| 9038 | 821 | GHashTable *components = chat->components; |
|
9030
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8891
diff
changeset
|
822 | GaimConnection *gc = gaim_account_get_connection(chat->account); |
| 8849 | 823 | SilcGaim sg = gc->proto_data; |
| 824 | SilcClientConnection conn = sg->conn; | |
| 825 | const char *chname = NULL; | |
| 826 | SilcChannelEntry channel = NULL; | |
| 827 | SilcChannelUser chu = NULL; | |
| 828 | SilcUInt32 mode = 0; | |
| 829 | ||
| 9038 | 830 | GList *m = NULL; |
|
9030
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8891
diff
changeset
|
831 | GaimBlistNodeAction *act; |
|
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8891
diff
changeset
|
832 | |
| 8849 | 833 | if (components) |
| 834 | chname = g_hash_table_lookup(components, "channel"); | |
| 835 | if (chname) | |
| 836 | channel = silc_client_get_channel(sg->client, sg->conn, | |
| 837 | (char *)chname); | |
| 838 | if (channel) { | |
| 839 | chu = silc_client_on_channel(channel, conn->local_entry); | |
| 840 | if (chu) | |
| 841 | mode = chu->mode; | |
| 842 | } | |
| 843 | ||
| 844 | if (strstr(chname, "[Private Group]")) | |
| 845 | return NULL; | |
| 846 | ||
|
9030
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8891
diff
changeset
|
847 | act = gaim_blist_node_action_new(_("Get Info"), |
| 9038 | 848 | silcgaim_chat_getinfo_menu, NULL); |
|
9030
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8891
diff
changeset
|
849 | m = g_list_append(m, act); |
| 8849 | 850 | |
| 851 | #if 0 /* XXX For now these are not implemented. We need better | |
| 852 | listview dialog from Gaim for these. */ | |
| 853 | if (mode & SILC_CHANNEL_UMODE_CHANOP) { | |
|
9030
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8891
diff
changeset
|
854 | act = gaim_blist_node_action_new(_("Invite List"), |
|
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8891
diff
changeset
|
855 | silcgaim_chat_invitelist, NULL); |
|
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8891
diff
changeset
|
856 | m = g_list_append(m, act); |
| 8849 | 857 | |
|
9030
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8891
diff
changeset
|
858 | act = gaim_blist_node_action_new(_("Ban List"), |
|
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8891
diff
changeset
|
859 | silcgaim_chat_banlist, NULL); |
|
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8891
diff
changeset
|
860 | m = g_list_append(m, act); |
| 8849 | 861 | } |
| 862 | #endif | |
| 863 | ||
| 864 | if (chu) { | |
|
9030
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8891
diff
changeset
|
865 | act = gaim_blist_node_action_new(_("Add Private Group"), |
|
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8891
diff
changeset
|
866 | silcgaim_chat_prv, NULL); |
|
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8891
diff
changeset
|
867 | m = g_list_append(m, act); |
| 8849 | 868 | } |
| 869 | ||
| 870 | if (mode & SILC_CHANNEL_UMODE_CHANFO) { | |
|
9030
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8891
diff
changeset
|
871 | act = gaim_blist_node_action_new(_("Channel Authentication"), |
|
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8891
diff
changeset
|
872 | silcgaim_chat_chauth, NULL); |
|
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8891
diff
changeset
|
873 | m = g_list_append(m, act); |
| 8849 | 874 | |
| 875 | if (channel->mode & SILC_CHANNEL_MODE_FOUNDER_AUTH) { | |
|
9030
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8891
diff
changeset
|
876 | act = gaim_blist_node_action_new(_("Reset Permanent"), |
|
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8891
diff
changeset
|
877 | silcgaim_chat_permanent_reset, NULL); |
|
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8891
diff
changeset
|
878 | m = g_list_append(m, act); |
| 8849 | 879 | } else { |
|
9030
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8891
diff
changeset
|
880 | act = gaim_blist_node_action_new(_("Set Permanent"), |
|
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8891
diff
changeset
|
881 | silcgaim_chat_permanent, NULL); |
|
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8891
diff
changeset
|
882 | m = g_list_append(m, act); |
| 8849 | 883 | } |
| 884 | } | |
| 885 | ||
| 886 | if (mode & SILC_CHANNEL_UMODE_CHANOP) { | |
|
9030
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8891
diff
changeset
|
887 | act = gaim_blist_node_action_new(_("Set User Limit"), |
|
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8891
diff
changeset
|
888 | silcgaim_chat_ulimit, NULL); |
|
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8891
diff
changeset
|
889 | m = g_list_append(m, act); |
| 8849 | 890 | |
| 891 | if (channel->mode & SILC_CHANNEL_MODE_TOPIC) { | |
|
9030
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8891
diff
changeset
|
892 | act = gaim_blist_node_action_new(_("Reset Topic Restriction"), |
|
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8891
diff
changeset
|
893 | silcgaim_chat_resettopic, NULL); |
|
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8891
diff
changeset
|
894 | m = g_list_append(m, act); |
| 8849 | 895 | } else { |
|
9030
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8891
diff
changeset
|
896 | act = gaim_blist_node_action_new(_("Set Topic Restriction"), |
|
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8891
diff
changeset
|
897 | silcgaim_chat_settopic, NULL); |
|
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8891
diff
changeset
|
898 | m = g_list_append(m, act); |
| 8849 | 899 | } |
| 900 | ||
| 901 | if (channel->mode & SILC_CHANNEL_MODE_PRIVATE) { | |
|
9030
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8891
diff
changeset
|
902 | act = gaim_blist_node_action_new(_("Reset Private Channel"), |
|
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8891
diff
changeset
|
903 | silcgaim_chat_resetprivate, NULL); |
|
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8891
diff
changeset
|
904 | m = g_list_append(m, act); |
| 8849 | 905 | } else { |
|
9030
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8891
diff
changeset
|
906 | act = gaim_blist_node_action_new(_("Set Private Channel"), |
|
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8891
diff
changeset
|
907 | silcgaim_chat_setprivate, NULL); |
|
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8891
diff
changeset
|
908 | m = g_list_append(m, act); |
| 8849 | 909 | } |
| 910 | ||
| 911 | if (channel->mode & SILC_CHANNEL_MODE_SECRET) { | |
|
9030
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8891
diff
changeset
|
912 | act = gaim_blist_node_action_new(_("Reset Secret Channel"), |
|
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8891
diff
changeset
|
913 | silcgaim_chat_resetsecret, NULL); |
|
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8891
diff
changeset
|
914 | m = g_list_append(m, act); |
| 8849 | 915 | } else { |
|
9030
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8891
diff
changeset
|
916 | act = gaim_blist_node_action_new(_("Set Secret Channel"), |
|
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8891
diff
changeset
|
917 | silcgaim_chat_setsecret, NULL); |
|
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8891
diff
changeset
|
918 | m = g_list_append(m, act); |
| 8849 | 919 | } |
| 920 | } | |
| 921 | ||
| 922 | return m; | |
| 923 | } | |
| 924 | ||
| 925 | ||
| 926 | /******************************* Joining Etc. ********************************/ | |
| 927 | ||
| 928 | void silcgaim_chat_join_done(SilcClient client, | |
| 929 | SilcClientConnection conn, | |
| 930 | SilcClientEntry *clients, | |
| 931 | SilcUInt32 clients_count, | |
| 932 | void *context) | |
| 933 | { | |
| 934 | GaimConnection *gc = client->application; | |
| 935 | SilcGaim sg = gc->proto_data; | |
| 936 | SilcChannelEntry channel = context; | |
| 937 | GaimConversation *convo; | |
| 938 | SilcUInt32 retry = SILC_PTR_TO_32(channel->context); | |
| 939 | SilcHashTableList htl; | |
| 940 | SilcChannelUser chu; | |
| 941 | GList *users = NULL; | |
| 942 | char tmp[256]; | |
| 943 | ||
| 944 | if (!clients && retry < 1) { | |
| 945 | /* Resolving users failed, try again. */ | |
| 946 | channel->context = SILC_32_TO_PTR(retry + 1); | |
| 947 | silc_client_get_clients_by_channel(client, conn, channel, | |
| 948 | silcgaim_chat_join_done, channel); | |
| 949 | return; | |
| 950 | } | |
| 951 | ||
| 952 | /* Add channel to Gaim */ | |
| 953 | channel->context = SILC_32_TO_PTR(++sg->channel_ids); | |
| 954 | serv_got_joined_chat(gc, sg->channel_ids, channel->channel_name); | |
| 955 | convo = gaim_find_conversation_with_account(channel->channel_name, | |
| 956 | sg->account); | |
| 957 | if (!convo) | |
| 958 | return; | |
| 959 | ||
| 960 | /* Add all users to channel */ | |
| 961 | silc_hash_table_list(channel->user_list, &htl); | |
| 962 | while (silc_hash_table_get(&htl, NULL, (void *)&chu)) { | |
| 963 | if (!chu->client->nickname) | |
| 964 | continue; | |
| 965 | chu->context = SILC_32_TO_PTR(sg->channel_ids); | |
| 966 | ||
| 967 | #if 0 /* XXX don't append mode char to nick because Gaim doesn't | |
| 968 | give a way to change it afterwards when mode changes. */ | |
| 969 | tmp2 = silc_client_chumode_char(chu->mode); | |
| 970 | if (tmp2) | |
| 8891 | 971 | g_snprintf(tmp, sizeof(tmp), "%s%s", tmp2, |
| 8849 | 972 | chu->client->nickname); |
| 973 | else | |
| 8891 | 974 | g_snprintf(tmp, sizeof(tmp), "%s", |
| 8849 | 975 | chu->client->nickname); |
| 976 | silc_free(tmp2); | |
| 977 | ||
| 978 | users = g_list_append(users, g_strdup(tmp)); | |
| 979 | #else | |
| 980 | users = g_list_append(users, g_strdup(chu->client->nickname)); | |
| 981 | #endif | |
| 982 | ||
| 983 | if (chu->mode & SILC_CHANNEL_UMODE_CHANFO) { | |
| 984 | if (chu->client == conn->local_entry) | |
| 985 | g_snprintf(tmp, sizeof(tmp), | |
| 986 | _("You are channel founder on <I>%s</I>"), | |
| 987 | channel->channel_name); | |
| 988 | else | |
| 989 | g_snprintf(tmp, sizeof(tmp), | |
| 990 | _("Channel founder on <I>%s</I> is <I>%s</I>"), | |
| 991 | channel->channel_name, chu->client->nickname); | |
| 992 | ||
| 993 | gaim_conversation_write(convo, NULL, tmp, | |
| 994 | GAIM_MESSAGE_SYSTEM, time(NULL)); | |
| 995 | ||
| 996 | } | |
| 997 | } | |
| 998 | silc_hash_table_list_reset(&htl); | |
| 999 | ||
| 1000 | gaim_conv_chat_add_users(GAIM_CONV_CHAT(convo), users); | |
| 1001 | g_list_free(users); | |
| 1002 | ||
| 1003 | /* Set topic */ | |
| 1004 | if (channel->topic) | |
| 1005 | gaim_conv_chat_set_topic(GAIM_CONV_CHAT(convo), NULL, channel->topic); | |
|
9353
ff6546387358
[gaim-migrate @ 10161]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9295
diff
changeset
|
1006 | |
|
ff6546387358
[gaim-migrate @ 10161]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9295
diff
changeset
|
1007 | /* Set nick */ |
|
ff6546387358
[gaim-migrate @ 10161]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9295
diff
changeset
|
1008 | gaim_conv_chat_set_nick(GAIM_CONV_CHAT(convo), conn->local_entry->nickname); |
| 8849 | 1009 | } |
| 1010 | ||
| 1011 | void silcgaim_chat_join(GaimConnection *gc, GHashTable *data) | |
| 1012 | { | |
| 1013 | SilcGaim sg = gc->proto_data; | |
| 1014 | SilcClient client = sg->client; | |
| 1015 | SilcClientConnection conn = sg->conn; | |
| 1016 | const char *channel, *passphrase, *parentch; | |
| 1017 | ||
| 1018 | if (!conn) | |
| 1019 | return; | |
| 1020 | ||
| 1021 | channel = g_hash_table_lookup(data, "channel"); | |
| 1022 | passphrase = g_hash_table_lookup(data, "passphrase"); | |
| 1023 | ||
| 1024 | /* Check if we are joining a private group. Handle it | |
| 1025 | purely locally as it's not a real channel */ | |
| 1026 | if (strstr(channel, "[Private Group]")) { | |
| 1027 | SilcChannelEntry channel_entry; | |
| 1028 | SilcChannelPrivateKey key; | |
| 1029 | GaimChat *c; | |
| 1030 | SilcGaimPrvgrp grp; | |
| 1031 | ||
| 1032 | c = gaim_blist_find_chat(sg->account, channel); | |
| 1033 | parentch = gaim_blist_node_get_string((GaimBlistNode *)c, "parentch"); | |
| 1034 | if (!parentch) | |
| 1035 | return; | |
| 1036 | ||
| 1037 | channel_entry = silc_client_get_channel(sg->client, sg->conn, | |
| 1038 | (char *)parentch); | |
| 1039 | if (!channel_entry || | |
| 1040 | !silc_client_on_channel(channel_entry, sg->conn->local_entry)) { | |
| 1041 | char tmp[512]; | |
| 1042 | g_snprintf(tmp, sizeof(tmp), | |
| 1043 | _("You have to join the %s channel before you are " | |
| 1044 | "able to join the private group"), parentch); | |
| 1045 | gaim_notify_error(gc, _("Join Private Group"), | |
| 1046 | _("Cannot join private group"), tmp); | |
| 1047 | return; | |
| 1048 | } | |
| 1049 | ||
| 1050 | /* Add channel private key */ | |
| 1051 | if (!silc_client_add_channel_private_key(client, conn, | |
| 1052 | channel_entry, channel, | |
| 1053 | NULL, NULL, | |
| 1054 | (unsigned char *)passphrase, | |
| 1055 | strlen(passphrase), &key)) | |
| 1056 | return; | |
| 1057 | ||
| 1058 | /* Join the group */ | |
| 1059 | grp = silc_calloc(1, sizeof(*grp)); | |
| 1060 | if (!grp) | |
| 1061 | return; | |
| 1062 | grp->id = ++sg->channel_ids + SILCGAIM_PRVGRP; | |
| 1063 | grp->chid = SILC_PTR_TO_32(channel_entry->context); | |
| 1064 | grp->parentch = parentch; | |
| 1065 | grp->channel = channel; | |
| 1066 | grp->key = key; | |
| 1067 | sg->grps = g_list_append(sg->grps, grp); | |
| 1068 | serv_got_joined_chat(gc, grp->id, channel); | |
| 1069 | return; | |
| 1070 | } | |
| 1071 | ||
| 1072 | /* XXX We should have other properties here as well: | |
| 1073 | 1. whether to try to authenticate to the channel | |
| 1074 | 1a. with default key, | |
| 1075 | 1b. with specific key. | |
| 1076 | 2. whether to try to authenticate to become founder. | |
| 1077 | 2a. with default key, | |
| 1078 | 2b. with specific key. | |
| 1079 | ||
| 1080 | Since now such variety is not possible in the join dialog | |
| 1081 | we always use -founder and -auth options, which try to | |
| 1082 | do both 1 and 2 with default keys. */ | |
| 1083 | ||
| 1084 | /* Call JOIN */ | |
|
9172
2e04033bc831
[gaim-migrate @ 9957]
Mark Doliner <markdoliner@pidgin.im>
parents:
9168
diff
changeset
|
1085 | if ((passphrase != NULL) && (*passphrase != '\0')) |
| 8849 | 1086 | silc_client_command_call(client, conn, NULL, "JOIN", |
| 1087 | channel, passphrase, "-auth", "-founder", NULL); | |
| 1088 | else | |
| 1089 | silc_client_command_call(client, conn, NULL, "JOIN", | |
| 1090 | channel, "-auth", "-founder", NULL); | |
| 1091 | } | |
| 1092 | ||
| 1093 | void silcgaim_chat_invite(GaimConnection *gc, int id, const char *msg, | |
| 1094 | const char *name) | |
| 1095 | { | |
| 1096 | SilcGaim sg = gc->proto_data; | |
| 1097 | SilcClient client = sg->client; | |
| 1098 | SilcClientConnection conn = sg->conn; | |
| 1099 | SilcHashTableList htl; | |
| 1100 | SilcChannelUser chu; | |
| 1101 | gboolean found = FALSE; | |
| 1102 | ||
| 1103 | if (!conn) | |
| 1104 | return; | |
| 1105 | ||
| 1106 | /* See if we are inviting on a private group. Invite | |
| 1107 | to the actual channel */ | |
| 1108 | if (id > SILCGAIM_PRVGRP) { | |
| 1109 | GList *l; | |
| 1110 | SilcGaimPrvgrp prv; | |
| 1111 | ||
| 1112 | for (l = sg->grps; l; l = l->next) | |
| 1113 | if (((SilcGaimPrvgrp)l->data)->id == id) | |
| 1114 | break; | |
| 1115 | if (!l) | |
| 1116 | return; | |
| 1117 | prv = l->data; | |
| 1118 | id = prv->chid; | |
| 1119 | } | |
| 1120 | ||
| 1121 | /* Find channel by id */ | |
| 1122 | silc_hash_table_list(conn->local_entry->channels, &htl); | |
| 1123 | while (silc_hash_table_get(&htl, NULL, (void *)&chu)) { | |
| 1124 | if (SILC_PTR_TO_32(chu->channel->context) == id ) { | |
| 1125 | found = TRUE; | |
| 1126 | break; | |
| 1127 | } | |
| 1128 | } | |
| 1129 | silc_hash_table_list_reset(&htl); | |
| 1130 | if (!found) | |
| 1131 | return; | |
| 1132 | ||
| 1133 | /* Call INVITE */ | |
| 1134 | silc_client_command_call(client, conn, NULL, "INVITE", | |
| 1135 | chu->channel->channel_name, | |
|
9353
ff6546387358
[gaim-migrate @ 10161]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9295
diff
changeset
|
1136 | name, NULL); |
| 8849 | 1137 | } |
| 1138 | ||
| 1139 | void silcgaim_chat_leave(GaimConnection *gc, int id) | |
| 1140 | { | |
| 1141 | SilcGaim sg = gc->proto_data; | |
| 1142 | SilcClient client = sg->client; | |
| 1143 | SilcClientConnection conn = sg->conn; | |
| 1144 | SilcHashTableList htl; | |
| 1145 | SilcChannelUser chu; | |
| 1146 | gboolean found = FALSE; | |
| 1147 | GList *l; | |
| 1148 | SilcGaimPrvgrp prv; | |
| 1149 | ||
| 1150 | if (!conn) | |
| 1151 | return; | |
| 1152 | ||
| 1153 | /* See if we are leaving a private group */ | |
| 1154 | if (id > SILCGAIM_PRVGRP) { | |
| 1155 | SilcChannelEntry channel; | |
| 1156 | ||
| 1157 | for (l = sg->grps; l; l = l->next) | |
| 1158 | if (((SilcGaimPrvgrp)l->data)->id == id) | |
| 1159 | break; | |
| 1160 | if (!l) | |
| 1161 | return; | |
| 1162 | prv = l->data; | |
| 1163 | channel = silc_client_get_channel(sg->client, sg->conn, | |
| 1164 | (char *)prv->parentch); | |
| 1165 | if (!channel) | |
| 1166 | return; | |
| 1167 | silc_client_del_channel_private_key(client, conn, | |
| 1168 | channel, prv->key); | |
| 1169 | silc_free(prv); | |
| 1170 | sg->grps = g_list_remove(sg->grps, prv); | |
| 1171 | serv_got_chat_left(gc, id); | |
| 1172 | return; | |
| 1173 | } | |
| 1174 | ||
| 1175 | /* Find channel by id */ | |
| 1176 | silc_hash_table_list(conn->local_entry->channels, &htl); | |
| 1177 | while (silc_hash_table_get(&htl, NULL, (void *)&chu)) { | |
| 1178 | if (SILC_PTR_TO_32(chu->channel->context) == id ) { | |
| 1179 | found = TRUE; | |
| 1180 | break; | |
| 1181 | } | |
| 1182 | } | |
| 1183 | silc_hash_table_list_reset(&htl); | |
| 1184 | if (!found) | |
| 1185 | return; | |
| 1186 | ||
| 1187 | /* Call LEAVE */ | |
| 1188 | silc_client_command_call(client, conn, NULL, "LEAVE", | |
| 1189 | chu->channel->channel_name, NULL); | |
| 1190 | ||
| 1191 | serv_got_chat_left(gc, id); | |
| 1192 | ||
| 1193 | /* Leave from private groups on this channel as well */ | |
| 1194 | for (l = sg->grps; l; l = l->next) | |
| 1195 | if (((SilcGaimPrvgrp)l->data)->chid == id) { | |
| 1196 | prv = l->data; | |
| 1197 | silc_client_del_channel_private_key(client, conn, | |
| 1198 | chu->channel, | |
| 1199 | prv->key); | |
| 1200 | serv_got_chat_left(gc, prv->id); | |
| 1201 | silc_free(prv); | |
| 1202 | sg->grps = g_list_remove(sg->grps, prv); | |
| 1203 | if (!sg->grps) | |
| 1204 | break; | |
| 1205 | } | |
| 1206 | } | |
| 1207 | ||
| 1208 | int silcgaim_chat_send(GaimConnection *gc, int id, const char *msg) | |
| 1209 | { | |
| 1210 | SilcGaim sg = gc->proto_data; | |
| 1211 | SilcClient client = sg->client; | |
| 1212 | SilcClientConnection conn = sg->conn; | |
| 1213 | SilcHashTableList htl; | |
| 1214 | SilcChannelUser chu; | |
| 1215 | SilcChannelEntry channel = NULL; | |
| 1216 | SilcChannelPrivateKey key = NULL; | |
| 1217 | SilcUInt32 flags; | |
| 1218 | int ret; | |
|
9353
ff6546387358
[gaim-migrate @ 10161]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9295
diff
changeset
|
1219 | const char *msg2; |
|
9359
89c40efa7f7b
[gaim-migrate @ 10167]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9353
diff
changeset
|
1220 | char *tmp; |
| 8849 | 1221 | gboolean found = FALSE; |
| 1222 | gboolean sign = gaim_prefs_get_bool("/plugins/prpl/silc/sign_chat"); | |
| 1223 | ||
| 1224 | if (!msg || !conn) | |
| 1225 | return 0; | |
| 1226 | ||
|
9353
ff6546387358
[gaim-migrate @ 10161]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9295
diff
changeset
|
1227 | flags = SILC_MESSAGE_FLAG_UTF8; |
|
ff6546387358
[gaim-migrate @ 10161]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9295
diff
changeset
|
1228 | |
|
ff6546387358
[gaim-migrate @ 10161]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9295
diff
changeset
|
1229 | msg2 = msg; |
|
ff6546387358
[gaim-migrate @ 10161]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9295
diff
changeset
|
1230 | |
|
ff6546387358
[gaim-migrate @ 10161]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9295
diff
changeset
|
1231 | if (!g_ascii_strncasecmp(msg2, "/me ", 4)) |
|
ff6546387358
[gaim-migrate @ 10161]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9295
diff
changeset
|
1232 | { |
|
ff6546387358
[gaim-migrate @ 10161]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9295
diff
changeset
|
1233 | msg2 += 4; |
|
ff6546387358
[gaim-migrate @ 10161]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9295
diff
changeset
|
1234 | if (!msg2) |
|
ff6546387358
[gaim-migrate @ 10161]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9295
diff
changeset
|
1235 | return 0; |
|
ff6546387358
[gaim-migrate @ 10161]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9295
diff
changeset
|
1236 | flags |= SILC_MESSAGE_FLAG_ACTION; |
|
ff6546387358
[gaim-migrate @ 10161]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9295
diff
changeset
|
1237 | } else if (strlen(msg) > 1 && msg[0] == '/') { |
| 8849 | 1238 | if (!silc_client_command_call(client, conn, msg + 1)) |
| 1239 | gaim_notify_error(gc, ("Call Command"), _("Cannot call command"), | |
|
9353
ff6546387358
[gaim-migrate @ 10161]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9295
diff
changeset
|
1240 | _("Unknown command")); |
| 8849 | 1241 | return 0; |
| 1242 | } | |
| 1243 | ||
|
9353
ff6546387358
[gaim-migrate @ 10161]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9295
diff
changeset
|
1244 | |
| 8849 | 1245 | if (sign) |
| 1246 | flags |= SILC_MESSAGE_FLAG_SIGNED; | |
| 1247 | ||
| 1248 | /* Get the channel private key if we are sending on | |
| 1249 | private group */ | |
| 1250 | if (id > SILCGAIM_PRVGRP) { | |
| 1251 | GList *l; | |
| 1252 | SilcGaimPrvgrp prv; | |
| 1253 | ||
| 1254 | for (l = sg->grps; l; l = l->next) | |
| 1255 | if (((SilcGaimPrvgrp)l->data)->id == id) | |
| 1256 | break; | |
| 1257 | if (!l) | |
| 1258 | return 0; | |
| 1259 | prv = l->data; | |
| 1260 | channel = silc_client_get_channel(sg->client, sg->conn, | |
| 1261 | (char *)prv->parentch); | |
| 1262 | if (!channel) | |
| 1263 | return 0; | |
| 1264 | key = prv->key; | |
| 1265 | } | |
| 1266 | ||
| 1267 | if (!channel) { | |
| 1268 | /* Find channel by id */ | |
| 1269 | silc_hash_table_list(conn->local_entry->channels, &htl); | |
| 1270 | while (silc_hash_table_get(&htl, NULL, (void *)&chu)) { | |
| 1271 | if (SILC_PTR_TO_32(chu->channel->context) == id ) { | |
| 1272 | found = TRUE; | |
| 1273 | break; | |
| 1274 | } | |
| 1275 | } | |
| 1276 | silc_hash_table_list_reset(&htl); | |
| 1277 | if (!found) | |
| 1278 | return 0; | |
| 1279 | channel = chu->channel; | |
| 1280 | } | |
| 1281 | ||
| 1282 | /* Send channel message */ | |
| 1283 | ret = silc_client_send_channel_message(client, conn, channel, key, | |
|
9353
ff6546387358
[gaim-migrate @ 10161]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9295
diff
changeset
|
1284 | flags, (unsigned char *)msg2, |
|
ff6546387358
[gaim-migrate @ 10161]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9295
diff
changeset
|
1285 | strlen(msg2), TRUE); |
|
9359
89c40efa7f7b
[gaim-migrate @ 10167]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9353
diff
changeset
|
1286 | if (ret) { |
|
89c40efa7f7b
[gaim-migrate @ 10167]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9353
diff
changeset
|
1287 | tmp = gaim_escape_html(msg); |
|
89c40efa7f7b
[gaim-migrate @ 10167]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9353
diff
changeset
|
1288 | serv_got_chat_in(gc, id, gaim_connection_get_display_name(gc), 0, tmp, |
| 8849 | 1289 | time(NULL)); |
|
9359
89c40efa7f7b
[gaim-migrate @ 10167]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9353
diff
changeset
|
1290 | g_free(tmp); |
|
89c40efa7f7b
[gaim-migrate @ 10167]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9353
diff
changeset
|
1291 | } |
| 8849 | 1292 | |
| 1293 | return ret; | |
| 1294 | } | |
| 1295 | ||
| 1296 | void silcgaim_chat_set_topic(GaimConnection *gc, int id, const char *topic) | |
| 1297 | { | |
| 1298 | SilcGaim sg = gc->proto_data; | |
| 1299 | SilcClient client = sg->client; | |
| 1300 | SilcClientConnection conn = sg->conn; | |
| 1301 | SilcHashTableList htl; | |
| 1302 | SilcChannelUser chu; | |
| 1303 | gboolean found = FALSE; | |
| 1304 | ||
|
9353
ff6546387358
[gaim-migrate @ 10161]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9295
diff
changeset
|
1305 | if (!conn) |
| 8849 | 1306 | return; |
| 1307 | ||
| 1308 | /* See if setting topic on private group. Set it | |
| 1309 | on the actual channel */ | |
| 1310 | if (id > SILCGAIM_PRVGRP) { | |
| 1311 | GList *l; | |
| 1312 | SilcGaimPrvgrp prv; | |
| 1313 | ||
| 1314 | for (l = sg->grps; l; l = l->next) | |
| 1315 | if (((SilcGaimPrvgrp)l->data)->id == id) | |
| 1316 | break; | |
| 1317 | if (!l) | |
| 1318 | return; | |
| 1319 | prv = l->data; | |
| 1320 | id = prv->chid; | |
| 1321 | } | |
| 1322 | ||
| 1323 | /* Find channel by id */ | |
| 1324 | silc_hash_table_list(conn->local_entry->channels, &htl); | |
| 1325 | while (silc_hash_table_get(&htl, NULL, (void *)&chu)) { | |
| 1326 | if (SILC_PTR_TO_32(chu->channel->context) == id ) { | |
| 1327 | found = TRUE; | |
| 1328 | break; | |
| 1329 | } | |
| 1330 | } | |
| 1331 | silc_hash_table_list_reset(&htl); | |
| 1332 | if (!found) | |
| 1333 | return; | |
| 1334 | ||
| 1335 | /* Call TOPIC */ | |
| 1336 | silc_client_command_call(client, conn, NULL, "TOPIC", | |
| 1337 | chu->channel->channel_name, topic, NULL); | |
| 1338 | } | |
| 1339 | ||
| 1340 | GaimRoomlist *silcgaim_roomlist_get_list(GaimConnection *gc) | |
| 1341 | { | |
| 1342 | SilcGaim sg = gc->proto_data; | |
| 1343 | SilcClient client = sg->client; | |
| 1344 | SilcClientConnection conn = sg->conn; | |
| 1345 | GList *fields = NULL; | |
| 1346 | GaimRoomlistField *f; | |
| 1347 | ||
| 1348 | if (!conn) | |
| 1349 | return NULL; | |
| 1350 | ||
| 1351 | if (sg->roomlist) | |
| 1352 | gaim_roomlist_unref(sg->roomlist); | |
| 1353 | ||
| 1354 | sg->roomlist_canceled = FALSE; | |
| 1355 | ||
| 1356 | sg->roomlist = gaim_roomlist_new(gaim_connection_get_account(gc)); | |
| 1357 | f = gaim_roomlist_field_new(GAIM_ROOMLIST_FIELD_STRING, "", "channel", TRUE); | |
| 1358 | fields = g_list_append(fields, f); | |
| 1359 | f = gaim_roomlist_field_new(GAIM_ROOMLIST_FIELD_INT, | |
| 1360 | _("Users"), "users", FALSE); | |
| 1361 | fields = g_list_append(fields, f); | |
| 1362 | f = gaim_roomlist_field_new(GAIM_ROOMLIST_FIELD_STRING, | |
| 1363 | _("Topic"), "topic", FALSE); | |
| 1364 | fields = g_list_append(fields, f); | |
| 1365 | gaim_roomlist_set_fields(sg->roomlist, fields); | |
| 1366 | ||
| 1367 | /* Call LIST */ | |
| 1368 | silc_client_command_call(client, conn, "LIST"); | |
| 1369 | ||
| 1370 | gaim_roomlist_set_in_progress(sg->roomlist, TRUE); | |
| 1371 | ||
| 1372 | return sg->roomlist; | |
| 1373 | } | |
| 1374 | ||
| 1375 | void silcgaim_roomlist_cancel(GaimRoomlist *list) | |
| 1376 | { | |
| 1377 | GaimConnection *gc = gaim_account_get_connection(list->account); | |
| 1378 | SilcGaim sg; | |
| 1379 | ||
| 1380 | if (!gc) | |
| 1381 | return; | |
| 1382 | sg = gc->proto_data; | |
| 1383 | ||
| 1384 | gaim_roomlist_set_in_progress(list, FALSE); | |
| 1385 | if (sg->roomlist == list) { | |
| 1386 | gaim_roomlist_unref(sg->roomlist); | |
| 1387 | sg->roomlist = NULL; | |
| 1388 | sg->roomlist_canceled = TRUE; | |
| 1389 | } | |
| 1390 | } |