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