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