Fri, 09 Nov 2007 08:48:40 +0000
applied changes from 32f31e981f0618a4167aa98bcc22c2dab13d1550
through a9f75de97d6cdf8fe8bf091b95def6c648aac82f
applied changes from a9f75de97d6cdf8fe8bf091b95def6c648aac82f
through 7c9f2e0cc4967a3eaade95d32f164349b6d1aa03
applied changes from a9f75de97d6cdf8fe8bf091b95def6c648aac82f
through fc4350a15fdd1f51b4496568afaa83355e18b714
applied changes from fc4350a15fdd1f51b4496568afaa83355e18b714
through 18ccd2ba2c1c9b7fa3dfedf72b48b3bd01c3a7c4
applied changes from a9f75de97d6cdf8fe8bf091b95def6c648aac82f
through 20236f54c97e87512b7eb716559a4bd86b73f833
applied changes from 868a040ee69c6e45b9132e7254a3f523e55385b2
through 0e154355bb3e8bdaeb793b142075b60671b37a48
applied changes from 329395b9793793f35bcf231033c1eb942513ab01
through 9d8120be512c235d76a8f6fee60cae024da8772e
| 8849 | 1 | /* |
| 2 | ||
| 15884 | 3 | silcpurple_chat.c |
| 8849 | 4 | |
| 5 | Author: Pekka Riikonen <priikone@silcnet.org> | |
| 6 | ||
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16492
diff
changeset
|
7 | Copyright (C) 2004 - 2007 Pekka Riikonen |
| 8849 | 8 | |
| 9 | This program is free software; you can redistribute it and/or modify | |
| 10 | it under the terms of the GNU General Public License as published by | |
| 11 | the Free Software Foundation; version 2 of the License. | |
| 12 | ||
| 13 | This program is distributed in the hope that it will be useful, | |
| 14 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 16 | GNU General Public License for more details. | |
| 17 | ||
| 18 | */ | |
| 19 | ||
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16492
diff
changeset
|
20 | #include "silc.h" |
| 8849 | 21 | #include "silcclient.h" |
| 15884 | 22 | #include "silcpurple.h" |
|
12058
6d4b6e3bd0ba
[gaim-migrate @ 14353]
Pekka Riikonen <priikone@silcnet.org>
parents:
11454
diff
changeset
|
23 | #include "wb.h" |
| 8849 | 24 | |
| 25 | /***************************** Channel Routines ******************************/ | |
| 26 | ||
| 15884 | 27 | GList *silcpurple_chat_info(PurpleConnection *gc) |
| 8849 | 28 | { |
| 29 | GList *ci = NULL; | |
| 30 | struct proto_chat_entry *pce; | |
| 31 | ||
| 32 | pce = g_new0(struct proto_chat_entry, 1); | |
| 33 | pce->label = _("_Channel:"); | |
| 34 | pce->identifier = "channel"; | |
|
10519
80801a34a246
[gaim-migrate @ 11833]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10246
diff
changeset
|
35 | pce->required = TRUE; |
| 8849 | 36 | ci = g_list_append(ci, pce); |
| 37 | ||
| 38 | pce = g_new0(struct proto_chat_entry, 1); | |
| 39 | pce->label = _("_Passphrase:"); | |
| 40 | pce->identifier = "passphrase"; | |
| 41 | pce->secret = TRUE; | |
| 42 | ci = g_list_append(ci, pce); | |
| 43 | ||
| 44 | return ci; | |
| 45 | } | |
| 46 | ||
| 15884 | 47 | GHashTable *silcpurple_chat_info_defaults(PurpleConnection *gc, const char *chat_name) |
|
9754
3a17eee239b2
[gaim-migrate @ 10621]
Nathan Fredrickson <nathan@silverorange.com>
parents:
9554
diff
changeset
|
48 | { |
|
3a17eee239b2
[gaim-migrate @ 10621]
Nathan Fredrickson <nathan@silverorange.com>
parents:
9554
diff
changeset
|
49 | GHashTable *defaults; |
|
3a17eee239b2
[gaim-migrate @ 10621]
Nathan Fredrickson <nathan@silverorange.com>
parents:
9554
diff
changeset
|
50 | |
|
3a17eee239b2
[gaim-migrate @ 10621]
Nathan Fredrickson <nathan@silverorange.com>
parents:
9554
diff
changeset
|
51 | defaults = g_hash_table_new_full(g_str_hash, g_str_equal, NULL, g_free); |
|
3a17eee239b2
[gaim-migrate @ 10621]
Nathan Fredrickson <nathan@silverorange.com>
parents:
9554
diff
changeset
|
52 | |
|
3a17eee239b2
[gaim-migrate @ 10621]
Nathan Fredrickson <nathan@silverorange.com>
parents:
9554
diff
changeset
|
53 | if (chat_name != NULL) |
|
3a17eee239b2
[gaim-migrate @ 10621]
Nathan Fredrickson <nathan@silverorange.com>
parents:
9554
diff
changeset
|
54 | g_hash_table_insert(defaults, "channel", g_strdup(chat_name)); |
|
3a17eee239b2
[gaim-migrate @ 10621]
Nathan Fredrickson <nathan@silverorange.com>
parents:
9554
diff
changeset
|
55 | |
|
3a17eee239b2
[gaim-migrate @ 10621]
Nathan Fredrickson <nathan@silverorange.com>
parents:
9554
diff
changeset
|
56 | return defaults; |
|
3a17eee239b2
[gaim-migrate @ 10621]
Nathan Fredrickson <nathan@silverorange.com>
parents:
9554
diff
changeset
|
57 | } |
|
3a17eee239b2
[gaim-migrate @ 10621]
Nathan Fredrickson <nathan@silverorange.com>
parents:
9554
diff
changeset
|
58 | |
| 8849 | 59 | static void |
| 15884 | 60 | silcpurple_chat_getinfo(PurpleConnection *gc, GHashTable *components); |
| 8849 | 61 | |
| 62 | static void | |
| 15884 | 63 | silcpurple_chat_getinfo_res(SilcClient client, |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16492
diff
changeset
|
64 | SilcClientConnection conn, |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16492
diff
changeset
|
65 | SilcStatus status, |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16492
diff
changeset
|
66 | SilcDList channels, |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16492
diff
changeset
|
67 | void *context) |
| 8849 | 68 | { |
| 69 | GHashTable *components = context; | |
| 15884 | 70 | PurpleConnection *gc = client->application; |
| 8849 | 71 | const char *chname; |
| 72 | char tmp[256]; | |
| 73 | ||
| 74 | chname = g_hash_table_lookup(components, "channel"); | |
| 75 | if (!chname) | |
| 76 | return; | |
| 77 | ||
| 78 | if (!channels) { | |
| 79 | g_snprintf(tmp, sizeof(tmp), | |
| 80 | _("Channel %s does not exist in the network"), chname); | |
| 15884 | 81 | purple_notify_error(gc, _("Channel Information"), |
| 8849 | 82 | _("Cannot get channel information"), tmp); |
| 83 | return; | |
| 84 | } | |
| 85 | ||
| 15884 | 86 | silcpurple_chat_getinfo(gc, components); |
| 8849 | 87 | } |
| 88 | ||
| 9038 | 89 | |
| 8849 | 90 | static void |
| 15884 | 91 | silcpurple_chat_getinfo(PurpleConnection *gc, GHashTable *components) |
| 8849 | 92 | { |
| 15884 | 93 | SilcPurple sg = gc->proto_data; |
| 8849 | 94 | const char *chname; |
|
9488
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9359
diff
changeset
|
95 | char *buf, tmp[256], *tmp2; |
| 8849 | 96 | GString *s; |
| 97 | SilcChannelEntry channel; | |
| 98 | SilcHashTableList htl; | |
| 99 | SilcChannelUser chu; | |
| 100 | ||
| 9038 | 101 | if (!components) |
| 102 | return; | |
| 8849 | 103 | |
| 9038 | 104 | chname = g_hash_table_lookup(components, "channel"); |
| 8849 | 105 | if (!chname) |
| 106 | return; | |
| 107 | channel = silc_client_get_channel(sg->client, sg->conn, | |
| 108 | (char *)chname); | |
| 109 | if (!channel) { | |
| 110 | silc_client_get_channel_resolve(sg->client, sg->conn, | |
| 111 | (char *)chname, | |
| 15884 | 112 | silcpurple_chat_getinfo_res, |
| 9038 | 113 | components); |
| 8849 | 114 | return; |
| 115 | } | |
| 116 | ||
| 117 | s = g_string_new(""); | |
|
10732
5e314ab498bf
[gaim-migrate @ 12334]
Richard Laager <rlaager@pidgin.im>
parents:
10662
diff
changeset
|
118 | tmp2 = g_markup_escape_text(channel->channel_name, -1); |
|
9488
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9359
diff
changeset
|
119 | g_string_append_printf(s, _("<b>Channel Name:</b> %s"), tmp2); |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9359
diff
changeset
|
120 | g_free(tmp2); |
| 8849 | 121 | if (channel->user_list && silc_hash_table_count(channel->user_list)) |
|
9488
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9359
diff
changeset
|
122 | g_string_append_printf(s, _("<br><b>User Count:</b> %d"), |
| 8849 | 123 | (int)silc_hash_table_count(channel->user_list)); |
| 124 | ||
| 125 | silc_hash_table_list(channel->user_list, &htl); | |
| 126 | while (silc_hash_table_get(&htl, NULL, (void *)&chu)) { | |
| 127 | if (chu->mode & SILC_CHANNEL_UMODE_CHANFO) { | |
|
10732
5e314ab498bf
[gaim-migrate @ 12334]
Richard Laager <rlaager@pidgin.im>
parents:
10662
diff
changeset
|
128 | tmp2 = g_markup_escape_text(chu->client->nickname, -1); |
|
9488
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9359
diff
changeset
|
129 | g_string_append_printf(s, _("<br><b>Channel Founder:</b> %s"), |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9359
diff
changeset
|
130 | tmp2); |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9359
diff
changeset
|
131 | g_free(tmp2); |
| 8849 | 132 | break; |
| 133 | } | |
| 134 | } | |
| 135 | silc_hash_table_list_reset(&htl); | |
| 136 | ||
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16492
diff
changeset
|
137 | if (channel->cipher) |
|
9488
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9359
diff
changeset
|
138 | g_string_append_printf(s, _("<br><b>Channel Cipher:</b> %s"), |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16492
diff
changeset
|
139 | channel->cipher); |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16492
diff
changeset
|
140 | |
| 8849 | 141 | if (channel->hmac) |
|
13702
35310965f38a
[gaim-migrate @ 16103]
Richard Laager <rlaager@pidgin.im>
parents:
12919
diff
changeset
|
142 | /* Definition of HMAC: http://en.wikipedia.org/wiki/HMAC */ |
|
9488
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9359
diff
changeset
|
143 | g_string_append_printf(s, _("<br><b>Channel HMAC:</b> %s"), |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16492
diff
changeset
|
144 | channel->hmac); |
| 8849 | 145 | |
|
9488
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9359
diff
changeset
|
146 | if (channel->topic) { |
|
10732
5e314ab498bf
[gaim-migrate @ 12334]
Richard Laager <rlaager@pidgin.im>
parents:
10662
diff
changeset
|
147 | tmp2 = g_markup_escape_text(channel->topic, -1); |
|
9488
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9359
diff
changeset
|
148 | g_string_append_printf(s, _("<br><b>Channel Topic:</b><br>%s"), tmp2); |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9359
diff
changeset
|
149 | g_free(tmp2); |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9359
diff
changeset
|
150 | } |
| 8849 | 151 | |
| 152 | if (channel->mode) { | |
|
9488
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9359
diff
changeset
|
153 | g_string_append_printf(s, _("<br><b>Channel Modes:</b> ")); |
| 15884 | 154 | silcpurple_get_chmode_string(channel->mode, tmp, sizeof(tmp)); |
|
12317
3a2f08276e58
[gaim-migrate @ 14621]
Richard Laager <rlaager@pidgin.im>
parents:
12216
diff
changeset
|
155 | g_string_append(s, tmp); |
| 8849 | 156 | } |
| 157 | ||
| 158 | if (channel->founder_key) { | |
| 159 | char *fingerprint, *babbleprint; | |
| 160 | unsigned char *pk; | |
| 161 | SilcUInt32 pk_len; | |
| 162 | pk = silc_pkcs_public_key_encode(channel->founder_key, &pk_len); | |
|
20289
5c844288fbec
applied changes from 32f31e981f0618a4167aa98bcc22c2dab13d1550
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
18190
diff
changeset
|
163 | if (pk) { |
|
5c844288fbec
applied changes from 32f31e981f0618a4167aa98bcc22c2dab13d1550
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
18190
diff
changeset
|
164 | fingerprint = silc_hash_fingerprint(NULL, pk, pk_len); |
|
5c844288fbec
applied changes from 32f31e981f0618a4167aa98bcc22c2dab13d1550
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
18190
diff
changeset
|
165 | babbleprint = silc_hash_babbleprint(NULL, pk, pk_len); |
| 8849 | 166 | |
|
20289
5c844288fbec
applied changes from 32f31e981f0618a4167aa98bcc22c2dab13d1550
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
18190
diff
changeset
|
167 | g_string_append_printf(s, _("<br><b>Founder Key Fingerprint:</b><br>%s"), fingerprint); |
|
5c844288fbec
applied changes from 32f31e981f0618a4167aa98bcc22c2dab13d1550
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
18190
diff
changeset
|
168 | g_string_append_printf(s, _("<br><b>Founder Key Babbleprint:</b><br>%s"), babbleprint); |
| 8849 | 169 | |
|
20289
5c844288fbec
applied changes from 32f31e981f0618a4167aa98bcc22c2dab13d1550
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
18190
diff
changeset
|
170 | silc_free(fingerprint); |
|
5c844288fbec
applied changes from 32f31e981f0618a4167aa98bcc22c2dab13d1550
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
18190
diff
changeset
|
171 | silc_free(babbleprint); |
|
5c844288fbec
applied changes from 32f31e981f0618a4167aa98bcc22c2dab13d1550
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
18190
diff
changeset
|
172 | silc_free(pk); |
|
5c844288fbec
applied changes from 32f31e981f0618a4167aa98bcc22c2dab13d1550
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
18190
diff
changeset
|
173 | } |
| 8849 | 174 | } |
| 175 | ||
| 176 | buf = g_string_free(s, FALSE); | |
| 15884 | 177 | purple_notify_formatted(gc, NULL, _("Channel Information"), NULL, buf, NULL, NULL); |
| 8849 | 178 | g_free(buf); |
| 179 | } | |
| 180 | ||
| 181 | ||
| 9038 | 182 | static void |
| 15884 | 183 | silcpurple_chat_getinfo_menu(PurpleBlistNode *node, gpointer data) |
| 9038 | 184 | { |
| 15884 | 185 | PurpleChat *chat = (PurpleChat *)node; |
| 186 | silcpurple_chat_getinfo(chat->account->gc, chat->components); | |
| 9038 | 187 | } |
| 188 | ||
| 189 | ||
| 8849 | 190 | #if 0 /* XXX For now these are not implemented. We need better |
| 15884 | 191 | listview dialog from Purple for these. */ |
| 8849 | 192 | /************************** Channel Invite List ******************************/ |
| 193 | ||
| 194 | static void | |
| 15884 | 195 | silcpurple_chat_invitelist(PurpleBlistNode *node, gpointer data); |
| 8849 | 196 | { |
| 197 | ||
| 198 | } | |
| 199 | ||
| 200 | ||
| 201 | /**************************** Channel Ban List *******************************/ | |
| 202 | ||
| 203 | static void | |
| 15884 | 204 | silcpurple_chat_banlist(PurpleBlistNode *node, gpointer data); |
| 8849 | 205 | { |
| 206 | ||
| 207 | } | |
| 208 | #endif | |
| 209 | ||
| 210 | ||
| 211 | /************************* Channel Authentication ****************************/ | |
| 212 | ||
| 213 | typedef struct { | |
| 15884 | 214 | SilcPurple sg; |
| 8849 | 215 | SilcChannelEntry channel; |
| 15884 | 216 | PurpleChat *c; |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16492
diff
changeset
|
217 | SilcDList pubkeys; |
| 15884 | 218 | } *SilcPurpleChauth; |
| 8849 | 219 | |
| 220 | static void | |
| 15884 | 221 | silcpurple_chat_chpk_add(void *user_data, const char *name) |
| 8849 | 222 | { |
| 15884 | 223 | SilcPurpleChauth sgc = (SilcPurpleChauth)user_data; |
| 224 | SilcPurple sg = sgc->sg; | |
| 8849 | 225 | SilcClient client = sg->client; |
| 226 | SilcClientConnection conn = sg->conn; | |
| 227 | SilcPublicKey public_key; | |
| 228 | SilcBuffer chpks, pk, chidp; | |
| 229 | unsigned char mode[4]; | |
| 230 | SilcUInt32 m; | |
| 231 | ||
| 232 | /* Load the public key */ | |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16492
diff
changeset
|
233 | if (!silc_pkcs_load_public_key(name, &public_key)) { |
| 15884 | 234 | silcpurple_chat_chauth_show(sgc->sg, sgc->channel, sgc->pubkeys); |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16492
diff
changeset
|
235 | silc_dlist_uninit(sgc->pubkeys); |
| 8849 | 236 | silc_free(sgc); |
| 15884 | 237 | purple_notify_error(client->application, |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16492
diff
changeset
|
238 | _("Add Channel Public Key"), |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16492
diff
changeset
|
239 | _("Could not load public key"), NULL); |
| 8849 | 240 | return; |
| 241 | } | |
| 242 | ||
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16492
diff
changeset
|
243 | pk = silc_public_key_payload_encode(public_key); |
| 8849 | 244 | chpks = silc_buffer_alloc_size(2); |
| 245 | SILC_PUT16_MSB(1, chpks->head); | |
| 246 | chpks = silc_argument_payload_encode_one(chpks, pk->data, | |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16492
diff
changeset
|
247 | silc_buffer_len(pk), 0x00); |
| 8849 | 248 | silc_buffer_free(pk); |
| 249 | ||
| 250 | m = sgc->channel->mode; | |
| 251 | m |= SILC_CHANNEL_MODE_CHANNEL_AUTH; | |
| 252 | ||
| 253 | /* Send CMODE */ | |
| 254 | SILC_PUT32_MSB(m, mode); | |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16492
diff
changeset
|
255 | chidp = silc_id_payload_encode(&sgc->channel->id, SILC_ID_CHANNEL); |
| 8849 | 256 | silc_client_command_send(client, conn, SILC_COMMAND_CMODE, |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16492
diff
changeset
|
257 | silcpurple_command_reply, NULL, 3, |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16492
diff
changeset
|
258 | 1, chidp->data, silc_buffer_len(chidp), |
| 8849 | 259 | 2, mode, sizeof(mode), |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16492
diff
changeset
|
260 | 9, chpks->data, silc_buffer_len(chpks)); |
| 8849 | 261 | silc_buffer_free(chpks); |
| 262 | silc_buffer_free(chidp); | |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16492
diff
changeset
|
263 | if (sgc->pubkeys) { |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16492
diff
changeset
|
264 | silc_dlist_start(sgc->pubkeys); |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16492
diff
changeset
|
265 | while ((public_key = silc_dlist_get(sgc->pubkeys))) |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16492
diff
changeset
|
266 | silc_pkcs_public_key_free(public_key); |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16492
diff
changeset
|
267 | silc_dlist_uninit(sgc->pubkeys); |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16492
diff
changeset
|
268 | } |
| 8849 | 269 | silc_free(sgc); |
| 270 | } | |
| 271 | ||
| 272 | static void | |
| 15884 | 273 | silcpurple_chat_chpk_cancel(void *user_data, const char *name) |
| 8849 | 274 | { |
| 15884 | 275 | SilcPurpleChauth sgc = (SilcPurpleChauth)user_data; |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16492
diff
changeset
|
276 | SilcPublicKey public_key; |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16492
diff
changeset
|
277 | |
| 15884 | 278 | silcpurple_chat_chauth_show(sgc->sg, sgc->channel, sgc->pubkeys); |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16492
diff
changeset
|
279 | |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16492
diff
changeset
|
280 | if (sgc->pubkeys) { |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16492
diff
changeset
|
281 | silc_dlist_start(sgc->pubkeys); |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16492
diff
changeset
|
282 | while ((public_key = silc_dlist_get(sgc->pubkeys))) |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16492
diff
changeset
|
283 | silc_pkcs_public_key_free(public_key); |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16492
diff
changeset
|
284 | silc_dlist_uninit(sgc->pubkeys); |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16492
diff
changeset
|
285 | } |
| 8849 | 286 | silc_free(sgc); |
| 287 | } | |
| 288 | ||
| 289 | static void | |
| 15884 | 290 | silcpurple_chat_chpk_cb(SilcPurpleChauth sgc, PurpleRequestFields *fields) |
| 8849 | 291 | { |
| 15884 | 292 | SilcPurple sg = sgc->sg; |
| 8849 | 293 | SilcClient client = sg->client; |
| 294 | SilcClientConnection conn = sg->conn; | |
| 15884 | 295 | PurpleRequestField *f; |
|
18190
bcf28ef7e8ff
Re-fix the DBus list handling code by killing const GList* / const GSList*
Richard Laager <rlaager@pidgin.im>
parents:
17680
diff
changeset
|
296 | GList *list; |
| 8849 | 297 | SilcPublicKey public_key; |
| 298 | SilcBuffer chpks, pk, chidp; | |
| 299 | SilcUInt16 c = 0, ct; | |
| 300 | unsigned char mode[4]; | |
| 301 | SilcUInt32 m; | |
| 302 | ||
| 15884 | 303 | f = purple_request_fields_get_field(fields, "list"); |
| 304 | if (!purple_request_field_list_get_selected(f)) { | |
| 8849 | 305 | /* Add new public key */ |
| 15884 | 306 | purple_request_file(sg->gc, _("Open Public Key..."), NULL, FALSE, |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16492
diff
changeset
|
307 | G_CALLBACK(silcpurple_chat_chpk_add), |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16492
diff
changeset
|
308 | G_CALLBACK(silcpurple_chat_chpk_cancel), |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16492
diff
changeset
|
309 | purple_connection_get_account(sg->gc), NULL, NULL, sgc); |
| 8849 | 310 | return; |
| 311 | } | |
| 312 | ||
| 15884 | 313 | list = purple_request_field_list_get_items(f); |
| 8849 | 314 | chpks = silc_buffer_alloc_size(2); |
| 315 | ||
| 316 | for (ct = 0; list; list = list->next, ct++) { | |
| 15884 | 317 | public_key = purple_request_field_list_get_data(f, list->data); |
| 318 | if (purple_request_field_list_is_selected(f, list->data)) { | |
| 8849 | 319 | /* Delete this public key */ |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16492
diff
changeset
|
320 | pk = silc_public_key_payload_encode(public_key); |
| 8849 | 321 | chpks = silc_argument_payload_encode_one(chpks, pk->data, |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16492
diff
changeset
|
322 | silc_buffer_len(pk), 0x01); |
| 8849 | 323 | silc_buffer_free(pk); |
| 324 | c++; | |
| 325 | } | |
| 326 | } | |
| 327 | if (!c) { | |
| 328 | silc_buffer_free(chpks); | |
| 329 | return; | |
| 330 | } | |
| 331 | SILC_PUT16_MSB(c, chpks->head); | |
| 332 | ||
| 333 | m = sgc->channel->mode; | |
| 334 | if (ct == c) | |
| 335 | m &= ~SILC_CHANNEL_MODE_CHANNEL_AUTH; | |
| 336 | ||
| 337 | /* Send CMODE */ | |
| 338 | SILC_PUT32_MSB(m, mode); | |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16492
diff
changeset
|
339 | chidp = silc_id_payload_encode(&sgc->channel->id, SILC_ID_CHANNEL); |
| 8849 | 340 | silc_client_command_send(client, conn, SILC_COMMAND_CMODE, |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16492
diff
changeset
|
341 | silcpurple_command_reply, NULL, 3, |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16492
diff
changeset
|
342 | 1, chidp->data, silc_buffer_len(chidp), |
| 8849 | 343 | 2, mode, sizeof(mode), |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16492
diff
changeset
|
344 | 9, chpks->data, silc_buffer_len(chpks)); |
| 8849 | 345 | silc_buffer_free(chpks); |
| 346 | silc_buffer_free(chidp); | |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16492
diff
changeset
|
347 | if (sgc->pubkeys) { |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16492
diff
changeset
|
348 | silc_dlist_start(sgc->pubkeys); |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16492
diff
changeset
|
349 | while ((public_key = silc_dlist_get(sgc->pubkeys))) |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16492
diff
changeset
|
350 | silc_pkcs_public_key_free(public_key); |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16492
diff
changeset
|
351 | silc_dlist_uninit(sgc->pubkeys); |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16492
diff
changeset
|
352 | } |
| 8849 | 353 | silc_free(sgc); |
| 354 | } | |
| 355 | ||
| 356 | static void | |
| 15884 | 357 | silcpurple_chat_chauth_ok(SilcPurpleChauth sgc, PurpleRequestFields *fields) |
| 8849 | 358 | { |
| 15884 | 359 | SilcPurple sg = sgc->sg; |
| 360 | PurpleRequestField *f; | |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16492
diff
changeset
|
361 | SilcPublicKey public_key; |
| 8849 | 362 | const char *curpass, *val; |
| 363 | int set; | |
| 364 | ||
| 15884 | 365 | f = purple_request_fields_get_field(fields, "passphrase"); |
| 366 | val = purple_request_field_string_get_value(f); | |
| 367 | curpass = purple_blist_node_get_string((PurpleBlistNode *)sgc->c, "passphrase"); | |
| 8849 | 368 | |
| 369 | if (!val && curpass) | |
| 370 | set = 0; | |
| 371 | else if (val && !curpass) | |
| 372 | set = 1; | |
| 373 | else if (val && curpass && strcmp(val, curpass)) | |
| 374 | set = 1; | |
| 375 | else | |
| 376 | set = -1; | |
| 377 | ||
| 378 | if (set == 1) { | |
| 379 | silc_client_command_call(sg->client, sg->conn, NULL, "CMODE", | |
| 380 | sgc->channel->channel_name, "+a", val, NULL); | |
| 15884 | 381 | purple_blist_node_set_string((PurpleBlistNode *)sgc->c, "passphrase", val); |
| 8849 | 382 | } else if (set == 0) { |
| 383 | silc_client_command_call(sg->client, sg->conn, NULL, "CMODE", | |
| 384 | sgc->channel->channel_name, "-a", NULL); | |
| 15884 | 385 | purple_blist_node_remove_setting((PurpleBlistNode *)sgc->c, "passphrase"); |
| 8849 | 386 | } |
| 387 | ||
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16492
diff
changeset
|
388 | if (sgc->pubkeys) { |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16492
diff
changeset
|
389 | silc_dlist_start(sgc->pubkeys); |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16492
diff
changeset
|
390 | while ((public_key = silc_dlist_get(sgc->pubkeys))) |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16492
diff
changeset
|
391 | silc_pkcs_public_key_free(public_key); |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16492
diff
changeset
|
392 | silc_dlist_uninit(sgc->pubkeys); |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16492
diff
changeset
|
393 | } |
| 8849 | 394 | silc_free(sgc); |
| 395 | } | |
| 396 | ||
| 15884 | 397 | void silcpurple_chat_chauth_show(SilcPurple sg, SilcChannelEntry channel, |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16492
diff
changeset
|
398 | SilcDList channel_pubkeys) |
| 8849 | 399 | { |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16492
diff
changeset
|
400 | SilcPublicKey public_key; |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16492
diff
changeset
|
401 | SilcSILCPublicKey silc_pubkey; |
| 8849 | 402 | unsigned char *pk; |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16492
diff
changeset
|
403 | SilcUInt32 pk_len; |
| 8849 | 404 | char *fingerprint, *babbleprint; |
| 405 | SilcPublicKeyIdentifier ident; | |
| 406 | char tmp2[1024], t[512]; | |
| 15884 | 407 | PurpleRequestFields *fields; |
| 408 | PurpleRequestFieldGroup *g; | |
| 409 | PurpleRequestField *f; | |
| 410 | SilcPurpleChauth sgc; | |
| 8849 | 411 | const char *curpass = NULL; |
| 412 | ||
| 413 | sgc = silc_calloc(1, sizeof(*sgc)); | |
| 414 | if (!sgc) | |
| 415 | return; | |
| 416 | sgc->sg = sg; | |
| 417 | sgc->channel = channel; | |
| 418 | ||
| 15884 | 419 | fields = purple_request_fields_new(); |
| 8849 | 420 | |
| 421 | if (sgc->c) | |
| 15884 | 422 | curpass = purple_blist_node_get_string((PurpleBlistNode *)sgc->c, "passphrase"); |
| 8849 | 423 | |
| 15884 | 424 | g = purple_request_field_group_new(NULL); |
| 425 | f = purple_request_field_string_new("passphrase", _("Channel Passphrase"), | |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16492
diff
changeset
|
426 | curpass, FALSE); |
| 15884 | 427 | purple_request_field_string_set_masked(f, TRUE); |
| 428 | purple_request_field_group_add_field(g, f); | |
| 429 | purple_request_fields_add_group(fields, g); | |
| 8849 | 430 | |
| 15884 | 431 | g = purple_request_field_group_new(NULL); |
| 432 | f = purple_request_field_label_new("l1", _("Channel Public Keys List")); | |
| 433 | purple_request_field_group_add_field(g, f); | |
| 434 | purple_request_fields_add_group(fields, g); | |
| 8849 | 435 | |
| 436 | g_snprintf(t, sizeof(t), | |
| 437 | _("Channel authentication is used to secure the channel from " | |
| 438 | "unauthorized access. The authentication may be based on " | |
| 439 | "passphrase and digital signatures. If passphrase is set, it " | |
| 440 | "is required to be able to join. If channel public keys are set " | |
| 441 | "then only users whose public keys are listed are able to join.")); | |
| 442 | ||
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16492
diff
changeset
|
443 | if (!channel_pubkeys || !silc_dlist_count(channel_pubkeys)) { |
| 15884 | 444 | f = purple_request_field_list_new("list", NULL); |
| 445 | purple_request_field_group_add_field(g, f); | |
| 446 | purple_request_fields(sg->gc, _("Channel Authentication"), | |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16492
diff
changeset
|
447 | _("Channel Authentication"), t, fields, |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16492
diff
changeset
|
448 | _("Add / Remove"), G_CALLBACK(silcpurple_chat_chpk_cb), |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16492
diff
changeset
|
449 | _("OK"), G_CALLBACK(silcpurple_chat_chauth_ok), |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16492
diff
changeset
|
450 | purple_connection_get_account(sg->gc), NULL, NULL, sgc); |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16492
diff
changeset
|
451 | if (channel_pubkeys) |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16492
diff
changeset
|
452 | silc_dlist_uninit(channel_pubkeys); |
| 8849 | 453 | return; |
| 454 | } | |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16492
diff
changeset
|
455 | sgc->pubkeys = channel_pubkeys; |
| 8849 | 456 | |
| 15884 | 457 | g = purple_request_field_group_new(NULL); |
| 458 | f = purple_request_field_list_new("list", NULL); | |
| 459 | purple_request_field_group_add_field(g, f); | |
| 460 | purple_request_fields_add_group(fields, g); | |
| 8849 | 461 | |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16492
diff
changeset
|
462 | silc_dlist_start(channel_pubkeys); |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16492
diff
changeset
|
463 | while ((public_key = silc_dlist_get(channel_pubkeys))) { |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16492
diff
changeset
|
464 | pk = silc_pkcs_public_key_encode(public_key, &pk_len); |
|
20289
5c844288fbec
applied changes from 32f31e981f0618a4167aa98bcc22c2dab13d1550
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
18190
diff
changeset
|
465 | if (!pk) |
|
5c844288fbec
applied changes from 32f31e981f0618a4167aa98bcc22c2dab13d1550
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
18190
diff
changeset
|
466 | continue; |
| 8849 | 467 | fingerprint = silc_hash_fingerprint(NULL, pk + 4, pk_len - 4); |
| 468 | babbleprint = silc_hash_babbleprint(NULL, pk + 4, pk_len - 4); | |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16492
diff
changeset
|
469 | |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16492
diff
changeset
|
470 | silc_pubkey = silc_pkcs_get_context(SILC_PKCS_SILC, public_key); |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16492
diff
changeset
|
471 | ident = &silc_pubkey->identifier; |
| 8849 | 472 | |
| 473 | g_snprintf(tmp2, sizeof(tmp2), "%s\n %s\n %s", | |
| 474 | ident->realname ? ident->realname : ident->username ? | |
| 475 | ident->username : "", fingerprint, babbleprint); | |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16492
diff
changeset
|
476 | purple_request_field_list_add(f, tmp2, public_key); |
| 8849 | 477 | |
| 478 | silc_free(fingerprint); | |
| 479 | silc_free(babbleprint); | |
| 480 | } | |
| 481 | ||
| 15884 | 482 | purple_request_field_list_set_multi_select(f, FALSE); |
| 483 | purple_request_fields(sg->gc, _("Channel Authentication"), | |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16492
diff
changeset
|
484 | _("Channel Authentication"), t, fields, |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16492
diff
changeset
|
485 | _("Add / Remove"), G_CALLBACK(silcpurple_chat_chpk_cb), |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16492
diff
changeset
|
486 | _("OK"), G_CALLBACK(silcpurple_chat_chauth_ok), |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16492
diff
changeset
|
487 | purple_connection_get_account(sg->gc), NULL, NULL, sgc); |
| 8849 | 488 | } |
| 489 | ||
| 490 | static void | |
| 15884 | 491 | silcpurple_chat_chauth(PurpleBlistNode *node, gpointer data) |
| 8849 | 492 | { |
| 15884 | 493 | PurpleChat *chat; |
| 494 | PurpleConnection *gc; | |
| 495 | SilcPurple sg; | |
|
9030
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8891
diff
changeset
|
496 | |
| 15884 | 497 | g_return_if_fail(PURPLE_BLIST_NODE_IS_CHAT(node)); |
|
9030
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8891
diff
changeset
|
498 | |
| 15884 | 499 | chat = (PurpleChat *) node; |
| 500 | gc = purple_account_get_connection(chat->account); | |
|
9030
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8891
diff
changeset
|
501 | sg = gc->proto_data; |
|
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8891
diff
changeset
|
502 | |
| 8849 | 503 | silc_client_command_call(sg->client, sg->conn, NULL, "CMODE", |
|
9030
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8891
diff
changeset
|
504 | g_hash_table_lookup(chat->components, "channel"), |
| 8849 | 505 | "+C", NULL); |
| 506 | } | |
| 507 | ||
| 508 | ||
| 509 | /************************** Channel Private Groups **************************/ | |
| 510 | ||
| 511 | /* Private groups are "virtual" channels. They are groups inside a channel. | |
| 512 | This is implemented by using channel private keys. By knowing a channel | |
| 513 | private key user becomes part of that group and is able to talk on that | |
| 514 | group. Other users, on the same channel, won't be able to see the | |
| 515 | messages of that group. It is possible to have multiple groups inside | |
| 516 | a channel - and thus having multiple private keys on the channel. */ | |
| 517 | ||
| 518 | typedef struct { | |
| 15884 | 519 | SilcPurple sg; |
| 520 | PurpleChat *c; | |
| 8849 | 521 | const char *channel; |
| 15884 | 522 | } *SilcPurpleCharPrv; |
| 8849 | 523 | |
| 524 | static void | |
| 15884 | 525 | silcpurple_chat_prv_add(SilcPurpleCharPrv p, PurpleRequestFields *fields) |
| 8849 | 526 | { |
| 15884 | 527 | SilcPurple sg = p->sg; |
| 8849 | 528 | char tmp[512]; |
| 15884 | 529 | PurpleRequestField *f; |
| 8849 | 530 | const char *name, *passphrase, *alias; |
| 531 | GHashTable *comp; | |
| 15884 | 532 | PurpleGroup *g; |
| 533 | PurpleChat *cn; | |
| 8849 | 534 | |
| 15884 | 535 | f = purple_request_fields_get_field(fields, "name"); |
| 536 | name = purple_request_field_string_get_value(f); | |
| 8849 | 537 | if (!name) { |
| 538 | silc_free(p); | |
| 539 | return; | |
| 540 | } | |
| 15884 | 541 | f = purple_request_fields_get_field(fields, "passphrase"); |
| 542 | passphrase = purple_request_field_string_get_value(f); | |
| 543 | f = purple_request_fields_get_field(fields, "alias"); | |
| 544 | alias = purple_request_field_string_get_value(f); | |
| 8849 | 545 | |
| 546 | /* Add private group to buddy list */ | |
| 547 | g_snprintf(tmp, sizeof(tmp), "%s [Private Group]", name); | |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16492
diff
changeset
|
548 | comp = g_hash_table_new_full(g_str_hash, g_str_equal, NULL, g_free); |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16492
diff
changeset
|
549 | g_hash_table_replace(comp, "channel", g_strdup(tmp)); |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16492
diff
changeset
|
550 | g_hash_table_replace(comp, "passphrase", g_strdup(passphrase)); |
| 8849 | 551 | |
| 15884 | 552 | cn = purple_chat_new(sg->account, alias, comp); |
| 553 | g = (PurpleGroup *)p->c->node.parent; | |
| 554 | purple_blist_add_chat(cn, g, (PurpleBlistNode *)p->c); | |
| 8849 | 555 | |
| 556 | /* Associate to a real channel */ | |
| 15884 | 557 | purple_blist_node_set_string((PurpleBlistNode *)cn, "parentch", p->channel); |
| 8849 | 558 | |
| 559 | /* Join the group */ | |
| 15884 | 560 | silcpurple_chat_join(sg->gc, comp); |
| 8849 | 561 | |
| 562 | silc_free(p); | |
| 563 | } | |
| 564 | ||
| 565 | static void | |
| 15884 | 566 | silcpurple_chat_prv_cancel(SilcPurpleCharPrv p, PurpleRequestFields *fields) |
| 8849 | 567 | { |
| 568 | silc_free(p); | |
| 569 | } | |
| 570 | ||
| 571 | static void | |
| 15884 | 572 | silcpurple_chat_prv(PurpleBlistNode *node, gpointer data) |
| 8849 | 573 | { |
| 15884 | 574 | PurpleChat *chat; |
| 575 | PurpleConnection *gc; | |
| 576 | SilcPurple sg; | |
|
9030
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8891
diff
changeset
|
577 | |
| 15884 | 578 | SilcPurpleCharPrv p; |
| 579 | PurpleRequestFields *fields; | |
| 580 | PurpleRequestFieldGroup *g; | |
| 581 | PurpleRequestField *f; | |
| 8849 | 582 | char tmp[512]; |
| 583 | ||
| 15884 | 584 | g_return_if_fail(PURPLE_BLIST_NODE_IS_CHAT(node)); |
|
9030
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8891
diff
changeset
|
585 | |
| 15884 | 586 | chat = (PurpleChat *) node; |
| 587 | gc = purple_account_get_connection(chat->account); | |
|
9030
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8891
diff
changeset
|
588 | sg = gc->proto_data; |
|
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8891
diff
changeset
|
589 | |
| 8849 | 590 | p = silc_calloc(1, sizeof(*p)); |
| 591 | if (!p) | |
| 592 | return; | |
| 593 | p->sg = sg; | |
| 594 | ||
|
9030
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8891
diff
changeset
|
595 | p->channel = g_hash_table_lookup(chat->components, "channel"); |
| 15884 | 596 | p->c = purple_blist_find_chat(sg->account, p->channel); |
| 8849 | 597 | |
| 15884 | 598 | fields = purple_request_fields_new(); |
| 8849 | 599 | |
| 15884 | 600 | g = purple_request_field_group_new(NULL); |
| 601 | f = purple_request_field_string_new("name", _("Group Name"), | |
| 8849 | 602 | NULL, FALSE); |
| 15884 | 603 | purple_request_field_group_add_field(g, f); |
| 8849 | 604 | |
| 15884 | 605 | f = purple_request_field_string_new("passphrase", _("Passphrase"), |
| 8849 | 606 | NULL, FALSE); |
| 15884 | 607 | purple_request_field_string_set_masked(f, TRUE); |
| 608 | purple_request_field_group_add_field(g, f); | |
| 8849 | 609 | |
| 15884 | 610 | f = purple_request_field_string_new("alias", _("Alias"), |
| 8849 | 611 | NULL, FALSE); |
| 15884 | 612 | purple_request_field_group_add_field(g, f); |
| 613 | purple_request_fields_add_group(fields, g); | |
| 8849 | 614 | |
| 615 | g_snprintf(tmp, sizeof(tmp), | |
| 616 | _("Please enter the %s channel private group name and passphrase."), | |
| 617 | p->channel); | |
| 15884 | 618 | purple_request_fields(gc, _("Add Channel Private Group"), NULL, tmp, fields, |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16492
diff
changeset
|
619 | _("Add"), G_CALLBACK(silcpurple_chat_prv_add), |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16492
diff
changeset
|
620 | _("Cancel"), G_CALLBACK(silcpurple_chat_prv_cancel), |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16492
diff
changeset
|
621 | purple_connection_get_account(gc), NULL, NULL, p); |
| 8849 | 622 | } |
| 623 | ||
| 624 | ||
| 625 | /****************************** Channel Modes ********************************/ | |
| 626 | ||
| 627 | static void | |
| 15884 | 628 | silcpurple_chat_permanent_reset(PurpleBlistNode *node, gpointer data) |
| 8849 | 629 | { |
| 15884 | 630 | PurpleChat *chat; |
| 631 | PurpleConnection *gc; | |
| 632 | SilcPurple sg; | |
|
9030
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8891
diff
changeset
|
633 | |
| 15884 | 634 | g_return_if_fail(PURPLE_BLIST_NODE_IS_CHAT(node)); |
|
9030
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8891
diff
changeset
|
635 | |
| 15884 | 636 | chat = (PurpleChat *) node; |
| 637 | gc = purple_account_get_connection(chat->account); | |
|
9030
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8891
diff
changeset
|
638 | sg = gc->proto_data; |
|
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8891
diff
changeset
|
639 | |
| 8849 | 640 | silc_client_command_call(sg->client, sg->conn, NULL, "CMODE", |
|
9030
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8891
diff
changeset
|
641 | g_hash_table_lookup(chat->components, "channel"), |
| 8849 | 642 | "-f", NULL); |
| 643 | } | |
| 644 | ||
| 645 | static void | |
| 15884 | 646 | silcpurple_chat_permanent(PurpleBlistNode *node, gpointer data) |
| 8849 | 647 | { |
| 15884 | 648 | PurpleChat *chat; |
| 649 | PurpleConnection *gc; | |
| 650 | SilcPurple sg; | |
| 8849 | 651 | const char *channel; |
| 652 | ||
| 15884 | 653 | g_return_if_fail(PURPLE_BLIST_NODE_IS_CHAT(node)); |
|
9030
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8891
diff
changeset
|
654 | |
| 15884 | 655 | chat = (PurpleChat *) node; |
| 656 | gc = purple_account_get_connection(chat->account); | |
|
9030
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8891
diff
changeset
|
657 | sg = gc->proto_data; |
|
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8891
diff
changeset
|
658 | |
| 8849 | 659 | if (!sg->conn) |
| 660 | return; | |
| 661 | ||
| 662 | /* XXX we should have ability to define which founder | |
| 663 | key to use. Now we use the user's own public key | |
| 664 | (default key). */ | |
| 665 | ||
| 666 | /* Call CMODE */ | |
|
9030
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8891
diff
changeset
|
667 | channel = g_hash_table_lookup(chat->components, "channel"); |
| 8849 | 668 | silc_client_command_call(sg->client, sg->conn, NULL, "CMODE", channel, |
| 669 | "+f", NULL); | |
| 670 | } | |
| 671 | ||
| 672 | typedef struct { | |
| 15884 | 673 | SilcPurple sg; |
| 8849 | 674 | const char *channel; |
| 15884 | 675 | } *SilcPurpleChatInput; |
| 8849 | 676 | |
| 677 | static void | |
| 15884 | 678 | silcpurple_chat_ulimit_cb(SilcPurpleChatInput s, const char *limit) |
| 8849 | 679 | { |
| 680 | SilcChannelEntry channel; | |
| 681 | int ulimit = 0; | |
| 682 | ||
| 683 | channel = silc_client_get_channel(s->sg->client, s->sg->conn, | |
| 684 | (char *)s->channel); | |
| 685 | if (!channel) | |
| 686 | return; | |
| 687 | if (limit) | |
| 688 | ulimit = atoi(limit); | |
| 689 | ||
| 690 | if (!limit || !(*limit) || *limit == '0') { | |
| 691 | if (limit && ulimit == channel->user_limit) { | |
| 692 | silc_free(s); | |
| 693 | return; | |
| 694 | } | |
| 695 | silc_client_command_call(s->sg->client, s->sg->conn, NULL, "CMODE", | |
| 696 | s->channel, "-l", NULL); | |
| 697 | ||
| 698 | silc_free(s); | |
| 699 | return; | |
| 700 | } | |
| 701 | ||
| 702 | if (ulimit == channel->user_limit) { | |
| 703 | silc_free(s); | |
| 704 | return; | |
| 705 | } | |
| 706 | ||
| 707 | /* Call CMODE */ | |
| 708 | silc_client_command_call(s->sg->client, s->sg->conn, NULL, "CMODE", | |
| 709 | s->channel, "+l", limit, NULL); | |
| 710 | ||
| 711 | silc_free(s); | |
| 712 | } | |
| 713 | ||
| 714 | static void | |
| 15884 | 715 | silcpurple_chat_ulimit(PurpleBlistNode *node, gpointer data) |
| 8849 | 716 | { |
| 15884 | 717 | PurpleChat *chat; |
| 718 | PurpleConnection *gc; | |
| 719 | SilcPurple sg; | |
|
9030
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8891
diff
changeset
|
720 | |
| 15884 | 721 | SilcPurpleChatInput s; |
| 8849 | 722 | SilcChannelEntry channel; |
| 723 | const char *ch; | |
| 724 | char tmp[32]; | |
| 725 | ||
| 15884 | 726 | g_return_if_fail(PURPLE_BLIST_NODE_IS_CHAT(node)); |
|
9030
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8891
diff
changeset
|
727 | |
| 15884 | 728 | chat = (PurpleChat *) node; |
| 729 | gc = purple_account_get_connection(chat->account); | |
|
9030
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8891
diff
changeset
|
730 | sg = gc->proto_data; |
|
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8891
diff
changeset
|
731 | |
| 8849 | 732 | if (!sg->conn) |
| 733 | return; | |
| 734 | ||
|
9030
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8891
diff
changeset
|
735 | ch = g_strdup(g_hash_table_lookup(chat->components, "channel")); |
| 8849 | 736 | channel = silc_client_get_channel(sg->client, sg->conn, (char *)ch); |
| 737 | if (!channel) | |
| 738 | return; | |
| 739 | ||
| 740 | s = silc_calloc(1, sizeof(*s)); | |
| 741 | if (!s) | |
| 742 | return; | |
| 743 | s->channel = ch; | |
| 744 | s->sg = sg; | |
| 745 | g_snprintf(tmp, sizeof(tmp), "%d", (int)channel->user_limit); | |
| 15884 | 746 | purple_request_input(gc, _("User Limit"), NULL, |
| 8849 | 747 | _("Set user limit on channel. Set to zero to reset user limit."), |
| 748 | tmp, FALSE, FALSE, NULL, | |
| 15884 | 749 | _("OK"), G_CALLBACK(silcpurple_chat_ulimit_cb), |
|
16492
4f0dc2d16e55
Update SILC to match resent request API changes
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15884
diff
changeset
|
750 | _("Cancel"), G_CALLBACK(silcpurple_chat_ulimit_cb), |
|
4f0dc2d16e55
Update SILC to match resent request API changes
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15884
diff
changeset
|
751 | purple_connection_get_account(gc), NULL, NULL, s); |
| 8849 | 752 | } |
| 753 | ||
| 754 | static void | |
| 15884 | 755 | silcpurple_chat_resettopic(PurpleBlistNode *node, gpointer data) |
| 8849 | 756 | { |
| 15884 | 757 | PurpleChat *chat; |
| 758 | PurpleConnection *gc; | |
| 759 | SilcPurple sg; | |
|
9030
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8891
diff
changeset
|
760 | |
| 15884 | 761 | g_return_if_fail(PURPLE_BLIST_NODE_IS_CHAT(node)); |
|
9030
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8891
diff
changeset
|
762 | |
| 15884 | 763 | chat = (PurpleChat *) node; |
| 764 | gc = purple_account_get_connection(chat->account); | |
|
9030
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8891
diff
changeset
|
765 | sg = gc->proto_data; |
|
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8891
diff
changeset
|
766 | |
| 8849 | 767 | silc_client_command_call(sg->client, sg->conn, NULL, "CMODE", |
|
9030
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8891
diff
changeset
|
768 | g_hash_table_lookup(chat->components, "channel"), |
| 8849 | 769 | "-t", NULL); |
| 770 | } | |
| 771 | ||
| 772 | static void | |
| 15884 | 773 | silcpurple_chat_settopic(PurpleBlistNode *node, gpointer data) |
| 8849 | 774 | { |
| 15884 | 775 | PurpleChat *chat; |
| 776 | PurpleConnection *gc; | |
| 777 | SilcPurple sg; | |
|
9030
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8891
diff
changeset
|
778 | |
| 15884 | 779 | g_return_if_fail(PURPLE_BLIST_NODE_IS_CHAT(node)); |
|
9030
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8891
diff
changeset
|
780 | |
| 15884 | 781 | chat = (PurpleChat *) node; |
| 782 | gc = purple_account_get_connection(chat->account); | |
|
9030
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8891
diff
changeset
|
783 | sg = gc->proto_data; |
|
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8891
diff
changeset
|
784 | |
| 8849 | 785 | silc_client_command_call(sg->client, sg->conn, NULL, "CMODE", |
|
9030
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8891
diff
changeset
|
786 | g_hash_table_lookup(chat->components, "channel"), |
| 8849 | 787 | "+t", NULL); |
| 788 | } | |
| 789 | ||
| 790 | static void | |
| 15884 | 791 | silcpurple_chat_resetprivate(PurpleBlistNode *node, gpointer data) |
| 8849 | 792 | { |
| 15884 | 793 | PurpleChat *chat; |
| 794 | PurpleConnection *gc; | |
| 795 | SilcPurple sg; | |
|
9030
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8891
diff
changeset
|
796 | |
| 15884 | 797 | g_return_if_fail(PURPLE_BLIST_NODE_IS_CHAT(node)); |
|
9030
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8891
diff
changeset
|
798 | |
| 15884 | 799 | chat = (PurpleChat *) node; |
| 800 | gc = purple_account_get_connection(chat->account); | |
|
9030
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8891
diff
changeset
|
801 | sg = gc->proto_data; |
|
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8891
diff
changeset
|
802 | |
| 8849 | 803 | silc_client_command_call(sg->client, sg->conn, NULL, "CMODE", |
|
9030
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8891
diff
changeset
|
804 | g_hash_table_lookup(chat->components, "channel"), |
| 8849 | 805 | "-p", NULL); |
| 806 | } | |
| 807 | ||
| 808 | static void | |
| 15884 | 809 | silcpurple_chat_setprivate(PurpleBlistNode *node, gpointer data) |
| 8849 | 810 | { |
| 15884 | 811 | PurpleChat *chat; |
| 812 | PurpleConnection *gc; | |
| 813 | SilcPurple sg; | |
|
9030
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8891
diff
changeset
|
814 | |
| 15884 | 815 | g_return_if_fail(PURPLE_BLIST_NODE_IS_CHAT(node)); |
|
9030
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8891
diff
changeset
|
816 | |
| 15884 | 817 | chat = (PurpleChat *) node; |
| 818 | gc = purple_account_get_connection(chat->account); | |
|
9030
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8891
diff
changeset
|
819 | sg = gc->proto_data; |
|
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8891
diff
changeset
|
820 | |
| 8849 | 821 | silc_client_command_call(sg->client, sg->conn, NULL, "CMODE", |
|
9030
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8891
diff
changeset
|
822 | g_hash_table_lookup(chat->components, "channel"), |
| 8849 | 823 | "+p", NULL); |
| 824 | } | |
| 825 | ||
| 826 | static void | |
| 15884 | 827 | silcpurple_chat_resetsecret(PurpleBlistNode *node, gpointer data) |
| 8849 | 828 | { |
| 15884 | 829 | PurpleChat *chat; |
| 830 | PurpleConnection *gc; | |
| 831 | SilcPurple sg; | |
|
9030
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8891
diff
changeset
|
832 | |
| 15884 | 833 | g_return_if_fail(PURPLE_BLIST_NODE_IS_CHAT(node)); |
|
9030
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8891
diff
changeset
|
834 | |
| 15884 | 835 | chat = (PurpleChat *) node; |
| 836 | gc = purple_account_get_connection(chat->account); | |
|
9030
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8891
diff
changeset
|
837 | sg = gc->proto_data; |
|
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8891
diff
changeset
|
838 | |
| 8849 | 839 | silc_client_command_call(sg->client, sg->conn, NULL, "CMODE", |
|
9030
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8891
diff
changeset
|
840 | g_hash_table_lookup(chat->components, "channel"), |
| 8849 | 841 | "-s", NULL); |
| 842 | } | |
| 843 | ||
| 844 | static void | |
| 15884 | 845 | silcpurple_chat_setsecret(PurpleBlistNode *node, gpointer data) |
| 8849 | 846 | { |
| 15884 | 847 | PurpleChat *chat; |
| 848 | PurpleConnection *gc; | |
| 849 | SilcPurple sg; | |
|
9030
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8891
diff
changeset
|
850 | |
| 15884 | 851 | g_return_if_fail(PURPLE_BLIST_NODE_IS_CHAT(node)); |
|
9030
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8891
diff
changeset
|
852 | |
| 15884 | 853 | chat = (PurpleChat *) node; |
| 854 | gc = purple_account_get_connection(chat->account); | |
|
9030
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8891
diff
changeset
|
855 | sg = gc->proto_data; |
|
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8891
diff
changeset
|
856 | |
| 8849 | 857 | silc_client_command_call(sg->client, sg->conn, NULL, "CMODE", |
|
9030
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8891
diff
changeset
|
858 | g_hash_table_lookup(chat->components, "channel"), |
| 8849 | 859 | "+s", NULL); |
| 860 | } | |
| 861 | ||
|
12058
6d4b6e3bd0ba
[gaim-migrate @ 14353]
Pekka Riikonen <priikone@silcnet.org>
parents:
11454
diff
changeset
|
862 | typedef struct { |
| 15884 | 863 | SilcPurple sg; |
|
12058
6d4b6e3bd0ba
[gaim-migrate @ 14353]
Pekka Riikonen <priikone@silcnet.org>
parents:
11454
diff
changeset
|
864 | SilcChannelEntry channel; |
| 15884 | 865 | } *SilcPurpleChatWb; |
|
12058
6d4b6e3bd0ba
[gaim-migrate @ 14353]
Pekka Riikonen <priikone@silcnet.org>
parents:
11454
diff
changeset
|
866 | |
|
6d4b6e3bd0ba
[gaim-migrate @ 14353]
Pekka Riikonen <priikone@silcnet.org>
parents:
11454
diff
changeset
|
867 | static void |
| 15884 | 868 | silcpurple_chat_wb(PurpleBlistNode *node, gpointer data) |
|
12058
6d4b6e3bd0ba
[gaim-migrate @ 14353]
Pekka Riikonen <priikone@silcnet.org>
parents:
11454
diff
changeset
|
869 | { |
| 15884 | 870 | SilcPurpleChatWb wb = data; |
| 871 | silcpurple_wb_init_ch(wb->sg, wb->channel); | |
|
12058
6d4b6e3bd0ba
[gaim-migrate @ 14353]
Pekka Riikonen <priikone@silcnet.org>
parents:
11454
diff
changeset
|
872 | silc_free(wb); |
|
6d4b6e3bd0ba
[gaim-migrate @ 14353]
Pekka Riikonen <priikone@silcnet.org>
parents:
11454
diff
changeset
|
873 | } |
|
6d4b6e3bd0ba
[gaim-migrate @ 14353]
Pekka Riikonen <priikone@silcnet.org>
parents:
11454
diff
changeset
|
874 | |
| 15884 | 875 | GList *silcpurple_chat_menu(PurpleChat *chat) |
| 8849 | 876 | { |
| 9038 | 877 | GHashTable *components = chat->components; |
| 15884 | 878 | PurpleConnection *gc = purple_account_get_connection(chat->account); |
| 879 | SilcPurple sg = gc->proto_data; | |
| 8849 | 880 | SilcClientConnection conn = sg->conn; |
| 881 | const char *chname = NULL; | |
| 882 | SilcChannelEntry channel = NULL; | |
| 883 | SilcChannelUser chu = NULL; | |
| 884 | SilcUInt32 mode = 0; | |
| 885 | ||
| 9038 | 886 | GList *m = NULL; |
| 15884 | 887 | PurpleMenuAction *act; |
|
9030
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8891
diff
changeset
|
888 | |
| 8849 | 889 | if (components) |
| 890 | chname = g_hash_table_lookup(components, "channel"); | |
| 891 | if (chname) | |
| 892 | channel = silc_client_get_channel(sg->client, sg->conn, | |
| 893 | (char *)chname); | |
| 894 | if (channel) { | |
| 895 | chu = silc_client_on_channel(channel, conn->local_entry); | |
| 896 | if (chu) | |
| 897 | mode = chu->mode; | |
| 898 | } | |
| 899 | ||
| 900 | if (strstr(chname, "[Private Group]")) | |
| 901 | return NULL; | |
| 902 | ||
| 15884 | 903 | act = purple_menu_action_new(_("Get Info"), |
| 904 | PURPLE_CALLBACK(silcpurple_chat_getinfo_menu), | |
| 12919 | 905 | NULL, NULL); |
|
9030
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8891
diff
changeset
|
906 | m = g_list_append(m, act); |
| 8849 | 907 | |
| 908 | #if 0 /* XXX For now these are not implemented. We need better | |
| 15884 | 909 | listview dialog from Purple for these. */ |
| 8849 | 910 | if (mode & SILC_CHANNEL_UMODE_CHANOP) { |
| 15884 | 911 | act = purple_menu_action_new(_("Invite List"), |
| 912 | PURPLE_CALLBACK(silcpurple_chat_invitelist), | |
| 12919 | 913 | NULL, NULL); |
|
9030
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8891
diff
changeset
|
914 | m = g_list_append(m, act); |
| 8849 | 915 | |
| 15884 | 916 | act = purple_menu_action_new(_("Ban List"), |
| 917 | PURPLE_CALLBACK(silcpurple_chat_banlist), | |
| 12919 | 918 | NULL, NULL); |
|
9030
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8891
diff
changeset
|
919 | m = g_list_append(m, act); |
| 8849 | 920 | } |
| 921 | #endif | |
| 922 | ||
| 923 | if (chu) { | |
| 15884 | 924 | act = purple_menu_action_new(_("Add Private Group"), |
| 925 | PURPLE_CALLBACK(silcpurple_chat_prv), | |
| 12919 | 926 | NULL, NULL); |
|
9030
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8891
diff
changeset
|
927 | m = g_list_append(m, act); |
| 8849 | 928 | } |
| 929 | ||
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16492
diff
changeset
|
930 | if (chu && mode & SILC_CHANNEL_UMODE_CHANFO) { |
| 15884 | 931 | act = purple_menu_action_new(_("Channel Authentication"), |
| 932 | PURPLE_CALLBACK(silcpurple_chat_chauth), | |
| 12919 | 933 | NULL, NULL); |
|
9030
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8891
diff
changeset
|
934 | m = g_list_append(m, act); |
| 8849 | 935 | |
| 936 | if (channel->mode & SILC_CHANNEL_MODE_FOUNDER_AUTH) { | |
| 15884 | 937 | act = purple_menu_action_new(_("Reset Permanent"), |
| 938 | PURPLE_CALLBACK(silcpurple_chat_permanent_reset), | |
| 12919 | 939 | NULL, NULL); |
|
9030
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8891
diff
changeset
|
940 | m = g_list_append(m, act); |
| 8849 | 941 | } else { |
| 15884 | 942 | act = purple_menu_action_new(_("Set Permanent"), |
| 943 | PURPLE_CALLBACK(silcpurple_chat_permanent), | |
| 12919 | 944 | NULL, NULL); |
|
9030
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8891
diff
changeset
|
945 | m = g_list_append(m, act); |
| 8849 | 946 | } |
| 947 | } | |
| 948 | ||
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16492
diff
changeset
|
949 | if (chu && mode & SILC_CHANNEL_UMODE_CHANOP) { |
| 15884 | 950 | act = purple_menu_action_new(_("Set User Limit"), |
| 951 | PURPLE_CALLBACK(silcpurple_chat_ulimit), | |
| 12919 | 952 | NULL, NULL); |
|
9030
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8891
diff
changeset
|
953 | m = g_list_append(m, act); |
| 8849 | 954 | |
| 955 | if (channel->mode & SILC_CHANNEL_MODE_TOPIC) { | |
| 15884 | 956 | act = purple_menu_action_new(_("Reset Topic Restriction"), |
| 957 | PURPLE_CALLBACK(silcpurple_chat_resettopic), | |
| 12919 | 958 | NULL, NULL); |
|
9030
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8891
diff
changeset
|
959 | m = g_list_append(m, act); |
| 8849 | 960 | } else { |
| 15884 | 961 | act = purple_menu_action_new(_("Set Topic Restriction"), |
| 962 | PURPLE_CALLBACK(silcpurple_chat_settopic), | |
| 12919 | 963 | NULL, NULL); |
|
9030
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8891
diff
changeset
|
964 | m = g_list_append(m, act); |
| 8849 | 965 | } |
| 966 | ||
| 967 | if (channel->mode & SILC_CHANNEL_MODE_PRIVATE) { | |
| 15884 | 968 | act = purple_menu_action_new(_("Reset Private Channel"), |
| 969 | PURPLE_CALLBACK(silcpurple_chat_resetprivate), | |
| 12919 | 970 | NULL, NULL); |
|
9030
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8891
diff
changeset
|
971 | m = g_list_append(m, act); |
| 8849 | 972 | } else { |
| 15884 | 973 | act = purple_menu_action_new(_("Set Private Channel"), |
| 974 | PURPLE_CALLBACK(silcpurple_chat_setprivate), | |
| 12919 | 975 | NULL, NULL); |
|
9030
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8891
diff
changeset
|
976 | m = g_list_append(m, act); |
| 8849 | 977 | } |
| 978 | ||
| 979 | if (channel->mode & SILC_CHANNEL_MODE_SECRET) { | |
| 15884 | 980 | act = purple_menu_action_new(_("Reset Secret Channel"), |
| 981 | PURPLE_CALLBACK(silcpurple_chat_resetsecret), | |
| 12919 | 982 | NULL, NULL); |
|
9030
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8891
diff
changeset
|
983 | m = g_list_append(m, act); |
| 8849 | 984 | } else { |
| 15884 | 985 | act = purple_menu_action_new(_("Set Secret Channel"), |
| 986 | PURPLE_CALLBACK(silcpurple_chat_setsecret), | |
| 12919 | 987 | NULL, NULL); |
|
9030
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8891
diff
changeset
|
988 | m = g_list_append(m, act); |
| 8849 | 989 | } |
| 990 | } | |
| 991 | ||
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16492
diff
changeset
|
992 | if (chu && channel) { |
| 15884 | 993 | SilcPurpleChatWb wb; |
| 12919 | 994 | wb = silc_calloc(1, sizeof(*wb)); |
| 995 | wb->sg = sg; | |
| 996 | wb->channel = channel; | |
| 15884 | 997 | act = purple_menu_action_new(_("Draw On Whiteboard"), |
| 998 | PURPLE_CALLBACK(silcpurple_chat_wb), | |
| 12919 | 999 | (void *)wb, NULL); |
| 1000 | m = g_list_append(m, act); | |
|
12058
6d4b6e3bd0ba
[gaim-migrate @ 14353]
Pekka Riikonen <priikone@silcnet.org>
parents:
11454
diff
changeset
|
1001 | } |
|
6d4b6e3bd0ba
[gaim-migrate @ 14353]
Pekka Riikonen <priikone@silcnet.org>
parents:
11454
diff
changeset
|
1002 | |
| 8849 | 1003 | return m; |
| 1004 | } | |
| 1005 | ||
| 1006 | ||
| 1007 | /******************************* Joining Etc. ********************************/ | |
| 1008 | ||
| 15884 | 1009 | char *silcpurple_get_chat_name(GHashTable *data) |
|
9917
2fbb3c9fab2b
[gaim-migrate @ 10809]
Daniel Atallah <datallah@pidgin.im>
parents:
9754
diff
changeset
|
1010 | { |
|
2fbb3c9fab2b
[gaim-migrate @ 10809]
Daniel Atallah <datallah@pidgin.im>
parents:
9754
diff
changeset
|
1011 | return g_strdup(g_hash_table_lookup(data, "channel")); |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16492
diff
changeset
|
1012 | } |
|
9917
2fbb3c9fab2b
[gaim-migrate @ 10809]
Daniel Atallah <datallah@pidgin.im>
parents:
9754
diff
changeset
|
1013 | |
| 15884 | 1014 | void silcpurple_chat_join(PurpleConnection *gc, GHashTable *data) |
| 8849 | 1015 | { |
| 15884 | 1016 | SilcPurple sg = gc->proto_data; |
| 8849 | 1017 | SilcClient client = sg->client; |
| 1018 | SilcClientConnection conn = sg->conn; | |
| 1019 | const char *channel, *passphrase, *parentch; | |
| 1020 | ||
| 1021 | if (!conn) | |
| 1022 | return; | |
| 1023 | ||
| 1024 | channel = g_hash_table_lookup(data, "channel"); | |
| 1025 | passphrase = g_hash_table_lookup(data, "passphrase"); | |
| 1026 | ||
| 1027 | /* Check if we are joining a private group. Handle it | |
| 1028 | purely locally as it's not a real channel */ | |
| 1029 | if (strstr(channel, "[Private Group]")) { | |
| 1030 | SilcChannelEntry channel_entry; | |
| 1031 | SilcChannelPrivateKey key; | |
| 15884 | 1032 | PurpleChat *c; |
| 1033 | SilcPurplePrvgrp grp; | |
| 8849 | 1034 | |
| 15884 | 1035 | c = purple_blist_find_chat(sg->account, channel); |
| 1036 | parentch = purple_blist_node_get_string((PurpleBlistNode *)c, "parentch"); | |
| 8849 | 1037 | if (!parentch) |
| 1038 | return; | |
| 1039 | ||
| 1040 | channel_entry = silc_client_get_channel(sg->client, sg->conn, | |
| 1041 | (char *)parentch); | |
| 1042 | if (!channel_entry || | |
| 1043 | !silc_client_on_channel(channel_entry, sg->conn->local_entry)) { | |
| 1044 | char tmp[512]; | |
| 1045 | g_snprintf(tmp, sizeof(tmp), | |
| 1046 | _("You have to join the %s channel before you are " | |
| 1047 | "able to join the private group"), parentch); | |
| 15884 | 1048 | purple_notify_error(gc, _("Join Private Group"), |
| 8849 | 1049 | _("Cannot join private group"), tmp); |
| 1050 | return; | |
| 1051 | } | |
| 1052 | ||
| 1053 | /* Add channel private key */ | |
| 1054 | if (!silc_client_add_channel_private_key(client, conn, | |
| 1055 | channel_entry, channel, | |
| 1056 | NULL, NULL, | |
| 1057 | (unsigned char *)passphrase, | |
| 1058 | strlen(passphrase), &key)) | |
| 1059 | return; | |
| 1060 | ||
| 1061 | /* Join the group */ | |
| 1062 | grp = silc_calloc(1, sizeof(*grp)); | |
| 1063 | if (!grp) | |
| 1064 | return; | |
| 15884 | 1065 | grp->id = ++sg->channel_ids + SILCPURPLE_PRVGRP; |
| 8849 | 1066 | grp->chid = SILC_PTR_TO_32(channel_entry->context); |
| 1067 | grp->parentch = parentch; | |
| 1068 | grp->channel = channel; | |
| 1069 | grp->key = key; | |
| 1070 | sg->grps = g_list_append(sg->grps, grp); | |
| 1071 | serv_got_joined_chat(gc, grp->id, channel); | |
| 1072 | return; | |
| 1073 | } | |
| 1074 | ||
| 1075 | /* XXX We should have other properties here as well: | |
| 1076 | 1. whether to try to authenticate to the channel | |
| 1077 | 1a. with default key, | |
| 1078 | 1b. with specific key. | |
| 1079 | 2. whether to try to authenticate to become founder. | |
| 1080 | 2a. with default key, | |
| 1081 | 2b. with specific key. | |
| 1082 | ||
| 1083 | Since now such variety is not possible in the join dialog | |
| 1084 | we always use -founder and -auth options, which try to | |
| 1085 | do both 1 and 2 with default keys. */ | |
| 1086 | ||
| 1087 | /* Call JOIN */ | |
|
9172
2e04033bc831
[gaim-migrate @ 9957]
Mark Doliner <markdoliner@pidgin.im>
parents:
9168
diff
changeset
|
1088 | if ((passphrase != NULL) && (*passphrase != '\0')) |
| 8849 | 1089 | silc_client_command_call(client, conn, NULL, "JOIN", |
| 1090 | channel, passphrase, "-auth", "-founder", NULL); | |
| 1091 | else | |
| 1092 | silc_client_command_call(client, conn, NULL, "JOIN", | |
| 1093 | channel, "-auth", "-founder", NULL); | |
| 1094 | } | |
| 1095 | ||
| 15884 | 1096 | void silcpurple_chat_invite(PurpleConnection *gc, int id, const char *msg, |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16492
diff
changeset
|
1097 | const char *name) |
| 8849 | 1098 | { |
| 15884 | 1099 | SilcPurple sg = gc->proto_data; |
| 8849 | 1100 | SilcClient client = sg->client; |
| 1101 | SilcClientConnection conn = sg->conn; | |
| 1102 | SilcHashTableList htl; | |
| 1103 | SilcChannelUser chu; | |
| 1104 | gboolean found = FALSE; | |
| 1105 | ||
| 1106 | if (!conn) | |
| 1107 | return; | |
| 1108 | ||
| 1109 | /* See if we are inviting on a private group. Invite | |
| 1110 | to the actual channel */ | |
| 15884 | 1111 | if (id > SILCPURPLE_PRVGRP) { |
| 8849 | 1112 | GList *l; |
| 15884 | 1113 | SilcPurplePrvgrp prv; |
| 8849 | 1114 | |
| 1115 | for (l = sg->grps; l; l = l->next) | |
| 15884 | 1116 | if (((SilcPurplePrvgrp)l->data)->id == id) |
| 8849 | 1117 | break; |
| 1118 | if (!l) | |
| 1119 | return; | |
| 1120 | prv = l->data; | |
| 1121 | id = prv->chid; | |
| 1122 | } | |
| 1123 | ||
| 1124 | /* Find channel by id */ | |
| 1125 | silc_hash_table_list(conn->local_entry->channels, &htl); | |
| 1126 | while (silc_hash_table_get(&htl, NULL, (void *)&chu)) { | |
| 1127 | if (SILC_PTR_TO_32(chu->channel->context) == id ) { | |
| 1128 | found = TRUE; | |
| 1129 | break; | |
| 1130 | } | |
| 1131 | } | |
| 1132 | silc_hash_table_list_reset(&htl); | |
| 1133 | if (!found) | |
| 1134 | return; | |
| 1135 | ||
| 1136 | /* Call INVITE */ | |
| 1137 | silc_client_command_call(client, conn, NULL, "INVITE", | |
| 1138 | chu->channel->channel_name, | |
|
9353
ff6546387358
[gaim-migrate @ 10161]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9295
diff
changeset
|
1139 | name, NULL); |
| 8849 | 1140 | } |
| 1141 | ||
| 15884 | 1142 | void silcpurple_chat_leave(PurpleConnection *gc, int id) |
| 8849 | 1143 | { |
| 15884 | 1144 | SilcPurple sg = gc->proto_data; |
| 8849 | 1145 | SilcClient client = sg->client; |
| 1146 | SilcClientConnection conn = sg->conn; | |
| 1147 | SilcHashTableList htl; | |
| 1148 | SilcChannelUser chu; | |
| 1149 | gboolean found = FALSE; | |
| 1150 | GList *l; | |
| 15884 | 1151 | SilcPurplePrvgrp prv; |
| 8849 | 1152 | |
| 1153 | if (!conn) | |
| 1154 | return; | |
| 1155 | ||
| 1156 | /* See if we are leaving a private group */ | |
| 15884 | 1157 | if (id > SILCPURPLE_PRVGRP) { |
| 8849 | 1158 | SilcChannelEntry channel; |
| 1159 | ||
| 1160 | for (l = sg->grps; l; l = l->next) | |
| 15884 | 1161 | if (((SilcPurplePrvgrp)l->data)->id == id) |
| 8849 | 1162 | break; |
| 1163 | if (!l) | |
| 1164 | return; | |
| 1165 | prv = l->data; | |
| 1166 | channel = silc_client_get_channel(sg->client, sg->conn, | |
| 1167 | (char *)prv->parentch); | |
| 1168 | if (!channel) | |
| 1169 | return; | |
| 1170 | silc_client_del_channel_private_key(client, conn, | |
| 1171 | channel, prv->key); | |
| 1172 | silc_free(prv); | |
| 1173 | sg->grps = g_list_remove(sg->grps, prv); | |
| 1174 | serv_got_chat_left(gc, id); | |
| 1175 | return; | |
| 1176 | } | |
| 1177 | ||
| 1178 | /* Find channel by id */ | |
| 1179 | silc_hash_table_list(conn->local_entry->channels, &htl); | |
| 1180 | while (silc_hash_table_get(&htl, NULL, (void *)&chu)) { | |
| 1181 | if (SILC_PTR_TO_32(chu->channel->context) == id ) { | |
| 1182 | found = TRUE; | |
| 1183 | break; | |
| 1184 | } | |
| 1185 | } | |
| 1186 | silc_hash_table_list_reset(&htl); | |
| 1187 | if (!found) | |
| 1188 | return; | |
| 1189 | ||
| 1190 | /* Call LEAVE */ | |
| 1191 | silc_client_command_call(client, conn, NULL, "LEAVE", | |
| 1192 | chu->channel->channel_name, NULL); | |
| 1193 | ||
| 1194 | serv_got_chat_left(gc, id); | |
| 1195 | ||
| 1196 | /* Leave from private groups on this channel as well */ | |
| 1197 | for (l = sg->grps; l; l = l->next) | |
| 15884 | 1198 | if (((SilcPurplePrvgrp)l->data)->chid == id) { |
| 8849 | 1199 | prv = l->data; |
| 1200 | silc_client_del_channel_private_key(client, conn, | |
| 1201 | chu->channel, | |
| 1202 | prv->key); | |
| 1203 | serv_got_chat_left(gc, prv->id); | |
| 1204 | silc_free(prv); | |
| 1205 | sg->grps = g_list_remove(sg->grps, prv); | |
| 1206 | if (!sg->grps) | |
| 1207 | break; | |
| 1208 | } | |
| 1209 | } | |
| 1210 | ||
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16492
diff
changeset
|
1211 | int silcpurple_chat_send(PurpleConnection *gc, int id, const char *msg, |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16492
diff
changeset
|
1212 | PurpleMessageFlags msgflags) |
| 8849 | 1213 | { |
| 15884 | 1214 | SilcPurple sg = gc->proto_data; |
| 8849 | 1215 | SilcClient client = sg->client; |
| 1216 | SilcClientConnection conn = sg->conn; | |
| 1217 | SilcHashTableList htl; | |
| 1218 | SilcChannelUser chu; | |
| 1219 | SilcChannelEntry channel = NULL; | |
| 1220 | SilcChannelPrivateKey key = NULL; | |
| 1221 | SilcUInt32 flags; | |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16492
diff
changeset
|
1222 | int ret = 0; |
|
12216
d80739091a63
[gaim-migrate @ 14518]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
12167
diff
changeset
|
1223 | char *msg2, *tmp; |
| 8849 | 1224 | gboolean found = FALSE; |
| 15884 | 1225 | gboolean sign = purple_account_get_bool(sg->account, "sign-verify", FALSE); |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16492
diff
changeset
|
1226 | SilcDList list; |
| 8849 | 1227 | |
| 1228 | if (!msg || !conn) | |
| 1229 | return 0; | |
| 1230 | ||
|
9353
ff6546387358
[gaim-migrate @ 10161]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9295
diff
changeset
|
1231 | flags = SILC_MESSAGE_FLAG_UTF8; |
|
ff6546387358
[gaim-migrate @ 10161]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9295
diff
changeset
|
1232 | |
| 15884 | 1233 | tmp = msg2 = purple_unescape_html(msg); |
|
9353
ff6546387358
[gaim-migrate @ 10161]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9295
diff
changeset
|
1234 | |
|
ff6546387358
[gaim-migrate @ 10161]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9295
diff
changeset
|
1235 | if (!g_ascii_strncasecmp(msg2, "/me ", 4)) |
|
ff6546387358
[gaim-migrate @ 10161]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9295
diff
changeset
|
1236 | { |
|
ff6546387358
[gaim-migrate @ 10161]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9295
diff
changeset
|
1237 | msg2 += 4; |
|
12216
d80739091a63
[gaim-migrate @ 14518]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
12167
diff
changeset
|
1238 | if (!*msg2) { |
|
d80739091a63
[gaim-migrate @ 14518]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
12167
diff
changeset
|
1239 | g_free(tmp); |
|
9353
ff6546387358
[gaim-migrate @ 10161]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9295
diff
changeset
|
1240 | return 0; |
|
12216
d80739091a63
[gaim-migrate @ 14518]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
12167
diff
changeset
|
1241 | } |
|
9353
ff6546387358
[gaim-migrate @ 10161]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9295
diff
changeset
|
1242 | flags |= SILC_MESSAGE_FLAG_ACTION; |
|
ff6546387358
[gaim-migrate @ 10161]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9295
diff
changeset
|
1243 | } else if (strlen(msg) > 1 && msg[0] == '/') { |
| 8849 | 1244 | if (!silc_client_command_call(client, conn, msg + 1)) |
| 15884 | 1245 | purple_notify_error(gc, _("Call Command"), _("Cannot call command"), |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16492
diff
changeset
|
1246 | _("Unknown command")); |
|
12216
d80739091a63
[gaim-migrate @ 14518]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
12167
diff
changeset
|
1247 | g_free(tmp); |
| 8849 | 1248 | return 0; |
| 1249 | } | |
| 1250 | ||
|
9353
ff6546387358
[gaim-migrate @ 10161]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9295
diff
changeset
|
1251 | |
| 8849 | 1252 | if (sign) |
| 1253 | flags |= SILC_MESSAGE_FLAG_SIGNED; | |
| 1254 | ||
| 1255 | /* Get the channel private key if we are sending on | |
| 1256 | private group */ | |
| 15884 | 1257 | if (id > SILCPURPLE_PRVGRP) { |
| 8849 | 1258 | GList *l; |
| 15884 | 1259 | SilcPurplePrvgrp prv; |
| 8849 | 1260 | |
| 1261 | for (l = sg->grps; l; l = l->next) | |
| 15884 | 1262 | if (((SilcPurplePrvgrp)l->data)->id == id) |
| 8849 | 1263 | break; |
|
12216
d80739091a63
[gaim-migrate @ 14518]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
12167
diff
changeset
|
1264 | if (!l) { |
|
d80739091a63
[gaim-migrate @ 14518]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
12167
diff
changeset
|
1265 | g_free(tmp); |
| 8849 | 1266 | return 0; |
|
12216
d80739091a63
[gaim-migrate @ 14518]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
12167
diff
changeset
|
1267 | } |
| 8849 | 1268 | prv = l->data; |
| 1269 | channel = silc_client_get_channel(sg->client, sg->conn, | |
| 1270 | (char *)prv->parentch); | |
|
12216
d80739091a63
[gaim-migrate @ 14518]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
12167
diff
changeset
|
1271 | if (!channel) { |
|
d80739091a63
[gaim-migrate @ 14518]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
12167
diff
changeset
|
1272 | g_free(tmp); |
| 8849 | 1273 | return 0; |
|
12216
d80739091a63
[gaim-migrate @ 14518]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
12167
diff
changeset
|
1274 | } |
| 8849 | 1275 | key = prv->key; |
| 1276 | } | |
| 1277 | ||
| 1278 | if (!channel) { | |
| 1279 | /* Find channel by id */ | |
| 1280 | silc_hash_table_list(conn->local_entry->channels, &htl); | |
| 1281 | while (silc_hash_table_get(&htl, NULL, (void *)&chu)) { | |
| 1282 | if (SILC_PTR_TO_32(chu->channel->context) == id ) { | |
| 1283 | found = TRUE; | |
| 1284 | break; | |
| 1285 | } | |
| 1286 | } | |
| 1287 | silc_hash_table_list_reset(&htl); | |
|
12216
d80739091a63
[gaim-migrate @ 14518]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
12167
diff
changeset
|
1288 | if (!found) { |
|
d80739091a63
[gaim-migrate @ 14518]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
12167
diff
changeset
|
1289 | g_free(tmp); |
| 8849 | 1290 | return 0; |
|
12216
d80739091a63
[gaim-migrate @ 14518]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
12167
diff
changeset
|
1291 | } |
| 8849 | 1292 | channel = chu->channel; |
| 1293 | } | |
| 1294 | ||
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16492
diff
changeset
|
1295 | /* Check for images */ |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16492
diff
changeset
|
1296 | if (msgflags & PURPLE_MESSAGE_IMAGES) { |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16492
diff
changeset
|
1297 | list = silcpurple_image_message(msg, &flags); |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16492
diff
changeset
|
1298 | if (list) { |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16492
diff
changeset
|
1299 | /* Send one or more MIME message. If more than one, they |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16492
diff
changeset
|
1300 | are MIME fragments due to over large message */ |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16492
diff
changeset
|
1301 | SilcBuffer buf; |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16492
diff
changeset
|
1302 | |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16492
diff
changeset
|
1303 | silc_dlist_start(list); |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16492
diff
changeset
|
1304 | while ((buf = silc_dlist_get(list)) != SILC_LIST_END) |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16492
diff
changeset
|
1305 | ret = |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16492
diff
changeset
|
1306 | silc_client_send_channel_message(client, conn, |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16492
diff
changeset
|
1307 | channel, key, |
|
20289
5c844288fbec
applied changes from 32f31e981f0618a4167aa98bcc22c2dab13d1550
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
18190
diff
changeset
|
1308 | flags, sg->sha1hash, |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16492
diff
changeset
|
1309 | buf->data, |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16492
diff
changeset
|
1310 | silc_buffer_len(buf)); |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16492
diff
changeset
|
1311 | silc_mime_partial_free(list); |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16492
diff
changeset
|
1312 | g_free(tmp); |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16492
diff
changeset
|
1313 | |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16492
diff
changeset
|
1314 | if (ret) |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16492
diff
changeset
|
1315 | serv_got_chat_in(gc, id, purple_connection_get_display_name(gc), 0, msg, time(NULL)); |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16492
diff
changeset
|
1316 | return ret; |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16492
diff
changeset
|
1317 | } |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16492
diff
changeset
|
1318 | } |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16492
diff
changeset
|
1319 | |
| 8849 | 1320 | /* Send channel message */ |
| 1321 | ret = silc_client_send_channel_message(client, conn, channel, key, | |
|
20289
5c844288fbec
applied changes from 32f31e981f0618a4167aa98bcc22c2dab13d1550
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
18190
diff
changeset
|
1322 | flags, sg->sha1hash, |
|
5c844288fbec
applied changes from 32f31e981f0618a4167aa98bcc22c2dab13d1550
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
18190
diff
changeset
|
1323 | (unsigned char *)msg2, |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16492
diff
changeset
|
1324 | strlen(msg2)); |
|
9359
89c40efa7f7b
[gaim-migrate @ 10167]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9353
diff
changeset
|
1325 | if (ret) { |
| 15884 | 1326 | serv_got_chat_in(gc, id, purple_connection_get_display_name(gc), 0, msg, |
| 8849 | 1327 | time(NULL)); |
|
9359
89c40efa7f7b
[gaim-migrate @ 10167]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9353
diff
changeset
|
1328 | } |
|
12216
d80739091a63
[gaim-migrate @ 14518]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
12167
diff
changeset
|
1329 | g_free(tmp); |
| 8849 | 1330 | |
| 1331 | return ret; | |
| 1332 | } | |
| 1333 | ||
| 15884 | 1334 | void silcpurple_chat_set_topic(PurpleConnection *gc, int id, const char *topic) |
| 8849 | 1335 | { |
| 15884 | 1336 | SilcPurple sg = gc->proto_data; |
| 8849 | 1337 | SilcClient client = sg->client; |
| 1338 | SilcClientConnection conn = sg->conn; | |
| 1339 | SilcHashTableList htl; | |
| 1340 | SilcChannelUser chu; | |
| 1341 | gboolean found = FALSE; | |
| 1342 | ||
|
9353
ff6546387358
[gaim-migrate @ 10161]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9295
diff
changeset
|
1343 | if (!conn) |
| 8849 | 1344 | return; |
| 1345 | ||
| 1346 | /* See if setting topic on private group. Set it | |
| 1347 | on the actual channel */ | |
| 15884 | 1348 | if (id > SILCPURPLE_PRVGRP) { |
| 8849 | 1349 | GList *l; |
| 15884 | 1350 | SilcPurplePrvgrp prv; |
| 8849 | 1351 | |
| 1352 | for (l = sg->grps; l; l = l->next) | |
| 15884 | 1353 | if (((SilcPurplePrvgrp)l->data)->id == id) |
| 8849 | 1354 | break; |
| 1355 | if (!l) | |
| 1356 | return; | |
| 1357 | prv = l->data; | |
| 1358 | id = prv->chid; | |
| 1359 | } | |
| 1360 | ||
| 1361 | /* Find channel by id */ | |
| 1362 | silc_hash_table_list(conn->local_entry->channels, &htl); | |
| 1363 | while (silc_hash_table_get(&htl, NULL, (void *)&chu)) { | |
| 1364 | if (SILC_PTR_TO_32(chu->channel->context) == id ) { | |
| 1365 | found = TRUE; | |
| 1366 | break; | |
| 1367 | } | |
| 1368 | } | |
| 1369 | silc_hash_table_list_reset(&htl); | |
| 1370 | if (!found) | |
| 1371 | return; | |
| 1372 | ||
| 1373 | /* Call TOPIC */ | |
| 1374 | silc_client_command_call(client, conn, NULL, "TOPIC", | |
| 1375 | chu->channel->channel_name, topic, NULL); | |
| 1376 | } | |
| 1377 | ||
| 15884 | 1378 | PurpleRoomlist *silcpurple_roomlist_get_list(PurpleConnection *gc) |
| 8849 | 1379 | { |
| 15884 | 1380 | SilcPurple sg = gc->proto_data; |
| 8849 | 1381 | SilcClient client = sg->client; |
| 1382 | SilcClientConnection conn = sg->conn; | |
| 1383 | GList *fields = NULL; | |
| 15884 | 1384 | PurpleRoomlistField *f; |
| 8849 | 1385 | |
| 1386 | if (!conn) | |
| 1387 | return NULL; | |
| 1388 | ||
| 1389 | if (sg->roomlist) | |
| 15884 | 1390 | purple_roomlist_unref(sg->roomlist); |
| 8849 | 1391 | |
| 1392 | sg->roomlist_canceled = FALSE; | |
| 1393 | ||
| 15884 | 1394 | sg->roomlist = purple_roomlist_new(purple_connection_get_account(gc)); |
| 1395 | f = purple_roomlist_field_new(PURPLE_ROOMLIST_FIELD_STRING, "", "channel", TRUE); | |
| 8849 | 1396 | fields = g_list_append(fields, f); |
| 15884 | 1397 | f = purple_roomlist_field_new(PURPLE_ROOMLIST_FIELD_INT, |
| 8849 | 1398 | _("Users"), "users", FALSE); |
| 1399 | fields = g_list_append(fields, f); | |
| 15884 | 1400 | f = purple_roomlist_field_new(PURPLE_ROOMLIST_FIELD_STRING, |
| 8849 | 1401 | _("Topic"), "topic", FALSE); |
| 1402 | fields = g_list_append(fields, f); | |
| 15884 | 1403 | purple_roomlist_set_fields(sg->roomlist, fields); |
| 8849 | 1404 | |
| 1405 | /* Call LIST */ | |
| 1406 | silc_client_command_call(client, conn, "LIST"); | |
| 1407 | ||
| 15884 | 1408 | purple_roomlist_set_in_progress(sg->roomlist, TRUE); |
| 8849 | 1409 | |
| 1410 | return sg->roomlist; | |
| 1411 | } | |
| 1412 | ||
| 15884 | 1413 | void silcpurple_roomlist_cancel(PurpleRoomlist *list) |
| 8849 | 1414 | { |
| 15884 | 1415 | PurpleConnection *gc = purple_account_get_connection(list->account); |
| 1416 | SilcPurple sg; | |
| 8849 | 1417 | |
| 1418 | if (!gc) | |
| 1419 | return; | |
| 1420 | sg = gc->proto_data; | |
| 1421 | ||
| 15884 | 1422 | purple_roomlist_set_in_progress(list, FALSE); |
| 8849 | 1423 | if (sg->roomlist == list) { |
| 15884 | 1424 | purple_roomlist_unref(sg->roomlist); |
| 8849 | 1425 | sg->roomlist = NULL; |
| 1426 | sg->roomlist_canceled = TRUE; | |
| 1427 | } | |
| 1428 | } |