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