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. */
52 ModestProtocol secure_auth;
53 ModestProtocol security;
55 } ModestServerAccountData;
64 ModestServerAccountData *transport_account;
65 ModestServerAccountData *store_account;
71 * modest_account_mgr_get_account_data:
72 * @self: a ModestAccountMgr instance
73 * @name: the name of the account
75 * get information about an account
77 * Returns: a ModestAccountData structure with information about the account.
78 * the data should not be changed, and be freed with modest_account_mgr_free_account_data
79 * The function does a sanity check, an if it's not returning NULL,
80 * it is a valid account
82 ModestAccountData *modest_account_mgr_get_account_data (ModestAccountMgr *self,
86 * modest_account_mgr_get_default_account:
87 * @self: a ModestAccountMgr instance
89 * get the default account name, or NULL if none is found
91 * Returns: the default account name (as newly allocated string, which
92 * must be g_free'd), or NULL
94 gchar* modest_account_mgr_get_default_account (ModestAccountMgr *self);
97 * modest_account_mgr_get_default_account:
98 * @self: a ModestAccountMgr instance
99 * @account: the name of an existing account
101 * set the default account name (which must be valid account)
103 * Returns: TRUE if succeeded, FALSE otherwise
105 gboolean modest_account_mgr_set_default_account (ModestAccountMgr *self,
106 const gchar* account);
109 * modest_account_mgr_free_account_data:
110 * @self: a ModestAccountMgr instance
111 * @data: a ModestAccountData instance
113 * free the account data structure
115 void modest_account_mgr_free_account_data (ModestAccountMgr *self,
116 ModestAccountData *data);
119 * modest_account_mgr_set_enabled
120 * @self: a ModestAccountMgr instance
121 * @name: the account name
122 * @enabled: if TRUE, the account will be enabled, if FALSE, it will be disabled
124 * enable/disabled an account
126 * Returns: TRUE if it worked, FALSE otherwise
128 gboolean modest_account_mgr_set_enabled (ModestAccountMgr *self, const gchar* name,
132 * modest_account_mgr_get_enabled:
133 * @self: a ModestAccountMgr instance
134 * @name: the account name to check
136 * check whether a certain account is enabled
138 * Returns: TRUE if it is enabled, FALSE otherwise
140 gboolean modest_account_mgr_get_enabled (ModestAccountMgr *self, const gchar* name);
143 * modest_account_mgr_set_signature
144 * @self: a ModestAccountMgr instance
145 * @name: the account name to check
146 * @signature: the signature text
147 * @use_signature: Whether the signature should be used.
149 * Sets the signature text for the account.
151 * Returns: TRUE if it worked, FALSE otherwise
153 gboolean modest_account_mgr_set_signature (ModestAccountMgr *self, const gchar* name,
154 const gchar* signature, gboolean use_signature);
157 * modest_account_mgr_get_signature:
158 * @self: a ModestAccountMgr instance
159 * @name: the account name
160 * @use_signature: Pointer to a gboolean taht will be set to TRUE if the signature should be used.
162 * Gets the signature text for this account.
164 * Returns: The signature text, which should be freed with g_free().
166 gchar* modest_account_mgr_get_signature (ModestAccountMgr *self, const gchar* name,
167 gboolean* use_signature);
170 * modest_account_mgr_set_connection_specific_smtp
171 * @self: a ModestAccountMgr instance
172 * @name: the account name
173 * @connection_name: A libconic IAP connection name
174 * @server_account_name: a server account name to use for this connection.
176 * Specify a server account to use with the specific connection for this account.
178 * Returns: TRUE if it worked, FALSE otherwise
180 gboolean modest_account_mgr_set_connection_specific_smtp (ModestAccountMgr *self, const gchar* name,
181 const gchar* connection_name, const gchar* server_account_name);
184 * modest_account_mgr_remove_connection_specific_smtp
185 * @self: a ModestAccountMgr instance
186 * @name: the account name
187 * @connection_name: A libconic IAP connection name
189 * Disassacoiate a server account to use with the specific connection for this account.
191 * Returns: TRUE if it worked, FALSE otherwise
193 gboolean modest_account_mgr_remove_connection_specific_smtp (ModestAccountMgr *self, const gchar* name,
194 const gchar* connection_name);
197 * modest_account_mgr_get_connection_specific_smtp
198 * @self: a ModestAccountMgr instance
199 * @name: the account name
200 * @connection_name: A libconic IAP connection name
202 * Retrieve a server account to use with this specific connection for this account.
204 * Returns: a server account name to use for this connection, or NULL if none is specified.
206 gchar* modest_account_mgr_get_connection_specific_smtp (ModestAccountMgr *self, const gchar* name,
207 const gchar* connection_name);
210 * modest_server_account_get_secure_auth:
211 * @self: a ModestAccountMgr instance
212 * @account_name: The name of a server account.
214 * Gets the secure authentication method for this server account.
216 * Returns: The secure authentication enum value.
219 modest_server_account_get_secure_auth (ModestAccountMgr *self, const gchar* account_name);
222 * modest_server_account_data_get_secure_auth:
223 * @self: a ModestAccountMgr instance
224 * @account_name: The name of a server account.
225 * @secure_auth: The secure authentication enum value.
227 * Gets the secure authentication method for this server account.
230 modest_server_account_set_secure_auth (ModestAccountMgr *self, const gchar* account_name,
231 ModestProtocol secure_auth);
234 * modest_server_account_data_get_security:
235 * @self: a ModestAccountMgr instance
236 * @account_name: The name of a server account.
238 * Gets the security method for this server account.
240 * Returns: The security enum value.
243 modest_server_account_get_security (ModestAccountMgr *self, const gchar* account_name);
246 * modest_server_account_set_security:
247 * @self: a ModestAccountMgr instance
248 * @secure_auth: The security enum value.
250 * Gets the security method for this server account.
253 modest_server_account_set_security (ModestAccountMgr *self, const gchar* account_name,
254 ModestProtocol security);
256 ModestServerAccountData*
257 modest_account_mgr_get_server_account_data (ModestAccountMgr *self, const gchar* name);
260 modest_account_mgr_free_server_account_data (ModestAccountMgr *self,
261 ModestServerAccountData* data);
265 * modest_account_mgr_get_account_option:
266 * @self: a ModestAccountMgr instance
267 * @account_name: the account name to check
268 * @account_name: the option name to check
270 * Returns: The account option value. This must be freed with g_free().
272 gchar* modest_account_mgr_get_server_account_option (ModestAccountMgr *self,
273 const gchar* account_name, const gchar* option_name);
276 * modest_server_account_data_get_option_value:
277 * @options_list: a ModestServerAccountData::options list.
278 * @option_name: the option name to check
280 * Returns: The account option value. This must be freed with g_free().
282 gchar* modest_server_account_data_get_option_string (GSList* options_list, const gchar* option_name);
285 * modest_server_account_data_get_option_bool:
286 * @options_list: a ModestServerAccountData::options list.
287 * @option_name: the option name to check
289 * Returns: Whether the account option is present.
291 gboolean modest_server_account_data_get_option_bool (GSList* options_list, const gchar* option_name);
295 * modest_account_mgr_get_from_string
296 * @self: a #ModestAccountMgr instance
297 * @name: the account name
299 * get the From: string for some account; ie. "Foo Bar" <foo.bar@cuux.yy>"
301 * Returns: the newly allocated from-string, or NULL in case of error
303 gchar * modest_account_mgr_get_from_string (ModestAccountMgr *self, const gchar* name);
307 * modest_account_mgr_get_unused_account_name
308 * @self: a #ModestAccountMgr instance
309 * @name: The initial account name
311 * get an unused account name, based on a starting string.
313 * Returns: the newly allocated name.
316 modest_account_mgr_get_unused_account_name (ModestAccountMgr *self, const gchar* starting_name,
317 gboolean server_account);
320 * modest_account_mgr_get_unused_account_display name
321 * @self: a #ModestAccountMgr instance
322 * @name: The initial account display name
324 * get an unused account display name, based on a starting string.
326 * Returns: the newly allocated name.
329 modest_account_mgr_get_unused_account_display_name (ModestAccountMgr *self, const gchar* starting_name);
333 #endif /* __MODEST_ACCOUNT_MGR_H__ */