comparison libpurple/protocols/silc/buddy.c @ 25290:8d562557ed6f

Some more PurpleBuddy::proto_data related changes. We need a purple_buddy_just_give_me_the_user_set_alias_okay to access PurpleBuddy::alias
author Sadrul Habib Chowdhury <imadil@gmail.com>
date Fri, 31 Oct 2008 10:14:23 +0000
parents aa876d48b5b2
children 9ea3474065dc
comparison
equal deleted inserted replaced
25289:aa876d48b5b2 25290:8d562557ed6f
687 687
688 b = purple_find_buddy(gc->account, nick); 688 b = purple_find_buddy(gc->account, nick);
689 if (b) { 689 if (b) {
690 /* See if we have this buddy's public key. If we do use that 690 /* See if we have this buddy's public key. If we do use that
691 to search the details. */ 691 to search the details. */
692 gpointer proto_data;
692 filename = purple_blist_node_get_string((PurpleBlistNode *)b, "public-key"); 693 filename = purple_blist_node_get_string((PurpleBlistNode *)b, "public-key");
693 if (filename) { 694 if (filename) {
694 /* Call WHOIS. The user info is displayed in the WHOIS 695 /* Call WHOIS. The user info is displayed in the WHOIS
695 command reply. */ 696 command reply. */
696 silc_client_command_call(client, conn, NULL, "WHOIS", 697 silc_client_command_call(client, conn, NULL, "WHOIS",
697 "-details", "-pubkey", filename, NULL); 698 "-details", "-pubkey", filename, NULL);
698 return; 699 return;
699 } 700 }
700 701
701 if (!b->proto_data) { 702 if (!(proto_data = purple_buddy_get_protocol_data(b))) {
702 g_snprintf(tmp, sizeof(tmp), 703 g_snprintf(tmp, sizeof(tmp),
703 _("User %s is not present in the network"), purple_buddy_get_name(b)); 704 _("User %s is not present in the network"), purple_buddy_get_name(b));
704 purple_notify_error(gc, _("User Information"), 705 purple_notify_error(gc, _("User Information"),
705 _("Cannot get user information"), tmp); 706 _("Cannot get user information"), tmp);
706 return; 707 return;
707 } 708 }
708 709
709 client_entry = silc_client_get_client_by_id(client, conn, b->proto_data); 710 client_entry = silc_client_get_client_by_id(client, conn, proto_data);
710 if (client_entry) { 711 if (client_entry) {
711 /* Call WHOIS. The user info is displayed in the WHOIS 712 /* Call WHOIS. The user info is displayed in the WHOIS
712 command reply. */ 713 command reply. */
713 silc_client_command_call(client, conn, NULL, "WHOIS", 714 silc_client_command_call(client, conn, NULL, "WHOIS",
714 client_entry->nickname, "-details", NULL); 715 client_entry->nickname, "-details", NULL);
1275 } 1276 }
1276 1277
1277 /* The client was found. Now get its public key and verify 1278 /* The client was found. Now get its public key and verify
1278 that before adding the buddy. */ 1279 that before adding the buddy. */
1279 memset(&userpk, 0, sizeof(userpk)); 1280 memset(&userpk, 0, sizeof(userpk));
1280 b->proto_data = silc_memdup(&client_entry->id, sizeof(client_entry->id)); 1281 purple_buddy_set_protocol_data(b, silc_memdup(&client_entry->id, sizeof(client_entry->id)));
1281 r->client_id = client_entry->id; 1282 r->client_id = client_entry->id;
1282 1283
1283 /* Get the public key from attributes, if not present then 1284 /* Get the public key from attributes, if not present then
1284 resolve it with GETKEY unless we have it cached already. */ 1285 resolve it with GETKEY unless we have it cached already. */
1285 if (client_entry->attrs && !client_entry->public_key) { 1286 if (client_entry->attrs && !client_entry->public_key) {
1434 } 1435 }
1435 1436
1436 void silcpurple_remove_buddy(PurpleConnection *gc, PurpleBuddy *buddy, 1437 void silcpurple_remove_buddy(PurpleConnection *gc, PurpleBuddy *buddy,
1437 PurpleGroup *group) 1438 PurpleGroup *group)
1438 { 1439 {
1439 silc_free(buddy->proto_data); 1440 silc_free(purple_buddy_get_protocol_data(buddy));
1440 } 1441 }
1441 1442
1442 void silcpurple_idle_set(PurpleConnection *gc, int idle) 1443 void silcpurple_idle_set(PurpleConnection *gc, int idle)
1443 1444
1444 { 1445 {
1480 PurpleAccount *account = purple_buddy_get_account(b); 1481 PurpleAccount *account = purple_buddy_get_account(b);
1481 PurpleConnection *gc = purple_account_get_connection(account); 1482 PurpleConnection *gc = purple_account_get_connection(account);
1482 SilcPurple sg = gc->proto_data; 1483 SilcPurple sg = gc->proto_data;
1483 SilcClient client = sg->client; 1484 SilcClient client = sg->client;
1484 SilcClientConnection conn = sg->conn; 1485 SilcClientConnection conn = sg->conn;
1485 SilcClientID *client_id = b->proto_data; 1486 SilcClientID *client_id = purple_buddy_get_protocol_data(b);
1486 SilcClientEntry client_entry; 1487 SilcClientEntry client_entry;
1487 SilcAttributePayload attr; 1488 SilcAttributePayload attr;
1488 SilcAttributeMood mood = 0; 1489 SilcAttributeMood mood = 0;
1489 1490
1490 /* Get the client entry. */ 1491 /* Get the client entry. */
1546 PurpleAccount *account = purple_buddy_get_account(b); 1547 PurpleAccount *account = purple_buddy_get_account(b);
1547 PurpleConnection *gc = purple_account_get_connection(account); 1548 PurpleConnection *gc = purple_account_get_connection(account);
1548 SilcPurple sg = gc->proto_data; 1549 SilcPurple sg = gc->proto_data;
1549 SilcClient client = sg->client; 1550 SilcClient client = sg->client;
1550 SilcClientConnection conn = sg->conn; 1551 SilcClientConnection conn = sg->conn;
1551 SilcClientID *client_id = b->proto_data; 1552 SilcClientID *client_id = purple_buddy_get_protocol_data(b);
1552 SilcClientEntry client_entry; 1553 SilcClientEntry client_entry;
1553 char *moodstr, *statusstr, *contactstr, *langstr, *devicestr, *tzstr, *geostr; 1554 char *moodstr, *statusstr, *contactstr, *langstr, *devicestr, *tzstr, *geostr;
1554 char tmp[256]; 1555 char tmp[256];
1555 1556
1556 /* Get the client entry. */ 1557 /* Get the client entry. */
1656 SilcPurpleBuddyWb wb; 1657 SilcPurpleBuddyWb wb;
1657 1658
1658 pkfile = purple_blist_node_get_string((PurpleBlistNode *) buddy, "public-key"); 1659 pkfile = purple_blist_node_get_string((PurpleBlistNode *) buddy, "public-key");
1659 client_entry = silc_client_get_client_by_id(sg->client, 1660 client_entry = silc_client_get_client_by_id(sg->client,
1660 sg->conn, 1661 sg->conn,
1661 buddy->proto_data); 1662 purple_buddy_get_protocol_data(buddy));
1662 1663
1663 if (client_entry && 1664 if (client_entry &&
1664 silc_client_private_message_key_is_set(sg->client, 1665 silc_client_private_message_key_is_set(sg->client,
1665 sg->conn, client_entry)) { 1666 sg->conn, client_entry)) {
1666 act = purple_menu_action_new(_("Reset IM Key"), 1667 act = purple_menu_action_new(_("Reset IM Key"),