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