* now fix NB#78955:
[modest] / src / modest-account-mgr-helpers.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 LIMIT
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_ACCOUNT_MGR_HELPERS_H__
32 #define __MODEST_ACCOUNT_MGR_HELPERS_H__
33
34 #include <modest-account-mgr.h>
35 #include <modest-tny-account-store.h>
36
37 #include <tny-account.h>
38 #include <tny-store-account.h>
39 #include <tny-transport-account.h>
40 #include <modest-server-account-settings.h>
41
42 G_BEGIN_DECLS
43
44 /**
45  * modest_account_mgr_load_account_settings:
46  * @self: a ModestAccountMgr instance
47  * @name: the name of the account
48  * 
49  * get information about an account
50  *
51  * Returns: a ModestAccountSettings instance with information about the account,
52  *  or NULL if the account is not valid or does not exist.
53  */
54 ModestAccountSettings *modest_account_mgr_load_account_settings     (ModestAccountMgr *self,
55                                                                      const gchar* name);
56
57 void modest_account_mgr_save_account_settings (ModestAccountMgr *self,
58                                                ModestAccountSettings *settings);
59
60 /**
61  * modest_account_mgr_set_first_account_as_default:
62  * @self: a ModestAccountMgr instance
63  * 
64  * Guarantees that at least one account, if there are any accounts, is the default,
65  * so that modest_account_mgr_get_default_account() will return non-NULL if there 
66  * are any accounts.
67  *
68  * Returns: TRUE if succeeded, FALSE otherwise
69  */
70 gboolean
71 modest_account_mgr_set_first_account_as_default  (ModestAccountMgr *self);
72
73 /** Get the first one, alphabetically, by title. */
74 gchar* 
75 modest_account_mgr_get_first_account_name (ModestAccountMgr *self);
76
77
78 /**
79  * modest_account_mgr_set_enabled
80  * @self: a ModestAccountMgr instance
81  * @name: the account name 
82  * @enabled: if TRUE, the account will be enabled, if FALSE, it will be disabled
83  * 
84  * enable/disabled an account
85  *
86  * Returns: TRUE if it worked, FALSE otherwise
87  */
88 gboolean modest_account_mgr_set_enabled (ModestAccountMgr *self, const gchar* name,
89                                          gboolean enabled);
90
91 /**
92  * modest_account_mgr_get_enabled:
93  * @self: a ModestAccountMgr instance
94  * @name: the account name to check
95  *
96  * check whether a certain account is enabled
97  *
98  * Returns: TRUE if it is enabled, FALSE otherwise
99  */
100 gboolean modest_account_mgr_get_enabled (ModestAccountMgr *self, const gchar* name);
101
102 /**
103  * modest_account_mgr_set_signature
104  * @self: a ModestAccountMgr instance
105  * @name: the account name to check
106  * @signature: the signature text 
107  * @use_signature: Whether the signature should be used.
108  * 
109  * Sets the signature text for the account.
110  *
111  * Returns: TRUE if it worked, FALSE otherwise
112  */
113 gboolean modest_account_mgr_set_signature (ModestAccountMgr *self, const gchar* name, 
114         const gchar* signature, gboolean use_signature);
115
116 /**
117  * modest_account_mgr_get_signature:
118  * @self: a ModestAccountMgr instance
119  * @name: the account name
120  * @use_signature: Pointer to a gboolean taht will be set to TRUE if the signature should be used.
121  *
122  * Gets the signature text for this account.
123  *
124  * Returns: The signature text, which should be freed with g_free().
125  */
126 gchar* modest_account_mgr_get_signature (ModestAccountMgr *self, const gchar* name, 
127         gboolean* use_signature);
128         
129 /**
130  * modest_account_mgr_get_store_protocol:
131  * @self: a ModestAccountMgr instance
132  * @name: the account name
133  *
134  * Gets the protocol type (For instance, POP or IMAP) used for the store server account.
135  *
136  * Returns: The protocol type.
137  */
138 ModestTransportStoreProtocol modest_account_mgr_get_store_protocol (ModestAccountMgr *self, const gchar* name);
139
140 /**
141  * modest_account_mgr_set_connection_specific_smtp
142  * @self: a ModestAccountMgr instance
143  * @connection_name: A libconic IAP connection name
144  * @server_account_name: a server account name to use for this connection.
145  * 
146  * Specify a server account to use with the specific connection for this account.
147  *
148  * Returns: TRUE if it worked, FALSE otherwise
149  */
150 gboolean modest_account_mgr_set_connection_specific_smtp (ModestAccountMgr *self, 
151                                          const gchar* connection_name, const gchar* server_account_name);
152
153 /**
154  * modest_account_mgr_remove_connection_specific_smtp
155  * @self: a ModestAccountMgr instance
156  * @connection_name: A libconic IAP connection name
157  * 
158  * Disassociate a server account to use with the specific connection for this account.
159  *
160  * Returns: TRUE if it worked, FALSE otherwise
161  */                              
162 gboolean modest_account_mgr_remove_connection_specific_smtp (ModestAccountMgr *self, 
163         const gchar* connection_name);
164
165 /**
166  * modest_account_mgr_get_use_connection_specific_smtp
167  * @self: a ModestAccountMgr instance
168  * @account_name: the account name
169  * @result: Whether this account should use connection-specific smtp server accounts.
170  */
171 gboolean modest_account_mgr_get_use_connection_specific_smtp (ModestAccountMgr *self, const gchar* account_name);
172
173 /**
174  * modest_account_mgr_set_use_connection_specific_smtp
175  * @self: a ModestAccountMgr instance
176  * @account_name: the account name
177  * @new_value: New value that indicates if if this account should use connection-specific smtp server accounts.
178  * @result: TRUE if it succeeded, FALSE otherwise
179  */
180 gboolean modest_account_mgr_set_use_connection_specific_smtp (ModestAccountMgr *self, 
181                                                               const gchar* account_name,
182                                                               gboolean new_value);
183
184 /**
185  * modest_account_mgr_get_connection_specific_smtp
186  * @self: a ModestAccountMgr instance
187  * @connection_name: A libconic IAP connection name
188  * 
189  * Retrieve a server account to use with this specific connection for this account.
190  *
191  * Returns: a server account name to use for this connection, or NULL if none is specified.
192  */                      
193 gchar* modest_account_mgr_get_connection_specific_smtp (ModestAccountMgr *self, 
194                                                         const gchar* connection_name);
195
196
197 /**
198  * modest_account_mgr_get_server_account_username:
199  * @self: a ModestAccountMgr instance
200  * @account_name: The name of a server account.
201  *
202  * Gets the username this server account.
203  *
204  * Returns: The username.
205  */
206 gchar* modest_account_mgr_get_server_account_username (ModestAccountMgr *self, 
207                                                        const gchar* account_name);
208
209 /**
210  * modest_account_mgr_set_server_account_username:
211  * @self: a ModestAccountMgr instance
212  * @account_name: The name of a server account.
213  * @username: The new username.
214  *
215  * Sets the username this server account.
216  */
217 void modest_account_mgr_set_server_account_username (ModestAccountMgr *self, 
218                                                      const gchar* account_name, 
219                                                      const gchar* username);
220
221 /**
222  * modest_account_mgr_get_server_account_username_has_succeeded:
223  * @self: a ModestAccountMgr instance
224  * @account_name: The name of a server account.
225  *
226  * Whether a connection has ever been successfully made to this account with 
227  * the current username. This can be used to avoid asking again for the username 
228  * when asking a second time for a non-stored password.
229  *
230  * Returns: TRUE if the username is known to be correct.
231  */
232 gboolean modest_account_mgr_get_server_account_username_has_succeeded (ModestAccountMgr *self, 
233                                                                        const gchar* account_name);
234
235 /**
236  * modest_account_mgr_set_server_account_username_has_succeeded:
237  * @self: a ModestAccountMgr instance
238  * @account_name: The name of a server account.
239  * @succeeded: Whether the username has succeeded
240  *
241  * Sets whether the username is known to be correct.
242  */
243 void modest_account_mgr_set_server_account_username_has_succeeded (ModestAccountMgr *self, 
244                                                                    const gchar* account_name, 
245                                                                    gboolean succeeded);
246         
247 /**
248  * modest_account_mgr_set_server_account_password:
249  * @self: a ModestAccountMgr instance
250  * @account_name: The name of a server account.
251  * @password: The new password.
252  *
253  * Sets the password for this server account.
254  */
255 void modest_account_mgr_set_server_account_password (ModestAccountMgr *self, 
256                                                      const gchar* account_name, 
257                                                      const gchar* password);
258         
259 /**
260  * modest_account_mgr_get_server_account_password:
261  * @self: a ModestAccountMgr instance
262  * @account_name: The name of a server account.
263  *
264  * Gets the password for this server account from the account settings.
265  */
266 gchar* modest_account_mgr_get_server_account_password (ModestAccountMgr *self, 
267                                                        const gchar* account_name);
268
269 /**
270  * modest_account_mgr_get_server_account_has_password:
271  * @self: a ModestAccountMgr instance
272  * @account_name: The name of a server account.
273  *
274  * Gets whether a password has been set for this server account in the account settings.
275  */
276 gboolean modest_account_mgr_get_server_account_has_password (ModestAccountMgr *self, 
277                                                              const gchar* account_name);         
278
279 /**
280  * modest_server_account_modest_account_mgr_get_server_account_hostname:
281  * @self: a ModestAccountMgr instance
282  * @account_name: The name of a server account.
283  *
284  * Gets the hostname this server account.
285  *
286  * Returns: The hostname.
287  */
288 gchar* modest_account_mgr_get_server_account_hostname (ModestAccountMgr *self, 
289                                                        const gchar* account_name);
290
291 /**
292  * modest_server_account_modest_account_mgr_set_server_account_hostname:
293  * @self: a ModestAccountMgr instance
294  * @account_name: The name of a server account.
295  * @hostname: The new hostname
296  *
297  * Sets the hostname this server account.
298  */
299 void  modest_account_mgr_set_server_account_hostname (ModestAccountMgr *self, 
300                                                       const gchar* account_name,
301                                                       const gchar *hostname);
302
303 /**
304  * modest_account_mgr_get_server_account_secure_auth:
305  * @self: a ModestAccountMgr instance
306  * @account_name: The name of a server account.
307  *
308  * Gets the secure authentication method for this server account.
309  *
310  * Returns: The secure authentication enum value.
311  */
312 ModestAuthProtocol modest_account_mgr_get_server_account_secure_auth (ModestAccountMgr *self, 
313                                                                       const gchar* account_name);
314
315 /**
316  * modest_server_account_data_get_secure_auth:
317  * @self: a ModestAccountMgr instance
318  * @account_name: The name of a server account.
319  * @secure_auth: The secure authentication enum value.
320  *
321  * Gets the secure authentication method for this server account.
322  */
323 void modest_account_mgr_set_server_account_secure_auth (ModestAccountMgr *self, 
324                                                         const gchar* account_name, 
325                                                         ModestAuthProtocol secure_auth);
326         
327 /**
328  * modest_server_account_data_get_security:
329  * @self: a ModestAccountMgr instance
330  * @account_name: The name of a server account.
331  *
332  * Gets the security method for this server account.
333  *
334  * Returns: The security enum value.
335  */
336 ModestConnectionProtocol modest_account_mgr_get_server_account_security (ModestAccountMgr *self, 
337                                                                          const gchar* account_name);
338
339 /**
340  * modest_account_mgr_set_server_account_security:
341  * @self: a ModestAccountMgr instance
342  * @secure_auth: The security enum value.
343  *
344  * Gets the security method for this server account.
345  */
346 void modest_account_mgr_set_server_account_security (ModestAccountMgr *self, 
347                                                      const gchar* account_name, 
348                                                      ModestConnectionProtocol security);
349
350 gboolean modest_account_mgr_save_server_settings (ModestAccountMgr *self,
351                                                   ModestServerAccountSettings *settings);
352
353 ModestServerAccountSettings *modest_account_mgr_load_server_settings (ModestAccountMgr *self,
354                                                                       const gchar *account_name);
355
356 /**
357  * modest_account_mgr_get_from_string
358  * @self: a #ModestAccountMgr instance
359  * @name: the account name
360  *
361  * get the From: string for some account; ie. "Foo Bar" &lt;foo.bar@cuux.yy&gt;"
362  *
363  * Returns: the newly allocated from-string, or NULL in case of error
364  */
365 gchar * modest_account_mgr_get_from_string (ModestAccountMgr *self, const gchar* name);
366
367
368 /**
369  * modest_account_mgr_get_unused_account_name
370  * @self: a #ModestAccountMgr instance
371  * @name: The initial account name
372  *
373  * get an unused account name, based on a starting string.
374  *
375  * Returns: the newly allocated name.
376  */
377 gchar* modest_account_mgr_get_unused_account_name (ModestAccountMgr *self, 
378                                                    const gchar* starting_name,
379                                                    gboolean server_account);
380
381 /**
382  * modest_account_mgr_get_unused_account_display name
383  * @self: a #ModestAccountMgr instance
384  * @name: The initial account display name
385  *
386  * get an unused account display name, based on a starting string.
387  *
388  * Returns: the newly allocated name.
389  */
390 gchar* modest_account_mgr_get_unused_account_display_name (ModestAccountMgr *self, 
391                                                            const gchar* starting_name);
392
393 /**
394  * modest_account_mgr_set_server_account_security:
395  * @self: a ModestAccountMgr instance
396  * @secure_auth: The security enum value.
397  *
398  * Gets the security method for this server account.
399  */
400 void modest_account_mgr_set_leave_on_server (ModestAccountMgr *self, 
401                                              const gchar* account_name, 
402                                              gboolean leave_on_server);
403
404 gboolean modest_account_mgr_get_leave_on_server (ModestAccountMgr *self, 
405                                                  const gchar* account_name);
406
407 gint  modest_account_mgr_get_last_updated (ModestAccountMgr *self, 
408                                            const gchar* account_name);
409
410 void  modest_account_mgr_set_last_updated (ModestAccountMgr *self, 
411                                            const gchar* account_name,
412                                            gint time);
413
414 gint  modest_account_mgr_get_retrieve_limit (ModestAccountMgr *self, 
415                                              const gchar* account_name);
416
417 void  modest_account_mgr_set_retrieve_limit (ModestAccountMgr *self, 
418                                              const gchar* account_name,
419                                              gint limit_retrieve);
420
421 gint  modest_account_mgr_get_server_account_port (ModestAccountMgr *self, 
422                                                   const gchar* account_name);
423
424 void  modest_account_mgr_set_server_account_port (ModestAccountMgr *self, 
425                                                   const gchar *account_name,
426                                                   gint port_num);
427
428 gchar* modest_account_mgr_get_server_account_name (ModestAccountMgr *self, 
429                                                    const gchar *account_name,
430                                                    TnyAccountType account_type);
431
432 ModestAccountRetrieveType modest_account_mgr_get_retrieve_type (ModestAccountMgr *self, 
433                                                                 const gchar *account_name);
434
435 void  modest_account_mgr_set_retrieve_type (ModestAccountMgr *self, 
436                                             const gchar *account_name,
437                                             ModestAccountRetrieveType retrieve_type);
438
439 void  modest_account_mgr_set_user_fullname (ModestAccountMgr *self, 
440                                             const gchar *account_name,
441                                             const gchar *fullname);
442
443 void  modest_account_mgr_set_user_email (ModestAccountMgr *self, 
444                                          const gchar *account_name,
445                                          const gchar *email);
446
447 G_END_DECLS
448
449 #endif /* __MODEST_ACCOUNT_MGR_H__ */