Do ignore empty recipients when checking names
[modest] / src / modest-account-protocol.c
index 9256c02..a995db2 100644 (file)
@@ -32,6 +32,7 @@
 #include "modest-account-mgr-helpers.h"
 #include "widgets/modest-default-account-settings-dialog.h"
 #include "modest-runtime.h"
+#include "modest-marshal.h"
 
 enum {
        PROP_0,
@@ -82,6 +83,57 @@ static void modest_account_protocol_save_wizard_settings_default (ModestAccountP
                                                                  GList *wizard_pages,
                                                                  ModestAccountSettings *settings);
 
+static ModestWizardDialogResponseOverrideFunc 
+modest_account_protocol_get_wizard_response_override_default (ModestAccountProtocol *self);
+
+static void modest_account_protocol_check_support_default (ModestAccountProtocol *self,
+                                                          ModestAccountProtocolCheckSupportFunc func,
+                                                          gpointer userdata);
+static void modest_account_protocol_cancel_check_support_default (ModestAccountProtocol *self);
+static void modest_account_protocol_wizard_finished_default (ModestAccountProtocol *self);
+static gboolean modest_account_protocol_decode_part_to_stream_default (ModestAccountProtocol *protocol,
+                                                                      TnyMimePart *part,
+                                                                      const gchar *stream_uri,
+                                                                      TnyStream *stream,
+                                                                      gssize *written,
+                                                                      GError **error);
+static gboolean modest_account_protocol_decode_part_to_stream_async_default (ModestAccountProtocol *protocol,
+                                                                            TnyMimePart *self, 
+                                                                            const gchar *stream_uri,
+                                                                            TnyStream *stream, 
+                                                                            TnyMimePartCallback callback, 
+                                                                            TnyStatusCallback status_callback, 
+                                                                            gpointer user_data);
+static gboolean modest_account_protocol_is_supported_default (ModestAccountProtocol *self);
+static gchar *modest_account_protocol_get_from_default (ModestAccountProtocol *self,
+                                                       const gchar *account_id,
+                                                       const gchar *mailbox);
+static ModestPairList *modest_account_protocol_get_from_list_default (ModestAccountProtocol *self,
+                                                                     const gchar *account_id);
+static gchar *modest_account_protocol_get_signature_default (ModestAccountProtocol *self,
+                                                            const gchar *account_id,
+                                                            const gchar *mailbox,
+                                                            gboolean *has_signature);
+static const GdkPixbuf *modest_account_protocol_get_icon_default (ModestAccountProtocol *self,
+                                                                 ModestAccountProtocolIconType icon_type, 
+                                                                 GObject *object, 
+                                                                 guint icon_size);
+
+static gchar *modest_account_protocol_get_service_name_default (ModestAccountProtocol *self,
+                                                               const gchar *account_id,
+                                                               const gchar *mailbox);
+
+static const GdkPixbuf *modest_account_protocol_get_service_icon_default (ModestAccountProtocol *self,
+                                                                         const gchar *account_id,
+                                                                         const gchar *mailbox,
+                                                                         guint icon_size);
+static void modest_account_protocol_save_remote_draft_default (ModestAccountProtocol *self,
+                                                              const gchar *account_id,
+                                                              TnyMsg *new_msg,
+                                                              TnyMsg *old_msg,
+                                                              ModestAccountProtocolSaveRemoteDraftCallback callback,
+                                                              gpointer userdata);
+
 /* globals */
 static GObjectClass *parent_class = NULL;
 
@@ -162,6 +214,35 @@ modest_account_protocol_class_init (ModestAccountProtocolClass *klass)
                modest_account_protocol_save_wizard_settings_default;
        account_class->create_account =
                modest_account_protocol_create_account_default;
+       account_class->get_wizard_response_override =
+               modest_account_protocol_get_wizard_response_override_default;
+       account_class->is_supported =
+               modest_account_protocol_is_supported_default;
+       account_class->check_support =
+               modest_account_protocol_check_support_default;
+       account_class->cancel_check_support =
+               modest_account_protocol_cancel_check_support_default;
+       account_class->wizard_finished =
+               modest_account_protocol_wizard_finished_default;
+       account_class->decode_part_to_stream =
+               modest_account_protocol_decode_part_to_stream_default;
+       account_class->decode_part_to_stream_async =
+               modest_account_protocol_decode_part_to_stream_async_default;
+       account_class->get_from =
+               modest_account_protocol_get_from_default;
+       account_class->get_from_list =
+               modest_account_protocol_get_from_list_default;
+       account_class->get_signature =
+               modest_account_protocol_get_signature_default;
+       account_class->get_icon =
+               modest_account_protocol_get_icon_default;
+       account_class->get_service_name =
+               modest_account_protocol_get_service_name_default;
+       account_class->get_service_icon =
+               modest_account_protocol_get_service_icon_default;
+       account_class->save_remote_draft =
+               modest_account_protocol_save_remote_draft_default;
+
 }
 
 static void
@@ -474,12 +555,16 @@ modest_account_protocol_get_account_settings_dialog (ModestAccountProtocol *self
        if (dialog == NULL) {
 
                dialog = MODEST_ACCOUNT_PROTOCOL_GET_CLASS (self)->create_account_settings_dialog (self);
-       
+
+               /* Check existence of dialog */
+               if (dialog == NULL)
+                       return NULL;
+
                /* Load settings */
-               settings = modest_account_mgr_load_account_settings (modest_runtime_get_account_mgr (), 
+               settings = modest_account_mgr_load_account_settings (modest_runtime_get_account_mgr (),
                                                                     account_name);
                modest_account_settings_dialog_load_settings (dialog, settings);
-       
+
                /* Close dialog on response */
                g_signal_connect_swapped (dialog,
                                          "response",
@@ -553,3 +638,268 @@ modest_account_protocol_save_wizard_settings_default (ModestAccountProtocol *sel
 
        g_warning ("You must implement save_wizard_settings");
 }
+
+static ModestWizardDialogResponseOverrideFunc
+modest_account_protocol_get_wizard_response_override_default (ModestAccountProtocol *self)
+{
+       g_return_val_if_fail (MODEST_IS_ACCOUNT_PROTOCOL (self), NULL);
+
+       return NULL;
+}
+
+ModestWizardDialogResponseOverrideFunc
+modest_account_protocol_get_wizard_response_override (ModestAccountProtocol *self)
+{
+       g_return_val_if_fail (MODEST_IS_ACCOUNT_PROTOCOL (self), NULL);
+
+       return MODEST_ACCOUNT_PROTOCOL_GET_CLASS (self)->get_wizard_response_override (self);   
+}
+
+static gboolean
+modest_account_protocol_is_supported_default (ModestAccountProtocol *self)
+{
+       return TRUE;
+}
+
+gboolean
+modest_account_protocol_is_supported (ModestAccountProtocol *self)
+{
+       return MODEST_ACCOUNT_PROTOCOL_GET_CLASS (self)->is_supported (self);
+}
+
+static void
+modest_account_protocol_check_support_default (ModestAccountProtocol *self,
+                                              ModestAccountProtocolCheckSupportFunc func,
+                                              gpointer userdata)
+{
+       if (func)
+               func (self, TRUE, userdata);
+}
+
+void
+modest_account_protocol_check_support (ModestAccountProtocol *self,
+                                      ModestAccountProtocolCheckSupportFunc func,
+                                      gpointer userdata)
+{
+       MODEST_ACCOUNT_PROTOCOL_GET_CLASS (self)->check_support (self, func, userdata);
+}
+
+static void
+modest_account_protocol_cancel_check_support_default (ModestAccountProtocol *self)
+{
+       return;
+}
+
+void
+modest_account_protocol_cancel_check_support (ModestAccountProtocol *self)
+{
+       MODEST_ACCOUNT_PROTOCOL_GET_CLASS (self)->cancel_check_support (self);
+}
+
+static void
+modest_account_protocol_wizard_finished_default (ModestAccountProtocol *self)
+{
+       return;
+}
+
+void
+modest_account_protocol_wizard_finished (ModestAccountProtocol *self)
+{
+       MODEST_ACCOUNT_PROTOCOL_GET_CLASS (self)->wizard_finished (self);
+}
+
+static gboolean
+modest_account_protocol_decode_part_to_stream_default (ModestAccountProtocol *self,
+                                                      TnyMimePart *part,
+                                                      const gchar *stream_uri,
+                                                      TnyStream *stream,
+                                                      gssize *written,
+                                                      GError **error)
+{
+       /* By default account protocols do not handle themselves the transfer */
+       return FALSE;
+}
+
+gboolean
+modest_account_protocol_decode_part_to_stream (ModestAccountProtocol *self,
+                                              TnyMimePart *part,
+                                              const gchar *stream_uri,
+                                              TnyStream *stream,
+                                              gssize *written,
+                                              GError **error)
+{
+       return MODEST_ACCOUNT_PROTOCOL_GET_CLASS (self)->decode_part_to_stream (self,
+                                                                               part,
+                                                                               stream_uri,
+                                                                               stream,
+                                                                               written,
+                                                                               error);
+}
+
+static gboolean
+modest_account_protocol_decode_part_to_stream_async_default (ModestAccountProtocol *self,
+                                                            TnyMimePart *part,
+                                                            const gchar *stream_uri,
+                                                            TnyStream *stream, 
+                                                            TnyMimePartCallback callback, 
+                                                            TnyStatusCallback status_callback, 
+                                                            gpointer user_data)
+{
+       /* By default account protocols do not handle themselves the transfer */
+       return FALSE;
+}
+
+gboolean
+modest_account_protocol_decode_part_to_stream_async (ModestAccountProtocol *self,
+                                                    TnyMimePart *part, 
+                                                    const gchar *stream_uri,
+                                                    TnyStream *stream, 
+                                                    TnyMimePartCallback callback, 
+                                                    TnyStatusCallback status_callback, 
+                                                    gpointer user_data)
+{
+       return MODEST_ACCOUNT_PROTOCOL_GET_CLASS (self)->decode_part_to_stream_async (self,
+                                                                                     part,
+                                                                                     stream_uri,
+                                                                                     stream,
+                                                                                     callback,
+                                                                                     status_callback,
+                                                                                     user_data);
+}
+
+gchar *
+modest_account_protocol_get_from (ModestAccountProtocol *self,
+                                 const gchar *account_id,
+                                 const gchar *mailbox)
+{
+       return MODEST_ACCOUNT_PROTOCOL_GET_CLASS (self)->get_from (self, account_id, mailbox);
+}
+static gchar *
+modest_account_protocol_get_from_default (ModestAccountProtocol *self,
+                                         const gchar *account_id,
+                                         const gchar *mailbox)
+{
+       g_return_val_if_fail (MODEST_IS_ACCOUNT_PROTOCOL (self), NULL);
+
+       return NULL;
+}
+
+ModestPairList *
+modest_account_protocol_get_from_list (ModestAccountProtocol *self,
+                                      const gchar *account_id)
+{
+       return MODEST_ACCOUNT_PROTOCOL_GET_CLASS (self)->get_from_list (self, account_id);
+}
+static ModestPairList *
+modest_account_protocol_get_from_list_default (ModestAccountProtocol *self,
+                                              const gchar *account_id)
+{
+       g_return_val_if_fail (MODEST_IS_ACCOUNT_PROTOCOL (self), NULL);
+
+       return NULL;
+}
+
+gchar *
+modest_account_protocol_get_signature (ModestAccountProtocol *self,
+                                      const gchar *account_id,
+                                      const gchar *mailbox,
+                                      gboolean *has_signature)
+{
+       return MODEST_ACCOUNT_PROTOCOL_GET_CLASS (self)->get_signature (self, account_id, mailbox, has_signature);
+}
+
+static gchar *
+modest_account_protocol_get_signature_default (ModestAccountProtocol *self,
+                                              const gchar *account_id,
+                                              const gchar *mailbox,
+                                              gboolean *has_signature)
+{
+       g_return_val_if_fail (MODEST_IS_ACCOUNT_PROTOCOL (self), NULL);
+       if (has_signature)
+               *has_signature = FALSE;
+
+       return NULL;
+}
+
+const GdkPixbuf*
+modest_account_protocol_get_icon (ModestAccountProtocol *self,
+                                 ModestAccountProtocolIconType icon_type,
+                                 GObject *object,
+                                 guint icon_size)
+{
+       return MODEST_ACCOUNT_PROTOCOL_GET_CLASS (self)->get_icon (self, icon_type, object, icon_size);
+}
+
+static const GdkPixbuf * 
+modest_account_protocol_get_icon_default (ModestAccountProtocol *self, ModestAccountProtocolIconType icon_type, 
+                                         GObject *object, guint icon_size)
+{
+       g_return_val_if_fail (MODEST_IS_ACCOUNT_PROTOCOL (self), NULL);
+
+       return NULL;
+}
+
+gchar *
+modest_account_protocol_get_service_name (ModestAccountProtocol *self,
+                                         const gchar *account_id,
+                                         const gchar *mailbox)
+{
+       return MODEST_ACCOUNT_PROTOCOL_GET_CLASS (self)->get_service_name (self, account_id, mailbox);
+}
+
+static gchar *
+modest_account_protocol_get_service_name_default (ModestAccountProtocol *self,
+                                                 const gchar *account_id,
+                                                 const gchar *mailbox)
+{
+       g_return_val_if_fail (MODEST_IS_ACCOUNT_PROTOCOL (self), NULL);
+
+       return NULL;
+}
+
+const GdkPixbuf *
+modest_account_protocol_get_service_icon (ModestAccountProtocol *self,
+                                         const gchar *account_id,
+                                         const gchar *mailbox,
+                                         guint icon_size)
+{
+       return MODEST_ACCOUNT_PROTOCOL_GET_CLASS (self)->get_service_icon (self, account_id, mailbox, icon_size);
+}
+
+static const GdkPixbuf *
+modest_account_protocol_get_service_icon_default (ModestAccountProtocol *self,
+                                                 const gchar *account_id,
+                                                 const gchar *mailbox,
+                                                 guint icon_size)
+{
+       g_return_val_if_fail (MODEST_IS_ACCOUNT_PROTOCOL (self), NULL);
+
+       return NULL;
+}
+
+void
+modest_account_protocol_save_remote_draft (ModestAccountProtocol *self,
+                                          const gchar *account_id,
+                                          TnyMsg *new_msg,
+                                          TnyMsg *old_msg,
+                                          ModestAccountProtocolSaveRemoteDraftCallback callback,
+                                          gpointer userdata)
+{
+       MODEST_ACCOUNT_PROTOCOL_GET_CLASS (self)->save_remote_draft (self, account_id, 
+                                                                    new_msg, old_msg,
+                                                                    callback, userdata);
+}
+
+static void
+modest_account_protocol_save_remote_draft_default (ModestAccountProtocol *self,
+                                                  const gchar *account_id,
+                                                  TnyMsg *new_msg,
+                                                  TnyMsg *old_msg,
+                                                  ModestAccountProtocolSaveRemoteDraftCallback callback,
+                                                  gpointer userdata)
+{
+       if (callback) {
+               callback (self, NULL, account_id, NULL, new_msg, old_msg, userdata);
+       }
+}
+