Mercurial > pidgin
comparison src/protocols/silc/silc.c @ 10825:cb625efd1071
[gaim-migrate @ 12490]
Multiple account support for SILC in HEAD too
committer: Tailor Script <tailor@pidgin.im>
author | Stu Tomlinson <stu@nosnilmot.com> |
---|---|
date | Fri, 15 Apr 2005 01:58:22 +0000 |
parents | 0edc30641f4b |
children | 3e43c132f151 |
comparison
equal
deleted
inserted
replaced
10824:8d52201620d0 | 10825:cb625efd1071 |
---|---|
2 | 2 |
3 silcgaim.c | 3 silcgaim.c |
4 | 4 |
5 Author: Pekka Riikonen <priikone@silcnet.org> | 5 Author: Pekka Riikonen <priikone@silcnet.org> |
6 | 6 |
7 Copyright (C) 2004 Pekka Riikonen | 7 Copyright (C) 2004 - 2005 Pekka Riikonen |
8 | 8 |
9 This program is free software; you can redistribute it and/or modify | 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 | 10 it under the terms of the GNU General Public License as published by |
11 the Free Software Foundation; version 2 of the License. | 11 the Free Software Foundation; version 2 of the License. |
12 | 12 |
258 { | 258 { |
259 SilcGaim sg; | 259 SilcGaim sg; |
260 SilcClient client; | 260 SilcClient client; |
261 SilcClientParams params; | 261 SilcClientParams params; |
262 GaimConnection *gc; | 262 GaimConnection *gc; |
263 char pkd[256], prd[256]; | |
263 | 264 |
264 gc = account->gc; | 265 gc = account->gc; |
265 if (!gc) | 266 if (!gc) |
266 return; | 267 return; |
267 gc->proto_data = NULL; | 268 gc->proto_data = NULL; |
279 return; | 280 return; |
280 } | 281 } |
281 | 282 |
282 /* Get username, real name and local hostname for SILC library */ | 283 /* Get username, real name and local hostname for SILC library */ |
283 if (gaim_account_get_username(account)) { | 284 if (gaim_account_get_username(account)) { |
284 client->username = strdup(gaim_account_get_username(account)); | 285 const char *u = gaim_account_get_username(account); |
286 char **up = g_strsplit(u, "@", 2); | |
287 client->username = strdup(up[0]); | |
288 g_strfreev(up); | |
285 } else { | 289 } else { |
286 client->username = silc_get_username(); | 290 client->username = silc_get_username(); |
287 gaim_account_set_username(account, client->username); | 291 gaim_account_set_username(account, client->username); |
288 } | 292 } |
289 if (gaim_account_get_user_info(account)) { | 293 if (gaim_account_get_user_info(account)) { |
310 | 314 |
311 /* Progress */ | 315 /* Progress */ |
312 gaim_connection_update_progress(gc, _("Connecting to SILC Server"), 1, 5); | 316 gaim_connection_update_progress(gc, _("Connecting to SILC Server"), 1, 5); |
313 | 317 |
314 /* Load SILC key pair */ | 318 /* Load SILC key pair */ |
315 if (!silc_load_key_pair(gaim_prefs_get_string("/plugins/prpl/silc/pubkey"), | 319 g_snprintf(pkd, sizeof(prd), "%s" G_DIR_SEPARATOR_S "public_key.pub", silcgaim_silcdir()); |
316 gaim_prefs_get_string("/plugins/prpl/silc/privkey"), | 320 g_snprintf(prd, sizeof(prd), "%s" G_DIR_SEPARATOR_S "private_key.pub", silcgaim_silcdir()); |
321 if (!silc_load_key_pair((char *)gaim_account_get_string(account, "public-key", prd), | |
322 (char *)gaim_account_get_string(account, "private-key", prd), | |
317 (gc->password == NULL) ? "" : gc->password, &client->pkcs, | 323 (gc->password == NULL) ? "" : gc->password, &client->pkcs, |
318 &client->public_key, &client->private_key)) { | 324 &client->public_key, &client->private_key)) { |
319 gaim_connection_error(gc, ("Could not load SILC key pair")); | 325 gaim_connection_error(gc, ("Could not load SILC key pair")); |
320 return; | 326 return; |
321 } | 327 } |
769 } | 775 } |
770 | 776 |
771 static void | 777 static void |
772 silcgaim_change_passwd(GaimConnection *gc, const char *old, const char *new) | 778 silcgaim_change_passwd(GaimConnection *gc, const char *old, const char *new) |
773 { | 779 { |
774 silc_change_private_key_passphrase(gaim_prefs_get_string("/plugins/prpl/silc/privkey"), old, new); | 780 char prd[256]; |
781 g_snprintf(prd, sizeof(prd), "%s" G_DIR_SEPARATOR_S "private_key.pub", silcgaim_silcdir()); | |
782 silc_change_private_key_passphrase(gaim_account_get_string(gc->account, | |
783 "private-key", | |
784 prd), old, new); | |
775 } | 785 } |
776 | 786 |
777 static void | 787 static void |
778 silcgaim_show_set_info(GaimPluginAction *action) | 788 silcgaim_show_set_info(GaimPluginAction *action) |
779 { | 789 { |
1471 ppref = gaim_plugin_pref_new_with_name_and_label( | 1481 ppref = gaim_plugin_pref_new_with_name_and_label( |
1472 "/plugins/prpl/silc/verify_chat", | 1482 "/plugins/prpl/silc/verify_chat", |
1473 _("Verify all channel message signatures")); | 1483 _("Verify all channel message signatures")); |
1474 gaim_plugin_pref_frame_add(frame, ppref); | 1484 gaim_plugin_pref_frame_add(frame, ppref); |
1475 | 1485 |
1476 ppref = gaim_plugin_pref_new_with_label(_("Default SILC Key Pair")); | |
1477 gaim_plugin_pref_frame_add(frame, ppref); | |
1478 | |
1479 ppref = gaim_plugin_pref_new_with_name_and_label( | |
1480 "/plugins/prpl/silc/pubkey", | |
1481 _("SILC Public Key")); | |
1482 gaim_plugin_pref_frame_add(frame, ppref); | |
1483 | |
1484 ppref = gaim_plugin_pref_new_with_name_and_label( | |
1485 "/plugins/prpl/silc/privkey", | |
1486 _("SILC Private Key")); | |
1487 gaim_plugin_pref_frame_add(frame, ppref); | |
1488 | |
1489 return frame; | 1486 return frame; |
1490 } | 1487 } |
1491 | 1488 |
1492 static GaimPluginUiInfo prefs_info = | 1489 static GaimPluginUiInfo prefs_info = |
1493 { | 1490 { |
1590 | 1587 |
1591 static void | 1588 static void |
1592 init_plugin(GaimPlugin *plugin) | 1589 init_plugin(GaimPlugin *plugin) |
1593 { | 1590 { |
1594 GaimAccountOption *option; | 1591 GaimAccountOption *option; |
1592 GaimAccountUserSplit *split; | |
1595 char tmp[256]; | 1593 char tmp[256]; |
1596 | 1594 |
1597 silc_plugin = plugin; | 1595 silc_plugin = plugin; |
1596 | |
1597 split = gaim_account_user_split_new(_("Network"), "silcnet.org", '@'); | |
1598 prpl_info.user_splits = g_list_append(prpl_info.user_splits, split); | |
1598 | 1599 |
1599 /* Account options */ | 1600 /* Account options */ |
1600 option = gaim_account_option_string_new(_("Connect server"), | 1601 option = gaim_account_option_string_new(_("Connect server"), |
1601 "server", | 1602 "server", |
1602 "silc.silcnet.org"); | 1603 "silc.silcnet.org"); |
1603 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); | 1604 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); |
1604 option = gaim_account_option_int_new(_("Port"), "port", 706); | 1605 option = gaim_account_option_int_new(_("Port"), "port", 706); |
1605 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); | 1606 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); |
1606 | 1607 g_snprintf(tmp, sizeof(tmp), "%s" G_DIR_SEPARATOR_S "public_key.pub", silcgaim_silcdir()); |
1608 option = gaim_account_option_string_new(_("Public Key file"), | |
1609 "public-key", tmp); | |
1610 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); | |
1611 g_snprintf(tmp, sizeof(tmp), "%s" G_DIR_SEPARATOR_S "private_key.prv", silcgaim_silcdir()); | |
1612 option = gaim_account_option_string_new(_("Private Key file"), | |
1613 "private-key", tmp); | |
1614 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); | |
1607 option = gaim_account_option_bool_new(_("Public key authentication"), | 1615 option = gaim_account_option_bool_new(_("Public key authentication"), |
1608 "pubkey-auth", FALSE); | 1616 "pubkey-auth", FALSE); |
1609 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); | 1617 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); |
1610 #if 0 /* XXX Public key auth interface with explicit key pair is | |
1611 broken in SILC Toolkit */ | |
1612 g_snprintf(tmp, sizeof(tmp), "%s" G_DIR_SEPARATOR_S "public_key.pub", silcgaim_silcdir()); | |
1613 option = gaim_account_option_string_new(_("Public Key File"), | |
1614 "public-key", tmp); | |
1615 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); | |
1616 g_snprintf(tmp, sizeof(tmp), "%s" G_DIR_SEPARATOR_S "private_key.prv", silcgaim_silcdir()); | |
1617 option = gaim_account_option_string_new(_("Private Key File"), | |
1618 "public-key", tmp); | |
1619 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); | |
1620 #endif | |
1621 | 1618 |
1622 option = gaim_account_option_bool_new(_("Reject watching by other users"), | 1619 option = gaim_account_option_bool_new(_("Reject watching by other users"), |
1623 "reject-watch", FALSE); | 1620 "reject-watch", FALSE); |
1624 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); | 1621 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); |
1625 option = gaim_account_option_bool_new(_("Block invites"), | 1622 option = gaim_account_option_bool_new(_("Block invites"), |
1636 gaim_prefs_add_none("/plugins/prpl/silc"); | 1633 gaim_prefs_add_none("/plugins/prpl/silc"); |
1637 gaim_prefs_add_bool("/plugins/prpl/silc/sign_im", FALSE); | 1634 gaim_prefs_add_bool("/plugins/prpl/silc/sign_im", FALSE); |
1638 gaim_prefs_add_bool("/plugins/prpl/silc/verify_im", FALSE); | 1635 gaim_prefs_add_bool("/plugins/prpl/silc/verify_im", FALSE); |
1639 gaim_prefs_add_bool("/plugins/prpl/silc/sign_chat", FALSE); | 1636 gaim_prefs_add_bool("/plugins/prpl/silc/sign_chat", FALSE); |
1640 gaim_prefs_add_bool("/plugins/prpl/silc/verify_chat", FALSE); | 1637 gaim_prefs_add_bool("/plugins/prpl/silc/verify_chat", FALSE); |
1641 g_snprintf(tmp, sizeof(tmp), "%s" G_DIR_SEPARATOR_S "public_key.pub", silcgaim_silcdir()); | |
1642 gaim_prefs_add_string("/plugins/prpl/silc/pubkey", tmp); | |
1643 g_snprintf(tmp, sizeof(tmp), "%s" G_DIR_SEPARATOR_S "private_key.prv", silcgaim_silcdir()); | |
1644 gaim_prefs_add_string("/plugins/prpl/silc/privkey", tmp); | |
1645 gaim_prefs_add_string("/plugins/prpl/silc/vcard", ""); | 1638 gaim_prefs_add_string("/plugins/prpl/silc/vcard", ""); |
1646 | 1639 |
1647 silcgaim_register_commands(); | 1640 silcgaim_register_commands(); |
1648 | 1641 |
1649 #ifdef _WIN32 | 1642 #ifdef _WIN32 |