Properly handle download of parts for forwarding subpart messages
[modest] / src / widgets / modest-msg-view-window.h
1 /* Copyright (c) 2006,2007 Nokia Corporation
2  * All rights reserved.
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions are
6  * met:
7  *
8  * * Redistributions of source code must retain the above copyright
9  *   notice, this list of conditions and the following disclaimer.
10  * * Redistributions in binary form must reproduce the above copyright
11  *   notice, this list of conditions and the following disclaimer in the
12  *   documentation and/or other materials provided with the distribution.
13  * * Neither the name of the Nokia Corporation nor the names of its
14  *   contributors may be used to endorse or promote products derived from
15  *   this software without specific prior written permission.
16  *
17  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
18  * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
19  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
20  * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
21  * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
22  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
23  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
24  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
25  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
26  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
27  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28  */
29
30 #ifndef __MODEST_MSG_VIEW_WINDOW_H__
31 #define __MODEST_MSG_VIEW_WINDOW_H__
32
33 #include <tny-msg.h>
34 #include <tny-folder.h>
35 #ifdef MODEST_TOOLKIT_HILDON2
36 #include <modest-hildon2-window.h>
37 #endif
38 #include <widgets/modest-window.h>
39 #include <widgets/modest-header-view.h>
40 #include <gtk/gtktreemodel.h>
41 #include <gtk/gtkenums.h>
42
43 G_BEGIN_DECLS
44
45 /* convenience macros */
46 #define MODEST_TYPE_MSG_VIEW_WINDOW             (modest_msg_view_window_get_type())
47 #define MODEST_MSG_VIEW_WINDOW(obj)             (G_TYPE_CHECK_INSTANCE_CAST((obj),MODEST_TYPE_MSG_VIEW_WINDOW,ModestMsgViewWindow))
48 #define MODEST_MSG_VIEW_WINDOW_CLASS(klass)     (G_TYPE_CHECK_CLASS_CAST((klass),MODEST_TYPE_MSG_VIEW_WINDOW,ModestWindow))
49 #define MODEST_IS_MSG_VIEW_WINDOW(obj)          (G_TYPE_CHECK_INSTANCE_TYPE((obj),MODEST_TYPE_MSG_VIEW_WINDOW))
50 #define MODEST_IS_MSG_VIEW_WINDOW_CLASS(klass)  (G_TYPE_CHECK_CLASS_TYPE((klass),MODEST_TYPE_MSG_VIEW_WINDOW))
51 #define MODEST_MSG_VIEW_WINDOW_GET_CLASS(obj)   (G_TYPE_INSTANCE_GET_CLASS((obj),MODEST_TYPE_MSG_VIEW_WINDOW,ModestMsgVIewWindowClass))
52
53
54 typedef struct {
55 #ifdef MODEST_TOOLKIT_HILDON2
56         ModestHildon2Window parent;
57 #else
58         ModestWindow parent;
59 #endif
60 } ModestMsgViewWindow;
61         
62 typedef struct {
63 #ifdef MODEST_TOOLKIT_HILDON2
64         ModestHildon2WindowClass parent_class;
65 #else
66         ModestWindowClass parent_class;
67 #endif
68
69         void (*msg_changed) (ModestMsgViewWindow *self,
70                              GtkTreeModel *model,
71                              GtkTreeRowReference *row_reference, 
72                              gpointer user_data);
73
74         gboolean (*scroll_child) (ModestMsgViewWindow *self,
75                                    GtkScrollType scroll_type,
76                                    gboolean horizontal,
77                                    gpointer userdata);
78 } ModestMsgViewWindowClass;
79
80 /**
81  * modest_msg_view_window_get_type:
82  * 
83  * get the GType for the #ModestMsgViewWindow class
84  *
85  * Returns: a GType for #ModestMsgViewWindow
86  */
87 GType        modest_msg_view_window_get_type    (void) G_GNUC_CONST;
88         
89
90 /**
91  * modest_msg_view_window_new_for_attachment:
92  * @msg: an #TnyMsg instance
93  * @modest_account_name: the account name 
94  * @mailbox: the mailbox (if any)
95  * 
96  * instantiates a new #ModestMsgViewWindow widget to view a message that is an
97  * attachment in another message.
98  * The account name is used to
99  * set the proper account when choosing reply/forward from the msg view window
100  *
101  * Returns: a new #ModestMsgViewWindow, or NULL in case of error
102  */
103 ModestWindow*   modest_msg_view_window_new_for_attachment         (TnyMsg *msg, 
104                                                                    TnyMsg *top_msg,
105                                                                    const gchar *modest_account_name,
106                                                                    const gchar *mailbox,
107                                                                    const gchar *msg_uid);
108
109 /**
110  * modest_msg_view_window_new_with_other_body:
111  * @msg: an #TnyMsg instance
112  * @modest_account_name: the account name 
113  * @mailbox: the mailbox (if any)
114  * 
115  * instantiates a new #ModestMsgViewWindow widget to view a message that is a different body
116  * in another message.
117  * The account name is used to
118  * set the proper account when choosing reply/forward from the msg view window
119  *
120  * Returns: a new #ModestMsgViewWindow, or NULL in case of error
121  */
122 ModestWindow*   modest_msg_view_window_new_with_other_body         (TnyMsg *msg,
123                                                                    TnyMimePart *other_body,
124                                                                    TnyMsg *top_msg,
125                                                                    const gchar *modest_account_name,
126                                                                    const gchar *mailbox,
127                                                                    const gchar *msg_uid);
128
129 /**
130  * modest_msg_view_window_is_other_body:
131  * @self: a #ModestMsgViewWindow
132  *
133  * tells if the view window is showing other body
134  *
135  * Returns: %TRUE if showing "not first body"
136  */
137 gboolean modest_msg_view_window_is_other_body (ModestMsgViewWindow *self);
138
139 /**
140  * modest_msg_view_window_new_with_header_model:
141  * @msg: an #TnyMsg instance
142  * @modest_account_name: the account name 
143  * @mailbox: the mailbox (if any)
144  * @model: a #GtkTreeModel, with the format used by #ModestHeaderView
145  * @row_reference: a #GtkTreeRowReference, pointing to the position of @msg in @model.
146  * 
147  * instantiates a new #ModestMsgViewWindow widget. The account name is used to
148  * set the proper account when choosing reply/forward from the msg view window.
149  * This constructor also passes a reference to the @model of the header view
150  * to allow selecting previous/next messages in the message list when appropriate.
151  *
152  * Returns: a new #ModestMsgViewWindow, or NULL in case of error
153  */
154 ModestWindow*   modest_msg_view_window_new_with_header_model (TnyMsg *msg, 
155                                                               const gchar *modest_account_name, 
156                                                               const gchar *mailbox,
157                                                               const gchar *msg_uid,
158                                                               GtkTreeModel *model, 
159                                                               GtkTreeRowReference *row_reference);
160
161 /**
162  * modest_msg_view_window_new_from_header_view:
163  * @header_view: an #ModestHeaderView instance
164  * @modest_account_name: the account name 
165  * @mailbox: the mailbox (if any)
166  * @msg_uid: the initial uid reserved by this window
167  * @row_reference: a #GtkTreeRowReference, pointing to the selected position @model.
168  * 
169  * instantiates a new #ModestMsgViewWindow widget. The account name is used to
170  * set the proper account when choosing reply/forward from the msg view window.
171  * It's different from new_with_header_model, as it creates the window and then
172  * loads the message in that window.
173  *
174  * Returns: a new #ModestMsgViewWindow, or NULL in case of error
175  */
176 ModestWindow*   modest_msg_view_window_new_from_header_view (ModestHeaderView *header_view, 
177                                                              const gchar *modest_account_name, 
178                                                              const gchar *mailbox,
179                                                              const gchar *msg_uid,
180                                                              GtkTreeRowReference *row_reference);
181
182
183 /**
184  * modest_msg_view_window_new_from_uid:
185  */
186 ModestWindow *
187 modest_msg_view_window_new_from_uid (const gchar *modest_account_name,
188                                      const gchar *mailbox,
189                                      const gchar *msg_uid);
190                                               
191 /**
192  * modest_msg_view_window_new_for_search_result:
193  * @msg: an #TnyMsg instance
194  * @modest_account_name: the account name 
195  * 
196  * instantiates a new #ModestMsgViewWindow widget. The account name is used to
197  * set the proper account when choosing reply/forward from the msg view window.
198  * This constructor marks the window as being for a search result, which should 
199  * cause some UI to be disabled, such as the previous/next buttons.
200  *
201  * Returns: a new #ModestMsgViewWindow, or NULL in case of error
202  */
203 ModestWindow *
204 modest_msg_view_window_new_for_search_result (TnyMsg *msg, 
205                                               const gchar *modest_account_name,
206                                               const gchar *mailbox,
207                                               const gchar *msg_uid);
208                                               
209 /**
210  * modest_msg_view_window_get_header:
211  * @window: an #ModestMsgViewWindow instance
212  * 
213  * get the message header in this msg view. Header instance is get
214  * from tree_model of headers list. 
215  * 
216  * Returns: a new #TnyHeader instance, or NULL in case of error
217  */
218 TnyHeader*
219 modest_msg_view_window_get_header (ModestMsgViewWindow *self);
220
221 /**
222  * modest_msg_view_window_get_message:
223  * @window: an #ModestMsgViewWindow instance
224  * 
225  * get a new reference to the message in this msg view. The caller
226  * must free this new reference
227  * 
228  * Returns: a new #TnyMsg instance, or NULL in case of error
229  */
230 TnyMsg*         modest_msg_view_window_get_message     (ModestMsgViewWindow *window);
231
232 /**
233  * modest_msg_view_window_get_top_message:
234  * @window: an #ModestMsgViewWindow instance
235  * 
236  * get a new reference to the parent message of the tree of views. The caller
237  * must free this new reference
238  * 
239  * Returns: a new #TnyMsg instance, or NULL in case of error
240  */
241 TnyMsg*         modest_msg_view_window_get_top_message     (ModestMsgViewWindow *window);
242
243 /**
244  * modest_msg_view_window_get_message_uid:
245  * @msg: an #ModestMsgViewWindow instance
246  * 
247  * gets the unique identifier for the message in this msg view. The
248  * returned value *must* not be freed
249  * 
250  * Returns: the id of the #TnyMsg being shown, or NULL in case of error
251  */
252 const gchar*    modest_msg_view_window_get_message_uid (ModestMsgViewWindow *window);
253
254 /**
255  * modest_msg_view_window_select_next_message:
256  * @window: a #ModestMsgViewWindow instance
257  *
258  * select the next message obtained from the header view this view 
259  * was called from
260  *
261  * Returns: %TRUE if a new message is shown.
262  */
263 gboolean        modest_msg_view_window_select_next_message (ModestMsgViewWindow *window);
264
265 /**
266  * modest_msg_view_window_select_previous_message:
267  * @window: a #ModestMsgViewWindow instance
268  *
269  * select the previous message obtained from the header view this view 
270  * was called from
271  *
272  * Returns: %TRUE if a new message is shown.
273  */
274 gboolean        modest_msg_view_window_select_previous_message (ModestMsgViewWindow *window);
275
276 /**
277  * modest_msg_view_window_view_attachment:
278  * @window: a #ModestMsgViewWindow
279  * @mime_part: a #TnyMimePart
280  *
281  * Opens @mime_part, or the currently selected attachment if @mime_part is %NULL. 
282  * If it's a message, it opens it  for viewing. Otherwise it opens a temporary file 
283  * with the contents of the attachment.
284  */
285 void            modest_msg_view_window_view_attachment (ModestMsgViewWindow *window,
286                                                         TnyMimePart *mime_part);
287
288 /**
289  * modest_msg_view_window_get_attachments:
290  * @window: a #ModestMsgViewWindow
291  *
292  * Get selected attachments from #ModetMsgView private object.  
293  */
294 TnyList *         modest_msg_view_window_get_attachments (ModestMsgViewWindow *win);
295
296 /**
297  * modest_msg_view_window_save_attachments:
298  * @window: a #ModestMsgViewWindow
299  * @mime_parts: a #TnyList of #TnyMimePart
300  *
301  * Save the #TnyMimePart attachments in @mime_parts, or currently selected attachments
302  * if @mime_parts is %NULL, offering a dialog to the user to choose the location.
303  */
304 void            modest_msg_view_window_save_attachments (ModestMsgViewWindow *window,
305                                                          TnyList *mime_parts);
306
307 /**
308  * modest_msg_view_window_remove_attachments:
309  * @window: a #ModestMsgViewWindow
310  * @get_all: a #gboolean. If %TRUE, purges all attachmnents, if %FALSE,
311  * purges only selected ones.
312  *
313  * Removes selected attachments.
314  */
315 void            modest_msg_view_window_remove_attachments (ModestMsgViewWindow *window,
316                                                            gboolean get_all);
317
318
319 /**
320  * modest_msg_view_window_toolbar_on_transfer_mode:
321  * @window: a #ModestMsgViewWindow
322  *
323  * Check if toolbar is in transfer mode, which determines whether a
324  * transfer operation is being processed.
325  */
326 gboolean  modest_msg_view_window_toolbar_on_transfer_mode     (ModestMsgViewWindow *self);
327
328
329 /**
330  * modest_msg_view_window_last_message_selected:
331  * @window: a #ModestMsgViewWindow
332  *
333  * Check message currently viewed is the last message into folder . 
334 */
335 gboolean modest_msg_view_window_last_message_selected (ModestMsgViewWindow *window); 
336
337
338 /**
339  * modest_msg_view_window_first_message_selected:
340  * @window: a #ModestMsgViewWindow
341  *
342  * Check message currently viewed is the last message into folder . 
343 */
344 gboolean modest_msg_view_window_first_message_selected (ModestMsgViewWindow *window);
345
346 /**
347  * modest_msg_view_window_has_headers_model:
348  * @window: a #ModestMsgViewWindow
349  *
350  * Check if window has been created with a full headers model. 
351 */
352 gboolean modest_msg_view_window_has_headers_model (ModestMsgViewWindow *window);
353
354 /**
355  * modest_msg_view_window_is_search_result:
356  * @window: a #ModestMsgViewWindow
357  *
358  * Check if window has been created to show a search result. 
359  */
360 gboolean modest_msg_view_window_is_search_result (ModestMsgViewWindow *window);
361
362
363 /**
364  * modest_msg_view_window_get_folder_type:
365  * @window: a #ModestMsgViewWindow
366  *
367  * Gets folder type of message currently viewed . 
368 */
369 TnyFolderType
370 modest_msg_view_window_get_folder_type (ModestMsgViewWindow *window);
371
372 /**
373  * modest_msg_view_window_transfer_mode_enabled:
374  * @window: a #ModestMsgViewWindow
375  *
376  * Determines if some transfer operation is in progress.
377  *
378  * Returns: TRUE if transfer mode is enabled, FASE otherwise.
379 */
380 gboolean 
381 modest_msg_view_window_transfer_mode_enabled (ModestMsgViewWindow *self);
382
383 /**
384  * modest_msg_view_window_add_to_contacts:
385  * @self: a #ModestMsgViewWindow
386  *
387  * activates the add to contacts use case. In Diablo and gnome it gets the
388  * clipboard selection current value and tries to add it to the addressbook.
389  * In fremantle, it shows the add to contacts dialog to select the recipient
390  * to add.
391  */
392 void
393 modest_msg_view_window_add_to_contacts (ModestMsgViewWindow *self);
394
395 /**
396  * modest_msg_view_window_get_msg_view:
397  * @self: a #ModestMsgViewWindow
398  *
399  * Tells that external images should be fetched in this window.
400  */
401 void
402 modest_msg_view_window_fetch_images (ModestMsgViewWindow *self);
403
404 /**
405  * modest_msg_view_window_has_blocked_external_images:
406  * @self: a #ModestMsgViewWindow
407  * 
408  * checks if the msg currently shown has blocked external images.
409  *
410  * Returns: %TRUE if external images are blocked, %FALSE otherwise
411  */
412 gboolean modest_msg_view_window_has_blocked_external_images (ModestMsgViewWindow *self);
413
414 /**
415  * modest_msg_view_window_reload:
416  * @self: a #ModestMsgViewWindow
417  *
418  * Reloads currently loaded message. This is intended to show the message in case it
419  * has some update on the previously visible result.
420  */
421 void modest_msg_view_window_reload (ModestMsgViewWindow *self);
422
423 G_END_DECLS
424
425 #endif /* __MODEST_MSG_VIEW_WINDOW_H__ */
426