aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--mail/ChangeLog11
-rw-r--r--mail/mail-mt.c53
-rw-r--r--mail/mail-mt.h3
-rw-r--r--mail/mail-session.c15
4 files changed, 52 insertions, 30 deletions
diff --git a/mail/ChangeLog b/mail/ChangeLog
index 9cdc022bf4..a8f7fa1f00 100644
--- a/mail/ChangeLog
+++ b/mail/ChangeLog
@@ -1,3 +1,14 @@
+2001-09-18 Jeffrey Stedfast <fejj@ximian.com>
+
+ * mail-session.c (get_password): Pass a 'cache-me' argument to
+ mail_get_password.
+
+ * mail-mt.c (pass_got): Make less confusing...
+ (mail_get_password): Now takes an argument 'cache' that allows our
+ caller to determine if the user wanted to cache his/her password
+ or not.
+ (pass_got): Set the cache option.
+
2001-09-18 Dan Winship <danw@ximian.com>
* mail-format.c (mail_format_raw_message): Call
diff --git a/mail/mail-mt.c b/mail/mail-mt.c
index 99277d56b4..7ca2b3342c 100644
--- a/mail/mail-mt.c
+++ b/mail/mail-mt.c
@@ -388,10 +388,11 @@ static pthread_mutex_t status_lock = PTHREAD_MUTEX_INITIALIZER;
struct _pass_msg {
struct _mail_msg msg;
const char *prompt;
- int secret;
+ gboolean secret;
+ gboolean *cache;
char *result;
char *service_url;
- GtkWidget *tb;
+ GtkWidget *check;
};
static void
@@ -400,25 +401,28 @@ pass_got (char *string, void *data)
struct _pass_msg *m = data;
if (string) {
+ MailConfigService *service = NULL;
const MailConfigAccount *mca;
gboolean remember;
m->result = g_strdup (string);
- remember = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (m->tb));
+ remember = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (m->check));
if (m->service_url) {
mca = mail_config_get_account_by_source_url (m->service_url);
- if (mca)
- mail_config_service_set_save_passwd (mca->source, remember);
- else {
+ if (mca) {
+ service = mca->source;
+ } else {
mca = mail_config_get_account_by_transport_url (m->service_url);
if (mca)
- mail_config_service_set_save_passwd (mca->transport, remember);
- else
- printf ("Cannot figure out which account owns URL \"%s\" (could before?)\n",
- m->service_url);
+ service = mca->transport;
}
+
+ mail_config_service_set_save_passwd (service, remember);
}
+
+ if (m->cache)
+ *(m->cache) = remember;
}
}
@@ -428,32 +432,36 @@ do_get_pass (struct _mail_msg *mm)
struct _pass_msg *m = (struct _pass_msg *)mm;
const MailConfigAccount *mca;
GtkWidget *dialogue;
- GtkWidget *tb, *entry;
+ GtkWidget *check, *entry;
GList *children, *iter;
+ gboolean show;
/* this api is just awful ... hence the hacks */
dialogue = gnome_request_dialog (m->secret, m->prompt, NULL,
0, pass_got, m, NULL);
/* Remember the password? */
- tb = gtk_check_button_new_with_label (_("Remember this password"));
- gtk_widget_show (tb);
+ check = gtk_check_button_new_with_label (_("Remember this password"));
+ show = TRUE;
if (m->service_url) {
mca = mail_config_get_account_by_source_url (m->service_url);
if (mca)
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (tb), mca->source->save_passwd);
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (check), mca->source->save_passwd);
else {
mca = mail_config_get_account_by_transport_url (m->service_url);
if (mca)
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (tb), mca->transport->save_passwd);
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (check), mca->transport->save_passwd);
else {
- printf ("Cannot figure out which account owns URL \"%s\"\n", m->service_url);
- gtk_widget_hide (tb);
+ d(printf ("Cannot figure out which account owns URL \"%s\"\n", m->service_url));
+ show = FALSE;
}
}
}
+ if (show)
+ gtk_widget_show (check);
+
/* do some dirty stuff to put the checkbutton after the entry */
entry = NULL;
children = gtk_container_children (GTK_CONTAINER (GNOME_DIALOG (dialogue)->vbox));
@@ -473,7 +481,7 @@ do_get_pass (struct _mail_msg *mm)
}
gtk_box_pack_end (GTK_BOX (GNOME_DIALOG (dialogue)->vbox),
- tb, TRUE, FALSE, 0);
+ check, TRUE, FALSE, 0);
if (entry) {
gtk_box_pack_end (GTK_BOX (GNOME_DIALOG (dialogue)->vbox), entry, TRUE, FALSE, 0);
@@ -481,7 +489,7 @@ do_get_pass (struct _mail_msg *mm)
gtk_object_unref (GTK_OBJECT (entry));
}
- m->tb = tb;
+ m->check = check;
/* hrm, we can't run this async since the gui_port from which we're called
will reply to our message for us */
@@ -509,7 +517,7 @@ struct _mail_msg_op get_pass_op = {
/* returns the password, or NULL if cancelled */
char *
-mail_get_password (CamelService *service, const char *prompt, gboolean secret)
+mail_get_password (CamelService *service, const char *prompt, gboolean secret, gboolean *cache)
{
char *ret;
struct _pass_msg *m, *r;
@@ -521,10 +529,9 @@ mail_get_password (CamelService *service, const char *prompt, gboolean secret)
m->prompt = prompt;
m->secret = secret;
+ m->cache = cache;
if (service) {
- m->service_url = camel_url_to_string (service->url,
- CAMEL_URL_HIDE_PASSWORD |
- CAMEL_URL_HIDE_PARAMS);
+ m->service_url = camel_url_to_string (service->url, CAMEL_URL_HIDE_ALL);
} else
m->service_url = NULL;
diff --git a/mail/mail-mt.h b/mail/mail-mt.h
index e24a359b27..6ec2255bc7 100644
--- a/mail/mail-mt.h
+++ b/mail/mail-mt.h
@@ -58,7 +58,8 @@ void mail_msg_cancel(unsigned int msgid);
void mail_msg_wait(unsigned int msgid);
/* request a string/password */
-char *mail_get_password (CamelService *service, const char *prompt, gboolean secret);
+char *mail_get_password (CamelService *service, const char *prompt,
+ gboolean secret, gboolean *cache);
/* present information and get an ok (or possibly cancel)
* "type" is as for gnome_message_box_new();
diff --git a/mail/mail-session.c b/mail/mail-session.c
index 25490b5984..d3e06419c2 100644
--- a/mail/mail-session.c
+++ b/mail/mail-session.c
@@ -152,16 +152,17 @@ get_password (CamelSession *session, const char *prompt, gboolean secret,
CamelService *service, const char *item, CamelException *ex)
{
MailSession *mail_session = MAIL_SESSION (session);
+ gboolean cache = TRUE;
char *key, *ans;
-
- if (!strcmp(item, "popb4smtp_uri")) {
+
+ if (!strcmp (item, "popb4smtp_uri")) {
char *url = camel_url_to_string(service->url, 0);
const MailConfigAccount *account = mail_config_get_account_by_transport_url(url);
-
+
g_free(url);
if (account == NULL)
return NULL;
-
+
return g_strdup(account->source->url);
}
@@ -176,14 +177,16 @@ get_password (CamelSession *session, const char *prompt, gboolean secret,
}
if (!mail_session->interaction_enabled ||
- !(ans = mail_get_password (service, prompt, secret))) {
+ !(ans = mail_get_password (service, prompt, secret, &cache))) {
g_free (key);
camel_exception_set (ex, CAMEL_EXCEPTION_USER_CANCEL,
_("User canceled operation."));
return NULL;
}
- g_hash_table_insert (mail_session->passwords, key, g_strdup (ans));
+ if (cache)
+ g_hash_table_insert (mail_session->passwords, key, g_strdup (ans));
+
return ans;
}