1 /* Copyright (c) 2006, Nokia Corporation
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
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.
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.
31 #ifndef __MODEST_ACCOUNT_MGR_HELPERS_H__
32 #define __MODEST_ACCOUNT_MGR_HELPERS_H__
34 #include <modest-account-mgr.h>
35 #include <modest-tny-account-store.h>
37 #include <tny-account.h>
38 #include <tny-store-account.h>
39 #include <tny-transport-account.h>
48 ModestProtocol proto; /*< The store or transport. Not ORed. */
51 gint port; /* Or 0, if the default should be used. */
53 } ModestServerAccountData;
62 ModestServerAccountData *transport_account;
63 ModestServerAccountData *store_account;
69 * modest_account_mgr_get_account_data:
70 * @self: a ModestAccountMgr instance
71 * @name: the name of the account
73 * get information about an account
75 * Returns: a ModestAccountData structure with information about the account.
76 * the data should not be changed, and be freed with modest_account_mgr_free_account_data
77 * The function does a sanity check, an if it's not returning NULL,
78 * it is a valid account
80 ModestAccountData *modest_account_mgr_get_account_data (ModestAccountMgr *self,
84 * modest_account_mgr_get_default_account:
85 * @self: a ModestAccountMgr instance
87 * get the default account name, or NULL if none is found
89 * Returns: the default account name (as newly allocated string, which
90 * must be g_free'd), or NULL
92 gchar* modest_account_mgr_get_default_account (ModestAccountMgr *self);
95 * modest_account_mgr_get_default_account:
96 * @self: a ModestAccountMgr instance
97 * @account: the name of an existing account
99 * set the default account name (which must be valid account)
101 * Returns: TRUE if succeeded, FALSE otherwise
103 gboolean modest_account_mgr_set_default_account (ModestAccountMgr *self,
104 const gchar* account);
107 * modest_account_mgr_free_account_data:
108 * @self: a ModestAccountMgr instance
109 * @data: a ModestAccountData instance
111 * free the account data structure
113 void modest_account_mgr_free_account_data (ModestAccountMgr *self,
114 ModestAccountData *data);
117 * modest_account_mgr_set_enabled
118 * @self: a ModestAccountMgr instance
119 * @name: the account name
120 * @enabled: if TRUE, the account will be enabled, if FALSE, it will be disabled
122 * enable/disabled an account
124 * Returns: TRUE if it worked, FALSE otherwise
126 gboolean modest_account_mgr_set_enabled (ModestAccountMgr *self, const gchar* name,
130 * modest_account_mgr_get_enabled:
131 * @self: a ModestAccountMgr instance
132 * @name: the account name to check
134 * check whether a certain account is enabled
136 * Returns: TRUE if it is enabled, FALSE otherwise
138 gboolean modest_account_mgr_get_enabled (ModestAccountMgr *self, const gchar* name);
141 * modest_server_account_get_secure_auth:
142 * @self: a ModestAccountMgr instance
143 * @account_name: The name of a server account.
145 * Gets the secure authentication method for this server account.
147 * Returns: The secure authentication enum value.
150 modest_server_account_get_secure_auth (ModestAccountMgr *self, const gchar* account_name);
153 * modest_server_account_data_get_secure_auth:
154 * @self: a ModestAccountMgr instance
155 * @account_name: The name of a server account.
156 * @secure_auth: The secure authentication enum value.
158 * Gets the secure authentication method for this server account.
161 modest_server_account_set_secure_auth (ModestAccountMgr *self, const gchar* account_name,
162 ModestProtocol secure_auth);
165 * modest_server_account_data_get_security:
166 * @self: a ModestAccountMgr instance
167 * @account_name: The name of a server account.
169 * Gets the security method for this server account.
171 * Returns: The security enum value.
174 modest_server_account_get_security (ModestAccountMgr *self, const gchar* account_name);
177 * modest_server_account_set_security:
178 * @self: a ModestAccountMgr instance
179 * @secure_auth: The security enum value.
181 * Gets the security method for this server account.
184 modest_server_account_set_security (ModestAccountMgr *self, const gchar* account_name,
185 ModestProtocol security);
189 * modest_account_mgr_get_account_option:
190 * @self: a ModestAccountMgr instance
191 * @account_name: the account name to check
192 * @account_name: the option name to check
194 * Returns: The account option value. This must be freed with g_free().
196 gchar* modest_account_mgr_get_server_account_option (ModestAccountMgr *self,
197 const gchar* account_name, const gchar* option_name);
200 * modest_server_account_data_get_option_value:
201 * @options_list: a ModestServerAccountData::options list.
202 * @option_name: the option name to check
204 * Returns: The account option value. This must be freed with g_free().
206 gchar* modest_server_account_data_get_option_string (GSList* options_list, const gchar* option_name);
209 * modest_server_account_data_get_option_bool:
210 * @options_list: a ModestServerAccountData::options list.
211 * @option_name: the option name to check
213 * Returns: Whether the account option is present.
215 gboolean modest_server_account_data_get_option_bool (GSList* options_list, const gchar* option_name);
219 * modest_account_mgr_get_from_string
220 * @self: a #ModestAccountMgr instance
221 * @name: the account name
223 * get the From: string for some account; ie. "Foo Bar" <foo.bar@cuux.yy>"
225 * Returns: the newly allocated from-string, or NULL in case of error
227 gchar * modest_account_mgr_get_from_string (ModestAccountMgr *self, const gchar* name);
232 #endif /* __MODEST_ACCOUNT_MGR_H__ */