Let the user change his mind
authorColin Leroy <colin@colino.net>
Fri, 9 Jul 2004 17:59:54 +0000 (17:59 +0000)
committerColin Leroy <colin@colino.net>
Fri, 9 Jul 2004 17:59:54 +0000 (17:59 +0000)
ChangeLog-gtk2.claws
PATCHSETS
configure.ac
src/messageview.c
src/pop.c
src/pop.h

index b4dca08d571609514c5db4af5ec619e36414613e..f48dd6289b684e9baee95304f886e93e0c9633e4 100644 (file)
@@ -1,3 +1,12 @@
+2004-07-09 [colin]     0.9.11cvs17.21
+
+       * src/messageview.c
+       * src/pop.c
+       * src/pop.h
+               Allow user to change his mind
+               and postpone decision (by
+               unmarking the mail)
+
 2004-07-09 [colin]     0.9.11cvs17.20
 
        * src/messageview.c
index 3feef390f3e4d4cf6713ef3cc22a9f654f432d29..6d0ae3ed838152017af606963cecee908263b965 100644 (file)
--- a/PATCHSETS
+++ b/PATCHSETS
@@ -14,3 +14,4 @@
 ( cvs diff -u -r 1.94.2.13 -r 1.94.2.14 src/messageview.c; ) > 0.9.11cvs17.18.patchset
 ( cvs diff -u -r 1.56.2.7 -r 1.56.2.8 src/pop.c; ) > 0.9.11cvs17.19.patchset
 ( cvs diff -u -r 1.94.2.14 -r 1.94.2.15 src/messageview.c; cvs diff -u -r 1.56.2.8 -r 1.56.2.9 src/pop.c; cvs diff -u -r 1.17.2.5 -r 1.17.2.6 src/pop.h; ) > 0.9.11cvs17.20.patchset
+( cvs diff -u -r 1.94.2.15 -r 1.94.2.16 src/messageview.c; cvs diff -u -r 1.56.2.9 -r 1.56.2.10 src/pop.c; cvs diff -u -r 1.17.2.6 -r 1.17.2.7 src/pop.h; ) > 0.9.11cvs17.21.patchset
index 1a697bd4a264b9c2108efdbe1c1f99feb3554bde..1b1501cf7271cb21c1a84a137f002c871c46943f 100644 (file)
@@ -11,7 +11,7 @@ MINOR_VERSION=9
 MICRO_VERSION=11
 INTERFACE_AGE=0
 BINARY_AGE=0
-EXTRA_VERSION=17.20
+EXTRA_VERSION=17.21
 EXTRA_RELEASE=
 
 if test \( $EXTRA_VERSION -eq 0 \) -o \( "x$EXTRA_RELEASE" != "x" \); then
index 05926212ac8182b91bfd4a4c1a0734db1dee8347..5334a3a764a9b4d15f2627647ffc332da79e234d 100644 (file)
@@ -80,9 +80,11 @@ static void return_receipt_send_clicked (NoticeView  *noticeview,
                                          MsgInfo        *msginfo);
 static void partial_recv_show          (NoticeView     *noticeview, 
                                         MsgInfo        *msginfo);      
-static void partial_recv_dload_clicked (NoticeView     *noticeview, 
+static void partial_recv_dload_clicked         (NoticeView     *noticeview, 
                                          MsgInfo        *msginfo);
-static void partial_recv_del_clicked (NoticeView       *noticeview, 
+static void partial_recv_del_clicked   (NoticeView     *noticeview, 
+                                         MsgInfo        *msginfo);
+static void partial_recv_unmark_clicked (NoticeView    *noticeview, 
                                          MsgInfo        *msginfo);
 static void save_as_cb                 (gpointer        data,
                                         guint           action,
@@ -1085,21 +1087,23 @@ static void partial_recv_show(NoticeView *noticeview, MsgInfo *msginfo)
                break;
        case POP3_PARTIAL_DLOAD_DLOAD:
                text = g_strdup_printf(_("This message has been partially "
-                               "retrieved and is planned for "
-                               "download;\nit is %s."),
+                               "retrieved;\nit is %s and will be downloaded."),
                                to_human_readable(
                                        (off_t)(msginfo->total_size)));
-               button1 = _("Mark for deletion");
-               button1_cb = partial_recv_del_clicked;
+               button1 = _("Unmark");
+               button1_cb = partial_recv_unmark_clicked;
+               button2 = _("Mark for deletion");
+               button2_cb = partial_recv_del_clicked;
                break;
        case POP3_PARTIAL_DLOAD_DELE:
                text = g_strdup_printf(_("This message has been partially "
-                               "retrieved and is planned for "
-                               "deletion;\nit is %s."),
+                               "retrieved;\nit is %s. and will be deleted."),
                                to_human_readable(
                                        (off_t)(msginfo->total_size)));
                button1 = _("Mark for download");
                button1_cb = partial_recv_dload_clicked;
+               button2 = _("Unmark");
+               button2_cb = partial_recv_unmark_clicked;
                break;
        default:
                return;
@@ -1176,6 +1180,33 @@ static void partial_recv_del_clicked(NoticeView *noticeview,
        g_free(file);
 }
 
+static void partial_recv_unmark_clicked(NoticeView *noticeview, 
+                                      MsgInfo *msginfo)
+{
+       MsgInfo *tmpmsginfo;
+       gchar *file;
+
+       file = procmsg_get_message_file_path(msginfo);
+       if (!file) {
+               g_warning("can't get message file path.\n");
+               return;
+       }
+
+       tmpmsginfo = procheader_parse_file(file, msginfo->flags, TRUE, TRUE);
+       tmpmsginfo->folder = msginfo->folder;
+       tmpmsginfo->msgnum = msginfo->msgnum;
+
+       if (pop3_unmark(tmpmsginfo->account_server, 
+                       tmpmsginfo->account_login, 
+                       tmpmsginfo->partial_recv, file) == 0) {
+               msginfo->planned_download = POP3_PARTIAL_DLOAD_UNKN;
+               partial_recv_show(noticeview, msginfo);
+       }
+
+       procmsg_msginfo_free(tmpmsginfo);
+       g_free(file);
+}
+
 static void select_account_cb(GtkWidget *w, gpointer data)
 {
        *(gint*)data = GPOINTER_TO_INT(gtk_object_get_user_data(GTK_OBJECT(w)));
index 966f295a825e5de0e9b3a46f671752721288a551..6054ce9beb13bc1b5e39d3c33816c84e32561698 100644 (file)
--- a/src/pop.c
+++ b/src/pop.c
@@ -781,10 +781,13 @@ static int pop3_uidl_mark_mail(const gchar *server, const gchar *login,
                        fprintf(fpnew, "%s\t%ld\t%s\n", 
                                uidl, recv_time, partial_recv);
                } else {
+                       gchar *stat = "0";
+                       if (download == POP3_PARTIAL_DLOAD_DLOAD)
+                               stat = filename;
+                       if (download == POP3_PARTIAL_DLOAD_UNKN)
+                               stat = "1";
                        fprintf(fpnew, "%s\t%ld\t%s\n", 
-                               uidl, recv_time, 
-                               download == POP3_PARTIAL_DLOAD_DLOAD
-                                        ? filename : "0");
+                               uidl, recv_time, stat);
                }
        }
        fclose(fpnew);
@@ -811,9 +814,10 @@ static int pop3_uidl_mark_mail(const gchar *server, const gchar *login,
                buf[len]='\0';
                if (start) {
                        start = FALSE;
-                       fprintf(fpnew, "SC-Marked-For-Download: %d\n", 
-                               download);
-                       printf("buf '%s'\n", buf);
+                       if (download != POP3_PARTIAL_DLOAD_UNKN)
+                               fprintf(fpnew, "SC-Marked-For-Download: %d\n", 
+                                       download);
+                       
                        if(strlen(buf) > strlen("SC-Marked-For-Download: x\n")
                        && !strncmp(buf, "SC-Marked-For-Download:", 
                                    strlen("SC-Marked-For-Download:"))) {
@@ -841,12 +845,19 @@ int pop3_mark_for_delete(const gchar *server, const gchar *login,
 }
 
 int pop3_mark_for_download(const gchar *server, const gchar *login, 
-                        const gchar *muidl, const gchar *filename)
+                         const gchar *muidl, const gchar *filename)
 {
        return pop3_uidl_mark_mail(server, login, muidl, filename, 
                POP3_PARTIAL_DLOAD_DLOAD);
 }
 
+int pop3_unmark(const gchar *server, const gchar *login, 
+               const gchar *muidl, const gchar *filename)
+{
+       return pop3_uidl_mark_mail(server, login, muidl, filename, 
+               POP3_PARTIAL_DLOAD_UNKN);
+}
+
 gint pop3_write_uidl_list(Pop3Session *session)
 {
        gchar *path;
index 044c77c284ae5a0a5e9c872807de84e12a1a27ee..45198af9e5ab88c83d867d17a4be49012e6d1ed7 100644 (file)
--- a/src/pop.h
+++ b/src/pop.h
@@ -173,5 +173,9 @@ int pop3_mark_for_delete    (const gchar    *server,
                                 const gchar    *login, 
                                 const gchar    *uidl, 
                                 const gchar    *filename);
+int pop3_unmark                        (const gchar    *server, 
+                                const gchar    *login, 
+                                const gchar    *uidl, 
+                                const gchar    *filename);
 
 #endif /* __POP_H__ */