* added REALNAME to identities
[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  * @email: the user's email address which is used when sending email
60  * @replyto: the default replyto address
61  * @signature: the signature for this identity
62  * @use_signature: whether to use this signature instead of the default one
63  * @id_via: the transport to send emails for this identity via
64  * @use_id_via: whether to use this via instead of the default one
65  * 
66  * add a user identity to the configuration
67  * 
68  * Returns: TRUE if  succeeded, FALSE otherwise,
69  */
70 gboolean modest_identity_mgr_add_identity (ModestIdentityMgr * self,
71                                            const gchar * name,
72                                            const gchar * realname,
73                                            const gchar * email,
74                                            const gchar * replyto,
75                                            const gchar * signature,
76                                            const gboolean use_signature,
77                                            const gchar * id_via,
78                                            const gboolean use_id_via);
79
80
81 /**
82  * modest_identity_mgr_remove_identity:
83  * @self: a ModestIdentityMgr instance
84  * @name: the name of the identity to remove
85  * @err: a GError ptr, or NULL to ignore.
86  * 
87  * remove identity from the configuration
88  * the identity with @name should exist
89  *
90  * Returns: TRUE if the removal succeeded, FALSE otherwise,
91  * @err gives details in case of error
92  */
93 gboolean modest_identity_mgr_remove_identity (ModestIdentityMgr * self,
94                                                                                           const gchar * name,
95                                                                                           GError ** err);
96
97
98 /**
99  * modest_identity_mgr_identity_names:
100  * @self: a ModestIdentityMgr instance
101  * @err: a GError ptr, or NULL to ignore.
102  * 
103  * list all identities
104  *
105  * Returns: a newly allocated list of identities, or NULL in case of error or
106  * if there are no identities. The caller must free the returned GSList
107  * @err gives details in case of error
108  */
109 GSList *modest_identity_mgr_identity_names (ModestIdentityMgr * self,
110                                                                                         GError ** err);
111
112
113 /**
114  * modest_identity_mgr_identity_exists:
115  * @self: a ModestIdentityMgr instance
116  * @err: a GError ptr, or NULL to ignore.
117  * 
118  * check whether identity @name exists
119  *
120  * Returns: TRUE if the identity exists, FALSE otherwise (or in case of error)
121  * @err gives details in case of error
122  */
123 gboolean modest_identity_mgr_identity_exists (ModestIdentityMgr * self,
124                                                                                           const gchar * name,
125                                                                                           GError ** err);
126
127
128 /* identity specific functions */
129
130 /**
131  * modest_identity_mgr_get_identity_string:
132  * @self: a ModestIdentityMgr instance
133  * @name: the name of the identity
134  * @key: the key of the value to retrieve
135  * @err: a GError ptr, or NULL to ignore.
136  * 
137  * get a config string from an identity
138  *
139  * Returns: a newly allocated string with the value for the key,
140  * or NULL in case of error. @err gives details in case of error
141  */
142 gchar *modest_identity_mgr_get_identity_string (ModestIdentityMgr * self,
143                                                                                                 const gchar * name,
144                                                                                                 const gchar * key,
145                                                                                                 GError ** err);
146
147
148 /**
149  * modest_identity_mgr_get_identity_int:
150  * @self: a ModestIdentityMgr instance
151  * @name: the name of the identity
152  * @key: the key of the value to retrieve
153  * @err: a GError ptr, or NULL to ignore.
154  * 
155  * get a config int from an identity
156  *
157  * Returns: an integer with the value for the key, or -1 in case of
158  * error (but of course -1 does not necessarily imply an error)
159  * @err gives details in case of error
160  */
161 gint modest_identity_mgr_get_identity_int (ModestIdentityMgr * self,
162                                                                                    const gchar * name,
163                                                                                    const gchar * key,
164                                                                                    GError ** err);
165
166
167 /**
168  * modest_identity_mgr_get_identity_bool:
169  * @self: a ModestIdentityMgr instance
170  * @name: the name of the identity
171  * @key: the key of the value to retrieve
172  * @err: a GError ptr, or NULL to ignore.
173  * 
174  * get a config boolean from an identity
175  *
176  * Returns: an boolean with the value for the key, or FALSE in case of
177  * error (but of course FALSE does not necessarily imply an error)
178  * @err gives details in case of error
179  */
180 gboolean modest_identity_mgr_get_identity_bool (ModestIdentityMgr * self,
181                                                                                                 const gchar * name,
182                                                                                                 const gchar * key,
183                                                                                                 GError ** err);
184
185
186 /**
187  * modest_identity_mgr_set_identity_string:
188  * @self: a ModestIdentityMgr instance
189  * @name: the name of the identity
190  * @key: the key of the value to set
191  * @val: the value to set
192  * @err: a GError ptr, or NULL to ignore.
193  * 
194  * set a config string for an identity
195  *
196  * Returns: TRUE if setting the value succeeded, or FALSE in case of error.
197  * @err gives details in case of error
198  */
199 gboolean modest_identity_mgr_set_identity_string (ModestIdentityMgr *
200                                                                                                   self,
201                                                                                                   const gchar * name,
202                                                                                                   const gchar * key,
203                                                                                                   const gchar * val,
204                                                                                                   GError ** err);
205
206
207 /**
208  * modest_identity_mgr_set_identity_int:
209  * @self: a ModestIdentityMgr instance
210  * @name: the name of the identity
211  * @key: the key of the value to set
212  * @val: the value to set
213  * @err: a GError ptr, or NULL to ignore.
214  * 
215  * set a config int for an identity
216  *
217  * Returns: TRUE if setting the value succeeded, or FALSE in case of error.
218  * @err gives details in case of error
219  */
220 gboolean modest_identity_mgr_set_identity_int (ModestIdentityMgr * self,
221                                                                                            const gchar * name,
222                                                                                            const gchar * key,
223                                                                                            gint val, GError ** err);
224
225
226 /**
227  * modest_identity_mgr_set_identity_bool:
228  * @self: a ModestIdentityMgr instance
229  * @name: the name of the identity
230  * @key: the key of the value to set
231  * @val: the value to set
232  * @err: a GError ptr, or NULL to ignore.
233  * 
234  * set a config bool for an identity
235  *
236  * Returns: TRUE if setting the value succeeded, or FALSE in case of error.
237  * @err gives details in case of error
238  */
239 gboolean modest_identity_mgr_set_identity_bool (ModestIdentityMgr * self,
240                                                                                                 const gchar * name,
241                                                                                                 const gchar * key,
242                                                                                                 gboolean val,
243                                                                                                 GError ** err);
244
245
246 G_END_DECLS
247 #endif /* __MODEST_IDENTITY_MGR_H__ */