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