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