* cosmetics
[modest] / src / modest-identity-mgr.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 /* modest-identity-mgr.h */
32
33 #ifndef __MODEST_IDENTITY_MGR_H__
34 #define __MODEST_IDENTITY_MGR_H__
35
36 #include <glib-object.h>
37 #include "modest-conf.h"
38 #include "modest-identity-keys.h"
39 #include "modest-proto.h"
40
41 G_BEGIN_DECLS
42 /* convenience macros */
43 #define MODEST_TYPE_IDENTITY_MGR             (modest_identity_mgr_get_type())
44 #define MODEST_IDENTITY_MGR(obj)             (G_TYPE_CHECK_INSTANCE_CAST((obj),MODEST_TYPE_IDENTITY_MGR,ModestIdentityMgr))
45 #define MODEST_IDENTITY_MGR_CLASS(klass)     (G_TYPE_CHECK_CLASS_CAST((klass),MODEST_TYPE_IDENTITY_MGR,GObject))
46 #define MODEST_IS_IDENTITY_MGR(obj)          (G_TYPE_CHECK_INSTANCE_TYPE((obj),MODEST_TYPE_IDENTITY_MGR))
47 #define MODEST_IS_IDENTITY_MGR_CLASS(klass)  (G_TYPE_CHECK_CLASS_TYPE((klass),MODEST_TYPE_IDENTITY_MGR))
48 #define MODEST_IDENTITY_MGR_GET_CLASS(obj)   (G_TYPE_INSTANCE_GET_CLASS((obj),MODEST_TYPE_IDENTITY_MGR,ModestIdentityMgrClass))
49 typedef struct _ModestIdentityMgr ModestIdentityMgr;
50 typedef struct _ModestIdentityMgrClass ModestIdentityMgrClass;
51
52
53 struct _ModestIdentityMgr {
54         GObject parent;
55         /* insert public members, if any */
56 };
57
58 struct _ModestIdentityMgrClass {
59         GObjectClass parent_class;
60         /* insert signal callback declarations, eg. */
61         /* void (* my_event) (ModestIdentityMgr* obj); */
62 };
63
64
65 /**
66  * modest_ui_get_type:
67  *
68  * get the GType for ModestIdentityMgr
69  *
70  * Returns: the GType
71  */
72 GType modest_identity_mgr_get_type (void) G_GNUC_CONST;
73
74
75 /**
76  * modest_identity_mgr_new:
77  * @modest_conf: a ModestConf instance
78  *
79  * Returns: a new ModestIdentityMgr, or NULL in case of error
80  */
81 GObject * modest_identity_mgr_new (ModestConf * modest_conf);
82
83
84 /**
85  * modest_identity_mgr_add_identity:
86  * @self: a ModestIdentityMgr instance
87  * @name: the name (id) for the identity
88  * @realname: the real name of the user
89  * @email: the user's email address which is used when sending email
90  * @replyto: the default replyto address
91  * @signature: the signature for this identity
92  * @use_signature: whether to use this signature instead of the default one
93  * @id_via: the transport to send emails for this identity via
94  * @use_id_via: whether to use this via instead of the default one
95  *
96  * add a user identity to the configuration
97  *
98  * Returns: TRUE if  succeeded, FALSE otherwise,
99  */
100 gboolean modest_identity_mgr_add_identity (ModestIdentityMgr * self,
101                                            const gchar * name,
102                                            const gchar * realname,
103                                            const gchar * email,
104                                            const gchar * replyto,
105                                            const gchar * signature,
106                                            const gboolean use_signature,
107                                            const gchar * id_via,
108                                            const gboolean use_id_via);
109
110
111 /**
112  * modest_identity_mgr_remove_identity:
113  * @self: a ModestIdentityMgr instance
114  * @name: the name of the identity to remove
115  * @err: a GError ptr, or NULL to ignore.
116  *
117  * remove identity from the configuration
118  * the identity with @name should exist
119  *
120  * Returns: TRUE if the removal succeeded, FALSE otherwise,
121  * @err gives details in case of error
122  */
123 gboolean modest_identity_mgr_remove_identity (ModestIdentityMgr * self,
124                                                                                           const gchar * name,
125                                                                                           GError ** err);
126
127
128 /**
129  * modest_identity_mgr_identity_names:
130  * @self: a ModestIdentityMgr instance
131  * @err: a GError ptr, or NULL to ignore.
132  *
133  * list all identities
134  *
135  * Returns: a newly allocated list of identities, or NULL in case of error or
136  * if there are no identities. The caller must free the returned GSList
137  * @err gives details in case of error
138  */
139 GSList *modest_identity_mgr_identity_names (ModestIdentityMgr * self,
140                                                                                         GError ** err);
141
142
143 /**
144  * modest_identity_mgr_identity_exists:
145  * @self: a ModestIdentityMgr instance
146  * @err: a GError ptr, or NULL to ignore.
147  *
148  * check whether identity @name exists
149  *
150  * Returns: TRUE if the identity exists, FALSE otherwise (or in case of error)
151  * @err gives details in case of error
152  */
153 gboolean modest_identity_mgr_identity_exists (ModestIdentityMgr * self,
154                                                                                           const gchar * name,
155                                                                                           GError ** err);
156
157
158 /* identity specific functions */
159
160 /**
161  * modest_identity_mgr_get_identity_string:
162  * @self: a ModestIdentityMgr instance
163  * @name: the name of the identity
164  * @key: the key of the value to retrieve
165  * @err: a GError ptr, or NULL to ignore.
166  *
167  * get a config string from an identity
168  *
169  * Returns: a newly allocated string with the value for the key,
170  * or NULL in case of error. @err gives details in case of error
171  */
172 gchar *modest_identity_mgr_get_identity_string (ModestIdentityMgr * self,
173                                                                                                 const gchar * name,
174                                                                                                 const gchar * key,
175                                                                                                 GError ** err);
176
177
178 /**
179  * modest_identity_mgr_get_identity_int:
180  * @self: a ModestIdentityMgr instance
181  * @name: the name of the identity
182  * @key: the key of the value to retrieve
183  * @err: a GError ptr, or NULL to ignore.
184  *
185  * get a config int from an identity
186  *
187  * Returns: an integer with the value for the key, or -1 in case of
188  * error (but of course -1 does not necessarily imply an error)
189  * @err gives details in case of error
190  */
191 gint modest_identity_mgr_get_identity_int (ModestIdentityMgr * self,
192                                                                                    const gchar * name,
193                                                                                    const gchar * key,
194                                                                                    GError ** err);
195
196
197 /**
198  * modest_identity_mgr_get_identity_bool:
199  * @self: a ModestIdentityMgr instance
200  * @name: the name of the identity
201  * @key: the key of the value to retrieve
202  * @err: a GError ptr, or NULL to ignore.
203  *
204  * get a config boolean from an identity
205  *
206  * Returns: an boolean with the value for the key, or FALSE in case of
207  * error (but of course FALSE does not necessarily imply an error)
208  * @err gives details in case of error
209  */
210 gboolean modest_identity_mgr_get_identity_bool (ModestIdentityMgr * self,
211                                                                                                 const gchar * name,
212                                                                                                 const gchar * key,
213                                                                                                 GError ** err);
214
215
216 /**
217  * modest_identity_mgr_set_identity_string:
218  * @self: a ModestIdentityMgr instance
219  * @name: the name of the identity
220  * @key: the key of the value to set
221  * @val: the value to set
222  * @err: a GError ptr, or NULL to ignore.
223  *
224  * set a config string for an identity
225  *
226  * Returns: TRUE if setting the value succeeded, or FALSE in case of error.
227  * @err gives details in case of error
228  */
229 gboolean modest_identity_mgr_set_identity_string (ModestIdentityMgr *
230                                                                                                   self,
231                                                                                                   const gchar * name,
232                                                                                                   const gchar * key,
233                                                                                                   const gchar * val,
234                                                                                                   GError ** err);
235
236
237 /**
238  * modest_identity_mgr_set_identity_int:
239  * @self: a ModestIdentityMgr instance
240  * @name: the name of the identity
241  * @key: the key of the value to set
242  * @val: the value to set
243  * @err: a GError ptr, or NULL to ignore.
244  *
245  * set a config int for an identity
246  *
247  * Returns: TRUE if setting the value succeeded, or FALSE in case of error.
248  * @err gives details in case of error
249  */
250 gboolean modest_identity_mgr_set_identity_int (ModestIdentityMgr * self,
251                                                                                            const gchar * name,
252                                                                                            const gchar * key,
253                                                                                            gint val, GError ** err);
254
255
256 /**
257  * modest_identity_mgr_set_identity_bool:
258  * @self: a ModestIdentityMgr instance
259  * @name: the name of the identity
260  * @key: the key of the value to set
261  * @val: the value to set
262  * @err: a GError ptr, or NULL to ignore.
263  *
264  * set a config bool for an identity
265  *
266  * Returns: TRUE if setting the value succeeded, or FALSE in case of error.
267  * @err gives details in case of error
268  */
269 gboolean modest_identity_mgr_set_identity_bool (ModestIdentityMgr * self,
270                                                                                                 const gchar * name,
271                                                                                                 const gchar * key,
272                                                                                                 gboolean val,
273                                                                                                 GError ** err);
274
275
276 G_END_DECLS
277 #endif /* __MODEST_IDENTITY_MGR_H__ */