comparison src/protocols/silc/buddy.c @ 9038:095731b5e4f6

[gaim-migrate @ 9814] Hmm. there's still a compile warning, but at least it compiles now. committer: Tailor Script <tailor@pidgin.im>
author Tim Ringenbach <marv@pidgin.im>
date Sun, 23 May 2004 19:40:55 +0000
parents 7ab20f829190
children bf4ecb0ae208
comparison
equal deleted inserted replaced
9037:960bb3bd9ba6 9038:095731b5e4f6
415 silcgaim_buddy_privkey(client->application, context); 415 silcgaim_buddy_privkey(client->application, context);
416 silc_free(context); 416 silc_free(context);
417 } 417 }
418 418
419 static void 419 static void
420 silcgaim_buddy_privkey(GaimBlistNode *node, gpointer data) 420 silcgaim_buddy_privkey(GaimConnection *gc, const char *name)
421 { 421 {
422 GaimBuddy *b; 422 SilcGaim sg = gc->proto_data;
423 GaimConnection *gc;
424 SilcGaim sg;
425 char *nickname; 423 char *nickname;
426 SilcGaimPrivkey p; 424 SilcGaimPrivkey p;
427 SilcClientEntry *clients; 425 SilcClientEntry *clients;
428 SilcUInt32 clients_count; 426 SilcUInt32 clients_count;
429 427
430 g_return_if_fail(GAIM_BLIST_NODE_IS_BUDDY(node)); 428 if (!name)
431 429 return;
432 b = (GaimBuddy *) node; 430 if (!silc_parse_userfqdn(name, &nickname, NULL))
433 gc = gaim_account_get_connection(b->account);
434 sg = gc->proto_data;
435
436 if (!silc_parse_userfqdn(b->name, &nickname, NULL))
437 return; 431 return;
438 432
439 /* Find client entry */ 433 /* Find client entry */
440 clients = silc_client_get_clients_local(sg->client, sg->conn, 434 clients = silc_client_get_clients_local(sg->client, sg->conn,
441 nickname, b->name, 435 nickname, name,
442 &clients_count); 436 &clients_count);
443 if (!clients) { 437 if (!clients) {
444 silc_client_get_clients(sg->client, sg->conn, nickname, NULL, 438 silc_client_get_clients(sg->client, sg->conn, nickname, NULL,
445 silcgaim_buddy_privkey_resolved, 439 silcgaim_buddy_privkey_resolved,
446 g_strdup(b->name)); 440 g_strdup(name));
447 silc_free(nickname); 441 silc_free(nickname);
448 return; 442 return;
449 } 443 }
450 444
451 p = silc_calloc(1, sizeof(*p)); 445 p = silc_calloc(1, sizeof(*p));
462 456
463 silc_free(clients); 457 silc_free(clients);
464 silc_free(nickname); 458 silc_free(nickname);
465 } 459 }
466 460
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
467 475
468 /**************************** Get Public Key *********************************/ 476 /**************************** Get Public Key *********************************/
469 477
470 typedef struct { 478 typedef struct {
471 SilcClient client; 479 SilcClient client;
532 silcgaim_buddy_getkey(client->application, context); 540 silcgaim_buddy_getkey(client->application, context);
533 silc_free(context); 541 silc_free(context);
534 } 542 }
535 543
536 static void 544 static void
537 silcgaim_buddy_getkey(GaimBlistNode *node, gpointer data) 545 silcgaim_buddy_getkey(GaimConnection *gc, const char *name)
538 { 546 {
539 GaimBuddy *b; 547 SilcGaim sg = gc->proto_data;
540 GaimConnection *gc; 548 SilcClient client = sg->client;
541 SilcGaim sg; 549 SilcClientConnection conn = sg->conn;
542 SilcClient client;
543 SilcClientConnection;
544 SilcClientEntry *clients; 550 SilcClientEntry *clients;
545 SilcUInt32 clients_count; 551 SilcUInt32 clients_count;
546 SilcGaimBuddyGetkey g; 552 SilcGaimBuddyGetkey g;
547 char *nickname; 553 char *nickname;
548 554
549 g_return_if_fail(GAIM_BLIST_NODE_IS_BUDDY(node)); 555 if (!name)
550 556 return;
551 b = (GaimBuddy *) node; 557
552 gc = gaim_account_get_connection(b->account); 558 if (!silc_parse_userfqdn(name, &nickname, NULL))
553 sg = gc->proto_data;
554 client = sg->client;
555 conn = sg->conn;
556
557 if (!silc_parse_userfqdn(b->name, &nickname, NULL))
558 return; 559 return;
559 560
560 /* Find client entry */ 561 /* Find client entry */
561 clients = silc_client_get_clients_local(client, conn, nickname, 562 clients = silc_client_get_clients_local(client, conn, nickname, name,
562 b->name, &clients_count); 563 &clients_count);
563 if (!clients) { 564 if (!clients) {
564 silc_client_get_clients(client, conn, nickname, NULL, 565 silc_client_get_clients(client, conn, nickname, NULL,
565 silcgaim_buddy_getkey_resolved, 566 silcgaim_buddy_getkey_resolved,
566 g_strdup(b->name)); 567 g_strdup(name));
567 silc_free(nickname); 568 silc_free(nickname);
568 return; 569 return;
569 } 570 }
570 571
571 /* Call GETKEY */ 572 /* Call GETKEY */
583 silc_free(clients); 584 silc_free(clients);
584 silc_free(nickname); 585 silc_free(nickname);
585 } 586 }
586 587
587 static void 588 static void
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
588 silcgaim_buddy_showkey(GaimBlistNode *node, gpointer data) 604 silcgaim_buddy_showkey(GaimBlistNode *node, gpointer data)
589 { 605 {
590 GaimBuddy *b; 606 GaimBuddy *b;
591 GaimConnection *gc; 607 GaimConnection *gc;
592 SilcGaim sg; 608 SilcGaim sg;
597 613
598 b = (GaimBuddy *) node; 614 b = (GaimBuddy *) node;
599 gc = gaim_account_get_connection(b->account); 615 gc = gaim_account_get_connection(b->account);
600 sg = gc->proto_data; 616 sg = gc->proto_data;
601 617
602 pkfile = gaim_blist_node_get_string(buddy, "public-key"); 618 pkfile = gaim_blist_node_get_string(node, "public-key");
603 if (!silc_pkcs_load_public_key(pkfile, &public_key, SILC_PKCS_FILE_PEM) && 619 if (!silc_pkcs_load_public_key(pkfile, &public_key, SILC_PKCS_FILE_PEM) &&
604 !silc_pkcs_load_public_key(pkfile, &public_key, SILC_PKCS_FILE_BIN)) { 620 !silc_pkcs_load_public_key(pkfile, &public_key, SILC_PKCS_FILE_BIN)) {
605 gaim_notify_error(gc, 621 gaim_notify_error(gc,
606 _("Show Public Key"), 622 _("Show Public Key"),
607 _("Could not load public key"), NULL); 623 _("Could not load public key"), NULL);
1556 buf = g_string_free(s, FALSE); 1572 buf = g_string_free(s, FALSE);
1557 return buf; 1573 return buf;
1558 } 1574 }
1559 1575
1560 static void 1576 static void
1561 silcgaim_buddy_kill(GaimBlistNode *buddy, gpointer data) 1577 silcgaim_buddy_kill(GaimBlistNode *node, gpointer data)
1562 { 1578 {
1563 GaimBuddy *b; 1579 GaimBuddy *b;
1564 GaimConnection *gc; 1580 GaimConnection *gc;
1565 SilcGaim sg; 1581 SilcGaim sg;
1566 1582
1574 silc_client_command_call(sg->client, sg->conn, NULL, "KILL", 1590 silc_client_command_call(sg->client, sg->conn, NULL, "KILL",
1575 b->name, "Killed by operator", NULL); 1591 b->name, "Killed by operator", NULL);
1576 } 1592 }
1577 1593
1578 static void 1594 static void
1579 silcgaim_buddy_send_file(GaimBlistNode *buddy, gpointer data) 1595 silcgaim_buddy_send_file(GaimBlistNode *node, gpointer data)
1580 { 1596 {
1581 GaimBuddy *b; 1597 GaimBuddy *b;
1582 GaimConnection *gc; 1598 GaimConnection *gc;
1583 1599
1584 g_return_if_fail(GAIM_BLIST_NODE_IS_BUDDY(node)); 1600 g_return_if_fail(GAIM_BLIST_NODE_IS_BUDDY(node));
1598 const char *pkfile = NULL; 1614 const char *pkfile = NULL;
1599 SilcClientEntry client_entry = NULL; 1615 SilcClientEntry client_entry = NULL;
1600 GaimBlistNodeAction *act; 1616 GaimBlistNodeAction *act;
1601 GList *m = NULL; 1617 GList *m = NULL;
1602 1618
1603 pkfile = gaim_blist_node_get_string(node, "public-key"); 1619 pkfile = gaim_blist_node_get_string((GaimBlistNode *) buddy, "public-key");
1604 client_entry = silc_client_get_client_by_id(sg->client, 1620 client_entry = silc_client_get_client_by_id(sg->client,
1605 sg->conn, 1621 sg->conn,
1606 b->proto_data); 1622 buddy->proto_data);
1607 1623
1608 if (client_entry && client_entry->send_key) { 1624 if (client_entry && client_entry->send_key) {
1609 act = gaim_blist_node_action_new(_("Reset IM Key"), 1625 act = gaim_blist_node_action_new(_("Reset IM Key"),
1610 silcgaim_buddy_resetkey); 1626 silcgaim_buddy_resetkey, NULL);
1611 m = g_list_append(m, act); 1627 m = g_list_append(m, act);
1612 1628
1613 } else { 1629 } else {
1614 act = gaim_blist_node_action_new(_("IM with Key Exchange"), 1630 act = gaim_blist_node_action_new(_("IM with Key Exchange"),
1615 silcgaim_buddy_keyagr); 1631 silcgaim_buddy_keyagr, NULL);
1616 m = g_list_append(m, act); 1632 m = g_list_append(m, act);
1617 1633
1618 act = gaim_blist_node_action_new(_("IM with Password"), 1634 act = gaim_blist_node_action_new(_("IM with Password"),
1619 silcgaim_buddy_privkey); 1635 silcgaim_buddy_privkey_menu, NULL);
1620 m = g_list_append(m, act); 1636 m = g_list_append(m, act);
1621 } 1637 }
1622 1638
1623 if (pkfile) { 1639 if (pkfile) {
1624 act = gaim_blist_node_action_new(_("Show Public Key"), 1640 act = gaim_blist_node_action_new(_("Show Public Key"),
1625 silcgaim_buddy_showkey); 1641 silcgaim_buddy_showkey, NULL);
1626 m = g_list_append(m, act); 1642 m = g_list_append(m, act);
1627 1643
1628 } else { 1644 } else {
1629 act = gaim_blist_node_action_new(_("Get Public Key..."), 1645 act = gaim_blist_node_action_new(_("Get Public Key..."),
1630 silcgaim_buddy_getkey); 1646 silcgaim_buddy_getkey_menu, NULL);
1631 m = g_list_append(m, act); 1647 m = g_list_append(m, act);
1632 } 1648 }
1633 1649
1634 act = gaim_blist_node_action_new(_("Send File..."), 1650 act = gaim_blist_node_action_new(_("Send File..."),
1635 silcgaim_buddy_send_file); 1651 silcgaim_buddy_send_file, NULL);
1636 m = g_list_append(m, act); 1652 m = g_list_append(m, act);
1637 1653
1638 if (conn && conn->local_entry->mode & SILC_UMODE_ROUTER_OPERATOR) { 1654 if (conn && conn->local_entry->mode & SILC_UMODE_ROUTER_OPERATOR) {
1639 act = gaim_blist_node_action_new(_("Kill User"), 1655 act = gaim_blist_node_action_new(_("Kill User"),
1640 silcgaim_buddy_kill); 1656 silcgaim_buddy_kill, NULL);
1641 m = g_list_append(m, act); 1657 m = g_list_append(m, act);
1642 } 1658 }
1643 1659
1644 return m; 1660 return m;
1645 } 1661 }