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