Added method modest_account_protocol_check_support
[modest] / src / modest-account-protocol.c
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 #include <tny-simple-list.h>
31 #include "modest-account-protocol.h"
32 #include "modest-account-mgr-helpers.h"
33 #include "widgets/modest-default-account-settings-dialog.h"
34 #include "modest-runtime.h"
35
36 enum {
37         PROP_0,
38         PROP_PORT,
39         PROP_ALTERNATE_PORT,
40         PROP_ACCOUNT_G_TYPE,
41 };
42
43 typedef struct _ModestAccountProtocolPrivate ModestAccountProtocolPrivate;
44 struct _ModestAccountProtocolPrivate {
45         guint port;
46         guint alternate_port;
47         TnyList *account_options;
48         GHashTable *custom_auth_mechs;
49         GType account_g_type;
50
51         GHashTable *account_dialogs;
52 };
53
54 /* 'private'/'protected' functions */
55 static void   modest_account_protocol_class_init (ModestAccountProtocolClass *klass);
56 static void   modest_account_protocol_finalize   (GObject *obj);
57 static void   modest_account_protocol_get_property (GObject *obj,
58                                             guint property_id,
59                                             GValue *value,
60                                             GParamSpec *pspec);
61 static void   modest_account_protocol_set_property (GObject *obj,
62                                             guint property_id,
63                                             const GValue *value,
64                                             GParamSpec *pspec);
65 static void   modest_account_protocol_instance_init (ModestAccountProtocol *obj);
66
67 #define MODEST_ACCOUNT_PROTOCOL_GET_PRIVATE(o)     (G_TYPE_INSTANCE_GET_PRIVATE ((o), \
68                                                                                  MODEST_TYPE_ACCOUNT_PROTOCOL, \
69                                                                                  ModestAccountProtocolPrivate))
70
71 static TnyAccount *modest_account_protocol_create_account_default (ModestAccountProtocol *self);
72
73 static ModestAccountSettingsDialog *modest_account_protocol_create_account_settings_dialog_default (ModestAccountProtocol *self);
74
75 static ModestPairList* modest_account_protocol_get_easysetupwizard_tabs_default (ModestAccountProtocol *self);
76
77 static void modest_account_protocol_save_settings_default (ModestAccountProtocol *self, 
78                                                            ModestAccountSettingsDialog *dialog,
79                                                            ModestAccountSettings *settings);
80
81 static void modest_account_protocol_save_wizard_settings_default (ModestAccountProtocol *self, 
82                                                                   GList *wizard_pages,
83                                                                   ModestAccountSettings *settings);
84
85 static ModestWizardDialogResponseOverrideFunc 
86 modest_account_protocol_get_wizard_response_override_default (ModestAccountProtocol *self);
87
88 static void modest_account_protocol_check_support_default (ModestAccountProtocol *self,
89                                                            ModestAccountProtocolCheckSupportFunc func,
90                                                            gpointer userdata);
91 static gboolean modest_account_protocol_is_supported_default (ModestAccountProtocol *self);
92
93 /* globals */
94 static GObjectClass *parent_class = NULL;
95
96 GType
97 modest_account_protocol_get_type (void)
98 {
99         static GType my_type = 0;
100
101         if (!my_type) {
102                 static const GTypeInfo my_info = {
103                         sizeof(ModestAccountProtocolClass),
104                         NULL,   /* base init */
105                         NULL,   /* base finalize */
106                         (GClassInitFunc) modest_account_protocol_class_init,
107                         NULL,   /* class finalize */
108                         NULL,   /* class data */
109                         sizeof(ModestAccountProtocol),
110                         0,      /* n_preallocs */
111                         (GInstanceInitFunc) modest_account_protocol_instance_init,
112                         NULL
113                 };
114
115                 my_type = g_type_register_static (MODEST_TYPE_PROTOCOL,
116                                                   "ModestAccountProtocol",
117                                                   &my_info, 0);
118         }
119         return my_type;
120 }
121
122 static void
123 modest_account_protocol_class_init (ModestAccountProtocolClass *klass)
124 {
125         GObjectClass *object_class;
126         ModestAccountProtocolClass *account_class;
127
128         object_class = (GObjectClass *) klass;
129         account_class = MODEST_ACCOUNT_PROTOCOL_CLASS (klass);
130         parent_class = g_type_class_peek_parent (klass);
131         object_class->finalize = modest_account_protocol_finalize;
132         object_class->set_property = modest_account_protocol_set_property;
133         object_class->get_property = modest_account_protocol_get_property;
134
135         g_object_class_install_property (object_class,
136                                          PROP_PORT,
137                                          g_param_spec_uint ("port",
138                                                            _("Standard port"),
139                                                            _("The standard port for the protocol"),
140                                                            0, G_MAXINT, 0,
141                                                            G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT));
142
143         g_object_class_install_property (object_class,
144                                          PROP_ALTERNATE_PORT,
145                                          g_param_spec_uint ("alternate-port",
146                                                            _("Alternate port"),
147                                                            _("The alternate port for the protocol (usually used in SSL)"),
148                                                            0, G_MAXINT, 0,
149                                                            G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT));
150
151         g_object_class_install_property (object_class,
152                                          PROP_ACCOUNT_G_TYPE,
153                                          g_param_spec_gtype ("account-g-type",
154                                                              _("Account factory GType"),
155                                                              _("Account factory GType used for creating new instances."),
156                                                              TNY_TYPE_ACCOUNT,
157                                                              G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT));
158
159         g_type_class_add_private (object_class,
160                                   sizeof(ModestAccountProtocolPrivate));
161
162         /* Virtual methods */
163         account_class->create_account_settings_dialog = 
164                 modest_account_protocol_create_account_settings_dialog_default;
165         account_class->get_easysetupwizard_tabs = 
166                 modest_account_protocol_get_easysetupwizard_tabs_default;
167         account_class->save_settings = 
168                 modest_account_protocol_save_settings_default;
169         account_class->save_wizard_settings = 
170                 modest_account_protocol_save_wizard_settings_default;
171         account_class->create_account =
172                 modest_account_protocol_create_account_default;
173         account_class->get_wizard_response_override =
174                 modest_account_protocol_get_wizard_response_override_default;
175         account_class->is_supported =
176                 modest_account_protocol_is_supported_default;
177         account_class->check_support =
178                 modest_account_protocol_check_support_default;
179 }
180
181 static void
182 modest_account_protocol_instance_init (ModestAccountProtocol *obj)
183 {
184         ModestAccountProtocolPrivate *priv;
185
186         priv = MODEST_ACCOUNT_PROTOCOL_GET_PRIVATE (obj);
187
188         priv->port = 0;
189         priv->alternate_port = 0;
190         priv->account_g_type = 0;
191         priv->account_options = tny_simple_list_new ();
192         priv->custom_auth_mechs = g_hash_table_new_full (g_direct_hash, g_direct_equal, NULL, g_free);
193
194         priv->account_dialogs = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL);
195 }
196
197 static gboolean
198 remove_account (const gchar *account_name, GObject *account, GObject *account_to_remove)
199 {
200         return (account == account_to_remove);
201 }
202
203 static void
204 account_dialog_weak_handler (ModestAccountProtocol *self, GObject *where_the_object_was)
205 {
206         ModestAccountProtocolPrivate *priv = MODEST_ACCOUNT_PROTOCOL_GET_PRIVATE (self);
207
208         g_hash_table_foreach_remove (priv->account_dialogs, (GHRFunc) remove_account, where_the_object_was);
209 }
210
211 static gboolean
212 dialogs_remove (const gchar *account_name, GObject *account_dialog, ModestAccountProtocol *self)
213 {
214         g_object_weak_unref (account_dialog, (GWeakNotify) account_dialog_weak_handler, self);
215
216         return TRUE;
217 }
218
219 static void   
220 modest_account_protocol_finalize   (GObject *obj)
221 {
222         ModestAccountProtocol *protocol = MODEST_ACCOUNT_PROTOCOL (obj);
223         ModestAccountProtocolPrivate *priv = MODEST_ACCOUNT_PROTOCOL_GET_PRIVATE (protocol);
224
225         if (priv->account_dialogs) {
226                 g_hash_table_foreach_remove (priv->account_dialogs, (GHRFunc) dialogs_remove, obj);
227                 g_hash_table_destroy (priv->account_dialogs);
228         }
229
230         if (priv->account_options)
231                 g_object_unref (priv->account_options);
232         priv->account_options = NULL;
233
234         if (priv->custom_auth_mechs)
235                 g_hash_table_destroy (priv->custom_auth_mechs);
236         priv->custom_auth_mechs = NULL;
237
238         G_OBJECT_CLASS (parent_class)->finalize (obj);
239 }
240
241 static void   
242 modest_account_protocol_get_property (GObject *obj,
243                                       guint property_id,
244                                       GValue *value,
245                                       GParamSpec *pspec)
246 {
247         ModestAccountProtocol *protocol = MODEST_ACCOUNT_PROTOCOL (obj);
248         ModestAccountProtocolPrivate *priv = MODEST_ACCOUNT_PROTOCOL_GET_PRIVATE (protocol);
249
250         switch (property_id) {
251         case PROP_PORT:
252                 g_value_set_uint (value, priv->port);
253                 break;
254         case PROP_ALTERNATE_PORT:
255                 g_value_set_uint (value, priv->alternate_port);
256                 break;
257         case PROP_ACCOUNT_G_TYPE:
258                 g_value_set_gtype (value, priv->account_g_type);
259                 break;
260         default:
261                 G_OBJECT_WARN_INVALID_PROPERTY_ID (obj, property_id, pspec);
262         }
263
264 }
265
266 static void   
267 modest_account_protocol_set_property (GObject *obj,
268                                       guint property_id,
269                                       const GValue *value,
270                                       GParamSpec *pspec)
271 {
272         ModestAccountProtocol *protocol = MODEST_ACCOUNT_PROTOCOL (obj);
273
274         switch (property_id) {
275         case PROP_PORT:
276                 modest_account_protocol_set_port (protocol, g_value_get_uint (value));
277                 break;
278         case PROP_ALTERNATE_PORT:
279                 modest_account_protocol_set_alternate_port (protocol, g_value_get_uint (value));
280                 break;
281         case PROP_ACCOUNT_G_TYPE:
282                 modest_account_protocol_set_account_g_type (protocol, g_value_get_gtype (value));
283                 break;
284         default:
285                 G_OBJECT_WARN_INVALID_PROPERTY_ID (obj, property_id, pspec);
286         }
287
288 }
289
290
291 ModestProtocol*
292 modest_account_protocol_new (const gchar *name, const gchar *display_name,
293                              guint port, guint alternate_port,
294                              GType account_g_type)
295 {
296         return g_object_new (MODEST_TYPE_ACCOUNT_PROTOCOL, 
297                              "display-name", display_name, "name", name, 
298                              "port", port, "alternate-port", alternate_port,
299                              "account-g-type", account_g_type,
300                              NULL);
301 }
302
303 guint
304 modest_account_protocol_get_port (ModestAccountProtocol *self)
305 {
306         ModestAccountProtocolPrivate *priv;
307
308         g_return_val_if_fail (MODEST_IS_ACCOUNT_PROTOCOL (self), 0);
309
310         priv = MODEST_ACCOUNT_PROTOCOL_GET_PRIVATE (self);      
311         return priv->port;
312 }
313
314 void         
315 modest_account_protocol_set_port (ModestAccountProtocol *self,
316                                   guint port)
317 {
318         ModestAccountProtocolPrivate *priv;
319
320         g_return_if_fail (MODEST_IS_ACCOUNT_PROTOCOL (self));
321
322         priv = MODEST_ACCOUNT_PROTOCOL_GET_PRIVATE (self);
323         priv->port = port;
324 }
325
326
327 guint
328 modest_account_protocol_get_alternate_port (ModestAccountProtocol *self)
329 {
330         ModestAccountProtocolPrivate *priv;
331
332         g_return_val_if_fail (MODEST_IS_ACCOUNT_PROTOCOL (self), 0);
333
334         priv = MODEST_ACCOUNT_PROTOCOL_GET_PRIVATE (self);      
335         return priv->alternate_port;
336 }
337
338 void         
339 modest_account_protocol_set_alternate_port (ModestAccountProtocol *self,
340                                             guint alternate_port)
341 {
342         ModestAccountProtocolPrivate *priv;
343
344         g_return_if_fail (MODEST_IS_ACCOUNT_PROTOCOL (self));
345
346         priv = MODEST_ACCOUNT_PROTOCOL_GET_PRIVATE (self);
347         priv->alternate_port = alternate_port;
348 }
349
350 GType
351 modest_account_protocol_get_account_g_type (ModestAccountProtocol *self)
352 {
353         ModestAccountProtocolPrivate *priv;
354
355         g_return_val_if_fail (MODEST_IS_ACCOUNT_PROTOCOL (self), 0);
356
357         priv = MODEST_ACCOUNT_PROTOCOL_GET_PRIVATE (self);      
358         return priv->account_g_type;
359 }
360
361 TnyList *
362 modest_account_protocol_get_account_options (ModestAccountProtocol *self)
363 {
364         TnyList *result;
365         ModestAccountProtocolPrivate *priv;
366
367         g_return_val_if_fail (MODEST_IS_ACCOUNT_PROTOCOL (self), NULL);
368         priv = MODEST_ACCOUNT_PROTOCOL_GET_PRIVATE (self);      
369
370         result = tny_list_copy (priv->account_options);
371
372         return result;
373 }
374
375 void
376 modest_account_protocol_set_account_options (ModestAccountProtocol *self,
377                                              TnyList *list)
378 {
379         ModestAccountProtocolPrivate *priv;
380
381         g_return_if_fail (MODEST_IS_ACCOUNT_PROTOCOL (self));
382         priv = MODEST_ACCOUNT_PROTOCOL_GET_PRIVATE (self);      
383
384         if (priv->account_options) {
385                 g_object_unref (priv->account_options);
386                 priv->account_options = NULL;
387         }
388         priv->account_options = tny_list_copy (list);
389 }
390
391 gboolean
392 modest_account_protocol_has_custom_secure_auth_mech (ModestAccountProtocol *self, 
393                                                      ModestProtocolType auth_protocol_type)
394 {
395         ModestAccountProtocolPrivate *priv;
396
397         g_return_val_if_fail (MODEST_IS_ACCOUNT_PROTOCOL (self), FALSE);
398         priv = MODEST_ACCOUNT_PROTOCOL_GET_PRIVATE (self);      
399
400         return g_hash_table_lookup_extended (priv->custom_auth_mechs, GINT_TO_POINTER (auth_protocol_type), NULL, NULL);
401 }
402
403 const gchar *
404 modest_account_protocol_get_custom_secure_auth_mech (ModestAccountProtocol *self, 
405                                                      ModestProtocolType auth_protocol_type)
406 {
407         ModestAccountProtocolPrivate *priv;
408
409         g_return_val_if_fail (MODEST_IS_ACCOUNT_PROTOCOL (self), NULL);
410         priv = MODEST_ACCOUNT_PROTOCOL_GET_PRIVATE (self);      
411
412         return (const gchar *) g_hash_table_lookup (priv->custom_auth_mechs, GINT_TO_POINTER (auth_protocol_type));
413 }
414
415 void
416 modest_account_protocol_set_custom_secure_auth_mech (ModestAccountProtocol *self, ModestProtocolType auth_protocol_type, const gchar *secure_auth_mech)
417 {
418         ModestAccountProtocolPrivate *priv;
419
420         g_return_if_fail (MODEST_IS_ACCOUNT_PROTOCOL (self));
421         priv = MODEST_ACCOUNT_PROTOCOL_GET_PRIVATE (self);      
422
423         g_hash_table_replace (priv->custom_auth_mechs, GINT_TO_POINTER (auth_protocol_type), g_strdup (secure_auth_mech));
424 }
425
426 void
427 modest_account_protocol_unset_custom_secure_auth_mech (ModestAccountProtocol *self, ModestProtocolType auth_protocol_type)
428 {
429         ModestAccountProtocolPrivate *priv;
430
431         g_return_if_fail (MODEST_IS_ACCOUNT_PROTOCOL (self));
432         priv = MODEST_ACCOUNT_PROTOCOL_GET_PRIVATE (self);      
433
434         g_hash_table_remove (priv->custom_auth_mechs, GINT_TO_POINTER (auth_protocol_type));
435 }
436
437
438 void         
439 modest_account_protocol_set_account_g_type (ModestAccountProtocol *self,
440                                             GType account_g_type)
441 {
442         ModestAccountProtocolPrivate *priv;
443
444         g_return_if_fail (MODEST_IS_ACCOUNT_PROTOCOL (self));
445
446         priv = MODEST_ACCOUNT_PROTOCOL_GET_PRIVATE (self);
447         priv->account_g_type = account_g_type;
448 }
449
450 static TnyAccount *
451 modest_account_protocol_create_account_default (ModestAccountProtocol *self)
452 {
453         ModestAccountProtocolPrivate *priv;
454
455         g_return_val_if_fail (MODEST_IS_ACCOUNT_PROTOCOL (self), NULL);
456
457         priv = MODEST_ACCOUNT_PROTOCOL_GET_PRIVATE (self);
458         if (priv->account_g_type > 0) {
459                 return g_object_new (priv->account_g_type, NULL);
460         } else {
461                 return NULL;
462         }
463 }
464
465 TnyAccount *
466 modest_account_protocol_create_account (ModestAccountProtocol *self)
467 {
468         g_return_val_if_fail (MODEST_IS_ACCOUNT_PROTOCOL (self), NULL);
469
470         return MODEST_ACCOUNT_PROTOCOL_GET_CLASS (self)->create_account (self); 
471 }
472
473 /* This is a template method for getting the account settings
474    dialog. It calls create_account_settings that must be implemented
475    by subclasses and then perform several common operations with the
476    dialog */
477 ModestAccountSettingsDialog *
478 modest_account_protocol_get_account_settings_dialog (ModestAccountProtocol *self,
479                                                      const gchar *account_name)
480 {
481         ModestAccountSettingsDialog *dialog;
482         ModestAccountSettings *settings;
483         ModestAccountProtocolPrivate *priv;
484
485         priv = MODEST_ACCOUNT_PROTOCOL_GET_PRIVATE (self);
486         dialog = g_hash_table_lookup (priv->account_dialogs, account_name);
487
488         if (dialog == NULL) {
489
490                 dialog = MODEST_ACCOUNT_PROTOCOL_GET_CLASS (self)->create_account_settings_dialog (self);
491         
492                 /* Load settings */
493                 settings = modest_account_mgr_load_account_settings (modest_runtime_get_account_mgr (), 
494                                                                      account_name);
495                 modest_account_settings_dialog_load_settings (dialog, settings);
496         
497                 /* Close dialog on response */
498                 g_signal_connect_swapped (dialog,
499                                           "response",
500                                           G_CALLBACK (gtk_widget_destroy),
501                                           dialog);
502
503                 g_hash_table_insert (priv->account_dialogs, g_strdup (account_name), dialog);
504                 g_object_weak_ref (G_OBJECT (dialog), (GWeakNotify) account_dialog_weak_handler, self);
505         }
506
507         return dialog;
508 }
509
510 ModestPairList*
511 modest_account_protocol_get_easysetupwizard_tabs (ModestAccountProtocol *self)
512 {
513         return MODEST_ACCOUNT_PROTOCOL_GET_CLASS (self)->get_easysetupwizard_tabs (self);
514 }
515
516
517 void 
518 modest_account_protocol_save_settings (ModestAccountProtocol *self, 
519                                        ModestAccountSettingsDialog *dialog,
520                                        ModestAccountSettings *settings)
521 {
522         return MODEST_ACCOUNT_PROTOCOL_GET_CLASS (self)->save_settings (self, dialog, settings);
523 }
524
525 void 
526 modest_account_protocol_save_wizard_settings (ModestAccountProtocol *self, 
527                                               GList *wizard_pages,
528                                               ModestAccountSettings *settings)
529 {
530         return MODEST_ACCOUNT_PROTOCOL_GET_CLASS (self)->save_wizard_settings (self, wizard_pages, settings);
531 }
532
533 /* Default implementations */
534 static ModestAccountSettingsDialog *
535 modest_account_protocol_create_account_settings_dialog_default (ModestAccountProtocol *self)
536 {
537         return modest_default_account_settings_dialog_new ();
538 }
539
540 static ModestPairList*
541 modest_account_protocol_get_easysetupwizard_tabs_default (ModestAccountProtocol *self)
542 {
543         g_warning ("You must implement get_easysetupwizard_tabs");
544         return NULL;
545 }
546
547 static void 
548 modest_account_protocol_save_settings_default (ModestAccountProtocol *self, 
549                                                ModestAccountSettingsDialog *dialog,
550                                                ModestAccountSettings *settings)
551 {
552         g_return_if_fail (MODEST_IS_ACCOUNT_PROTOCOL (self));
553         g_return_if_fail (MODEST_IS_ACCOUNT_SETTINGS_DIALOG (dialog));
554         g_return_if_fail (MODEST_IS_ACCOUNT_SETTINGS (settings));
555
556         g_warning ("You must implement save_settings");
557 }
558
559 static void 
560 modest_account_protocol_save_wizard_settings_default (ModestAccountProtocol *self, 
561                                                       GList *wizard_pages,
562                                                       ModestAccountSettings *settings)
563 {
564         g_return_if_fail (MODEST_IS_ACCOUNT_PROTOCOL (self));
565         g_return_if_fail (wizard_pages);
566         g_return_if_fail (MODEST_IS_ACCOUNT_SETTINGS (settings));
567
568         g_warning ("You must implement save_wizard_settings");
569 }
570
571 static ModestWizardDialogResponseOverrideFunc
572 modest_account_protocol_get_wizard_response_override_default (ModestAccountProtocol *self)
573 {
574         g_return_val_if_fail (MODEST_IS_ACCOUNT_PROTOCOL (self), NULL);
575
576         return NULL;
577 }
578
579 ModestWizardDialogResponseOverrideFunc
580 modest_account_protocol_get_wizard_response_override (ModestAccountProtocol *self)
581 {
582         g_return_val_if_fail (MODEST_IS_ACCOUNT_PROTOCOL (self), NULL);
583
584         return MODEST_ACCOUNT_PROTOCOL_GET_CLASS (self)->get_wizard_response_override (self);   
585 }
586
587 static gboolean
588 modest_account_protocol_is_supported_default (ModestAccountProtocol *self)
589 {
590         return TRUE;
591 }
592
593 gboolean
594 modest_account_protocol_is_supported (ModestAccountProtocol *self)
595 {
596         return MODEST_ACCOUNT_PROTOCOL_GET_CLASS (self)->is_supported (self);
597 }
598
599 static void
600 modest_account_protocol_check_support_default (ModestAccountProtocol *self,
601                                                ModestAccountProtocolCheckSupportFunc func,
602                                                gpointer userdata)
603 {
604         if (func)
605                 func (self, TRUE, userdata);
606 }
607
608 void
609 modest_account_protocol_check_support (ModestAccountProtocol *self,
610                                        ModestAccountProtocolCheckSupportFunc func,
611                                        gpointer userdata)
612 {
613         MODEST_ACCOUNT_PROTOCOL_GET_CLASS (self)->check_support (self, func, userdata);
614 }