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>
44 TnyAccount *tny_account;
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);
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);
145 * modest_account_mgr_get_tny_account:
146 * @self: a #ModestAccountMgr instance
147 * @name: the account name
148 * @type: the #TnyAccountType to check; either TNY_ACCOUNT_TYPE_TRANSPORT or TNY_ACCOUNT_TYPE_STORE
150 * get the TnyAccount corresponding to the store/transport (server) accounts for some account.
151 * ie., every account has two server accounts, and for every server account there is a corresponding
154 * Returns: the requested TnyAccount, or NULL in case of error
156 TnyAccount* modest_account_mgr_get_tny_account (ModestAccountMgr *self, const gchar* name,
157 TnyAccountType type);
160 * modest_account_mgr_get_from_string
161 * @self: a #ModestAccountMgr instance
162 * @name: the account name
164 * get the From: string for some account; ie. "Foo Bar" <foo.bar@cuux.yy>"
166 * Returns: the newly allocated from-string, or NULL in case of error
168 gchar * modest_account_mgr_get_from_string (ModestAccountMgr *self, const gchar* name);
173 #endif /* __MODEST_ACCOUNT_MGR_H__ */