Close the edit mode after running move to dialog, not before.
[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 gchar *modest_account_mgr_get_signature_from_recipient (ModestAccountMgr *self, const gchar *recipient,
130                                                         gboolean *use_signature);
131 gboolean modest_account_mgr_account_is_multimailbox (ModestAccountMgr *mgr,
132                                                      const gchar *account_name, 
133                                                      ModestProtocol **mmb_protocol);
134         
135 /**
136  * modest_account_mgr_get_store_protocol:
137  * @self: a ModestAccountMgr instance
138  * @name: the account name
139  *
140  * Gets the protocol type (For instance, POP or IMAP) used for the store server account.
141  *
142  * Returns: The protocol type.
143  */
144 ModestProtocolType modest_account_mgr_get_store_protocol (ModestAccountMgr *self, const gchar* name);
145
146 /**
147  * modest_account_mgr_set_connection_specific_smtp
148  * @self: a ModestAccountMgr instance
149  * @connection_id: A libconic IAP connection name
150  * @server_account_name: a server account name to use for this connection.
151  * 
152  * Specify a server account to use with the specific connection for this account.
153  *
154  * Returns: TRUE if it worked, FALSE otherwise
155  */
156 gboolean modest_account_mgr_set_connection_specific_smtp (ModestAccountMgr *self, 
157                                          const gchar* connection_id, const gchar* server_account_name);
158
159 /**
160  * modest_account_mgr_remove_connection_specific_smtp
161  * @self: a ModestAccountMgr instance
162  * @connection_id: A libconic IAP connection name
163  * 
164  * Disassociate a server account to use with the specific connection for this account.
165  *
166  * Returns: TRUE if it worked, FALSE otherwise
167  */                              
168 gboolean modest_account_mgr_remove_connection_specific_smtp (ModestAccountMgr *self, 
169         const gchar* connection_id);
170
171 /**
172  * modest_account_mgr_get_use_connection_specific_smtp
173  * @self: a ModestAccountMgr instance
174  * @account_name: the account name
175  * @result: Whether this account should use connection-specific smtp server accounts.
176  */
177 gboolean modest_account_mgr_get_use_connection_specific_smtp (ModestAccountMgr *self, const gchar* account_name);
178
179 /**
180  * modest_account_mgr_set_use_connection_specific_smtp
181  * @self: a ModestAccountMgr instance
182  * @account_name: the account name
183  * @new_value: New value that indicates if if this account should use connection-specific smtp server accounts.
184  * @result: TRUE if it succeeded, FALSE otherwise
185  */
186 gboolean modest_account_mgr_set_use_connection_specific_smtp (ModestAccountMgr *self, 
187                                                               const gchar* account_name,
188                                                               gboolean new_value);
189
190 /**
191  * modest_account_mgr_get_connection_specific_smtp
192  * @self: a ModestAccountMgr instance
193  * @connection_id: A libconic IAP connection id
194  * 
195  * Retrieve a server account to use with this specific connection for this account.
196  *
197  * Returns: a server account name to use for this connection, or NULL if none is specified.
198  */                      
199 gchar* modest_account_mgr_get_connection_specific_smtp (ModestAccountMgr *self, 
200                                                         const gchar* connection_id);
201
202
203 /**
204  * modest_account_mgr_get_server_account_username:
205  * @self: a ModestAccountMgr instance
206  * @account_name: The name of a server account.
207  *
208  * Gets the username this server account.
209  *
210  * Returns: The username.
211  */
212 gchar* modest_account_mgr_get_server_account_username (ModestAccountMgr *self, 
213                                                        const gchar* account_name);
214
215 /**
216  * modest_account_mgr_set_server_account_username:
217  * @self: a ModestAccountMgr instance
218  * @account_name: The name of a server account.
219  * @username: The new username.
220  *
221  * Sets the username this server account.
222  */
223 void modest_account_mgr_set_server_account_username (ModestAccountMgr *self, 
224                                                      const gchar* account_name, 
225                                                      const gchar* username);
226
227 /**
228  * modest_account_mgr_get_server_account_username_has_succeeded:
229  * @self: a ModestAccountMgr instance
230  * @account_name: The name of a server account.
231  *
232  * Whether a connection has ever been successfully made to this account with 
233  * the current username. This can be used to avoid asking again for the username 
234  * when asking a second time for a non-stored password.
235  *
236  * Returns: TRUE if the username is known to be correct.
237  */
238 gboolean modest_account_mgr_get_server_account_username_has_succeeded (ModestAccountMgr *self, 
239                                                                        const gchar* account_name);
240
241 /**
242  * modest_account_mgr_set_server_account_username_has_succeeded:
243  * @self: a ModestAccountMgr instance
244  * @account_name: The name of a server account.
245  * @succeeded: Whether the username has succeeded
246  *
247  * Sets whether the username is known to be correct.
248  */
249 void modest_account_mgr_set_server_account_username_has_succeeded (ModestAccountMgr *self, 
250                                                                    const gchar* account_name, 
251                                                                    gboolean succeeded);
252         
253 /**
254  * modest_account_mgr_set_server_account_password:
255  * @self: a ModestAccountMgr instance
256  * @account_name: The name of a server account.
257  * @password: The new password.
258  *
259  * Sets the password for this server account.
260  */
261 void modest_account_mgr_set_server_account_password (ModestAccountMgr *self, 
262                                                      const gchar* account_name, 
263                                                      const gchar* password);
264         
265 /**
266  * modest_account_mgr_get_server_account_password:
267  * @self: a ModestAccountMgr instance
268  * @account_name: The name of a server account.
269  *
270  * Gets the password for this server account from the account settings.
271  */
272 gchar* modest_account_mgr_get_server_account_password (ModestAccountMgr *self, 
273                                                        const gchar* account_name);
274
275 /**
276  * modest_account_mgr_get_server_account_has_password:
277  * @self: a ModestAccountMgr instance
278  * @account_name: The name of a server account.
279  *
280  * Gets whether a password has been set for this server account in the account settings.
281  */
282 gboolean modest_account_mgr_get_server_account_has_password (ModestAccountMgr *self, 
283                                                              const gchar* account_name);         
284
285 /**
286  * modest_server_account_modest_account_mgr_get_server_account_hostname:
287  * @self: a ModestAccountMgr instance
288  * @account_name: The name of a server account.
289  *
290  * Gets the hostname this server account.
291  *
292  * Returns: The hostname.
293  */
294 gchar* modest_account_mgr_get_server_account_hostname (ModestAccountMgr *self, 
295                                                        const gchar* account_name);
296
297 /**
298  * modest_server_account_modest_account_mgr_set_server_account_hostname:
299  * @self: a ModestAccountMgr instance
300  * @account_name: The name of a server account.
301  * @hostname: The new hostname
302  *
303  * Sets the hostname this server account.
304  */
305 void  modest_account_mgr_set_server_account_hostname (ModestAccountMgr *self, 
306                                                       const gchar* account_name,
307                                                       const gchar *hostname);
308
309 /**
310  * modest_account_mgr_get_server_account_secure_auth:
311  * @self: a ModestAccountMgr instance
312  * @account_name: The name of a server account.
313  *
314  * Gets the secure authentication method for this server account.
315  *
316  * Returns: The secure authentication enum value.
317  */
318 ModestProtocolType modest_account_mgr_get_server_account_secure_auth (ModestAccountMgr *self, 
319                                                                       const gchar* account_name);
320
321 /**
322  * modest_server_account_data_get_secure_auth:
323  * @self: a ModestAccountMgr instance
324  * @account_name: The name of a server account.
325  * @secure_auth: The secure authentication enum value.
326  *
327  * Gets the secure authentication method for this server account.
328  */
329 void modest_account_mgr_set_server_account_secure_auth (ModestAccountMgr *self, 
330                                                         const gchar* account_name, 
331                                                         ModestProtocolType secure_auth);
332         
333 /**
334  * modest_server_account_data_get_security:
335  * @self: a ModestAccountMgr instance
336  * @account_name: The name of a server account.
337  *
338  * Gets the security method for this server account.
339  *
340  * Returns: The security connection protocol.
341  */
342 ModestProtocolType modest_account_mgr_get_server_account_security (ModestAccountMgr *self, 
343                                                                    const gchar* account_name);
344
345 /**
346  * modest_account_mgr_set_server_account_security:
347  * @self: a ModestAccountMgr instance
348  * @secure_auth: The security enum value.
349  *
350  * Gets the security method for this server account.
351  */
352 void modest_account_mgr_set_server_account_security (ModestAccountMgr *self, 
353                                                      const gchar* account_name, 
354                                                      ModestProtocolType security);
355
356 gboolean modest_account_mgr_save_server_settings (ModestAccountMgr *self,
357                                                   ModestServerAccountSettings *settings);
358
359 ModestServerAccountSettings *modest_account_mgr_load_server_settings (ModestAccountMgr *self,
360                                                                       const gchar *account_name,
361                                                                       gboolean is_transport_not_store);
362
363 /**
364  * modest_account_mgr_get_from_string
365  * @self: a #ModestAccountMgr instance
366  * @name: the account name
367  * @mailbox: the mailbox
368  *
369  * get the From: string for some account; ie. "Foo Bar" &lt;foo.bar@cuux.yy&gt;"
370  *
371  * Returns: the newly allocated from-string, or NULL in case of error
372  */
373 gchar * modest_account_mgr_get_from_string (ModestAccountMgr *self, const gchar* name, const gchar *mailbox);
374
375
376 /**
377  * modest_account_mgr_get_unused_account_name
378  * @self: a #ModestAccountMgr instance
379  * @name: The initial account name
380  *
381  * get an unused account name, based on a starting string.
382  *
383  * Returns: the newly allocated name.
384  */
385 gchar* modest_account_mgr_get_unused_account_name (ModestAccountMgr *self, 
386                                                    const gchar* starting_name,
387                                                    gboolean server_account);
388
389 /**
390  * modest_account_mgr_get_unused_account_display name
391  * @self: a #ModestAccountMgr instance
392  * @name: The initial account display name
393  *
394  * get an unused account display name, based on a starting string.
395  *
396  * Returns: the newly allocated name.
397  */
398 gchar* modest_account_mgr_get_unused_account_display_name (ModestAccountMgr *self, 
399                                                            const gchar* starting_name);
400
401 /**
402  * modest_account_mgr_set_server_account_security:
403  * @self: a ModestAccountMgr instance
404  * @secure_auth: The security enum value.
405  *
406  * Gets the security method for this server account.
407  */
408 void modest_account_mgr_set_leave_on_server (ModestAccountMgr *self, 
409                                              const gchar* account_name, 
410                                              gboolean leave_on_server);
411
412 gboolean modest_account_mgr_get_leave_on_server (ModestAccountMgr *self, 
413                                                  const gchar* account_name);
414
415 gint  modest_account_mgr_get_last_updated (ModestAccountMgr *self, 
416                                            const gchar* account_name);
417
418 void  modest_account_mgr_set_last_updated (ModestAccountMgr *self, 
419                                            const gchar* account_name,
420                                            gint time);
421
422 gint  modest_account_mgr_get_retrieve_limit (ModestAccountMgr *self, 
423                                              const gchar* account_name);
424
425 void  modest_account_mgr_set_retrieve_limit (ModestAccountMgr *self, 
426                                              const gchar* account_name,
427                                              gint limit_retrieve);
428
429 gint  modest_account_mgr_get_server_account_port (ModestAccountMgr *self, 
430                                                   const gchar* account_name);
431
432 void  modest_account_mgr_set_server_account_port (ModestAccountMgr *self, 
433                                                   const gchar *account_name,
434                                                   gint port_num);
435
436 gchar* modest_account_mgr_get_server_account_name (ModestAccountMgr *self, 
437                                                    const gchar *account_name,
438                                                    TnyAccountType account_type);
439
440 ModestAccountRetrieveType modest_account_mgr_get_retrieve_type (ModestAccountMgr *self, 
441                                                                 const gchar *account_name);
442
443 void  modest_account_mgr_set_retrieve_type (ModestAccountMgr *self, 
444                                             const gchar *account_name,
445                                             ModestAccountRetrieveType retrieve_type);
446
447 void  modest_account_mgr_set_user_fullname (ModestAccountMgr *self, 
448                                             const gchar *account_name,
449                                             const gchar *fullname);
450
451 void  modest_account_mgr_set_user_email (ModestAccountMgr *self, 
452                                          const gchar *account_name,
453                                          const gchar *email);
454
455 G_END_DECLS
456
457 #endif /* __MODEST_ACCOUNT_MGR_H__ */