strlen checks, refactoring
authorColin Leroy <colin@colino.net>
Fri, 9 Jul 2004 07:06:34 +0000 (07:06 +0000)
committerColin Leroy <colin@colino.net>
Fri, 9 Jul 2004 07:06:34 +0000 (07:06 +0000)
ChangeLog-gtk2.claws
PATCHSETS
configure.ac
src/messageview.c
src/pop.c

index daf2a4660d6daf850cbd29d72648f40201d55daf..e043189501bf75c270244733895f11d96509d2ba 100644 (file)
@@ -1,3 +1,10 @@
+2004-07-09 [colin]     0.9.11cvs17.17
+
+       * src/pop.c
+               strlen checking...
+       * src/messageview.c
+               refactoring a bit
+
 2004-07-08 [colin]     0.9.11cvs17.16
 
        * src/noticeview.c
index 8827532ce0c72f34b2638961e6f12d421ef82947..91fbb2966e67c453ec73985acc0485cc368824ca 100644 (file)
--- a/PATCHSETS
+++ b/PATCHSETS
@@ -10,3 +10,4 @@
 ( cvs diff -u -r 1.94.2.9 -r 1.94.2.11 src/messageview.c; cvs diff -u -r 1.11.2.2 -r 1.11.2.4 src/common/smtp.c; ) > 0.9.11cvs17.14.patchset
 ( cvs diff -u -r 1.6.2.1 -r 1.6.2.2 src/common/smtp.h; ) > 0.9.11cvs17.15.patchset
 ( cvs diff -u -r 1.94.2.11 -r 1.94.2.12 src/messageview.c; cvs diff -u -r 1.5.2.3 -r 1.5.2.4 src/noticeview.c; cvs diff -u -r 1.3.8.1 -r 1.3.8.2 src/noticeview.h; cvs diff -u -r 1.56.2.5 -r 1.56.2.6 src/pop.c; cvs diff -u -r 1.17.2.4 -r 1.17.2.5 src/pop.h; ) > 0.9.11cvs17.16.patchset
+( cvs diff -u -r 1.56.2.6 -r 1.56.2.7 src/pop.c; cvs diff -u -r 1.94.2.12 -r 1.94.2.13 src/messageview.c; ) > 0.9.11cvs17.17.patchset
index c6d65fcfcbba04ef26f95715842ac20c1d32ecc5..985f81565141f4f7ba56ddeb6d5105fea9c23cad 100644 (file)
@@ -11,7 +11,7 @@ MINOR_VERSION=9
 MICRO_VERSION=11
 INTERFACE_AGE=0
 BINARY_AGE=0
-EXTRA_VERSION=17.16
+EXTRA_VERSION=17.17
 EXTRA_RELEASE=
 
 if test \( $EXTRA_VERSION -eq 0 \) -o \( "x$EXTRA_RELEASE" != "x" \); then
index cc8a74f1d03f9fe1c20acf78587c8f6faa14a963..bac3e9e11c65d9fb782e97d6eb1a67d52749f163 100644 (file)
@@ -1064,57 +1064,62 @@ static void return_receipt_send_clicked(NoticeView *noticeview, MsgInfo *msginfo
 static void partial_recv_show(NoticeView *noticeview, MsgInfo *msginfo)
 {
        gchar *text = NULL;
+       gchar *button1 = NULL;
+       gchar *button2 = NULL;
+       void  *button1_cb = NULL;
+       void  *button2_cb = NULL;
+
        if (!pop3_msg_in_uidl_list(msginfo->account_server, msginfo->account_login,
                                   msginfo->partial_recv))
                return;
-       if (msginfo->planned_download == 0) {
+       switch (msginfo->planned_download) {
+       case 0: /* unknown yet */
                text = g_strdup_printf(_("This message has been partially "
-                                "retrieved;\n it is %s large."), 
-                                to_human_readable(
-                                       (off_t)(msginfo->total_size)));
-
-               noticeview_set_text(noticeview, text);
-               g_free(text);
-               noticeview_set_button_text(noticeview, _("Mark for download"));
-               noticeview_set_button_press_callback(noticeview,
-                            GTK_SIGNAL_FUNC(partial_recv_dload_clicked),
-                            (gpointer) msginfo);
-               noticeview_set_2ndbutton_text(noticeview, _("Mark for deletion"));
-               noticeview_set_2ndbutton_press_callback(noticeview,
-                            GTK_SIGNAL_FUNC(partial_recv_del_clicked),
-                            (gpointer) msginfo);
-               noticeview_show(noticeview);
-       } else if (msginfo->planned_download == 1) {
+                               "retrieved;\nit is %s large."),
+                               to_human_readable(
+                                       (off_t)(msginfo->total_size)));
+               button1 = _("Mark for download");
+               button2 = _("Mark for deletion");
+               button1_cb = partial_recv_dload_clicked;
+               button2_cb = partial_recv_del_clicked;
+               break;
+       case 1:
                text = g_strdup_printf(_("This message has been partially "
-                                "retrieved and is planned for "
-                                "download;\n it is %s large."), 
-                                to_human_readable(
-                                       (off_t)(msginfo->total_size)));
-
-               noticeview_set_text(noticeview, text);
-               noticeview_set_button_text(noticeview, _("Mark for deletion"));
-               noticeview_set_2ndbutton_text(noticeview, NULL);
-               noticeview_set_button_press_callback(noticeview,
-                            GTK_SIGNAL_FUNC(partial_recv_del_clicked),
-                            (gpointer) msginfo);
-               g_free(text);
-               noticeview_show(noticeview);
-       } else if (msginfo->planned_download == -1) {
+                               "retrieved and is planned for "
+                               "download;\nit is %s large."),
+                               to_human_readable(
+                                       (off_t)(msginfo->total_size)));
+               button1 = _("Mark for deletion");
+               button1_cb = partial_recv_del_clicked;
+               break;
+       case -1:
                text = g_strdup_printf(_("This message has been partially "
-                                "retrieved and is planned for "
-                                "deletion;\n it is %s large."), 
-                                to_human_readable(
-                                       (off_t)(msginfo->total_size)));
+                               "retrieved and is planned for "
+                               "deletion;\nit is %s large."),
+                               to_human_readable(
+                                       (off_t)(msginfo->total_size)));
+               button1 = _("Mark for download");
+               button1_cb = partial_recv_dload_clicked;
+               break;
+       default:
+               return;
+       }
+       
+       noticeview_set_text(noticeview, text);
+       g_free(text);
+       noticeview_set_button_text(noticeview, button1);
+       noticeview_set_button_press_callback(noticeview,
+                    GTK_SIGNAL_FUNC(button1_cb), (gpointer) msginfo);
 
-               noticeview_set_text(noticeview, text);
-               noticeview_set_button_text(noticeview, _("Mark for download"));
+       if (button2 && button2_cb) {
+               noticeview_set_2ndbutton_text(noticeview, button2);
+               noticeview_set_2ndbutton_press_callback(noticeview,
+                            GTK_SIGNAL_FUNC(button2_cb), (gpointer) msginfo);
+       } else {
                noticeview_set_2ndbutton_text(noticeview, NULL);
-               noticeview_set_button_press_callback(noticeview,
-                            GTK_SIGNAL_FUNC(partial_recv_dload_clicked),
-                            (gpointer) msginfo);
-               g_free(text);
-               noticeview_show(noticeview);
        }
+
+       noticeview_show(noticeview);
 }
 
 static void partial_recv_dload_clicked(NoticeView *noticeview, 
index 20f4006af6466e19f2daab9bbc7af164fd8d6448..b78a12aaa01bbb830144d5b99198224464ea3097 100644 (file)
--- a/src/pop.c
+++ b/src/pop.c
@@ -720,7 +720,7 @@ static gchar *pop3_get_filename_for_partial_mail(Pop3Session *session,
 
 #define DOWNLOAD_MAIL 1
 #define DELETE_MAIL 2
-static int pop3_mark_mail(const gchar *server, const gchar *login, 
+static int pop3_uidl_mark_mail(const gchar *server, const gchar *login, 
                          const gchar *muidl, const gchar *filename, 
                          int download)
 {
@@ -810,11 +810,14 @@ static int pop3_mark_mail(const gchar *server, const gchar *login,
        while ((len = fread(buf, sizeof(gchar), sizeof(buf), fp)) > 0) {
                if (start) {
                        start = FALSE;
-                       fprintf(fpnew, "SC-Marked-For-Download: %d\n", download);
+                       fprintf(fpnew, "SC-Marked-For-Download: %d\n", 
+                               download);
                        printf("buf '%s'\n", buf);
-                       if(!strncmp(buf, "SC-Marked-For-Download:", 
+                       if(strlen(buf) > strlen("SC-Marked-For-Download: x\n")
+                       && !strncmp(buf, "SC-Marked-For-Download:", 
                                    strlen("SC-Marked-For-Download:"))) {
-                               fprintf(fpnew, "%s", buf+strlen("SC-Marked-For-Download: x\n"));
+                               fprintf(fpnew, "%s", 
+                                buf+strlen("SC-Marked-For-Download: x\n"));
                                continue;
                        }
                }
@@ -832,13 +835,15 @@ static int pop3_mark_mail(const gchar *server, const gchar *login,
 int pop3_mark_for_delete(const gchar *server, const gchar *login, 
                         const gchar *muidl, const gchar *filename)
 {
-       return pop3_mark_mail(server, login, muidl, filename, DELETE_MAIL);
+       return pop3_uidl_mark_mail(server, login, muidl, filename, 
+               DELETE_MAIL);
 }
 
 int pop3_mark_for_download(const gchar *server, const gchar *login, 
                         const gchar *muidl, const gchar *filename)
 {
-       return pop3_mark_mail(server, login, muidl, filename, DOWNLOAD_MAIL);
+       return pop3_uidl_mark_mail(server, login, muidl, filename, 
+               DOWNLOAD_MAIL);
 }
 
 gint pop3_write_uidl_list(Pop3Session *session)