diff options
author | hiro <hiro@ee746299-78ed-0310-b773-934348b2243d> | 2007-07-10 06:00:12 +0000 |
---|---|---|
committer | hiro <hiro@ee746299-78ed-0310-b773-934348b2243d> | 2007-07-10 06:00:12 +0000 |
commit | 9e9eff6f8bf3bde63ddc7cc6344a43268a27943e (patch) | |
tree | f696045557d00d404402d4593899a861573c7995 /src | |
parent | 8184b1fe44c098265726a5aa6e219f420ac77c42 (diff) |
added the feature to reply to attached message/rfc822 messages.
git-svn-id: svn://sylpheed.sraoss.jp/sylpheed/trunk@1852 ee746299-78ed-0310-b773-934348b2243d
Diffstat (limited to 'src')
-rw-r--r-- | src/compose.c | 22 | ||||
-rw-r--r-- | src/mimeview.c | 78 | ||||
-rw-r--r-- | src/mimeview.h | 2 | ||||
-rw-r--r-- | src/quote_fmt_parse.y | 148 | ||||
-rw-r--r-- | src/send_message.c | 4 |
5 files changed, 161 insertions, 93 deletions
diff --git a/src/compose.c b/src/compose.c index 26354fb4..6c3bc116 100644 --- a/src/compose.c +++ b/src/compose.c @@ -798,25 +798,26 @@ void compose_reply(MsgInfo *msginfo, FolderItem *item, ComposeMode mode, const gchar *body) { Compose *compose; - PrefsAccount *account; + PrefsAccount *account = NULL; GtkTextBuffer *buffer; GtkTextIter iter; gboolean quote = FALSE; g_return_if_fail(msginfo != NULL); - g_return_if_fail(msginfo->folder != NULL); + //g_return_if_fail(msginfo->folder != NULL); if (COMPOSE_QUOTE_MODE(mode) == COMPOSE_WITH_QUOTE) quote = TRUE; - account = account_find_from_item_property(msginfo->folder); + if (msginfo->folder) + account = account_find_from_item_property(msginfo->folder); if (!account && msginfo->to && prefs_common.reply_account_autosel) { gchar *to; Xstrdup_a(to, msginfo->to, return); extract_address(to); account = account_find_from_address(to); } - if (!account && msginfo->folder->folder) + if (!account && msginfo->folder && msginfo->folder->folder) account = msginfo->folder->folder->account; if (!account) account = cur_account; @@ -889,7 +890,7 @@ void compose_forward(GSList *mlist, FolderItem *item, gboolean as_attach, const gchar *body) { Compose *compose; - PrefsAccount *account; + PrefsAccount *account = NULL; GtkTextView *text; GtkTextBuffer *buffer; GtkTextIter iter; @@ -899,9 +900,10 @@ void compose_forward(GSList *mlist, FolderItem *item, gboolean as_attach, g_return_if_fail(mlist != NULL); msginfo = (MsgInfo *)mlist->data; - g_return_if_fail(msginfo->folder != NULL); + //g_return_if_fail(msginfo->folder != NULL); - account = account_find_from_item(msginfo->folder); + if (msginfo->folder) + account = account_find_from_item(msginfo->folder); if (!account) account = cur_account; g_return_if_fail(account != NULL); @@ -2871,7 +2873,9 @@ static gint compose_set_reply_flag(Compose *compose) SummaryView *summaryview; g_return_val_if_fail(compose->replyinfo != NULL, -1); - g_return_val_if_fail(compose->replyinfo->folder != NULL, -1); + + if (!compose->replyinfo->folder) + return -1; replyinfo = compose->replyinfo; @@ -3709,7 +3713,7 @@ static gint compose_queue(Compose *compose, const gchar *file) /* Sylpheed account ID */ fprintf(fp, "AID:%d\n", compose->account->account_id); /* Reply target */ - if (compose->replyinfo) { + if (compose->replyinfo && compose->replyinfo->folder) { gchar *id; id = folder_item_get_identifier(compose->replyinfo->folder); if (id) { diff --git a/src/mimeview.c b/src/mimeview.c index 9ce62a15..9851b698 100644 --- a/src/mimeview.c +++ b/src/mimeview.c @@ -1,6 +1,6 @@ /* * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client - * Copyright (C) 1999-2006 Hiroyuki Yamamoto + * Copyright (C) 1999-2007 Hiroyuki Yamamoto * * 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 @@ -54,6 +54,7 @@ #include "procheader.h" #include "summaryview.h" #include "menu.h" +#include "compose.h" #include "filesel.h" #include "alertpanel.h" #include "inputdialog.h" @@ -120,6 +121,10 @@ static void mimeview_open_with (MimeView *mimeview); static void mimeview_view_file (const gchar *filename, MimeInfo *partinfo, const gchar *cmdline); + +static void mimeview_reply (MimeView *mimeview, + guint action); + #if USE_GPGME static void mimeview_check_signature (MimeView *mimeview); #endif @@ -131,9 +136,18 @@ static GtkItemFactoryEntry mimeview_popup_entries[] = {N_("/_Display as text"), NULL, mimeview_display_as_text, 0, NULL}, {N_("/_Save as..."), NULL, mimeview_save_as, 0, NULL}, {N_("/Save _all..."), NULL, mimeview_save_all, 0, NULL}, - {N_("/_Print..."), NULL, mimeview_print, 0, NULL} + {N_("/_Print..."), NULL, mimeview_print, 0, NULL}, + {N_("/---"), NULL, NULL, 0, "<Separator>"}, + {N_("/_Reply"), NULL, NULL, 0, "<Branch>"}, + {N_("/_Reply/_Reply"), NULL, mimeview_reply, COMPOSE_REPLY, NULL}, + {N_("/_Reply/Reply to _all"), + NULL, mimeview_reply, COMPOSE_REPLY_TO_ALL, NULL}, + {N_("/_Reply/Reply to _sender"), + NULL, mimeview_reply, COMPOSE_REPLY_TO_SENDER, NULL}, + {N_("/_Reply/Reply to mailing _list"), + NULL, mimeview_reply, COMPOSE_REPLY_TO_LIST, NULL}, #if USE_GPGME - , + {N_("/---"), NULL, NULL, 0, "<Separator>"}, {N_("/_Check signature"), NULL, mimeview_check_signature, 0, NULL} #endif }; @@ -158,6 +172,9 @@ MimeView *mimeview_create(void) GtkWidget *popupmenu; GtkItemFactory *popupfactory; gint n_entries; + GtkWidget *reply_separator; + GtkWidget *reply_menuitem; + GList *child; debug_print(_("Creating MIME view...\n")); mimeview = g_new0(MimeView, 1); @@ -240,6 +257,11 @@ MimeView *mimeview_create(void) popupmenu = menu_create_items(mimeview_popup_entries, n_entries, "<MimeView>", &popupfactory, mimeview); + reply_menuitem = gtk_item_factory_get_item(popupfactory, "/Reply"); + child = g_list_find(GTK_MENU_SHELL(popupmenu)->children, + reply_menuitem); + reply_separator = GTK_WIDGET(child->prev->data); + mimeview->paned = paned; mimeview->scrolledwin = scrolledwin; mimeview->treeview = treeview; @@ -248,6 +270,8 @@ MimeView *mimeview_create(void) mimeview->mime_vbox = mime_vbox; mimeview->popupmenu = popupmenu; mimeview->popupfactory = popupfactory; + mimeview->reply_separator = reply_separator; + mimeview->reply_menuitem = reply_menuitem; mimeview->type = -1; return mimeview; @@ -854,6 +878,14 @@ static gint mimeview_button_pressed(GtkWidget *widget, GdkEventButton *event, else menu_set_sensitive(mimeview->popupfactory, "/Print...", FALSE); + + if (partinfo && partinfo->mime_type == MIME_MESSAGE_RFC822) { + gtk_widget_show(mimeview->reply_separator); + gtk_widget_show(mimeview->reply_menuitem); + } else { + gtk_widget_hide(mimeview->reply_separator); + gtk_widget_hide(mimeview->reply_menuitem); + } #if USE_GPGME menu_set_sensitive(mimeview->popupfactory, "/Check signature", @@ -1221,6 +1253,46 @@ static void mimeview_view_file(const gchar *filename, MimeInfo *partinfo, g_warning("MIME viewer command line is invalid: '%s'", cmd); } +static void mimeview_reply(MimeView *mimeview, guint action) +{ + MimeInfo *partinfo; + gchar *filename; + MsgInfo *msginfo; + MsgFlags flags = {0, 0}; + ComposeMode mode = action; + + if (!mimeview->opened) return; + if (!mimeview->file) return; + + partinfo = mimeview_get_selected_part(mimeview); + g_return_if_fail(partinfo != NULL); + + if (partinfo->mime_type != MIME_MESSAGE_RFC822) + return; + + filename = procmime_get_tmp_file_name(partinfo); + if (procmime_get_part(filename, mimeview->file, partinfo) < 0) { + alertpanel_error + (_("Can't save the part of multipart message.")); + g_free(filename); + return; + } + + msginfo = procheader_parse_file(filename, flags, TRUE); + msginfo->file_path = filename; + filename = NULL; + if (prefs_common.reply_with_quote) + mode |= COMPOSE_WITH_QUOTE; + + if (mimeview->messageview->mainwin) + compose_reply(msginfo, mimeview->messageview->mainwin->summaryview->folder_item, + mode, NULL); + else + compose_reply(msginfo, NULL, mode, NULL); + + procmsg_msginfo_free(msginfo); +} + #if USE_GPGME static gboolean update_node_name_func(GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *iter, gpointer data) diff --git a/src/mimeview.h b/src/mimeview.h index a9a3df40..f8ac8c4f 100644 --- a/src/mimeview.h +++ b/src/mimeview.h @@ -56,6 +56,8 @@ struct _MimeView GtkWidget *popupmenu; GtkItemFactory *popupfactory; + GtkWidget *reply_separator; + GtkWidget *reply_menuitem; GtkTreePath *opened; diff --git a/src/quote_fmt_parse.y b/src/quote_fmt_parse.y index dab2befd..db1aa9f2 100644 --- a/src/quote_fmt_parse.y +++ b/src/quote_fmt_parse.y @@ -265,102 +265,90 @@ special: } | SHOW_MESSAGE { - if (msginfo->folder || body) { - gchar buf[BUFFSIZE]; - FILE *fp; - - if (body) - fp = str_open_as_stream(body); - else - fp = procmime_get_first_text_content - (msginfo, NULL); - - if (fp == NULL) - g_warning("Can't get text part\n"); - else { - while (fgets(buf, sizeof(buf), fp) != NULL) { - strcrchomp(buf); - INSERT(buf); - } - fclose(fp); + gchar buf[BUFFSIZE]; + FILE *fp; + + if (body) + fp = str_open_as_stream(body); + else + fp = procmime_get_first_text_content(msginfo, NULL); + + if (fp == NULL) + g_warning("Can't get text part\n"); + else { + while (fgets(buf, sizeof(buf), fp) != NULL) { + strcrchomp(buf); + INSERT(buf); } + fclose(fp); } } | SHOW_QUOTED_MESSAGE { - if (msginfo->folder || body) { - gchar buf[BUFFSIZE]; - FILE *fp; - - if (body) - fp = str_open_as_stream(body); - else - fp = procmime_get_first_text_content - (msginfo, NULL); - - if (fp == NULL) - g_warning("Can't get text part\n"); - else { - while (fgets(buf, sizeof(buf), fp) != NULL) { - strcrchomp(buf); - if (quote_str) - INSERT(quote_str); - INSERT(buf); - } - fclose(fp); + gchar buf[BUFFSIZE]; + FILE *fp; + + if (body) + fp = str_open_as_stream(body); + else + fp = procmime_get_first_text_content(msginfo, NULL); + + if (fp == NULL) + g_warning("Can't get text part\n"); + else { + while (fgets(buf, sizeof(buf), fp) != NULL) { + strcrchomp(buf); + if (quote_str) + INSERT(quote_str); + INSERT(buf); } + fclose(fp); } } | SHOW_MESSAGE_NO_SIGNATURE { - if (msginfo->folder || body) { - gchar buf[BUFFSIZE]; - FILE *fp; - - if (body) - fp = str_open_as_stream(body); - else - fp = procmime_get_first_text_content - (msginfo, NULL); - - if (fp == NULL) - g_warning("Can't get text part\n"); - else { - while (fgets(buf, sizeof(buf), fp) != NULL) { - strcrchomp(buf); - if (strncmp(buf, "-- \n", 4) == 0) - break; - INSERT(buf); - } - fclose(fp); + gchar buf[BUFFSIZE]; + FILE *fp; + + if (body) + fp = str_open_as_stream(body); + else + fp = procmime_get_first_text_content(msginfo, NULL); + + if (fp == NULL) + g_warning("Can't get text part\n"); + else { + while (fgets(buf, sizeof(buf), fp) != NULL) { + strcrchomp(buf); + if (strncmp(buf, "-- \n", 4) == 0) + break; + INSERT(buf); } + fclose(fp); } } | SHOW_QUOTED_MESSAGE_NO_SIGNATURE { - if (msginfo->folder || body) { - gchar buf[BUFFSIZE]; - FILE *fp; - - if (body) - fp = str_open_as_stream(body); - else - fp = procmime_get_first_text_content - (msginfo, NULL); - - if (fp == NULL) - g_warning("Can't get text part\n"); - else { - while (fgets(buf, sizeof(buf), fp) != NULL) { - strcrchomp(buf); - if (strncmp(buf, "-- \n", 4) == 0) - break; - if (quote_str) - INSERT(quote_str); - INSERT(buf); - } - fclose(fp); + gchar buf[BUFFSIZE]; + FILE *fp; + + if (body) + fp = str_open_as_stream(body); + else + fp = procmime_get_first_text_content(msginfo, NULL); + + if (fp == NULL) + g_warning("Can't get text part\n"); + else { + while (fgets(buf, sizeof(buf), fp) != NULL) { + strcrchomp(buf); + if (strncmp(buf, "-- \n", 4) == 0) + break; + if (quote_str) + INSERT(quote_str); + INSERT(buf); } + fclose(fp); } } | SHOW_BACKSLASH diff --git a/src/send_message.c b/src/send_message.c index 01b9b4ed..483f6126 100644 --- a/src/send_message.c +++ b/src/send_message.c @@ -451,7 +451,9 @@ static gint send_message_set_reply_flag(QueueInfo *qinfo) SummaryView *summaryview; g_return_val_if_fail(qinfo->replyinfo != NULL, -1); - g_return_val_if_fail(qinfo->replyinfo->folder != NULL, -1); + + if (!qinfo->replyinfo->folder) + return -1; replyinfo = qinfo->replyinfo; |