Adds support for Gaim password to be used as the passphrase for the SILC
private key (used both for initial private key generation and for
reading the passphrase during signon)
 
Allows successful signon when connecting for the first time if key had
to be generated (it wasn't stat'ing the key file after creating it,
causing the ownership check to fail)
 
Replaces fprintf()'s with gaim_debug_{error,warning}()
 
Adds 1 translateable string "Change Password..." which is a duplicate
so this shouldn't break string freeze.
 

Index: src/protocols/silc/ops.c
===================================================================
RCS file: /cvsroot/gaim/gaim/src/protocols/silc/ops.c,v
retrieving revision 1.5
diff -u -p -r1.5 ops.c
--- src/protocols/silc/ops.c	23 May 2004 20:06:10 -0000	1.5
+++ src/protocols/silc/ops.c	26 May 2004 19:58:46 -0000
@@ -653,7 +653,7 @@ silc_notify(SilcClient client, SilcClien
 				/* Find buddy by nickname */
 				b = gaim_find_buddy(sg->account, client_entry->nickname);
 				if (!b) {
-					fprintf(stderr, "WATCH for %s, unknown buddy",
+					gaim_debug_warning("silc", "WATCH for %s, unknown buddy",
 						client_entry->nickname);
 					break;
 				}
Index: src/protocols/silc/silc.c
===================================================================
RCS file: /cvsroot/gaim/gaim/src/protocols/silc/silc.c,v
retrieving revision 1.10
diff -u -p -r1.10 silc.c
--- src/protocols/silc/silc.c	23 May 2004 20:06:10 -0000	1.10
+++ src/protocols/silc/silc.c	26 May 2004 19:58:46 -0000
@@ -278,8 +278,8 @@ silcgaim_login(GaimAccount *account)
 	/* Load SILC key pair */
 	if (!silc_load_key_pair(gaim_prefs_get_string("/plugins/prpl/silc/pubkey"),
 				gaim_prefs_get_string("/plugins/prpl/silc/privkey"),
-				"", &client->pkcs, &client->public_key,
-				&client->private_key)) {
+				(account->password == NULL) ? "" : account->password, &client->pkcs,
+				&client->public_key, &client->private_key)) {
 		gaim_connection_error(gc, ("Could not load SILC key pair"));
 		return;
 	}
@@ -729,6 +729,19 @@ silcgaim_view_motd(GaimPluginAction *act
 			      sg->motd, NULL, NULL);
 }
 
+static void
+silcgaim_change_pass(GaimPluginAction *action)
+{
+	GaimConnection *gc = (GaimConnection *) action->context;
+	gaim_account_request_change_password(gaim_connection_get_account(gc));
+}
+
+static void
+silcgaim_change_passwd(GaimConnection *gc, const char *old, const char *new)
+{
+	silc_change_private_key_passphrase(gaim_prefs_get_string("/plugins/prpl/silc/privkey"), old, new);
+}
+
 static GList *
 silcgaim_actions(GaimPlugin *plugin, gpointer context)
 {
@@ -750,6 +763,10 @@ silcgaim_actions(GaimPlugin *plugin, gpo
 			silcgaim_view_motd);
 	list = g_list_append(list, act);
 
+	act = gaim_plugin_action_new(_("Change Password..."),
+			silcgaim_change_pass);
+	list = g_list_append(list, act);
+
 	return list;
 }
 
@@ -973,7 +990,7 @@ static GaimPluginProtocolInfo prpl_info 
 	silcgaim_get_info,
 	silcgaim_set_away,
 	silcgaim_idle_set,
-	NULL,
+	silcgaim_change_passwd,
 	silcgaim_add_buddy,
 	silcgaim_add_buddies,
 	silcgaim_remove_buddy,
Index: src/protocols/silc/util.c
===================================================================
RCS file: /cvsroot/gaim/gaim/src/protocols/silc/util.c,v
retrieving revision 1.3
diff -u -p -r1.3 util.c
--- src/protocols/silc/util.c	23 May 2004 20:06:10 -0000	1.3
+++ src/protocols/silc/util.c	26 May 2004 19:58:46 -0000
@@ -76,7 +76,7 @@ gboolean silcgaim_check_silc_dir(GaimCon
 
 	pw = getpwuid(getuid());
 	if (!pw) {
-		fprintf(stderr, "silc: %s\n", strerror(errno));
+		gaim_debug_error("silc", "silc: %s\n", strerror(errno));
 		return FALSE;
 	}
 
@@ -96,22 +96,22 @@ gboolean silcgaim_check_silc_dir(GaimCon
 		if (errno == ENOENT) {
 			if (pw->pw_uid == geteuid()) {
 				if ((mkdir(filename, 0755)) == -1) {
-					fprintf(stderr, "Couldn't create `%s' directory\n", filename);
+					gaim_debug_error("silc", "Couldn't create '%s' directory\n", filename);
 					return FALSE;
 				}
 			} else {
-				fprintf(stderr, "Couldn't create `%s' directory due to a wrong uid!\n",
+				gaim_debug_error("silc", "Couldn't create '%s' directory due to a wrong uid!\n",
 					filename);
 				return FALSE;
 			}
 		} else {
-			fprintf(stderr, "%s\n", strerror(errno));
+			gaim_debug_error("silc", "Couldn't stat '%s' directory, error: %s\n", filename, strerror(errno));
 			return FALSE;
 		}
 	} else {
 		/* Check the owner of the dir */
 		if (st.st_uid != 0 && st.st_uid != pw->pw_uid) {
-			fprintf(stderr, "You don't seem to own `%s' directory\n",
+			gaim_debug_error("silc", "You don't seem to own '%s' directory\n",
 				filename);
 			return FALSE;
 		}
@@ -125,16 +125,17 @@ gboolean silcgaim_check_silc_dir(GaimCon
 		if (errno == ENOENT) {
 			if (pw->pw_uid == geteuid()) {
 				if ((mkdir(servfilename, 0755)) == -1) {
-					fprintf(stderr, "Couldn't create `%s' directory\n", servfilename);
+					gaim_debug_error("silc", "Couldn't create '%s' directory\n", servfilename);
 					return FALSE;
 				}
 			} else {
-				fprintf(stderr, "Couldn't create `%s' directory due to a wrong uid!\n",
+				gaim_debug_error("silc", "Couldn't create '%s' directory due to a wrong uid!\n",
 					servfilename);
 				return FALSE;
 			}
 		} else {
-			fprintf(stderr, "%s\n", strerror(errno));
+			gaim_debug_error("silc", "Couldn't stat '%s' directory, error: %s\n",
+							 servfilename, strerror(errno));
 			return FALSE;
 		}
 	}
@@ -147,16 +148,17 @@ gboolean silcgaim_check_silc_dir(GaimCon
 		if (errno == ENOENT) {
 			if (pw->pw_uid == geteuid()) {
 				if ((mkdir(clientfilename, 0755)) == -1) {
-					fprintf(stderr, "Couldn't create `%s' directory\n", clientfilename);
+					gaim_debug_error("silc", "Couldn't create '%s' directory\n", clientfilename);
 					return FALSE;
 				}
 			} else {
-				fprintf(stderr, "Couldn't create `%s' directory due to a wrong uid!\n",
+				gaim_debug_error("silc", "Couldn't create '%s' directory due to a wrong uid!\n",
 					clientfilename);
 				return FALSE;
 			}
 		} else {
-			fprintf(stderr, "%s\n", strerror(errno));
+			gaim_debug_error("silc", "Couldn't stat '%s' directory, error: %s\n",
+							 clientfilename, strerror(errno));
 			return FALSE;
 		}
 	}
@@ -169,16 +171,17 @@ gboolean silcgaim_check_silc_dir(GaimCon
 		if (errno == ENOENT) {
 			if (pw->pw_uid == geteuid()) {
 				if ((mkdir(friendsfilename, 0755)) == -1) {
-					fprintf(stderr, "Couldn't create `%s' directory\n", friendsfilename);
+					gaim_debug_error("silc", "Couldn't create '%s' directory\n", friendsfilename);
 					return FALSE;
 				}
 			} else {
-				fprintf(stderr, "Couldn't create `%s' directory due to a wrong uid!\n",
+				gaim_debug_error("silc", "Couldn't create '%s' directory due to a wrong uid!\n",
 					friendsfilename);
 				return FALSE;
 			}
 		} else {
-			fprintf(stderr, "%s\n", strerror(errno));
+			gaim_debug_error("silc", "Couldn't stat '%s' directory, error: %s\n",
+							 friendsfilename, strerror(errno));
 			return FALSE;
 		}
 	}
@@ -198,16 +201,19 @@ gboolean silcgaim_check_silc_dir(GaimCon
 			silc_create_key_pair(SILCGAIM_DEF_PKCS,
 					     SILCGAIM_DEF_PKCS_LEN,
 					     file_public_key, file_private_key, NULL,
-					     "", NULL, NULL, NULL, FALSE);
+					     (gc->account->password == NULL) ? "" : gc->account->password,
+						 NULL, NULL, NULL, FALSE);
+			stat(file_public_key, &st);
 		} else {
-			fprintf(stderr, "%s\n", strerror(errno));
+			gaim_debug_error("silc", "Couldn't stat '%s' public key, error: %s\n",
+							 file_public_key, strerror(errno));
 			return FALSE;
 		}
 	}
 
 	/* Check the owner of the public key */
 	if (st.st_uid != 0 && st.st_uid != pw->pw_uid) {
-		fprintf(stderr, "You don't seem to own your public key!?\n");
+		gaim_debug_error("silc", "You don't seem to own your public key!?\n");
 		return FALSE;
 	}
 
@@ -218,30 +224,33 @@ gboolean silcgaim_check_silc_dir(GaimCon
 			silc_create_key_pair(SILCGAIM_DEF_PKCS,
 					     SILCGAIM_DEF_PKCS_LEN,
 					     file_public_key, file_private_key, NULL,
-					     "", NULL, NULL, NULL, FALSE);
+					     (gc->account->password == NULL) ? "" : gc->account->password,
+						 NULL, NULL, NULL, FALSE);
+			stat(file_private_key, &st);
 		} else {
-			fprintf(stderr, "%s\n", strerror(errno));
+			gaim_debug_error("silc", "Couldn't stat '%s' private key, error: %s\n",
+							 file_private_key, strerror(errno));
 			return FALSE;
 		}
 	}
 
 	/* Check the owner of the private key */
 	if (st.st_uid != 0 && st.st_uid != pw->pw_uid) {
-		fprintf(stderr, "You don't seem to own your private key!?\n");
+		gaim_debug_error("silc", "You don't seem to own your private key!?\n");
 		return FALSE;
 	}
 
 	/* Check the permissions for the private key */
 	if ((st.st_mode & 0777) != 0600) {
-		fprintf(stderr, "Wrong permissions in your private key file `%s'!\n"
+		gaim_debug_warning("silc", "Wrong permissions in your private key file `%s'!\n"
 			"Trying to change them ... ", file_private_key);
 		if ((chmod(file_private_key, 0600)) == -1) {
-			fprintf(stderr,
+			gaim_debug_error("silc",
 				"Failed to change permissions for private key file!\n"
 				"Permissions for your private key file must be 0600.\n");
 			return FALSE;
 		}
-		fprintf(stderr, "Done.\n\n");
+		gaim_debug_warning("silc", "Done.\n\n");
 	}
 
 	return TRUE;