/*
- * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
- * Copyright (C) 1999-2013 Hiroyuki Yamamoto and the Claws Mail team
+ * Claws Mail -- a GTK+ based, lightweight, and fast e-mail client
+ * Copyright (C) 1999-2016 Hiroyuki Yamamoto and the Claws Mail team
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
*/
#include "defs.h"
#include "statusbar.h"
#include "folder_item_prefs.h"
#include "avatars.h"
-#ifndef USE_NEW_ADDRBOOK
+#ifndef USE_ALT_ADDRBOOK
#include "addressbook.h"
#else
#include "addressadd.h"
{"View/Goto/ParentMessage", NULL, N_("Parent message"), "<control>Up", NULL, G_CALLBACK(parent_cb) },
/* {"View/Goto/---", NULL, "---", NULL, NULL, NULL }, */
{"View/Goto/NextUnreadFolder", NULL, N_("Next unread _folder"), "<shift>G", NULL, G_CALLBACK(goto_unread_folder_cb) },
- {"View/Goto/OtherFolder", NULL, N_("_Other folder..."), "G", NULL, G_CALLBACK(goto_folder_cb) },
+ {"View/Goto/Folder", NULL, N_("F_older..."), "G", NULL, G_CALLBACK(goto_folder_cb) },
/* {"View/Goto/---", NULL, "---", NULL, NULL, NULL }, */
{"View/Goto/NextPart", NULL, N_("Next part"), "A", NULL, G_CALLBACK(goto_next_part_cb) },
{"View/Goto/PrevPart", NULL, N_("Previous part"), "Z", NULL, G_CALLBACK(goto_prev_part_cb) },
MENUITEM_ADDUI_MANAGER(msgview->ui_manager, "/Menu/View/Goto", "ParentMessage", "View/Goto/ParentMessage", GTK_UI_MANAGER_MENUITEM)
MENUITEM_ADDUI_MANAGER(msgview->ui_manager, "/Menu/View/Goto", "Separator7", "View/Goto/---", GTK_UI_MANAGER_SEPARATOR)
MENUITEM_ADDUI_MANAGER(msgview->ui_manager, "/Menu/View/Goto", "NextUnreadFolder", "View/Goto/NextUnreadFolder", GTK_UI_MANAGER_MENUITEM)
- MENUITEM_ADDUI_MANAGER(msgview->ui_manager, "/Menu/View/Goto", "OtherFolder", "View/Goto/OtherFolder", GTK_UI_MANAGER_MENUITEM)
+ MENUITEM_ADDUI_MANAGER(msgview->ui_manager, "/Menu/View/Goto", "Folder", "View/Goto/Folder", GTK_UI_MANAGER_MENUITEM)
MENUITEM_ADDUI_MANAGER(msgview->ui_manager, "/Menu/View/Goto", "Separator8", "View/Goto/---", GTK_UI_MANAGER_SEPARATOR)
MENUITEM_ADDUI_MANAGER(msgview->ui_manager, "/Menu/View/Goto", "NextPart", "View/Goto/NextPart", GTK_UI_MANAGER_MENUITEM)
MENUITEM_ADDUI_MANAGER(msgview->ui_manager, "/Menu/View/Goto", "PrevPart", "View/Goto/PrevPart", GTK_UI_MANAGER_MENUITEM)
return info;
}
+static gboolean messageview_try_select_mimeinfo(MessageView *messageview, MsgInfo *msginfo, MimeInfo *mimeinfo)
+{
+ if (mimeinfo->type == MIMETYPE_TEXT) {
+ if (!strcasecmp(mimeinfo->subtype, "calendar")
+ && mimeview_has_viewer_for_content_type(messageview->mimeview, "text/calendar")) {
+ mimeview_select_mimepart_icon(messageview->mimeview, mimeinfo);
+ return TRUE;
+ } else if (!strcasecmp(mimeinfo->subtype, "html")
+ && mimeinfo->disposition != DISPOSITIONTYPE_ATTACHMENT
+ && (msginfo->folder->prefs->promote_html_part == HTML_PROMOTE_ALWAYS
+ || (msginfo->folder->prefs->promote_html_part == HTML_PROMOTE_DEFAULT
+ && prefs_common.promote_html_part))) {
+ mimeview_select_mimepart_icon(messageview->mimeview, mimeinfo);
+ return TRUE;
+ }
+ }
+ return FALSE;
+}
+
+static void messageview_find_part_depth_first(MimeInfoSearch *context, MimeMediaType type, const gchar *subtype)
+{
+ MimeInfo * mimeinfo = context->current;
+
+ if (!mimeinfo)
+ return;
+
+ debug_print("found part %d/%s\n", mimeinfo->type, mimeinfo->subtype);
+
+ if (mimeinfo->type == MIMETYPE_MULTIPART) {
+ if (!strcasecmp(mimeinfo->subtype, "alternative")
+ || !strcasecmp(mimeinfo->subtype, "related")) {
+ context->found = procmime_mimeinfo_next(mimeinfo);
+ while (context->found && context->found != context->parent) {
+ if (context->found->type == type
+ && !strcasecmp(context->found->subtype, subtype))
+ break;
+ context->found = procmime_mimeinfo_next(context->found);
+ }
+ if (context->found == context->parent)
+ context->found = NULL;
+ }
+ if (!context->found
+ && (!strcasecmp(mimeinfo->subtype, "related")
+ || !strcasecmp(mimeinfo->subtype, "mixed"))) {
+ context->parent = mimeinfo;
+ context->current = procmime_mimeinfo_next(mimeinfo);
+ messageview_find_part_depth_first(context, type, subtype);
+ }
+ }
+}
+
gint messageview_show(MessageView *messageview, MsgInfo *msginfo,
gboolean all_headers)
{
}
if (messageview->msginfo != msginfo) {
- procmsg_msginfo_free(messageview->msginfo);
+ procmsg_msginfo_free(&(messageview->msginfo));
messageview->msginfo = NULL;
messageview_set_menu_sensitive(messageview);
messageview->msginfo =
root = mimeinfo;
mimeinfo = procmime_mimeinfo_next(mimeinfo);
- if (!all_headers && mimeinfo
- && (mimeinfo->type != MIMETYPE_TEXT ||
- strcasecmp(mimeinfo->subtype, "plain"))
- && (mimeinfo->type != MIMETYPE_MULTIPART ||
- strcasecmp(mimeinfo->subtype, "signed"))) {
- if (strcasecmp(mimeinfo->subtype, "html")) {
- MimeInfo *saved_mimeinfo = mimeinfo;
- MimeInfo *alt_parent = mimeinfo;
-
- /* if multipart/{related,mixed} part, look inside for a multipart/alternative child */
- if (mimeinfo->type == MIMETYPE_MULTIPART &&
- (!strcasecmp(mimeinfo->subtype, "related") ||
- !strcasecmp(mimeinfo->subtype, "mixed"))) {
- for (; mimeinfo; mimeinfo = procmime_mimeinfo_next(mimeinfo)) {
- if (mimeinfo->node->parent != saved_mimeinfo->node) {
- /* only consider children of the
- * multipart/{related,mixed} part */
- continue;
- }
- if (mimeinfo->type == MIMETYPE_MULTIPART &&
- !strcasecmp(mimeinfo->subtype, "alternative")) {
- /* we got an alternative part */
- alt_parent = mimeinfo;
- break;
- }
- if (mimeinfo->type == MIMETYPE_TEXT &&
- !strcasecmp(mimeinfo->subtype, "calendar") &&
- mimeview_has_viewer_for_content_type(messageview->mimeview,
- "text/calendar")) {
- mimeview_select_mimepart_icon(messageview->mimeview, mimeinfo);
- goto done;
- } else if (mimeinfo->type == MIMETYPE_TEXT &&
- !strcasecmp(mimeinfo->subtype, "html") &&
- mimeinfo->disposition != DISPOSITIONTYPE_ATTACHMENT &&
- (msginfo->folder->prefs->promote_html_part == HTML_PROMOTE_ALWAYS ||
- (msginfo->folder->prefs->promote_html_part == HTML_PROMOTE_DEFAULT &&
- prefs_common.promote_html_part))) {
- mimeview_select_mimepart_icon(messageview->mimeview, mimeinfo);
+ if (!all_headers && mimeinfo
+ && (mimeinfo->type != MIMETYPE_TEXT
+ || strcasecmp(mimeinfo->subtype, "plain"))
+ && (mimeinfo->type != MIMETYPE_MULTIPART
+ || strcasecmp(mimeinfo->subtype, "signed"))) {
+ if (strcasecmp(mimeinfo->subtype, "html")) {
+ MimeInfoSearch context = {
+ .parent = root,
+ .current = mimeinfo,
+ .found = NULL
+ };
+ if (mimeview_has_viewer_for_content_type(messageview->mimeview, "text/calendar")) {
+ MimeInfoSearch cal_context = context;
+ messageview_find_part_depth_first(&cal_context, MIMETYPE_TEXT, "calendar");
+ if (cal_context.found) { /* calendar found */
+ mimeinfo = cal_context.found;
+ if (messageview_try_select_mimeinfo(messageview, msginfo, mimeinfo))
goto done;
- }
}
}
-
- /* if we now have a multipart/alternative part (possibly inside a
- * multipart/{related,mixed} part, look for an HTML part inside */
- if (mimeinfo && mimeinfo->type == MIMETYPE_MULTIPART &&
- !strcasecmp(mimeinfo->subtype, "alternative")) {
- for (; mimeinfo; mimeinfo = procmime_mimeinfo_next(mimeinfo)) {
- if (mimeinfo->node->parent != alt_parent->node) {
- /* only consider children of the
- * multipart/alternative part, so as
- * not to show html attachments */
- continue;
- }
-
- if (mimeinfo->type == MIMETYPE_TEXT &&
- !strcasecmp(mimeinfo->subtype, "calendar") &&
- mimeview_has_viewer_for_content_type(messageview->mimeview,
- "text/calendar")) {
- mimeview_select_mimepart_icon(messageview->mimeview, mimeinfo);
- goto done;
- } else if (mimeinfo->type == MIMETYPE_TEXT &&
- !strcasecmp(mimeinfo->subtype, "html") &&
- mimeinfo->disposition != DISPOSITIONTYPE_ATTACHMENT &&
- (msginfo->folder->prefs->promote_html_part == HTML_PROMOTE_ALWAYS ||
- (msginfo->folder->prefs->promote_html_part == HTML_PROMOTE_DEFAULT &&
- prefs_common.promote_html_part))) {
- mimeview_select_mimepart_icon(messageview->mimeview, mimeinfo);
- goto done;
- }
- }
- }
-
- /* if we didn't find anything, go back to start */
- if (!mimeinfo)
- mimeinfo = saved_mimeinfo;
+ messageview_find_part_depth_first(&context, MIMETYPE_TEXT, "html");
+ if (context.found &&
+ (msginfo->folder->prefs->promote_html_part == HTML_PROMOTE_ALWAYS ||
+ (msginfo->folder->prefs->promote_html_part == HTML_PROMOTE_DEFAULT &&
+ prefs_common.promote_html_part))) { /* html found */
+ mimeinfo = context.found;
+ if (messageview_try_select_mimeinfo(messageview, msginfo, mimeinfo))
+ goto done;
+ } else
+ mimeinfo = root; /* nothing found */
if (!mimeview_show_part(messageview->mimeview, mimeinfo))
mimeview_select_mimepart_icon(messageview->mimeview, root);
{
if (!messageview)
return;
- procmsg_msginfo_free(messageview->msginfo);
+ procmsg_msginfo_free(&(messageview->msginfo));
messageview->msginfo = NULL;
messageview->filtered = FALSE;
mimeview_destroy(messageview->mimeview);
noticeview_destroy(messageview->noticeview);
- procmsg_msginfo_free(messageview->msginfo);
+ procmsg_msginfo_free(&(messageview->msginfo));
toolbar_clear_list(TOOLBAR_MSGVIEW);
if (messageview->toolbar) {
toolbar_destroy(messageview->toolbar);
if (from_me) {
noticeview_set_icon(noticeview, STOCK_PIXMAP_NOTICE_WARN);
if (MSG_IS_RETRCPT_GOT(msginfo->flags)) {
- noticeview_set_text(noticeview, _("You got a return receipt for this message : "
+ noticeview_set_text(noticeview, _("You got a return receipt for this message: "
"it has been displayed by the recipient."));
} else {
noticeview_set_text(noticeview, _("You asked for a return receipt in this message."));
noticeview_hide(noticeview);
}
- procmsg_msginfo_free(tmpmsginfo);
+ procmsg_msginfo_free(&tmpmsginfo);
g_free(file);
}
messageview_show(messageview, info,
messageview->all_headers);
messageview->updating = FALSE;
- procmsg_msginfo_free(info);
+ procmsg_msginfo_free(&info);
if (messageview->deferred_destroy) {
debug_print("messageview got away!\n");
messageview_destroy(messageview);
messageview_show(messageview, info,
messageview->all_headers);
messageview->updating = FALSE;
- procmsg_msginfo_free(info);
+ procmsg_msginfo_free(&info);
if (messageview->deferred_destroy) {
debug_print("messageview got away!\n");
messageview_destroy(messageview);
if (!msginfo) return;
messageview->msginfo = NULL;
messageview_show(messageview, msginfo, messageview->all_headers);
- procmsg_msginfo_free(msginfo);
+ procmsg_msginfo_free(&msginfo);
main_window_set_menu_sensitive(messageview->mainwin);
summary_redisplay_msg(messageview->mainwin->summaryview);
}
messageview->msginfo = NULL;
messageview_show(messageview, msginfo,
messageview->all_headers);
- procmsg_msginfo_free(msginfo);
+ procmsg_msginfo_free(&msginfo);
/* update main window */
main_window_set_menu_sensitive(messageview->mainwin);
static void addressbook_open_cb(GtkAction *action, gpointer data)
{
-#ifndef USE_NEW_ADDRBOOK
+#ifndef USE_ALT_ADDRBOOK
addressbook_open(NULL);
#else
GError* error = NULL;
avatarr = avatars_avatarrender_new(full_msginfo);
hooks_invoke(AVATAR_IMAGE_RENDER_HOOKLIST, avatarr);
- procmsg_msginfo_free(full_msginfo);
+ procmsg_msginfo_free(&full_msginfo);
if (avatarr->image != NULL)
picture = gtk_image_get_pixbuf(GTK_IMAGE(avatarr->image));
-#ifndef USE_NEW_ADDRBOOK
+#ifndef USE_ALT_ADDRBOOK
addressbook_add_contact(msginfo->fromname, from, NULL, picture);
#else
if (addressadd_selection(msginfo->fromname, from, NULL, picture)) {