aboutsummaryrefslogtreecommitdiffstats
path: root/mail/folder-browser.c
diff options
context:
space:
mode:
authorNot Zed <NotZed@HelixCode.com>2001-01-03 09:18:21 +0800
committerMichael Zucci <zucchi@src.gnome.org>2001-01-03 09:18:21 +0800
commita16344fff4780b6b1c5d8c2d6531963e1fe07d52 (patch)
tree1f71c805d1f3d27131f68fd744113b2535a3d1ce /mail/folder-browser.c
parentef48c6d6b0f84c1bbc5ce8ec666b0a581c9e3cc8 (diff)
downloadgsoc2013-evolution-a16344fff4780b6b1c5d8c2d6531963e1fe07d52.tar
gsoc2013-evolution-a16344fff4780b6b1c5d8c2d6531963e1fe07d52.tar.gz
gsoc2013-evolution-a16344fff4780b6b1c5d8c2d6531963e1fe07d52.tar.bz2
gsoc2013-evolution-a16344fff4780b6b1c5d8c2d6531963e1fe07d52.tar.lz
gsoc2013-evolution-a16344fff4780b6b1c5d8c2d6531963e1fe07d52.tar.xz
gsoc2013-evolution-a16344fff4780b6b1c5d8c2d6531963e1fe07d52.tar.zst
gsoc2013-evolution-a16344fff4780b6b1c5d8c2d6531963e1fe07d52.zip
Fix for mail_get_message change, use queue thread.
2001-01-02 Not Zed <NotZed@HelixCode.com> * mail-callbacks.c (view_msg): Fix for mail_get_message change, use queue thread. * folder-browser.c (done_message_selected): Fix mail_Get_message calls, use new thread. (do_message_selected): " * mail-ops.c (mail_get_message): Add a thread argument so callers can specify which queue it executes on. * mail-mt.c (mail_msg_free): Fix a free order problem. (mail_msg_destroy): Call mail_msg_free to do the work. (mail_msgport_replied): " (mail_msgport_replied): Check/display errors if we get them. (mail_msgport_received): If we have a describe function, say what we're doing, also set busy/unbusy. (mail_msgport_replied): Clear busy when we get a reply. (mail_get_password): Unset busy. (mail_msg_received): Set busy as we go. (mail_msg_destroy): Unset busy when done. (mail_status): Blah blah, new status interface, the other wans't workable with the way the shell api works. 2000-12-29 Not Zed <NotZed@HelixCode.com> * folder-browser.c (do_message_selected): If we are reconfiguring, just keep polling till we are done (yeah kinda shitty, but easy). (folder_browser_set_uri): Clear reconfigure flag here. ick. (got_folder): And here too. (on_right_click): Remove locking. (hide_sender): and here too. (hide_subject): And here. (on_right_click): If we are in reconfigure, then the whole menu is disabled. * mail-mt.c (status_busy_timeout): Clear the status_busy_timeout_id. * mail-local.c (local_storage_new_folder_cb): Made getting folders completely synchronous. The shell expects it, and it was only synchronous before by a sideeffect. (do_reconfigure_folder): Remove locking stuff. (do_reconfigure_folder): Use our own much simpler copying routine than that stupid move_folder_contents thing. (update_progress): Use mail_status_message() instead. (do_reconfigure_folder): Set the reconfigure flag during reconfigure & set busy flag. (cleanup_reconfigure_folder): clear busy flag. * mail-tools.c (mail_tool_uri_to_folder): Remove the tool_lock stuff. (mail_tool_uri_to_folder_noex): Clear exception on exit. (mail_tool_move_folder_contents): Get rid of this really stupid function that is only used in one place. * component-factory.c (owner_set_cb): Use direct calls to get the folders, as this code must run synchronous. Remove the event wait stuff. * mail-callbacks.c (edit_msg): Call mail_get_messages, and create the composers ourself. (do_edit_messages): get_messages callback, create the composers and connect to signals we need. (view_msg): Dont call do_view_messages, just call mail_get_messge for each to get them in parallel. (do_view_message): view a single message. * mail-ops.c (mail_edit_messages): Just use mail_get_messages for this operation. Removed the other async operation stuff. Changed my mind, just removed entirely. (mail_do_view_messages): Removed. (mail_do_setup_folder): Removed. (mail_do_scan_subfolders): Make this run synchronously, as every caller expects it to (even if they didn't realise). 2000-12-28 Not Zed <NotZed@HelixCode.com> * mail-callbacks.c (send_queued_mail): Dont expunge the folder here, but in send_queue, otherwise it might execute out of order. (expunge_folder): Remove the talbe prechange stuff, and infact references to the message_list folder, as we have our own folder. Also, dont allow expunge if we're already expunging. (expunged_folder): Clkear the expunging flag if we're finished. * folder-browser-factory.c (control_deactivate): Likewise here. Hrm, i thought this function required a callback, silly me. * mail-tools.c (mail_tool_make_message_attachment): Remov e locking. * folder-browser.c (on_message_selected): Use a timeout handler so we dont select immediately. (folder_browser_set_uri): Changed to use mail_get_folder. (got_folder): New callback called when get_folder is finished. (folder_browser_destroy): Use new sync interface. * mail-ops.c (mail_get_message): New function to asynchrounously get a message. : #define out mail_tool_camel_lock stuff entirely. (mail_get_folder): New function to asynchrounously get a folder. (mail_do_load_folder): Removed, replaced by more generic function above. (mail_do_display_message): Removed, replaced by the more generic funciton get_message. (mail_get_messages): New function to get a list of messages asynchronously. (mail_sync_folder): New interface to sync a folder async. (mail_expunge_folder): New interface for expunging folder, with callback. (do_send_queue): Remove lock stuff, and expunge if (and only if) successful, also sync the sent folder while we're at it. * session.c (mail_session_request_dialog): Changed to use new mail_get_password call. * mail-mt.[ch]: New threading/interthread messaging framework. * main.c (main): Init the message/thread system. svn path=/trunk/; revision=7223
Diffstat (limited to 'mail/folder-browser.c')
-rw-r--r--mail/folder-browser.c168
1 files changed, 140 insertions, 28 deletions
diff --git a/mail/folder-browser.c b/mail/folder-browser.c
index 5a94c91ba9..d3ed8c7cfb 100644
--- a/mail/folder-browser.c
+++ b/mail/folder-browser.c
@@ -65,7 +65,7 @@ folder_browser_destroy (GtkObject *object)
g_free (folder_browser->uri);
if (folder_browser->folder) {
- mail_do_sync_folder (folder_browser->folder);
+ mail_sync_folder (folder_browser->folder, NULL, NULL);
camel_object_unref (CAMEL_OBJECT (folder_browser->folder));
}
@@ -109,11 +109,53 @@ folder_browser_class_init (GtkObjectClass *object_class)
#define EQUAL(a,b) (strcmp (a,b) == 0)
+static void
+got_folder(char *uri, CamelFolder *folder, void *data)
+{
+ FolderBrowser *fb = data;
+
+ printf("got folder '%s' = %p\n", uri, folder);
+
+ if (fb->folder == folder)
+ goto done;
+
+ if (fb->folder)
+ camel_object_unref((CamelObject *)fb->folder);
+ g_free(fb->uri);
+ fb->uri = g_strdup(uri);
+ fb->folder = folder;
+
+ if (folder == NULL)
+ goto done;
+
+ camel_object_ref((CamelObject *)folder);
+
+ gtk_widget_set_sensitive (GTK_WIDGET (fb->search->entry),
+ camel_folder_has_search_capability (folder));
+ gtk_widget_set_sensitive (GTK_WIDGET (fb->search->option),
+ camel_folder_has_search_capability (folder));
+ message_list_set_threaded(fb->message_list, mail_config_thread_list());
+ message_list_set_folder(fb->message_list, folder);
+done:
+ gtk_object_unref((GtkObject *)fb);
+
+ /* Sigh, i dont like this (it can be set in reconfigure folder),
+ but its just easier right now to do it this way */
+ fb->reconfigure = FALSE;
+}
+
gboolean
folder_browser_set_uri (FolderBrowser *folder_browser, const char *uri)
{
- if (*uri)
- mail_do_load_folder (folder_browser, uri);
+ if (uri && *uri) {
+ gtk_object_ref((GtkObject *)folder_browser);
+ mail_get_folder(uri, got_folder, folder_browser);
+ } else {
+ /* Sigh, i dont like this (it can be set in reconfigure folder),
+ but its just easier right now to do it this way */
+ folder_browser->reconfigure = FALSE;
+ }
+
return TRUE;
}
@@ -507,8 +549,6 @@ hide_subject(GtkWidget *w, FolderBrowser *fb)
GString *expr;
if (fb->mail_display->current_message) {
- /* need to lock for full life of const data */
- mail_tool_camel_lock_up();
subject = camel_mime_message_get_subject(fb->mail_display->current_message);
if (subject) {
subject = strip_re(subject);
@@ -522,7 +562,6 @@ hide_subject(GtkWidget *w, FolderBrowser *fb)
return;
}
}
- mail_tool_camel_lock_down();
}
}
@@ -534,8 +573,6 @@ hide_sender(GtkWidget *w, FolderBrowser *fb)
GString *expr;
if (fb->mail_display->current_message) {
- /* need to lock for full life of const data */
- mail_tool_camel_lock_up();
from = camel_mime_message_get_from(fb->mail_display->current_message);
if (camel_internet_address_get(from, 0, &real, &addr)) {
expr = g_string_new("(match-all (header-contains \"from\" ");
@@ -546,7 +583,6 @@ hide_sender(GtkWidget *w, FolderBrowser *fb)
g_string_free(expr, TRUE);
return;
}
- mail_tool_camel_lock_down();
}
}
@@ -559,7 +595,7 @@ on_right_click (ETable *table, gint row, gint col, GdkEvent *event, FolderBrowse
GPtrArray *uids;
int enable_mask = 0;
int last_item, i;
- char *mailing_list_name;
+ char *mailing_list_name = NULL;
char *subject_match = NULL, *from_match = NULL;
EPopupMenu filter_menu[] = {
@@ -618,6 +654,11 @@ on_right_click (ETable *table, gint row, gint col, GdkEvent *event, FolderBrowse
};
last_item = (sizeof (filter_menu) / sizeof (*filter_menu)) - 2;
+
+ if (fb->reconfigure) {
+ enable_mask = 0;
+ goto display_menu;
+ }
if (fb->folder != drafts_folder)
enable_mask |= 1;
@@ -629,7 +670,6 @@ on_right_click (ETable *table, gint row, gint col, GdkEvent *event, FolderBrowse
const char *subject, *real, *addr;
const CamelInternetAddress *from;
- mail_tool_camel_lock_up();
mailing_list_name = mail_mlist_magic_detect_list (fb->mail_display->current_message, NULL, NULL);
if ((subject = camel_mime_message_get_subject(fb->mail_display->current_message))
@@ -641,8 +681,6 @@ on_right_click (ETable *table, gint row, gint col, GdkEvent *event, FolderBrowse
&& camel_internet_address_get(from, 0, &real, &addr)
&& addr && addr[0])
from_match = g_strdup(addr);
-
- mail_tool_camel_lock_down();
}
/* get a list of uids */
@@ -655,9 +693,11 @@ on_right_click (ETable *table, gint row, gint col, GdkEvent *event, FolderBrowse
gboolean have_seen = FALSE;
gboolean have_unseen = FALSE;
- mail_tool_camel_lock_up();
for (i = 0; i < uids->len; i++) {
info = camel_folder_get_message_info (fb->folder, uids->pdata[i]);
+ if (info == NULL)
+ continue;
+
if (info->flags & CAMEL_MESSAGE_SEEN)
have_seen = TRUE;
else
@@ -673,7 +713,6 @@ on_right_click (ETable *table, gint row, gint col, GdkEvent *event, FolderBrowse
if (have_seen && have_unseen && have_deleted && have_undeleted)
break;
}
- mail_tool_camel_lock_down();
if (!have_unseen)
enable_mask |= 4;
@@ -685,6 +724,13 @@ on_right_click (ETable *table, gint row, gint col, GdkEvent *event, FolderBrowse
if (!have_deleted)
enable_mask |= 32;
}
+
+ /* free uids */
+ for (i = 0; i < uids->len; i++)
+ g_free (uids->pdata[i]);
+ g_ptr_array_free (uids, TRUE);
+
+display_menu:
/* generate the "Filter on Mailing List menu item name */
if (mailing_list_name == NULL) {
@@ -712,11 +758,6 @@ on_right_click (ETable *table, gint row, gint col, GdkEvent *event, FolderBrowse
if (fb->message_list->hidden == NULL)
enable_mask |= 128;
- /* free uids */
- for (i = 0; i < uids->len; i++)
- g_free (uids->pdata[i]);
- g_ptr_array_free (uids, TRUE);
-
e_popup_menu_run (menu, (GdkEventButton *)event, enable_mask, 0, fb);
g_free(filter_menu[last_item].name);
@@ -850,23 +891,94 @@ folder_browser_gui_init (FolderBrowser *fb)
gtk_widget_show (GTK_WIDGET (fb));
}
+/* mark the message seen if the current message still matches */
static gint
-mark_msg_seen (gpointer data)
+do_mark_seen (gpointer data)
{
- MessageList *ml = data;
+ FolderBrowser *fb = data;
+
+ if (fb->new_uid && fb->loaded_uid
+ && strcmp(fb->new_uid, fb->loaded_uid) == 0) {
+ camel_folder_set_message_flags(fb->folder, fb->new_uid, CAMEL_MESSAGE_SEEN, CAMEL_MESSAGE_SEEN);
+ }
- if (!ml->cursor_uid)
- return FALSE;
-
- camel_folder_set_message_flags(ml->folder, ml->cursor_uid, CAMEL_MESSAGE_SEEN, CAMEL_MESSAGE_SEEN);
return FALSE;
}
+/* callback when we have the message to display, after async loading it (see below) */
+/* if we have pending uid's, it means another was selected before we finished displaying
+ the last one - so we cycle through and start loading the pending one immediately now */
+static void done_message_selected(CamelFolder *folder, char *uid, CamelMimeMessage *msg, void *data)
+{
+ FolderBrowser *fb = data;
+ int timeout = mail_config_mark_as_seen_timeout ();
+
+ if (folder != fb->folder)
+ return;
+
+ mail_display_set_message(fb->mail_display, (CamelMedium *)msg);
+
+ /* pain, if we have pending stuff, re-run */
+ if (fb->pending_uid) {
+ g_free(fb->loading_uid);
+ fb->loading_uid = fb->pending_uid;
+ fb->pending_uid = NULL;
+
+ mail_get_message(fb->folder, fb->loading_uid, done_message_selected, fb, mail_thread_new);
+ return;
+ }
+
+ g_free(fb->loaded_uid);
+ fb->loaded_uid = fb->loading_uid;
+ fb->loading_uid = NULL;
+
+ /* if we are still on the same message, do the 'idle read' thing */
+ if (fb->seen_id)
+ gtk_timeout_remove(fb->seen_id);
+
+ if (msg) {
+ if (timeout > 0)
+ fb->seen_id = gtk_timeout_add(timeout, do_mark_seen, fb);
+ else
+ do_mark_seen(fb);
+ }
+}
+
+/* ok we waited enough, display it anyway (see below) */
+static gboolean
+do_message_selected(FolderBrowser *fb)
+{
+ d(printf ("selecting uid %s (delayed)\n", fb->new_uid));
+
+ /* keep polling if we are busy */
+ if (fb->reconfigure)
+ return TRUE;
+
+ fb->loading_id = 0;
+
+ /* if we are loading, then set a pending, but leave the loading, coudl cancel here (?) */
+ if (fb->loading_uid) {
+ g_free(fb->pending_uid);
+ fb->pending_uid = g_strdup(fb->new_uid);
+ } else {
+ fb->loading_uid = g_strdup(fb->new_uid);
+ mail_get_message(fb->folder, fb->loading_uid, done_message_selected, fb, mail_thread_new);
+ }
+
+ return FALSE;
+}
+
+/* when a message is selected, wait a while before trying to display it */
static void
on_message_selected (MessageList *ml, const char *uid, FolderBrowser *fb)
{
- d(printf ("selecting uid %s\n", uid));
- mail_do_display_message (ml, fb->mail_display, uid, mark_msg_seen);
+ d(printf ("selecting uid %s (direct)\n", uid));
+ g_free(fb->new_uid);
+ fb->new_uid = g_strdup(uid);
+ if (fb->loading_id != 0)
+ gtk_timeout_remove(fb->loading_id);
+
+ fb->loading_id = gtk_timeout_add(100, (GtkFunction)do_message_selected, fb);
}
static void