diff options
author | Dan Winship <danw@src.gnome.org> | 2001-05-17 05:40:52 +0800 |
---|---|---|
committer | Dan Winship <danw@src.gnome.org> | 2001-05-17 05:40:52 +0800 |
commit | 7031a911d71eb1f527f8ff9336f050679a7b74f9 (patch) | |
tree | 1c05b828c60c41dd40a97f39a5940c75dc0c2d17 | |
parent | d8fcf587007ce67a1eda2b036599ac3f7e643af9 (diff) | |
download | gsoc2013-evolution-7031a911d71eb1f527f8ff9336f050679a7b74f9.tar gsoc2013-evolution-7031a911d71eb1f527f8ff9336f050679a7b74f9.tar.gz gsoc2013-evolution-7031a911d71eb1f527f8ff9336f050679a7b74f9.tar.bz2 gsoc2013-evolution-7031a911d71eb1f527f8ff9336f050679a7b74f9.tar.lz gsoc2013-evolution-7031a911d71eb1f527f8ff9336f050679a7b74f9.tar.xz gsoc2013-evolution-7031a911d71eb1f527f8ff9336f050679a7b74f9.tar.zst gsoc2013-evolution-7031a911d71eb1f527f8ff9336f050679a7b74f9.zip |
Functions to determine if a folderbrowser is one of the drafts, sent, or
* folder-browser.c (folder_browser_is_drafts,
folder_browser_is_sent, folder_browser_is_outbox): Functions to
determine if a folderbrowser is one of the drafts, sent, or outbox
folders.
(got_folder): Pass TRUE for the "outgoing" flag to
message_list_set_folder if this is a Sent, Drafts, or Outbox
folder.
* message-list.c (message_list_set_folder): Take a flag saying
whether or not the folder is an "outgoing" folder.
(message_list_setup_etree): Ditto. Use that rather than a
hardcoded list of foldernames for deciding whether to swap From
and To in the default layout.
* mail-config.c (mail_config_folder_to_cachename): Make IMAP
folders have unique cachenames rather than only one per store, so
that IMAP Sent and Drafts folders don't get forced into having the
same layout as the INBOX.
* mail-callbacks.c: (is_sent_folder, is_drafts_folder): Gone.
Replaced with simpler folder_browser_is_* routines.
(edit_msg, resend_msg, open_msg): Use folder_browser_is_*
routines.
* mail-local.c (reconfigure_clicked): Update call to
message_list_set_folder.
svn path=/trunk/; revision=9857
-rw-r--r-- | mail/ChangeLog | 29 | ||||
-rw-r--r-- | mail/folder-browser.c | 99 | ||||
-rw-r--r-- | mail/folder-browser.h | 4 | ||||
-rw-r--r-- | mail/mail-callbacks.c | 123 | ||||
-rw-r--r-- | mail/mail-config.c | 20 | ||||
-rw-r--r-- | mail/mail-local.c | 2 | ||||
-rw-r--r-- | mail/message-list.c | 10 | ||||
-rw-r--r-- | mail/message-list.h | 3 |
8 files changed, 140 insertions, 150 deletions
diff --git a/mail/ChangeLog b/mail/ChangeLog index e75b043d81..be019bdf19 100644 --- a/mail/ChangeLog +++ b/mail/ChangeLog @@ -1,3 +1,32 @@ +2001-05-16 Dan Winship <danw@ximian.com> + + * folder-browser.c (folder_browser_is_drafts, + folder_browser_is_sent, folder_browser_is_outbox): Functions to + determine if a folderbrowser is one of the drafts, sent, or outbox + folders. + (got_folder): Pass TRUE for the "outgoing" flag to + message_list_set_folder if this is a Sent, Drafts, or Outbox + folder. + + * message-list.c (message_list_set_folder): Take a flag saying + whether or not the folder is an "outgoing" folder. + (message_list_setup_etree): Ditto. Use that rather than a + hardcoded list of foldernames for deciding whether to swap From + and To in the default layout. + + * mail-config.c (mail_config_folder_to_cachename): Make IMAP + folders have unique cachenames rather than only one per store, so + that IMAP Sent and Drafts folders don't get forced into having the + same layout as the INBOX. + + * mail-callbacks.c: (is_sent_folder, is_drafts_folder): Gone. + Replaced with simpler folder_browser_is_* routines. + (edit_msg, resend_msg, open_msg): Use folder_browser_is_* + routines. + + * mail-local.c (reconfigure_clicked): Update call to + message_list_set_folder. + 2001-05-16 Jeffrey Stedfast <fejj@ximian.com> * mail-crypto.c (mail_crypto_is_smime_v3_signed): Removed (this diff --git a/mail/folder-browser.c b/mail/folder-browser.c index 5469a2d782..81c27f450f 100644 --- a/mail/folder-browser.c +++ b/mail/folder-browser.c @@ -137,25 +137,6 @@ folder_browser_class_init (GtkObjectClass *object_class) gtk_object_class_add_signals (object_class, folder_browser_signals, LAST_SIGNAL); } -/* - * static gboolean - * folder_browser_load_folder (FolderBrowser *fb, const char *name) - * { - * CamelFolder *new_folder; - * - * new_folder = mail_tool_uri_to_folder_noex (name); - * - * if (!new_folder) - * return FALSE; - * - * if (fb->folder) - * camel_object_unref (CAMEL_OBJECT (fb->folder)); - * fb->folder = new_folder; - * message_list_set_folder (fb->message_list, new_folder); - * return TRUE; - * } - */ - static void update_unread_count_main(CamelObject *object, gpointer event_data, gpointer user_data) { @@ -224,7 +205,10 @@ got_folder(char *uri, CamelFolder *folder, void *data) gtk_widget_set_sensitive(GTK_WIDGET(fb->search), camel_folder_has_search_capability(folder)); message_list_set_threaded(fb->message_list, mail_config_get_thread_list()); - message_list_set_folder(fb->message_list, folder); + message_list_set_folder(fb->message_list, folder, + folder_browser_is_drafts (fb) || + folder_browser_is_sent (fb) || + folder_browser_is_outbox (fb)); vfolder_register_source(folder); done: gtk_object_unref((GtkObject *)fb); @@ -251,6 +235,81 @@ folder_browser_set_uri (FolderBrowser *folder_browser, const char *uri) return TRUE; } + +extern CamelFolder *drafts_folder, *sent_folder, *outbox_folder; + +/** + * folder_browser_is_drafts: + * @fb: a FolderBrowser + * + * Return value: %TRUE if @fb refers to /local/Drafts or any other + * configured Drafts folder. + **/ +gboolean +folder_browser_is_drafts (FolderBrowser *fb) +{ + const GSList *accounts; + MailConfigAccount *account; + + g_return_val_if_fail (IS_FOLDER_BROWSER (fb) && fb->uri, FALSE); + + if (fb->folder == drafts_folder) + return TRUE; + + accounts = mail_config_get_accounts (); + while (accounts) { + account = accounts->data; + if (account->drafts_folder_uri && + !strcmp (account->drafts_folder_uri, fb->uri)) + return TRUE; + accounts = accounts->next; + } + return FALSE; +} + +/** + * folder_browser_is_sent: + * @fb: a FolderBrowser + * + * Return value: %TRUE if @fb refers to /local/Sent or any other + * configured Sent folder. + **/ +gboolean +folder_browser_is_sent (FolderBrowser *fb) +{ + const GSList *accounts; + MailConfigAccount *account; + + g_return_val_if_fail (IS_FOLDER_BROWSER (fb) && fb->uri, FALSE); + + if (fb->folder == sent_folder) + return TRUE; + + accounts = mail_config_get_accounts (); + while (accounts) { + account = accounts->data; + if (account->sent_folder_uri && + !strcmp (account->sent_folder_uri, fb->uri)) + return TRUE; + accounts = accounts->next; + } + return FALSE; +} + +/** + * folder_browser_is_outbox: + * @fb: a FolderBrowser + * + * Return value: %TRUE if @fb refers to /local/Outbox or any other + * configured Outbox folder. + **/ +gboolean +folder_browser_is_outbox (FolderBrowser *fb) +{ + /* There can be only one. */ + return fb->folder == outbox_folder; +} + void folder_browser_set_message_preview (FolderBrowser *folder_browser, gboolean show_message_preview) { diff --git a/mail/folder-browser.h b/mail/folder-browser.h index 6b5ab5fa84..8794753c62 100644 --- a/mail/folder-browser.h +++ b/mail/folder-browser.h @@ -121,4 +121,8 @@ void folder_browser_set_message_display_style (BonoboUIComponent *comp const char *state, gpointer user_data); +gboolean folder_browser_is_drafts (FolderBrowser *fb); +gboolean folder_browser_is_sent (FolderBrowser *fb); +gboolean folder_browser_is_outbox (FolderBrowser *fb); + #endif /* _FOLDER_BROWSER_H_ */ diff --git a/mail/mail-callbacks.c b/mail/mail-callbacks.c index fe262c389e..b62aa990f0 100644 --- a/mail/mail-callbacks.c +++ b/mail/mail-callbacks.c @@ -69,9 +69,6 @@ #include <sys/stat.h> #endif -extern CamelFolder *drafts_folder; -extern CamelFolder *sent_folder; - struct post_send_data { CamelFolder *folder; gchar *uid; @@ -983,120 +980,6 @@ do_edit_messages(CamelFolder *folder, GPtrArray *uids, GPtrArray *messages, void } static gboolean -is_sent_folder (CamelFolder *folder) -{ - /* FIXME: hide other attributes of the URL? */ - CamelService *service = CAMEL_SERVICE (folder->parent_store); - guint32 flags = CAMEL_URL_HIDE_PASSWORD | CAMEL_URL_HIDE_PARAMS; - const GSList *accounts; - CamelURL *url; - char *str; - - if (folder == sent_folder) - return TRUE; - - str = camel_url_to_string (service->url, flags); - url = camel_url_new (str, NULL); - g_free (str); - - g_free (url->path); - url->path = g_strdup_printf ("/%s", folder->full_name); - - accounts = mail_config_get_accounts (); - while (accounts) { - const MailConfigAccount *account = accounts->data; - - if (account && account->sent_folder_uri) { - CamelURL *sent_url; - - sent_url = camel_url_new (account->sent_folder_uri, NULL); - - if (sent_url) { - g_free (sent_url->passwd); - sent_url->passwd = NULL; - - if (sent_url->params) { - g_datalist_clear (&url->params); - url->params = NULL; - } - - if (camel_url_equal (url, sent_url)) { - camel_url_free (sent_url); - camel_url_free (url); - - return TRUE; - } - - camel_url_free (sent_url); - } - } - - accounts = accounts->next; - } - - camel_url_free (url); - - return FALSE; -} - -static gboolean -is_drafts_folder (CamelFolder *folder) -{ - /* FIXME: hide other attributes of the URL? */ - CamelService *service = CAMEL_SERVICE (folder->parent_store); - guint32 flags = CAMEL_URL_HIDE_PASSWORD | CAMEL_URL_HIDE_PARAMS; - const GSList *accounts; - CamelURL *url; - char *str; - - if (folder == drafts_folder) - return TRUE; - - str = camel_url_to_string (service->url, flags); - url = camel_url_new (str, NULL); - g_free (str); - - g_free (url->path); - url->path = g_strdup_printf ("/%s", folder->full_name); - - accounts = mail_config_get_accounts (); - while (accounts) { - const MailConfigAccount *account = accounts->data; - - if (account && account->drafts_folder_uri) { - CamelURL *drafts_url; - - drafts_url = camel_url_new (account->drafts_folder_uri, NULL); - - if (drafts_url) { - g_free (drafts_url->passwd); - drafts_url->passwd = NULL; - - if (drafts_url->params) { - g_datalist_clear (&url->params); - url->params = NULL; - } - - if (camel_url_equal (url, drafts_url)) { - camel_url_free (drafts_url); - camel_url_free (url); - - return TRUE; - } - - camel_url_free (drafts_url); - } - } - - accounts = accounts->next; - } - - camel_url_free (url); - - return FALSE; -} - -static gboolean are_you_sure (const char *msg, GPtrArray *uids, FolderBrowser *fb) { GtkWidget *window = gtk_widget_get_ancestor (GTK_WIDGET (fb), GTK_TYPE_WINDOW); @@ -1146,7 +1029,7 @@ edit_msg (GtkWidget *widget, gpointer user_data) { FolderBrowser *fb = FOLDER_BROWSER (user_data); - if (is_drafts_folder (fb->folder)) { + if (!folder_browser_is_drafts (fb)) { GtkWidget *message; message = gnome_warning_dialog (_("You may only edit messages saved\n" @@ -1180,7 +1063,7 @@ resend_msg (GtkWidget *widget, gpointer user_data) FolderBrowser *fb = FOLDER_BROWSER (user_data); GPtrArray *uids; - if (!is_sent_folder (fb->folder)) { + if (!folder_browser_is_sent (fb)) { GtkWidget *message; message = gnome_warning_dialog (_("You may only resend messages\n" @@ -1674,7 +1557,7 @@ open_msg (GtkWidget *widget, gpointer user_data) { FolderBrowser *fb = FOLDER_BROWSER (user_data); - if (is_drafts_folder (fb->folder)) + if (folder_browser_is_drafts (fb)) edit_msg_internal (fb); else view_msg (NULL, user_data); diff --git a/mail/mail-config.c b/mail/mail-config.c index 8da0a17c3c..420ae587af 100644 --- a/mail/mail-config.c +++ b/mail/mail-config.c @@ -1107,11 +1107,25 @@ mail_config_get_sources (void) char * mail_config_folder_to_cachename (CamelFolder *folder, const char *prefix) { + CamelService *service = CAMEL_SERVICE (folder->parent_store); char *url, *filename; - - url = camel_url_to_string (CAMEL_SERVICE (folder->parent_store)->url, CAMEL_URL_HIDE_PASSWORD | CAMEL_URL_HIDE_PARAMS); + + /* This is the way it is for backward compatibility with + * the way it was, not because it's necessarily a good thing. + */ + + url = camel_url_to_string (service->url, CAMEL_URL_HIDE_PASSWORD | CAMEL_URL_HIDE_PARAMS); + + /* Really we want to check CAMEL_IS_LOCAL_FOLDER here, but we + * can't do that. + */ + if (service->provider->flags & CAMEL_PROVIDER_IS_REMOTE) { + char *store_url = url; + url = g_strdup_printf ("%s/%s", store_url, folder->full_name); + g_free (store_url); + } e_filename_make_safe (url); - + filename = g_strdup_printf ("%s/config/%s%s", evolution_dir, prefix, url); g_free (url); diff --git a/mail/mail-local.c b/mail/mail-local.c index 960288e6e7..e6167b812d 100644 --- a/mail/mail-local.c +++ b/mail/mail-local.c @@ -997,7 +997,7 @@ reconfigure_clicked (GnomeDialog *dialog, int button, struct _reconfigure_msg *m char *types[] = { "mbox", "maildir", "mh" }; /* hack to clear the message list during update */ - message_list_set_folder (m->fb->message_list, NULL); + message_list_set_folder (m->fb->message_list, NULL, FALSE); menu = gtk_option_menu_get_menu (m->optionlist); type = g_list_index (GTK_MENU_SHELL (menu)->children, diff --git a/mail/message-list.c b/mail/message-list.c index f42707e807..f4235a5642 100644 --- a/mail/message-list.c +++ b/mail/message-list.c @@ -1106,7 +1106,7 @@ message_list_get_layout (MessageList *message_list) } static void -message_list_setup_etree(MessageList *message_list) +message_list_setup_etree(MessageList *message_list, gboolean outgoing) { /* build the spec based on the folder, and possibly from a saved file */ /* otherwise, leave default */ @@ -1122,8 +1122,8 @@ message_list_setup_etree(MessageList *message_list) if (path && stat (path, &st) == 0 && st.st_size > 0 && S_ISREG (st.st_mode)) { /* build based on saved file */ e_tree_load_state (message_list->tree, path); - } else if (strstr (name, "/Drafts") || strstr (name, "/Outbox") || strstr (name, "/Sent")) { - /* these folders have special defaults */ + } else if (outgoing) { + /* Swap From/To for Drafts, Sent, Outbox */ char *state = "<ETableState>" "<column source=\"0\"/> <column source=\"1\"/> " "<column source=\"8\"/> <column source=\"5\"/> " @@ -1952,7 +1952,7 @@ message_changed (CamelObject *o, gpointer event_data, gpointer user_data) } void -message_list_set_folder (MessageList *message_list, CamelFolder *camel_folder) +message_list_set_folder (MessageList *message_list, CamelFolder *camel_folder, gboolean outgoing) { CamelException ex; @@ -1985,7 +1985,7 @@ message_list_set_folder (MessageList *message_list, CamelFolder *camel_folder) if (camel_folder) { /* build the etree suitable for this folder */ - message_list_setup_etree(message_list); + message_list_setup_etree(message_list, outgoing); camel_object_hook_event(CAMEL_OBJECT (camel_folder), "folder_changed", folder_changed, message_list); diff --git a/mail/message-list.h b/mail/message-list.h index a856396ecf..837b8d837f 100644 --- a/mail/message-list.h +++ b/mail/message-list.h @@ -101,7 +101,8 @@ typedef enum { GtkType message_list_get_type (void); GtkWidget *message_list_new (void); void message_list_set_folder (MessageList *message_list, - CamelFolder *camel_folder); + CamelFolder *camel_folder, + gboolean outgoing); void message_list_foreach (MessageList *message_list, MessageListForeachFunc callback, |