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