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