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