comparison libpurple/protocols/silc/chat.c @ 15823:32c366eeeb99

sed -ie 's/gaim/purple/g'
author Sean Egan <seanegan@gmail.com>
date Mon, 19 Mar 2007 07:01:17 +0000
parents 5fe8042783c1
children a5176db228b7
comparison
equal deleted inserted replaced
15822:84b0f9b23ede 15823:32c366eeeb99
1 /* 1 /*
2 2
3 silcgaim_chat.c 3 silcpurple_chat.c
4 4
5 Author: Pekka Riikonen <priikone@silcnet.org> 5 Author: Pekka Riikonen <priikone@silcnet.org>
6 6
7 Copyright (C) 2004 Pekka Riikonen 7 Copyright (C) 2004 Pekka Riikonen
8 8
17 17
18 */ 18 */
19 19
20 #include "silcincludes.h" 20 #include "silcincludes.h"
21 #include "silcclient.h" 21 #include "silcclient.h"
22 #include "silcgaim.h" 22 #include "silcpurple.h"
23 #include "wb.h" 23 #include "wb.h"
24 24
25 /***************************** Channel Routines ******************************/ 25 /***************************** Channel Routines ******************************/
26 26
27 GList *silcgaim_chat_info(GaimConnection *gc) 27 GList *silcpurple_chat_info(PurpleConnection *gc)
28 { 28 {
29 GList *ci = NULL; 29 GList *ci = NULL;
30 struct proto_chat_entry *pce; 30 struct proto_chat_entry *pce;
31 31
32 pce = g_new0(struct proto_chat_entry, 1); 32 pce = g_new0(struct proto_chat_entry, 1);
42 ci = g_list_append(ci, pce); 42 ci = g_list_append(ci, pce);
43 43
44 return ci; 44 return ci;
45 } 45 }
46 46
47 GHashTable *silcgaim_chat_info_defaults(GaimConnection *gc, const char *chat_name) 47 GHashTable *silcpurple_chat_info_defaults(PurpleConnection *gc, const char *chat_name)
48 { 48 {
49 GHashTable *defaults; 49 GHashTable *defaults;
50 50
51 defaults = g_hash_table_new_full(g_str_hash, g_str_equal, NULL, g_free); 51 defaults = g_hash_table_new_full(g_str_hash, g_str_equal, NULL, g_free);
52 52
55 55
56 return defaults; 56 return defaults;
57 } 57 }
58 58
59 static void 59 static void
60 silcgaim_chat_getinfo(GaimConnection *gc, GHashTable *components); 60 silcpurple_chat_getinfo(PurpleConnection *gc, GHashTable *components);
61 61
62 static void 62 static void
63 silcgaim_chat_getinfo_res(SilcClient client, 63 silcpurple_chat_getinfo_res(SilcClient client,
64 SilcClientConnection conn, 64 SilcClientConnection conn,
65 SilcChannelEntry *channels, 65 SilcChannelEntry *channels,
66 SilcUInt32 channels_count, 66 SilcUInt32 channels_count,
67 void *context) 67 void *context)
68 { 68 {
69 GHashTable *components = context; 69 GHashTable *components = context;
70 GaimConnection *gc = client->application; 70 PurpleConnection *gc = client->application;
71 const char *chname; 71 const char *chname;
72 char tmp[256]; 72 char tmp[256];
73 73
74 chname = g_hash_table_lookup(components, "channel"); 74 chname = g_hash_table_lookup(components, "channel");
75 if (!chname) 75 if (!chname)
76 return; 76 return;
77 77
78 if (!channels) { 78 if (!channels) {
79 g_snprintf(tmp, sizeof(tmp), 79 g_snprintf(tmp, sizeof(tmp),
80 _("Channel %s does not exist in the network"), chname); 80 _("Channel %s does not exist in the network"), chname);
81 gaim_notify_error(gc, _("Channel Information"), 81 purple_notify_error(gc, _("Channel Information"),
82 _("Cannot get channel information"), tmp); 82 _("Cannot get channel information"), tmp);
83 return; 83 return;
84 } 84 }
85 85
86 silcgaim_chat_getinfo(gc, components); 86 silcpurple_chat_getinfo(gc, components);
87 } 87 }
88 88
89 89
90 static void 90 static void
91 silcgaim_chat_getinfo(GaimConnection *gc, GHashTable *components) 91 silcpurple_chat_getinfo(PurpleConnection *gc, GHashTable *components)
92 { 92 {
93 SilcGaim sg = gc->proto_data; 93 SilcPurple sg = gc->proto_data;
94 const char *chname; 94 const char *chname;
95 char *buf, tmp[256], *tmp2; 95 char *buf, tmp[256], *tmp2;
96 GString *s; 96 GString *s;
97 SilcChannelEntry channel; 97 SilcChannelEntry channel;
98 SilcHashTableList htl; 98 SilcHashTableList htl;
107 channel = silc_client_get_channel(sg->client, sg->conn, 107 channel = silc_client_get_channel(sg->client, sg->conn,
108 (char *)chname); 108 (char *)chname);
109 if (!channel) { 109 if (!channel) {
110 silc_client_get_channel_resolve(sg->client, sg->conn, 110 silc_client_get_channel_resolve(sg->client, sg->conn,
111 (char *)chname, 111 (char *)chname,
112 silcgaim_chat_getinfo_res, 112 silcpurple_chat_getinfo_res,
113 components); 113 components);
114 return; 114 return;
115 } 115 }
116 116
117 s = g_string_new(""); 117 s = g_string_new("");
148 g_free(tmp2); 148 g_free(tmp2);
149 } 149 }
150 150
151 if (channel->mode) { 151 if (channel->mode) {
152 g_string_append_printf(s, _("<br><b>Channel Modes:</b> ")); 152 g_string_append_printf(s, _("<br><b>Channel Modes:</b> "));
153 silcgaim_get_chmode_string(channel->mode, tmp, sizeof(tmp)); 153 silcpurple_get_chmode_string(channel->mode, tmp, sizeof(tmp));
154 g_string_append(s, tmp); 154 g_string_append(s, tmp);
155 } 155 }
156 156
157 if (channel->founder_key) { 157 if (channel->founder_key) {
158 char *fingerprint, *babbleprint; 158 char *fingerprint, *babbleprint;
169 silc_free(babbleprint); 169 silc_free(babbleprint);
170 silc_free(pk); 170 silc_free(pk);
171 } 171 }
172 172
173 buf = g_string_free(s, FALSE); 173 buf = g_string_free(s, FALSE);
174 gaim_notify_formatted(gc, NULL, _("Channel Information"), NULL, buf, NULL, NULL); 174 purple_notify_formatted(gc, NULL, _("Channel Information"), NULL, buf, NULL, NULL);
175 g_free(buf); 175 g_free(buf);
176 } 176 }
177 177
178 178
179 static void 179 static void
180 silcgaim_chat_getinfo_menu(GaimBlistNode *node, gpointer data) 180 silcpurple_chat_getinfo_menu(PurpleBlistNode *node, gpointer data)
181 { 181 {
182 GaimChat *chat = (GaimChat *)node; 182 PurpleChat *chat = (PurpleChat *)node;
183 silcgaim_chat_getinfo(chat->account->gc, chat->components); 183 silcpurple_chat_getinfo(chat->account->gc, chat->components);
184 } 184 }
185 185
186 186
187 #if 0 /* XXX For now these are not implemented. We need better 187 #if 0 /* XXX For now these are not implemented. We need better
188 listview dialog from Gaim for these. */ 188 listview dialog from Purple for these. */
189 /************************** Channel Invite List ******************************/ 189 /************************** Channel Invite List ******************************/
190 190
191 static void 191 static void
192 silcgaim_chat_invitelist(GaimBlistNode *node, gpointer data); 192 silcpurple_chat_invitelist(PurpleBlistNode *node, gpointer data);
193 { 193 {
194 194
195 } 195 }
196 196
197 197
198 /**************************** Channel Ban List *******************************/ 198 /**************************** Channel Ban List *******************************/
199 199
200 static void 200 static void
201 silcgaim_chat_banlist(GaimBlistNode *node, gpointer data); 201 silcpurple_chat_banlist(PurpleBlistNode *node, gpointer data);
202 { 202 {
203 203
204 } 204 }
205 #endif 205 #endif
206 206
207 207
208 /************************* Channel Authentication ****************************/ 208 /************************* Channel Authentication ****************************/
209 209
210 typedef struct { 210 typedef struct {
211 SilcGaim sg; 211 SilcPurple sg;
212 SilcChannelEntry channel; 212 SilcChannelEntry channel;
213 GaimChat *c; 213 PurpleChat *c;
214 SilcBuffer pubkeys; 214 SilcBuffer pubkeys;
215 } *SilcGaimChauth; 215 } *SilcPurpleChauth;
216 216
217 static void 217 static void
218 silcgaim_chat_chpk_add(void *user_data, const char *name) 218 silcpurple_chat_chpk_add(void *user_data, const char *name)
219 { 219 {
220 SilcGaimChauth sgc = (SilcGaimChauth)user_data; 220 SilcPurpleChauth sgc = (SilcPurpleChauth)user_data;
221 SilcGaim sg = sgc->sg; 221 SilcPurple sg = sgc->sg;
222 SilcClient client = sg->client; 222 SilcClient client = sg->client;
223 SilcClientConnection conn = sg->conn; 223 SilcClientConnection conn = sg->conn;
224 SilcPublicKey public_key; 224 SilcPublicKey public_key;
225 SilcBuffer chpks, pk, chidp; 225 SilcBuffer chpks, pk, chidp;
226 unsigned char mode[4]; 226 unsigned char mode[4];
227 SilcUInt32 m; 227 SilcUInt32 m;
228 228
229 /* Load the public key */ 229 /* Load the public key */
230 if (!silc_pkcs_load_public_key(name, &public_key, SILC_PKCS_FILE_PEM) && 230 if (!silc_pkcs_load_public_key(name, &public_key, SILC_PKCS_FILE_PEM) &&
231 !silc_pkcs_load_public_key(name, &public_key, SILC_PKCS_FILE_BIN)) { 231 !silc_pkcs_load_public_key(name, &public_key, SILC_PKCS_FILE_BIN)) {
232 silcgaim_chat_chauth_show(sgc->sg, sgc->channel, sgc->pubkeys); 232 silcpurple_chat_chauth_show(sgc->sg, sgc->channel, sgc->pubkeys);
233 silc_buffer_free(sgc->pubkeys); 233 silc_buffer_free(sgc->pubkeys);
234 silc_free(sgc); 234 silc_free(sgc);
235 gaim_notify_error(client->application, 235 purple_notify_error(client->application,
236 _("Add Channel Public Key"), 236 _("Add Channel Public Key"),
237 _("Could not load public key"), NULL); 237 _("Could not load public key"), NULL);
238 return; 238 return;
239 } 239 }
240 240
261 silc_buffer_free(sgc->pubkeys); 261 silc_buffer_free(sgc->pubkeys);
262 silc_free(sgc); 262 silc_free(sgc);
263 } 263 }
264 264
265 static void 265 static void
266 silcgaim_chat_chpk_cancel(void *user_data, const char *name) 266 silcpurple_chat_chpk_cancel(void *user_data, const char *name)
267 { 267 {
268 SilcGaimChauth sgc = (SilcGaimChauth)user_data; 268 SilcPurpleChauth sgc = (SilcPurpleChauth)user_data;
269 silcgaim_chat_chauth_show(sgc->sg, sgc->channel, sgc->pubkeys); 269 silcpurple_chat_chauth_show(sgc->sg, sgc->channel, sgc->pubkeys);
270 silc_buffer_free(sgc->pubkeys); 270 silc_buffer_free(sgc->pubkeys);
271 silc_free(sgc); 271 silc_free(sgc);
272 } 272 }
273 273
274 static void 274 static void
275 silcgaim_chat_chpk_cb(SilcGaimChauth sgc, GaimRequestFields *fields) 275 silcpurple_chat_chpk_cb(SilcPurpleChauth sgc, PurpleRequestFields *fields)
276 { 276 {
277 SilcGaim sg = sgc->sg; 277 SilcPurple sg = sgc->sg;
278 SilcClient client = sg->client; 278 SilcClient client = sg->client;
279 SilcClientConnection conn = sg->conn; 279 SilcClientConnection conn = sg->conn;
280 GaimRequestField *f; 280 PurpleRequestField *f;
281 const GList *list; 281 const GList *list;
282 SilcPublicKey public_key; 282 SilcPublicKey public_key;
283 SilcBuffer chpks, pk, chidp; 283 SilcBuffer chpks, pk, chidp;
284 SilcUInt16 c = 0, ct; 284 SilcUInt16 c = 0, ct;
285 unsigned char mode[4]; 285 unsigned char mode[4];
286 SilcUInt32 m; 286 SilcUInt32 m;
287 287
288 f = gaim_request_fields_get_field(fields, "list"); 288 f = purple_request_fields_get_field(fields, "list");
289 if (!gaim_request_field_list_get_selected(f)) { 289 if (!purple_request_field_list_get_selected(f)) {
290 /* Add new public key */ 290 /* Add new public key */
291 gaim_request_file(sg->gc, _("Open Public Key..."), NULL, FALSE, 291 purple_request_file(sg->gc, _("Open Public Key..."), NULL, FALSE,
292 G_CALLBACK(silcgaim_chat_chpk_add), 292 G_CALLBACK(silcpurple_chat_chpk_add),
293 G_CALLBACK(silcgaim_chat_chpk_cancel), sgc); 293 G_CALLBACK(silcpurple_chat_chpk_cancel), sgc);
294 return; 294 return;
295 } 295 }
296 296
297 list = gaim_request_field_list_get_items(f); 297 list = purple_request_field_list_get_items(f);
298 chpks = silc_buffer_alloc_size(2); 298 chpks = silc_buffer_alloc_size(2);
299 299
300 for (ct = 0; list; list = list->next, ct++) { 300 for (ct = 0; list; list = list->next, ct++) {
301 public_key = gaim_request_field_list_get_data(f, list->data); 301 public_key = purple_request_field_list_get_data(f, list->data);
302 if (gaim_request_field_list_is_selected(f, list->data)) { 302 if (purple_request_field_list_is_selected(f, list->data)) {
303 /* Delete this public key */ 303 /* Delete this public key */
304 pk = silc_pkcs_public_key_payload_encode(public_key); 304 pk = silc_pkcs_public_key_payload_encode(public_key);
305 chpks = silc_argument_payload_encode_one(chpks, pk->data, 305 chpks = silc_argument_payload_encode_one(chpks, pk->data,
306 pk->len, 0x01); 306 pk->len, 0x01);
307 silc_buffer_free(pk); 307 silc_buffer_free(pk);
332 silc_buffer_free(sgc->pubkeys); 332 silc_buffer_free(sgc->pubkeys);
333 silc_free(sgc); 333 silc_free(sgc);
334 } 334 }
335 335
336 static void 336 static void
337 silcgaim_chat_chauth_ok(SilcGaimChauth sgc, GaimRequestFields *fields) 337 silcpurple_chat_chauth_ok(SilcPurpleChauth sgc, PurpleRequestFields *fields)
338 { 338 {
339 SilcGaim sg = sgc->sg; 339 SilcPurple sg = sgc->sg;
340 GaimRequestField *f; 340 PurpleRequestField *f;
341 const char *curpass, *val; 341 const char *curpass, *val;
342 int set; 342 int set;
343 343
344 f = gaim_request_fields_get_field(fields, "passphrase"); 344 f = purple_request_fields_get_field(fields, "passphrase");
345 val = gaim_request_field_string_get_value(f); 345 val = purple_request_field_string_get_value(f);
346 curpass = gaim_blist_node_get_string((GaimBlistNode *)sgc->c, "passphrase"); 346 curpass = purple_blist_node_get_string((PurpleBlistNode *)sgc->c, "passphrase");
347 347
348 if (!val && curpass) 348 if (!val && curpass)
349 set = 0; 349 set = 0;
350 else if (val && !curpass) 350 else if (val && !curpass)
351 set = 1; 351 set = 1;
355 set = -1; 355 set = -1;
356 356
357 if (set == 1) { 357 if (set == 1) {
358 silc_client_command_call(sg->client, sg->conn, NULL, "CMODE", 358 silc_client_command_call(sg->client, sg->conn, NULL, "CMODE",
359 sgc->channel->channel_name, "+a", val, NULL); 359 sgc->channel->channel_name, "+a", val, NULL);
360 gaim_blist_node_set_string((GaimBlistNode *)sgc->c, "passphrase", val); 360 purple_blist_node_set_string((PurpleBlistNode *)sgc->c, "passphrase", val);
361 } else if (set == 0) { 361 } else if (set == 0) {
362 silc_client_command_call(sg->client, sg->conn, NULL, "CMODE", 362 silc_client_command_call(sg->client, sg->conn, NULL, "CMODE",
363 sgc->channel->channel_name, "-a", NULL); 363 sgc->channel->channel_name, "-a", NULL);
364 gaim_blist_node_remove_setting((GaimBlistNode *)sgc->c, "passphrase"); 364 purple_blist_node_remove_setting((PurpleBlistNode *)sgc->c, "passphrase");
365 } 365 }
366 366
367 silc_buffer_free(sgc->pubkeys); 367 silc_buffer_free(sgc->pubkeys);
368 silc_free(sgc); 368 silc_free(sgc);
369 } 369 }
370 370
371 void silcgaim_chat_chauth_show(SilcGaim sg, SilcChannelEntry channel, 371 void silcpurple_chat_chauth_show(SilcPurple sg, SilcChannelEntry channel,
372 SilcBuffer channel_pubkeys) 372 SilcBuffer channel_pubkeys)
373 { 373 {
374 SilcUInt16 argc; 374 SilcUInt16 argc;
375 SilcArgumentPayload chpks; 375 SilcArgumentPayload chpks;
376 unsigned char *pk; 376 unsigned char *pk;
377 SilcUInt32 pk_len, type; 377 SilcUInt32 pk_len, type;
378 char *fingerprint, *babbleprint; 378 char *fingerprint, *babbleprint;
379 SilcPublicKey pubkey; 379 SilcPublicKey pubkey;
380 SilcPublicKeyIdentifier ident; 380 SilcPublicKeyIdentifier ident;
381 char tmp2[1024], t[512]; 381 char tmp2[1024], t[512];
382 GaimRequestFields *fields; 382 PurpleRequestFields *fields;
383 GaimRequestFieldGroup *g; 383 PurpleRequestFieldGroup *g;
384 GaimRequestField *f; 384 PurpleRequestField *f;
385 SilcGaimChauth sgc; 385 SilcPurpleChauth sgc;
386 const char *curpass = NULL; 386 const char *curpass = NULL;
387 387
388 sgc = silc_calloc(1, sizeof(*sgc)); 388 sgc = silc_calloc(1, sizeof(*sgc));
389 if (!sgc) 389 if (!sgc)
390 return; 390 return;
391 sgc->sg = sg; 391 sgc->sg = sg;
392 sgc->channel = channel; 392 sgc->channel = channel;
393 393
394 fields = gaim_request_fields_new(); 394 fields = purple_request_fields_new();
395 395
396 if (sgc->c) 396 if (sgc->c)
397 curpass = gaim_blist_node_get_string((GaimBlistNode *)sgc->c, "passphrase"); 397 curpass = purple_blist_node_get_string((PurpleBlistNode *)sgc->c, "passphrase");
398 398
399 g = gaim_request_field_group_new(NULL); 399 g = purple_request_field_group_new(NULL);
400 f = gaim_request_field_string_new("passphrase", _("Channel Passphrase"), 400 f = purple_request_field_string_new("passphrase", _("Channel Passphrase"),
401 curpass, FALSE); 401 curpass, FALSE);
402 gaim_request_field_string_set_masked(f, TRUE); 402 purple_request_field_string_set_masked(f, TRUE);
403 gaim_request_field_group_add_field(g, f); 403 purple_request_field_group_add_field(g, f);
404 gaim_request_fields_add_group(fields, g); 404 purple_request_fields_add_group(fields, g);
405 405
406 g = gaim_request_field_group_new(NULL); 406 g = purple_request_field_group_new(NULL);
407 f = gaim_request_field_label_new("l1", _("Channel Public Keys List")); 407 f = purple_request_field_label_new("l1", _("Channel Public Keys List"));
408 gaim_request_field_group_add_field(g, f); 408 purple_request_field_group_add_field(g, f);
409 gaim_request_fields_add_group(fields, g); 409 purple_request_fields_add_group(fields, g);
410 410
411 g_snprintf(t, sizeof(t), 411 g_snprintf(t, sizeof(t),
412 _("Channel authentication is used to secure the channel from " 412 _("Channel authentication is used to secure the channel from "
413 "unauthorized access. The authentication may be based on " 413 "unauthorized access. The authentication may be based on "
414 "passphrase and digital signatures. If passphrase is set, it " 414 "passphrase and digital signatures. If passphrase is set, it "
415 "is required to be able to join. If channel public keys are set " 415 "is required to be able to join. If channel public keys are set "
416 "then only users whose public keys are listed are able to join.")); 416 "then only users whose public keys are listed are able to join."));
417 417
418 if (!channel_pubkeys) { 418 if (!channel_pubkeys) {
419 f = gaim_request_field_list_new("list", NULL); 419 f = purple_request_field_list_new("list", NULL);
420 gaim_request_field_group_add_field(g, f); 420 purple_request_field_group_add_field(g, f);
421 gaim_request_fields(sg->gc, _("Channel Authentication"), 421 purple_request_fields(sg->gc, _("Channel Authentication"),
422 _("Channel Authentication"), t, fields, 422 _("Channel Authentication"), t, fields,
423 _("Add / Remove"), G_CALLBACK(silcgaim_chat_chpk_cb), 423 _("Add / Remove"), G_CALLBACK(silcpurple_chat_chpk_cb),
424 _("OK"), G_CALLBACK(silcgaim_chat_chauth_ok), sgc); 424 _("OK"), G_CALLBACK(silcpurple_chat_chauth_ok), sgc);
425 return; 425 return;
426 } 426 }
427 sgc->pubkeys = silc_buffer_copy(channel_pubkeys); 427 sgc->pubkeys = silc_buffer_copy(channel_pubkeys);
428 428
429 g = gaim_request_field_group_new(NULL); 429 g = purple_request_field_group_new(NULL);
430 f = gaim_request_field_list_new("list", NULL); 430 f = purple_request_field_list_new("list", NULL);
431 gaim_request_field_group_add_field(g, f); 431 purple_request_field_group_add_field(g, f);
432 gaim_request_fields_add_group(fields, g); 432 purple_request_fields_add_group(fields, g);
433 433
434 SILC_GET16_MSB(argc, channel_pubkeys->data); 434 SILC_GET16_MSB(argc, channel_pubkeys->data);
435 chpks = silc_argument_payload_parse(channel_pubkeys->data + 2, 435 chpks = silc_argument_payload_parse(channel_pubkeys->data + 2,
436 channel_pubkeys->len - 2, argc); 436 channel_pubkeys->len - 2, argc);
437 if (!chpks) 437 if (!chpks)
445 ident = silc_pkcs_decode_identifier(pubkey->identifier); 445 ident = silc_pkcs_decode_identifier(pubkey->identifier);
446 446
447 g_snprintf(tmp2, sizeof(tmp2), "%s\n %s\n %s", 447 g_snprintf(tmp2, sizeof(tmp2), "%s\n %s\n %s",
448 ident->realname ? ident->realname : ident->username ? 448 ident->realname ? ident->realname : ident->username ?
449 ident->username : "", fingerprint, babbleprint); 449 ident->username : "", fingerprint, babbleprint);
450 gaim_request_field_list_add(f, tmp2, pubkey); 450 purple_request_field_list_add(f, tmp2, pubkey);
451 451
452 silc_free(fingerprint); 452 silc_free(fingerprint);
453 silc_free(babbleprint); 453 silc_free(babbleprint);
454 silc_pkcs_free_identifier(ident); 454 silc_pkcs_free_identifier(ident);
455 pk = silc_argument_get_next_arg(chpks, &type, &pk_len); 455 pk = silc_argument_get_next_arg(chpks, &type, &pk_len);
456 } 456 }
457 457
458 gaim_request_field_list_set_multi_select(f, FALSE); 458 purple_request_field_list_set_multi_select(f, FALSE);
459 gaim_request_fields(sg->gc, _("Channel Authentication"), 459 purple_request_fields(sg->gc, _("Channel Authentication"),
460 _("Channel Authentication"), t, fields, 460 _("Channel Authentication"), t, fields,
461 _("Add / Remove"), G_CALLBACK(silcgaim_chat_chpk_cb), 461 _("Add / Remove"), G_CALLBACK(silcpurple_chat_chpk_cb),
462 _("OK"), G_CALLBACK(silcgaim_chat_chauth_ok), sgc); 462 _("OK"), G_CALLBACK(silcpurple_chat_chauth_ok), sgc);
463 463
464 silc_argument_payload_free(chpks); 464 silc_argument_payload_free(chpks);
465 } 465 }
466 466
467 static void 467 static void
468 silcgaim_chat_chauth(GaimBlistNode *node, gpointer data) 468 silcpurple_chat_chauth(PurpleBlistNode *node, gpointer data)
469 { 469 {
470 GaimChat *chat; 470 PurpleChat *chat;
471 GaimConnection *gc; 471 PurpleConnection *gc;
472 SilcGaim sg; 472 SilcPurple sg;
473 473
474 g_return_if_fail(GAIM_BLIST_NODE_IS_CHAT(node)); 474 g_return_if_fail(PURPLE_BLIST_NODE_IS_CHAT(node));
475 475
476 chat = (GaimChat *) node; 476 chat = (PurpleChat *) node;
477 gc = gaim_account_get_connection(chat->account); 477 gc = purple_account_get_connection(chat->account);
478 sg = gc->proto_data; 478 sg = gc->proto_data;
479 479
480 silc_client_command_call(sg->client, sg->conn, NULL, "CMODE", 480 silc_client_command_call(sg->client, sg->conn, NULL, "CMODE",
481 g_hash_table_lookup(chat->components, "channel"), 481 g_hash_table_lookup(chat->components, "channel"),
482 "+C", NULL); 482 "+C", NULL);
491 group. Other users, on the same channel, won't be able to see the 491 group. Other users, on the same channel, won't be able to see the
492 messages of that group. It is possible to have multiple groups inside 492 messages of that group. It is possible to have multiple groups inside
493 a channel - and thus having multiple private keys on the channel. */ 493 a channel - and thus having multiple private keys on the channel. */
494 494
495 typedef struct { 495 typedef struct {
496 SilcGaim sg; 496 SilcPurple sg;
497 GaimChat *c; 497 PurpleChat *c;
498 const char *channel; 498 const char *channel;
499 } *SilcGaimCharPrv; 499 } *SilcPurpleCharPrv;
500 500
501 static void 501 static void
502 silcgaim_chat_prv_add(SilcGaimCharPrv p, GaimRequestFields *fields) 502 silcpurple_chat_prv_add(SilcPurpleCharPrv p, PurpleRequestFields *fields)
503 { 503 {
504 SilcGaim sg = p->sg; 504 SilcPurple sg = p->sg;
505 char tmp[512]; 505 char tmp[512];
506 GaimRequestField *f; 506 PurpleRequestField *f;
507 const char *name, *passphrase, *alias; 507 const char *name, *passphrase, *alias;
508 GHashTable *comp; 508 GHashTable *comp;
509 GaimGroup *g; 509 PurpleGroup *g;
510 GaimChat *cn; 510 PurpleChat *cn;
511 511
512 f = gaim_request_fields_get_field(fields, "name"); 512 f = purple_request_fields_get_field(fields, "name");
513 name = gaim_request_field_string_get_value(f); 513 name = purple_request_field_string_get_value(f);
514 if (!name) { 514 if (!name) {
515 silc_free(p); 515 silc_free(p);
516 return; 516 return;
517 } 517 }
518 f = gaim_request_fields_get_field(fields, "passphrase"); 518 f = purple_request_fields_get_field(fields, "passphrase");
519 passphrase = gaim_request_field_string_get_value(f); 519 passphrase = purple_request_field_string_get_value(f);
520 f = gaim_request_fields_get_field(fields, "alias"); 520 f = purple_request_fields_get_field(fields, "alias");
521 alias = gaim_request_field_string_get_value(f); 521 alias = purple_request_field_string_get_value(f);
522 522
523 /* Add private group to buddy list */ 523 /* Add private group to buddy list */
524 g_snprintf(tmp, sizeof(tmp), "%s [Private Group]", name); 524 g_snprintf(tmp, sizeof(tmp), "%s [Private Group]", name);
525 comp = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free); 525 comp = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free);
526 g_hash_table_replace(comp, g_strdup("channel"), g_strdup(tmp)); 526 g_hash_table_replace(comp, g_strdup("channel"), g_strdup(tmp));
527 g_hash_table_replace(comp, g_strdup("passphrase"), g_strdup(passphrase)); 527 g_hash_table_replace(comp, g_strdup("passphrase"), g_strdup(passphrase));
528 528
529 cn = gaim_chat_new(sg->account, alias, comp); 529 cn = purple_chat_new(sg->account, alias, comp);
530 g = (GaimGroup *)p->c->node.parent; 530 g = (PurpleGroup *)p->c->node.parent;
531 gaim_blist_add_chat(cn, g, (GaimBlistNode *)p->c); 531 purple_blist_add_chat(cn, g, (PurpleBlistNode *)p->c);
532 532
533 /* Associate to a real channel */ 533 /* Associate to a real channel */
534 gaim_blist_node_set_string((GaimBlistNode *)cn, "parentch", p->channel); 534 purple_blist_node_set_string((PurpleBlistNode *)cn, "parentch", p->channel);
535 535
536 /* Join the group */ 536 /* Join the group */
537 silcgaim_chat_join(sg->gc, comp); 537 silcpurple_chat_join(sg->gc, comp);
538 538
539 silc_free(p); 539 silc_free(p);
540 } 540 }
541 541
542 static void 542 static void
543 silcgaim_chat_prv_cancel(SilcGaimCharPrv p, GaimRequestFields *fields) 543 silcpurple_chat_prv_cancel(SilcPurpleCharPrv p, PurpleRequestFields *fields)
544 { 544 {
545 silc_free(p); 545 silc_free(p);
546 } 546 }
547 547
548 static void 548 static void
549 silcgaim_chat_prv(GaimBlistNode *node, gpointer data) 549 silcpurple_chat_prv(PurpleBlistNode *node, gpointer data)
550 { 550 {
551 GaimChat *chat; 551 PurpleChat *chat;
552 GaimConnection *gc; 552 PurpleConnection *gc;
553 SilcGaim sg; 553 SilcPurple sg;
554 554
555 SilcGaimCharPrv p; 555 SilcPurpleCharPrv p;
556 GaimRequestFields *fields; 556 PurpleRequestFields *fields;
557 GaimRequestFieldGroup *g; 557 PurpleRequestFieldGroup *g;
558 GaimRequestField *f; 558 PurpleRequestField *f;
559 char tmp[512]; 559 char tmp[512];
560 560
561 g_return_if_fail(GAIM_BLIST_NODE_IS_CHAT(node)); 561 g_return_if_fail(PURPLE_BLIST_NODE_IS_CHAT(node));
562 562
563 chat = (GaimChat *) node; 563 chat = (PurpleChat *) node;
564 gc = gaim_account_get_connection(chat->account); 564 gc = purple_account_get_connection(chat->account);
565 sg = gc->proto_data; 565 sg = gc->proto_data;
566 566
567 p = silc_calloc(1, sizeof(*p)); 567 p = silc_calloc(1, sizeof(*p));
568 if (!p) 568 if (!p)
569 return; 569 return;
570 p->sg = sg; 570 p->sg = sg;
571 571
572 p->channel = g_hash_table_lookup(chat->components, "channel"); 572 p->channel = g_hash_table_lookup(chat->components, "channel");
573 p->c = gaim_blist_find_chat(sg->account, p->channel); 573 p->c = purple_blist_find_chat(sg->account, p->channel);
574 574
575 fields = gaim_request_fields_new(); 575 fields = purple_request_fields_new();
576 576
577 g = gaim_request_field_group_new(NULL); 577 g = purple_request_field_group_new(NULL);
578 f = gaim_request_field_string_new("name", _("Group Name"), 578 f = purple_request_field_string_new("name", _("Group Name"),
579 NULL, FALSE); 579 NULL, FALSE);
580 gaim_request_field_group_add_field(g, f); 580 purple_request_field_group_add_field(g, f);
581 581
582 f = gaim_request_field_string_new("passphrase", _("Passphrase"), 582 f = purple_request_field_string_new("passphrase", _("Passphrase"),
583 NULL, FALSE); 583 NULL, FALSE);
584 gaim_request_field_string_set_masked(f, TRUE); 584 purple_request_field_string_set_masked(f, TRUE);
585 gaim_request_field_group_add_field(g, f); 585 purple_request_field_group_add_field(g, f);
586 586
587 f = gaim_request_field_string_new("alias", _("Alias"), 587 f = purple_request_field_string_new("alias", _("Alias"),
588 NULL, FALSE); 588 NULL, FALSE);
589 gaim_request_field_group_add_field(g, f); 589 purple_request_field_group_add_field(g, f);
590 gaim_request_fields_add_group(fields, g); 590 purple_request_fields_add_group(fields, g);
591 591
592 g_snprintf(tmp, sizeof(tmp), 592 g_snprintf(tmp, sizeof(tmp),
593 _("Please enter the %s channel private group name and passphrase."), 593 _("Please enter the %s channel private group name and passphrase."),
594 p->channel); 594 p->channel);
595 gaim_request_fields(gc, _("Add Channel Private Group"), NULL, tmp, fields, 595 purple_request_fields(gc, _("Add Channel Private Group"), NULL, tmp, fields,
596 _("Add"), G_CALLBACK(silcgaim_chat_prv_add), 596 _("Add"), G_CALLBACK(silcpurple_chat_prv_add),
597 _("Cancel"), G_CALLBACK(silcgaim_chat_prv_cancel), p); 597 _("Cancel"), G_CALLBACK(silcpurple_chat_prv_cancel), p);
598 } 598 }
599 599
600 600
601 /****************************** Channel Modes ********************************/ 601 /****************************** Channel Modes ********************************/
602 602
603 static void 603 static void
604 silcgaim_chat_permanent_reset(GaimBlistNode *node, gpointer data) 604 silcpurple_chat_permanent_reset(PurpleBlistNode *node, gpointer data)
605 { 605 {
606 GaimChat *chat; 606 PurpleChat *chat;
607 GaimConnection *gc; 607 PurpleConnection *gc;
608 SilcGaim sg; 608 SilcPurple sg;
609 609
610 g_return_if_fail(GAIM_BLIST_NODE_IS_CHAT(node)); 610 g_return_if_fail(PURPLE_BLIST_NODE_IS_CHAT(node));
611 611
612 chat = (GaimChat *) node; 612 chat = (PurpleChat *) node;
613 gc = gaim_account_get_connection(chat->account); 613 gc = purple_account_get_connection(chat->account);
614 sg = gc->proto_data; 614 sg = gc->proto_data;
615 615
616 silc_client_command_call(sg->client, sg->conn, NULL, "CMODE", 616 silc_client_command_call(sg->client, sg->conn, NULL, "CMODE",
617 g_hash_table_lookup(chat->components, "channel"), 617 g_hash_table_lookup(chat->components, "channel"),
618 "-f", NULL); 618 "-f", NULL);
619 } 619 }
620 620
621 static void 621 static void
622 silcgaim_chat_permanent(GaimBlistNode *node, gpointer data) 622 silcpurple_chat_permanent(PurpleBlistNode *node, gpointer data)
623 { 623 {
624 GaimChat *chat; 624 PurpleChat *chat;
625 GaimConnection *gc; 625 PurpleConnection *gc;
626 SilcGaim sg; 626 SilcPurple sg;
627 const char *channel; 627 const char *channel;
628 628
629 g_return_if_fail(GAIM_BLIST_NODE_IS_CHAT(node)); 629 g_return_if_fail(PURPLE_BLIST_NODE_IS_CHAT(node));
630 630
631 chat = (GaimChat *) node; 631 chat = (PurpleChat *) node;
632 gc = gaim_account_get_connection(chat->account); 632 gc = purple_account_get_connection(chat->account);
633 sg = gc->proto_data; 633 sg = gc->proto_data;
634 634
635 if (!sg->conn) 635 if (!sg->conn)
636 return; 636 return;
637 637
644 silc_client_command_call(sg->client, sg->conn, NULL, "CMODE", channel, 644 silc_client_command_call(sg->client, sg->conn, NULL, "CMODE", channel,
645 "+f", NULL); 645 "+f", NULL);
646 } 646 }
647 647
648 typedef struct { 648 typedef struct {
649 SilcGaim sg; 649 SilcPurple sg;
650 const char *channel; 650 const char *channel;
651 } *SilcGaimChatInput; 651 } *SilcPurpleChatInput;
652 652
653 static void 653 static void
654 silcgaim_chat_ulimit_cb(SilcGaimChatInput s, const char *limit) 654 silcpurple_chat_ulimit_cb(SilcPurpleChatInput s, const char *limit)
655 { 655 {
656 SilcChannelEntry channel; 656 SilcChannelEntry channel;
657 int ulimit = 0; 657 int ulimit = 0;
658 658
659 channel = silc_client_get_channel(s->sg->client, s->sg->conn, 659 channel = silc_client_get_channel(s->sg->client, s->sg->conn,
686 686
687 silc_free(s); 687 silc_free(s);
688 } 688 }
689 689
690 static void 690 static void
691 silcgaim_chat_ulimit(GaimBlistNode *node, gpointer data) 691 silcpurple_chat_ulimit(PurpleBlistNode *node, gpointer data)
692 { 692 {
693 GaimChat *chat; 693 PurpleChat *chat;
694 GaimConnection *gc; 694 PurpleConnection *gc;
695 SilcGaim sg; 695 SilcPurple sg;
696 696
697 SilcGaimChatInput s; 697 SilcPurpleChatInput s;
698 SilcChannelEntry channel; 698 SilcChannelEntry channel;
699 const char *ch; 699 const char *ch;
700 char tmp[32]; 700 char tmp[32];
701 701
702 g_return_if_fail(GAIM_BLIST_NODE_IS_CHAT(node)); 702 g_return_if_fail(PURPLE_BLIST_NODE_IS_CHAT(node));
703 703
704 chat = (GaimChat *) node; 704 chat = (PurpleChat *) node;
705 gc = gaim_account_get_connection(chat->account); 705 gc = purple_account_get_connection(chat->account);
706 sg = gc->proto_data; 706 sg = gc->proto_data;
707 707
708 if (!sg->conn) 708 if (!sg->conn)
709 return; 709 return;
710 710
717 if (!s) 717 if (!s)
718 return; 718 return;
719 s->channel = ch; 719 s->channel = ch;
720 s->sg = sg; 720 s->sg = sg;
721 g_snprintf(tmp, sizeof(tmp), "%d", (int)channel->user_limit); 721 g_snprintf(tmp, sizeof(tmp), "%d", (int)channel->user_limit);
722 gaim_request_input(gc, _("User Limit"), NULL, 722 purple_request_input(gc, _("User Limit"), NULL,
723 _("Set user limit on channel. Set to zero to reset user limit."), 723 _("Set user limit on channel. Set to zero to reset user limit."),
724 tmp, FALSE, FALSE, NULL, 724 tmp, FALSE, FALSE, NULL,
725 _("OK"), G_CALLBACK(silcgaim_chat_ulimit_cb), 725 _("OK"), G_CALLBACK(silcpurple_chat_ulimit_cb),
726 _("Cancel"), G_CALLBACK(silcgaim_chat_ulimit_cb), s); 726 _("Cancel"), G_CALLBACK(silcpurple_chat_ulimit_cb), s);
727 } 727 }
728 728
729 static void 729 static void
730 silcgaim_chat_resettopic(GaimBlistNode *node, gpointer data) 730 silcpurple_chat_resettopic(PurpleBlistNode *node, gpointer data)
731 { 731 {
732 GaimChat *chat; 732 PurpleChat *chat;
733 GaimConnection *gc; 733 PurpleConnection *gc;
734 SilcGaim sg; 734 SilcPurple sg;
735 735
736 g_return_if_fail(GAIM_BLIST_NODE_IS_CHAT(node)); 736 g_return_if_fail(PURPLE_BLIST_NODE_IS_CHAT(node));
737 737
738 chat = (GaimChat *) node; 738 chat = (PurpleChat *) node;
739 gc = gaim_account_get_connection(chat->account); 739 gc = purple_account_get_connection(chat->account);
740 sg = gc->proto_data; 740 sg = gc->proto_data;
741 741
742 silc_client_command_call(sg->client, sg->conn, NULL, "CMODE", 742 silc_client_command_call(sg->client, sg->conn, NULL, "CMODE",
743 g_hash_table_lookup(chat->components, "channel"), 743 g_hash_table_lookup(chat->components, "channel"),
744 "-t", NULL); 744 "-t", NULL);
745 } 745 }
746 746
747 static void 747 static void
748 silcgaim_chat_settopic(GaimBlistNode *node, gpointer data) 748 silcpurple_chat_settopic(PurpleBlistNode *node, gpointer data)
749 { 749 {
750 GaimChat *chat; 750 PurpleChat *chat;
751 GaimConnection *gc; 751 PurpleConnection *gc;
752 SilcGaim sg; 752 SilcPurple sg;
753 753
754 g_return_if_fail(GAIM_BLIST_NODE_IS_CHAT(node)); 754 g_return_if_fail(PURPLE_BLIST_NODE_IS_CHAT(node));
755 755
756 chat = (GaimChat *) node; 756 chat = (PurpleChat *) node;
757 gc = gaim_account_get_connection(chat->account); 757 gc = purple_account_get_connection(chat->account);
758 sg = gc->proto_data; 758 sg = gc->proto_data;
759 759
760 silc_client_command_call(sg->client, sg->conn, NULL, "CMODE", 760 silc_client_command_call(sg->client, sg->conn, NULL, "CMODE",
761 g_hash_table_lookup(chat->components, "channel"), 761 g_hash_table_lookup(chat->components, "channel"),
762 "+t", NULL); 762 "+t", NULL);
763 } 763 }
764 764
765 static void 765 static void
766 silcgaim_chat_resetprivate(GaimBlistNode *node, gpointer data) 766 silcpurple_chat_resetprivate(PurpleBlistNode *node, gpointer data)
767 { 767 {
768 GaimChat *chat; 768 PurpleChat *chat;
769 GaimConnection *gc; 769 PurpleConnection *gc;
770 SilcGaim sg; 770 SilcPurple sg;
771 771
772 g_return_if_fail(GAIM_BLIST_NODE_IS_CHAT(node)); 772 g_return_if_fail(PURPLE_BLIST_NODE_IS_CHAT(node));
773 773
774 chat = (GaimChat *) node; 774 chat = (PurpleChat *) node;
775 gc = gaim_account_get_connection(chat->account); 775 gc = purple_account_get_connection(chat->account);
776 sg = gc->proto_data; 776 sg = gc->proto_data;
777 777
778 silc_client_command_call(sg->client, sg->conn, NULL, "CMODE", 778 silc_client_command_call(sg->client, sg->conn, NULL, "CMODE",
779 g_hash_table_lookup(chat->components, "channel"), 779 g_hash_table_lookup(chat->components, "channel"),
780 "-p", NULL); 780 "-p", NULL);
781 } 781 }
782 782
783 static void 783 static void
784 silcgaim_chat_setprivate(GaimBlistNode *node, gpointer data) 784 silcpurple_chat_setprivate(PurpleBlistNode *node, gpointer data)
785 { 785 {
786 GaimChat *chat; 786 PurpleChat *chat;
787 GaimConnection *gc; 787 PurpleConnection *gc;
788 SilcGaim sg; 788 SilcPurple sg;
789 789
790 g_return_if_fail(GAIM_BLIST_NODE_IS_CHAT(node)); 790 g_return_if_fail(PURPLE_BLIST_NODE_IS_CHAT(node));
791 791
792 chat = (GaimChat *) node; 792 chat = (PurpleChat *) node;
793 gc = gaim_account_get_connection(chat->account); 793 gc = purple_account_get_connection(chat->account);
794 sg = gc->proto_data; 794 sg = gc->proto_data;
795 795
796 silc_client_command_call(sg->client, sg->conn, NULL, "CMODE", 796 silc_client_command_call(sg->client, sg->conn, NULL, "CMODE",
797 g_hash_table_lookup(chat->components, "channel"), 797 g_hash_table_lookup(chat->components, "channel"),
798 "+p", NULL); 798 "+p", NULL);
799 } 799 }
800 800
801 static void 801 static void
802 silcgaim_chat_resetsecret(GaimBlistNode *node, gpointer data) 802 silcpurple_chat_resetsecret(PurpleBlistNode *node, gpointer data)
803 { 803 {
804 GaimChat *chat; 804 PurpleChat *chat;
805 GaimConnection *gc; 805 PurpleConnection *gc;
806 SilcGaim sg; 806 SilcPurple sg;
807 807
808 g_return_if_fail(GAIM_BLIST_NODE_IS_CHAT(node)); 808 g_return_if_fail(PURPLE_BLIST_NODE_IS_CHAT(node));
809 809
810 chat = (GaimChat *) node; 810 chat = (PurpleChat *) node;
811 gc = gaim_account_get_connection(chat->account); 811 gc = purple_account_get_connection(chat->account);
812 sg = gc->proto_data; 812 sg = gc->proto_data;
813 813
814 silc_client_command_call(sg->client, sg->conn, NULL, "CMODE", 814 silc_client_command_call(sg->client, sg->conn, NULL, "CMODE",
815 g_hash_table_lookup(chat->components, "channel"), 815 g_hash_table_lookup(chat->components, "channel"),
816 "-s", NULL); 816 "-s", NULL);
817 } 817 }
818 818
819 static void 819 static void
820 silcgaim_chat_setsecret(GaimBlistNode *node, gpointer data) 820 silcpurple_chat_setsecret(PurpleBlistNode *node, gpointer data)
821 { 821 {
822 GaimChat *chat; 822 PurpleChat *chat;
823 GaimConnection *gc; 823 PurpleConnection *gc;
824 SilcGaim sg; 824 SilcPurple sg;
825 825
826 g_return_if_fail(GAIM_BLIST_NODE_IS_CHAT(node)); 826 g_return_if_fail(PURPLE_BLIST_NODE_IS_CHAT(node));
827 827
828 chat = (GaimChat *) node; 828 chat = (PurpleChat *) node;
829 gc = gaim_account_get_connection(chat->account); 829 gc = purple_account_get_connection(chat->account);
830 sg = gc->proto_data; 830 sg = gc->proto_data;
831 831
832 silc_client_command_call(sg->client, sg->conn, NULL, "CMODE", 832 silc_client_command_call(sg->client, sg->conn, NULL, "CMODE",
833 g_hash_table_lookup(chat->components, "channel"), 833 g_hash_table_lookup(chat->components, "channel"),
834 "+s", NULL); 834 "+s", NULL);
835 } 835 }
836 836
837 typedef struct { 837 typedef struct {
838 SilcGaim sg; 838 SilcPurple sg;
839 SilcChannelEntry channel; 839 SilcChannelEntry channel;
840 } *SilcGaimChatWb; 840 } *SilcPurpleChatWb;
841 841
842 static void 842 static void
843 silcgaim_chat_wb(GaimBlistNode *node, gpointer data) 843 silcpurple_chat_wb(PurpleBlistNode *node, gpointer data)
844 { 844 {
845 SilcGaimChatWb wb = data; 845 SilcPurpleChatWb wb = data;
846 silcgaim_wb_init_ch(wb->sg, wb->channel); 846 silcpurple_wb_init_ch(wb->sg, wb->channel);
847 silc_free(wb); 847 silc_free(wb);
848 } 848 }
849 849
850 GList *silcgaim_chat_menu(GaimChat *chat) 850 GList *silcpurple_chat_menu(PurpleChat *chat)
851 { 851 {
852 GHashTable *components = chat->components; 852 GHashTable *components = chat->components;
853 GaimConnection *gc = gaim_account_get_connection(chat->account); 853 PurpleConnection *gc = purple_account_get_connection(chat->account);
854 SilcGaim sg = gc->proto_data; 854 SilcPurple sg = gc->proto_data;
855 SilcClientConnection conn = sg->conn; 855 SilcClientConnection conn = sg->conn;
856 const char *chname = NULL; 856 const char *chname = NULL;
857 SilcChannelEntry channel = NULL; 857 SilcChannelEntry channel = NULL;
858 SilcChannelUser chu = NULL; 858 SilcChannelUser chu = NULL;
859 SilcUInt32 mode = 0; 859 SilcUInt32 mode = 0;
860 860
861 GList *m = NULL; 861 GList *m = NULL;
862 GaimMenuAction *act; 862 PurpleMenuAction *act;
863 863
864 if (components) 864 if (components)
865 chname = g_hash_table_lookup(components, "channel"); 865 chname = g_hash_table_lookup(components, "channel");
866 if (chname) 866 if (chname)
867 channel = silc_client_get_channel(sg->client, sg->conn, 867 channel = silc_client_get_channel(sg->client, sg->conn,
873 } 873 }
874 874
875 if (strstr(chname, "[Private Group]")) 875 if (strstr(chname, "[Private Group]"))
876 return NULL; 876 return NULL;
877 877
878 act = gaim_menu_action_new(_("Get Info"), 878 act = purple_menu_action_new(_("Get Info"),
879 GAIM_CALLBACK(silcgaim_chat_getinfo_menu), 879 PURPLE_CALLBACK(silcpurple_chat_getinfo_menu),
880 NULL, NULL); 880 NULL, NULL);
881 m = g_list_append(m, act); 881 m = g_list_append(m, act);
882 882
883 #if 0 /* XXX For now these are not implemented. We need better 883 #if 0 /* XXX For now these are not implemented. We need better
884 listview dialog from Gaim for these. */ 884 listview dialog from Purple for these. */
885 if (mode & SILC_CHANNEL_UMODE_CHANOP) { 885 if (mode & SILC_CHANNEL_UMODE_CHANOP) {
886 act = gaim_menu_action_new(_("Invite List"), 886 act = purple_menu_action_new(_("Invite List"),
887 GAIM_CALLBACK(silcgaim_chat_invitelist), 887 PURPLE_CALLBACK(silcpurple_chat_invitelist),
888 NULL, NULL); 888 NULL, NULL);
889 m = g_list_append(m, act); 889 m = g_list_append(m, act);
890 890
891 act = gaim_menu_action_new(_("Ban List"), 891 act = purple_menu_action_new(_("Ban List"),
892 GAIM_CALLBACK(silcgaim_chat_banlist), 892 PURPLE_CALLBACK(silcpurple_chat_banlist),
893 NULL, NULL); 893 NULL, NULL);
894 m = g_list_append(m, act); 894 m = g_list_append(m, act);
895 } 895 }
896 #endif 896 #endif
897 897
898 if (chu) { 898 if (chu) {
899 act = gaim_menu_action_new(_("Add Private Group"), 899 act = purple_menu_action_new(_("Add Private Group"),
900 GAIM_CALLBACK(silcgaim_chat_prv), 900 PURPLE_CALLBACK(silcpurple_chat_prv),
901 NULL, NULL); 901 NULL, NULL);
902 m = g_list_append(m, act); 902 m = g_list_append(m, act);
903 } 903 }
904 904
905 if (mode & SILC_CHANNEL_UMODE_CHANFO) { 905 if (mode & SILC_CHANNEL_UMODE_CHANFO) {
906 act = gaim_menu_action_new(_("Channel Authentication"), 906 act = purple_menu_action_new(_("Channel Authentication"),
907 GAIM_CALLBACK(silcgaim_chat_chauth), 907 PURPLE_CALLBACK(silcpurple_chat_chauth),
908 NULL, NULL); 908 NULL, NULL);
909 m = g_list_append(m, act); 909 m = g_list_append(m, act);
910 910
911 if (channel->mode & SILC_CHANNEL_MODE_FOUNDER_AUTH) { 911 if (channel->mode & SILC_CHANNEL_MODE_FOUNDER_AUTH) {
912 act = gaim_menu_action_new(_("Reset Permanent"), 912 act = purple_menu_action_new(_("Reset Permanent"),
913 GAIM_CALLBACK(silcgaim_chat_permanent_reset), 913 PURPLE_CALLBACK(silcpurple_chat_permanent_reset),
914 NULL, NULL); 914 NULL, NULL);
915 m = g_list_append(m, act); 915 m = g_list_append(m, act);
916 } else { 916 } else {
917 act = gaim_menu_action_new(_("Set Permanent"), 917 act = purple_menu_action_new(_("Set Permanent"),
918 GAIM_CALLBACK(silcgaim_chat_permanent), 918 PURPLE_CALLBACK(silcpurple_chat_permanent),
919 NULL, NULL); 919 NULL, NULL);
920 m = g_list_append(m, act); 920 m = g_list_append(m, act);
921 } 921 }
922 } 922 }
923 923
924 if (mode & SILC_CHANNEL_UMODE_CHANOP) { 924 if (mode & SILC_CHANNEL_UMODE_CHANOP) {
925 act = gaim_menu_action_new(_("Set User Limit"), 925 act = purple_menu_action_new(_("Set User Limit"),
926 GAIM_CALLBACK(silcgaim_chat_ulimit), 926 PURPLE_CALLBACK(silcpurple_chat_ulimit),
927 NULL, NULL); 927 NULL, NULL);
928 m = g_list_append(m, act); 928 m = g_list_append(m, act);
929 929
930 if (channel->mode & SILC_CHANNEL_MODE_TOPIC) { 930 if (channel->mode & SILC_CHANNEL_MODE_TOPIC) {
931 act = gaim_menu_action_new(_("Reset Topic Restriction"), 931 act = purple_menu_action_new(_("Reset Topic Restriction"),
932 GAIM_CALLBACK(silcgaim_chat_resettopic), 932 PURPLE_CALLBACK(silcpurple_chat_resettopic),
933 NULL, NULL); 933 NULL, NULL);
934 m = g_list_append(m, act); 934 m = g_list_append(m, act);
935 } else { 935 } else {
936 act = gaim_menu_action_new(_("Set Topic Restriction"), 936 act = purple_menu_action_new(_("Set Topic Restriction"),
937 GAIM_CALLBACK(silcgaim_chat_settopic), 937 PURPLE_CALLBACK(silcpurple_chat_settopic),
938 NULL, NULL); 938 NULL, NULL);
939 m = g_list_append(m, act); 939 m = g_list_append(m, act);
940 } 940 }
941 941
942 if (channel->mode & SILC_CHANNEL_MODE_PRIVATE) { 942 if (channel->mode & SILC_CHANNEL_MODE_PRIVATE) {
943 act = gaim_menu_action_new(_("Reset Private Channel"), 943 act = purple_menu_action_new(_("Reset Private Channel"),
944 GAIM_CALLBACK(silcgaim_chat_resetprivate), 944 PURPLE_CALLBACK(silcpurple_chat_resetprivate),
945 NULL, NULL); 945 NULL, NULL);
946 m = g_list_append(m, act); 946 m = g_list_append(m, act);
947 } else { 947 } else {
948 act = gaim_menu_action_new(_("Set Private Channel"), 948 act = purple_menu_action_new(_("Set Private Channel"),
949 GAIM_CALLBACK(silcgaim_chat_setprivate), 949 PURPLE_CALLBACK(silcpurple_chat_setprivate),
950 NULL, NULL); 950 NULL, NULL);
951 m = g_list_append(m, act); 951 m = g_list_append(m, act);
952 } 952 }
953 953
954 if (channel->mode & SILC_CHANNEL_MODE_SECRET) { 954 if (channel->mode & SILC_CHANNEL_MODE_SECRET) {
955 act = gaim_menu_action_new(_("Reset Secret Channel"), 955 act = purple_menu_action_new(_("Reset Secret Channel"),
956 GAIM_CALLBACK(silcgaim_chat_resetsecret), 956 PURPLE_CALLBACK(silcpurple_chat_resetsecret),
957 NULL, NULL); 957 NULL, NULL);
958 m = g_list_append(m, act); 958 m = g_list_append(m, act);
959 } else { 959 } else {
960 act = gaim_menu_action_new(_("Set Secret Channel"), 960 act = purple_menu_action_new(_("Set Secret Channel"),
961 GAIM_CALLBACK(silcgaim_chat_setsecret), 961 PURPLE_CALLBACK(silcpurple_chat_setsecret),
962 NULL, NULL); 962 NULL, NULL);
963 m = g_list_append(m, act); 963 m = g_list_append(m, act);
964 } 964 }
965 } 965 }
966 966
967 if (channel) { 967 if (channel) {
968 SilcGaimChatWb wb; 968 SilcPurpleChatWb wb;
969 wb = silc_calloc(1, sizeof(*wb)); 969 wb = silc_calloc(1, sizeof(*wb));
970 wb->sg = sg; 970 wb->sg = sg;
971 wb->channel = channel; 971 wb->channel = channel;
972 act = gaim_menu_action_new(_("Draw On Whiteboard"), 972 act = purple_menu_action_new(_("Draw On Whiteboard"),
973 GAIM_CALLBACK(silcgaim_chat_wb), 973 PURPLE_CALLBACK(silcpurple_chat_wb),
974 (void *)wb, NULL); 974 (void *)wb, NULL);
975 m = g_list_append(m, act); 975 m = g_list_append(m, act);
976 } 976 }
977 977
978 return m; 978 return m;
979 } 979 }
980 980
981 981
982 /******************************* Joining Etc. ********************************/ 982 /******************************* Joining Etc. ********************************/
983 983
984 void silcgaim_chat_join_done(SilcClient client, 984 void silcpurple_chat_join_done(SilcClient client,
985 SilcClientConnection conn, 985 SilcClientConnection conn,
986 SilcClientEntry *clients, 986 SilcClientEntry *clients,
987 SilcUInt32 clients_count, 987 SilcUInt32 clients_count,
988 void *context) 988 void *context)
989 { 989 {
990 GaimConnection *gc = client->application; 990 PurpleConnection *gc = client->application;
991 SilcGaim sg = gc->proto_data; 991 SilcPurple sg = gc->proto_data;
992 SilcChannelEntry channel = context; 992 SilcChannelEntry channel = context;
993 GaimConversation *convo; 993 PurpleConversation *convo;
994 SilcUInt32 retry = SILC_PTR_TO_32(channel->context); 994 SilcUInt32 retry = SILC_PTR_TO_32(channel->context);
995 SilcHashTableList htl; 995 SilcHashTableList htl;
996 SilcChannelUser chu; 996 SilcChannelUser chu;
997 GList *users = NULL, *flags = NULL; 997 GList *users = NULL, *flags = NULL;
998 char tmp[256]; 998 char tmp[256];
999 999
1000 if (!clients && retry < 1) { 1000 if (!clients && retry < 1) {
1001 /* Resolving users failed, try again. */ 1001 /* Resolving users failed, try again. */
1002 channel->context = SILC_32_TO_PTR(retry + 1); 1002 channel->context = SILC_32_TO_PTR(retry + 1);
1003 silc_client_get_clients_by_channel(client, conn, channel, 1003 silc_client_get_clients_by_channel(client, conn, channel,
1004 silcgaim_chat_join_done, channel); 1004 silcpurple_chat_join_done, channel);
1005 return; 1005 return;
1006 } 1006 }
1007 1007
1008 /* Add channel to Gaim */ 1008 /* Add channel to Purple */
1009 channel->context = SILC_32_TO_PTR(++sg->channel_ids); 1009 channel->context = SILC_32_TO_PTR(++sg->channel_ids);
1010 serv_got_joined_chat(gc, sg->channel_ids, channel->channel_name); 1010 serv_got_joined_chat(gc, sg->channel_ids, channel->channel_name);
1011 convo = gaim_find_conversation_with_account(GAIM_CONV_TYPE_CHAT, 1011 convo = purple_find_conversation_with_account(PURPLE_CONV_TYPE_CHAT,
1012 channel->channel_name, sg->account); 1012 channel->channel_name, sg->account);
1013 if (!convo) 1013 if (!convo)
1014 return; 1014 return;
1015 1015
1016 /* Add all users to channel */ 1016 /* Add all users to channel */
1017 silc_hash_table_list(channel->user_list, &htl); 1017 silc_hash_table_list(channel->user_list, &htl);
1018 while (silc_hash_table_get(&htl, NULL, (void *)&chu)) { 1018 while (silc_hash_table_get(&htl, NULL, (void *)&chu)) {
1019 GaimConvChatBuddyFlags f = GAIM_CBFLAGS_NONE; 1019 PurpleConvChatBuddyFlags f = PURPLE_CBFLAGS_NONE;
1020 if (!chu->client->nickname) 1020 if (!chu->client->nickname)
1021 continue; 1021 continue;
1022 chu->context = SILC_32_TO_PTR(sg->channel_ids); 1022 chu->context = SILC_32_TO_PTR(sg->channel_ids);
1023 1023
1024 if (chu->mode & SILC_CHANNEL_UMODE_CHANFO) 1024 if (chu->mode & SILC_CHANNEL_UMODE_CHANFO)
1025 f |= GAIM_CBFLAGS_FOUNDER; 1025 f |= PURPLE_CBFLAGS_FOUNDER;
1026 if (chu->mode & SILC_CHANNEL_UMODE_CHANOP) 1026 if (chu->mode & SILC_CHANNEL_UMODE_CHANOP)
1027 f |= GAIM_CBFLAGS_OP; 1027 f |= PURPLE_CBFLAGS_OP;
1028 users = g_list_append(users, g_strdup(chu->client->nickname)); 1028 users = g_list_append(users, g_strdup(chu->client->nickname));
1029 flags = g_list_append(flags, GINT_TO_POINTER(f)); 1029 flags = g_list_append(flags, GINT_TO_POINTER(f));
1030 1030
1031 if (chu->mode & SILC_CHANNEL_UMODE_CHANFO) { 1031 if (chu->mode & SILC_CHANNEL_UMODE_CHANFO) {
1032 if (chu->client == conn->local_entry) 1032 if (chu->client == conn->local_entry)
1036 else 1036 else
1037 g_snprintf(tmp, sizeof(tmp), 1037 g_snprintf(tmp, sizeof(tmp),
1038 _("Channel founder on <I>%s</I> is <I>%s</I>"), 1038 _("Channel founder on <I>%s</I> is <I>%s</I>"),
1039 channel->channel_name, chu->client->nickname); 1039 channel->channel_name, chu->client->nickname);
1040 1040
1041 gaim_conversation_write(convo, NULL, tmp, 1041 purple_conversation_write(convo, NULL, tmp,
1042 GAIM_MESSAGE_SYSTEM, time(NULL)); 1042 PURPLE_MESSAGE_SYSTEM, time(NULL));
1043 1043
1044 } 1044 }
1045 } 1045 }
1046 silc_hash_table_list_reset(&htl); 1046 silc_hash_table_list_reset(&htl);
1047 1047
1048 gaim_conv_chat_add_users(GAIM_CONV_CHAT(convo), users, NULL, flags, FALSE); 1048 purple_conv_chat_add_users(PURPLE_CONV_CHAT(convo), users, NULL, flags, FALSE);
1049 g_list_free(users); 1049 g_list_free(users);
1050 g_list_free(flags); 1050 g_list_free(flags);
1051 1051
1052 /* Set topic */ 1052 /* Set topic */
1053 if (channel->topic) 1053 if (channel->topic)
1054 gaim_conv_chat_set_topic(GAIM_CONV_CHAT(convo), NULL, channel->topic); 1054 purple_conv_chat_set_topic(PURPLE_CONV_CHAT(convo), NULL, channel->topic);
1055 1055
1056 /* Set nick */ 1056 /* Set nick */
1057 gaim_conv_chat_set_nick(GAIM_CONV_CHAT(convo), conn->local_entry->nickname); 1057 purple_conv_chat_set_nick(PURPLE_CONV_CHAT(convo), conn->local_entry->nickname);
1058 } 1058 }
1059 1059
1060 char *silcgaim_get_chat_name(GHashTable *data) 1060 char *silcpurple_get_chat_name(GHashTable *data)
1061 { 1061 {
1062 return g_strdup(g_hash_table_lookup(data, "channel")); 1062 return g_strdup(g_hash_table_lookup(data, "channel"));
1063 } 1063 }
1064 1064
1065 void silcgaim_chat_join(GaimConnection *gc, GHashTable *data) 1065 void silcpurple_chat_join(PurpleConnection *gc, GHashTable *data)
1066 { 1066 {
1067 SilcGaim sg = gc->proto_data; 1067 SilcPurple sg = gc->proto_data;
1068 SilcClient client = sg->client; 1068 SilcClient client = sg->client;
1069 SilcClientConnection conn = sg->conn; 1069 SilcClientConnection conn = sg->conn;
1070 const char *channel, *passphrase, *parentch; 1070 const char *channel, *passphrase, *parentch;
1071 1071
1072 if (!conn) 1072 if (!conn)
1078 /* Check if we are joining a private group. Handle it 1078 /* Check if we are joining a private group. Handle it
1079 purely locally as it's not a real channel */ 1079 purely locally as it's not a real channel */
1080 if (strstr(channel, "[Private Group]")) { 1080 if (strstr(channel, "[Private Group]")) {
1081 SilcChannelEntry channel_entry; 1081 SilcChannelEntry channel_entry;
1082 SilcChannelPrivateKey key; 1082 SilcChannelPrivateKey key;
1083 GaimChat *c; 1083 PurpleChat *c;
1084 SilcGaimPrvgrp grp; 1084 SilcPurplePrvgrp grp;
1085 1085
1086 c = gaim_blist_find_chat(sg->account, channel); 1086 c = purple_blist_find_chat(sg->account, channel);
1087 parentch = gaim_blist_node_get_string((GaimBlistNode *)c, "parentch"); 1087 parentch = purple_blist_node_get_string((PurpleBlistNode *)c, "parentch");
1088 if (!parentch) 1088 if (!parentch)
1089 return; 1089 return;
1090 1090
1091 channel_entry = silc_client_get_channel(sg->client, sg->conn, 1091 channel_entry = silc_client_get_channel(sg->client, sg->conn,
1092 (char *)parentch); 1092 (char *)parentch);
1094 !silc_client_on_channel(channel_entry, sg->conn->local_entry)) { 1094 !silc_client_on_channel(channel_entry, sg->conn->local_entry)) {
1095 char tmp[512]; 1095 char tmp[512];
1096 g_snprintf(tmp, sizeof(tmp), 1096 g_snprintf(tmp, sizeof(tmp),
1097 _("You have to join the %s channel before you are " 1097 _("You have to join the %s channel before you are "
1098 "able to join the private group"), parentch); 1098 "able to join the private group"), parentch);
1099 gaim_notify_error(gc, _("Join Private Group"), 1099 purple_notify_error(gc, _("Join Private Group"),
1100 _("Cannot join private group"), tmp); 1100 _("Cannot join private group"), tmp);
1101 return; 1101 return;
1102 } 1102 }
1103 1103
1104 /* Add channel private key */ 1104 /* Add channel private key */
1111 1111
1112 /* Join the group */ 1112 /* Join the group */
1113 grp = silc_calloc(1, sizeof(*grp)); 1113 grp = silc_calloc(1, sizeof(*grp));
1114 if (!grp) 1114 if (!grp)
1115 return; 1115 return;
1116 grp->id = ++sg->channel_ids + SILCGAIM_PRVGRP; 1116 grp->id = ++sg->channel_ids + SILCPURPLE_PRVGRP;
1117 grp->chid = SILC_PTR_TO_32(channel_entry->context); 1117 grp->chid = SILC_PTR_TO_32(channel_entry->context);
1118 grp->parentch = parentch; 1118 grp->parentch = parentch;
1119 grp->channel = channel; 1119 grp->channel = channel;
1120 grp->key = key; 1120 grp->key = key;
1121 sg->grps = g_list_append(sg->grps, grp); 1121 sg->grps = g_list_append(sg->grps, grp);
1142 else 1142 else
1143 silc_client_command_call(client, conn, NULL, "JOIN", 1143 silc_client_command_call(client, conn, NULL, "JOIN",
1144 channel, "-auth", "-founder", NULL); 1144 channel, "-auth", "-founder", NULL);
1145 } 1145 }
1146 1146
1147 void silcgaim_chat_invite(GaimConnection *gc, int id, const char *msg, 1147 void silcpurple_chat_invite(PurpleConnection *gc, int id, const char *msg,
1148 const char *name) 1148 const char *name)
1149 { 1149 {
1150 SilcGaim sg = gc->proto_data; 1150 SilcPurple sg = gc->proto_data;
1151 SilcClient client = sg->client; 1151 SilcClient client = sg->client;
1152 SilcClientConnection conn = sg->conn; 1152 SilcClientConnection conn = sg->conn;
1153 SilcHashTableList htl; 1153 SilcHashTableList htl;
1154 SilcChannelUser chu; 1154 SilcChannelUser chu;
1155 gboolean found = FALSE; 1155 gboolean found = FALSE;
1157 if (!conn) 1157 if (!conn)
1158 return; 1158 return;
1159 1159
1160 /* See if we are inviting on a private group. Invite 1160 /* See if we are inviting on a private group. Invite
1161 to the actual channel */ 1161 to the actual channel */
1162 if (id > SILCGAIM_PRVGRP) { 1162 if (id > SILCPURPLE_PRVGRP) {
1163 GList *l; 1163 GList *l;
1164 SilcGaimPrvgrp prv; 1164 SilcPurplePrvgrp prv;
1165 1165
1166 for (l = sg->grps; l; l = l->next) 1166 for (l = sg->grps; l; l = l->next)
1167 if (((SilcGaimPrvgrp)l->data)->id == id) 1167 if (((SilcPurplePrvgrp)l->data)->id == id)
1168 break; 1168 break;
1169 if (!l) 1169 if (!l)
1170 return; 1170 return;
1171 prv = l->data; 1171 prv = l->data;
1172 id = prv->chid; 1172 id = prv->chid;
1188 silc_client_command_call(client, conn, NULL, "INVITE", 1188 silc_client_command_call(client, conn, NULL, "INVITE",
1189 chu->channel->channel_name, 1189 chu->channel->channel_name,
1190 name, NULL); 1190 name, NULL);
1191 } 1191 }
1192 1192
1193 void silcgaim_chat_leave(GaimConnection *gc, int id) 1193 void silcpurple_chat_leave(PurpleConnection *gc, int id)
1194 { 1194 {
1195 SilcGaim sg = gc->proto_data; 1195 SilcPurple sg = gc->proto_data;
1196 SilcClient client = sg->client; 1196 SilcClient client = sg->client;
1197 SilcClientConnection conn = sg->conn; 1197 SilcClientConnection conn = sg->conn;
1198 SilcHashTableList htl; 1198 SilcHashTableList htl;
1199 SilcChannelUser chu; 1199 SilcChannelUser chu;
1200 gboolean found = FALSE; 1200 gboolean found = FALSE;
1201 GList *l; 1201 GList *l;
1202 SilcGaimPrvgrp prv; 1202 SilcPurplePrvgrp prv;
1203 1203
1204 if (!conn) 1204 if (!conn)
1205 return; 1205 return;
1206 1206
1207 /* See if we are leaving a private group */ 1207 /* See if we are leaving a private group */
1208 if (id > SILCGAIM_PRVGRP) { 1208 if (id > SILCPURPLE_PRVGRP) {
1209 SilcChannelEntry channel; 1209 SilcChannelEntry channel;
1210 1210
1211 for (l = sg->grps; l; l = l->next) 1211 for (l = sg->grps; l; l = l->next)
1212 if (((SilcGaimPrvgrp)l->data)->id == id) 1212 if (((SilcPurplePrvgrp)l->data)->id == id)
1213 break; 1213 break;
1214 if (!l) 1214 if (!l)
1215 return; 1215 return;
1216 prv = l->data; 1216 prv = l->data;
1217 channel = silc_client_get_channel(sg->client, sg->conn, 1217 channel = silc_client_get_channel(sg->client, sg->conn,
1244 1244
1245 serv_got_chat_left(gc, id); 1245 serv_got_chat_left(gc, id);
1246 1246
1247 /* Leave from private groups on this channel as well */ 1247 /* Leave from private groups on this channel as well */
1248 for (l = sg->grps; l; l = l->next) 1248 for (l = sg->grps; l; l = l->next)
1249 if (((SilcGaimPrvgrp)l->data)->chid == id) { 1249 if (((SilcPurplePrvgrp)l->data)->chid == id) {
1250 prv = l->data; 1250 prv = l->data;
1251 silc_client_del_channel_private_key(client, conn, 1251 silc_client_del_channel_private_key(client, conn,
1252 chu->channel, 1252 chu->channel,
1253 prv->key); 1253 prv->key);
1254 serv_got_chat_left(gc, prv->id); 1254 serv_got_chat_left(gc, prv->id);
1257 if (!sg->grps) 1257 if (!sg->grps)
1258 break; 1258 break;
1259 } 1259 }
1260 } 1260 }
1261 1261
1262 int silcgaim_chat_send(GaimConnection *gc, int id, const char *msg, GaimMessageFlags msgflags) 1262 int silcpurple_chat_send(PurpleConnection *gc, int id, const char *msg, PurpleMessageFlags msgflags)
1263 { 1263 {
1264 SilcGaim sg = gc->proto_data; 1264 SilcPurple sg = gc->proto_data;
1265 SilcClient client = sg->client; 1265 SilcClient client = sg->client;
1266 SilcClientConnection conn = sg->conn; 1266 SilcClientConnection conn = sg->conn;
1267 SilcHashTableList htl; 1267 SilcHashTableList htl;
1268 SilcChannelUser chu; 1268 SilcChannelUser chu;
1269 SilcChannelEntry channel = NULL; 1269 SilcChannelEntry channel = NULL;
1270 SilcChannelPrivateKey key = NULL; 1270 SilcChannelPrivateKey key = NULL;
1271 SilcUInt32 flags; 1271 SilcUInt32 flags;
1272 int ret; 1272 int ret;
1273 char *msg2, *tmp; 1273 char *msg2, *tmp;
1274 gboolean found = FALSE; 1274 gboolean found = FALSE;
1275 gboolean sign = gaim_account_get_bool(sg->account, "sign-verify", FALSE); 1275 gboolean sign = purple_account_get_bool(sg->account, "sign-verify", FALSE);
1276 1276
1277 if (!msg || !conn) 1277 if (!msg || !conn)
1278 return 0; 1278 return 0;
1279 1279
1280 flags = SILC_MESSAGE_FLAG_UTF8; 1280 flags = SILC_MESSAGE_FLAG_UTF8;
1281 1281
1282 tmp = msg2 = gaim_unescape_html(msg); 1282 tmp = msg2 = purple_unescape_html(msg);
1283 1283
1284 if (!g_ascii_strncasecmp(msg2, "/me ", 4)) 1284 if (!g_ascii_strncasecmp(msg2, "/me ", 4))
1285 { 1285 {
1286 msg2 += 4; 1286 msg2 += 4;
1287 if (!*msg2) { 1287 if (!*msg2) {
1289 return 0; 1289 return 0;
1290 } 1290 }
1291 flags |= SILC_MESSAGE_FLAG_ACTION; 1291 flags |= SILC_MESSAGE_FLAG_ACTION;
1292 } else if (strlen(msg) > 1 && msg[0] == '/') { 1292 } else if (strlen(msg) > 1 && msg[0] == '/') {
1293 if (!silc_client_command_call(client, conn, msg + 1)) 1293 if (!silc_client_command_call(client, conn, msg + 1))
1294 gaim_notify_error(gc, _("Call Command"), _("Cannot call command"), 1294 purple_notify_error(gc, _("Call Command"), _("Cannot call command"),
1295 _("Unknown command")); 1295 _("Unknown command"));
1296 g_free(tmp); 1296 g_free(tmp);
1297 return 0; 1297 return 0;
1298 } 1298 }
1299 1299
1301 if (sign) 1301 if (sign)
1302 flags |= SILC_MESSAGE_FLAG_SIGNED; 1302 flags |= SILC_MESSAGE_FLAG_SIGNED;
1303 1303
1304 /* Get the channel private key if we are sending on 1304 /* Get the channel private key if we are sending on
1305 private group */ 1305 private group */
1306 if (id > SILCGAIM_PRVGRP) { 1306 if (id > SILCPURPLE_PRVGRP) {
1307 GList *l; 1307 GList *l;
1308 SilcGaimPrvgrp prv; 1308 SilcPurplePrvgrp prv;
1309 1309
1310 for (l = sg->grps; l; l = l->next) 1310 for (l = sg->grps; l; l = l->next)
1311 if (((SilcGaimPrvgrp)l->data)->id == id) 1311 if (((SilcPurplePrvgrp)l->data)->id == id)
1312 break; 1312 break;
1313 if (!l) { 1313 if (!l) {
1314 g_free(tmp); 1314 g_free(tmp);
1315 return 0; 1315 return 0;
1316 } 1316 }
1344 /* Send channel message */ 1344 /* Send channel message */
1345 ret = silc_client_send_channel_message(client, conn, channel, key, 1345 ret = silc_client_send_channel_message(client, conn, channel, key,
1346 flags, (unsigned char *)msg2, 1346 flags, (unsigned char *)msg2,
1347 strlen(msg2), TRUE); 1347 strlen(msg2), TRUE);
1348 if (ret) { 1348 if (ret) {
1349 serv_got_chat_in(gc, id, gaim_connection_get_display_name(gc), 0, msg, 1349 serv_got_chat_in(gc, id, purple_connection_get_display_name(gc), 0, msg,
1350 time(NULL)); 1350 time(NULL));
1351 } 1351 }
1352 g_free(tmp); 1352 g_free(tmp);
1353 1353
1354 return ret; 1354 return ret;
1355 } 1355 }
1356 1356
1357 void silcgaim_chat_set_topic(GaimConnection *gc, int id, const char *topic) 1357 void silcpurple_chat_set_topic(PurpleConnection *gc, int id, const char *topic)
1358 { 1358 {
1359 SilcGaim sg = gc->proto_data; 1359 SilcPurple sg = gc->proto_data;
1360 SilcClient client = sg->client; 1360 SilcClient client = sg->client;
1361 SilcClientConnection conn = sg->conn; 1361 SilcClientConnection conn = sg->conn;
1362 SilcHashTableList htl; 1362 SilcHashTableList htl;
1363 SilcChannelUser chu; 1363 SilcChannelUser chu;
1364 gboolean found = FALSE; 1364 gboolean found = FALSE;
1366 if (!conn) 1366 if (!conn)
1367 return; 1367 return;
1368 1368
1369 /* See if setting topic on private group. Set it 1369 /* See if setting topic on private group. Set it
1370 on the actual channel */ 1370 on the actual channel */
1371 if (id > SILCGAIM_PRVGRP) { 1371 if (id > SILCPURPLE_PRVGRP) {
1372 GList *l; 1372 GList *l;
1373 SilcGaimPrvgrp prv; 1373 SilcPurplePrvgrp prv;
1374 1374
1375 for (l = sg->grps; l; l = l->next) 1375 for (l = sg->grps; l; l = l->next)
1376 if (((SilcGaimPrvgrp)l->data)->id == id) 1376 if (((SilcPurplePrvgrp)l->data)->id == id)
1377 break; 1377 break;
1378 if (!l) 1378 if (!l)
1379 return; 1379 return;
1380 prv = l->data; 1380 prv = l->data;
1381 id = prv->chid; 1381 id = prv->chid;
1396 /* Call TOPIC */ 1396 /* Call TOPIC */
1397 silc_client_command_call(client, conn, NULL, "TOPIC", 1397 silc_client_command_call(client, conn, NULL, "TOPIC",
1398 chu->channel->channel_name, topic, NULL); 1398 chu->channel->channel_name, topic, NULL);
1399 } 1399 }
1400 1400
1401 GaimRoomlist *silcgaim_roomlist_get_list(GaimConnection *gc) 1401 PurpleRoomlist *silcpurple_roomlist_get_list(PurpleConnection *gc)
1402 { 1402 {
1403 SilcGaim sg = gc->proto_data; 1403 SilcPurple sg = gc->proto_data;
1404 SilcClient client = sg->client; 1404 SilcClient client = sg->client;
1405 SilcClientConnection conn = sg->conn; 1405 SilcClientConnection conn = sg->conn;
1406 GList *fields = NULL; 1406 GList *fields = NULL;
1407 GaimRoomlistField *f; 1407 PurpleRoomlistField *f;
1408 1408
1409 if (!conn) 1409 if (!conn)
1410 return NULL; 1410 return NULL;
1411 1411
1412 if (sg->roomlist) 1412 if (sg->roomlist)
1413 gaim_roomlist_unref(sg->roomlist); 1413 purple_roomlist_unref(sg->roomlist);
1414 1414
1415 sg->roomlist_canceled = FALSE; 1415 sg->roomlist_canceled = FALSE;
1416 1416
1417 sg->roomlist = gaim_roomlist_new(gaim_connection_get_account(gc)); 1417 sg->roomlist = purple_roomlist_new(purple_connection_get_account(gc));
1418 f = gaim_roomlist_field_new(GAIM_ROOMLIST_FIELD_STRING, "", "channel", TRUE); 1418 f = purple_roomlist_field_new(PURPLE_ROOMLIST_FIELD_STRING, "", "channel", TRUE);
1419 fields = g_list_append(fields, f); 1419 fields = g_list_append(fields, f);
1420 f = gaim_roomlist_field_new(GAIM_ROOMLIST_FIELD_INT, 1420 f = purple_roomlist_field_new(PURPLE_ROOMLIST_FIELD_INT,
1421 _("Users"), "users", FALSE); 1421 _("Users"), "users", FALSE);
1422 fields = g_list_append(fields, f); 1422 fields = g_list_append(fields, f);
1423 f = gaim_roomlist_field_new(GAIM_ROOMLIST_FIELD_STRING, 1423 f = purple_roomlist_field_new(PURPLE_ROOMLIST_FIELD_STRING,
1424 _("Topic"), "topic", FALSE); 1424 _("Topic"), "topic", FALSE);
1425 fields = g_list_append(fields, f); 1425 fields = g_list_append(fields, f);
1426 gaim_roomlist_set_fields(sg->roomlist, fields); 1426 purple_roomlist_set_fields(sg->roomlist, fields);
1427 1427
1428 /* Call LIST */ 1428 /* Call LIST */
1429 silc_client_command_call(client, conn, "LIST"); 1429 silc_client_command_call(client, conn, "LIST");
1430 1430
1431 gaim_roomlist_set_in_progress(sg->roomlist, TRUE); 1431 purple_roomlist_set_in_progress(sg->roomlist, TRUE);
1432 1432
1433 return sg->roomlist; 1433 return sg->roomlist;
1434 } 1434 }
1435 1435
1436 void silcgaim_roomlist_cancel(GaimRoomlist *list) 1436 void silcpurple_roomlist_cancel(PurpleRoomlist *list)
1437 { 1437 {
1438 GaimConnection *gc = gaim_account_get_connection(list->account); 1438 PurpleConnection *gc = purple_account_get_connection(list->account);
1439 SilcGaim sg; 1439 SilcPurple sg;
1440 1440
1441 if (!gc) 1441 if (!gc)
1442 return; 1442 return;
1443 sg = gc->proto_data; 1443 sg = gc->proto_data;
1444 1444
1445 gaim_roomlist_set_in_progress(list, FALSE); 1445 purple_roomlist_set_in_progress(list, FALSE);
1446 if (sg->roomlist == list) { 1446 if (sg->roomlist == list) {
1447 gaim_roomlist_unref(sg->roomlist); 1447 purple_roomlist_unref(sg->roomlist);
1448 sg->roomlist = NULL; 1448 sg->roomlist = NULL;
1449 sg->roomlist_canceled = TRUE; 1449 sg->roomlist_canceled = TRUE;
1450 } 1450 }
1451 } 1451 }