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