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