2004-11-18 [paul] 0.9.12cvs158.1
[claws.git] / src / messageview.c
index a98e56f5bc9210b7365a22d93ee7c23e27232f28..ffd6319fd15142a7a6c509418f4a5cce2b5d40e2 100644 (file)
@@ -57,7 +57,6 @@
 #include "prefs_account.h"
 #include "gtkutils.h"
 #include "utils.h"
-#include "rfc2015.h"
 #include "send_message.h"
 #include "stock_pixmap.h"
 #include "hooks.h"
@@ -108,6 +107,9 @@ static void search_cb                       (gpointer        data,
 static void set_charset_cb             (gpointer        data,
                                         guint           action,
                                         GtkWidget      *widget);
+static void set_decode_cb              (gpointer        data,
+                                        guint           action,
+                                        GtkWidget      *widget);
 static void view_source_cb             (gpointer        data,
                                         guint           action,
                                         GtkWidget      *widget);
@@ -246,6 +248,22 @@ static GtkItemFactoryEntry msgview_entries[] =
 #undef CODESET_SEPARATOR
 #undef CODESET_ACTION
 
+#define DECODE_SEPARATOR \
+       {N_("/_View/Decode/---"),               NULL, NULL, 0, "<Separator>"}
+#define DECODE_ACTION(action) \
+        NULL, set_decode_cb, action, "/View/Decode/Auto detect"
+       {N_("/_View/Decode"),           NULL, NULL, 0, "<Branch>"},
+       {N_("/_View/Decode/_Auto detect"),
+        NULL, set_decode_cb, 0, "<RadioItem>"},
+       {N_("/_View/Decode/---"),               NULL, NULL, 0, "<Separator>"},
+       {N_("/_View/Decode/_8bit"),             DECODE_ACTION(ENC_8BIT)},
+       {N_("/_View/Decode/_Quoted printable"), DECODE_ACTION(ENC_QUOTED_PRINTABLE)},
+       {N_("/_View/Decode/_Base64"),           DECODE_ACTION(ENC_BASE64)},
+       {N_("/_View/Decode/_Uuencode"),         DECODE_ACTION(ENC_X_UUENCODE)},
+
+#undef DECODE_SEPARATOR
+#undef DECODE_ACTION
+
        {N_("/_View/---"),              NULL, NULL, 0, "<Separator>"},
        {N_("/_View/Mess_age source"),  NULL, view_source_cb, 0, NULL},
        {N_("/_View/Show all _headers"),NULL, show_all_header_cb, 0, "<ToggleItem>"},
@@ -625,7 +643,7 @@ static gint disposition_notification_send(MsgInfo *msginfo)
        fprintf(fp, "Subject: Disposition notification: %s\n", buf);
 
        /* Message ID */
-       generate_msgid(account->address, buf, sizeof buf);
+       generate_msgid(buf, sizeof(buf));
        fprintf(fp, "Message-ID: <%s>\n", buf);
 
        if (fclose(fp) == EOF) {
@@ -943,7 +961,7 @@ void messageview_save_as(MessageView *messageview)
 {
        gchar *filename = NULL;
        MsgInfo *msginfo;
-       gchar *src, *dest;
+       gchar *src, *dest, *tmp;
 
        if (!messageview->msginfo) return;
        msginfo = messageview->msginfo;
@@ -965,9 +983,11 @@ void messageview_save_as(MessageView *messageview)
 
        src = procmsg_get_message_file(msginfo);
        if (copy_file(src, dest, TRUE) < 0) {
-               alertpanel_error(_("Can't save the file `%s'."),
-                                g_basename(dest));
+               tmp =  g_path_get_basename(dest);
+               alertpanel_error(_("Can't save the file `%s'."), tmp);
+               g_free(tmp);
        }
+       g_free(dest);
        g_free(src);
 }
 
@@ -1072,44 +1092,46 @@ static void partial_recv_show(NoticeView *noticeview, MsgInfo *msginfo)
        void  *button2_cb = NULL;
 
        if (!partial_msg_in_uidl_list(msginfo)) {
-               /* in case it was there from previous mail */
-               noticeview_hide(noticeview);
-               return;
-       }
-
-       switch (msginfo->planned_download) {
-       case POP3_PARTIAL_DLOAD_UNKN:
                text = g_strdup_printf(_("This message has been partially "
-                               "retrieved;\nit is %s."),
-                               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 POP3_PARTIAL_DLOAD_DLOAD:
-               text = g_strdup_printf(_("This message has been partially "
-                               "retrieved;\nit is %s and will be downloaded."),
-                               to_human_readable(
-                                       (off_t)(msginfo->total_size)));
-               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;\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;
+                               "retrieved,\nand has been deleted from the "
+                               "server."));
+       } else {
+               switch (msginfo->planned_download) {
+               case POP3_PARTIAL_DLOAD_UNKN:
+                       text = g_strdup_printf(_("This message has been "
+                                       "partially retrieved;\nit is %s."),
+                                       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 POP3_PARTIAL_DLOAD_DLOAD:
+                       text = g_strdup_printf(_("This message has been "
+                                       "partially retrieved;\nit is %s and "
+                                       "will be downloaded."),
+                                       to_human_readable(
+                                               (off_t)(msginfo->total_size)));
+                       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;\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;
+               }
        }
        
        noticeview_set_text(noticeview, text);
@@ -1151,7 +1173,7 @@ static void partial_recv_unmark_clicked(NoticeView *noticeview,
 
 static void select_account_cb(GtkWidget *w, gpointer data)
 {
-       *(gint*)data = GPOINTER_TO_INT(gtk_object_get_user_data(GTK_OBJECT(w)));
+       *(gint*)data = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(w), MENU_VAL_ID));
 }
        
 static PrefsAccount *select_account_from_list(GList *ac_list)
@@ -1288,10 +1310,25 @@ static void set_charset_cb(gpointer data, guint action, GtkWidget *widget)
                charset = conv_get_charset_str((CharSet)action);
                g_free(messageview->forced_charset);
                messageview->forced_charset = g_strdup(charset);
+               procmime_force_charset(charset);
+               
+               messageview_show(messageview, messageview->msginfo, FALSE);
+       }
+}
+
+static void set_decode_cb(gpointer data, guint action, GtkWidget *widget)
+{
+       MessageView *messageview = (MessageView *)data;
+       if (GTK_CHECK_MENU_ITEM(widget)->active) {
+               messageview->forced_encoding = (EncodingType)action;
+
                messageview_show(messageview, messageview->msginfo, FALSE);
+               
+               debug_print("forced encoding: %d\n", action);
        }
 }
 
+
 static void view_source_cb(gpointer data, guint action, GtkWidget *widget)
 {
        MessageView *messageview = (MessageView *)data;