X-Git-Url: http://git.maemo.org/git/?a=blobdiff_plain;f=src%2Fmodest-account-protocol.c;h=70d8d24d6c3a1ae87b05c396d28499b2a570e76f;hb=0cd70c5f256d6071c5fc9671b5094a37ea0faabe;hp=38ec0c36628f7ef75991f1f0949ac4f74aca8b8d;hpb=b4d53de55cf1dec1eef9e16530f620f1bccdf03c;p=modest diff --git a/src/modest-account-protocol.c b/src/modest-account-protocol.c index 38ec0c3..70d8d24 100644 --- a/src/modest-account-protocol.c +++ b/src/modest-account-protocol.c @@ -47,6 +47,8 @@ struct _ModestAccountProtocolPrivate { TnyList *account_options; GHashTable *custom_auth_mechs; GType account_g_type; + + GHashTable *account_dialogs; }; /* 'private'/'protected' functions */ @@ -80,6 +82,28 @@ 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 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); + + /* globals */ static GObjectClass *parent_class = NULL; @@ -160,6 +184,20 @@ 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->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; } static void @@ -174,6 +212,30 @@ modest_account_protocol_instance_init (ModestAccountProtocol *obj) priv->account_g_type = 0; priv->account_options = tny_simple_list_new (); priv->custom_auth_mechs = g_hash_table_new_full (g_direct_hash, g_direct_equal, NULL, g_free); + + priv->account_dialogs = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL); +} + +static gboolean +remove_account (const gchar *account_name, GObject *account, GObject *account_to_remove) +{ + return (account == account_to_remove); +} + +static void +account_dialog_weak_handler (ModestAccountProtocol *self, GObject *where_the_object_was) +{ + ModestAccountProtocolPrivate *priv = MODEST_ACCOUNT_PROTOCOL_GET_PRIVATE (self); + + g_hash_table_foreach_remove (priv->account_dialogs, (GHRFunc) remove_account, where_the_object_was); +} + +static gboolean +dialogs_remove (const gchar *account_name, GObject *account_dialog, ModestAccountProtocol *self) +{ + g_object_weak_unref (account_dialog, (GWeakNotify) account_dialog_weak_handler, self); + + return TRUE; } static void @@ -182,6 +244,11 @@ modest_account_protocol_finalize (GObject *obj) ModestAccountProtocol *protocol = MODEST_ACCOUNT_PROTOCOL (obj); ModestAccountProtocolPrivate *priv = MODEST_ACCOUNT_PROTOCOL_GET_PRIVATE (protocol); + if (priv->account_dialogs) { + g_hash_table_foreach_remove (priv->account_dialogs, (GHRFunc) dialogs_remove, obj); + g_hash_table_destroy (priv->account_dialogs); + } + if (priv->account_options) g_object_unref (priv->account_options); priv->account_options = NULL; @@ -435,19 +502,29 @@ modest_account_protocol_get_account_settings_dialog (ModestAccountProtocol *self { ModestAccountSettingsDialog *dialog; ModestAccountSettings *settings; + ModestAccountProtocolPrivate *priv; + + priv = MODEST_ACCOUNT_PROTOCOL_GET_PRIVATE (self); + dialog = g_hash_table_lookup (priv->account_dialogs, account_name); + + if (dialog == NULL) { - dialog = MODEST_ACCOUNT_PROTOCOL_GET_CLASS (self)->create_account_settings_dialog (self); + dialog = MODEST_ACCOUNT_PROTOCOL_GET_CLASS (self)->create_account_settings_dialog (self); - /* Load settings */ - settings = modest_account_mgr_load_account_settings (modest_runtime_get_account_mgr (), - account_name); - modest_account_settings_dialog_load_settings (dialog, settings); + /* Load settings */ + 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", - G_CALLBACK (gtk_widget_destroy), - dialog); + /* Close dialog on response */ + g_signal_connect_swapped (dialog, + "response", + G_CALLBACK (gtk_widget_destroy), + dialog); + + g_hash_table_insert (priv->account_dialogs, g_strdup (account_name), dialog); + g_object_weak_ref (G_OBJECT (dialog), (GWeakNotify) account_dialog_weak_handler, self); + } return dialog; } @@ -512,3 +589,120 @@ 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); +} + +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_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_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_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_ACCOUNT_PROTOCOL (self), NULL); + + return NULL; +}