* modest-account-mgr*.[ch]:
[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
36 G_BEGIN_DECLS
37
38 typedef struct {
39         gchar *account_name;
40         gchar *hostname;
41         gchar *username;
42         ModestProtocol proto;
43         gchar *password;
44 } ModestServerAccountData;
45
46 typedef struct {
47         gchar *account_name;
48         gchar *display_name;
49         gchar *fullname;
50         gchar *email;
51         gboolean enabled;
52         ModestServerAccountData *transport_account;
53         ModestServerAccountData *store_account;
54 } ModestAccountData;
55
56 /**
57  * modest_account_mgr_get_account_data:
58  * @self: a ModestAccountMgr instance
59  * @name: the name of the account
60  * 
61  * get information about an account
62  *
63  * Returns: a ModestAccountData structure with information about the account.
64  * the data should not be changed, and be freed with modest_account_mgr_free_account_data
65  * The function does a sanity check, an if it's not returning NULL,
66  * it is a valid account
67  */
68 ModestAccountData *modest_account_mgr_get_account_data     (ModestAccountMgr *self,
69                                                             const gchar* name);
70
71
72 /**
73  * modest_account_mgr_free_account_data:
74  * @self: a ModestAccountMgr instance
75  * @data: a ModestAccountData instance
76  * 
77  * free the account data structure
78  */
79 void       modest_account_mgr_free_account_data     (ModestAccountMgr *self,
80                                                      ModestAccountData *data);
81
82
83 /**
84  * modest_account_mgr_server_account_names:
85  * @self: a ModestAccountMgr instance
86  * @account_name: get only server accounts for @account_name, or NULL for any
87  * @type: get only server accounts from protocol type @type, or MODEST_PROTO_TYPE_ANY
88  * @proto: get only server account with protocol @proto, or NULL for any
89  * @only_enabled: get only enabled server accounts if TRUE
90  * 
91  * list all the server account names
92  *
93  * Returns: a newly allocated list of server account names, or NULL in case of
94  * error or if there are no server accounts. The caller must free the returned GSList
95  */
96 GSList*  modest_account_mgr_search_server_accounts  (ModestAccountMgr *self,
97                                                      const gchar*       account_name,
98                                                      ModestProtocolType type,
99                                                      ModestProtocol     proto);
100
101 /**
102  * modest_account_mgr_account_set_enabled
103  * @self: a ModestAccountMgr instance
104  * @name: the account name 
105  * @enabled: if TRUE, the account will be enabled, if FALSE, it will be disabled
106  * 
107  * enable/disabled an account
108  *
109  * Returns: TRUE if it worked, FALSE otherwise
110  */
111 gboolean modest_account_mgr_account_set_enabled (ModestAccountMgr *self, const gchar* name,
112                                                  gboolean enabled);
113
114
115 /**
116  * modest_account_mgr_account_get_enabled:
117  * @self: a ModestAccountMgr instance
118  * @name: the account name to check
119  *
120  * check whether a certain account is enabled
121  *
122  * Returns: TRUE if it is enabled, FALSE otherwise
123  */
124 gboolean modest_account_mgr_account_get_enabled (ModestAccountMgr *self, const gchar* name);
125
126
127 G_END_DECLS
128
129 #endif /* __MODEST_ACCOUNT_MGR_H__ */