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