annotate src/protocols/silc/ops.c @ 13226:51dd24fd8290

[gaim-migrate @ 15591] Whitespace. I remember when this file was ~5000 lines. It's almost 9000 now. I should really do something about that. committer: Tailor Script <tailor@pidgin.im>
author Mark Doliner <mark@kingant.net>
date Sat, 11 Feb 2006 18:12:06 +0000
parents b704e60fe5de
children b2efa1432708
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
8849
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1 /*
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
3 silcgaim_ops.c
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
4
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
5 Author: Pekka Riikonen <priikone@silcnet.org>
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
6
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
7 Copyright (C) 2004 Pekka Riikonen
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
8
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
9 This program is free software; you can redistribute it and/or modify
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
10 it under the terms of the GNU General Public License as published by
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
11 the Free Software Foundation; version 2 of the License.
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
12
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
13 This program is distributed in the hope that it will be useful,
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
16 GNU General Public License for more details.
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
17
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
18 */
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
19
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
20 #include "silcincludes.h"
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
21 #include "silcclient.h"
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
22 #include "silcgaim.h"
12217
029802981b81 [gaim-migrate @ 14519]
Stu Tomlinson <stu@nosnilmot.com>
parents: 12167
diff changeset
23 #include "imgstore.h"
12058
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents: 11533
diff changeset
24 #include "wb.h"
8849
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
25
12217
029802981b81 [gaim-migrate @ 14519]
Stu Tomlinson <stu@nosnilmot.com>
parents: 12167
diff changeset
26 static void
029802981b81 [gaim-migrate @ 14519]
Stu Tomlinson <stu@nosnilmot.com>
parents: 12167
diff changeset
27 silc_channel_message(SilcClient client, SilcClientConnection conn,
029802981b81 [gaim-migrate @ 14519]
Stu Tomlinson <stu@nosnilmot.com>
parents: 12167
diff changeset
28 SilcClientEntry sender, SilcChannelEntry channel,
029802981b81 [gaim-migrate @ 14519]
Stu Tomlinson <stu@nosnilmot.com>
parents: 12167
diff changeset
29 SilcMessagePayload payload, SilcChannelPrivateKey key,
029802981b81 [gaim-migrate @ 14519]
Stu Tomlinson <stu@nosnilmot.com>
parents: 12167
diff changeset
30 SilcMessageFlags flags, const unsigned char *message,
029802981b81 [gaim-migrate @ 14519]
Stu Tomlinson <stu@nosnilmot.com>
parents: 12167
diff changeset
31 SilcUInt32 message_len);
029802981b81 [gaim-migrate @ 14519]
Stu Tomlinson <stu@nosnilmot.com>
parents: 12167
diff changeset
32 static void
029802981b81 [gaim-migrate @ 14519]
Stu Tomlinson <stu@nosnilmot.com>
parents: 12167
diff changeset
33 silc_private_message(SilcClient client, SilcClientConnection conn,
029802981b81 [gaim-migrate @ 14519]
Stu Tomlinson <stu@nosnilmot.com>
parents: 12167
diff changeset
34 SilcClientEntry sender, SilcMessagePayload payload,
029802981b81 [gaim-migrate @ 14519]
Stu Tomlinson <stu@nosnilmot.com>
parents: 12167
diff changeset
35 SilcMessageFlags flags, const unsigned char *message,
029802981b81 [gaim-migrate @ 14519]
Stu Tomlinson <stu@nosnilmot.com>
parents: 12167
diff changeset
36 SilcUInt32 message_len);
029802981b81 [gaim-migrate @ 14519]
Stu Tomlinson <stu@nosnilmot.com>
parents: 12167
diff changeset
37
8849
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
38 /* Message sent to the application by library. `conn' associates the
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
39 message to a specific connection. `conn', however, may be NULL.
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
40 The `type' indicates the type of the message sent by the library.
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
41 The application can for example filter the message according the
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
42 type. */
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
43
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
44 static void
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
45 silc_say(SilcClient client, SilcClientConnection conn,
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
46 SilcClientMessageType type, char *msg, ...)
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
47 {
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
48 /* Nothing */
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
49 }
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
50
12217
029802981b81 [gaim-migrate @ 14519]
Stu Tomlinson <stu@nosnilmot.com>
parents: 12167
diff changeset
51 #ifdef HAVE_SILCMIME_H
029802981b81 [gaim-migrate @ 14519]
Stu Tomlinson <stu@nosnilmot.com>
parents: 12167
diff changeset
52 /* Processes incoming MIME message. Can be private message or channel
029802981b81 [gaim-migrate @ 14519]
Stu Tomlinson <stu@nosnilmot.com>
parents: 12167
diff changeset
53 message. */
029802981b81 [gaim-migrate @ 14519]
Stu Tomlinson <stu@nosnilmot.com>
parents: 12167
diff changeset
54
029802981b81 [gaim-migrate @ 14519]
Stu Tomlinson <stu@nosnilmot.com>
parents: 12167
diff changeset
55 static void
029802981b81 [gaim-migrate @ 14519]
Stu Tomlinson <stu@nosnilmot.com>
parents: 12167
diff changeset
56 silcgaim_mime_message(SilcClient client, SilcClientConnection conn,
029802981b81 [gaim-migrate @ 14519]
Stu Tomlinson <stu@nosnilmot.com>
parents: 12167
diff changeset
57 SilcClientEntry sender, SilcChannelEntry channel,
029802981b81 [gaim-migrate @ 14519]
Stu Tomlinson <stu@nosnilmot.com>
parents: 12167
diff changeset
58 SilcMessagePayload payload, SilcChannelPrivateKey key,
029802981b81 [gaim-migrate @ 14519]
Stu Tomlinson <stu@nosnilmot.com>
parents: 12167
diff changeset
59 SilcMessageFlags flags, SilcMime mime,
029802981b81 [gaim-migrate @ 14519]
Stu Tomlinson <stu@nosnilmot.com>
parents: 12167
diff changeset
60 gboolean recursive)
029802981b81 [gaim-migrate @ 14519]
Stu Tomlinson <stu@nosnilmot.com>
parents: 12167
diff changeset
61 {
029802981b81 [gaim-migrate @ 14519]
Stu Tomlinson <stu@nosnilmot.com>
parents: 12167
diff changeset
62 GaimConnection *gc = client->application;
029802981b81 [gaim-migrate @ 14519]
Stu Tomlinson <stu@nosnilmot.com>
parents: 12167
diff changeset
63 SilcGaim sg = gc->proto_data;
029802981b81 [gaim-migrate @ 14519]
Stu Tomlinson <stu@nosnilmot.com>
parents: 12167
diff changeset
64 const char *type;
029802981b81 [gaim-migrate @ 14519]
Stu Tomlinson <stu@nosnilmot.com>
parents: 12167
diff changeset
65 const unsigned char *data;
029802981b81 [gaim-migrate @ 14519]
Stu Tomlinson <stu@nosnilmot.com>
parents: 12167
diff changeset
66 SilcUInt32 data_len;
029802981b81 [gaim-migrate @ 14519]
Stu Tomlinson <stu@nosnilmot.com>
parents: 12167
diff changeset
67 GaimMessageFlags cflags = 0;
029802981b81 [gaim-migrate @ 14519]
Stu Tomlinson <stu@nosnilmot.com>
parents: 12167
diff changeset
68 GaimConversation *convo = NULL;
029802981b81 [gaim-migrate @ 14519]
Stu Tomlinson <stu@nosnilmot.com>
parents: 12167
diff changeset
69
029802981b81 [gaim-migrate @ 14519]
Stu Tomlinson <stu@nosnilmot.com>
parents: 12167
diff changeset
70 if (!mime)
029802981b81 [gaim-migrate @ 14519]
Stu Tomlinson <stu@nosnilmot.com>
parents: 12167
diff changeset
71 return;
029802981b81 [gaim-migrate @ 14519]
Stu Tomlinson <stu@nosnilmot.com>
parents: 12167
diff changeset
72
029802981b81 [gaim-migrate @ 14519]
Stu Tomlinson <stu@nosnilmot.com>
parents: 12167
diff changeset
73 /* Check for fragmented MIME message */
029802981b81 [gaim-migrate @ 14519]
Stu Tomlinson <stu@nosnilmot.com>
parents: 12167
diff changeset
74 if (silc_mime_is_partial(mime)) {
029802981b81 [gaim-migrate @ 14519]
Stu Tomlinson <stu@nosnilmot.com>
parents: 12167
diff changeset
75 if (!sg->mimeass)
029802981b81 [gaim-migrate @ 14519]
Stu Tomlinson <stu@nosnilmot.com>
parents: 12167
diff changeset
76 sg->mimeass = silc_mime_assembler_alloc();
029802981b81 [gaim-migrate @ 14519]
Stu Tomlinson <stu@nosnilmot.com>
parents: 12167
diff changeset
77
029802981b81 [gaim-migrate @ 14519]
Stu Tomlinson <stu@nosnilmot.com>
parents: 12167
diff changeset
78 /* Defragment */
029802981b81 [gaim-migrate @ 14519]
Stu Tomlinson <stu@nosnilmot.com>
parents: 12167
diff changeset
79 mime = silc_mime_assemble(sg->mimeass, mime);
029802981b81 [gaim-migrate @ 14519]
Stu Tomlinson <stu@nosnilmot.com>
parents: 12167
diff changeset
80 if (!mime)
029802981b81 [gaim-migrate @ 14519]
Stu Tomlinson <stu@nosnilmot.com>
parents: 12167
diff changeset
81 /* More fragments to come */
029802981b81 [gaim-migrate @ 14519]
Stu Tomlinson <stu@nosnilmot.com>
parents: 12167
diff changeset
82 return;
029802981b81 [gaim-migrate @ 14519]
Stu Tomlinson <stu@nosnilmot.com>
parents: 12167
diff changeset
83
029802981b81 [gaim-migrate @ 14519]
Stu Tomlinson <stu@nosnilmot.com>
parents: 12167
diff changeset
84 /* Process the complete message */
029802981b81 [gaim-migrate @ 14519]
Stu Tomlinson <stu@nosnilmot.com>
parents: 12167
diff changeset
85 silcgaim_mime_message(client, conn, sender, channel,
029802981b81 [gaim-migrate @ 14519]
Stu Tomlinson <stu@nosnilmot.com>
parents: 12167
diff changeset
86 payload, key, flags, mime, FALSE);
029802981b81 [gaim-migrate @ 14519]
Stu Tomlinson <stu@nosnilmot.com>
parents: 12167
diff changeset
87 return;
029802981b81 [gaim-migrate @ 14519]
Stu Tomlinson <stu@nosnilmot.com>
parents: 12167
diff changeset
88 }
029802981b81 [gaim-migrate @ 14519]
Stu Tomlinson <stu@nosnilmot.com>
parents: 12167
diff changeset
89
029802981b81 [gaim-migrate @ 14519]
Stu Tomlinson <stu@nosnilmot.com>
parents: 12167
diff changeset
90 /* Check for multipart message */
029802981b81 [gaim-migrate @ 14519]
Stu Tomlinson <stu@nosnilmot.com>
parents: 12167
diff changeset
91 if (silc_mime_is_multipart(mime)) {
029802981b81 [gaim-migrate @ 14519]
Stu Tomlinson <stu@nosnilmot.com>
parents: 12167
diff changeset
92 SilcMime p;
029802981b81 [gaim-migrate @ 14519]
Stu Tomlinson <stu@nosnilmot.com>
parents: 12167
diff changeset
93 const char *mtype;
029802981b81 [gaim-migrate @ 14519]
Stu Tomlinson <stu@nosnilmot.com>
parents: 12167
diff changeset
94 SilcDList parts = silc_mime_get_multiparts(mime, &mtype);
029802981b81 [gaim-migrate @ 14519]
Stu Tomlinson <stu@nosnilmot.com>
parents: 12167
diff changeset
95
029802981b81 [gaim-migrate @ 14519]
Stu Tomlinson <stu@nosnilmot.com>
parents: 12167
diff changeset
96 /* Only "mixed" type supported */
029802981b81 [gaim-migrate @ 14519]
Stu Tomlinson <stu@nosnilmot.com>
parents: 12167
diff changeset
97 if (strcmp(mtype, "mixed"))
029802981b81 [gaim-migrate @ 14519]
Stu Tomlinson <stu@nosnilmot.com>
parents: 12167
diff changeset
98 goto out;
029802981b81 [gaim-migrate @ 14519]
Stu Tomlinson <stu@nosnilmot.com>
parents: 12167
diff changeset
99
029802981b81 [gaim-migrate @ 14519]
Stu Tomlinson <stu@nosnilmot.com>
parents: 12167
diff changeset
100 silc_dlist_start(parts);
029802981b81 [gaim-migrate @ 14519]
Stu Tomlinson <stu@nosnilmot.com>
parents: 12167
diff changeset
101 while ((p = silc_dlist_get(parts)) != SILC_LIST_END) {
029802981b81 [gaim-migrate @ 14519]
Stu Tomlinson <stu@nosnilmot.com>
parents: 12167
diff changeset
102 /* Recursively process parts */
029802981b81 [gaim-migrate @ 14519]
Stu Tomlinson <stu@nosnilmot.com>
parents: 12167
diff changeset
103 silcgaim_mime_message(client, conn, sender, channel,
029802981b81 [gaim-migrate @ 14519]
Stu Tomlinson <stu@nosnilmot.com>
parents: 12167
diff changeset
104 payload, key, flags, p, TRUE);
029802981b81 [gaim-migrate @ 14519]
Stu Tomlinson <stu@nosnilmot.com>
parents: 12167
diff changeset
105 }
029802981b81 [gaim-migrate @ 14519]
Stu Tomlinson <stu@nosnilmot.com>
parents: 12167
diff changeset
106 goto out;
029802981b81 [gaim-migrate @ 14519]
Stu Tomlinson <stu@nosnilmot.com>
parents: 12167
diff changeset
107 }
029802981b81 [gaim-migrate @ 14519]
Stu Tomlinson <stu@nosnilmot.com>
parents: 12167
diff changeset
108
029802981b81 [gaim-migrate @ 14519]
Stu Tomlinson <stu@nosnilmot.com>
parents: 12167
diff changeset
109 /* Get content type and MIME data */
029802981b81 [gaim-migrate @ 14519]
Stu Tomlinson <stu@nosnilmot.com>
parents: 12167
diff changeset
110 type = silc_mime_get_field(mime, "Content-Type");
029802981b81 [gaim-migrate @ 14519]
Stu Tomlinson <stu@nosnilmot.com>
parents: 12167
diff changeset
111 if (!type)
029802981b81 [gaim-migrate @ 14519]
Stu Tomlinson <stu@nosnilmot.com>
parents: 12167
diff changeset
112 goto out;
029802981b81 [gaim-migrate @ 14519]
Stu Tomlinson <stu@nosnilmot.com>
parents: 12167
diff changeset
113 data = silc_mime_get_data(mime, &data_len);
029802981b81 [gaim-migrate @ 14519]
Stu Tomlinson <stu@nosnilmot.com>
parents: 12167
diff changeset
114 if (!data)
029802981b81 [gaim-migrate @ 14519]
Stu Tomlinson <stu@nosnilmot.com>
parents: 12167
diff changeset
115 goto out;
029802981b81 [gaim-migrate @ 14519]
Stu Tomlinson <stu@nosnilmot.com>
parents: 12167
diff changeset
116
029802981b81 [gaim-migrate @ 14519]
Stu Tomlinson <stu@nosnilmot.com>
parents: 12167
diff changeset
117 /* Process according to content type */
029802981b81 [gaim-migrate @ 14519]
Stu Tomlinson <stu@nosnilmot.com>
parents: 12167
diff changeset
118
029802981b81 [gaim-migrate @ 14519]
Stu Tomlinson <stu@nosnilmot.com>
parents: 12167
diff changeset
119 /* Plain text */
029802981b81 [gaim-migrate @ 14519]
Stu Tomlinson <stu@nosnilmot.com>
parents: 12167
diff changeset
120 if (strstr(type, "text/plain")) {
029802981b81 [gaim-migrate @ 14519]
Stu Tomlinson <stu@nosnilmot.com>
parents: 12167
diff changeset
121 /* Default is UTF-8, don't check for other charsets */
029802981b81 [gaim-migrate @ 14519]
Stu Tomlinson <stu@nosnilmot.com>
parents: 12167
diff changeset
122 if (!strstr(type, "utf-8"))
029802981b81 [gaim-migrate @ 14519]
Stu Tomlinson <stu@nosnilmot.com>
parents: 12167
diff changeset
123 goto out;
029802981b81 [gaim-migrate @ 14519]
Stu Tomlinson <stu@nosnilmot.com>
parents: 12167
diff changeset
124
029802981b81 [gaim-migrate @ 14519]
Stu Tomlinson <stu@nosnilmot.com>
parents: 12167
diff changeset
125 if (channel)
029802981b81 [gaim-migrate @ 14519]
Stu Tomlinson <stu@nosnilmot.com>
parents: 12167
diff changeset
126 silc_channel_message(client, conn, sender, channel,
029802981b81 [gaim-migrate @ 14519]
Stu Tomlinson <stu@nosnilmot.com>
parents: 12167
diff changeset
127 payload, key,
029802981b81 [gaim-migrate @ 14519]
Stu Tomlinson <stu@nosnilmot.com>
parents: 12167
diff changeset
128 SILC_MESSAGE_FLAG_UTF8, data,
029802981b81 [gaim-migrate @ 14519]
Stu Tomlinson <stu@nosnilmot.com>
parents: 12167
diff changeset
129 data_len);
029802981b81 [gaim-migrate @ 14519]
Stu Tomlinson <stu@nosnilmot.com>
parents: 12167
diff changeset
130 else
029802981b81 [gaim-migrate @ 14519]
Stu Tomlinson <stu@nosnilmot.com>
parents: 12167
diff changeset
131 silc_private_message(client, conn, sender, payload,
029802981b81 [gaim-migrate @ 14519]
Stu Tomlinson <stu@nosnilmot.com>
parents: 12167
diff changeset
132 SILC_MESSAGE_FLAG_UTF8, data,
029802981b81 [gaim-migrate @ 14519]
Stu Tomlinson <stu@nosnilmot.com>
parents: 12167
diff changeset
133 data_len);
029802981b81 [gaim-migrate @ 14519]
Stu Tomlinson <stu@nosnilmot.com>
parents: 12167
diff changeset
134 goto out;
029802981b81 [gaim-migrate @ 14519]
Stu Tomlinson <stu@nosnilmot.com>
parents: 12167
diff changeset
135 }
029802981b81 [gaim-migrate @ 14519]
Stu Tomlinson <stu@nosnilmot.com>
parents: 12167
diff changeset
136
029802981b81 [gaim-migrate @ 14519]
Stu Tomlinson <stu@nosnilmot.com>
parents: 12167
diff changeset
137 /* Image */
029802981b81 [gaim-migrate @ 14519]
Stu Tomlinson <stu@nosnilmot.com>
parents: 12167
diff changeset
138 if (strstr(type, "image/png") ||
029802981b81 [gaim-migrate @ 14519]
Stu Tomlinson <stu@nosnilmot.com>
parents: 12167
diff changeset
139 strstr(type, "image/jpeg") ||
029802981b81 [gaim-migrate @ 14519]
Stu Tomlinson <stu@nosnilmot.com>
parents: 12167
diff changeset
140 strstr(type, "image/gif") ||
029802981b81 [gaim-migrate @ 14519]
Stu Tomlinson <stu@nosnilmot.com>
parents: 12167
diff changeset
141 strstr(type, "image/tiff")) {
029802981b81 [gaim-migrate @ 14519]
Stu Tomlinson <stu@nosnilmot.com>
parents: 12167
diff changeset
142 char tmp[32];
029802981b81 [gaim-migrate @ 14519]
Stu Tomlinson <stu@nosnilmot.com>
parents: 12167
diff changeset
143 int imgid;
029802981b81 [gaim-migrate @ 14519]
Stu Tomlinson <stu@nosnilmot.com>
parents: 12167
diff changeset
144
029802981b81 [gaim-migrate @ 14519]
Stu Tomlinson <stu@nosnilmot.com>
parents: 12167
diff changeset
145 /* Get channel convo (if message is for channel) */
029802981b81 [gaim-migrate @ 14519]
Stu Tomlinson <stu@nosnilmot.com>
parents: 12167
diff changeset
146 if (key && channel) {
029802981b81 [gaim-migrate @ 14519]
Stu Tomlinson <stu@nosnilmot.com>
parents: 12167
diff changeset
147 GList *l;
029802981b81 [gaim-migrate @ 14519]
Stu Tomlinson <stu@nosnilmot.com>
parents: 12167
diff changeset
148 SilcGaimPrvgrp prv;
029802981b81 [gaim-migrate @ 14519]
Stu Tomlinson <stu@nosnilmot.com>
parents: 12167
diff changeset
149
029802981b81 [gaim-migrate @ 14519]
Stu Tomlinson <stu@nosnilmot.com>
parents: 12167
diff changeset
150 for (l = sg->grps; l; l = l->next)
029802981b81 [gaim-migrate @ 14519]
Stu Tomlinson <stu@nosnilmot.com>
parents: 12167
diff changeset
151 if (((SilcGaimPrvgrp)l->data)->key == key) {
029802981b81 [gaim-migrate @ 14519]
Stu Tomlinson <stu@nosnilmot.com>
parents: 12167
diff changeset
152 prv = l->data;
029802981b81 [gaim-migrate @ 14519]
Stu Tomlinson <stu@nosnilmot.com>
parents: 12167
diff changeset
153 convo = gaim_find_conversation_with_account(GAIM_CONV_TYPE_CHAT,
029802981b81 [gaim-migrate @ 14519]
Stu Tomlinson <stu@nosnilmot.com>
parents: 12167
diff changeset
154 prv->channel, sg->account);
029802981b81 [gaim-migrate @ 14519]
Stu Tomlinson <stu@nosnilmot.com>
parents: 12167
diff changeset
155 break;
029802981b81 [gaim-migrate @ 14519]
Stu Tomlinson <stu@nosnilmot.com>
parents: 12167
diff changeset
156 }
029802981b81 [gaim-migrate @ 14519]
Stu Tomlinson <stu@nosnilmot.com>
parents: 12167
diff changeset
157 }
029802981b81 [gaim-migrate @ 14519]
Stu Tomlinson <stu@nosnilmot.com>
parents: 12167
diff changeset
158 if (channel && !convo)
029802981b81 [gaim-migrate @ 14519]
Stu Tomlinson <stu@nosnilmot.com>
parents: 12167
diff changeset
159 convo = gaim_find_conversation_with_account(GAIM_CONV_TYPE_CHAT,
029802981b81 [gaim-migrate @ 14519]
Stu Tomlinson <stu@nosnilmot.com>
parents: 12167
diff changeset
160 channel->channel_name, sg->account);
029802981b81 [gaim-migrate @ 14519]
Stu Tomlinson <stu@nosnilmot.com>
parents: 12167
diff changeset
161 if (channel && !convo)
029802981b81 [gaim-migrate @ 14519]
Stu Tomlinson <stu@nosnilmot.com>
parents: 12167
diff changeset
162 goto out;
029802981b81 [gaim-migrate @ 14519]
Stu Tomlinson <stu@nosnilmot.com>
parents: 12167
diff changeset
163
029802981b81 [gaim-migrate @ 14519]
Stu Tomlinson <stu@nosnilmot.com>
parents: 12167
diff changeset
164 imgid = gaim_imgstore_add(data, data_len, "");
029802981b81 [gaim-migrate @ 14519]
Stu Tomlinson <stu@nosnilmot.com>
parents: 12167
diff changeset
165 if (imgid) {
029802981b81 [gaim-migrate @ 14519]
Stu Tomlinson <stu@nosnilmot.com>
parents: 12167
diff changeset
166 cflags |= GAIM_MESSAGE_IMAGES | GAIM_MESSAGE_RECV;
029802981b81 [gaim-migrate @ 14519]
Stu Tomlinson <stu@nosnilmot.com>
parents: 12167
diff changeset
167 g_snprintf(tmp, sizeof(tmp), "<IMG ID=\"%d\">", imgid);
029802981b81 [gaim-migrate @ 14519]
Stu Tomlinson <stu@nosnilmot.com>
parents: 12167
diff changeset
168
029802981b81 [gaim-migrate @ 14519]
Stu Tomlinson <stu@nosnilmot.com>
parents: 12167
diff changeset
169 if (channel)
029802981b81 [gaim-migrate @ 14519]
Stu Tomlinson <stu@nosnilmot.com>
parents: 12167
diff changeset
170 serv_got_chat_in(gc, gaim_conv_chat_get_id(GAIM_CONV_CHAT(convo)),
029802981b81 [gaim-migrate @ 14519]
Stu Tomlinson <stu@nosnilmot.com>
parents: 12167
diff changeset
171 sender->nickname ?
029802981b81 [gaim-migrate @ 14519]
Stu Tomlinson <stu@nosnilmot.com>
parents: 12167
diff changeset
172 sender->nickname :
029802981b81 [gaim-migrate @ 14519]
Stu Tomlinson <stu@nosnilmot.com>
parents: 12167
diff changeset
173 "<unknown>", cflags,
029802981b81 [gaim-migrate @ 14519]
Stu Tomlinson <stu@nosnilmot.com>
parents: 12167
diff changeset
174 tmp, time(NULL));
029802981b81 [gaim-migrate @ 14519]
Stu Tomlinson <stu@nosnilmot.com>
parents: 12167
diff changeset
175 else
029802981b81 [gaim-migrate @ 14519]
Stu Tomlinson <stu@nosnilmot.com>
parents: 12167
diff changeset
176 serv_got_im(gc, sender->nickname ?
029802981b81 [gaim-migrate @ 14519]
Stu Tomlinson <stu@nosnilmot.com>
parents: 12167
diff changeset
177 sender->nickname : "<unknown>",
029802981b81 [gaim-migrate @ 14519]
Stu Tomlinson <stu@nosnilmot.com>
parents: 12167
diff changeset
178 tmp, cflags, time(NULL));
029802981b81 [gaim-migrate @ 14519]
Stu Tomlinson <stu@nosnilmot.com>
parents: 12167
diff changeset
179
029802981b81 [gaim-migrate @ 14519]
Stu Tomlinson <stu@nosnilmot.com>
parents: 12167
diff changeset
180 gaim_imgstore_unref(imgid);
029802981b81 [gaim-migrate @ 14519]
Stu Tomlinson <stu@nosnilmot.com>
parents: 12167
diff changeset
181 cflags = 0;
029802981b81 [gaim-migrate @ 14519]
Stu Tomlinson <stu@nosnilmot.com>
parents: 12167
diff changeset
182 }
029802981b81 [gaim-migrate @ 14519]
Stu Tomlinson <stu@nosnilmot.com>
parents: 12167
diff changeset
183 goto out;
029802981b81 [gaim-migrate @ 14519]
Stu Tomlinson <stu@nosnilmot.com>
parents: 12167
diff changeset
184 }
029802981b81 [gaim-migrate @ 14519]
Stu Tomlinson <stu@nosnilmot.com>
parents: 12167
diff changeset
185
029802981b81 [gaim-migrate @ 14519]
Stu Tomlinson <stu@nosnilmot.com>
parents: 12167
diff changeset
186 /* Whiteboard message */
029802981b81 [gaim-migrate @ 14519]
Stu Tomlinson <stu@nosnilmot.com>
parents: 12167
diff changeset
187 if (strstr(type, "application/x-wb") &&
029802981b81 [gaim-migrate @ 14519]
Stu Tomlinson <stu@nosnilmot.com>
parents: 12167
diff changeset
188 !gaim_account_get_bool(sg->account, "block-wb", FALSE)) {
029802981b81 [gaim-migrate @ 14519]
Stu Tomlinson <stu@nosnilmot.com>
parents: 12167
diff changeset
189 if (channel)
029802981b81 [gaim-migrate @ 14519]
Stu Tomlinson <stu@nosnilmot.com>
parents: 12167
diff changeset
190 silcgaim_wb_receive_ch(client, conn, sender, channel,
029802981b81 [gaim-migrate @ 14519]
Stu Tomlinson <stu@nosnilmot.com>
parents: 12167
diff changeset
191 payload, flags, data, data_len);
029802981b81 [gaim-migrate @ 14519]
Stu Tomlinson <stu@nosnilmot.com>
parents: 12167
diff changeset
192 else
029802981b81 [gaim-migrate @ 14519]
Stu Tomlinson <stu@nosnilmot.com>
parents: 12167
diff changeset
193 silcgaim_wb_receive(client, conn, sender, payload,
029802981b81 [gaim-migrate @ 14519]
Stu Tomlinson <stu@nosnilmot.com>
parents: 12167
diff changeset
194 flags, data, data_len);
029802981b81 [gaim-migrate @ 14519]
Stu Tomlinson <stu@nosnilmot.com>
parents: 12167
diff changeset
195 goto out;
029802981b81 [gaim-migrate @ 14519]
Stu Tomlinson <stu@nosnilmot.com>
parents: 12167
diff changeset
196 }
029802981b81 [gaim-migrate @ 14519]
Stu Tomlinson <stu@nosnilmot.com>
parents: 12167
diff changeset
197
029802981b81 [gaim-migrate @ 14519]
Stu Tomlinson <stu@nosnilmot.com>
parents: 12167
diff changeset
198 out:
029802981b81 [gaim-migrate @ 14519]
Stu Tomlinson <stu@nosnilmot.com>
parents: 12167
diff changeset
199 if (!recursive)
029802981b81 [gaim-migrate @ 14519]
Stu Tomlinson <stu@nosnilmot.com>
parents: 12167
diff changeset
200 silc_mime_free(mime);
029802981b81 [gaim-migrate @ 14519]
Stu Tomlinson <stu@nosnilmot.com>
parents: 12167
diff changeset
201 }
029802981b81 [gaim-migrate @ 14519]
Stu Tomlinson <stu@nosnilmot.com>
parents: 12167
diff changeset
202 #endif /* HAVE_SILCMIME_H */
8849
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
203
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
204 /* Message for a channel. The `sender' is the sender of the message
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
205 The `channel' is the channel. The `message' is the message. Note
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
206 that `message' maybe NULL. The `flags' indicates message flags
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
207 and it is used to determine how the message can be interpreted
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
208 (like it may tell the message is multimedia message). */
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
209
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
210 static void
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
211 silc_channel_message(SilcClient client, SilcClientConnection conn,
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
212 SilcClientEntry sender, SilcChannelEntry channel,
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
213 SilcMessagePayload payload, SilcChannelPrivateKey key,
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
214 SilcMessageFlags flags, const unsigned char *message,
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
215 SilcUInt32 message_len)
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
216 {
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
217 GaimConnection *gc = client->application;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
218 SilcGaim sg = gc->proto_data;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
219 GaimConversation *convo = NULL;
9359
43741d8f76f7 [gaim-migrate @ 10167]
Ethan Blanton <elb@pidgin.im>
parents: 9353
diff changeset
220 char *msg, *tmp;
8849
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
221
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
222 if (!message)
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
223 return;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
224
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
225 if (key) {
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
226 GList *l;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
227 SilcGaimPrvgrp prv;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
228
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
229 for (l = sg->grps; l; l = l->next)
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
230 if (((SilcGaimPrvgrp)l->data)->key == key) {
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
231 prv = l->data;
11338
17142948653e [gaim-migrate @ 13551]
Mark Doliner <mark@kingant.net>
parents: 11201
diff changeset
232 convo = gaim_find_conversation_with_account(GAIM_CONV_TYPE_CHAT,
10246
a66cf83552dc [gaim-migrate @ 11386]
Mark Doliner <mark@kingant.net>
parents: 10091
diff changeset
233 prv->channel, sg->account);
8849
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
234 break;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
235 }
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
236 }
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
237 if (!convo)
11338
17142948653e [gaim-migrate @ 13551]
Mark Doliner <mark@kingant.net>
parents: 11201
diff changeset
238 convo = gaim_find_conversation_with_account(GAIM_CONV_TYPE_CHAT,
10246
a66cf83552dc [gaim-migrate @ 11386]
Mark Doliner <mark@kingant.net>
parents: 10091
diff changeset
239 channel->channel_name, sg->account);
8849
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
240 if (!convo)
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
241 return;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
242
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
243 if (flags & SILC_MESSAGE_FLAG_SIGNED &&
12167
5851a9219bc7 [gaim-migrate @ 14468]
Ethan Blanton <elb@pidgin.im>
parents: 12058
diff changeset
244 gaim_account_get_bool(sg->account, "sign-verify", FALSE)) {
8849
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
245 /* XXX */
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
246 }
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
247
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
248 if (flags & SILC_MESSAGE_FLAG_DATA) {
12217
029802981b81 [gaim-migrate @ 14519]
Stu Tomlinson <stu@nosnilmot.com>
parents: 12167
diff changeset
249 /* Process MIME message */
029802981b81 [gaim-migrate @ 14519]
Stu Tomlinson <stu@nosnilmot.com>
parents: 12167
diff changeset
250 #ifdef HAVE_SILCMIME_H
029802981b81 [gaim-migrate @ 14519]
Stu Tomlinson <stu@nosnilmot.com>
parents: 12167
diff changeset
251 SilcMime mime;
029802981b81 [gaim-migrate @ 14519]
Stu Tomlinson <stu@nosnilmot.com>
parents: 12167
diff changeset
252 mime = silc_mime_decode(message, message_len);
029802981b81 [gaim-migrate @ 14519]
Stu Tomlinson <stu@nosnilmot.com>
parents: 12167
diff changeset
253 silcgaim_mime_message(client, conn, sender, channel, payload,
029802981b81 [gaim-migrate @ 14519]
Stu Tomlinson <stu@nosnilmot.com>
parents: 12167
diff changeset
254 key, flags, mime, FALSE);
029802981b81 [gaim-migrate @ 14519]
Stu Tomlinson <stu@nosnilmot.com>
parents: 12167
diff changeset
255 #else
12058
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents: 11533
diff changeset
256 char type[128], enc[128];
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents: 11533
diff changeset
257 unsigned char *data;
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents: 11533
diff changeset
258 SilcUInt32 data_len;
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents: 11533
diff changeset
259
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents: 11533
diff changeset
260 memset(type, 0, sizeof(type));
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents: 11533
diff changeset
261 memset(enc, 0, sizeof(enc));
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents: 11533
diff changeset
262
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents: 11533
diff changeset
263 if (!silc_mime_parse(message, message_len, NULL, 0,
12217
029802981b81 [gaim-migrate @ 14519]
Stu Tomlinson <stu@nosnilmot.com>
parents: 12167
diff changeset
264 type, sizeof(type) - 1, enc, sizeof(enc) - 1, &data,
12058
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents: 11533
diff changeset
265 &data_len))
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents: 11533
diff changeset
266 return;
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents: 11533
diff changeset
267
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents: 11533
diff changeset
268 if (!strcmp(type, "application/x-wb") &&
12167
5851a9219bc7 [gaim-migrate @ 14468]
Ethan Blanton <elb@pidgin.im>
parents: 12058
diff changeset
269 !strcmp(enc, "binary") &&
5851a9219bc7 [gaim-migrate @ 14468]
Ethan Blanton <elb@pidgin.im>
parents: 12058
diff changeset
270 !gaim_account_get_bool(sg->account, "block-wb", FALSE))
12058
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents: 11533
diff changeset
271 silcgaim_wb_receive_ch(client, conn, sender, channel,
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents: 11533
diff changeset
272 payload, flags, data, data_len);
12217
029802981b81 [gaim-migrate @ 14519]
Stu Tomlinson <stu@nosnilmot.com>
parents: 12167
diff changeset
273 #endif
8849
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
274 return;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
275 }
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
276
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
277 if (flags & SILC_MESSAGE_FLAG_ACTION) {
9353
b8138f3959dc [gaim-migrate @ 10161]
Ethan Blanton <elb@pidgin.im>
parents: 9272
diff changeset
278 msg = g_strdup_printf("/me %s",
8849
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
279 (const char *)message);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
280 if (!msg)
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
281 return;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
282
10732
c4cb90065e1d [gaim-migrate @ 12334]
Luke Schierer <lschiere@pidgin.im>
parents: 10589
diff changeset
283 tmp = g_markup_escape_text(msg, -1);
8849
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
284 /* Send to Gaim */
9353
b8138f3959dc [gaim-migrate @ 10161]
Ethan Blanton <elb@pidgin.im>
parents: 9272
diff changeset
285 serv_got_chat_in(gc, gaim_conv_chat_get_id(GAIM_CONV_CHAT(convo)),
b8138f3959dc [gaim-migrate @ 10161]
Ethan Blanton <elb@pidgin.im>
parents: 9272
diff changeset
286 sender->nickname ?
b8138f3959dc [gaim-migrate @ 10161]
Ethan Blanton <elb@pidgin.im>
parents: 9272
diff changeset
287 sender->nickname : "<unknown>", 0,
9359
43741d8f76f7 [gaim-migrate @ 10167]
Ethan Blanton <elb@pidgin.im>
parents: 9353
diff changeset
288 tmp, time(NULL));
43741d8f76f7 [gaim-migrate @ 10167]
Ethan Blanton <elb@pidgin.im>
parents: 9353
diff changeset
289 g_free(tmp);
8849
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
290 g_free(msg);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
291 return;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
292 }
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
293
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
294 if (flags & SILC_MESSAGE_FLAG_NOTICE) {
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
295 msg = g_strdup_printf("(notice) <I>%s</I> %s",
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
296 sender->nickname ?
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
297 sender->nickname : "<unknown>",
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
298 (const char *)message);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
299 if (!msg)
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
300 return;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
301
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
302 /* Send to Gaim */
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
303 gaim_conversation_write(convo, NULL, (const char *)msg,
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
304 GAIM_MESSAGE_SYSTEM, time(NULL));
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
305 g_free(msg);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
306 return;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
307 }
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
308
9359
43741d8f76f7 [gaim-migrate @ 10167]
Ethan Blanton <elb@pidgin.im>
parents: 9353
diff changeset
309 if (flags & SILC_MESSAGE_FLAG_UTF8) {
10732
c4cb90065e1d [gaim-migrate @ 12334]
Luke Schierer <lschiere@pidgin.im>
parents: 10589
diff changeset
310 tmp = g_markup_escape_text((const char *)message, -1);
8849
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
311 /* Send to Gaim */
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
312 serv_got_chat_in(gc, gaim_conv_chat_get_id(GAIM_CONV_CHAT(convo)),
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
313 sender->nickname ?
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
314 sender->nickname : "<unknown>", 0,
9359
43741d8f76f7 [gaim-migrate @ 10167]
Ethan Blanton <elb@pidgin.im>
parents: 9353
diff changeset
315 tmp, time(NULL));
43741d8f76f7 [gaim-migrate @ 10167]
Ethan Blanton <elb@pidgin.im>
parents: 9353
diff changeset
316 g_free(tmp);
43741d8f76f7 [gaim-migrate @ 10167]
Ethan Blanton <elb@pidgin.im>
parents: 9353
diff changeset
317 }
8849
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
318 }
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
319
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
320
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
321 /* Private message to the client. The `sender' is the sender of the
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
322 message. The message is `message'and maybe NULL. The `flags'
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
323 indicates message flags and it is used to determine how the message
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
324 can be interpreted (like it may tell the message is multimedia
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
325 message). */
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
326
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
327 static void
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
328 silc_private_message(SilcClient client, SilcClientConnection conn,
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
329 SilcClientEntry sender, SilcMessagePayload payload,
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
330 SilcMessageFlags flags, const unsigned char *message,
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
331 SilcUInt32 message_len)
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
332 {
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
333 GaimConnection *gc = client->application;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
334 SilcGaim sg = gc->proto_data;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
335 GaimConversation *convo = NULL;
9359
43741d8f76f7 [gaim-migrate @ 10167]
Ethan Blanton <elb@pidgin.im>
parents: 9353
diff changeset
336 char *msg, *tmp;
8849
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
337
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
338 if (!message)
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
339 return;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
340
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
341 if (sender->nickname)
11338
17142948653e [gaim-migrate @ 13551]
Mark Doliner <mark@kingant.net>
parents: 11201
diff changeset
342 /* XXX - Should this be GAIM_CONV_TYPE_IM? */
17142948653e [gaim-migrate @ 13551]
Mark Doliner <mark@kingant.net>
parents: 11201
diff changeset
343 convo = gaim_find_conversation_with_account(GAIM_CONV_TYPE_ANY,
10246
a66cf83552dc [gaim-migrate @ 11386]
Mark Doliner <mark@kingant.net>
parents: 10091
diff changeset
344 sender->nickname, sg->account);
8849
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
345
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
346 if (flags & SILC_MESSAGE_FLAG_SIGNED &&
12167
5851a9219bc7 [gaim-migrate @ 14468]
Ethan Blanton <elb@pidgin.im>
parents: 12058
diff changeset
347 gaim_account_get_bool(sg->account, "sign-verify", FALSE)) {
8849
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
348 /* XXX */
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
349 }
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
350
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
351 if (flags & SILC_MESSAGE_FLAG_DATA) {
12217
029802981b81 [gaim-migrate @ 14519]
Stu Tomlinson <stu@nosnilmot.com>
parents: 12167
diff changeset
352 #ifdef HAVE_SILCMIME_H
029802981b81 [gaim-migrate @ 14519]
Stu Tomlinson <stu@nosnilmot.com>
parents: 12167
diff changeset
353 /* Process MIME message */
029802981b81 [gaim-migrate @ 14519]
Stu Tomlinson <stu@nosnilmot.com>
parents: 12167
diff changeset
354 SilcMime mime;
029802981b81 [gaim-migrate @ 14519]
Stu Tomlinson <stu@nosnilmot.com>
parents: 12167
diff changeset
355 mime = silc_mime_decode(message, message_len);
029802981b81 [gaim-migrate @ 14519]
Stu Tomlinson <stu@nosnilmot.com>
parents: 12167
diff changeset
356 silcgaim_mime_message(client, conn, sender, NULL, payload,
029802981b81 [gaim-migrate @ 14519]
Stu Tomlinson <stu@nosnilmot.com>
parents: 12167
diff changeset
357 NULL, flags, mime, FALSE);
029802981b81 [gaim-migrate @ 14519]
Stu Tomlinson <stu@nosnilmot.com>
parents: 12167
diff changeset
358 #else
12058
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents: 11533
diff changeset
359 char type[128], enc[128];
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents: 11533
diff changeset
360 unsigned char *data;
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents: 11533
diff changeset
361 SilcUInt32 data_len;
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents: 11533
diff changeset
362
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents: 11533
diff changeset
363 memset(type, 0, sizeof(type));
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents: 11533
diff changeset
364 memset(enc, 0, sizeof(enc));
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents: 11533
diff changeset
365
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents: 11533
diff changeset
366 if (!silc_mime_parse(message, message_len, NULL, 0,
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents: 11533
diff changeset
367 type, sizeof(type) - 1, enc, sizeof(enc) - 1, &data,
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents: 11533
diff changeset
368 &data_len))
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents: 11533
diff changeset
369 return;
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents: 11533
diff changeset
370
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents: 11533
diff changeset
371 if (!strcmp(type, "application/x-wb") &&
12167
5851a9219bc7 [gaim-migrate @ 14468]
Ethan Blanton <elb@pidgin.im>
parents: 12058
diff changeset
372 !strcmp(enc, "binary") &&
5851a9219bc7 [gaim-migrate @ 14468]
Ethan Blanton <elb@pidgin.im>
parents: 12058
diff changeset
373 !gaim_account_get_bool(sg->account, "block-wb", FALSE))
12058
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents: 11533
diff changeset
374 silcgaim_wb_receive(client, conn, sender, payload,
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents: 11533
diff changeset
375 flags, data, data_len);
12217
029802981b81 [gaim-migrate @ 14519]
Stu Tomlinson <stu@nosnilmot.com>
parents: 12167
diff changeset
376 #endif
8849
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
377 return;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
378 }
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
379
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
380 if (flags & SILC_MESSAGE_FLAG_ACTION && convo) {
9353
b8138f3959dc [gaim-migrate @ 10161]
Ethan Blanton <elb@pidgin.im>
parents: 9272
diff changeset
381 msg = g_strdup_printf("/me %s",
8849
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
382 (const char *)message);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
383 if (!msg)
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
384 return;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
385
10732
c4cb90065e1d [gaim-migrate @ 12334]
Luke Schierer <lschiere@pidgin.im>
parents: 10589
diff changeset
386 tmp = g_markup_escape_text(msg, -1);
8849
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
387 /* Send to Gaim */
9353
b8138f3959dc [gaim-migrate @ 10161]
Ethan Blanton <elb@pidgin.im>
parents: 9272
diff changeset
388 serv_got_im(gc, sender->nickname ?
b8138f3959dc [gaim-migrate @ 10161]
Ethan Blanton <elb@pidgin.im>
parents: 9272
diff changeset
389 sender->nickname : "<unknown>",
9359
43741d8f76f7 [gaim-migrate @ 10167]
Ethan Blanton <elb@pidgin.im>
parents: 9353
diff changeset
390 tmp, 0, time(NULL));
8849
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
391 g_free(msg);
9359
43741d8f76f7 [gaim-migrate @ 10167]
Ethan Blanton <elb@pidgin.im>
parents: 9353
diff changeset
392 g_free(tmp);
8849
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
393 return;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
394 }
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
395
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
396 if (flags & SILC_MESSAGE_FLAG_NOTICE && convo) {
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
397 msg = g_strdup_printf("(notice) <I>%s</I> %s",
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
398 sender->nickname ?
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
399 sender->nickname : "<unknown>",
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
400 (const char *)message);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
401 if (!msg)
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
402 return;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
403
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
404 /* Send to Gaim */
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
405 gaim_conversation_write(convo, NULL, (const char *)msg,
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
406 GAIM_MESSAGE_SYSTEM, time(NULL));
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
407 g_free(msg);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
408 return;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
409 }
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
410
9359
43741d8f76f7 [gaim-migrate @ 10167]
Ethan Blanton <elb@pidgin.im>
parents: 9353
diff changeset
411 if (flags & SILC_MESSAGE_FLAG_UTF8) {
10732
c4cb90065e1d [gaim-migrate @ 12334]
Luke Schierer <lschiere@pidgin.im>
parents: 10589
diff changeset
412 tmp = g_markup_escape_text((const char *)message, -1);
8849
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
413 /* Send to Gaim */
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
414 serv_got_im(gc, sender->nickname ?
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
415 sender->nickname : "<unknown>",
9359
43741d8f76f7 [gaim-migrate @ 10167]
Ethan Blanton <elb@pidgin.im>
parents: 9353
diff changeset
416 tmp, 0, time(NULL));
43741d8f76f7 [gaim-migrate @ 10167]
Ethan Blanton <elb@pidgin.im>
parents: 9353
diff changeset
417 g_free(tmp);
43741d8f76f7 [gaim-migrate @ 10167]
Ethan Blanton <elb@pidgin.im>
parents: 9353
diff changeset
418 }
8849
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
419 }
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
420
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
421
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
422 /* Notify message to the client. The notify arguments are sent in the
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
423 same order as servers sends them. The arguments are same as received
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
424 from the server except for ID's. If ID is received application receives
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
425 the corresponding entry to the ID. For example, if Client ID is received
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
426 application receives SilcClientEntry. Also, if the notify type is
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
427 for channel the channel entry is sent to application (even if server
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
428 does not send it because client library gets the channel entry from
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
429 the Channel ID in the packet's header). */
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
430
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
431 static void
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
432 silc_notify(SilcClient client, SilcClientConnection conn,
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
433 SilcNotifyType type, ...)
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
434 {
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
435 va_list va;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
436 GaimConnection *gc = client->application;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
437 SilcGaim sg = gc->proto_data;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
438 GaimConversation *convo;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
439 SilcClientEntry client_entry, client_entry2;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
440 SilcChannelEntry channel;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
441 SilcServerEntry server_entry;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
442 SilcIdType idtype;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
443 void *entry;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
444 SilcUInt32 mode;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
445 SilcHashTableList htl;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
446 SilcChannelUser chu;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
447 char buf[512], buf2[512], *tmp, *name;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
448 SilcBuffer buffer;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
449 SilcNotifyType notify;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
450 GaimBuddy *b;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
451 int i;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
452
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
453 va_start(va, type);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
454 memset(buf, 0, sizeof(buf));
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
455
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
456 switch (type) {
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
457
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
458 case SILC_NOTIFY_TYPE_NONE:
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
459 break;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
460
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
461 case SILC_NOTIFY_TYPE_INVITE:
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
462 {
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
463 GHashTable *components;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
464 channel = va_arg(va, SilcChannelEntry);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
465 name = va_arg(va, char *);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
466 client_entry = va_arg(va, SilcClientEntry);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
467
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
468 components = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free);
9353
b8138f3959dc [gaim-migrate @ 10161]
Ethan Blanton <elb@pidgin.im>
parents: 9272
diff changeset
469 g_hash_table_insert(components, strdup("channel"), strdup(name));
b8138f3959dc [gaim-migrate @ 10161]
Ethan Blanton <elb@pidgin.im>
parents: 9272
diff changeset
470 serv_got_chat_invite(gc, name, client_entry->nickname, NULL, components);
8849
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
471 }
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
472 break;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
473
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
474 case SILC_NOTIFY_TYPE_JOIN:
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
475 client_entry = va_arg(va, SilcClientEntry);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
476 channel = va_arg(va, SilcChannelEntry);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
477
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
478 /* If we joined channel, do nothing */
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
479 if (client_entry == conn->local_entry)
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
480 break;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
481
11338
17142948653e [gaim-migrate @ 13551]
Mark Doliner <mark@kingant.net>
parents: 11201
diff changeset
482 convo = gaim_find_conversation_with_account(GAIM_CONV_TYPE_CHAT,
10246
a66cf83552dc [gaim-migrate @ 11386]
Mark Doliner <mark@kingant.net>
parents: 10091
diff changeset
483 channel->channel_name, sg->account);
8849
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
484 if (!convo)
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
485 break;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
486
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
487 /* Join user to channel */
8891
4f7c365c5c5a [gaim-migrate @ 9660]
Mark Doliner <mark@kingant.net>
parents: 8849
diff changeset
488 g_snprintf(buf, sizeof(buf), "%s@%s",
8849
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
489 client_entry->username, client_entry->hostname);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
490 gaim_conv_chat_add_user(GAIM_CONV_CHAT(convo),
9846
c28d5b45624e [gaim-migrate @ 10724]
Mark Doliner <mark@kingant.net>
parents: 9797
diff changeset
491 g_strdup(client_entry->nickname), buf, GAIM_CBFLAGS_NONE, TRUE);
8849
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
492
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
493 break;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
494
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
495 case SILC_NOTIFY_TYPE_LEAVE:
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
496 client_entry = va_arg(va, SilcClientEntry);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
497 channel = va_arg(va, SilcChannelEntry);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
498
11338
17142948653e [gaim-migrate @ 13551]
Mark Doliner <mark@kingant.net>
parents: 11201
diff changeset
499 convo = gaim_find_conversation_with_account(GAIM_CONV_TYPE_CHAT,
10246
a66cf83552dc [gaim-migrate @ 11386]
Mark Doliner <mark@kingant.net>
parents: 10091
diff changeset
500 channel->channel_name, sg->account);
8849
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
501 if (!convo)
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
502 break;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
503
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
504 /* Remove user from channel */
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
505 gaim_conv_chat_remove_user(GAIM_CONV_CHAT(convo),
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
506 client_entry->nickname, NULL);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
507
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
508 break;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
509
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
510 case SILC_NOTIFY_TYPE_SIGNOFF:
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
511 client_entry = va_arg(va, SilcClientEntry);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
512 tmp = va_arg(va, char *);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
513
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
514 if (!client_entry->nickname)
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
515 break;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
516
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
517 /* Remove from all channels */
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
518 silc_hash_table_list(client_entry->channels, &htl);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
519 while (silc_hash_table_get(&htl, NULL, (void *)&chu)) {
11338
17142948653e [gaim-migrate @ 13551]
Mark Doliner <mark@kingant.net>
parents: 11201
diff changeset
520 convo = gaim_find_conversation_with_account(GAIM_CONV_TYPE_CHAT,
10246
a66cf83552dc [gaim-migrate @ 11386]
Mark Doliner <mark@kingant.net>
parents: 10091
diff changeset
521 chu->channel->channel_name, sg->account);
8849
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
522 if (!convo)
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
523 continue;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
524 gaim_conv_chat_remove_user(GAIM_CONV_CHAT(convo),
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
525 client_entry->nickname,
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
526 tmp);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
527 }
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
528 silc_hash_table_list_reset(&htl);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
529
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
530 break;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
531
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
532 case SILC_NOTIFY_TYPE_TOPIC_SET:
9762
3f97624e7753 [gaim-migrate @ 10630]
Tim Ringenbach <marv@pidgin.im>
parents: 9645
diff changeset
533 {
3f97624e7753 [gaim-migrate @ 10630]
Tim Ringenbach <marv@pidgin.im>
parents: 9645
diff changeset
534 char *esc, *tmp2;
3f97624e7753 [gaim-migrate @ 10630]
Tim Ringenbach <marv@pidgin.im>
parents: 9645
diff changeset
535 idtype = va_arg(va, int);
3f97624e7753 [gaim-migrate @ 10630]
Tim Ringenbach <marv@pidgin.im>
parents: 9645
diff changeset
536 entry = va_arg(va, void *);
3f97624e7753 [gaim-migrate @ 10630]
Tim Ringenbach <marv@pidgin.im>
parents: 9645
diff changeset
537 tmp = va_arg(va, char *);
3f97624e7753 [gaim-migrate @ 10630]
Tim Ringenbach <marv@pidgin.im>
parents: 9645
diff changeset
538 channel = va_arg(va, SilcChannelEntry);
3f97624e7753 [gaim-migrate @ 10630]
Tim Ringenbach <marv@pidgin.im>
parents: 9645
diff changeset
539
11338
17142948653e [gaim-migrate @ 13551]
Mark Doliner <mark@kingant.net>
parents: 11201
diff changeset
540 convo = gaim_find_conversation_with_account(GAIM_CONV_TYPE_CHAT,
10246
a66cf83552dc [gaim-migrate @ 11386]
Mark Doliner <mark@kingant.net>
parents: 10091
diff changeset
541 channel->channel_name, sg->account);
9762
3f97624e7753 [gaim-migrate @ 10630]
Tim Ringenbach <marv@pidgin.im>
parents: 9645
diff changeset
542 if (!convo)
3f97624e7753 [gaim-migrate @ 10630]
Tim Ringenbach <marv@pidgin.im>
parents: 9645
diff changeset
543 break;
3f97624e7753 [gaim-migrate @ 10630]
Tim Ringenbach <marv@pidgin.im>
parents: 9645
diff changeset
544
3f97624e7753 [gaim-migrate @ 10630]
Tim Ringenbach <marv@pidgin.im>
parents: 9645
diff changeset
545 if (!tmp)
3f97624e7753 [gaim-migrate @ 10630]
Tim Ringenbach <marv@pidgin.im>
parents: 9645
diff changeset
546 break;
3f97624e7753 [gaim-migrate @ 10630]
Tim Ringenbach <marv@pidgin.im>
parents: 9645
diff changeset
547
10732
c4cb90065e1d [gaim-migrate @ 12334]
Luke Schierer <lschiere@pidgin.im>
parents: 10589
diff changeset
548 esc = g_markup_escape_text(tmp, -1);
9762
3f97624e7753 [gaim-migrate @ 10630]
Tim Ringenbach <marv@pidgin.im>
parents: 9645
diff changeset
549 tmp2 = gaim_markup_linkify(esc);
3f97624e7753 [gaim-migrate @ 10630]
Tim Ringenbach <marv@pidgin.im>
parents: 9645
diff changeset
550 g_free(esc);
8849
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
551
9762
3f97624e7753 [gaim-migrate @ 10630]
Tim Ringenbach <marv@pidgin.im>
parents: 9645
diff changeset
552 if (idtype == SILC_ID_CLIENT) {
3f97624e7753 [gaim-migrate @ 10630]
Tim Ringenbach <marv@pidgin.im>
parents: 9645
diff changeset
553 client_entry = (SilcClientEntry)entry;
3f97624e7753 [gaim-migrate @ 10630]
Tim Ringenbach <marv@pidgin.im>
parents: 9645
diff changeset
554 g_snprintf(buf, sizeof(buf),
3f97624e7753 [gaim-migrate @ 10630]
Tim Ringenbach <marv@pidgin.im>
parents: 9645
diff changeset
555 _("%s has changed the topic of <I>%s</I> to: %s"),
3f97624e7753 [gaim-migrate @ 10630]
Tim Ringenbach <marv@pidgin.im>
parents: 9645
diff changeset
556 client_entry->nickname, channel->channel_name, tmp2);
3f97624e7753 [gaim-migrate @ 10630]
Tim Ringenbach <marv@pidgin.im>
parents: 9645
diff changeset
557 gaim_conv_chat_write(GAIM_CONV_CHAT(convo), client_entry->nickname,
3f97624e7753 [gaim-migrate @ 10630]
Tim Ringenbach <marv@pidgin.im>
parents: 9645
diff changeset
558 buf, GAIM_MESSAGE_SYSTEM, time(NULL));
3f97624e7753 [gaim-migrate @ 10630]
Tim Ringenbach <marv@pidgin.im>
parents: 9645
diff changeset
559 gaim_conv_chat_set_topic(GAIM_CONV_CHAT(convo),
3f97624e7753 [gaim-migrate @ 10630]
Tim Ringenbach <marv@pidgin.im>
parents: 9645
diff changeset
560 client_entry->nickname, tmp);
3f97624e7753 [gaim-migrate @ 10630]
Tim Ringenbach <marv@pidgin.im>
parents: 9645
diff changeset
561 } else if (idtype == SILC_ID_SERVER) {
3f97624e7753 [gaim-migrate @ 10630]
Tim Ringenbach <marv@pidgin.im>
parents: 9645
diff changeset
562 server_entry = (SilcServerEntry)entry;
3f97624e7753 [gaim-migrate @ 10630]
Tim Ringenbach <marv@pidgin.im>
parents: 9645
diff changeset
563 g_snprintf(buf, sizeof(buf),
3f97624e7753 [gaim-migrate @ 10630]
Tim Ringenbach <marv@pidgin.im>
parents: 9645
diff changeset
564 _("%s has changed the topic of <I>%s</I> to: %s"),
3f97624e7753 [gaim-migrate @ 10630]
Tim Ringenbach <marv@pidgin.im>
parents: 9645
diff changeset
565 server_entry->server_name, channel->channel_name, tmp2);
3f97624e7753 [gaim-migrate @ 10630]
Tim Ringenbach <marv@pidgin.im>
parents: 9645
diff changeset
566 gaim_conv_chat_write(GAIM_CONV_CHAT(convo), server_entry->server_name,
3f97624e7753 [gaim-migrate @ 10630]
Tim Ringenbach <marv@pidgin.im>
parents: 9645
diff changeset
567 buf, GAIM_MESSAGE_SYSTEM, time(NULL));
3f97624e7753 [gaim-migrate @ 10630]
Tim Ringenbach <marv@pidgin.im>
parents: 9645
diff changeset
568 gaim_conv_chat_set_topic(GAIM_CONV_CHAT(convo),
3f97624e7753 [gaim-migrate @ 10630]
Tim Ringenbach <marv@pidgin.im>
parents: 9645
diff changeset
569 server_entry->server_name, tmp);
3f97624e7753 [gaim-migrate @ 10630]
Tim Ringenbach <marv@pidgin.im>
parents: 9645
diff changeset
570 } else if (idtype == SILC_ID_CHANNEL) {
3f97624e7753 [gaim-migrate @ 10630]
Tim Ringenbach <marv@pidgin.im>
parents: 9645
diff changeset
571 channel = (SilcChannelEntry)entry;
3f97624e7753 [gaim-migrate @ 10630]
Tim Ringenbach <marv@pidgin.im>
parents: 9645
diff changeset
572 g_snprintf(buf, sizeof(buf),
3f97624e7753 [gaim-migrate @ 10630]
Tim Ringenbach <marv@pidgin.im>
parents: 9645
diff changeset
573 _("%s has changed the topic of <I>%s</I> to: %s"),
3f97624e7753 [gaim-migrate @ 10630]
Tim Ringenbach <marv@pidgin.im>
parents: 9645
diff changeset
574 channel->channel_name, channel->channel_name, tmp2);
3f97624e7753 [gaim-migrate @ 10630]
Tim Ringenbach <marv@pidgin.im>
parents: 9645
diff changeset
575 gaim_conv_chat_write(GAIM_CONV_CHAT(convo), channel->channel_name,
3f97624e7753 [gaim-migrate @ 10630]
Tim Ringenbach <marv@pidgin.im>
parents: 9645
diff changeset
576 buf, GAIM_MESSAGE_SYSTEM, time(NULL));
3f97624e7753 [gaim-migrate @ 10630]
Tim Ringenbach <marv@pidgin.im>
parents: 9645
diff changeset
577 gaim_conv_chat_set_topic(GAIM_CONV_CHAT(convo),
3f97624e7753 [gaim-migrate @ 10630]
Tim Ringenbach <marv@pidgin.im>
parents: 9645
diff changeset
578 channel->channel_name, tmp);
3f97624e7753 [gaim-migrate @ 10630]
Tim Ringenbach <marv@pidgin.im>
parents: 9645
diff changeset
579 } else {
3f97624e7753 [gaim-migrate @ 10630]
Tim Ringenbach <marv@pidgin.im>
parents: 9645
diff changeset
580 gaim_conv_chat_set_topic(GAIM_CONV_CHAT(convo), NULL, tmp);
3f97624e7753 [gaim-migrate @ 10630]
Tim Ringenbach <marv@pidgin.im>
parents: 9645
diff changeset
581 }
8849
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
582
9762
3f97624e7753 [gaim-migrate @ 10630]
Tim Ringenbach <marv@pidgin.im>
parents: 9645
diff changeset
583 g_free(tmp2);
3f97624e7753 [gaim-migrate @ 10630]
Tim Ringenbach <marv@pidgin.im>
parents: 9645
diff changeset
584
8849
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
585 break;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
586
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
587 }
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
588 case SILC_NOTIFY_TYPE_NICK_CHANGE:
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
589 client_entry = va_arg(va, SilcClientEntry);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
590 client_entry2 = va_arg(va, SilcClientEntry);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
591
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
592 if (!strcmp(client_entry->nickname, client_entry2->nickname))
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
593 break;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
594
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
595 /* Change nick on all channels */
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
596 silc_hash_table_list(client_entry2->channels, &htl);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
597 while (silc_hash_table_get(&htl, NULL, (void *)&chu)) {
11338
17142948653e [gaim-migrate @ 13551]
Mark Doliner <mark@kingant.net>
parents: 11201
diff changeset
598 convo = gaim_find_conversation_with_account(GAIM_CONV_TYPE_CHAT,
10246
a66cf83552dc [gaim-migrate @ 11386]
Mark Doliner <mark@kingant.net>
parents: 10091
diff changeset
599 chu->channel->channel_name, sg->account);
8849
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
600 if (!convo)
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
601 continue;
9628
b85d6212d707 [gaim-migrate @ 10472]
Ethan Blanton <elb@pidgin.im>
parents: 9554
diff changeset
602 if (gaim_conv_chat_find_user(GAIM_CONV_CHAT(convo), client_entry->nickname))
b85d6212d707 [gaim-migrate @ 10472]
Ethan Blanton <elb@pidgin.im>
parents: 9554
diff changeset
603 gaim_conv_chat_rename_user(GAIM_CONV_CHAT(convo),
b85d6212d707 [gaim-migrate @ 10472]
Ethan Blanton <elb@pidgin.im>
parents: 9554
diff changeset
604 client_entry->nickname,
b85d6212d707 [gaim-migrate @ 10472]
Ethan Blanton <elb@pidgin.im>
parents: 9554
diff changeset
605 client_entry2->nickname);
8849
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
606 }
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
607 silc_hash_table_list_reset(&htl);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
608
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
609 break;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
610
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
611 case SILC_NOTIFY_TYPE_CMODE_CHANGE:
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
612 idtype = va_arg(va, int);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
613 entry = va_arg(va, void *);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
614 mode = va_arg(va, SilcUInt32);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
615 (void)va_arg(va, char *);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
616 (void)va_arg(va, char *);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
617 (void)va_arg(va, char *);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
618 (void)va_arg(va, SilcPublicKey);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
619 buffer = va_arg(va, SilcBuffer);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
620 channel = va_arg(va, SilcChannelEntry);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
621
11338
17142948653e [gaim-migrate @ 13551]
Mark Doliner <mark@kingant.net>
parents: 11201
diff changeset
622 convo = gaim_find_conversation_with_account(GAIM_CONV_TYPE_CHAT,
10246
a66cf83552dc [gaim-migrate @ 11386]
Mark Doliner <mark@kingant.net>
parents: 10091
diff changeset
623 channel->channel_name, sg->account);
8849
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
624 if (!convo)
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
625 break;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
626
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
627 if (idtype == SILC_ID_CLIENT)
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
628 name = ((SilcClientEntry)entry)->nickname;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
629 else if (idtype == SILC_ID_SERVER)
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
630 name = ((SilcServerEntry)entry)->server_name;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
631 else
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
632 name = ((SilcChannelEntry)entry)->channel_name;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
633 if (!name)
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
634 break;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
635
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
636 if (mode) {
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
637 silcgaim_get_chmode_string(mode, buf2, sizeof(buf2));
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
638 g_snprintf(buf, sizeof(buf),
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
639 _("<I>%s</I> set channel <I>%s</I> modes to: %s"), name,
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
640 channel->channel_name, buf2);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
641 } else {
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
642 g_snprintf(buf, sizeof(buf),
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
643 _("<I>%s</I> removed all channel <I>%s</I> modes"), name,
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
644 channel->channel_name);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
645 }
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
646 gaim_conv_chat_write(GAIM_CONV_CHAT(convo), channel->channel_name,
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
647 buf, GAIM_MESSAGE_SYSTEM, time(NULL));
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
648 break;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
649
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
650 case SILC_NOTIFY_TYPE_CUMODE_CHANGE:
9554
8b2451878e26 [gaim-migrate @ 10387]
Luke Schierer <lschiere@pidgin.im>
parents: 9518
diff changeset
651 {
8b2451878e26 [gaim-migrate @ 10387]
Luke Schierer <lschiere@pidgin.im>
parents: 9518
diff changeset
652 GaimConvChatBuddyFlags flags = GAIM_CBFLAGS_NONE;
8b2451878e26 [gaim-migrate @ 10387]
Luke Schierer <lschiere@pidgin.im>
parents: 9518
diff changeset
653 idtype = va_arg(va, int);
8b2451878e26 [gaim-migrate @ 10387]
Luke Schierer <lschiere@pidgin.im>
parents: 9518
diff changeset
654 entry = va_arg(va, void *);
8b2451878e26 [gaim-migrate @ 10387]
Luke Schierer <lschiere@pidgin.im>
parents: 9518
diff changeset
655 mode = va_arg(va, SilcUInt32);
8b2451878e26 [gaim-migrate @ 10387]
Luke Schierer <lschiere@pidgin.im>
parents: 9518
diff changeset
656 client_entry2 = va_arg(va, SilcClientEntry);
8b2451878e26 [gaim-migrate @ 10387]
Luke Schierer <lschiere@pidgin.im>
parents: 9518
diff changeset
657 channel = va_arg(va, SilcChannelEntry);
8849
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
658
11338
17142948653e [gaim-migrate @ 13551]
Mark Doliner <mark@kingant.net>
parents: 11201
diff changeset
659 convo = gaim_find_conversation_with_account(GAIM_CONV_TYPE_CHAT,
10246
a66cf83552dc [gaim-migrate @ 11386]
Mark Doliner <mark@kingant.net>
parents: 10091
diff changeset
660 channel->channel_name, sg->account);
9554
8b2451878e26 [gaim-migrate @ 10387]
Luke Schierer <lschiere@pidgin.im>
parents: 9518
diff changeset
661 if (!convo)
8b2451878e26 [gaim-migrate @ 10387]
Luke Schierer <lschiere@pidgin.im>
parents: 9518
diff changeset
662 break;
8849
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
663
9554
8b2451878e26 [gaim-migrate @ 10387]
Luke Schierer <lschiere@pidgin.im>
parents: 9518
diff changeset
664 if (idtype == SILC_ID_CLIENT)
8b2451878e26 [gaim-migrate @ 10387]
Luke Schierer <lschiere@pidgin.im>
parents: 9518
diff changeset
665 name = ((SilcClientEntry)entry)->nickname;
8b2451878e26 [gaim-migrate @ 10387]
Luke Schierer <lschiere@pidgin.im>
parents: 9518
diff changeset
666 else if (idtype == SILC_ID_SERVER)
8b2451878e26 [gaim-migrate @ 10387]
Luke Schierer <lschiere@pidgin.im>
parents: 9518
diff changeset
667 name = ((SilcServerEntry)entry)->server_name;
8b2451878e26 [gaim-migrate @ 10387]
Luke Schierer <lschiere@pidgin.im>
parents: 9518
diff changeset
668 else
8b2451878e26 [gaim-migrate @ 10387]
Luke Schierer <lschiere@pidgin.im>
parents: 9518
diff changeset
669 name = ((SilcChannelEntry)entry)->channel_name;
8b2451878e26 [gaim-migrate @ 10387]
Luke Schierer <lschiere@pidgin.im>
parents: 9518
diff changeset
670 if (!name)
8b2451878e26 [gaim-migrate @ 10387]
Luke Schierer <lschiere@pidgin.im>
parents: 9518
diff changeset
671 break;
8849
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
672
9554
8b2451878e26 [gaim-migrate @ 10387]
Luke Schierer <lschiere@pidgin.im>
parents: 9518
diff changeset
673 if (mode) {
8b2451878e26 [gaim-migrate @ 10387]
Luke Schierer <lschiere@pidgin.im>
parents: 9518
diff changeset
674 silcgaim_get_chumode_string(mode, buf2, sizeof(buf2));
8b2451878e26 [gaim-migrate @ 10387]
Luke Schierer <lschiere@pidgin.im>
parents: 9518
diff changeset
675 g_snprintf(buf, sizeof(buf),
8b2451878e26 [gaim-migrate @ 10387]
Luke Schierer <lschiere@pidgin.im>
parents: 9518
diff changeset
676 _("<I>%s</I> set <I>%s's</I> modes to: %s"), name,
8b2451878e26 [gaim-migrate @ 10387]
Luke Schierer <lschiere@pidgin.im>
parents: 9518
diff changeset
677 client_entry2->nickname, buf2);
8b2451878e26 [gaim-migrate @ 10387]
Luke Schierer <lschiere@pidgin.im>
parents: 9518
diff changeset
678 if (mode & SILC_CHANNEL_UMODE_CHANFO)
8b2451878e26 [gaim-migrate @ 10387]
Luke Schierer <lschiere@pidgin.im>
parents: 9518
diff changeset
679 flags |= GAIM_CBFLAGS_FOUNDER;
8b2451878e26 [gaim-migrate @ 10387]
Luke Schierer <lschiere@pidgin.im>
parents: 9518
diff changeset
680 if (mode & SILC_CHANNEL_UMODE_CHANOP)
8b2451878e26 [gaim-migrate @ 10387]
Luke Schierer <lschiere@pidgin.im>
parents: 9518
diff changeset
681 flags |= GAIM_CBFLAGS_OP;
8b2451878e26 [gaim-migrate @ 10387]
Luke Schierer <lschiere@pidgin.im>
parents: 9518
diff changeset
682 } else {
8b2451878e26 [gaim-migrate @ 10387]
Luke Schierer <lschiere@pidgin.im>
parents: 9518
diff changeset
683 g_snprintf(buf, sizeof(buf),
8b2451878e26 [gaim-migrate @ 10387]
Luke Schierer <lschiere@pidgin.im>
parents: 9518
diff changeset
684 _("<I>%s</I> removed all <I>%s's</I> modes"), name,
8b2451878e26 [gaim-migrate @ 10387]
Luke Schierer <lschiere@pidgin.im>
parents: 9518
diff changeset
685 client_entry2->nickname);
8b2451878e26 [gaim-migrate @ 10387]
Luke Schierer <lschiere@pidgin.im>
parents: 9518
diff changeset
686 }
8b2451878e26 [gaim-migrate @ 10387]
Luke Schierer <lschiere@pidgin.im>
parents: 9518
diff changeset
687 gaim_conv_chat_write(GAIM_CONV_CHAT(convo), channel->channel_name,
8b2451878e26 [gaim-migrate @ 10387]
Luke Schierer <lschiere@pidgin.im>
parents: 9518
diff changeset
688 buf, GAIM_MESSAGE_SYSTEM, time(NULL));
8b2451878e26 [gaim-migrate @ 10387]
Luke Schierer <lschiere@pidgin.im>
parents: 9518
diff changeset
689 gaim_conv_chat_user_set_flags(GAIM_CONV_CHAT(convo), client_entry2->nickname, flags);
8b2451878e26 [gaim-migrate @ 10387]
Luke Schierer <lschiere@pidgin.im>
parents: 9518
diff changeset
690 break;
8849
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
691 }
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
692
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
693 case SILC_NOTIFY_TYPE_MOTD:
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
694 tmp = va_arg(va, char *);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
695 silc_free(sg->motd);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
696 sg->motd = silc_memdup(tmp, strlen(tmp));
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
697 break;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
698
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
699 case SILC_NOTIFY_TYPE_KICKED:
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
700 client_entry = va_arg(va, SilcClientEntry);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
701 tmp = va_arg(va, char *);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
702 client_entry2 = va_arg(va, SilcClientEntry);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
703 channel = va_arg(va, SilcChannelEntry);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
704
11338
17142948653e [gaim-migrate @ 13551]
Mark Doliner <mark@kingant.net>
parents: 11201
diff changeset
705 convo = gaim_find_conversation_with_account(GAIM_CONV_TYPE_CHAT,
10246
a66cf83552dc [gaim-migrate @ 11386]
Mark Doliner <mark@kingant.net>
parents: 10091
diff changeset
706 channel->channel_name, sg->account);
8849
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
707 if (!convo)
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
708 break;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
709
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
710 if (client_entry == conn->local_entry) {
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
711 /* Remove us from channel */
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
712 g_snprintf(buf, sizeof(buf),
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
713 _("You have been kicked off <I>%s</I> by <I>%s</I> (%s)"),
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
714 channel->channel_name, client_entry2->nickname,
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
715 tmp ? tmp : "");
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
716 gaim_conv_chat_write(GAIM_CONV_CHAT(convo), client_entry->nickname,
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
717 buf, GAIM_MESSAGE_SYSTEM, time(NULL));
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
718 serv_got_chat_left(gc, gaim_conv_chat_get_id(GAIM_CONV_CHAT(convo)));
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
719 } else {
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
720 /* Remove user from channel */
12885
b704e60fe5de [gaim-migrate @ 15237]
Stu Tomlinson <stu@nosnilmot.com>
parents: 12603
diff changeset
721 g_snprintf(buf, sizeof(buf), _("Kicked by %s (%s)"),
8849
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
722 client_entry2->nickname, tmp ? tmp : "");
9353
b8138f3959dc [gaim-migrate @ 10161]
Ethan Blanton <elb@pidgin.im>
parents: 9272
diff changeset
723 gaim_conv_chat_remove_user(GAIM_CONV_CHAT(convo),
8849
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
724 client_entry->nickname,
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
725 buf);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
726 }
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
727
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
728 break;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
729
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
730 case SILC_NOTIFY_TYPE_KILLED:
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
731 client_entry = va_arg(va, SilcClientEntry);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
732 tmp = va_arg(va, char *);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
733 idtype = va_arg(va, int);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
734 entry = va_arg(va, SilcClientEntry);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
735
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
736 if (!client_entry->nickname)
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
737 break;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
738
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
739 if (client_entry == conn->local_entry) {
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
740 if (idtype == SILC_ID_CLIENT) {
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
741 client_entry2 = (SilcClientEntry)entry;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
742 g_snprintf(buf, sizeof(buf),
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
743 _("You have been killed by %s (%s)"),
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
744 client_entry2->nickname, tmp ? tmp : "");
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
745 } else if (idtype == SILC_ID_SERVER) {
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
746 server_entry = (SilcServerEntry)entry;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
747 g_snprintf(buf, sizeof(buf),
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
748 _("You have been killed by %s (%s)"),
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
749 server_entry->server_name, tmp ? tmp : "");
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
750 } else if (idtype == SILC_ID_CHANNEL) {
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
751 channel = (SilcChannelEntry)entry;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
752 g_snprintf(buf, sizeof(buf),
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
753 _("You have been killed by %s (%s)"),
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
754 channel->channel_name, tmp ? tmp : "");
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
755 }
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
756
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
757 /* Remove us from all channels */
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
758 silc_hash_table_list(client_entry->channels, &htl);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
759 while (silc_hash_table_get(&htl, NULL, (void *)&chu)) {
11338
17142948653e [gaim-migrate @ 13551]
Mark Doliner <mark@kingant.net>
parents: 11201
diff changeset
760 convo = gaim_find_conversation_with_account(GAIM_CONV_TYPE_CHAT,
10246
a66cf83552dc [gaim-migrate @ 11386]
Mark Doliner <mark@kingant.net>
parents: 10091
diff changeset
761 chu->channel->channel_name, sg->account);
8849
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
762 if (!convo)
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
763 continue;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
764 gaim_conv_chat_write(GAIM_CONV_CHAT(convo), client_entry->nickname,
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
765 buf, GAIM_MESSAGE_SYSTEM, time(NULL));
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
766 serv_got_chat_left(gc, gaim_conv_chat_get_id(GAIM_CONV_CHAT(convo)));
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
767 }
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
768 silc_hash_table_list_reset(&htl);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
769
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
770 } else {
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
771 if (idtype == SILC_ID_CLIENT) {
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
772 client_entry2 = (SilcClientEntry)entry;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
773 g_snprintf(buf, sizeof(buf),
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
774 _("Killed by %s (%s)"),
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
775 client_entry2->nickname, tmp ? tmp : "");
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
776 } else if (idtype == SILC_ID_SERVER) {
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
777 server_entry = (SilcServerEntry)entry;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
778 g_snprintf(buf, sizeof(buf),
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
779 _("Killed by %s (%s)"),
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
780 server_entry->server_name, tmp ? tmp : "");
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
781 } else if (idtype == SILC_ID_CHANNEL) {
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
782 channel = (SilcChannelEntry)entry;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
783 g_snprintf(buf, sizeof(buf),
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
784 _("Killed by %s (%s)"),
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
785 channel->channel_name, tmp ? tmp : "");
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
786 }
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
787
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
788 /* Remove user from all channels */
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
789 silc_hash_table_list(client_entry->channels, &htl);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
790 while (silc_hash_table_get(&htl, NULL, (void *)&chu)) {
11338
17142948653e [gaim-migrate @ 13551]
Mark Doliner <mark@kingant.net>
parents: 11201
diff changeset
791 convo = gaim_find_conversation_with_account(GAIM_CONV_TYPE_CHAT,
10246
a66cf83552dc [gaim-migrate @ 11386]
Mark Doliner <mark@kingant.net>
parents: 10091
diff changeset
792 chu->channel->channel_name, sg->account);
8849
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
793 if (!convo)
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
794 continue;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
795 gaim_conv_chat_remove_user(GAIM_CONV_CHAT(convo),
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
796 client_entry->nickname, tmp);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
797 }
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
798 silc_hash_table_list_reset(&htl);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
799 }
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
800
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
801 break;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
802
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
803 case SILC_NOTIFY_TYPE_CHANNEL_CHANGE:
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
804 break;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
805
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
806 case SILC_NOTIFY_TYPE_SERVER_SIGNOFF:
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
807 {
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
808 int i;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
809 SilcClientEntry *clients;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
810 SilcUInt32 clients_count;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
811
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
812 (void)va_arg(va, void *);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
813 clients = va_arg(va, SilcClientEntry *);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
814 clients_count = va_arg(va, SilcUInt32);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
815
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
816 for (i = 0; i < clients_count; i++) {
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
817 if (!clients[i]->nickname)
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
818 break;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
819
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
820 /* Remove from all channels */
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
821 silc_hash_table_list(clients[i]->channels, &htl);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
822 while (silc_hash_table_get(&htl, NULL, (void *)&chu)) {
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
823 convo =
11338
17142948653e [gaim-migrate @ 13551]
Mark Doliner <mark@kingant.net>
parents: 11201
diff changeset
824 gaim_find_conversation_with_account(GAIM_CONV_TYPE_CHAT,
10246
a66cf83552dc [gaim-migrate @ 11386]
Mark Doliner <mark@kingant.net>
parents: 10091
diff changeset
825 chu->channel->channel_name, sg->account);
8849
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
826 if (!convo)
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
827 continue;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
828 gaim_conv_chat_remove_user(GAIM_CONV_CHAT(convo),
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
829 clients[i]->nickname,
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
830 _("Server signoff"));
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
831 }
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
832 silc_hash_table_list_reset(&htl);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
833 }
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
834 }
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
835 break;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
836
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
837 case SILC_NOTIFY_TYPE_ERROR:
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
838 {
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
839 SilcStatus error = va_arg(va, int);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
840 gaim_notify_error(gc, "Error Notify",
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
841 silc_get_status_message(error),
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
842 NULL);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
843 }
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
844 break;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
845
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
846 case SILC_NOTIFY_TYPE_WATCH:
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
847 {
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
848 SilcPublicKey public_key;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
849 unsigned char *pk;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
850 SilcUInt32 pk_len;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
851 char *fingerprint;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
852
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
853 client_entry = va_arg(va, SilcClientEntry);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
854 (void)va_arg(va, char *);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
855 mode = va_arg(va, SilcUInt32);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
856 notify = va_arg(va, int);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
857 public_key = va_arg(va, SilcPublicKey);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
858
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
859 b = NULL;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
860 if (public_key) {
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
861 GaimBlistNode *gnode, *cnode, *bnode;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
862 const char *f;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
863
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
864 pk = silc_pkcs_public_key_encode(public_key, &pk_len);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
865 if (!pk)
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
866 break;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
867 fingerprint = silc_hash_fingerprint(NULL, pk, pk_len);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
868 for (i = 0; i < strlen(fingerprint); i++)
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
869 if (fingerprint[i] == ' ')
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
870 fingerprint[i] = '_';
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
871 g_snprintf(buf, sizeof(buf) - 1,
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
872 "%s" G_DIR_SEPARATOR_S "clientkeys"
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
873 G_DIR_SEPARATOR_S "clientkey_%s.pub",
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
874 silcgaim_silcdir(), fingerprint);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
875 silc_free(fingerprint);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
876 silc_free(pk);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
877
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
878 /* Find buddy by associated public key */
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
879 for (gnode = gaim_get_blist()->root; gnode;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
880 gnode = gnode->next) {
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
881 if (!GAIM_BLIST_NODE_IS_GROUP(gnode))
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
882 continue;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
883 for (cnode = gnode->child; cnode; cnode = cnode->next) {
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
884 if( !GAIM_BLIST_NODE_IS_CONTACT(cnode))
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
885 continue;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
886 for (bnode = cnode->child; bnode;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
887 bnode = bnode->next) {
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
888 if (!GAIM_BLIST_NODE_IS_BUDDY(bnode))
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
889 continue;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
890 b = (GaimBuddy *)bnode;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
891 if (b->account != gc->account)
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
892 continue;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
893 f = gaim_blist_node_get_string(bnode, "public-key");
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
894 if (!strcmp(f, buf))
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
895 goto cont;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
896 }
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
897 }
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
898 }
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
899 }
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
900 cont:
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
901 if (!b) {
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
902 /* Find buddy by nickname */
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
903 b = gaim_find_buddy(sg->account, client_entry->nickname);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
904 if (!b) {
9272
ac4480944fc3 [gaim-migrate @ 10075]
Ethan Blanton <elb@pidgin.im>
parents: 9039
diff changeset
905 gaim_debug_warning("silc", "WATCH for %s, unknown buddy",
8849
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
906 client_entry->nickname);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
907 break;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
908 }
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
909 }
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
910
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
911 silc_free(b->proto_data);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
912 b->proto_data = silc_memdup(client_entry->id,
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
913 sizeof(*client_entry->id));
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
914 if (notify == SILC_NOTIFY_TYPE_NICK_CHANGE) {
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
915 break;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
916 } else if (notify == SILC_NOTIFY_TYPE_UMODE_CHANGE) {
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
917 /* See if client was away and is now present */
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
918 if (!(mode & (SILC_UMODE_GONE | SILC_UMODE_INDISPOSED |
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
919 SILC_UMODE_BUSY | SILC_UMODE_PAGE |
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
920 SILC_UMODE_DETACHED)) &&
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
921 (client_entry->mode & SILC_UMODE_GONE ||
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
922 client_entry->mode & SILC_UMODE_INDISPOSED ||
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
923 client_entry->mode & SILC_UMODE_BUSY ||
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
924 client_entry->mode & SILC_UMODE_PAGE ||
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
925 client_entry->mode & SILC_UMODE_DETACHED)) {
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
926 client_entry->mode = mode;
11522
a26eb48d1953 [gaim-migrate @ 13770]
Mark Doliner <mark@kingant.net>
parents: 11500
diff changeset
927 gaim_prpl_got_user_status(gaim_buddy_get_account(b), gaim_buddy_get_name(b), SILCGAIM_STATUS_ID_AVAILABLE, NULL);
8849
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
928 }
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
929 else if ((mode & SILC_UMODE_GONE) ||
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
930 (mode & SILC_UMODE_INDISPOSED) ||
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
931 (mode & SILC_UMODE_BUSY) ||
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
932 (mode & SILC_UMODE_PAGE) ||
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
933 (mode & SILC_UMODE_DETACHED)) {
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
934 client_entry->mode = mode;
10050
30e052ebb5ae [gaim-migrate @ 11011]
Mark Doliner <mark@kingant.net>
parents: 10030
diff changeset
935 gaim_prpl_got_user_status(gaim_buddy_get_account(b), gaim_buddy_get_name(b), SILCGAIM_STATUS_ID_OFFLINE, NULL);
8849
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
936 }
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
937 } else if (notify == SILC_NOTIFY_TYPE_SIGNOFF ||
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
938 notify == SILC_NOTIFY_TYPE_SERVER_SIGNOFF ||
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
939 notify == SILC_NOTIFY_TYPE_KILLED) {
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
940 client_entry->mode = mode;
10050
30e052ebb5ae [gaim-migrate @ 11011]
Mark Doliner <mark@kingant.net>
parents: 10030
diff changeset
941 gaim_prpl_got_user_status(gaim_buddy_get_account(b), gaim_buddy_get_name(b), SILCGAIM_STATUS_ID_OFFLINE, NULL);
8849
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
942 } else if (notify == SILC_NOTIFY_TYPE_NONE) {
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
943 client_entry->mode = mode;
11522
a26eb48d1953 [gaim-migrate @ 13770]
Mark Doliner <mark@kingant.net>
parents: 11500
diff changeset
944 gaim_prpl_got_user_status(gaim_buddy_get_account(b), gaim_buddy_get_name(b), SILCGAIM_STATUS_ID_AVAILABLE, NULL);
8849
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
945 }
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
946 }
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
947 break;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
948
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
949 default:
9353
b8138f3959dc [gaim-migrate @ 10161]
Ethan Blanton <elb@pidgin.im>
parents: 9272
diff changeset
950 gaim_debug_info("silc", "Unhandled notification: %d\n", type);
8849
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
951 break;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
952 }
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
953
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
954 va_end(va);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
955 }
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
956
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
957
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
958 /* Command handler. This function is called always in the command function.
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
959 If error occurs it will be called as well. `conn' is the associated
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
960 client connection. `cmd_context' is the command context that was
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
961 originally sent to the command. `success' is FALSE if error occurred
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
962 during command. `command' is the command being processed. It must be
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
963 noted that this is not reply from server. This is merely called just
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
964 after application has called the command. Just to tell application
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
965 that the command really was processed. */
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
966
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
967 static void
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
968 silc_command(SilcClient client, SilcClientConnection conn,
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
969 SilcClientCommandContext cmd_context, bool success,
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
970 SilcCommand command, SilcStatus status)
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
971 {
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
972 GaimConnection *gc = client->application;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
973 SilcGaim sg = gc->proto_data;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
974
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
975 switch (command) {
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
976
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
977 case SILC_COMMAND_CMODE:
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
978 if (cmd_context->argc == 3 &&
11488
9c7ca8a8c4b8 [gaim-migrate @ 13730]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11338
diff changeset
979 !strcmp((char *)cmd_context->argv[2], "+C"))
8849
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
980 sg->chpk = TRUE;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
981 else
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
982 sg->chpk = FALSE;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
983 break;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
984
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
985 default:
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
986 break;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
987 }
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
988 }
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
989
9024
85caba2f820a [gaim-migrate @ 9800]
Tim Ringenbach <marv@pidgin.im>
parents: 8910
diff changeset
990 #if 0
8849
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
991 static void
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
992 silcgaim_whois_more(SilcClientEntry client_entry, gint id)
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
993 {
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
994 SilcAttributePayload attr;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
995 SilcAttribute attribute;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
996 char *buf;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
997 GString *s;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
998 SilcVCardStruct vcard;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
999 int i;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1000
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1001 if (id != 0)
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1002 return;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1003
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1004 memset(&vcard, 0, sizeof(vcard));
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1005
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1006 s = g_string_new("");
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1007
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1008 silc_dlist_start(client_entry->attrs);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1009 while ((attr = silc_dlist_get(client_entry->attrs)) != SILC_LIST_END) {
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1010 attribute = silc_attribute_get_attribute(attr);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1011 switch (attribute) {
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1012
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1013 case SILC_ATTRIBUTE_USER_INFO:
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1014 if (!silc_attribute_get_object(attr, (void *)&vcard,
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1015 sizeof(vcard)))
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1016 continue;
9039
bf4ecb0ae208 [gaim-migrate @ 9815]
Luke Schierer <lschiere@pidgin.im>
parents: 9024
diff changeset
1017 g_string_append_printf(s, "%s:\n\n", _("Personal Information"));
8849
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1018 if (vcard.full_name)
9039
bf4ecb0ae208 [gaim-migrate @ 9815]
Luke Schierer <lschiere@pidgin.im>
parents: 9024
diff changeset
1019 g_string_append_printf(s, "%s:\t\t%s\n",
bf4ecb0ae208 [gaim-migrate @ 9815]
Luke Schierer <lschiere@pidgin.im>
parents: 9024
diff changeset
1020 _("Full Name"),
8849
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1021 vcard.full_name);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1022 if (vcard.first_name)
9039
bf4ecb0ae208 [gaim-migrate @ 9815]
Luke Schierer <lschiere@pidgin.im>
parents: 9024
diff changeset
1023 g_string_append_printf(s, "%s:\t%s\n",
bf4ecb0ae208 [gaim-migrate @ 9815]
Luke Schierer <lschiere@pidgin.im>
parents: 9024
diff changeset
1024 _("First Name"),
8849
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1025 vcard.first_name);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1026 if (vcard.middle_names)
9039
bf4ecb0ae208 [gaim-migrate @ 9815]
Luke Schierer <lschiere@pidgin.im>
parents: 9024
diff changeset
1027 g_string_append_printf(s, "%s:\t%s\n",
bf4ecb0ae208 [gaim-migrate @ 9815]
Luke Schierer <lschiere@pidgin.im>
parents: 9024
diff changeset
1028 _("Middle Name"),
8849
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1029 vcard.middle_names);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1030 if (vcard.family_name)
9039
bf4ecb0ae208 [gaim-migrate @ 9815]
Luke Schierer <lschiere@pidgin.im>
parents: 9024
diff changeset
1031 g_string_append_printf(s, "%s:\t%s\n",
bf4ecb0ae208 [gaim-migrate @ 9815]
Luke Schierer <lschiere@pidgin.im>
parents: 9024
diff changeset
1032 _("Family Name"),
8849
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1033 vcard.family_name);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1034 if (vcard.nickname)
9039
bf4ecb0ae208 [gaim-migrate @ 9815]
Luke Schierer <lschiere@pidgin.im>
parents: 9024
diff changeset
1035 g_string_append_printf(s, "%s:\t\t%s\n",
bf4ecb0ae208 [gaim-migrate @ 9815]
Luke Schierer <lschiere@pidgin.im>
parents: 9024
diff changeset
1036 _("Nickname"),
8849
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1037 vcard.nickname);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1038 if (vcard.bday)
9039
bf4ecb0ae208 [gaim-migrate @ 9815]
Luke Schierer <lschiere@pidgin.im>
parents: 9024
diff changeset
1039 g_string_append_printf(s, "%s:\t\t%s\n",
bf4ecb0ae208 [gaim-migrate @ 9815]
Luke Schierer <lschiere@pidgin.im>
parents: 9024
diff changeset
1040 _("Birth Day"),
8849
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1041 vcard.bday);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1042 if (vcard.title)
9039
bf4ecb0ae208 [gaim-migrate @ 9815]
Luke Schierer <lschiere@pidgin.im>
parents: 9024
diff changeset
1043 g_string_append_printf(s, "%s:\t\t%s\n",
bf4ecb0ae208 [gaim-migrate @ 9815]
Luke Schierer <lschiere@pidgin.im>
parents: 9024
diff changeset
1044 _("Job Title"),
8849
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1045 vcard.title);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1046 if (vcard.role)
9039
bf4ecb0ae208 [gaim-migrate @ 9815]
Luke Schierer <lschiere@pidgin.im>
parents: 9024
diff changeset
1047 g_string_append_printf(s, "%s:\t\t%s\n",
bf4ecb0ae208 [gaim-migrate @ 9815]
Luke Schierer <lschiere@pidgin.im>
parents: 9024
diff changeset
1048 _("Job Role"),
8849
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1049 vcard.role);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1050 if (vcard.org_name)
9039
bf4ecb0ae208 [gaim-migrate @ 9815]
Luke Schierer <lschiere@pidgin.im>
parents: 9024
diff changeset
1051 g_string_append_printf(s, "%s:\t%s\n",
bf4ecb0ae208 [gaim-migrate @ 9815]
Luke Schierer <lschiere@pidgin.im>
parents: 9024
diff changeset
1052 _("Organization"),
8849
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1053 vcard.org_name);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1054 if (vcard.org_unit)
9039
bf4ecb0ae208 [gaim-migrate @ 9815]
Luke Schierer <lschiere@pidgin.im>
parents: 9024
diff changeset
1055 g_string_append_printf(s, "%s:\t\t%s\n",
bf4ecb0ae208 [gaim-migrate @ 9815]
Luke Schierer <lschiere@pidgin.im>
parents: 9024
diff changeset
1056 _("Unit"),
8849
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1057 vcard.org_unit);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1058 if (vcard.url)
9039
bf4ecb0ae208 [gaim-migrate @ 9815]
Luke Schierer <lschiere@pidgin.im>
parents: 9024
diff changeset
1059 g_string_append_printf(s, "%s:\t%s\n",
bf4ecb0ae208 [gaim-migrate @ 9815]
Luke Schierer <lschiere@pidgin.im>
parents: 9024
diff changeset
1060 _("Homepage"),
8849
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1061 vcard.url);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1062 if (vcard.label)
9039
bf4ecb0ae208 [gaim-migrate @ 9815]
Luke Schierer <lschiere@pidgin.im>
parents: 9024
diff changeset
1063 g_string_append_printf(s, "%s:\t%s\n",
bf4ecb0ae208 [gaim-migrate @ 9815]
Luke Schierer <lschiere@pidgin.im>
parents: 9024
diff changeset
1064 _("Address"),
8849
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1065 vcard.label);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1066 for (i = 0; i < vcard.num_tels; i++) {
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1067 if (vcard.tels[i].telnum)
9039
bf4ecb0ae208 [gaim-migrate @ 9815]
Luke Schierer <lschiere@pidgin.im>
parents: 9024
diff changeset
1068 g_string_append_printf(s, "%s:\t\t\t%s\n",
bf4ecb0ae208 [gaim-migrate @ 9815]
Luke Schierer <lschiere@pidgin.im>
parents: 9024
diff changeset
1069 _("Phone"),
8849
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1070 vcard.tels[i].telnum);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1071 }
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1072 for (i = 0; i < vcard.num_emails; i++) {
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1073 if (vcard.emails[i].address)
9039
bf4ecb0ae208 [gaim-migrate @ 9815]
Luke Schierer <lschiere@pidgin.im>
parents: 9024
diff changeset
1074 g_string_append_printf(s, "%s:\t\t%s\n",
bf4ecb0ae208 [gaim-migrate @ 9815]
Luke Schierer <lschiere@pidgin.im>
parents: 9024
diff changeset
1075 _("EMail"),
8849
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1076 vcard.emails[i].address);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1077 }
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1078 if (vcard.note)
9039
bf4ecb0ae208 [gaim-migrate @ 9815]
Luke Schierer <lschiere@pidgin.im>
parents: 9024
diff changeset
1079 g_string_append_printf(s, "\n%s:\t\t%s\n",
bf4ecb0ae208 [gaim-migrate @ 9815]
Luke Schierer <lschiere@pidgin.im>
parents: 9024
diff changeset
1080 _("Note"),
8849
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1081 vcard.note);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1082 break;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1083 }
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1084 }
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1085
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1086 buf = g_string_free(s, FALSE);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1087 gaim_notify_info(NULL, _("User Information"), _("User Information"),
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1088 buf);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1089 g_free(buf);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1090 }
9024
85caba2f820a [gaim-migrate @ 9800]
Tim Ringenbach <marv@pidgin.im>
parents: 8910
diff changeset
1091 #endif
8849
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1092
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1093 /* Command reply handler. This function is called always in the command reply
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1094 function. If error occurs it will be called as well. Normal scenario
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1095 is that it will be called after the received command data has been parsed
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1096 and processed. The function is used to pass the received command data to
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1097 the application.
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1098
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1099 `conn' is the associated client connection. `cmd_payload' is the command
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1100 payload data received from server and it can be ignored. It is provided
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1101 if the application would like to re-parse the received command data,
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1102 however, it must be noted that the data is parsed already by the library
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1103 thus the payload can be ignored. `success' is FALSE if error occurred.
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1104 In this case arguments are not sent to the application. The `status' is
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1105 the command reply status server returned. The `command' is the command
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1106 reply being processed. The function has variable argument list and each
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1107 command defines the number and type of arguments it passes to the
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1108 application (on error they are not sent). */
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1109
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1110 static void
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1111 silc_command_reply(SilcClient client, SilcClientConnection conn,
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1112 SilcCommandPayload cmd_payload, bool success,
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1113 SilcCommand command, SilcStatus status, ...)
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1114 {
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1115 GaimConnection *gc = client->application;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1116 SilcGaim sg = gc->proto_data;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1117 GaimConversation *convo;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1118 va_list vp;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1119
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1120 va_start(vp, status);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1121
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1122 switch (command) {
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1123 case SILC_COMMAND_JOIN:
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1124 {
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1125 SilcChannelEntry channel_entry;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1126
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1127 if (!success) {
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1128 gaim_notify_error(gc, _("Join Chat"), _("Cannot join channel"),
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1129 silc_get_status_message(status));
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1130 return;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1131 }
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1132
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1133 (void)va_arg(vp, char *);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1134 channel_entry = va_arg(vp, SilcChannelEntry);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1135
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1136 /* Resolve users on channel */
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1137 silc_client_get_clients_by_channel(client, conn, channel_entry,
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1138 silcgaim_chat_join_done,
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1139 channel_entry);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1140 }
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1141 break;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1142
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1143 case SILC_COMMAND_LEAVE:
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1144 break;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1145
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1146 case SILC_COMMAND_USERS:
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1147 break;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1148
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1149 case SILC_COMMAND_WHOIS:
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1150 {
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1151 SilcUInt32 idle, mode;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1152 SilcBuffer channels, user_modes;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1153 SilcClientEntry client_entry;
11531
bf763a1b2454 [gaim-migrate @ 13780]
Luke Schierer <lschiere@pidgin.im>
parents: 11522
diff changeset
1154 char *buf, tmp[1024], *tmp2;
9488
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9359
diff changeset
1155 char *moodstr, *statusstr, *contactstr, *langstr, *devicestr, *tzstr, *geostr;
8849
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1156 GString *s;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1157
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1158 if (!success) {
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1159 gaim_notify_error(gc, _("User Information"),
9488
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9359
diff changeset
1160 _("Cannot get user information"),
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9359
diff changeset
1161 silc_get_status_message(status));
8849
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1162 break;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1163 }
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1164
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1165 client_entry = va_arg(vp, SilcClientEntry);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1166 if (!client_entry->nickname)
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1167 break;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1168 (void)va_arg(vp, char *);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1169 (void)va_arg(vp, char *);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1170 (void)va_arg(vp, char *);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1171 channels = va_arg(vp, SilcBuffer);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1172 mode = va_arg(vp, SilcUInt32);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1173 idle = va_arg(vp, SilcUInt32);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1174 (void)va_arg(vp, unsigned char *);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1175 user_modes = va_arg(vp, SilcBuffer);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1176
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1177 s = g_string_new("");
10732
c4cb90065e1d [gaim-migrate @ 12334]
Luke Schierer <lschiere@pidgin.im>
parents: 10589
diff changeset
1178 tmp2 = g_markup_escape_text(client_entry->nickname, -1);
9488
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9359
diff changeset
1179 g_string_append_printf(s, "<b>%s:</b> %s", _("Nickname"), tmp2);
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9359
diff changeset
1180 g_free(tmp2);
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9359
diff changeset
1181 if (client_entry->realname) {
10732
c4cb90065e1d [gaim-migrate @ 12334]
Luke Schierer <lschiere@pidgin.im>
parents: 10589
diff changeset
1182 tmp2 = g_markup_escape_text(client_entry->realname, -1);
9488
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9359
diff changeset
1183 g_string_append_printf(s, "<br><b>%s:</b> %s", _("Realname"), tmp2);
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9359
diff changeset
1184 g_free(tmp2);
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9359
diff changeset
1185 }
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9359
diff changeset
1186 if (client_entry->username) {
10732
c4cb90065e1d [gaim-migrate @ 12334]
Luke Schierer <lschiere@pidgin.im>
parents: 10589
diff changeset
1187 tmp2 = g_markup_escape_text(client_entry->username, -1);
9488
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9359
diff changeset
1188 if (client_entry->hostname)
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9359
diff changeset
1189 g_string_append_printf(s, "<br><b>%s:</b> %s@%s", _("Username"), tmp2, client_entry->hostname);
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9359
diff changeset
1190 else
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9359
diff changeset
1191 g_string_append_printf(s, "<br><b>%s:</b> %s", _("Username"), tmp2);
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9359
diff changeset
1192 g_free(tmp2);
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9359
diff changeset
1193 }
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9359
diff changeset
1194
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9359
diff changeset
1195 if (client_entry->mode) {
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9359
diff changeset
1196 g_string_append_printf(s, "<br><b>%s:</b> ", _("User Modes"));
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9359
diff changeset
1197 memset(tmp, 0, sizeof(tmp));
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9359
diff changeset
1198 silcgaim_get_umode_string(client_entry->mode,
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9359
diff changeset
1199 tmp, sizeof(tmp) - strlen(tmp));
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9359
diff changeset
1200 g_string_append_printf(s, "%s", tmp);
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9359
diff changeset
1201 }
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9359
diff changeset
1202
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9359
diff changeset
1203 silcgaim_parse_attrs(client_entry->attrs, &moodstr, &statusstr, &contactstr, &langstr, &devicestr, &tzstr, &geostr);
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9359
diff changeset
1204 if (moodstr) {
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9359
diff changeset
1205 g_string_append_printf(s, "<br><b>%s:</b> %s", _("Mood"), moodstr);
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9359
diff changeset
1206 g_free(moodstr);
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9359
diff changeset
1207 }
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9359
diff changeset
1208
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9359
diff changeset
1209 if (statusstr) {
10732
c4cb90065e1d [gaim-migrate @ 12334]
Luke Schierer <lschiere@pidgin.im>
parents: 10589
diff changeset
1210 tmp2 = g_markup_escape_text(statusstr, -1);
9488
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9359
diff changeset
1211 g_string_append_printf(s, "<br><b>%s:</b> %s", _("Status Text"), tmp2);
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9359
diff changeset
1212 g_free(statusstr);
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9359
diff changeset
1213 g_free(tmp2);
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9359
diff changeset
1214 }
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9359
diff changeset
1215
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9359
diff changeset
1216 if (contactstr) {
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9359
diff changeset
1217 g_string_append_printf(s, "<br><b>%s:</b> %s", _("Preferred Contact"), contactstr);
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9359
diff changeset
1218 g_free(contactstr);
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9359
diff changeset
1219 }
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9359
diff changeset
1220
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9359
diff changeset
1221 if (langstr) {
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9359
diff changeset
1222 g_string_append_printf(s, "<br><b>%s:</b> %s", _("Preferred Language"), langstr);
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9359
diff changeset
1223 g_free(langstr);
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9359
diff changeset
1224 }
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9359
diff changeset
1225
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9359
diff changeset
1226 if (devicestr) {
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9359
diff changeset
1227 g_string_append_printf(s, "<br><b>%s:</b> %s", _("Device"), devicestr);
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9359
diff changeset
1228 g_free(devicestr);
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9359
diff changeset
1229 }
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9359
diff changeset
1230
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9359
diff changeset
1231 if (tzstr) {
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9359
diff changeset
1232 g_string_append_printf(s, "<br><b>%s:</b> %s", _("Timezone"), tzstr);
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9359
diff changeset
1233 g_free(tzstr);
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9359
diff changeset
1234 }
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9359
diff changeset
1235
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9359
diff changeset
1236 if (geostr) {
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9359
diff changeset
1237 g_string_append_printf(s, "<br><b>%s:</b> %s", _("Geolocation"), geostr);
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9359
diff changeset
1238 g_free(geostr);
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9359
diff changeset
1239 }
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9359
diff changeset
1240
8849
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1241 if (client_entry->server)
9488
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9359
diff changeset
1242 g_string_append_printf(s, "<br><b>%s:</b> %s", _("Server"), client_entry->server);
8849
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1243
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1244 if (channels && user_modes) {
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1245 SilcUInt32 *umodes;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1246 SilcDList list =
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1247 silc_channel_payload_parse_list(channels->data,
9488
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9359
diff changeset
1248 channels->len);
8849
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1249 if (list && silc_get_mode_list(user_modes,
9488
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9359
diff changeset
1250 silc_dlist_count(list),
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9359
diff changeset
1251 &umodes)) {
8849
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1252 SilcChannelPayload entry;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1253 int i = 0;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1254
9488
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9359
diff changeset
1255 g_string_append_printf(s, "<br><b>%s:</b> ", _("Currently on"));
8849
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1256 memset(tmp, 0, sizeof(tmp));
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1257 silc_dlist_start(list);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1258 while ((entry = silc_dlist_get(list))
9488
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9359
diff changeset
1259 != SILC_LIST_END) {
8849
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1260 SilcUInt32 name_len;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1261 char *m = silc_client_chumode_char(umodes[i++]);
11488
9c7ca8a8c4b8 [gaim-migrate @ 13730]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11338
diff changeset
1262 char *name = (char *)silc_channel_get_name(entry, &name_len);
8849
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1263 if (m)
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1264 silc_strncat(tmp, sizeof(tmp) - 1, m, strlen(m));
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1265 silc_strncat(tmp, sizeof(tmp) - 1, name, name_len);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1266 silc_strncat(tmp, sizeof(tmp) - 1, " ", 1);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1267 silc_free(m);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1268
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1269 }
10732
c4cb90065e1d [gaim-migrate @ 12334]
Luke Schierer <lschiere@pidgin.im>
parents: 10589
diff changeset
1270 tmp2 = g_markup_escape_text(tmp, -1);
9488
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9359
diff changeset
1271 g_string_append_printf(s, "%s", tmp2);
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9359
diff changeset
1272 g_free(tmp2);
8849
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1273 silc_free(umodes);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1274 }
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1275 }
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1276
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1277 if (client_entry->public_key) {
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1278 char *fingerprint, *babbleprint;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1279 unsigned char *pk;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1280 SilcUInt32 pk_len;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1281 pk = silc_pkcs_public_key_encode(client_entry->public_key, &pk_len);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1282 fingerprint = silc_hash_fingerprint(NULL, pk, pk_len);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1283 babbleprint = silc_hash_babbleprint(NULL, pk, pk_len);
9488
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9359
diff changeset
1284 g_string_append_printf(s, "<br><b>%s:</b><br>%s", _("Public Key Fingerprint"), fingerprint);
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9359
diff changeset
1285 g_string_append_printf(s, "<br><b>%s:</b><br>%s", _("Public Key Babbleprint"), babbleprint);
8849
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1286 silc_free(fingerprint);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1287 silc_free(babbleprint);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1288 silc_free(pk);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1289 }
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1290
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1291 buf = g_string_free(s, FALSE);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1292 #if 0 /* XXX for now, let's not show attrs here */
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1293 if (client_entry->attrs)
11201
07dc8c6a359f [gaim-migrate @ 13329]
Mark Doliner <mark@kingant.net>
parents: 10869
diff changeset
1294 gaim_request_action(gc, _("User Information"),
9488
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9359
diff changeset
1295 _("User Information"),
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9359
diff changeset
1296 buf, 1, client_entry, 2,
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9359
diff changeset
1297 _("OK"), G_CALLBACK(silcgaim_whois_more),
12603
e4e47871c373 [gaim-migrate @ 14938]
Richard Laager <rlaager@wiktel.com>
parents: 12217
diff changeset
1298 _("_More..."), G_CALLBACK(silcgaim_whois_more));
8849
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1299 else
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1300 #endif
11533
c9b815aeddc1 [gaim-migrate @ 13782]
Richard Laager <rlaager@wiktel.com>
parents: 11531
diff changeset
1301 gaim_notify_userinfo(gc, client_entry->nickname, buf, NULL, NULL);
9488
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9359
diff changeset
1302 g_free(buf);
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9359
diff changeset
1303 }
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9359
diff changeset
1304 break;
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9359
diff changeset
1305
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9359
diff changeset
1306 case SILC_COMMAND_WHOWAS:
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9359
diff changeset
1307 {
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9359
diff changeset
1308 SilcClientEntry client_entry;
11531
bf763a1b2454 [gaim-migrate @ 13780]
Luke Schierer <lschiere@pidgin.im>
parents: 11522
diff changeset
1309 char *buf, *nickname, *realname, *username, *tmp;
9488
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9359
diff changeset
1310 GString *s;
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9359
diff changeset
1311
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9359
diff changeset
1312 if (!success) {
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9359
diff changeset
1313 gaim_notify_error(gc, _("User Information"),
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9359
diff changeset
1314 _("Cannot get user information"),
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9359
diff changeset
1315 silc_get_status_message(status));
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9359
diff changeset
1316 break;
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9359
diff changeset
1317 }
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9359
diff changeset
1318
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9359
diff changeset
1319 client_entry = va_arg(vp, SilcClientEntry);
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9359
diff changeset
1320 nickname = va_arg(vp, char *);
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9359
diff changeset
1321 username = va_arg(vp, char *);
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9359
diff changeset
1322 realname = va_arg(vp, char *);
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9359
diff changeset
1323 if (!nickname)
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9359
diff changeset
1324 break;
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9359
diff changeset
1325
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9359
diff changeset
1326 s = g_string_new("");
10732
c4cb90065e1d [gaim-migrate @ 12334]
Luke Schierer <lschiere@pidgin.im>
parents: 10589
diff changeset
1327 tmp = g_markup_escape_text(nickname, -1);
9488
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9359
diff changeset
1328 g_string_append_printf(s, "<b>%s:</b> %s", _("Nickname"), tmp);
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9359
diff changeset
1329 g_free(tmp);
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9359
diff changeset
1330 if (realname) {
10732
c4cb90065e1d [gaim-migrate @ 12334]
Luke Schierer <lschiere@pidgin.im>
parents: 10589
diff changeset
1331 tmp = g_markup_escape_text(realname, -1);
9488
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9359
diff changeset
1332 g_string_append_printf(s, "<br><b>%s:</b> %s", _("Realname"), tmp);
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9359
diff changeset
1333 g_free(tmp);
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9359
diff changeset
1334 }
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9359
diff changeset
1335 if (username) {
10732
c4cb90065e1d [gaim-migrate @ 12334]
Luke Schierer <lschiere@pidgin.im>
parents: 10589
diff changeset
1336 tmp = g_markup_escape_text(username, -1);
9488
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9359
diff changeset
1337 if (client_entry && client_entry->hostname)
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9359
diff changeset
1338 g_string_append_printf(s, "<br><b>%s:</b> %s@%s", _("Username"), tmp, client_entry->hostname);
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9359
diff changeset
1339 else
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9359
diff changeset
1340 g_string_append_printf(s, "<br><b>%s:</b> %s", _("Username"), tmp);
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9359
diff changeset
1341 g_free(tmp);
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9359
diff changeset
1342 }
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9359
diff changeset
1343 if (client_entry && client_entry->server)
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9359
diff changeset
1344 g_string_append_printf(s, "<br><b>%s:</b> %s", _("Server"), client_entry->server);
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9359
diff changeset
1345
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9359
diff changeset
1346
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9359
diff changeset
1347 if (client_entry && client_entry->public_key) {
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9359
diff changeset
1348 char *fingerprint, *babbleprint;
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9359
diff changeset
1349 unsigned char *pk;
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9359
diff changeset
1350 SilcUInt32 pk_len;
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9359
diff changeset
1351 pk = silc_pkcs_public_key_encode(client_entry->public_key, &pk_len);
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9359
diff changeset
1352 fingerprint = silc_hash_fingerprint(NULL, pk, pk_len);
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9359
diff changeset
1353 babbleprint = silc_hash_babbleprint(NULL, pk, pk_len);
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9359
diff changeset
1354 g_string_append_printf(s, "<br><b>%s:</b><br>%s", _("Public Key Fingerprint"), fingerprint);
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9359
diff changeset
1355 g_string_append_printf(s, "<br><b>%s:</b><br>%s", _("Public Key Babbleprint"), babbleprint);
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9359
diff changeset
1356 silc_free(fingerprint);
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9359
diff changeset
1357 silc_free(babbleprint);
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9359
diff changeset
1358 silc_free(pk);
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9359
diff changeset
1359 }
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9359
diff changeset
1360
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9359
diff changeset
1361 buf = g_string_free(s, FALSE);
11533
c9b815aeddc1 [gaim-migrate @ 13782]
Richard Laager <rlaager@wiktel.com>
parents: 11531
diff changeset
1362 gaim_notify_userinfo(gc, client_entry->nickname, buf, NULL, NULL);
8849
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1363 g_free(buf);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1364 }
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1365 break;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1366
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1367 case SILC_COMMAND_DETACH:
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1368 if (!success) {
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1369 gaim_notify_error(gc, _("Detach From Server"), _("Cannot detach"),
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1370 silc_get_status_message(status));
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1371 return;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1372 }
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1373 break;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1374
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1375 case SILC_COMMAND_TOPIC:
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1376 {
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1377 SilcChannelEntry channel;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1378
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1379 if (!success) {
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1380 gaim_notify_error(gc, _("Topic"), _("Cannot set topic"),
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1381 silc_get_status_message(status));
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1382 return;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1383 }
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1384
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1385 channel = va_arg(vp, SilcChannelEntry);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1386
11338
17142948653e [gaim-migrate @ 13551]
Mark Doliner <mark@kingant.net>
parents: 11201
diff changeset
1387 convo = gaim_find_conversation_with_account(GAIM_CONV_TYPE_CHAT,
10246
a66cf83552dc [gaim-migrate @ 11386]
Mark Doliner <mark@kingant.net>
parents: 10091
diff changeset
1388 channel->channel_name, sg->account);
9353
b8138f3959dc [gaim-migrate @ 10161]
Ethan Blanton <elb@pidgin.im>
parents: 9272
diff changeset
1389 if (!convo) {
b8138f3959dc [gaim-migrate @ 10161]
Ethan Blanton <elb@pidgin.im>
parents: 9272
diff changeset
1390 gaim_debug_error("silc", "Got a topic for %s, which doesn't exist\n",
b8138f3959dc [gaim-migrate @ 10161]
Ethan Blanton <elb@pidgin.im>
parents: 9272
diff changeset
1391 channel->channel_name);
8849
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1392 break;
9353
b8138f3959dc [gaim-migrate @ 10161]
Ethan Blanton <elb@pidgin.im>
parents: 9272
diff changeset
1393 }
b8138f3959dc [gaim-migrate @ 10161]
Ethan Blanton <elb@pidgin.im>
parents: 9272
diff changeset
1394
8849
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1395 /* Set topic */
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1396 if (channel->topic)
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1397 gaim_conv_chat_set_topic(GAIM_CONV_CHAT(convo), NULL, channel->topic);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1398 }
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1399 break;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1400
9353
b8138f3959dc [gaim-migrate @ 10161]
Ethan Blanton <elb@pidgin.im>
parents: 9272
diff changeset
1401 case SILC_COMMAND_NICK:
b8138f3959dc [gaim-migrate @ 10161]
Ethan Blanton <elb@pidgin.im>
parents: 9272
diff changeset
1402 {
b8138f3959dc [gaim-migrate @ 10161]
Ethan Blanton <elb@pidgin.im>
parents: 9272
diff changeset
1403 /* I don't think we should need to do this because the server should
b8138f3959dc [gaim-migrate @ 10161]
Ethan Blanton <elb@pidgin.im>
parents: 9272
diff changeset
1404 * be sending a SILC_NOTIFY_TYPE_NICK_CHANGE when we change our own
b8138f3959dc [gaim-migrate @ 10161]
Ethan Blanton <elb@pidgin.im>
parents: 9272
diff changeset
1405 * nick, but it isn't, so we deal with it here instead. Stu. */
b8138f3959dc [gaim-migrate @ 10161]
Ethan Blanton <elb@pidgin.im>
parents: 9272
diff changeset
1406 SilcClientEntry local_entry;
b8138f3959dc [gaim-migrate @ 10161]
Ethan Blanton <elb@pidgin.im>
parents: 9272
diff changeset
1407 SilcHashTableList htl;
b8138f3959dc [gaim-migrate @ 10161]
Ethan Blanton <elb@pidgin.im>
parents: 9272
diff changeset
1408 SilcChannelUser chu;
b8138f3959dc [gaim-migrate @ 10161]
Ethan Blanton <elb@pidgin.im>
parents: 9272
diff changeset
1409 const char *oldnick;
b8138f3959dc [gaim-migrate @ 10161]
Ethan Blanton <elb@pidgin.im>
parents: 9272
diff changeset
1410
b8138f3959dc [gaim-migrate @ 10161]
Ethan Blanton <elb@pidgin.im>
parents: 9272
diff changeset
1411 if (!success) {
9488
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9359
diff changeset
1412 gaim_notify_error(gc, _("Nick"), _("Failed to change nickname"),
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9359
diff changeset
1413 silc_get_status_message(status));
9353
b8138f3959dc [gaim-migrate @ 10161]
Ethan Blanton <elb@pidgin.im>
parents: 9272
diff changeset
1414 return;
b8138f3959dc [gaim-migrate @ 10161]
Ethan Blanton <elb@pidgin.im>
parents: 9272
diff changeset
1415 }
b8138f3959dc [gaim-migrate @ 10161]
Ethan Blanton <elb@pidgin.im>
parents: 9272
diff changeset
1416
b8138f3959dc [gaim-migrate @ 10161]
Ethan Blanton <elb@pidgin.im>
parents: 9272
diff changeset
1417 local_entry = va_arg(vp, SilcClientEntry);
b8138f3959dc [gaim-migrate @ 10161]
Ethan Blanton <elb@pidgin.im>
parents: 9272
diff changeset
1418
b8138f3959dc [gaim-migrate @ 10161]
Ethan Blanton <elb@pidgin.im>
parents: 9272
diff changeset
1419 /* Change nick on all channels */
b8138f3959dc [gaim-migrate @ 10161]
Ethan Blanton <elb@pidgin.im>
parents: 9272
diff changeset
1420 silc_hash_table_list(local_entry->channels, &htl);
b8138f3959dc [gaim-migrate @ 10161]
Ethan Blanton <elb@pidgin.im>
parents: 9272
diff changeset
1421 while (silc_hash_table_get(&htl, NULL, (void *)&chu)) {
11338
17142948653e [gaim-migrate @ 13551]
Mark Doliner <mark@kingant.net>
parents: 11201
diff changeset
1422 convo = gaim_find_conversation_with_account(GAIM_CONV_TYPE_CHAT,
10246
a66cf83552dc [gaim-migrate @ 11386]
Mark Doliner <mark@kingant.net>
parents: 10091
diff changeset
1423 chu->channel->channel_name, sg->account);
a66cf83552dc [gaim-migrate @ 11386]
Mark Doliner <mark@kingant.net>
parents: 10091
diff changeset
1424 if (!convo)
9353
b8138f3959dc [gaim-migrate @ 10161]
Ethan Blanton <elb@pidgin.im>
parents: 9272
diff changeset
1425 continue;
b8138f3959dc [gaim-migrate @ 10161]
Ethan Blanton <elb@pidgin.im>
parents: 9272
diff changeset
1426 oldnick = gaim_conv_chat_get_nick(GAIM_CONV_CHAT(convo));
11500
9fc7d0153332 [gaim-migrate @ 13745]
Richard Laager <rlaager@wiktel.com>
parents: 11488
diff changeset
1427 if (strcmp(oldnick, gaim_normalize(gaim_conversation_get_account(convo), local_entry->nickname))) {
9353
b8138f3959dc [gaim-migrate @ 10161]
Ethan Blanton <elb@pidgin.im>
parents: 9272
diff changeset
1428 gaim_conv_chat_rename_user(GAIM_CONV_CHAT(convo),
b8138f3959dc [gaim-migrate @ 10161]
Ethan Blanton <elb@pidgin.im>
parents: 9272
diff changeset
1429 oldnick, local_entry->nickname);
b8138f3959dc [gaim-migrate @ 10161]
Ethan Blanton <elb@pidgin.im>
parents: 9272
diff changeset
1430 gaim_conv_chat_set_nick(GAIM_CONV_CHAT(convo), local_entry->nickname);
b8138f3959dc [gaim-migrate @ 10161]
Ethan Blanton <elb@pidgin.im>
parents: 9272
diff changeset
1431 }
b8138f3959dc [gaim-migrate @ 10161]
Ethan Blanton <elb@pidgin.im>
parents: 9272
diff changeset
1432 }
b8138f3959dc [gaim-migrate @ 10161]
Ethan Blanton <elb@pidgin.im>
parents: 9272
diff changeset
1433 silc_hash_table_list_reset(&htl);
9488
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9359
diff changeset
1434
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9359
diff changeset
1435 gaim_connection_set_display_name(gc, local_entry->nickname);
9353
b8138f3959dc [gaim-migrate @ 10161]
Ethan Blanton <elb@pidgin.im>
parents: 9272
diff changeset
1436 }
b8138f3959dc [gaim-migrate @ 10161]
Ethan Blanton <elb@pidgin.im>
parents: 9272
diff changeset
1437 break;
b8138f3959dc [gaim-migrate @ 10161]
Ethan Blanton <elb@pidgin.im>
parents: 9272
diff changeset
1438
8849
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1439 case SILC_COMMAND_LIST:
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1440 {
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1441 char *topic, *name;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1442 int usercount;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1443 GaimRoomlistRoom *room;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1444
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1445 if (sg->roomlist_canceled)
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1446 break;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1447
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1448 if (!success) {
10091
4e376556566e [gaim-migrate @ 11107]
Mark Doliner <mark@kingant.net>
parents: 10050
diff changeset
1449 gaim_notify_error(gc, _("Error"), _("Error retrieving room list"),
8849
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1450 silc_get_status_message(status));
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1451 gaim_roomlist_set_in_progress(sg->roomlist, FALSE);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1452 gaim_roomlist_unref(sg->roomlist);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1453 sg->roomlist = NULL;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1454 return;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1455 }
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1456
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1457 (void)va_arg(vp, SilcChannelEntry);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1458 name = va_arg(vp, char *);
10855
2d3a935462aa [gaim-migrate @ 12530]
Luke Schierer <lschiere@pidgin.im>
parents: 10774
diff changeset
1459 if (!name) {
2d3a935462aa [gaim-migrate @ 12530]
Luke Schierer <lschiere@pidgin.im>
parents: 10774
diff changeset
1460 gaim_notify_error(gc, _("Roomlist"), _("Cannot get room list"),
2d3a935462aa [gaim-migrate @ 12530]
Luke Schierer <lschiere@pidgin.im>
parents: 10774
diff changeset
1461 silc_get_status_message(status));
2d3a935462aa [gaim-migrate @ 12530]
Luke Schierer <lschiere@pidgin.im>
parents: 10774
diff changeset
1462 gaim_roomlist_set_in_progress(sg->roomlist, FALSE);
2d3a935462aa [gaim-migrate @ 12530]
Luke Schierer <lschiere@pidgin.im>
parents: 10774
diff changeset
1463 gaim_roomlist_unref(sg->roomlist);
2d3a935462aa [gaim-migrate @ 12530]
Luke Schierer <lschiere@pidgin.im>
parents: 10774
diff changeset
1464 sg->roomlist = NULL;
2d3a935462aa [gaim-migrate @ 12530]
Luke Schierer <lschiere@pidgin.im>
parents: 10774
diff changeset
1465 return;
2d3a935462aa [gaim-migrate @ 12530]
Luke Schierer <lschiere@pidgin.im>
parents: 10774
diff changeset
1466 }
8849
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1467 topic = va_arg(vp, char *);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1468 usercount = va_arg(vp, int);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1469
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1470 room = gaim_roomlist_room_new(GAIM_ROOMLIST_ROOMTYPE_ROOM, name, NULL);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1471 gaim_roomlist_room_add_field(sg->roomlist, room, name);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1472 gaim_roomlist_room_add_field(sg->roomlist, room,
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1473 SILC_32_TO_PTR(usercount));
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1474 gaim_roomlist_room_add_field(sg->roomlist, room,
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1475 topic ? topic : "");
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1476 gaim_roomlist_room_add(sg->roomlist, room);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1477
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1478 if (status == SILC_STATUS_LIST_END ||
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1479 status == SILC_STATUS_OK) {
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1480 gaim_roomlist_set_in_progress(sg->roomlist, FALSE);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1481 gaim_roomlist_unref(sg->roomlist);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1482 sg->roomlist = NULL;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1483 }
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1484 }
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1485 break;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1486
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1487 case SILC_COMMAND_GETKEY:
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1488 {
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1489 SilcPublicKey public_key;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1490
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1491 if (!success) {
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1492 gaim_notify_error(gc, _("Get Public Key"),
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1493 _("Cannot fetch the public key"),
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1494 silc_get_status_message(status));
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1495 return;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1496 }
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1497
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1498 (void)va_arg(vp, SilcUInt32);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1499 (void)va_arg(vp, void *);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1500 public_key = va_arg(vp, SilcPublicKey);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1501
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1502 if (!public_key)
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1503 gaim_notify_error(gc, _("Get Public Key"),
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1504 _("Cannot fetch the public key"),
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1505 _("No public key was received"));
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1506 }
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1507 break;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1508
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1509 case SILC_COMMAND_INFO:
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1510 {
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1511
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1512 SilcServerEntry server_entry;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1513 char *server_name;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1514 char *server_info;
10774
d83f745c997b [gaim-migrate @ 12383]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10751
diff changeset
1515 char tmp[256];
8849
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1516
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1517 if (!success) {
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1518 gaim_notify_error(gc, _("Server Information"),
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1519 _("Cannot get server information"),
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1520 silc_get_status_message(status));
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1521 return;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1522 }
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1523
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1524 server_entry = va_arg(vp, SilcServerEntry);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1525 server_name = va_arg(vp, char *);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1526 server_info = va_arg(vp, char *);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1527
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1528 if (server_name && server_info) {
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1529 g_snprintf(tmp, sizeof(tmp), "Server: %s\n%s",
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1530 server_name, server_info);
10774
d83f745c997b [gaim-migrate @ 12383]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10751
diff changeset
1531 gaim_notify_info(gc, NULL, _("Server Information"), tmp);
8849
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1532 }
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1533 }
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1534 break;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1535
9488
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9359
diff changeset
1536 case SILC_COMMAND_STATS:
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9359
diff changeset
1537 {
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9359
diff changeset
1538 SilcUInt32 starttime, uptime, my_clients, my_channels, my_server_ops,
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9359
diff changeset
1539 my_router_ops, cell_clients, cell_channels, cell_servers,
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9359
diff changeset
1540 clients, channels, servers, routers, server_ops, router_ops;
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9359
diff changeset
1541 SilcUInt32 buffer_length;
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9359
diff changeset
1542 SilcBufferStruct buf;
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9359
diff changeset
1543
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9359
diff changeset
1544 unsigned char *server_stats;
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9359
diff changeset
1545 char *msg;
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9359
diff changeset
1546
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9359
diff changeset
1547 if (!success) {
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9359
diff changeset
1548 gaim_notify_error(gc, _("Server Statistics"),
9507
7c28878de23a [gaim-migrate @ 10334]
Mark Doliner <mark@kingant.net>
parents: 9488
diff changeset
1549 _("Cannot get server statistics"),
9488
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9359
diff changeset
1550 silc_get_status_message(status));
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9359
diff changeset
1551 return;
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9359
diff changeset
1552 }
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9359
diff changeset
1553
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9359
diff changeset
1554 server_stats = va_arg(vp, unsigned char *);
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9359
diff changeset
1555 buffer_length = va_arg(vp, SilcUInt32);
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9359
diff changeset
1556 if (!server_stats || !buffer_length) {
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9359
diff changeset
1557 gaim_notify_error(gc, _("Server Statistics"),
9645
1ba8c6a5ecd9 [gaim-migrate @ 10493]
Mark Doliner <mark@kingant.net>
parents: 9628
diff changeset
1558 _("No server statistics available"), NULL);
9488
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9359
diff changeset
1559 break;
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9359
diff changeset
1560 }
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9359
diff changeset
1561 silc_buffer_set(&buf, server_stats, buffer_length);
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9359
diff changeset
1562 silc_buffer_unformat(&buf,
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9359
diff changeset
1563 SILC_STR_UI_INT(&starttime),
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9359
diff changeset
1564 SILC_STR_UI_INT(&uptime),
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9359
diff changeset
1565 SILC_STR_UI_INT(&my_clients),
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9359
diff changeset
1566 SILC_STR_UI_INT(&my_channels),
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9359
diff changeset
1567 SILC_STR_UI_INT(&my_server_ops),
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9359
diff changeset
1568 SILC_STR_UI_INT(&my_router_ops),
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9359
diff changeset
1569 SILC_STR_UI_INT(&cell_clients),
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9359
diff changeset
1570 SILC_STR_UI_INT(&cell_channels),
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9359
diff changeset
1571 SILC_STR_UI_INT(&cell_servers),
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9359
diff changeset
1572 SILC_STR_UI_INT(&clients),
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9359
diff changeset
1573 SILC_STR_UI_INT(&channels),
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9359
diff changeset
1574 SILC_STR_UI_INT(&servers),
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9359
diff changeset
1575 SILC_STR_UI_INT(&routers),
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9359
diff changeset
1576 SILC_STR_UI_INT(&server_ops),
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9359
diff changeset
1577 SILC_STR_UI_INT(&router_ops),
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9359
diff changeset
1578 SILC_STR_END);
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9359
diff changeset
1579
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9359
diff changeset
1580 msg = g_strdup_printf(_("Local server start time: %s\n"
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9359
diff changeset
1581 "Local server uptime: %s\n"
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9359
diff changeset
1582 "Local server clients: %d\n"
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9359
diff changeset
1583 "Local server channels: %d\n"
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9359
diff changeset
1584 "Local server operators: %d\n"
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9359
diff changeset
1585 "Local router operators: %d\n"
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9359
diff changeset
1586 "Local cell clients: %d\n"
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9359
diff changeset
1587 "Local cell channels: %d\n"
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9359
diff changeset
1588 "Local cell servers: %d\n"
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9359
diff changeset
1589 "Total clients: %d\n"
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9359
diff changeset
1590 "Total channels: %d\n"
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9359
diff changeset
1591 "Total servers: %d\n"
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9359
diff changeset
1592 "Total routers: %d\n"
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9359
diff changeset
1593 "Total server operators: %d\n"
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9359
diff changeset
1594 "Total router operators: %d\n"),
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9359
diff changeset
1595 silc_get_time(starttime),
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9359
diff changeset
1596 gaim_str_seconds_to_string((int)uptime),
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9359
diff changeset
1597 (int)my_clients, (int)my_channels, (int)my_server_ops, (int)my_router_ops,
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9359
diff changeset
1598 (int)cell_clients, (int)cell_channels, (int)cell_servers,
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9359
diff changeset
1599 (int)clients, (int)channels, (int)servers, (int)routers,
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9359
diff changeset
1600 (int)server_ops, (int)router_ops);
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9359
diff changeset
1601
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9359
diff changeset
1602 gaim_notify_info(gc, NULL,
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9359
diff changeset
1603 _("Network Statistics"), msg);
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9359
diff changeset
1604 g_free(msg);
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9359
diff changeset
1605 }
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9359
diff changeset
1606 break;
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9359
diff changeset
1607
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9359
diff changeset
1608 case SILC_COMMAND_PING:
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9359
diff changeset
1609 {
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9359
diff changeset
1610 if (!success) {
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9359
diff changeset
1611 gaim_notify_error(gc, _("Ping"), _("Ping failed"),
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9359
diff changeset
1612 silc_get_status_message(status));
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9359
diff changeset
1613 return;
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9359
diff changeset
1614 }
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9359
diff changeset
1615
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9359
diff changeset
1616 gaim_notify_info(gc, _("Ping"), _("Ping reply received from server"),
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9359
diff changeset
1617 NULL);
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9359
diff changeset
1618 }
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9359
diff changeset
1619 break;
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9359
diff changeset
1620
8849
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1621 case SILC_COMMAND_KILL:
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1622 if (!success) {
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1623 gaim_notify_error(gc, _("Kill User"),
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1624 _("Could not kill user"),
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1625 silc_get_status_message(status));
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1626 return;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1627 }
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1628 break;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1629
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1630 case SILC_COMMAND_CMODE:
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1631 {
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1632 SilcChannelEntry channel_entry;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1633 SilcBuffer channel_pubkeys;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1634
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1635 if (!success)
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1636 return;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1637
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1638 channel_entry = va_arg(vp, SilcChannelEntry);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1639 (void)va_arg(vp, SilcUInt32);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1640 (void)va_arg(vp, SilcPublicKey);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1641 channel_pubkeys = va_arg(vp, SilcBuffer);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1642
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1643 if (sg->chpk)
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1644 silcgaim_chat_chauth_show(sg, channel_entry, channel_pubkeys);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1645 }
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1646 break;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1647
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1648 default:
9353
b8138f3959dc [gaim-migrate @ 10161]
Ethan Blanton <elb@pidgin.im>
parents: 9272
diff changeset
1649 if (success)
b8138f3959dc [gaim-migrate @ 10161]
Ethan Blanton <elb@pidgin.im>
parents: 9272
diff changeset
1650 gaim_debug_info("silc", "Unhandled command: %d (succeeded)\n", command);
b8138f3959dc [gaim-migrate @ 10161]
Ethan Blanton <elb@pidgin.im>
parents: 9272
diff changeset
1651 else
b8138f3959dc [gaim-migrate @ 10161]
Ethan Blanton <elb@pidgin.im>
parents: 9272
diff changeset
1652 gaim_debug_info("silc", "Unhandled command: %d (failed: %s)\n", command,
b8138f3959dc [gaim-migrate @ 10161]
Ethan Blanton <elb@pidgin.im>
parents: 9272
diff changeset
1653 silc_get_status_message(status));
8849
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1654 break;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1655 }
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1656
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1657 va_end(vp);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1658 }
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1659
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1660
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1661 /* Called to indicate that connection was either successfully established
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1662 or connecting failed. This is also the first time application receives
9488
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9359
diff changeset
1663 the SilcClientConnection object which it should save somewhere.
8849
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1664 If the `success' is FALSE the application must always call the function
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1665 silc_client_close_connection. */
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1666
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1667 static void
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1668 silc_connected(SilcClient client, SilcClientConnection conn,
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1669 SilcClientConnectionStatus status)
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1670 {
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1671 GaimConnection *gc = client->application;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1672 SilcGaim sg = gc->proto_data;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1673 gboolean reject_watch, block_invites, block_ims;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1674
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1675 if (!gc) {
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1676 sg->conn = NULL;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1677 silc_client_close_connection(client, conn);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1678 return;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1679 }
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1680
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1681 switch (status) {
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1682 case SILC_CLIENT_CONN_SUCCESS:
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1683 case SILC_CLIENT_CONN_SUCCESS_RESUME:
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1684 gaim_connection_set_state(gc, GAIM_CONNECTED);
10869
3e43c132f151 [gaim-migrate @ 12556]
Mark Doliner <mark@kingant.net>
parents: 10855
diff changeset
1685
3e43c132f151 [gaim-migrate @ 12556]
Mark Doliner <mark@kingant.net>
parents: 10855
diff changeset
1686 /* Send the server our buddy list */
3e43c132f151 [gaim-migrate @ 12556]
Mark Doliner <mark@kingant.net>
parents: 10855
diff changeset
1687 silcgaim_send_buddylist(gc);
3e43c132f151 [gaim-migrate @ 12556]
Mark Doliner <mark@kingant.net>
parents: 10855
diff changeset
1688
10589
0f7452b1f777 [gaim-migrate @ 11994]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 10336
diff changeset
1689 g_unlink(silcgaim_session_file(gaim_account_get_username(sg->account)));
8849
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1690
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1691 /* Send any UMODEs configured for account */
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1692 reject_watch = gaim_account_get_bool(sg->account, "reject-watch", FALSE);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1693 block_invites = gaim_account_get_bool(sg->account, "block-invites", FALSE);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1694 block_ims = gaim_account_get_bool(sg->account, "block-ims", FALSE);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1695 if (reject_watch || block_invites || block_ims) {
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1696 char m[5];
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1697 g_snprintf(m, sizeof(m), "+%s%s%s",
9488
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9359
diff changeset
1698 reject_watch ? "w" : "",
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9359
diff changeset
1699 block_invites ? "I" : "",
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9359
diff changeset
1700 block_ims ? "P" : "");
8849
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1701 silc_client_command_call(sg->client, sg->conn, NULL,
9488
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9359
diff changeset
1702 "UMODE", m, NULL);
8849
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1703 }
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1704
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1705 return;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1706 break;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1707 case SILC_CLIENT_CONN_ERROR:
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1708 gaim_connection_error(gc, _("Error during connecting to SILC Server"));
10589
0f7452b1f777 [gaim-migrate @ 11994]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 10336
diff changeset
1709 g_unlink(silcgaim_session_file(gaim_account_get_username(sg->account)));
8849
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1710 break;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1711
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1712 case SILC_CLIENT_CONN_ERROR_KE:
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1713 gaim_connection_error(gc, _("Key Exchange failed"));
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1714 break;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1715
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1716 case SILC_CLIENT_CONN_ERROR_AUTH:
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1717 gaim_connection_error(gc, _("Authentication failed"));
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1718 break;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1719
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1720 case SILC_CLIENT_CONN_ERROR_RESUME:
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1721 gaim_connection_error(gc,
8910
26c9b8761707 [gaim-migrate @ 9680]
Luke Schierer <lschiere@pidgin.im>
parents: 8891
diff changeset
1722 _("Resuming detached session failed. "
8849
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1723 "Press Reconnect to create new connection."));
10589
0f7452b1f777 [gaim-migrate @ 11994]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 10336
diff changeset
1724 g_unlink(silcgaim_session_file(gaim_account_get_username(sg->account)));
8849
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1725 break;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1726
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1727 case SILC_CLIENT_CONN_ERROR_TIMEOUT:
9039
bf4ecb0ae208 [gaim-migrate @ 9815]
Luke Schierer <lschiere@pidgin.im>
parents: 9024
diff changeset
1728 gaim_connection_error(gc, _("Connection Timeout"));
8849
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1729 break;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1730 }
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1731
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1732 /* Error */
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1733 sg->conn = NULL;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1734 silc_client_close_connection(client, conn);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1735 }
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1736
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1737
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1738 /* Called to indicate that connection was disconnected to the server.
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1739 The `status' may tell the reason of the disconnection, and if the
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1740 `message' is non-NULL it may include the disconnection message
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1741 received from server. */
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1742
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1743 static void
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1744 silc_disconnected(SilcClient client, SilcClientConnection conn,
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1745 SilcStatus status, const char *message)
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1746 {
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1747 GaimConnection *gc = client->application;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1748 SilcGaim sg = gc->proto_data;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1749
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1750 if (sg->resuming && !sg->detaching)
10589
0f7452b1f777 [gaim-migrate @ 11994]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 10336
diff changeset
1751 g_unlink(silcgaim_session_file(gaim_account_get_username(sg->account)));
8849
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1752
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1753 sg->conn = NULL;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1754
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1755 /* Close the connection */
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1756 if (!sg->detaching)
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1757 gaim_connection_error(gc, _("Disconnected by server"));
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1758 else
10740
94cc67130789 [gaim-migrate @ 12342]
Mark Doliner <mark@kingant.net>
parents: 10732
diff changeset
1759 /* TODO: Does this work correctly? Maybe we need to set wants_to_die? */
94cc67130789 [gaim-migrate @ 12342]
Mark Doliner <mark@kingant.net>
parents: 10732
diff changeset
1760 gaim_account_disconnect(gaim_connection_get_account(gc));
8849
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1761 }
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1762
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1763
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1764 typedef struct {
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1765 SilcGetAuthMeth completion;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1766 void *context;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1767 } *SilcGaimGetAuthMethod;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1768
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1769 /* Callback called when we've received the authentication method information
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1770 from the server after we've requested it. */
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1771
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1772 static void silc_get_auth_method_callback(SilcClient client,
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1773 SilcClientConnection conn,
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1774 SilcAuthMethod auth_meth,
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1775 void *context)
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1776 {
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1777 SilcGaimGetAuthMethod internal = context;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1778
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1779 switch (auth_meth) {
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1780 case SILC_AUTH_NONE:
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1781 /* No authentication required. */
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1782 (*internal->completion)(TRUE, auth_meth, NULL, 0, internal->context);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1783 break;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1784
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1785 case SILC_AUTH_PASSWORD:
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1786 /* By returning NULL here the library will ask the passphrase from us
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1787 by calling the silc_ask_passphrase. */
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1788 (*internal->completion)(TRUE, auth_meth, NULL, 0, internal->context);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1789 break;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1790
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1791 case SILC_AUTH_PUBLIC_KEY:
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1792 /* Do not get the authentication data now, the library will generate
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1793 it using our default key, if we do not provide it here. */
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1794 (*internal->completion)(TRUE, auth_meth, NULL, 0, internal->context);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1795 break;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1796 }
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1797
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1798 silc_free(internal);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1799 }
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1800
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1801 /* Find authentication method and authentication data by hostname and
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1802 port. The hostname may be IP address as well. When the authentication
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1803 method has been resolved the `completion' callback with the found
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1804 authentication method and authentication data is called. The `conn'
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1805 may be NULL. */
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1806
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1807 static void
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1808 silc_get_auth_method(SilcClient client, SilcClientConnection conn,
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1809 char *hostname, SilcUInt16 port,
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1810 SilcGetAuthMeth completion, void *context)
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1811 {
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1812 GaimConnection *gc = client->application;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1813 SilcGaim sg = gc->proto_data;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1814 SilcGaimGetAuthMethod internal;
10751
bf5e48215158 [gaim-migrate @ 12354]
Mark Doliner <mark@kingant.net>
parents: 10740
diff changeset
1815 const char *password;
8849
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1816
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1817 /* Progress */
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1818 if (sg->resuming)
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1819 gaim_connection_update_progress(gc, _("Resuming session"), 4, 5);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1820 else
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1821 gaim_connection_update_progress(gc, _("Authenticating connection"), 4, 5);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1822
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1823 /* Check configuration if we have this connection configured. If we
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1824 have then return that data immediately, as it's faster way. */
10336
114d3ac8ff5a [gaim-migrate @ 11543]
Mark Doliner <mark@kingant.net>
parents: 10246
diff changeset
1825 if (gaim_account_get_bool(sg->account, "pubkey-auth", FALSE)) {
114d3ac8ff5a [gaim-migrate @ 11543]
Mark Doliner <mark@kingant.net>
parents: 10246
diff changeset
1826 completion(TRUE, SILC_AUTH_PUBLIC_KEY, NULL, 0, context);
114d3ac8ff5a [gaim-migrate @ 11543]
Mark Doliner <mark@kingant.net>
parents: 10246
diff changeset
1827 return;
114d3ac8ff5a [gaim-migrate @ 11543]
Mark Doliner <mark@kingant.net>
parents: 10246
diff changeset
1828 }
10751
bf5e48215158 [gaim-migrate @ 12354]
Mark Doliner <mark@kingant.net>
parents: 10740
diff changeset
1829 password = gaim_connection_get_password(gc);
bf5e48215158 [gaim-migrate @ 12354]
Mark Doliner <mark@kingant.net>
parents: 10740
diff changeset
1830 if (password && *password) {
11488
9c7ca8a8c4b8 [gaim-migrate @ 13730]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11338
diff changeset
1831 completion(TRUE, SILC_AUTH_PASSWORD, (unsigned char *)password, strlen(password), context);
8849
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1832 return;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1833 }
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1834
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1835 /* Resolve the authentication method from server, as we may not know it. */
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1836 internal = silc_calloc(1, sizeof(*internal));
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1837 if (!internal)
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1838 return;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1839 internal->completion = completion;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1840 internal->context = context;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1841 silc_client_request_authentication_method(client, conn,
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1842 silc_get_auth_method_callback,
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1843 internal);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1844 }
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1845
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1846
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1847 /* Verifies received public key. The `conn_type' indicates which entity
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1848 (server, client etc.) has sent the public key. If user decides to trust
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1849 the application may save the key as trusted public key for later
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1850 use. The `completion' must be called after the public key has been
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1851 verified. */
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1852
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1853 static void
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1854 silc_verify_public_key(SilcClient client, SilcClientConnection conn,
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1855 SilcSocketType conn_type, unsigned char *pk,
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1856 SilcUInt32 pk_len, SilcSKEPKType pk_type,
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1857 SilcVerifyPublicKey completion, void *context)
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1858 {
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1859 GaimConnection *gc = client->application;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1860 SilcGaim sg = gc->proto_data;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1861
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1862 if (!sg->conn && (conn_type == SILC_SOCKET_TYPE_SERVER ||
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1863 conn_type == SILC_SOCKET_TYPE_ROUTER)) {
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1864 /* Progress */
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1865 if (sg->resuming)
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1866 gaim_connection_update_progress(gc, _("Resuming session"), 3, 5);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1867 else
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1868 gaim_connection_update_progress(gc, _("Verifying server public key"),
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1869 3, 5);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1870 }
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1871
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1872 /* Verify public key */
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1873 silcgaim_verify_public_key(client, conn, NULL, conn_type, pk,
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1874 pk_len, pk_type, completion, context);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1875 }
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1876
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1877 typedef struct {
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1878 SilcAskPassphrase completion;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1879 void *context;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1880 } *SilcGaimAskPassphrase;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1881
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1882 static void
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1883 silc_ask_passphrase_cb(SilcGaimAskPassphrase internal, const char *passphrase)
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1884 {
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1885 if (!passphrase || !(*passphrase))
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1886 internal->completion(NULL, 0, internal->context);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1887 else
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1888 internal->completion((unsigned char *)passphrase,
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1889 strlen(passphrase), internal->context);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1890 silc_free(internal);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1891 }
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1892
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1893 /* Ask (interact, that is) a passphrase from user. The passphrase is
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1894 returned to the library by calling the `completion' callback with
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1895 the `context'. The returned passphrase SHOULD be in UTF-8 encoded,
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1896 if not then the library will attempt to encode. */
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1897
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1898 static void
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1899 silc_ask_passphrase(SilcClient client, SilcClientConnection conn,
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1900 SilcAskPassphrase completion, void *context)
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1901 {
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1902 SilcGaimAskPassphrase internal = silc_calloc(1, sizeof(*internal));
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1903
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1904 if (!internal)
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1905 return;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1906 internal->completion = completion;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1907 internal->context = context;
11201
07dc8c6a359f [gaim-migrate @ 13329]
Mark Doliner <mark@kingant.net>
parents: 10869
diff changeset
1908 gaim_request_input(client->application, _("Passphrase"), NULL,
8849
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1909 _("Passphrase required"), NULL, FALSE, TRUE, NULL,
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1910 _("OK"), G_CALLBACK(silc_ask_passphrase_cb),
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1911 _("Cancel"), G_CALLBACK(silc_ask_passphrase_cb),
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1912 internal);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1913 }
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1914
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1915
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1916 /* Notifies application that failure packet was received. This is called
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1917 if there is some protocol active in the client. The `protocol' is the
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1918 protocol context. The `failure' is opaque pointer to the failure
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1919 indication. Note, that the `failure' is protocol dependant and
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1920 application must explicitly cast it to correct type. Usually `failure'
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1921 is 32 bit failure type (see protocol specs for all protocol failure
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1922 types). */
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1923
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1924 static void
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1925 silc_failure(SilcClient client, SilcClientConnection conn,
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1926 SilcProtocol protocol, void *failure)
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1927 {
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1928 GaimConnection *gc = client->application;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1929 char buf[128];
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1930
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1931 memset(buf, 0, sizeof(buf));
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1932
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1933 if (protocol->protocol->type == SILC_PROTOCOL_CLIENT_KEY_EXCHANGE) {
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1934 SilcSKEStatus status = (SilcSKEStatus)SILC_PTR_TO_32(failure);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1935
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1936 if (status == SILC_SKE_STATUS_BAD_VERSION)
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1937 g_snprintf(buf, sizeof(buf),
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1938 _("Failure: Version mismatch, upgrade your client"));
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1939 if (status == SILC_SKE_STATUS_UNSUPPORTED_PUBLIC_KEY)
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1940 g_snprintf(buf, sizeof(buf),
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1941 _("Failure: Remote does not trust/support your public key"));
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1942 if (status == SILC_SKE_STATUS_UNKNOWN_GROUP)
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1943 g_snprintf(buf, sizeof(buf),
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1944 _("Failure: Remote does not support proposed KE group"));
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1945 if (status == SILC_SKE_STATUS_UNKNOWN_CIPHER)
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1946 g_snprintf(buf, sizeof(buf),
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1947 _("Failure: Remote does not support proposed cipher"));
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1948 if (status == SILC_SKE_STATUS_UNKNOWN_PKCS)
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1949 g_snprintf(buf, sizeof(buf),
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1950 _("Failure: Remote does not support proposed PKCS"));
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1951 if (status == SILC_SKE_STATUS_UNKNOWN_HASH_FUNCTION)
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1952 g_snprintf(buf, sizeof(buf),
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1953 _("Failure: Remote does not support proposed hash function"));
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1954 if (status == SILC_SKE_STATUS_UNKNOWN_HMAC)
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1955 g_snprintf(buf, sizeof(buf),
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1956 _("Failure: Remote does not support proposed HMAC"));
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1957 if (status == SILC_SKE_STATUS_INCORRECT_SIGNATURE)
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1958 g_snprintf(buf, sizeof(buf), _("Failure: Incorrect signature"));
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1959 if (status == SILC_SKE_STATUS_INVALID_COOKIE)
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1960 g_snprintf(buf, sizeof(buf), _("Failure: Invalid cookie"));
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1961
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1962 /* Show the error on the progress bar. A more generic error message
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1963 is going to be showed to user after this in the silc_connected. */
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1964 gaim_connection_update_progress(gc, buf, 2, 5);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1965 }
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1966
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1967 if (protocol->protocol->type == SILC_PROTOCOL_CLIENT_CONNECTION_AUTH) {
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1968 SilcUInt32 err = SILC_PTR_TO_32(failure);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1969
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1970 if (err == SILC_AUTH_FAILED)
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1971 g_snprintf(buf, sizeof(buf), _("Failure: Authentication failed"));
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1972
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1973 /* Show the error on the progress bar. A more generic error message
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1974 is going to be showed to user after this in the silc_connected. */
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1975 gaim_connection_update_progress(gc, buf, 4, 5);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1976 }
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1977 }
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1978
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1979 /* Asks whether the user would like to perform the key agreement protocol.
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1980 This is called after we have received an key agreement packet or an
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1981 reply to our key agreement packet. This returns TRUE if the user wants
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1982 the library to perform the key agreement protocol and FALSE if it is not
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1983 desired (application may start it later by calling the function
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1984 silc_client_perform_key_agreement). If TRUE is returned also the
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1985 `completion' and `context' arguments must be set by the application. */
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1986
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1987 static bool
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1988 silc_key_agreement(SilcClient client, SilcClientConnection conn,
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1989 SilcClientEntry client_entry, const char *hostname,
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1990 SilcUInt16 port, SilcKeyAgreementCallback *completion,
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1991 void **context)
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1992 {
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1993 silcgaim_buddy_keyagr_request(client, conn, client_entry, hostname, port);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1994 *completion = NULL;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1995 *context = NULL;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1996 return FALSE;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1997 }
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1998
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1999
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2000 /* Notifies application that file transfer protocol session is being
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2001 requested by the remote client indicated by the `client_entry' from
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2002 the `hostname' and `port'. The `session_id' is the file transfer
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2003 session and it can be used to either accept or reject the file
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2004 transfer request, by calling the silc_client_file_receive or
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2005 silc_client_file_close, respectively. */
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2006
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2007 static void
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2008 silc_ftp(SilcClient client, SilcClientConnection conn,
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2009 SilcClientEntry client_entry, SilcUInt32 session_id,
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2010 const char *hostname, SilcUInt16 port)
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2011 {
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2012 silcgaim_ftp_request(client, conn, client_entry, session_id,
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2013 hostname, port);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2014 }
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2015
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2016
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2017 /* Delivers SILC session detachment data indicated by `detach_data' to the
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2018 application. If application has issued SILC_COMMAND_DETACH command
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2019 the client session in the SILC network is not quit. The client remains
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2020 in the network but is detached. The detachment data may be used later
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2021 to resume the session in the SILC Network. The appliation is
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2022 responsible of saving the `detach_data', to for example in a file.
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2023
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2024 The detachment data can be given as argument to the functions
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2025 silc_client_connect_to_server, or silc_client_add_connection when
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2026 creating connection to remote server, inside SilcClientConnectionParams
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2027 structure. If it is provided the client library will attempt to resume
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2028 the session in the network. After the connection is created
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2029 successfully, the application is responsible of setting the user
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2030 interface for user into the same state it was before detaching (showing
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2031 same channels, channel modes, etc). It can do this by fetching the
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2032 information (like joined channels) from the client library. */
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2033
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2034 static void
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2035 silc_detach(SilcClient client, SilcClientConnection conn,
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2036 const unsigned char *detach_data, SilcUInt32 detach_data_len)
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2037 {
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2038 GaimConnection *gc = client->application;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2039 SilcGaim sg = gc->proto_data;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2040 const char *file;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2041
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2042 /* Save the detachment data to file. */
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2043 file = silcgaim_session_file(gaim_account_get_username(sg->account));
10589
0f7452b1f777 [gaim-migrate @ 11994]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 10336
diff changeset
2044 g_unlink(file);
11488
9c7ca8a8c4b8 [gaim-migrate @ 13730]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11338
diff changeset
2045 silc_file_writefile(file, (char *)detach_data, detach_data_len);
8849
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2046 }
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2047
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2048 SilcClientOperations ops = {
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2049 silc_say,
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2050 silc_channel_message,
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2051 silc_private_message,
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2052 silc_notify,
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2053 silc_command,
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2054 silc_command_reply,
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2055 silc_connected,
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2056 silc_disconnected,
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2057 silc_get_auth_method,
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2058 silc_verify_public_key,
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2059 silc_ask_passphrase,
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2060 silc_failure,
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2061 silc_key_agreement,
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2062 silc_ftp,
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2063 silc_detach
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2064 };