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 #else
38 #include <modest-shell-window.h>
39 #endif
40 #include <widgets/modest-window.h>
41 #include <widgets/modest-header-view.h>
42 #include <gtk/gtk.h>
43
44 G_BEGIN_DECLS
45
46 /* convenience macros */
47 #define MODEST_TYPE_MSG_VIEW_WINDOW             (modest_msg_view_window_get_type())
48 #define MODEST_MSG_VIEW_WINDOW(obj)             (G_TYPE_CHECK_INSTANCE_CAST((obj),MODEST_TYPE_MSG_VIEW_WINDOW,ModestMsgViewWindow))
49 #define MODEST_MSG_VIEW_WINDOW_CLASS(klass)     (G_TYPE_CHECK_CLASS_CAST((klass),MODEST_TYPE_MSG_VIEW_WINDOW,ModestWindow))
50 #define MODEST_IS_MSG_VIEW_WINDOW(obj)          (G_TYPE_CHECK_INSTANCE_TYPE((obj),MODEST_TYPE_MSG_VIEW_WINDOW))
51 #define MODEST_IS_MSG_VIEW_WINDOW_CLASS(klass)  (G_TYPE_CHECK_CLASS_TYPE((klass),MODEST_TYPE_MSG_VIEW_WINDOW))
52 #define MODEST_MSG_VIEW_WINDOW_GET_CLASS(obj)   (G_TYPE_INSTANCE_GET_CLASS((obj),MODEST_TYPE_MSG_VIEW_WINDOW,ModestMsgVIewWindowClass))
53
54
55 typedef struct {
56 #ifdef MODEST_TOOLKIT_HILDON2
57         ModestHildon2Window parent;
58 #else
59         ModestShellWindow parent;
60 #endif
61 } ModestMsgViewWindow;
62         
63 typedef struct {
64 #ifdef MODEST_TOOLKIT_HILDON2
65         ModestHildon2WindowClass parent_class;
66 #else
67         ModestShellWindowClass parent_class;
68 #endif
69
70         void (*msg_changed) (ModestMsgViewWindow *self,
71                              GtkTreeModel *model,
72                              GtkTreeRowReference *row_reference, 
73                              gpointer user_data);
74
75         gboolean (*scroll_child) (ModestMsgViewWindow *self,
76                                    GtkScrollType scroll_type,
77                                    gboolean horizontal,
78                                    gpointer userdata);
79 } ModestMsgViewWindowClass;
80
81 /**
82  * modest_msg_view_window_get_type:
83  * 
84  * get the GType for the #ModestMsgViewWindow class
85  *
86  * Returns: a GType for #ModestMsgViewWindow
87  */
88 GType        modest_msg_view_window_get_type    (void) G_GNUC_CONST;
89         
90
91 /**
92  * modest_msg_view_window_new_for_attachment:
93  * @msg: an #TnyMsg instance
94  * @modest_account_name: the account name 
95  * @mailbox: the mailbox (if any)
96  * 
97  * instantiates a new #ModestMsgViewWindow widget to view a message that is an
98  * attachment in another message.
99  * The account name is used to
100  * set the proper account when choosing reply/forward from the msg view window
101  *
102  * Returns: a new #ModestMsgViewWindow, or NULL in case of error
103  */
104 ModestWindow*   modest_msg_view_window_new_for_attachment         (TnyMsg *msg, 
105                                                                    TnyMsg *top_msg,
106                                                                    const gchar *modest_account_name,
107                                                                    const gchar *mailbox,
108                                                                    const gchar *msg_uid);
109
110 /**
111  * modest_msg_view_window_new_with_other_body:
112  * @msg: an #TnyMsg instance
113  * @modest_account_name: the account name 
114  * @mailbox: the mailbox (if any)
115  * 
116  * instantiates a new #ModestMsgViewWindow widget to view a message that is a different body
117  * in another message.
118  * The account name is used to
119  * set the proper account when choosing reply/forward from the msg view window
120  *
121  * Returns: a new #ModestMsgViewWindow, or NULL in case of error
122  */
123 ModestWindow*   modest_msg_view_window_new_with_other_body         (TnyMsg *msg,
124                                                                    TnyMimePart *other_body,
125                                                                    TnyMsg *top_msg,
126                                                                    const gchar *modest_account_name,
127                                                                    const gchar *mailbox,
128                                                                    const gchar *msg_uid);
129
130 /**
131  * modest_msg_view_window_is_other_body:
132  * @self: a #ModestMsgViewWindow
133  *
134  * tells if the view window is showing other body
135  *
136  * Returns: %TRUE if showing "not first body"
137  */
138 gboolean modest_msg_view_window_is_other_body (ModestMsgViewWindow *self);
139
140 /**
141  * modest_msg_view_window_new_with_header_model:
142  * @msg: an #TnyMsg instance
143  * @modest_account_name: the account name 
144  * @mailbox: the mailbox (if any)
145  * @model: a #GtkTreeModel, with the format used by #ModestHeaderView
146  * @row_reference: a #GtkTreeRowReference, pointing to the position of @msg in @model.
147  * 
148  * instantiates a new #ModestMsgViewWindow widget. The account name is used to
149  * set the proper account when choosing reply/forward from the msg view window.
150  * This constructor also passes a reference to the @model of the header view
151  * to allow selecting previous/next messages in the message list when appropriate.
152  *
153  * Returns: a new #ModestMsgViewWindow, or NULL in case of error
154  */
155 ModestWindow*   modest_msg_view_window_new_with_header_model (TnyMsg *msg, 
156                                                               const gchar *modest_account_name, 
157                                                               const gchar *mailbox,
158                                                               const gchar *msg_uid,
159                                                               GtkTreeModel *model, 
160                                                               GtkTreeRowReference *row_reference);
161
162 /**
163  * modest_msg_view_window_new_from_header_view:
164  * @header_view: an #ModestHeaderView instance
165  * @modest_account_name: the account name 
166  * @mailbox: the mailbox (if any)
167  * @msg_uid: the initial uid reserved by this window
168  * @row_reference: a #GtkTreeRowReference, pointing to the selected position @model.
169  * 
170  * instantiates a new #ModestMsgViewWindow widget. The account name is used to
171  * set the proper account when choosing reply/forward from the msg view window.
172  * It's different from new_with_header_model, as it creates the window and then
173  * loads the message in that window.
174  *
175  * Returns: a new #ModestMsgViewWindow, or NULL in case of error
176  */
177 ModestWindow*   modest_msg_view_window_new_from_header_view (ModestHeaderView *header_view, 
178                                                              const gchar *modest_account_name, 
179                                                              const gchar *mailbox,
180                                                              const gchar *msg_uid,
181                                                              GtkTreeRowReference *row_reference);
182
183
184 /**
185  * modest_msg_view_window_new_from_uid:
186  */
187 ModestWindow *
188 modest_msg_view_window_new_from_uid (const gchar *modest_account_name,
189                                      const gchar *mailbox,
190                                      const gchar *msg_uid);
191                                               
192 /**
193  * modest_msg_view_window_new_for_search_result:
194  * @msg: an #TnyMsg instance
195  * @modest_account_name: the account name 
196  * 
197  * instantiates a new #ModestMsgViewWindow widget. The account name is used to
198  * set the proper account when choosing reply/forward from the msg view window.
199  * This constructor marks the window as being for a search result, which should 
200  * cause some UI to be disabled, such as the previous/next buttons.
201  *
202  * Returns: a new #ModestMsgViewWindow, or NULL in case of error
203  */
204 ModestWindow *
205 modest_msg_view_window_new_for_search_result (TnyMsg *msg, 
206                                               const gchar *modest_account_name,
207                                               const gchar *mailbox,
208                                               const gchar *msg_uid);
209                                               
210 /**
211  * modest_msg_view_window_get_header:
212  * @window: an #ModestMsgViewWindow instance
213  * 
214  * get the message header in this msg view. Header instance is get
215  * from tree_model of headers list. 
216  * 
217  * Returns: a new #TnyHeader instance, or NULL in case of error
218  */
219 TnyHeader*
220 modest_msg_view_window_get_header (ModestMsgViewWindow *self);
221
222 /**
223  * modest_msg_view_window_get_message:
224  * @window: an #ModestMsgViewWindow instance
225  * 
226  * get a new reference to the message in this msg view. The caller
227  * must free this new reference
228  * 
229  * Returns: a new #TnyMsg instance, or NULL in case of error
230  */
231 TnyMsg*         modest_msg_view_window_get_message     (ModestMsgViewWindow *window);
232
233 /**
234  * modest_msg_view_window_get_top_message:
235  * @window: an #ModestMsgViewWindow instance
236  * 
237  * get a new reference to the parent message of the tree of views. The caller
238  * must free this new reference
239  * 
240  * Returns: a new #TnyMsg instance, or NULL in case of error
241  */
242 TnyMsg*         modest_msg_view_window_get_top_message     (ModestMsgViewWindow *window);
243
244 /**
245  * modest_msg_view_window_get_message_uid:
246  * @msg: an #ModestMsgViewWindow instance
247  * 
248  * gets the unique identifier for the message in this msg view. The
249  * returned value *must* not be freed
250  * 
251  * Returns: the id of the #TnyMsg being shown, or NULL in case of error
252  */
253 const gchar*    modest_msg_view_window_get_message_uid (ModestMsgViewWindow *window);
254
255 /**
256  * modest_msg_view_window_select_next_message:
257  * @window: a #ModestMsgViewWindow instance
258  *
259  * select the next message obtained from the header view this view 
260  * was called from
261  *
262  * Returns: %TRUE if a new message is shown.
263  */
264 gboolean        modest_msg_view_window_select_next_message (ModestMsgViewWindow *window);
265
266 /**
267  * modest_msg_view_window_select_previous_message:
268  * @window: a #ModestMsgViewWindow instance
269  *
270  * select the previous message obtained from the header view this view 
271  * was called from
272  *
273  * Returns: %TRUE if a new message is shown.
274  */
275 gboolean        modest_msg_view_window_select_previous_message (ModestMsgViewWindow *window);
276
277 /**
278  * modest_msg_view_window_view_attachment:
279  * @window: a #ModestMsgViewWindow
280  * @mime_part: a #TnyMimePart
281  *
282  * Opens @mime_part, or the currently selected attachment if @mime_part is %NULL. 
283  * If it's a message, it opens it  for viewing. Otherwise it opens a temporary file 
284  * with the contents of the attachment.
285  */
286 void            modest_msg_view_window_view_attachment (ModestMsgViewWindow *window,
287                                                         TnyMimePart *mime_part);
288
289 /**
290  * modest_msg_view_window_get_attachments:
291  * @window: a #ModestMsgViewWindow
292  *
293  * Get selected attachments from #ModetMsgView private object.  
294  */
295 TnyList *         modest_msg_view_window_get_attachments (ModestMsgViewWindow *win);
296
297 /**
298  * modest_msg_view_window_save_attachments:
299  * @window: a #ModestMsgViewWindow
300  * @mime_parts: a #TnyList of #TnyMimePart
301  *
302  * Save the #TnyMimePart attachments in @mime_parts, or currently selected attachments
303  * if @mime_parts is %NULL, offering a dialog to the user to choose the location.
304  */
305 void            modest_msg_view_window_save_attachments (ModestMsgViewWindow *window,
306                                                          TnyList *mime_parts);
307
308 /**
309  * modest_msg_view_window_remove_attachments:
310  * @window: a #ModestMsgViewWindow
311  * @get_all: a #gboolean. If %TRUE, purges all attachmnents, if %FALSE,
312  * purges only selected ones.
313  *
314  * Removes selected attachments.
315  */
316 void            modest_msg_view_window_remove_attachments (ModestMsgViewWindow *window,
317                                                            gboolean get_all);
318
319
320 /**
321  * modest_msg_view_window_toolbar_on_transfer_mode:
322  * @window: a #ModestMsgViewWindow
323  *
324  * Check if toolbar is in transfer mode, which determines whether a
325  * transfer operation is being processed.
326  */
327 gboolean  modest_msg_view_window_toolbar_on_transfer_mode     (ModestMsgViewWindow *self);
328
329
330 /**
331  * modest_msg_view_window_last_message_selected:
332  * @window: a #ModestMsgViewWindow
333  *
334  * Check message currently viewed is the last message into folder . 
335 */
336 gboolean modest_msg_view_window_last_message_selected (ModestMsgViewWindow *window); 
337
338
339 /**
340  * modest_msg_view_window_first_message_selected:
341  * @window: a #ModestMsgViewWindow
342  *
343  * Check message currently viewed is the last message into folder . 
344 */
345 gboolean modest_msg_view_window_first_message_selected (ModestMsgViewWindow *window);
346
347 /**
348  * modest_msg_view_window_has_headers_model:
349  * @window: a #ModestMsgViewWindow
350  *
351  * Check if window has been created with a full headers model. 
352 */
353 gboolean modest_msg_view_window_has_headers_model (ModestMsgViewWindow *window);
354
355 /**
356  * modest_msg_view_window_is_search_result:
357  * @window: a #ModestMsgViewWindow
358  *
359  * Check if window has been created to show a search result. 
360  */
361 gboolean modest_msg_view_window_is_search_result (ModestMsgViewWindow *window);
362
363
364 /**
365  * modest_msg_view_window_get_folder_type:
366  * @window: a #ModestMsgViewWindow
367  *
368  * Gets folder type of message currently viewed . 
369 */
370 TnyFolderType
371 modest_msg_view_window_get_folder_type (ModestMsgViewWindow *window);
372
373 /**
374  * modest_msg_view_window_transfer_mode_enabled:
375  * @window: a #ModestMsgViewWindow
376  *
377  * Determines if some transfer operation is in progress.
378  *
379  * Returns: TRUE if transfer mode is enabled, FASE otherwise.
380 */
381 gboolean 
382 modest_msg_view_window_transfer_mode_enabled (ModestMsgViewWindow *self);
383
384 /**
385  * modest_msg_view_window_add_to_contacts:
386  * @self: a #ModestMsgViewWindow
387  *
388  * activates the add to contacts use case. In Diablo and gnome it gets the
389  * clipboard selection current value and tries to add it to the addressbook.
390  * In fremantle, it shows the add to contacts dialog to select the recipient
391  * to add.
392  */
393 void
394 modest_msg_view_window_add_to_contacts (ModestMsgViewWindow *self);
395
396 /**
397  * modest_msg_view_window_get_msg_view:
398  * @self: a #ModestMsgViewWindow
399  *
400  * Tells that external images should be fetched in this window.
401  */
402 void
403 modest_msg_view_window_fetch_images (ModestMsgViewWindow *self);
404
405 /**
406  * modest_msg_view_window_has_blocked_external_images:
407  * @self: a #ModestMsgViewWindow
408  * 
409  * checks if the msg currently shown has blocked external images.
410  *
411  * Returns: %TRUE if external images are blocked, %FALSE otherwise
412  */
413 gboolean modest_msg_view_window_has_blocked_external_images (ModestMsgViewWindow *self);
414
415 /**
416  * modest_msg_view_window_reload:
417  * @self: a #ModestMsgViewWindow
418  *
419  * Reloads currently loaded message. This is intended to show the message in case it
420  * has some update on the previously visible result.
421  */
422 void modest_msg_view_window_reload (ModestMsgViewWindow *self);
423
424 G_END_DECLS
425
426 #endif /* __MODEST_MSG_VIEW_WINDOW_H__ */
427