aboutsummaryrefslogtreecommitdiffstats
path: root/mail/session.c
diff options
context:
space:
mode:
authorDan Winship <danw@src.gnome.org>2000-08-02 10:56:48 +0800
committerDan Winship <danw@src.gnome.org>2000-08-02 10:56:48 +0800
commit324b1e8675ed32dcdc051a2fd916158bd02a9893 (patch)
tree341c0f634e335e1deba13131ffaac4545f6c43e3 /mail/session.c
parentfad59bb3a344526f343b8e28a8d28059e81a42a9 (diff)
downloadgsoc2013-evolution-324b1e8675ed32dcdc051a2fd916158bd02a9893.tar
gsoc2013-evolution-324b1e8675ed32dcdc051a2fd916158bd02a9893.tar.gz
gsoc2013-evolution-324b1e8675ed32dcdc051a2fd916158bd02a9893.tar.bz2
gsoc2013-evolution-324b1e8675ed32dcdc051a2fd916158bd02a9893.tar.lz
gsoc2013-evolution-324b1e8675ed32dcdc051a2fd916158bd02a9893.tar.xz
gsoc2013-evolution-324b1e8675ed32dcdc051a2fd916158bd02a9893.tar.zst
gsoc2013-evolution-324b1e8675ed32dcdc051a2fd916158bd02a9893.zip
New code to spawn off GPG/PGP to do stuff. Currently only deals with
* mail-crypto.c: New code to spawn off GPG/PGP to do stuff. Currently only deals with decryption. From Nathan Thompson-Amato <ndt@jps.net>, with bunches of changes from me. * session.c (mail_request_dialog): Expose the password dialog to the rest of the app (for use by the GPG/PGP code). * mail-format.c (handle_text_plain): Handle special inline data types. (Currently uuencoding, BinHex, and PGP encryption.) This is not the best way to deal with it, but it works for now. (try_inline_pgp): Convert an inline PGP-encrypted message into a multipart/encrypted part. (try_inline_binhex): Convert an inline BinHex attachment into an application/mac-binhex40 part (which we currently don't deal with...) (try_uudecoding): Convert a uuencoded attachment to an application/octet-stream part. (handle_multipart_encrypted): Deal with RFC2015 MIME-encoded PGP encrypted messages. (From ndt.) * mail-display.c (mail_text_write, mail_error_write): New utility functions. * Makefile.am (evolution_mail_SOURCES): add mail-crypto.c svn path=/trunk/; revision=4466
Diffstat (limited to 'mail/session.c')
-rw-r--r--mail/session.c71
1 files changed, 38 insertions, 33 deletions
diff --git a/mail/session.c b/mail/session.c
index 53ec9370db..7eaefd390c 100644
--- a/mail/session.c
+++ b/mail/session.c
@@ -37,15 +37,44 @@ request_callback (gchar *string, gpointer data)
}
#endif
-static char *
-evolution_auth_callback (CamelAuthCallbackMode mode, char *data,
- gboolean secret, CamelService *service, char *item,
- CamelException *ex)
+char *
+mail_request_dialog (const char *prompt, gboolean secret, const char *key)
{
#ifndef ASYNC_AUTH_CALLBACK
GtkWidget *dialog;
#endif
+ char *ans;
+
+ if (!passwords)
+ passwords = g_hash_table_new (g_str_hash, g_str_equal);
+
+ ans = g_hash_table_lookup (passwords, key);
+ if (ans)
+ return g_strdup (ans);
+
+#ifndef ASYNC_AUTH_CALLBACK
+ /* XXX parent window? */
+ dialog = gnome_request_dialog (secret, prompt, NULL, 0,
+ request_callback, &ans, NULL);
+ if (!dialog)
+ return NULL;
+ if (gnome_dialog_run_and_close (GNOME_DIALOG (dialog)) == -1 ||
+ ans == NULL)
+ return NULL;
+#else
+ if (!mail_op_get_password (data, secret, &ans))
+ return NULL;
+#endif
+
+ g_hash_table_insert (passwords, g_strdup (key), g_strdup (ans));
+ return ans;
+}
+
+static char *
+auth_callback (CamelAuthCallbackMode mode, char *data, gboolean secret,
+ CamelService *service, char *item, CamelException *ex)
+{
char *key, *ans;
if (!passwords)
@@ -75,38 +104,14 @@ evolution_auth_callback (CamelAuthCallbackMode mode, char *data,
return NULL;
}
- ans = g_hash_table_lookup (passwords, key);
- if (ans) {
- g_free (key);
- return g_strdup (ans);
- }
+ ans = mail_request_dialog (data, secret, key);
+ g_free (key);
-#ifndef ASYNC_AUTH_CALLBACK
- /* XXX parent window? */
- dialog = gnome_request_dialog (secret, data, NULL, 0,
- request_callback, &ans, NULL);
- if (!dialog) {
- camel_exception_set (ex, CAMEL_EXCEPTION_SYSTEM,
- "Could not create dialog box.");
- g_free (key);
- return NULL;
- }
- if (gnome_dialog_run_and_close (GNOME_DIALOG (dialog)) == -1 ||
- ans == NULL) {
+ if (!ans) {
camel_exception_set (ex, CAMEL_EXCEPTION_USER_CANCEL,
- "User cancelled query.");
- g_free (key);
- return NULL;
+ "User canceled operation.");
}
-#else
- if( mail_op_get_password( data, secret, &ans ) == FALSE ) {
- camel_exception_set( ex, CAMEL_EXCEPTION_USER_CANCEL, ans );
- g_free( key );
- return NULL;
- }
-#endif
- g_hash_table_insert (passwords, key, g_strdup (ans));
return ans;
}
@@ -116,7 +121,7 @@ session_init (void)
e_setup_base_dir ();
camel_init ();
- session = camel_session_new (evolution_auth_callback);
+ session = camel_session_new (auth_callback);
}
static gboolean