annotate src/protocols/silc/ops.c @ 10732:c4cb90065e1d

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