2007-06-08 [wwp] 2.9.2cvs50
authorTristan Chabredier <wwp@claws-mail.org>
Fri, 8 Jun 2007 13:18:44 +0000 (13:18 +0000)
committerTristan Chabredier <wwp@claws-mail.org>
Fri, 8 Jun 2007 13:18:44 +0000 (13:18 +0000)
* src/compose.c
* src/compose.h
* src/main.c
* src/mainwindow.c
* src/mainwindow.h
Provide a way out of automatic draft saving on IMAP, when
exiting offline.
Prevent drafting while sending and quitting while sending.
Thanks for Colin.

ChangeLog
PATCHSETS
configure.ac
src/compose.c
src/compose.h
src/main.c
src/mainwindow.c
src/mainwindow.h

index e3d976d43fddb1e28859230959134de3122a78e0..2b71ee89fd0652afd5c2e44ec58f7f333bc21970 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,17 @@
+2007-06-08 [wwp]       2.9.2cvs50
+
+       * src/compose.c
+       * src/compose.h
+       * src/main.c
+       * src/mainwindow.c
+       * src/mainwindow.h
+               Provide a way out of automatic draft saving on IMAP, when
+               exiting offline.
+               Prevent drafting while sending and quitting while sending.
+               Thanks for Colin.
+
+
+
 2007-06-08 [wwp]       2.9.2cvs49
 
        * src/prefs_account.c
index 75f1bc19f16d690a63a4556e37ee87825c900a44..1473dc143c82ff458e1bb0975833e4a9a6bf34fc 100644 (file)
--- a/PATCHSETS
+++ b/PATCHSETS
 ( cvs diff -u -r 1.12.2.34 -r 1.12.2.35 src/gtk/prefswindow.c;  ) > 2.9.2cvs47.patchset
 ( cvs diff -u -r 1.13.2.32 -r 1.13.2.33 src/common/socket.c;  ) > 2.9.2cvs48.patchset
 ( cvs diff -u -r 1.105.2.101 -r 1.105.2.102 src/prefs_account.c;  cvs diff -u -r 1.12.2.35 -r 1.12.2.36 src/gtk/prefswindow.c;  cvs diff -u -r 1.7.2.9 -r 1.7.2.10 src/gtk/prefswindow.h;  ) > 2.9.2cvs49.patchset
+( cvs diff -u -r 1.382.2.388 -r 1.382.2.389 src/compose.c;  cvs diff -u -r 1.50.2.36 -r 1.50.2.37 src/compose.h;  cvs diff -u -r 1.115.2.153 -r 1.115.2.154 src/main.c;  cvs diff -u -r 1.274.2.189 -r 1.274.2.190 src/mainwindow.c;  cvs diff -u -r 1.39.2.36 -r 1.39.2.37 src/mainwindow.h;  ) > 2.9.2cvs50.patchset
index e0a716f6fd1787298f52f58a16fd7993da2b8b64..d75166e3b3c6268002ba0d4ab6ca1ee567fa11ea 100644 (file)
@@ -11,7 +11,7 @@ MINOR_VERSION=9
 MICRO_VERSION=2
 INTERFACE_AGE=0
 BINARY_AGE=0
-EXTRA_VERSION=49
+EXTRA_VERSION=50
 EXTRA_RELEASE=
 EXTRA_GTK2_VERSION=
 
index 59a27174c345f2f7475a6f74ee4b3e20465a0efe..b9b406f1a533fc515078faebbd3cb0aa9b4b0009 100644 (file)
@@ -8258,22 +8258,7 @@ static void compose_send_later_cb(gpointer data, guint action,
        toolbar_main_set_sensitive(mainwindow_get_mainwindow());
 }
 
-void compose_draft (gpointer data, guint action) 
-{
-       compose_draft_cb(data, action, NULL);   
-}
-
 #define DRAFTED_AT_EXIT "drafted_at_exit"
-void compose_clear_exit_drafts(void)
-{
-       gchar *filepath = g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S,
-                                     DRAFTED_AT_EXIT, NULL);
-       if (is_file_exist(filepath))
-               g_unlink(filepath);
-       
-       g_free(filepath);
-}
-
 static void compose_register_draft(MsgInfo *info)
 {
        gchar *filepath = g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S,
@@ -8289,34 +8274,7 @@ static void compose_register_draft(MsgInfo *info)
        g_free(filepath);       
 }
 
-void compose_reopen_exit_drafts(void)
-{
-       gchar *filepath = g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S,
-                                     DRAFTED_AT_EXIT, NULL);
-       FILE *fp = fopen(filepath, "rb");
-       gchar buf[1024];
-       
-       if (fp) {
-               while (fgets(buf, sizeof(buf), fp)) {
-                       gchar **parts = g_strsplit(buf, "\t", 2);
-                       const gchar *folder = parts[0];
-                       int msgnum = parts[1] ? atoi(parts[1]):-1;
-                       
-                       if (folder && *folder && msgnum > -1) {
-                               FolderItem *item = folder_find_item_from_identifier(folder);
-                               MsgInfo *info = folder_item_get_msginfo(item, msgnum);
-                               if (info)
-                                       compose_reedit(info, FALSE);
-                       }
-                       g_strfreev(parts);
-               }       
-               fclose(fp);
-       }       
-       g_free(filepath);
-       compose_clear_exit_drafts();
-}
-
-static void compose_draft_cb(gpointer data, guint action, GtkWidget *widget)
+gboolean compose_draft (gpointer data, guint action) 
 {
        Compose *compose = (Compose *)data;
        FolderItem *draft;
@@ -8328,10 +8286,13 @@ static void compose_draft_cb(gpointer data, guint action, GtkWidget *widget)
        FILE *fp;
        gboolean target_locked = FALSE;
        
-       if (lock) return;
+       if (lock) return FALSE;
+
+       if (compose->sending)
+               return TRUE;
 
        draft = account_get_special_folder(compose->account, F_DRAFT);
-       g_return_if_fail(draft != NULL);
+       g_return_val_if_fail(draft != NULL, FALSE);
        
        if (!g_mutex_trylock(compose->mutex)) {
                /* we don't want to lock the mutex once it's available,
@@ -8339,7 +8300,7 @@ static void compose_draft_cb(gpointer data, guint action, GtkWidget *widget)
                 * it is compose_close - which means once unlocked,
                 * the compose struct will be freed */
                debug_print("couldn't lock mutex, probably sending\n");
-               return;
+               return FALSE;
        }
        
        lock = TRUE;
@@ -8415,8 +8376,29 @@ static void compose_draft_cb(gpointer data, guint action, GtkWidget *widget)
        if ((msgnum = folder_item_add_msg(draft, tmp, &flag, TRUE)) < 0) {
                g_unlink(tmp);
                g_free(tmp);
-               if (action != COMPOSE_AUTO_SAVE)
-                       alertpanel_error(_("Could not save draft."));
+               if (action != COMPOSE_AUTO_SAVE) {
+                       if (action != COMPOSE_DRAFT_FOR_EXIT)
+                               alertpanel_error(_("Could not save draft."));
+                       else {
+                               AlertValue val;
+                               gtkut_window_popup(compose->window);
+                               val = alertpanel_full(_("Could not save draft"),
+                                       _("Could not save draft.\n"
+                                       "Do you want to cancel exit or discard this email?"),
+                                         _("_Cancel exit"), _("_Discard email"), NULL,
+                                         FALSE, NULL, ALERT_QUESTION, G_ALERTDEFAULT);
+                               if (val == G_ALERTALTERNATE) {
+                                       lock = FALSE;
+                                       g_mutex_unlock(compose->mutex); /* must be done before closing */
+                                       compose_close(compose);
+                                       return TRUE;
+                               } else {
+                                       lock = FALSE;
+                                       g_mutex_unlock(compose->mutex); /* must be done before closing */
+                                       return FALSE;
+                               }
+                       }
+               }
                goto unlock;
        }
        g_free(tmp);
@@ -8448,7 +8430,7 @@ static void compose_draft_cb(gpointer data, guint action, GtkWidget *widget)
                lock = FALSE;
                g_mutex_unlock(compose->mutex); /* must be done before closing */
                compose_close(compose);
-               return;
+               return TRUE;
        } else {
                struct stat s;
                gchar *path;
@@ -8484,6 +8466,49 @@ static void compose_draft_cb(gpointer data, guint action, GtkWidget *widget)
 unlock:
        lock = FALSE;
        g_mutex_unlock(compose->mutex);
+       return TRUE;
+}
+
+void compose_clear_exit_drafts(void)
+{
+       gchar *filepath = g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S,
+                                     DRAFTED_AT_EXIT, NULL);
+       if (is_file_exist(filepath))
+               g_unlink(filepath);
+       
+       g_free(filepath);
+}
+
+void compose_reopen_exit_drafts(void)
+{
+       gchar *filepath = g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S,
+                                     DRAFTED_AT_EXIT, NULL);
+       FILE *fp = fopen(filepath, "rb");
+       gchar buf[1024];
+       
+       if (fp) {
+               while (fgets(buf, sizeof(buf), fp)) {
+                       gchar **parts = g_strsplit(buf, "\t", 2);
+                       const gchar *folder = parts[0];
+                       int msgnum = parts[1] ? atoi(parts[1]):-1;
+                       
+                       if (folder && *folder && msgnum > -1) {
+                               FolderItem *item = folder_find_item_from_identifier(folder);
+                               MsgInfo *info = folder_item_get_msginfo(item, msgnum);
+                               if (info)
+                                       compose_reedit(info, FALSE);
+                       }
+                       g_strfreev(parts);
+               }       
+               fclose(fp);
+       }       
+       g_free(filepath);
+       compose_clear_exit_drafts();
+}
+
+static void compose_draft_cb(gpointer data, guint action, GtkWidget *widget)
+{
+       compose_draft(data, action);
 }
 
 static void compose_attach_cb(gpointer data, guint action, GtkWidget *widget)
index 5be9c8a51a7b678ce995800c75c810ffc36c6955..4d1b48d7783b0e98897fa4a99f4a77855e9feac8 100644 (file)
@@ -283,7 +283,7 @@ void compose_reflect_prefs_all                      (void);
 void compose_reflect_prefs_pixmap_theme        (void);
 
 void compose_destroy_all                (void);
-void compose_draft                     (gpointer data, guint action);
+gboolean compose_draft                 (gpointer data, guint action);
 void compose_toolbar_cb                        (gint           action, 
                                         gpointer       data);
 void compose_reply_from_messageview    (MessageView    *msgview, 
index d144f15ba59c8b1528e386c93fc6c726f29e295d..90d42478cb930c04af7002eed0ab8dfcacd0508b 100644 (file)
@@ -314,7 +314,7 @@ static gboolean defer_jump(void *data)
        } else if (cmd.receive) {
                defer_check(NULL);
        } 
-       mainwindow_jump_to(data);
+       mainwindow_jump_to(data, FALSE);
        return FALSE;
 }
 
@@ -1387,15 +1387,19 @@ static void initial_processing(FolderItem *item, gpointer data)
        STATUSBAR_POP(mainwin);
 }
 
-static void draft_all_messages(void)
+static gboolean draft_all_messages(void)
 {
        GList *compose_list = NULL;
        
        compose_clear_exit_drafts();
-       while ((compose_list = compose_get_compose_list()) != NULL) {
+       compose_list = compose_get_compose_list();
+       while (compose_list != NULL) {
                Compose *c = (Compose*)compose_list->data;
-               compose_draft(c, COMPOSE_DRAFT_FOR_EXIT);
-       }       
+               if (!compose_draft(c, COMPOSE_DRAFT_FOR_EXIT))
+                       return FALSE;
+               compose_list = compose_list->next;
+       }
+       return TRUE;
 }
 gboolean clean_quit(gpointer data)
 {
@@ -1441,7 +1445,11 @@ void app_will_exit(GtkWidget *widget, gpointer data)
        sc_exiting = TRUE;
        debug_print("exiting\n");
        if (compose_get_compose_list()) {
-               draft_all_messages();
+               if (!draft_all_messages()) {
+                       main_window_popup(mainwin);
+                       sc_exiting = FALSE;
+                       return;
+               }
        }
 
        if (prefs_common.warn_queued_on_exit && procmsg_have_queued_mails_fast()) {
@@ -1733,7 +1741,7 @@ static void lock_socket_input_cb(gpointer data,
                if (folders) g_ptr_array_free(folders, TRUE);
        } else if (!strncmp(buf, "select ", 7)) {
                const gchar *target = buf+7;
-               mainwindow_jump_to(target);
+               mainwindow_jump_to(target, TRUE);
        } else if (!strncmp(buf, "exit", 4)) {
                app_will_exit(NULL, mainwin);
        }
index bba078b9ae6b8f207bef21eea2cdc770c9ae2663..7ac43eaaae2ee6f11aa3d59da1267100a876cc0e 100644 (file)
@@ -4071,7 +4071,7 @@ void mainwindow_learn (MainWindow *mainwin, gboolean is_spam)
        summary_mark_as_spam(mainwin->summaryview, is_spam, NULL);
 }
 
-void mainwindow_jump_to(const gchar *target)
+void mainwindow_jump_to(const gchar *target, gboolean popup)
 {
        gchar *tmp = NULL;
        gchar *p = NULL;
@@ -4097,7 +4097,8 @@ void mainwindow_jump_to(const gchar *target)
        if ((item = folder_find_item_from_identifier(tmp))) {
                printf("selecting folder '%s'\n", tmp);
                folderview_select(mainwin->folderview, item);
-               main_window_popup(mainwin);
+               if (popup)
+                       main_window_popup(mainwin);
                g_free(tmp);
                return;
        }
@@ -4115,7 +4116,8 @@ void mainwindow_jump_to(const gchar *target)
                        printf("selecting message %d\n", atoi(msg));
                        summary_select_by_msgnum(mainwin->summaryview, atoi(msg));
                        summary_display_msg_selected(mainwin->summaryview, FALSE);
-                       main_window_popup(mainwin);
+                       if (popup)
+                               main_window_popup(mainwin);
                        g_free(tmp);
                        return;
                } else if (item && msg[0] == '<' && msg[strlen(msg)-1] == '>') {
@@ -4127,7 +4129,8 @@ void mainwindow_jump_to(const gchar *target)
                                printf("selecting message %s\n", msg);
                                summary_select_by_msgnum(mainwin->summaryview, msginfo->msgnum);
                                summary_display_msg_selected(mainwin->summaryview, FALSE);
-                               main_window_popup(mainwin);
+                               if (popup)
+                                       main_window_popup(mainwin);
                                g_free(tmp);
                                procmsg_msginfo_free(msginfo);
                                return;
index e3c0184bef8be9ab9e774c17ff247469e00bc58c..ed9c941955192f32c03b48317f1517907dbd0007 100644 (file)
@@ -203,7 +203,8 @@ gboolean mainwindow_key_pressed                   (GtkWidget         *widget,
 MainWindow *mainwindow_get_mainwindow        (void);
 void mainwindow_learn                        (MainWindow *mainwin,
                                               gboolean is_spam);
-void mainwindow_jump_to                              (const gchar       *target);
+void mainwindow_jump_to                              (const gchar       *target,
+                                              gboolean popup);
 void mainwindow_show_error                   (void);
 void mainwindow_clear_error                  (MainWindow *mainwin);
 gboolean mainwindow_is_obscured                      (void);