aboutsummaryrefslogtreecommitdiffstats
path: root/mail
diff options
context:
space:
mode:
authorJeffrey Stedfast <fejj@ximian.com>2001-04-21 03:59:24 +0800
committerJeffrey Stedfast <fejj@src.gnome.org>2001-04-21 03:59:24 +0800
commitc36302e415de5eabc850fac77ff570a40d8e129e (patch)
tree7595ad8006b3e402773307261f76b631f447de28 /mail
parentcbdc25be7a8e6ba1e2cc483fa1b6ba477e00b0ac (diff)
downloadgsoc2013-evolution-c36302e415de5eabc850fac77ff570a40d8e129e.tar
gsoc2013-evolution-c36302e415de5eabc850fac77ff570a40d8e129e.tar.gz
gsoc2013-evolution-c36302e415de5eabc850fac77ff570a40d8e129e.tar.bz2
gsoc2013-evolution-c36302e415de5eabc850fac77ff570a40d8e129e.tar.lz
gsoc2013-evolution-c36302e415de5eabc850fac77ff570a40d8e129e.tar.xz
gsoc2013-evolution-c36302e415de5eabc850fac77ff570a40d8e129e.tar.zst
gsoc2013-evolution-c36302e415de5eabc850fac77ff570a40d8e129e.zip
Use a CamelPgpType. (mail_config_get_pgp_type): Return a CamelPgpType.
2001-04-20 Jeffrey Stedfast <fejj@ximian.com> * mail-config.c (mail_config_set_pgp_type): Use a CamelPgpType. (mail_config_get_pgp_type): Return a CamelPgpType. (auto_detect_pgp_variables): auto-detect the user's pgp settings. svn path=/trunk/; revision=9479
Diffstat (limited to 'mail')
-rw-r--r--mail/ChangeLog6
-rw-r--r--mail/mail-config.c86
-rw-r--r--mail/mail-config.h4
3 files changed, 90 insertions, 6 deletions
diff --git a/mail/ChangeLog b/mail/ChangeLog
index 804838f825..e102cbeff6 100644
--- a/mail/ChangeLog
+++ b/mail/ChangeLog
@@ -1,3 +1,9 @@
+2001-04-20 Jeffrey Stedfast <fejj@ximian.com>
+
+ * mail-config.c (mail_config_set_pgp_type): Use a CamelPgpType.
+ (mail_config_get_pgp_type): Return a CamelPgpType.
+ (auto_detect_pgp_variables): auto-detect the user's pgp settings.
+
2001-04-20 Dan Winship <danw@ximian.com>
* mail-format.c (handle_text_plain): Fix a dumb thinko in my 04-11
diff --git a/mail/mail-config.c b/mail/mail-config.c
index 50b0e49874..52f8e5306c 100644
--- a/mail/mail-config.c
+++ b/mail/mail-config.c
@@ -58,7 +58,7 @@ typedef struct {
GSList *news;
char *pgp_path;
- int pgp_type;
+ CamelPgpType pgp_type;
} MailConfig;
static const char GCONFPATH[] = "/apps/Evolution/Mail";
@@ -424,7 +424,7 @@ config_read (void)
evolution_dir);
config->pgp_type = gnome_config_get_int_with_default (str, &def);
if (def)
- config->pgp_type = 0;
+ config->pgp_type = CAMEL_PGP_TYPE_NONE;
g_free (str);
gnome_config_sync ();
@@ -731,14 +731,89 @@ mail_config_set_prompt_empty_subject (gboolean value)
config->prompt_empty_subject = value;
}
-gint
+
+struct {
+ char *bin;
+ CamelPgpType type;
+} binaries[] = {
+ { "gpg", CAMEL_PGP_TYPE_GPG },
+ { "pgpv", CAMEL_PGP_TYPE_PGP5 },
+ { "pgp", CAMEL_PGP_TYPE_PGP2 },
+ { NULL, CAMEL_PGP_TYPE_NONE }
+};
+
+/* FIXME: what about PGP 6.x? And I assume we want to "prefer" GnuPG
+ over the other, which is done now, but after that do we have a
+ order-of-preference for the rest? */
+static void
+auto_detect_pgp_variables (void)
+{
+ CamelPgpType type = CAMEL_PGP_TYPE_NONE;
+ const char *PATH, *path;
+ char *pgp = NULL;
+
+ PATH = getenv ("PATH");
+
+ path = PATH;
+ while (path && *path && !type) {
+ const char *pend = strchr (path, ':');
+ char *dirname;
+ int i;
+
+ if (pend) {
+ /* don't even think of using "." */
+ if (!strncmp (path, ".", pend - path)) {
+ path = pend + 1;
+ continue;
+ }
+
+ dirname = g_strndup (path, pend - path);
+ path = pend + 1;
+ } else {
+ /* don't even think of using "." */
+ if (!strcmp (path, "."))
+ break;
+
+ dirname = g_strdup (path);
+ path = NULL;
+ }
+
+ for (i = 0; binaries[i].bin; i++) {
+ struct stat st;
+
+ pgp = g_strdup_printf ("%s/%s", dirname, binaries[i].bin);
+ /* make sure the file exists *and* is executable? */
+ if (stat (pgp, &st) != -1 && st.st_mode & (S_IXOTH | S_IXGRP | S_IXUSR)) {
+ type = binaries[i].type;
+ break;
+ }
+
+ g_free (pgp);
+ pgp = NULL;
+ }
+
+ g_free (dirname);
+ }
+
+ if (pgp && type) {
+ mail_config_set_pgp_path (pgp);
+ mail_config_set_pgp_type (type);
+ }
+
+ g_free (pgp);
+}
+
+CamelPgpType
mail_config_get_pgp_type (void)
{
+ if (!config->pgp_path || !config->pgp_type)
+ auto_detect_pgp_variables ();
+
return config->pgp_type;
}
void
-mail_config_set_pgp_type (gint pgp_type)
+mail_config_set_pgp_type (CamelPgpType pgp_type)
{
config->pgp_type = pgp_type;
}
@@ -746,6 +821,9 @@ mail_config_set_pgp_type (gint pgp_type)
const char *
mail_config_get_pgp_path (void)
{
+ if (!config->pgp_path || !config->pgp_type)
+ auto_detect_pgp_variables ();
+
return config->pgp_path;
}
diff --git a/mail/mail-config.h b/mail/mail-config.h
index 6203052770..10c403389f 100644
--- a/mail/mail-config.h
+++ b/mail/mail-config.h
@@ -109,8 +109,8 @@ void mail_config_set_mark_as_seen_timeout (gint timeout);
gboolean mail_config_get_prompt_empty_subject (void);
void mail_config_set_prompt_empty_subject (gboolean value);
-gint mail_config_get_pgp_type (void);
-void mail_config_set_pgp_type (gint pgp_type);
+CamelPgpType mail_config_get_pgp_type (void);
+void mail_config_set_pgp_type (CamelPgpType pgp_type);
const char *mail_config_get_pgp_path (void);
void mail_config_set_pgp_path (const char *pgp_path);