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