comparison libpurple/protocols/silc/buddy.c @ 32819:2c6510167895 default tip

propagate from branch 'im.pidgin.pidgin.2.x.y' (head 3315c5dfbd0ad16511bdcf865e5b07c02d07df24) to branch 'im.pidgin.pidgin' (head cbd1eda6bcbf0565ae7766396bb8f6f419cb6a9a)
author Elliott Sales de Andrade <qulogic@pidgin.im>
date Sat, 02 Jun 2012 02:30:49 +0000
parents 2ec94166be43
children
comparison
equal deleted inserted replaced
32818:01ff09d4a463 32819:2c6510167895
70 SilcKeyAgreementStatus status, 70 SilcKeyAgreementStatus status,
71 SilcSKEKeyMaterial key, 71 SilcSKEKeyMaterial key,
72 void *context) 72 void *context)
73 { 73 {
74 PurpleConnection *gc = client->application; 74 PurpleConnection *gc = client->application;
75 SilcPurple sg = gc->proto_data; 75 SilcPurple sg = purple_connection_get_protocol_data(gc);
76 76
77 if (!sg->conn) 77 if (!sg->conn)
78 return; 78 return;
79 79
80 switch (status) { 80 switch (status) {
144 144
145 static void 145 static void
146 silcpurple_buddy_keyagr_do(PurpleConnection *gc, const char *name, 146 silcpurple_buddy_keyagr_do(PurpleConnection *gc, const char *name,
147 gboolean force_local) 147 gboolean force_local)
148 { 148 {
149 SilcPurple sg = gc->proto_data; 149 SilcPurple sg = purple_connection_get_protocol_data(gc);
150 SilcDList clients; 150 SilcDList clients;
151 SilcClientEntry client_entry; 151 SilcClientEntry client_entry;
152 SilcClientConnectionParams params; 152 SilcClientConnectionParams params;
153 char *local_ip = NULL, *remote_ip = NULL; 153 char *local_ip = NULL, *remote_ip = NULL;
154 gboolean local = TRUE; 154 gboolean local = TRUE;
312 if (hostname) 312 if (hostname)
313 a->hostname = g_strdup(hostname); 313 a->hostname = g_strdup(hostname);
314 a->port = port; 314 a->port = port;
315 315
316 purple_request_action(client->application, _("Key Agreement Request"), tmp, 316 purple_request_action(client->application, _("Key Agreement Request"), tmp,
317 hostname ? tmp2 : NULL, 1, gc->account, client_entry->nickname, 317 hostname ? tmp2 : NULL, 1, purple_connection_get_account(gc), client_entry->nickname,
318 NULL, a, 2, _("Yes"), G_CALLBACK(silcpurple_buddy_keyagr_request_cb), 318 NULL, a, 2, _("Yes"), G_CALLBACK(silcpurple_buddy_keyagr_request_cb),
319 _("No"), G_CALLBACK(silcpurple_buddy_keyagr_request_cb)); 319 _("No"), G_CALLBACK(silcpurple_buddy_keyagr_request_cb));
320 } 320 }
321 321
322 static void 322 static void
344 344
345 g_return_if_fail(PURPLE_BLIST_NODE_IS_BUDDY(node)); 345 g_return_if_fail(PURPLE_BLIST_NODE_IS_BUDDY(node));
346 346
347 b = (PurpleBuddy *) node; 347 b = (PurpleBuddy *) node;
348 gc = purple_account_get_connection(purple_buddy_get_account(b)); 348 gc = purple_account_get_connection(purple_buddy_get_account(b));
349 sg = gc->proto_data; 349 sg = purple_connection_get_protocol_data(gc);
350 350
351 /* Find client entry */ 351 /* Find client entry */
352 clients = silc_client_get_clients_local(sg->client, sg->conn, 352 clients = silc_client_get_clients_local(sg->client, sg->conn,
353 purple_buddy_get_name(b), FALSE); 353 purple_buddy_get_name(b), FALSE);
354 if (!clients) 354 if (!clients)
424 } 424 }
425 425
426 static void 426 static void
427 silcpurple_buddy_privkey(PurpleConnection *gc, const char *name) 427 silcpurple_buddy_privkey(PurpleConnection *gc, const char *name)
428 { 428 {
429 SilcPurple sg = gc->proto_data; 429 SilcPurple sg = purple_connection_get_protocol_data(gc);
430 SilcPurplePrivkey p; 430 SilcPurplePrivkey p;
431 SilcDList clients; 431 SilcDList clients;
432 SilcClientEntry client_entry; 432 SilcClientEntry client_entry;
433 433
434 if (!name) 434 if (!name)
455 p->client_id = client_entry->id; 455 p->client_id = client_entry->id;
456 purple_request_input(gc, _("IM With Password"), NULL, 456 purple_request_input(gc, _("IM With Password"), NULL,
457 _("Set IM Password"), NULL, FALSE, TRUE, NULL, 457 _("Set IM Password"), NULL, FALSE, TRUE, NULL,
458 _("OK"), G_CALLBACK(silcpurple_buddy_privkey_cb), 458 _("OK"), G_CALLBACK(silcpurple_buddy_privkey_cb),
459 _("Cancel"), G_CALLBACK(silcpurple_buddy_privkey_cb), 459 _("Cancel"), G_CALLBACK(silcpurple_buddy_privkey_cb),
460 gc->account, NULL, NULL, p); 460 purple_connection_get_account(gc), NULL, NULL, p);
461 461
462 silc_client_list_free(sg->client, sg->conn, clients); 462 silc_client_list_free(sg->client, sg->conn, clients);
463 } 463 }
464 464
465 static void 465 static void
552 } 552 }
553 553
554 static void 554 static void
555 silcpurple_buddy_getkey(PurpleConnection *gc, const char *name) 555 silcpurple_buddy_getkey(PurpleConnection *gc, const char *name)
556 { 556 {
557 SilcPurple sg = gc->proto_data; 557 SilcPurple sg = purple_connection_get_protocol_data(gc);
558 SilcClient client = sg->client; 558 SilcClient client = sg->client;
559 SilcClientConnection conn = sg->conn; 559 SilcClientConnection conn = sg->conn;
560 SilcClientEntry client_entry; 560 SilcClientEntry client_entry;
561 SilcDList clients; 561 SilcDList clients;
562 SilcPurpleBuddyGetkey g; 562 SilcPurpleBuddyGetkey g;
616 616
617 g_return_if_fail(PURPLE_BLIST_NODE_IS_BUDDY(node)); 617 g_return_if_fail(PURPLE_BLIST_NODE_IS_BUDDY(node));
618 618
619 b = (PurpleBuddy *) node; 619 b = (PurpleBuddy *) node;
620 gc = purple_account_get_connection(purple_buddy_get_account(b)); 620 gc = purple_account_get_connection(purple_buddy_get_account(b));
621 sg = gc->proto_data; 621 sg = purple_connection_get_protocol_data(gc);
622 622
623 pkfile = purple_blist_node_get_string(node, "public-key"); 623 pkfile = purple_blist_node_get_string(node, "public-key");
624 if (!silc_pkcs_load_public_key(pkfile, &public_key)) { 624 if (!silc_pkcs_load_public_key(pkfile, &public_key)) {
625 purple_notify_error(gc, 625 purple_notify_error(gc,
626 _("Show Public Key"), 626 _("Show Public Key"),
667 SilcDList clients, 667 SilcDList clients,
668 void *context); 668 void *context);
669 669
670 void silcpurple_get_info(PurpleConnection *gc, const char *who) 670 void silcpurple_get_info(PurpleConnection *gc, const char *who)
671 { 671 {
672 SilcPurple sg = gc->proto_data; 672 SilcPurple sg = purple_connection_get_protocol_data(gc);
673 SilcClient client = sg->client; 673 SilcClient client = sg->client;
674 SilcClientConnection conn = sg->conn; 674 SilcClientConnection conn = sg->conn;
675 SilcClientEntry client_entry; 675 SilcClientEntry client_entry;
676 PurpleBuddy *b; 676 PurpleBuddy *b;
677 const char *filename, *nick = who; 677 const char *filename, *nick = who;
684 if (strlen(who) > 1 && who[0] == '*') 684 if (strlen(who) > 1 && who[0] == '*')
685 nick = who + 1; 685 nick = who + 1;
686 if (strlen(who) > 2 && who[0] == '*' && who[1] == '@') 686 if (strlen(who) > 2 && who[0] == '*' && who[1] == '@')
687 nick = who + 2; 687 nick = who + 2;
688 688
689 b = purple_find_buddy(gc->account, nick); 689 b = purple_find_buddy(purple_connection_get_account(gc), nick);
690 if (b) { 690 if (b) {
691 /* See if we have this buddy's public key. If we do use that 691 /* See if we have this buddy's public key. If we do use that
692 to search the details. */ 692 to search the details. */
693 gpointer proto_data; 693 gpointer proto_data;
694 filename = purple_blist_node_get_string((PurpleBlistNode *)b, "public-key"); 694 filename = purple_blist_node_get_string((PurpleBlistNode *)b, "public-key");
1336 } 1336 }
1337 1337
1338 static void 1338 static void
1339 silcpurple_add_buddy_i(PurpleConnection *gc, PurpleBuddy *b, gboolean init) 1339 silcpurple_add_buddy_i(PurpleConnection *gc, PurpleBuddy *b, gboolean init)
1340 { 1340 {
1341 SilcPurple sg = gc->proto_data; 1341 SilcPurple sg = purple_connection_get_protocol_data(gc);
1342 SilcClient client = sg->client; 1342 SilcClient client = sg->client;
1343 SilcClientConnection conn = sg->conn; 1343 SilcClientConnection conn = sg->conn;
1344 SilcPurpleBuddyRes r; 1344 SilcPurpleBuddyRes r;
1345 SilcBuffer attrs; 1345 SilcBuffer attrs;
1346 const char *filename, *name = purple_buddy_get_name(b); 1346 const char *filename, *name = purple_buddy_get_name(b);
1394 silc_client_get_clients_whois(client, conn, name, NULL, attrs, 1394 silc_client_get_clients_whois(client, conn, name, NULL, attrs,
1395 silcpurple_add_buddy_resolved, r); 1395 silcpurple_add_buddy_resolved, r);
1396 silc_buffer_free(attrs); 1396 silc_buffer_free(attrs);
1397 } 1397 }
1398 1398
1399 void silcpurple_add_buddy(PurpleConnection *gc, PurpleBuddy *buddy, PurpleGroup *group) 1399 void silcpurple_add_buddy(PurpleConnection *gc, PurpleBuddy *buddy, PurpleGroup *group, const char *message)
1400 { 1400 {
1401 /* Don't add if the buddy is already on the list. 1401 /* Don't add if the buddy is already on the list.
1402 * 1402 *
1403 * SILC doesn't have groups, so we also don't need to do anything 1403 * SILC doesn't have groups, so we also don't need to do anything
1404 * for a move. */ 1404 * for a move. */
1435 SilcClientConnection conn; 1435 SilcClientConnection conn;
1436 SilcAttributeObjService service; 1436 SilcAttributeObjService service;
1437 const char *server; 1437 const char *server;
1438 int port; 1438 int port;
1439 1439
1440 sg = gc->proto_data; 1440 sg = purple_connection_get_protocol_data(gc);
1441 if (sg == NULL) 1441 if (sg == NULL)
1442 return; 1442 return;
1443 1443
1444 client = sg->client; 1444 client = sg->client;
1445 if (client == NULL) 1445 if (client == NULL)
1465 1465
1466 char *silcpurple_status_text(PurpleBuddy *b) 1466 char *silcpurple_status_text(PurpleBuddy *b)
1467 { 1467 {
1468 PurpleAccount *account = purple_buddy_get_account(b); 1468 PurpleAccount *account = purple_buddy_get_account(b);
1469 PurpleConnection *gc = purple_account_get_connection(account); 1469 PurpleConnection *gc = purple_account_get_connection(account);
1470 SilcPurple sg = gc->proto_data; 1470 SilcPurple sg = purple_connection_get_protocol_data(gc);
1471 SilcClient client = sg->client; 1471 SilcClient client = sg->client;
1472 SilcClientConnection conn = sg->conn; 1472 SilcClientConnection conn = sg->conn;
1473 SilcClientID *client_id = purple_buddy_get_protocol_data(b); 1473 SilcClientID *client_id = purple_buddy_get_protocol_data(b);
1474 SilcClientEntry client_entry; 1474 SilcClientEntry client_entry;
1475 SilcAttributePayload attr; 1475 SilcAttributePayload attr;
1531 1531
1532 void silcpurple_tooltip_text(PurpleBuddy *b, PurpleNotifyUserInfo *user_info, gboolean full) 1532 void silcpurple_tooltip_text(PurpleBuddy *b, PurpleNotifyUserInfo *user_info, gboolean full)
1533 { 1533 {
1534 PurpleAccount *account = purple_buddy_get_account(b); 1534 PurpleAccount *account = purple_buddy_get_account(b);
1535 PurpleConnection *gc = purple_account_get_connection(account); 1535 PurpleConnection *gc = purple_account_get_connection(account);
1536 SilcPurple sg = gc->proto_data; 1536 SilcPurple sg = purple_connection_get_protocol_data(gc);
1537 SilcClient client = sg->client; 1537 SilcClient client = sg->client;
1538 SilcClientConnection conn = sg->conn; 1538 SilcClientConnection conn = sg->conn;
1539 SilcClientID *client_id = purple_buddy_get_protocol_data(b); 1539 SilcClientID *client_id = purple_buddy_get_protocol_data(b);
1540 SilcClientEntry client_entry; 1540 SilcClientEntry client_entry;
1541 char *moodstr, *statusstr, *contactstr, *langstr, *devicestr, *tzstr, *geostr; 1541 char *moodstr, *statusstr, *contactstr, *langstr, *devicestr, *tzstr, *geostr;
1545 client_entry = silc_client_get_client_by_id(client, conn, client_id); 1545 client_entry = silc_client_get_client_by_id(client, conn, client_id);
1546 if (!client_entry) 1546 if (!client_entry)
1547 return; 1547 return;
1548 1548
1549 if (client_entry->nickname) 1549 if (client_entry->nickname)
1550 purple_notify_user_info_add_pair(user_info, _("Nickname"), 1550 /* TODO: Check whether it's correct to call add_pair_html,
1551 or if we should be using add_pair_plaintext */
1552 purple_notify_user_info_add_pair_html(user_info, _("Nickname"),
1551 client_entry->nickname); 1553 client_entry->nickname);
1552 if (client_entry->username && client_entry->hostname) { 1554 if (client_entry->username && client_entry->hostname) {
1553 g_snprintf(tmp, sizeof(tmp), "%s@%s", client_entry->username, client_entry->hostname); 1555 g_snprintf(tmp, sizeof(tmp), "%s@%s", client_entry->username, client_entry->hostname);
1554 purple_notify_user_info_add_pair(user_info, _("Username"), tmp); 1556 /* TODO: Check whether it's correct to call add_pair_html,
1557 or if we should be using add_pair_plaintext */
1558 purple_notify_user_info_add_pair_html(user_info, _("Username"), tmp);
1555 } 1559 }
1556 if (client_entry->mode) { 1560 if (client_entry->mode) {
1557 memset(tmp, 0, sizeof(tmp)); 1561 memset(tmp, 0, sizeof(tmp));
1558 silcpurple_get_umode_string(client_entry->mode, 1562 silcpurple_get_umode_string(client_entry->mode,
1559 tmp, sizeof(tmp) - strlen(tmp)); 1563 tmp, sizeof(tmp) - strlen(tmp));
1560 purple_notify_user_info_add_pair(user_info, _("User Modes"), tmp); 1564 purple_notify_user_info_add_pair_plaintext(user_info, _("User Modes"), tmp);
1561 } 1565 }
1562 1566
1563 silcpurple_parse_attrs(client_entry->attrs, &moodstr, &statusstr, &contactstr, &langstr, &devicestr, &tzstr, &geostr); 1567 silcpurple_parse_attrs(client_entry->attrs, &moodstr, &statusstr, &contactstr, &langstr, &devicestr, &tzstr, &geostr);
1564 1568
1565 if (statusstr) { 1569 if (statusstr) {
1566 purple_notify_user_info_add_pair(user_info, _("Message"), statusstr); 1570 /* TODO: Check whether it's correct to call add_pair_html,
1571 or if we should be using add_pair_plaintext */
1572 purple_notify_user_info_add_pair_html(user_info, _("Message"), statusstr);
1567 g_free(statusstr); 1573 g_free(statusstr);
1568 } 1574 }
1569 1575
1570 if (full) { 1576 if (full) {
1571 if (moodstr) { 1577 if (moodstr) {
1572 purple_notify_user_info_add_pair(user_info, _("Mood"), moodstr); 1578 /* TODO: Check whether it's correct to call add_pair_html,
1579 or if we should be using add_pair_plaintext */
1580 purple_notify_user_info_add_pair_html(user_info, _("Mood"), moodstr);
1573 g_free(moodstr); 1581 g_free(moodstr);
1574 } 1582 }
1575 1583
1576 if (contactstr) { 1584 if (contactstr) {
1577 purple_notify_user_info_add_pair(user_info, _("Preferred Contact"), contactstr); 1585 /* TODO: Check whether it's correct to call add_pair_html,
1586 or if we should be using add_pair_plaintext */
1587 purple_notify_user_info_add_pair_html(user_info, _("Preferred Contact"), contactstr);
1578 g_free(contactstr); 1588 g_free(contactstr);
1579 } 1589 }
1580 1590
1581 if (langstr) { 1591 if (langstr) {
1582 purple_notify_user_info_add_pair(user_info, _("Preferred Language"), langstr); 1592 /* TODO: Check whether it's correct to call add_pair_html,
1593 or if we should be using add_pair_plaintext */
1594 purple_notify_user_info_add_pair_html(user_info, _("Preferred Language"), langstr);
1583 g_free(langstr); 1595 g_free(langstr);
1584 } 1596 }
1585 1597
1586 if (devicestr) { 1598 if (devicestr) {
1587 purple_notify_user_info_add_pair(user_info, _("Device"), devicestr); 1599 /* TODO: Check whether it's correct to call add_pair_html,
1600 or if we should be using add_pair_plaintext */
1601 purple_notify_user_info_add_pair_html(user_info, _("Device"), devicestr);
1588 g_free(devicestr); 1602 g_free(devicestr);
1589 } 1603 }
1590 1604
1591 if (tzstr) { 1605 if (tzstr) {
1592 purple_notify_user_info_add_pair(user_info, _("Timezone"), tzstr); 1606 /* TODO: Check whether it's correct to call add_pair_html,
1607 or if we should be using add_pair_plaintext */
1608 purple_notify_user_info_add_pair_html(user_info, _("Timezone"), tzstr);
1593 g_free(tzstr); 1609 g_free(tzstr);
1594 } 1610 }
1595 1611
1596 if (geostr) { 1612 if (geostr) {
1597 purple_notify_user_info_add_pair(user_info, _("Geolocation"), geostr); 1613 /* TODO: Check whether it's correct to call add_pair_html,
1614 or if we should be using add_pair_plaintext */
1615 purple_notify_user_info_add_pair_html(user_info, _("Geolocation"), geostr);
1598 g_free(geostr); 1616 g_free(geostr);
1599 } 1617 }
1600 } 1618 }
1601 } 1619 }
1602 1620
1609 1627
1610 g_return_if_fail(PURPLE_BLIST_NODE_IS_BUDDY(node)); 1628 g_return_if_fail(PURPLE_BLIST_NODE_IS_BUDDY(node));
1611 1629
1612 b = (PurpleBuddy *) node; 1630 b = (PurpleBuddy *) node;
1613 gc = purple_account_get_connection(purple_buddy_get_account(b)); 1631 gc = purple_account_get_connection(purple_buddy_get_account(b));
1614 sg = gc->proto_data; 1632 sg = purple_connection_get_protocol_data(gc);
1615 1633
1616 /* Call KILL */ 1634 /* Call KILL */
1617 silc_client_command_call(sg->client, sg->conn, NULL, "KILL", 1635 silc_client_command_call(sg->client, sg->conn, NULL, "KILL",
1618 purple_buddy_get_name(b), "Killed by operator", NULL); 1636 purple_buddy_get_name(b), "Killed by operator", NULL);
1619 } 1637 }
1633 1651
1634 GList *silcpurple_buddy_menu(PurpleBuddy *buddy) 1652 GList *silcpurple_buddy_menu(PurpleBuddy *buddy)
1635 { 1653 {
1636 PurpleAccount *account = purple_buddy_get_account(buddy); 1654 PurpleAccount *account = purple_buddy_get_account(buddy);
1637 PurpleConnection *gc = purple_account_get_connection(account); 1655 PurpleConnection *gc = purple_account_get_connection(account);
1638 SilcPurple sg = gc->proto_data; 1656 SilcPurple sg = purple_connection_get_protocol_data(gc);
1639 SilcClientConnection conn = sg->conn; 1657 SilcClientConnection conn = sg->conn;
1640 const char *pkfile = NULL; 1658 const char *pkfile = NULL;
1641 SilcClientEntry client_entry = NULL; 1659 SilcClientEntry client_entry = NULL;
1642 PurpleMenuAction *act; 1660 PurpleMenuAction *act;
1643 GList *m = NULL; 1661 GList *m = NULL;
1699 return m; 1717 return m;
1700 } 1718 }
1701 1719
1702 void silcpurple_buddy_set_icon(PurpleConnection *gc, PurpleStoredImage *img) 1720 void silcpurple_buddy_set_icon(PurpleConnection *gc, PurpleStoredImage *img)
1703 { 1721 {
1704 SilcPurple sg = gc->proto_data; 1722 SilcPurple sg = purple_connection_get_protocol_data(gc);
1705 SilcClient client = sg->client; 1723 SilcClient client = sg->client;
1706 SilcClientConnection conn = sg->conn; 1724 SilcClientConnection conn = sg->conn;
1707 SilcMime mime; 1725 SilcMime mime;
1708 char type[32]; 1726 char type[32];
1709 const char *t; 1727 const char *t;