* Fixes a crash when removing accounts. Added by a code I commited today
[modest] / src / modest-email-clipboard.h
1 /* Copyright (c) 2006, 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
31 #ifndef __MODEST_EMAIL_CLIPBOARD_H__
32 #define __MODEST_EMAIL_CLIPBOARD_H__
33
34 #include <glib-object.h>
35 #include <modest-conf.h>
36 #include <modest-defs.h>
37 #include <tny-folder.h>
38
39 G_BEGIN_DECLS
40
41 /* convenience macros */
42 #define MODEST_TYPE_EMAIL_CLIPBOARD             (modest_email_clipboard_get_type())
43 #define MODEST_EMAIL_CLIPBOARD(obj)             (G_TYPE_CHECK_INSTANCE_CAST((obj),MODEST_TYPE_EMAIL_CLIPBOARD,ModestEmailClipboard))
44 #define MODEST_EMAIL_CLIPBOARD_CLASS(klass)     (G_TYPE_CHECK_CLASS_CAST((klass),MODEST_TYPE_EMAIL_CLIPBOARD,ModestEmailClipboardClass))
45 #define MODEST_IS_EMAIL_CLIPBOARD(obj)          (G_TYPE_CHECK_INSTANCE_TYPE((obj),MODEST_TYPE_EMAIL_CLIPBOARD))
46 #define MODEST_IS_EMAIL_CLIPBOARD_CLASS(klass)  (G_TYPE_CHECK_CLASS_TYPE((klass),MODEST_TYPE_EMAIL_CLIPBOARD))
47 #define MODEST_EMAIL_CLIPBOARD_GET_CLASS(obj)   (G_TYPE_INSTANCE_GET_CLASS((obj),MODEST_TYPE_EMAIL_CLIPBOARD,ModestEmailClipboardClass))
48
49 typedef struct _ModestEmailClipboard      ModestEmailClipboard;
50 typedef struct _ModestEmailClipboardClass ModestEmailClipboardClass;
51 typedef struct _ModestEmailClipboardPrivate ModestEmailClipboardPrivate;
52
53 struct _ModestEmailClipboard {
54          GObject parent;
55         ModestEmailClipboardPrivate *priv;
56 };
57
58 struct _ModestEmailClipboardClass {
59         GObjectClass parent_class;
60
61 };
62
63 /**
64  * modest_email_clipboard_get_type:
65  * 
66  * get the GType for #ModestEmailClipboard
67  *  
68  * Returns: the GType
69  */
70 GType           modest_email_clipboard_get_type       (void) G_GNUC_CONST;
71
72
73 /**
74  * modest_email_clipboard_new:
75  *  
76  * Returns: a new #ModestEmailClipboard, or NULL in case of error
77  */
78 ModestEmailClipboard*        modest_email_clipboard_new (void);
79
80
81 /**
82  * modest_email_clipboard_get_data:
83  * @self: a #ModestEmailClipboard singlenton instance.   
84  * @src_folder: a #TnyFolder instance which is the source of selection data. 
85  * @data: a #TnyList of objects to manage.
86  * @delete: determines whether data will be removed after copy them.
87  *  
88  * Gets data from clipboard to manage them with copy, cut and paste operations.
89  * Currently imementation allows #TnyFolder or #TnyHeader objects.
90  *
91  * After getting data, clipboard will be cleared.
92  */
93 void
94 modest_email_clipboard_get_data (ModestEmailClipboard *self,
95                                  TnyFolder **src_folder,
96                                  TnyList **data,
97                                  gboolean *delete);
98
99 /**
100  * modest_email_clipboard_set_data:
101  * @self: a #ModestEmailClipboard singlenton instance.   
102  * @src_folder: a #TnyFolder instance which is the source of selection data. 
103  * @data: a #TnyList of objects to manage.
104  * @delete: determines whether data will be removed after copy them.
105  *  
106  * Sets data on clipboard to manage them wiht copy, cut and paste operations.
107  * Currently imementation allows #TnyFolder or #TnyHeader objects.
108  *
109  */
110 void modest_email_clipboard_set_data (ModestEmailClipboard *self,
111                                       TnyFolder *src_folder, 
112                                       TnyList *data,
113                                       gboolean delete);
114
115
116 /**
117  * modest_email_clipboard_clear:
118  * @self: a #ModestEmailClipboard singlenton instance.   
119  *  
120  * Clear all data stored inside clipboard.
121  */
122 void modest_email_clipboard_clear (ModestEmailClipboard *self);
123
124
125 /**
126  * modest_email_clipboard_cleared:
127  * @self: a #ModestEmailClipboard singlenton instance.   
128  * 
129  * Determines if clipboard is clreared, no seleciton data is stored.
130  *  
131  * returns TRUE, if clipboard is cleared, FALSE otherwise.
132  */
133 gboolean modest_email_clipboard_cleared (ModestEmailClipboard *self);
134
135
136 /**
137  * modest_email_clipboard_cleared:
138  * @self: a #ModestEmailClipboard singlenton instance.   
139  * @folder: a #TnyFolder instance to compare.
140  * 
141  * Determines if source folder stored on clipboard is the 
142  * same as @folder, passed as argument. 
143  *  
144  * returns TRUE, if clipboard is cleared, FALSE otherwise.
145  */
146 gboolean 
147 modest_email_clipboard_check_source_folder (ModestEmailClipboard *self,
148                                             TnyFolder *folder);
149
150 /**
151  * modest_email_clipboard_set_data:
152  * @self: a #ModestEmailClipboard singlenton instance.   
153  * @n_selected: the number of items copied and marked to delete.
154  * 
155  * Returns the string array of item identifiers stored on clipboard.
156  * 
157  * returns TRUE, if clipboard is cleared, FALSE otherwise.
158  */
159 const gchar **modest_email_clipboard_get_hidding_ids (ModestEmailClipboard *self,
160                                                       guint *n_selected);
161
162 /**
163  * modest_email_clipboard_get_folder_name:
164  * @self: a #ModestEmailClipboard singlenton instance.   
165  * 
166  * Gets the source folder name.
167  * 
168  * returns a const string with folder name, or NULL if data are not valid.
169  */
170 const gchar *modest_email_clipboard_get_folder_name (ModestEmailClipboard *self);
171
172
173 /**
174  * modest_email_clipboard_headers_copied:
175  * @self: a #ModestEmailClipboard singlenton instance.   
176  *
177  * Checks if clipboard has headers stored.
178  * 
179  * returns TRUE, if clipboard stores headers, FALSE otherwise.
180  */
181 gboolean modest_email_clipboard_headers_copied (ModestEmailClipboard *self);
182
183 /**
184  * modest_email_clipboard_headers_copied:
185  * @self: a #ModestEmailClipboard singlenton instance.   
186  *
187  * Checks if clipboard has one folder stored.
188  * 
189  * returns TRUE, if clipboard stores one folder, FALSE otherwise.
190  */
191 gboolean modest_email_clipboard_folder_copied (ModestEmailClipboard *self);
192
193 G_END_DECLS
194
195 #endif /* __MODEST_EMAIL_CLIPBOARD_H__ */