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