* Fixes NB#91689. fixes a wrong check for ASCII
[modest] / src / modest-account-protocol.h
1 /* Copyright (c) 2008, 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 /* modest-account-settings.h */
32
33 #ifndef __MODEST_ACCOUNT_PROTOCOL_H__
34 #define __MODEST_ACCOUNT_PROTOCOL_H__
35
36 #include "widgets/modest-account-settings-dialog.h"
37 #include "modest-protocol.h"
38 #include "modest-pair.h"
39 #include <tny-account.h>
40 #include <tny-list.h>
41
42 G_BEGIN_DECLS
43
44 /* convenience macros */
45 #define MODEST_TYPE_ACCOUNT_PROTOCOL             (modest_account_protocol_get_type())
46 #define MODEST_ACCOUNT_PROTOCOL(obj)             (G_TYPE_CHECK_INSTANCE_CAST((obj),MODEST_TYPE_ACCOUNT_PROTOCOL,ModestAccountProtocol))
47 #define MODEST_ACCOUNT_PROTOCOL_CLASS(klass)     (G_TYPE_CHECK_CLASS_CAST((klass),MODEST_TYPE_ACCOUNT_PROTOCOL,ModestAccountProtocolClass))
48 #define MODEST_IS_ACCOUNT_PROTOCOL(obj)          (G_TYPE_CHECK_INSTANCE_TYPE((obj),MODEST_TYPE_ACCOUNT_PROTOCOL))
49 #define MODEST_IS_ACCOUNT_PROTOCOL_CLASS(klass)  (G_TYPE_CHECK_CLASS_TYPE((klass),MODEST_TYPE_ACCOUNT_PROTOCOL))
50 #define MODEST_ACCOUNT_PROTOCOL_GET_CLASS(obj)   (G_TYPE_INSTANCE_GET_CLASS((obj),MODEST_TYPE_ACCOUNT_PROTOCOL,ModestAccountProtocolClass))
51
52 typedef struct _ModestAccountProtocol      ModestAccountProtocol;
53 typedef struct _ModestAccountProtocolClass ModestAccountProtocolClass;
54
55
56 struct _ModestAccountProtocol {
57         ModestProtocol parent;
58 };
59
60 struct _ModestAccountProtocolClass {
61         ModestProtocolClass parent_class;
62
63         /* Virtual methods */
64         TnyAccount * (*create_account) (ModestAccountProtocol *self);
65         ModestAccountSettingsDialog* (*create_account_settings_dialog) (ModestAccountProtocol* self);
66         ModestPairList* (*get_easysetupwizard_tabs) (ModestAccountProtocol* self);
67         void (*save_settings) (ModestAccountProtocol *self, ModestAccountSettingsDialog *dialog, ModestAccountSettings *settings);
68         void (*save_wizard_settings) (ModestAccountProtocol *self, GList *wizard_pages, ModestAccountSettings *settings);
69 };
70
71 /**
72  * modest_account_protocol_get_type:
73  *
74  * Returns: GType of the account protocol type
75  */
76 GType  modest_account_protocol_get_type   (void) G_GNUC_CONST;
77
78 /**
79  * modest_account_protocol_new:
80  *
81  * creates a new instance of #ModestAccountProtocol
82  *
83  * Returns: a #ModestAccountProtocol
84  */
85 ModestProtocol*    modest_account_protocol_new (const gchar *name, const gchar *display_name, 
86                                                 guint port, guint alternate_port,
87                                                 GType account_g_type);
88
89 /**
90  * modest_account_protocol_get_port:
91  * @self: a #ModestAccountProtocol
92  *
93  * get the protocol standard port
94  *
95  * Returns: a string
96  */
97 guint modest_account_protocol_get_port (ModestAccountProtocol *self);
98
99 /**
100  * modest_account_protocol_set_port:
101  * @self: a #ModestAccountProtocol
102  * @port: a #guint
103  *
104  * set @port as the protocol standard port
105  */
106 void         modest_account_protocol_set_port (ModestAccountProtocol *self,
107                                                guint port);
108
109 /**
110  * modest_account_protocol_get_alternate_port:
111  * @self: a #ModestAccountProtocol
112  *
113  * get the protocol standard alternate_port
114  *
115  * Returns: a #guint
116  */
117 guint modest_account_protocol_get_alternate_port (ModestAccountProtocol *self);
118
119 /**
120  * modest_account_protocol_set_alternate_port:
121  * @self: a #ModestAccountProtocol
122  * @alternate_port: a #guint
123  *
124  * set @alternate_port as the protocol alternate port
125  */
126 void         modest_account_protocol_set_alternate_port (ModestAccountProtocol *self,
127                                                          guint alternate_port);
128
129 /**
130  * modest_account_protocol_set_account_options:
131  * @self: a #ModestAccountProtocol
132  * @account_options: a #TnyList of account options and their values
133  *
134  * set the account options that will be passed to TnyCamelAccount for this protocol.
135  * This replaces previous option lists for this protocol
136  */
137 void modest_account_protocol_set_account_options (ModestAccountProtocol *self,
138                                                   TnyList *account_options);
139
140 /**
141  * modest_account_protocol_get_account_options:
142  * @self: a #ModestAccountProtocol
143  *
144  * obtain the account options for this account protocol.
145  *
146  * Returns: a caller-owner copy of the account options list.
147  */
148 TnyList *modest_account_protocol_get_account_options (ModestAccountProtocol *self);
149
150 /**
151  * modest_account_protocol_has_custom_secure_auth_mech:
152  * @self: a #ModestAccountProtocol
153  * @auth_protocol_type: a #ModestProtocolType for an auth protocol
154  *
155  * checks whether there's a custom secure auth mech camel string for @auth_protocol_type.
156  *
157  * Returns: %TRUE if registered, %FALSE otherwise
158  */
159 gboolean
160 modest_account_protocol_has_custom_secure_auth_mech (ModestAccountProtocol *self, ModestProtocolType auth_protocol_type);
161
162 /**
163  * modest_account_protocol_get_custom_secure_auth_mech:
164  * @self: a #ModestAccountProtocol
165  * @auth_protocol_type: a #ModestProtocolType for an auth protocol
166  *
167  * obtains the secure auth mech of @auth_protocol_type in protocol. Be careful as %NULL does not imply
168  * there's no custom auth mech registered (you can register %NULL). To check if it's registered, just
169  * use modest_account_protocol_has_custom_secure_auth_mech().
170  *
171  * Returns: the secure auth mech for this auth protocol type that will be passed to camel.
172  */
173 const gchar *
174 modest_account_protocol_get_custom_secure_auth_mech (ModestAccountProtocol *self, ModestProtocolType auth_protocol_type);
175
176 /**
177  * modest_account_protocol_unset_custom_secure_auth_mech:
178  * @self: a #ModestAccountProtocol
179  * @auth_protocol_type: a #ModestProtocolType for an auth protocol
180  *
181  * Unsets the secure auth meth of @auth_protocol_type in protocol.
182  */
183 void
184 modest_account_protocol_unset_custom_secure_auth_mech (ModestAccountProtocol *self, ModestProtocolType auth_protocol_type);
185
186 /**
187  * modest_account_protocol_set_custom_secure_auth_mech:
188  * @self: a #ModestAccountProtocol
189  * @auth_protocol_type: a #ModestProtocolType for an auth protocol
190  * @secure_auth_mech: a string or %NULL
191  *
192  * sets the secure auth mech of @auth_protocol_type in protocol. Be careful as %NULL does not imply
193  * there's no custom auth mech registered (you can register %NULL). If you set %NULL you're regitering %NULL as the custom secure auth
194  * mechanism instead of unsetting it.
195  */
196 void
197 modest_account_protocol_set_custom_secure_auth_mech (ModestAccountProtocol *self, ModestProtocolType auth_protocol_type, const gchar *secure_auth_mech);
198
199 /**
200  * modest_account_protocol_get_account_g_type:
201  * @self: a #ModestAccountProtocol
202  *
203  * get the protocol type used for factoring new TnyAccount
204  *
205  * Returns: a #GType
206  */
207 GType modest_account_protocol_get_account_g_type (ModestAccountProtocol *self);
208
209 /**
210  * modest_account_protocol_set_account_g_type:
211  * @self: a #ModestAccountProtocol
212  * @account_g_type: a #GType
213  *
214  * set @account_g_type as the type modest_account_protocol_create_account will
215  * instanciate
216  */
217 void         modest_account_protocol_set_account_g_type (ModestAccountProtocol *self,
218                                                          GType account_g_type);
219
220 /**
221  * modest_account_protocol_create_account:
222  * @self: a #ModestAccountProtocol
223  *
224  * create a new account instance for this protocol
225  *
226  * Returns: a #TnyAccount
227  */
228 TnyAccount * modest_account_protocol_create_account (ModestAccountProtocol *self);
229
230 /**
231  * modest_account_protocol_get_account_settings_dialog:
232  * @self: a #ModestAccountProtocol
233  * @account_name: the name of the account we're creating the dialog for
234  * 
235  * retrieves the account settings dialog used to setup the account
236  * represented by this protocol
237  * 
238  * Returns: a #ModestAccountSettingsDialog
239  **/
240 ModestAccountSettingsDialog* modest_account_protocol_get_account_settings_dialog (ModestAccountProtocol *self,
241                                                                                   const gchar *account_name);
242
243 ModestPairList* modest_account_protocol_get_easysetupwizard_tabs (ModestAccountProtocol *self);
244
245 /**
246  * modest_account_protocol_save_settings:
247  * @self: this #ModestAccountProtocol
248  * @dialog: a #ModestAccountSettingsDialog
249  * @settings: the #ModestAccountSettings
250  * 
251  * this function stores the values held by the account settings dialog
252  * in the account settings object that is passed as argument
253  *
254  * NOTE: this function provides a default implementation that calls
255  * the save_settings method of the acocunt settings dialog. So if your
256  * implementation do not do anything more just do not redefine it
257  **/
258 void modest_account_protocol_save_settings (ModestAccountProtocol *self, 
259                                             ModestAccountSettingsDialog *dialog,
260                                             ModestAccountSettings *settings);
261
262 /**
263  * modest_account_protocol_save_wizard_settings:
264  * @self: this #ModestAccountProtocol
265  * @wizard_pages: a list of #ModestEasysetupWizardPage
266  * @settings: the #ModestAccountSettings
267  * 
268  * this function stores the data input by the users in the wizard in
269  * the account settings object passed as argument
270  **/
271 void modest_account_protocol_save_wizard_settings (ModestAccountProtocol *self, 
272                                                    GList *wizard_pages,
273                                                    ModestAccountSettings *settings);
274
275 G_END_DECLS
276
277 #endif /* __MODEST_ACCOUNT_PROTOCOL_H__ */