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