2001-04-19 14:21:46 +02:00
|
|
|
/*
|
|
|
|
* Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
|
2002-01-29 11:03:33 +01:00
|
|
|
* Copyright (C) 1999-2002 Hiroyuki Yamamoto
|
2001-04-19 14:21:46 +02:00
|
|
|
*
|
|
|
|
* 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
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "defs.h"
|
|
|
|
|
|
|
|
#include <glib.h>
|
|
|
|
#include <gdk/gdkkeysyms.h>
|
|
|
|
#include <gtk/gtkvbox.h>
|
|
|
|
#include <gtk/gtkcontainer.h>
|
|
|
|
#include <gtk/gtkeditable.h>
|
|
|
|
#include <gtk/gtkwindow.h>
|
|
|
|
#include <gtk/gtktext.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <ctype.h>
|
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
#include "intl.h"
|
|
|
|
#include "main.h"
|
|
|
|
#include "messageview.h"
|
|
|
|
#include "headerview.h"
|
2002-11-28 23:53:24 +01:00
|
|
|
#include "summaryview.h"
|
2001-04-19 14:21:46 +02:00
|
|
|
#include "textview.h"
|
|
|
|
#include "imageview.h"
|
|
|
|
#include "mimeview.h"
|
|
|
|
#include "procmsg.h"
|
|
|
|
#include "procheader.h"
|
|
|
|
#include "procmime.h"
|
|
|
|
#include "prefs_common.h"
|
|
|
|
#include "gtkutils.h"
|
|
|
|
#include "utils.h"
|
|
|
|
#include "rfc2015.h"
|
2002-11-28 23:53:24 +01:00
|
|
|
#include "about.h"
|
2001-05-02 16:16:51 +02:00
|
|
|
#include "account.h"
|
|
|
|
#include "alertpanel.h"
|
2001-05-11 01:00:27 +02:00
|
|
|
#include "send.h"
|
2001-10-13 09:11:42 +02:00
|
|
|
#include "pgptext.h"
|
2002-07-02 21:49:11 +02:00
|
|
|
#include "menu.h"
|
2002-11-28 23:53:24 +01:00
|
|
|
#include "stock_pixmap.h"
|
2001-04-19 14:21:46 +02:00
|
|
|
|
|
|
|
static void messageview_change_view_type(MessageView *messageview,
|
|
|
|
MessageType type);
|
|
|
|
static void messageview_destroy_cb (GtkWidget *widget,
|
|
|
|
MessageView *messageview);
|
|
|
|
static void messageview_size_allocate_cb(GtkWidget *widget,
|
|
|
|
GtkAllocation *allocation);
|
|
|
|
static void key_pressed (GtkWidget *widget,
|
|
|
|
GdkEventKey *event,
|
|
|
|
MessageView *messageview);
|
2002-11-29 19:59:03 +01:00
|
|
|
static void focus_in (GtkWidget *widget,
|
|
|
|
GdkEventFocus *event,
|
|
|
|
gpointer data);
|
2002-11-28 23:53:24 +01:00
|
|
|
static void messageview_toolbar_create (MessageView *messageview,
|
|
|
|
GtkWidget *container);
|
|
|
|
static void toolbar_messageview_buttons_cb (GtkWidget *widget,
|
|
|
|
ToolbarItem *item);
|
2001-04-19 14:21:46 +02:00
|
|
|
|
2002-07-21 17:47:39 +02:00
|
|
|
static void return_receipt_show (NoticeView *noticeview,
|
|
|
|
MsgInfo *msginfo);
|
|
|
|
static void return_receipt_send_clicked (NoticeView *noticeview,
|
|
|
|
MsgInfo *msginfo);
|
|
|
|
|
2002-08-06 01:50:37 +02:00
|
|
|
static PrefsAccount *select_account_from_list
|
|
|
|
(GList *ac_list);
|
|
|
|
|
2002-11-28 23:53:24 +01:00
|
|
|
static void messageview_reply_cb (gpointer data,
|
|
|
|
guint action,
|
|
|
|
GtkWidget *widget);
|
|
|
|
|
|
|
|
static void messageview_delete_cb (gpointer data,
|
|
|
|
guint action,
|
|
|
|
GtkWidget *widget);
|
|
|
|
|
|
|
|
static void messageview_close_cb (gpointer data,
|
|
|
|
guint action,
|
|
|
|
GtkWidget *widget);
|
|
|
|
|
2002-08-23 08:52:15 +02:00
|
|
|
MessageView *messageview_create(MainWindow *mainwin)
|
2001-04-19 14:21:46 +02:00
|
|
|
{
|
|
|
|
MessageView *messageview;
|
|
|
|
GtkWidget *vbox;
|
|
|
|
HeaderView *headerview;
|
|
|
|
TextView *textview;
|
|
|
|
ImageView *imageview;
|
|
|
|
MimeView *mimeview;
|
2002-07-21 17:47:39 +02:00
|
|
|
NoticeView *noticeview;
|
2001-04-19 14:21:46 +02:00
|
|
|
|
2002-08-15 09:38:17 +02:00
|
|
|
debug_print("Creating message view...\n");
|
2001-04-19 14:21:46 +02:00
|
|
|
messageview = g_new0(MessageView, 1);
|
|
|
|
|
|
|
|
messageview->type = MVIEW_TEXT;
|
|
|
|
|
|
|
|
headerview = headerview_create();
|
|
|
|
|
2002-08-23 08:52:15 +02:00
|
|
|
noticeview = noticeview_create(mainwin);
|
2002-07-21 17:47:39 +02:00
|
|
|
|
2001-04-19 14:21:46 +02:00
|
|
|
textview = textview_create();
|
|
|
|
textview->messageview = messageview;
|
|
|
|
|
|
|
|
imageview = imageview_create();
|
|
|
|
imageview->messageview = messageview;
|
|
|
|
|
|
|
|
mimeview = mimeview_create();
|
2002-02-25 10:25:17 +01:00
|
|
|
mimeview->textview = textview_create();
|
|
|
|
mimeview->textview->messageview = messageview;
|
2001-04-19 14:21:46 +02:00
|
|
|
mimeview->imageview = imageview;
|
|
|
|
mimeview->messageview = messageview;
|
|
|
|
|
|
|
|
vbox = gtk_vbox_new(FALSE, 0);
|
|
|
|
gtk_box_pack_start(GTK_BOX(vbox), GTK_WIDGET_PTR(headerview),
|
|
|
|
FALSE, FALSE, 0);
|
2002-07-21 17:47:39 +02:00
|
|
|
gtk_box_pack_start(GTK_BOX(vbox), GTK_WIDGET_PTR(noticeview),
|
|
|
|
FALSE, FALSE, 0);
|
2001-04-19 14:21:46 +02:00
|
|
|
gtk_box_pack_start(GTK_BOX(vbox), GTK_WIDGET_PTR(textview),
|
|
|
|
TRUE, TRUE, 0);
|
|
|
|
|
|
|
|
/* to remove without destroyed */
|
|
|
|
gtk_widget_ref(GTK_WIDGET_PTR(textview));
|
|
|
|
gtk_widget_ref(GTK_WIDGET_PTR(imageview));
|
|
|
|
gtk_widget_ref(GTK_WIDGET_PTR(mimeview));
|
2002-02-25 10:25:17 +01:00
|
|
|
gtk_widget_ref(GTK_WIDGET_PTR(mimeview->textview));
|
2001-04-19 14:21:46 +02:00
|
|
|
|
|
|
|
messageview->vbox = vbox;
|
|
|
|
messageview->new_window = FALSE;
|
|
|
|
messageview->window = NULL;
|
|
|
|
messageview->headerview = headerview;
|
|
|
|
messageview->textview = textview;
|
|
|
|
messageview->imageview = imageview;
|
|
|
|
messageview->mimeview = mimeview;
|
2002-07-21 17:47:39 +02:00
|
|
|
messageview->noticeview = noticeview;
|
2002-11-28 23:53:24 +01:00
|
|
|
messageview->mainwin = mainwin;
|
2001-04-19 14:21:46 +02:00
|
|
|
|
|
|
|
return messageview;
|
|
|
|
}
|
|
|
|
|
2002-11-28 23:53:24 +01:00
|
|
|
static GtkItemFactoryEntry messageview_entries[] =
|
|
|
|
{
|
|
|
|
{N_("/_File"), NULL, NULL, 0, "<Branch>"},
|
|
|
|
{N_("/_File/---"), NULL, NULL, 0, "<Separator>"},
|
|
|
|
{N_("/_File/_Close"), "<control>W", messageview_close_cb, 0, NULL},
|
|
|
|
|
|
|
|
{N_("/_Message"), NULL, NULL, 0, "<Branch>"},
|
|
|
|
{N_("/_Message/_Reply"), "<control>R", messageview_reply_cb, COMPOSE_REPLY, NULL},
|
|
|
|
{N_("/_Message/Repl_y to"), NULL, NULL, 0, "<Branch>"},
|
|
|
|
{N_("/_Message/Repl_y to/_all"), "<shift><control>R", messageview_reply_cb, COMPOSE_REPLY_TO_ALL, NULL},
|
|
|
|
{N_("/_Message/Repl_y to/_sender"), NULL, messageview_reply_cb, COMPOSE_REPLY_TO_SENDER, NULL},
|
|
|
|
{N_("/_Message/Repl_y to/mailing _list"),
|
|
|
|
"<control>L", messageview_reply_cb, COMPOSE_REPLY_TO_LIST, NULL},
|
|
|
|
{N_("/_Message/Follow-up and reply to"),NULL, messageview_reply_cb, COMPOSE_FOLLOWUP_AND_REPLY_TO, NULL},
|
|
|
|
{N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
|
|
|
|
{N_("/_Message/_Delete"), "<control>D", messageview_delete_cb, 0, NULL},
|
|
|
|
|
|
|
|
{N_("/_Help"), NULL, NULL, 0, "<Branch>"},
|
|
|
|
{N_("/_Help/_About"), NULL, about_show, 0, NULL}
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
2002-08-23 08:52:15 +02:00
|
|
|
MessageView *messageview_create_with_new_window(MainWindow *mainwin)
|
2001-04-19 14:21:46 +02:00
|
|
|
{
|
|
|
|
GtkWidget *window;
|
|
|
|
MessageView *msgview;
|
2002-11-28 23:53:24 +01:00
|
|
|
GtkWidget *vbox;
|
|
|
|
GtkWidget *menubar;
|
|
|
|
GtkWidget *handlebox;
|
|
|
|
|
|
|
|
guint n_menu_entries;
|
2001-04-19 14:21:46 +02:00
|
|
|
|
|
|
|
window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
|
2002-01-08 20:30:01 +01:00
|
|
|
gtk_window_set_title(GTK_WINDOW(window), _("Sylpheed - Message View"));
|
|
|
|
gtk_window_set_wmclass(GTK_WINDOW(window), "message_view", "Sylpheed");
|
2001-04-19 14:21:46 +02:00
|
|
|
gtk_window_set_policy(GTK_WINDOW(window), TRUE, TRUE, FALSE);
|
|
|
|
gtk_widget_set_usize(window, prefs_common.msgwin_width,
|
|
|
|
prefs_common.msgwin_height);
|
|
|
|
|
2002-11-28 23:53:24 +01:00
|
|
|
vbox = gtk_vbox_new(FALSE, 0);
|
|
|
|
gtk_widget_show(vbox);
|
|
|
|
gtk_container_add(GTK_CONTAINER(window), vbox);
|
|
|
|
|
2002-08-23 08:52:15 +02:00
|
|
|
msgview = messageview_create(mainwin);
|
2001-04-19 14:21:46 +02:00
|
|
|
|
|
|
|
gtk_signal_connect(GTK_OBJECT(window), "size_allocate",
|
|
|
|
GTK_SIGNAL_FUNC(messageview_size_allocate_cb),
|
|
|
|
msgview);
|
|
|
|
gtk_signal_connect(GTK_OBJECT(window), "destroy",
|
|
|
|
GTK_SIGNAL_FUNC(messageview_destroy_cb), msgview);
|
|
|
|
gtk_signal_connect(GTK_OBJECT(window), "key_press_event",
|
|
|
|
GTK_SIGNAL_FUNC(key_pressed), msgview);
|
2002-11-29 19:59:03 +01:00
|
|
|
gtk_signal_connect(GTK_OBJECT(window), "focus_in_event",
|
|
|
|
GTK_SIGNAL_FUNC(focus_in), msgview);
|
2001-04-19 14:21:46 +02:00
|
|
|
|
2002-11-28 23:53:24 +01:00
|
|
|
n_menu_entries = sizeof(messageview_entries) / sizeof(messageview_entries[0]);
|
|
|
|
menubar = menubar_create(window, messageview_entries,
|
|
|
|
n_menu_entries, "<MessageView>", msgview);
|
|
|
|
gtk_box_pack_start(GTK_BOX(vbox), menubar, FALSE, TRUE, 0);
|
|
|
|
|
|
|
|
handlebox = gtk_handle_box_new();
|
|
|
|
gtk_box_pack_start(GTK_BOX(vbox), handlebox, FALSE, FALSE, 0);
|
|
|
|
messageview_toolbar_create(msgview,handlebox);
|
|
|
|
|
|
|
|
gtk_container_add(GTK_CONTAINER(vbox), GTK_WIDGET_PTR(msgview));
|
2001-04-19 14:21:46 +02:00
|
|
|
gtk_widget_grab_focus(msgview->textview->text);
|
|
|
|
gtk_widget_show_all(window);
|
|
|
|
|
|
|
|
msgview->new_window = TRUE;
|
|
|
|
msgview->window = window;
|
2002-06-11 23:46:03 +02:00
|
|
|
msgview->visible = TRUE;
|
2002-11-28 23:53:24 +01:00
|
|
|
msgview->menubar = menubar;
|
|
|
|
msgview->handlebox = handlebox;
|
2001-04-19 14:21:46 +02:00
|
|
|
|
2002-11-28 23:53:24 +01:00
|
|
|
|
2001-04-19 14:21:46 +02:00
|
|
|
messageview_init(msgview);
|
2002-11-28 23:53:24 +01:00
|
|
|
common_toolbar_set_style(msgview, TOOLBAR_MSGVIEW);
|
2001-04-19 14:21:46 +02:00
|
|
|
|
|
|
|
return msgview;
|
|
|
|
}
|
|
|
|
|
|
|
|
void messageview_init(MessageView *messageview)
|
|
|
|
{
|
|
|
|
headerview_init(messageview->headerview);
|
|
|
|
textview_init(messageview->textview);
|
|
|
|
imageview_init(messageview->imageview);
|
|
|
|
mimeview_init(messageview->mimeview);
|
2001-06-30 13:40:01 +02:00
|
|
|
/*messageview_set_font(messageview);*/
|
2002-07-21 17:47:39 +02:00
|
|
|
|
|
|
|
noticeview_hide(messageview->noticeview);
|
2001-04-19 14:21:46 +02:00
|
|
|
}
|
|
|
|
|
2002-06-23 19:51:28 +02:00
|
|
|
static void notification_convert_header(gchar *dest, gint len,
|
|
|
|
const gchar *src_,
|
2001-05-02 16:16:51 +02:00
|
|
|
gint header_len)
|
|
|
|
{
|
2002-06-23 19:51:28 +02:00
|
|
|
char *src;
|
|
|
|
|
|
|
|
g_return_if_fail(src_ != NULL);
|
2001-05-02 16:16:51 +02:00
|
|
|
g_return_if_fail(dest != NULL);
|
|
|
|
|
|
|
|
if (len < 1) return;
|
|
|
|
|
2002-06-23 19:51:28 +02:00
|
|
|
Xstrndup_a(src, src_, len, return);
|
|
|
|
|
2001-05-02 16:16:51 +02:00
|
|
|
remove_return(src);
|
|
|
|
|
|
|
|
if (is_ascii_str(src)) {
|
|
|
|
strncpy2(dest, src, len);
|
|
|
|
dest[len - 1] = '\0';
|
|
|
|
return;
|
|
|
|
} else
|
|
|
|
conv_encode_header(dest, len, src, header_len);
|
|
|
|
}
|
|
|
|
|
2001-06-04 12:14:21 +02:00
|
|
|
static gint disposition_notification_queue(PrefsAccount * account,
|
|
|
|
gchar * to, const gchar *file)
|
|
|
|
{
|
|
|
|
FolderItem *queue;
|
2002-06-30 01:33:42 +02:00
|
|
|
gchar *tmp;
|
2001-06-04 12:14:21 +02:00
|
|
|
FILE *fp, *src_fp;
|
|
|
|
gchar buf[BUFFSIZE];
|
|
|
|
gint num;
|
|
|
|
|
2002-08-15 09:38:17 +02:00
|
|
|
debug_print("queueing message...\n");
|
2001-06-04 12:14:21 +02:00
|
|
|
g_return_val_if_fail(account != NULL, -1);
|
|
|
|
|
|
|
|
tmp = g_strdup_printf("%s%cqueue.%d", g_get_tmp_dir(),
|
|
|
|
G_DIR_SEPARATOR, (gint)file);
|
2002-03-14 11:17:32 +01:00
|
|
|
if ((fp = fopen(tmp, "wb")) == NULL) {
|
2001-06-04 12:14:21 +02:00
|
|
|
FILE_OP_ERROR(tmp, "fopen");
|
|
|
|
g_free(tmp);
|
|
|
|
return -1;
|
|
|
|
}
|
2002-03-14 11:17:32 +01:00
|
|
|
if ((src_fp = fopen(file, "rb")) == NULL) {
|
2001-06-04 12:14:21 +02:00
|
|
|
FILE_OP_ERROR(file, "fopen");
|
|
|
|
fclose(fp);
|
|
|
|
unlink(tmp);
|
|
|
|
g_free(tmp);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
if (change_file_mode_rw(fp, tmp) < 0) {
|
|
|
|
FILE_OP_ERROR(tmp, "chmod");
|
|
|
|
g_warning(_("can't change file mode\n"));
|
|
|
|
}
|
|
|
|
|
|
|
|
/* queueing variables */
|
|
|
|
fprintf(fp, "AF:\n");
|
|
|
|
fprintf(fp, "NF:0\n");
|
|
|
|
fprintf(fp, "PS:10\n");
|
|
|
|
fprintf(fp, "SRH:1\n");
|
|
|
|
fprintf(fp, "SFN:\n");
|
|
|
|
fprintf(fp, "DSR:\n");
|
|
|
|
fprintf(fp, "MID:\n");
|
|
|
|
fprintf(fp, "CFG:\n");
|
|
|
|
fprintf(fp, "PT:0\n");
|
|
|
|
fprintf(fp, "S:%s\n", account->address);
|
|
|
|
fprintf(fp, "RQ:\n");
|
|
|
|
if (account->smtp_server)
|
|
|
|
fprintf(fp, "SSV:%s\n", account->smtp_server);
|
|
|
|
else
|
|
|
|
fprintf(fp, "SSV:\n");
|
|
|
|
if (account->nntp_server)
|
|
|
|
fprintf(fp, "NSV:%s\n", account->nntp_server);
|
|
|
|
else
|
|
|
|
fprintf(fp, "NSV:\n");
|
|
|
|
fprintf(fp, "SSH:\n");
|
|
|
|
fprintf(fp, "R:<%s>", to);
|
|
|
|
fprintf(fp, "\n");
|
|
|
|
fprintf(fp, "\n");
|
|
|
|
|
|
|
|
while (fgets(buf, sizeof(buf), src_fp) != NULL) {
|
|
|
|
if (fputs(buf, fp) == EOF) {
|
|
|
|
FILE_OP_ERROR(tmp, "fputs");
|
|
|
|
fclose(fp);
|
|
|
|
fclose(src_fp);
|
|
|
|
unlink(tmp);
|
|
|
|
g_free(tmp);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fclose(src_fp);
|
|
|
|
if (fclose(fp) == EOF) {
|
|
|
|
FILE_OP_ERROR(tmp, "fclose");
|
|
|
|
unlink(tmp);
|
|
|
|
g_free(tmp);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
queue = folder_get_default_queue();
|
|
|
|
if ((num = folder_item_add_msg(queue, tmp, TRUE)) < 0) {
|
|
|
|
g_warning(_("can't queue the message\n"));
|
|
|
|
unlink(tmp);
|
|
|
|
g_free(tmp);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
g_free(tmp);
|
|
|
|
|
2002-11-09 17:35:13 +01:00
|
|
|
folder_update_item(queue, TRUE);
|
2001-06-04 12:14:21 +02:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2002-10-18 12:40:25 +02:00
|
|
|
static gint disposition_notification_send(MsgInfo *msginfo)
|
2001-05-02 16:16:51 +02:00
|
|
|
{
|
|
|
|
gchar buf[BUFFSIZE];
|
|
|
|
gchar tmp[MAXPATHLEN + 1];
|
|
|
|
FILE *fp;
|
2002-08-06 01:50:37 +02:00
|
|
|
GSList *to_list;
|
|
|
|
GList *ac_list;
|
|
|
|
PrefsAccount *account;
|
2001-05-02 16:16:51 +02:00
|
|
|
gint ok;
|
2002-08-06 01:50:37 +02:00
|
|
|
gchar *to;
|
2001-05-02 16:16:51 +02:00
|
|
|
|
2001-05-12 17:52:47 +02:00
|
|
|
if ((!msginfo->returnreceiptto) &&
|
2002-07-21 21:03:10 +02:00
|
|
|
(!msginfo->dispositionnotificationto))
|
2001-05-12 17:52:47 +02:00
|
|
|
return -1;
|
|
|
|
|
2002-08-06 01:50:37 +02:00
|
|
|
/* RFC2298: Test for Return-Path */
|
|
|
|
if (msginfo->dispositionnotificationto)
|
|
|
|
to = msginfo->dispositionnotificationto;
|
|
|
|
else
|
|
|
|
to = msginfo->returnreceiptto;
|
|
|
|
|
|
|
|
ok = get_header_from_msginfo(msginfo, buf, sizeof(buf),
|
|
|
|
"Return-Path:");
|
|
|
|
if (ok == 0) {
|
|
|
|
gchar *to_addr = g_strdup(to);
|
|
|
|
extract_address(to_addr);
|
|
|
|
extract_address(buf);
|
|
|
|
ok = strcmp(to_addr, buf);
|
|
|
|
g_free(to_addr);
|
|
|
|
} else {
|
|
|
|
strncpy(buf, _("<No Return-Path found>"),
|
|
|
|
sizeof(buf));
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ok != 0) {
|
|
|
|
AlertValue val;
|
|
|
|
gchar *message;
|
|
|
|
message = g_strdup_printf(
|
|
|
|
_("The notification address to which the "
|
|
|
|
"return receipt is to be sent\n"
|
|
|
|
"does not correspond to the return path:\n"
|
|
|
|
"Notification address: %s\n"
|
|
|
|
"Return path: %s\n"
|
|
|
|
"It is advised to not to send the return "
|
|
|
|
"receipt."), to, buf);
|
|
|
|
val = alertpanel(_("Warning"), message, _("Send"),
|
|
|
|
_("+Don't Send"), NULL);
|
|
|
|
if (val != G_ALERTDEFAULT)
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
ac_list = account_find_all_from_address(NULL, msginfo->to);
|
|
|
|
ac_list = account_find_all_from_address(ac_list, msginfo->cc);
|
|
|
|
|
|
|
|
if (ac_list == NULL) {
|
|
|
|
alertpanel_error(_("This message is asking for a return "
|
|
|
|
"receipt notification\n"
|
|
|
|
"but according to its 'To:' and 'CC:' "
|
|
|
|
"headers it was not\nofficially addressed "
|
|
|
|
"to you.\n"
|
|
|
|
"Receipt notification cancelled."));
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (g_list_length(ac_list) > 1)
|
|
|
|
account = select_account_from_list(ac_list);
|
|
|
|
else
|
|
|
|
account = (PrefsAccount *) ac_list->data;
|
|
|
|
g_list_free(ac_list);
|
|
|
|
|
|
|
|
if (account == NULL)
|
|
|
|
return -1;
|
|
|
|
|
2001-05-02 16:16:51 +02:00
|
|
|
/* write to temporary file */
|
|
|
|
g_snprintf(tmp, sizeof(tmp), "%s%ctmpmsg%d",
|
|
|
|
get_rc_dir(), G_DIR_SEPARATOR, (gint)msginfo);
|
|
|
|
|
2002-03-14 11:17:32 +01:00
|
|
|
if ((fp = fopen(tmp, "wb")) == NULL) {
|
2001-05-02 16:16:51 +02:00
|
|
|
FILE_OP_ERROR(tmp, "fopen");
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* chmod for security */
|
|
|
|
if (change_file_mode_rw(fp, tmp) < 0) {
|
|
|
|
FILE_OP_ERROR(tmp, "chmod");
|
|
|
|
g_warning(_("can't change file mode\n"));
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Date */
|
|
|
|
get_rfc822_date(buf, sizeof(buf));
|
|
|
|
fprintf(fp, "Date: %s\n", buf);
|
|
|
|
|
|
|
|
/* From */
|
2002-08-06 01:50:37 +02:00
|
|
|
if (account->name && *account->name) {
|
2001-05-02 16:16:51 +02:00
|
|
|
notification_convert_header
|
2002-08-06 01:50:37 +02:00
|
|
|
(buf, sizeof(buf), account->name,
|
2001-05-02 16:16:51 +02:00
|
|
|
strlen("From: "));
|
2002-08-06 01:50:37 +02:00
|
|
|
fprintf(fp, "From: %s <%s>\n", buf, account->address);
|
2001-05-02 16:16:51 +02:00
|
|
|
} else
|
2002-08-06 01:50:37 +02:00
|
|
|
fprintf(fp, "From: %s\n", account->address);
|
2001-05-02 16:16:51 +02:00
|
|
|
|
2001-06-04 12:14:21 +02:00
|
|
|
fprintf(fp, "To: %s\n", to);
|
2001-05-02 16:16:51 +02:00
|
|
|
|
|
|
|
/* Subject */
|
|
|
|
notification_convert_header(buf, sizeof(buf), msginfo->subject,
|
|
|
|
strlen("Subject: "));
|
|
|
|
fprintf(fp, "Subject: Disposition notification: %s\n", buf);
|
|
|
|
|
|
|
|
if (fclose(fp) == EOF) {
|
|
|
|
FILE_OP_ERROR(tmp, "fclose");
|
|
|
|
unlink(tmp);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2002-08-03 20:36:40 +02:00
|
|
|
to_list = address_list_append(NULL, to);
|
2002-08-06 01:50:37 +02:00
|
|
|
ok = send_message(tmp, account, to_list);
|
2001-06-04 12:14:21 +02:00
|
|
|
|
|
|
|
if (ok < 0) {
|
|
|
|
if (prefs_common.queue_msg) {
|
|
|
|
AlertValue val;
|
|
|
|
|
|
|
|
val = alertpanel
|
|
|
|
(_("Queueing"),
|
|
|
|
_("Error occurred while sending the notification.\n"
|
|
|
|
"Put this notification into queue folder?"),
|
|
|
|
_("OK"), _("Cancel"), NULL);
|
|
|
|
if (G_ALERTDEFAULT == val) {
|
2002-08-06 01:50:37 +02:00
|
|
|
ok = disposition_notification_queue(account, to, tmp);
|
2001-06-04 12:14:21 +02:00
|
|
|
if (ok < 0)
|
|
|
|
alertpanel_error(_("Can't queue the notification."));
|
|
|
|
}
|
|
|
|
} else
|
|
|
|
alertpanel_error(_("Error occurred while sending the notification."));
|
|
|
|
}
|
2001-05-02 16:16:51 +02:00
|
|
|
|
|
|
|
if (unlink(tmp) < 0) FILE_OP_ERROR(tmp, "unlink");
|
|
|
|
|
|
|
|
return ok;
|
|
|
|
}
|
|
|
|
|
2002-02-04 10:56:44 +01:00
|
|
|
void messageview_show(MessageView *messageview, MsgInfo *msginfo,
|
|
|
|
gboolean all_headers)
|
2001-04-19 14:21:46 +02:00
|
|
|
{
|
|
|
|
FILE *fp;
|
|
|
|
gchar *file;
|
|
|
|
MimeInfo *mimeinfo;
|
|
|
|
MsgInfo *tmpmsginfo;
|
|
|
|
|
|
|
|
g_return_if_fail(msginfo != NULL);
|
2002-11-28 23:53:24 +01:00
|
|
|
messageview->msginfo = msginfo;
|
2001-04-19 14:21:46 +02:00
|
|
|
|
|
|
|
#if USE_GPGME
|
2002-02-21 15:56:09 +01:00
|
|
|
if ((fp = procmsg_open_message_decrypted(msginfo, &mimeinfo)) == NULL)
|
|
|
|
return;
|
2001-04-19 14:21:46 +02:00
|
|
|
#else /* !USE_GPGME */
|
|
|
|
if ((fp = procmsg_open_message(msginfo)) == NULL) return;
|
2002-02-21 15:56:09 +01:00
|
|
|
mimeinfo = procmime_scan_mime_header(fp);
|
2001-04-19 14:21:46 +02:00
|
|
|
#endif /* USE_GPGME */
|
|
|
|
fclose(fp);
|
|
|
|
if (!mimeinfo) return;
|
|
|
|
|
|
|
|
file = procmsg_get_message_file_path(msginfo);
|
2002-03-28 08:15:00 +01:00
|
|
|
if (!file) {
|
2002-07-21 21:03:10 +02:00
|
|
|
g_warning(_("can't get message file path.\n"));
|
2002-11-07 09:28:17 +01:00
|
|
|
procmime_mimeinfo_free_all(mimeinfo);
|
2002-03-28 08:15:00 +01:00
|
|
|
return;
|
|
|
|
}
|
2001-04-19 14:21:46 +02:00
|
|
|
|
2002-06-19 09:31:13 +02:00
|
|
|
tmpmsginfo = procheader_parse_file(file, msginfo->flags, TRUE, TRUE);
|
2001-05-02 16:16:51 +02:00
|
|
|
|
2001-04-19 14:21:46 +02:00
|
|
|
headerview_show(messageview->headerview, tmpmsginfo);
|
|
|
|
procmsg_msginfo_free(tmpmsginfo);
|
|
|
|
|
2002-11-28 23:53:24 +01:00
|
|
|
messageview->all_headers = all_headers;
|
2002-02-04 10:56:44 +01:00
|
|
|
textview_set_all_headers(messageview->textview, all_headers);
|
2002-03-02 11:02:42 +01:00
|
|
|
textview_set_all_headers(messageview->mimeview->textview, all_headers);
|
2002-02-04 10:56:44 +01:00
|
|
|
|
2002-06-23 09:49:25 +02:00
|
|
|
if (mimeinfo->mime_type != MIME_TEXT &&
|
|
|
|
mimeinfo->mime_type != MIME_TEXT_HTML) {
|
2001-04-19 14:21:46 +02:00
|
|
|
messageview_change_view_type(messageview, MVIEW_MIME);
|
|
|
|
mimeview_show_message(messageview->mimeview, mimeinfo, file);
|
|
|
|
} else {
|
|
|
|
messageview_change_view_type(messageview, MVIEW_TEXT);
|
|
|
|
textview_show_message(messageview->textview, mimeinfo, file);
|
2002-11-07 09:28:17 +01:00
|
|
|
procmime_mimeinfo_free_all(mimeinfo);
|
2001-04-19 14:21:46 +02:00
|
|
|
}
|
|
|
|
|
2002-07-21 17:47:39 +02:00
|
|
|
if (MSG_IS_RETRCPT_PENDING(msginfo->flags))
|
|
|
|
return_receipt_show(messageview->noticeview, msginfo);
|
|
|
|
else
|
|
|
|
noticeview_hide(messageview->noticeview);
|
|
|
|
|
2001-04-19 14:21:46 +02:00
|
|
|
g_free(file);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void messageview_change_view_type(MessageView *messageview,
|
|
|
|
MessageType type)
|
|
|
|
{
|
|
|
|
TextView *textview = messageview->textview;
|
|
|
|
MimeView *mimeview = messageview->mimeview;
|
|
|
|
|
|
|
|
if (messageview->type == type) return;
|
|
|
|
|
|
|
|
if (type == MVIEW_MIME) {
|
2002-06-23 09:49:25 +02:00
|
|
|
gtkut_container_remove
|
|
|
|
(GTK_CONTAINER(GTK_WIDGET_PTR(messageview)),
|
|
|
|
GTK_WIDGET_PTR(textview));
|
2002-06-23 10:18:03 +02:00
|
|
|
gtk_box_pack_start(GTK_BOX(messageview->vbox),
|
|
|
|
GTK_WIDGET_PTR(mimeview), TRUE, TRUE, 0);
|
|
|
|
gtk_container_add(GTK_CONTAINER(mimeview->vbox),
|
|
|
|
GTK_WIDGET_PTR(textview));
|
2001-04-19 14:21:46 +02:00
|
|
|
} else if (type == MVIEW_TEXT) {
|
2002-06-23 09:49:25 +02:00
|
|
|
gtkut_container_remove
|
|
|
|
(GTK_CONTAINER(GTK_WIDGET_PTR(messageview)),
|
|
|
|
GTK_WIDGET_PTR(mimeview));
|
|
|
|
|
2002-02-25 10:25:17 +01:00
|
|
|
if (mimeview->vbox == GTK_WIDGET_PTR(textview)->parent)
|
2001-12-11 10:18:29 +01:00
|
|
|
gtkut_container_remove(GTK_CONTAINER(mimeview->vbox),
|
|
|
|
GTK_WIDGET_PTR(textview));
|
2001-04-19 14:21:46 +02:00
|
|
|
|
|
|
|
gtk_box_pack_start(GTK_BOX(messageview->vbox),
|
|
|
|
GTK_WIDGET_PTR(textview), TRUE, TRUE, 0);
|
|
|
|
} else
|
|
|
|
return;
|
|
|
|
|
|
|
|
messageview->type = type;
|
|
|
|
}
|
|
|
|
|
|
|
|
void messageview_clear(MessageView *messageview)
|
|
|
|
{
|
|
|
|
messageview_change_view_type(messageview, MVIEW_TEXT);
|
|
|
|
headerview_clear(messageview->headerview);
|
|
|
|
textview_clear(messageview->textview);
|
2002-01-23 18:58:56 +01:00
|
|
|
imageview_clear(messageview->imageview);
|
2002-07-21 21:03:10 +02:00
|
|
|
noticeview_hide(messageview->noticeview);
|
2001-04-19 14:21:46 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void messageview_destroy(MessageView *messageview)
|
|
|
|
{
|
|
|
|
GtkWidget *textview = GTK_WIDGET_PTR(messageview->textview);
|
|
|
|
GtkWidget *imageview = GTK_WIDGET_PTR(messageview->imageview);
|
|
|
|
GtkWidget *mimeview = GTK_WIDGET_PTR(messageview->mimeview);
|
|
|
|
|
|
|
|
headerview_destroy(messageview->headerview);
|
|
|
|
textview_destroy(messageview->textview);
|
|
|
|
imageview_destroy(messageview->imageview);
|
|
|
|
mimeview_destroy(messageview->mimeview);
|
2002-07-21 21:03:10 +02:00
|
|
|
noticeview_destroy(messageview->noticeview);
|
2001-04-19 14:21:46 +02:00
|
|
|
|
2002-11-28 23:53:24 +01:00
|
|
|
toolbar_clear_list(TOOLBAR_MSGVIEW);
|
|
|
|
TOOLBAR_DESTROY_ITEMS(messageview->toolbar->item_list);
|
|
|
|
TOOLBAR_DESTROY_ACTIONS(messageview->toolbar->action_list);
|
|
|
|
|
2001-04-19 14:21:46 +02:00
|
|
|
g_free(messageview);
|
|
|
|
|
|
|
|
gtk_widget_unref(textview);
|
|
|
|
gtk_widget_unref(imageview);
|
|
|
|
gtk_widget_unref(mimeview);
|
|
|
|
}
|
|
|
|
|
|
|
|
void messageview_quote_color_set(void)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void messageview_set_font(MessageView *messageview)
|
|
|
|
{
|
|
|
|
textview_set_font(messageview->textview, NULL);
|
|
|
|
}
|
|
|
|
|
2002-06-22 19:49:39 +02:00
|
|
|
TextView *messageview_get_current_textview(MessageView *messageview)
|
2001-04-19 14:21:46 +02:00
|
|
|
{
|
2002-06-22 19:49:39 +02:00
|
|
|
TextView *text = NULL;
|
2002-05-15 09:47:34 +02:00
|
|
|
|
|
|
|
if (messageview->type == MVIEW_TEXT)
|
2002-06-22 19:49:39 +02:00
|
|
|
text = messageview->textview;
|
2002-05-15 09:47:34 +02:00
|
|
|
else if (messageview->type == MVIEW_MIME) {
|
|
|
|
if (gtk_notebook_get_current_page
|
|
|
|
(GTK_NOTEBOOK(messageview->mimeview->notebook)) == 0)
|
2002-06-22 19:49:39 +02:00
|
|
|
text = messageview->textview;
|
2002-05-15 09:47:34 +02:00
|
|
|
else if (messageview->mimeview->type == MIMEVIEW_TEXT)
|
2002-06-22 19:49:39 +02:00
|
|
|
text = messageview->mimeview->textview;
|
2001-12-12 19:30:35 +01:00
|
|
|
}
|
2002-05-15 09:47:34 +02:00
|
|
|
|
2002-06-22 19:49:39 +02:00
|
|
|
return text;
|
|
|
|
}
|
|
|
|
|
|
|
|
void messageview_copy_clipboard(MessageView *messageview)
|
|
|
|
{
|
|
|
|
TextView *text;
|
|
|
|
|
|
|
|
text = messageview_get_current_textview(messageview);
|
2002-05-15 09:47:34 +02:00
|
|
|
if (text)
|
2002-06-22 19:49:39 +02:00
|
|
|
gtk_editable_copy_clipboard(GTK_EDITABLE(text->text));
|
|
|
|
}
|
|
|
|
|
|
|
|
void messageview_select_all(MessageView *messageview)
|
|
|
|
{
|
|
|
|
TextView *text;
|
|
|
|
|
|
|
|
text = messageview_get_current_textview(messageview);
|
|
|
|
if (text)
|
|
|
|
gtk_editable_select_region(GTK_EDITABLE(text->text), 0, -1);
|
2001-04-19 14:21:46 +02:00
|
|
|
}
|
|
|
|
|
2001-09-30 13:07:34 +02:00
|
|
|
void messageview_set_position(MessageView *messageview, gint pos)
|
|
|
|
{
|
2002-03-03 10:32:58 +01:00
|
|
|
textview_set_position(messageview->textview, pos);
|
2001-09-30 13:07:34 +02:00
|
|
|
}
|
|
|
|
|
2001-09-24 10:15:52 +02:00
|
|
|
gboolean messageview_search_string(MessageView *messageview, const gchar *str,
|
|
|
|
gboolean case_sens)
|
|
|
|
{
|
2002-03-03 10:32:58 +01:00
|
|
|
return textview_search_string(messageview->textview, str, case_sens);
|
2001-09-24 10:15:52 +02:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2001-09-30 13:07:34 +02:00
|
|
|
gboolean messageview_search_string_backward(MessageView *messageview,
|
|
|
|
const gchar *str,
|
|
|
|
gboolean case_sens)
|
|
|
|
{
|
2002-03-03 10:32:58 +01:00
|
|
|
return textview_search_string_backward(messageview->textview,
|
|
|
|
str, case_sens);
|
2001-09-30 13:07:34 +02:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2002-06-11 23:46:03 +02:00
|
|
|
gboolean messageview_is_visible(MessageView *messageview)
|
|
|
|
{
|
|
|
|
return messageview->visible;
|
|
|
|
}
|
|
|
|
|
2001-04-19 14:21:46 +02:00
|
|
|
static void messageview_destroy_cb(GtkWidget *widget, MessageView *messageview)
|
|
|
|
{
|
|
|
|
messageview_destroy(messageview);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void messageview_size_allocate_cb(GtkWidget *widget,
|
|
|
|
GtkAllocation *allocation)
|
|
|
|
{
|
|
|
|
g_return_if_fail(allocation != NULL);
|
|
|
|
|
|
|
|
prefs_common.msgwin_width = allocation->width;
|
|
|
|
prefs_common.msgwin_height = allocation->height;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void key_pressed(GtkWidget *widget, GdkEventKey *event,
|
|
|
|
MessageView *messageview)
|
|
|
|
{
|
|
|
|
if (event && event->keyval == GDK_Escape && messageview->window)
|
|
|
|
gtk_widget_destroy(messageview->window);
|
|
|
|
}
|
2002-01-21 11:54:32 +01:00
|
|
|
|
2002-11-29 19:59:03 +01:00
|
|
|
static void focus_in(GtkWidget *widget, GdkEventFocus *event,
|
|
|
|
gpointer data)
|
|
|
|
{
|
|
|
|
MessageView *msgview = (MessageView*)data;
|
|
|
|
|
|
|
|
summary_select_by_msgnum(msgview->mainwin->summaryview,
|
|
|
|
msgview->msginfo->msgnum);
|
|
|
|
}
|
|
|
|
|
2002-01-21 11:54:32 +01:00
|
|
|
void messageview_toggle_view_real(MessageView *messageview)
|
|
|
|
{
|
|
|
|
MainWindow *mainwin = messageview->mainwin;
|
|
|
|
union CompositeWin *cwin = &mainwin->win;
|
|
|
|
GtkWidget *vpaned = NULL;
|
|
|
|
GtkWidget *container = NULL;
|
2002-11-28 23:53:24 +01:00
|
|
|
GtkItemFactory *ifactory = gtk_item_factory_from_widget(mainwin->menubar);
|
2002-01-21 11:54:32 +01:00
|
|
|
|
|
|
|
switch (mainwin->type) {
|
|
|
|
case SEPARATE_NONE:
|
|
|
|
vpaned = cwin->sep_none.vpaned;
|
|
|
|
container = cwin->sep_none.hpaned;
|
|
|
|
break;
|
|
|
|
case SEPARATE_FOLDER:
|
|
|
|
vpaned = cwin->sep_folder.vpaned;
|
|
|
|
container = mainwin->vbox_body;
|
|
|
|
break;
|
|
|
|
case SEPARATE_MESSAGE:
|
|
|
|
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);
|
|
|
|
gtk_widget_grab_focus(GTK_WIDGET(messageview->textview->text));
|
|
|
|
} 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));
|
|
|
|
}
|
|
|
|
}
|
2002-07-21 17:47:39 +02:00
|
|
|
|
|
|
|
static void return_receipt_show(NoticeView *noticeview, MsgInfo *msginfo)
|
|
|
|
{
|
|
|
|
noticeview_set_text(noticeview, _("This messages asks for a return receipt."));
|
|
|
|
noticeview_set_button_text(noticeview, _("Send receipt"));
|
|
|
|
noticeview_set_button_press_callback(noticeview,
|
|
|
|
GTK_SIGNAL_FUNC(return_receipt_send_clicked),
|
|
|
|
(gpointer) msginfo);
|
|
|
|
noticeview_show(noticeview);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void return_receipt_send_clicked(NoticeView *noticeview, MsgInfo *msginfo)
|
|
|
|
{
|
2002-07-21 21:03:10 +02:00
|
|
|
MsgInfo *tmpmsginfo;
|
|
|
|
gchar *file;
|
|
|
|
|
|
|
|
file = procmsg_get_message_file_path(msginfo);
|
|
|
|
if (!file) {
|
|
|
|
g_warning(_("can't get message file path.\n"));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
tmpmsginfo = procheader_parse_file(file, msginfo->flags, TRUE, TRUE);
|
2002-08-06 01:50:37 +02:00
|
|
|
tmpmsginfo->folder = msginfo->folder;
|
|
|
|
tmpmsginfo->msgnum = msginfo->msgnum;
|
|
|
|
|
2002-07-21 21:03:10 +02:00
|
|
|
if (disposition_notification_send(tmpmsginfo) >= 0) {
|
|
|
|
procmsg_msginfo_unset_flags(msginfo, MSG_RETRCPT_PENDING, 0);
|
2002-07-21 17:47:39 +02:00
|
|
|
noticeview_hide(noticeview);
|
2002-07-21 21:03:10 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
procmsg_msginfo_free(tmpmsginfo);
|
|
|
|
g_free(file);
|
2002-07-21 17:47:39 +02:00
|
|
|
}
|
|
|
|
|
2002-08-06 01:50:37 +02:00
|
|
|
static void select_account_cb(GtkWidget *w, gpointer data)
|
|
|
|
{
|
|
|
|
*(gint*)data = GPOINTER_TO_INT(gtk_object_get_user_data(GTK_OBJECT(w)));
|
|
|
|
}
|
|
|
|
|
|
|
|
static PrefsAccount *select_account_from_list(GList *ac_list)
|
|
|
|
{
|
|
|
|
GtkWidget *optmenu;
|
|
|
|
GtkWidget *menu;
|
|
|
|
gint account_id;
|
2002-07-21 17:47:39 +02:00
|
|
|
|
2002-08-06 01:50:37 +02:00
|
|
|
g_return_val_if_fail(ac_list != NULL, NULL);
|
|
|
|
g_return_val_if_fail(ac_list->data != NULL, NULL);
|
|
|
|
|
|
|
|
optmenu = gtk_option_menu_new();
|
|
|
|
menu = gtkut_account_menu_new(ac_list, select_account_cb, &account_id);
|
|
|
|
if (!menu)
|
|
|
|
return NULL;
|
|
|
|
gtk_option_menu_set_menu(GTK_OPTION_MENU(optmenu), menu);
|
|
|
|
gtk_option_menu_set_history(GTK_OPTION_MENU(optmenu), 0);
|
|
|
|
account_id = ((PrefsAccount *) ac_list->data)->account_id;
|
|
|
|
if (alertpanel_with_widget(
|
|
|
|
_("Return Receipt Notification"),
|
|
|
|
_("The message was sent to several of your "
|
|
|
|
"accounts.\n"
|
|
|
|
"Please choose which account do you want to "
|
|
|
|
"use for sending the receipt notification:"),
|
|
|
|
_("Send Notification"), _("+Cancel"), NULL,
|
|
|
|
optmenu) != G_ALERTDEFAULT)
|
|
|
|
return NULL;
|
|
|
|
return account_find_from_id(account_id);
|
|
|
|
}
|
2002-11-28 23:53:24 +01:00
|
|
|
|
|
|
|
static void messageview_toolbar_create(MessageView *messageview,
|
|
|
|
GtkWidget *container)
|
|
|
|
{
|
|
|
|
ToolbarItem *toolbar_item;
|
|
|
|
|
|
|
|
GtkWidget *toolbar;
|
|
|
|
GtkWidget *icon_wid = NULL;
|
|
|
|
GtkWidget *item;
|
|
|
|
GtkTooltips *toolbar_tips;
|
|
|
|
ToolbarSylpheedActions *action_item;
|
|
|
|
GSList *cur;
|
|
|
|
GSList *toolbar_list;
|
|
|
|
toolbar_tips = gtk_tooltips_new();
|
|
|
|
|
|
|
|
toolbar_read_config_file(TOOLBAR_MSGVIEW);
|
|
|
|
toolbar_list = toolbar_get_list(TOOLBAR_MSGVIEW);
|
|
|
|
|
|
|
|
messageview->toolbar = g_new0(Toolbar, 1);
|
|
|
|
|
|
|
|
toolbar = gtk_toolbar_new(GTK_ORIENTATION_HORIZONTAL,
|
|
|
|
GTK_TOOLBAR_BOTH);
|
|
|
|
gtk_container_add(GTK_CONTAINER(container), toolbar);
|
|
|
|
gtk_container_set_border_width(GTK_CONTAINER(container), 2);
|
|
|
|
gtk_toolbar_set_button_relief(GTK_TOOLBAR(toolbar), GTK_RELIEF_NONE);
|
|
|
|
gtk_toolbar_set_space_style(GTK_TOOLBAR(toolbar),
|
|
|
|
GTK_TOOLBAR_SPACE_LINE);
|
|
|
|
|
|
|
|
for (cur = toolbar_list; cur != NULL; cur = cur->next) {
|
|
|
|
|
|
|
|
if (g_strcasecmp(((ToolbarItem*)cur->data)->file, SEPARATOR) == 0) {
|
|
|
|
gtk_toolbar_append_space(GTK_TOOLBAR(toolbar));
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
toolbar_item = g_new0(ToolbarItem, 1);
|
|
|
|
toolbar_item->file = g_strdup(((ToolbarItem*)cur->data)->file);
|
|
|
|
toolbar_item->text = g_strdup(((ToolbarItem*)cur->data)->text);
|
|
|
|
toolbar_item->index = ((ToolbarItem*)cur->data)->index;
|
|
|
|
|
|
|
|
toolbar_item->parent = g_new0(ToolbarParent, 1);
|
|
|
|
toolbar_item->parent->data = (gpointer)messageview;
|
|
|
|
toolbar_item->parent->type = TOOLBAR_MSGVIEW;
|
|
|
|
|
|
|
|
/* collect toolbar items in list to keep track */
|
|
|
|
messageview->toolbar->item_list =
|
|
|
|
g_slist_append(messageview->toolbar->item_list,
|
|
|
|
toolbar_item);
|
|
|
|
|
|
|
|
icon_wid = stock_pixmap_widget(container, stock_pixmap_get_icon(toolbar_item->file));
|
|
|
|
item = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
|
|
|
|
toolbar_item->text,
|
|
|
|
(""),
|
|
|
|
(""),
|
|
|
|
icon_wid, toolbar_messageview_buttons_cb,
|
|
|
|
toolbar_item);
|
|
|
|
|
|
|
|
switch (toolbar_item->index) {
|
|
|
|
case A_COMPOSE_EMAIL:
|
|
|
|
messageview->toolbar->compose_mail_btn = item;
|
|
|
|
gtk_tooltips_set_tip(GTK_TOOLTIPS(toolbar_tips),
|
|
|
|
messageview->toolbar->compose_mail_btn,
|
|
|
|
_("Compose Email"), NULL);
|
|
|
|
break;
|
|
|
|
case A_REPLY_MESSAGE:
|
|
|
|
messageview->toolbar->reply_btn = item;
|
|
|
|
gtk_tooltips_set_tip(GTK_TOOLTIPS(toolbar_tips),
|
|
|
|
messageview->toolbar->reply_btn,
|
|
|
|
_("Reply to Message"), NULL);
|
|
|
|
break;
|
|
|
|
case A_REPLY_SENDER:
|
|
|
|
messageview->toolbar->replysender_btn = item;
|
|
|
|
gtk_tooltips_set_tip(GTK_TOOLTIPS(toolbar_tips),
|
|
|
|
messageview->toolbar->replysender_btn,
|
|
|
|
_("Reply to Sender"), NULL);
|
|
|
|
break;
|
|
|
|
case A_REPLY_ALL:
|
|
|
|
messageview->toolbar->replyall_btn = item;
|
|
|
|
gtk_tooltips_set_tip(GTK_TOOLTIPS(toolbar_tips),
|
|
|
|
messageview->toolbar->replyall_btn,
|
|
|
|
_("Reply to All"), NULL);
|
|
|
|
break;
|
|
|
|
case A_REPLY_ML:
|
|
|
|
messageview->toolbar->replylist_btn = item;
|
|
|
|
gtk_tooltips_set_tip(GTK_TOOLTIPS(toolbar_tips),
|
|
|
|
messageview->toolbar->replylist_btn,
|
|
|
|
_("Reply to Mailing-list"), NULL);
|
|
|
|
break;
|
|
|
|
case A_FORWARD:
|
|
|
|
messageview->toolbar->fwd_btn = item;
|
|
|
|
gtk_tooltips_set_tip(GTK_TOOLTIPS(toolbar_tips),
|
|
|
|
messageview->toolbar->fwd_btn,
|
|
|
|
_("Forward Message"), NULL);
|
|
|
|
break;
|
|
|
|
case A_DELETE:
|
|
|
|
messageview->toolbar->delete_btn = item;
|
|
|
|
gtk_tooltips_set_tip(GTK_TOOLTIPS(toolbar_tips),
|
|
|
|
messageview->toolbar->delete_btn,
|
|
|
|
_("Delete Message"), NULL);
|
|
|
|
break;
|
|
|
|
case A_GOTO_NEXT:
|
|
|
|
messageview->toolbar->next_btn = item;
|
|
|
|
gtk_tooltips_set_tip(GTK_TOOLTIPS(toolbar_tips),
|
|
|
|
messageview->toolbar->next_btn,
|
|
|
|
_("Goto Next Message"), NULL);
|
|
|
|
break;
|
|
|
|
case A_SYL_ACTIONS:
|
|
|
|
action_item = g_new0(ToolbarSylpheedActions, 1);
|
|
|
|
action_item->widget = item;
|
|
|
|
action_item->name = g_strdup(toolbar_item->text);
|
|
|
|
|
|
|
|
messageview->toolbar->action_list =
|
|
|
|
g_slist_append(messageview->toolbar->action_list,
|
|
|
|
action_item);
|
|
|
|
|
|
|
|
gtk_tooltips_set_tip(GTK_TOOLTIPS(toolbar_tips),
|
|
|
|
item,
|
|
|
|
action_item->name, NULL);
|
|
|
|
|
|
|
|
gtk_widget_show(item);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
messageview->toolbar->toolbar = toolbar;
|
|
|
|
|
|
|
|
gtk_widget_show_all(toolbar);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void toolbar_messageview_buttons_cb(GtkWidget *widget,
|
|
|
|
ToolbarItem *item)
|
|
|
|
{
|
|
|
|
|
|
|
|
struct {
|
|
|
|
gint index;
|
|
|
|
void (*func)(GtkWidget *widget, gpointer data);
|
|
|
|
} messageview_action[] = {
|
|
|
|
{ A_COMPOSE_EMAIL, common_toolbar_compose_cb },
|
|
|
|
{ A_REPLY_MESSAGE, common_toolbar_reply_cb },
|
|
|
|
{ A_REPLY_SENDER, common_toolbar_reply_to_sender_cb },
|
|
|
|
{ A_REPLY_ALL, common_toolbar_reply_to_all_cb },
|
|
|
|
{ A_REPLY_ML, common_toolbar_reply_to_list_cb },
|
|
|
|
{ A_FORWARD, common_toolbar_forward_cb },
|
|
|
|
{ A_DELETE, common_toolbar_delete_cb },
|
|
|
|
{ A_GOTO_NEXT, common_toolbar_next_unread_cb },
|
|
|
|
{ A_SYL_ACTIONS, common_toolbar_actions_execute_cb },
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
gint num_items = sizeof(messageview_action)/sizeof(messageview_action[0]);
|
|
|
|
gint i;
|
|
|
|
for (i = 0; i < num_items; i++) {
|
|
|
|
|
|
|
|
if (messageview_action[i].index == item->index) {
|
|
|
|
messageview_action[i].func(widget, (gpointer)item->parent);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void messageview_reply_cb(gpointer data, guint action, GtkWidget *widget)
|
|
|
|
{
|
|
|
|
MessageView *messageview = (MessageView *)data;
|
|
|
|
|
|
|
|
switch (action) {
|
|
|
|
case COMPOSE_REPLY:
|
|
|
|
common_toolbar_reply_cb(NULL,messageview);
|
|
|
|
break;
|
|
|
|
case COMPOSE_REPLY_TO_ALL:
|
|
|
|
common_toolbar_reply_to_all_cb(NULL,messageview);
|
|
|
|
break;
|
|
|
|
case COMPOSE_REPLY_TO_SENDER:
|
|
|
|
common_toolbar_reply_to_sender_cb(NULL,messageview);
|
|
|
|
break;
|
|
|
|
case COMPOSE_REPLY_TO_LIST:
|
|
|
|
common_toolbar_reply_to_list_cb(NULL,messageview);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void messageview_delete_cb(gpointer data, guint action, GtkWidget *widget)
|
|
|
|
{
|
|
|
|
MessageView *messageview = (MessageView *)data;
|
|
|
|
|
|
|
|
common_toolbar_delete_cb(NULL,messageview);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void messageview_close_cb(gpointer data, guint action, GtkWidget *widget)
|
|
|
|
{
|
|
|
|
MessageView *messageview = (MessageView *)data;
|
|
|
|
|
|
|
|
gtk_widget_destroy(messageview->window);
|
|
|
|
}
|