diff options
author | Dan Winship <danw@src.gnome.org> | 2001-03-29 01:48:07 +0800 |
---|---|---|
committer | Dan Winship <danw@src.gnome.org> | 2001-03-29 01:48:07 +0800 |
commit | b38a35a5187475b13210474cea7140025793b502 (patch) | |
tree | 3508123310f89e26c0d4f93e6d764fd6ccf7a6ac | |
parent | 34ea3020395002ea43ddad071db305b4a35c51cc (diff) | |
download | gsoc2013-evolution-b38a35a5187475b13210474cea7140025793b502.tar gsoc2013-evolution-b38a35a5187475b13210474cea7140025793b502.tar.gz gsoc2013-evolution-b38a35a5187475b13210474cea7140025793b502.tar.bz2 gsoc2013-evolution-b38a35a5187475b13210474cea7140025793b502.tar.lz gsoc2013-evolution-b38a35a5187475b13210474cea7140025793b502.tar.xz gsoc2013-evolution-b38a35a5187475b13210474cea7140025793b502.tar.zst gsoc2013-evolution-b38a35a5187475b13210474cea7140025793b502.zip |
Set up the sent/drafts folder buttons. (folder_picker_clicked): Pop up the
* mail-account-gui.c (mail_account_gui_new): Set up the
sent/drafts folder buttons.
(folder_picker_clicked): Pop up the folder selector when sent or
drafts is clicked.
(mail_account_gui_save): Save the sent/drafts folders.
* mail-config.c (account_copy): copy sent/drafts info
(config_read): read sent/drafts info
(mail_config_write): write sent/drafts info
* mail-callbacks.c (composer_send_cb, composer_postpone_cb):
split out some common code here (and fix inconsistencies). Always
set headers on the message giving the account name, transport,
and sent folder to use.
* mail-ops.c (mail_send_message): If the message has an
X-Evolution-Account header, use the transport/sent folder info for
that account (assuming it still exists). Otherwise, if it has
X-Evolution-Transport and/or X-Evolution-Fcc, use those. If not,
use the default transport and sent folder.
FIXME: Falls back silently to the default sent folder if it can't
open the account-specific one...
(send_queue_send): remove the X-Evolution-Transport, etc
processing here, as it gets done by mail_send_message now.
FIXME: We only sync the default sent folder.
* component-factory.c (owner_set_cb): While setting up the
standard folders, also record their URIs.
svn path=/trunk/; revision=8991
-rw-r--r-- | mail/ChangeLog | 31 | ||||
-rw-r--r-- | mail/component-factory.c | 18 | ||||
-rw-r--r-- | mail/mail-account-gui.c | 71 | ||||
-rw-r--r-- | mail/mail-account-gui.h | 10 | ||||
-rw-r--r-- | mail/mail-callbacks.c | 93 | ||||
-rw-r--r-- | mail/mail-config.c | 30 | ||||
-rw-r--r-- | mail/mail-config.h | 3 | ||||
-rw-r--r-- | mail/mail-ops.c | 79 |
8 files changed, 255 insertions, 80 deletions
diff --git a/mail/ChangeLog b/mail/ChangeLog index 383dccaa59..2faf614f4a 100644 --- a/mail/ChangeLog +++ b/mail/ChangeLog @@ -1,3 +1,34 @@ +2001-03-28 Dan Winship <danw@ximian.com> + + * mail-account-gui.c (mail_account_gui_new): Set up the + sent/drafts folder buttons. + (folder_picker_clicked): Pop up the folder selector when sent or + drafts is clicked. + (mail_account_gui_save): Save the sent/drafts folders. + + * mail-config.c (account_copy): copy sent/drafts info + (config_read): read sent/drafts info + (mail_config_write): write sent/drafts info + + * mail-callbacks.c (composer_send_cb, composer_postpone_cb): + split out some common code here (and fix inconsistencies). Always + set headers on the message giving the account name, transport, + and sent folder to use. + + * mail-ops.c (mail_send_message): If the message has an + X-Evolution-Account header, use the transport/sent folder info for + that account (assuming it still exists). Otherwise, if it has + X-Evolution-Transport and/or X-Evolution-Fcc, use those. If not, + use the default transport and sent folder. + FIXME: Falls back silently to the default sent folder if it can't + open the account-specific one... + (send_queue_send): remove the X-Evolution-Transport, etc + processing here, as it gets done by mail_send_message now. + FIXME: We only sync the default sent folder. + + * component-factory.c (owner_set_cb): While setting up the + standard folders, also record their URIs. + 2001-03-27 Jeffrey Stedfast <fejj@ximian.com> * mail-account-editor.c (switch_page): Lets do some NULL checking diff --git a/mail/component-factory.c b/mail/component-factory.c index 18999dc3ed..3485919cce 100644 --- a/mail/component-factory.c +++ b/mail/component-factory.c @@ -51,9 +51,12 @@ #include "mail-summary.h" #include "mail-send-recv.h" +char *default_drafts_folder_uri; CamelFolder *drafts_folder = NULL; +char *default_sent_folder_uri; +CamelFolder *sent_folder = NULL; +char *default_outbox_folder_uri; CamelFolder *outbox_folder = NULL; -CamelFolder *sent_folder = NULL; /* this one should be configurable? */ char *evolution_dir; #define COMPONENT_FACTORY_ID "OAFIID:GNOME_Evolution_Mail_ShellComponentFactory" @@ -156,12 +159,12 @@ create_folder (EvolutionShellComponent *shell_component, } static struct { - char *name; + char *name, **uri; CamelFolder **folder; } standard_folders[] = { - { "Drafts", &drafts_folder }, - { "Outbox", &outbox_folder }, - { "Sent", &sent_folder }, + { "Drafts", &default_drafts_folder_uri, &drafts_folder }, + { "Outbox", &default_outbox_folder_uri, &outbox_folder }, + { "Sent", &default_sent_folder_uri, &sent_folder }, }; static void @@ -226,9 +229,8 @@ owner_set_cb (EvolutionShellComponent *shell_component, mail_importer_init (shell_client); for (i = 0; i < sizeof (standard_folders) / sizeof (standard_folders[0]); i++) { - char *uri = g_strdup_printf ("file://%s/local/%s", evolution_dir, standard_folders[i].name); - mail_msg_wait (mail_get_folder (uri, got_folder, standard_folders[i].folder)); - g_free (uri); + *standard_folders[i].uri = g_strdup_printf ("file://%s/local/%s", evolution_dir, standard_folders[i].name); + mail_msg_wait (mail_get_folder (*standard_folders[i].uri, got_folder, standard_folders[i].folder)); } mail_session_enable_interaction (TRUE); diff --git a/mail/mail-account-gui.c b/mail/mail-account-gui.c index 198db8c11d..5ea67558df 100644 --- a/mail/mail-account-gui.c +++ b/mail/mail-account-gui.c @@ -28,9 +28,12 @@ #include <gal/widgets/e-unicode.h> +#include "shell/evolution-shell-client.h" #include "mail-account-gui.h" #include "mail-session.h" +extern char *default_drafts_folder_uri, *default_sent_folder_uri; + static void save_service (MailAccountGuiService *gsvc, GHashTable *extra_conf, MailConfigService *service); static gboolean @@ -646,6 +649,44 @@ extract_values (MailAccountGuiService *source, GHashTable *extra_config, CamelUR } +extern EvolutionShellClient *global_shell_client; + +static void +set_folder_picker_label (GtkButton *button, const char *name) +{ + char *string; + + string = e_utf8_to_gtk_string (GTK_WIDGET (button), name); + gtk_label_set_text (GTK_LABEL (GTK_BIN (button)->child), string); + g_free (string); +} + +static void +folder_picker_clicked (GtkButton *button, gpointer user_data) +{ + MailAccountGuiFolder *folder = user_data; + const char *allowed_types[] = { "mail", NULL }; + char *physical_uri, *evolution_uri; + + physical_uri = evolution_uri = NULL; + evolution_shell_client_user_select_folder ( + global_shell_client, _("Select Folder"), folder->uri, + allowed_types, &evolution_uri, &physical_uri); + if (!physical_uri || !*physical_uri) { + g_free (physical_uri); + g_free (evolution_uri); + return; + } + + g_free (folder->uri); + folder->uri = physical_uri; + g_free (folder->name); + folder->name = g_strdup (g_basename (evolution_uri)); + g_free (evolution_uri); + set_folder_picker_label (button, folder->name); +} + + static gboolean setup_service (MailAccountGuiService *gsvc, MailConfigService *service) { @@ -781,6 +822,27 @@ mail_account_gui_new (MailConfigAccount *account) gui->transport.check_supported = GTK_BUTTON (glade_xml_get_widget (gui->xml, "transport_check_supported")); gtk_signal_connect (GTK_OBJECT (gui->transport.check_supported), "clicked", GTK_SIGNAL_FUNC (service_check_supported), &gui->transport); + gui->drafts_folder_button = GTK_BUTTON (glade_xml_get_widget (gui->xml, "drafts_button")); + gtk_signal_connect (GTK_OBJECT (gui->drafts_folder_button), "clicked", GTK_SIGNAL_FUNC (folder_picker_clicked), &gui->drafts_folder); + if (account->drafts_folder_uri) { + gui->drafts_folder.uri = g_strdup (account->drafts_folder_uri); + gui->drafts_folder.name = g_strdup (account->drafts_folder_name); + } else { + gui->drafts_folder.uri = g_strdup (default_drafts_folder_uri); + gui->drafts_folder.name = g_strdup (strrchr (default_drafts_folder_uri, '/') + 1); + } + set_folder_picker_label (gui->drafts_folder_button, gui->drafts_folder.name); + gui->sent_folder_button = GTK_BUTTON (glade_xml_get_widget (gui->xml, "sent_button")); + gtk_signal_connect (GTK_OBJECT (gui->sent_folder_button), "clicked", GTK_SIGNAL_FUNC (folder_picker_clicked), &gui->sent_folder); + if (account->sent_folder_uri) { + gui->sent_folder.uri = g_strdup (account->sent_folder_uri); + gui->sent_folder.name = g_strdup (account->sent_folder_name); + } else { + gui->sent_folder.uri = g_strdup (default_sent_folder_uri); + gui->sent_folder.name = g_strdup (strrchr (default_sent_folder_uri, '/') + 1); + } + set_folder_picker_label (gui->sent_folder_button, gui->sent_folder.name); + return gui; } @@ -1082,6 +1144,15 @@ mail_account_gui_save (MailAccountGui *gui) account->transport = g_new0 (MailConfigService, 1); save_service (&gui->transport, NULL, account->transport); + g_free (account->drafts_folder_name); + account->drafts_folder_name = g_strdup (gui->drafts_folder.name); + g_free (account->drafts_folder_uri); + account->drafts_folder_uri = g_strdup (gui->drafts_folder.uri); + g_free (account->sent_folder_name); + account->sent_folder_name = g_strdup (gui->sent_folder.name); + g_free (account->sent_folder_uri); + account->sent_folder_uri = g_strdup (gui->sent_folder.uri); + return TRUE; } diff --git a/mail/mail-account-gui.h b/mail/mail-account-gui.h index 2684dd934c..9950157ece 100644 --- a/mail/mail-account-gui.h +++ b/mail/mail-account-gui.h @@ -52,6 +52,10 @@ typedef struct { } MailAccountGuiService; typedef struct { + char *name, *uri; +} MailAccountGuiFolder; + +typedef struct { GtkWidget *top; MailConfigAccount *account; GladeXML *xml; @@ -77,6 +81,12 @@ typedef struct { /* account management */ GtkEntry *account_name; GtkToggleButton *default_account; + + /* special folders */ + GtkButton *drafts_folder_button; + MailAccountGuiFolder drafts_folder; + GtkButton *sent_folder_button; + MailAccountGuiFolder sent_folder; } MailAccountGui; diff --git a/mail/mail-callbacks.c b/mail/mail-callbacks.c index eb612da9db..1e453b98ea 100644 --- a/mail/mail-callbacks.c +++ b/mail/mail-callbacks.c @@ -280,35 +280,17 @@ composer_sent_cb(char *uri, CamelMimeMessage *message, gboolean sent, void *data camel_object_unref (CAMEL_OBJECT (message)); } -void -composer_send_cb (EMsgComposer *composer, gpointer data) +CamelMimeMessage * +composer_get_message (EMsgComposer *composer) { - const MailConfigAccount *account = NULL; CamelMimeMessage *message; const CamelInternetAddress *iaddr; const char *subject; - struct post_send_data *psd = data; - struct _send_data *send; - - 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 (); + const MailConfigAccount *account; - /* Get the message */ message = e_msg_composer_get_message (composer); if (message == NULL) - return; + return NULL; /* Check for no recipients */ iaddr = camel_mime_message_get_recipients (message, CAMEL_RECIPIENT_TYPE_TO); @@ -324,7 +306,7 @@ composer_send_cb (EMsgComposer *composer, gpointer data) gnome_dialog_run_and_close (GNOME_DIALOG (message_box)); camel_object_unref (CAMEL_OBJECT (message)); - return; + return NULL; } /* Check for no subject */ @@ -332,55 +314,70 @@ composer_send_cb (EMsgComposer *composer, gpointer data) if (subject == NULL || subject[0] == '\0') { if (!ask_confirm_for_empty_subject (composer)) { camel_object_unref (CAMEL_OBJECT (message)); - return; + return NULL; } } + + /* Add info about the sending account */ + account = e_msg_composer_get_preferred_account (composer); + if (account) { + camel_medium_set_header (CAMEL_MEDIUM (message), "X-Evolution-Account", account->name); + camel_medium_set_header (CAMEL_MEDIUM (message), "X-Evolution-Transport", account->transport->url); + camel_medium_set_header (CAMEL_MEDIUM (message), "X-Evolution-Fcc", account->sent_folder_uri); + } + + return message; +} + +void +composer_send_cb (EMsgComposer *composer, gpointer data) +{ + const MailConfigService *transport; + CamelMimeMessage *message; + struct post_send_data *psd = data; + struct _send_data *send; + 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; + } + + message = composer_get_message (composer); + if (!message) + return; + transport = mail_config_get_default_transport (); + send = g_malloc (sizeof (*send)); send->psd = psd; send->composer = composer; gtk_object_ref (GTK_OBJECT (composer)); gtk_widget_hide (GTK_WIDGET (composer)); - mail_send_mail (account->transport->url, message, composer_sent_cb, send); + mail_send_mail (transport->url, message, composer_sent_cb, send); } void composer_postpone_cb (EMsgComposer *composer, gpointer data) { - const MailConfigAccount *account = NULL; extern CamelFolder *outbox_folder; CamelMimeMessage *message; struct post_send_data *psd = data; - const char *subject; - /* Get the message */ - message = e_msg_composer_get_message (composer); + message = composer_get_message (composer); if (message == NULL) return; - /* Check for no subject */ - subject = camel_mime_message_get_subject (message); - if (subject == NULL || subject[0] == '\0') { - if (!ask_confirm_for_empty_subject (composer)) { - camel_object_unref (CAMEL_OBJECT (message)); - return; - } - } - - /* Attach a X-Evolution-Transport header so we know which account - to use when it gets sent later. */ - account = e_msg_composer_get_preferred_account (composer); - if (!account) - account = mail_config_get_default_account (); - camel_medium_add_header (CAMEL_MEDIUM (message), "X-Evolution-Transport", account->transport->url); - - /* Save the message in Outbox */ mail_append_mail (outbox_folder, message, NULL, NULL, NULL); - camel_object_unref (CAMEL_OBJECT (message)); - if (psd) + if (psd) { camel_folder_set_message_flags (psd->folder, psd->uid, psd->flags, psd->flags); + free_psd (NULL, psd); + } gtk_widget_destroy (GTK_WIDGET (composer)); } diff --git a/mail/mail-config.c b/mail/mail-config.c index 41b1b482bf..00e0c8e7d0 100644 --- a/mail/mail-config.c +++ b/mail/mail-config.c @@ -141,6 +141,11 @@ account_copy (const MailConfigAccount *account) new->source = service_copy (account->source); new->transport = service_copy (account->transport); + new->drafts_folder_name = g_strdup (account->drafts_folder_name); + new->drafts_folder_uri = g_strdup (account->drafts_folder_uri); + new->sent_folder_name = g_strdup (account->sent_folder_name); + new->sent_folder_uri = g_strdup (account->sent_folder_uri); + return new; } @@ -231,6 +236,19 @@ config_read (void) have_default = TRUE; g_free (path); + path = g_strdup_printf ("account_drafts_folder_name_%d", i); + account->drafts_folder_name = gnome_config_get_string (path); + g_free (path); + path = g_strdup_printf ("account_drafts_folder_uri_%d", i); + account->drafts_folder_uri = gnome_config_get_string (path); + g_free (path); + path = g_strdup_printf ("account_sent_folder_name_%d", i); + account->sent_folder_name = gnome_config_get_string (path); + g_free (path); + path = g_strdup_printf ("account_sent_folder_uri_%d", i); + account->sent_folder_uri = gnome_config_get_string (path); + g_free (path); + /* get the identity info */ id = g_new0 (MailConfigIdentity, 1); path = g_strdup_printf ("identity_name_%d", i); @@ -423,6 +441,18 @@ mail_config_write (void) path = g_strdup_printf ("account_is_default_%d", i); gnome_config_set_bool (path, account->default_account); g_free (path); + path = g_strdup_printf ("account_drafts_folder_name_%d", i); + gnome_config_set_string (path, account->drafts_folder_name); + g_free (path); + path = g_strdup_printf ("account_drafts_folder_uri_%d", i); + gnome_config_set_string (path, account->drafts_folder_uri); + g_free (path); + path = g_strdup_printf ("account_sent_folder_name_%d", i); + gnome_config_set_string (path, account->sent_folder_name); + g_free (path); + path = g_strdup_printf ("account_sent_folder_uri_%d", i); + gnome_config_set_string (path, account->sent_folder_uri); + g_free (path); /* identity info */ path = g_strdup_printf ("identity_name_%d", i); diff --git a/mail/mail-config.h b/mail/mail-config.h index 5a293ef9ce..60dc23465f 100644 --- a/mail/mail-config.h +++ b/mail/mail-config.h @@ -54,6 +54,9 @@ typedef struct { MailConfigIdentity *id; MailConfigService *source; MailConfigService *transport; + + gchar *drafts_folder_name, *drafts_folder_uri; + gchar *sent_folder_name, *sent_folder_uri; } MailConfigAccount; /* Identities */ diff --git a/mail/mail-ops.c b/mail/mail-ops.c index 7b1e8adcf4..475ab7767f 100644 --- a/mail/mail-ops.c +++ b/mail/mail-ops.c @@ -473,14 +473,17 @@ int mail_update_subfolders(CamelStore *store, EvolutionStorage *storage, /* sending stuff */ /* ** SEND MAIL *********************************************************** */ +extern CamelFolder *sent_folder; + /* send 1 message to a specific transport */ static void mail_send_message(CamelMimeMessage *message, const char *destination, CamelFilterDriver *driver, CamelException *ex) { - extern CamelFolder *sent_folder; /* FIXME */ CamelMessageInfo *info; - CamelTransport *xport; - const char *version; + CamelTransport *xport = NULL; + CamelFolder *folder; + const char *version, *header; + char *transport_url = NULL, *sent_folder_uri = NULL; if (SUB_VERSION[0] == '\0') version = "Evolution/" VERSION " (Preview Release)"; @@ -492,14 +495,48 @@ mail_send_message(CamelMimeMessage *message, const char *destination, CamelFilte /* Remove the X-Evolution header so we don't send our flags too ;-) */ camel_medium_remove_header (CAMEL_MEDIUM (message), "X-Evolution"); - xport = camel_session_get_transport (session, destination, ex); - if (camel_exception_is_set (ex)) + /* Get information about the account this was composed by. */ + header = camel_medium_get_header (CAMEL_MEDIUM (message), "X-Evolution-Account"); + if (header) { + const MailConfigAccount *account; + + account = mail_config_get_account_by_name (header); + camel_medium_remove_header (CAMEL_MEDIUM (message), "X-Evolution-Account"); + if (account) { + transport_url = g_strdup (account->transport->url); + camel_medium_remove_header (CAMEL_MEDIUM (message), "X-Evolution-Transport"); + sent_folder_uri = account->sent_folder_uri; + camel_medium_remove_header (CAMEL_MEDIUM (message), "X-Evolution-Fcc"); + } + } + if (!transport_url) { + header = camel_medium_get_header (CAMEL_MEDIUM (message), "X-Evolution-Transport"); + if (header) { + transport_url = g_strdup (header); + camel_medium_remove_header (CAMEL_MEDIUM (message), "X-Evolution-Transport"); + } + } + if (!sent_folder_uri) { + header = camel_medium_get_header (CAMEL_MEDIUM (message), "X-Evolution-Fcc"); + if (header) { + sent_folder_uri = g_strdup (header); + camel_medium_remove_header (CAMEL_MEDIUM (message), "X-Evolution-Fcc"); + } + } + + xport = camel_session_get_transport (session, transport_url ? transport_url : destination, ex); + g_free (transport_url); + if (!xport) { + g_free (sent_folder_uri); return; + } camel_transport_send (xport, (CamelMedium *)message, ex); camel_object_unref (CAMEL_OBJECT (xport)); - if (camel_exception_is_set (ex)) + if (camel_exception_is_set (ex)) { + g_free (sent_folder_uri); return; + } /* post-process */ info = camel_message_info_new (); @@ -509,8 +546,17 @@ mail_send_message(CamelMimeMessage *message, const char *destination, CamelFilte camel_filter_driver_filter_message (driver, message, info, NULL, NULL, "", ex); - if (sent_folder) - camel_folder_append_message (sent_folder, message, info, ex); + if (sent_folder_uri) { + folder = mail_tool_uri_to_folder (sent_folder_uri, NULL); + if (!folder) { + /* FIXME */ + folder = sent_folder; + } + } else + folder = sent_folder; + + if (folder) + camel_folder_append_message (folder, message, info, ex); camel_message_info_free (info); } @@ -650,7 +696,6 @@ send_queue_send(struct _mail_msg *mm) for (i = 0; i < uids->len; i++) { CamelMimeMessage *message; CamelMessageInfo *info; - char *destination; int pc = (100 * i) / uids->len; report_status (m, CAMEL_FILTER_STATUS_START, pc, "Sending message %d of %d", i+1, uids->len); @@ -663,21 +708,7 @@ send_queue_send(struct _mail_msg *mm) if (camel_exception_is_set (&mm->ex)) break; - /* Remove the X-Evolution header so we don't send our flags too ;-) */ - camel_medium_remove_header (CAMEL_MEDIUM (message), "X-Evolution"); - - /* We also don't want to send our identity header. */ - camel_medium_remove_header (CAMEL_MEDIUM (message), "X-Evolution-Identity"); - - /* Get the preferred transport URI */ - destination = (char *)camel_medium_get_header (CAMEL_MEDIUM (message), "X-Evolution-Transport"); - if (destination) { - destination = g_strdup (destination); - camel_medium_remove_header (CAMEL_MEDIUM (message), "X-Evolution-Transport"); - mail_send_message (message, g_strstrip (destination), m->driver, &mm->ex); - g_free (destination); - } else - mail_send_message (message, m->destination, m->driver, &mm->ex); + mail_send_message (message, m->destination, m->driver, &mm->ex); if (camel_exception_is_set (&mm->ex)) break; |