diff options
-rw-r--r-- | mail/ChangeLog | 10 | ||||
-rw-r--r-- | mail/mail-callbacks.c | 23 | ||||
-rw-r--r-- | mail/mail-config.c | 21 | ||||
-rw-r--r-- | mail/mail-config.h | 1 |
4 files changed, 50 insertions, 5 deletions
diff --git a/mail/ChangeLog b/mail/ChangeLog index 71671d19d5..44555fcfca 100644 --- a/mail/ChangeLog +++ b/mail/ChangeLog @@ -1,3 +1,13 @@ +2001-01-12 Jeffrey Stedfast <fejj@helixcode.com> + + * mail-callbacks.c (composer_send_cb): Get the account by using + the new e_msg_composer_get_preferred_account() function. Also + check to make sure everything is configured (in case they deleted + their accounts while composing mail?). + + * mail-config.c (mail_config_get_account_by_address): New + convenience function. + 2001-01-12 Ettore Perazzoli <ettore@helixcode.com> * component-factory.c (component_fn): Pass NULL as the diff --git a/mail/mail-callbacks.c b/mail/mail-callbacks.c index b691fbe591..636f95aecd 100644 --- a/mail/mail-callbacks.c +++ b/mail/mail-callbacks.c @@ -208,6 +208,8 @@ send_queued_mail (GtkWidget *widget, gpointer user_data) return; } + /* FIXME: use the preferred transport for each message */ + account = mail_config_get_default_account (); if (!account || !account->transport) { GtkWidget *win = gtk_widget_get_ancestor (GTK_WIDGET (user_data), @@ -305,9 +307,21 @@ composer_send_cb (EMsgComposer *composer, gpointer data) const char *subject; struct post_send_data *psd = data; struct _send_data *send; - - /* Config info */ - account = mail_config_get_default_account (); + + if (!mail_config_is_configured ()) { + GtkWidget *dialog; + + dialog = gnome_ok_dialog_parented (_("You must configure an account before you " + "can send this email."), + GTK_WINDOW (composer)); + gnome_dialog_run_and_close (GNOME_DIALOG (dialog)); + return; + } + + /* Use the preferred account */ + account = e_msg_composer_get_preferred_account (composer); + if (!account) + account = mail_config_get_default_account (); /* Get the message */ message = e_msg_composer_get_message (composer); @@ -317,7 +331,8 @@ composer_send_cb (EMsgComposer *composer, gpointer data) if (!iaddr || CAMEL_ADDRESS (iaddr)->addresses->len == 0) { GtkWidget *message_box; - message_box = gnome_message_box_new (_("You must specify recipients in order to send this message."), + message_box = gnome_message_box_new (_("You must specify recipients in order to " + "send this message."), GNOME_MESSAGE_BOX_WARNING, GNOME_STOCK_BUTTON_OK, NULL); diff --git a/mail/mail-config.c b/mail/mail-config.c index c5ba93f4a1..6ba5f1b51e 100644 --- a/mail/mail-config.c +++ b/mail/mail-config.c @@ -542,7 +542,26 @@ mail_config_get_account_by_name (const char *account_name) l = config->accounts; while (l) { account = l->data; - if (!strcmp (account->name, account_name)) + if (account && !strcmp (account->name, account_name)) + return account; + + l = l->next; + } + + return NULL; +} + +const MailConfigAccount * +mail_config_get_account_by_address (const char *address) +{ + /* FIXME: this should really use a hash? */ + const MailConfigAccount *account; + GSList *l; + + l = config->accounts; + while (l) { + account = l->data; + if (account && account->id && !g_strcasecmp (account->id->address, address)) return account; l = l->next; diff --git a/mail/mail-config.h b/mail/mail-config.h index cc8e9b7cbe..b8713be1e3 100644 --- a/mail/mail-config.h +++ b/mail/mail-config.h @@ -95,6 +95,7 @@ void mail_config_set_mark_as_seen_timeout (gint timeout); const MailConfigAccount *mail_config_get_default_account (void); const MailConfigAccount *mail_config_get_account_by_name (const char *account_name); +const MailConfigAccount *mail_config_get_account_by_address (const char *address); const GSList *mail_config_get_accounts (void); void mail_config_add_account (MailConfigAccount *account); void mail_config_set_default_account (const MailConfigAccount *account); |