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