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