2006-09-04 [colin] 2.4.0cvs143
[claws.git] / src / messageview.c
index 99fbc73c36ba9280640e681e1fa3dbf6c05d9e60..b1d065b05c37b201be883c2949c38d7fc4b3fd24 100644 (file)
@@ -532,15 +532,17 @@ static gint disposition_notification_send(MsgInfo *msginfo)
         gchar *addr;
         gchar *addrp;
        gchar *foo = NULL;
-       if ((!msginfo->returnreceiptto) && 
-           (!msginfo->dispositionnotificationto)) 
+       if (!msginfo->extradata)
+               return -1;
+       if (!msginfo->extradata->returnreceiptto && 
+           !msginfo->extradata->dispositionnotificationto) 
                return -1;
 
        /* RFC2298: Test for Return-Path */
-       if (msginfo->dispositionnotificationto)
-               to = msginfo->dispositionnotificationto;
+       if (msginfo->extradata->dispositionnotificationto)
+               to = msginfo->extradata->dispositionnotificationto;
        else
-               to = msginfo->returnreceiptto;
+               to = msginfo->extradata->returnreceiptto;
 
        ok = procheader_get_header_from_msginfo(msginfo, buf, sizeof(buf),
                                "Return-Path:");
@@ -711,7 +713,7 @@ static gint disposition_notification_send(MsgInfo *msginfo)
 
        /* send it */
        path = folder_item_fetch_msg(queue, num);
-       ok = procmsg_send_message_queue(path, &foo);
+       ok = procmsg_send_message_queue(path, &foo, queue, num);
        g_free(path);
        g_free(foo);
        folder_item_remove_msg(queue, num);
@@ -828,6 +830,8 @@ gint messageview_show(MessageView *messageview, MsgInfo *msginfo,
        }
        headerview_show(messageview->headerview, messageview->msginfo);
 
+       messageview_set_position(messageview, 0);
+
        textview_set_all_headers(messageview->mimeview->textview, 
                        messageview->all_headers);
 
@@ -850,15 +854,15 @@ gint messageview_show(MessageView *messageview, MsgInfo *msginfo,
                g_free(subject);
        }
 
-       messageview_set_position(messageview, 0);
-
        main_create_mailing_list_menu(messageview->mainwin, messageview->msginfo);
 
-       if (messageview->msginfo->partial_recv)
+       if (messageview->msginfo->extradata
+           && messageview->msginfo->extradata->partial_recv)
                partial_recv_show(messageview->noticeview, 
                                  messageview->msginfo);
-       else if ((messageview->msginfo->dispositionnotificationto || 
-            messageview->msginfo->returnreceiptto) &&
+       else if (messageview->msginfo->extradata &&
+           (messageview->msginfo->extradata->dispositionnotificationto || 
+            messageview->msginfo->extradata->returnreceiptto) &&
            !MSG_IS_RETRCPT_SENT(messageview->msginfo->flags) &&
            !prefs_common.never_send_retrcpt)
                return_receipt_show(messageview->noticeview, 
@@ -868,11 +872,11 @@ gint messageview_show(MessageView *messageview, MsgInfo *msginfo,
 
        mimeinfo = procmime_mimeinfo_next(mimeinfo);
        if (mimeinfo && (mimeinfo->type != MIMETYPE_TEXT || 
-           strcmp(mimeinfo->subtype, "plain"))) {
-               if (strcmp(mimeinfo->subtype, "html"))
+           strcasecmp(mimeinfo->subtype, "plain"))) {
+               if (strcasecmp(mimeinfo->subtype, "html"))
                        mimeview_show_part(messageview->mimeview,mimeinfo);
                else if (prefs_common.invoke_plugin_on_html)
-                       mimeview_show_part(messageview->mimeview,mimeinfo);
+                       mimeview_select_mimepart_icon(messageview->mimeview,mimeinfo);
        }
 
        g_free(file);
@@ -913,11 +917,20 @@ void messageview_destroy(MessageView *messageview)
        }
 
        if (messageview->updating) {
-               debug_print("uh oh, better not touch that now\n");
+               debug_print("uh oh, better not touch that now (fetching)\n");
                messageview->deferred_destroy = TRUE;
                gtk_widget_hide(messageview->window);
                return;
        }
+       
+       if (messageview->mimeview->textview
+       &&  messageview->mimeview->textview->loading) {
+               debug_print("uh oh, better not touch that now (loading text)\n");
+               messageview->deferred_destroy = TRUE;
+               messageview->mimeview->textview->stop_loading = TRUE;
+               gtk_widget_hide(messageview->window);
+               return;
+       }
 
        headerview_destroy(messageview->headerview);
        mimeview_destroy(messageview->mimeview);
@@ -1171,7 +1184,6 @@ void messageview_toggle_view_real(MessageView *messageview)
        union CompositeWin *cwin = &mainwin->win;
        GtkWidget *vpaned = NULL;
        GtkWidget *container = NULL;
-       GtkItemFactory *ifactory = gtk_item_factory_from_widget(mainwin->menubar);
        
        switch (mainwin->type) {
        case SEPARATE_NONE:
@@ -1186,33 +1198,37 @@ void messageview_toggle_view_real(MessageView *messageview)
        case SEPARATE_BOTH:
                return;
        }
-
-       if (vpaned->parent != NULL) {
-               gtk_widget_ref(vpaned);
-               gtkut_container_remove(GTK_CONTAINER(container), vpaned);
-               gtk_widget_reparent(GTK_WIDGET_PTR(messageview), container);
-               menu_set_sensitive(ifactory, "/View/Expand Summary View", FALSE);
-       } else {
-               gtk_widget_reparent(GTK_WIDGET_PTR(messageview), vpaned);
-               gtk_container_add(GTK_CONTAINER(container), vpaned);
-               gtk_widget_unref(vpaned);
-               menu_set_sensitive(ifactory, "/View/Expand Summary View", TRUE);
-               gtk_widget_grab_focus(GTK_WIDGET(mainwin->summaryview->ctree));
-       }
 }
 
 static void return_receipt_show(NoticeView *noticeview, MsgInfo *msginfo)
 {
+       gchar *addr = NULL;
+       gboolean from_me = FALSE;
        if (msginfo->folder 
                && (folder_has_parent_of_type(msginfo->folder, F_QUEUE)
                 || folder_has_parent_of_type(msginfo->folder, F_DRAFT)))
                return;
 
-       noticeview_set_text(noticeview, _("This message asks for a return receipt."));
-       noticeview_set_button_text(noticeview, _("Send receipt"));
-       noticeview_set_button_press_callback(noticeview,
-                                            G_CALLBACK(return_receipt_send_clicked),
-                                            (gpointer) msginfo);
+       addr = g_strdup(msginfo->from);
+       if (addr) {
+               extract_address(addr);
+               if (account_find_from_address(addr)) {
+                       from_me = TRUE;
+               }
+               g_free(addr);
+       }
+
+       if (from_me) {
+               noticeview_set_text(noticeview, _("You asked for a return receipt in this message."));
+               noticeview_set_button_text(noticeview, NULL);
+               noticeview_set_button_press_callback(noticeview, NULL, NULL);
+       } else {
+               noticeview_set_text(noticeview, _("This message asks for a return receipt."));
+               noticeview_set_button_text(noticeview, _("Send receipt"));
+               noticeview_set_button_press_callback(noticeview,
+                                                    G_CALLBACK(return_receipt_send_clicked),
+                                                    (gpointer) msginfo);
+       }
        noticeview_show(noticeview);
 }
 
@@ -1248,6 +1264,8 @@ static void partial_recv_show(NoticeView *noticeview, MsgInfo *msginfo)
        void  *button1_cb = NULL;
        void  *button2_cb = NULL;
 
+       if (!msginfo->extradata)
+               return;
        if (!partial_msg_in_uidl_list(msginfo)) {
                text = g_strdup_printf(_("This message has been partially "
                                "retrieved,\nand has been deleted from the "
@@ -1381,6 +1399,15 @@ gchar *messageview_get_selection(MessageView *msgview)
        
        g_return_val_if_fail(msgview != NULL, NULL);
 
+       if (msgview->mimeview->type == MIMEVIEW_VIEWER) {
+               MimeViewer *viewer = msgview->mimeview->mimeviewer;
+               if (viewer && viewer->get_selection) {
+                       text = viewer->get_selection(viewer);
+                       if (text)
+                               return text;
+               }
+       }
+
        textview = messageview_get_current_textview(msgview);
        g_return_val_if_fail(textview != NULL, NULL);
 
@@ -1672,7 +1699,7 @@ void messageview_set_menu_sensitive(MessageView *messageview)
        ifactory = gtk_item_factory_from_widget(messageview->menubar);
        if (!ifactory) return;
        if (messageview->mainwin->type == SEPARATE_MESSAGE) {
-               menuitem = gtk_item_factory_get_widget(ifactory, "/View/Show all headers");
+               menuitem = gtk_item_factory_get_widget(ifactory, "/View/All headers");
                gtk_check_menu_item_set_active
                        (GTK_CHECK_MENU_ITEM(menuitem),
                         messageview->mimeview->textview->show_all_headers);