pidgin: 0a066500: Prompt for silc private key passphrase i...
nosnilmot at pidgin.im
nosnilmot at pidgin.im
Wed Apr 23 12:40:51 EDT 2008
-----------------------------------------------------------------
Revision: 0a066500ab718cb86302e0e4dbc30c2bb40ac366
Ancestor: 4a85606739229eebc3d3a91da0d5eaf001e45966
Author: nosnilmot at pidgin.im
Date: 2008-04-23T16:37:28
Branch: im.pidgin.pidgin
URL: http://d.pidgin.im/viewmtn/revision/info/0a066500ab718cb86302e0e4dbc30c2bb40ac366
Modified files:
libpurple/protocols/silc/silc.c
ChangeLog:
Prompt for silc private key passphrase if it is not saved for the account
and we are unable to open the private key without it
-------------- next part --------------
============================================================
--- libpurple/protocols/silc/silc.c 0fcc777a1dd4ee0f6d277b559092cadb433d01fc
+++ libpurple/protocols/silc/silc.c c659c8776178b6d9861c147bd29017d1484161d9
@@ -433,23 +433,60 @@ silcpurple_login_connected(gpointer data
silcpurple_stream_created, gc);
}
-static void silcpurple_running(SilcClient client, void *context)
+static void silcpurple_continue_running(SilcPurple sg)
{
- SilcPurple sg = context;
PurpleConnection *gc = sg->gc;
PurpleAccount *account = purple_connection_get_account(gc);
+
+ /* Connect to the SILC server */
+ if (purple_proxy_connect(gc, account,
+ purple_account_get_string(account, "server",
+ "silc.silcnet.org"),
+ purple_account_get_int(account, "port", 706),
+ silcpurple_login_connected, gc) == NULL)
+ {
+ purple_connection_error_reason(gc, PURPLE_CONNECTION_ERROR_NETWORK_ERROR,
+ _("Unable to create connection"));
+ gc->proto_data = NULL;
+ silc_free(sg);
+ return;
+ }
+}
+
+static void silcpurple_got_password_cb(PurpleConnection *gc, PurpleRequestFields *fields)
+{
+ SilcPurple sg = (SilcPurple)gc->proto_data;
+ PurpleAccount *account = purple_connection_get_account(gc);
char pkd[256], prd[256];
+ const char *password;
+ gboolean remember;
+ /* The password prompt dialog doesn't get disposed if the account disconnects */
+ if (!PURPLE_CONNECTION_IS_VALID(gc))
+ return;
- /* Progress */
- purple_connection_update_progress(gc, _("Connecting to SILC Server"), 1, 5);
+ password = purple_request_fields_get_string(fields, "password");
+ remember = purple_request_fields_get_bool(fields, "remember");
+ if (!password || !*password)
+ {
+ purple_notify_error(gc, NULL, _("Password is required to sign on."), NULL);
+ gc->proto_data = NULL;
+ silc_free(sg);
+ return;
+ }
+
+ if (remember)
+ purple_account_set_remember_password(account, TRUE);
+
+ purple_account_set_password(account, password);
+
/* Load SILC key pair */
g_snprintf(pkd, sizeof(pkd), "%s" G_DIR_SEPARATOR_S "public_key.pub", silcpurple_silcdir());
g_snprintf(prd, sizeof(prd), "%s" G_DIR_SEPARATOR_S "private_key.prv", silcpurple_silcdir());
if (!silc_load_key_pair((char *)purple_account_get_string(account, "public-key", pkd),
(char *)purple_account_get_string(account, "private-key", prd),
- (gc->password == NULL) ? "" : gc->password,
+ password,
&sg->public_key, &sg->private_key)) {
purple_connection_error_reason(gc, PURPLE_CONNECTION_ERROR_OTHER_ERROR,
_("Could not load SILC key pair"));
@@ -457,20 +494,52 @@ static void silcpurple_running(SilcClien
silc_free(sg);
return;
}
+ silcpurple_continue_running(sg);
+}
- /* Connect to the SILC server */
- if (purple_proxy_connect(gc, account,
- purple_account_get_string(account, "server",
- "silc.silcnet.org"),
- purple_account_get_int(account, "port", 706),
- silcpurple_login_connected, gc) == NULL)
- {
- purple_connection_error_reason(gc, PURPLE_CONNECTION_ERROR_NETWORK_ERROR,
- _("Unable to create connection"));
+static void silcpurple_no_password_cb(PurpleConnection *gc, PurpleRequestFields *fields)
+{
+ SilcPurple sg;
+ /* The password prompt dialog doesn't get disposed if the account disconnects */
+ if (!PURPLE_CONNECTION_IS_VALID(gc))
+ return;
+ sg = gc->proto_data;
+ purple_connection_error_reason(gc, PURPLE_CONNECTION_ERROR_OTHER_ERROR,
+ _("Could not load SILC key pair"));
+ gc->proto_data = NULL;
+ silc_free(sg);
+}
+
+static void silcpurple_running(SilcClient client, void *context)
+{
+ SilcPurple sg = context;
+ PurpleConnection *gc = sg->gc;
+ PurpleAccount *account = purple_connection_get_account(gc);
+ char pkd[256], prd[256];
+
+
+ /* Progress */
+ purple_connection_update_progress(gc, _("Connecting to SILC Server"), 1, 5);
+
+ /* Load SILC key pair */
+ g_snprintf(pkd, sizeof(pkd), "%s" G_DIR_SEPARATOR_S "public_key.pub", silcpurple_silcdir());
+ g_snprintf(prd, sizeof(prd), "%s" G_DIR_SEPARATOR_S "private_key.prv", silcpurple_silcdir());
+ if (!silc_load_key_pair((char *)purple_account_get_string(account, "public-key", pkd),
+ (char *)purple_account_get_string(account, "private-key", prd),
+ (gc->password == NULL) ? "" : gc->password,
+ &sg->public_key, &sg->private_key)) {
+ if (!purple_account_get_password(account)) {
+ purple_account_request_password(account, G_CALLBACK(silcpurple_got_password_cb),
+ G_CALLBACK(silcpurple_no_password_cb), gc);
+ return;
+ }
+ purple_connection_error_reason(gc, PURPLE_CONNECTION_ERROR_OTHER_ERROR,
+ _("Could not load SILC key pair"));
gc->proto_data = NULL;
silc_free(sg);
return;
}
+ silcpurple_continue_running(sg);
}
static void
More information about the Commits
mailing list