diff options
-rw-r--r-- | ChangeLog | 10 | ||||
-rw-r--r-- | libsylph/procmime.c | 37 | ||||
-rw-r--r-- | src/folderview.c | 10 | ||||
-rw-r--r-- | src/mainwindow.c | 8 | ||||
-rw-r--r-- | src/summaryview.c | 84 |
5 files changed, 121 insertions, 28 deletions
@@ -1,3 +1,13 @@ +2011-09-15 + + * libsylph/procmime.c: made MIME debug print optional and disabled by + default. + * src/summaryview.c + src/folderview.c + src/mainwindow.c: prevent "imap_cmd_gen_send: cannot send command + because another command is already running." error by locking the + UI on command execution. + 2011-09-08 * version 3.2.0beta3 diff --git a/libsylph/procmime.c b/libsylph/procmime.c index a8af27ac..182dafad 100644 --- a/libsylph/procmime.c +++ b/libsylph/procmime.c @@ -1,6 +1,6 @@ /* * LibSylph -- E-Mail client library - * Copyright (C) 1999-2008 Hiroyuki Yamamoto + * Copyright (C) 1999-2011 Hiroyuki Yamamoto * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -40,6 +40,13 @@ #include "utils.h" #include "prefs_common.h" +#undef MIME_DEBUG +#ifdef MIME_DEBUG +# define mime_debug_print debug_print +#else +# define mime_debug_print 1 ? (void)0 : debug_print +#endif + #define MAX_MIME_LEVEL 64 static GHashTable *procmime_get_mime_type_table (void); @@ -245,7 +252,7 @@ void procmime_scan_multipart_message(MimeInfo *mimeinfo, FILE *fp) return; } - debug_print("level = %d\n", mimeinfo->level); + mime_debug_print("level = %d\n", mimeinfo->level); for (;;) { MimeInfo *partinfo; @@ -257,7 +264,7 @@ void procmime_scan_multipart_message(MimeInfo *mimeinfo, FILE *fp) gint b64_pad_len = 0; prev_fpos = fpos; - debug_print("prev_fpos: %ld\n", fpos); + mime_debug_print("prev_fpos: %ld\n", fpos); /* scan part header */ if (mimeinfo->mime_type == MIME_MESSAGE_RFC822) { @@ -266,8 +273,8 @@ void procmime_scan_multipart_message(MimeInfo *mimeinfo, FILE *fp) mimeinfo->sub = sub = procmime_scan_mime_header(fp); if (!sub) break; - debug_print("message/rfc822 part (content-type: %s)\n", - sub->content_type); + mime_debug_print("message/rfc822 part (content-type: %s)\n", + sub->content_type); sub->level = mimeinfo->level + 1; sub->parent = mimeinfo->parent; sub->main = mimeinfo; @@ -277,13 +284,13 @@ void procmime_scan_multipart_message(MimeInfo *mimeinfo, FILE *fp) partinfo = procmime_scan_mime_header(fp); if (!partinfo) break; procmime_mimeinfo_insert(mimeinfo, partinfo); - debug_print("content-type: %s\n", - partinfo->content_type); + mime_debug_print("content-type: %s\n", + partinfo->content_type); } /* begin content */ content_pos = ftell(fp); - debug_print("content_pos: %ld\n", content_pos); + mime_debug_print("content_pos: %ld\n", content_pos); if (partinfo->mime_type == MIME_MULTIPART || partinfo->mime_type == MIME_MESSAGE_RFC822) { @@ -314,10 +321,10 @@ void procmime_scan_multipart_message(MimeInfo *mimeinfo, FILE *fp) buf[0] = '\0'; eom = TRUE; } - debug_print("boundary: %s\n", buf); + mime_debug_print("boundary: %s\n", buf); fpos = ftell(fp); - debug_print("fpos: %ld\n", fpos); + mime_debug_print("fpos: %ld\n", fpos); len = strlen(buf); partinfo->size = fpos - prev_fpos - len; @@ -326,15 +333,15 @@ void procmime_scan_multipart_message(MimeInfo *mimeinfo, FILE *fp) b64_content_len / 4 * 3 - b64_pad_len; else partinfo->content_size = fpos - content_pos - len; - debug_print("partinfo->size: %d\n", partinfo->size); - debug_print("partinfo->content_size: %d\n", - partinfo->content_size); + mime_debug_print("partinfo->size: %d\n", partinfo->size); + mime_debug_print("partinfo->content_size: %d\n", + partinfo->content_size); if (partinfo->sub && !partinfo->sub->sub && !partinfo->sub->children) { partinfo->sub->size = fpos - partinfo->sub->fpos - strlen(buf); - debug_print("partinfo->sub->size: %d\n", - partinfo->sub->size); + mime_debug_print("partinfo->sub->size: %d\n", + partinfo->sub->size); } if (mimeinfo->mime_type == MIME_MESSAGE_RFC822) { diff --git a/src/folderview.c b/src/folderview.c index cb7d30a8..69844bb9 100644 --- a/src/folderview.c +++ b/src/folderview.c @@ -2766,6 +2766,10 @@ static void folderview_empty_trash_cb(FolderView *folderview, guint action, if (item->stype != F_TRASH && item->stype != F_JUNK) return; + if (folderview->selection_locked || + summary_is_locked(folderview->summaryview)) return; + folderview->selection_locked = TRUE; + sel_path = gtk_tree_row_reference_get_path(folderview->selected); if (item->stype == F_TRASH) { @@ -2773,6 +2777,7 @@ static void folderview_empty_trash_cb(FolderView *folderview, guint action, _("Delete all messages in the trash folder?"), GTK_STOCK_YES, GTK_STOCK_NO, NULL) != G_ALERTDEFAULT) { gtk_tree_path_free(sel_path); + folderview->selection_locked = FALSE; return; } } else { @@ -2780,11 +2785,14 @@ static void folderview_empty_trash_cb(FolderView *folderview, guint action, _("Delete all messages in the junk folder?"), GTK_STOCK_YES, GTK_STOCK_NO, NULL) != G_ALERTDEFAULT) { gtk_tree_path_free(sel_path); + folderview->selection_locked = FALSE; return; } } + summary_lock(folderview->summaryview); procmsg_empty_trash(item); + summary_unlock(folderview->summaryview); statusbar_pop_all(); folderview_update_item(item, TRUE); trayicon_set_tooltip(NULL); @@ -2796,6 +2804,8 @@ static void folderview_empty_trash_cb(FolderView *folderview, guint action, gtk_widget_grab_focus(folderview->treeview); gtk_tree_path_free(open_path); gtk_tree_path_free(sel_path); + + folderview->selection_locked = FALSE; } static void folderview_remove_mailbox_cb(FolderView *folderview, guint action, diff --git a/src/mainwindow.c b/src/mainwindow.c index 185c42b9..a42fbcac 100644 --- a/src/mainwindow.c +++ b/src/mainwindow.c @@ -3830,8 +3830,8 @@ static void prev_cb(MainWindow *mainwin, guint action, GtkWidget *widget) mimeview_step(messageview->mimeview, GTK_SCROLL_STEP_BACKWARD)) return; - summary_step(mainwin->summaryview, GTK_SCROLL_STEP_BACKWARD); - summary_mark_displayed_read(mainwin->summaryview, NULL); + if (summary_step(mainwin->summaryview, GTK_SCROLL_STEP_BACKWARD)) + summary_mark_displayed_read(mainwin->summaryview, NULL); } static void next_cb(MainWindow *mainwin, guint action, GtkWidget *widget) @@ -3843,8 +3843,8 @@ static void next_cb(MainWindow *mainwin, guint action, GtkWidget *widget) mimeview_step(messageview->mimeview, GTK_SCROLL_STEP_FORWARD)) return; - summary_step(mainwin->summaryview, GTK_SCROLL_STEP_FORWARD); - summary_mark_displayed_read(mainwin->summaryview, NULL); + if (summary_step(mainwin->summaryview, GTK_SCROLL_STEP_FORWARD)) + summary_mark_displayed_read(mainwin->summaryview, NULL); } static void prev_unread_cb(MainWindow *mainwin, guint action, diff --git a/src/summaryview.c b/src/summaryview.c index 768ad527..b5f27485 100644 --- a/src/summaryview.c +++ b/src/summaryview.c @@ -286,7 +286,7 @@ static void summary_row_collapsed (GtkTreeView *treeview, static void summary_columns_changed (GtkTreeView *treeview, SummaryView *summaryview); -static gboolean summary_select_func (GtkTreeSelection *treeview, +static gboolean summary_select_func (GtkTreeSelection *selection, GtkTreeModel *model, GtkTreePath *path, gboolean cur_selected, @@ -920,9 +920,10 @@ gboolean summary_show(SummaryView *summaryview, FolderItem *item, summary_select_row(summaryview, &iter, TRUE, TRUE); summary_lock(summaryview); - } else + } else { summary_select_row(summaryview, &iter, FALSE, TRUE); + } } else { summary_unlock(summaryview); if (item->sort_type == SORT_ASCENDING && @@ -1131,10 +1132,12 @@ void summary_lock(SummaryView *summaryview) { summaryview->lock_count++; summaryview->write_lock_count++; + /* g_print("summary_lock: %d\n", summaryview->lock_count); */ } void summary_unlock(SummaryView *summaryview) { + /* g_print("summary_unlock: %d\n", summaryview->lock_count); */ if (summaryview->lock_count) summaryview->lock_count--; if (summaryview->write_lock_count) @@ -1734,6 +1737,11 @@ MsgInfo *summary_get_msginfo_by_msgnum(SummaryView *summaryview, guint msgnum) return msginfo; } +static gboolean summary_select_true_func(GtkTreeSelection *selection, GtkTreeModel *model, GtkTreePath *path, gboolean cur_selected, gpointer data) +{ + return TRUE; +} + /** * summary_select_row: * @summaryview: Summary view. @@ -1763,8 +1771,16 @@ void summary_select_row(SummaryView *summaryview, GtkTreeIter *iter, summaryview->display_msg = display_msg; path = gtk_tree_model_get_path(GTK_TREE_MODEL(summaryview->store), iter); + if (!display_msg) + gtk_tree_selection_set_select_function(summaryview->selection, + summary_select_true_func, + summaryview, NULL); gtk_tree_view_set_cursor(GTK_TREE_VIEW(summaryview->treeview), path, NULL, FALSE); + if (!display_msg) + gtk_tree_selection_set_select_function(summaryview->selection, + summary_select_func, + summaryview, NULL); if (do_refresh) { GTK_EVENTS_FLUSH(); gtk_tree_view_scroll_to_cell @@ -3048,6 +3064,7 @@ void summary_mark(SummaryView *summaryview) summary_is_read_locked(summaryview)) return; + summary_lock(summaryview); SORT_BLOCK(SORT_BY_MARK); rows = summary_get_selected_rows(summaryview); @@ -3066,6 +3083,7 @@ void summary_mark(SummaryView *summaryview) } SORT_UNBLOCK(SORT_BY_MARK); + summary_unlock(summaryview); summary_status_show(summaryview); } @@ -3122,6 +3140,7 @@ void summary_mark_as_read(SummaryView *summaryview) summary_is_read_locked(summaryview)) return; + summary_lock(summaryview); SORT_BLOCK(SORT_BY_UNREAD); rows = summary_get_selected_rows(summaryview); @@ -3142,6 +3161,7 @@ void summary_mark_as_read(SummaryView *summaryview) } SORT_UNBLOCK(SORT_BY_UNREAD); + summary_unlock(summaryview); trayicon_set_tooltip(NULL); trayicon_set_notify(FALSE); @@ -3177,6 +3197,7 @@ void summary_mark_thread_as_read(SummaryView *summaryview) summary_is_read_locked(summaryview)) return; + summary_lock(summaryview); SORT_BLOCK(SORT_BY_UNREAD); rows = summary_get_selected_rows(summaryview); @@ -3238,6 +3259,7 @@ void summary_mark_thread_as_read(SummaryView *summaryview) g_slist_free(thr_rows); SORT_UNBLOCK(SORT_BY_UNREAD); + summary_unlock(summaryview); trayicon_set_tooltip(NULL); trayicon_set_notify(FALSE); @@ -3256,6 +3278,7 @@ void summary_mark_all_read(SummaryView *summaryview) summary_is_read_locked(summaryview)) return; + summary_lock(summaryview); SORT_BLOCK(SORT_BY_UNREAD); if (FOLDER_TYPE(summaryview->folder_item->folder) == F_IMAP) { @@ -3288,6 +3311,7 @@ void summary_mark_all_read(SummaryView *summaryview) } SORT_UNBLOCK(SORT_BY_UNREAD); + summary_unlock(summaryview); trayicon_set_tooltip(NULL); trayicon_set_notify(FALSE); @@ -3337,6 +3361,7 @@ void summary_mark_as_unread(SummaryView *summaryview) summary_is_read_locked(summaryview)) return; + summary_lock(summaryview); SORT_BLOCK(SORT_BY_UNREAD); rows = summary_get_selected_rows(summaryview); @@ -3356,6 +3381,7 @@ void summary_mark_as_unread(SummaryView *summaryview) } SORT_UNBLOCK(SORT_BY_UNREAD); + summary_unlock(summaryview); summary_status_show(summaryview); } @@ -3547,6 +3573,7 @@ void summary_unmark(SummaryView *summaryview) summary_is_read_locked(summaryview)) return; + summary_lock(summaryview); SORT_BLOCK(SORT_BY_MARK); rows = summary_get_selected_rows(summaryview); @@ -3565,6 +3592,7 @@ void summary_unmark(SummaryView *summaryview) } SORT_UNBLOCK(SORT_BY_MARK); + summary_unlock(summaryview); summary_status_show(summaryview); } @@ -5158,6 +5186,11 @@ void summary_set_colorlabel(SummaryView *summaryview, guint labelcolor, FolderSortKey sort_key = SORT_BY_NONE; FolderSortType sort_type = SORT_ASCENDING; + if (FOLDER_TYPE(summaryview->folder_item->folder) == F_IMAP && + summary_is_read_locked(summaryview)) + return; + + summary_lock(summaryview); SORT_BLOCK(SORT_BY_LABEL); rows = summary_get_selected_rows(summaryview); @@ -5183,6 +5216,7 @@ void summary_set_colorlabel(SummaryView *summaryview, guint labelcolor, summaryview->folder_item->mark_dirty = TRUE; SORT_UNBLOCK(SORT_BY_LABEL); + summary_unlock(summaryview); } static void summary_colorlabel_menu_item_activate_item_cb(GtkMenuItem *menuitem, @@ -5541,6 +5575,8 @@ void summary_qsearch_reset(SummaryView *summaryview) if (!summaryview->folder_item) return; + if (summary_is_read_locked(summaryview)) return; + g_signal_handlers_block_matched(G_OBJECT(summaryview->treeview), (GSignalMatchType)G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, summaryview); @@ -5566,8 +5602,8 @@ void summary_qsearch_reset(SummaryView *summaryview) summaryview->flt_new = 0; summaryview->flt_unread = 0; - summary_lock(summaryview); main_window_cursor_wait(summaryview->mainwin); + summary_lock(summaryview); gtkut_tree_view_fast_clear(GTK_TREE_VIEW(summaryview->treeview), summaryview->store); @@ -5576,8 +5612,8 @@ void summary_qsearch_reset(SummaryView *summaryview) summary_set_tree_model_from_list(summaryview, summaryview->all_mlist); summary_selection_list_free(summaryview); - main_window_cursor_normal(summaryview->mainwin); summary_unlock(summaryview); + main_window_cursor_normal(summaryview->mainwin); g_signal_handlers_unblock_matched(G_OBJECT(summaryview->treeview), (GSignalMatchType)G_SIGNAL_MATCH_DATA, @@ -5594,6 +5630,8 @@ void summary_qsearch_reset(SummaryView *summaryview) void summary_qsearch_clear_entry(SummaryView *summaryview) { + if (summary_is_read_locked(summaryview)) + return; quick_search_clear_entry(summaryview->qsearch); summary_qsearch(summaryview); } @@ -5610,6 +5648,8 @@ void summary_qsearch(SummaryView *summaryview) if (!summaryview->folder_item) return; + if (summary_is_read_locked(summaryview)) return; + menuitem = gtk_menu_get_active(GTK_MENU(summaryview->qsearch->menu)); type = GPOINTER_TO_INT (g_object_get_data(G_OBJECT(menuitem), MENU_VAL_ID)); @@ -5642,8 +5682,8 @@ void summary_qsearch(SummaryView *summaryview) summaryview->flt_new = 0; summaryview->flt_unread = 0; - summary_lock(summaryview); main_window_cursor_wait(summaryview->mainwin); + summary_lock(summaryview); flt_mlist = quick_search_filter(summaryview->qsearch, type, key); summaryview->on_filter = TRUE; @@ -5664,11 +5704,11 @@ void summary_qsearch(SummaryView *summaryview) (GSignalMatchType)G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, summaryview); + summary_unlock(summaryview); summary_update_display_state(summaryview, displayed_msgnum, selected_msgnum); main_window_cursor_normal(summaryview->mainwin); - summary_unlock(summaryview); summary_update_status(summaryview); summary_status_show(summaryview); summary_set_menu_sensitive(summaryview); @@ -5680,6 +5720,8 @@ void summary_mark_displayed_read(SummaryView *summaryview, GtkTreeIter *iter) MsgInfo *msginfo = NULL; GtkTreeIter iter_; + if (summary_is_read_locked(summaryview)) return; + if (prefs_common.mark_as_read_on_new_window) return; @@ -5695,6 +5737,8 @@ void summary_mark_displayed_read(SummaryView *summaryview, GtkTreeIter *iter) if (!msginfo) return; + summary_lock(summaryview); + if (MSG_IS_NEW(msginfo->flags) || MSG_IS_UNREAD(msginfo->flags)) { summary_mark_row_as_read(summaryview, iter); @@ -5704,6 +5748,8 @@ void summary_mark_displayed_read(SummaryView *summaryview, GtkTreeIter *iter) summary_set_row(summaryview, iter, msginfo); summary_status_show(summaryview); } + + summary_unlock(summaryview); } @@ -5732,6 +5778,11 @@ static gboolean summary_button_pressed(GtkWidget *treeview, if (!event) return FALSE; + if (summaryview->folder_item && summaryview->folder_item->folder && + FOLDER_TYPE(summaryview->folder_item->folder) == F_IMAP && + summary_is_locked(summaryview)) + return TRUE; + if (!gtk_tree_view_get_path_at_pos(GTK_TREE_VIEW(treeview), event->x, event->y, &path, &column, NULL, NULL)) @@ -5919,9 +5970,23 @@ static gboolean summary_key_pressed(GtkWidget *widget, GdkEventKey *event, gboolean mod_pressed; gboolean scrolled; - if (summary_is_read_locked(summaryview)) return FALSE; if (!event) return FALSE; + if (summary_is_read_locked(summaryview)) { + switch (event->keyval) { + case GDK_Home: + case GDK_End: + case GDK_Up: + case GDK_Down: + case GDK_Page_Up: + case GDK_Page_Down: + return TRUE; + default: + break; + } + return FALSE; + } + switch (event->keyval) { case GDK_Left: /* Move focus */ case GDK_KP_Left: @@ -6053,13 +6118,14 @@ static void summary_columns_changed(GtkTreeView *treeview, summary_get_column_order(summaryview); } -static gboolean summary_select_func(GtkTreeSelection *treeview, +static gboolean summary_select_func(GtkTreeSelection *selection, GtkTreeModel *model, GtkTreePath *path, gboolean cur_selected, gpointer data) { SummaryView *summaryview = (SummaryView *)data; - return summaryview->can_toggle_selection; + return summaryview->can_toggle_selection && + !summary_is_read_locked(summaryview); } static gboolean summary_display_msg_idle_func(gpointer data) |