093c4d633cece40db54278ac4610cc2deeb9b000
[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 LIMITED
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 G_BEGIN_DECLS
38
39 typedef struct {
40         gchar *account_name;
41         gchar *hostname;
42         gchar *username;
43         ModestProtocol proto;
44         gchar *password;
45         GSList *options;
46 } ModestServerAccountData;
47
48 typedef struct {
49         gchar *account_name;
50         gchar *display_name;
51         gchar *fullname;
52         gchar *email;
53         gboolean enabled;
54         ModestServerAccountData *transport_account;
55         ModestServerAccountData *store_account;
56 } ModestAccountData;
57
58
59
60 /**
61  * modest_account_mgr_get_account_data:
62  * @self: a ModestAccountMgr instance
63  * @name: the name of the account
64  * 
65  * get information about an account
66  *
67  * Returns: a ModestAccountData structure with information about the account.
68  * the data should not be changed, and be freed with modest_account_mgr_free_account_data
69  * The function does a sanity check, an if it's not returning NULL,
70  * it is a valid account
71  */
72 ModestAccountData *modest_account_mgr_get_account_data     (ModestAccountMgr *self,
73                                                             const gchar* name);
74
75 /**
76  * modest_account_mgr_get_default_account:
77  * @self: a ModestAccountMgr instance
78  * 
79  * get the default account name, or NULL if none is found
80  *
81  * Returns: the default account name (as newly allocated string, which
82  * must be g_free'd), or NULL
83  */
84 gchar* modest_account_mgr_get_default_account  (ModestAccountMgr *self);
85
86 /**
87  * modest_account_mgr_get_default_account:
88  * @self: a ModestAccountMgr instance
89  * @account: the name of an existing account
90  * 
91  * set the default account name (which must be valid account)
92  *
93  * Returns: TRUE if succeeded, FALSE otherwise
94  */
95 gboolean modest_account_mgr_set_default_account  (ModestAccountMgr *self,
96                                                   const gchar* account);
97
98 /**
99  * modest_account_mgr_free_account_data:
100  * @self: a ModestAccountMgr instance
101  * @data: a ModestAccountData instance
102  * 
103  * free the account data structure
104  */
105 void       modest_account_mgr_free_account_data     (ModestAccountMgr *self,
106                                                      ModestAccountData *data);
107
108
109
110 /**
111  * modest_account_mgr_account_set_enabled
112  * @self: a ModestAccountMgr instance
113  * @name: the account name 
114  * @enabled: if TRUE, the account will be enabled, if FALSE, it will be disabled
115  * 
116  * enable/disabled an account
117  *
118  * Returns: TRUE if it worked, FALSE otherwise
119  */
120 gboolean modest_account_mgr_account_set_enabled (ModestAccountMgr *self, const gchar* name,
121                                                  gboolean enabled);
122
123 /**
124  * modest_account_mgr_account_get_enabled:
125  * @self: a ModestAccountMgr instance
126  * @name: the account name to check
127  *
128  * check whether a certain account is enabled
129  *
130  * Returns: TRUE if it is enabled, FALSE otherwise
131  */
132 gboolean modest_account_mgr_account_get_enabled (ModestAccountMgr *self, const gchar* name);
133
134
135 G_END_DECLS
136
137 #endif /* __MODEST_ACCOUNT_MGR_H__ */