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