Sun, 23 May 2004 20:06:10 +0000
[gaim-migrate @ 9815]
i18n string updates from Bjoern Voigt, someone tell me if anything here is objectionable, i lost track of that thread. also he updated his translation
committer: Luke Schierer <lschiere@pidgin.im>
| 8849 | 1 | /* |
| 2 | ||
| 3 | silcgaim_buddy.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 | /***************************** Key Agreement *********************************/ | |
| 25 | ||
| 26 | static void | |
| 27 | silcgaim_buddy_keyagr(GaimConnection *gc, const char *name); | |
| 28 | ||
| 29 | typedef struct { | |
| 30 | char *nick; | |
| 31 | GaimConnection *gc; | |
| 32 | } *SilcGaimResolve; | |
| 33 | ||
| 34 | static void | |
| 35 | silcgaim_buddy_keyagr_resolved(SilcClient client, | |
| 36 | SilcClientConnection conn, | |
| 37 | SilcClientEntry *clients, | |
| 38 | SilcUInt32 clients_count, | |
| 39 | void *context) | |
| 40 | { | |
| 41 | GaimConnection *gc = client->application; | |
| 42 | SilcGaimResolve r = context; | |
| 43 | char tmp[256]; | |
| 44 | ||
| 45 | if (!clients) { | |
| 46 | g_snprintf(tmp, sizeof(tmp), | |
| 47 | _("User %s is not present in the network"), r->nick); | |
| 48 | gaim_notify_error(gc, _("Key Agreement"), | |
| 49 | _("Cannot perform the key agreement"), tmp); | |
| 50 | silc_free(r->nick); | |
| 51 | silc_free(r); | |
| 52 | return; | |
| 53 | } | |
| 54 | ||
| 55 | silcgaim_buddy_keyagr(gc, r->nick); | |
| 56 | silc_free(r->nick); | |
| 57 | silc_free(r); | |
| 58 | } | |
| 59 | ||
| 60 | typedef struct { | |
| 61 | gboolean responder; | |
| 62 | } *SilcGaimKeyAgr; | |
| 63 | ||
| 64 | static void | |
| 65 | silcgaim_buddy_keyagr_cb(SilcClient client, | |
| 66 | SilcClientConnection conn, | |
| 67 | SilcClientEntry client_entry, | |
| 68 | SilcKeyAgreementStatus status, | |
| 69 | SilcSKEKeyMaterial *key, | |
| 70 | void *context) | |
| 71 | { | |
| 72 | GaimConnection *gc = client->application; | |
| 73 | SilcGaim sg = gc->proto_data; | |
| 74 | SilcGaimKeyAgr a = context; | |
| 75 | ||
| 76 | if (!sg->conn) | |
| 77 | return; | |
| 78 | ||
| 79 | switch (status) { | |
| 80 | case SILC_KEY_AGREEMENT_OK: | |
| 81 | { | |
| 82 | GaimConversation *convo; | |
| 83 | char tmp[128]; | |
| 84 | ||
| 85 | /* Set the private key for this client */ | |
| 86 | silc_client_del_private_message_key(client, conn, client_entry); | |
| 87 | silc_client_add_private_message_key_ske(client, conn, client_entry, | |
| 88 | NULL, NULL, key, a->responder); | |
| 89 | silc_ske_free_key_material(key); | |
| 90 | ||
| 91 | /* Open IM window */ | |
| 92 | convo = gaim_find_conversation_with_account(client_entry->nickname, | |
| 93 | sg->account); | |
| 94 | if (convo) | |
| 95 | gaim_conv_window_show(gaim_conversation_get_window(convo)); | |
| 96 | else | |
| 97 | convo = gaim_conversation_new(GAIM_CONV_IM, sg->account, | |
| 98 | client_entry->nickname); | |
| 99 | g_snprintf(tmp, sizeof(tmp), "%s [private key]", client_entry->nickname); | |
| 100 | gaim_conversation_set_title(convo, tmp); | |
| 101 | } | |
| 102 | break; | |
| 103 | ||
| 104 | case SILC_KEY_AGREEMENT_ERROR: | |
| 105 | gaim_notify_error(gc, _("Key Agreement"), | |
| 106 | _("Error occurred during key agreement"), NULL); | |
| 107 | break; | |
| 108 | ||
| 109 | case SILC_KEY_AGREEMENT_FAILURE: | |
| 110 | gaim_notify_error(gc, _("Key Agreement"), _("Key Agreement failed"), NULL); | |
| 111 | break; | |
| 112 | ||
| 113 | case SILC_KEY_AGREEMENT_TIMEOUT: | |
| 114 | gaim_notify_error(gc, _("Key Agreement"), | |
| 115 | _("Timeout during key agreement"), NULL); | |
| 116 | break; | |
| 117 | ||
| 118 | case SILC_KEY_AGREEMENT_ABORTED: | |
| 119 | gaim_notify_error(gc, _("Key Agreement"), | |
| 120 | _("Key agreement was aborted"), NULL); | |
| 121 | break; | |
| 122 | ||
| 123 | case SILC_KEY_AGREEMENT_ALREADY_STARTED: | |
| 124 | gaim_notify_error(gc, _("Key Agreement"), | |
| 125 | _("Key agreement is already started"), NULL); | |
| 126 | break; | |
| 127 | ||
| 128 | case SILC_KEY_AGREEMENT_SELF_DENIED: | |
| 129 | gaim_notify_error(gc, _("Key Agreement"), | |
| 130 | _("Key agreement cannot be started with yourself"), | |
| 131 | NULL); | |
| 132 | break; | |
| 133 | ||
| 134 | default: | |
| 135 | break; | |
| 136 | } | |
| 137 | ||
| 138 | silc_free(a); | |
| 139 | } | |
| 140 | ||
| 141 | static void | |
| 142 | silcgaim_buddy_keyagr_do(GaimConnection *gc, const char *name, | |
| 143 | gboolean force_local) | |
| 144 | { | |
| 145 | SilcGaim sg = gc->proto_data; | |
| 146 | SilcClientEntry *clients; | |
| 147 | SilcUInt32 clients_count; | |
| 8910 | 148 | char *local_ip = NULL, *remote_ip = NULL; |
| 8849 | 149 | gboolean local = TRUE; |
| 150 | char *nickname; | |
| 151 | SilcGaimKeyAgr a; | |
| 152 | ||
| 153 | if (!sg->conn || !name) | |
| 154 | return; | |
| 155 | ||
| 156 | if (!silc_parse_userfqdn(name, &nickname, NULL)) | |
| 157 | return; | |
| 158 | ||
| 159 | /* Find client entry */ | |
| 160 | clients = silc_client_get_clients_local(sg->client, sg->conn, nickname, name, | |
| 161 | &clients_count); | |
| 162 | if (!clients) { | |
| 163 | /* Resolve unknown user */ | |
| 164 | SilcGaimResolve r = silc_calloc(1, sizeof(*r)); | |
| 165 | if (!r) | |
| 166 | return; | |
| 167 | r->nick = g_strdup(name); | |
| 168 | r->gc = gc; | |
| 169 | silc_client_get_clients(sg->client, sg->conn, nickname, NULL, | |
| 170 | silcgaim_buddy_keyagr_resolved, r); | |
| 171 | silc_free(nickname); | |
| 172 | return; | |
| 173 | } | |
| 174 | ||
| 175 | /* Resolve the local IP from the outgoing socket connection. We resolve | |
| 176 | it to check whether we have a private range IP address or public IP | |
| 177 | address. If we have public then we will assume that we are not behind | |
| 178 | NAT and will provide automatically the point of connection to the | |
| 179 | agreement. If we have private range address we assume that we are | |
| 180 | behind NAT and we let the responder provide the point of connection. | |
| 181 | ||
| 182 | The algorithm also checks the remote IP address of server connection. | |
| 183 | If it is private range address and we have private range address we | |
| 184 | assume that we are chatting in LAN and will provide the point of | |
| 185 | connection. | |
| 186 | ||
| 187 | Naturally this algorithm does not always get things right. */ | |
| 188 | ||
| 189 | if (silc_net_check_local_by_sock(sg->conn->sock->sock, NULL, &local_ip)) { | |
| 190 | /* Check if the IP is private */ | |
| 191 | if (!force_local && silcgaim_ip_is_private(local_ip)) { | |
| 192 | local = FALSE; | |
| 193 | ||
| 194 | /* Local IP is private, resolve the remote server IP to see whether | |
| 195 | we are talking to Internet or just on LAN. */ | |
| 196 | if (silc_net_check_host_by_sock(sg->conn->sock->sock, NULL, | |
| 197 | &remote_ip)) | |
| 198 | if (silcgaim_ip_is_private(remote_ip)) | |
| 199 | /* We assume we are in LAN. Let's provide | |
| 200 | the connection point. */ | |
| 201 | local = TRUE; | |
| 202 | } | |
| 203 | } | |
| 204 | ||
| 205 | if (force_local) | |
| 206 | local = TRUE; | |
| 207 | ||
| 208 | if (local && !local_ip) | |
| 209 | local_ip = silc_net_localip(); | |
| 210 | ||
| 211 | a = silc_calloc(1, sizeof(*a)); | |
| 212 | if (!a) | |
| 213 | return; | |
| 214 | a->responder = local; | |
| 215 | ||
| 216 | /* Send the key agreement request */ | |
| 217 | silc_client_send_key_agreement(sg->client, sg->conn, clients[0], | |
| 218 | local ? local_ip : NULL, NULL, 0, 60, | |
| 219 | silcgaim_buddy_keyagr_cb, a); | |
| 220 | ||
| 221 | silc_free(local_ip); | |
| 222 | silc_free(remote_ip); | |
| 223 | silc_free(clients); | |
| 224 | } | |
| 225 | ||
| 226 | typedef struct { | |
| 227 | SilcClient client; | |
| 228 | SilcClientConnection conn; | |
| 229 | SilcClientID client_id; | |
| 230 | char *hostname; | |
| 231 | SilcUInt16 port; | |
| 232 | } *SilcGaimKeyAgrAsk; | |
| 233 | ||
| 234 | static void | |
| 235 | silcgaim_buddy_keyagr_request_cb(SilcGaimKeyAgrAsk a, gint id) | |
| 236 | { | |
| 237 | SilcGaimKeyAgr ai; | |
| 238 | SilcClientEntry client_entry; | |
| 239 | ||
| 240 | if (id != 1) | |
| 241 | goto out; | |
| 242 | ||
| 243 | /* Get the client entry. */ | |
| 244 | client_entry = silc_client_get_client_by_id(a->client, a->conn, | |
| 245 | &a->client_id); | |
| 246 | if (!client_entry) { | |
| 247 | gaim_notify_error(a->client->application, _("Key Agreement"), | |
| 248 | _("The remote user is not present in the network any more"), | |
| 249 | NULL); | |
| 250 | goto out; | |
| 251 | } | |
| 252 | ||
| 253 | /* If the hostname was provided by the requestor perform the key agreement | |
| 254 | now. Otherwise, we will send him a request to connect to us. */ | |
| 255 | if (a->hostname) { | |
| 256 | ai = silc_calloc(1, sizeof(*ai)); | |
| 257 | if (!ai) | |
| 258 | goto out; | |
| 259 | ai->responder = FALSE; | |
| 260 | silc_client_perform_key_agreement(a->client, a->conn, client_entry, | |
| 261 | a->hostname, a->port, | |
| 262 | silcgaim_buddy_keyagr_cb, ai); | |
| 263 | } else { | |
| 264 | /* Send request. Force us as the point of connection since requestor | |
| 265 | did not provide the point of connection. */ | |
| 266 | silcgaim_buddy_keyagr_do(a->client->application, | |
| 267 | client_entry->nickname, TRUE); | |
| 268 | } | |
| 269 | ||
| 270 | out: | |
| 271 | silc_free(a->hostname); | |
| 272 | silc_free(a); | |
| 273 | } | |
| 274 | ||
| 275 | void silcgaim_buddy_keyagr_request(SilcClient client, | |
| 276 | SilcClientConnection conn, | |
| 277 | SilcClientEntry client_entry, | |
| 278 | const char *hostname, SilcUInt16 port) | |
| 279 | { | |
| 280 | char tmp[128], tmp2[128]; | |
| 281 | SilcGaimKeyAgrAsk a; | |
| 282 | ||
| 283 | g_snprintf(tmp, sizeof(tmp), | |
| 284 | _("Key agreement request received from %s. Would you like to " | |
| 285 | "perform the key agreement?"), client_entry->nickname); | |
| 286 | if (hostname) | |
| 287 | g_snprintf(tmp2, sizeof(tmp2), | |
| 288 | _("The remote user is waiting key agreement on:\n" | |
| 289 | "Remote host: %s\nRemote port: %d"), hostname, port); | |
| 290 | ||
| 291 | a = silc_calloc(1, sizeof(*a)); | |
| 292 | if (!a) | |
| 293 | return; | |
| 294 | a->client = client; | |
| 295 | a->conn = conn; | |
| 296 | a->client_id = *client_entry->id; | |
| 297 | if (hostname) | |
| 298 | a->hostname = strdup(hostname); | |
| 299 | a->port = port; | |
| 300 | ||
| 301 | gaim_request_action(NULL, _("Key Agreement Request"), tmp, | |
| 302 | hostname ? tmp2 : NULL, 1, a, 2, | |
| 303 | _("Yes"), G_CALLBACK(silcgaim_buddy_keyagr_request_cb), | |
| 304 | _("No"), G_CALLBACK(silcgaim_buddy_keyagr_request_cb)); | |
| 305 | } | |
| 306 | ||
| 307 | static void | |
| 308 | silcgaim_buddy_keyagr(GaimConnection *gc, const char *name) | |
| 309 | { | |
| 310 | silcgaim_buddy_keyagr_do(gc, name, FALSE); | |
| 311 | } | |
| 312 | ||
| 313 | ||
| 314 | /**************************** Static IM Key **********************************/ | |
| 315 | ||
| 316 | static void | |
|
9030
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8910
diff
changeset
|
317 | silcgaim_buddy_resetkey(GaimBlistNode *node, gpointer data) |
| 8849 | 318 | { |
|
9030
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8910
diff
changeset
|
319 | GaimBuddy *b; |
|
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8910
diff
changeset
|
320 | GaimConnection *gc; |
|
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8910
diff
changeset
|
321 | SilcGaim sg; |
| 8849 | 322 | char *nickname; |
| 323 | SilcClientEntry *clients; | |
| 324 | SilcUInt32 clients_count; | |
| 325 | ||
|
9030
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8910
diff
changeset
|
326 | g_return_if_fail(GAIM_BLIST_NODE_IS_BUDDY(node)); |
|
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8910
diff
changeset
|
327 | |
|
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8910
diff
changeset
|
328 | b = (GaimBuddy *) node; |
|
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8910
diff
changeset
|
329 | gc = gaim_account_get_connection(b->account); |
|
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8910
diff
changeset
|
330 | sg = gc->proto_data; |
|
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8910
diff
changeset
|
331 | |
|
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8910
diff
changeset
|
332 | if (!silc_parse_userfqdn(b->name, &nickname, NULL)) |
| 8849 | 333 | return; |
| 334 | ||
| 335 | /* Find client entry */ | |
| 336 | clients = silc_client_get_clients_local(sg->client, sg->conn, | |
|
9030
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8910
diff
changeset
|
337 | nickname, b->name, |
| 8849 | 338 | &clients_count); |
| 339 | if (!clients) { | |
| 340 | silc_free(nickname); | |
| 341 | return; | |
| 342 | } | |
| 343 | ||
| 344 | clients[0]->prv_resp = FALSE; | |
| 345 | silc_client_del_private_message_key(sg->client, sg->conn, | |
| 346 | clients[0]); | |
| 347 | silc_free(clients); | |
| 348 | silc_free(nickname); | |
| 349 | } | |
| 350 | ||
| 351 | typedef struct { | |
| 352 | SilcClient client; | |
| 353 | SilcClientConnection conn; | |
| 354 | SilcClientID client_id; | |
| 355 | } *SilcGaimPrivkey; | |
| 356 | ||
| 357 | static void | |
| 358 | silcgaim_buddy_privkey(GaimConnection *gc, const char *name); | |
| 359 | ||
| 360 | static void | |
| 361 | silcgaim_buddy_privkey_cb(SilcGaimPrivkey p, const char *passphrase) | |
| 362 | { | |
| 363 | SilcClientEntry client_entry; | |
| 364 | ||
| 365 | if (!passphrase || !(*passphrase)) { | |
| 366 | silc_free(p); | |
| 367 | return; | |
| 368 | } | |
| 369 | ||
| 370 | /* Get the client entry. */ | |
| 371 | client_entry = silc_client_get_client_by_id(p->client, p->conn, | |
| 372 | &p->client_id); | |
| 373 | if (!client_entry) { | |
| 374 | gaim_notify_error(p->client->application, _("IM With Password"), | |
| 375 | _("The remote user is not present in the network any more"), | |
| 376 | NULL); | |
| 377 | silc_free(p); | |
| 378 | return; | |
| 379 | } | |
| 380 | ||
| 381 | /* Set the private message key */ | |
| 382 | silc_client_del_private_message_key(p->client, p->conn, | |
| 383 | client_entry); | |
| 384 | silc_client_add_private_message_key(p->client, p->conn, | |
| 385 | client_entry, NULL, NULL, | |
| 386 | (unsigned char *)passphrase, | |
| 387 | strlen(passphrase), FALSE, | |
| 388 | client_entry->prv_resp); | |
| 389 | if (!client_entry->prv_resp) | |
| 390 | silc_client_send_private_message_key_request(p->client, | |
| 391 | p->conn, | |
| 392 | client_entry); | |
| 393 | silc_free(p); | |
| 394 | } | |
| 395 | ||
| 396 | static void | |
| 397 | silcgaim_buddy_privkey_resolved(SilcClient client, | |
| 398 | SilcClientConnection conn, | |
| 399 | SilcClientEntry *clients, | |
| 400 | SilcUInt32 clients_count, | |
| 401 | void *context) | |
| 402 | { | |
| 403 | char tmp[256]; | |
| 404 | ||
| 405 | if (!clients) { | |
| 406 | g_snprintf(tmp, sizeof(tmp), | |
| 407 | _("User %s is not present in the network"), | |
| 408 | (const char *)context); | |
| 409 | gaim_notify_error(client->application, _("IM With Password"), | |
| 410 | _("Cannot set IM key"), tmp); | |
| 411 | g_free(context); | |
| 412 | return; | |
| 413 | } | |
| 414 | ||
| 415 | silcgaim_buddy_privkey(client->application, context); | |
| 416 | silc_free(context); | |
| 417 | } | |
| 418 | ||
| 419 | static void | |
| 9038 | 420 | silcgaim_buddy_privkey(GaimConnection *gc, const char *name) |
| 8849 | 421 | { |
| 9038 | 422 | SilcGaim sg = gc->proto_data; |
| 8849 | 423 | char *nickname; |
| 424 | SilcGaimPrivkey p; | |
| 425 | SilcClientEntry *clients; | |
| 426 | SilcUInt32 clients_count; | |
| 427 | ||
| 9038 | 428 | if (!name) |
| 429 | return; | |
| 430 | if (!silc_parse_userfqdn(name, &nickname, NULL)) | |
| 8849 | 431 | return; |
| 432 | ||
| 433 | /* Find client entry */ | |
| 434 | clients = silc_client_get_clients_local(sg->client, sg->conn, | |
| 9038 | 435 | nickname, name, |
| 8849 | 436 | &clients_count); |
| 437 | if (!clients) { | |
| 438 | silc_client_get_clients(sg->client, sg->conn, nickname, NULL, | |
| 439 | silcgaim_buddy_privkey_resolved, | |
| 9038 | 440 | g_strdup(name)); |
| 8849 | 441 | silc_free(nickname); |
| 442 | return; | |
| 443 | } | |
| 444 | ||
| 445 | p = silc_calloc(1, sizeof(*p)); | |
| 446 | if (!p) | |
| 447 | return; | |
| 448 | p->client = sg->client; | |
| 449 | p->conn = sg->conn; | |
| 450 | p->client_id = *clients[0]->id; | |
| 451 | gaim_request_input(NULL, _("IM With Password"), NULL, | |
| 452 | _("Set IM Password"), NULL, FALSE, TRUE, NULL, | |
| 453 | _("OK"), G_CALLBACK(silcgaim_buddy_privkey_cb), | |
| 454 | _("Cancel"), G_CALLBACK(silcgaim_buddy_privkey_cb), | |
| 455 | p); | |
| 456 | ||
| 457 | silc_free(clients); | |
| 458 | silc_free(nickname); | |
| 459 | } | |
| 460 | ||
| 9038 | 461 | static void |
| 462 | silcgaim_buddy_privkey_menu(GaimBlistNode *node, gpointer data) | |
| 463 | { | |
| 464 | GaimBuddy *buddy; | |
| 465 | GaimConnection *gc; | |
| 466 | ||
| 467 | g_return_if_fail(GAIM_BLIST_NODE_IS_BUDDY(node)); | |
| 468 | ||
| 469 | buddy = (GaimBuddy *) node; | |
| 470 | gc = gaim_account_get_connection(buddy->account); | |
| 471 | ||
| 472 | silcgaim_buddy_privkey(gc, buddy->name); | |
| 473 | } | |
| 474 | ||
| 8849 | 475 | |
| 476 | /**************************** Get Public Key *********************************/ | |
| 477 | ||
| 478 | typedef struct { | |
| 479 | SilcClient client; | |
| 480 | SilcClientConnection conn; | |
| 481 | SilcClientID client_id; | |
| 482 | } *SilcGaimBuddyGetkey; | |
| 483 | ||
| 484 | static void | |
| 485 | silcgaim_buddy_getkey(GaimConnection *gc, const char *name); | |
| 486 | ||
| 487 | static void | |
| 488 | silcgaim_buddy_getkey_cb(SilcGaimBuddyGetkey g, | |
| 489 | SilcClientCommandReplyContext cmd) | |
| 490 | { | |
| 491 | SilcClientEntry client_entry; | |
| 492 | unsigned char *pk; | |
| 493 | SilcUInt32 pk_len; | |
| 494 | ||
| 495 | /* Get the client entry. */ | |
| 496 | client_entry = silc_client_get_client_by_id(g->client, g->conn, | |
| 497 | &g->client_id); | |
| 498 | if (!client_entry) { | |
| 499 | gaim_notify_error(g->client->application, _("Get Public Key"), | |
| 500 | _("The remote user is not present in the network any more"), | |
| 501 | NULL); | |
| 502 | silc_free(g); | |
| 503 | return; | |
| 504 | } | |
| 505 | ||
| 506 | if (!client_entry->public_key) { | |
| 507 | silc_free(g); | |
| 508 | return; | |
| 509 | } | |
| 510 | ||
| 511 | /* Now verify the public key */ | |
| 512 | pk = silc_pkcs_public_key_encode(client_entry->public_key, &pk_len); | |
| 513 | silcgaim_verify_public_key(g->client, g->conn, client_entry->nickname, | |
| 514 | SILC_SOCKET_TYPE_CLIENT, | |
| 515 | pk, pk_len, SILC_SKE_PK_TYPE_SILC, | |
| 516 | NULL, NULL); | |
| 517 | silc_free(pk); | |
| 518 | silc_free(g); | |
| 519 | } | |
| 520 | ||
| 521 | static void | |
| 522 | silcgaim_buddy_getkey_resolved(SilcClient client, | |
| 523 | SilcClientConnection conn, | |
| 524 | SilcClientEntry *clients, | |
| 525 | SilcUInt32 clients_count, | |
| 526 | void *context) | |
| 527 | { | |
| 528 | char tmp[256]; | |
| 529 | ||
| 530 | if (!clients) { | |
| 531 | g_snprintf(tmp, sizeof(tmp), | |
| 532 | _("User %s is not present in the network"), | |
| 533 | (const char *)context); | |
| 534 | gaim_notify_error(client->application, _("Get Public Key"), | |
| 535 | _("Cannot fetch the public key"), tmp); | |
| 536 | g_free(context); | |
| 537 | return; | |
| 538 | } | |
| 539 | ||
| 540 | silcgaim_buddy_getkey(client->application, context); | |
| 541 | silc_free(context); | |
| 542 | } | |
| 543 | ||
| 544 | static void | |
| 9038 | 545 | silcgaim_buddy_getkey(GaimConnection *gc, const char *name) |
| 8849 | 546 | { |
| 9038 | 547 | SilcGaim sg = gc->proto_data; |
| 548 | SilcClient client = sg->client; | |
| 549 | SilcClientConnection conn = sg->conn; | |
| 8849 | 550 | SilcClientEntry *clients; |
| 551 | SilcUInt32 clients_count; | |
| 552 | SilcGaimBuddyGetkey g; | |
| 553 | char *nickname; | |
| 554 | ||
| 9038 | 555 | if (!name) |
| 556 | return; | |
| 8849 | 557 | |
| 9038 | 558 | if (!silc_parse_userfqdn(name, &nickname, NULL)) |
| 8849 | 559 | return; |
| 560 | ||
| 561 | /* Find client entry */ | |
| 9038 | 562 | clients = silc_client_get_clients_local(client, conn, nickname, name, |
| 563 | &clients_count); | |
| 8849 | 564 | if (!clients) { |
| 565 | silc_client_get_clients(client, conn, nickname, NULL, | |
| 566 | silcgaim_buddy_getkey_resolved, | |
| 9038 | 567 | g_strdup(name)); |
| 8849 | 568 | silc_free(nickname); |
| 569 | return; | |
| 570 | } | |
| 571 | ||
| 572 | /* Call GETKEY */ | |
| 573 | g = silc_calloc(1, sizeof(*g)); | |
| 574 | if (!g) | |
| 575 | return; | |
| 576 | g->client = client; | |
| 577 | g->conn = conn; | |
| 578 | g->client_id = *clients[0]->id; | |
| 579 | silc_client_command_call(client, conn, NULL, "GETKEY", | |
| 580 | clients[0]->nickname, NULL); | |
| 581 | silc_client_command_pending(conn, SILC_COMMAND_GETKEY, | |
| 582 | conn->cmd_ident, | |
| 583 | (SilcCommandCb)silcgaim_buddy_getkey_cb, g); | |
| 584 | silc_free(clients); | |
| 585 | silc_free(nickname); | |
| 586 | } | |
| 587 | ||
| 588 | static void | |
| 9038 | 589 | silcgaim_buddy_getkey_menu(GaimBlistNode *node, gpointer data) |
| 590 | { | |
| 591 | GaimBuddy *buddy; | |
| 592 | GaimConnection *gc; | |
| 593 | ||
| 594 | g_return_if_fail(GAIM_BLIST_NODE_IS_BUDDY(node)); | |
| 595 | ||
| 596 | buddy = (GaimBuddy *) node; | |
| 597 | gc = gaim_account_get_connection(buddy->account); | |
| 598 | ||
| 599 | silcgaim_buddy_privkey(gc, buddy->name); | |
| 600 | ||
| 601 | } | |
| 602 | ||
| 603 | static void | |
|
9030
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8910
diff
changeset
|
604 | silcgaim_buddy_showkey(GaimBlistNode *node, gpointer data) |
| 8849 | 605 | { |
|
9030
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8910
diff
changeset
|
606 | GaimBuddy *b; |
|
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8910
diff
changeset
|
607 | GaimConnection *gc; |
|
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8910
diff
changeset
|
608 | SilcGaim sg; |
| 8849 | 609 | SilcPublicKey public_key; |
| 610 | const char *pkfile; | |
|
9030
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8910
diff
changeset
|
611 | |
|
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8910
diff
changeset
|
612 | g_return_if_fail(GAIM_BLIST_NODE_IS_BUDDY(node)); |
| 8849 | 613 | |
|
9030
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8910
diff
changeset
|
614 | b = (GaimBuddy *) node; |
|
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8910
diff
changeset
|
615 | gc = gaim_account_get_connection(b->account); |
|
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8910
diff
changeset
|
616 | sg = gc->proto_data; |
| 8849 | 617 | |
| 9038 | 618 | pkfile = gaim_blist_node_get_string(node, "public-key"); |
| 8849 | 619 | if (!silc_pkcs_load_public_key(pkfile, &public_key, SILC_PKCS_FILE_PEM) && |
| 620 | !silc_pkcs_load_public_key(pkfile, &public_key, SILC_PKCS_FILE_BIN)) { | |
| 621 | gaim_notify_error(gc, | |
| 622 | _("Show Public Key"), | |
| 623 | _("Could not load public key"), NULL); | |
| 624 | return; | |
| 625 | } | |
| 626 | ||
|
9030
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8910
diff
changeset
|
627 | silcgaim_show_public_key(sg, b->name, public_key, NULL, NULL); |
| 8849 | 628 | silc_pkcs_public_key_free(public_key); |
| 629 | } | |
| 630 | ||
| 631 | ||
| 632 | /**************************** Buddy routines *********************************/ | |
| 633 | ||
| 634 | /* The buddies are implemented by using the WHOIS and WATCH commands that | |
| 635 | can be used to search users by their public key. Since nicknames aren't | |
| 636 | unique in SILC we cannot trust the buddy list using their nickname. We | |
| 637 | associate public keys to buddies and use those to search and watch | |
| 638 | in the network. | |
| 639 | ||
| 640 | The problem is that Gaim does not return GaimBuddy contexts to the | |
| 641 | callbacks but the buddy names. Naturally, this is not going to work | |
| 642 | with SILC. But, for now, we have to do what we can... */ | |
| 643 | ||
| 644 | typedef struct { | |
| 645 | SilcClient client; | |
| 646 | SilcClientConnection conn; | |
| 647 | SilcClientID client_id; | |
| 648 | GaimBuddy *b; | |
| 649 | unsigned char *offline_pk; | |
| 650 | SilcUInt32 offline_pk_len; | |
| 651 | unsigned int offline : 1; | |
| 652 | unsigned int pubkey_search : 1; | |
| 653 | unsigned int init : 1; | |
| 654 | } *SilcGaimBuddyRes; | |
| 655 | ||
| 656 | static void | |
| 657 | silcgaim_add_buddy_ask_pk_cb(SilcGaimBuddyRes r, gint id); | |
| 658 | static void | |
| 659 | silcgaim_add_buddy_resolved(SilcClient client, | |
| 660 | SilcClientConnection conn, | |
| 661 | SilcClientEntry *clients, | |
| 662 | SilcUInt32 clients_count, | |
| 663 | void *context); | |
| 664 | ||
| 665 | void silcgaim_get_info(GaimConnection *gc, const char *who) | |
| 666 | { | |
| 667 | SilcGaim sg = gc->proto_data; | |
| 668 | SilcClient client = sg->client; | |
| 669 | SilcClientConnection conn = sg->conn; | |
| 670 | SilcClientEntry client_entry; | |
| 671 | GaimBuddy *b; | |
| 672 | const char *filename, *nick = who; | |
| 673 | char tmp[256]; | |
| 674 | ||
| 675 | if (!who) | |
| 676 | return; | |
| 677 | if (strlen(who) > 1 && who[0] == '@') | |
| 678 | nick = who + 1; | |
| 679 | if (strlen(who) > 1 && who[0] == '*') | |
| 680 | nick = who + 1; | |
| 681 | if (strlen(who) > 2 && who[0] == '*' && who[1] == '@') | |
| 682 | nick = who + 2; | |
| 683 | ||
| 684 | b = gaim_find_buddy(gc->account, nick); | |
| 685 | if (b) { | |
| 686 | /* See if we have this buddy's public key. If we do use that | |
| 687 | to search the details. */ | |
| 688 | filename = gaim_blist_node_get_string((GaimBlistNode *)b, "public-key"); | |
| 689 | if (filename) { | |
| 690 | /* Call WHOIS. The user info is displayed in the WHOIS | |
| 691 | command reply. */ | |
| 692 | silc_client_command_call(client, conn, NULL, "WHOIS", | |
| 693 | "-details", "-pubkey", filename, NULL); | |
| 694 | return; | |
| 695 | } | |
| 696 | ||
| 697 | if (!b->proto_data) { | |
| 698 | g_snprintf(tmp, sizeof(tmp), | |
| 699 | _("User %s is not present in the network"), b->name); | |
| 700 | gaim_notify_error(gc, _("User Information"), | |
| 701 | _("Cannot get user information"), tmp); | |
| 702 | return; | |
| 703 | } | |
| 704 | ||
| 705 | client_entry = silc_client_get_client_by_id(client, conn, b->proto_data); | |
| 706 | if (client_entry) { | |
| 707 | /* Call WHOIS. The user info is displayed in the WHOIS | |
| 708 | command reply. */ | |
| 709 | silc_client_command_call(client, conn, NULL, "WHOIS", | |
| 710 | client_entry->nickname, "-details", NULL); | |
| 711 | } | |
| 712 | } else { | |
| 713 | /* Call WHOIS just with nickname. */ | |
| 714 | silc_client_command_call(client, conn, NULL, "WHOIS", nick, NULL); | |
| 715 | } | |
| 716 | } | |
| 717 | ||
| 718 | static void | |
| 719 | silcgaim_add_buddy_pk_no(SilcGaimBuddyRes r) | |
| 720 | { | |
| 721 | char tmp[512]; | |
| 722 | g_snprintf(tmp, sizeof(tmp), _("The %s buddy is not trusted"), | |
| 723 | r->b->name); | |
| 724 | gaim_notify_error(r->client->application, _("Add Buddy"), tmp, | |
| 8910 | 725 | _("You cannot receive buddy notifications until you " |
| 726 | "import his/her public key. You can use the Get Public Key " | |
| 8849 | 727 | "command to get the public key.")); |
| 728 | gaim_blist_update_buddy_presence(r->b, GAIM_BUDDY_OFFLINE); | |
| 729 | } | |
| 730 | ||
| 731 | static void | |
| 732 | silcgaim_add_buddy_save(bool success, void *context) | |
| 733 | { | |
| 734 | SilcGaimBuddyRes r = context; | |
| 735 | GaimBuddy *b = r->b; | |
| 736 | SilcClient client = r->client; | |
| 737 | SilcClientEntry client_entry; | |
| 738 | SilcAttributePayload attr; | |
| 739 | SilcAttribute attribute; | |
| 740 | SilcVCardStruct vcard; | |
| 741 | SilcAttributeObjMime message, extension; | |
| 742 | SilcAttributeObjPk serverpk, usersign, serversign; | |
| 743 | gboolean usign_success = TRUE, ssign_success = TRUE; | |
| 744 | unsigned char filename[256], filename2[256], *fingerprint = NULL, *tmp; | |
| 745 | SilcUInt32 len; | |
| 746 | int i; | |
| 747 | ||
| 748 | if (!success) { | |
| 749 | /* The user did not trust the public key. */ | |
| 750 | silcgaim_add_buddy_pk_no(r); | |
| 751 | silc_free(r); | |
| 752 | return; | |
| 753 | } | |
| 754 | ||
| 755 | if (r->offline) { | |
| 756 | /* User is offline. Associate the imported public key with | |
| 757 | this user. */ | |
| 758 | fingerprint = silc_hash_fingerprint(NULL, r->offline_pk, | |
| 759 | r->offline_pk_len); | |
| 760 | for (i = 0; i < strlen(fingerprint); i++) | |
| 761 | if (fingerprint[i] == ' ') | |
| 762 | fingerprint[i] = '_'; | |
| 763 | g_snprintf(filename, sizeof(filename) - 1, | |
| 764 | "%s" G_DIR_SEPARATOR_S "clientkeys" G_DIR_SEPARATOR_S "clientkey_%s.pub", | |
| 765 | silcgaim_silcdir(), fingerprint); | |
| 766 | gaim_blist_node_set_string((GaimBlistNode *)b, "public-key", filename); | |
| 767 | gaim_blist_save(); | |
| 768 | gaim_blist_update_buddy_presence(r->b, GAIM_BUDDY_OFFLINE); | |
| 769 | silc_free(fingerprint); | |
| 770 | silc_free(r->offline_pk); | |
| 771 | silc_free(r); | |
| 772 | return; | |
| 773 | } | |
| 774 | ||
| 775 | /* Get the client entry. */ | |
| 776 | client_entry = silc_client_get_client_by_id(r->client, r->conn, | |
| 777 | &r->client_id); | |
| 778 | if (!client_entry) { | |
| 779 | silc_free(r); | |
| 780 | return; | |
| 781 | } | |
| 782 | ||
| 783 | memset(&vcard, 0, sizeof(vcard)); | |
| 784 | memset(&message, 0, sizeof(message)); | |
| 785 | memset(&extension, 0, sizeof(extension)); | |
| 786 | memset(&serverpk, 0, sizeof(serverpk)); | |
| 787 | memset(&usersign, 0, sizeof(usersign)); | |
| 788 | memset(&serversign, 0, sizeof(serversign)); | |
| 789 | ||
| 790 | /* Now that we have the public key and we trust it now we | |
| 791 | save the attributes of the buddy and update its status. */ | |
| 792 | ||
| 793 | silc_dlist_start(client_entry->attrs); | |
| 794 | while ((attr = silc_dlist_get(client_entry->attrs)) != SILC_LIST_END) { | |
| 795 | attribute = silc_attribute_get_attribute(attr); | |
| 796 | ||
| 797 | switch (attribute) { | |
| 798 | ||
| 799 | case SILC_ATTRIBUTE_USER_INFO: | |
| 800 | if (!silc_attribute_get_object(attr, (void *)&vcard, | |
| 801 | sizeof(vcard))) | |
| 802 | continue; | |
| 803 | break; | |
| 804 | ||
| 805 | case SILC_ATTRIBUTE_STATUS_MESSAGE: | |
| 806 | if (!silc_attribute_get_object(attr, (void *)&message, | |
| 807 | sizeof(message))) | |
| 808 | continue; | |
| 809 | break; | |
| 810 | ||
| 811 | case SILC_ATTRIBUTE_EXTENSION: | |
| 812 | if (!silc_attribute_get_object(attr, (void *)&extension, | |
| 813 | sizeof(extension))) | |
| 814 | continue; | |
| 815 | break; | |
| 816 | ||
| 817 | case SILC_ATTRIBUTE_SERVER_PUBLIC_KEY: | |
| 818 | if (serverpk.type) | |
| 819 | continue; | |
| 820 | if (!silc_attribute_get_object(attr, (void *)&serverpk, | |
| 821 | sizeof(serverpk))) | |
| 822 | continue; | |
| 823 | break; | |
| 824 | ||
| 825 | case SILC_ATTRIBUTE_USER_DIGITAL_SIGNATURE: | |
| 826 | if (usersign.data) | |
| 827 | continue; | |
| 828 | if (!silc_attribute_get_object(attr, (void *)&usersign, | |
| 829 | sizeof(usersign))) | |
| 830 | continue; | |
| 831 | break; | |
| 832 | ||
| 833 | case SILC_ATTRIBUTE_SERVER_DIGITAL_SIGNATURE: | |
| 834 | if (serversign.data) | |
| 835 | continue; | |
| 836 | if (!silc_attribute_get_object(attr, (void *)&serversign, | |
| 837 | sizeof(serversign))) | |
| 838 | continue; | |
| 839 | break; | |
| 840 | ||
| 841 | default: | |
| 842 | break; | |
| 843 | } | |
| 844 | } | |
| 845 | ||
| 846 | /* Verify the attribute signatures */ | |
| 847 | ||
| 848 | if (usersign.data) { | |
| 849 | SilcPKCS pkcs; | |
| 850 | unsigned char *verifyd; | |
| 851 | SilcUInt32 verify_len; | |
| 852 | ||
| 853 | silc_pkcs_alloc("rsa", &pkcs); | |
| 854 | verifyd = silc_attribute_get_verify_data(client_entry->attrs, | |
| 855 | FALSE, &verify_len); | |
| 856 | if (verifyd && silc_pkcs_public_key_set(pkcs, client_entry->public_key)){ | |
| 857 | if (!silc_pkcs_verify_with_hash(pkcs, client->sha1hash, | |
| 858 | usersign.data, | |
| 859 | usersign.data_len, | |
| 860 | verifyd, verify_len)) | |
| 861 | usign_success = FALSE; | |
| 862 | } | |
| 863 | silc_free(verifyd); | |
| 864 | } | |
| 865 | ||
| 866 | if (serversign.data && !strcmp(serverpk.type, "silc-rsa")) { | |
| 867 | SilcPublicKey public_key; | |
| 868 | SilcPKCS pkcs; | |
| 869 | unsigned char *verifyd; | |
| 870 | SilcUInt32 verify_len; | |
| 871 | ||
| 872 | if (silc_pkcs_public_key_decode(serverpk.data, serverpk.data_len, | |
| 873 | &public_key)) { | |
| 874 | silc_pkcs_alloc("rsa", &pkcs); | |
| 875 | verifyd = silc_attribute_get_verify_data(client_entry->attrs, | |
| 876 | TRUE, &verify_len); | |
| 877 | if (verifyd && silc_pkcs_public_key_set(pkcs, public_key)) { | |
| 878 | if (!silc_pkcs_verify_with_hash(pkcs, client->sha1hash, | |
| 879 | serversign.data, | |
| 880 | serversign.data_len, | |
| 881 | verifyd, verify_len)) | |
| 882 | ssign_success = FALSE; | |
| 883 | } | |
| 884 | silc_pkcs_public_key_free(public_key); | |
| 885 | silc_free(verifyd); | |
| 886 | } | |
| 887 | } | |
| 888 | ||
| 889 | fingerprint = silc_fingerprint(client_entry->fingerprint, | |
| 890 | client_entry->fingerprint_len); | |
| 891 | for (i = 0; i < strlen(fingerprint); i++) | |
| 892 | if (fingerprint[i] == ' ') | |
| 893 | fingerprint[i] = '_'; | |
| 894 | ||
| 895 | if (usign_success || ssign_success) { | |
| 896 | struct passwd *pw; | |
| 897 | struct stat st; | |
| 898 | ||
| 899 | memset(filename2, 0, sizeof(filename2)); | |
| 900 | ||
| 901 | /* Filename for dir */ | |
| 902 | tmp = fingerprint + strlen(fingerprint) - 9; | |
| 903 | g_snprintf(filename, sizeof(filename) - 1, | |
| 904 | "%s" G_DIR_SEPARATOR_S "friends" G_DIR_SEPARATOR_S "%s", | |
| 905 | silcgaim_silcdir(), tmp); | |
| 906 | ||
| 907 | pw = getpwuid(getuid()); | |
| 908 | if (!pw) | |
| 909 | return; | |
| 910 | ||
| 911 | /* Create dir if it doesn't exist */ | |
| 912 | if ((stat(filename, &st)) == -1) { | |
| 913 | if (errno == ENOENT) { | |
| 914 | if (pw->pw_uid == geteuid()) | |
| 915 | mkdir(filename, 0755); | |
| 916 | } | |
| 917 | } | |
| 918 | ||
| 919 | /* Save VCard */ | |
| 920 | g_snprintf(filename2, sizeof(filename2) - 1, | |
| 921 | "%s" G_DIR_SEPARATOR_S "vcard", filename); | |
| 922 | if (vcard.full_name) { | |
| 923 | tmp = silc_vcard_encode(&vcard, &len); | |
| 924 | silc_file_writefile(filename2, tmp, len); | |
| 925 | silc_free(tmp); | |
| 926 | } | |
| 927 | ||
| 928 | /* Save status message */ | |
| 929 | if (message.mime) { | |
| 930 | memset(filename2, 0, sizeof(filename2)); | |
| 931 | g_snprintf(filename2, sizeof(filename2) - 1, | |
| 932 | "%s" G_DIR_SEPARATOR_S "status_message.mime", | |
| 933 | filename); | |
| 934 | silc_file_writefile(filename2, message.mime, | |
| 935 | message.mime_len); | |
| 936 | } | |
| 937 | ||
| 938 | /* Save extension data */ | |
| 939 | if (extension.mime) { | |
| 940 | memset(filename2, 0, sizeof(filename2)); | |
| 941 | g_snprintf(filename2, sizeof(filename2) - 1, | |
| 942 | "%s" G_DIR_SEPARATOR_S "extension.mime", | |
| 943 | filename); | |
| 944 | silc_file_writefile(filename2, extension.mime, | |
| 945 | extension.mime_len); | |
| 946 | } | |
| 947 | } | |
| 948 | ||
| 949 | /* Save the public key path to buddy properties, as it is used | |
| 950 | to identify the buddy in the network (and not the nickname). */ | |
| 951 | memset(filename, 0, sizeof(filename)); | |
| 952 | g_snprintf(filename, sizeof(filename) - 1, | |
| 953 | "%s" G_DIR_SEPARATOR_S "clientkeys" G_DIR_SEPARATOR_S "clientkey_%s.pub", | |
| 954 | silcgaim_silcdir(), fingerprint); | |
| 955 | gaim_blist_node_set_string((GaimBlistNode *)b, "public-key", filename); | |
| 956 | gaim_blist_save(); | |
| 957 | ||
| 958 | /* Update online status on the buddy list */ | |
| 959 | gaim_blist_update_buddy_presence(b, GAIM_BUDDY_ONLINE); | |
| 960 | ||
| 961 | /* Finally, start watching this user so we receive its status | |
| 962 | changes from the server */ | |
| 963 | g_snprintf(filename2, sizeof(filename2) - 1, "+%s", filename); | |
| 964 | silc_client_command_call(r->client, r->conn, NULL, "WATCH", "-pubkey", | |
| 965 | filename2, NULL); | |
| 966 | ||
| 967 | silc_free(fingerprint); | |
| 968 | silc_free(r); | |
| 969 | } | |
| 970 | ||
| 971 | static void | |
| 972 | silcgaim_add_buddy_ask_import(void *user_data, const char *name) | |
| 973 | { | |
| 974 | SilcGaimBuddyRes r = (SilcGaimBuddyRes)user_data; | |
| 975 | SilcPublicKey public_key; | |
| 976 | ||
| 977 | /* Load the public key */ | |
| 978 | if (!silc_pkcs_load_public_key(name, &public_key, SILC_PKCS_FILE_PEM) && | |
| 979 | !silc_pkcs_load_public_key(name, &public_key, SILC_PKCS_FILE_BIN)) { | |
| 980 | silcgaim_add_buddy_ask_pk_cb(r, 0); | |
| 981 | gaim_notify_error(r->client->application, | |
| 982 | _("Add Buddy"), _("Could not load public key"), NULL); | |
| 983 | return; | |
| 984 | } | |
| 985 | ||
| 986 | /* Now verify the public key */ | |
| 987 | r->offline_pk = silc_pkcs_public_key_encode(public_key, &r->offline_pk_len); | |
| 988 | silcgaim_verify_public_key(r->client, r->conn, r->b->name, | |
| 989 | SILC_SOCKET_TYPE_CLIENT, | |
| 990 | r->offline_pk, r->offline_pk_len, | |
| 991 | SILC_SKE_PK_TYPE_SILC, | |
| 992 | silcgaim_add_buddy_save, r); | |
| 993 | } | |
| 994 | ||
| 995 | static void | |
| 996 | silcgaim_add_buddy_ask_pk_cancel(void *user_data, const char *name) | |
| 997 | { | |
| 998 | SilcGaimBuddyRes r = (SilcGaimBuddyRes)user_data; | |
| 999 | ||
| 1000 | /* The user did not import public key. The buddy is unusable. */ | |
| 1001 | silcgaim_add_buddy_pk_no(r); | |
| 1002 | silc_free(r); | |
| 1003 | } | |
| 1004 | ||
| 1005 | static void | |
| 1006 | silcgaim_add_buddy_ask_pk_cb(SilcGaimBuddyRes r, gint id) | |
| 1007 | { | |
| 1008 | if (id != 0) { | |
| 1009 | /* The user did not import public key. The buddy is unusable. */ | |
| 1010 | silcgaim_add_buddy_pk_no(r); | |
| 1011 | silc_free(r); | |
| 1012 | return; | |
| 1013 | } | |
| 1014 | ||
| 1015 | /* Open file selector to select the public key. */ | |
| 1016 | gaim_request_file(NULL, _("Open..."), NULL, | |
| 1017 | G_CALLBACK(silcgaim_add_buddy_ask_import), | |
| 1018 | G_CALLBACK(silcgaim_add_buddy_ask_pk_cancel), r); | |
| 1019 | } | |
| 1020 | ||
| 1021 | static void | |
| 1022 | silcgaim_add_buddy_ask_pk(SilcGaimBuddyRes r) | |
| 1023 | { | |
| 1024 | char tmp[512]; | |
| 1025 | g_snprintf(tmp, sizeof(tmp), _("The %s buddy is not present in the network"), | |
| 1026 | r->b->name); | |
| 1027 | gaim_request_action(NULL, _("Add Buddy"), tmp, | |
| 8910 | 1028 | _("To add the buddy you must import his/her public key. " |
| 8849 | 1029 | "Press Import to import a public key."), 0, r, 2, |
| 1030 | _("Cancel"), G_CALLBACK(silcgaim_add_buddy_ask_pk_cb), | |
| 1031 | _("Import..."), G_CALLBACK(silcgaim_add_buddy_ask_pk_cb)); | |
| 1032 | } | |
| 1033 | ||
| 1034 | static void | |
| 1035 | silcgaim_add_buddy_getkey_cb(SilcGaimBuddyRes r, | |
| 1036 | SilcClientCommandReplyContext cmd) | |
| 1037 | { | |
| 1038 | SilcClientEntry client_entry; | |
| 1039 | unsigned char *pk; | |
| 1040 | SilcUInt32 pk_len; | |
| 1041 | ||
| 1042 | /* Get the client entry. */ | |
| 1043 | client_entry = silc_client_get_client_by_id(r->client, r->conn, | |
| 1044 | &r->client_id); | |
| 1045 | if (!client_entry || !client_entry->public_key) { | |
| 1046 | /* The buddy is offline/nonexistent. We will require user | |
| 1047 | to associate a public key with the buddy or the buddy | |
| 1048 | cannot be added. */ | |
| 1049 | r->offline = TRUE; | |
| 1050 | silcgaim_add_buddy_ask_pk(r); | |
| 1051 | return; | |
| 1052 | } | |
| 1053 | ||
| 1054 | /* Now verify the public key */ | |
| 1055 | pk = silc_pkcs_public_key_encode(client_entry->public_key, &pk_len); | |
| 1056 | silcgaim_verify_public_key(r->client, r->conn, client_entry->nickname, | |
| 1057 | SILC_SOCKET_TYPE_CLIENT, | |
| 1058 | pk, pk_len, SILC_SKE_PK_TYPE_SILC, | |
| 1059 | silcgaim_add_buddy_save, r); | |
| 1060 | silc_free(pk); | |
| 1061 | } | |
| 1062 | ||
| 1063 | static void | |
| 1064 | silcgaim_add_buddy_select_cb(SilcGaimBuddyRes r, GaimRequestFields *fields) | |
| 1065 | { | |
| 1066 | GaimRequestField *f; | |
| 1067 | const GList *list; | |
| 1068 | SilcClientEntry client_entry; | |
| 1069 | ||
| 1070 | f = gaim_request_fields_get_field(fields, "list"); | |
| 1071 | list = gaim_request_field_list_get_selected(f); | |
| 1072 | if (!list) { | |
| 1073 | /* The user did not select any user. */ | |
| 1074 | silcgaim_add_buddy_pk_no(r); | |
| 1075 | silc_free(r); | |
| 1076 | return; | |
| 1077 | } | |
| 1078 | ||
| 1079 | client_entry = gaim_request_field_list_get_data(f, list->data); | |
| 1080 | silcgaim_add_buddy_resolved(r->client, r->conn, &client_entry, 1, r); | |
| 1081 | } | |
| 1082 | ||
| 1083 | static void | |
| 1084 | silcgaim_add_buddy_select_cancel(SilcGaimBuddyRes r, GaimRequestFields *fields) | |
| 1085 | { | |
| 1086 | /* The user did not select any user. */ | |
| 1087 | silcgaim_add_buddy_pk_no(r); | |
| 1088 | silc_free(r); | |
| 1089 | } | |
| 1090 | ||
| 1091 | static void | |
| 1092 | silcgaim_add_buddy_select(SilcGaimBuddyRes r, | |
| 1093 | SilcClientEntry *clients, | |
| 1094 | SilcUInt32 clients_count) | |
| 1095 | { | |
| 1096 | GaimRequestFields *fields; | |
| 1097 | GaimRequestFieldGroup *g; | |
| 1098 | GaimRequestField *f; | |
| 1099 | char tmp[512]; | |
| 1100 | int i; | |
| 1101 | ||
| 1102 | fields = gaim_request_fields_new(); | |
| 1103 | g = gaim_request_field_group_new(NULL); | |
| 1104 | f = gaim_request_field_list_new("list", NULL); | |
| 1105 | gaim_request_field_group_add_field(g, f); | |
| 1106 | gaim_request_field_list_set_multi_select(f, FALSE); | |
| 1107 | gaim_request_fields_add_group(fields, g); | |
| 1108 | ||
| 1109 | for (i = 0; i < clients_count; i++) { | |
| 1110 | g_snprintf(tmp, sizeof(tmp), "%s - %s (%s@%s)", | |
| 1111 | clients[i]->realname, clients[i]->nickname, | |
| 1112 | clients[i]->username, clients[i]->hostname ? | |
| 1113 | clients[i]->hostname : ""); | |
| 1114 | gaim_request_field_list_add(f, tmp, clients[i]); | |
| 1115 | } | |
| 1116 | ||
| 1117 | gaim_request_fields(NULL, _("Add Buddy"), | |
| 8891 | 1118 | _("Select correct user"), |
| 1119 | r->pubkey_search | |
| 1120 | ? _("More than one user was found with the same public key. Select " | |
| 1121 | "the correct user from the list to add to the buddy list.") | |
| 1122 | : _("More than one user was found with the same name. Select " | |
| 1123 | "the correct user from the list to add to the buddy list."), | |
| 1124 | fields, | |
| 1125 | _("OK"), G_CALLBACK(silcgaim_add_buddy_select_cb), | |
| 1126 | _("Cancel"), G_CALLBACK(silcgaim_add_buddy_select_cancel), r); | |
| 8849 | 1127 | } |
| 1128 | ||
| 1129 | static void | |
| 1130 | silcgaim_add_buddy_resolved(SilcClient client, | |
| 1131 | SilcClientConnection conn, | |
| 1132 | SilcClientEntry *clients, | |
| 1133 | SilcUInt32 clients_count, | |
| 1134 | void *context) | |
| 1135 | { | |
| 1136 | SilcGaimBuddyRes r = context; | |
| 1137 | GaimBuddy *b = r->b; | |
| 1138 | SilcAttributePayload pub; | |
| 1139 | SilcAttributeObjPk userpk; | |
| 1140 | unsigned char *pk; | |
| 1141 | SilcUInt32 pk_len; | |
| 1142 | const char *filename; | |
| 1143 | ||
| 1144 | /* If the buddy is offline/nonexistent, we will require user | |
| 1145 | to associate a public key with the buddy or the buddy | |
| 1146 | cannot be added. */ | |
| 1147 | if (!clients_count) { | |
| 1148 | if (r->init) { | |
| 1149 | silc_free(r); | |
| 1150 | return; | |
| 1151 | } | |
| 1152 | ||
| 1153 | r->offline = TRUE; | |
| 1154 | silcgaim_add_buddy_ask_pk(r); | |
| 1155 | return; | |
| 1156 | } | |
| 1157 | ||
| 1158 | /* If more than one client was found with nickname, we need to verify | |
| 1159 | from user which one is the correct. */ | |
| 1160 | if (clients_count > 1 && !r->pubkey_search) { | |
| 1161 | if (r->init) { | |
| 1162 | silc_free(r); | |
| 1163 | return; | |
| 1164 | } | |
| 1165 | ||
| 1166 | silcgaim_add_buddy_select(r, clients, clients_count); | |
| 1167 | return; | |
| 1168 | } | |
| 1169 | ||
| 1170 | /* If we searched using public keys and more than one entry was found | |
| 1171 | the same person is logged on multiple times. */ | |
| 1172 | if (clients_count > 1 && r->pubkey_search && b->name) { | |
| 1173 | if (r->init) { | |
| 1174 | /* Find the entry that closest matches to the | |
| 1175 | buddy nickname. */ | |
| 1176 | int i; | |
| 1177 | for (i = 0; i < clients_count; i++) { | |
| 1178 | if (!strncasecmp(b->name, clients[i]->nickname, | |
| 1179 | strlen(b->name))) { | |
| 1180 | clients[0] = clients[i]; | |
| 1181 | break; | |
| 1182 | } | |
| 1183 | } | |
| 1184 | } else { | |
| 1185 | /* Verify from user which one is correct */ | |
| 1186 | silcgaim_add_buddy_select(r, clients, clients_count); | |
| 1187 | return; | |
| 1188 | } | |
| 1189 | } | |
| 1190 | ||
| 1191 | /* The client was found. Now get its public key and verify | |
| 1192 | that before adding the buddy. */ | |
| 1193 | memset(&userpk, 0, sizeof(userpk)); | |
| 1194 | b->proto_data = silc_memdup(clients[0]->id, sizeof(*clients[0]->id)); | |
| 1195 | r->client_id = *clients[0]->id; | |
| 1196 | ||
| 1197 | filename = gaim_blist_node_get_string((GaimBlistNode *)b, "public-key"); | |
| 1198 | ||
| 1199 | /* Get the public key from attributes, if not present then | |
| 1200 | resolve it with GETKEY unless we have it cached already. */ | |
| 1201 | if (clients[0]->attrs && !clients[0]->public_key) { | |
| 1202 | pub = silcgaim_get_attr(clients[0]->attrs, | |
| 1203 | SILC_ATTRIBUTE_USER_PUBLIC_KEY); | |
| 1204 | if (!pub || !silc_attribute_get_object(pub, (void *)&userpk, | |
| 1205 | sizeof(userpk))) { | |
| 1206 | /* Get public key with GETKEY */ | |
| 1207 | silc_client_command_call(client, conn, NULL, | |
| 1208 | "GETKEY", clients[0]->nickname, NULL); | |
| 1209 | silc_client_command_pending(conn, SILC_COMMAND_GETKEY, | |
| 1210 | conn->cmd_ident, | |
| 1211 | (SilcCommandCb)silcgaim_add_buddy_getkey_cb, | |
| 1212 | r); | |
| 1213 | return; | |
| 1214 | } | |
| 1215 | if (!silc_pkcs_public_key_decode(userpk.data, userpk.data_len, | |
| 1216 | &clients[0]->public_key)) | |
| 1217 | return; | |
| 1218 | silc_free(userpk.data); | |
| 1219 | } else if (filename && !clients[0]->public_key) { | |
| 1220 | if (!silc_pkcs_load_public_key(filename, &clients[0]->public_key, | |
| 1221 | SILC_PKCS_FILE_PEM) && | |
| 1222 | !silc_pkcs_load_public_key(filename, &clients[0]->public_key, | |
| 1223 | SILC_PKCS_FILE_BIN)) { | |
| 1224 | /* Get public key with GETKEY */ | |
| 1225 | silc_client_command_call(client, conn, NULL, | |
| 1226 | "GETKEY", clients[0]->nickname, NULL); | |
| 1227 | silc_client_command_pending(conn, SILC_COMMAND_GETKEY, | |
| 1228 | conn->cmd_ident, | |
| 1229 | (SilcCommandCb)silcgaim_add_buddy_getkey_cb, | |
| 1230 | r); | |
| 1231 | return; | |
| 1232 | } | |
| 1233 | } else if (!clients[0]->public_key) { | |
| 1234 | /* Get public key with GETKEY */ | |
| 1235 | silc_client_command_call(client, conn, NULL, | |
| 1236 | "GETKEY", clients[0]->nickname, NULL); | |
| 1237 | silc_client_command_pending(conn, SILC_COMMAND_GETKEY, | |
| 1238 | conn->cmd_ident, | |
| 1239 | (SilcCommandCb)silcgaim_add_buddy_getkey_cb, | |
| 1240 | r); | |
| 1241 | return; | |
| 1242 | } | |
| 1243 | ||
| 1244 | /* We have the public key, verify it. */ | |
| 1245 | pk = silc_pkcs_public_key_encode(clients[0]->public_key, &pk_len); | |
| 1246 | silcgaim_verify_public_key(client, conn, clients[0]->nickname, | |
| 1247 | SILC_SOCKET_TYPE_CLIENT, | |
| 1248 | pk, pk_len, SILC_SKE_PK_TYPE_SILC, | |
| 1249 | silcgaim_add_buddy_save, r); | |
| 1250 | silc_free(pk); | |
| 1251 | } | |
| 1252 | ||
| 1253 | static void | |
| 1254 | silcgaim_add_buddy_i(GaimConnection *gc, GaimBuddy *b, gboolean init) | |
| 1255 | { | |
| 1256 | SilcGaim sg = gc->proto_data; | |
| 1257 | SilcClient client = sg->client; | |
| 1258 | SilcClientConnection conn = sg->conn; | |
| 1259 | SilcGaimBuddyRes r; | |
| 1260 | SilcBuffer attrs; | |
| 1261 | const char *filename, *name = b->name; | |
| 1262 | ||
| 1263 | r = silc_calloc(1, sizeof(*r)); | |
| 1264 | if (!r) | |
| 1265 | return; | |
| 1266 | r->client = client; | |
| 1267 | r->conn = conn; | |
| 1268 | r->b = b; | |
| 1269 | r->init = init; | |
| 1270 | ||
| 1271 | /* See if we have this buddy's public key. If we do use that | |
| 1272 | to search the details. */ | |
| 1273 | filename = gaim_blist_node_get_string((GaimBlistNode *)b, "public-key"); | |
| 1274 | if (filename) { | |
| 1275 | SilcPublicKey public_key; | |
| 1276 | SilcAttributeObjPk userpk; | |
| 1277 | ||
| 1278 | if (!silc_pkcs_load_public_key(filename, &public_key, | |
| 1279 | SILC_PKCS_FILE_PEM) && | |
| 1280 | !silc_pkcs_load_public_key(filename, &public_key, | |
| 1281 | SILC_PKCS_FILE_BIN)) | |
| 1282 | return; | |
| 1283 | ||
| 1284 | /* Get all attributes, and use the public key to search user */ | |
| 1285 | name = NULL; | |
| 1286 | attrs = silc_client_attributes_request(SILC_ATTRIBUTE_USER_INFO, | |
| 1287 | SILC_ATTRIBUTE_SERVICE, | |
| 1288 | SILC_ATTRIBUTE_STATUS_MOOD, | |
| 1289 | SILC_ATTRIBUTE_STATUS_FREETEXT, | |
| 1290 | SILC_ATTRIBUTE_STATUS_MESSAGE, | |
| 1291 | SILC_ATTRIBUTE_PREFERRED_LANGUAGE, | |
| 1292 | SILC_ATTRIBUTE_PREFERRED_CONTACT, | |
| 1293 | SILC_ATTRIBUTE_TIMEZONE, | |
| 1294 | SILC_ATTRIBUTE_GEOLOCATION, | |
| 1295 | SILC_ATTRIBUTE_DEVICE_INFO, 0); | |
| 1296 | userpk.type = "silc-rsa"; | |
| 1297 | userpk.data = silc_pkcs_public_key_encode(public_key, &userpk.data_len); | |
| 1298 | attrs = silc_attribute_payload_encode(attrs, | |
| 1299 | SILC_ATTRIBUTE_USER_PUBLIC_KEY, | |
| 1300 | SILC_ATTRIBUTE_FLAG_VALID, | |
| 1301 | &userpk, sizeof(userpk)); | |
| 1302 | silc_free(userpk.data); | |
| 1303 | silc_pkcs_public_key_free(public_key); | |
| 1304 | r->pubkey_search = TRUE; | |
| 1305 | } else { | |
| 1306 | /* Get all attributes */ | |
| 1307 | attrs = silc_client_attributes_request(0); | |
| 1308 | } | |
| 1309 | ||
| 1310 | /* Resolve */ | |
| 1311 | silc_client_get_clients_whois(client, conn, name, NULL, attrs, | |
| 1312 | silcgaim_add_buddy_resolved, r); | |
| 1313 | silc_buffer_free(attrs); | |
| 1314 | } | |
| 1315 | ||
| 1316 | void silcgaim_add_buddy(GaimConnection *gc, const char *name, GaimGroup *grp) | |
| 1317 | { | |
| 1318 | GaimBuddy *b; | |
| 1319 | ||
| 1320 | b = gaim_find_buddy_in_group(gc->account, name, grp); | |
| 1321 | if (!b) | |
| 1322 | return; | |
| 1323 | ||
| 1324 | silcgaim_add_buddy_i(gc, b, FALSE); | |
| 1325 | } | |
| 1326 | ||
| 1327 | void silcgaim_add_buddies(GaimConnection *gc, GList *buddies) | |
| 1328 | { | |
| 1329 | while (buddies) { | |
| 1330 | GaimBuddy *b; | |
| 1331 | b = gaim_find_buddy(gc->account, buddies->data); | |
| 1332 | if (!b) | |
| 1333 | continue; | |
| 1334 | silcgaim_add_buddy_i(gc, b, TRUE); | |
| 1335 | buddies = buddies->next; | |
| 1336 | } | |
| 1337 | } | |
| 1338 | ||
| 1339 | void silcgaim_remove_buddy(GaimConnection *gc, const char *name, | |
| 1340 | const char *group) | |
| 1341 | { | |
| 1342 | GaimBuddy *b; | |
| 1343 | GaimGroup *g; | |
| 1344 | ||
| 1345 | g = gaim_find_group(group); | |
| 1346 | b = gaim_find_buddy_in_group(gc->account, name, g); | |
| 1347 | if (!b) | |
| 1348 | return; | |
| 1349 | ||
| 1350 | silc_free(b->proto_data); | |
| 1351 | } | |
| 1352 | ||
| 1353 | void silcgaim_idle_set(GaimConnection *gc, int idle) | |
| 1354 | ||
| 1355 | { | |
| 1356 | SilcGaim sg = gc->proto_data; | |
| 1357 | SilcClient client = sg->client; | |
| 1358 | SilcClientConnection conn = sg->conn; | |
| 1359 | SilcAttributeObjService service; | |
| 1360 | const char *server; | |
| 1361 | int port; | |
| 1362 | ||
| 1363 | server = gaim_account_get_string(sg->account, "server", | |
| 1364 | "silc.silcnet.org"); | |
| 1365 | port = gaim_account_get_int(sg->account, "port", 706), | |
| 1366 | ||
| 1367 | memset(&service, 0, sizeof(service)); | |
| 1368 | silc_client_attribute_del(client, conn, | |
| 1369 | SILC_ATTRIBUTE_SERVICE, NULL); | |
| 1370 | service.port = port; | |
| 1371 | g_snprintf(service.address, sizeof(service.address), "%s", server); | |
| 1372 | service.idle = idle; | |
| 1373 | silc_client_attribute_add(client, conn, SILC_ATTRIBUTE_SERVICE, | |
| 1374 | &service, sizeof(service)); | |
| 1375 | } | |
| 1376 | ||
| 1377 | char *silcgaim_status_text(GaimBuddy *b) | |
| 1378 | { | |
| 1379 | SilcGaim sg = b->account->gc->proto_data; | |
| 1380 | SilcClient client = sg->client; | |
| 1381 | SilcClientConnection conn = sg->conn; | |
| 1382 | SilcClientID *client_id = b->proto_data; | |
| 1383 | SilcClientEntry client_entry; | |
| 1384 | SilcAttributePayload attr; | |
| 1385 | SilcAttributeMood mood = 0; | |
| 1386 | ||
| 1387 | /* Get the client entry. */ | |
| 1388 | client_entry = silc_client_get_client_by_id(client, conn, client_id); | |
| 1389 | if (!client_entry) | |
| 1390 | return NULL; | |
| 1391 | ||
| 1392 | /* If user is online, we show the mood status, if available. | |
| 1393 | If user is offline or away that status is indicated. */ | |
| 1394 | ||
| 1395 | if (client_entry->mode & SILC_UMODE_DETACHED) | |
| 1396 | return g_strdup(_("Detached")); | |
| 1397 | if (client_entry->mode & SILC_UMODE_GONE) | |
| 1398 | return g_strdup(_("Away")); | |
| 1399 | if (client_entry->mode & SILC_UMODE_INDISPOSED) | |
| 1400 | return g_strdup(_("Indisposed")); | |
| 1401 | if (client_entry->mode & SILC_UMODE_BUSY) | |
| 1402 | return g_strdup(_("Busy")); | |
| 1403 | if (client_entry->mode & SILC_UMODE_PAGE) | |
| 1404 | return g_strdup(_("Wake Me Up")); | |
| 1405 | if (client_entry->mode & SILC_UMODE_HYPER) | |
| 1406 | return g_strdup(_("Hyper Active")); | |
| 1407 | if (client_entry->mode & SILC_UMODE_ROBOT) | |
| 1408 | return g_strdup(_("Robot")); | |
| 1409 | ||
| 1410 | attr = silcgaim_get_attr(client_entry->attrs, SILC_ATTRIBUTE_STATUS_MOOD); | |
| 1411 | if (attr && silc_attribute_get_object(attr, &mood, sizeof(mood))) { | |
| 1412 | /* The mood is a bit mask, so we could show multiple moods, | |
| 1413 | but let's show only one for now. */ | |
| 1414 | if (mood & SILC_ATTRIBUTE_MOOD_HAPPY) | |
| 1415 | return g_strdup(_("Happy")); | |
| 1416 | if (mood & SILC_ATTRIBUTE_MOOD_SAD) | |
| 1417 | return g_strdup(_("Sad")); | |
| 1418 | if (mood & SILC_ATTRIBUTE_MOOD_ANGRY) | |
| 1419 | return g_strdup(_("Angry")); | |
| 1420 | if (mood & SILC_ATTRIBUTE_MOOD_JEALOUS) | |
| 1421 | return g_strdup(_("Jealous")); | |
| 1422 | if (mood & SILC_ATTRIBUTE_MOOD_ASHAMED) | |
| 1423 | return g_strdup(_("Ashamed")); | |
| 1424 | if (mood & SILC_ATTRIBUTE_MOOD_INVINCIBLE) | |
| 1425 | return g_strdup(_("Invincible")); | |
| 1426 | if (mood & SILC_ATTRIBUTE_MOOD_INLOVE) | |
| 1427 | return g_strdup(_("In Love")); | |
| 1428 | if (mood & SILC_ATTRIBUTE_MOOD_SLEEPY) | |
| 1429 | return g_strdup(_("Sleepy")); | |
| 1430 | if (mood & SILC_ATTRIBUTE_MOOD_BORED) | |
| 1431 | return g_strdup(_("Bored")); | |
| 1432 | if (mood & SILC_ATTRIBUTE_MOOD_EXCITED) | |
| 1433 | return g_strdup(_("Excited")); | |
| 1434 | if (mood & SILC_ATTRIBUTE_MOOD_ANXIOUS) | |
| 1435 | return g_strdup(_("Anxious")); | |
| 1436 | } | |
| 1437 | ||
| 1438 | return NULL; | |
| 1439 | } | |
| 1440 | ||
| 1441 | char *silcgaim_tooltip_text(GaimBuddy *b) | |
| 1442 | { | |
| 1443 | SilcGaim sg = b->account->gc->proto_data; | |
| 1444 | SilcClient client = sg->client; | |
| 1445 | SilcClientConnection conn = sg->conn; | |
| 1446 | SilcClientID *client_id = b->proto_data; | |
| 1447 | SilcClientEntry client_entry; | |
| 1448 | SilcAttributePayload attr; | |
| 1449 | SilcAttributeMood mood = 0; | |
| 1450 | SilcAttributeContact contact; | |
| 1451 | SilcAttributeObjDevice device; | |
| 1452 | SilcAttributeObjGeo geo; | |
| 1453 | GString *s; | |
| 1454 | char *buf; | |
| 1455 | char tmp[256]; | |
| 1456 | ||
| 1457 | s = g_string_new(""); | |
| 1458 | ||
| 1459 | /* Get the client entry. */ | |
| 1460 | client_entry = silc_client_get_client_by_id(client, conn, client_id); | |
| 1461 | if (!client_entry) | |
| 1462 | return NULL; | |
| 1463 | ||
| 1464 | if (client_entry->nickname) | |
|
9039
2fb80b14dd95
[gaim-migrate @ 9815]
Björn Voigt <bjoern@cs.tu-berlin.de>
parents:
9038
diff
changeset
|
1465 | g_string_append_printf(s, "<b>%s:</b> %s\n", _("Nickname"), |
| 8849 | 1466 | client_entry->nickname); |
| 1467 | if (client_entry->username && client_entry->hostname) | |
|
9039
2fb80b14dd95
[gaim-migrate @ 9815]
Björn Voigt <bjoern@cs.tu-berlin.de>
parents:
9038
diff
changeset
|
1468 | g_string_append_printf(s, "<b>%s:</b> %s@%s\n", _("Username"), |
| 8849 | 1469 | client_entry->username, client_entry->hostname); |
| 1470 | if (client_entry->mode) { | |
|
9039
2fb80b14dd95
[gaim-migrate @ 9815]
Björn Voigt <bjoern@cs.tu-berlin.de>
parents:
9038
diff
changeset
|
1471 | g_string_append_printf(s, "<b>%s:</b> ", _("Modes")); |
| 8849 | 1472 | memset(tmp, 0, sizeof(tmp)); |
| 1473 | silcgaim_get_umode_string(client_entry->mode, | |
| 1474 | tmp, sizeof(tmp) - strlen(tmp)); | |
| 1475 | g_string_append_printf(s, "%s\n", tmp); | |
| 1476 | } | |
| 1477 | ||
| 1478 | attr = silcgaim_get_attr(client_entry->attrs, SILC_ATTRIBUTE_STATUS_MOOD); | |
| 1479 | if (attr && silc_attribute_get_object(attr, &mood, sizeof(mood))) { | |
| 1480 | if (mood) | |
|
9039
2fb80b14dd95
[gaim-migrate @ 9815]
Björn Voigt <bjoern@cs.tu-berlin.de>
parents:
9038
diff
changeset
|
1481 | g_string_append_printf(s, "<b>%s:</b> ", _("Mood")); |
| 8849 | 1482 | if (mood & SILC_ATTRIBUTE_MOOD_HAPPY) |
|
9039
2fb80b14dd95
[gaim-migrate @ 9815]
Björn Voigt <bjoern@cs.tu-berlin.de>
parents:
9038
diff
changeset
|
1483 | g_string_append_printf(s, "[%s] ", _("Happy")); |
| 8849 | 1484 | if (mood & SILC_ATTRIBUTE_MOOD_SAD) |
|
9039
2fb80b14dd95
[gaim-migrate @ 9815]
Björn Voigt <bjoern@cs.tu-berlin.de>
parents:
9038
diff
changeset
|
1485 | g_string_append_printf(s, "[%s] ", _("Sad")); |
| 8849 | 1486 | if (mood & SILC_ATTRIBUTE_MOOD_ANGRY) |
|
9039
2fb80b14dd95
[gaim-migrate @ 9815]
Björn Voigt <bjoern@cs.tu-berlin.de>
parents:
9038
diff
changeset
|
1487 | g_string_append_printf(s, "[%s] ", _("Angry")); |
| 8849 | 1488 | if (mood & SILC_ATTRIBUTE_MOOD_JEALOUS) |
|
9039
2fb80b14dd95
[gaim-migrate @ 9815]
Björn Voigt <bjoern@cs.tu-berlin.de>
parents:
9038
diff
changeset
|
1489 | g_string_append_printf(s, "[%s] ", _("Jealous")); |
| 8849 | 1490 | if (mood & SILC_ATTRIBUTE_MOOD_ASHAMED) |
|
9039
2fb80b14dd95
[gaim-migrate @ 9815]
Björn Voigt <bjoern@cs.tu-berlin.de>
parents:
9038
diff
changeset
|
1491 | g_string_append_printf(s, "[%s] ", _("Ashamed")); |
| 8849 | 1492 | if (mood & SILC_ATTRIBUTE_MOOD_INVINCIBLE) |
|
9039
2fb80b14dd95
[gaim-migrate @ 9815]
Björn Voigt <bjoern@cs.tu-berlin.de>
parents:
9038
diff
changeset
|
1493 | g_string_append_printf(s, "[%s] ", _("Invincible")); |
| 8849 | 1494 | if (mood & SILC_ATTRIBUTE_MOOD_INLOVE) |
|
9039
2fb80b14dd95
[gaim-migrate @ 9815]
Björn Voigt <bjoern@cs.tu-berlin.de>
parents:
9038
diff
changeset
|
1495 | g_string_append_printf(s, "[%s] ", _("In Love")); |
| 8849 | 1496 | if (mood & SILC_ATTRIBUTE_MOOD_SLEEPY) |
|
9039
2fb80b14dd95
[gaim-migrate @ 9815]
Björn Voigt <bjoern@cs.tu-berlin.de>
parents:
9038
diff
changeset
|
1497 | g_string_append_printf(s, "[%s] ", _("Sleepy")); |
| 8849 | 1498 | if (mood & SILC_ATTRIBUTE_MOOD_BORED) |
|
9039
2fb80b14dd95
[gaim-migrate @ 9815]
Björn Voigt <bjoern@cs.tu-berlin.de>
parents:
9038
diff
changeset
|
1499 | g_string_append_printf(s, "[%s] ", _("Bored")); |
| 8849 | 1500 | if (mood & SILC_ATTRIBUTE_MOOD_EXCITED) |
|
9039
2fb80b14dd95
[gaim-migrate @ 9815]
Björn Voigt <bjoern@cs.tu-berlin.de>
parents:
9038
diff
changeset
|
1501 | g_string_append_printf(s, "[%s] ", _("Excited")); |
| 8849 | 1502 | if (mood & SILC_ATTRIBUTE_MOOD_ANXIOUS) |
|
9039
2fb80b14dd95
[gaim-migrate @ 9815]
Björn Voigt <bjoern@cs.tu-berlin.de>
parents:
9038
diff
changeset
|
1503 | g_string_append_printf(s, "[%s] ", _("Anxious")); |
| 8849 | 1504 | if (mood) |
| 1505 | g_string_append_printf(s, "\n"); | |
| 1506 | } | |
| 1507 | ||
| 1508 | attr = silcgaim_get_attr(client_entry->attrs, SILC_ATTRIBUTE_STATUS_FREETEXT); | |
| 1509 | memset(tmp, 0, sizeof(tmp)); | |
| 1510 | if (attr && silc_attribute_get_object(attr, tmp, sizeof(tmp))) | |
|
9039
2fb80b14dd95
[gaim-migrate @ 9815]
Björn Voigt <bjoern@cs.tu-berlin.de>
parents:
9038
diff
changeset
|
1511 | g_string_append_printf(s, "<b>%s:</b> %s\n", _("Status Text"), tmp); |
| 8849 | 1512 | |
| 1513 | attr = silcgaim_get_attr(client_entry->attrs, SILC_ATTRIBUTE_PREFERRED_CONTACT); | |
| 1514 | if (attr && silc_attribute_get_object(attr, &contact, sizeof(contact))) { | |
| 1515 | if (contact) | |
|
9039
2fb80b14dd95
[gaim-migrate @ 9815]
Björn Voigt <bjoern@cs.tu-berlin.de>
parents:
9038
diff
changeset
|
1516 | g_string_append_printf(s, "<b>%s:</b> ", _("Preferred Contact")); |
| 8849 | 1517 | if (contact & SILC_ATTRIBUTE_CONTACT_CHAT) |
|
9039
2fb80b14dd95
[gaim-migrate @ 9815]
Björn Voigt <bjoern@cs.tu-berlin.de>
parents:
9038
diff
changeset
|
1518 | g_string_append_printf(s, "[%s] ", _("Chat")); |
| 8849 | 1519 | if (contact & SILC_ATTRIBUTE_CONTACT_EMAIL) |
|
9039
2fb80b14dd95
[gaim-migrate @ 9815]
Björn Voigt <bjoern@cs.tu-berlin.de>
parents:
9038
diff
changeset
|
1520 | g_string_append_printf(s, "[%s] ", _("Email")); |
| 8849 | 1521 | if (contact & SILC_ATTRIBUTE_CONTACT_CALL) |
|
9039
2fb80b14dd95
[gaim-migrate @ 9815]
Björn Voigt <bjoern@cs.tu-berlin.de>
parents:
9038
diff
changeset
|
1522 | g_string_append_printf(s, "[%s] ", _("Phone")); |
| 8849 | 1523 | if (contact & SILC_ATTRIBUTE_CONTACT_PAGE) |
|
9039
2fb80b14dd95
[gaim-migrate @ 9815]
Björn Voigt <bjoern@cs.tu-berlin.de>
parents:
9038
diff
changeset
|
1524 | g_string_append_printf(s, "[%s] ", _("Paging")); |
| 8849 | 1525 | if (contact & SILC_ATTRIBUTE_CONTACT_SMS) |
|
9039
2fb80b14dd95
[gaim-migrate @ 9815]
Björn Voigt <bjoern@cs.tu-berlin.de>
parents:
9038
diff
changeset
|
1526 | g_string_append_printf(s, "[%s] ", _("SMS")); |
| 8849 | 1527 | if (contact & SILC_ATTRIBUTE_CONTACT_MMS) |
|
9039
2fb80b14dd95
[gaim-migrate @ 9815]
Björn Voigt <bjoern@cs.tu-berlin.de>
parents:
9038
diff
changeset
|
1528 | g_string_append_printf(s, "[%s] ", _("MMS")); |
| 8849 | 1529 | if (contact & SILC_ATTRIBUTE_CONTACT_VIDEO) |
|
9039
2fb80b14dd95
[gaim-migrate @ 9815]
Björn Voigt <bjoern@cs.tu-berlin.de>
parents:
9038
diff
changeset
|
1530 | g_string_append_printf(s, "[%s] ", _("Video Conferencing")); |
| 8849 | 1531 | g_string_append_printf(s, "\n"); |
| 1532 | } | |
| 1533 | ||
| 1534 | attr = silcgaim_get_attr(client_entry->attrs, SILC_ATTRIBUTE_PREFERRED_LANGUAGE); | |
| 1535 | memset(tmp, 0, sizeof(tmp)); | |
| 1536 | if (attr && silc_attribute_get_object(attr, tmp, sizeof(tmp))) | |
|
9039
2fb80b14dd95
[gaim-migrate @ 9815]
Björn Voigt <bjoern@cs.tu-berlin.de>
parents:
9038
diff
changeset
|
1537 | g_string_append_printf(s, "<b>%s:</b> %s\n", _("Preferred Language"), tmp); |
| 8849 | 1538 | |
| 1539 | attr = silcgaim_get_attr(client_entry->attrs, SILC_ATTRIBUTE_DEVICE_INFO); | |
| 1540 | memset(&device, 0, sizeof(device)); | |
| 1541 | if (attr && silc_attribute_get_object(attr, &device, sizeof(device))) { | |
|
9039
2fb80b14dd95
[gaim-migrate @ 9815]
Björn Voigt <bjoern@cs.tu-berlin.de>
parents:
9038
diff
changeset
|
1542 | g_string_append_printf(s, "<b>%s:</b> ", _("Device")); |
| 8849 | 1543 | if (device.type == SILC_ATTRIBUTE_DEVICE_COMPUTER) |
|
9039
2fb80b14dd95
[gaim-migrate @ 9815]
Björn Voigt <bjoern@cs.tu-berlin.de>
parents:
9038
diff
changeset
|
1544 | g_string_append_printf(s, "%s: ", _("Computer")); |
| 8849 | 1545 | if (device.type == SILC_ATTRIBUTE_DEVICE_MOBILE_PHONE) |
|
9039
2fb80b14dd95
[gaim-migrate @ 9815]
Björn Voigt <bjoern@cs.tu-berlin.de>
parents:
9038
diff
changeset
|
1546 | g_string_append_printf(s, "%s: ", _("Mobile Phone")); |
| 8849 | 1547 | if (device.type == SILC_ATTRIBUTE_DEVICE_PDA) |
|
9039
2fb80b14dd95
[gaim-migrate @ 9815]
Björn Voigt <bjoern@cs.tu-berlin.de>
parents:
9038
diff
changeset
|
1548 | g_string_append_printf(s, "%s: ", _("PDA")); |
| 8849 | 1549 | if (device.type == SILC_ATTRIBUTE_DEVICE_TERMINAL) |
|
9039
2fb80b14dd95
[gaim-migrate @ 9815]
Björn Voigt <bjoern@cs.tu-berlin.de>
parents:
9038
diff
changeset
|
1550 | g_string_append_printf(s, "%s: ", _("Terminal")); |
| 8849 | 1551 | g_string_append_printf(s, "%s %s %s %s\n", |
| 1552 | device.manufacturer ? device.manufacturer : "", | |
| 1553 | device.version ? device.version : "", | |
| 1554 | device.model ? device.model : "", | |
| 1555 | device.language ? device.language : ""); | |
| 1556 | } | |
| 1557 | ||
| 1558 | attr = silcgaim_get_attr(client_entry->attrs, SILC_ATTRIBUTE_TIMEZONE); | |
| 1559 | memset(tmp, 0, sizeof(tmp)); | |
| 1560 | if (attr && silc_attribute_get_object(attr, tmp, sizeof(tmp))) | |
|
9039
2fb80b14dd95
[gaim-migrate @ 9815]
Björn Voigt <bjoern@cs.tu-berlin.de>
parents:
9038
diff
changeset
|
1561 | g_string_append_printf(s, "<b>%s:</b> %s\n", _("Timezone"), tmp); |
| 8849 | 1562 | |
| 1563 | attr = silcgaim_get_attr(client_entry->attrs, SILC_ATTRIBUTE_GEOLOCATION); | |
| 1564 | memset(&geo, 0, sizeof(geo)); | |
| 1565 | if (attr && silc_attribute_get_object(attr, &geo, sizeof(geo))) | |
|
9039
2fb80b14dd95
[gaim-migrate @ 9815]
Björn Voigt <bjoern@cs.tu-berlin.de>
parents:
9038
diff
changeset
|
1566 | g_string_append_printf(s, "<b>%s:</b> %s %s %s (%s)\n", |
|
2fb80b14dd95
[gaim-migrate @ 9815]
Björn Voigt <bjoern@cs.tu-berlin.de>
parents:
9038
diff
changeset
|
1567 | _("Geolocation"), |
| 8849 | 1568 | geo.longitude ? geo.longitude : "", |
| 1569 | geo.latitude ? geo.latitude : "", | |
| 1570 | geo.altitude ? geo.altitude : "", | |
| 1571 | geo.accuracy ? geo.accuracy : ""); | |
| 1572 | ||
| 1573 | buf = g_string_free(s, FALSE); | |
| 1574 | return buf; | |
| 1575 | } | |
| 1576 | ||
| 1577 | static void | |
| 9038 | 1578 | silcgaim_buddy_kill(GaimBlistNode *node, gpointer data) |
| 8849 | 1579 | { |
|
9030
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8910
diff
changeset
|
1580 | GaimBuddy *b; |
|
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8910
diff
changeset
|
1581 | GaimConnection *gc; |
|
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8910
diff
changeset
|
1582 | SilcGaim sg; |
|
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8910
diff
changeset
|
1583 | |
|
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8910
diff
changeset
|
1584 | g_return_if_fail(GAIM_BLIST_NODE_IS_BUDDY(node)); |
|
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8910
diff
changeset
|
1585 | |
|
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8910
diff
changeset
|
1586 | b = (GaimBuddy *) node; |
|
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8910
diff
changeset
|
1587 | gc = gaim_account_get_connection(b->account); |
|
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8910
diff
changeset
|
1588 | sg = gc->proto_data; |
| 8849 | 1589 | |
| 1590 | /* Call KILL */ | |
|
9030
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8910
diff
changeset
|
1591 | silc_client_command_call(sg->client, sg->conn, NULL, "KILL", |
|
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8910
diff
changeset
|
1592 | b->name, "Killed by operator", NULL); |
| 8849 | 1593 | } |
| 1594 | ||
| 1595 | static void | |
| 9038 | 1596 | silcgaim_buddy_send_file(GaimBlistNode *node, gpointer data) |
| 8849 | 1597 | { |
|
9030
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8910
diff
changeset
|
1598 | GaimBuddy *b; |
|
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8910
diff
changeset
|
1599 | GaimConnection *gc; |
|
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8910
diff
changeset
|
1600 | |
|
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8910
diff
changeset
|
1601 | g_return_if_fail(GAIM_BLIST_NODE_IS_BUDDY(node)); |
|
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8910
diff
changeset
|
1602 | |
|
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8910
diff
changeset
|
1603 | b = (GaimBuddy *) node; |
|
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8910
diff
changeset
|
1604 | gc = gaim_account_get_connection(b->account); |
|
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8910
diff
changeset
|
1605 | |
|
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8910
diff
changeset
|
1606 | silcgaim_ftp_send_file(gc, b->name); |
| 8849 | 1607 | } |
| 1608 | ||
|
9030
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8910
diff
changeset
|
1609 | GList *silcgaim_buddy_menu(GaimBuddy *buddy) |
| 8849 | 1610 | { |
|
9030
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8910
diff
changeset
|
1611 | |
|
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8910
diff
changeset
|
1612 | GaimConnection *gc = gaim_account_get_connection(buddy->account); |
| 8849 | 1613 | SilcGaim sg = gc->proto_data; |
| 1614 | SilcClientConnection conn = sg->conn; | |
| 1615 | const char *pkfile = NULL; | |
| 1616 | SilcClientEntry client_entry = NULL; | |
|
9030
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8910
diff
changeset
|
1617 | GaimBlistNodeAction *act; |
|
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8910
diff
changeset
|
1618 | GList *m = NULL; |
| 8849 | 1619 | |
| 9038 | 1620 | pkfile = gaim_blist_node_get_string((GaimBlistNode *) buddy, "public-key"); |
|
9030
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8910
diff
changeset
|
1621 | client_entry = silc_client_get_client_by_id(sg->client, |
|
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8910
diff
changeset
|
1622 | sg->conn, |
| 9038 | 1623 | buddy->proto_data); |
| 8849 | 1624 | |
| 1625 | if (client_entry && client_entry->send_key) { | |
|
9030
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8910
diff
changeset
|
1626 | act = gaim_blist_node_action_new(_("Reset IM Key"), |
| 9038 | 1627 | silcgaim_buddy_resetkey, NULL); |
|
9030
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8910
diff
changeset
|
1628 | m = g_list_append(m, act); |
|
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8910
diff
changeset
|
1629 | |
| 8849 | 1630 | } else { |
|
9030
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8910
diff
changeset
|
1631 | act = gaim_blist_node_action_new(_("IM with Key Exchange"), |
| 9038 | 1632 | silcgaim_buddy_keyagr, NULL); |
|
9030
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8910
diff
changeset
|
1633 | m = g_list_append(m, act); |
| 8849 | 1634 | |
|
9030
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8910
diff
changeset
|
1635 | act = gaim_blist_node_action_new(_("IM with Password"), |
| 9038 | 1636 | silcgaim_buddy_privkey_menu, NULL); |
|
9030
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8910
diff
changeset
|
1637 | m = g_list_append(m, act); |
| 8849 | 1638 | } |
| 1639 | ||
| 1640 | if (pkfile) { | |
|
9030
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8910
diff
changeset
|
1641 | act = gaim_blist_node_action_new(_("Show Public Key"), |
| 9038 | 1642 | silcgaim_buddy_showkey, NULL); |
|
9030
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8910
diff
changeset
|
1643 | m = g_list_append(m, act); |
|
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8910
diff
changeset
|
1644 | |
| 8849 | 1645 | } else { |
|
9030
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8910
diff
changeset
|
1646 | act = gaim_blist_node_action_new(_("Get Public Key..."), |
| 9038 | 1647 | silcgaim_buddy_getkey_menu, NULL); |
|
9030
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8910
diff
changeset
|
1648 | m = g_list_append(m, act); |
| 8849 | 1649 | } |
| 1650 | ||
|
9030
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8910
diff
changeset
|
1651 | act = gaim_blist_node_action_new(_("Send File..."), |
| 9038 | 1652 | silcgaim_buddy_send_file, NULL); |
|
9030
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8910
diff
changeset
|
1653 | m = g_list_append(m, act); |
| 8849 | 1654 | |
| 1655 | if (conn && conn->local_entry->mode & SILC_UMODE_ROUTER_OPERATOR) { | |
|
9030
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8910
diff
changeset
|
1656 | act = gaim_blist_node_action_new(_("Kill User"), |
| 9038 | 1657 | silcgaim_buddy_kill, NULL); |
|
9030
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8910
diff
changeset
|
1658 | m = g_list_append(m, act); |
| 8849 | 1659 | } |
| 1660 | ||
| 1661 | return m; | |
| 1662 | } |