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