2 * Claws Mail -- a GTK based, lightweight, and fast e-mail client
3 * Copyright (C) 1999-2022 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/>.
23 #include <glib/gi18n.h>
24 #include <gdk/gdkkeysyms.h>
31 #include "messageview.h"
32 #include "message_search.h"
33 #include "headerview.h"
34 #include "summaryview.h"
40 #include "foldersel.h"
41 #include "sourcewindow.h"
42 #include "alertpanel.h"
43 #include "inputdialog.h"
44 #include "mainwindow.h"
45 #include "manage_window.h"
47 #include "procheader.h"
51 #include "prefs_common.h"
52 #include "prefs_account.h"
55 #include "send_message.h"
56 #include "stock_pixmap.h"
58 #include "filtering.h"
59 #include "partial_download.h"
60 #include "uri_opener.h"
66 #include "quoted-printable.h"
68 #include "statusbar.h"
69 #include "folder_item_prefs.h"
71 #include "file-utils.h"
73 #ifndef USE_ALT_ADDRBOOK
74 #include "addressbook.h"
76 #include "addressadd.h"
77 #include "addressbook-dbus.h"
79 static GList
*messageview_list
= NULL
;
81 static gint
messageview_delete_cb (GtkWidget
*widget
,
83 MessageView
*messageview
);
84 static void messageview_size_allocate_cb(GtkWidget
*widget
,
85 GtkAllocation
*allocation
);
86 static gboolean
key_pressed (GtkWidget
*widget
,
88 MessageView
*messageview
);
89 static void return_receipt_show (NoticeView
*noticeview
,
91 static void return_receipt_send_clicked (NoticeView
*noticeview
,
93 static void partial_recv_show (NoticeView
*noticeview
,
95 static void partial_recv_dload_clicked (NoticeView
*noticeview
,
97 static void partial_recv_del_clicked (NoticeView
*noticeview
,
99 static void partial_recv_unmark_clicked (NoticeView
*noticeview
,
101 static void save_as_cb (GtkAction
*action
,
103 static void page_setup_cb (GtkAction
*action
,
105 static void print_cb (GtkAction
*action
,
107 static void close_cb (GtkAction
*action
,
109 static void copy_cb (GtkAction
*action
,
111 static void allsel_cb (GtkAction
*action
,
113 static void search_cb (GtkAction
*action
,
116 static void prev_cb (GtkAction
*action
,
118 static void next_cb (GtkAction
*action
,
120 static void prev_unread_cb (GtkAction
*action
,
122 static void next_unread_cb (GtkAction
*action
,
124 static void prev_new_cb (GtkAction
*action
,
126 static void next_new_cb (GtkAction
*action
,
128 static void prev_marked_cb (GtkAction
*action
,
130 static void next_marked_cb (GtkAction
*action
,
132 static void prev_labeled_cb (GtkAction
*action
,
134 static void next_labeled_cb (GtkAction
*action
,
136 static void prev_history_cb (GtkAction
*action
,
138 static void next_history_cb (GtkAction
*action
,
140 static void parent_cb (GtkAction
*action
,
142 static void goto_unread_folder_cb (GtkAction
*action
,
144 static void goto_folder_cb (GtkAction
*action
,
147 static void scroll_prev_line_cb (GtkAction
*action
,
149 static void scroll_next_line_cb (GtkAction
*action
,
151 static void scroll_next_page_cb (GtkAction
*action
,
153 static void scroll_prev_page_cb (GtkAction
*action
,
156 static void set_charset_cb (GtkAction
*action
, GtkRadioAction
*current
, gpointer data
);
157 static void set_decode_cb (GtkAction
*action
, GtkRadioAction
*current
, gpointer data
);
159 static void view_source_cb (GtkAction
*action
,
162 static void show_all_header_cb (GtkToggleAction
*action
,
164 static void msg_hide_quotes_cb (GtkToggleAction
*action
,
167 static void compose_cb (GtkAction
*action
,
169 static void reply_cb (GtkAction
*action
,
172 static PrefsAccount
*select_account_from_list
174 gboolean has_accounts
);
175 static void addressbook_open_cb (GtkAction
*action
,
177 static void add_address_cb (GtkAction
*action
,
179 static void create_filter_cb (GtkAction
*action
,
181 static void create_processing_cb (GtkAction
*action
,
183 static void open_urls_cb (GtkAction
*action
,
186 static void about_cb (GtkAction
*action
,
188 static void messageview_update (MessageView
*msgview
,
189 MsgInfo
*old_msginfo
);
190 static gboolean
messageview_update_msg (gpointer source
, gpointer data
);
192 static void save_part_as_cb(GtkAction
*action
, gpointer data
);
193 static void view_part_as_text_cb(GtkAction
*action
, gpointer data
);
194 static void open_part_cb(GtkAction
*action
, gpointer data
);
196 static void open_part_with_cb(GtkAction
*action
, gpointer data
);
198 static void check_signature_cb(GtkAction
*action
, gpointer data
);
199 static void goto_next_part_cb(GtkAction
*action
, gpointer data
);
200 static void goto_prev_part_cb(GtkAction
*action
, gpointer data
);
202 static void messageview_nothing_cb (GtkAction
*action
, gpointer data
)
207 static GList
*msgview_list
= NULL
;
208 static GtkActionEntry msgview_entries
[] =
210 {"Menu", NULL
, "Menu", NULL
, NULL
, NULL
},
212 {"File", NULL
, N_("_File"), NULL
, NULL
, NULL
},
213 {"Edit", NULL
, N_("_Edit"), NULL
, NULL
, NULL
},
214 {"View", NULL
, N_("_View"), NULL
, NULL
, NULL
},
215 {"Message", NULL
, N_("_Message"), NULL
, NULL
, NULL
},
216 {"Tools", NULL
, N_("_Tools"), NULL
, NULL
, NULL
},
217 {"Help", NULL
, N_("_Help"), NULL
, NULL
, NULL
},
218 {"PlaceHolder", NULL
, "Placeholder", NULL
, NULL
, G_CALLBACK(messageview_nothing_cb
) },
221 {"File/SaveAs", NULL
, N_("_Save email as..."), "<control>S", NULL
, G_CALLBACK(save_as_cb
) },
222 {"File/SavePartAs", NULL
, N_("_Save part as..."), "Y", NULL
, G_CALLBACK(save_part_as_cb
) },
223 {"File/PageSetup", NULL
, N_("Page setup..."), NULL
, NULL
, G_CALLBACK(page_setup_cb
) },
224 {"File/Print", NULL
, N_("_Print..."), "<control>P", NULL
, G_CALLBACK(print_cb
) },
225 {"File/---", NULL
, "---", NULL
, NULL
, NULL
},
226 {"File/Close", NULL
, N_("_Close"), "<control>W", NULL
, G_CALLBACK(close_cb
) },
229 {"Edit/Copy", NULL
, N_("_Copy"), "<control>C", NULL
, G_CALLBACK(copy_cb
) },
230 {"Edit/SelectAll", NULL
, N_("_Select all"), "<control>A", NULL
, G_CALLBACK(allsel_cb
) },
231 {"Edit/---", NULL
, "---", NULL
, NULL
, NULL
},
232 {"Edit/Find", NULL
, N_("_Find"), "<control>F", NULL
, G_CALLBACK(search_cb
) },
235 {"View/Goto", NULL
, N_("_Go to"), NULL
, NULL
, NULL
},
236 {"View/Goto/Prev", NULL
, N_("_Previous message"), "P", NULL
, G_CALLBACK(prev_cb
) },
237 {"View/Goto/Next", NULL
, N_("_Next message"), "N", NULL
, G_CALLBACK(next_cb
) },
238 {"View/Goto/---", NULL
, "---", NULL
, NULL
, NULL
},
239 {"View/Goto/PrevUnread", NULL
, N_("P_revious unread message"), "<shift>P", NULL
, G_CALLBACK(prev_unread_cb
) },
240 {"View/Goto/NextUnread", NULL
, N_("N_ext unread message"), "<shift>N", NULL
, G_CALLBACK(next_unread_cb
) },
241 /* {"View/Goto/---", NULL, "---", NULL, NULL, NULL }, */
242 {"View/Goto/PrevNew", NULL
, N_("Previous ne_w message"), NULL
, NULL
, G_CALLBACK(prev_new_cb
) },
243 {"View/Goto/NextNew", NULL
, N_("Ne_xt new message"), NULL
, NULL
, G_CALLBACK(next_new_cb
) },
244 /* {"View/Goto/---", NULL, "---", NULL, NULL, NULL }, */
245 {"View/Goto/PrevMarked", NULL
, N_("Previous _marked message"), NULL
, NULL
, G_CALLBACK(prev_marked_cb
) },
246 {"View/Goto/NextMarked", NULL
, N_("Next m_arked message"), NULL
, NULL
, G_CALLBACK(next_marked_cb
) },
247 /* {"View/Goto/---", NULL, "---", NULL, NULL, NULL }, */
248 {"View/Goto/PrevLabeled", NULL
, N_("Previous _labeled message"), NULL
, NULL
, G_CALLBACK(prev_labeled_cb
) },
249 {"View/Goto/NextLabeled", NULL
, N_("Next la_beled message"), NULL
, NULL
, G_CALLBACK(next_labeled_cb
) },
250 /* {"View/Goto/---", NULL, "---", NULL, NULL, NULL }, */
251 {"View/Goto/PrevHistory", NULL
, N_("Previous opened message"), "<alt>Left", NULL
, G_CALLBACK(prev_history_cb
) },
252 {"View/Goto/NextHistory", NULL
, N_("Next opened message"), "<alt>Right", NULL
, G_CALLBACK(next_history_cb
) },
253 /* {"View/Goto/---", NULL, "---", NULL, NULL, NULL }, */
254 {"View/Goto/ParentMessage", NULL
, N_("Parent message"), "<control>Up", NULL
, G_CALLBACK(parent_cb
) },
255 /* {"View/Goto/---", NULL, "---", NULL, NULL, NULL }, */
256 {"View/Goto/NextUnreadFolder", NULL
, N_("Next unread _folder"), "<shift>G", NULL
, G_CALLBACK(goto_unread_folder_cb
) },
257 {"View/Goto/Folder", NULL
, N_("F_older..."), "G", NULL
, G_CALLBACK(goto_folder_cb
) },
258 /* {"View/Goto/---", NULL, "---", NULL, NULL, NULL }, */
259 {"View/Goto/NextPart", NULL
, N_("Next part"), "A", NULL
, G_CALLBACK(goto_next_part_cb
) },
260 {"View/Goto/PrevPart", NULL
, N_("Previous part"), "Z", NULL
, G_CALLBACK(goto_prev_part_cb
) },
261 {"View/Scroll", NULL
, N_("Message scroll"), NULL
, NULL
, NULL
},
262 {"View/Scroll/PrevLine", NULL
, N_("Previous line"), NULL
, NULL
, G_CALLBACK(scroll_prev_line_cb
) },
263 {"View/Scroll/NextLine", NULL
, N_("Next line"), NULL
, NULL
, G_CALLBACK(scroll_next_line_cb
) },
264 {"View/Scroll/PrevPage", NULL
, N_("Previous page"), NULL
, NULL
, G_CALLBACK(scroll_prev_page_cb
) },
265 {"View/Scroll/NextPage", NULL
, N_("Next page"), NULL
, NULL
, G_CALLBACK(scroll_next_page_cb
) },
266 /* {"View/Scroll/---", NULL, "---", NULL, NULL, NULL }, */
268 {"View/Encoding", NULL
, N_("Character _encoding"), NULL
, NULL
, NULL
}, /* set_charset_cb */
269 {"View/Encoding/---", NULL
, "---", NULL
, NULL
, NULL
},
270 #define ENC_ACTION(cs_char,c_char,string) \
271 { "View/Encoding/" cs_char, NULL, N_(string), NULL, NULL, c_char }
273 {"View/Encoding/Western", NULL
, N_("Western European"), NULL
, NULL
, NULL
},
274 {"View/Encoding/Baltic", NULL
, N_("Baltic"), NULL
, NULL
, NULL
},
275 {"View/Encoding/Hebrew", NULL
, N_("Hebrew"), NULL
, NULL
, NULL
},
276 {"View/Encoding/Arabic", NULL
, N_("Arabic"), NULL
, NULL
, NULL
},
277 {"View/Encoding/Cyrillic", NULL
, N_("Cyrillic"), NULL
, NULL
, NULL
},
278 {"View/Encoding/Japanese", NULL
, N_("Japanese"), NULL
, NULL
, NULL
},
279 {"View/Encoding/Chinese", NULL
, N_("Chinese"), NULL
, NULL
, NULL
},
280 {"View/Encoding/Korean", NULL
, N_("Korean"), NULL
, NULL
, NULL
},
281 {"View/Encoding/Thai", NULL
, N_("Thai"), NULL
, NULL
, NULL
},
283 {"View/Decode", NULL
, N_("Decode"), NULL
, NULL
, NULL
}, /* set_decode_cb */
284 {"View/Decode/---", NULL
, "---", NULL
, NULL
, NULL
},
286 #define DEC_ACTION(cs_type,c_type,string) \
287 { "View/Decode/" cs_type, NULL, N_(string), NULL, NULL, c_type }
289 {"View/---", NULL
, "---", NULL
, NULL
, NULL
},
290 {"View/MessageSource", NULL
, N_("Mess_age source"), "<control>U", NULL
, G_CALLBACK(view_source_cb
) },
291 {"View/Part", NULL
, N_("Message part"), NULL
, NULL
, NULL
},
292 {"View/Part/AsText", NULL
, N_("View as text"), "T", NULL
, G_CALLBACK(view_part_as_text_cb
) },
293 {"View/Part/Open", NULL
, N_("Open"), "L", NULL
, G_CALLBACK(open_part_cb
) },
295 {"View/Part/OpenWith", NULL
, N_("Open with..."), "O", NULL
, G_CALLBACK(open_part_with_cb
) },
298 {"View/Quotes", NULL
, N_("Quotes"), NULL
, NULL
, NULL
},
301 {"Message/Compose", NULL
, N_("Compose _new message"), "<control>M", NULL
, G_CALLBACK(compose_cb
) },
302 {"Message/---", NULL
, "---", NULL
, NULL
, NULL
},
304 {"Message/Reply", NULL
, N_("_Reply"), "<control>R", NULL
, G_CALLBACK(reply_cb
) }, /* COMPOSE_REPLY */
305 {"Message/ReplyTo", NULL
, N_("Repl_y to"), NULL
, NULL
, NULL
},
306 {"Message/ReplyTo/All", NULL
, N_("_All"), "<control><shift>R", NULL
, G_CALLBACK(reply_cb
) }, /* COMPOSE_REPLY_TO_ALL */
307 {"Message/ReplyTo/Sender", NULL
, N_("_Sender"), NULL
, NULL
, G_CALLBACK(reply_cb
) }, /* COMPOSE_REPLY_TO_SENDER */
308 {"Message/ReplyTo/List", NULL
, N_("Mailing _list"), "<control>L", NULL
, G_CALLBACK(reply_cb
) }, /* COMPOSE_REPLY_TO_LIST */
309 /* {"Message/---", NULL, "---", NULL, NULL, NULL }, */
311 {"Message/Forward", NULL
, N_("_Forward"), "<control><alt>F", NULL
, G_CALLBACK(reply_cb
) }, /* COMPOSE_FORWARD_INLINE */
312 {"Message/ForwardAtt", NULL
, N_("For_ward as attachment"), NULL
, NULL
, G_CALLBACK(reply_cb
) }, /* COMPOSE_FORWARD_AS_ATTACH */
313 {"Message/Redirect", NULL
, N_("Redirec_t"), NULL
, NULL
, G_CALLBACK(reply_cb
) }, /* COMPOSE_REDIRECT */
314 {"Message/CheckSignature", NULL
, N_("Check signature"), "C", NULL
, G_CALLBACK(check_signature_cb
) },
317 {"Tools/AddressBook", NULL
, N_("_Address book"), "<control><shift>A", NULL
, G_CALLBACK(addressbook_open_cb
) },
318 {"Tools/AddSenderToAB", NULL
, N_("Add sender to address boo_k"), NULL
, NULL
, G_CALLBACK(add_address_cb
) },
319 {"Tools/---", NULL
, "---", NULL
, NULL
, NULL
},
321 {"Tools/CreateFilterRule", NULL
, N_("_Create filter rule"), NULL
, NULL
, NULL
},
322 {"Tools/CreateFilterRule/Automatically", NULL
, N_("_Automatically"), NULL
, NULL
, G_CALLBACK(create_filter_cb
) }, /* FILTER_BY_AUTO */
323 {"Tools/CreateFilterRule/ByFrom", NULL
, N_("By _From"), NULL
, NULL
, G_CALLBACK(create_filter_cb
) }, /* FILTER_BY_FROM */
324 {"Tools/CreateFilterRule/ByTo", NULL
, N_("By _To"), NULL
, NULL
, G_CALLBACK(create_filter_cb
) }, /* FILTER_BY_TO */
325 {"Tools/CreateFilterRule/BySubject", NULL
, N_("By _Subject"), NULL
, NULL
, G_CALLBACK(create_filter_cb
) }, /* FILTER_BY_SUBJECT */
326 {"Tools/CreateFilterRule/BySender", NULL
, N_("By S_ender"), NULL
, NULL
, G_CALLBACK(create_filter_cb
) }, /* FILTER_BY_SENDER */
328 {"Tools/CreateProcessingRule", NULL
, N_("Create processing rule"), NULL
, NULL
, NULL
},
329 {"Tools/CreateProcessingRule/Automatically", NULL
, N_("_Automatically"), NULL
, NULL
, G_CALLBACK(create_processing_cb
) },
330 {"Tools/CreateProcessingRule/ByFrom", NULL
, N_("By _From"), NULL
, NULL
, G_CALLBACK(create_processing_cb
) },
331 {"Tools/CreateProcessingRule/ByTo", NULL
, N_("By _To"), NULL
, NULL
, G_CALLBACK(create_processing_cb
) },
332 {"Tools/CreateProcessingRule/BySubject", NULL
, N_("By _Subject"), NULL
, NULL
, G_CALLBACK(create_processing_cb
) },
333 {"Tools/CreateProcessingRule/BySender", NULL
, N_("By S_ender"), NULL
, NULL
, G_CALLBACK(create_processing_cb
) },
334 /* {"Tools/---", NULL, "---", NULL, NULL, NULL }, */
336 {"Tools/ListUrls", NULL
, N_("List _URLs..."), "<control><shift>U", NULL
, G_CALLBACK(open_urls_cb
) },
338 /* {"Tools/---", NULL, "---", NULL, NULL, NULL }, */
339 {"Tools/Actions", NULL
, N_("Actio_ns"), NULL
, NULL
, NULL
},
340 {"Tools/Actions/PlaceHolder", NULL
, "Placeholder", NULL
, NULL
, G_CALLBACK(messageview_nothing_cb
) },
343 {"Help/About", NULL
, N_("_About"), NULL
, NULL
, G_CALLBACK(about_cb
) },
346 static GtkToggleActionEntry msgview_toggle_entries
[] =
348 {"View/AllHeaders", NULL
, N_("Show all _headers"), "<control>H", NULL
, G_CALLBACK(show_all_header_cb
), FALSE
}, /* toggle */
349 {"View/Quotes/CollapseAll", NULL
, N_("_Collapse all"), "<control><shift>Q", NULL
, G_CALLBACK(msg_hide_quotes_cb
), FALSE
}, /* 1 toggle */
350 {"View/Quotes/Collapse2", NULL
, N_("Collapse from level _2"), NULL
, NULL
, G_CALLBACK(msg_hide_quotes_cb
), FALSE
}, /* 2 toggle */
351 {"View/Quotes/Collapse3", NULL
, N_("Collapse from level _3"), NULL
, NULL
, G_CALLBACK(msg_hide_quotes_cb
), FALSE
}, /* 3 toggle */
354 static GtkRadioActionEntry msgview_radio_enc_entries
[] =
356 ENC_ACTION(CS_AUTO
, C_AUTO
, N_("_Automatic")), /* RADIO set_charset_cb */
357 ENC_ACTION(CS_US_ASCII
, C_US_ASCII
, N_("7bit ASCII (US-ASC_II)")), /* RADIO set_charset_cb */
358 ENC_ACTION(CS_UTF_8
, C_UTF_8
, N_("Unicode (_UTF-8)")), /* RADIO set_charset_cb */
359 ENC_ACTION("Western/"CS_ISO_8859_1
, C_ISO_8859_1
, "ISO-8859-_1"), /* RADIO set_charset_cb */
360 ENC_ACTION("Western/"CS_ISO_8859_15
, C_ISO_8859_15
, "ISO-8859-15"), /* RADIO set_charset_cb */
361 ENC_ACTION("Western/"CS_WINDOWS_1252
, C_WINDOWS_1252
, "Windows-1252"), /* RADIO set_charset_cb */
362 ENC_ACTION(CS_ISO_8859_2
, C_ISO_8859_2
, N_("Central European (ISO-8859-_2)")), /* RADIO set_charset_cb */
363 ENC_ACTION("Baltic/"CS_ISO_8859_13
, C_ISO_8859_13
, "ISO-8859-13"), /* RADIO set_charset_cb */
364 ENC_ACTION("Baltic/"CS_ISO_8859_4
, C_ISO_8859_14
, "ISO-8859-_4"), /* RADIO set_charset_cb */
365 ENC_ACTION(CS_ISO_8859_7
, C_ISO_8859_7
, N_("Greek (ISO-8859-_7)")), /* RADIO set_charset_cb */
366 ENC_ACTION("Hebrew/"CS_ISO_8859_8
, C_ISO_8859_8
, "ISO-8859-_8"), /* RADIO set_charset_cb */
367 ENC_ACTION("Hebrew/"CS_WINDOWS_1255
, C_WINDOWS_1255
, "Windows-1255"), /* RADIO set_charset_cb */
368 ENC_ACTION("Arabic/"CS_ISO_8859_6
, C_ISO_8859_6
, "ISO-8859-_6"), /* RADIO set_charset_cb */
369 ENC_ACTION("Arabic/"CS_WINDOWS_1256
, C_WINDOWS_1256
, "Windows-1256"), /* RADIO set_charset_cb */
370 ENC_ACTION(CS_ISO_8859_9
, C_ISO_8859_9
, N_("Turkish (ISO-8859-_9)")), /* RADIO set_charset_cb */
371 ENC_ACTION("Cyrillic/"CS_ISO_8859_5
, C_ISO_8859_5
, "ISO-8859-_5"), /* RADIO set_charset_cb */
372 ENC_ACTION("Cyrillic/"CS_KOI8_R
, C_KOI8_R
, "KOI8-_R"), /* RADIO set_charset_cb */
373 ENC_ACTION("Cyrillic/"CS_MACCYR
, C_MACCYR
, "MAC_CYR"), /* RADIO set_charset_cb */
374 ENC_ACTION("Cyrillic/"CS_KOI8_U
, C_KOI8_U
, "KOI8-_U"), /* RADIO set_charset_cb */
375 ENC_ACTION("Cyrillic/"CS_WINDOWS_1251
, C_WINDOWS_1251
, "Windows-1251"), /* RADIO set_charset_cb */
376 ENC_ACTION("Japanese/"CS_ISO_2022_JP
, C_ISO_2022_JP
, "ISO-2022-_JP"), /* RADIO set_charset_cb */
377 ENC_ACTION("Japanese/"CS_ISO_2022_JP_2
, C_ISO_2022_JP_2
, "ISO-2022-JP-_2"), /* RADIO set_charset_cb */
378 ENC_ACTION("Japanese/"CS_EUC_JP
, C_EUC_JP
, "_EUC-JP"), /* RADIO set_charset_cb */
379 ENC_ACTION("Japanese/"CS_SHIFT_JIS
, C_SHIFT_JIS
, "_Shift-JIS"), /* RADIO set_charset_cb */
380 ENC_ACTION("Chinese/"CS_GB18030
, C_GB18030
, "_GB18030"), /* RADIO set_charset_cb */
381 ENC_ACTION("Chinese/"CS_GB2312
, C_GB2312
, "_GB2312"), /* RADIO set_charset_cb */
382 ENC_ACTION("Chinese/"CS_GBK
, C_GBK
, "GB_K"), /* RADIO set_charset_cb */
383 ENC_ACTION("Chinese/"CS_BIG5
, C_BIG5
, "_Big5-JP"), /* RADIO set_charset_cb */
384 ENC_ACTION("Chinese/"CS_EUC_TW
, C_EUC_TW
, "EUC-_TW"), /* RADIO set_charset_cb */
385 ENC_ACTION("Korean/"CS_EUC_KR
, C_EUC_KR
, "_EUC-KR"), /* RADIO set_charset_cb */
386 ENC_ACTION("Korean/"CS_ISO_2022_KR
, C_ISO_2022_KR
, "_ISO-2022-KR"), /* RADIO set_charset_cb */
387 ENC_ACTION("Thai/"CS_TIS_620
, C_TIS_620
, "_TIS-620-KR"), /* RADIO set_charset_cb */
388 ENC_ACTION("Thai/"CS_WINDOWS_874
, C_WINDOWS_874
, "_Windows-874"), /* RADIO set_charset_cb */
391 static GtkRadioActionEntry msgview_radio_dec_entries
[] =
393 DEC_ACTION("AutoDetect", 0, N_("_Auto detect")), /* set_decode_cb */
395 DEC_ACTION("8bit", ENC_8BIT
, "_8bit"),
396 DEC_ACTION("QP", ENC_QUOTED_PRINTABLE
, "_Quoted printable"),
397 DEC_ACTION("B64", ENC_BASE64
, "_Base64"),
398 DEC_ACTION("Uuencode", ENC_X_UUENCODE
, "_Uuencode"),
401 MessageView
*messageview_create(MainWindow
*mainwin
)
403 MessageView
*messageview
;
405 HeaderView
*headerview
;
407 NoticeView
*noticeview
;
409 debug_print("Creating message view...\n");
410 messageview
= g_new0(MessageView
, 1);
412 headerview
= headerview_create();
414 noticeview
= noticeview_create(mainwin
);
416 mimeview
= mimeview_create(mainwin
);
417 mimeview
->textview
= textview_create();
418 mimeview
->textview
->messageview
= messageview
;
419 mimeview
->messageview
= messageview
;
421 vbox
= gtk_box_new(GTK_ORIENTATION_VERTICAL
, 0);
422 gtk_widget_set_name(GTK_WIDGET(vbox
), "messageview");
423 gtk_box_pack_start(GTK_BOX(vbox
), GTK_WIDGET_PTR(headerview
),
425 gtk_box_pack_start(GTK_BOX(vbox
), GTK_WIDGET_PTR(noticeview
),
427 gtk_box_pack_start(GTK_BOX(vbox
),
428 GTK_WIDGET_PTR(mimeview
), TRUE
, TRUE
, 0);
429 gtk_widget_show(vbox
);
431 messageview
->vbox
= vbox
;
432 messageview
->new_window
= FALSE
;
433 messageview
->window
= NULL
;
434 messageview
->headerview
= headerview
;
435 messageview
->mimeview
= mimeview
;
436 messageview
->noticeview
= noticeview
;
437 messageview
->mainwin
= mainwin
;
439 messageview
->statusbar
= NULL
;
440 messageview
->statusbar_cid
= 0;
442 messageview
->show_full_text
= FALSE
;
443 messageview
->update_needed
= FALSE
;
445 messageview
->msginfo_update_callback_id
=
446 hooks_register_hook(MSGINFO_UPDATE_HOOKLIST
, messageview_update_msg
, (gpointer
) messageview
);
451 const GList
*messageview_get_msgview_list(void)
456 void messageview_update_actions_menu(MessageView
*msgview
)
458 /* Messages opened in a new window do not have a menu bar */
459 if (msgview
->menubar
== NULL
)
461 action_update_msgview_menu(msgview
->ui_manager
, "/Menu/Tools/Actions", msgview
);
464 static void messageview_add_toolbar(MessageView
*msgview
, GtkWidget
*window
)
466 GtkWidget
*handlebox
;
470 GtkWidget
*statusbar
= NULL
;
472 GtkActionGroup
*action_group
;
475 vbox
= gtk_box_new(GTK_ORIENTATION_VERTICAL
, 0);
476 gtk_widget_show(vbox
);
477 gtk_container_add(GTK_CONTAINER(window
), vbox
);
479 msgview
->ui_manager
= gtk_ui_manager_new();
480 action_group
= cm_menu_create_action_group_full(msgview
->ui_manager
,"Menu", msgview_entries
,
481 G_N_ELEMENTS(msgview_entries
), (gpointer
)msgview
);
482 gtk_action_group_add_toggle_actions(action_group
, msgview_toggle_entries
,
483 G_N_ELEMENTS(msgview_toggle_entries
), (gpointer
)msgview
);
484 gtk_action_group_add_radio_actions(action_group
, msgview_radio_enc_entries
,
485 G_N_ELEMENTS(msgview_radio_enc_entries
), C_AUTO
, G_CALLBACK(set_charset_cb
), (gpointer
)msgview
);
486 gtk_action_group_add_radio_actions(action_group
, msgview_radio_dec_entries
,
487 G_N_ELEMENTS(msgview_radio_dec_entries
), C_AUTO
, G_CALLBACK(set_decode_cb
), (gpointer
)msgview
);
489 MENUITEM_ADDUI_MANAGER(msgview
->ui_manager
, "/", "Menu", NULL
, GTK_UI_MANAGER_MENUBAR
)
490 MENUITEM_ADDUI_MANAGER(msgview
->ui_manager
, "/Menu", "File", "File", GTK_UI_MANAGER_MENU
)
491 MENUITEM_ADDUI_MANAGER(msgview
->ui_manager
, "/Menu", "Edit", "Edit", GTK_UI_MANAGER_MENU
)
492 MENUITEM_ADDUI_MANAGER(msgview
->ui_manager
, "/Menu", "View", "View", GTK_UI_MANAGER_MENU
)
493 MENUITEM_ADDUI_MANAGER(msgview
->ui_manager
, "/Menu", "Message", "Message", GTK_UI_MANAGER_MENU
)
494 MENUITEM_ADDUI_MANAGER(msgview
->ui_manager
, "/Menu", "Tools", "Tools", GTK_UI_MANAGER_MENU
)
495 MENUITEM_ADDUI_MANAGER(msgview
->ui_manager
, "/Menu", "Help", "Help", GTK_UI_MANAGER_MENU
)
498 MENUITEM_ADDUI_MANAGER(msgview
->ui_manager
, "/Menu/File", "SaveAs", "File/SaveAs", GTK_UI_MANAGER_MENUITEM
)
499 MENUITEM_ADDUI_MANAGER(msgview
->ui_manager
, "/Menu/File", "SavePartAs", "File/SavePartAs", GTK_UI_MANAGER_MENUITEM
)
500 MENUITEM_ADDUI_MANAGER(msgview
->ui_manager
, "/Menu/File", "Separator1", "File/---", GTK_UI_MANAGER_SEPARATOR
)
501 MENUITEM_ADDUI_MANAGER(msgview
->ui_manager
, "/Menu/File", "PageSetup", "File/PageSetup", GTK_UI_MANAGER_MENUITEM
)
502 MENUITEM_ADDUI_MANAGER(msgview
->ui_manager
, "/Menu/File", "Print", "File/Print", GTK_UI_MANAGER_MENUITEM
)
503 MENUITEM_ADDUI_MANAGER(msgview
->ui_manager
, "/Menu/File", "Separator2", "File/---", GTK_UI_MANAGER_SEPARATOR
)
504 MENUITEM_ADDUI_MANAGER(msgview
->ui_manager
, "/Menu/File", "Close", "File/Close", GTK_UI_MANAGER_MENUITEM
)
507 MENUITEM_ADDUI_MANAGER(msgview
->ui_manager
, "/Menu/Edit", "Copy", "Edit/Copy", GTK_UI_MANAGER_MENUITEM
)
508 MENUITEM_ADDUI_MANAGER(msgview
->ui_manager
, "/Menu/Edit", "SelectAll", "Edit/SelectAll", GTK_UI_MANAGER_MENUITEM
)
509 MENUITEM_ADDUI_MANAGER(msgview
->ui_manager
, "/Menu/Edit", "Separator1", "Edit/---", GTK_UI_MANAGER_SEPARATOR
)
510 MENUITEM_ADDUI_MANAGER(msgview
->ui_manager
, "/Menu/Edit", "Find", "Edit/Find", GTK_UI_MANAGER_MENUITEM
)
513 MENUITEM_ADDUI_MANAGER(msgview
->ui_manager
, "/Menu/View", "Goto", "View/Goto", GTK_UI_MANAGER_MENU
)
514 MENUITEM_ADDUI_MANAGER(msgview
->ui_manager
, "/Menu/View/Goto", "Prev", "View/Goto/Prev", GTK_UI_MANAGER_MENUITEM
)
515 MENUITEM_ADDUI_MANAGER(msgview
->ui_manager
, "/Menu/View/Goto", "Next", "View/Goto/Next", GTK_UI_MANAGER_MENUITEM
)
516 MENUITEM_ADDUI_MANAGER(msgview
->ui_manager
, "/Menu/View/Goto", "Separator1", "View/Goto/---", GTK_UI_MANAGER_SEPARATOR
)
517 MENUITEM_ADDUI_MANAGER(msgview
->ui_manager
, "/Menu/View/Goto", "PrevUnread", "View/Goto/PrevUnread", GTK_UI_MANAGER_MENUITEM
)
518 MENUITEM_ADDUI_MANAGER(msgview
->ui_manager
, "/Menu/View/Goto", "NextUnread", "View/Goto/NextUnread", GTK_UI_MANAGER_MENUITEM
)
519 MENUITEM_ADDUI_MANAGER(msgview
->ui_manager
, "/Menu/View/Goto", "Separator2", "View/Goto/---", GTK_UI_MANAGER_SEPARATOR
)
520 MENUITEM_ADDUI_MANAGER(msgview
->ui_manager
, "/Menu/View/Goto", "PrevNew", "View/Goto/PrevNew", GTK_UI_MANAGER_MENUITEM
)
521 MENUITEM_ADDUI_MANAGER(msgview
->ui_manager
, "/Menu/View/Goto", "NextNew", "View/Goto/NextNew", GTK_UI_MANAGER_MENUITEM
)
522 MENUITEM_ADDUI_MANAGER(msgview
->ui_manager
, "/Menu/View/Goto", "Separator3", "View/Goto/---", GTK_UI_MANAGER_SEPARATOR
)
523 MENUITEM_ADDUI_MANAGER(msgview
->ui_manager
, "/Menu/View/Goto", "PrevMarked", "View/Goto/PrevMarked", GTK_UI_MANAGER_MENUITEM
)
524 MENUITEM_ADDUI_MANAGER(msgview
->ui_manager
, "/Menu/View/Goto", "NextMarked", "View/Goto/NextMarked", GTK_UI_MANAGER_MENUITEM
)
525 MENUITEM_ADDUI_MANAGER(msgview
->ui_manager
, "/Menu/View/Goto", "Separator4", "View/Goto/---", GTK_UI_MANAGER_SEPARATOR
)
526 MENUITEM_ADDUI_MANAGER(msgview
->ui_manager
, "/Menu/View/Goto", "PrevLabeled", "View/Goto/PrevLabeled", GTK_UI_MANAGER_MENUITEM
)
527 MENUITEM_ADDUI_MANAGER(msgview
->ui_manager
, "/Menu/View/Goto", "NextLabeled", "View/Goto/NextLabeled", GTK_UI_MANAGER_MENUITEM
)
528 MENUITEM_ADDUI_MANAGER(msgview
->ui_manager
, "/Menu/View/Goto", "Separator5", "View/Goto/---", GTK_UI_MANAGER_SEPARATOR
)
529 MENUITEM_ADDUI_MANAGER(msgview
->ui_manager
, "/Menu/View/Goto", "PrevHistory", "View/Goto/PrevHistory", GTK_UI_MANAGER_MENUITEM
)
530 MENUITEM_ADDUI_MANAGER(msgview
->ui_manager
, "/Menu/View/Goto", "NextHistory", "View/Goto/NextHistory", GTK_UI_MANAGER_MENUITEM
)
531 MENUITEM_ADDUI_MANAGER(msgview
->ui_manager
, "/Menu/View/Goto", "Separator6", "View/Goto/---", GTK_UI_MANAGER_SEPARATOR
)
532 MENUITEM_ADDUI_MANAGER(msgview
->ui_manager
, "/Menu/View/Goto", "ParentMessage", "View/Goto/ParentMessage", GTK_UI_MANAGER_MENUITEM
)
533 MENUITEM_ADDUI_MANAGER(msgview
->ui_manager
, "/Menu/View/Goto", "Separator7", "View/Goto/---", GTK_UI_MANAGER_SEPARATOR
)
534 MENUITEM_ADDUI_MANAGER(msgview
->ui_manager
, "/Menu/View/Goto", "NextUnreadFolder", "View/Goto/NextUnreadFolder", GTK_UI_MANAGER_MENUITEM
)
535 MENUITEM_ADDUI_MANAGER(msgview
->ui_manager
, "/Menu/View/Goto", "Folder", "View/Goto/Folder", GTK_UI_MANAGER_MENUITEM
)
536 MENUITEM_ADDUI_MANAGER(msgview
->ui_manager
, "/Menu/View/Goto", "Separator8", "View/Goto/---", GTK_UI_MANAGER_SEPARATOR
)
537 MENUITEM_ADDUI_MANAGER(msgview
->ui_manager
, "/Menu/View/Goto", "NextPart", "View/Goto/NextPart", GTK_UI_MANAGER_MENUITEM
)
538 MENUITEM_ADDUI_MANAGER(msgview
->ui_manager
, "/Menu/View/Goto", "PrevPart", "View/Goto/PrevPart", GTK_UI_MANAGER_MENUITEM
)
540 MENUITEM_ADDUI_MANAGER(msgview
->ui_manager
, "/Menu/View", "Scroll", "View/Scroll", GTK_UI_MANAGER_MENU
)
541 MENUITEM_ADDUI_MANAGER(msgview
->ui_manager
, "/Menu/View/Scroll", "PrevLine", "View/Scroll/PrevLine", GTK_UI_MANAGER_MENUITEM
)
542 MENUITEM_ADDUI_MANAGER(msgview
->ui_manager
, "/Menu/View/Scroll", "NextLine", "View/Scroll/NextLine", GTK_UI_MANAGER_MENUITEM
)
543 MENUITEM_ADDUI_MANAGER(msgview
->ui_manager
, "/Menu/View/Scroll", "PrevPage", "View/Scroll/PrevPage", GTK_UI_MANAGER_MENUITEM
)
544 MENUITEM_ADDUI_MANAGER(msgview
->ui_manager
, "/Menu/View/Scroll", "NextPage", "View/Scroll/NextPage", GTK_UI_MANAGER_MENUITEM
)
546 MENUITEM_ADDUI_MANAGER(msgview
->ui_manager
, "/Menu/View", "Separator1", "View/---", GTK_UI_MANAGER_SEPARATOR
)
548 MENUITEM_ADDUI_MANAGER(msgview
->ui_manager
, "/Menu/View", "Encoding", "View/Encoding", GTK_UI_MANAGER_MENU
)
549 MENUITEM_ADDUI_MANAGER(msgview
->ui_manager
, "/Menu/View/Encoding", CS_AUTO
, "View/Encoding/"CS_AUTO
, GTK_UI_MANAGER_MENUITEM
)
550 MENUITEM_ADDUI_MANAGER(msgview
->ui_manager
, "/Menu/View/Encoding", "Separator1", "View/Encoding/---", GTK_UI_MANAGER_SEPARATOR
)
551 MENUITEM_ADDUI_MANAGER(msgview
->ui_manager
, "/Menu/View/Encoding", CS_US_ASCII
, "View/Encoding/"CS_US_ASCII
, GTK_UI_MANAGER_MENUITEM
)
552 MENUITEM_ADDUI_MANAGER(msgview
->ui_manager
, "/Menu/View/Encoding", CS_UTF_8
, "View/Encoding/"CS_UTF_8
, GTK_UI_MANAGER_MENUITEM
)
553 MENUITEM_ADDUI_MANAGER(msgview
->ui_manager
, "/Menu/View/Encoding", "Separator2", "View/Encoding/---", GTK_UI_MANAGER_SEPARATOR
)
555 MENUITEM_ADDUI_MANAGER(msgview
->ui_manager
, "/Menu/View/Encoding", "Western", "View/Encoding/Western", GTK_UI_MANAGER_MENU
)
556 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
)
557 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
)
558 MENUITEM_ADDUI_MANAGER(msgview
->ui_manager
, "/Menu/View/Encoding/Western", CS_WINDOWS_1252
, "View/Encoding/Western/"CS_WINDOWS_1252
, GTK_UI_MANAGER_MENUITEM
)
560 MENUITEM_ADDUI_MANAGER(msgview
->ui_manager
, "/Menu/View/Encoding", CS_ISO_8859_2
, "View/Encoding/"CS_ISO_8859_2
, GTK_UI_MANAGER_MENUITEM
)
562 MENUITEM_ADDUI_MANAGER(msgview
->ui_manager
, "/Menu/View/Encoding", "Baltic", "View/Encoding/Baltic", GTK_UI_MANAGER_MENU
)
563 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
)
564 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
)
566 MENUITEM_ADDUI_MANAGER(msgview
->ui_manager
, "/Menu/View/Encoding", CS_ISO_8859_7
, "View/Encoding/"CS_ISO_8859_7
, GTK_UI_MANAGER_MENUITEM
)
568 MENUITEM_ADDUI_MANAGER(msgview
->ui_manager
, "/Menu/View/Encoding", "Hebrew", "View/Encoding/Hebrew", GTK_UI_MANAGER_MENU
)
569 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
)
570 MENUITEM_ADDUI_MANAGER(msgview
->ui_manager
, "/Menu/View/Encoding/Hebrew", CS_WINDOWS_1255
, "View/Encoding/Hebrew/"CS_WINDOWS_1255
, GTK_UI_MANAGER_MENUITEM
)
572 MENUITEM_ADDUI_MANAGER(msgview
->ui_manager
, "/Menu/View/Encoding", "Arabic", "View/Encoding/Arabic", GTK_UI_MANAGER_MENU
)
573 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
)
574 MENUITEM_ADDUI_MANAGER(msgview
->ui_manager
, "/Menu/View/Encoding/Arabic", CS_WINDOWS_1256
, "View/Encoding/Arabic/"CS_WINDOWS_1256
, GTK_UI_MANAGER_MENUITEM
)
576 MENUITEM_ADDUI_MANAGER(msgview
->ui_manager
, "/Menu/View/Encoding", CS_ISO_8859_9
, "View/Encoding/"CS_ISO_8859_9
, GTK_UI_MANAGER_MENUITEM
)
578 MENUITEM_ADDUI_MANAGER(msgview
->ui_manager
, "/Menu/View/Encoding", "Cyrillic", "View/Encoding/Cyrillic", GTK_UI_MANAGER_MENU
)
579 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
)
580 MENUITEM_ADDUI_MANAGER(msgview
->ui_manager
, "/Menu/View/Encoding/Cyrillic", CS_KOI8_R
, "View/Encoding/Cyrillic/"CS_KOI8_R
, GTK_UI_MANAGER_MENUITEM
)
581 MENUITEM_ADDUI_MANAGER(msgview
->ui_manager
, "/Menu/View/Encoding/Cyrillic", CS_MACCYR
, "View/Encoding/Cyrillic/"CS_MACCYR
, GTK_UI_MANAGER_MENUITEM
)
582 MENUITEM_ADDUI_MANAGER(msgview
->ui_manager
, "/Menu/View/Encoding/Cyrillic", CS_KOI8_U
, "View/Encoding/Cyrillic/"CS_KOI8_U
, GTK_UI_MANAGER_MENUITEM
)
583 MENUITEM_ADDUI_MANAGER(msgview
->ui_manager
, "/Menu/View/Encoding/Cyrillic", CS_WINDOWS_1251
, "View/Encoding/Cyrillic/"CS_WINDOWS_1251
, GTK_UI_MANAGER_MENUITEM
)
585 MENUITEM_ADDUI_MANAGER(msgview
->ui_manager
, "/Menu/View/Encoding", "Japanese", "View/Encoding/Japanese", GTK_UI_MANAGER_MENU
)
586 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
)
587 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
)
588 MENUITEM_ADDUI_MANAGER(msgview
->ui_manager
, "/Menu/View/Encoding/Japanese", CS_EUC_JP
, "View/Encoding/Japanese/"CS_EUC_JP
, GTK_UI_MANAGER_MENUITEM
)
589 MENUITEM_ADDUI_MANAGER(msgview
->ui_manager
, "/Menu/View/Encoding/Japanese", CS_SHIFT_JIS
, "View/Encoding/Japanese/"CS_SHIFT_JIS
, GTK_UI_MANAGER_MENUITEM
)
591 MENUITEM_ADDUI_MANAGER(msgview
->ui_manager
, "/Menu/View/Encoding", "Chinese", "View/Encoding/Chinese", GTK_UI_MANAGER_MENU
)
592 MENUITEM_ADDUI_MANAGER(msgview
->ui_manager
, "/Menu/View/Encoding/Chinese", CS_GB18030
, "View/Encoding/Chinese/"CS_GB18030
, GTK_UI_MANAGER_MENUITEM
)
593 MENUITEM_ADDUI_MANAGER(msgview
->ui_manager
, "/Menu/View/Encoding/Chinese", CS_GB2312
, "View/Encoding/Chinese/"CS_GB2312
, GTK_UI_MANAGER_MENUITEM
)
594 MENUITEM_ADDUI_MANAGER(msgview
->ui_manager
, "/Menu/View/Encoding/Chinese", CS_GBK
, "View/Encoding/Chinese/"CS_GBK
, GTK_UI_MANAGER_MENUITEM
)
595 MENUITEM_ADDUI_MANAGER(msgview
->ui_manager
, "/Menu/View/Encoding/Chinese", CS_BIG5
, "View/Encoding/Chinese/"CS_BIG5
, GTK_UI_MANAGER_MENUITEM
)
596 MENUITEM_ADDUI_MANAGER(msgview
->ui_manager
, "/Menu/View/Encoding/Chinese", CS_EUC_TW
, "View/Encoding/Chinese/"CS_EUC_TW
, GTK_UI_MANAGER_MENUITEM
)
598 MENUITEM_ADDUI_MANAGER(msgview
->ui_manager
, "/Menu/View/Encoding", "Korean", "View/Encoding/Korean", GTK_UI_MANAGER_MENU
)
599 MENUITEM_ADDUI_MANAGER(msgview
->ui_manager
, "/Menu/View/Encoding/Korean", CS_EUC_KR
, "View/Encoding/Korean/"CS_EUC_KR
, GTK_UI_MANAGER_MENUITEM
)
600 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
)
602 MENUITEM_ADDUI_MANAGER(msgview
->ui_manager
, "/Menu/View/Encoding", "Thai", "View/Encoding/Thai", GTK_UI_MANAGER_MENU
)
603 MENUITEM_ADDUI_MANAGER(msgview
->ui_manager
, "/Menu/View/Encoding/Thai", CS_TIS_620
, "View/Encoding/Thai/"CS_TIS_620
, GTK_UI_MANAGER_MENUITEM
)
604 MENUITEM_ADDUI_MANAGER(msgview
->ui_manager
, "/Menu/View/Encoding/Thai", CS_WINDOWS_874
, "View/Encoding/Thai/"CS_WINDOWS_874
, GTK_UI_MANAGER_MENUITEM
)
606 MENUITEM_ADDUI_MANAGER(msgview
->ui_manager
, "/Menu/View", "Decode", "View/Decode", GTK_UI_MANAGER_MENU
)
607 MENUITEM_ADDUI_MANAGER(msgview
->ui_manager
, "/Menu/View/Decode", "AutoDetect", "View/Decode/AutoDetect", GTK_UI_MANAGER_MENUITEM
)
608 MENUITEM_ADDUI_MANAGER(msgview
->ui_manager
, "/Menu/View/Decode", "Separator1", "View/Decode/---", GTK_UI_MANAGER_SEPARATOR
)
609 MENUITEM_ADDUI_MANAGER(msgview
->ui_manager
, "/Menu/View/Decode", "8bit", "View/Decode/8bit", GTK_UI_MANAGER_MENUITEM
)
610 MENUITEM_ADDUI_MANAGER(msgview
->ui_manager
, "/Menu/View/Decode", "QP", "View/Decode/QP", GTK_UI_MANAGER_MENUITEM
)
611 MENUITEM_ADDUI_MANAGER(msgview
->ui_manager
, "/Menu/View/Decode", "B64", "View/Decode/B64", GTK_UI_MANAGER_MENUITEM
)
612 MENUITEM_ADDUI_MANAGER(msgview
->ui_manager
, "/Menu/View/Decode", "Uuencode", "View/Decode/Uuencode", GTK_UI_MANAGER_MENUITEM
)
614 MENUITEM_ADDUI_MANAGER(msgview
->ui_manager
, "/Menu/View", "Separator2", "View/---", GTK_UI_MANAGER_SEPARATOR
)
616 MENUITEM_ADDUI_MANAGER(msgview
->ui_manager
, "/Menu/View", "MessageSource", "View/MessageSource", GTK_UI_MANAGER_MENUITEM
)
617 MENUITEM_ADDUI_MANAGER(msgview
->ui_manager
, "/Menu/View", "AllHeaders", "View/AllHeaders", GTK_UI_MANAGER_MENUITEM
)
618 MENUITEM_ADDUI_MANAGER(msgview
->ui_manager
, "/Menu/View", "Quotes", "View/Quotes", GTK_UI_MANAGER_MENU
)
619 MENUITEM_ADDUI_MANAGER(msgview
->ui_manager
, "/Menu/View/Quotes", "CollapseAll", "View/Quotes/CollapseAll", GTK_UI_MANAGER_MENUITEM
)
620 MENUITEM_ADDUI_MANAGER(msgview
->ui_manager
, "/Menu/View/Quotes", "Collapse2", "View/Quotes/Collapse2", GTK_UI_MANAGER_MENUITEM
)
621 MENUITEM_ADDUI_MANAGER(msgview
->ui_manager
, "/Menu/View/Quotes", "Collapse3", "View/Quotes/Collapse3", GTK_UI_MANAGER_MENUITEM
)
622 MENUITEM_ADDUI_MANAGER(msgview
->ui_manager
, "/Menu/View", "Part", "View/Part", GTK_UI_MANAGER_MENU
)
623 MENUITEM_ADDUI_MANAGER(msgview
->ui_manager
, "/Menu/View/Part", "AsText", "View/Part/AsText", GTK_UI_MANAGER_MENUITEM
)
624 MENUITEM_ADDUI_MANAGER(msgview
->ui_manager
, "/Menu/View/Part", "Open", "View/Part/Open", GTK_UI_MANAGER_MENUITEM
)
626 MENUITEM_ADDUI_MANAGER(msgview
->ui_manager
, "/Menu/View/Part", "OpenWith", "View/Part/OpenWith", GTK_UI_MANAGER_MENUITEM
)
630 MENUITEM_ADDUI_MANAGER(msgview
->ui_manager
, "/Menu/Message", "Compose", "Message/Compose", GTK_UI_MANAGER_MENUITEM
)
631 MENUITEM_ADDUI_MANAGER(msgview
->ui_manager
, "/Menu/Message", "Separator1", "Message/---", GTK_UI_MANAGER_SEPARATOR
)
632 MENUITEM_ADDUI_MANAGER(msgview
->ui_manager
, "/Menu/Message", "Reply", "Message/Reply", GTK_UI_MANAGER_MENUITEM
)
633 MENUITEM_ADDUI_MANAGER(msgview
->ui_manager
, "/Menu/Message", "ReplyTo", "Message/ReplyTo", GTK_UI_MANAGER_MENU
)
634 MENUITEM_ADDUI_MANAGER(msgview
->ui_manager
, "/Menu/Message/ReplyTo", "All", "Message/ReplyTo/All", GTK_UI_MANAGER_MENUITEM
)
635 MENUITEM_ADDUI_MANAGER(msgview
->ui_manager
, "/Menu/Message/ReplyTo", "Sender", "Message/ReplyTo/Sender", GTK_UI_MANAGER_MENUITEM
)
636 MENUITEM_ADDUI_MANAGER(msgview
->ui_manager
, "/Menu/Message/ReplyTo", "List", "Message/ReplyTo/List", GTK_UI_MANAGER_MENUITEM
)
637 MENUITEM_ADDUI_MANAGER(msgview
->ui_manager
, "/Menu/Message", "Separator2", "Message/---", GTK_UI_MANAGER_SEPARATOR
)
638 MENUITEM_ADDUI_MANAGER(msgview
->ui_manager
, "/Menu/Message", "Forward", "Message/Forward", GTK_UI_MANAGER_MENUITEM
)
639 MENUITEM_ADDUI_MANAGER(msgview
->ui_manager
, "/Menu/Message", "ForwardAtt", "Message/ForwardAtt", GTK_UI_MANAGER_MENUITEM
)
640 MENUITEM_ADDUI_MANAGER(msgview
->ui_manager
, "/Menu/Message", "Redirect", "Message/Redirect", GTK_UI_MANAGER_MENUITEM
)
641 MENUITEM_ADDUI_MANAGER(msgview
->ui_manager
, "/Menu/Message", "CheckSignature", "Message/CheckSignature", GTK_UI_MANAGER_MENUITEM
)
644 MENUITEM_ADDUI_MANAGER(msgview
->ui_manager
, "/Menu/Tools", "AddressBook", "Tools/AddressBook", GTK_UI_MANAGER_MENUITEM
)
645 MENUITEM_ADDUI_MANAGER(msgview
->ui_manager
, "/Menu/Tools", "AddSenderToAB", "Tools/AddSenderToAB", GTK_UI_MANAGER_MENUITEM
)
646 MENUITEM_ADDUI_MANAGER(msgview
->ui_manager
, "/Menu/Tools", "Separator1", "Tools/---", GTK_UI_MANAGER_SEPARATOR
)
648 MENUITEM_ADDUI_MANAGER(msgview
->ui_manager
, "/Menu/Tools", "CreateFilterRule", "Tools/CreateFilterRule", GTK_UI_MANAGER_MENU
)
649 MENUITEM_ADDUI_MANAGER(msgview
->ui_manager
, "/Menu/Tools/CreateFilterRule", "Automatically", "Tools/CreateFilterRule/Automatically", GTK_UI_MANAGER_MENUITEM
)
650 MENUITEM_ADDUI_MANAGER(msgview
->ui_manager
, "/Menu/Tools/CreateFilterRule", "ByFrom", "Tools/CreateFilterRule/ByFrom", GTK_UI_MANAGER_MENUITEM
)
651 MENUITEM_ADDUI_MANAGER(msgview
->ui_manager
, "/Menu/Tools/CreateFilterRule", "ByTo", "Tools/CreateFilterRule/ByTo", GTK_UI_MANAGER_MENUITEM
)
652 MENUITEM_ADDUI_MANAGER(msgview
->ui_manager
, "/Menu/Tools/CreateFilterRule", "BySubject", "Tools/CreateFilterRule/BySubject", GTK_UI_MANAGER_MENUITEM
)
653 MENUITEM_ADDUI_MANAGER(msgview
->ui_manager
, "/Menu/Tools/CreateFilterRule", "BySender", "Tools/CreateFilterRule/BySender", GTK_UI_MANAGER_MENUITEM
)
655 MENUITEM_ADDUI_MANAGER(msgview
->ui_manager
, "/Menu/Tools", "CreateProcessingRule", "Tools/CreateProcessingRule", GTK_UI_MANAGER_MENU
)
656 MENUITEM_ADDUI_MANAGER(msgview
->ui_manager
, "/Menu/Tools/CreateProcessingRule", "Automatically", "Tools/CreateProcessingRule/Automatically", GTK_UI_MANAGER_MENUITEM
)
657 MENUITEM_ADDUI_MANAGER(msgview
->ui_manager
, "/Menu/Tools/CreateProcessingRule", "ByFrom", "Tools/CreateProcessingRule/ByFrom", GTK_UI_MANAGER_MENUITEM
)
658 MENUITEM_ADDUI_MANAGER(msgview
->ui_manager
, "/Menu/Tools/CreateProcessingRule", "ByTo", "Tools/CreateProcessingRule/ByTo", GTK_UI_MANAGER_MENUITEM
)
659 MENUITEM_ADDUI_MANAGER(msgview
->ui_manager
, "/Menu/Tools/CreateProcessingRule", "BySubject", "Tools/CreateProcessingRule/BySubject", GTK_UI_MANAGER_MENUITEM
)
660 MENUITEM_ADDUI_MANAGER(msgview
->ui_manager
, "/Menu/Tools/CreateProcessingRule", "BySender", "Tools/CreateProcessingRule/BySender", GTK_UI_MANAGER_MENUITEM
)
661 MENUITEM_ADDUI_MANAGER(msgview
->ui_manager
, "/Menu/Tools", "Separator2", "Tools/---", GTK_UI_MANAGER_SEPARATOR
)
663 MENUITEM_ADDUI_MANAGER(msgview
->ui_manager
, "/Menu/Tools", "ListUrls", "Tools/ListUrls", GTK_UI_MANAGER_MENUITEM
)
664 MENUITEM_ADDUI_MANAGER(msgview
->ui_manager
, "/Menu/Tools", "Separator3", "Tools/---", GTK_UI_MANAGER_SEPARATOR
)
666 MENUITEM_ADDUI_MANAGER(msgview
->ui_manager
, "/Menu/Tools", "Actions", "Tools/Actions", GTK_UI_MANAGER_MENU
)
667 MENUITEM_ADDUI_MANAGER(msgview
->ui_manager
, "/Menu/Tools/Actions", "PlaceHolder", "Tools/Actions/PlaceHolder", GTK_UI_MANAGER_MENUITEM
)
670 MENUITEM_ADDUI_MANAGER(msgview
->ui_manager
, "/Menu/Help", "About", "Help/About", GTK_UI_MANAGER_MENUITEM
)
672 menubar
= gtk_ui_manager_get_widget(msgview
->ui_manager
, "/Menu");
673 gtk_widget_show_all(menubar
);
674 gtk_window_add_accel_group(GTK_WINDOW(window
), gtk_ui_manager_get_accel_group(msgview
->ui_manager
));
676 gtk_box_pack_start(GTK_BOX(vbox
), menubar
, FALSE
, TRUE
, 0);
678 cm_toggle_menu_set_active_full(msgview
->ui_manager
, "Menu/View/AllHeaders",
679 prefs_common
.show_all_headers
);
681 handlebox
= gtk_box_new(GTK_ORIENTATION_HORIZONTAL
, 0);
682 gtk_box_pack_start(GTK_BOX(vbox
), handlebox
, FALSE
, FALSE
, 0);
683 gtk_widget_realize(handlebox
);
684 msgview
->toolbar
= toolbar_create(TOOLBAR_MSGVIEW
, handlebox
,
687 statusbar
= gtk_statusbar_new();
688 gtk_widget_show(statusbar
);
689 gtk_box_pack_end(GTK_BOX(vbox
), statusbar
, FALSE
, FALSE
, 0);
690 msgview
->statusbar
= statusbar
;
691 msgview
->statusbar_cid
= gtk_statusbar_get_context_id
692 (GTK_STATUSBAR(statusbar
), "Message View");
694 msgview
->statusbar
= NULL
;
695 msgview
->statusbar_cid
= 0;
699 msgview
->handlebox
= handlebox
;
700 msgview
->menubar
= menubar
;
702 gtk_container_add(GTK_CONTAINER(vbox
),
703 GTK_WIDGET_PTR(msgview
));
705 messageview_update_actions_menu(msgview
);
707 msgview_list
= g_list_append(msgview_list
, msgview
);
710 static MessageView
*messageview_create_with_new_window_visible(MainWindow
*mainwin
, gboolean show
)
712 MessageView
*msgview
;
714 static GdkGeometry geometry
;
716 window
= gtkut_window_new(GTK_WINDOW_TOPLEVEL
, "messageview");
717 gtk_window_set_title(GTK_WINDOW(window
), _("Claws Mail - Message View"));
718 gtk_window_set_resizable(GTK_WINDOW(window
), TRUE
);
720 gtk_window_set_default_size(GTK_WINDOW(window
), prefs_common
.msgwin_width
,
721 prefs_common
.msgwin_height
);
723 if (!geometry
.min_height
) {
724 geometry
.min_width
= 320;
725 geometry
.min_height
= 200;
727 gtk_window_set_geometry_hints(GTK_WINDOW(window
), NULL
, &geometry
,
731 gtk_window_move(GTK_WINDOW(window
), 48, 48);
734 msgview
= messageview_create(mainwin
);
736 g_signal_connect(G_OBJECT(window
), "size_allocate",
737 G_CALLBACK(messageview_size_allocate_cb
),
739 g_signal_connect(G_OBJECT(window
), "delete_event",
740 G_CALLBACK(messageview_delete_cb
), msgview
);
741 g_signal_connect(G_OBJECT(window
), "key_press_event",
742 G_CALLBACK(key_pressed
), msgview
);
743 messageview_add_toolbar(msgview
, window
);
746 gtk_widget_show(window
);
748 gtk_widget_realize(window
);
751 msgview
->new_window
= TRUE
;
752 msgview
->window
= window
;
753 msgview
->visible
= TRUE
;
755 toolbar_set_style(msgview
->toolbar
->toolbar
, msgview
->handlebox
,
756 prefs_common
.toolbar_style
);
757 messageview_init(msgview
);
761 gtk_widget_grab_focus(msgview
->mimeview
->textview
->text
);
767 MessageView
*messageview_create_with_new_window(MainWindow
*mainwin
)
769 return messageview_create_with_new_window_visible(mainwin
, TRUE
);
771 void messageview_init(MessageView
*messageview
)
773 headerview_init(messageview
->headerview
);
774 mimeview_init(messageview
->mimeview
);
775 /*messageview_set_font(messageview);*/
777 noticeview_hide(messageview
->noticeview
);
780 static void notification_convert_header(gchar
**dest
,
786 cm_return_if_fail(src_
!= NULL
);
788 if (header_len
< 1) {
789 *dest
= g_strdup("");
793 Xstrndup_a(src
, src_
, strlen(src_
), return);
797 if (is_ascii_str(src
)) {
798 *dest
= g_strdup(src
);
801 *dest
= g_malloc(BUFFSIZE
);
802 conv_encode_header(*dest
, BUFFSIZE
, src
, header_len
, FALSE
);
806 static gint
disposition_notification_send(MsgInfo
*msginfo
)
809 gchar tmp
[MAXPATHLEN
+ 1];
812 PrefsAccount
*account
= NULL
;
815 FolderItem
*queue
, *outbox
;
821 gboolean queued_removed
= FALSE
;
822 gchar
*boundary
= NULL
;
823 gchar buf_date
[RFC822_DATE_BUFFSIZE
];
825 gchar
*orig_to
= NULL
;
826 gchar
*enc_sub
= NULL
;
828 if (!msginfo
->extradata
)
830 if (!msginfo
->extradata
->returnreceiptto
&&
831 !msginfo
->extradata
->dispositionnotificationto
)
834 /* RFC2298: Test for Return-Path */
835 if (msginfo
->extradata
->dispositionnotificationto
)
836 to
= msginfo
->extradata
->dispositionnotificationto
;
838 to
= msginfo
->extradata
->returnreceiptto
;
840 ok
= procheader_get_header_from_msginfo(msginfo
, &buf
, "Return-Path:");
842 gchar
*to_addr
= g_strdup(to
);
843 extract_address(to_addr
);
844 extract_address(buf
);
845 ok
= strcasecmp(to_addr
, buf
);
848 buf
= g_strdup(_("<No Return-Path found>"));
854 message
= g_markup_printf_escaped(
855 _("The notification address to which the return receipt is\n"
856 "to be sent does not correspond to the return path:\n"
857 "Notification address: %s\n"
859 "It is advised to not send the return receipt."),
861 val
= alertpanel_full(_("Warning"), message
,
862 NULL
, _("_Don't Send"), NULL
, _("_Send"),
863 NULL
, NULL
, ALERTFOCUS_FIRST
, FALSE
,
864 NULL
, ALERT_WARNING
);
866 if (val
!= G_ALERTALTERNATE
) {
874 ac_list
= account_find_all_from_address(NULL
, msginfo
->to
);
875 ac_list
= account_find_all_from_address(ac_list
, msginfo
->cc
);
877 if (ac_list
== NULL
) {
878 ac_list
= account_find_all();
879 if ((account
= select_account_from_list(ac_list
, FALSE
)) == NULL
)
881 } else if (g_list_length(ac_list
) > 1) {
882 if ((account
= select_account_from_list(ac_list
, TRUE
)) == NULL
)
884 } else if (ac_list
!= NULL
)
885 account
= (PrefsAccount
*) ac_list
->data
;
886 g_list_free(ac_list
);
889 account
= account_get_default();
890 if (!account
|| account
->protocol
== A_NNTP
) {
891 alertpanel_error(_("Account for sending mail is not specified.\n"
892 "Please select a mail account before sending."));
896 /* write to temporary file */
897 g_snprintf(tmp
, sizeof(tmp
), "%s%ctmpmsg%p",
898 get_rc_dir(), G_DIR_SEPARATOR
, msginfo
);
900 if ((fp
= claws_fopen(tmp
, "wb")) == NULL
) {
901 FILE_OP_ERROR(tmp
, "claws_fopen");
905 /* chmod for security */
906 if (change_file_mode_rw(fp
, tmp
) < 0) {
907 FILE_OP_ERROR(tmp
, "chmod");
908 g_warning("can't change file mode");
913 extract_address(addr
);
916 /* write queue headers */
917 ok
= fprintf(fp
, "AF:\n"
932 account
->smtp_server
?account
->smtp_server
:"",
939 /* check whether we need to save the message */
940 outbox
= account_get_special_folder(account
, F_OUTBOX
);
941 if (folder_get_default_outbox() == outbox
&& !prefs_common
.savemsg
)
944 path
= folder_item_get_identifier(outbox
);
945 ok
= fprintf(fp
, "SCF:%s\n", path
);
952 if (fprintf(fp
, "X-Claws-End-Special-Headers: 1\n") < 0)
956 get_rfc822_date(buf_date
, sizeof(buf_date
));
957 if (fprintf(fp
, "Date: %s\n", buf_date
) < 0)
961 if (account
->name
&& *account
->name
) {
962 notification_convert_header(&buf
, account
->name
, strlen("From: "));
965 if (fprintf(fp
, "From: %s <%s>\n", buf
, account
->address
) < 0) {
972 if (fprintf(fp
, "From: %s\n", account
->address
) < 0)
976 if (fprintf(fp
, "To: %s\n", to
) < 0)
980 notification_convert_header(&buf
, msginfo
->subject
, strlen("Subject: "));
983 if (fprintf(fp
, "Subject: Disposition notification: %s\n", buf
) < 0) {
991 if (account
->gen_msgid
) {
992 gchar
*addr
= prefs_account_generate_msgid(account
);
993 if (fprintf(fp
, "Message-ID: <%s>\n", addr
) < 0) {
1000 boundary
= generate_mime_boundary("DN");
1001 date
= g_strdup(buf_date
);
1003 orig_to
= g_strdup(msginfo
->to
);
1004 extract_address(orig_to
);
1006 if (msginfo
->subject
&& *(msginfo
->subject
)) {
1007 enc_sub
= g_malloc0(strlen(msginfo
->subject
)*8);
1008 qp_encode_line(enc_sub
, (const guchar
*)msginfo
->subject
);
1009 g_strstrip(enc_sub
);
1011 ok
= fprintf(fp
,"MIME-Version: 1.0\n"
1012 "Content-Type: multipart/report; report-type=disposition-notification;\n"
1013 " boundary=\"%s\"\n"
1016 "Content-Type: text/plain; charset=UTF-8\n"
1017 "Content-Transfer-Encoding: quoted-printable\n"
1019 "The message sent on: %s\n"
1021 "With subject: \"%s\"\n"
1022 "has been displayed at %s.\n"
1024 "There is no guarantee that the message has been read or understood.\n"
1027 "Content-Type: message/disposition-notification\n"
1029 "Reporting-UA: %s\n"
1030 "Original-Recipient: rfc822;%s\n"
1031 "Final-Recipient: rfc822;%s\n"
1032 "Original-Message-ID: <%s>\n"
1033 "Disposition: manual-action/MDN-sent-manually; displayed\n"
1036 "Content-Type: application/octet-stream\n"
1038 "Reporting-UA: %s\n"
1039 "Original-Recipient: rfc822;%s\n"
1040 "Final-Recipient: rfc822;%s\n"
1041 "Original-Message-ID: <%s>\n"
1042 "Disposition: manual-action/MDN-sent-manually; displayed\n"
1048 orig_to
?orig_to
:"No To:",
1049 enc_sub
?enc_sub
:"No subject",
1053 orig_to
?orig_to
:"No To:",
1055 msginfo
->msgid
?msginfo
->msgid
:"NO MESSAGE ID",
1058 orig_to
?orig_to
:"No To:",
1060 msginfo
->msgid
?msginfo
->msgid
:"NO MESSAGE ID",
1071 if (claws_safe_fclose(fp
) == EOF
) {
1072 FILE_OP_ERROR(tmp
, "claws_fclose");
1077 /* put it in queue */
1078 queue
= account_get_special_folder(account
, F_QUEUE
);
1079 if (!queue
) queue
= folder_get_default_queue();
1081 g_warning("can't find queue folder");
1085 folder_item_scan(queue
);
1086 if ((num
= folder_item_add_msg(queue
, tmp
, NULL
, TRUE
)) < 0) {
1087 g_warning("can't queue the message");
1092 if (prefs_common
.work_offline
&&
1093 !inc_offline_should_override(TRUE
,
1094 _("Claws Mail needs network access in order "
1095 "to send this email.")))
1099 path
= folder_item_fetch_msg(queue
, num
);
1100 ok
= procmsg_send_message_queue_with_lock(path
, &foo
, queue
, num
, &queued_removed
);
1103 if (ok
== 0 && !queued_removed
)
1104 folder_item_remove_msg(queue
, num
);
1114 static gboolean
find_encrypted_func(GNode
*node
, gpointer data
)
1116 MimeInfo
*mimeinfo
= (MimeInfo
*) node
->data
;
1117 MimeInfo
**encinfo
= (MimeInfo
**) data
;
1119 if (privacy_mimeinfo_is_encrypted(mimeinfo
)) {
1120 *encinfo
= mimeinfo
;
1127 static MimeInfo
*find_encrypted_part(MimeInfo
*rootinfo
)
1129 MimeInfo
*encinfo
= NULL
;
1131 g_node_traverse(rootinfo
->node
, G_IN_ORDER
, G_TRAVERSE_ALL
, -1,
1132 find_encrypted_func
, &encinfo
);
1137 static gboolean
find_broken_func(GNode
*node
, gpointer data
)
1139 MimeInfo
*mimeinfo
= (MimeInfo
*) node
->data
;
1140 MimeInfo
**brokeninfo
= (MimeInfo
**) data
;
1142 if (mimeinfo
->broken
) {
1143 *brokeninfo
= mimeinfo
;
1150 static MimeInfo
*find_broken_part(MimeInfo
*rootinfo
)
1152 MimeInfo
*brokeninfo
= NULL
;
1154 g_node_traverse(rootinfo
->node
, G_IN_ORDER
, G_TRAVERSE_ALL
, -1,
1155 find_broken_func
, &brokeninfo
);
1160 static void messageview_register_nav(MessageView
*messageview
)
1166 cm_return_if_fail(messageview
);
1167 cm_return_if_fail(messageview
->msginfo
);
1169 id
= procmsg_msginfo_get_identifier(messageview
->msginfo
);
1170 existing
= g_list_find_custom(messageview
->trail
, id
, (GCompareFunc
)g_strcmp0
);
1172 if (existing
!= NULL
)
1173 pos
= g_list_position(messageview
->trail
, existing
);
1178 messageview
->trail_pos
= pos
;
1181 /* Cut the end of the list */
1182 GList
*end
= g_list_nth(messageview
->trail
, messageview
->trail_pos
+ 1);
1185 end
->prev
->next
= NULL
;
1187 list_free_strings_full(end
);
1189 list_free_strings_full(messageview
->trail
);
1190 messageview
->trail
= NULL
;
1193 messageview
->trail
= g_list_append(messageview
->trail
, id
);
1194 messageview
->trail_pos
= (gint
)g_list_length(messageview
->trail
) - 1;
1196 /* Cut the beginning if needed */
1197 while (messageview
->trail_pos
> prefs_common
.nav_history_length
) {
1198 g_free(messageview
->trail
->data
);
1199 messageview
->trail
= g_list_delete_link(messageview
->trail
,
1200 messageview
->trail
);
1201 messageview
->trail_pos
--;
1204 messageview_set_menu_sensitive(messageview
);
1207 gboolean
messageview_nav_has_prev(MessageView
*messageview
) {
1208 return messageview
!= NULL
&& messageview
->trail
!= NULL
1209 && messageview
->trail_pos
> 0;
1212 gboolean
messageview_nav_has_next(MessageView
*messageview
) {
1213 if (!messageview
|| !messageview
->trail
)
1216 return sc_g_list_bigger(messageview
->trail
, messageview
->trail_pos
+ 1);
1219 MsgInfo
*messageview_nav_get_prev(MessageView
*messageview
) {
1223 cm_return_val_if_fail(messageview
, NULL
);
1224 cm_return_val_if_fail(messageview
->trail
, NULL
);
1227 if (!messageview_nav_has_prev(messageview
))
1230 item
= g_list_nth(messageview
->trail
, messageview
->trail_pos
- 1);
1231 cm_return_val_if_fail(item
!= NULL
, NULL
);
1233 info
= procmsg_get_msginfo_from_identifier((const gchar
*)item
->data
);
1238 messageview
->trail
= g_list_delete_link(messageview
->trail
, item
);
1239 if (messageview
->trail_pos
> 0)
1240 messageview
->trail_pos
--;
1241 } while (info
== NULL
);
1246 MsgInfo
*messageview_nav_get_next(MessageView
*messageview
) {
1250 cm_return_val_if_fail(messageview
, NULL
);
1251 cm_return_val_if_fail(messageview
->trail
, NULL
);
1254 if (!messageview_nav_has_next(messageview
))
1257 item
= g_list_nth(messageview
->trail
, messageview
->trail_pos
+ 1);
1258 cm_return_val_if_fail(item
!= NULL
, NULL
);
1260 info
= procmsg_get_msginfo_from_identifier((const gchar
*)item
->data
);
1265 messageview
->trail
= g_list_delete_link(messageview
->trail
, item
);
1266 } while (info
== NULL
);
1271 static gboolean
messageview_try_select_mimeinfo(MessageView
*messageview
, MsgInfo
*msginfo
, MimeInfo
*mimeinfo
)
1273 if (mimeinfo
->type
== MIMETYPE_TEXT
) {
1274 if (!strcasecmp(mimeinfo
->subtype
, "calendar")
1275 && mimeview_has_viewer_for_content_type(messageview
->mimeview
, "text/calendar")) {
1276 mimeview_select_mimepart_icon(messageview
->mimeview
, mimeinfo
);
1278 } else if (!strcasecmp(mimeinfo
->subtype
, "html")
1279 && mimeinfo
->disposition
!= DISPOSITIONTYPE_ATTACHMENT
1280 && ((msginfo
->folder
&& msginfo
->folder
->prefs
->promote_html_part
== HTML_PROMOTE_ALWAYS
)
1281 || ((msginfo
->folder
&& msginfo
->folder
->prefs
->promote_html_part
== HTML_PROMOTE_DEFAULT
)
1282 && prefs_common
.promote_html_part
))) {
1283 mimeview_select_mimepart_icon(messageview
->mimeview
, mimeinfo
);
1290 static void messageview_find_part_depth_first(MimeInfoSearch
*context
, MimeMediaType type
, const gchar
*subtype
)
1292 MimeInfo
* mimeinfo
= context
->current
;
1297 debug_print("found part %d/%s\n", mimeinfo
->type
, mimeinfo
->subtype
);
1299 if (mimeinfo
->type
== type
1300 && !strcasecmp(mimeinfo
->subtype
, subtype
)) {
1301 context
->found
= mimeinfo
;
1302 } else if (mimeinfo
->type
== MIMETYPE_MULTIPART
) {
1303 if (!strcasecmp(mimeinfo
->subtype
, "alternative")
1304 || !strcasecmp(mimeinfo
->subtype
, "related")) {
1305 context
->found
= procmime_mimeinfo_next(mimeinfo
);
1306 while (context
->found
&& context
->found
!= context
->parent
) {
1307 if (context
->found
->type
== type
1308 && !strcasecmp(context
->found
->subtype
, subtype
))
1310 context
->found
= procmime_mimeinfo_next(context
->found
);
1312 if (context
->found
== context
->parent
)
1313 context
->found
= NULL
;
1316 && (!strcasecmp(mimeinfo
->subtype
, "related")
1317 || !strcasecmp(mimeinfo
->subtype
, "mixed"))) {
1318 context
->parent
= mimeinfo
;
1319 context
->current
= procmime_mimeinfo_next(mimeinfo
);
1320 messageview_find_part_depth_first(context
, type
, subtype
);
1325 gint
messageview_show(MessageView
*messageview
, MsgInfo
*msginfo
,
1326 gboolean all_headers
)
1330 MimeInfo
*mimeinfo
, *encinfo
, *root
;
1331 gchar
*subject
= NULL
;
1332 cm_return_val_if_fail(msginfo
!= NULL
, -1);
1334 if (msginfo
!= messageview
->msginfo
)
1335 messageview
->show_full_text
= FALSE
;
1337 if (messageview
->mimeview
->textview
&&
1338 messageview
->mimeview
->textview
->loading
) {
1339 messageview
->mimeview
->textview
->stop_loading
= TRUE
;
1343 if (messageview
->toolbar
)
1344 toolbar_set_learn_button
1345 (messageview
->toolbar
,
1346 MSG_IS_SPAM(msginfo
->flags
)?LEARN_HAM
:LEARN_SPAM
);
1348 toolbar_set_learn_button
1349 (messageview
->mainwin
->toolbar
,
1350 MSG_IS_SPAM(msginfo
->flags
)?LEARN_HAM
:LEARN_SPAM
);
1352 if (messageview
->toolbar
) {
1353 if (messageview
->toolbar
->learn_spam_btn
) {
1354 gboolean can_learn
= FALSE
;
1355 if (procmsg_spam_can_learn() &&
1357 msginfo
->folder
->folder
->klass
->type
!= F_UNKNOWN
&&
1358 msginfo
->folder
->folder
->klass
->type
!= F_NEWS
))
1361 gtk_widget_set_sensitive(
1362 messageview
->toolbar
->learn_spam_btn
,
1367 noticeview_hide(messageview
->noticeview
);
1368 mimeview_clear(messageview
->mimeview
);
1369 messageview
->updating
= TRUE
;
1371 if (msginfo
->size
> 1024*1024)
1372 statusbar_print_all(_("Fetching message (%s)..."),
1373 to_human_readable(msginfo
->size
));
1375 file
= procmsg_get_message_file_path(msginfo
);
1377 if (msginfo
->size
> 1024*1024)
1378 statusbar_pop_all();
1381 g_warning("can't get message file path");
1382 textview_show_error(messageview
->mimeview
->textview
);
1386 if (!folder_has_parent_of_type(msginfo
->folder
, F_QUEUE
) &&
1387 !folder_has_parent_of_type(msginfo
->folder
, F_DRAFT
))
1388 mimeinfo
= procmime_scan_file(file
);
1390 mimeinfo
= procmime_scan_queue_file(file
);
1392 messageview
->updating
= FALSE
;
1394 if (messageview
->deferred_destroy
) {
1396 messageview_destroy(messageview
);
1401 textview_show_error(messageview
->mimeview
->textview
);
1405 while ((encinfo
= find_encrypted_part(mimeinfo
)) != NULL
) {
1406 debug_print("decrypting message part\n");
1407 if (privacy_mimeinfo_decrypt(encinfo
) < 0) {
1408 text
= g_strdup_printf(_("Couldn't decrypt: %s"),
1409 privacy_get_error());
1410 noticeview_show(messageview
->noticeview
);
1411 noticeview_set_icon(messageview
->noticeview
,
1412 STOCK_PIXMAP_NOTICE_WARN
);
1413 noticeview_set_text(messageview
->noticeview
, text
);
1414 gtk_widget_hide(messageview
->noticeview
->button
);
1415 gtk_widget_hide(messageview
->noticeview
->button2
);
1421 if (messageview
->msginfo
!= msginfo
) {
1422 procmsg_msginfo_free(&(messageview
->msginfo
));
1423 messageview
->msginfo
= NULL
;
1424 messageview_set_menu_sensitive(messageview
);
1425 messageview
->msginfo
=
1426 procmsg_msginfo_get_full_info_from_file(msginfo
, file
);
1427 if (!messageview
->msginfo
)
1428 messageview
->msginfo
= procmsg_msginfo_copy(msginfo
);
1430 messageview
->msginfo
= NULL
;
1431 messageview_set_menu_sensitive(messageview
);
1432 messageview
->msginfo
= msginfo
;
1434 if (prefs_common
.display_header_pane
)
1435 headerview_show(messageview
->headerview
, messageview
->msginfo
);
1437 messageview_register_nav(messageview
);
1438 messageview_set_position(messageview
, 0);
1440 if (messageview
->window
) {
1441 gtk_window_set_title(GTK_WINDOW(messageview
->window
),
1442 _("Claws Mail - Message View"));
1445 mimeview_show_message(messageview
->mimeview
, mimeinfo
, file
);
1447 #ifndef GENERIC_UMPC
1448 messageview_set_position(messageview
, 0);
1451 if (messageview
->window
&& msginfo
->subject
) {
1452 subject
= g_strdup(msginfo
->subject
);
1453 if (!g_utf8_validate(subject
, -1, NULL
)) {
1455 subject
= g_malloc(strlen(msginfo
->subject
)*2 +1);
1456 conv_localetodisp(subject
, strlen(msginfo
->subject
)*2 +1,
1459 if (g_utf8_validate(subject
, -1, NULL
))
1460 gtk_window_set_title(GTK_WINDOW(messageview
->window
),
1465 if (msginfo
->folder
) {
1466 msginfo
->folder
->last_seen
= msginfo
->msgnum
;
1469 main_create_mailing_list_menu(messageview
->mainwin
, messageview
->msginfo
);
1471 if (messageview
->msginfo
&& messageview
->msginfo
->extradata
1472 && messageview
->msginfo
->extradata
->partial_recv
1473 && !noticeview_is_visible(messageview
->noticeview
))
1474 partial_recv_show(messageview
->noticeview
,
1475 messageview
->msginfo
);
1476 else if (messageview
->msginfo
&& messageview
->msginfo
->extradata
&&
1477 (messageview
->msginfo
->extradata
->dispositionnotificationto
||
1478 messageview
->msginfo
->extradata
->returnreceiptto
) &&
1479 !MSG_IS_RETRCPT_SENT(messageview
->msginfo
->flags
) &&
1480 !prefs_common
.never_send_retrcpt
&&
1481 !noticeview_is_visible(messageview
->noticeview
))
1482 return_receipt_show(messageview
->noticeview
,
1483 messageview
->msginfo
);
1485 if (find_broken_part(mimeinfo
) != NULL
) {
1486 noticeview_set_icon(messageview
->noticeview
,
1487 STOCK_PIXMAP_NOTICE_WARN
);
1488 if (!noticeview_is_visible(messageview
->noticeview
)) {
1489 noticeview_set_text(messageview
->noticeview
, _("Message doesn't conform to MIME standard. "
1490 "It may render wrongly."));
1491 gtk_widget_hide(messageview
->noticeview
->button
);
1492 gtk_widget_hide(messageview
->noticeview
->button2
);
1494 gchar
*full
= g_strconcat(
1495 gtk_label_get_text(GTK_LABEL(messageview
->noticeview
->text
)),
1497 _("Message doesn't conform to MIME standard. "
1498 "It may render wrongly."), NULL
);
1499 noticeview_set_text(messageview
->noticeview
, full
);
1502 noticeview_show(messageview
->noticeview
);
1506 mimeinfo
= procmime_mimeinfo_next(mimeinfo
);
1507 if (!all_headers
&& mimeinfo
1508 && (mimeinfo
->type
!= MIMETYPE_TEXT
1509 || strcasecmp(mimeinfo
->subtype
, "plain"))
1510 && (mimeinfo
->type
!= MIMETYPE_MULTIPART
1511 || strcasecmp(mimeinfo
->subtype
, "signed"))) {
1512 if (strcasecmp(mimeinfo
->subtype
, "html")) {
1513 MimeInfoSearch context
= {
1515 .current
= mimeinfo
,
1518 if (mimeview_has_viewer_for_content_type(messageview
->mimeview
, "text/calendar")) {
1519 MimeInfoSearch cal_context
= context
;
1520 messageview_find_part_depth_first(&cal_context
, MIMETYPE_TEXT
, "calendar");
1521 if (cal_context
.found
) { /* calendar found */
1522 mimeinfo
= cal_context
.found
;
1523 if (messageview_try_select_mimeinfo(messageview
, msginfo
, mimeinfo
))
1527 messageview_find_part_depth_first(&context
, MIMETYPE_TEXT
, "html");
1528 if (context
.found
&&
1529 (msginfo
->folder
->prefs
->promote_html_part
== HTML_PROMOTE_ALWAYS
||
1530 (msginfo
->folder
->prefs
->promote_html_part
== HTML_PROMOTE_DEFAULT
&&
1531 prefs_common
.promote_html_part
))) { /* html found */
1532 mimeinfo
= context
.found
;
1533 if (messageview_try_select_mimeinfo(messageview
, msginfo
, mimeinfo
))
1536 mimeinfo
= root
; /* nothing found */
1538 if (!mimeview_show_part(messageview
->mimeview
, mimeinfo
))
1539 mimeview_select_mimepart_icon(messageview
->mimeview
, root
);
1541 } else if (prefs_common
.invoke_plugin_on_html
) {
1542 mimeview_select_mimepart_icon(messageview
->mimeview
, mimeinfo
);
1546 if (!all_headers
&& mimeinfo
&&
1547 mimeinfo
->type
== MIMETYPE_MULTIPART
&&
1548 mimeview_has_viewer_for_content_type(messageview
->mimeview
, "text/calendar")) {
1549 /* look for a calendar part or it looks really strange */
1551 if (mimeinfo
->type
== MIMETYPE_TEXT
&&
1552 !strcasecmp(mimeinfo
->subtype
, "calendar")) {
1553 mimeview_select_mimepart_icon(messageview
->mimeview
, mimeinfo
);
1556 mimeinfo
= procmime_mimeinfo_next(mimeinfo
);
1560 mimeview_select_mimepart_icon(messageview
->mimeview
, root
);
1562 messageview_set_menu_sensitive(messageview
);
1563 /* plugins may hook in here to work with the message view */
1564 hooks_invoke(MESSAGE_VIEW_SHOW_DONE_HOOKLIST
, messageview
);
1571 void messageview_reflect_prefs_pixmap_theme(void)
1574 MessageView
*msgview
;
1576 for (cur
= msgview_list
; cur
!= NULL
; cur
= cur
->next
) {
1577 msgview
= (MessageView
*)cur
->data
;
1578 toolbar_update(TOOLBAR_MSGVIEW
, msgview
);
1579 mimeview_update(msgview
->mimeview
);
1583 void messageview_clear(MessageView
*messageview
)
1587 procmsg_msginfo_free(&(messageview
->msginfo
));
1588 messageview
->msginfo
= NULL
;
1589 messageview
->filtered
= FALSE
;
1591 if (messageview
->window
) {
1592 gtk_window_set_title(GTK_WINDOW(messageview
->window
),
1593 _("Claws Mail - Message View"));
1597 mimeview_clear(messageview
->mimeview
);
1598 headerview_clear(messageview
->headerview
);
1599 noticeview_hide(messageview
->noticeview
);
1602 void messageview_destroy(MessageView
*messageview
)
1604 debug_print("destroy messageview\n");
1605 messageview_list
= g_list_remove(messageview_list
, messageview
);
1607 if (messageview
->mainwin
->summaryview
->messageview
== messageview
) {
1608 messageview
->mainwin
->summaryview
->displayed
= NULL
;
1609 messageview
->mainwin
->summaryview
->messageview
= NULL
;
1611 if (messageview
->mainwin
->summaryview
->ext_messageview
== messageview
) {
1612 messageview
->mainwin
->summaryview
->displayed
= NULL
;
1613 messageview
->mainwin
->summaryview
->ext_messageview
= NULL
;
1615 if (!messageview
->deferred_destroy
)
1616 hooks_unregister_hook(MSGINFO_UPDATE_HOOKLIST
,
1617 messageview
->msginfo_update_callback_id
);
1619 if (messageview
->updating
) {
1620 debug_print("uh oh, better not touch that now (fetching)\n");
1621 messageview
->deferred_destroy
= TRUE
;
1622 gtk_widget_hide(messageview
->window
);
1626 if (messageview
->mimeview
->textview
1627 && messageview
->mimeview
->textview
->loading
) {
1628 debug_print("uh oh, better not touch that now (loading text)\n");
1629 messageview
->deferred_destroy
= TRUE
;
1630 messageview
->mimeview
->textview
->stop_loading
= TRUE
;
1631 gtk_widget_hide(messageview
->window
);
1635 headerview_destroy(messageview
->headerview
);
1636 mimeview_destroy(messageview
->mimeview
);
1637 noticeview_destroy(messageview
->noticeview
);
1639 procmsg_msginfo_free(&(messageview
->msginfo
));
1640 toolbar_clear_list(TOOLBAR_MSGVIEW
);
1641 if (messageview
->toolbar
) {
1642 toolbar_destroy(messageview
->toolbar
);
1643 g_free(messageview
->toolbar
);
1646 message_search_close(messageview
);
1648 list_free_strings_full(messageview
->trail
);
1649 msgview_list
= g_list_remove(msgview_list
, messageview
);
1651 if (messageview
->window
)
1652 gtk_widget_destroy(messageview
->window
);
1653 g_free(messageview
);
1656 void messageview_delete(MessageView
*msgview
)
1658 MsgInfo
*msginfo
= NULL
;
1659 FolderItem
*trash
= NULL
;
1660 PrefsAccount
*ac
= NULL
;
1662 if (msgview
->msginfo
&& msgview
->mainwin
&& msgview
->mainwin
->summaryview
)
1663 msginfo
= summary_get_selected_msg(msgview
->mainwin
->summaryview
);
1665 /* need a procmsg_msginfo_equal() */
1666 if (msginfo
&& msgview
->msginfo
&&
1667 msginfo
->msgnum
== msgview
->msginfo
->msgnum
&&
1668 msginfo
->folder
== msgview
->msginfo
->folder
) {
1669 summary_delete_trash(msgview
->mainwin
->summaryview
);
1671 msginfo
= msgview
->msginfo
;
1673 cm_return_if_fail(msginfo
!= NULL
);
1675 /* We will need to access the original message's msginfo
1676 * later, so we add our own reference. */
1677 procmsg_msginfo_new_ref(msginfo
);
1679 /* to get the trash folder, we have to choose either
1680 * the folder's or account's trash default - we prefer
1681 * the one in the account prefs */
1682 if (msginfo
->folder
) {
1683 if (NULL
!= (ac
= account_find_from_item(msginfo
->folder
)))
1684 trash
= account_get_special_folder(ac
, F_TRASH
);
1685 if (!trash
&& msginfo
->folder
->folder
)
1686 trash
= msginfo
->folder
->folder
->trash
;
1687 /* if still not found, use the default */
1689 trash
= folder_get_default_trash();
1692 cm_return_if_fail(trash
!= NULL
);
1694 if (prefs_common
.immediate_exec
)
1695 /* TODO: Delete from trash */
1696 folder_item_move_msg(trash
, msginfo
);
1698 procmsg_msginfo_set_to_folder(msginfo
, trash
);
1699 procmsg_msginfo_set_flags(msginfo
, MSG_DELETED
, 0);
1700 /* NOTE: does not update to next message in summaryview */
1703 procmsg_msginfo_free(&msginfo
);
1706 if (msgview
->window
&& !prefs_common
.always_show_msg
) {
1707 messageview_destroy(msgview
);
1713 * \brief update messageview with currently selected message in summaryview
1714 * leave unchanged if summaryview is empty
1715 * \param pointer to MessageView
1717 static void messageview_update(MessageView
*msgview
, MsgInfo
*old_msginfo
)
1719 SummaryView
*summaryview
= (SummaryView
*)msgview
->mainwin
->summaryview
;
1721 cm_return_if_fail(summaryview
!= NULL
);
1723 if (summaryview
->selected
) {
1724 MsgInfo
*msginfo
= summary_get_selected_msg(summaryview
);
1725 if (msginfo
== NULL
|| msginfo
== old_msginfo
)
1728 messageview_show(msgview
, msginfo
,
1729 msgview
->all_headers
);
1733 TextView
*messageview_get_current_textview(MessageView
*messageview
)
1735 TextView
*text
= NULL
;
1737 text
= messageview
->mimeview
->textview
;
1742 MimeInfo
*messageview_get_selected_mime_part(MessageView
*messageview
)
1744 return mimeview_get_selected_part(messageview
->mimeview
);
1747 void messageview_copy_clipboard(MessageView
*messageview
)
1749 gchar
*text
= messageview_get_selection(messageview
);
1751 gtk_clipboard_set_text(
1752 gtk_clipboard_get(GDK_SELECTION_CLIPBOARD
),
1758 void messageview_select_all(MessageView
*messageview
)
1762 text
= messageview_get_current_textview(messageview
);
1764 GtkTextView
*textview
= GTK_TEXT_VIEW(text
->text
);
1765 GtkTextBuffer
*buffer
;
1766 GtkTextIter start
, end
;
1768 buffer
= gtk_text_view_get_buffer(textview
);
1769 gtk_text_buffer_get_bounds(buffer
, &start
, &end
);
1770 gtk_text_buffer_select_range(buffer
, &start
, &end
);
1774 void messageview_set_position(MessageView
*messageview
, gint pos
)
1778 text
= messageview_get_current_textview(messageview
);
1780 textview_set_position(text
, pos
);
1783 gboolean
messageview_search_string(MessageView
*messageview
, const gchar
*str
,
1788 if (messageview
->mimeview
->type
== MIMEVIEW_VIEWER
) {
1789 MimeViewer
*viewer
= messageview
->mimeview
->mimeviewer
;
1790 if (viewer
&& viewer
->text_search
) {
1791 return viewer
->text_search(viewer
, FALSE
, str
, case_sens
);
1795 text
= messageview_get_current_textview(messageview
);
1797 return textview_search_string(text
, str
, case_sens
);
1801 gboolean
messageview_search_string_backward(MessageView
*messageview
,
1807 if (messageview
->mimeview
->type
== MIMEVIEW_VIEWER
) {
1808 MimeViewer
*viewer
= messageview
->mimeview
->mimeviewer
;
1809 if (viewer
&& viewer
->text_search
) {
1810 return viewer
->text_search(viewer
, TRUE
, str
, case_sens
);
1814 text
= messageview_get_current_textview(messageview
);
1816 return textview_search_string_backward(text
,
1821 gboolean
messageview_is_visible(MessageView
*messageview
)
1823 if (messageview
== NULL
)
1825 return messageview
->visible
;
1828 static gint
messageview_delete_cb(GtkWidget
*widget
, GdkEventAny
*event
,
1829 MessageView
*messageview
)
1831 messageview_destroy(messageview
);
1835 static void messageview_size_allocate_cb(GtkWidget
*widget
,
1836 GtkAllocation
*allocation
)
1838 cm_return_if_fail(allocation
!= NULL
);
1840 gtk_window_get_size(GTK_WINDOW(widget
),
1841 &prefs_common
.msgwin_width
, &prefs_common
.msgwin_height
);
1844 static gboolean
key_pressed(GtkWidget
*widget
, GdkEventKey
*event
,
1845 MessageView
*messageview
)
1847 if (event
&& event
->keyval
== GDK_KEY_Escape
&& messageview
->window
) {
1848 messageview_destroy(messageview
);
1852 if (event
&& (event
->state
& (GDK_MOD1_MASK
|GDK_CONTROL_MASK
)) != 0)
1854 if (event
&& (event
->state
& GDK_SHIFT_MASK
) && event
->keyval
!= GDK_KEY_space
)
1857 if (event
&& (event
->keyval
== GDK_KEY_KP_Enter
|| event
->keyval
== GDK_KEY_Return
) &&
1858 messageview
->window
) {
1859 MsgInfo
*new_msginfo
= summary_get_selected_msg(messageview
->mainwin
->summaryview
);
1860 messageview_show(messageview
, new_msginfo
, messageview
->all_headers
);
1864 return mimeview_pass_key_press_event(messageview
->mimeview
, event
);
1867 static void messageview_show_partial_display_cb(NoticeView
*noticeview
, MessageView
*messageview
)
1869 messageview
->show_full_text
= TRUE
;
1870 main_window_cursor_wait(mainwindow_get_mainwindow());
1871 noticeview_hide(messageview
->noticeview
);
1872 messageview
->partial_display_shown
= FALSE
;
1874 mimeview_handle_cmd(messageview
->mimeview
, "sc://display_as_text", NULL
, NULL
);
1875 main_window_cursor_normal(mainwindow_get_mainwindow());
1878 void messageview_show_partial_display(MessageView
*messageview
, MsgInfo
*msginfo
,
1881 gchar
*msg
= g_strdup_printf(_("Show all %s."), to_human_readable((goffset
)length
));
1882 noticeview_set_icon(messageview
->noticeview
, STOCK_PIXMAP_NOTICE_WARN
);
1883 noticeview_set_text(messageview
->noticeview
, _("Only the first megabyte of text is shown."));
1884 noticeview_set_button_text(messageview
->noticeview
, msg
);
1886 noticeview_set_button_press_callback(messageview
->noticeview
,
1887 G_CALLBACK(messageview_show_partial_display_cb
),
1888 (gpointer
) messageview
);
1889 noticeview_show(messageview
->noticeview
);
1890 messageview
->partial_display_shown
= TRUE
;
1893 static void return_receipt_show(NoticeView
*noticeview
, MsgInfo
*msginfo
)
1896 gboolean from_me
= FALSE
;
1898 && (folder_has_parent_of_type(msginfo
->folder
, F_QUEUE
)
1899 || folder_has_parent_of_type(msginfo
->folder
, F_DRAFT
)))
1902 addr
= g_strdup(msginfo
->from
);
1904 extract_address(addr
);
1905 if (account_find_from_address(addr
, FALSE
)) {
1912 noticeview_set_icon(noticeview
, STOCK_PIXMAP_NOTICE_WARN
);
1913 if (MSG_IS_RETRCPT_GOT(msginfo
->flags
)) {
1914 noticeview_set_text(noticeview
, _("You got a return receipt for this message: "
1915 "it has been displayed by the recipient."));
1917 noticeview_set_text(noticeview
, _("You asked for a return receipt in this message."));
1919 noticeview_set_button_text(noticeview
, NULL
);
1920 noticeview_set_button_press_callback(noticeview
, NULL
, NULL
);
1922 noticeview_set_icon(noticeview
, STOCK_PIXMAP_NOTICE_WARN
);
1923 noticeview_set_text(noticeview
, _("This message asks for a return receipt."));
1924 noticeview_set_button_text(noticeview
, _("Send receipt"));
1925 noticeview_set_button_press_callback(noticeview
,
1926 G_CALLBACK(return_receipt_send_clicked
),
1927 (gpointer
) msginfo
);
1929 noticeview_show(noticeview
);
1932 static void return_receipt_send_clicked(NoticeView
*noticeview
, MsgInfo
*msginfo
)
1934 MsgInfo
*tmpmsginfo
;
1937 file
= procmsg_get_message_file_path(msginfo
);
1939 g_warning("can't get message file path");
1943 tmpmsginfo
= procheader_parse_file(file
, msginfo
->flags
, TRUE
, TRUE
);
1944 tmpmsginfo
->folder
= msginfo
->folder
;
1945 tmpmsginfo
->msgnum
= msginfo
->msgnum
;
1947 if (disposition_notification_send(tmpmsginfo
) >= 0) {
1948 procmsg_msginfo_set_flags(msginfo
, MSG_RETRCPT_SENT
, 0);
1949 noticeview_hide(noticeview
);
1952 procmsg_msginfo_free(&tmpmsginfo
);
1956 static void partial_recv_show(NoticeView
*noticeview
, MsgInfo
*msginfo
)
1959 gchar
*button1
= NULL
;
1960 gchar
*button2
= NULL
;
1961 void *button1_cb
= NULL
;
1962 void *button2_cb
= NULL
;
1964 if (!msginfo
->extradata
)
1966 if (!partial_msg_in_uidl_list(msginfo
)) {
1967 text
= g_strdup_printf(_("This message has been partially "
1968 "retrieved,\nand has been deleted from the "
1971 switch (msginfo
->planned_download
) {
1972 case POP3_PARTIAL_DLOAD_UNKN
:
1973 text
= g_strdup_printf(_("This message has been "
1974 "partially retrieved;\nit is %s."),
1976 (goffset
)(msginfo
->total_size
)));
1977 button1
= _("Mark for download");
1978 button2
= _("Mark for deletion");
1979 button1_cb
= partial_recv_dload_clicked
;
1980 button2_cb
= partial_recv_del_clicked
;
1982 case POP3_PARTIAL_DLOAD_DLOAD
:
1983 text
= g_strdup_printf(_("This message has been "
1984 "partially retrieved;\nit is %s and "
1985 "will be downloaded."),
1987 (goffset
)(msginfo
->total_size
)));
1988 button1
= _("Unmark");
1989 button1_cb
= partial_recv_unmark_clicked
;
1990 button2
= _("Mark for deletion");
1991 button2_cb
= partial_recv_del_clicked
;
1993 case POP3_PARTIAL_DLOAD_DELE
:
1994 text
= g_strdup_printf(_("This message has been "
1995 "partially retrieved;\nit is %s and "
1996 "will be deleted."),
1998 (goffset
)(msginfo
->total_size
)));
1999 button1
= _("Mark for download");
2000 button1_cb
= partial_recv_dload_clicked
;
2001 button2
= _("Unmark");
2002 button2_cb
= partial_recv_unmark_clicked
;
2009 noticeview_set_icon(noticeview
, STOCK_PIXMAP_NOTICE_WARN
);
2010 noticeview_set_text(noticeview
, text
);
2012 noticeview_set_button_text(noticeview
, button1
);
2013 noticeview_set_button_press_callback(noticeview
,
2014 G_CALLBACK(button1_cb
), (gpointer
) msginfo
);
2016 noticeview_set_2ndbutton_text(noticeview
, button2
);
2017 noticeview_set_2ndbutton_press_callback(noticeview
,
2018 G_CALLBACK(button2_cb
), (gpointer
) msginfo
);
2020 noticeview_show(noticeview
);
2023 static void partial_recv_dload_clicked(NoticeView
*noticeview
,
2026 if (partial_mark_for_download(msginfo
) == 0) {
2027 partial_recv_show(noticeview
, msginfo
);
2031 static void partial_recv_del_clicked(NoticeView
*noticeview
,
2034 if (partial_mark_for_delete(msginfo
) == 0) {
2035 partial_recv_show(noticeview
, msginfo
);
2039 static void partial_recv_unmark_clicked(NoticeView
*noticeview
,
2042 if (partial_unmark(msginfo
) == 0) {
2043 partial_recv_show(noticeview
, msginfo
);
2047 static void select_account_cb(GtkWidget
*w
, gpointer data
)
2049 *(gint
*)data
= combobox_get_active_data(GTK_COMBO_BOX(w
));
2052 static PrefsAccount
*select_account_from_list(GList
*ac_list
, gboolean has_accounts
)
2058 cm_return_val_if_fail(ac_list
!= NULL
, NULL
);
2059 cm_return_val_if_fail(ac_list
->data
!= NULL
, NULL
);
2061 optmenu
= gtkut_account_menu_new(ac_list
,
2062 G_CALLBACK(select_account_cb
),
2066 account_id
= ((PrefsAccount
*) ac_list
->data
)->account_id
;
2067 if (!has_accounts
) {
2070 tr
= g_strdup(C_("'%s' stands for 'To' then 'Cc'",
2071 "This message is asking for a return receipt notification\n"
2072 "but according to its '%s' and '%s' headers it was not\n"
2073 "officially addressed to you.\n"
2074 "It is advised to not send the return receipt."));
2075 text
= g_strdup_printf(tr
,
2076 prefs_common_translated_header_name("To"),
2077 prefs_common_translated_header_name("Cc"));
2078 val
= alertpanel_with_widget(
2079 _("Return Receipt Notification"),
2080 text
, NULL
, _("_Cancel"), NULL
, _("_Send Notification"),
2081 NULL
, NULL
, ALERTFOCUS_FIRST
, FALSE
, optmenu
);
2085 val
= alertpanel_with_widget(
2086 _("Return Receipt Notification"),
2087 _("More than one of your accounts uses the "
2088 "address that this message was sent to.\n"
2089 "Please choose which account you want to "
2090 "use for sending the receipt notification:"),
2091 NULL
, _("_Cancel"), NULL
, _("_Send Notification"),
2092 NULL
, NULL
, ALERTFOCUS_FIRST
, FALSE
, optmenu
);
2094 if (val
!= G_ALERTALTERNATE
)
2097 return account_find_from_id(account_id
);
2101 * \brief return selected messageview text, when nothing is
2102 * selected and message was filtered, return complete text
2104 * \param pointer to Messageview
2106 * \return pointer to text (needs to be free'd by calling func)
2108 gchar
*messageview_get_selection(MessageView
*msgview
)
2112 GtkTextView
*edit
= NULL
;
2113 GtkTextBuffer
*textbuf
;
2115 GtkTextIter start_iter
, end_iter
;
2116 GtkTextMark
*body_start
, *body_end
;
2118 cm_return_val_if_fail(msgview
!= NULL
, NULL
);
2120 if (msgview
->mimeview
->type
== MIMEVIEW_VIEWER
) {
2121 MimeViewer
*viewer
= msgview
->mimeview
->mimeviewer
;
2122 if (viewer
&& viewer
->get_selection
) {
2123 text
= viewer
->get_selection(viewer
);
2129 textview
= messageview_get_current_textview(msgview
);
2130 cm_return_val_if_fail(textview
!= NULL
, NULL
);
2132 edit
= GTK_TEXT_VIEW(textview
->text
);
2133 cm_return_val_if_fail(edit
!= NULL
, NULL
);
2134 body_pos
= textview
->body_pos
;
2136 textbuf
= gtk_text_view_get_buffer(edit
);
2138 if (gtk_text_buffer_get_selection_bounds(textbuf
, NULL
, NULL
)) {
2139 return gtkut_text_view_get_selection(edit
);
2141 if (msgview
->filtered
) {
2142 gtk_text_buffer_get_iter_at_offset(textbuf
, &start_iter
, body_pos
);
2143 gtk_text_buffer_get_end_iter(textbuf
, &end_iter
);
2145 body_start
= gtk_text_buffer_get_mark(textbuf
, "body_start");
2147 /* If there is no body_start mark, an attachment is likely
2148 * selected, and we're looking at instructions on what to do
2149 * with it. No point in quoting that, so we'll just return NULL,
2150 * so that original message body is quoted instead down the line.
2152 if (body_start
== NULL
) {
2156 gtk_text_buffer_get_iter_at_mark(textbuf
, &start_iter
, body_start
);
2158 body_end
= gtk_text_buffer_get_mark(textbuf
, "body_end");
2159 if (body_end
!= NULL
) /* Just in case */
2160 gtk_text_buffer_get_iter_at_mark(textbuf
, &end_iter
, body_end
);
2162 gtk_text_buffer_get_end_iter(textbuf
, &end_iter
);
2165 return gtk_text_buffer_get_text(textbuf
, &start_iter
, &end_iter
, FALSE
);
2171 static void save_as_cb(GtkAction
*action
, gpointer data
)
2173 MessageView
*messageview
= (MessageView
*)data
;
2174 summary_save_as(messageview
->mainwin
->summaryview
);
2177 static void print_mimeview(MimeView
*mimeview
, gint sel_start
, gint sel_end
, gint partnum
)
2179 MainWindow
*mainwin
;
2181 || !mimeview
->textview
2182 || !mimeview
->textview
->text
)
2183 alertpanel_warning(_("Cannot print: the message doesn't "
2186 gtk_widget_realize(mimeview
->textview
->text
);
2188 mimeview_select_part_num(mimeview
, partnum
);
2190 if (mimeview
->type
== MIMEVIEW_VIEWER
) {
2191 MimeViewer
*viewer
= mimeview
->mimeviewer
;
2192 if (viewer
&& viewer
->print
) {
2193 viewer
->print(viewer
);
2196 /* Force text rendering if possible */
2199 mimepart
= mimeview_get_selected_part(mimeview
);
2200 if (mimepart
== NULL
2201 || (mimepart
->type
!= MIMETYPE_TEXT
&& mimepart
->type
!= MIMETYPE_MESSAGE
)) {
2202 alertpanel_warning(_("Cannot print: the message doesn't "
2206 mimeview_show_part_as_text(mimeview
, mimepart
);
2209 if (sel_start
!= -1 && sel_end
!= -1) {
2210 GtkTextIter start
, end
;
2211 GtkTextView
*text
= GTK_TEXT_VIEW(mimeview
->textview
->text
);
2212 GtkTextBuffer
*buffer
= gtk_text_view_get_buffer(text
);
2214 gtk_text_buffer_get_iter_at_offset(buffer
, &start
, sel_start
);
2215 gtk_text_buffer_get_iter_at_offset(buffer
, &end
, sel_end
);
2216 gtk_text_buffer_select_range(buffer
, &start
, &end
);
2218 /* TODO: Get the real parent window, not the main window */
2219 mainwin
= mainwindow_get_mainwindow();
2220 printing_print(GTK_TEXT_VIEW(mimeview
->textview
->text
),
2221 mainwin
? GTK_WINDOW(mainwin
->window
) : NULL
,
2223 (mimeview
->textview
->image
2224 ? GTK_IMAGE(mimeview
->textview
->image
)
2229 void messageview_print(MsgInfo
*msginfo
, gboolean all_headers
,
2230 gint sel_start
, gint sel_end
, gint partnum
)
2232 PangoFontDescription
*font_desc
= NULL
;
2233 MessageView
*tmpview
= messageview_create_with_new_window_visible(
2234 mainwindow_get_mainwindow(), FALSE
);
2236 if (prefs_common
.use_different_print_font
) {
2237 font_desc
= pango_font_description_from_string
2238 (prefs_common
.printfont
);
2240 font_desc
= pango_font_description_from_string
2241 (prefs_common
.textfont
);
2244 gtk_widget_override_font(tmpview
->mimeview
->textview
->text
,
2246 pango_font_description_free(font_desc
);
2249 tmpview
->all_headers
= all_headers
;
2250 if (msginfo
&& messageview_show(tmpview
, msginfo
,
2251 tmpview
->all_headers
) >= 0) {
2252 print_mimeview(tmpview
->mimeview
,
2253 sel_start
, sel_end
, partnum
);
2255 messageview_clear(tmpview
);
2256 messageview_destroy(tmpview
);
2259 static void page_setup_cb(GtkAction
*action
, gpointer data
)
2261 MessageView
*messageview
= (MessageView
*)data
;
2262 printing_page_setup(messageview
?
2263 GTK_WINDOW(messageview
->window
) : NULL
);
2266 static void print_cb(GtkAction
*action
, gpointer data
)
2268 MessageView
*messageview
= (MessageView
*)data
;
2269 gint sel_start
= -1, sel_end
= -1, partnum
= 0;
2271 if (!messageview
->msginfo
) return;
2273 partnum
= mimeview_get_selected_part_num(messageview
->mimeview
);
2274 textview_get_selection_offsets(messageview
->mimeview
->textview
,
2275 &sel_start
, &sel_end
);
2276 messageview_print(messageview
->msginfo
, messageview
->all_headers
,
2277 sel_start
, sel_end
, partnum
);
2280 static void close_cb(GtkAction
*action
, gpointer data
)
2282 MessageView
*messageview
= (MessageView
*)data
;
2283 messageview_destroy(messageview
);
2286 static void copy_cb(GtkAction
*action
, gpointer data
)
2288 MessageView
*messageview
= (MessageView
*)data
;
2289 messageview_copy_clipboard(messageview
);
2292 static void allsel_cb(GtkAction
*action
, gpointer data
)
2294 MessageView
*messageview
= (MessageView
*)data
;
2295 messageview_select_all(messageview
);
2298 static void search_cb(GtkAction
*action
, gpointer data
)
2300 MessageView
*messageview
= (MessageView
*)data
;
2301 message_search(messageview
);
2304 static void prev_cb(GtkAction
*action
, gpointer data
)
2306 MessageView
*messageview
= (MessageView
*)data
;
2307 messageview
->updating
= TRUE
;
2308 summary_select_prev(messageview
->mainwin
->summaryview
);
2309 messageview
->updating
= FALSE
;
2311 if (messageview
->deferred_destroy
) {
2312 debug_print("messageview got away!\n");
2313 messageview_destroy(messageview
);
2316 if (messageview
->mainwin
->summaryview
->selected
) {
2317 #ifndef GENERIC_UMPC
2318 MsgInfo
* msginfo
= summary_get_selected_msg(messageview
->mainwin
->summaryview
);
2321 messageview_show(messageview
, msginfo
,
2322 messageview
->all_headers
);
2325 gtk_widget_destroy(messageview
->window
);
2329 static void next_cb(GtkAction
*action
, gpointer data
)
2331 MessageView
*messageview
= (MessageView
*)data
;
2332 messageview
->updating
= TRUE
;
2333 summary_select_next(messageview
->mainwin
->summaryview
);
2334 messageview
->updating
= FALSE
;
2336 if (messageview
->deferred_destroy
) {
2337 debug_print("messageview got away!\n");
2338 messageview_destroy(messageview
);
2341 if (messageview
->mainwin
->summaryview
->selected
) {
2342 #ifndef GENERIC_UMPC
2343 MsgInfo
* msginfo
= summary_get_selected_msg(messageview
->mainwin
->summaryview
);
2346 messageview_show(messageview
, msginfo
,
2347 messageview
->all_headers
);
2350 gtk_widget_destroy(messageview
->window
);
2354 static void prev_unread_cb(GtkAction
*action
, gpointer data
)
2356 MessageView
*messageview
= (MessageView
*)data
;
2357 messageview
->updating
= TRUE
;
2358 summary_select_prev_unread(messageview
->mainwin
->summaryview
);
2359 messageview
->updating
= FALSE
;
2361 if (messageview
->deferred_destroy
) {
2362 debug_print("messageview got away!\n");
2363 messageview_destroy(messageview
);
2366 if (messageview
->mainwin
->summaryview
->selected
) {
2367 #ifndef GENERIC_UMPC
2368 MsgInfo
* msginfo
= summary_get_selected_msg(messageview
->mainwin
->summaryview
);
2371 messageview_show(messageview
, msginfo
,
2372 messageview
->all_headers
);
2375 gtk_widget_destroy(messageview
->window
);
2379 static void next_unread_cb(GtkAction
*action
, gpointer data
)
2381 MessageView
*messageview
= (MessageView
*)data
;
2382 messageview
->updating
= TRUE
;
2383 summary_select_next_unread(messageview
->mainwin
->summaryview
);
2384 messageview
->updating
= FALSE
;
2386 if (messageview
->deferred_destroy
) {
2387 debug_print("messageview got away!\n");
2388 messageview_destroy(messageview
);
2391 if (messageview
->mainwin
->summaryview
->selected
) {
2392 #ifndef GENERIC_UMPC
2393 MsgInfo
* msginfo
= summary_get_selected_msg(messageview
->mainwin
->summaryview
);
2396 messageview_show(messageview
, msginfo
,
2397 messageview
->all_headers
);
2400 gtk_widget_destroy(messageview
->window
);
2404 static void prev_new_cb(GtkAction
*action
, gpointer data
)
2406 MessageView
*messageview
= (MessageView
*)data
;
2407 messageview
->updating
= TRUE
;
2408 summary_select_prev_new(messageview
->mainwin
->summaryview
);
2409 messageview
->updating
= FALSE
;
2411 if (messageview
->deferred_destroy
) {
2412 debug_print("messageview got away!\n");
2413 messageview_destroy(messageview
);
2416 if (messageview
->mainwin
->summaryview
->selected
) {
2417 #ifndef GENERIC_UMPC
2418 MsgInfo
* msginfo
= summary_get_selected_msg(messageview
->mainwin
->summaryview
);
2421 messageview_show(messageview
, msginfo
,
2422 messageview
->all_headers
);
2425 gtk_widget_destroy(messageview
->window
);
2429 static void next_new_cb(GtkAction
*action
, gpointer data
)
2431 MessageView
*messageview
= (MessageView
*)data
;
2432 messageview
->updating
= TRUE
;
2433 summary_select_next_new(messageview
->mainwin
->summaryview
);
2434 messageview
->updating
= FALSE
;
2436 if (messageview
->deferred_destroy
) {
2437 debug_print("messageview got away!\n");
2438 messageview_destroy(messageview
);
2441 if (messageview
->mainwin
->summaryview
->selected
) {
2442 #ifndef GENERIC_UMPC
2443 MsgInfo
* msginfo
= summary_get_selected_msg(messageview
->mainwin
->summaryview
);
2446 messageview_show(messageview
, msginfo
,
2447 messageview
->all_headers
);
2450 gtk_widget_destroy(messageview
->window
);
2454 static void prev_marked_cb(GtkAction
*action
, gpointer data
)
2456 MessageView
*messageview
= (MessageView
*)data
;
2457 messageview
->updating
= TRUE
;
2458 summary_select_prev_marked(messageview
->mainwin
->summaryview
);
2459 messageview
->updating
= FALSE
;
2461 if (messageview
->deferred_destroy
) {
2462 debug_print("messageview got away!\n");
2463 messageview_destroy(messageview
);
2466 if (messageview
->mainwin
->summaryview
->selected
) {
2467 #ifndef GENERIC_UMPC
2468 MsgInfo
* msginfo
= summary_get_selected_msg(messageview
->mainwin
->summaryview
);
2471 messageview_show(messageview
, msginfo
,
2472 messageview
->all_headers
);
2475 gtk_widget_destroy(messageview
->window
);
2479 static void next_marked_cb(GtkAction
*action
, gpointer data
)
2481 MessageView
*messageview
= (MessageView
*)data
;
2482 messageview
->updating
= TRUE
;
2483 summary_select_next_marked(messageview
->mainwin
->summaryview
);
2484 messageview
->updating
= FALSE
;
2486 if (messageview
->deferred_destroy
) {
2487 debug_print("messageview got away!\n");
2488 messageview_destroy(messageview
);
2491 if (messageview
->mainwin
->summaryview
->selected
) {
2492 #ifndef GENERIC_UMPC
2493 MsgInfo
* msginfo
= summary_get_selected_msg(messageview
->mainwin
->summaryview
);
2496 messageview_show(messageview
, msginfo
,
2497 messageview
->all_headers
);
2500 gtk_widget_destroy(messageview
->window
);
2504 static void prev_labeled_cb(GtkAction
*action
, gpointer data
)
2506 MessageView
*messageview
= (MessageView
*)data
;
2507 messageview
->updating
= TRUE
;
2508 summary_select_prev_labeled(messageview
->mainwin
->summaryview
);
2509 messageview
->updating
= FALSE
;
2511 if (messageview
->deferred_destroy
) {
2512 debug_print("messageview got away!\n");
2513 messageview_destroy(messageview
);
2516 if (messageview
->mainwin
->summaryview
->selected
) {
2517 #ifndef GENERIC_UMPC
2518 MsgInfo
* msginfo
= summary_get_selected_msg(messageview
->mainwin
->summaryview
);
2521 messageview_show(messageview
, msginfo
,
2522 messageview
->all_headers
);
2525 gtk_widget_destroy(messageview
->window
);
2529 static void next_labeled_cb(GtkAction
*action
, gpointer data
)
2531 MessageView
*messageview
= (MessageView
*)data
;
2532 messageview
->updating
= TRUE
;
2533 summary_select_next_labeled(messageview
->mainwin
->summaryview
);
2534 messageview
->updating
= FALSE
;
2536 if (messageview
->deferred_destroy
) {
2537 debug_print("messageview got away!\n");
2538 messageview_destroy(messageview
);
2541 if (messageview
->mainwin
->summaryview
->selected
) {
2542 #ifndef GENERIC_UMPC
2543 MsgInfo
* msginfo
= summary_get_selected_msg(messageview
->mainwin
->summaryview
);
2546 messageview_show(messageview
, msginfo
,
2547 messageview
->all_headers
);
2550 gtk_widget_destroy(messageview
->window
);
2554 static void prev_history_cb(GtkAction
*action
, gpointer data
)
2556 MessageView
*messageview
= (MessageView
*)data
;
2557 MsgInfo
*info
= messageview_nav_get_prev(messageview
);
2559 messageview
->updating
= TRUE
;
2560 messageview_show(messageview
, info
,
2561 messageview
->all_headers
);
2562 messageview
->updating
= FALSE
;
2563 procmsg_msginfo_free(&info
);
2564 if (messageview
->deferred_destroy
) {
2565 debug_print("messageview got away!\n");
2566 messageview_destroy(messageview
);
2572 static void next_history_cb(GtkAction
*action
, gpointer data
)
2574 MessageView
*messageview
= (MessageView
*)data
;
2575 MsgInfo
*info
= messageview_nav_get_next(messageview
);
2577 messageview
->updating
= TRUE
;
2578 messageview_show(messageview
, info
,
2579 messageview
->all_headers
);
2580 messageview
->updating
= FALSE
;
2581 procmsg_msginfo_free(&info
);
2582 if (messageview
->deferred_destroy
) {
2583 debug_print("messageview got away!\n");
2584 messageview_destroy(messageview
);
2590 static void parent_cb(GtkAction
*action
, gpointer data
)
2592 MessageView
*messageview
= (MessageView
*)data
;
2593 messageview
->updating
= TRUE
;
2594 summary_select_parent(messageview
->mainwin
->summaryview
);
2595 messageview
->updating
= FALSE
;
2597 if (messageview
->deferred_destroy
) {
2598 debug_print("messageview got away!\n");
2599 messageview_destroy(messageview
);
2602 if (messageview
->mainwin
->summaryview
->selected
) {
2603 #ifndef GENERIC_UMPC
2604 MsgInfo
* msginfo
= summary_get_selected_msg(messageview
->mainwin
->summaryview
);
2607 messageview_show(messageview
, msginfo
,
2608 messageview
->all_headers
);
2611 gtk_widget_destroy(messageview
->window
);
2615 static void goto_unread_folder_cb(GtkAction
*action
, gpointer data
)
2617 MessageView
*messageview
= (MessageView
*)data
;
2619 messageview
->updating
= TRUE
;
2620 folderview_select_next_with_flag(messageview
->mainwin
->folderview
, MSG_UNREAD
);
2621 messageview
->updating
= FALSE
;
2623 if (messageview
->deferred_destroy
) {
2624 debug_print("messageview got away!\n");
2625 messageview_destroy(messageview
);
2628 if (messageview
->mainwin
->summaryview
->selected
) {
2629 #ifndef GENERIC_UMPC
2630 MsgInfo
* msginfo
= summary_get_selected_msg(messageview
->mainwin
->summaryview
);
2633 messageview_show(messageview
, msginfo
,
2634 messageview
->all_headers
);
2637 gtk_widget_destroy(messageview
->window
);
2641 static void goto_folder_cb(GtkAction
*action
, gpointer data
)
2643 MessageView
*messageview
= (MessageView
*)data
;
2644 FolderItem
*to_folder
;
2646 to_folder
= foldersel_folder_sel(NULL
, FOLDER_SEL_ALL
, NULL
, FALSE
,
2647 _("Select folder to go to"));
2650 folderview_select(messageview
->mainwin
->folderview
, to_folder
);
2652 if (messageview
->deferred_destroy
) {
2653 debug_print("messageview got away!\n");
2654 messageview_destroy(messageview
);
2657 if (messageview
->mainwin
->summaryview
->selected
) {
2658 #ifndef GENERIC_UMPC
2659 MsgInfo
* msginfo
= summary_get_selected_msg(messageview
->mainwin
->summaryview
);
2662 messageview_show(messageview
, msginfo
,
2663 messageview
->all_headers
);
2666 gtk_widget_destroy(messageview
->window
);
2671 static void scroll_prev_line_cb(GtkAction
*action
, gpointer data
)
2673 MessageView
*messageview
= (MessageView
*)data
;
2674 mimeview_scroll_one_line(messageview
->mimeview
,TRUE
);
2677 static void scroll_next_line_cb(GtkAction
*action
, gpointer data
)
2679 MessageView
*messageview
= (MessageView
*)data
;
2680 mimeview_scroll_one_line(messageview
->mimeview
,FALSE
);
2683 static void scroll_prev_page_cb(GtkAction
*action
, gpointer data
)
2685 MessageView
*messageview
= (MessageView
*)data
;
2686 mimeview_scroll_page(messageview
->mimeview
,TRUE
);
2689 static void scroll_next_page_cb(GtkAction
*action
, gpointer data
)
2691 MessageView
*messageview
= (MessageView
*)data
;
2692 mimeview_scroll_page(messageview
->mimeview
,FALSE
);
2695 static void set_charset_cb(GtkAction
*action
, GtkRadioAction
*current
, gpointer data
)
2697 MessageView
*messageview
= (MessageView
*)data
;
2698 gboolean active
= gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (current
));
2699 gint value
= gtk_radio_action_get_current_value (GTK_RADIO_ACTION (current
));
2700 const gchar
*charset
;
2703 charset
= conv_get_charset_str((CharSet
)value
);
2704 g_free(messageview
->forced_charset
);
2705 messageview
->forced_charset
= g_strdup(charset
);
2706 procmime_force_charset(charset
);
2708 messageview_show(messageview
, messageview
->msginfo
, FALSE
);
2712 static void set_decode_cb(GtkAction
*action
, GtkRadioAction
*current
, gpointer data
)
2714 MessageView
*messageview
= (MessageView
*)data
;
2715 gboolean active
= gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (current
));
2716 gint value
= gtk_radio_action_get_current_value (GTK_RADIO_ACTION (current
));
2719 messageview
->forced_encoding
= (EncodingType
)value
;
2721 messageview_show(messageview
, messageview
->msginfo
, FALSE
);
2722 debug_print("forced encoding: %d\n", value
);
2727 static void view_source_cb(GtkAction
*action
, gpointer data
)
2729 MessageView
*messageview
= (MessageView
*)data
;
2730 SourceWindow
*srcwin
;
2732 if (!messageview
->msginfo
) return;
2734 srcwin
= source_window_create();
2735 source_window_show_msg(srcwin
, messageview
->msginfo
);
2736 source_window_show(srcwin
);
2739 static void show_all_header_cb(GtkToggleAction
*action
, gpointer data
)
2741 MessageView
*messageview
= (MessageView
*)data
;
2742 MsgInfo
*msginfo
= messageview
->msginfo
;
2744 if (messageview
->mimeview
->textview
&&
2745 messageview
->mimeview
->textview
->loading
) {
2748 if (messageview
->updating
)
2751 messageview
->all_headers
= prefs_common
.show_all_headers
=
2752 gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action
));
2753 if (!msginfo
) return;
2754 messageview
->msginfo
= NULL
;
2755 messageview_show(messageview
, msginfo
, messageview
->all_headers
);
2756 procmsg_msginfo_free(&msginfo
);
2757 main_window_set_menu_sensitive(messageview
->mainwin
);
2758 summary_redisplay_msg(messageview
->mainwin
->summaryview
);
2761 static void msg_hide_quotes_cb(GtkToggleAction
*action
, gpointer data
)
2763 MessageView
*messageview
= (MessageView
*)data
;
2764 MsgInfo
*msginfo
= messageview
->msginfo
;
2765 static gboolean updating_menu
= FALSE
;
2769 if (gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action
))) {
2770 const gchar
*a_name
= gtk_action_get_name(GTK_ACTION(action
));
2771 if (!strcmp(a_name
, "View/Quotes/CollapseAll")) prefs_common
.hide_quotes
= 1;
2772 else if (!strcmp(a_name
, "View/Quotes/Collapse2")) prefs_common
.hide_quotes
= 2;
2773 else if (!strcmp(a_name
, "View/Quotes/Collapse3")) prefs_common
.hide_quotes
= 3;
2775 prefs_common
.hide_quotes
= 0;
2779 cm_toggle_menu_set_active_full(messageview
->ui_manager
, "Menu/View/Quotes/CollapseAll", (prefs_common
.hide_quotes
== 1));
2780 cm_toggle_menu_set_active_full(messageview
->ui_manager
, "Menu/View/Quotes/Collapse2", (prefs_common
.hide_quotes
== 2));
2781 cm_toggle_menu_set_active_full(messageview
->ui_manager
, "Menu/View/Quotes/Collapse3", (prefs_common
.hide_quotes
== 3));
2783 updating_menu
=FALSE
;
2784 if (!msginfo
) return;
2785 messageview
->msginfo
= NULL
;
2786 messageview_show(messageview
, msginfo
,
2787 messageview
->all_headers
);
2788 procmsg_msginfo_free(&msginfo
);
2790 /* update main window */
2791 main_window_set_menu_sensitive(messageview
->mainwin
);
2792 summary_redisplay_msg(messageview
->mainwin
->summaryview
);
2794 #undef SET_CHECK_MENU_ACTIVE
2796 static void compose_cb(GtkAction
*action
, gpointer data
)
2798 MessageView
*messageview
= (MessageView
*)data
;
2799 PrefsAccount
*ac
= NULL
;
2800 FolderItem
*item
= NULL
;
2802 if (messageview
->msginfo
)
2803 item
= messageview
->msginfo
->folder
;
2806 ac
= account_find_from_item(item
);
2807 if (ac
&& ac
->protocol
== A_NNTP
&&
2808 FOLDER_TYPE(item
->folder
) == F_NEWS
) {
2809 compose_new(ac
, item
->path
, NULL
);
2814 compose_new(ac
, NULL
, NULL
);
2817 #define DO_ACTION(name, act) { if (!strcmp(a_name, name)) action = act; }
2819 static void reply_cb(GtkAction
*gaction
, gpointer data
)
2821 MessageView
*messageview
= (MessageView
*)data
;
2822 GSList
*msginfo_list
= NULL
;
2823 gint action
= COMPOSE_REPLY
;
2824 const gchar
*a_name
= gtk_action_get_name(gaction
);
2826 cm_return_if_fail(messageview
->msginfo
);
2828 DO_ACTION("Message/Reply", COMPOSE_REPLY
);
2829 DO_ACTION("Message/ReplyTo/All", COMPOSE_REPLY_TO_ALL
);
2830 DO_ACTION("Message/ReplyTo/Sender", COMPOSE_REPLY_TO_SENDER
);
2831 DO_ACTION("Message/ReplyTo/List", COMPOSE_REPLY_TO_LIST
);
2832 DO_ACTION("Message/Forward", COMPOSE_FORWARD_INLINE
);
2833 DO_ACTION("Message/ForwardAtt", COMPOSE_FORWARD_AS_ATTACH
);
2834 DO_ACTION("Message/Redirect", COMPOSE_REDIRECT
);
2836 msginfo_list
= g_slist_append(msginfo_list
, messageview
->msginfo
);
2837 compose_reply_from_messageview(messageview
, msginfo_list
, action
);
2838 g_slist_free(msginfo_list
);
2841 static void addressbook_open_cb(GtkAction
*action
, gpointer data
)
2843 #ifndef USE_ALT_ADDRBOOK
2844 addressbook_open(NULL
);
2846 GError
* error
= NULL
;
2848 addressbook_dbus_open(FALSE
, &error
);
2850 g_warning("failed to open address book: %s", error
->message
);
2851 g_error_free(error
);
2856 static void add_address_cb(GtkAction
*action
, gpointer data
)
2858 MessageView
*messageview
= (MessageView
*)data
;
2859 MsgInfo
*msginfo
, *full_msginfo
;
2861 GdkPixbuf
*picture
= NULL
;
2862 AvatarRender
*avatarr
;
2864 if (!messageview
->msginfo
|| !messageview
->msginfo
->from
)
2867 msginfo
= messageview
->msginfo
;
2868 Xstrdup_a(from
, msginfo
->from
, return);
2869 eliminate_address_comment(from
);
2870 extract_address(from
);
2872 full_msginfo
= procmsg_msginfo_get_full_info(msginfo
);
2874 avatarr
= avatars_avatarrender_new(full_msginfo
);
2875 hooks_invoke(AVATAR_IMAGE_RENDER_HOOKLIST
, avatarr
);
2877 procmsg_msginfo_free(&full_msginfo
);
2879 if (avatarr
->image
!= NULL
)
2880 picture
= gtk_image_get_pixbuf(GTK_IMAGE(avatarr
->image
));
2882 #ifndef USE_ALT_ADDRBOOK
2883 addressbook_add_contact(msginfo
->fromname
, from
, NULL
, picture
);
2885 if (addressadd_selection(msginfo
->fromname
, from
, NULL
, picture
)) {
2886 debug_print( "addressbook_add_contact - added\n" );
2889 avatars_avatarrender_free(avatarr
);
2892 static void create_filter_cb(GtkAction
*gaction
, gpointer data
)
2894 MessageView
*messageview
= (MessageView
*)data
;
2897 const gchar
*a_name
= gtk_action_get_name(gaction
);
2899 if (!messageview
->msginfo
) return;
2901 DO_ACTION("Tools/CreateFilterRule/Automatically", FILTER_BY_AUTO
);
2902 DO_ACTION("Tools/CreateFilterRule/ByFrom", FILTER_BY_FROM
);
2903 DO_ACTION("Tools/CreateFilterRule/ByTo", FILTER_BY_TO
);
2904 DO_ACTION("Tools/CreateFilterRule/BySubject", FILTER_BY_SUBJECT
);
2905 DO_ACTION("Tools/CreateFilterRule/BySender", FILTER_BY_SENDER
);
2907 item
= messageview
->msginfo
->folder
;
2908 summary_msginfo_filter_open(item
, messageview
->msginfo
,
2909 (PrefsFilterType
)action
, 0);
2912 static void create_processing_cb(GtkAction
*gaction
, gpointer data
)
2914 MessageView
*messageview
= (MessageView
*)data
;
2917 const gchar
*a_name
= gtk_action_get_name(gaction
);
2919 if (!messageview
->msginfo
) return;
2921 DO_ACTION("Tools/CreateProcessingRule/Automatically", FILTER_BY_AUTO
);
2922 DO_ACTION("Tools/CreateProcessingRule/ByFrom", FILTER_BY_FROM
);
2923 DO_ACTION("Tools/CreateProcessingRule/ByTo", FILTER_BY_TO
);
2924 DO_ACTION("Tools/CreateProcessingRule/BySubject", FILTER_BY_SUBJECT
);
2925 DO_ACTION("Tools/CreateProcessingRule/BySender", FILTER_BY_SENDER
);
2927 item
= messageview
->msginfo
->folder
;
2928 summary_msginfo_filter_open(item
, messageview
->msginfo
,
2929 (PrefsFilterType
)action
, 1);
2932 static void open_urls_cb(GtkAction
*action
, gpointer data
)
2934 MessageView
*messageview
= (MessageView
*)data
;
2935 messageview_list_urls(messageview
);
2938 static void about_cb(GtkAction
*gaction
, gpointer data
)
2943 static gboolean
messageview_update_msg(gpointer source
, gpointer data
)
2945 MsgInfoUpdate
*msginfo_update
= (MsgInfoUpdate
*) source
;
2946 MessageView
*messageview
= (MessageView
*)data
;
2947 MsgInfo
*old_msginfo
= messageview
->msginfo
;
2949 if (messageview
->msginfo
!= msginfo_update
->msginfo
)
2952 if ((msginfo_update
->flags
& MSGINFO_UPDATE_DELETED
) ||
2953 MSG_IS_DELETED(old_msginfo
->flags
)) {
2954 if (messageview
->new_window
) {
2955 if (old_msginfo
->folder
&& old_msginfo
->folder
->total_msgs
== 0) {
2956 messageview_clear(messageview
);
2957 textview_show_info(messageview
->mimeview
->textview
,
2958 _("\n There are no messages in this folder"));
2962 if (!OPEN_SELECTED_ON_DELETEMOVE
&& !OPEN_SELECTED_ON_PREVNEXT
) {
2963 messageview_clear(messageview
);
2964 textview_show_info(messageview
->mimeview
->textview
,
2965 MSG_IS_DELETED(old_msginfo
->flags
) ?
2966 _("\n Message has been deleted") :
2967 _("\n Message has been deleted or moved to another folder"));
2969 messageview
->update_needed
= TRUE
;
2971 messageview_clear(messageview
);
2972 messageview_update(messageview
, old_msginfo
);
2979 void messageview_set_menu_sensitive(MessageView
*messageview
)
2981 if (!messageview
|| !messageview
->ui_manager
)
2984 cm_toggle_menu_set_active_full(messageview
->ui_manager
, "Menu/View/Quotes/CollapseAll", (prefs_common
.hide_quotes
== 1));
2985 cm_toggle_menu_set_active_full(messageview
->ui_manager
, "Menu/View/Quotes/Collapse2", (prefs_common
.hide_quotes
== 2));
2986 cm_toggle_menu_set_active_full(messageview
->ui_manager
, "Menu/View/Quotes/Collapse3", (prefs_common
.hide_quotes
== 3));
2987 cm_menu_set_sensitive_full(messageview
->ui_manager
, "Menu/View/Goto/PrevHistory", messageview_nav_has_prev(messageview
));
2988 cm_menu_set_sensitive_full(messageview
->ui_manager
, "Menu/View/Goto/NextHistory", messageview_nav_has_next(messageview
));
2990 cm_menu_set_sensitive_full(messageview
->ui_manager
, "Menu/Message/CheckSignature", messageview
->mimeview
->signed_part
);
2993 void messageview_learn (MessageView
*msgview
, gboolean is_spam
)
2996 if (procmsg_spam_learner_learn(msgview
->msginfo
, NULL
, TRUE
) == 0)
2997 procmsg_msginfo_set_flags(msgview
->msginfo
, MSG_SPAM
, 0);
2999 log_error(LOG_PROTOCOL
, _("An error happened while learning.\n"));
3002 if (procmsg_spam_learner_learn(msgview
->msginfo
, NULL
, FALSE
) == 0)
3003 procmsg_msginfo_unset_flags(msgview
->msginfo
, MSG_SPAM
, 0);
3005 log_error(LOG_PROTOCOL
, _("An error happened while learning.\n"));
3007 if (msgview
->toolbar
)
3008 toolbar_set_learn_button
3010 MSG_IS_SPAM(msgview
->msginfo
->flags
)?LEARN_HAM
:LEARN_SPAM
);
3012 toolbar_set_learn_button
3013 (msgview
->mainwin
->toolbar
,
3014 MSG_IS_SPAM(msgview
->msginfo
->flags
)?LEARN_HAM
:LEARN_SPAM
);
3017 void messageview_list_urls (MessageView
*msgview
)
3019 GSList
*cur
= msgview
->mimeview
->textview
->uri_list
;
3020 GSList
*newlist
= NULL
;
3021 GHashTable
*uri_hashtable
;
3024 uri_hashtable
= g_hash_table_new_full(g_str_hash
, g_str_equal
,
3025 (GDestroyNotify
) g_free
, NULL
);
3027 for (; cur
; cur
= cur
->next
) {
3028 ClickableText
*uri
= (ClickableText
*)cur
->data
;
3030 (!g_ascii_strncasecmp(uri
->uri
, "ftp.", 4) ||
3031 !g_ascii_strncasecmp(uri
->uri
, "ftp:", 4) ||
3032 !g_ascii_strncasecmp(uri
->uri
, "ftps:", 5) ||
3033 !g_ascii_strncasecmp(uri
->uri
, "sftp:", 5) ||
3034 !g_ascii_strncasecmp(uri
->uri
, "www.", 4) ||
3035 !g_ascii_strncasecmp(uri
->uri
, "webcal:", 7) ||
3036 !g_ascii_strncasecmp(uri
->uri
, "webcals:", 8) ||
3037 !g_ascii_strncasecmp(uri
->uri
, "http:", 5) ||
3038 !g_ascii_strncasecmp(uri
->uri
, "https:", 6)))
3040 tmp
= g_utf8_strdown(uri
->uri
, -1);
3042 if (g_hash_table_lookup(uri_hashtable
, tmp
)) {
3047 newlist
= g_slist_prepend(newlist
, uri
);
3048 g_hash_table_insert(uri_hashtable
, tmp
,
3049 GUINT_TO_POINTER(g_str_hash(tmp
)));
3052 newlist
= g_slist_reverse(newlist
);
3053 uri_opener_open(msgview
, newlist
);
3054 g_slist_free(newlist
);
3055 g_hash_table_destroy(uri_hashtable
);
3058 static void save_part_as_cb(GtkAction
*action
, gpointer data
)
3060 MessageView
*messageview
= (MessageView
*)data
;
3062 if (messageview
->mimeview
)
3063 mimeview_save_as(messageview
->mimeview
);
3066 static void view_part_as_text_cb(GtkAction
*action
, gpointer data
)
3068 MessageView
*messageview
= (MessageView
*)data
;
3070 if (messageview
->mimeview
)
3071 mimeview_display_as_text(messageview
->mimeview
);
3074 static void open_part_cb(GtkAction
*action
, gpointer data
)
3076 MessageView
*messageview
= (MessageView
*)data
;
3078 if (messageview
->mimeview
)
3079 mimeview_launch(messageview
->mimeview
, NULL
);
3082 static void open_part_with_cb(GtkAction
*action
, gpointer data
)
3084 MessageView
*messageview
= (MessageView
*)data
;
3086 if (messageview
->mimeview
)
3087 mimeview_open_with(messageview
->mimeview
);
3090 static void check_signature_cb(GtkAction
*action
, gpointer data
)
3092 MessageView
*messageview
= (MessageView
*)data
;
3094 if (messageview
->mimeview
)
3095 mimeview_check_signature(messageview
->mimeview
);
3098 static void goto_next_part_cb(GtkAction
*action
, gpointer data
)
3100 MessageView
*messageview
= (MessageView
*)data
;
3102 if (messageview
->mimeview
)
3103 mimeview_select_next_part(messageview
->mimeview
);
3106 static void goto_prev_part_cb(GtkAction
*action
, gpointer data
)
3108 MessageView
*messageview
= (MessageView
*)data
;
3110 if (messageview
->mimeview
)
3111 mimeview_select_prev_part(messageview
->mimeview
);