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