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