comparison libpurple/protocols/silc/silc.c @ 32827:4a34689eeb33 default tip

merged from im.pidgin.pidgin
author Yoshiki Yazawa <yaz@honeyplanet.jp>
date Sat, 19 Nov 2011 14:42:54 +0900
parents 3e7a7e14af62
children
comparison
equal deleted inserted replaced
32692:0f94ec89f0bc 32827:4a34689eeb33
526 /* Load SILC key pair */ 526 /* Load SILC key pair */
527 g_snprintf(pkd, sizeof(pkd), "%s" G_DIR_SEPARATOR_S "public_key.pub", silcpurple_silcdir()); 527 g_snprintf(pkd, sizeof(pkd), "%s" G_DIR_SEPARATOR_S "public_key.pub", silcpurple_silcdir());
528 g_snprintf(prd, sizeof(prd), "%s" G_DIR_SEPARATOR_S "private_key.prv", silcpurple_silcdir()); 528 g_snprintf(prd, sizeof(prd), "%s" G_DIR_SEPARATOR_S "private_key.prv", silcpurple_silcdir());
529 if (!silc_load_key_pair((char *)purple_account_get_string(account, "public-key", pkd), 529 if (!silc_load_key_pair((char *)purple_account_get_string(account, "public-key", pkd),
530 (char *)purple_account_get_string(account, "private-key", prd), 530 (char *)purple_account_get_string(account, "private-key", prd),
531 (gc->password == NULL) ? "" : gc->password, 531 (purple_connection_get_password(gc) == NULL) ? "" : purple_connection_get_password(gc),
532 &sg->public_key, &sg->private_key)) { 532 &sg->public_key, &sg->private_key)) {
533 if (!purple_account_get_password(account)) { 533 if (!purple_account_get_password(account)) {
534 purple_account_request_password(account, G_CALLBACK(silcpurple_got_password_cb), 534 purple_account_request_password(account, G_CALLBACK(silcpurple_got_password_cb),
535 G_CALLBACK(silcpurple_no_password_cb), gc); 535 G_CALLBACK(silcpurple_no_password_cb), gc);
536 return; 536 return;
553 SilcClientParams params; 553 SilcClientParams params;
554 const char *cipher, *hmac; 554 const char *cipher, *hmac;
555 char *username, *hostname, *realname, **up; 555 char *username, *hostname, *realname, **up;
556 int i; 556 int i;
557 557
558 gc = account->gc; 558 gc = purple_account_get_connection(account);
559 if (!gc) 559 if (!gc)
560 return; 560 return;
561 purple_connection_set_protocol_data(gc, NULL); 561 purple_connection_set_protocol_data(gc, NULL);
562 562
563 memset(&params, 0, sizeof(params)); 563 memset(&params, 0, sizeof(params));
1059 "and your personal information. Please fill the information " 1059 "and your personal information. Please fill the information "
1060 "you would like other users to see about yourself."), 1060 "you would like other users to see about yourself."),
1061 fields, 1061 fields,
1062 _("OK"), G_CALLBACK(silcpurple_attrs_cb), 1062 _("OK"), G_CALLBACK(silcpurple_attrs_cb),
1063 _("Cancel"), G_CALLBACK(silcpurple_attrs_cancel), 1063 _("Cancel"), G_CALLBACK(silcpurple_attrs_cancel),
1064 gc->account, NULL, NULL, gc); 1064 purple_connection_get_account(gc), NULL, NULL, gc);
1065 } 1065 }
1066 1066
1067 static void 1067 static void
1068 silcpurple_detach(PurplePluginAction *action) 1068 silcpurple_detach(PurplePluginAction *action)
1069 { 1069 {
1224 g_snprintf(tmp, sizeof(tmp), "%s@%s", username, hostname); 1224 g_snprintf(tmp, sizeof(tmp), "%s@%s", username, hostname);
1225 1225
1226 g_snprintf(pkd2, sizeof(pkd2), "%s" G_DIR_SEPARATOR_S"public_key.pub", silcpurple_silcdir()); 1226 g_snprintf(pkd2, sizeof(pkd2), "%s" G_DIR_SEPARATOR_S"public_key.pub", silcpurple_silcdir());
1227 g_snprintf(prd2, sizeof(prd2), "%s" G_DIR_SEPARATOR_S"private_key.prv", silcpurple_silcdir()); 1227 g_snprintf(prd2, sizeof(prd2), "%s" G_DIR_SEPARATOR_S"private_key.prv", silcpurple_silcdir());
1228 g_snprintf(pkd, sizeof(pkd) - 1, "%s", 1228 g_snprintf(pkd, sizeof(pkd) - 1, "%s",
1229 purple_account_get_string(gc->account, "public-key", pkd2)); 1229 purple_account_get_string(purple_connection_get_account(gc), "public-key", pkd2));
1230 g_snprintf(prd, sizeof(prd) - 1, "%s", 1230 g_snprintf(prd, sizeof(prd) - 1, "%s",
1231 purple_account_get_string(gc->account, "private-key", prd2)); 1231 purple_account_get_string(purple_connection_get_account(gc), "private-key", prd2));
1232 1232
1233 fields = purple_request_fields_new(); 1233 fields = purple_request_fields_new();
1234 1234
1235 g = purple_request_field_group_new(NULL); 1235 g = purple_request_field_group_new(NULL);
1236 f = purple_request_field_string_new("key", _("Key length"), "2048", FALSE); 1236 f = purple_request_field_string_new("key", _("Key length"), "2048", FALSE);
1267 1267
1268 purple_request_fields(gc, _("Create New SILC Key Pair"), 1268 purple_request_fields(gc, _("Create New SILC Key Pair"),
1269 _("Create New SILC Key Pair"), NULL, fields, 1269 _("Create New SILC Key Pair"), NULL, fields,
1270 _("Generate Key Pair"), G_CALLBACK(silcpurple_create_keypair_cb), 1270 _("Generate Key Pair"), G_CALLBACK(silcpurple_create_keypair_cb),
1271 _("Cancel"), G_CALLBACK(silcpurple_create_keypair_cancel), 1271 _("Cancel"), G_CALLBACK(silcpurple_create_keypair_cancel),
1272 gc->account, NULL, NULL, gc); 1272 purple_connection_get_account(gc), NULL, NULL, gc);
1273 1273
1274 g_strfreev(u); 1274 g_strfreev(u);
1275 silc_free(hostname); 1275 silc_free(hostname);
1276 } 1276 }
1277 1277
1285 static void 1285 static void
1286 silcpurple_change_passwd(PurpleConnection *gc, const char *old, const char *new) 1286 silcpurple_change_passwd(PurpleConnection *gc, const char *old, const char *new)
1287 { 1287 {
1288 char prd[256]; 1288 char prd[256];
1289 g_snprintf(prd, sizeof(prd), "%s" G_DIR_SEPARATOR_S "private_key.pub", silcpurple_silcdir()); 1289 g_snprintf(prd, sizeof(prd), "%s" G_DIR_SEPARATOR_S "private_key.pub", silcpurple_silcdir());
1290 silc_change_private_key_passphrase(purple_account_get_string(gc->account, 1290 silc_change_private_key_passphrase(purple_account_get_string(purple_connection_get_account(gc),
1291 "private-key", 1291 "private-key",
1292 prd), old ? old : "", new ? new : ""); 1292 prd), old ? old : "", new ? new : "");
1293 } 1293 }
1294 1294
1295 static void 1295 static void
1546 { 1546 {
1547 PurpleConnection *gc; 1547 PurpleConnection *gc;
1548 PurpleConversation *convo = conv; 1548 PurpleConversation *convo = conv;
1549 int id = 0; 1549 int id = 0;
1550 1550
1551 gc = purple_conversation_get_gc(conv); 1551 gc = purple_conversation_get_connection(conv);
1552 1552
1553 if (gc == NULL) 1553 if (gc == NULL)
1554 return PURPLE_CMD_RET_FAILED; 1554 return PURPLE_CMD_RET_FAILED;
1555 1555
1556 if(args && args[0]) 1556 if(args && args[0])
1557 convo = purple_find_conversation_with_account(PURPLE_CONV_TYPE_CHAT, args[0], 1557 convo = purple_find_conversation_with_account(PURPLE_CONV_TYPE_CHAT, args[0],
1558 gc->account); 1558 purple_connection_get_account(gc));
1559 1559
1560 if (convo != NULL) 1560 if (convo != NULL)
1561 id = purple_conv_chat_get_id(PURPLE_CONV_CHAT(convo)); 1561 id = purple_conv_chat_get_id(PURPLE_CONV_CHAT(convo));
1562 1562
1563 if (id == 0) 1563 if (id == 0)
1575 PurpleConnection *gc; 1575 PurpleConnection *gc;
1576 int id = 0; 1576 int id = 0;
1577 char *buf, *tmp, *tmp2; 1577 char *buf, *tmp, *tmp2;
1578 const char *topic; 1578 const char *topic;
1579 1579
1580 gc = purple_conversation_get_gc(conv); 1580 gc = purple_conversation_get_connection(conv);
1581 id = purple_conv_chat_get_id(PURPLE_CONV_CHAT(conv)); 1581 id = purple_conv_chat_get_id(PURPLE_CONV_CHAT(conv));
1582 1582
1583 if (gc == NULL || id == 0) 1583 if (gc == NULL || id == 0)
1584 return PURPLE_CMD_RET_FAILED; 1584 return PURPLE_CMD_RET_FAILED;
1585 1585
1591 buf = g_strdup_printf(_("current topic is: %s"), tmp2); 1591 buf = g_strdup_printf(_("current topic is: %s"), tmp2);
1592 g_free(tmp); 1592 g_free(tmp);
1593 g_free(tmp2); 1593 g_free(tmp2);
1594 } else 1594 } else
1595 buf = g_strdup(_("No topic is set")); 1595 buf = g_strdup(_("No topic is set"));
1596 purple_conv_chat_write(PURPLE_CONV_CHAT(conv), gc->account->username, buf, 1596 purple_conv_chat_write(PURPLE_CONV_CHAT(conv), purple_account_get_username(purple_connection_get_account(gc)), buf,
1597 PURPLE_MESSAGE_SYSTEM|PURPLE_MESSAGE_NO_LOG, time(NULL)); 1597 PURPLE_MESSAGE_SYSTEM|PURPLE_MESSAGE_NO_LOG, time(NULL));
1598 g_free(buf); 1598 g_free(buf);
1599 1599
1600 } 1600 }
1601 1601
1621 1621
1622 g_hash_table_replace(comp, "channel", args[0]); 1622 g_hash_table_replace(comp, "channel", args[0]);
1623 if(args[1]) 1623 if(args[1])
1624 g_hash_table_replace(comp, "passphrase", args[1]); 1624 g_hash_table_replace(comp, "passphrase", args[1]);
1625 1625
1626 silcpurple_chat_join(purple_conversation_get_gc(conv), comp); 1626 silcpurple_chat_join(purple_conversation_get_connection(conv), comp);
1627 1627
1628 g_hash_table_destroy(comp); 1628 g_hash_table_destroy(comp);
1629 return PURPLE_CMD_RET_OK; 1629 return PURPLE_CMD_RET_OK;
1630 } 1630 }
1631 1631
1632 static PurpleCmdRet silcpurple_cmd_chat_list(PurpleConversation *conv, 1632 static PurpleCmdRet silcpurple_cmd_chat_list(PurpleConversation *conv,
1633 const char *cmd, char **args, char **error, void *data) 1633 const char *cmd, char **args, char **error, void *data)
1634 { 1634 {
1635 PurpleConnection *gc; 1635 PurpleConnection *gc;
1636 gc = purple_conversation_get_gc(conv); 1636 gc = purple_conversation_get_connection(conv);
1637 purple_roomlist_show_with_account(purple_connection_get_account(gc)); 1637 purple_roomlist_show_with_account(purple_connection_get_account(gc));
1638 return PURPLE_CMD_RET_OK; 1638 return PURPLE_CMD_RET_OK;
1639 } 1639 }
1640 1640
1641 static PurpleCmdRet silcpurple_cmd_whois(PurpleConversation *conv, 1641 static PurpleCmdRet silcpurple_cmd_whois(PurpleConversation *conv,
1642 const char *cmd, char **args, char **error, void *data) 1642 const char *cmd, char **args, char **error, void *data)
1643 { 1643 {
1644 PurpleConnection *gc; 1644 PurpleConnection *gc;
1645 1645
1646 gc = purple_conversation_get_gc(conv); 1646 gc = purple_conversation_get_connection(conv);
1647 1647
1648 if (gc == NULL) 1648 if (gc == NULL)
1649 return PURPLE_CMD_RET_FAILED; 1649 return PURPLE_CMD_RET_FAILED;
1650 1650
1651 silcpurple_get_info(gc, args[0]); 1651 silcpurple_get_info(gc, args[0]);
1657 const char *cmd, char **args, char **error, void *data) 1657 const char *cmd, char **args, char **error, void *data)
1658 { 1658 {
1659 int ret; 1659 int ret;
1660 PurpleConnection *gc; 1660 PurpleConnection *gc;
1661 1661
1662 gc = purple_conversation_get_gc(conv); 1662 gc = purple_conversation_get_connection(conv);
1663 1663
1664 if (gc == NULL) 1664 if (gc == NULL)
1665 return PURPLE_CMD_RET_FAILED; 1665 return PURPLE_CMD_RET_FAILED;
1666 1666
1667 ret = silcpurple_send_im(gc, args[0], args[1], PURPLE_MESSAGE_SEND); 1667 ret = silcpurple_send_im(gc, args[0], args[1], PURPLE_MESSAGE_SEND);
1683 if (!args || !args[0]) { 1683 if (!args || !args[0]) {
1684 *error = g_strdup(_("You must specify a nick")); 1684 *error = g_strdup(_("You must specify a nick"));
1685 return PURPLE_CMD_RET_FAILED; 1685 return PURPLE_CMD_RET_FAILED;
1686 } 1686 }
1687 1687
1688 gc = purple_conversation_get_gc(conv); 1688 gc = purple_conversation_get_connection(conv);
1689 1689
1690 if (gc == NULL) 1690 if (gc == NULL)
1691 return PURPLE_CMD_RET_FAILED; 1691 return PURPLE_CMD_RET_FAILED;
1692 1692
1693 account = purple_connection_get_account(gc); 1693 account = purple_connection_get_account(gc);
1711 { 1711 {
1712 PurpleConnection *gc; 1712 PurpleConnection *gc;
1713 SilcPurple sg; 1713 SilcPurple sg;
1714 char *tmp; 1714 char *tmp;
1715 1715
1716 gc = purple_conversation_get_gc(conv); 1716 gc = purple_conversation_get_connection(conv);
1717 1717
1718 if (gc == NULL) 1718 if (gc == NULL)
1719 return PURPLE_CMD_RET_FAILED; 1719 return PURPLE_CMD_RET_FAILED;
1720 1720
1721 sg = purple_connection_get_protocol_data(gc); 1721 sg = purple_connection_get_protocol_data(gc);
1740 const char *cmd, char **args, char **error, void *data) 1740 const char *cmd, char **args, char **error, void *data)
1741 { 1741 {
1742 PurpleConnection *gc; 1742 PurpleConnection *gc;
1743 SilcPurple sg; 1743 SilcPurple sg;
1744 1744
1745 gc = purple_conversation_get_gc(conv); 1745 gc = purple_conversation_get_connection(conv);
1746 1746
1747 if (gc == NULL) 1747 if (gc == NULL)
1748 return PURPLE_CMD_RET_FAILED; 1748 return PURPLE_CMD_RET_FAILED;
1749 1749
1750 sg = purple_connection_get_protocol_data(gc); 1750 sg = purple_connection_get_protocol_data(gc);
1765 SilcPurple sg; 1765 SilcPurple sg;
1766 SilcChannelEntry channel; 1766 SilcChannelEntry channel;
1767 char *silccmd, *silcargs, *msg, tmp[256]; 1767 char *silccmd, *silcargs, *msg, tmp[256];
1768 const char *chname; 1768 const char *chname;
1769 1769
1770 gc = purple_conversation_get_gc(conv); 1770 gc = purple_conversation_get_connection(conv);
1771 1771
1772 if (gc == NULL || !args || purple_connection_get_protocol_data(gc) == NULL) 1772 if (gc == NULL || !args || purple_connection_get_protocol_data(gc) == NULL)
1773 return PURPLE_CMD_RET_FAILED; 1773 return PURPLE_CMD_RET_FAILED;
1774 1774
1775 sg = purple_connection_get_protocol_data(gc); 1775 sg = purple_connection_get_protocol_data(gc);
1816 { 1816 {
1817 PurpleConnection *gc; 1817 PurpleConnection *gc;
1818 SilcPurple sg; 1818 SilcPurple sg;
1819 char *silccmd, *silcargs; 1819 char *silccmd, *silcargs;
1820 1820
1821 gc = purple_conversation_get_gc(conv); 1821 gc = purple_conversation_get_connection(conv);
1822 1822
1823 if (gc == NULL) 1823 if (gc == NULL)
1824 return PURPLE_CMD_RET_FAILED; 1824 return PURPLE_CMD_RET_FAILED;
1825 1825
1826 sg = purple_connection_get_protocol_data(gc); 1826 sg = purple_connection_get_protocol_data(gc);
1848 SilcPurple sg; 1848 SilcPurple sg;
1849 GHashTable *ui_info; 1849 GHashTable *ui_info;
1850 const char *ui_name = NULL, *ui_website = NULL; 1850 const char *ui_name = NULL, *ui_website = NULL;
1851 char *quit_msg; 1851 char *quit_msg;
1852 1852
1853 gc = purple_conversation_get_gc(conv); 1853 gc = purple_conversation_get_connection(conv);
1854 1854
1855 if (gc == NULL) 1855 if (gc == NULL)
1856 return PURPLE_CMD_RET_FAILED; 1856 return PURPLE_CMD_RET_FAILED;
1857 1857
1858 sg = purple_connection_get_protocol_data(gc); 1858 sg = purple_connection_get_protocol_data(gc);
1885 const char *cmd, char **args, char **error, void *data) 1885 const char *cmd, char **args, char **error, void *data)
1886 { 1886 {
1887 PurpleConnection *gc; 1887 PurpleConnection *gc;
1888 SilcPurple sg; 1888 SilcPurple sg;
1889 1889
1890 gc = purple_conversation_get_gc(conv); 1890 gc = purple_conversation_get_connection(conv);
1891 1891
1892 if (gc == NULL) 1892 if (gc == NULL)
1893 return PURPLE_CMD_RET_FAILED; 1893 return PURPLE_CMD_RET_FAILED;
1894 1894
1895 sg = purple_connection_get_protocol_data(gc); 1895 sg = purple_connection_get_protocol_data(gc);