2 * Claws Mail -- a GTK+ based, lightweight, and fast e-mail client
3 * Copyright (C) 1999-2020 the Claws Mail team and Hiroyuki Yamamoto
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 3 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
22 #include <glib/gi18n.h>
23 #include <gdk/gdkkeysyms.h>
30 #include "messageview.h"
31 #include "message_search.h"
32 #include "headerview.h"
33 #include "summaryview.h"
39 #include "foldersel.h"
40 #include "sourcewindow.h"
41 #include "alertpanel.h"
42 #include "inputdialog.h"
43 #include "mainwindow.h"
44 #include "manage_window.h"
46 #include "procheader.h"
50 #include "prefs_common.h"
51 #include "prefs_account.h"
54 #include "send_message.h"
55 #include "stock_pixmap.h"
57 #include "filtering.h"
58 #include "partial_download.h"
59 #include "uri_opener.h"
65 #include "quoted-printable.h"
67 #include "statusbar.h"
68 #include "folder_item_prefs.h"
70 #include "file-utils.h"
72 #ifndef USE_ALT_ADDRBOOK
73 #include "addressbook.h"
75 #include "addressadd.h"
76 #include "addressbook-dbus.h"
78 static GList
*messageview_list
= NULL
;
80 static gint
messageview_delete_cb (GtkWidget
*widget
,
82 MessageView
*messageview
);
83 static void messageview_size_allocate_cb(GtkWidget
*widget
,
84 GtkAllocation
*allocation
);
85 static gboolean
key_pressed (GtkWidget
*widget
,
87 MessageView
*messageview
);
88 static void return_receipt_show (NoticeView
*noticeview
,
90 static void return_receipt_send_clicked (NoticeView
*noticeview
,
92 static void partial_recv_show (NoticeView
*noticeview
,
94 static void partial_recv_dload_clicked (NoticeView
*noticeview
,
96 static void partial_recv_del_clicked (NoticeView
*noticeview
,
98 static void partial_recv_unmark_clicked (NoticeView
*noticeview
,
100 static void save_as_cb (GtkAction
*action
,
102 static void page_setup_cb (GtkAction
*action
,
104 static void print_cb (GtkAction
*action
,
106 static void close_cb (GtkAction
*action
,
108 static void copy_cb (GtkAction
*action
,
110 static void allsel_cb (GtkAction
*action
,
112 static void search_cb (GtkAction
*action
,
115 static void prev_cb (GtkAction
*action
,
117 static void next_cb (GtkAction
*action
,
119 static void prev_unread_cb (GtkAction
*action
,
121 static void next_unread_cb (GtkAction
*action
,
123 static void prev_new_cb (GtkAction
*action
,
125 static void next_new_cb (GtkAction
*action
,
127 static void prev_marked_cb (GtkAction
*action
,
129 static void next_marked_cb (GtkAction
*action
,
131 static void prev_labeled_cb (GtkAction
*action
,
133 static void next_labeled_cb (GtkAction
*action
,
135 static void prev_history_cb (GtkAction
*action
,
137 static void next_history_cb (GtkAction
*action
,
139 static void parent_cb (GtkAction
*action
,
141 static void goto_unread_folder_cb (GtkAction
*action
,
143 static void goto_folder_cb (GtkAction
*action
,
146 static void scroll_prev_line_cb (GtkAction
*action
,
148 static void scroll_next_line_cb (GtkAction
*action
,
150 static void scroll_next_page_cb (GtkAction
*action
,
152 static void scroll_prev_page_cb (GtkAction
*action
,
155 static void set_charset_cb (GtkAction
*action
, GtkRadioAction
*current
, gpointer data
);
156 static void set_decode_cb (GtkAction
*action
, GtkRadioAction
*current
, gpointer data
);
158 static void view_source_cb (GtkAction
*action
,
161 static void show_all_header_cb (GtkToggleAction
*action
,
163 static void msg_hide_quotes_cb (GtkToggleAction
*action
,
166 static void compose_cb (GtkAction
*action
,
168 static void reply_cb (GtkAction
*action
,
171 static PrefsAccount
*select_account_from_list
173 gboolean has_accounts
);
174 static void addressbook_open_cb (GtkAction
*action
,
176 static void add_address_cb (GtkAction
*action
,
178 static void create_filter_cb (GtkAction
*action
,
180 static void create_processing_cb (GtkAction
*action
,
182 static void open_urls_cb (GtkAction
*action
,
185 static void about_cb (GtkAction
*action
,
187 static void messageview_update (MessageView
*msgview
,
188 MsgInfo
*old_msginfo
);
189 static gboolean
messageview_update_msg (gpointer source
, gpointer data
);
191 static void save_part_as_cb(GtkAction
*action
, gpointer data
);
192 static void view_part_as_text_cb(GtkAction
*action
, gpointer data
);
193 static void open_part_cb(GtkAction
*action
, gpointer data
);
195 static void open_part_with_cb(GtkAction
*action
, gpointer data
);
197 static void check_signature_cb(GtkAction
*action
, gpointer data
);
198 static void goto_next_part_cb(GtkAction
*action
, gpointer data
);
199 static void goto_prev_part_cb(GtkAction
*action
, gpointer data
);
201 static void messageview_nothing_cb (GtkAction
*action
, gpointer data
)
206 static GList
*msgview_list
= NULL
;
207 static GtkActionEntry msgview_entries
[] =
209 {"Menu", NULL
, "Menu", NULL
, NULL
, NULL
},
211 {"File", NULL
, N_("_File"), NULL
, NULL
, NULL
},
212 {"Edit", NULL
, N_("_Edit"), NULL
, NULL
, NULL
},
213 {"View", NULL
, N_("_View"), NULL
, NULL
, NULL
},
214 {"Message", NULL
, N_("_Message"), NULL
, NULL
, NULL
},
215 {"Tools", NULL
, N_("_Tools"), NULL
, NULL
, NULL
},
216 {"Help", NULL
, N_("_Help"), NULL
, NULL
, NULL
},
217 {"PlaceHolder", NULL
, "Placeholder", NULL
, NULL
, G_CALLBACK(messageview_nothing_cb
) },
220 {"File/SaveAs", NULL
, N_("_Save email as..."), "<control>S", NULL
, G_CALLBACK(save_as_cb
) },
221 {"File/SavePartAs", NULL
, N_("_Save part as..."), "Y", NULL
, G_CALLBACK(save_part_as_cb
) },
222 {"File/PageSetup", NULL
, N_("Page setup..."), NULL
, NULL
, G_CALLBACK(page_setup_cb
) },
223 {"File/Print", NULL
, N_("_Print..."), "<control>P", NULL
, G_CALLBACK(print_cb
) },
224 {"File/---", NULL
, "---", NULL
, NULL
, NULL
},
225 {"File/Close", NULL
, N_("_Close"), "<control>W", NULL
, G_CALLBACK(close_cb
) },
228 {"Edit/Copy", NULL
, N_("_Copy"), "<control>C", NULL
, G_CALLBACK(copy_cb
) },
229 {"Edit/SelectAll", NULL
, N_("_Select all"), "<control>A", NULL
, G_CALLBACK(allsel_cb
) },
230 {"Edit/---", NULL
, "---", NULL
, NULL
, NULL
},
231 {"Edit/Find", NULL
, N_("_Find"), "<control>F", NULL
, G_CALLBACK(search_cb
) },
234 {"View/Goto", NULL
, N_("_Go to"), NULL
, NULL
, NULL
},
235 {"View/Goto/Prev", NULL
, N_("_Previous message"), "P", NULL
, G_CALLBACK(prev_cb
) },
236 {"View/Goto/Next", NULL
, N_("_Next message"), "N", NULL
, G_CALLBACK(next_cb
) },
237 {"View/Goto/---", NULL
, "---", NULL
, NULL
, NULL
},
238 {"View/Goto/PrevUnread", NULL
, N_("P_revious unread message"), "<shift>P", NULL
, G_CALLBACK(prev_unread_cb
) },
239 {"View/Goto/NextUnread", NULL
, N_("N_ext unread message"), "<shift>N", NULL
, G_CALLBACK(next_unread_cb
) },
240 /* {"View/Goto/---", NULL, "---", NULL, NULL, NULL }, */
241 {"View/Goto/PrevNew", NULL
, N_("Previous ne_w message"), NULL
, NULL
, G_CALLBACK(prev_new_cb
) },
242 {"View/Goto/NextNew", NULL
, N_("Ne_xt new message"), NULL
, NULL
, G_CALLBACK(next_new_cb
) },
243 /* {"View/Goto/---", NULL, "---", NULL, NULL, NULL }, */
244 {"View/Goto/PrevMarked", NULL
, N_("Previous _marked message"), NULL
, NULL
, G_CALLBACK(prev_marked_cb
) },
245 {"View/Goto/NextMarked", NULL
, N_("Next m_arked message"), NULL
, NULL
, G_CALLBACK(next_marked_cb
) },
246 /* {"View/Goto/---", NULL, "---", NULL, NULL, NULL }, */
247 {"View/Goto/PrevLabeled", NULL
, N_("Previous _labeled message"), NULL
, NULL
, G_CALLBACK(prev_labeled_cb
) },
248 {"View/Goto/NextLabeled", NULL
, N_("Next la_beled message"), NULL
, NULL
, G_CALLBACK(next_labeled_cb
) },
249 /* {"View/Goto/---", NULL, "---", NULL, NULL, NULL }, */
250 {"View/Goto/PrevHistory", NULL
, N_("Previous opened message"), "<alt>Left", NULL
, G_CALLBACK(prev_history_cb
) },
251 {"View/Goto/NextHistory", NULL
, N_("Next opened message"), "<alt>Right", NULL
, G_CALLBACK(next_history_cb
) },
252 /* {"View/Goto/---", NULL, "---", NULL, NULL, NULL }, */
253 {"View/Goto/ParentMessage", NULL
, N_("Parent message"), "<control>Up", NULL
, G_CALLBACK(parent_cb
) },
254 /* {"View/Goto/---", NULL, "---", NULL, NULL, NULL }, */
255 {"View/Goto/NextUnreadFolder", NULL
, N_("Next unread _folder"), "<shift>G", NULL
, G_CALLBACK(goto_unread_folder_cb
) },
256 {"View/Goto/Folder", NULL
, N_("F_older..."), "G", NULL
, G_CALLBACK(goto_folder_cb
) },
257 /* {"View/Goto/---", NULL, "---", NULL, NULL, NULL }, */
258 {"View/Goto/NextPart", NULL
, N_("Next part"), "A", NULL
, G_CALLBACK(goto_next_part_cb
) },
259 {"View/Goto/PrevPart", NULL
, N_("Previous part"), "Z", NULL
, G_CALLBACK(goto_prev_part_cb
) },
260 {"View/Scroll", NULL
, N_("Message scroll"), NULL
, NULL
, NULL
},
261 {"View/Scroll/PrevLine", NULL
, N_("Previous line"), NULL
, NULL
, G_CALLBACK(scroll_prev_line_cb
) },
262 {"View/Scroll/NextLine", NULL
, N_("Next line"), NULL
, NULL
, G_CALLBACK(scroll_next_line_cb
) },
263 {"View/Scroll/PrevPage", NULL
, N_("Previous page"), NULL
, NULL
, G_CALLBACK(scroll_prev_page_cb
) },
264 {"View/Scroll/NextPage", NULL
, N_("Next page"), NULL
, NULL
, G_CALLBACK(scroll_next_page_cb
) },
265 /* {"View/Scroll/---", NULL, "---", NULL, NULL, NULL }, */
267 {"View/Encoding", NULL
, N_("Character _encoding"), NULL
, NULL
, NULL
}, /* set_charset_cb */
268 {"View/Encoding/---", NULL
, "---", NULL
, NULL
, NULL
},
269 #define ENC_ACTION(cs_char,c_char,string) \
270 { "View/Encoding/" cs_char, NULL, N_(string), NULL, NULL, c_char }
272 {"View/Encoding/Western", NULL
, N_("Western European"), NULL
, NULL
, NULL
},
273 {"View/Encoding/Baltic", NULL
, N_("Baltic"), NULL
, NULL
, NULL
},
274 {"View/Encoding/Hebrew", NULL
, N_("Hebrew"), NULL
, NULL
, NULL
},
275 {"View/Encoding/Arabic", NULL
, N_("Arabic"), NULL
, NULL
, NULL
},
276 {"View/Encoding/Cyrillic", NULL
, N_("Cyrillic"), NULL
, NULL
, NULL
},
277 {"View/Encoding/Japanese", NULL
, N_("Japanese"), NULL
, NULL
, NULL
},
278 {"View/Encoding/Chinese", NULL
, N_("Chinese"), NULL
, NULL
, NULL
},
279 {"View/Encoding/Korean", NULL
, N_("Korean"), NULL
, NULL
, NULL
},
280 {"View/Encoding/Thai", NULL
, N_("Thai"), NULL
, NULL
, NULL
},
282 {"View/Decode", NULL
, N_("Decode"), NULL
, NULL
, NULL
}, /* set_decode_cb */
283 {"View/Decode/---", NULL
, "---", NULL
, NULL
, NULL
},
285 #define DEC_ACTION(cs_type,c_type,string) \
286 { "View/Decode/" cs_type, NULL, N_(string), NULL, NULL, c_type }
288 {"View/---", NULL
, "---", NULL
, NULL
, NULL
},
289 {"View/MessageSource", NULL
, N_("Mess_age source"), "<control>U", NULL
, G_CALLBACK(view_source_cb
) },
290 {"View/Part", NULL
, N_("Message part"), NULL
, NULL
, NULL
},
291 {"View/Part/AsText", NULL
, N_("View as text"), "T", NULL
, G_CALLBACK(view_part_as_text_cb
) },
292 {"View/Part/Open", NULL
, N_("Open"), "L", NULL
, G_CALLBACK(open_part_cb
) },
294 {"View/Part/OpenWith", NULL
, N_("Open with..."), "O", NULL
, G_CALLBACK(open_part_with_cb
) },
297 {"View/Quotes", NULL
, N_("Quotes"), NULL
, NULL
, NULL
},
300 {"Message/Compose", NULL
, N_("Compose _new message"), "<control>M", NULL
, G_CALLBACK(compose_cb
) },
301 {"Message/---", NULL
, "---", NULL
, NULL
, NULL
},
303 {"Message/Reply", NULL
, N_("_Reply"), "<control>R", NULL
, G_CALLBACK(reply_cb
) }, /* COMPOSE_REPLY */
304 {"Message/ReplyTo", NULL
, N_("Repl_y to"), NULL
, NULL
, NULL
},
305 {"Message/ReplyTo/All", NULL
, N_("_All"), "<control><shift>R", NULL
, G_CALLBACK(reply_cb
) }, /* COMPOSE_REPLY_TO_ALL */
306 {"Message/ReplyTo/Sender", NULL
, N_("_Sender"), NULL
, NULL
, G_CALLBACK(reply_cb
) }, /* COMPOSE_REPLY_TO_SENDER */
307 {"Message/ReplyTo/List", NULL
, N_("Mailing _list"), "<control>L", NULL
, G_CALLBACK(reply_cb
) }, /* COMPOSE_REPLY_TO_LIST */
308 /* {"Message/---", NULL, "---", NULL, NULL, NULL }, */
310 {"Message/Forward", NULL
, N_("_Forward"), "<control><alt>F", NULL
, G_CALLBACK(reply_cb
) }, /* COMPOSE_FORWARD_INLINE */
311 {"Message/ForwardAtt", NULL
, N_("For_ward as attachment"), NULL
, NULL
, G_CALLBACK(reply_cb
) }, /* COMPOSE_FORWARD_AS_ATTACH */
312 {"Message/Redirect", NULL
, N_("Redirec_t"), NULL
, NULL
, G_CALLBACK(reply_cb
) }, /* COMPOSE_REDIRECT */
313 {"Message/CheckSignature", NULL
, N_("Check signature"), "C", NULL
, G_CALLBACK(check_signature_cb
) },
316 {"Tools/AddressBook", NULL
, N_("_Address book"), "<control><shift>A", NULL
, G_CALLBACK(addressbook_open_cb
) },
317 {"Tools/AddSenderToAB", NULL
, N_("Add sender to address boo_k"), NULL
, NULL
, G_CALLBACK(add_address_cb
) },
318 {"Tools/---", NULL
, "---", NULL
, NULL
, NULL
},
320 {"Tools/CreateFilterRule", NULL
, N_("_Create filter rule"), NULL
, NULL
, NULL
},
321 {"Tools/CreateFilterRule/Automatically", NULL
, N_("_Automatically"), NULL
, NULL
, G_CALLBACK(create_filter_cb
) }, /* FILTER_BY_AUTO */
322 {"Tools/CreateFilterRule/ByFrom", NULL
, N_("By _From"), NULL
, NULL
, G_CALLBACK(create_filter_cb
) }, /* FILTER_BY_FROM */
323 {"Tools/CreateFilterRule/ByTo", NULL
, N_("By _To"), NULL
, NULL
, G_CALLBACK(create_filter_cb
) }, /* FILTER_BY_TO */
324 {"Tools/CreateFilterRule/BySubject", NULL
, N_("By _Subject"), NULL
, NULL
, G_CALLBACK(create_filter_cb
) }, /* FILTER_BY_SUBJECT */
326 {"Tools/CreateProcessingRule", NULL
, N_("Create processing rule"), NULL
, NULL
, NULL
},
327 {"Tools/CreateProcessingRule/Automatically", NULL
, N_("_Automatically"), NULL
, NULL
, G_CALLBACK(create_processing_cb
) },
328 {"Tools/CreateProcessingRule/ByFrom", NULL
, N_("By _From"), NULL
, NULL
, G_CALLBACK(create_processing_cb
) },
329 {"Tools/CreateProcessingRule/ByTo", NULL
, N_("By _To"), NULL
, NULL
, G_CALLBACK(create_processing_cb
) },
330 {"Tools/CreateProcessingRule/BySubject", NULL
, N_("By _Subject"), NULL
, NULL
, G_CALLBACK(create_processing_cb
) },
331 /* {"Tools/---", NULL, "---", NULL, NULL, NULL }, */
333 {"Tools/ListUrls", NULL
, N_("List _URLs..."), "<control><shift>U", NULL
, G_CALLBACK(open_urls_cb
) },
335 /* {"Tools/---", NULL, "---", NULL, NULL, NULL }, */
336 {"Tools/Actions", NULL
, N_("Actio_ns"), NULL
, NULL
, NULL
},
337 {"Tools/Actions/PlaceHolder", NULL
, "Placeholder", NULL
, NULL
, G_CALLBACK(messageview_nothing_cb
) },
340 {"Help/About", NULL
, N_("_About"), NULL
, NULL
, G_CALLBACK(about_cb
) },
343 static GtkToggleActionEntry msgview_toggle_entries
[] =
345 {"View/AllHeaders", NULL
, N_("Show all _headers"), "<control>H", NULL
, G_CALLBACK(show_all_header_cb
), FALSE
}, /* toggle */
346 {"View/Quotes/CollapseAll", NULL
, N_("_Collapse all"), "<control><shift>Q", NULL
, G_CALLBACK(msg_hide_quotes_cb
), FALSE
}, /* 1 toggle */
347 {"View/Quotes/Collapse2", NULL
, N_("Collapse from level _2"), NULL
, NULL
, G_CALLBACK(msg_hide_quotes_cb
), FALSE
}, /* 2 toggle */
348 {"View/Quotes/Collapse3", NULL
, N_("Collapse from level _3"), NULL
, NULL
, G_CALLBACK(msg_hide_quotes_cb
), FALSE
}, /* 3 toggle */
351 static GtkRadioActionEntry msgview_radio_enc_entries
[] =
353 ENC_ACTION(CS_AUTO
, C_AUTO
, N_("_Automatic")), /* RADIO set_charset_cb */
354 ENC_ACTION(CS_US_ASCII
, C_US_ASCII
, N_("7bit ASCII (US-ASC_II)")), /* RADIO set_charset_cb */
355 ENC_ACTION(CS_UTF_8
, C_UTF_8
, N_("Unicode (_UTF-8)")), /* RADIO set_charset_cb */
356 ENC_ACTION("Western/"CS_ISO_8859_1
, C_ISO_8859_1
, "ISO-8859-_1"), /* RADIO set_charset_cb */
357 ENC_ACTION("Western/"CS_ISO_8859_15
, C_ISO_8859_15
, "ISO-8859-15"), /* RADIO set_charset_cb */
358 ENC_ACTION("Western/"CS_WINDOWS_1252
, C_WINDOWS_1252
, "Windows-1252"), /* RADIO set_charset_cb */
359 ENC_ACTION(CS_ISO_8859_2
, C_ISO_8859_2
, N_("Central European (ISO-8859-_2)")), /* RADIO set_charset_cb */
360 ENC_ACTION("Baltic/"CS_ISO_8859_13
, C_ISO_8859_13
, "ISO-8859-13"), /* RADIO set_charset_cb */
361 ENC_ACTION("Baltic/"CS_ISO_8859_4
, C_ISO_8859_14
, "ISO-8859-_4"), /* RADIO set_charset_cb */
362 ENC_ACTION(CS_ISO_8859_7
, C_ISO_8859_7
, N_("Greek (ISO-8859-_7)")), /* RADIO set_charset_cb */
363 ENC_ACTION("Hebrew/"CS_ISO_8859_8
, C_ISO_8859_8
, "ISO-8859-_8"), /* RADIO set_charset_cb */
364 ENC_ACTION("Hebrew/"CS_WINDOWS_1255
, C_WINDOWS_1255
, "Windows-1255"), /* RADIO set_charset_cb */
365 ENC_ACTION("Arabic/"CS_ISO_8859_6
, C_ISO_8859_6
, "ISO-8859-_6"), /* RADIO set_charset_cb */
366 ENC_ACTION("Arabic/"CS_WINDOWS_1256
, C_WINDOWS_1256
, "Windows-1256"), /* RADIO set_charset_cb */
367 ENC_ACTION(CS_ISO_8859_9
, C_ISO_8859_9
, N_("Turkish (ISO-8859-_9)")), /* RADIO set_charset_cb */
368 ENC_ACTION("Cyrillic/"CS_ISO_8859_5
, C_ISO_8859_5
, "ISO-8859-_5"), /* RADIO set_charset_cb */
369 ENC_ACTION("Cyrillic/"CS_KOI8_R
, C_KOI8_R
, "KOI8-_R"), /* RADIO set_charset_cb */
370 ENC_ACTION("Cyrillic/"CS_MACCYR
, C_MACCYR
, "MAC_CYR"), /* RADIO set_charset_cb */
371 ENC_ACTION("Cyrillic/"CS_KOI8_U
, C_KOI8_U
, "KOI8-_U"), /* RADIO set_charset_cb */
372 ENC_ACTION("Cyrillic/"CS_WINDOWS_1251
, C_WINDOWS_1251
, "Windows-1251"), /* RADIO set_charset_cb */
373 ENC_ACTION("Japanese/"CS_ISO_2022_JP
, C_ISO_2022_JP
, "ISO-2022-_JP"), /* RADIO set_charset_cb */
374 ENC_ACTION("Japanese/"CS_ISO_2022_JP_2
, C_ISO_2022_JP_2
, "ISO-2022-JP-_2"), /* RADIO set_charset_cb */
375 ENC_ACTION("Japanese/"CS_EUC_JP
, C_EUC_JP
, "_EUC-JP"), /* RADIO set_charset_cb */
376 ENC_ACTION("Japanese/"CS_SHIFT_JIS
, C_SHIFT_JIS
, "_Shift-JIS"), /* RADIO set_charset_cb */
377 ENC_ACTION("Chinese/"CS_GB18030
, C_GB18030
, "_GB18030"), /* RADIO set_charset_cb */
378 ENC_ACTION("Chinese/"CS_GB2312
, C_GB2312
, "_GB2312"), /* RADIO set_charset_cb */
379 ENC_ACTION("Chinese/"CS_GBK
, C_GBK
, "GB_K"), /* RADIO set_charset_cb */
380 ENC_ACTION("Chinese/"CS_BIG5
, C_BIG5
, "_Big5-JP"), /* RADIO set_charset_cb */
381 ENC_ACTION("Chinese/"CS_EUC_TW
, C_EUC_TW
, "EUC-_TW"), /* RADIO set_charset_cb */
382 ENC_ACTION("Korean/"CS_EUC_KR
, C_EUC_KR
, "_EUC-KR"), /* RADIO set_charset_cb */
383 ENC_ACTION("Korean/"CS_ISO_2022_KR
, C_ISO_2022_KR
, "_ISO-2022-KR"), /* RADIO set_charset_cb */
384 ENC_ACTION("Thai/"CS_TIS_620
, C_TIS_620
, "_TIS-620-KR"), /* RADIO set_charset_cb */
385 ENC_ACTION("Thai/"CS_WINDOWS_874
, C_WINDOWS_874
, "_Windows-874"), /* RADIO set_charset_cb */
388 static GtkRadioActionEntry msgview_radio_dec_entries
[] =
390 DEC_ACTION("AutoDetect", 0, N_("_Auto detect")), /* set_decode_cb */
392 DEC_ACTION("8bit", ENC_8BIT
, "_8bit"),
393 DEC_ACTION("QP", ENC_QUOTED_PRINTABLE
, "_Quoted printable"),
394 DEC_ACTION("B64", ENC_BASE64
, "_Base64"),
395 DEC_ACTION("Uuencode", ENC_X_UUENCODE
, "_Uuencode"),
398 MessageView
*messageview_create(MainWindow
*mainwin
)
400 MessageView
*messageview
;
402 HeaderView
*headerview
;
404 NoticeView
*noticeview
;
406 debug_print("Creating message view...\n");
407 messageview
= g_new0(MessageView
, 1);
409 headerview
= headerview_create();
411 noticeview
= noticeview_create(mainwin
);
413 mimeview
= mimeview_create(mainwin
);
414 mimeview
->textview
= textview_create();
415 mimeview
->textview
->messageview
= messageview
;
416 mimeview
->messageview
= messageview
;
418 vbox
= gtk_box_new(GTK_ORIENTATION_VERTICAL
, 0);
419 gtk_widget_set_name(GTK_WIDGET(vbox
), "messageview");
420 gtk_box_pack_start(GTK_BOX(vbox
), GTK_WIDGET_PTR(headerview
),
422 gtk_box_pack_start(GTK_BOX(vbox
), GTK_WIDGET_PTR(noticeview
),
424 gtk_box_pack_start(GTK_BOX(vbox
),
425 GTK_WIDGET_PTR(mimeview
), TRUE
, TRUE
, 0);
426 gtk_widget_show(vbox
);
428 messageview
->vbox
= vbox
;
429 messageview
->new_window
= FALSE
;
430 messageview
->window
= NULL
;
431 messageview
->headerview
= headerview
;
432 messageview
->mimeview
= mimeview
;
433 messageview
->noticeview
= noticeview
;
434 messageview
->mainwin
= mainwin
;
436 messageview
->statusbar
= NULL
;
437 messageview
->statusbar_cid
= 0;
439 messageview
->show_full_text
= FALSE
;
440 messageview
->update_needed
= FALSE
;
442 messageview
->msginfo_update_callback_id
=
443 hooks_register_hook(MSGINFO_UPDATE_HOOKLIST
, messageview_update_msg
, (gpointer
) messageview
);
448 const GList
*messageview_get_msgview_list(void)
453 void messageview_update_actions_menu(MessageView
*msgview
)
455 /* Messages opened in a new window do not have a menu bar */
456 if (msgview
->menubar
== NULL
)
458 action_update_msgview_menu(msgview
->ui_manager
, "/Menu/Tools/Actions", msgview
);
461 static void messageview_add_toolbar(MessageView
*msgview
, GtkWidget
*window
)
463 GtkWidget
*handlebox
;
467 GtkWidget
*statusbar
= NULL
;
469 GtkActionGroup
*action_group
;
472 vbox
= gtk_box_new(GTK_ORIENTATION_VERTICAL
, 0);
473 gtk_widget_show(vbox
);
474 gtk_container_add(GTK_CONTAINER(window
), vbox
);
476 msgview
->ui_manager
= gtk_ui_manager_new();
477 action_group
= cm_menu_create_action_group_full(msgview
->ui_manager
,"Menu", msgview_entries
,
478 G_N_ELEMENTS(msgview_entries
), (gpointer
)msgview
);
479 gtk_action_group_add_toggle_actions(action_group
, msgview_toggle_entries
,
480 G_N_ELEMENTS(msgview_toggle_entries
), (gpointer
)msgview
);
481 gtk_action_group_add_radio_actions(action_group
, msgview_radio_enc_entries
,
482 G_N_ELEMENTS(msgview_radio_enc_entries
), C_AUTO
, G_CALLBACK(set_charset_cb
), (gpointer
)msgview
);
483 gtk_action_group_add_radio_actions(action_group
, msgview_radio_dec_entries
,
484 G_N_ELEMENTS(msgview_radio_dec_entries
), C_AUTO
, G_CALLBACK(set_decode_cb
), (gpointer
)msgview
);
486 MENUITEM_ADDUI_MANAGER(msgview
->ui_manager
, "/", "Menu", NULL
, GTK_UI_MANAGER_MENUBAR
)
487 MENUITEM_ADDUI_MANAGER(msgview
->ui_manager
, "/Menu", "File", "File", GTK_UI_MANAGER_MENU
)
488 MENUITEM_ADDUI_MANAGER(msgview
->ui_manager
, "/Menu", "Edit", "Edit", GTK_UI_MANAGER_MENU
)
489 MENUITEM_ADDUI_MANAGER(msgview
->ui_manager
, "/Menu", "View", "View", GTK_UI_MANAGER_MENU
)
490 MENUITEM_ADDUI_MANAGER(msgview
->ui_manager
, "/Menu", "Message", "Message", GTK_UI_MANAGER_MENU
)
491 MENUITEM_ADDUI_MANAGER(msgview
->ui_manager
, "/Menu", "Tools", "Tools", GTK_UI_MANAGER_MENU
)
492 MENUITEM_ADDUI_MANAGER(msgview
->ui_manager
, "/Menu", "Help", "Help", GTK_UI_MANAGER_MENU
)
495 MENUITEM_ADDUI_MANAGER(msgview
->ui_manager
, "/Menu/File", "SaveAs", "File/SaveAs", GTK_UI_MANAGER_MENUITEM
)
496 MENUITEM_ADDUI_MANAGER(msgview
->ui_manager
, "/Menu/File", "SavePartAs", "File/SavePartAs", GTK_UI_MANAGER_MENUITEM
)
497 MENUITEM_ADDUI_MANAGER(msgview
->ui_manager
, "/Menu/File", "Separator1", "File/---", GTK_UI_MANAGER_SEPARATOR
)
498 MENUITEM_ADDUI_MANAGER(msgview
->ui_manager
, "/Menu/File", "PageSetup", "File/PageSetup", GTK_UI_MANAGER_MENUITEM
)
499 MENUITEM_ADDUI_MANAGER(msgview
->ui_manager
, "/Menu/File", "Print", "File/Print", GTK_UI_MANAGER_MENUITEM
)
500 MENUITEM_ADDUI_MANAGER(msgview
->ui_manager
, "/Menu/File", "Separator2", "File/---", GTK_UI_MANAGER_SEPARATOR
)
501 MENUITEM_ADDUI_MANAGER(msgview
->ui_manager
, "/Menu/File", "Close", "File/Close", GTK_UI_MANAGER_MENUITEM
)
504 MENUITEM_ADDUI_MANAGER(msgview
->ui_manager
, "/Menu/Edit", "Copy", "Edit/Copy", GTK_UI_MANAGER_MENUITEM
)
505 MENUITEM_ADDUI_MANAGER(msgview
->ui_manager
, "/Menu/Edit", "SelectAll", "Edit/SelectAll", GTK_UI_MANAGER_MENUITEM
)
506 MENUITEM_ADDUI_MANAGER(msgview
->ui_manager
, "/Menu/Edit", "Separator1", "Edit/---", GTK_UI_MANAGER_SEPARATOR
)
507 MENUITEM_ADDUI_MANAGER(msgview
->ui_manager
, "/Menu/Edit", "Find", "Edit/Find", GTK_UI_MANAGER_MENUITEM
)
510 MENUITEM_ADDUI_MANAGER(msgview
->ui_manager
, "/Menu/View", "Goto", "View/Goto", GTK_UI_MANAGER_MENU
)
511 MENUITEM_ADDUI_MANAGER(msgview
->ui_manager
, "/Menu/View/Goto", "Prev", "View/Goto/Prev", GTK_UI_MANAGER_MENUITEM
)
512 MENUITEM_ADDUI_MANAGER(msgview
->ui_manager
, "/Menu/View/Goto", "Next", "View/Goto/Next", GTK_UI_MANAGER_MENUITEM
)
513 MENUITEM_ADDUI_MANAGER(msgview
->ui_manager
, "/Menu/View/Goto", "Separator1", "View/Goto/---", GTK_UI_MANAGER_SEPARATOR
)
514 MENUITEM_ADDUI_MANAGER(msgview
->ui_manager
, "/Menu/View/Goto", "PrevUnread", "View/Goto/PrevUnread", GTK_UI_MANAGER_MENUITEM
)
515 MENUITEM_ADDUI_MANAGER(msgview
->ui_manager
, "/Menu/View/Goto", "NextUnread", "View/Goto/NextUnread", GTK_UI_MANAGER_MENUITEM
)
516 MENUITEM_ADDUI_MANAGER(msgview
->ui_manager
, "/Menu/View/Goto", "Separator2", "View/Goto/---", GTK_UI_MANAGER_SEPARATOR
)
517 MENUITEM_ADDUI_MANAGER(msgview
->ui_manager
, "/Menu/View/Goto", "PrevNew", "View/Goto/PrevNew", GTK_UI_MANAGER_MENUITEM
)
518 MENUITEM_ADDUI_MANAGER(msgview
->ui_manager
, "/Menu/View/Goto", "NextNew", "View/Goto/NextNew", GTK_UI_MANAGER_MENUITEM
)
519 MENUITEM_ADDUI_MANAGER(msgview
->ui_manager
, "/Menu/View/Goto", "Separator3", "View/Goto/---", GTK_UI_MANAGER_SEPARATOR
)
520 MENUITEM_ADDUI_MANAGER(msgview
->ui_manager
, "/Menu/View/Goto", "PrevMarked", "View/Goto/PrevMarked", GTK_UI_MANAGER_MENUITEM
)
521 MENUITEM_ADDUI_MANAGER(msgview
->ui_manager
, "/Menu/View/Goto", "NextMarked", "View/Goto/NextMarked", GTK_UI_MANAGER_MENUITEM
)
522 MENUITEM_ADDUI_MANAGER(msgview
->ui_manager
, "/Menu/View/Goto", "Separator4", "View/Goto/---", GTK_UI_MANAGER_SEPARATOR
)
523 MENUITEM_ADDUI_MANAGER(msgview
->ui_manager
, "/Menu/View/Goto", "PrevLabeled", "View/Goto/PrevLabeled", GTK_UI_MANAGER_MENUITEM
)
524 MENUITEM_ADDUI_MANAGER(msgview
->ui_manager
, "/Menu/View/Goto", "NextLabeled", "View/Goto/NextLabeled", GTK_UI_MANAGER_MENUITEM
)
525 MENUITEM_ADDUI_MANAGER(msgview
->ui_manager
, "/Menu/View/Goto", "Separator5", "View/Goto/---", GTK_UI_MANAGER_SEPARATOR
)
526 MENUITEM_ADDUI_MANAGER(msgview
->ui_manager
, "/Menu/View/Goto", "PrevHistory", "View/Goto/PrevHistory", GTK_UI_MANAGER_MENUITEM
)
527 MENUITEM_ADDUI_MANAGER(msgview
->ui_manager
, "/Menu/View/Goto", "NextHistory", "View/Goto/NextHistory", GTK_UI_MANAGER_MENUITEM
)
528 MENUITEM_ADDUI_MANAGER(msgview
->ui_manager
, "/Menu/View/Goto", "Separator6", "View/Goto/---", GTK_UI_MANAGER_SEPARATOR
)
529 MENUITEM_ADDUI_MANAGER(msgview
->ui_manager
, "/Menu/View/Goto", "ParentMessage", "View/Goto/ParentMessage", GTK_UI_MANAGER_MENUITEM
)
530 MENUITEM_ADDUI_MANAGER(msgview
->ui_manager
, "/Menu/View/Goto", "Separator7", "View/Goto/---", GTK_UI_MANAGER_SEPARATOR
)
531 MENUITEM_ADDUI_MANAGER(msgview
->ui_manager
, "/Menu/View/Goto", "NextUnreadFolder", "View/Goto/NextUnreadFolder", GTK_UI_MANAGER_MENUITEM
)
532 MENUITEM_ADDUI_MANAGER(msgview
->ui_manager
, "/Menu/View/Goto", "Folder", "View/Goto/Folder", GTK_UI_MANAGER_MENUITEM
)
533 MENUITEM_ADDUI_MANAGER(msgview
->ui_manager
, "/Menu/View/Goto", "Separator8", "View/Goto/---", GTK_UI_MANAGER_SEPARATOR
)
534 MENUITEM_ADDUI_MANAGER(msgview
->ui_manager
, "/Menu/View/Goto", "NextPart", "View/Goto/NextPart", GTK_UI_MANAGER_MENUITEM
)
535 MENUITEM_ADDUI_MANAGER(msgview
->ui_manager
, "/Menu/View/Goto", "PrevPart", "View/Goto/PrevPart", GTK_UI_MANAGER_MENUITEM
)
537 MENUITEM_ADDUI_MANAGER(msgview
->ui_manager
, "/Menu/View", "Scroll", "View/Scroll", GTK_UI_MANAGER_MENU
)
538 MENUITEM_ADDUI_MANAGER(msgview
->ui_manager
, "/Menu/View/Scroll", "PrevLine", "View/Scroll/PrevLine", GTK_UI_MANAGER_MENUITEM
)
539 MENUITEM_ADDUI_MANAGER(msgview
->ui_manager
, "/Menu/View/Scroll", "NextLine", "View/Scroll/NextLine", GTK_UI_MANAGER_MENUITEM
)
540 MENUITEM_ADDUI_MANAGER(msgview
->ui_manager
, "/Menu/View/Scroll", "PrevPage", "View/Scroll/PrevPage", GTK_UI_MANAGER_MENUITEM
)
541 MENUITEM_ADDUI_MANAGER(msgview
->ui_manager
, "/Menu/View/Scroll", "NextPage", "View/Scroll/NextPage", GTK_UI_MANAGER_MENUITEM
)
543 MENUITEM_ADDUI_MANAGER(msgview
->ui_manager
, "/Menu/View", "Separator1", "View/---", GTK_UI_MANAGER_SEPARATOR
)
545 MENUITEM_ADDUI_MANAGER(msgview
->ui_manager
, "/Menu/View", "Encoding", "View/Encoding", GTK_UI_MANAGER_MENU
)
546 MENUITEM_ADDUI_MANAGER(msgview
->ui_manager
, "/Menu/View/Encoding", CS_AUTO
, "View/Encoding/"CS_AUTO
, GTK_UI_MANAGER_MENUITEM
)
547 MENUITEM_ADDUI_MANAGER(msgview
->ui_manager
, "/Menu/View/Encoding", "Separator1", "View/Encoding/---", GTK_UI_MANAGER_SEPARATOR
)
548 MENUITEM_ADDUI_MANAGER(msgview
->ui_manager
, "/Menu/View/Encoding", CS_US_ASCII
, "View/Encoding/"CS_US_ASCII
, GTK_UI_MANAGER_MENUITEM
)
549 MENUITEM_ADDUI_MANAGER(msgview
->ui_manager
, "/Menu/View/Encoding", CS_UTF_8
, "View/Encoding/"CS_UTF_8
, GTK_UI_MANAGER_MENUITEM
)
550 MENUITEM_ADDUI_MANAGER(msgview
->ui_manager
, "/Menu/View/Encoding", "Separator2", "View/Encoding/---", GTK_UI_MANAGER_SEPARATOR
)
552 MENUITEM_ADDUI_MANAGER(msgview
->ui_manager
, "/Menu/View/Encoding", "Western", "View/Encoding/Western", GTK_UI_MANAGER_MENU
)
553 MENUITEM_ADDUI_MANAGER(msgview
->ui_manager
, "/Menu/View/Encoding/Western", CS_ISO_8859_1
, "View/Encoding/Western/"CS_ISO_8859_1
, GTK_UI_MANAGER_MENUITEM
)
554 MENUITEM_ADDUI_MANAGER(msgview
->ui_manager
, "/Menu/View/Encoding/Western", CS_ISO_8859_15
, "View/Encoding/Western/"CS_ISO_8859_15
, GTK_UI_MANAGER_MENUITEM
)
555 MENUITEM_ADDUI_MANAGER(msgview
->ui_manager
, "/Menu/View/Encoding/Western", CS_WINDOWS_1252
, "View/Encoding/Western/"CS_WINDOWS_1252
, GTK_UI_MANAGER_MENUITEM
)
557 MENUITEM_ADDUI_MANAGER(msgview
->ui_manager
, "/Menu/View/Encoding", CS_ISO_8859_2
, "View/Encoding/"CS_ISO_8859_2
, GTK_UI_MANAGER_MENUITEM
)
559 MENUITEM_ADDUI_MANAGER(msgview
->ui_manager
, "/Menu/View/Encoding", "Baltic", "View/Encoding/Baltic", GTK_UI_MANAGER_MENU
)
560 MENUITEM_ADDUI_MANAGER(msgview
->ui_manager
, "/Menu/View/Encoding/Baltic", CS_ISO_8859_13
, "View/Encoding/Baltic/"CS_ISO_8859_13
, GTK_UI_MANAGER_MENUITEM
)
561 MENUITEM_ADDUI_MANAGER(msgview
->ui_manager
, "/Menu/View/Encoding/Baltic", CS_ISO_8859_4
, "View/Encoding/Baltic/"CS_ISO_8859_4
, GTK_UI_MANAGER_MENUITEM
)
563 MENUITEM_ADDUI_MANAGER(msgview
->ui_manager
, "/Menu/View/Encoding", CS_ISO_8859_7
, "View/Encoding/"CS_ISO_8859_7
, GTK_UI_MANAGER_MENUITEM
)
565 MENUITEM_ADDUI_MANAGER(msgview
->ui_manager
, "/Menu/View/Encoding", "Hebrew", "View/Encoding/Hebrew", GTK_UI_MANAGER_MENU
)
566 MENUITEM_ADDUI_MANAGER(msgview
->ui_manager
, "/Menu/View/Encoding/Hebrew", CS_ISO_8859_8
, "View/Encoding/Hebrew/"CS_ISO_8859_8
, GTK_UI_MANAGER_MENUITEM
)
567 MENUITEM_ADDUI_MANAGER(msgview
->ui_manager
, "/Menu/View/Encoding/Hebrew", CS_WINDOWS_1255
, "View/Encoding/Hebrew/"CS_WINDOWS_1255
, GTK_UI_MANAGER_MENUITEM
)
569 MENUITEM_ADDUI_MANAGER(msgview
->ui_manager
, "/Menu/View/Encoding", "Arabic", "View/Encoding/Arabic", GTK_UI_MANAGER_MENU
)
570 MENUITEM_ADDUI_MANAGER(msgview
->ui_manager
, "/Menu/View/Encoding/Arabic", CS_ISO_8859_6
, "View/Encoding/Arabic/"CS_ISO_8859_6
, GTK_UI_MANAGER_MENUITEM
)
571 MENUITEM_ADDUI_MANAGER(msgview
->ui_manager
, "/Menu/View/Encoding/Arabic", CS_WINDOWS_1256
, "View/Encoding/Arabic/"CS_WINDOWS_1256
, GTK_UI_MANAGER_MENUITEM
)
573 MENUITEM_ADDUI_MANAGER(msgview
->ui_manager
, "/Menu/View/Encoding", CS_ISO_8859_9
, "View/Encoding/"CS_ISO_8859_9
, GTK_UI_MANAGER_MENUITEM
)
575 MENUITEM_ADDUI_MANAGER(msgview
->ui_manager
, "/Menu/View/Encoding", "Cyrillic", "View/Encoding/Cyrillic", GTK_UI_MANAGER_MENU
)
576 MENUITEM_ADDUI_MANAGER(msgview
->ui_manager
, "/Menu/View/Encoding/Cyrillic", CS_ISO_8859_5
, "View/Encoding/Cyrillic/"CS_ISO_8859_5
, GTK_UI_MANAGER_MENUITEM
)
577 MENUITEM_ADDUI_MANAGER(msgview
->ui_manager
, "/Menu/View/Encoding/Cyrillic", CS_KOI8_R
, "View/Encoding/Cyrillic/"CS_KOI8_R
, GTK_UI_MANAGER_MENUITEM
)
578 MENUITEM_ADDUI_MANAGER(msgview
->ui_manager
, "/Menu/View/Encoding/Cyrillic", CS_MACCYR
, "View/Encoding/Cyrillic/"CS_MACCYR
, GTK_UI_MANAGER_MENUITEM
)
579 MENUITEM_ADDUI_MANAGER(msgview
->ui_manager
, "/Menu/View/Encoding/Cyrillic", CS_KOI8_U
, "View/Encoding/Cyrillic/"CS_KOI8_U
, GTK_UI_MANAGER_MENUITEM
)
580 MENUITEM_ADDUI_MANAGER(msgview
->ui_manager
, "/Menu/View/Encoding/Cyrillic", CS_WINDOWS_1251
, "View/Encoding/Cyrillic/"CS_WINDOWS_1251
, GTK_UI_MANAGER_MENUITEM
)
582 MENUITEM_ADDUI_MANAGER(msgview
->ui_manager
, "/Menu/View/Encoding", "Japanese", "View/Encoding/Japanese", GTK_UI_MANAGER_MENU
)
583 MENUITEM_ADDUI_MANAGER(msgview
->ui_manager
, "/Menu/View/Encoding/Japanese", CS_ISO_2022_JP
, "View/Encoding/Japanese/"CS_ISO_2022_JP
, GTK_UI_MANAGER_MENUITEM
)
584 MENUITEM_ADDUI_MANAGER(msgview
->ui_manager
, "/Menu/View/Encoding/Japanese", CS_ISO_2022_JP_2
, "View/Encoding/Japanese/"CS_ISO_2022_JP_2
, GTK_UI_MANAGER_MENUITEM
)
585 MENUITEM_ADDUI_MANAGER(msgview
->ui_manager
, "/Menu/View/Encoding/Japanese", CS_EUC_JP
, "View/Encoding/Japanese/"CS_EUC_JP
, GTK_UI_MANAGER_MENUITEM
)
586 MENUITEM_ADDUI_MANAGER(msgview
->ui_manager
, "/Menu/View/Encoding/Japanese", CS_SHIFT_JIS
, "View/Encoding/Japanese/"CS_SHIFT_JIS
, GTK_UI_MANAGER_MENUITEM
)
588 MENUITEM_ADDUI_MANAGER(msgview
->ui_manager
, "/Menu/View/Encoding", "Chinese", "View/Encoding/Chinese", GTK_UI_MANAGER_MENU
)
589 MENUITEM_ADDUI_MANAGER(msgview
->ui_manager
, "/Menu/View/Encoding/Chinese", CS_GB18030
, "View/Encoding/Chinese/"CS_GB18030
, GTK_UI_MANAGER_MENUITEM
)
590 MENUITEM_ADDUI_MANAGER(msgview
->ui_manager
, "/Menu/View/Encoding/Chinese", CS_GB2312
, "View/Encoding/Chinese/"CS_GB2312
, GTK_UI_MANAGER_MENUITEM
)
591 MENUITEM_ADDUI_MANAGER(msgview
->ui_manager
, "/Menu/View/Encoding/Chinese", CS_GBK
, "View/Encoding/Chinese/"CS_GBK
, GTK_UI_MANAGER_MENUITEM
)
592 MENUITEM_ADDUI_MANAGER(msgview
->ui_manager
, "/Menu/View/Encoding/Chinese", CS_BIG5
, "View/Encoding/Chinese/"CS_BIG5
, GTK_UI_MANAGER_MENUITEM
)
593 MENUITEM_ADDUI_MANAGER(msgview
->ui_manager
, "/Menu/View/Encoding/Chinese", CS_EUC_TW
, "View/Encoding/Chinese/"CS_EUC_TW
, GTK_UI_MANAGER_MENUITEM
)
595 MENUITEM_ADDUI_MANAGER(msgview
->ui_manager
, "/Menu/View/Encoding", "Korean", "View/Encoding/Korean", GTK_UI_MANAGER_MENU
)
596 MENUITEM_ADDUI_MANAGER(msgview
->ui_manager
, "/Menu/View/Encoding/Korean", CS_EUC_KR
, "View/Encoding/Korean/"CS_EUC_KR
, GTK_UI_MANAGER_MENUITEM
)
597 MENUITEM_ADDUI_MANAGER(msgview
->ui_manager
, "/Menu/View/Encoding/Korean", CS_ISO_2022_KR
, "View/Encoding/Korean/"CS_ISO_2022_KR
, GTK_UI_MANAGER_MENUITEM
)
599 MENUITEM_ADDUI_MANAGER(msgview
->ui_manager
, "/Menu/View/Encoding", "Thai", "View/Encoding/Thai", GTK_UI_MANAGER_MENU
)
600 MENUITEM_ADDUI_MANAGER(msgview
->ui_manager
, "/Menu/View/Encoding/Thai", CS_TIS_620
, "View/Encoding/Thai/"CS_TIS_620
, GTK_UI_MANAGER_MENUITEM
)
601 MENUITEM_ADDUI_MANAGER(msgview
->ui_manager
, "/Menu/View/Encoding/Thai", CS_WINDOWS_874
, "View/Encoding/Thai/"CS_WINDOWS_874
, GTK_UI_MANAGER_MENUITEM
)
603 MENUITEM_ADDUI_MANAGER(msgview
->ui_manager
, "/Menu/View", "Decode", "View/Decode", GTK_UI_MANAGER_MENU
)
604 MENUITEM_ADDUI_MANAGER(msgview
->ui_manager
, "/Menu/View/Decode", "AutoDetect", "View/Decode/AutoDetect", GTK_UI_MANAGER_MENUITEM
)
605 MENUITEM_ADDUI_MANAGER(msgview
->ui_manager
, "/Menu/View/Decode", "Separator1", "View/Decode/---", GTK_UI_MANAGER_SEPARATOR
)
606 MENUITEM_ADDUI_MANAGER(msgview
->ui_manager
, "/Menu/View/Decode", "8bit", "View/Decode/8bit", GTK_UI_MANAGER_MENUITEM
)
607 MENUITEM_ADDUI_MANAGER(msgview
->ui_manager
, "/Menu/View/Decode", "QP", "View/Decode/QP", GTK_UI_MANAGER_MENUITEM
)
608 MENUITEM_ADDUI_MANAGER(msgview
->ui_manager
, "/Menu/View/Decode", "B64", "View/Decode/B64", GTK_UI_MANAGER_MENUITEM
)
609 MENUITEM_ADDUI_MANAGER(msgview
->ui_manager
, "/Menu/View/Decode", "Uuencode", "View/Decode/Uuencode", GTK_UI_MANAGER_MENUITEM
)
611 MENUITEM_ADDUI_MANAGER(msgview
->ui_manager
, "/Menu/View", "Separator2", "View/---", GTK_UI_MANAGER_SEPARATOR
)
613 MENUITEM_ADDUI_MANAGER(msgview
->ui_manager
, "/Menu/View", "MessageSource", "View/MessageSource", GTK_UI_MANAGER_MENUITEM
)
614 MENUITEM_ADDUI_MANAGER(msgview
->ui_manager
, "/Menu/View", "AllHeaders", "View/AllHeaders", GTK_UI_MANAGER_MENUITEM
)
615 MENUITEM_ADDUI_MANAGER(msgview
->ui_manager
, "/Menu/View", "Quotes", "View/Quotes", GTK_UI_MANAGER_MENU
)
616 MENUITEM_ADDUI_MANAGER(msgview
->ui_manager
, "/Menu/View/Quotes", "CollapseAll", "View/Quotes/CollapseAll", GTK_UI_MANAGER_MENUITEM
)
617 MENUITEM_ADDUI_MANAGER(msgview
->ui_manager
, "/Menu/View/Quotes", "Collapse2", "View/Quotes/Collapse2", GTK_UI_MANAGER_MENUITEM
)
618 MENUITEM_ADDUI_MANAGER(msgview
->ui_manager
, "/Menu/View/Quotes", "Collapse3", "View/Quotes/Collapse3", GTK_UI_MANAGER_MENUITEM
)
619 MENUITEM_ADDUI_MANAGER(msgview
->ui_manager
, "/Menu/View", "Part", "View/Part", GTK_UI_MANAGER_MENU
)
620 MENUITEM_ADDUI_MANAGER(msgview
->ui_manager
, "/Menu/View/Part", "AsText", "View/Part/AsText", GTK_UI_MANAGER_MENUITEM
)
621 MENUITEM_ADDUI_MANAGER(msgview
->ui_manager
, "/Menu/View/Part", "Open", "View/Part/Open", GTK_UI_MANAGER_MENUITEM
)
623 MENUITEM_ADDUI_MANAGER(msgview
->ui_manager
, "/Menu/View/Part", "OpenWith", "View/Part/OpenWith", GTK_UI_MANAGER_MENUITEM
)
627 MENUITEM_ADDUI_MANAGER(msgview
->ui_manager
, "/Menu/Message", "Compose", "Message/Compose", GTK_UI_MANAGER_MENUITEM
)
628 MENUITEM_ADDUI_MANAGER(msgview
->ui_manager
, "/Menu/Message", "Separator1", "Message/---", GTK_UI_MANAGER_SEPARATOR
)
629 MENUITEM_ADDUI_MANAGER(msgview
->ui_manager
, "/Menu/Message", "Reply", "Message/Reply", GTK_UI_MANAGER_MENUITEM
)
630 MENUITEM_ADDUI_MANAGER(msgview
->ui_manager
, "/Menu/Message", "ReplyTo", "Message/ReplyTo", GTK_UI_MANAGER_MENU
)
631 MENUITEM_ADDUI_MANAGER(msgview
->ui_manager
, "/Menu/Message/ReplyTo", "All", "Message/ReplyTo/All", GTK_UI_MANAGER_MENUITEM
)
632 MENUITEM_ADDUI_MANAGER(msgview
->ui_manager
, "/Menu/Message/ReplyTo", "Sender", "Message/ReplyTo/Sender", GTK_UI_MANAGER_MENUITEM
)
633 MENUITEM_ADDUI_MANAGER(msgview
->ui_manager
, "/Menu/Message/ReplyTo", "List", "Message/ReplyTo/List", GTK_UI_MANAGER_MENUITEM
)
634 MENUITEM_ADDUI_MANAGER(msgview
->ui_manager
, "/Menu/Message", "Separator2", "Message/---", GTK_UI_MANAGER_SEPARATOR
)
635 MENUITEM_ADDUI_MANAGER(msgview
->ui_manager
, "/Menu/Message", "Forward", "Message/Forward", GTK_UI_MANAGER_MENUITEM
)
636 MENUITEM_ADDUI_MANAGER(msgview
->ui_manager
, "/Menu/Message", "ForwardAtt", "Message/ForwardAtt", GTK_UI_MANAGER_MENUITEM
)
637 MENUITEM_ADDUI_MANAGER(msgview
->ui_manager
, "/Menu/Message", "Redirect", "Message/Redirect", GTK_UI_MANAGER_MENUITEM
)
638 MENUITEM_ADDUI_MANAGER(msgview
->ui_manager
, "/Menu/Message", "CheckSignature", "Message/CheckSignature", GTK_UI_MANAGER_MENUITEM
)
641 MENUITEM_ADDUI_MANAGER(msgview
->ui_manager
, "/Menu/Tools", "AddressBook", "Tools/AddressBook", GTK_UI_MANAGER_MENUITEM
)
642 MENUITEM_ADDUI_MANAGER(msgview
->ui_manager
, "/Menu/Tools", "AddSenderToAB", "Tools/AddSenderToAB", GTK_UI_MANAGER_MENUITEM
)
643 MENUITEM_ADDUI_MANAGER(msgview
->ui_manager
, "/Menu/Tools", "Separator1", "Tools/---", GTK_UI_MANAGER_SEPARATOR
)
645 MENUITEM_ADDUI_MANAGER(msgview
->ui_manager
, "/Menu/Tools", "CreateFilterRule", "Tools/CreateFilterRule", GTK_UI_MANAGER_MENU
)
646 MENUITEM_ADDUI_MANAGER(msgview
->ui_manager
, "/Menu/Tools/CreateFilterRule", "Automatically", "Tools/CreateFilterRule/Automatically", GTK_UI_MANAGER_MENUITEM
)
647 MENUITEM_ADDUI_MANAGER(msgview
->ui_manager
, "/Menu/Tools/CreateFilterRule", "ByFrom", "Tools/CreateFilterRule/ByFrom", GTK_UI_MANAGER_MENUITEM
)
648 MENUITEM_ADDUI_MANAGER(msgview
->ui_manager
, "/Menu/Tools/CreateFilterRule", "ByTo", "Tools/CreateFilterRule/ByTo", GTK_UI_MANAGER_MENUITEM
)
649 MENUITEM_ADDUI_MANAGER(msgview
->ui_manager
, "/Menu/Tools/CreateFilterRule", "BySubject", "Tools/CreateFilterRule/BySubject", GTK_UI_MANAGER_MENUITEM
)
651 MENUITEM_ADDUI_MANAGER(msgview
->ui_manager
, "/Menu/Tools", "CreateProcessingRule", "Tools/CreateProcessingRule", GTK_UI_MANAGER_MENU
)
652 MENUITEM_ADDUI_MANAGER(msgview
->ui_manager
, "/Menu/Tools/CreateProcessingRule", "Automatically", "Tools/CreateProcessingRule/Automatically", GTK_UI_MANAGER_MENUITEM
)
653 MENUITEM_ADDUI_MANAGER(msgview
->ui_manager
, "/Menu/Tools/CreateProcessingRule", "ByFrom", "Tools/CreateProcessingRule/ByFrom", GTK_UI_MANAGER_MENUITEM
)
654 MENUITEM_ADDUI_MANAGER(msgview
->ui_manager
, "/Menu/Tools/CreateProcessingRule", "ByTo", "Tools/CreateProcessingRule/ByTo", GTK_UI_MANAGER_MENUITEM
)
655 MENUITEM_ADDUI_MANAGER(msgview
->ui_manager
, "/Menu/Tools/CreateProcessingRule", "BySubject", "Tools/CreateProcessingRule/BySubject", GTK_UI_MANAGER_MENUITEM
)
656 MENUITEM_ADDUI_MANAGER(msgview
->ui_manager
, "/Menu/Tools", "Separator2", "Tools/---", GTK_UI_MANAGER_SEPARATOR
)
658 MENUITEM_ADDUI_MANAGER(msgview
->ui_manager
, "/Menu/Tools", "ListUrls", "Tools/ListUrls", GTK_UI_MANAGER_MENUITEM
)
659 MENUITEM_ADDUI_MANAGER(msgview
->ui_manager
, "/Menu/Tools", "Separator3", "Tools/---", GTK_UI_MANAGER_SEPARATOR
)
661 MENUITEM_ADDUI_MANAGER(msgview
->ui_manager
, "/Menu/Tools", "Actions", "Tools/Actions", GTK_UI_MANAGER_MENU
)
662 MENUITEM_ADDUI_MANAGER(msgview
->ui_manager
, "/Menu/Tools/Actions", "PlaceHolder", "Tools/Actions/PlaceHolder", GTK_UI_MANAGER_MENUITEM
)
665 MENUITEM_ADDUI_MANAGER(msgview
->ui_manager
, "/Menu/Help", "About", "Help/About", GTK_UI_MANAGER_MENUITEM
)
667 menubar
= gtk_ui_manager_get_widget(msgview
->ui_manager
, "/Menu");
668 gtk_widget_show_all(menubar
);
669 gtk_window_add_accel_group(GTK_WINDOW(window
), gtk_ui_manager_get_accel_group(msgview
->ui_manager
));
671 gtk_box_pack_start(GTK_BOX(vbox
), menubar
, FALSE
, TRUE
, 0);
673 cm_toggle_menu_set_active_full(msgview
->ui_manager
, "Menu/View/AllHeaders",
674 prefs_common
.show_all_headers
);
676 handlebox
= gtk_box_new(GTK_ORIENTATION_HORIZONTAL
, 0);
677 gtk_box_pack_start(GTK_BOX(vbox
), handlebox
, FALSE
, FALSE
, 0);
678 gtk_widget_realize(handlebox
);
679 msgview
->toolbar
= toolbar_create(TOOLBAR_MSGVIEW
, handlebox
,
682 statusbar
= gtk_statusbar_new();
683 gtk_widget_show(statusbar
);
684 gtk_box_pack_end(GTK_BOX(vbox
), statusbar
, FALSE
, FALSE
, 0);
685 msgview
->statusbar
= statusbar
;
686 msgview
->statusbar_cid
= gtk_statusbar_get_context_id
687 (GTK_STATUSBAR(statusbar
), "Message View");
689 msgview
->statusbar
= NULL
;
690 msgview
->statusbar_cid
= 0;
694 msgview
->handlebox
= handlebox
;
695 msgview
->menubar
= menubar
;
697 gtk_container_add(GTK_CONTAINER(vbox
),
698 GTK_WIDGET_PTR(msgview
));
700 messageview_update_actions_menu(msgview
);
702 msgview_list
= g_list_append(msgview_list
, msgview
);
705 static MessageView
*messageview_create_with_new_window_visible(MainWindow
*mainwin
, gboolean show
)
707 MessageView
*msgview
;
709 static GdkGeometry geometry
;
711 window
= gtkut_window_new(GTK_WINDOW_TOPLEVEL
, "messageview");
712 gtk_window_set_title(GTK_WINDOW(window
), _("Claws Mail - Message View"));
713 gtk_window_set_resizable(GTK_WINDOW(window
), TRUE
);
715 gtk_window_set_default_size(GTK_WINDOW(window
), prefs_common
.msgwin_width
,
716 prefs_common
.msgwin_height
);
718 if (!geometry
.min_height
) {
719 geometry
.min_width
= 320;
720 geometry
.min_height
= 200;
722 gtk_window_set_geometry_hints(GTK_WINDOW(window
), NULL
, &geometry
,
726 gtk_window_move(GTK_WINDOW(window
), 48, 48);
729 msgview
= messageview_create(mainwin
);
731 g_signal_connect(G_OBJECT(window
), "size_allocate",
732 G_CALLBACK(messageview_size_allocate_cb
),
734 g_signal_connect(G_OBJECT(window
), "delete_event",
735 G_CALLBACK(messageview_delete_cb
), msgview
);
736 g_signal_connect(G_OBJECT(window
), "key_press_event",
737 G_CALLBACK(key_pressed
), msgview
);
738 messageview_add_toolbar(msgview
, window
);
741 gtk_widget_show(window
);
743 gtk_widget_realize(window
);
746 msgview
->new_window
= TRUE
;
747 msgview
->window
= window
;
748 msgview
->visible
= TRUE
;
750 toolbar_set_style(msgview
->toolbar
->toolbar
, msgview
->handlebox
,
751 prefs_common
.toolbar_style
);
752 messageview_init(msgview
);
756 gtk_widget_grab_focus(msgview
->mimeview
->textview
->text
);
762 MessageView
*messageview_create_with_new_window(MainWindow
*mainwin
)
764 return messageview_create_with_new_window_visible(mainwin
, TRUE
);
766 void messageview_init(MessageView
*messageview
)
768 headerview_init(messageview
->headerview
);
769 mimeview_init(messageview
->mimeview
);
770 /*messageview_set_font(messageview);*/
772 noticeview_hide(messageview
->noticeview
);
775 static void notification_convert_header(gchar
**dest
,
781 cm_return_if_fail(src_
!= NULL
);
783 if (header_len
< 1) {
784 *dest
= g_strdup("");
788 Xstrndup_a(src
, src_
, strlen(src_
), return);
792 if (is_ascii_str(src
)) {
793 *dest
= g_strdup(src
);
796 *dest
= g_malloc(BUFFSIZE
);
797 conv_encode_header(*dest
, BUFFSIZE
, src
, header_len
, FALSE
);
801 static gint
disposition_notification_send(MsgInfo
*msginfo
)
804 gchar tmp
[MAXPATHLEN
+ 1];
807 PrefsAccount
*account
= NULL
;
810 FolderItem
*queue
, *outbox
;
816 gboolean queued_removed
= FALSE
;
817 gchar
*boundary
= NULL
;
818 gchar buf_date
[RFC822_DATE_BUFFSIZE
];
820 gchar
*orig_to
= NULL
;
821 gchar
*enc_sub
= NULL
;
823 if (!msginfo
->extradata
)
825 if (!msginfo
->extradata
->returnreceiptto
&&
826 !msginfo
->extradata
->dispositionnotificationto
)
829 /* RFC2298: Test for Return-Path */
830 if (msginfo
->extradata
->dispositionnotificationto
)
831 to
= msginfo
->extradata
->dispositionnotificationto
;
833 to
= msginfo
->extradata
->returnreceiptto
;
835 ok
= procheader_get_header_from_msginfo(msginfo
, &buf
, "Return-Path:");
837 gchar
*to_addr
= g_strdup(to
);
838 extract_address(to_addr
);
839 extract_address(buf
);
840 ok
= strcasecmp(to_addr
, buf
);
843 buf
= g_strdup(_("<No Return-Path found>"));
849 message
= g_markup_printf_escaped(
850 _("The notification address to which the return receipt is\n"
851 "to be sent does not correspond to the return path:\n"
852 "Notification address: %s\n"
854 "It is advised to not send the return receipt."),
856 val
= alertpanel_full(_("Warning"), message
,
857 _("_Don't Send"), _("_Send"), NULL
, ALERTFOCUS_FIRST
, FALSE
,
858 NULL
, ALERT_WARNING
);
860 if (val
!= G_ALERTALTERNATE
) {
868 ac_list
= account_find_all_from_address(NULL
, msginfo
->to
);
869 ac_list
= account_find_all_from_address(ac_list
, msginfo
->cc
);
871 if (ac_list
== NULL
) {
872 ac_list
= account_find_all();
873 if ((account
= select_account_from_list(ac_list
, FALSE
)) == NULL
)
875 } else if (g_list_length(ac_list
) > 1) {
876 if ((account
= select_account_from_list(ac_list
, TRUE
)) == NULL
)
878 } else if (ac_list
!= NULL
)
879 account
= (PrefsAccount
*) ac_list
->data
;
880 g_list_free(ac_list
);
883 account
= account_get_default();
884 if (!account
|| account
->protocol
== A_NNTP
) {
885 alertpanel_error(_("Account for sending mail is not specified.\n"
886 "Please select a mail account before sending."));
890 /* write to temporary file */
891 g_snprintf(tmp
, sizeof(tmp
), "%s%ctmpmsg%p",
892 get_rc_dir(), G_DIR_SEPARATOR
, msginfo
);
894 if ((fp
= claws_fopen(tmp
, "wb")) == NULL
) {
895 FILE_OP_ERROR(tmp
, "claws_fopen");
899 /* chmod for security */
900 if (change_file_mode_rw(fp
, tmp
) < 0) {
901 FILE_OP_ERROR(tmp
, "chmod");
902 g_warning("can't change file mode");
907 extract_address(addr
);
910 /* write queue headers */
911 ok
= fprintf(fp
, "AF:\n"
926 account
->smtp_server
?account
->smtp_server
:"",
933 /* check whether we need to save the message */
934 outbox
= account_get_special_folder(account
, F_OUTBOX
);
935 if (folder_get_default_outbox() == outbox
&& !prefs_common
.savemsg
)
938 path
= folder_item_get_identifier(outbox
);
939 ok
= fprintf(fp
, "SCF:%s\n", path
);
946 if (fprintf(fp
, "X-Claws-End-Special-Headers: 1\n") < 0)
950 get_rfc822_date(buf_date
, sizeof(buf_date
));
951 if (fprintf(fp
, "Date: %s\n", buf_date
) < 0)
955 if (account
->name
&& *account
->name
) {
956 notification_convert_header(&buf
, account
->name
, strlen("From: "));
959 if (fprintf(fp
, "From: %s <%s>\n", buf
, account
->address
) < 0) {
968 if (fprintf(fp
, "To: %s\n", to
) < 0)
972 notification_convert_header(&buf
, msginfo
->subject
, strlen("Subject: "));
975 if (fprintf(fp
, "Subject: Disposition notification: %s\n", buf
) < 0) {
983 if (account
->gen_msgid
) {
984 gchar
*addr
= prefs_account_generate_msgid(account
);
985 if (fprintf(fp
, "Message-ID: <%s>\n", addr
) < 0) {
992 boundary
= generate_mime_boundary("DN");
993 date
= g_strdup(buf_date
);
995 orig_to
= g_strdup(msginfo
->to
);
996 extract_address(orig_to
);
998 if (msginfo
->subject
&& *(msginfo
->subject
)) {
999 enc_sub
= g_malloc0(strlen(msginfo
->subject
)*8);
1000 qp_encode_line(enc_sub
, (const guchar
*)msginfo
->subject
);
1001 g_strstrip(enc_sub
);
1003 ok
= fprintf(fp
,"MIME-Version: 1.0\n"
1004 "Content-Type: multipart/report; report-type=disposition-notification;\n"
1005 " boundary=\"%s\"\n"
1008 "Content-Type: text/plain; charset=UTF-8\n"
1009 "Content-Transfer-Encoding: quoted-printable\n"
1011 "The message sent on: %s\n"
1013 "With subject: \"%s\"\n"
1014 "has been displayed at %s.\n"
1016 "There is no guarantee that the message has been read or understood.\n"
1019 "Content-Type: message/disposition-notification\n"
1021 "Reporting-UA: %s\n"
1022 "Original-Recipient: rfc822;%s\n"
1023 "Final-Recipient: rfc822;%s\n"
1024 "Original-Message-ID: <%s>\n"
1025 "Disposition: manual-action/MDN-sent-manually; displayed\n"
1028 "Content-Type: application/octet-stream\n"
1030 "Reporting-UA: %s\n"
1031 "Original-Recipient: rfc822;%s\n"
1032 "Final-Recipient: rfc822;%s\n"
1033 "Original-Message-ID: <%s>\n"
1034 "Disposition: manual-action/MDN-sent-manually; displayed\n"
1040 orig_to
?orig_to
:"No To:",
1041 enc_sub
?enc_sub
:"No subject",
1045 orig_to
?orig_to
:"No To:",
1047 msginfo
->msgid
?msginfo
->msgid
:"NO MESSAGE ID",
1050 orig_to
?orig_to
:"No To:",
1052 msginfo
->msgid
?msginfo
->msgid
:"NO MESSAGE ID",
1063 if (claws_safe_fclose(fp
) == EOF
) {
1064 FILE_OP_ERROR(tmp
, "claws_fclose");
1069 /* put it in queue */
1070 queue
= account_get_special_folder(account
, F_QUEUE
);
1071 if (!queue
) queue
= folder_get_default_queue();
1073 g_warning("can't find queue folder");
1077 folder_item_scan(queue
);
1078 if ((num
= folder_item_add_msg(queue
, tmp
, NULL
, TRUE
)) < 0) {
1079 g_warning("can't queue the message");
1084 if (prefs_common
.work_offline
&&
1085 !inc_offline_should_override(TRUE
,
1086 _("Claws Mail needs network access in order "
1087 "to send this email.")))
1091 path
= folder_item_fetch_msg(queue
, num
);
1092 ok
= procmsg_send_message_queue_with_lock(path
, &foo
, queue
, num
, &queued_removed
);
1095 if (ok
== 0 && !queued_removed
)
1096 folder_item_remove_msg(queue
, num
);
1106 static gboolean
find_encrypted_func(GNode
*node
, gpointer data
)
1108 MimeInfo
*mimeinfo
= (MimeInfo
*) node
->data
;
1109 MimeInfo
**encinfo
= (MimeInfo
**) data
;
1111 if (privacy_mimeinfo_is_encrypted(mimeinfo
)) {
1112 *encinfo
= mimeinfo
;
1119 static MimeInfo
*find_encrypted_part(MimeInfo
*rootinfo
)
1121 MimeInfo
*encinfo
= NULL
;
1123 g_node_traverse(rootinfo
->node
, G_IN_ORDER
, G_TRAVERSE_ALL
, -1,
1124 find_encrypted_func
, &encinfo
);
1129 static gboolean
find_broken_func(GNode
*node
, gpointer data
)
1131 MimeInfo
*mimeinfo
= (MimeInfo
*) node
->data
;
1132 MimeInfo
**brokeninfo
= (MimeInfo
**) data
;
1134 if (mimeinfo
->broken
) {
1135 *brokeninfo
= mimeinfo
;
1142 static MimeInfo
*find_broken_part(MimeInfo
*rootinfo
)
1144 MimeInfo
*brokeninfo
= NULL
;
1146 g_node_traverse(rootinfo
->node
, G_IN_ORDER
, G_TRAVERSE_ALL
, -1,
1147 find_broken_func
, &brokeninfo
);
1152 static void messageview_register_nav(MessageView
*messageview
)
1158 cm_return_if_fail(messageview
);
1159 cm_return_if_fail(messageview
->msginfo
);
1161 id
= procmsg_msginfo_get_identifier(messageview
->msginfo
);
1162 existing
= g_list_find_custom(messageview
->trail
, id
, (GCompareFunc
)g_strcmp0
);
1164 if (existing
!= NULL
)
1165 pos
= g_list_position(messageview
->trail
, existing
);
1170 messageview
->trail_pos
= pos
;
1173 /* Cut the end of the list */
1174 GList
*end
= g_list_nth(messageview
->trail
, messageview
->trail_pos
+ 1);
1177 end
->prev
->next
= NULL
;
1179 list_free_strings_full(end
);
1181 list_free_strings_full(messageview
->trail
);
1182 messageview
->trail
= NULL
;
1185 messageview
->trail
= g_list_append(messageview
->trail
, id
);
1186 messageview
->trail_pos
= (gint
)g_list_length(messageview
->trail
) - 1;
1188 /* Cut the beginning if needed */
1189 while (messageview
->trail_pos
> prefs_common
.nav_history_length
) {
1190 g_free(messageview
->trail
->data
);
1191 messageview
->trail
= g_list_delete_link(messageview
->trail
,
1192 messageview
->trail
);
1193 messageview
->trail_pos
--;
1196 messageview_set_menu_sensitive(messageview
);
1199 gboolean
messageview_nav_has_prev(MessageView
*messageview
) {
1200 return messageview
!= NULL
&& messageview
->trail
!= NULL
1201 && messageview
->trail_pos
> 0;
1204 gboolean
messageview_nav_has_next(MessageView
*messageview
) {
1205 if (!messageview
|| !messageview
->trail
)
1208 return sc_g_list_bigger(messageview
->trail
, messageview
->trail_pos
+ 1);
1211 MsgInfo
*messageview_nav_get_prev(MessageView
*messageview
) {
1215 cm_return_val_if_fail(messageview
, NULL
);
1216 cm_return_val_if_fail(messageview
->trail
, NULL
);
1219 if (!messageview_nav_has_prev(messageview
))
1222 item
= g_list_nth(messageview
->trail
, messageview
->trail_pos
- 1);
1223 cm_return_val_if_fail(item
!= NULL
, NULL
);
1225 info
= procmsg_get_msginfo_from_identifier((const gchar
*)item
->data
);
1230 messageview
->trail
= g_list_delete_link(messageview
->trail
, item
);
1231 if (messageview
->trail_pos
> 0)
1232 messageview
->trail_pos
--;
1233 } while (info
== NULL
);
1238 MsgInfo
*messageview_nav_get_next(MessageView
*messageview
) {
1242 cm_return_val_if_fail(messageview
, NULL
);
1243 cm_return_val_if_fail(messageview
->trail
, NULL
);
1246 if (!messageview_nav_has_next(messageview
))
1249 item
= g_list_nth(messageview
->trail
, messageview
->trail_pos
+ 1);
1250 cm_return_val_if_fail(item
!= NULL
, NULL
);
1252 info
= procmsg_get_msginfo_from_identifier((const gchar
*)item
->data
);
1257 messageview
->trail
= g_list_delete_link(messageview
->trail
, item
);
1258 } while (info
== NULL
);
1263 static gboolean
messageview_try_select_mimeinfo(MessageView
*messageview
, MsgInfo
*msginfo
, MimeInfo
*mimeinfo
)
1265 if (mimeinfo
->type
== MIMETYPE_TEXT
) {
1266 if (!strcasecmp(mimeinfo
->subtype
, "calendar")
1267 && mimeview_has_viewer_for_content_type(messageview
->mimeview
, "text/calendar")) {
1268 mimeview_select_mimepart_icon(messageview
->mimeview
, mimeinfo
);
1270 } else if (!strcasecmp(mimeinfo
->subtype
, "html")
1271 && mimeinfo
->disposition
!= DISPOSITIONTYPE_ATTACHMENT
1272 && ((msginfo
->folder
&& msginfo
->folder
->prefs
->promote_html_part
== HTML_PROMOTE_ALWAYS
)
1273 || ((msginfo
->folder
&& msginfo
->folder
->prefs
->promote_html_part
== HTML_PROMOTE_DEFAULT
)
1274 && prefs_common
.promote_html_part
))) {
1275 mimeview_select_mimepart_icon(messageview
->mimeview
, mimeinfo
);
1282 static void messageview_find_part_depth_first(MimeInfoSearch
*context
, MimeMediaType type
, const gchar
*subtype
)
1284 MimeInfo
* mimeinfo
= context
->current
;
1289 debug_print("found part %d/%s\n", mimeinfo
->type
, mimeinfo
->subtype
);
1291 if (mimeinfo
->type
== type
1292 && !strcasecmp(mimeinfo
->subtype
, subtype
)) {
1293 context
->found
= mimeinfo
;
1294 } else if (mimeinfo
->type
== MIMETYPE_MULTIPART
) {
1295 if (!strcasecmp(mimeinfo
->subtype
, "alternative")
1296 || !strcasecmp(mimeinfo
->subtype
, "related")) {
1297 context
->found
= procmime_mimeinfo_next(mimeinfo
);
1298 while (context
->found
&& context
->found
!= context
->parent
) {
1299 if (context
->found
->type
== type
1300 && !strcasecmp(context
->found
->subtype
, subtype
))
1302 context
->found
= procmime_mimeinfo_next(context
->found
);
1304 if (context
->found
== context
->parent
)
1305 context
->found
= NULL
;
1308 && (!strcasecmp(mimeinfo
->subtype
, "related")
1309 || !strcasecmp(mimeinfo
->subtype
, "mixed"))) {
1310 context
->parent
= mimeinfo
;
1311 context
->current
= procmime_mimeinfo_next(mimeinfo
);
1312 messageview_find_part_depth_first(context
, type
, subtype
);
1317 gint
messageview_show(MessageView
*messageview
, MsgInfo
*msginfo
,
1318 gboolean all_headers
)
1322 MimeInfo
*mimeinfo
, *encinfo
, *root
;
1323 gchar
*subject
= NULL
;
1324 cm_return_val_if_fail(msginfo
!= NULL
, -1);
1326 if (msginfo
!= messageview
->msginfo
)
1327 messageview
->show_full_text
= FALSE
;
1329 if (messageview
->mimeview
->textview
&&
1330 messageview
->mimeview
->textview
->loading
) {
1331 messageview
->mimeview
->textview
->stop_loading
= TRUE
;
1335 if (messageview
->toolbar
)
1336 toolbar_set_learn_button
1337 (messageview
->toolbar
,
1338 MSG_IS_SPAM(msginfo
->flags
)?LEARN_HAM
:LEARN_SPAM
);
1340 toolbar_set_learn_button
1341 (messageview
->mainwin
->toolbar
,
1342 MSG_IS_SPAM(msginfo
->flags
)?LEARN_HAM
:LEARN_SPAM
);
1344 if (messageview
->toolbar
) {
1345 if (messageview
->toolbar
->learn_spam_btn
) {
1346 gboolean can_learn
= FALSE
;
1347 if (procmsg_spam_can_learn() &&
1349 msginfo
->folder
->folder
->klass
->type
!= F_UNKNOWN
&&
1350 msginfo
->folder
->folder
->klass
->type
!= F_NEWS
))
1353 gtk_widget_set_sensitive(
1354 messageview
->toolbar
->learn_spam_btn
,
1359 noticeview_hide(messageview
->noticeview
);
1360 mimeview_clear(messageview
->mimeview
);
1361 messageview
->updating
= TRUE
;
1363 if (msginfo
->size
> 1024*1024)
1364 statusbar_print_all(_("Fetching message (%s)..."),
1365 to_human_readable(msginfo
->size
));
1367 file
= procmsg_get_message_file_path(msginfo
);
1369 if (msginfo
->size
> 1024*1024)
1370 statusbar_pop_all();
1373 g_warning("can't get message file path.");
1374 textview_show_error(messageview
->mimeview
->textview
);
1378 if (!folder_has_parent_of_type(msginfo
->folder
, F_QUEUE
) &&
1379 !folder_has_parent_of_type(msginfo
->folder
, F_DRAFT
))
1380 mimeinfo
= procmime_scan_file(file
);
1382 mimeinfo
= procmime_scan_queue_file(file
);
1384 messageview
->updating
= FALSE
;
1386 if (messageview
->deferred_destroy
) {
1388 messageview_destroy(messageview
);
1393 textview_show_error(messageview
->mimeview
->textview
);
1397 while ((encinfo
= find_encrypted_part(mimeinfo
)) != NULL
) {
1398 debug_print("decrypting message part\n");
1399 if (privacy_mimeinfo_decrypt(encinfo
) < 0) {
1400 text
= g_strdup_printf(_("Couldn't decrypt: %s"),
1401 privacy_get_error());
1402 noticeview_show(messageview
->noticeview
);
1403 noticeview_set_icon(messageview
->noticeview
,
1404 STOCK_PIXMAP_NOTICE_WARN
);
1405 noticeview_set_text(messageview
->noticeview
, text
);
1406 gtk_widget_hide(messageview
->noticeview
->button
);
1407 gtk_widget_hide(messageview
->noticeview
->button2
);
1413 if (messageview
->msginfo
!= msginfo
) {
1414 procmsg_msginfo_free(&(messageview
->msginfo
));
1415 messageview
->msginfo
= NULL
;
1416 messageview_set_menu_sensitive(messageview
);
1417 messageview
->msginfo
=
1418 procmsg_msginfo_get_full_info_from_file(msginfo
, file
);
1419 if (!messageview
->msginfo
)
1420 messageview
->msginfo
= procmsg_msginfo_copy(msginfo
);
1422 messageview
->msginfo
= NULL
;
1423 messageview_set_menu_sensitive(messageview
);
1424 messageview
->msginfo
= msginfo
;
1426 if (prefs_common
.display_header_pane
)
1427 headerview_show(messageview
->headerview
, messageview
->msginfo
);
1429 messageview_register_nav(messageview
);
1430 messageview_set_position(messageview
, 0);
1432 if (messageview
->window
) {
1433 gtk_window_set_title(GTK_WINDOW(messageview
->window
),
1434 _("Claws Mail - Message View"));
1437 mimeview_show_message(messageview
->mimeview
, mimeinfo
, file
);
1439 #ifndef GENERIC_UMPC
1440 messageview_set_position(messageview
, 0);
1443 if (messageview
->window
&& msginfo
->subject
) {
1444 subject
= g_strdup(msginfo
->subject
);
1445 if (!g_utf8_validate(subject
, -1, NULL
)) {
1447 subject
= g_malloc(strlen(msginfo
->subject
)*2 +1);
1448 conv_localetodisp(subject
, strlen(msginfo
->subject
)*2 +1,
1451 if (g_utf8_validate(subject
, -1, NULL
))
1452 gtk_window_set_title(GTK_WINDOW(messageview
->window
),
1457 if (msginfo
->folder
) {
1458 msginfo
->folder
->last_seen
= msginfo
->msgnum
;
1461 main_create_mailing_list_menu(messageview
->mainwin
, messageview
->msginfo
);
1463 if (messageview
->msginfo
&& messageview
->msginfo
->extradata
1464 && messageview
->msginfo
->extradata
->partial_recv
1465 && !noticeview_is_visible(messageview
->noticeview
))
1466 partial_recv_show(messageview
->noticeview
,
1467 messageview
->msginfo
);
1468 else if (messageview
->msginfo
&& messageview
->msginfo
->extradata
&&
1469 (messageview
->msginfo
->extradata
->dispositionnotificationto
||
1470 messageview
->msginfo
->extradata
->returnreceiptto
) &&
1471 !MSG_IS_RETRCPT_SENT(messageview
->msginfo
->flags
) &&
1472 !prefs_common
.never_send_retrcpt
&&
1473 !noticeview_is_visible(messageview
->noticeview
))
1474 return_receipt_show(messageview
->noticeview
,
1475 messageview
->msginfo
);
1477 if (find_broken_part(mimeinfo
) != NULL
) {
1478 noticeview_set_icon(messageview
->noticeview
,
1479 STOCK_PIXMAP_NOTICE_WARN
);
1480 if (!noticeview_is_visible(messageview
->noticeview
)) {
1481 noticeview_set_text(messageview
->noticeview
, _("Message doesn't conform to MIME standard. "
1482 "It may render wrongly."));
1483 gtk_widget_hide(messageview
->noticeview
->button
);
1484 gtk_widget_hide(messageview
->noticeview
->button2
);
1486 gchar
*full
= g_strconcat(
1487 gtk_label_get_text(GTK_LABEL(messageview
->noticeview
->text
)),
1489 _("Message doesn't conform to MIME standard. "
1490 "It may render wrongly."), NULL
);
1491 noticeview_set_text(messageview
->noticeview
, full
);
1494 noticeview_show(messageview
->noticeview
);
1498 mimeinfo
= procmime_mimeinfo_next(mimeinfo
);
1499 if (!all_headers
&& mimeinfo
1500 && (mimeinfo
->type
!= MIMETYPE_TEXT
1501 || strcasecmp(mimeinfo
->subtype
, "plain"))
1502 && (mimeinfo
->type
!= MIMETYPE_MULTIPART
1503 || strcasecmp(mimeinfo
->subtype
, "signed"))) {
1504 if (strcasecmp(mimeinfo
->subtype
, "html")) {
1505 MimeInfoSearch context
= {
1507 .current
= mimeinfo
,
1510 if (mimeview_has_viewer_for_content_type(messageview
->mimeview
, "text/calendar")) {
1511 MimeInfoSearch cal_context
= context
;
1512 messageview_find_part_depth_first(&cal_context
, MIMETYPE_TEXT
, "calendar");
1513 if (cal_context
.found
) { /* calendar found */
1514 mimeinfo
= cal_context
.found
;
1515 if (messageview_try_select_mimeinfo(messageview
, msginfo
, mimeinfo
))
1519 messageview_find_part_depth_first(&context
, MIMETYPE_TEXT
, "html");
1520 if (context
.found
&&
1521 (msginfo
->folder
->prefs
->promote_html_part
== HTML_PROMOTE_ALWAYS
||
1522 (msginfo
->folder
->prefs
->promote_html_part
== HTML_PROMOTE_DEFAULT
&&
1523 prefs_common
.promote_html_part
))) { /* html found */
1524 mimeinfo
= context
.found
;
1525 if (messageview_try_select_mimeinfo(messageview
, msginfo
, mimeinfo
))
1528 mimeinfo
= root
; /* nothing found */
1530 if (!mimeview_show_part(messageview
->mimeview
, mimeinfo
))
1531 mimeview_select_mimepart_icon(messageview
->mimeview
, root
);
1533 } else if (prefs_common
.invoke_plugin_on_html
) {
1534 mimeview_select_mimepart_icon(messageview
->mimeview
, mimeinfo
);
1538 if (!all_headers
&& mimeinfo
&&
1539 mimeinfo
->type
== MIMETYPE_MULTIPART
&&
1540 mimeview_has_viewer_for_content_type(messageview
->mimeview
, "text/calendar")) {
1541 /* look for a calendar part or it looks really strange */
1543 if (mimeinfo
->type
== MIMETYPE_TEXT
&&
1544 !strcasecmp(mimeinfo
->subtype
, "calendar")) {
1545 mimeview_select_mimepart_icon(messageview
->mimeview
, mimeinfo
);
1548 mimeinfo
= procmime_mimeinfo_next(mimeinfo
);
1552 mimeview_select_mimepart_icon(messageview
->mimeview
, root
);
1554 messageview_set_menu_sensitive(messageview
);
1555 /* plugins may hook in here to work with the message view */
1556 hooks_invoke(MESSAGE_VIEW_SHOW_DONE_HOOKLIST
, messageview
);
1563 void messageview_reflect_prefs_pixmap_theme(void)
1566 MessageView
*msgview
;
1568 for (cur
= msgview_list
; cur
!= NULL
; cur
= cur
->next
) {
1569 msgview
= (MessageView
*)cur
->data
;
1570 toolbar_update(TOOLBAR_MSGVIEW
, msgview
);
1571 mimeview_update(msgview
->mimeview
);
1575 void messageview_clear(MessageView
*messageview
)
1579 procmsg_msginfo_free(&(messageview
->msginfo
));
1580 messageview
->msginfo
= NULL
;
1581 messageview
->filtered
= FALSE
;
1583 if (messageview
->window
) {
1584 gtk_window_set_title(GTK_WINDOW(messageview
->window
),
1585 _("Claws Mail - Message View"));
1589 mimeview_clear(messageview
->mimeview
);
1590 headerview_clear(messageview
->headerview
);
1591 noticeview_hide(messageview
->noticeview
);
1594 void messageview_destroy(MessageView
*messageview
)
1596 debug_print("destroy messageview\n");
1597 messageview_list
= g_list_remove(messageview_list
, messageview
);
1599 if (messageview
->mainwin
->summaryview
->messageview
== messageview
) {
1600 messageview
->mainwin
->summaryview
->displayed
= NULL
;
1601 messageview
->mainwin
->summaryview
->messageview
= NULL
;
1603 if (messageview
->mainwin
->summaryview
->ext_messageview
== messageview
) {
1604 messageview
->mainwin
->summaryview
->displayed
= NULL
;
1605 messageview
->mainwin
->summaryview
->ext_messageview
= NULL
;
1607 if (!messageview
->deferred_destroy
)
1608 hooks_unregister_hook(MSGINFO_UPDATE_HOOKLIST
,
1609 messageview
->msginfo_update_callback_id
);
1611 if (messageview
->updating
) {
1612 debug_print("uh oh, better not touch that now (fetching)\n");
1613 messageview
->deferred_destroy
= TRUE
;
1614 gtk_widget_hide(messageview
->window
);
1618 if (messageview
->mimeview
->textview
1619 && messageview
->mimeview
->textview
->loading
) {
1620 debug_print("uh oh, better not touch that now (loading text)\n");
1621 messageview
->deferred_destroy
= TRUE
;
1622 messageview
->mimeview
->textview
->stop_loading
= TRUE
;
1623 gtk_widget_hide(messageview
->window
);
1627 headerview_destroy(messageview
->headerview
);
1628 mimeview_destroy(messageview
->mimeview
);
1629 noticeview_destroy(messageview
->noticeview
);
1631 procmsg_msginfo_free(&(messageview
->msginfo
));
1632 toolbar_clear_list(TOOLBAR_MSGVIEW
);
1633 if (messageview
->toolbar
) {
1634 toolbar_destroy(messageview
->toolbar
);
1635 g_free(messageview
->toolbar
);
1638 message_search_close(messageview
);
1640 list_free_strings_full(messageview
->trail
);
1641 msgview_list
= g_list_remove(msgview_list
, messageview
);
1643 if (messageview
->window
)
1644 gtk_widget_destroy(messageview
->window
);
1645 g_free(messageview
);
1648 void messageview_delete(MessageView
*msgview
)
1650 MsgInfo
*msginfo
= NULL
;
1651 FolderItem
*trash
= NULL
;
1652 PrefsAccount
*ac
= NULL
;
1654 if (msgview
->msginfo
&& msgview
->mainwin
&& msgview
->mainwin
->summaryview
)
1655 msginfo
= summary_get_selected_msg(msgview
->mainwin
->summaryview
);
1657 /* need a procmsg_msginfo_equal() */
1658 if (msginfo
&& msgview
->msginfo
&&
1659 msginfo
->msgnum
== msgview
->msginfo
->msgnum
&&
1660 msginfo
->folder
== msgview
->msginfo
->folder
) {
1661 summary_delete_trash(msgview
->mainwin
->summaryview
);
1663 msginfo
= msgview
->msginfo
;
1665 cm_return_if_fail(msginfo
!= NULL
);
1667 /* We will need to access the original message's msginfo
1668 * later, so we add our own reference. */
1669 procmsg_msginfo_new_ref(msginfo
);
1671 /* to get the trash folder, we have to choose either
1672 * the folder's or account's trash default - we prefer
1673 * the one in the account prefs */
1674 if (msginfo
->folder
) {
1675 if (NULL
!= (ac
= account_find_from_item(msginfo
->folder
)))
1676 trash
= account_get_special_folder(ac
, F_TRASH
);
1677 if (!trash
&& msginfo
->folder
->folder
)
1678 trash
= msginfo
->folder
->folder
->trash
;
1679 /* if still not found, use the default */
1681 trash
= folder_get_default_trash();
1684 cm_return_if_fail(trash
!= NULL
);
1686 if (prefs_common
.immediate_exec
)
1687 /* TODO: Delete from trash */
1688 folder_item_move_msg(trash
, msginfo
);
1690 procmsg_msginfo_set_to_folder(msginfo
, trash
);
1691 procmsg_msginfo_set_flags(msginfo
, MSG_DELETED
, 0);
1692 /* NOTE: does not update to next message in summaryview */
1695 procmsg_msginfo_free(&msginfo
);
1698 if (msgview
->window
&& !prefs_common
.always_show_msg
) {
1699 messageview_destroy(msgview
);
1705 * \brief update messageview with currently selected message in summaryview
1706 * leave unchanged if summaryview is empty
1707 * \param pointer to MessageView
1709 static void messageview_update(MessageView
*msgview
, MsgInfo
*old_msginfo
)
1711 SummaryView
*summaryview
= (SummaryView
*)msgview
->mainwin
->summaryview
;
1713 cm_return_if_fail(summaryview
!= NULL
);
1715 if (summaryview
->selected
) {
1716 MsgInfo
*msginfo
= summary_get_selected_msg(summaryview
);
1717 if (msginfo
== NULL
|| msginfo
== old_msginfo
)
1720 messageview_show(msgview
, msginfo
,
1721 msgview
->all_headers
);
1725 TextView
*messageview_get_current_textview(MessageView
*messageview
)
1727 TextView
*text
= NULL
;
1729 text
= messageview
->mimeview
->textview
;
1734 MimeInfo
*messageview_get_selected_mime_part(MessageView
*messageview
)
1736 return mimeview_get_selected_part(messageview
->mimeview
);
1739 void messageview_copy_clipboard(MessageView
*messageview
)
1741 gchar
*text
= messageview_get_selection(messageview
);
1743 gtk_clipboard_set_text(
1744 gtk_clipboard_get(GDK_SELECTION_CLIPBOARD
),
1750 void messageview_select_all(MessageView
*messageview
)
1754 text
= messageview_get_current_textview(messageview
);
1756 GtkTextView
*textview
= GTK_TEXT_VIEW(text
->text
);
1757 GtkTextBuffer
*buffer
;
1758 GtkTextIter start
, end
;
1760 buffer
= gtk_text_view_get_buffer(textview
);
1761 gtk_text_buffer_get_bounds(buffer
, &start
, &end
);
1762 gtk_text_buffer_select_range(buffer
, &start
, &end
);
1766 void messageview_set_position(MessageView
*messageview
, gint pos
)
1770 text
= messageview_get_current_textview(messageview
);
1772 textview_set_position(text
, pos
);
1775 gboolean
messageview_search_string(MessageView
*messageview
, const gchar
*str
,
1780 if (messageview
->mimeview
->type
== MIMEVIEW_VIEWER
) {
1781 MimeViewer
*viewer
= messageview
->mimeview
->mimeviewer
;
1782 if (viewer
&& viewer
->text_search
) {
1783 return viewer
->text_search(viewer
, FALSE
, str
, case_sens
);
1787 text
= messageview_get_current_textview(messageview
);
1789 return textview_search_string(text
, str
, case_sens
);
1793 gboolean
messageview_search_string_backward(MessageView
*messageview
,
1799 if (messageview
->mimeview
->type
== MIMEVIEW_VIEWER
) {
1800 MimeViewer
*viewer
= messageview
->mimeview
->mimeviewer
;
1801 if (viewer
&& viewer
->text_search
) {
1802 return viewer
->text_search(viewer
, TRUE
, str
, case_sens
);
1806 text
= messageview_get_current_textview(messageview
);
1808 return textview_search_string_backward(text
,
1813 gboolean
messageview_is_visible(MessageView
*messageview
)
1815 if (messageview
== NULL
)
1817 return messageview
->visible
;
1820 static gint
messageview_delete_cb(GtkWidget
*widget
, GdkEventAny
*event
,
1821 MessageView
*messageview
)
1823 messageview_destroy(messageview
);
1827 static void messageview_size_allocate_cb(GtkWidget
*widget
,
1828 GtkAllocation
*allocation
)
1830 cm_return_if_fail(allocation
!= NULL
);
1832 gtk_window_get_size(GTK_WINDOW(widget
),
1833 &prefs_common
.msgwin_width
, &prefs_common
.msgwin_height
);
1836 static gboolean
key_pressed(GtkWidget
*widget
, GdkEventKey
*event
,
1837 MessageView
*messageview
)
1839 if (event
&& event
->keyval
== GDK_KEY_Escape
&& messageview
->window
) {
1840 messageview_destroy(messageview
);
1844 if (event
&& (event
->state
& (GDK_MOD1_MASK
|GDK_CONTROL_MASK
)) != 0)
1846 if (event
&& (event
->state
& GDK_SHIFT_MASK
) && event
->keyval
!= GDK_KEY_space
)
1849 return mimeview_pass_key_press_event(messageview
->mimeview
, event
);
1852 static void messageview_show_partial_display_cb(NoticeView
*noticeview
, MessageView
*messageview
)
1854 messageview
->show_full_text
= TRUE
;
1855 main_window_cursor_wait(mainwindow_get_mainwindow());
1856 noticeview_hide(messageview
->noticeview
);
1857 messageview
->partial_display_shown
= FALSE
;
1859 mimeview_handle_cmd(messageview
->mimeview
, "sc://display_as_text", NULL
, NULL
);
1860 main_window_cursor_normal(mainwindow_get_mainwindow());
1863 void messageview_show_partial_display(MessageView
*messageview
, MsgInfo
*msginfo
,
1866 gchar
*msg
= g_strdup_printf(_("Show all %s."), to_human_readable((goffset
)length
));
1867 noticeview_set_icon(messageview
->noticeview
, STOCK_PIXMAP_NOTICE_WARN
);
1868 noticeview_set_text(messageview
->noticeview
, _("Only the first megabyte of text is shown."));
1869 noticeview_set_button_text(messageview
->noticeview
, msg
);
1871 noticeview_set_button_press_callback(messageview
->noticeview
,
1872 G_CALLBACK(messageview_show_partial_display_cb
),
1873 (gpointer
) messageview
);
1874 noticeview_show(messageview
->noticeview
);
1875 messageview
->partial_display_shown
= TRUE
;
1878 static void return_receipt_show(NoticeView
*noticeview
, MsgInfo
*msginfo
)
1881 gboolean from_me
= FALSE
;
1883 && (folder_has_parent_of_type(msginfo
->folder
, F_QUEUE
)
1884 || folder_has_parent_of_type(msginfo
->folder
, F_DRAFT
)))
1887 addr
= g_strdup(msginfo
->from
);
1889 extract_address(addr
);
1890 if (account_find_from_address(addr
, FALSE
)) {
1897 noticeview_set_icon(noticeview
, STOCK_PIXMAP_NOTICE_WARN
);
1898 if (MSG_IS_RETRCPT_GOT(msginfo
->flags
)) {
1899 noticeview_set_text(noticeview
, _("You got a return receipt for this message: "
1900 "it has been displayed by the recipient."));
1902 noticeview_set_text(noticeview
, _("You asked for a return receipt in this message."));
1904 noticeview_set_button_text(noticeview
, NULL
);
1905 noticeview_set_button_press_callback(noticeview
, NULL
, NULL
);
1907 noticeview_set_icon(noticeview
, STOCK_PIXMAP_NOTICE_WARN
);
1908 noticeview_set_text(noticeview
, _("This message asks for a return receipt."));
1909 noticeview_set_button_text(noticeview
, _("Send receipt"));
1910 noticeview_set_button_press_callback(noticeview
,
1911 G_CALLBACK(return_receipt_send_clicked
),
1912 (gpointer
) msginfo
);
1914 noticeview_show(noticeview
);
1917 static void return_receipt_send_clicked(NoticeView
*noticeview
, MsgInfo
*msginfo
)
1919 MsgInfo
*tmpmsginfo
;
1922 file
= procmsg_get_message_file_path(msginfo
);
1924 g_warning("can't get message file path.");
1928 tmpmsginfo
= procheader_parse_file(file
, msginfo
->flags
, TRUE
, TRUE
);
1929 tmpmsginfo
->folder
= msginfo
->folder
;
1930 tmpmsginfo
->msgnum
= msginfo
->msgnum
;
1932 if (disposition_notification_send(tmpmsginfo
) >= 0) {
1933 procmsg_msginfo_set_flags(msginfo
, MSG_RETRCPT_SENT
, 0);
1934 noticeview_hide(noticeview
);
1937 procmsg_msginfo_free(&tmpmsginfo
);
1941 static void partial_recv_show(NoticeView
*noticeview
, MsgInfo
*msginfo
)
1944 gchar
*button1
= NULL
;
1945 gchar
*button2
= NULL
;
1946 void *button1_cb
= NULL
;
1947 void *button2_cb
= NULL
;
1949 if (!msginfo
->extradata
)
1951 if (!partial_msg_in_uidl_list(msginfo
)) {
1952 text
= g_strdup_printf(_("This message has been partially "
1953 "retrieved,\nand has been deleted from the "
1956 switch (msginfo
->planned_download
) {
1957 case POP3_PARTIAL_DLOAD_UNKN
:
1958 text
= g_strdup_printf(_("This message has been "
1959 "partially retrieved;\nit is %s."),
1961 (goffset
)(msginfo
->total_size
)));
1962 button1
= _("Mark for download");
1963 button2
= _("Mark for deletion");
1964 button1_cb
= partial_recv_dload_clicked
;
1965 button2_cb
= partial_recv_del_clicked
;
1967 case POP3_PARTIAL_DLOAD_DLOAD
:
1968 text
= g_strdup_printf(_("This message has been "
1969 "partially retrieved;\nit is %s and "
1970 "will be downloaded."),
1972 (goffset
)(msginfo
->total_size
)));
1973 button1
= _("Unmark");
1974 button1_cb
= partial_recv_unmark_clicked
;
1975 button2
= _("Mark for deletion");
1976 button2_cb
= partial_recv_del_clicked
;
1978 case POP3_PARTIAL_DLOAD_DELE
:
1979 text
= g_strdup_printf(_("This message has been "
1980 "partially retrieved;\nit is %s and "
1981 "will be deleted."),
1983 (goffset
)(msginfo
->total_size
)));
1984 button1
= _("Mark for download");
1985 button1_cb
= partial_recv_dload_clicked
;
1986 button2
= _("Unmark");
1987 button2_cb
= partial_recv_unmark_clicked
;
1994 noticeview_set_icon(noticeview
, STOCK_PIXMAP_NOTICE_WARN
);
1995 noticeview_set_text(noticeview
, text
);
1997 noticeview_set_button_text(noticeview
, button1
);
1998 noticeview_set_button_press_callback(noticeview
,
1999 G_CALLBACK(button1_cb
), (gpointer
) msginfo
);
2001 noticeview_set_2ndbutton_text(noticeview
, button2
);
2002 noticeview_set_2ndbutton_press_callback(noticeview
,
2003 G_CALLBACK(button2_cb
), (gpointer
) msginfo
);
2005 noticeview_show(noticeview
);
2008 static void partial_recv_dload_clicked(NoticeView
*noticeview
,
2011 if (partial_mark_for_download(msginfo
) == 0) {
2012 partial_recv_show(noticeview
, msginfo
);
2016 static void partial_recv_del_clicked(NoticeView
*noticeview
,
2019 if (partial_mark_for_delete(msginfo
) == 0) {
2020 partial_recv_show(noticeview
, msginfo
);
2024 static void partial_recv_unmark_clicked(NoticeView
*noticeview
,
2027 if (partial_unmark(msginfo
) == 0) {
2028 partial_recv_show(noticeview
, msginfo
);
2032 static void select_account_cb(GtkWidget
*w
, gpointer data
)
2034 *(gint
*)data
= combobox_get_active_data(GTK_COMBO_BOX(w
));
2037 static PrefsAccount
*select_account_from_list(GList
*ac_list
, gboolean has_accounts
)
2043 cm_return_val_if_fail(ac_list
!= NULL
, NULL
);
2044 cm_return_val_if_fail(ac_list
->data
!= NULL
, NULL
);
2046 optmenu
= gtkut_account_menu_new(ac_list
,
2047 G_CALLBACK(select_account_cb
),
2051 account_id
= ((PrefsAccount
*) ac_list
->data
)->account_id
;
2052 if (!has_accounts
) {
2055 tr
= g_strdup(C_("'%s' stands for 'To' then 'Cc'",
2056 "This message is asking for a return receipt notification\n"
2057 "but according to its '%s' and '%s' headers it was not\n"
2058 "officially addressed to you.\n"
2059 "It is advised to not send the return receipt."));
2060 text
= g_strdup_printf(tr
,
2061 prefs_common_translated_header_name("To"),
2062 prefs_common_translated_header_name("Cc"));
2063 val
= alertpanel_with_widget(
2064 _("Return Receipt Notification"),
2066 _("_Cancel"), _("_Send Notification"), NULL
,
2067 ALERTFOCUS_FIRST
, FALSE
, optmenu
);
2071 val
= alertpanel_with_widget(
2072 _("Return Receipt Notification"),
2073 _("More than one of your accounts uses the "
2074 "address that this message was sent to.\n"
2075 "Please choose which account you want to "
2076 "use for sending the receipt notification:"),
2077 _("_Cancel"), _("_Send Notification"), NULL
,
2078 ALERTFOCUS_FIRST
, FALSE
, optmenu
);
2080 if (val
!= G_ALERTALTERNATE
)
2083 return account_find_from_id(account_id
);
2087 * \brief return selected messageview text, when nothing is
2088 * selected and message was filtered, return complete text
2090 * \param pointer to Messageview
2092 * \return pointer to text (needs to be free'd by calling func)
2094 gchar
*messageview_get_selection(MessageView
*msgview
)
2098 GtkTextView
*edit
= NULL
;
2099 GtkTextBuffer
*textbuf
;
2101 GtkTextIter start_iter
, end_iter
;
2102 GtkTextMark
*body_start
, *body_end
;
2104 cm_return_val_if_fail(msgview
!= NULL
, NULL
);
2106 if (msgview
->mimeview
->type
== MIMEVIEW_VIEWER
) {
2107 MimeViewer
*viewer
= msgview
->mimeview
->mimeviewer
;
2108 if (viewer
&& viewer
->get_selection
) {
2109 text
= viewer
->get_selection(viewer
);
2115 textview
= messageview_get_current_textview(msgview
);
2116 cm_return_val_if_fail(textview
!= NULL
, NULL
);
2118 edit
= GTK_TEXT_VIEW(textview
->text
);
2119 cm_return_val_if_fail(edit
!= NULL
, NULL
);
2120 body_pos
= textview
->body_pos
;
2122 textbuf
= gtk_text_view_get_buffer(edit
);
2124 if (gtk_text_buffer_get_selection_bounds(textbuf
, NULL
, NULL
)) {
2125 return gtkut_text_view_get_selection(edit
);
2127 if (msgview
->filtered
) {
2128 gtk_text_buffer_get_iter_at_offset(textbuf
, &start_iter
, body_pos
);
2129 gtk_text_buffer_get_end_iter(textbuf
, &end_iter
);
2131 body_start
= gtk_text_buffer_get_mark(textbuf
, "body_start");
2133 /* If there is no body_start mark, an attachment is likely
2134 * selected, and we're looking at instructions on what to do
2135 * with it. No point in quoting that, so we'll just return NULL,
2136 * so that original message body is quoted instead down the line.
2138 if (body_start
== NULL
) {
2142 gtk_text_buffer_get_iter_at_mark(textbuf
, &start_iter
, body_start
);
2144 body_end
= gtk_text_buffer_get_mark(textbuf
, "body_end");
2145 if (body_end
!= NULL
) /* Just in case */
2146 gtk_text_buffer_get_iter_at_mark(textbuf
, &end_iter
, body_end
);
2148 gtk_text_buffer_get_end_iter(textbuf
, &end_iter
);
2151 return gtk_text_buffer_get_text(textbuf
, &start_iter
, &end_iter
, FALSE
);
2157 static void save_as_cb(GtkAction
*action
, gpointer data
)
2159 MessageView
*messageview
= (MessageView
*)data
;
2160 summary_save_as(messageview
->mainwin
->summaryview
);
2163 static void print_mimeview(MimeView
*mimeview
, gint sel_start
, gint sel_end
, gint partnum
)
2165 MainWindow
*mainwin
;
2167 || !mimeview
->textview
2168 || !mimeview
->textview
->text
)
2169 alertpanel_warning(_("Cannot print: the message doesn't "
2172 gtk_widget_realize(mimeview
->textview
->text
);
2174 mimeview_select_part_num(mimeview
, partnum
);
2176 if (mimeview
->type
== MIMEVIEW_VIEWER
) {
2177 MimeViewer
*viewer
= mimeview
->mimeviewer
;
2178 if (viewer
&& viewer
->print
) {
2179 viewer
->print(viewer
);
2182 /* Force text rendering if possible */
2185 mimepart
= mimeview_get_selected_part(mimeview
);
2186 if (mimepart
== NULL
2187 || (mimepart
->type
!= MIMETYPE_TEXT
&& mimepart
->type
!= MIMETYPE_MESSAGE
)) {
2188 alertpanel_warning(_("Cannot print: the message doesn't "
2192 mimeview_show_part_as_text(mimeview
, mimepart
);
2195 if (sel_start
!= -1 && sel_end
!= -1) {
2196 GtkTextIter start
, end
;
2197 GtkTextView
*text
= GTK_TEXT_VIEW(mimeview
->textview
->text
);
2198 GtkTextBuffer
*buffer
= gtk_text_view_get_buffer(text
);
2200 gtk_text_buffer_get_iter_at_offset(buffer
, &start
, sel_start
);
2201 gtk_text_buffer_get_iter_at_offset(buffer
, &end
, sel_end
);
2202 gtk_text_buffer_select_range(buffer
, &start
, &end
);
2204 /* TODO: Get the real parent window, not the main window */
2205 mainwin
= mainwindow_get_mainwindow();
2206 printing_print(GTK_TEXT_VIEW(mimeview
->textview
->text
),
2207 mainwin
? GTK_WINDOW(mainwin
->window
) : NULL
,
2209 (mimeview
->textview
->image
2210 ? GTK_IMAGE(mimeview
->textview
->image
)
2215 void messageview_print(MsgInfo
*msginfo
, gboolean all_headers
,
2216 gint sel_start
, gint sel_end
, gint partnum
)
2218 PangoFontDescription
*font_desc
= NULL
;
2219 MessageView
*tmpview
= messageview_create_with_new_window_visible(
2220 mainwindow_get_mainwindow(), FALSE
);
2222 if (prefs_common
.use_different_print_font
) {
2223 font_desc
= pango_font_description_from_string
2224 (prefs_common
.printfont
);
2226 font_desc
= pango_font_description_from_string
2227 (prefs_common
.textfont
);
2230 gtk_widget_override_font(tmpview
->mimeview
->textview
->text
,
2232 pango_font_description_free(font_desc
);
2235 tmpview
->all_headers
= all_headers
;
2236 if (msginfo
&& messageview_show(tmpview
, msginfo
,
2237 tmpview
->all_headers
) >= 0) {
2238 print_mimeview(tmpview
->mimeview
,
2239 sel_start
, sel_end
, partnum
);
2241 messageview_destroy(tmpview
);
2244 static void page_setup_cb(GtkAction
*action
, gpointer data
)
2246 MessageView
*messageview
= (MessageView
*)data
;
2247 printing_page_setup(messageview
?
2248 GTK_WINDOW(messageview
->window
) : NULL
);
2251 static void print_cb(GtkAction
*action
, gpointer data
)
2253 MessageView
*messageview
= (MessageView
*)data
;
2254 gint sel_start
= -1, sel_end
= -1, partnum
= 0;
2256 if (!messageview
->msginfo
) return;
2258 partnum
= mimeview_get_selected_part_num(messageview
->mimeview
);
2259 textview_get_selection_offsets(messageview
->mimeview
->textview
,
2260 &sel_start
, &sel_end
);
2261 messageview_print(messageview
->msginfo
, messageview
->all_headers
,
2262 sel_start
, sel_end
, partnum
);
2265 static void close_cb(GtkAction
*action
, gpointer data
)
2267 MessageView
*messageview
= (MessageView
*)data
;
2268 messageview_destroy(messageview
);
2271 static void copy_cb(GtkAction
*action
, gpointer data
)
2273 MessageView
*messageview
= (MessageView
*)data
;
2274 messageview_copy_clipboard(messageview
);
2277 static void allsel_cb(GtkAction
*action
, gpointer data
)
2279 MessageView
*messageview
= (MessageView
*)data
;
2280 messageview_select_all(messageview
);
2283 static void search_cb(GtkAction
*action
, gpointer data
)
2285 MessageView
*messageview
= (MessageView
*)data
;
2286 message_search(messageview
);
2289 static void prev_cb(GtkAction
*action
, gpointer data
)
2291 MessageView
*messageview
= (MessageView
*)data
;
2292 messageview
->updating
= TRUE
;
2293 summary_select_prev(messageview
->mainwin
->summaryview
);
2294 messageview
->updating
= FALSE
;
2296 if (messageview
->deferred_destroy
) {
2297 debug_print("messageview got away!\n");
2298 messageview_destroy(messageview
);
2301 if (messageview
->mainwin
->summaryview
->selected
) {
2302 #ifndef GENERIC_UMPC
2303 MsgInfo
* msginfo
= summary_get_selected_msg(messageview
->mainwin
->summaryview
);
2306 messageview_show(messageview
, msginfo
,
2307 messageview
->all_headers
);
2310 gtk_widget_destroy(messageview
->window
);
2314 static void next_cb(GtkAction
*action
, gpointer data
)
2316 MessageView
*messageview
= (MessageView
*)data
;
2317 messageview
->updating
= TRUE
;
2318 summary_select_next(messageview
->mainwin
->summaryview
);
2319 messageview
->updating
= FALSE
;
2321 if (messageview
->deferred_destroy
) {
2322 debug_print("messageview got away!\n");
2323 messageview_destroy(messageview
);
2326 if (messageview
->mainwin
->summaryview
->selected
) {
2327 #ifndef GENERIC_UMPC
2328 MsgInfo
* msginfo
= summary_get_selected_msg(messageview
->mainwin
->summaryview
);
2331 messageview_show(messageview
, msginfo
,
2332 messageview
->all_headers
);
2335 gtk_widget_destroy(messageview
->window
);
2339 static void prev_unread_cb(GtkAction
*action
, gpointer data
)
2341 MessageView
*messageview
= (MessageView
*)data
;
2342 messageview
->updating
= TRUE
;
2343 summary_select_prev_unread(messageview
->mainwin
->summaryview
);
2344 messageview
->updating
= FALSE
;
2346 if (messageview
->deferred_destroy
) {
2347 debug_print("messageview got away!\n");
2348 messageview_destroy(messageview
);
2351 if (messageview
->mainwin
->summaryview
->selected
) {
2352 #ifndef GENERIC_UMPC
2353 MsgInfo
* msginfo
= summary_get_selected_msg(messageview
->mainwin
->summaryview
);
2356 messageview_show(messageview
, msginfo
,
2357 messageview
->all_headers
);
2360 gtk_widget_destroy(messageview
->window
);
2364 static void next_unread_cb(GtkAction
*action
, gpointer data
)
2366 MessageView
*messageview
= (MessageView
*)data
;
2367 messageview
->updating
= TRUE
;
2368 summary_select_next_unread(messageview
->mainwin
->summaryview
);
2369 messageview
->updating
= FALSE
;
2371 if (messageview
->deferred_destroy
) {
2372 debug_print("messageview got away!\n");
2373 messageview_destroy(messageview
);
2376 if (messageview
->mainwin
->summaryview
->selected
) {
2377 #ifndef GENERIC_UMPC
2378 MsgInfo
* msginfo
= summary_get_selected_msg(messageview
->mainwin
->summaryview
);
2381 messageview_show(messageview
, msginfo
,
2382 messageview
->all_headers
);
2385 gtk_widget_destroy(messageview
->window
);
2389 static void prev_new_cb(GtkAction
*action
, gpointer data
)
2391 MessageView
*messageview
= (MessageView
*)data
;
2392 messageview
->updating
= TRUE
;
2393 summary_select_prev_new(messageview
->mainwin
->summaryview
);
2394 messageview
->updating
= FALSE
;
2396 if (messageview
->deferred_destroy
) {
2397 debug_print("messageview got away!\n");
2398 messageview_destroy(messageview
);
2401 if (messageview
->mainwin
->summaryview
->selected
) {
2402 #ifndef GENERIC_UMPC
2403 MsgInfo
* msginfo
= summary_get_selected_msg(messageview
->mainwin
->summaryview
);
2406 messageview_show(messageview
, msginfo
,
2407 messageview
->all_headers
);
2410 gtk_widget_destroy(messageview
->window
);
2414 static void next_new_cb(GtkAction
*action
, gpointer data
)
2416 MessageView
*messageview
= (MessageView
*)data
;
2417 messageview
->updating
= TRUE
;
2418 summary_select_next_new(messageview
->mainwin
->summaryview
);
2419 messageview
->updating
= FALSE
;
2421 if (messageview
->deferred_destroy
) {
2422 debug_print("messageview got away!\n");
2423 messageview_destroy(messageview
);
2426 if (messageview
->mainwin
->summaryview
->selected
) {
2427 #ifndef GENERIC_UMPC
2428 MsgInfo
* msginfo
= summary_get_selected_msg(messageview
->mainwin
->summaryview
);
2431 messageview_show(messageview
, msginfo
,
2432 messageview
->all_headers
);
2435 gtk_widget_destroy(messageview
->window
);
2439 static void prev_marked_cb(GtkAction
*action
, gpointer data
)
2441 MessageView
*messageview
= (MessageView
*)data
;
2442 messageview
->updating
= TRUE
;
2443 summary_select_prev_marked(messageview
->mainwin
->summaryview
);
2444 messageview
->updating
= FALSE
;
2446 if (messageview
->deferred_destroy
) {
2447 debug_print("messageview got away!\n");
2448 messageview_destroy(messageview
);
2451 if (messageview
->mainwin
->summaryview
->selected
) {
2452 #ifndef GENERIC_UMPC
2453 MsgInfo
* msginfo
= summary_get_selected_msg(messageview
->mainwin
->summaryview
);
2456 messageview_show(messageview
, msginfo
,
2457 messageview
->all_headers
);
2460 gtk_widget_destroy(messageview
->window
);
2464 static void next_marked_cb(GtkAction
*action
, gpointer data
)
2466 MessageView
*messageview
= (MessageView
*)data
;
2467 messageview
->updating
= TRUE
;
2468 summary_select_next_marked(messageview
->mainwin
->summaryview
);
2469 messageview
->updating
= FALSE
;
2471 if (messageview
->deferred_destroy
) {
2472 debug_print("messageview got away!\n");
2473 messageview_destroy(messageview
);
2476 if (messageview
->mainwin
->summaryview
->selected
) {
2477 #ifndef GENERIC_UMPC
2478 MsgInfo
* msginfo
= summary_get_selected_msg(messageview
->mainwin
->summaryview
);
2481 messageview_show(messageview
, msginfo
,
2482 messageview
->all_headers
);
2485 gtk_widget_destroy(messageview
->window
);
2489 static void prev_labeled_cb(GtkAction
*action
, gpointer data
)
2491 MessageView
*messageview
= (MessageView
*)data
;
2492 messageview
->updating
= TRUE
;
2493 summary_select_prev_labeled(messageview
->mainwin
->summaryview
);
2494 messageview
->updating
= FALSE
;
2496 if (messageview
->deferred_destroy
) {
2497 debug_print("messageview got away!\n");
2498 messageview_destroy(messageview
);
2501 if (messageview
->mainwin
->summaryview
->selected
) {
2502 #ifndef GENERIC_UMPC
2503 MsgInfo
* msginfo
= summary_get_selected_msg(messageview
->mainwin
->summaryview
);
2506 messageview_show(messageview
, msginfo
,
2507 messageview
->all_headers
);
2510 gtk_widget_destroy(messageview
->window
);
2514 static void next_labeled_cb(GtkAction
*action
, gpointer data
)
2516 MessageView
*messageview
= (MessageView
*)data
;
2517 messageview
->updating
= TRUE
;
2518 summary_select_next_labeled(messageview
->mainwin
->summaryview
);
2519 messageview
->updating
= FALSE
;
2521 if (messageview
->deferred_destroy
) {
2522 debug_print("messageview got away!\n");
2523 messageview_destroy(messageview
);
2526 if (messageview
->mainwin
->summaryview
->selected
) {
2527 #ifndef GENERIC_UMPC
2528 MsgInfo
* msginfo
= summary_get_selected_msg(messageview
->mainwin
->summaryview
);
2531 messageview_show(messageview
, msginfo
,
2532 messageview
->all_headers
);
2535 gtk_widget_destroy(messageview
->window
);
2539 static void prev_history_cb(GtkAction
*action
, gpointer data
)
2541 MessageView
*messageview
= (MessageView
*)data
;
2542 MsgInfo
*info
= messageview_nav_get_prev(messageview
);
2544 messageview
->updating
= TRUE
;
2545 messageview_show(messageview
, info
,
2546 messageview
->all_headers
);
2547 messageview
->updating
= FALSE
;
2548 procmsg_msginfo_free(&info
);
2549 if (messageview
->deferred_destroy
) {
2550 debug_print("messageview got away!\n");
2551 messageview_destroy(messageview
);
2557 static void next_history_cb(GtkAction
*action
, gpointer data
)
2559 MessageView
*messageview
= (MessageView
*)data
;
2560 MsgInfo
*info
= messageview_nav_get_next(messageview
);
2562 messageview
->updating
= TRUE
;
2563 messageview_show(messageview
, info
,
2564 messageview
->all_headers
);
2565 messageview
->updating
= FALSE
;
2566 procmsg_msginfo_free(&info
);
2567 if (messageview
->deferred_destroy
) {
2568 debug_print("messageview got away!\n");
2569 messageview_destroy(messageview
);
2575 static void parent_cb(GtkAction
*action
, gpointer data
)
2577 MessageView
*messageview
= (MessageView
*)data
;
2578 messageview
->updating
= TRUE
;
2579 summary_select_parent(messageview
->mainwin
->summaryview
);
2580 messageview
->updating
= FALSE
;
2582 if (messageview
->deferred_destroy
) {
2583 debug_print("messageview got away!\n");
2584 messageview_destroy(messageview
);
2587 if (messageview
->mainwin
->summaryview
->selected
) {
2588 #ifndef GENERIC_UMPC
2589 MsgInfo
* msginfo
= summary_get_selected_msg(messageview
->mainwin
->summaryview
);
2592 messageview_show(messageview
, msginfo
,
2593 messageview
->all_headers
);
2596 gtk_widget_destroy(messageview
->window
);
2600 static void goto_unread_folder_cb(GtkAction
*action
, gpointer data
)
2602 MessageView
*messageview
= (MessageView
*)data
;
2604 messageview
->updating
= TRUE
;
2605 folderview_select_next_with_flag(messageview
->mainwin
->folderview
, MSG_UNREAD
);
2606 messageview
->updating
= FALSE
;
2608 if (messageview
->deferred_destroy
) {
2609 debug_print("messageview got away!\n");
2610 messageview_destroy(messageview
);
2613 if (messageview
->mainwin
->summaryview
->selected
) {
2614 #ifndef GENERIC_UMPC
2615 MsgInfo
* msginfo
= summary_get_selected_msg(messageview
->mainwin
->summaryview
);
2618 messageview_show(messageview
, msginfo
,
2619 messageview
->all_headers
);
2622 gtk_widget_destroy(messageview
->window
);
2626 static void goto_folder_cb(GtkAction
*action
, gpointer data
)
2628 MessageView
*messageview
= (MessageView
*)data
;
2629 FolderItem
*to_folder
;
2631 to_folder
= foldersel_folder_sel(NULL
, FOLDER_SEL_ALL
, NULL
, FALSE
,
2632 _("Select folder to go to"));
2635 folderview_select(messageview
->mainwin
->folderview
, to_folder
);
2637 if (messageview
->deferred_destroy
) {
2638 debug_print("messageview got away!\n");
2639 messageview_destroy(messageview
);
2642 if (messageview
->mainwin
->summaryview
->selected
) {
2643 #ifndef GENERIC_UMPC
2644 MsgInfo
* msginfo
= summary_get_selected_msg(messageview
->mainwin
->summaryview
);
2647 messageview_show(messageview
, msginfo
,
2648 messageview
->all_headers
);
2651 gtk_widget_destroy(messageview
->window
);
2656 static void scroll_prev_line_cb(GtkAction
*action
, gpointer data
)
2658 MessageView
*messageview
= (MessageView
*)data
;
2659 mimeview_scroll_one_line(messageview
->mimeview
,TRUE
);
2662 static void scroll_next_line_cb(GtkAction
*action
, gpointer data
)
2664 MessageView
*messageview
= (MessageView
*)data
;
2665 mimeview_scroll_one_line(messageview
->mimeview
,FALSE
);
2668 static void scroll_prev_page_cb(GtkAction
*action
, gpointer data
)
2670 MessageView
*messageview
= (MessageView
*)data
;
2671 mimeview_scroll_page(messageview
->mimeview
,TRUE
);
2674 static void scroll_next_page_cb(GtkAction
*action
, gpointer data
)
2676 MessageView
*messageview
= (MessageView
*)data
;
2677 mimeview_scroll_page(messageview
->mimeview
,FALSE
);
2680 static void set_charset_cb(GtkAction
*action
, GtkRadioAction
*current
, gpointer data
)
2682 MessageView
*messageview
= (MessageView
*)data
;
2683 gboolean active
= gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (current
));
2684 gint value
= gtk_radio_action_get_current_value (GTK_RADIO_ACTION (current
));
2685 const gchar
*charset
;
2688 charset
= conv_get_charset_str((CharSet
)value
);
2689 g_free(messageview
->forced_charset
);
2690 messageview
->forced_charset
= g_strdup(charset
);
2691 procmime_force_charset(charset
);
2693 messageview_show(messageview
, messageview
->msginfo
, FALSE
);
2697 static void set_decode_cb(GtkAction
*action
, GtkRadioAction
*current
, gpointer data
)
2699 MessageView
*messageview
= (MessageView
*)data
;
2700 gboolean active
= gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (current
));
2701 gint value
= gtk_radio_action_get_current_value (GTK_RADIO_ACTION (current
));
2704 messageview
->forced_encoding
= (EncodingType
)value
;
2706 messageview_show(messageview
, messageview
->msginfo
, FALSE
);
2707 debug_print("forced encoding: %d\n", value
);
2712 static void view_source_cb(GtkAction
*action
, gpointer data
)
2714 MessageView
*messageview
= (MessageView
*)data
;
2715 SourceWindow
*srcwin
;
2717 if (!messageview
->msginfo
) return;
2719 srcwin
= source_window_create();
2720 source_window_show_msg(srcwin
, messageview
->msginfo
);
2721 source_window_show(srcwin
);
2724 static void show_all_header_cb(GtkToggleAction
*action
, gpointer data
)
2726 MessageView
*messageview
= (MessageView
*)data
;
2727 MsgInfo
*msginfo
= messageview
->msginfo
;
2729 if (messageview
->mimeview
->textview
&&
2730 messageview
->mimeview
->textview
->loading
) {
2733 if (messageview
->updating
)
2736 messageview
->all_headers
= prefs_common
.show_all_headers
=
2737 gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action
));
2738 if (!msginfo
) return;
2739 messageview
->msginfo
= NULL
;
2740 messageview_show(messageview
, msginfo
, messageview
->all_headers
);
2741 procmsg_msginfo_free(&msginfo
);
2742 main_window_set_menu_sensitive(messageview
->mainwin
);
2743 summary_redisplay_msg(messageview
->mainwin
->summaryview
);
2746 static void msg_hide_quotes_cb(GtkToggleAction
*action
, gpointer data
)
2748 MessageView
*messageview
= (MessageView
*)data
;
2749 MsgInfo
*msginfo
= messageview
->msginfo
;
2750 static gboolean updating_menu
= FALSE
;
2754 if (gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action
))) {
2755 const gchar
*a_name
= gtk_action_get_name(GTK_ACTION(action
));
2756 if (!strcmp(a_name
, "View/Quotes/CollapseAll")) prefs_common
.hide_quotes
= 1;
2757 else if (!strcmp(a_name
, "View/Quotes/Collapse2")) prefs_common
.hide_quotes
= 2;
2758 else if (!strcmp(a_name
, "View/Quotes/Collapse3")) prefs_common
.hide_quotes
= 3;
2760 prefs_common
.hide_quotes
= 0;
2764 cm_toggle_menu_set_active_full(messageview
->ui_manager
, "Menu/View/Quotes/CollapseAll", (prefs_common
.hide_quotes
== 1));
2765 cm_toggle_menu_set_active_full(messageview
->ui_manager
, "Menu/View/Quotes/Collapse2", (prefs_common
.hide_quotes
== 2));
2766 cm_toggle_menu_set_active_full(messageview
->ui_manager
, "Menu/View/Quotes/Collapse3", (prefs_common
.hide_quotes
== 3));
2768 updating_menu
=FALSE
;
2769 if (!msginfo
) return;
2770 messageview
->msginfo
= NULL
;
2771 messageview_show(messageview
, msginfo
,
2772 messageview
->all_headers
);
2773 procmsg_msginfo_free(&msginfo
);
2775 /* update main window */
2776 main_window_set_menu_sensitive(messageview
->mainwin
);
2777 summary_redisplay_msg(messageview
->mainwin
->summaryview
);
2779 #undef SET_CHECK_MENU_ACTIVE
2781 static void compose_cb(GtkAction
*action
, gpointer data
)
2783 MessageView
*messageview
= (MessageView
*)data
;
2784 PrefsAccount
*ac
= NULL
;
2785 FolderItem
*item
= NULL
;
2787 if (messageview
->msginfo
)
2788 item
= messageview
->msginfo
->folder
;
2791 ac
= account_find_from_item(item
);
2792 if (ac
&& ac
->protocol
== A_NNTP
&&
2793 FOLDER_TYPE(item
->folder
) == F_NEWS
) {
2794 compose_new(ac
, item
->path
, NULL
);
2799 compose_new(ac
, NULL
, NULL
);
2802 #define DO_ACTION(name, act) { if (!strcmp(a_name, name)) action = act; }
2804 static void reply_cb(GtkAction
*gaction
, gpointer data
)
2806 MessageView
*messageview
= (MessageView
*)data
;
2807 GSList
*msginfo_list
= NULL
;
2808 gint action
= COMPOSE_REPLY
;
2809 const gchar
*a_name
= gtk_action_get_name(gaction
);
2811 cm_return_if_fail(messageview
->msginfo
);
2813 DO_ACTION("Message/Reply", COMPOSE_REPLY
);
2814 DO_ACTION("Message/ReplyTo/All", COMPOSE_REPLY_TO_ALL
);
2815 DO_ACTION("Message/ReplyTo/Sender", COMPOSE_REPLY_TO_SENDER
);
2816 DO_ACTION("Message/ReplyTo/List", COMPOSE_REPLY_TO_LIST
);
2817 DO_ACTION("Message/Forward", COMPOSE_FORWARD_INLINE
);
2818 DO_ACTION("Message/ForwardAtt", COMPOSE_FORWARD_AS_ATTACH
);
2819 DO_ACTION("Message/Redirect", COMPOSE_REDIRECT
);
2821 msginfo_list
= g_slist_append(msginfo_list
, messageview
->msginfo
);
2822 compose_reply_from_messageview(messageview
, msginfo_list
, action
);
2823 g_slist_free(msginfo_list
);
2826 static void addressbook_open_cb(GtkAction
*action
, gpointer data
)
2828 #ifndef USE_ALT_ADDRBOOK
2829 addressbook_open(NULL
);
2831 GError
* error
= NULL
;
2833 addressbook_dbus_open(FALSE
, &error
);
2835 g_warning("Failed to open address book: %s", error
->message
);
2836 g_error_free(error
);
2841 static void add_address_cb(GtkAction
*action
, gpointer data
)
2843 MessageView
*messageview
= (MessageView
*)data
;
2844 MsgInfo
*msginfo
, *full_msginfo
;
2846 GdkPixbuf
*picture
= NULL
;
2847 AvatarRender
*avatarr
;
2849 if (!messageview
->msginfo
|| !messageview
->msginfo
->from
)
2852 msginfo
= messageview
->msginfo
;
2853 Xstrdup_a(from
, msginfo
->from
, return);
2854 eliminate_address_comment(from
);
2855 extract_address(from
);
2857 full_msginfo
= procmsg_msginfo_get_full_info(msginfo
);
2859 avatarr
= avatars_avatarrender_new(full_msginfo
);
2860 hooks_invoke(AVATAR_IMAGE_RENDER_HOOKLIST
, avatarr
);
2862 procmsg_msginfo_free(&full_msginfo
);
2864 if (avatarr
->image
!= NULL
)
2865 picture
= gtk_image_get_pixbuf(GTK_IMAGE(avatarr
->image
));
2867 #ifndef USE_ALT_ADDRBOOK
2868 addressbook_add_contact(msginfo
->fromname
, from
, NULL
, picture
);
2870 if (addressadd_selection(msginfo
->fromname
, from
, NULL
, picture
)) {
2871 debug_print( "addressbook_add_contact - added\n" );
2874 avatars_avatarrender_free(avatarr
);
2877 static void create_filter_cb(GtkAction
*gaction
, gpointer data
)
2879 MessageView
*messageview
= (MessageView
*)data
;
2882 const gchar
*a_name
= gtk_action_get_name(gaction
);
2884 if (!messageview
->msginfo
) return;
2886 DO_ACTION("Tools/CreateFilterRule/Automatically", FILTER_BY_AUTO
);
2887 DO_ACTION("Tools/CreateFilterRule/ByFrom", FILTER_BY_FROM
);
2888 DO_ACTION("Tools/CreateFilterRule/ByTo", FILTER_BY_TO
);
2889 DO_ACTION("Tools/CreateFilterRule/BySubject", FILTER_BY_SUBJECT
);
2891 item
= messageview
->msginfo
->folder
;
2892 summary_msginfo_filter_open(item
, messageview
->msginfo
,
2893 (PrefsFilterType
)action
, 0);
2896 static void create_processing_cb(GtkAction
*gaction
, gpointer data
)
2898 MessageView
*messageview
= (MessageView
*)data
;
2901 const gchar
*a_name
= gtk_action_get_name(gaction
);
2903 if (!messageview
->msginfo
) return;
2905 DO_ACTION("Tools/CreateProcessingRule/Automatically", FILTER_BY_AUTO
);
2906 DO_ACTION("Tools/CreateProcessingRule/ByFrom", FILTER_BY_FROM
);
2907 DO_ACTION("Tools/CreateProcessingRule/ByTo", FILTER_BY_TO
);
2908 DO_ACTION("Tools/CreateProcessingRule/BySubject", FILTER_BY_SUBJECT
);
2910 item
= messageview
->msginfo
->folder
;
2911 summary_msginfo_filter_open(item
, messageview
->msginfo
,
2912 (PrefsFilterType
)action
, 1);
2915 static void open_urls_cb(GtkAction
*action
, gpointer data
)
2917 MessageView
*messageview
= (MessageView
*)data
;
2918 messageview_list_urls(messageview
);
2921 static void about_cb(GtkAction
*gaction
, gpointer data
)
2926 static gboolean
messageview_update_msg(gpointer source
, gpointer data
)
2928 MsgInfoUpdate
*msginfo_update
= (MsgInfoUpdate
*) source
;
2929 MessageView
*messageview
= (MessageView
*)data
;
2930 MsgInfo
*old_msginfo
= messageview
->msginfo
;
2932 if (messageview
->msginfo
!= msginfo_update
->msginfo
)
2935 if ((msginfo_update
->flags
& MSGINFO_UPDATE_DELETED
) ||
2936 MSG_IS_DELETED(old_msginfo
->flags
))
2938 if (messageview
->new_window
) {
2939 if (old_msginfo
->folder
&& old_msginfo
->folder
->total_msgs
== 0) {
2940 messageview_clear(messageview
);
2941 textview_show_info(messageview
->mimeview
->textview
,
2942 _("\n There are no messages in this folder"));
2946 if (!prefs_common
.always_show_msg
) {
2947 messageview_clear(messageview
);
2948 textview_show_info(messageview
->mimeview
->textview
,
2949 MSG_IS_DELETED(old_msginfo
->flags
) ?
2950 _("\n Message has been deleted") :
2951 _("\n Message has been deleted or moved to another folder"));
2953 messageview
->update_needed
= TRUE
;
2956 messageview_clear(messageview
);
2957 messageview_update(messageview
, old_msginfo
);
2964 void messageview_set_menu_sensitive(MessageView
*messageview
)
2966 if (!messageview
|| !messageview
->ui_manager
)
2969 cm_toggle_menu_set_active_full(messageview
->ui_manager
, "Menu/View/Quotes/CollapseAll", (prefs_common
.hide_quotes
== 1));
2970 cm_toggle_menu_set_active_full(messageview
->ui_manager
, "Menu/View/Quotes/Collapse2", (prefs_common
.hide_quotes
== 2));
2971 cm_toggle_menu_set_active_full(messageview
->ui_manager
, "Menu/View/Quotes/Collapse3", (prefs_common
.hide_quotes
== 3));
2972 cm_menu_set_sensitive_full(messageview
->ui_manager
, "Menu/View/Goto/PrevHistory", messageview_nav_has_prev(messageview
));
2973 cm_menu_set_sensitive_full(messageview
->ui_manager
, "Menu/View/Goto/NextHistory", messageview_nav_has_next(messageview
));
2975 cm_menu_set_sensitive_full(messageview
->ui_manager
, "Menu/Message/CheckSignature", messageview
->mimeview
->signed_part
);
2978 void messageview_learn (MessageView
*msgview
, gboolean is_spam
)
2981 if (procmsg_spam_learner_learn(msgview
->msginfo
, NULL
, TRUE
) == 0)
2982 procmsg_msginfo_set_flags(msgview
->msginfo
, MSG_SPAM
, 0);
2984 log_error(LOG_PROTOCOL
, _("An error happened while learning.\n"));
2987 if (procmsg_spam_learner_learn(msgview
->msginfo
, NULL
, FALSE
) == 0)
2988 procmsg_msginfo_unset_flags(msgview
->msginfo
, MSG_SPAM
, 0);
2990 log_error(LOG_PROTOCOL
, _("An error happened while learning.\n"));
2992 if (msgview
->toolbar
)
2993 toolbar_set_learn_button
2995 MSG_IS_SPAM(msgview
->msginfo
->flags
)?LEARN_HAM
:LEARN_SPAM
);
2997 toolbar_set_learn_button
2998 (msgview
->mainwin
->toolbar
,
2999 MSG_IS_SPAM(msgview
->msginfo
->flags
)?LEARN_HAM
:LEARN_SPAM
);
3002 void messageview_list_urls (MessageView
*msgview
)
3004 GSList
*cur
= msgview
->mimeview
->textview
->uri_list
;
3005 GSList
*newlist
= NULL
;
3006 GHashTable
*uri_hashtable
;
3009 uri_hashtable
= g_hash_table_new_full(g_str_hash
, g_str_equal
,
3010 (GDestroyNotify
) g_free
, NULL
);
3012 for (; cur
; cur
= cur
->next
) {
3013 ClickableText
*uri
= (ClickableText
*)cur
->data
;
3015 (!g_ascii_strncasecmp(uri
->uri
, "ftp.", 4) ||
3016 !g_ascii_strncasecmp(uri
->uri
, "ftp:", 4) ||
3017 !g_ascii_strncasecmp(uri
->uri
, "www.", 4) ||
3018 !g_ascii_strncasecmp(uri
->uri
, "http:", 5) ||
3019 !g_ascii_strncasecmp(uri
->uri
, "https:", 6)))
3021 tmp
= g_utf8_strdown(uri
->uri
, -1);
3023 if (g_hash_table_lookup(uri_hashtable
, tmp
)) {
3028 newlist
= g_slist_prepend(newlist
, uri
);
3029 g_hash_table_insert(uri_hashtable
, tmp
,
3030 GUINT_TO_POINTER(g_str_hash(tmp
)));
3033 newlist
= g_slist_reverse(newlist
);
3034 uri_opener_open(msgview
, newlist
);
3035 g_slist_free(newlist
);
3036 g_hash_table_destroy(uri_hashtable
);
3039 static void save_part_as_cb(GtkAction
*action
, gpointer data
)
3041 MessageView
*messageview
= (MessageView
*)data
;
3043 if (messageview
->mimeview
)
3044 mimeview_save_as(messageview
->mimeview
);
3047 static void view_part_as_text_cb(GtkAction
*action
, gpointer data
)
3049 MessageView
*messageview
= (MessageView
*)data
;
3051 if (messageview
->mimeview
)
3052 mimeview_display_as_text(messageview
->mimeview
);
3055 static void open_part_cb(GtkAction
*action
, gpointer data
)
3057 MessageView
*messageview
= (MessageView
*)data
;
3059 if (messageview
->mimeview
)
3060 mimeview_launch(messageview
->mimeview
, NULL
);
3063 static void open_part_with_cb(GtkAction
*action
, gpointer data
)
3065 MessageView
*messageview
= (MessageView
*)data
;
3067 if (messageview
->mimeview
)
3068 mimeview_open_with(messageview
->mimeview
);
3071 static void check_signature_cb(GtkAction
*action
, gpointer data
)
3073 MessageView
*messageview
= (MessageView
*)data
;
3075 if (messageview
->mimeview
)
3076 mimeview_check_signature(messageview
->mimeview
);
3079 static void goto_next_part_cb(GtkAction
*action
, gpointer data
)
3081 MessageView
*messageview
= (MessageView
*)data
;
3083 if (messageview
->mimeview
)
3084 mimeview_select_next_part(messageview
->mimeview
);
3087 static void goto_prev_part_cb(GtkAction
*action
, gpointer data
)
3089 MessageView
*messageview
= (MessageView
*)data
;
3091 if (messageview
->mimeview
)
3092 mimeview_select_prev_part(messageview
->mimeview
);