c36e8498fa3d14741c943c7dd3cf84c7d09656e1
[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 static gchar *modest_account_protocol_get_from_default (ModestAccountProtocol *self,
93                                                         const gchar *account_id,
94                                                         const gchar *mailbox);
95 static ModestPairList *modest_account_protocol_get_from_list_default (ModestAccountProtocol *self,
96                                                                       const gchar *account_id);
97 static gchar *modest_account_protocol_get_signature_default (ModestAccountProtocol *self,
98                                                              const gchar *account_id,
99                                                              const gchar *mailbox,
100                                                              gboolean *has_signature);
101 static const GdkPixbuf *modest_account_protocol_get_icon_default (ModestAccountProtocol *self,
102                                                                   ModestAccountProtocolIconType icon_type, 
103                                                                   GObject *object, 
104                                                                   guint icon_size);
105
106 static gchar *modest_account_protocol_get_service_name_default (ModestAccountProtocol *self,
107                                                                 const gchar *account_id,
108                                                                 const gchar *mailbox);
109
110 /* globals */
111 static GObjectClass *parent_class = NULL;
112
113 GType
114 modest_account_protocol_get_type (void)
115 {
116         static GType my_type = 0;
117
118         if (!my_type) {
119                 static const GTypeInfo my_info = {
120                         sizeof(ModestAccountProtocolClass),
121                         NULL,   /* base init */
122                         NULL,   /* base finalize */
123                         (GClassInitFunc) modest_account_protocol_class_init,
124                         NULL,   /* class finalize */
125                         NULL,   /* class data */
126                         sizeof(ModestAccountProtocol),
127                         0,      /* n_preallocs */
128                         (GInstanceInitFunc) modest_account_protocol_instance_init,
129                         NULL
130                 };
131
132                 my_type = g_type_register_static (MODEST_TYPE_PROTOCOL,
133                                                   "ModestAccountProtocol",
134                                                   &my_info, 0);
135         }
136         return my_type;
137 }
138
139 static void
140 modest_account_protocol_class_init (ModestAccountProtocolClass *klass)
141 {
142         GObjectClass *object_class;
143         ModestAccountProtocolClass *account_class;
144
145         object_class = (GObjectClass *) klass;
146         account_class = MODEST_ACCOUNT_PROTOCOL_CLASS (klass);
147         parent_class = g_type_class_peek_parent (klass);
148         object_class->finalize = modest_account_protocol_finalize;
149         object_class->set_property = modest_account_protocol_set_property;
150         object_class->get_property = modest_account_protocol_get_property;
151
152         g_object_class_install_property (object_class,
153                                          PROP_PORT,
154                                          g_param_spec_uint ("port",
155                                                            _("Standard port"),
156                                                            _("The standard port for the protocol"),
157                                                            0, G_MAXINT, 0,
158                                                            G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT));
159
160         g_object_class_install_property (object_class,
161                                          PROP_ALTERNATE_PORT,
162                                          g_param_spec_uint ("alternate-port",
163                                                            _("Alternate port"),
164                                                            _("The alternate port for the protocol (usually used in SSL)"),
165                                                            0, G_MAXINT, 0,
166                                                            G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT));
167
168         g_object_class_install_property (object_class,
169                                          PROP_ACCOUNT_G_TYPE,
170                                          g_param_spec_gtype ("account-g-type",
171                                                              _("Account factory GType"),
172                                                              _("Account factory GType used for creating new instances."),
173                                                              TNY_TYPE_ACCOUNT,
174                                                              G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT));
175
176         g_type_class_add_private (object_class,
177                                   sizeof(ModestAccountProtocolPrivate));
178
179         /* Virtual methods */
180         account_class->create_account_settings_dialog = 
181                 modest_account_protocol_create_account_settings_dialog_default;
182         account_class->get_easysetupwizard_tabs = 
183                 modest_account_protocol_get_easysetupwizard_tabs_default;
184         account_class->save_settings = 
185                 modest_account_protocol_save_settings_default;
186         account_class->save_wizard_settings = 
187                 modest_account_protocol_save_wizard_settings_default;
188         account_class->create_account =
189                 modest_account_protocol_create_account_default;
190         account_class->get_wizard_response_override =
191                 modest_account_protocol_get_wizard_response_override_default;
192         account_class->is_supported =
193                 modest_account_protocol_is_supported_default;
194         account_class->check_support =
195                 modest_account_protocol_check_support_default;
196         account_class->get_from =
197                 modest_account_protocol_get_from_default;
198         account_class->get_from_list =
199                 modest_account_protocol_get_from_list_default;
200         account_class->get_signature =
201                 modest_account_protocol_get_signature_default;
202         account_class->get_icon =
203                 modest_account_protocol_get_icon_default;
204         account_class->get_service_name =
205                 modest_account_protocol_get_service_name_default;
206 }
207
208 static void
209 modest_account_protocol_instance_init (ModestAccountProtocol *obj)
210 {
211         ModestAccountProtocolPrivate *priv;
212
213         priv = MODEST_ACCOUNT_PROTOCOL_GET_PRIVATE (obj);
214
215         priv->port = 0;
216         priv->alternate_port = 0;
217         priv->account_g_type = 0;
218         priv->account_options = tny_simple_list_new ();
219         priv->custom_auth_mechs = g_hash_table_new_full (g_direct_hash, g_direct_equal, NULL, g_free);
220
221         priv->account_dialogs = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL);
222 }
223
224 static gboolean
225 remove_account (const gchar *account_name, GObject *account, GObject *account_to_remove)
226 {
227         return (account == account_to_remove);
228 }
229
230 static void
231 account_dialog_weak_handler (ModestAccountProtocol *self, GObject *where_the_object_was)
232 {
233         ModestAccountProtocolPrivate *priv = MODEST_ACCOUNT_PROTOCOL_GET_PRIVATE (self);
234
235         g_hash_table_foreach_remove (priv->account_dialogs, (GHRFunc) remove_account, where_the_object_was);
236 }
237
238 static gboolean
239 dialogs_remove (const gchar *account_name, GObject *account_dialog, ModestAccountProtocol *self)
240 {
241         g_object_weak_unref (account_dialog, (GWeakNotify) account_dialog_weak_handler, self);
242
243         return TRUE;
244 }
245
246 static void   
247 modest_account_protocol_finalize   (GObject *obj)
248 {
249         ModestAccountProtocol *protocol = MODEST_ACCOUNT_PROTOCOL (obj);
250         ModestAccountProtocolPrivate *priv = MODEST_ACCOUNT_PROTOCOL_GET_PRIVATE (protocol);
251
252         if (priv->account_dialogs) {
253                 g_hash_table_foreach_remove (priv->account_dialogs, (GHRFunc) dialogs_remove, obj);
254                 g_hash_table_destroy (priv->account_dialogs);
255         }
256
257         if (priv->account_options)
258                 g_object_unref (priv->account_options);
259         priv->account_options = NULL;
260
261         if (priv->custom_auth_mechs)
262                 g_hash_table_destroy (priv->custom_auth_mechs);
263         priv->custom_auth_mechs = NULL;
264
265         G_OBJECT_CLASS (parent_class)->finalize (obj);
266 }
267
268 static void   
269 modest_account_protocol_get_property (GObject *obj,
270                                       guint property_id,
271                                       GValue *value,
272                                       GParamSpec *pspec)
273 {
274         ModestAccountProtocol *protocol = MODEST_ACCOUNT_PROTOCOL (obj);
275         ModestAccountProtocolPrivate *priv = MODEST_ACCOUNT_PROTOCOL_GET_PRIVATE (protocol);
276
277         switch (property_id) {
278         case PROP_PORT:
279                 g_value_set_uint (value, priv->port);
280                 break;
281         case PROP_ALTERNATE_PORT:
282                 g_value_set_uint (value, priv->alternate_port);
283                 break;
284         case PROP_ACCOUNT_G_TYPE:
285                 g_value_set_gtype (value, priv->account_g_type);
286                 break;
287         default:
288                 G_OBJECT_WARN_INVALID_PROPERTY_ID (obj, property_id, pspec);
289         }
290
291 }
292
293 static void   
294 modest_account_protocol_set_property (GObject *obj,
295                                       guint property_id,
296                                       const GValue *value,
297                                       GParamSpec *pspec)
298 {
299         ModestAccountProtocol *protocol = MODEST_ACCOUNT_PROTOCOL (obj);
300
301         switch (property_id) {
302         case PROP_PORT:
303                 modest_account_protocol_set_port (protocol, g_value_get_uint (value));
304                 break;
305         case PROP_ALTERNATE_PORT:
306                 modest_account_protocol_set_alternate_port (protocol, g_value_get_uint (value));
307                 break;
308         case PROP_ACCOUNT_G_TYPE:
309                 modest_account_protocol_set_account_g_type (protocol, g_value_get_gtype (value));
310                 break;
311         default:
312                 G_OBJECT_WARN_INVALID_PROPERTY_ID (obj, property_id, pspec);
313         }
314
315 }
316
317
318 ModestProtocol*
319 modest_account_protocol_new (const gchar *name, const gchar *display_name,
320                              guint port, guint alternate_port,
321                              GType account_g_type)
322 {
323         return g_object_new (MODEST_TYPE_ACCOUNT_PROTOCOL, 
324                              "display-name", display_name, "name", name, 
325                              "port", port, "alternate-port", alternate_port,
326                              "account-g-type", account_g_type,
327                              NULL);
328 }
329
330 guint
331 modest_account_protocol_get_port (ModestAccountProtocol *self)
332 {
333         ModestAccountProtocolPrivate *priv;
334
335         g_return_val_if_fail (MODEST_IS_ACCOUNT_PROTOCOL (self), 0);
336
337         priv = MODEST_ACCOUNT_PROTOCOL_GET_PRIVATE (self);      
338         return priv->port;
339 }
340
341 void         
342 modest_account_protocol_set_port (ModestAccountProtocol *self,
343                                   guint port)
344 {
345         ModestAccountProtocolPrivate *priv;
346
347         g_return_if_fail (MODEST_IS_ACCOUNT_PROTOCOL (self));
348
349         priv = MODEST_ACCOUNT_PROTOCOL_GET_PRIVATE (self);
350         priv->port = port;
351 }
352
353
354 guint
355 modest_account_protocol_get_alternate_port (ModestAccountProtocol *self)
356 {
357         ModestAccountProtocolPrivate *priv;
358
359         g_return_val_if_fail (MODEST_IS_ACCOUNT_PROTOCOL (self), 0);
360
361         priv = MODEST_ACCOUNT_PROTOCOL_GET_PRIVATE (self);      
362         return priv->alternate_port;
363 }
364
365 void         
366 modest_account_protocol_set_alternate_port (ModestAccountProtocol *self,
367                                             guint alternate_port)
368 {
369         ModestAccountProtocolPrivate *priv;
370
371         g_return_if_fail (MODEST_IS_ACCOUNT_PROTOCOL (self));
372
373         priv = MODEST_ACCOUNT_PROTOCOL_GET_PRIVATE (self);
374         priv->alternate_port = alternate_port;
375 }
376
377 GType
378 modest_account_protocol_get_account_g_type (ModestAccountProtocol *self)
379 {
380         ModestAccountProtocolPrivate *priv;
381
382         g_return_val_if_fail (MODEST_IS_ACCOUNT_PROTOCOL (self), 0);
383
384         priv = MODEST_ACCOUNT_PROTOCOL_GET_PRIVATE (self);      
385         return priv->account_g_type;
386 }
387
388 TnyList *
389 modest_account_protocol_get_account_options (ModestAccountProtocol *self)
390 {
391         TnyList *result;
392         ModestAccountProtocolPrivate *priv;
393
394         g_return_val_if_fail (MODEST_IS_ACCOUNT_PROTOCOL (self), NULL);
395         priv = MODEST_ACCOUNT_PROTOCOL_GET_PRIVATE (self);      
396
397         result = tny_list_copy (priv->account_options);
398
399         return result;
400 }
401
402 void
403 modest_account_protocol_set_account_options (ModestAccountProtocol *self,
404                                              TnyList *list)
405 {
406         ModestAccountProtocolPrivate *priv;
407
408         g_return_if_fail (MODEST_IS_ACCOUNT_PROTOCOL (self));
409         priv = MODEST_ACCOUNT_PROTOCOL_GET_PRIVATE (self);      
410
411         if (priv->account_options) {
412                 g_object_unref (priv->account_options);
413                 priv->account_options = NULL;
414         }
415         priv->account_options = tny_list_copy (list);
416 }
417
418 gboolean
419 modest_account_protocol_has_custom_secure_auth_mech (ModestAccountProtocol *self, 
420                                                      ModestProtocolType auth_protocol_type)
421 {
422         ModestAccountProtocolPrivate *priv;
423
424         g_return_val_if_fail (MODEST_IS_ACCOUNT_PROTOCOL (self), FALSE);
425         priv = MODEST_ACCOUNT_PROTOCOL_GET_PRIVATE (self);      
426
427         return g_hash_table_lookup_extended (priv->custom_auth_mechs, GINT_TO_POINTER (auth_protocol_type), NULL, NULL);
428 }
429
430 const gchar *
431 modest_account_protocol_get_custom_secure_auth_mech (ModestAccountProtocol *self, 
432                                                      ModestProtocolType auth_protocol_type)
433 {
434         ModestAccountProtocolPrivate *priv;
435
436         g_return_val_if_fail (MODEST_IS_ACCOUNT_PROTOCOL (self), NULL);
437         priv = MODEST_ACCOUNT_PROTOCOL_GET_PRIVATE (self);      
438
439         return (const gchar *) g_hash_table_lookup (priv->custom_auth_mechs, GINT_TO_POINTER (auth_protocol_type));
440 }
441
442 void
443 modest_account_protocol_set_custom_secure_auth_mech (ModestAccountProtocol *self, ModestProtocolType auth_protocol_type, const gchar *secure_auth_mech)
444 {
445         ModestAccountProtocolPrivate *priv;
446
447         g_return_if_fail (MODEST_IS_ACCOUNT_PROTOCOL (self));
448         priv = MODEST_ACCOUNT_PROTOCOL_GET_PRIVATE (self);      
449
450         g_hash_table_replace (priv->custom_auth_mechs, GINT_TO_POINTER (auth_protocol_type), g_strdup (secure_auth_mech));
451 }
452
453 void
454 modest_account_protocol_unset_custom_secure_auth_mech (ModestAccountProtocol *self, ModestProtocolType auth_protocol_type)
455 {
456         ModestAccountProtocolPrivate *priv;
457
458         g_return_if_fail (MODEST_IS_ACCOUNT_PROTOCOL (self));
459         priv = MODEST_ACCOUNT_PROTOCOL_GET_PRIVATE (self);      
460
461         g_hash_table_remove (priv->custom_auth_mechs, GINT_TO_POINTER (auth_protocol_type));
462 }
463
464
465 void         
466 modest_account_protocol_set_account_g_type (ModestAccountProtocol *self,
467                                             GType account_g_type)
468 {
469         ModestAccountProtocolPrivate *priv;
470
471         g_return_if_fail (MODEST_IS_ACCOUNT_PROTOCOL (self));
472
473         priv = MODEST_ACCOUNT_PROTOCOL_GET_PRIVATE (self);
474         priv->account_g_type = account_g_type;
475 }
476
477 static TnyAccount *
478 modest_account_protocol_create_account_default (ModestAccountProtocol *self)
479 {
480         ModestAccountProtocolPrivate *priv;
481
482         g_return_val_if_fail (MODEST_IS_ACCOUNT_PROTOCOL (self), NULL);
483
484         priv = MODEST_ACCOUNT_PROTOCOL_GET_PRIVATE (self);
485         if (priv->account_g_type > 0) {
486                 return g_object_new (priv->account_g_type, NULL);
487         } else {
488                 return NULL;
489         }
490 }
491
492 TnyAccount *
493 modest_account_protocol_create_account (ModestAccountProtocol *self)
494 {
495         g_return_val_if_fail (MODEST_IS_ACCOUNT_PROTOCOL (self), NULL);
496
497         return MODEST_ACCOUNT_PROTOCOL_GET_CLASS (self)->create_account (self); 
498 }
499
500 /* This is a template method for getting the account settings
501    dialog. It calls create_account_settings that must be implemented
502    by subclasses and then perform several common operations with the
503    dialog */
504 ModestAccountSettingsDialog *
505 modest_account_protocol_get_account_settings_dialog (ModestAccountProtocol *self,
506                                                      const gchar *account_name)
507 {
508         ModestAccountSettingsDialog *dialog;
509         ModestAccountSettings *settings;
510         ModestAccountProtocolPrivate *priv;
511
512         priv = MODEST_ACCOUNT_PROTOCOL_GET_PRIVATE (self);
513         dialog = g_hash_table_lookup (priv->account_dialogs, account_name);
514
515         if (dialog == NULL) {
516
517                 dialog = MODEST_ACCOUNT_PROTOCOL_GET_CLASS (self)->create_account_settings_dialog (self);
518         
519                 /* Load settings */
520                 settings = modest_account_mgr_load_account_settings (modest_runtime_get_account_mgr (), 
521                                                                      account_name);
522                 modest_account_settings_dialog_load_settings (dialog, settings);
523         
524                 /* Close dialog on response */
525                 g_signal_connect_swapped (dialog,
526                                           "response",
527                                           G_CALLBACK (gtk_widget_destroy),
528                                           dialog);
529
530                 g_hash_table_insert (priv->account_dialogs, g_strdup (account_name), dialog);
531                 g_object_weak_ref (G_OBJECT (dialog), (GWeakNotify) account_dialog_weak_handler, self);
532         }
533
534         return dialog;
535 }
536
537 ModestPairList*
538 modest_account_protocol_get_easysetupwizard_tabs (ModestAccountProtocol *self)
539 {
540         return MODEST_ACCOUNT_PROTOCOL_GET_CLASS (self)->get_easysetupwizard_tabs (self);
541 }
542
543
544 void 
545 modest_account_protocol_save_settings (ModestAccountProtocol *self, 
546                                        ModestAccountSettingsDialog *dialog,
547                                        ModestAccountSettings *settings)
548 {
549         return MODEST_ACCOUNT_PROTOCOL_GET_CLASS (self)->save_settings (self, dialog, settings);
550 }
551
552 void 
553 modest_account_protocol_save_wizard_settings (ModestAccountProtocol *self, 
554                                               GList *wizard_pages,
555                                               ModestAccountSettings *settings)
556 {
557         return MODEST_ACCOUNT_PROTOCOL_GET_CLASS (self)->save_wizard_settings (self, wizard_pages, settings);
558 }
559
560 /* Default implementations */
561 static ModestAccountSettingsDialog *
562 modest_account_protocol_create_account_settings_dialog_default (ModestAccountProtocol *self)
563 {
564         return modest_default_account_settings_dialog_new ();
565 }
566
567 static ModestPairList*
568 modest_account_protocol_get_easysetupwizard_tabs_default (ModestAccountProtocol *self)
569 {
570         g_warning ("You must implement get_easysetupwizard_tabs");
571         return NULL;
572 }
573
574 static void 
575 modest_account_protocol_save_settings_default (ModestAccountProtocol *self, 
576                                                ModestAccountSettingsDialog *dialog,
577                                                ModestAccountSettings *settings)
578 {
579         g_return_if_fail (MODEST_IS_ACCOUNT_PROTOCOL (self));
580         g_return_if_fail (MODEST_IS_ACCOUNT_SETTINGS_DIALOG (dialog));
581         g_return_if_fail (MODEST_IS_ACCOUNT_SETTINGS (settings));
582
583         g_warning ("You must implement save_settings");
584 }
585
586 static void 
587 modest_account_protocol_save_wizard_settings_default (ModestAccountProtocol *self, 
588                                                       GList *wizard_pages,
589                                                       ModestAccountSettings *settings)
590 {
591         g_return_if_fail (MODEST_IS_ACCOUNT_PROTOCOL (self));
592         g_return_if_fail (wizard_pages);
593         g_return_if_fail (MODEST_IS_ACCOUNT_SETTINGS (settings));
594
595         g_warning ("You must implement save_wizard_settings");
596 }
597
598 static ModestWizardDialogResponseOverrideFunc
599 modest_account_protocol_get_wizard_response_override_default (ModestAccountProtocol *self)
600 {
601         g_return_val_if_fail (MODEST_IS_ACCOUNT_PROTOCOL (self), NULL);
602
603         return NULL;
604 }
605
606 ModestWizardDialogResponseOverrideFunc
607 modest_account_protocol_get_wizard_response_override (ModestAccountProtocol *self)
608 {
609         g_return_val_if_fail (MODEST_IS_ACCOUNT_PROTOCOL (self), NULL);
610
611         return MODEST_ACCOUNT_PROTOCOL_GET_CLASS (self)->get_wizard_response_override (self);   
612 }
613
614 static gboolean
615 modest_account_protocol_is_supported_default (ModestAccountProtocol *self)
616 {
617         return TRUE;
618 }
619
620 gboolean
621 modest_account_protocol_is_supported (ModestAccountProtocol *self)
622 {
623         return MODEST_ACCOUNT_PROTOCOL_GET_CLASS (self)->is_supported (self);
624 }
625
626 static void
627 modest_account_protocol_check_support_default (ModestAccountProtocol *self,
628                                                ModestAccountProtocolCheckSupportFunc func,
629                                                gpointer userdata)
630 {
631         if (func)
632                 func (self, TRUE, userdata);
633 }
634
635 void
636 modest_account_protocol_check_support (ModestAccountProtocol *self,
637                                        ModestAccountProtocolCheckSupportFunc func,
638                                        gpointer userdata)
639 {
640         MODEST_ACCOUNT_PROTOCOL_GET_CLASS (self)->check_support (self, func, userdata);
641 }
642
643 gchar *
644 modest_account_protocol_get_from (ModestAccountProtocol *self,
645                                   const gchar *account_id,
646                                   const gchar *mailbox)
647 {
648         return MODEST_ACCOUNT_PROTOCOL_GET_CLASS (self)->get_from (self, account_id, mailbox);
649 }
650 static gchar *
651 modest_account_protocol_get_from_default (ModestAccountProtocol *self,
652                                           const gchar *account_id,
653                                           const gchar *mailbox)
654 {
655         g_return_val_if_fail (MODEST_ACCOUNT_PROTOCOL (self), NULL);
656
657         return NULL;
658 }
659
660 ModestPairList *
661 modest_account_protocol_get_from_list (ModestAccountProtocol *self,
662                                        const gchar *account_id)
663 {
664         return MODEST_ACCOUNT_PROTOCOL_GET_CLASS (self)->get_from_list (self, account_id);
665 }
666 static ModestPairList *
667 modest_account_protocol_get_from_list_default (ModestAccountProtocol *self,
668                                                const gchar *account_id)
669 {
670         g_return_val_if_fail (MODEST_ACCOUNT_PROTOCOL (self), NULL);
671
672         return NULL;
673 }
674
675 gchar *
676 modest_account_protocol_get_signature (ModestAccountProtocol *self,
677                                        const gchar *account_id,
678                                        const gchar *mailbox,
679                                        gboolean *has_signature)
680 {
681         return MODEST_ACCOUNT_PROTOCOL_GET_CLASS (self)->get_signature (self, account_id, mailbox, has_signature);
682 }
683
684 static gchar *
685 modest_account_protocol_get_signature_default (ModestAccountProtocol *self,
686                                                const gchar *account_id,
687                                                const gchar *mailbox,
688                                                gboolean *has_signature)
689 {
690         g_return_val_if_fail (MODEST_ACCOUNT_PROTOCOL (self), NULL);
691         if (has_signature)
692                 *has_signature = FALSE;
693
694         return NULL;
695 }
696
697 const GdkPixbuf*
698 modest_account_protocol_get_icon (ModestAccountProtocol *self,
699                                   ModestAccountProtocolIconType icon_type,
700                                   GObject *object,
701                                   guint icon_size)
702 {
703         return MODEST_ACCOUNT_PROTOCOL_GET_CLASS (self)->get_icon (self, icon_type, object, icon_size);
704 }
705
706 static const GdkPixbuf * 
707 modest_account_protocol_get_icon_default (ModestAccountProtocol *self, ModestAccountProtocolIconType icon_type, 
708                                           GObject *object, guint icon_size)
709 {
710         g_return_val_if_fail (MODEST_ACCOUNT_PROTOCOL (self), NULL);
711
712         return NULL;
713 }
714
715 gchar *
716 modest_account_protocol_get_service_name (ModestAccountProtocol *self,
717                                           const gchar *account_id,
718                                           const gchar *mailbox)
719 {
720         return MODEST_ACCOUNT_PROTOCOL_GET_CLASS (self)->get_service_name (self, account_id, mailbox);
721 }
722
723 static gchar *
724 modest_account_protocol_get_service_name_default (ModestAccountProtocol *self,
725                                                   const gchar *account_id,
726                                                   const gchar *mailbox)
727 {
728         g_return_val_if_fail (MODEST_ACCOUNT_PROTOCOL (self), NULL);
729
730         return NULL;
731 }
732