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