[evolution/account-mgmt: 20/51] Adapt mail to the new ESource API.
- From: Matthew Barnes <mbarnes src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution/account-mgmt: 20/51] Adapt mail to the new ESource API.
- Date: Wed, 7 Mar 2012 19:12:00 +0000 (UTC)
commit eb5e2c102d7cd0f6e28ce682f08ca09bfa70ba6a
Author: Matthew Barnes <mbarnes redhat com>
Date: Wed Apr 13 10:30:40 2011 -0400
Adapt mail to the new ESource API.
libemail-engine/Makefile.am | 2 +
libemail-engine/e-mail-authenticator.c | 267 ++++
libemail-engine/e-mail-authenticator.h | 76 +
libemail-engine/e-mail-session-utils.c | 38 +-
libemail-engine/e-mail-session.c | 984 ++++++++-----
libemail-engine/e-mail-session.h | 30 +-
libemail-engine/e-mail-utils.c | 544 +++++---
libemail-engine/e-mail-utils.h | 38 +-
libemail-engine/mail-config.c | 21 -
libemail-engine/mail-config.h | 1 -
libemail-engine/mail-folder-cache.c | 11 +-
libemail-engine/mail-ops.c | 371 +++---
libemail-engine/mail-ops.h | 1 -
libemail-utils/Makefile.am | 8 -
mail/Makefile.am | 14 +
mail/e-mail-account-config.c | 52 +
mail/e-mail-account-config.h | 63 +
mail/e-mail-account-manager.c | 23 +-
mail/e-mail-account-manager.h | 6 +-
mail/e-mail-account-store.c | 298 ++---
mail/e-mail-backend.c | 242 ++--
mail/e-mail-config-auth-check.c | 503 +++++++
mail/e-mail-config-auth-check.h | 76 +
mail/e-mail-config-backend.c | 139 ++
mail/e-mail-config-backend.h | 92 ++
mail/e-mail-config-identity.c | 723 +++++++++
mail/e-mail-config-identity.h | 87 ++
mail/e-mail-config-provider.c | 645 ++++++++
mail/e-mail-config-provider.h | 67 +
mail/e-mail-config.c | 809 ++++++++++
mail/e-mail-config.h | 93 ++
mail/e-mail-folder-pane.c | 17 +-
mail/e-mail-migrate.c | 250 +---
mail/e-mail-paned-view.c | 8 +-
mail/e-mail-reader-utils.c | 27 +-
mail/e-mail-reader.c | 52 +-
mail/e-mail-transport-config.c | 52 +
mail/e-mail-transport-config.h | 64 +
mail/e-mail-ui-session.c | 321 ++---
mail/e-mail-ui-session.h | 8 +-
mail/e-mail.h | 1 +
mail/em-account-editor.c | 2517 ++++++++++++--------------------
mail/em-account-editor.h | 24 +-
mail/em-composer-utils.c | 317 +++--
mail/em-composer-utils.h | 3 +-
mail/em-filter-source-element.c | 111 +--
mail/em-folder-tree-model.c | 56 +-
mail/em-format-html.c | 21 +-
mail/em-subscription-editor.c | 12 +-
mail/em-utils.c | 48 +-
mail/em-utils.h | 6 -
mail/mail-config.ui | 50 -
mail/mail-send-recv.c | 293 +---
mail/mail.error.xml | 28 -
54 files changed, 6970 insertions(+), 3640 deletions(-)
---
diff --git a/libemail-engine/Makefile.am b/libemail-engine/Makefile.am
index 4c64ea8..103a9d5 100644
--- a/libemail-engine/Makefile.am
+++ b/libemail-engine/Makefile.am
@@ -22,6 +22,7 @@ libemail_engine_la_CPPFLAGS = \
libmailengineincludedir = $(privincludedir)/libemail-engine
libmailengineinclude_HEADERS = \
camel-null-store.h \
+ e-mail-authenticator.h \
e-mail-enums.h \
e-mail-enumtypes.h \
e-mail-folder-utils.h \
@@ -40,6 +41,7 @@ libmailengineinclude_HEADERS = \
libemail_engine_la_SOURCES = \
$(libmailengineinclude_HEADERS) \
camel-null-store.c \
+ e-mail-authenticator.c \
e-mail-enumtypes.c \
e-mail-folder-utils.c \
e-mail-junk-filter.c \
diff --git a/libemail-engine/e-mail-authenticator.c b/libemail-engine/e-mail-authenticator.c
new file mode 100644
index 0000000..9729d35
--- /dev/null
+++ b/libemail-engine/e-mail-authenticator.c
@@ -0,0 +1,267 @@
+/*
+ * e-mail-authenticator.c
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) version 3.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with the program; if not, see <http://www.gnu.org/licenses/>
+ *
+ */
+
+#include "e-mail-authenticator.h"
+
+#include <config.h>
+#include <glib/gi18n-lib.h>
+
+#define E_MAIL_AUTHENTICATOR_GET_PRIVATE(obj) \
+ (G_TYPE_INSTANCE_GET_PRIVATE \
+ ((obj), E_TYPE_MAIL_AUTHENTICATOR, EMailAuthenticatorPrivate))
+
+struct _EMailAuthenticatorPrivate {
+ CamelService *service;
+ gchar *mechanism;
+};
+
+enum {
+ PROP_0,
+ PROP_MECHANISM,
+ PROP_SERVICE
+};
+
+/* Forward Declarations */
+static void e_mail_authenticator_interface_init
+ (ESourceAuthenticatorInterface *interface);
+
+G_DEFINE_TYPE_WITH_CODE (
+ EMailAuthenticator,
+ e_mail_authenticator,
+ G_TYPE_OBJECT,
+ G_IMPLEMENT_INTERFACE (
+ E_TYPE_SOURCE_AUTHENTICATOR,
+ e_mail_authenticator_interface_init))
+
+static void
+mail_authenticator_set_mechanism (EMailAuthenticator *auth,
+ const gchar *mechanism)
+{
+ g_return_if_fail (auth->priv->mechanism == NULL);
+
+ auth->priv->mechanism = g_strdup (mechanism);
+}
+
+static void
+mail_authenticator_set_service (EMailAuthenticator *auth,
+ CamelService *service)
+{
+ g_return_if_fail (CAMEL_IS_SERVICE (service));
+ g_return_if_fail (auth->priv->service == NULL);
+
+ auth->priv->service = g_object_ref (service);
+}
+
+static void
+mail_authenticator_set_property (GObject *object,
+ guint property_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ switch (property_id) {
+ case PROP_MECHANISM:
+ mail_authenticator_set_mechanism (
+ E_MAIL_AUTHENTICATOR (object),
+ g_value_get_string (value));
+ return;
+
+ case PROP_SERVICE:
+ mail_authenticator_set_service (
+ E_MAIL_AUTHENTICATOR (object),
+ g_value_get_object (value));
+ return;
+ }
+
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+}
+
+static void
+mail_authenticator_get_property (GObject *object,
+ guint property_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ switch (property_id) {
+ case PROP_MECHANISM:
+ g_value_set_string (
+ value,
+ e_mail_authenticator_get_mechanism (
+ E_MAIL_AUTHENTICATOR (object)));
+ return;
+
+ case PROP_SERVICE:
+ g_value_set_object (
+ value,
+ e_mail_authenticator_get_service (
+ E_MAIL_AUTHENTICATOR (object)));
+ return;
+ }
+
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+}
+
+static void
+mail_authenticator_dispose (GObject *object)
+{
+ EMailAuthenticatorPrivate *priv;
+
+ priv = E_MAIL_AUTHENTICATOR_GET_PRIVATE (object);
+
+ if (priv->service != NULL) {
+ g_object_unref (priv->service);
+ priv->service = NULL;
+ }
+
+ /* Chain up to parent's dispose() method. */
+ G_OBJECT_CLASS (e_mail_authenticator_parent_class)->dispose (object);
+}
+
+static void
+mail_authenticator_finalize (GObject *object)
+{
+ EMailAuthenticatorPrivate *priv;
+
+ priv = E_MAIL_AUTHENTICATOR_GET_PRIVATE (object);
+
+ g_free (priv->mechanism);
+
+ /* Chain up to parent's finalize() method. */
+ G_OBJECT_CLASS (e_mail_authenticator_parent_class)->finalize (object);
+}
+
+static ESourceAuthenticationResult
+mail_authenticator_try_password_sync (ESourceAuthenticator *auth,
+ const GString *password,
+ GCancellable *cancellable,
+ GError **error)
+{
+ CamelService *service;
+ EMailAuthenticator *mail_auth;
+ CamelAuthenticationResult camel_result;
+ ESourceAuthenticationResult source_result;
+ const gchar *mechanism;
+
+ mail_auth = E_MAIL_AUTHENTICATOR (auth);
+ service = e_mail_authenticator_get_service (mail_auth);
+ mechanism = e_mail_authenticator_get_mechanism (mail_auth);
+
+ camel_service_set_password (service, password->str);
+
+ camel_result = camel_service_authenticate_sync (
+ service, mechanism, cancellable, error);
+
+ switch (camel_result) {
+ case CAMEL_AUTHENTICATION_ERROR:
+ source_result = E_SOURCE_AUTHENTICATION_ERROR;
+ break;
+ case CAMEL_AUTHENTICATION_ACCEPTED:
+ source_result = E_SOURCE_AUTHENTICATION_ACCEPTED;
+ break;
+ case CAMEL_AUTHENTICATION_REJECTED:
+ source_result = E_SOURCE_AUTHENTICATION_REJECTED;
+ break;
+ default:
+ g_set_error (
+ error, CAMEL_SERVICE_ERROR,
+ CAMEL_SERVICE_ERROR_CANT_AUTHENTICATE,
+ _("Invalid authentication result code (%d)"),
+ camel_result);
+ source_result = E_SOURCE_AUTHENTICATION_ERROR;
+ break;
+ }
+
+ return source_result;
+}
+
+static void
+e_mail_authenticator_class_init (EMailAuthenticatorClass *class)
+{
+ GObjectClass *object_class;
+
+ g_type_class_add_private (class, sizeof (EMailAuthenticatorPrivate));
+
+ object_class = G_OBJECT_CLASS (class);
+ object_class->set_property = mail_authenticator_set_property;
+ object_class->get_property = mail_authenticator_get_property;
+ object_class->dispose = mail_authenticator_dispose;
+ object_class->finalize = mail_authenticator_finalize;
+
+ g_object_class_install_property (
+ object_class,
+ PROP_MECHANISM,
+ g_param_spec_string (
+ "mechanism",
+ "Mechanism",
+ "Authentication mechanism",
+ NULL,
+ G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT_ONLY |
+ G_PARAM_STATIC_STRINGS));
+
+ g_object_class_install_property (
+ object_class,
+ PROP_SERVICE,
+ g_param_spec_object (
+ "service",
+ "Service",
+ "The CamelService to authenticate",
+ CAMEL_TYPE_SERVICE,
+ G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT_ONLY |
+ G_PARAM_STATIC_STRINGS));
+}
+
+static void
+e_mail_authenticator_interface_init (ESourceAuthenticatorInterface *interface)
+{
+ interface->try_password_sync = mail_authenticator_try_password_sync;
+}
+
+static void
+e_mail_authenticator_init (EMailAuthenticator *auth)
+{
+ auth->priv = E_MAIL_AUTHENTICATOR_GET_PRIVATE (auth);
+}
+
+ESourceAuthenticator *
+e_mail_authenticator_new (CamelService *service,
+ const gchar *mechanism)
+{
+ g_return_val_if_fail (CAMEL_IS_SERVICE (service), NULL);
+
+ return g_object_new (
+ E_TYPE_MAIL_AUTHENTICATOR,
+ "service", service, "mechanism", mechanism, NULL);
+}
+
+CamelService *
+e_mail_authenticator_get_service (EMailAuthenticator *auth)
+{
+ g_return_val_if_fail (E_IS_MAIL_AUTHENTICATOR (auth), NULL);
+
+ return auth->priv->service;
+}
+
+const gchar *
+e_mail_authenticator_get_mechanism (EMailAuthenticator *auth)
+{
+ g_return_val_if_fail (E_IS_MAIL_AUTHENTICATOR (auth), NULL);
+
+ return auth->priv->mechanism;
+}
+
diff --git a/libemail-engine/e-mail-authenticator.h b/libemail-engine/e-mail-authenticator.h
new file mode 100644
index 0000000..bcc3299
--- /dev/null
+++ b/libemail-engine/e-mail-authenticator.h
@@ -0,0 +1,76 @@
+/*
+ * e-mail-authenticator.h
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) version 3.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with the program; if not, see <http://www.gnu.org/licenses/>
+ *
+ */
+
+#ifndef E_MAIL_AUTHENTICATOR_H
+#define E_MAIL_AUTHENTICATOR_H
+
+#include <camel/camel.h>
+#include <libedataserver/e-source-authenticator.h>
+
+/* Standard GObject macros */
+#define E_TYPE_MAIL_AUTHENTICATOR \
+ (e_mail_authenticator_get_type ())
+#define E_MAIL_AUTHENTICATOR(obj) \
+ (G_TYPE_CHECK_INSTANCE_CAST \
+ ((obj), E_TYPE_MAIL_AUTHENTICATOR, EMailAuthenticator))
+#define E_MAIL_AUTHENTICATOR_CLASS(cls) \
+ (G_TYPE_CHECK_CLASS_CAST \
+ ((cls), E_TYPE_MAIL_AUTHENTICATOR, EMailAuthenticatorClass))
+#define E_IS_MAIL_AUTHENTICATOR(obj) \
+ (G_TYPE_CHECK_INSTANCE_TYPE \
+ ((obj), E_TYPE_MAIL_AUTHENTICATOR))
+#define E_IS_MAIL_AUTHENTICATOR_CLASS(cls) \
+ (G_TYPE_CHECK_CLASS_TYPE \
+ ((cls), E_TYPE_MAIL_AUTHENTICATOR))
+#define E_MAIL_AUTHENTICATOR_GET_CLASS(obj) \
+ (G_TYPE_INSTANCE_GET_CLASS \
+ ((obj), E_TYPE_MAIL_AUTHENTICATOR, EMailAuthenticatorClass))
+
+G_BEGIN_DECLS
+
+typedef struct _EMailAuthenticator EMailAuthenticator;
+typedef struct _EMailAuthenticatorClass EMailAuthenticatorClass;
+typedef struct _EMailAuthenticatorPrivate EMailAuthenticatorPrivate;
+
+/**
+ * EMailAuthenticator:
+ *
+ * Contains only private data that should be read and manipulated using the
+ * functions below.
+ **/
+struct _EMailAuthenticator {
+ GObject parent;
+ EMailAuthenticatorPrivate *priv;
+};
+
+struct _EMailAuthenticatorClass {
+ GObjectClass parent_class;
+};
+
+GType e_mail_authenticator_get_type (void);
+ESourceAuthenticator *
+ e_mail_authenticator_new (CamelService *service,
+ const gchar *mechanism);
+CamelService * e_mail_authenticator_get_service
+ (EMailAuthenticator *auth);
+const gchar * e_mail_authenticator_get_mechanism
+ (EMailAuthenticator *auth);
+
+G_END_DECLS
+
+#endif /* E_MAIL_AUTHENTICATOR_H */
diff --git a/libemail-engine/e-mail-session-utils.c b/libemail-engine/e-mail-session-utils.c
index 6aa090e..2b2b94c 100644
--- a/libemail-engine/e-mail-session-utils.c
+++ b/libemail-engine/e-mail-session-utils.c
@@ -23,11 +23,11 @@
#include "e-mail-session-utils.h"
#include <glib/gi18n-lib.h>
+#include <libedataserver/e-source-mail-submission.h>
#include <libemail-engine/e-mail-folder-utils.h>
#include <libemail-engine/e-mail-utils.h>
#include <libemail-engine/mail-tools.h>
-#include <libemail-utils/e-account-utils.h>
/* X-Mailer header value */
#define X_MAILER ("Evolution " VERSION SUB_VERSION " " VERSION_COMMENT)
@@ -648,7 +648,8 @@ e_mail_session_send_to (EMailSession *session,
CamelAddress *recipients;
CamelMedium *medium;
CamelMessageInfo *info;
- EAccount *account = NULL;
+ ESourceRegistry *registry;
+ ESource *source = NULL;
GPtrArray *post_to_uris;
struct _camel_header_raw *xev;
struct _camel_header_raw *header;
@@ -661,6 +662,8 @@ e_mail_session_send_to (EMailSession *session,
g_return_if_fail (E_IS_MAIL_SESSION (session));
g_return_if_fail (CAMEL_IS_MIME_MESSAGE (message));
+ registry = e_mail_session_get_registry (session);
+
medium = CAMEL_MEDIUM (message);
camel_medium_set_header (medium, "X-Mailer", X_MAILER);
@@ -669,28 +672,25 @@ e_mail_session_send_to (EMailSession *session,
/* Extract directives from X-Evolution headers. */
- string = camel_header_raw_find (&xev, "X-Evolution-Account", NULL);
+ string = camel_header_raw_find (&xev, "X-Evolution-Identity", NULL);
if (string != NULL) {
- gchar *account_uid;
-
- account_uid = g_strstrip (g_strdup (string));
- account = e_get_account_by_uid (account_uid);
- g_free (account_uid);
+ gchar *uid = g_strstrip (g_strdup (string));
+ source = e_source_registry_lookup_by_uid (registry, uid);
+ g_free (uid);
}
- if (account != NULL) {
- if (account->transport != NULL) {
+ if (E_IS_SOURCE (source)) {
+ ESourceMailSubmission *extension;
+ const gchar *extension_name;
- /* XXX Transport UIDs are kludgy right now. We
- * use the EAccount's regular UID and tack on
- * "-transport". Will be better soon. */
- transport_uid = g_strconcat (
- account->uid, "-transport", NULL);
+ extension_name = E_SOURCE_EXTENSION_MAIL_SUBMISSION;
+ extension = e_source_get_extension (source, extension_name);
- /* to reprompt password on sending if needed */
- account->transport->get_password_canceled = FALSE;
- }
- sent_folder_uri = g_strdup (account->sent_folder_uri);
+ string = e_source_mail_submission_get_sent_folder (extension);
+ sent_folder_uri = g_strdup (string);
+
+ string = e_source_mail_submission_get_transport_uid (extension);
+ transport_uid = g_strdup (string);
}
string = camel_header_raw_find (&xev, "X-Evolution-Fcc", NULL);
diff --git a/libemail-engine/e-mail-session.c b/libemail-engine/e-mail-session.c
index 193756f..63ac356 100644
--- a/libemail-engine/e-mail-session.c
+++ b/libemail-engine/e-mail-session.c
@@ -45,15 +45,22 @@
#include <libedataserver/e-flag.h>
#include <libedataserver/e-proxy.h>
#include <libebackend/e-extensible.h>
+#include <libedataserver/e-source-authentication.h>
+#include <libedataserver/e-source-camel.h>
+#include <libedataserver/e-source-mail-account.h>
+#include <libedataserver/e-source-mail-identity.h>
+#include <libedataserver/e-source-mail-submission.h>
+#include <libedataserver/e-source-mail-transport.h>
+#include <libedataserver/e-source-refresh.h>
#include <libedataserverui/e-passwords.h>
#include <libedataserver/e-data-server-util.h>
-#include "libemail-utils/e-account-utils.h"
#include "libemail-utils/mail-mt.h"
/* This is our hack, not part of libcamel. */
#include "camel-null-store.h"
+#include "e-mail-authenticator.h"
#include "e-mail-junk-filter.h"
#include "e-mail-session.h"
#include "e-mail-folder-utils.h"
@@ -70,9 +77,13 @@ typedef struct _AsyncContext AsyncContext;
struct _EMailSessionPrivate {
MailFolderCache *folder_cache;
+ ESourceRegistry *registry;
- EAccountList *account_list;
- gulong account_added_handler_id;
+ /* ESource UID -> Timeout ID */
+ GHashTable *auto_refresh_table;
+
+ gulong source_added_handler_id;
+ gulong source_removed_handler_id;
CamelStore *local_store;
CamelStore *vfolder_store;
@@ -101,6 +112,7 @@ enum {
PROP_FOLDER_CACHE,
PROP_JUNK_FILTER_NAME,
PROP_LOCAL_STORE,
+ PROP_REGISTRY,
PROP_VFOLDER_STORE
};
@@ -115,6 +127,7 @@ static const gchar *local_folder_names[E_MAIL_NUM_LOCAL_FOLDERS] = {
enum {
FLUSH_OUTBOX,
+ REFRESH_SERVICE,
STORE_ADDED,
STORE_REMOVED,
LAST_SIGNAL
@@ -317,21 +330,66 @@ async_context_free (AsyncContext *context)
}
static gchar *
-mail_session_make_key (CamelService *service,
- const gchar *item)
+mail_session_resolve_popb4smtp (ESourceRegistry *registry,
+ CamelService *smtp_service)
{
- gchar *key;
+ GList *list, *link;
+ const gchar *extension_name;
+ const gchar *smtp_uid;
+ gchar *pop_uid = NULL;
- if (service != NULL) {
- CamelURL *url;
+ /* Find a POP account that uses the given smtp_service as its
+ * transport. XXX This isn't foolproof though, since we don't
+ * check that the POP server is at the same domain as the SMTP
+ * server, which is kind of the point of POPB4SMTP. */
- url = camel_service_new_camel_url (service);
- key = camel_url_to_string (url, CAMEL_URL_HIDE_ALL);
- camel_url_free (url);
- } else
- key = g_strdup (item);
+ smtp_uid = camel_service_get_uid (smtp_service);
+
+ extension_name = E_SOURCE_EXTENSION_MAIL_ACCOUNT;
+ list = e_source_registry_list_sources (registry, extension_name);
+
+ for (link = list; link != NULL; link = g_list_next (link)) {
+ ESource *source = E_SOURCE (link->data);
+ ESourceExtension *extension;
+ const gchar *backend_name;
+ const gchar *uid;
+
+ extension_name = E_SOURCE_EXTENSION_MAIL_ACCOUNT;
+ extension = e_source_get_extension (source, extension_name);
+
+ /* We're only interested in POP accounts. */
+
+ backend_name = e_source_backend_get_backend_name (
+ E_SOURCE_BACKEND (extension));
+ if (g_strcmp0 (backend_name, "pop") != 0)
+ continue;
+
+ /* Get the mail account's default mail identity. */
+
+ source = e_source_mail_account_get_identity (
+ E_SOURCE_MAIL_ACCOUNT (extension));
+ if (source == NULL)
+ continue;
+
+ /* Get the mail identity's default mail transport. */
+
+ extension_name = E_SOURCE_EXTENSION_MAIL_SUBMISSION;
+ extension = e_source_get_extension (source, extension_name);
+
+ uid = e_source_mail_submission_get_transport_uid (
+ E_SOURCE_MAIL_SUBMISSION (extension));
+ if (uid == NULL)
+ continue;
- return key;
+ if (g_strcmp0 (uid, smtp_uid) == 0) {
+ pop_uid = g_strdup (uid);
+ break;
+ }
+ }
+
+ g_list_free (list);
+
+ return pop_uid;
}
static void
@@ -406,135 +464,142 @@ mail_session_set_junk_filter_name (EMailSession *session,
}
static void
-mail_session_add_by_account (EMailSession *session,
- EAccount *account)
-{
- CamelService *service = NULL;
- CamelProvider *provider;
- CamelURL *url = NULL;
- const gchar *protocol = NULL;
- gboolean have_source_url;
- GError *error = NULL;
-
- have_source_url =
- (account->source != NULL) &&
- (account->source->url != NULL);
+mail_session_refresh_cb (ESource *source,
+ CamelSession *session)
+{
+ CamelService *service;
+ const gchar *uid;
- if (have_source_url)
- url = camel_url_new (account->source->url, NULL);
+ uid = e_source_get_uid (source);
+ service = camel_session_get_service (session, uid);
+ g_return_if_fail (CAMEL_IS_SERVICE (service));
- protocol = (url != NULL) ? url->protocol : "none";
- provider = camel_provider_get (protocol, &error);
+ g_signal_emit (session, signals[REFRESH_SERVICE], 0, service);
+}
- if (url != NULL)
- camel_url_free (url);
+static void
+mail_session_add_from_source (EMailSession *session,
+ CamelProviderType type,
+ ESource *source)
+{
+ ESourceBackend *extension;
+ const gchar *uid;
+ const gchar *backend_name;
+ const gchar *display_name;
+ const gchar *extension_name;
+ GError *error = NULL;
- if (error != NULL) {
- g_warn_if_fail (provider == NULL);
- g_warning ("%s", error->message);
- g_error_free (error);
- return;
+ switch (type) {
+ case CAMEL_PROVIDER_STORE:
+ extension_name = E_SOURCE_EXTENSION_MAIL_ACCOUNT;
+ break;
+ case CAMEL_PROVIDER_TRANSPORT:
+ extension_name = E_SOURCE_EXTENSION_MAIL_TRANSPORT;
+ break;
+ default:
+ g_return_if_reached ();
}
- g_return_if_fail (provider != NULL);
+ uid = e_source_get_uid (source);
+ display_name = e_source_get_display_name (source);
- /* Load the service, but don't connect. Check its provider,
- * and if this belongs in the folder tree model, add it. */
+ extension = e_source_get_extension (source, extension_name);
+ backend_name = e_source_backend_get_backend_name (extension);
- service = camel_session_add_service (
- CAMEL_SESSION (session),
- account->uid, provider->protocol,
- CAMEL_PROVIDER_STORE, &error);
+ /* Sanity checks. */
+ g_return_if_fail (uid != NULL);
+ g_return_if_fail (backend_name != NULL);
+
+ /* Our own CamelSession.add_service() method will handle the
+ * resulting CamelService, so we don't need the return value. */
+ camel_session_add_service (
+ CAMEL_SESSION (session), uid,
+ backend_name, type, &error);
if (error != NULL) {
g_warning (
- "Failed to add service: %s: %s",
- account->name, error->message);
+ "Failed to add service '%s' (%s): %s",
+ display_name, uid, error->message);
g_error_free (error);
- return;
}
- camel_service_set_display_name (service, account->name);
-
- /* While we're at it, add the account's transport (if it has one)
- * to the CamelSession. The transport's UID is a kludge for now.
- * We take the EAccount's UID and tack on "-transport". */
+ /* Set up auto-refresh. */
+ extension_name = E_SOURCE_EXTENSION_REFRESH;
+ if (e_source_has_extension (source, extension_name)) {
+ guint timeout_id;
- if (account->transport) {
- GError *transport_error = NULL;
+ /* Transports should not have a refresh extension. */
+ g_warn_if_fail (type != CAMEL_PROVIDER_TRANSPORT);
- url = camel_url_new (
- account->transport->url,
- &transport_error);
+ timeout_id = e_source_refresh_add_timeout (
+ source, NULL, (ESourceRefreshFunc)
+ mail_session_refresh_cb, session,
+ (GDestroyNotify) NULL);
- if (url != NULL) {
- provider = camel_provider_get (
- url->protocol, &transport_error);
- camel_url_free (url);
- } else
- provider = NULL;
+ g_hash_table_insert (
+ session->priv->auto_refresh_table,
+ g_strdup (uid),
+ GUINT_TO_POINTER (timeout_id));
+ }
+}
- if (provider != NULL) {
- gchar *transport_uid;
+static void
+mail_session_source_added_cb (ESourceRegistry *registry,
+ ESource *source,
+ EMailSession *session)
+{
+ CamelProviderType provider_type;
+ const gchar *extension_name;
- transport_uid = g_strconcat (
- account->uid, "-transport", NULL);
+ provider_type = CAMEL_PROVIDER_STORE;
+ extension_name = E_SOURCE_EXTENSION_MAIL_ACCOUNT;
- camel_session_add_service (
- CAMEL_SESSION (session),
- transport_uid, provider->protocol,
- CAMEL_PROVIDER_TRANSPORT, &transport_error);
+ if (e_source_has_extension (source, extension_name))
+ mail_session_add_from_source (session, provider_type, source);
- g_free (transport_uid);
- }
+ provider_type = CAMEL_PROVIDER_TRANSPORT;
+ extension_name = E_SOURCE_EXTENSION_MAIL_TRANSPORT;
- if (transport_error) {
- g_warning (
- "%s: Failed to add transport service: %s",
- G_STRFUNC, transport_error->message);
- g_error_free (transport_error);
- }
- }
+ if (e_source_has_extension (source, extension_name))
+ mail_session_add_from_source (session, provider_type, source);
}
static void
-mail_session_account_added_cb (EAccountList *account_list,
- EAccount *account,
- EMailSession *session)
+mail_session_source_removed_cb (ESourceRegistry *registry,
+ ESource *source,
+ EMailSession *session)
{
- mail_session_add_by_account (session, account);
+ CamelSession *camel_session;
+ CamelService *service;
+ const gchar *uid;
+
+ camel_session = CAMEL_SESSION (session);
+
+ uid = e_source_get_uid (source);
+ service = camel_session_get_service (camel_session, uid);
+
+ if (CAMEL_IS_SERVICE (service))
+ camel_session_remove_service (camel_session, service);
}
static void
-mail_session_add_local_store (EMailSession *session)
+mail_session_configure_local_store (EMailSession *session)
{
CamelLocalSettings *local_settings;
CamelSession *camel_session;
CamelSettings *settings;
CamelService *service;
const gchar *data_dir;
+ const gchar *uid;
gchar *path;
gint ii;
- GError *error = NULL;
camel_session = CAMEL_SESSION (session);
- service = camel_session_add_service (
- camel_session, E_MAIL_SESSION_LOCAL_UID,
- "maildir", CAMEL_PROVIDER_STORE, &error);
-
- /* XXX One could argue this is a fatal error
- * since we depend on it in so many places. */
- if (error != NULL) {
- g_critical ("%s: %s", G_STRFUNC, error->message);
- g_error_free (error);
- return;
- }
-
+ uid = E_MAIL_SESSION_LOCAL_UID;
+ service = camel_session_get_service (camel_session, uid);
g_return_if_fail (CAMEL_IS_SERVICE (service));
- camel_service_set_display_name (service, _("On This Computer"));
-
settings = camel_service_get_settings (service);
local_settings = CAMEL_LOCAL_SETTINGS (settings);
data_dir = camel_session_get_user_data_dir (camel_session);
@@ -582,6 +647,105 @@ mail_session_add_local_store (EMailSession *session)
}
static void
+mail_session_force_refresh (EMailSession *session)
+{
+ ESourceRegistry *registry;
+ GHashTableIter iter;
+ GSettings *settings;
+ gboolean unconditionally;
+ gpointer key;
+
+ /* Only refresh when the session is online. */
+ if (!camel_session_get_online (CAMEL_SESSION (session)))
+ return;
+
+ /* FIXME EMailSession should define properties for these. */
+ settings = g_settings_new ("org.gnome.evolution.mail");
+ unconditionally =
+ g_settings_get_boolean (settings, "send-recv-on-start") &&
+ g_settings_get_boolean (settings, "send-recv-all-on-start");
+ g_object_unref (settings);
+
+ registry = e_mail_session_get_registry (session);
+ g_hash_table_iter_init (&iter, session->priv->auto_refresh_table);
+
+ while (g_hash_table_iter_next (&iter, &key, NULL)) {
+ ESource *source;
+ ESourceRefresh *extension;
+ const gchar *extension_name;
+ gboolean refresh_enabled;
+
+ /* The hash table key is the ESource UID. */
+ source = e_source_registry_lookup_by_uid (registry, key);
+
+ if (source == NULL)
+ continue;
+
+ extension_name = E_SOURCE_EXTENSION_REFRESH;
+ extension = e_source_get_extension (source, extension_name);
+ refresh_enabled = e_source_refresh_get_enabled (extension);
+
+ if (refresh_enabled || unconditionally)
+ e_source_refresh_force_timeout (source);
+ }
+}
+
+static void
+mail_session_cancel_refresh (EMailSession *session)
+{
+ ESourceRegistry *registry;
+ GHashTableIter iter;
+ gpointer key, value;
+
+ registry = e_mail_session_get_registry (session);
+ g_hash_table_iter_init (&iter, session->priv->auto_refresh_table);
+
+ while (g_hash_table_iter_next (&iter, &key, &value)) {
+ ESource *source;
+ guint timeout_id;
+
+ /* The hash table key is the ESource UID. */
+ source = e_source_registry_lookup_by_uid (registry, key);
+
+ /* The hash table value is the refresh timeout ID. */
+ timeout_id = GPOINTER_TO_UINT (value);
+
+ if (source == NULL)
+ continue;
+
+ e_source_refresh_remove_timeout (source, timeout_id);
+ }
+
+ /* All timeouts cancelled so clear the auto-refresh table. */
+ g_hash_table_remove_all (session->priv->auto_refresh_table);
+}
+
+static gboolean
+mail_session_idle_refresh_cb (EMailSession *session)
+{
+ /* This only runs once at startup (if settings allow). */
+
+ if (camel_session_get_online (CAMEL_SESSION (session))) {
+ mail_session_force_refresh (session);
+
+ /* Also flush the Outbox. */
+ g_signal_emit (session, signals[FLUSH_OUTBOX], 0);
+ }
+
+ return FALSE;
+}
+
+static void
+mail_session_set_registry (EMailSession *session,
+ ESourceRegistry *registry)
+{
+ g_return_if_fail (E_IS_SOURCE_REGISTRY (registry));
+ g_return_if_fail (session->priv->registry == NULL);
+
+ session->priv->registry = g_object_ref (registry);
+}
+
+static void
mail_session_set_property (GObject *object,
guint property_id,
const GValue *value,
@@ -593,6 +757,12 @@ mail_session_set_property (GObject *object,
E_MAIL_SESSION (object),
g_value_get_string (value));
return;
+
+ case PROP_REGISTRY:
+ mail_session_set_registry (
+ E_MAIL_SESSION (object),
+ g_value_get_object (value));
+ return;
}
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
@@ -626,6 +796,13 @@ mail_session_get_property (GObject *object,
E_MAIL_SESSION (object)));
return;
+ case PROP_REGISTRY:
+ g_value_set_object (
+ value,
+ e_mail_session_get_registry (
+ E_MAIL_SESSION (object)));
+ return;
+
case PROP_VFOLDER_STORE:
g_value_set_object (
value,
@@ -649,12 +826,19 @@ mail_session_dispose (GObject *object)
priv->folder_cache = NULL;
}
- if (priv->account_list != NULL) {
+ if (priv->registry != NULL) {
g_signal_handler_disconnect (
- priv->account_list,
- priv->account_added_handler_id);
- g_object_unref (priv->account_list);
- priv->account_list = NULL;
+ priv->registry,
+ priv->source_added_handler_id);
+ g_signal_handler_disconnect (
+ priv->registry,
+ priv->source_removed_handler_id);
+
+ /* This requires the registry. */
+ mail_session_cancel_refresh (E_MAIL_SESSION (object));
+
+ g_object_unref (priv->registry);
+ priv->registry = NULL;
}
if (priv->local_store != NULL) {
@@ -674,27 +858,18 @@ mail_session_dispose (GObject *object)
}
static void
-mail_session_add_vfolder_store (EMailSession *session)
+mail_session_configure_vfolder_store (EMailSession *session)
{
CamelSession *camel_session;
CamelService *service;
- GError *error = NULL;
+ const gchar *uid;
camel_session = CAMEL_SESSION (session);
- service = camel_session_add_service (
- camel_session, E_MAIL_SESSION_VFOLDER_UID,
- "vfolder", CAMEL_PROVIDER_STORE, &error);
-
- if (error != NULL) {
- g_critical ("%s: %s", G_STRFUNC, error->message);
- g_error_free (error);
- return;
- }
-
+ uid = E_MAIL_SESSION_VFOLDER_UID;
+ service = camel_session_get_service (camel_session, uid);
g_return_if_fail (CAMEL_IS_SERVICE (service));
- camel_service_set_display_name (service, _("Search Folders"));
em_utils_connect_service_sync (service, NULL, NULL);
/* XXX There's more configuration to do in vfolder_load_storage()
@@ -712,6 +887,7 @@ mail_session_finalize (GObject *object)
priv = E_MAIL_SESSION_GET_PRIVATE (object);
+ g_hash_table_destroy (priv->auto_refresh_table);
g_hash_table_destroy (priv->junk_filters);
g_object_unref (priv->proxy);
@@ -731,79 +907,81 @@ mail_session_notify (GObject *object,
{
/* GObject does not implement this method; do not chain up. */
+ /* CamelSession defines this property. */
+ if (g_strcmp0 (pspec->name, "online") == 0)
+ mail_session_force_refresh (E_MAIL_SESSION (object));
+
/* XXX Delete this once Evolution moves to GSettings and
* we're able to get rid of PROP_JUNK_FILTER_NAME. */
if (g_strcmp0 (pspec->name, "junk-filter") == 0)
g_object_notify (object, "junk-filter-name");
}
-static gboolean
-mail_session_initialize_stores_idle (gpointer user_data)
-{
- EMailSession *session = user_data;
- EAccountList *account_list;
- EAccount *account;
- EIterator *iter;
-
- g_return_val_if_fail (session != NULL, FALSE);
-
- account_list = e_get_account_list ();
- iter = e_list_get_iterator (E_LIST (account_list));
-
- while (e_iterator_is_valid (iter)) {
- /* XXX EIterator misuses const. */
- account = (EAccount *) e_iterator_get (iter);
-
- mail_session_add_by_account (session, account);
-
- e_iterator_next (iter);
- }
-
- g_object_unref (iter);
-
- return FALSE;
-}
-
static void
mail_session_constructed (GObject *object)
{
EMailSession *session;
EExtensible *extensible;
+ ESourceRegistry *registry;
GType extension_type;
GList *list, *link;
GSettings *settings;
- EAccountList *account_list;
+ CamelProviderType provider_type;
+ const gchar *extension_name;
gulong handler_id;
session = E_MAIL_SESSION (object);
+ registry = e_mail_session_get_registry (session);
/* Chain up to parent's constructed() method. */
G_OBJECT_CLASS (e_mail_session_parent_class)->constructed (object);
- account_list = e_get_account_list ();
- session->priv->account_list = g_object_ref (account_list);
+ /* Add available mail accounts. */
- /* This must be created after the account store. */
- session->priv->folder_cache = mail_folder_cache_new (session);
+ provider_type = CAMEL_PROVIDER_STORE;
+ extension_name = E_SOURCE_EXTENSION_MAIL_ACCOUNT;
- /* Add built-in CamelStores. */
- mail_session_add_local_store (session);
- mail_session_add_vfolder_store (session);
+ list = e_source_registry_list_sources (registry, extension_name);
- /* Give it a chance to load user settings, they are not loaded yet.
- *
- * XXX Is this the case where hiding such natural things like loading
- * user setting into an EExtension strikes back and proves itself
- * being suboptimal?
- */
- g_idle_add (mail_session_initialize_stores_idle, object);
+ for (link = list; link != NULL; link = g_list_next (link)) {
+ ESource *source = E_SOURCE (link->data);
+
+ mail_session_add_from_source (session, provider_type, source);
+ }
+
+ g_list_free (list);
+
+ /* Add available mail transports. */
+
+ provider_type = CAMEL_PROVIDER_TRANSPORT;
+ extension_name = E_SOURCE_EXTENSION_MAIL_TRANSPORT;
+
+ list = e_source_registry_list_sources (registry, extension_name);
- /* Listen for account list updates. */
+ for (link = list; link != NULL; link = g_list_next (link)) {
+ ESource *source = E_SOURCE (link->data);
+
+ mail_session_add_from_source (session, provider_type, source);
+ }
+
+ g_list_free (list);
+
+ /* Built-in stores require extra configuration. */
+
+ mail_session_configure_local_store (session);
+ mail_session_configure_vfolder_store (session);
+
+ /* Listen for registry changes. */
handler_id = g_signal_connect (
- account_list, "account-added",
- G_CALLBACK (mail_session_account_added_cb), session);
- session->priv->account_added_handler_id = handler_id;
+ registry, "source-added",
+ G_CALLBACK (mail_session_source_added_cb), session);
+ session->priv->source_added_handler_id = handler_id;
+
+ handler_id = g_signal_connect (
+ registry, "source-removed",
+ G_CALLBACK (mail_session_source_removed_cb), session);
+ session->priv->source_removed_handler_id = handler_id;
extensible = E_EXTENSIBLE (object);
e_extensible_load_extensions (extensible);
@@ -852,14 +1030,29 @@ mail_session_constructed (GObject *object)
g_list_free (list);
+ settings = g_settings_new ("org.gnome.evolution.mail");
+
/* Bind the "junk-default-plugin" GSettings
* key to our "junk-filter-name" property. */
- settings = g_settings_new ("org.gnome.evolution.mail");
g_settings_bind (
settings, "junk-default-plugin",
object, "junk-filter-name",
G_SETTINGS_BIND_DEFAULT);
+
+ /* Initialize the legacy message-passing framework
+ * before starting the first mail store refresh. */
+ mail_msg_init ();
+
+ /* The application is not yet fully initialized at this point,
+ * so run the first mail store refresh from an idle callback. */
+ if (g_settings_get_boolean (settings, "send-recv-on-start"))
+ g_idle_add_full (
+ G_PRIORITY_DEFAULT,
+ (GSourceFunc) mail_session_idle_refresh_cb,
+ g_object_ref (session),
+ (GDestroyNotify) g_object_unref);
+
g_object_unref (settings);
}
@@ -870,53 +1063,37 @@ mail_session_add_service (CamelSession *session,
CamelProviderType type,
GError **error)
{
+ ESourceRegistry *registry;
CamelService *service;
+ registry = e_mail_session_get_registry (E_MAIL_SESSION (session));
+
/* Chain up to parents add_service() method. */
service = CAMEL_SESSION_CLASS (e_mail_session_parent_class)->
add_service (session, uid, protocol, type, error);
- /* Initialize the CamelSettings object from CamelURL parameters.
- * This is temporary; soon we'll read settings from key files. */
+ /* Configure the CamelService from the corresponding ESource. */
if (CAMEL_IS_SERVICE (service)) {
- EAccount *account;
- CamelURL *url = NULL;
-
- account = e_get_account_by_uid (uid);
- if (account != NULL) {
- const gchar *url_string = NULL;
-
- switch (type) {
- case CAMEL_PROVIDER_STORE:
- url_string = account->source->url;
- break;
- case CAMEL_PROVIDER_TRANSPORT:
- url_string = account->transport->url;
- break;
- default:
- break;
- }
-
- /* Be lenient about malformed URLs. */
- if (url_string != NULL)
- url = camel_url_new (url_string, NULL);
- }
+ ESource *source;
- if (url != NULL) {
- CamelSettings *settings;
+ /* Each CamelService has a corresponding ESource. */
+ source = e_source_registry_lookup_by_uid (registry, uid);
+ g_return_val_if_fail (E_IS_SOURCE (source), service);
- settings = camel_service_get_settings (service);
- camel_settings_load_from_url (settings, url);
- camel_url_free (url);
+ /* This handles all the messy property bindings. */
+ e_source_camel_configure_service (source, service);
- g_object_notify (G_OBJECT (service), "settings");
+ g_object_bind_property (
+ source, "display-name",
+ service, "display-name",
+ G_BINDING_BIDIRECTIONAL |
+ G_BINDING_SYNC_CREATE);
- /* Migrate files for this service from its old
- * URL-based directory to a UID-based directory
- * if necessary. */
- camel_service_migrate_files (service);
- }
+ /* Migrate files for this service from its old
+ * URL-based directory to a UID-based directory
+ * if necessary. */
+ camel_service_migrate_files (service);
}
return service;
@@ -930,114 +1107,69 @@ mail_session_get_password (CamelSession *session,
guint32 flags,
GError **error)
{
- EAccount *account = NULL;
- const gchar *display_name = NULL;
- const gchar *uid = NULL;
- gchar *ret = NULL;
+ ESourceRegistry *registry;
+ gchar *password = NULL;
- if (CAMEL_IS_SERVICE (service)) {
- display_name = camel_service_get_display_name (service);
- uid = camel_service_get_uid (service);
- account = e_get_account_by_uid (uid);
- }
+ /* XXX This method is now only for fringe cases. For normal
+ * CamelService authentication, use authenticate_sync().
+ *
+ * The two known fringe cases that still need this are:
+ *
+ * 1) CamelSaslPOPB4SMTP, where the CamelService is an SMTP
+ * transport and the item name is always "popb4smtp_uid".
+ * (This is a dirty hack, Camel just needs some way to
+ * pair up a CamelService and CamelTransport. Not sure
+ * what that should look like just yet...)
+ *
+ * 2) CamelGpgContext, where the CamelService is NULL and
+ * the item name is a user ID (I think). (Seahorse, or
+ * one of its dependent libraries, ought to handle this
+ * transparently once Camel fully transitions to GIO.)
+ */
- if (!strcmp(item, "popb4smtp_uid")) {
- /* not 100% mt safe, but should be ok */
- ret = g_strdup ((account != NULL) ? account->uid : uid);
- } else {
- gchar *key = mail_session_make_key (service, item);
- EAccountService *config_service = NULL;
-
- ret = e_passwords_get_password (NULL, key);
- if (ret == NULL || (flags & CAMEL_SESSION_PASSWORD_REPROMPT)) {
- gboolean remember;
-
- g_free (ret);
- ret = NULL;
-
- if (account != NULL) {
- if (CAMEL_IS_STORE (service))
- config_service = account->source;
- if (CAMEL_IS_TRANSPORT (service))
- config_service = account->transport;
- }
+ registry = e_mail_session_get_registry (E_MAIL_SESSION (session));
- remember = config_service ? config_service->save_passwd : FALSE;
-
- if (!config_service || (config_service &&
- !config_service->get_password_canceled)) {
- guint32 eflags;
- gchar *title;
-
- if (flags & CAMEL_SESSION_PASSPHRASE) {
- if (display_name != NULL)
- title = g_strdup_printf (
- _("Enter Passphrase for %s"),
- display_name);
- else
- title = g_strdup (
- _("Enter Passphrase"));
- } else {
- if (display_name != NULL)
- title = g_strdup_printf (
- _("Enter Password for %s"),
- display_name);
- else
- title = g_strdup (
- _("Enter Password"));
- }
- if ((flags & CAMEL_SESSION_PASSWORD_STATIC) != 0)
- eflags = E_PASSWORDS_REMEMBER_NEVER;
- else if (config_service == NULL)
- eflags = E_PASSWORDS_REMEMBER_SESSION;
- else
- eflags = E_PASSWORDS_REMEMBER_FOREVER;
-
- if (flags & CAMEL_SESSION_PASSWORD_REPROMPT)
- eflags |= E_PASSWORDS_REPROMPT;
-
- if (flags & CAMEL_SESSION_PASSWORD_SECRET)
- eflags |= E_PASSWORDS_SECRET;
-
- if (flags & CAMEL_SESSION_PASSPHRASE)
- eflags |= E_PASSWORDS_PASSPHRASE;
-
- /* HACK: breaks abstraction ...
- * e_account_writable() doesn't use the
- * EAccount, it also uses the same writable
- * key for source and transport. */
- if (!e_account_writable (NULL, E_ACCOUNT_SOURCE_SAVE_PASSWD))
- eflags |= E_PASSWORDS_DISABLE_REMEMBER;
-
- ret = e_passwords_ask_password (
- title, NULL, key, prompt,
- eflags, &remember, NULL);
-
- if (!ret)
- e_passwords_forget_password (NULL, key);
-
- g_free (title);
-
- if (ret && config_service) {
- config_service->save_passwd = remember;
- e_account_list_save (e_get_account_list ());
- }
-
- if (config_service)
- config_service->get_password_canceled = ret == NULL;
- }
- }
+ /* Handle the CamelSaslPOPB4SMTP case. */
+ if (g_strcmp0 (item, "popb4smtp_uid") == 0)
+ return mail_session_resolve_popb4smtp (registry, service);
- g_free (key);
+ /* Otherwise this had better be the CamelGpgContext case. */
+ g_return_val_if_fail (service == NULL, NULL);
+
+ password = e_passwords_get_password (NULL, item);
+
+ if (password == NULL || (flags & CAMEL_SESSION_PASSWORD_REPROMPT)) {
+ gboolean remember;
+ guint eflags = 0;
+
+ if (flags & CAMEL_SESSION_PASSWORD_STATIC)
+ eflags |= E_PASSWORDS_REMEMBER_NEVER;
+ else
+ eflags |= E_PASSWORDS_REMEMBER_SESSION;
+
+ if (flags & CAMEL_SESSION_PASSWORD_REPROMPT)
+ eflags |= E_PASSWORDS_REPROMPT;
+
+ if (flags & CAMEL_SESSION_PASSWORD_SECRET)
+ eflags |= E_PASSWORDS_SECRET;
+
+ if (flags & CAMEL_SESSION_PASSPHRASE)
+ eflags |= E_PASSWORDS_PASSPHRASE;
+
+ password = e_passwords_ask_password (
+ "", NULL, item, prompt, eflags, &remember, NULL);
+
+ if (password == NULL)
+ e_passwords_forget_password (NULL, item);
}
- if (ret == NULL)
+ if (password == NULL)
g_set_error (
error, G_IO_ERROR,
G_IO_ERROR_CANCELLED,
- _("User canceled operation."));
+ _("User cancelled operation"));
- return ret;
+ return password;
}
static gboolean
@@ -1046,13 +1178,13 @@ mail_session_forget_password (CamelSession *session,
const gchar *item,
GError **error)
{
- gchar *key;
+ /* XXX The only remaining user of this method is CamelGpgContext,
+ * which does not provide a CamelService. Use 'item' as the
+ * password key. */
- key = mail_session_make_key (service, item);
+ g_return_val_if_fail (service == NULL, FALSE);
- e_passwords_forget_password (NULL, key);
-
- g_free (key);
+ e_passwords_forget_password (NULL, item);
return TRUE;
}
@@ -1112,16 +1244,19 @@ static gboolean
mail_session_lookup_addressbook (CamelSession *session,
const gchar *name)
{
+ ESourceRegistry *registry;
CamelInternetAddress *addr;
gboolean ret;
if (!mail_config_get_lookup_book ())
return FALSE;
+ registry = e_mail_session_get_registry (E_MAIL_SESSION (session));
+
addr = camel_internet_address_new ();
camel_address_decode ((CamelAddress *) addr, name);
ret = em_utils_in_addressbook (
- addr, mail_config_get_lookup_book_local_only ());
+ registry, addr, mail_config_get_lookup_book_local_only ());
g_object_unref (addr);
return ret;
@@ -1134,13 +1269,16 @@ mail_session_forward_to (CamelSession *session,
const gchar *address,
GError **error)
{
- EAccount *account;
+ ESource *source;
+ ESourceRegistry *registry;
+ ESourceMailIdentity *extension;
CamelMimeMessage *forward;
CamelStream *mem;
CamelInternetAddress *addr;
CamelFolder *out_folder;
CamelMessageInfo *info;
CamelMedium *medium;
+ const gchar *extension_name;
const gchar *from_address;
const gchar *from_name;
const gchar *header_name;
@@ -1154,22 +1292,27 @@ mail_session_forward_to (CamelSession *session,
if (!*address) {
g_set_error (
error, CAMEL_ERROR, CAMEL_ERROR_GENERIC,
- _("No destination address provided, forward "
+ _("No destination address provided, forwarding "
"of the message has been cancelled."));
return FALSE;
}
- account = em_utils_guess_account_with_recipients (message, folder);
- if (!account) {
+ registry = e_mail_session_get_registry (E_MAIL_SESSION (session));
+
+ source = em_utils_guess_mail_identity_with_recipients (
+ registry, message, folder);
+ if (source == NULL) {
g_set_error (
error, CAMEL_ERROR, CAMEL_ERROR_GENERIC,
- _("No account found to use, forward of the "
- "message has been cancelled."));
+ _("No identity found to use, forwarding "
+ "of the message has been cancelled."));
return FALSE;
}
- from_address = account->id->address;
- from_name = account->id->name;
+ extension_name = E_SOURCE_EXTENSION_MAIL_IDENTITY;
+ extension = e_source_get_extension (source, extension_name);
+ from_address = e_source_mail_identity_get_address (extension);
+ from_name = e_source_mail_identity_get_name (extension);
forward = camel_mime_message_new ();
@@ -1289,19 +1432,23 @@ mail_session_authenticate_sync (CamelSession *session,
GCancellable *cancellable,
GError **error)
{
+ ESource *source;
+ ESourceRegistry *registry;
+ ESourceAuthenticator *auth;
CamelServiceAuthType *authtype = NULL;
CamelAuthenticationResult result;
- CamelProvider *provider;
- CamelSettings *settings;
- const gchar *password;
- guint32 password_flags;
+ const gchar *uid;
+ gboolean authenticated;
GError *local_error = NULL;
/* Do not chain up. Camel's default method is only an example for
* subclasses to follow. Instead we mimic most of its logic here. */
- provider = camel_service_get_provider (service);
- settings = camel_service_get_settings (service);
+ registry = e_mail_session_get_registry (E_MAIL_SESSION (session));
+
+ /* Treat a mechanism name of "none" as NULL. */
+ if (g_strcmp0 (mechanism, "none") == 0)
+ mechanism = NULL;
/* APOP is one case where a non-SASL mechanism name is passed, so
* don't bail if the CamelServiceAuthType struct comes back NULL. */
@@ -1354,58 +1501,26 @@ mail_session_authenticate_sync (CamelSession *session,
g_clear_error (&local_error);
- password_flags = CAMEL_SESSION_PASSWORD_SECRET;
-
-retry:
- password = camel_service_get_password (service);
-
- if (password == NULL) {
- CamelNetworkSettings *network_settings;
- const gchar *host;
- const gchar *user;
- gchar *prompt;
- gchar *new_passwd;
-
- network_settings = CAMEL_NETWORK_SETTINGS (settings);
- host = camel_network_settings_get_host (network_settings);
- user = camel_network_settings_get_user (network_settings);
+ /* Find a matching ESource for this CamelService. */
+ uid = camel_service_get_uid (service);
+ source = e_source_registry_lookup_by_uid (registry, uid);
- prompt = camel_session_build_password_prompt (
- provider->name, user, host);
-
- new_passwd = camel_session_get_password (
- session, service, prompt, "password",
- password_flags, &local_error);
- camel_service_set_password (service, new_passwd);
- password = camel_service_get_password (service);
- g_free (new_passwd);
-
- g_free (prompt);
-
- if (local_error != NULL) {
- g_propagate_error (error, local_error);
- return FALSE;
- }
-
- if (password == NULL) {
- g_set_error (
- error, CAMEL_SERVICE_ERROR,
- CAMEL_SERVICE_ERROR_CANT_AUTHENTICATE,
- _("No password was provided"));
- return FALSE;
- }
+ if (source == NULL) {
+ g_set_error (
+ error, CAMEL_SERVICE_ERROR,
+ CAMEL_SERVICE_ERROR_CANT_AUTHENTICATE,
+ _("No data source found for UID '%s'"), uid);
+ return FALSE;
}
- result = camel_service_authenticate_sync (
- service, mechanism, cancellable, error);
+ auth = e_mail_authenticator_new (service, mechanism);
- if (result == CAMEL_AUTHENTICATION_REJECTED) {
- password_flags |= CAMEL_SESSION_PASSWORD_REPROMPT;
- camel_service_set_password (service, NULL);
- goto retry;
- }
+ authenticated = e_source_registry_authenticate_sync (
+ registry, source, auth, cancellable, error);
+
+ g_object_unref (auth);
- return (result == CAMEL_AUTHENTICATION_ACCEPTED);
+ return authenticated;
}
static EMVFolderContext *
@@ -1481,6 +1596,18 @@ e_mail_session_class_init (EMailSessionClass *class)
g_object_class_install_property (
object_class,
+ PROP_REGISTRY,
+ g_param_spec_object (
+ "registry",
+ "Registry",
+ "Data source registry",
+ E_TYPE_SOURCE_REGISTRY,
+ G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT_ONLY |
+ G_PARAM_STATIC_STRINGS));
+
+ g_object_class_install_property (
+ object_class,
PROP_VFOLDER_STORE,
g_param_spec_object (
"vfolder-store",
@@ -1500,15 +1627,32 @@ e_mail_session_class_init (EMailSessionClass *class)
"flush-outbox",
G_OBJECT_CLASS_TYPE (object_class),
G_SIGNAL_RUN_FIRST,
- 0, /* struct offset */
- NULL, NULL, /* accumulator */
+ G_STRUCT_OFFSET (EMailSessionClass, flush_outbox),
+ NULL, NULL,
g_cclosure_marshal_VOID__VOID,
G_TYPE_NONE, 0);
/**
+ * EMailSession::refresh-service
+ * @session: the #EMailSession that emitted the signal
+ * @service: a #CamelService
+ *
+ * Emitted when @service should be refreshed.
+ **/
+ signals[REFRESH_SERVICE] = g_signal_new (
+ "refresh-service",
+ G_OBJECT_CLASS_TYPE (object_class),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (EMailSessionClass, refresh_service),
+ NULL, NULL,
+ g_cclosure_marshal_VOID__OBJECT,
+ G_TYPE_NONE, 1,
+ CAMEL_TYPE_SERVICE);
+
+ /**
* EMailSession::store-added
- * @session: the email session
- * @store: the CamelStore
+ * @session: the #EMailSession that emitted the signal
+ * @store: a #CamelStore
*
* Emitted when a store is added
**/
@@ -1516,16 +1660,16 @@ e_mail_session_class_init (EMailSessionClass *class)
"store-added",
G_OBJECT_CLASS_TYPE (object_class),
G_SIGNAL_RUN_FIRST,
- 0, /* struct offset */
- NULL, NULL, /* accumulator */
+ G_STRUCT_OFFSET (EMailSessionClass, store_added),
+ NULL, NULL,
g_cclosure_marshal_VOID__OBJECT,
G_TYPE_NONE, 1,
CAMEL_TYPE_STORE);
/**
* EMailSession::store-removed
- * @session: the email session
- * @store: the CamelStore
+ * @session: the #EMailSession that emitted the signal
+ * @store: a #CamelStore
*
* Emitted when a store is removed
**/
@@ -1533,26 +1677,38 @@ e_mail_session_class_init (EMailSessionClass *class)
"store-removed",
G_OBJECT_CLASS_TYPE (object_class),
G_SIGNAL_RUN_FIRST,
- 0, /* struct offset */
- NULL, NULL, /* accumulator */
+ G_STRUCT_OFFSET (EMailSessionClass, store_removed),
+ NULL, NULL,
g_cclosure_marshal_VOID__OBJECT,
G_TYPE_NONE, 1,
CAMEL_TYPE_STORE);
camel_null_store_register_provider ();
+
+ /* Make sure ESourceCamel picks up the "none" provider. */
+ e_source_camel_register_types ();
}
static void
e_mail_session_init (EMailSession *session)
{
GSettings *settings;
+ GHashTable *auto_refresh_table;
GHashTable *junk_filters;
+ auto_refresh_table = g_hash_table_new_full (
+ (GHashFunc) g_str_hash,
+ (GEqualFunc) g_str_equal,
+ (GDestroyNotify) g_free,
+ (GDestroyNotify) NULL);
+
junk_filters = g_hash_table_new (
(GHashFunc) g_str_hash,
(GEqualFunc) g_str_equal);
session->priv = E_MAIL_SESSION_GET_PRIVATE (session);
+ session->priv->folder_cache = mail_folder_cache_new (session);
+ session->priv->auto_refresh_table = auto_refresh_table;
session->priv->junk_filters = junk_filters;
session->priv->proxy = e_proxy_new ();
@@ -1563,9 +1719,6 @@ e_mail_session_init (EMailSession *session)
g_ptr_array_new_with_free_func (
(GDestroyNotify) g_free);
- /* Initialize the EAccount setup. */
- e_account_writable (NULL, E_ACCOUNT_SOURCE_SAVE_PASSWD);
-
settings = g_settings_new ("org.gnome.evolution.mail");
camel_session_set_check_junk (
@@ -1583,11 +1736,13 @@ e_mail_session_init (EMailSession *session)
}
EMailSession *
-e_mail_session_new (void)
+e_mail_session_new (ESourceRegistry *registry)
{
const gchar *user_data_dir;
const gchar *user_cache_dir;
+ g_return_val_if_fail (E_IS_SOURCE_REGISTRY (registry), NULL);
+
user_data_dir = mail_session_get_data_dir ();
user_cache_dir = mail_session_get_cache_dir ();
@@ -1595,9 +1750,18 @@ e_mail_session_new (void)
E_TYPE_MAIL_SESSION,
"user-data-dir", user_data_dir,
"user-cache-dir", user_cache_dir,
+ "registry", registry,
NULL);
}
+ESourceRegistry *
+e_mail_session_get_registry (EMailSession *session)
+{
+ g_return_val_if_fail (E_IS_MAIL_SESSION (session), NULL);
+
+ return session->priv->registry;
+}
+
MailFolderCache *
e_mail_session_get_folder_cache (EMailSession *session)
{
@@ -1987,6 +2151,66 @@ e_mail_session_uri_to_folder_finish (EMailSession *session,
return g_object_ref (context->folder);
}
+gboolean
+e_binding_transform_service_to_source (GBinding *binding,
+ const GValue *source_value,
+ GValue *target_value,
+ gpointer session)
+{
+ CamelService *service;
+ ESourceRegistry *registry;
+ ESource *source;
+ const gchar *uid;
+
+ g_return_val_if_fail (G_IS_BINDING (binding), FALSE);
+ g_return_val_if_fail (E_IS_MAIL_SESSION (session), FALSE);
+
+ service = g_value_get_object (source_value);
+
+ if (!CAMEL_IS_SERVICE (service))
+ return FALSE;
+
+ uid = camel_service_get_uid (service);
+ registry = e_mail_session_get_registry (session);
+ source = e_source_registry_lookup_by_uid (registry, uid);
+
+ if (!E_IS_SOURCE (source))
+ return FALSE;
+
+ g_value_set_object (target_value, source);
+
+ return TRUE;
+}
+
+gboolean
+e_binding_transform_source_to_service (GBinding *binding,
+ const GValue *source_value,
+ GValue *target_value,
+ gpointer session)
+{
+ CamelService *service;
+ ESource *source;
+ const gchar *uid;
+
+ g_return_val_if_fail (G_IS_BINDING (binding), FALSE);
+ g_return_val_if_fail (E_IS_MAIL_SESSION (session), FALSE);
+
+ source = g_value_get_object (source_value);
+
+ if (!E_IS_SOURCE (source))
+ return FALSE;
+
+ uid = e_source_get_uid (source);
+ service = camel_session_get_service (session, uid);
+
+ if (!CAMEL_IS_SERVICE (service))
+ return FALSE;
+
+ g_value_set_object (target_value, service);
+
+ return TRUE;
+}
+
/******************************** Legacy API *********************************/
void
diff --git a/libemail-engine/e-mail-session.h b/libemail-engine/e-mail-session.h
index 16a6592..bf436c7 100644
--- a/libemail-engine/e-mail-session.h
+++ b/libemail-engine/e-mail-session.h
@@ -26,6 +26,7 @@
#define E_MAIL_SESSION_H
#include <camel/camel.h>
+#include <libedataserver/e-source-registry.h>
#include <libemail-engine/e-mail-enums.h>
#include <libemail-engine/mail-folder-cache.h>
#include <libemail-utils/em-vfolder-context.h>
@@ -67,12 +68,22 @@ struct _EMailSession {
struct _EMailSessionClass {
CamelSessionClass parent_class;
- EMVFolderContext * (*create_vfolder_context) (EMailSession *session);
-
+ EMVFolderContext *
+ (*create_vfolder_context)
+ (EMailSession *session);
+ void (*flush_outbox) (EMailSession *session);
+ void (*refresh_service) (EMailSession *session,
+ CamelService *service);
+ void (*store_added) (EMailSession *session,
+ CamelStore *store);
+ void (*store_removed) (EMailSession *session,
+ CamelStore *store);
};
GType e_mail_session_get_type (void);
-EMailSession * e_mail_session_new (void);
+EMailSession * e_mail_session_new (ESourceRegistry *registry);
+ESourceRegistry *
+ e_mail_session_get_registry (EMailSession *session);
MailFolderCache *
e_mail_session_get_folder_cache (EMailSession *session);
CamelStore * e_mail_session_get_local_store (EMailSession *session);
@@ -131,6 +142,19 @@ CamelFolder * e_mail_session_uri_to_folder_finish
EMVFolderContext *
e_mail_session_create_vfolder_context
(EMailSession *session);
+
+/* Useful GBinding transform functions */
+gboolean e_binding_transform_service_to_source
+ (GBinding *binding,
+ const GValue *source_value,
+ GValue *target_value,
+ gpointer session);
+gboolean e_binding_transform_source_to_service
+ (GBinding *binding,
+ const GValue *source_value,
+ GValue *target_value,
+ gpointer session);
+
/*** Legacy API ***/
void mail_session_flush_filter_log (EMailSession *session);
diff --git a/libemail-engine/e-mail-utils.c b/libemail-engine/e-mail-utils.c
index af861ca..0004d79 100644
--- a/libemail-engine/e-mail-utils.c
+++ b/libemail-engine/e-mail-utils.c
@@ -46,9 +46,14 @@
#include <libedataserver/e-data-server-util.h>
#include <libedataserver/e-flag.h>
#include <libedataserver/e-proxy.h>
+#include <libedataserver/e-source-address-book.h>
+#include <libedataserver/e-source-autocomplete.h>
+#include <libedataserver/e-source-mail-account.h>
+#include <libedataserver/e-source-mail-composition.h>
+#include <libedataserver/e-source-mail-identity.h>
+#include <libedataserver/e-source-mail-submission.h>
-#include "libemail-utils/e-account-utils.h"
-#include "libemail-utils/mail-mt.h"
+#include <libemail-utils/mail-mt.h>
#include "e-mail-folder-utils.h"
#include "e-mail-session.h"
@@ -58,120 +63,141 @@
#define d(x)
/**
- * em_utils_folder_is_templates:
+ * em_utils_folder_is_drafts:
+ * @registry: an #ESourceRegistry
* @folder: a #CamelFolder
*
- * Decides if @folder is a Templates folder.
+ * Decides if @folder is a Drafts folder.
*
- * Returns %TRUE if this is a Templates folder or %FALSE otherwise.
+ * Returns %TRUE if this is a Drafts folder or %FALSE otherwise.
**/
-
gboolean
-em_utils_folder_is_templates (CamelFolder *folder)
+em_utils_folder_is_drafts (ESourceRegistry *registry,
+ CamelFolder *folder)
{
- CamelFolder *local_templates_folder;
+ CamelFolder *local_drafts_folder;
CamelSession *session;
CamelStore *store;
- EAccountList *account_list;
- EIterator *iterator;
+ GList *list, *iter;
gchar *folder_uri;
- gboolean is_templates = FALSE;
+ gboolean is_drafts = FALSE;
+ const gchar *extension_name;
g_return_val_if_fail (CAMEL_IS_FOLDER (folder), FALSE);
store = camel_folder_get_parent_store (folder);
session = camel_service_get_session (CAMEL_SERVICE (store));
- local_templates_folder =
+ local_drafts_folder =
e_mail_session_get_local_folder (
- E_MAIL_SESSION (session), E_MAIL_LOCAL_FOLDER_TEMPLATES);
+ E_MAIL_SESSION (session), E_MAIL_LOCAL_FOLDER_DRAFTS);
- if (folder == local_templates_folder)
+ if (folder == local_drafts_folder)
return TRUE;
folder_uri = e_mail_folder_uri_from_folder (folder);
- account_list = e_get_account_list ();
- iterator = e_list_get_iterator (E_LIST (account_list));
+ store = camel_folder_get_parent_store (folder);
+ session = camel_service_get_session (CAMEL_SERVICE (store));
- while (!is_templates && e_iterator_is_valid (iterator)) {
- EAccount *account;
+ extension_name = E_SOURCE_EXTENSION_MAIL_COMPOSITION;
+ list = e_source_registry_list_sources (registry, extension_name);
- /* XXX EIterator misuses const. */
- account = (EAccount *) e_iterator_get (iterator);
+ for (iter = list; iter != NULL; iter = g_list_next (iter)) {
+ ESource *source = E_SOURCE (iter->data);
+ ESourceExtension *extension;
+ const gchar *drafts_folder_uri;
- if (account->templates_folder_uri != NULL)
- is_templates = e_mail_folder_uri_equal (
- session, folder_uri,
- account->templates_folder_uri);
+ extension = e_source_get_extension (source, extension_name);
- e_iterator_next (iterator);
+ drafts_folder_uri =
+ e_source_mail_composition_get_drafts_folder (
+ E_SOURCE_MAIL_COMPOSITION (extension));
+
+ if (drafts_folder_uri != NULL)
+ is_drafts = e_mail_folder_uri_equal (
+ session, folder_uri, drafts_folder_uri);
+
+ if (is_drafts)
+ break;
}
- g_object_unref (iterator);
+ g_list_free (list);
g_free (folder_uri);
- return is_templates;
+ return is_drafts;
}
/**
- * em_utils_folder_is_drafts:
+ * em_utils_folder_is_templates:
+ * @registry: an #ESourceRegistry
* @folder: a #CamelFolder
*
- * Decides if @folder is a Drafts folder.
+ * Decides if @folder is a Templates folder.
*
- * Returns %TRUE if this is a Drafts folder or %FALSE otherwise.
+ * Returns %TRUE if this is a Templates folder or %FALSE otherwise.
**/
+
gboolean
-em_utils_folder_is_drafts (CamelFolder *folder)
+em_utils_folder_is_templates (ESourceRegistry *registry,
+ CamelFolder *folder)
{
- CamelFolder *local_drafts_folder;
+ CamelFolder *local_templates_folder;
CamelSession *session;
CamelStore *store;
- EAccountList *account_list;
- EIterator *iterator;
+ GList *list, *iter;
gchar *folder_uri;
- gboolean is_drafts = FALSE;
+ gboolean is_templates = FALSE;
+ const gchar *extension_name;
g_return_val_if_fail (CAMEL_IS_FOLDER (folder), FALSE);
store = camel_folder_get_parent_store (folder);
session = camel_service_get_session (CAMEL_SERVICE (store));
- local_drafts_folder =
+ local_templates_folder =
e_mail_session_get_local_folder (
- E_MAIL_SESSION (session), E_MAIL_LOCAL_FOLDER_DRAFTS);
+ E_MAIL_SESSION (session), E_MAIL_LOCAL_FOLDER_TEMPLATES);
- if (folder == local_drafts_folder)
+ if (folder == local_templates_folder)
return TRUE;
folder_uri = e_mail_folder_uri_from_folder (folder);
- account_list = e_get_account_list ();
- iterator = e_list_get_iterator (E_LIST (account_list));
+ store = camel_folder_get_parent_store (folder);
+ session = camel_service_get_session (CAMEL_SERVICE (store));
+
+ extension_name = E_SOURCE_EXTENSION_MAIL_COMPOSITION;
+ list = e_source_registry_list_sources (registry, extension_name);
- while (!is_drafts && e_iterator_is_valid (iterator)) {
- EAccount *account;
+ for (iter = list; iter != NULL; iter = g_list_next (iter)) {
+ ESource *source = E_SOURCE (iter->data);
+ ESourceExtension *extension;
+ const gchar *templates_folder_uri;
- /* XXX EIterator misuses const. */
- account = (EAccount *) e_iterator_get (iterator);
+ extension = e_source_get_extension (source, extension_name);
- if (account->drafts_folder_uri != NULL)
- is_drafts = e_mail_folder_uri_equal (
- session, folder_uri,
- account->drafts_folder_uri);
+ templates_folder_uri =
+ e_source_mail_composition_get_templates_folder (
+ E_SOURCE_MAIL_COMPOSITION (extension));
- e_iterator_next (iterator);
+ if (templates_folder_uri != NULL)
+ is_templates = e_mail_folder_uri_equal (
+ session, folder_uri, templates_folder_uri);
+
+ if (is_templates)
+ break;
}
- g_object_unref (iterator);
+ g_list_free (list);
g_free (folder_uri);
- return is_drafts;
+ return is_templates;
}
/**
* em_utils_folder_is_sent:
+ * @registry: an #ESourceRegistry
* @folder: a #CamelFolder
*
* Decides if @folder is a Sent folder.
@@ -179,15 +205,16 @@ em_utils_folder_is_drafts (CamelFolder *folder)
* Returns %TRUE if this is a Sent folder or %FALSE otherwise.
**/
gboolean
-em_utils_folder_is_sent (CamelFolder *folder)
+em_utils_folder_is_sent (ESourceRegistry *registry,
+ CamelFolder *folder)
{
CamelFolder *local_sent_folder;
CamelSession *session;
CamelStore *store;
- EAccountList *account_list;
- EIterator *iterator;
+ GList *list, *iter;
gchar *folder_uri;
gboolean is_sent = FALSE;
+ const gchar *extension_name;
g_return_val_if_fail (CAMEL_IS_FOLDER (folder), FALSE);
@@ -203,24 +230,32 @@ em_utils_folder_is_sent (CamelFolder *folder)
folder_uri = e_mail_folder_uri_from_folder (folder);
- account_list = e_get_account_list ();
- iterator = e_list_get_iterator (E_LIST (account_list));
+ store = camel_folder_get_parent_store (folder);
+ session = camel_service_get_session (CAMEL_SERVICE (store));
+
+ extension_name = E_SOURCE_EXTENSION_MAIL_SUBMISSION;
+ list = e_source_registry_list_sources (registry, extension_name);
- while (!is_sent && e_iterator_is_valid (iterator)) {
- EAccount *account;
+ for (iter = list; iter != NULL; iter = g_list_next (iter)) {
+ ESource *source = E_SOURCE (iter->data);
+ ESourceExtension *extension;
+ const gchar *sent_folder_uri;
- /* XXX EIterator misuses const. */
- account = (EAccount *) e_iterator_get (iterator);
+ extension = e_source_get_extension (source, extension_name);
- if (account->sent_folder_uri != NULL)
+ sent_folder_uri =
+ e_source_mail_submission_get_sent_folder (
+ E_SOURCE_MAIL_SUBMISSION (extension));
+
+ if (sent_folder_uri != NULL)
is_sent = e_mail_folder_uri_equal (
- session, folder_uri,
- account->sent_folder_uri);
+ session, folder_uri, sent_folder_uri);
- e_iterator_next (iterator);
+ if (is_sent)
+ break;
}
- g_object_unref (iterator);
+ g_list_free (list);
g_free (folder_uri);
return is_sent;
@@ -228,6 +263,7 @@ em_utils_folder_is_sent (CamelFolder *folder)
/**
* em_utils_folder_is_outbox:
+ * @registry: an #ESourceRegistry
* @folder: a #CamelFolder
*
* Decides if @folder is an Outbox folder.
@@ -235,7 +271,8 @@ em_utils_folder_is_sent (CamelFolder *folder)
* Returns %TRUE if this is an Outbox folder or %FALSE otherwise.
**/
gboolean
-em_utils_folder_is_outbox (CamelFolder *folder)
+em_utils_folder_is_outbox (ESourceRegistry *registry,
+ CamelFolder *folder)
{
CamelStore *store;
CamelSession *session;
@@ -255,19 +292,6 @@ em_utils_folder_is_outbox (CamelFolder *folder)
/* ********************************************************************** */
-/* runs sync, in main thread */
-static gpointer
-emu_addr_setup (gpointer user_data)
-{
- GError *err = NULL;
- ESourceList **psource_list = user_data;
-
- if (!e_book_client_get_sources (psource_list, &err))
- g_error_free (err);
-
- return NULL;
-}
-
static void
emu_addr_cancel_stop (gpointer data)
{
@@ -383,33 +407,31 @@ static GHashTable *emu_books_hash = NULL;
* broken books, which failed to open for some reason */
static GHashTable *emu_broken_books_hash = NULL;
-static ESourceList *emu_books_source_list = NULL;
-
static gboolean
-search_address_in_addressbooks (const gchar *address,
+search_address_in_addressbooks (ESourceRegistry *registry,
+ const gchar *address,
gboolean local_only,
gboolean (*check_contact) (EContact *contact,
gpointer user_data),
gpointer user_data)
{
+ GList *list, *link;
+ GList *addr_sources = NULL;
gboolean found = FALSE, stop = FALSE, found_any = FALSE;
gchar *lowercase_addr;
gpointer ptr;
EBookQuery *book_query;
gchar *query;
- GSList *s, *g, *addr_sources = NULL;
GHook *hook_cancellable;
GCancellable *cancellable;
+ const gchar *extension_name;
if (!address || !*address)
return FALSE;
G_LOCK (contact_cache);
- if (!emu_books_source_list) {
- mail_call_main (
- MAIL_CALL_p_p, (MailMainFunc)
- emu_addr_setup, &emu_books_source_list);
+ if (emu_books_hash == NULL) {
emu_books_hash = g_hash_table_new_full (
g_str_hash, g_str_equal, g_free, g_object_unref);
emu_broken_books_hash = g_hash_table_new_full (
@@ -418,11 +440,6 @@ search_address_in_addressbooks (const gchar *address,
g_str_hash, g_str_equal, g_free, NULL);
}
- if (!emu_books_source_list) {
- G_UNLOCK (contact_cache);
- return FALSE;
- }
-
lowercase_addr = g_utf8_strdown (address, -1);
ptr = g_hash_table_lookup (contact_cache, lowercase_addr);
if (ptr != NULL && (check_contact == NULL || ptr == NOT_FOUND_BOOK)) {
@@ -435,35 +452,48 @@ search_address_in_addressbooks (const gchar *address,
query = e_book_query_to_string (book_query);
e_book_query_unref (book_query);
- for (g = e_source_list_peek_groups (emu_books_source_list);
- g; g = g_slist_next (g)) {
- ESourceGroup *group = g->data;
+ extension_name = E_SOURCE_EXTENSION_ADDRESS_BOOK;
+ list = e_source_registry_list_sources (registry, extension_name);
- if (!group)
- continue;
+ for (link = list; link != NULL; link = g_list_next (link)) {
+ ESource *source = E_SOURCE (link->data);
+ ESourceExtension *extension;
+ const gchar *backend_name;
+ gboolean source_is_local;
+ gboolean autocomplete;
+
+ extension_name = E_SOURCE_EXTENSION_ADDRESS_BOOK;
+ extension = e_source_get_extension (source, extension_name);
+
+ backend_name = e_source_backend_get_backend_name (
+ E_SOURCE_BACKEND (extension));
- if (local_only && !(e_source_group_peek_base_uri (group) &&
- g_str_has_prefix (
- e_source_group_peek_base_uri (group), "local:")))
+ source_is_local = (g_strcmp0 (backend_name, "local") == 0);
+
+ if (local_only && !source_is_local)
continue;
- for (s = e_source_group_peek_sources (group); s; s = g_slist_next (s)) {
- ESource *source = s->data;
- const gchar *completion = e_source_get_property (source, "completion");
+ extension_name = E_SOURCE_EXTENSION_AUTOCOMPLETE;
+ extension = e_source_get_extension (source, extension_name);
- if (completion && g_ascii_strcasecmp (completion, "true") == 0) {
- addr_sources = g_slist_prepend (
- addr_sources, g_object_ref (source));
- }
- }
+ autocomplete = e_source_autocomplete_get_include_me (
+ E_SOURCE_AUTOCOMPLETE (extension));
+
+ if (!autocomplete)
+ continue;
+
+ addr_sources = g_list_prepend (
+ addr_sources, g_object_ref (source));
}
+ g_list_free (list);
+
cancellable = g_cancellable_new ();
hook_cancellable = mail_cancel_hook_add (
emu_addr_cancel_cancellable, cancellable);
- for (s = addr_sources; !stop && !found && s; s = g_slist_next (s)) {
- ESource *source = s->data;
+ for (link = addr_sources; !stop && !found && link != NULL; link = g_list_next (link)) {
+ ESource *source = E_SOURCE (link->data);
GSList *contacts;
EBookClient *book_client = NULL;
GHook *hook_stop;
@@ -472,8 +502,8 @@ search_address_in_addressbooks (const gchar *address,
const gchar *uid;
GError *err = NULL;
- uid = e_source_peek_uid (source);
- display_name = e_source_peek_name (source);
+ uid = e_source_get_uid (source);
+ display_name = e_source_get_display_name (source);
/* failed to load this book last time, skip it now */
if (g_hash_table_lookup (emu_broken_books_hash, uid) != NULL) {
@@ -598,7 +628,7 @@ search_address_in_addressbooks (const gchar *address,
mail_cancel_hook_remove (hook_cancellable);
g_object_unref (cancellable);
- g_slist_free_full (addr_sources, (GDestroyNotify) g_object_unref);
+ g_list_free_full (addr_sources, (GDestroyNotify) g_object_unref);
g_free (query);
@@ -615,16 +645,20 @@ search_address_in_addressbooks (const gchar *address,
}
gboolean
-em_utils_in_addressbook (CamelInternetAddress *iaddr,
+em_utils_in_addressbook (ESourceRegistry *registry,
+ CamelInternetAddress *iaddr,
gboolean local_only)
{
const gchar *addr;
+ g_return_val_if_fail (E_IS_SOURCE_REGISTRY (registry), FALSE);
+
/* TODO: check all addresses? */
if (iaddr == NULL || !camel_internet_address_get (iaddr, 0, NULL, &addr))
return FALSE;
- return search_address_in_addressbooks (addr, local_only, NULL, NULL);
+ return search_address_in_addressbooks (
+ registry, addr, local_only, NULL, NULL);
}
static gboolean
@@ -665,7 +699,8 @@ G_LOCK_DEFINE_STATIC (photos_cache);
static GSList *photos_cache = NULL; /* list of PhotoInfo-s */
CamelMimePart *
-em_utils_contact_photo (CamelInternetAddress *cia,
+em_utils_contact_photo (ESourceRegistry *registry,
+ CamelInternetAddress *cia,
gboolean local_only)
{
const gchar *addr = NULL;
@@ -674,6 +709,8 @@ em_utils_contact_photo (CamelInternetAddress *cia,
GSList *p, *first_not_null = NULL;
gint count_not_null = 0;
+ g_return_val_if_fail (E_IS_SOURCE_REGISTRY (registry), NULL);
+
if (cia == NULL || !camel_internet_address_get (cia, 0, NULL, &addr) || !addr) {
return NULL;
}
@@ -701,7 +738,8 @@ em_utils_contact_photo (CamelInternetAddress *cia,
/* !p means the address had not been found in the cache */
if (!p && search_address_in_addressbooks (
- addr, local_only, extract_photo_data, &photo)) {
+ registry, addr, local_only, extract_photo_data, &photo)) {
+
PhotoInfo *pi;
if (photo && photo->type != E_CONTACT_PHOTO_TYPE_INLINED) {
@@ -815,11 +853,6 @@ emu_free_mail_cache (void)
emu_broken_books_hash = NULL;
}
- if (emu_books_source_list) {
- g_object_unref (emu_books_source_list);
- emu_books_source_list = NULL;
- }
-
if (contact_cache) {
g_hash_table_destroy (contact_cache);
contact_cache = NULL;
@@ -836,70 +869,164 @@ emu_free_mail_cache (void)
G_UNLOCK (photos_cache);
}
-static EAccount *
-guess_account_from_folder (CamelFolder *folder)
+static ESource *
+guess_mail_account_from_folder (ESourceRegistry *registry,
+ CamelFolder *folder)
{
+ ESource *source;
CamelStore *store;
const gchar *uid;
+ /* Lookup an ESource by CamelStore UID. */
store = camel_folder_get_parent_store (folder);
uid = camel_service_get_uid (CAMEL_SERVICE (store));
+ source = e_source_registry_lookup_by_uid (registry, uid);
+
+ /* If we found an ESource, make sure it's a mail account. */
+ if (source != NULL) {
+ const gchar *extension_name;
+
+ extension_name = E_SOURCE_EXTENSION_MAIL_ACCOUNT;
+ if (!e_source_has_extension (source, extension_name))
+ source = NULL;
+ }
- return e_get_account_by_uid (uid);
+ return source;
}
-static EAccount *
-guess_account_from_message (CamelMimeMessage *message)
+static ESource *
+guess_mail_account_from_message (ESourceRegistry *registry,
+ CamelMimeMessage *message)
{
+ ESource *source = NULL;
const gchar *uid;
+ /* Lookup an ESource by 'X-Evolution-Source' header. */
uid = camel_mime_message_get_source (message);
+ if (uid != NULL)
+ source = e_source_registry_lookup_by_uid (registry, uid);
+
+ /* If we found an ESource, make sure it's a mail account. */
+ if (source != NULL) {
+ const gchar *extension_name;
- return (uid != NULL) ? e_get_account_by_uid (uid) : NULL;
+ extension_name = E_SOURCE_EXTENSION_MAIL_ACCOUNT;
+ if (!e_source_has_extension (source, extension_name))
+ source = NULL;
+ }
+
+ return source;
}
-EAccount *
-em_utils_guess_account (CamelMimeMessage *message,
- CamelFolder *folder)
+ESource *
+em_utils_guess_mail_account (ESourceRegistry *registry,
+ CamelMimeMessage *message,
+ CamelFolder *folder)
{
- EAccount *account = NULL;
+ ESource *source = NULL;
+ const gchar *newsgroups;
+ g_return_val_if_fail (E_IS_SOURCE_REGISTRY (registry), NULL);
g_return_val_if_fail (CAMEL_IS_MIME_MESSAGE (message), NULL);
if (folder != NULL)
g_return_val_if_fail (CAMEL_IS_FOLDER (folder), NULL);
/* check for newsgroup header */
- if (folder != NULL
- && camel_medium_get_header (CAMEL_MEDIUM (message), "Newsgroups"))
- account = guess_account_from_folder (folder);
+ newsgroups = camel_medium_get_header (
+ CAMEL_MEDIUM (message), "Newsgroups");
+ if (folder != NULL && newsgroups != NULL)
+ source = guess_mail_account_from_folder (registry, folder);
/* check for source folder */
- if (account == NULL && folder != NULL)
- account = guess_account_from_folder (folder);
+ if (source == NULL && folder != NULL)
+ source = guess_mail_account_from_folder (registry, folder);
/* then message source */
- if (account == NULL)
- account = guess_account_from_message (message);
+ if (source == NULL)
+ source = guess_mail_account_from_message (registry, message);
+
+ return source;
+}
+
+ESource *
+em_utils_guess_mail_identity (ESourceRegistry *registry,
+ CamelMimeMessage *message,
+ CamelFolder *folder)
+{
+ ESource *source;
+ ESourceExtension *extension;
+ const gchar *extension_name;
+
+ g_return_val_if_fail (E_IS_SOURCE_REGISTRY (registry), NULL);
+ g_return_val_if_fail (CAMEL_IS_MIME_MESSAGE (message), NULL);
+
+ if (folder != NULL)
+ g_return_val_if_fail (CAMEL_IS_FOLDER (folder), NULL);
+
+ source = em_utils_guess_mail_account (registry, message, folder);
+
+ if (source == NULL)
+ return NULL;
+
+ extension_name = E_SOURCE_EXTENSION_MAIL_ACCOUNT;
+ extension = e_source_get_extension (source, extension_name);
+
+ return e_source_mail_account_get_identity (
+ E_SOURCE_MAIL_ACCOUNT (extension));
+}
+
+static gboolean
+mail_account_in_recipients (ESourceRegistry *registry,
+ ESource *source,
+ GHashTable *recipients)
+{
+ ESourceExtension *extension;
+ const gchar *extension_name;
+ const gchar *address;
+
+ /* Disregard disabled mail accounts. */
+ if (!e_source_get_enabled (source))
+ return FALSE;
+
+ extension_name = E_SOURCE_EXTENSION_MAIL_ACCOUNT;
+ extension = e_source_get_extension (source, extension_name);
- return account;
+ source = e_source_mail_account_get_identity (
+ E_SOURCE_MAIL_ACCOUNT (extension));
+
+ if (source == NULL)
+ return FALSE;
+
+ extension_name = E_SOURCE_EXTENSION_MAIL_IDENTITY;
+ extension = e_source_get_extension (source, extension_name);
+
+ address = e_source_mail_identity_get_address (
+ E_SOURCE_MAIL_IDENTITY (extension));
+
+ if (address == NULL)
+ return FALSE;
+
+ return (g_hash_table_lookup (recipients, address) != NULL);
}
-EAccount *
-em_utils_guess_account_with_recipients (CamelMimeMessage *message,
- CamelFolder *folder)
+ESource *
+em_utils_guess_mail_account_with_recipients (ESourceRegistry *registry,
+ CamelMimeMessage *message,
+ CamelFolder *folder)
{
- EAccount *account = NULL;
- EAccountList *account_list;
+ ESource *source = NULL;
GHashTable *recipients;
- EIterator *iterator;
CamelInternetAddress *addr;
+ GList *list, *iter;
+ const gchar *extension_name;
const gchar *type;
const gchar *key;
/* This policy is subject to debate and tweaking,
* but please also document the rational here. */
+ g_return_val_if_fail (E_IS_SOURCE_REGISTRY (registry), NULL);
g_return_val_if_fail (CAMEL_IS_MIME_MESSAGE (message), NULL);
/* Build a set of email addresses in which to test for membership.
@@ -929,53 +1056,128 @@ em_utils_guess_account_with_recipients (CamelMimeMessage *message,
}
/* First Preference: We were given a folder that maps to an
- * enabled account, and that account's email address appears
+ * enabled mail account, and that account's address appears
* in the list of To: or Cc: recipients. */
if (folder != NULL)
- account = guess_account_from_folder (folder);
+ source = guess_mail_account_from_folder (registry, folder);
- if (account == NULL || !account->enabled)
+ if (source == NULL)
goto second_preference;
- if ((key = account->id->address) == NULL)
- goto second_preference;
-
- if (g_hash_table_lookup (recipients, key) != NULL)
+ if (mail_account_in_recipients (registry, source, recipients))
goto exit;
second_preference:
- /* Second Preference: Choose any enabled account whose email
+ /* Second Preference: Choose any enabled mail account whose
* address appears in the list to To: or Cc: recipients. */
- account_list = e_get_account_list ();
- iterator = e_list_get_iterator (E_LIST (account_list));
+ source = NULL;
- while (e_iterator_is_valid (iterator)) {
- account = (EAccount *) e_iterator_get (iterator);
- e_iterator_next (iterator);
+ extension_name = E_SOURCE_EXTENSION_MAIL_ACCOUNT;
+ list = e_source_registry_list_sources (registry, extension_name);
- if (account == NULL || !account->enabled)
- continue;
+ for (iter = list; iter != NULL; iter = g_list_next (iter)) {
+ ESource *temp = E_SOURCE (iter->data);
- if ((key = account->id->address) == NULL)
- continue;
-
- if (g_hash_table_lookup (recipients, key) != NULL) {
- g_object_unref (iterator);
- goto exit;
+ if (mail_account_in_recipients (registry, temp, recipients)) {
+ source = temp;
+ break;
}
}
- g_object_unref (iterator);
- /* Last Preference: Defer to em_utils_guess_account(). */
- account = em_utils_guess_account (message, folder);
+ g_list_free (list);
+
+ if (source != NULL)
+ goto exit;
+
+ /* Last Preference: Defer to em_utils_guess_mail_account(). */
+ source = em_utils_guess_mail_account (registry, message, folder);
exit:
g_hash_table_destroy (recipients);
- return account;
+ return source;
+}
+
+ESource *
+em_utils_guess_mail_identity_with_recipients (ESourceRegistry *registry,
+ CamelMimeMessage *message,
+ CamelFolder *folder)
+{
+ ESource *source;
+ ESourceExtension *extension;
+ const gchar *extension_name;
+
+ g_return_val_if_fail (E_IS_SOURCE_REGISTRY (registry), NULL);
+ g_return_val_if_fail (CAMEL_IS_MIME_MESSAGE (message), NULL);
+
+ source = em_utils_guess_mail_account_with_recipients (
+ registry, message, folder);
+
+ if (source == NULL)
+ return NULL;
+
+ extension_name = E_SOURCE_EXTENSION_MAIL_ACCOUNT;
+ extension = e_source_get_extension (source, extension_name);
+
+ return e_source_mail_account_get_identity (
+ E_SOURCE_MAIL_ACCOUNT (extension));
+}
+
+gboolean
+em_utils_mail_identity_is_enabled (ESourceRegistry *registry,
+ ESource *mail_identity_source)
+{
+ GList *list, *link;
+ const gchar *extension_name;
+ gboolean found_account = FALSE;
+ gboolean found_enabled_account = FALSE;
+
+ g_return_val_if_fail (E_IS_SOURCE_REGISTRY (registry), FALSE);
+
+ if (mail_identity_source == NULL)
+ return FALSE;
+
+ extension_name = E_SOURCE_EXTENSION_MAIL_IDENTITY;
+ if (!e_source_has_extension (mail_identity_source, extension_name))
+ return FALSE;
+
+ /* If any enabled account references the given identity, then
+ * the identity is enabled. If no accounts reference the given
+ * identity, then the identity is assumed to be enabled. So in
+ * other words, an identity is disabled if and only if it is
+ * referenced exclusively by disabled accounts. */
+
+ extension_name = E_SOURCE_EXTENSION_MAIL_ACCOUNT;
+ list = e_source_registry_list_sources (registry, extension_name);
+
+ for (link = list; link != NULL; link = g_list_next (link)) {
+ ESource *source = E_SOURCE (link->data);
+ ESourceMailAccount *extension;
+ gboolean enabled;
+
+ extension = e_source_get_extension (source, extension_name);
+
+ enabled = e_source_get_enabled (source);
+ source = e_source_mail_account_get_identity (extension);
+
+ if (source == NULL)
+ continue;
+
+ if (e_source_equal (source, mail_identity_source)) {
+ found_account = TRUE;
+ found_enabled_account |= enabled;
+ }
+
+ if (found_enabled_account)
+ break;
+ }
+
+ g_list_free (list);
+
+ return found_enabled_account || !found_account;
}
static void
diff --git a/libemail-engine/e-mail-utils.h b/libemail-engine/e-mail-utils.h
index 144f13d..9cf342c 100644
--- a/libemail-engine/e-mail-utils.h
+++ b/libemail-engine/e-mail-utils.h
@@ -23,21 +23,39 @@
#define E_MAIL_UTILS_H
#include <camel/camel.h>
-#include <libedataserver/e-account.h>
+#include <libedataserver/e-source-registry.h>
-gboolean em_utils_folder_is_drafts (CamelFolder *folder);
-gboolean em_utils_folder_is_templates (CamelFolder *folder);
-gboolean em_utils_folder_is_sent (CamelFolder *folder);
-gboolean em_utils_folder_is_outbox (CamelFolder *folder);
-gboolean em_utils_in_addressbook (CamelInternetAddress *addr,
+gboolean em_utils_folder_is_drafts (ESourceRegistry *registry,
+ CamelFolder *folder);
+gboolean em_utils_folder_is_templates (ESourceRegistry *registry,
+ CamelFolder *folder);
+gboolean em_utils_folder_is_sent (ESourceRegistry *registry,
+ CamelFolder *folder);
+gboolean em_utils_folder_is_outbox (ESourceRegistry *registry,
+ CamelFolder *folder);
+gboolean em_utils_in_addressbook (ESourceRegistry *registry,
+ CamelInternetAddress *addr,
gboolean local_only);
-CamelMimePart * em_utils_contact_photo (CamelInternetAddress *addr,
+CamelMimePart * em_utils_contact_photo (ESourceRegistry *registry,
+ CamelInternetAddress *addr,
gboolean local);
-EAccount * em_utils_guess_account (CamelMimeMessage *message,
+ESource * em_utils_guess_mail_account (ESourceRegistry *registry,
+ CamelMimeMessage *message,
+ CamelFolder *folder);
+ESource * em_utils_guess_mail_identity (ESourceRegistry *registry,
+ CamelMimeMessage *message,
+ CamelFolder *folder);
+ESource * em_utils_guess_mail_account_with_recipients
+ (ESourceRegistry *registry,
+ CamelMimeMessage *message,
CamelFolder *folder);
-EAccount * em_utils_guess_account_with_recipients
- (CamelMimeMessage *message,
+ESource * em_utils_guess_mail_identity_with_recipients
+ (ESourceRegistry *registry,
+ CamelMimeMessage *message,
CamelFolder *folder);
+gboolean em_utils_mail_identity_is_enabled
+ (ESourceRegistry *registry,
+ ESource *mail_identity_source);
void emu_remove_from_mail_cache (const GSList *addresses);
void emu_remove_from_mail_cache_1 (const gchar *address);
void emu_free_mail_cache (void);
diff --git a/libemail-engine/mail-config.c b/libemail-engine/mail-config.c
index 09f0332..af193f5 100644
--- a/libemail-engine/mail-config.c
+++ b/libemail-engine/mail-config.c
@@ -31,9 +31,6 @@
#include <libedataserver/e-data-server-util.h>
-#include <libemail-utils/e-account-utils.h>
-#include <libemail-utils/e-signature-utils.h>
-
#include "e-mail-folder-utils.h"
#include "mail-config.h"
#include "mail-tools.h"
@@ -137,24 +134,6 @@ settings_int_value_changed (GSettings *settings,
*save_location = g_settings_get_int (settings, key);
}
-void
-mail_config_write (void)
-{
- EAccountList *account_list;
- ESignatureList *signature_list;
-
- if (!config)
- return;
-
- account_list = e_get_account_list ();
- signature_list = e_get_signature_list ();
-
- e_account_list_save (account_list);
- e_signature_list_save (signature_list);
-
- g_settings_sync ();
-}
-
gint
mail_config_get_address_count (void)
{
diff --git a/libemail-engine/mail-config.h b/libemail-engine/mail-config.h
index 0a1c618..cc836ac 100644
--- a/libemail-engine/mail-config.h
+++ b/libemail-engine/mail-config.h
@@ -29,7 +29,6 @@ G_BEGIN_DECLS
/* Configuration */
void mail_config_init (EMailSession *session);
-void mail_config_write (void);
/* General Accessor functions */
diff --git a/libemail-engine/mail-folder-cache.c b/libemail-engine/mail-folder-cache.c
index 5c459ef..dbb6fcc 100644
--- a/libemail-engine/mail-folder-cache.c
+++ b/libemail-engine/mail-folder-cache.c
@@ -341,11 +341,16 @@ update_1folder (MailFolderCache *cache,
const gchar *msg_subject,
CamelFolderInfo *info)
{
+ EMailSession *session;
+ ESourceRegistry *registry;
struct _folder_update *up;
CamelFolder *folder;
gint unread = -1;
gint deleted;
+ session = mail_folder_cache_get_session (cache);
+ registry = e_mail_session_get_registry (session);
+
folder = mfi->folder;
if (folder) {
gboolean folder_is_sent;
@@ -354,9 +359,9 @@ update_1folder (MailFolderCache *cache,
gboolean folder_is_vtrash;
gboolean special_case;
- folder_is_sent = em_utils_folder_is_sent (folder);
- folder_is_drafts = em_utils_folder_is_drafts (folder);
- folder_is_outbox = em_utils_folder_is_outbox (folder);
+ folder_is_sent = em_utils_folder_is_sent (registry, folder);
+ folder_is_drafts = em_utils_folder_is_drafts (registry, folder);
+ folder_is_outbox = em_utils_folder_is_outbox (registry, folder);
folder_is_vtrash = CAMEL_IS_VTRASH_FOLDER (folder);
special_case =
diff --git a/libemail-engine/mail-ops.c b/libemail-engine/mail-ops.c
index 3e40bd0..867f8e8 100644
--- a/libemail-engine/mail-ops.c
+++ b/libemail-engine/mail-ops.c
@@ -35,8 +35,9 @@
#include <glib/gi18n.h>
#include <libedataserver/e-data-server-util.h>
+#include <libedataserver/e-source-mail-account.h>
+#include <libedataserver/e-source-mail-submission.h>
-#include <libemail-utils/e-account-utils.h>
#include <libemail-utils/mail-mt.h>
#include "e-mail-utils.h"
@@ -75,7 +76,6 @@ struct _fetch_mail_msg {
CamelStore *store;
GCancellable *cancellable; /* we have our own cancellation
* struct, the other should be empty */
- gint keep; /* keep on server? */
void (*done)(gpointer data);
gpointer data;
@@ -215,12 +215,19 @@ fetch_mail_exec (struct _fetch_mail_msg *m,
GError **error)
{
struct _filter_mail_msg *fm = (struct _filter_mail_msg *) m;
+ GObjectClass *class;
CamelFolder *folder = NULL;
CamelService *service;
CamelSession *session;
+ CamelSettings *settings;
+ CamelUIDCache *cache = NULL;
CamelURL *url;
- gboolean is_local_delivery = FALSE;
+ gboolean keep = FALSE;
+ gboolean delete_fetched;
+ gboolean is_local_delivery;
+ const gchar *data_dir;
const gchar *uid;
+ gchar *cachename;
gint i;
service = CAMEL_SERVICE (m->store);
@@ -232,6 +239,19 @@ fetch_mail_exec (struct _fetch_mail_msg *m,
goto exit;
g_object_ref (fm->destination);
+ service = CAMEL_SERVICE (m->store);
+ uid = camel_service_get_uid (service);
+ settings = camel_service_get_settings (service);
+ data_dir = camel_service_get_user_data_dir (service);
+
+ /* XXX This is a POP3-specific setting. */
+ class = G_OBJECT_GET_CLASS (settings);
+ if (g_object_class_find_property (class, "keep-on-server") != NULL)
+ g_object_get (settings, "keep-on-server", &keep, NULL);
+
+ /* Just for readability. */
+ delete_fetched = !keep;
+
url = camel_service_new_camel_url (service);
is_local_delivery = em_utils_is_local_delivery_mbox_file (url);
@@ -258,8 +278,6 @@ fetch_mail_exec (struct _fetch_mail_msg *m,
g_free (path);
g_free (url_string);
} else {
- uid = camel_service_get_uid (service);
-
folder = fm->source_folder =
e_mail_session_get_inbox_sync (
fm->session, uid, cancellable, error);
@@ -267,78 +285,72 @@ fetch_mail_exec (struct _fetch_mail_msg *m,
camel_url_free (url);
- if (folder != NULL) {
- /* This handles 'keep on server' stuff, if we have any new
- * uid's to copy across, we need to copy them to a new array
- * 'cause of the way fetch_mail_free works. */
- CamelUIDCache *cache = NULL;
- CamelStore *parent_store;
- CamelService *service;
- const gchar *data_dir;
- gchar *cachename;
-
- parent_store = camel_folder_get_parent_store (folder);
+ if (folder == NULL)
+ goto exit;
- service = CAMEL_SERVICE (parent_store);
- data_dir = camel_service_get_user_data_dir (service);
+ /* This handles 'keep on server' stuff, if we have any new
+ * uid's to copy across, we need to copy them to a new array
+ * 'cause of the way fetch_mail_free works. */
- cachename = g_build_filename (data_dir, "uid-cache", NULL);
- cache = camel_uid_cache_new (cachename);
- g_free (cachename);
+ cachename = g_build_filename (data_dir, "uid-cache", NULL);
+ cache = camel_uid_cache_new (cachename);
+ g_free (cachename);
- if (cache) {
- GPtrArray *folder_uids, *cache_uids, *uids;
+ if (cache) {
+ GPtrArray *folder_uids, *cache_uids, *uids;
- folder_uids = camel_folder_get_uids (folder);
- cache_uids = camel_uid_cache_get_new_uids (cache, folder_uids);
- if (cache_uids) {
- /* need to copy this, sigh */
- fm->source_uids = uids = g_ptr_array_new ();
- g_ptr_array_set_size (uids, cache_uids->len);
- for (i = 0; i < cache_uids->len; i++)
- uids->pdata[i] = g_strdup (cache_uids->pdata[i]);
- camel_uid_cache_free_uids (cache_uids);
+ folder_uids = camel_folder_get_uids (folder);
+ cache_uids = camel_uid_cache_get_new_uids (cache, folder_uids);
+ if (cache_uids) {
+ /* need to copy this, sigh */
+ fm->source_uids = uids = g_ptr_array_new ();
+ g_ptr_array_set_size (uids, cache_uids->len);
+ for (i = 0; i < cache_uids->len; i++)
+ uids->pdata[i] = g_strdup (cache_uids->pdata[i]);
+ camel_uid_cache_free_uids (cache_uids);
- fm->cache = cache;
- em_filter_folder_element_exec (fm, cancellable, error);
+ fm->cache = cache;
- /* need to uncancel so writes/etc. don't fail */
- if (g_cancellable_is_cancelled (m->cancellable))
- g_cancellable_reset (m->cancellable);
+ /* FIXME Should return a success/failure flag. */
+ em_filter_folder_element_exec (fm, cancellable, error);
- /* save the cache of uids that we've just downloaded */
- camel_uid_cache_save (cache);
- }
+ /* need to uncancel so writes/etc. don't fail */
+ if (g_cancellable_is_cancelled (m->cancellable))
+ g_cancellable_reset (m->cancellable);
- if (fm->delete && (!error || !*error)) {
- /* not keep on server - just delete all
- * the actual messages on the server */
- for (i = 0; i < folder_uids->len; i++) {
- camel_folder_delete_message (
- folder, folder_uids->pdata[i]);
- }
- }
+ /* save the cache of uids that we've just downloaded */
+ camel_uid_cache_save (cache);
+ }
- if ((fm->delete || cache_uids) && (!error || !*error)) {
- /* expunge messages (downloaded so far) */
- /* FIXME Not passing a GCancellable or GError here. */
- camel_folder_synchronize_sync (
- folder, fm->delete, NULL, NULL);
+ if (delete_fetched && (!error || !*error)) {
+ /* not keep on server - just delete all
+ * the actual messages on the server */
+ for (i = 0; i < folder_uids->len; i++) {
+ camel_folder_delete_message (
+ folder, folder_uids->pdata[i]);
}
+ }
- camel_uid_cache_destroy (cache);
- camel_folder_free_uids (folder, folder_uids);
- } else {
- em_filter_folder_element_exec (fm, cancellable, error);
+ if ((delete_fetched || cache_uids) && (!error || !*error)) {
+ /* expunge messages (downloaded so far) */
+ /* FIXME Not passing a GCancellable or GError here. */
+ camel_folder_synchronize_sync (
+ folder, delete_fetched, NULL, NULL);
}
- /* we unref the source folder here since we
- * may now block in finalize (we try to
- * disconnect cleanly) */
- g_object_unref (fm->source_folder);
- fm->source_folder = NULL;
+ camel_uid_cache_destroy (cache);
+ camel_folder_free_uids (folder, folder_uids);
+ } else {
+ /* FIXME Should return a success/failure flag. */
+ em_filter_folder_element_exec (fm, cancellable, error);
}
+ /* we unref the source folder here since we
+ * may now block in finalize (we try to
+ * disconnect cleanly) */
+ g_object_unref (fm->source_folder);
+ fm->source_folder = NULL;
+
exit:
/* we unref this here as it may have more work to do (syncing
* folders and whatnot) before we are really done */
@@ -385,7 +397,6 @@ static MailMsgInfo fetch_mail_info = {
/* ouch, a 'do everything' interface ... */
void
mail_fetch_mail (CamelStore *store,
- gint keep,
const gchar *type,
GCancellable *cancellable,
CamelFilterGetFolderFunc get_folder,
@@ -407,7 +418,6 @@ mail_fetch_mail (CamelStore *store,
fm = (struct _filter_mail_msg *) m;
fm->session = g_object_ref (session);
m->store = g_object_ref (store);
- fm->delete = !keep;
fm->cache = NULL;
if (cancellable)
m->cancellable = g_object_ref (cancellable);
@@ -461,6 +471,44 @@ static void report_status (struct _send_queue_msg *m,
const gchar *desc,
...);
+static gboolean
+get_submission_details_from_identity (EMailSession *session,
+ const gchar *identity_uid,
+ gchar **out_transport_uid,
+ gchar **out_sent_folder_uri)
+{
+ ESource *source;
+ ESourceRegistry *registry;
+ ESourceExtension *extension;
+ const gchar *extension_name;
+ const gchar *sent_folder_uri;
+ const gchar *transport_uid;
+
+ registry = e_mail_session_get_registry (session);
+ extension_name = E_SOURCE_EXTENSION_MAIL_SUBMISSION;
+ source = e_source_registry_lookup_by_uid (registry, identity_uid);
+
+ if (source == NULL)
+ return FALSE;
+
+ if (!e_source_has_extension (source, extension_name))
+ return FALSE;
+
+ extension = e_source_get_extension (source, extension_name);
+
+ sent_folder_uri = e_source_mail_submission_get_sent_folder (
+ E_SOURCE_MAIL_SUBMISSION (extension));
+
+ transport_uid = e_source_mail_submission_get_transport_uid (
+ E_SOURCE_MAIL_SUBMISSION (extension));
+
+ *out_transport_uid = g_strdup (transport_uid);
+
+ *out_sent_folder_uri = g_strdup (sent_folder_uri);
+
+ return TRUE;
+}
+
/* send 1 message to a specific transport */
static void
mail_send_message (struct _send_queue_msg *m,
@@ -471,11 +519,11 @@ mail_send_message (struct _send_queue_msg *m,
GCancellable *cancellable,
GError **error)
{
- EAccount *account = NULL;
+ CamelService *service;
const CamelInternetAddress *iaddr;
CamelAddress *from, *recipients;
CamelMessageInfo *info = NULL;
- CamelProvider *provider;
+ CamelProvider *provider = NULL;
gchar *transport_uid = NULL;
gchar *sent_folder_uri = NULL;
const gchar *resent_from, *tmp;
@@ -496,48 +544,31 @@ mail_send_message (struct _send_queue_msg *m,
err = g_string_new ("");
xev = mail_tool_remove_xevolution_headers (message);
- tmp = camel_header_raw_find (&xev, "X-Evolution-Account", NULL);
+ tmp = camel_header_raw_find (&xev, "X-Evolution-Identity", NULL);
if (tmp != NULL) {
- gchar *name;
-
- name = g_strstrip (g_strdup (tmp));
- if ((account = e_get_account_by_uid (name))
- /* 'old' x-evolution-account stored the name, how silly */
- || (account = e_get_account_by_name (name))) {
- if (account->transport) {
- CamelService *service;
- gchar *transport_uid;
-
- transport_uid = g_strconcat (
- account->uid, "-transport", NULL);
- service = camel_session_get_service (
- CAMEL_SESSION (m->session),
- transport_uid);
- g_free (transport_uid);
-
- if (CAMEL_IS_TRANSPORT (service))
- transport = CAMEL_TRANSPORT (service);
- }
+ gchar *identity_uid;
- sent_folder_uri = g_strdup (account->sent_folder_uri);
- }
- g_free (name);
+ identity_uid = g_strstrip (g_strdup (tmp));
+ get_submission_details_from_identity (
+ m->session, identity_uid,
+ &transport_uid, &sent_folder_uri);
+ g_free (identity_uid);
}
- if (!account) {
- /* default back to these headers */
- tmp = camel_header_raw_find(&xev, "X-Evolution-Transport", NULL);
- if (tmp)
- transport_uid = g_strstrip (g_strdup (tmp));
+ tmp = camel_header_raw_find (&xev, "X-Evolution-Transport", NULL);
+ if (transport_uid == NULL && tmp != NULL)
+ transport_uid = g_strstrip (g_strdup (tmp));
- tmp = camel_header_raw_find(&xev, "X-Evolution-Fcc", NULL);
- if (tmp)
- sent_folder_uri = g_strstrip (g_strdup (tmp));
- }
+ tmp = camel_header_raw_find (&xev, "X-Evolution-Fcc", NULL);
+ if (sent_folder_uri == NULL && tmp != NULL)
+ sent_folder_uri = g_strstrip (g_strdup (tmp));
- if (transport != NULL) {
- const gchar *uid;
+ service = camel_session_get_service (
+ CAMEL_SESSION (m->session), transport_uid);
+ if (service != NULL)
+ provider = camel_service_get_provider (service);
+ if (CAMEL_IS_TRANSPORT (service)) {
/* Let the dialog know the right account it is using. */
uid = camel_service_get_uid (CAMEL_SERVICE (transport));
report_status (m, CAMEL_FILTER_STATUS_ACTION, 0, uid);
@@ -564,12 +595,12 @@ mail_send_message (struct _send_queue_msg *m,
if (camel_address_length (recipients) > 0) {
if (!em_utils_connect_service_sync (
- CAMEL_SERVICE (transport), cancellable, error))
+ service, cancellable, error))
goto exit;
if (!camel_transport_send_to_sync (
- transport, message, from,
- recipients, cancellable, error))
+ CAMEL_TRANSPORT (service), message,
+ from, recipients, cancellable, error))
goto exit;
}
@@ -620,8 +651,6 @@ mail_send_message (struct _send_queue_msg *m,
}
}
- provider = camel_service_get_provider (CAMEL_SERVICE (transport));
-
if (provider == NULL
|| !(provider->flags & CAMEL_PROVIDER_DISABLE_SENT_FOLDER)) {
GError *local_error = NULL;
@@ -1319,9 +1348,10 @@ expunge_pop3_stores (CamelFolder *expunging,
CamelStore *parent_store;
CamelService *service;
CamelSession *session;
+ ESourceRegistry *registry;
GPtrArray *uids;
- EAccount *account;
- EIterator *iter;
+ GList *list, *link;
+ const gchar *extension_name;
gboolean success = TRUE;
guint ii;
@@ -1329,6 +1359,7 @@ expunge_pop3_stores (CamelFolder *expunging,
service = CAMEL_SERVICE (parent_store);
session = camel_service_get_session (service);
+ registry = e_mail_session_get_registry (E_MAIL_SESSION (session));
uids = camel_folder_get_uids (expunging);
@@ -1389,79 +1420,89 @@ expunge_pop3_stores (CamelFolder *expunging,
return TRUE;
}
- for (iter = e_list_get_iterator ((EList *) e_get_account_list ());
- e_iterator_is_valid (iter); e_iterator_next (iter)) {
- account = (EAccount *) e_iterator_get (iter);
+ extension_name = E_SOURCE_EXTENSION_MAIL_ACCOUNT;
+ list = e_source_registry_list_sources (registry, extension_name);
- if (account->enabled &&
- account->source && account->source->url &&
- g_str_has_prefix (account->source->url, "pop://")) {
- CamelFolder *folder;
- CamelService *service;
- CamelSettings *settings;
- gboolean any_found = FALSE;
- gboolean delete_expunged = FALSE;
- gboolean keep_on_server = FALSE;
+ for (link = list; link != NULL; link = g_list_next (link)) {
+ ESource *source = E_SOURCE (link->data);
+ ESourceBackend *extension;
+ CamelFolder *folder;
+ CamelService *service;
+ CamelSettings *settings;
+ const gchar *backend_name;
+ const gchar *source_uid;
+ gboolean any_found = FALSE;
+ gboolean delete_expunged = FALSE;
+ gboolean keep_on_server = FALSE;
+ gboolean enabled;
- service = camel_session_get_service (session, account->uid);
+ source_uid = e_source_get_uid (source);
+ enabled = e_source_get_enabled (source);
- if (!CAMEL_IS_STORE (service))
- continue;
+ extension = e_source_get_extension (source, extension_name);
+ backend_name = e_source_backend_get_backend_name (extension);
- settings = camel_service_get_settings (service);
- if (!settings)
- continue;
+ if (!enabled || g_strcmp0 (backend_name, "pop") != 0)
+ continue;
- g_object_get (
- settings,
- "delete-expunged", &delete_expunged,
- "keep-on-server", &keep_on_server,
- NULL);
+ service = camel_session_get_service (
+ CAMEL_SESSION (session), source_uid);
- if (!keep_on_server || !delete_expunged)
- continue;
+ settings = camel_service_get_settings (service);
- folder = e_mail_session_get_inbox_sync (
- E_MAIL_SESSION (session),
- account->uid, cancellable, error);
+ g_object_get (
+ settings,
+ "delete-expunged", &delete_expunged,
+ "keep-on-server", &keep_on_server,
+ NULL);
- /* Abort the loop on error. */
- if (folder == NULL) {
- success = FALSE;
- break;
- }
+ if (!keep_on_server || !delete_expunged)
+ continue;
- uids = camel_folder_get_uids (folder);
- if (uids) {
- for (ii = 0; ii < uids->len; ii++) {
- /* ensure the ID is from this account,
- * as it's generated by evolution */
- const gchar *source_uid;
-
- source_uid = g_hash_table_lookup (
- expunging_uids, uids->pdata[ii]);
- if (folder_is_from_source_uid (folder, source_uid)) {
- any_found = TRUE;
- camel_folder_delete_message (folder, uids->pdata[ii]);
- }
- }
- camel_folder_free_uids (folder, uids);
- }
+ folder = camel_store_get_inbox_folder_sync (
+ CAMEL_STORE (service), cancellable, error);
- if (any_found)
- success = camel_folder_synchronize_sync (
- folder, TRUE, cancellable, error);
+ /* Abort the loop on error. */
+ if (folder == NULL) {
+ success = FALSE;
+ break;
+ }
+ uids = camel_folder_get_uids (folder);
+
+ if (uids == NULL) {
g_object_unref (folder);
+ continue;
+ }
- /* Abort the loop on error. */
- if (!success)
- break;
+ for (ii = 0; ii < uids->len; ii++) {
+ /* ensure the ID is from this account,
+ * as it's generated by evolution */
+ const gchar *source_uid;
+
+ source_uid = g_hash_table_lookup (
+ expunging_uids, uids->pdata[ii]);
+ if (folder_is_from_source_uid (folder, source_uid)) {
+ any_found = TRUE;
+ camel_folder_delete_message (
+ folder, uids->pdata[ii]);
+ }
}
+
+ camel_folder_free_uids (folder, uids);
+
+ if (any_found)
+ success = camel_folder_synchronize_sync (
+ folder, TRUE, cancellable, error);
+
+ g_object_unref (folder);
+
+ /* Abort the loop on error. */
+ if (!success)
+ break;
}
- if (iter)
- g_object_unref (iter);
+ g_list_free (list);
g_hash_table_destroy (expunging_uids);
diff --git a/libemail-engine/mail-ops.h b/libemail-engine/mail-ops.h
index 236dd23..cafcefc 100644
--- a/libemail-engine/mail-ops.h
+++ b/libemail-engine/mail-ops.h
@@ -72,7 +72,6 @@ void mail_send_queue (EMailSession *session,
gpointer data);
void mail_fetch_mail (CamelStore *store,
- gint keep,
const gchar *type,
GCancellable *cancellable,
CamelFilterGetFolderFunc get_folder,
diff --git a/libemail-utils/Makefile.am b/libemail-utils/Makefile.am
index a856df6..18e9926 100644
--- a/libemail-utils/Makefile.am
+++ b/libemail-utils/Makefile.am
@@ -13,10 +13,6 @@ libemail_utils_la_CPPFLAGS = \
libmailutilsincludedir = $(privincludedir)/libemail-utils
libmailutilsinclude_HEADERS = \
- e-account-utils.h \
- e-signature-list.h \
- e-signature-utils.h \
- e-signature.h \
em-filter-folder-element.h \
em-vfolder-context.h \
em-vfolder-rule.h \
@@ -25,10 +21,6 @@ libmailutilsinclude_HEADERS = \
libemail_utils_la_SOURCES = \
$(libmailutilsinclude_HEADERS) \
- e-account-utils.c \
- e-signature-list.c \
- e-signature-utils.c \
- e-signature.c \
em-filter-folder-element.c \
em-vfolder-context.c \
em-vfolder-rule.c \
diff --git a/mail/Makefile.am b/mail/Makefile.am
index 3a13284..6a47dcb 100644
--- a/mail/Makefile.am
+++ b/mail/Makefile.am
@@ -38,12 +38,18 @@ libevolution_mail_la_CPPFLAGS = \
mailinclude_HEADERS = \
e-mail.h \
+ e-mail-account-config.h \
e-mail-account-manager.h \
e-mail-account-store.h \
e-mail-account-tree-view.h \
e-mail-attachment-bar.h \
e-mail-backend.h \
e-mail-browser.h \
+ e-mail-config.h \
+ e-mail-config-auth-check.h \
+ e-mail-config-backend.h \
+ e-mail-config-identity.h \
+ e-mail-config-provider.h \
e-mail-display.h \
e-mail-folder-pane.h \
e-mail-junk-options.h \
@@ -61,6 +67,7 @@ mailinclude_HEADERS = \
e-mail-ui-session.h \
e-mail-sidebar.h \
e-mail-tag-editor.h \
+ e-mail-transport-config.h \
e-mail-view.h \
em-account-editor.h \
em-composer-utils.h \
@@ -103,12 +110,18 @@ mailinclude_HEADERS += \
endif
libevolution_mail_la_SOURCES = \
+ e-mail-account-config.c \
e-mail-account-manager.c \
e-mail-account-store.c \
e-mail-account-tree-view.c \
e-mail-attachment-bar.c \
e-mail-backend.c \
e-mail-browser.c \
+ e-mail-config.c \
+ e-mail-config-auth-check.c \
+ e-mail-config-backend.c \
+ e-mail-config-identity.c \
+ e-mail-config-provider.c \
e-mail-display.c \
e-mail-folder-pane.c \
e-mail-junk-options.c \
@@ -126,6 +139,7 @@ libevolution_mail_la_SOURCES = \
e-mail-ui-session.c \
e-mail-sidebar.c \
e-mail-tag-editor.c \
+ e-mail-transport-config.c \
e-mail-view.c \
em-account-editor.c \
em-composer-utils.c \
diff --git a/mail/e-mail-account-config.c b/mail/e-mail-account-config.c
new file mode 100644
index 0000000..0d9cb49
--- /dev/null
+++ b/mail/e-mail-account-config.c
@@ -0,0 +1,52 @@
+/*
+ * e-mail-account-config.c
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) version 3.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with the program; if not, see <http://www.gnu.org/licenses/>
+ *
+ */
+
+#include "e-mail-account-config.h"
+
+#include <libedataserver/e-source-mail-account.h>
+
+G_DEFINE_TYPE (
+ EMailAccountConfig,
+ e_mail_account_config,
+ E_TYPE_MAIL_CONFIG)
+
+static void
+e_mail_account_config_class_init (EMailAccountConfigClass *class)
+{
+ EMailConfigClass *mail_config_class;
+
+ mail_config_class = E_MAIL_CONFIG_CLASS (class);
+ mail_config_class->extension_name = E_SOURCE_EXTENSION_MAIL_ACCOUNT;
+ mail_config_class->provider_type = CAMEL_PROVIDER_STORE;
+}
+
+static void
+e_mail_account_config_init (EMailAccountConfig *config)
+{
+}
+
+GtkWidget *
+e_mail_account_config_new (ESourceRegistry *registry)
+{
+ g_return_val_if_fail (E_IS_SOURCE_REGISTRY (registry), NULL);
+
+ return g_object_new (
+ E_TYPE_MAIL_ACCOUNT_CONFIG,
+ "registry", registry, NULL);
+}
+
diff --git a/mail/e-mail-account-config.h b/mail/e-mail-account-config.h
new file mode 100644
index 0000000..24492a3
--- /dev/null
+++ b/mail/e-mail-account-config.h
@@ -0,0 +1,63 @@
+/*
+ * e-mail-account-config.h
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) version 3.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with the program; if not, see <http://www.gnu.org/licenses/>
+ *
+ */
+
+#ifndef E_MAIL_ACCOUNT_CONFIG_H
+#define E_MAIL_ACCOUNT_CONFIG_H
+
+#include <mail/e-mail-config.h>
+
+/* Standard GObject macros */
+#define E_TYPE_MAIL_ACCOUNT_CONFIG \
+ (e_mail_account_config_get_type ())
+#define E_MAIL_ACCOUNT_CONFIG(obj) \
+ (G_TYPE_CHECK_INSTANCE_CAST \
+ ((obj), E_TYPE_MAIL_ACCOUNT_CONFIG, EMailAccountConfig))
+#define E_MAIL_ACCOUNT_CONFIG_CLASS(cls) \
+ (G_TYPE_CHECK_CLASS_CAST \
+ ((cls), E_TYPE_MAIL_ACCOUNT_CONFIG, EMailAccountConfigClass))
+#define E_IS_MAIL_ACCOUNT_CONFIG(obj) \
+ (G_TYPE_CHECK_INSTANCE_TYPE \
+ ((obj), E_TYPE_MAIL_ACCOUNT_CONFIG))
+#define E_IS_MAIL_ACCOUNT_CONFIG_CLASS(cls) \
+ (G_TYPE_CHECK_CLASS_TYPE \
+ ((cls), E_TYPE_MAIL_ACCOUNT_CONFIG))
+#define E_MAIL_ACCOUNT_CONFIG_GET_CLASS(obj) \
+ (G_TYPE_INSTANCE_GET_CLASS \
+ ((obj), E_TYPE_MAIL_ACCOUNT_CONFIG, EMailAccountConfigClass))
+
+G_BEGIN_DECLS
+
+typedef struct _EMailAccountConfig EMailAccountConfig;
+typedef struct _EMailAccountConfigClass EMailAccountConfigClass;
+typedef struct _EMailAccountConfigPrivate EMailAccountConfigPrivate;
+
+struct _EMailAccountConfig {
+ EMailConfig parent;
+};
+
+struct _EMailAccountConfigClass {
+ EMailConfigClass parent_class;
+};
+
+GType e_mail_account_config_get_type (void) G_GNUC_CONST;
+GtkWidget * e_mail_account_config_new (ESourceRegistry *registry);
+
+G_END_DECLS
+
+#endif /* E_MAIL_ACCOUNT_CONFIG_H */
+
diff --git a/mail/e-mail-account-manager.c b/mail/e-mail-account-manager.c
index 86a0bf5..0f57078 100644
--- a/mail/e-mail-account-manager.c
+++ b/mail/e-mail-account-manager.c
@@ -70,18 +70,25 @@ static void
mail_account_manager_edit_cb (EMailAccountManager *manager)
{
EMailAccountTreeView *tree_view;
- EAccount *account;
+ EMailAccountStore *store;
+ ESourceRegistry *registry;
+ EMailSession *session;
CamelService *service;
+ ESource *source;
const gchar *uid;
+ store = e_mail_account_manager_get_store (manager);
+ session = e_mail_account_store_get_session (store);
+ registry = e_mail_session_get_registry (session);
+
tree_view = E_MAIL_ACCOUNT_TREE_VIEW (manager->priv->tree_view);
service = e_mail_account_tree_view_get_selected_service (tree_view);
uid = camel_service_get_uid (service);
- account = e_get_account_by_uid (uid);
- g_return_if_fail (account != NULL);
+ source = e_source_registry_lookup_by_uid (registry, uid);
+ g_return_if_fail (source != NULL);
- e_mail_account_manager_edit_account (manager, account);
+ e_mail_account_manager_edit_account (manager, source);
}
static void
@@ -519,7 +526,7 @@ e_mail_account_manager_class_init (EMailAccountManagerClass *class)
NULL, NULL,
g_cclosure_marshal_VOID__OBJECT,
G_TYPE_NONE, 1,
- E_TYPE_ACCOUNT);
+ E_TYPE_SOURCE);
}
static void
@@ -556,11 +563,11 @@ e_mail_account_manager_add_account (EMailAccountManager *manager)
void
e_mail_account_manager_edit_account (EMailAccountManager *manager,
- EAccount *account)
+ ESource *source)
{
g_return_if_fail (E_IS_MAIL_ACCOUNT_MANAGER (manager));
- g_return_if_fail (E_IS_ACCOUNT (account));
+ g_return_if_fail (E_IS_SOURCE (source));
- g_signal_emit (manager, signals[EDIT_ACCOUNT], 0, account);
+ g_signal_emit (manager, signals[EDIT_ACCOUNT], 0, source);
}
diff --git a/mail/e-mail-account-manager.h b/mail/e-mail-account-manager.h
index 63e52b4..a17ff2a 100644
--- a/mail/e-mail-account-manager.h
+++ b/mail/e-mail-account-manager.h
@@ -20,8 +20,8 @@
#define E_MAIL_ACCOUNT_MANAGER_H
#include <gtk/gtk.h>
+#include <libedataserver/e-source.h>
#include <mail/e-mail-account-store.h>
-#include <libemail-utils/e-account-utils.h>
/* Standard GObject macros */
#define E_TYPE_MAIL_ACCOUNT_MANAGER \
@@ -59,7 +59,7 @@ struct _EMailAccountManagerClass {
/* Signals */
void (*add_account) (EMailAccountManager *manager);
void (*edit_account) (EMailAccountManager *manager,
- EAccount *account);
+ ESource *source);
};
GType e_mail_account_manager_get_type (void) G_GNUC_CONST;
@@ -71,7 +71,7 @@ void e_mail_account_manager_add_account
(EMailAccountManager *manager);
void e_mail_account_manager_edit_account
(EMailAccountManager *manager,
- EAccount *account);
+ ESource *source);
G_END_DECLS
diff --git a/mail/e-mail-account-store.c b/mail/e-mail-account-store.c
index 2dac692..bab5d1b 100644
--- a/mail/e-mail-account-store.c
+++ b/mail/e-mail-account-store.c
@@ -27,7 +27,6 @@
#include <e-util/e-marshal.h>
#include <libevolution-utils/e-alert-dialog.h>
-#include <libemail-utils/e-account-utils.h>
#include <libemail-engine/mail-ops.h>
#include <mail/mail-vfolder-ui.h>
@@ -101,24 +100,6 @@ index_item_free (IndexItem *item)
g_slice_free (IndexItem, item);
}
-static void
-mail_account_store_save_default (EMailAccountStore *store)
-{
- EAccountList *account_list;
- EAccount *account;
- CamelService *service;
- const gchar *uid;
-
- service = e_mail_account_store_get_default_service (store);
-
- account_list = e_get_account_list ();
- uid = camel_service_get_uid (service);
- account = e_get_account_by_uid (uid);
- g_return_if_fail (account != NULL);
-
- e_account_list_set_default (account_list, account);
-}
-
static gboolean
mail_account_store_get_iter (EMailAccountStore *store,
CamelService *service,
@@ -238,6 +219,46 @@ mail_account_store_service_notify_cb (CamelService *service,
}
static void
+mail_account_store_remove_source_cb (ESourceRegistry *registry,
+ GAsyncResult *result,
+ EMailAccountStore *store)
+{
+ GError *error = NULL;
+
+ /* FIXME EMailAccountStore should implement EAlertSink. */
+ if (!e_source_registry_remove_source_finish (registry, result, &error)) {
+ g_warning ("%s: %s", G_STRFUNC, error->message);
+ g_error_free (error);
+ }
+
+ g_return_if_fail (store->priv->busy_count > 0);
+ store->priv->busy_count--;
+ g_object_notify (G_OBJECT (store), "busy");
+
+ g_object_unref (store);
+}
+
+static void
+mail_account_store_write_source_cb (ESource *source,
+ GAsyncResult *result,
+ EMailAccountStore *store)
+{
+ GError *error = NULL;
+
+ /* FIXME EMailAccountStore should implement EAlertSink. */
+ if (!e_source_write_finish (source, result, &error)) {
+ g_warning ("%s: %s", G_STRFUNC, error->message);
+ g_error_free (error);
+ }
+
+ g_return_if_fail (store->priv->busy_count > 0);
+ store->priv->busy_count--;
+ g_object_notify (G_OBJECT (store), "busy");
+
+ g_object_unref (store);
+}
+
+static void
mail_account_store_clean_index (EMailAccountStore *store)
{
GQueue trash = G_QUEUE_INIT;
@@ -427,23 +448,34 @@ static void
mail_account_store_constructed (GObject *object)
{
EMailAccountStore *store;
+ EMailSession *session;
+ ESourceRegistry *registry;
const gchar *config_dir;
/* Chain up to parent's constructed() method. */
G_OBJECT_CLASS (e_mail_account_store_parent_class)->constructed (object);
store = E_MAIL_ACCOUNT_STORE (object);
+ session = e_mail_account_store_get_session (store);
+ registry = e_mail_session_get_registry (session);
+
+ /* Bind the default mail account ESource to our default
+ * CamelService, with help from some transform functions. */
+ g_object_bind_property_full (
+ registry, "default-mail-account",
+ store, "default-service",
+ G_BINDING_BIDIRECTIONAL |
+ G_BINDING_SYNC_CREATE,
+ e_binding_transform_source_to_service,
+ e_binding_transform_service_to_source,
+ session, (GDestroyNotify) NULL);
+
config_dir = mail_session_get_config_dir ();
/* XXX Should we take the filename as a constructor property? */
store->priv->sort_order_filename = g_build_filename (
config_dir, "sortorder.ini", NULL);
- /* XXX This is kinda lame, but should work until EAccount dies. */
- g_signal_connect (
- object, "notify::default-service",
- G_CALLBACK (mail_account_store_save_default), NULL);
-
e_extensible_load_extensions (E_EXTENSIBLE (object));
}
@@ -458,94 +490,55 @@ static void
mail_account_store_service_removed (EMailAccountStore *store,
CamelService *service)
{
- /* XXX On the account-mgmt branch this operation is asynchronous.
- * The 'busy_count' is bumped until changes are written back
- * to the D-Bus service. For now I guess we'll just block. */
-
- EAccountList *account_list;
- EAccount *account;
EMailSession *session;
- MailFolderCache *cache;
- CamelProvider *provider;
+ ESourceRegistry *registry;
+ ESource *source;
const gchar *uid;
session = e_mail_account_store_get_session (store);
- cache = e_mail_session_get_folder_cache (session);
+ registry = e_mail_session_get_registry (session);
- mail_folder_cache_service_removed (cache, service);
-
- account_list = e_get_account_list ();
uid = camel_service_get_uid (service);
- account = e_get_account_by_uid (uid);
- g_return_if_fail (account != NULL);
-
- /* no change */
- if (!account->enabled)
- return;
-
- provider = camel_service_get_provider (service);
- g_return_if_fail (provider != NULL);
-
- if (provider->flags & CAMEL_PROVIDER_IS_STORAGE)
- mail_disconnect_store (CAMEL_STORE (service));
+ source = e_source_registry_lookup_by_uid (registry, uid);
- /* Remove all the proxies the account has created.
- * FIXME This proxy stuff belongs in evolution-groupwise. */
- e_account_list_remove_account_proxies (account_list, account);
+ if (E_IS_SOURCE (source)) {
+ store->priv->busy_count++;
+ g_object_notify (G_OBJECT (store), "busy");
- e_account_list_remove (account_list, account);
-
- e_account_list_save (account_list);
+ /* XXX Should this be cancellable? */
+ e_source_registry_remove_source (
+ registry, source, NULL, (GAsyncReadyCallback)
+ mail_account_store_remove_source_cb,
+ g_object_ref (store));
+ }
}
static void
mail_account_store_service_enabled (EMailAccountStore *store,
CamelService *service)
{
- /* XXX On the account-mgmt branch this operation is asynchronous.
- * The 'busy_count' is bumped until changes are written back
- * to the D-Bus service. For now I guess we'll just block. */
-
EMailSession *session;
- MailFolderCache *cache;
- GSettings *settings;
+ ESourceRegistry *registry;
+ ESource *source;
const gchar *uid;
session = e_mail_account_store_get_session (store);
- cache = e_mail_session_get_folder_cache (session);
-
- mail_folder_cache_service_enabled (cache, service);
+ registry = e_mail_session_get_registry (session);
uid = camel_service_get_uid (service);
+ source = e_source_registry_lookup_by_uid (registry, uid);
- /* Handle built-in services that don't have an EAccount. */
-
- if (g_strcmp0 (uid, E_MAIL_SESSION_LOCAL_UID) == 0) {
- settings = g_settings_new ("org.gnome.evolution.mail");
- g_settings_set_boolean (settings, "enable-local", TRUE);
- g_object_unref (settings);
-
- } else if (g_strcmp0 (uid, E_MAIL_SESSION_VFOLDER_UID) == 0) {
- settings = g_settings_new ("org.gnome.evolution.mail");
- g_settings_set_boolean (settings, "enable-vfolders", TRUE);
- g_object_unref (settings);
-
- } else {
- EAccountList *account_list;
- EAccount *account;
-
- account_list = e_get_account_list ();
- account = e_get_account_by_uid (uid);
- g_return_if_fail (account != NULL);
-
- /* no change */
- if (account->enabled)
- return;
+ if (E_IS_SOURCE (source)) {
+ e_source_set_enabled (source, TRUE);
- account->enabled = TRUE;
+ store->priv->busy_count++;
+ g_object_notify (G_OBJECT (store), "busy");
- e_account_list_change (account_list, account);
- e_account_list_save (account_list);
+ /* XXX Should this be cancellable? */
+ e_source_write (
+ source, NULL, (GAsyncReadyCallback)
+ mail_account_store_write_source_cb,
+ g_object_ref (store));
}
}
@@ -553,63 +546,28 @@ static void
mail_account_store_service_disabled (EMailAccountStore *store,
CamelService *service)
{
- /* XXX On the account-mgmt branch this operation is asynchronous.
- * The 'busy_count' is bumped until changes are written back
- * to the D-Bus service. For now I guess we'll just block. */
-
EMailSession *session;
- MailFolderCache *cache;
- GSettings *settings;
+ ESourceRegistry *registry;
+ ESource *source;
const gchar *uid;
session = e_mail_account_store_get_session (store);
- cache = e_mail_session_get_folder_cache (session);
-
- mail_folder_cache_service_disabled (cache, service);
+ registry = e_mail_session_get_registry (session);
uid = camel_service_get_uid (service);
+ source = e_source_registry_lookup_by_uid (registry, uid);
- /* Handle built-in services that don't have an EAccount. */
+ if (E_IS_SOURCE (source)) {
+ e_source_set_enabled (source, FALSE);
- if (g_strcmp0 (uid, E_MAIL_SESSION_LOCAL_UID) == 0) {
- settings = g_settings_new ("org.gnome.evolution.mail");
- g_settings_set_boolean (settings, "enable-local", FALSE);
- g_object_unref (settings);
-
- } else if (g_strcmp0 (uid, E_MAIL_SESSION_VFOLDER_UID) == 0) {
- settings = g_settings_new ("org.gnome.evolution.mail");
- g_settings_set_boolean (settings, "enable-vfolders", FALSE);
- g_object_unref (settings);
-
- } else {
- EAccountList *account_list;
- EAccount *account;
- CamelProvider *provider;
+ store->priv->busy_count++;
+ g_object_notify (G_OBJECT (store), "busy");
- account_list = e_get_account_list ();
- account = e_get_account_by_uid (uid);
- g_return_if_fail (account != NULL);
-
- /* no change */
- if (!account->enabled)
- return;
-
- account->enabled = FALSE;
-
- provider = camel_service_get_provider (service);
- g_return_if_fail (provider != NULL);
-
- if (provider->flags & CAMEL_PROVIDER_IS_STORAGE)
- mail_disconnect_store (CAMEL_STORE (service));
-
- /* FIXME This proxy stuff belongs in evolution-groupwise. */
- e_account_list_remove_account_proxies (account_list, account);
-
- if (account->parent_uid != NULL)
- e_account_list_remove (account_list, account);
-
- e_account_list_change (account_list, account);
- e_account_list_save (account_list);
+ /* XXX Should this be cancellable? */
+ e_source_write (
+ source, NULL, (GAsyncReadyCallback)
+ mail_account_store_write_source_cb,
+ g_object_ref (store));
}
}
@@ -643,25 +601,14 @@ mail_account_store_remove_requested (EMailAccountStore *store,
GtkWindow *parent_window,
CamelService *service)
{
- EAccountList *account_list;
- EAccount *account;
- const gchar *alert;
- const gchar *uid;
gint response;
- account_list = e_get_account_list ();
- uid = camel_service_get_uid (service);
- account = e_get_account_by_uid (uid);
-
- g_return_val_if_fail (account != NULL, FALSE);
-
- /* FIXME This proxy stuff belongs in evolution-groupwise. */
- if (e_account_list_account_has_proxies (account_list, account))
- alert = "mail:ask-delete-account-with-proxies";
- else
- alert = "mail:ask-delete-account";
+ /* FIXME Need to use "mail:ask-delete-account-with-proxies" if the
+ * mail account has proxies. But this is groupwise-specific
+ * and doesn't belong here anyway. Think of a better idea. */
- response = e_alert_run_dialog_for_args (parent_window, alert, NULL);
+ response = e_alert_run_dialog_for_args (
+ parent_window, "mail:ask-delete-account", NULL);
return (response == GTK_RESPONSE_YES);
}
@@ -679,34 +626,12 @@ mail_account_store_disable_requested (EMailAccountStore *store,
GtkWindow *parent_window,
CamelService *service)
{
- EAccountList *account_list;
- EAccount *account;
- const gchar *uid;
- gint response;
-
- account_list = e_get_account_list ();
- uid = camel_service_get_uid (service);
- account = e_get_account_by_uid (uid);
-
- /* "On This Computer" and "Search Folders" do not have
- * EAccounts, so just silently return TRUE if we failed
- * to find a matching EAccount for the CamelService. */
-
- /* Silently return TRUE if we failed to find a matching
- * EAccount since "On This Computer" and "Search Folders"
- * do not have EAccounts. */
- if (account == NULL)
- return TRUE;
-
- /* FIXME This proxy stuff belongs in evolution-groupwise. */
- if (e_account_list_account_has_proxies (account_list, account))
- response = e_alert_run_dialog_for_args (
- parent_window,
- "mail:ask-delete-proxy-accounts", NULL);
- else
- response = GTK_RESPONSE_YES;
+ /* FIXME Need to check whether the account has proxies and run a
+ * "mail:ask-delete-proxy-accounts" alert dialog, but this
+ * is groupwise-specific and doesn't belong here anyway.
+ * Think of a better idea. */
- return (response == GTK_RESPONSE_YES);
+ return TRUE;
}
static void
@@ -1086,13 +1011,18 @@ e_mail_account_store_add_service (EMailAccountStore *store,
g_object_unref (settings);
} else {
- EAccount *account;
+ EMailSession *session;
+ ESourceRegistry *registry;
+ ESource *source;
+
+ session = e_mail_account_store_get_session (store);
- account = e_get_account_by_uid (uid);
- g_return_if_fail (account != NULL);
+ registry = e_mail_session_get_registry (session);
+ source = e_source_registry_lookup_by_uid (registry, uid);
+ g_return_if_fail (source != NULL);
builtin = FALSE;
- enabled = account->enabled;
+ enabled = e_source_get_enabled (source);
}
/* Where do we insert new services now that accounts can be
diff --git a/mail/e-mail-backend.c b/mail/e-mail-backend.c
index c350bd7..2a0a386 100644
--- a/mail/e-mail-backend.c
+++ b/mail/e-mail-backend.c
@@ -32,15 +32,15 @@
#include <glib/gstdio.h>
#include <glib/gi18n-lib.h>
#include <libedataserver/e-data-server-util.h>
+#include <libedataserver/e-source-mail-account.h>
+#include <libedataserver/e-source-mail-composition.h>
+#include <libedataserver/e-source-mail-submission.h>
#include <shell/e-shell.h>
#include <libevolution-utils/e-alert-dialog.h>
#include <libevolution-utils/e-alert-sink.h>
-#include <misc/e-account-combo-box.h>
-
-#include <libemail-utils/e-account-utils.h>
#include <libemail-engine/e-mail-folder-utils.h>
#include <libemail-engine/e-mail-session.h>
#include <libemail-engine/e-mail-store-utils.h>
@@ -141,11 +141,14 @@ mail_backend_prepare_for_offline_cb (EShell *shell,
{
GtkWindow *window;
EMailSession *session;
+ ESourceRegistry *registry;
GList *list, *link;
+ const gchar *extension_name;
gboolean synchronize = FALSE;
window = e_shell_get_active_window (shell);
session = e_mail_backend_get_session (backend);
+ registry = e_mail_session_get_registry (session);
if (e_shell_get_network_available (shell) &&
e_shell_backend_is_started (E_SHELL_BACKEND (backend)))
@@ -158,12 +161,17 @@ mail_backend_prepare_for_offline_cb (EShell *shell,
CAMEL_SESSION (session), FALSE);
}
- list = camel_session_list_services (CAMEL_SESSION (session));
+ extension_name = E_SOURCE_EXTENSION_MAIL_ACCOUNT;
+ list = e_source_registry_list_sources (registry, extension_name);
for (link = list; link != NULL; link = g_list_next (link)) {
+ ESource *source = E_SOURCE (link->data);
CamelService *service;
+ const gchar *uid;
- service = CAMEL_SERVICE (link->data);
+ uid = e_source_get_uid (source);
+ service = camel_session_get_service (
+ CAMEL_SESSION (session), uid);
if (!CAMEL_IS_STORE (service))
continue;
@@ -185,27 +193,31 @@ mail_backend_prepare_for_online_cb (EShell *shell,
EMailBackend *backend)
{
EMailSession *session;
+ ESourceRegistry *registry;
GList *list, *link;
+ const gchar *extension_name;
session = e_mail_backend_get_session (backend);
+ registry = e_mail_session_get_registry (session);
+
camel_session_set_online (CAMEL_SESSION (session), TRUE);
- list = camel_session_list_services (CAMEL_SESSION (session));
+ extension_name = E_SOURCE_EXTENSION_MAIL_ACCOUNT;
+ list = e_source_registry_list_sources (registry, extension_name);
for (link = list; link != NULL; link = g_list_next (link)) {
+ ESource *source = E_SOURCE (link->data);
CamelService *service;
- EAccount *account;
const gchar *uid;
- service = CAMEL_SERVICE (link->data);
-
- if (!CAMEL_IS_STORE (service))
+ if (!e_source_get_enabled (source))
continue;
- uid = camel_service_get_uid (service);
- account = e_get_account_by_uid (uid);
+ uid = e_source_get_uid (source);
+ service = camel_session_get_service (
+ CAMEL_SESSION (session), uid);
- if (account != NULL && !account->enabled)
+ if (!CAMEL_IS_STORE (service))
continue;
/* FIXME Not passing a GCancellable. */
@@ -273,7 +285,6 @@ mail_backend_prepare_for_quit_cb (EShell *shell,
EActivity *activity,
EMailBackend *backend)
{
- EAccountList *account_list;
EMailSession *session;
GList *list, *link;
gboolean delete_junk;
@@ -286,9 +297,6 @@ mail_backend_prepare_for_quit_cb (EShell *shell,
camel_application_is_exiting = TRUE;
- account_list = e_get_account_list ();
- e_account_list_prune_proxies (account_list);
-
mail_vfolder_shutdown ();
/* Cancel all pending activities. */
@@ -399,20 +407,26 @@ mail_backend_folder_deleted_cb (MailFolderCache *folder_cache,
const gchar *folder_name,
EMailBackend *backend)
{
+ EShell *shell;
CamelStoreClass *class;
- EAccountList *account_list;
- EIterator *iterator;
+ ESourceRegistry *registry;
+ EShellBackend *shell_backend;
EMailSession *session;
EAlertSink *alert_sink;
+ GList *list, *link;
+ const gchar *extension_name;
const gchar *local_drafts_folder_uri;
const gchar *local_sent_folder_uri;
- gboolean write_config = FALSE;
gchar *uri;
/* Check whether the deleted folder was a designated Drafts or
* Sent folder for any mail account, and if so revert the setting
* to the equivalent local folder, which is always present. */
+ shell_backend = E_SHELL_BACKEND (backend);
+ shell = e_shell_backend_get_shell (shell_backend);
+ registry = e_shell_get_registry (shell);
+
class = CAMEL_STORE_GET_CLASS (store);
g_return_if_fail (class->compare_folder_name != NULL);
@@ -429,51 +443,69 @@ mail_backend_folder_deleted_cb (MailFolderCache *folder_cache,
uri = e_mail_folder_uri_build (store, folder_name);
- account_list = e_get_account_list ();
- iterator = e_list_get_iterator (E_LIST (account_list));
+ extension_name = E_SOURCE_EXTENSION_MAIL_COMPOSITION;
+ list = e_source_registry_list_sources (registry, extension_name);
+
+ for (link = list; link != NULL; link = g_list_next (link)) {
+ ESource *source = E_SOURCE (link->data);
+ ESourceExtension *extension;
+ const gchar *drafts_folder_uri;
- while (e_iterator_is_valid (iterator)) {
- EAccount *account;
+ extension = e_source_get_extension (source, extension_name);
- /* XXX EIterator misuses const. */
- account = (EAccount *) e_iterator_get (iterator);
+ drafts_folder_uri =
+ e_source_mail_composition_get_drafts_folder (
+ E_SOURCE_MAIL_COMPOSITION (extension));
- if (account->sent_folder_uri != NULL) {
- gboolean match;
+ if (class->compare_folder_name (drafts_folder_uri, uri)) {
+ GError *error = NULL;
- match = class->compare_folder_name (
- account->sent_folder_uri, uri);
+ e_source_mail_composition_set_drafts_folder (
+ E_SOURCE_MAIL_COMPOSITION (extension),
+ local_drafts_folder_uri);
- if (match) {
- g_free (account->sent_folder_uri);
- account->sent_folder_uri =
- g_strdup (local_sent_folder_uri);
- write_config = TRUE;
+ /* FIXME This is a blocking D-Bus method call. */
+ if (!e_source_write_sync (source, NULL, &error)) {
+ g_warning ("%s", error->message);
+ g_error_free (error);
}
}
+ }
+
+ g_list_free (list);
- if (account->drafts_folder_uri != NULL) {
- gboolean match;
+ extension_name = E_SOURCE_EXTENSION_MAIL_SUBMISSION;
+ list = e_source_registry_list_sources (registry, extension_name);
- match = class->compare_folder_name (
- account->drafts_folder_uri, uri);
+ for (link = list; link != NULL; link = g_list_next (link)) {
+ ESource *source = E_SOURCE (link->data);
+ ESourceExtension *extension;
+ const gchar *sent_folder_uri;
+
+ extension = e_source_get_extension (source, extension_name);
+
+ sent_folder_uri =
+ e_source_mail_submission_get_sent_folder (
+ E_SOURCE_MAIL_SUBMISSION (extension));
+
+ if (class->compare_folder_name (sent_folder_uri, uri)) {
+ GError *error = NULL;
- if (match) {
- g_free (account->drafts_folder_uri);
- account->drafts_folder_uri =
- g_strdup (local_drafts_folder_uri);
- write_config = TRUE;
+ e_source_mail_submission_set_sent_folder (
+ E_SOURCE_MAIL_SUBMISSION (extension),
+ local_sent_folder_uri);
+
+ /* FIXME This is a blocking D-Bus method call. */
+ if (!e_source_write_sync (source, NULL, &error)) {
+ g_warning ("%s", error->message);
+ g_error_free (error);
}
}
-
- e_iterator_next (iterator);
}
- g_object_unref (iterator);
- g_free (uri);
+ g_list_free (list);
- if (write_config)
- mail_config_write ();
+ g_free (uri);
/* This does something completely different.
* XXX Make it a separate signal handler? */
@@ -487,10 +519,12 @@ mail_backend_folder_renamed_cb (MailFolderCache *folder_cache,
const gchar *new_folder_name,
EMailBackend *backend)
{
+ EShell *shell;
CamelStoreClass *class;
- EAccountList *account_list;
- EIterator *iterator;
- gboolean write_config = FALSE;
+ ESourceRegistry *registry;
+ EShellBackend *shell_backend;
+ GList *list, *link;
+ const gchar *extension_name;
gchar *old_uri;
gchar *new_uri;
gint ii;
@@ -500,54 +534,84 @@ mail_backend_folder_renamed_cb (MailFolderCache *folder_cache,
"views/custom_view-"
};
+ /* Check whether the renamed folder was a designated Drafts or
+ * Sent folder for any mail account, and if so update the setting
+ * to the new folder name. */
+
+ shell_backend = E_SHELL_BACKEND (backend);
+ shell = e_shell_backend_get_shell (shell_backend);
+ registry = e_shell_get_registry (shell);
+
class = CAMEL_STORE_GET_CLASS (store);
g_return_if_fail (class->compare_folder_name != NULL);
old_uri = e_mail_folder_uri_build (store, old_folder_name);
new_uri = e_mail_folder_uri_build (store, new_folder_name);
- account_list = e_get_account_list ();
- iterator = e_list_get_iterator (E_LIST (account_list));
+ extension_name = E_SOURCE_EXTENSION_MAIL_COMPOSITION;
+ list = e_source_registry_list_sources (registry, extension_name);
+
+ for (link = list; link != NULL; link = g_list_next (link)) {
+ ESource *source = E_SOURCE (link->data);
+ ESourceExtension *extension;
+ const gchar *drafts_folder_uri;
- while (e_iterator_is_valid (iterator)) {
- EAccount *account;
+ extension = e_source_get_extension (source, extension_name);
- /* XXX EIterator misuses const. */
- account = (EAccount *) e_iterator_get (iterator);
+ drafts_folder_uri =
+ e_source_mail_composition_get_drafts_folder (
+ E_SOURCE_MAIL_COMPOSITION (extension));
- if (account->sent_folder_uri != NULL) {
- gboolean match;
+ if (class->compare_folder_name (drafts_folder_uri, old_uri)) {
+ GError *error = NULL;
- match = class->compare_folder_name (
- account->sent_folder_uri, old_uri);
+ e_source_mail_composition_set_drafts_folder (
+ E_SOURCE_MAIL_COMPOSITION (extension),
+ new_uri);
- if (match) {
- g_free (account->sent_folder_uri);
- account->sent_folder_uri = g_strdup (new_uri);
- write_config = TRUE;
+ /* FIXME This is a blocking D-Bus method call. */
+ if (!e_source_write_sync (source, NULL, &error)) {
+ g_warning ("%s", error->message);
+ g_error_free (error);
}
}
+ }
- if (account->drafts_folder_uri != NULL) {
- gboolean match;
+ g_list_free (list);
+
+ extension_name = E_SOURCE_EXTENSION_MAIL_SUBMISSION;
+ list = e_source_registry_list_sources (registry, extension_name);
- match = class->compare_folder_name (
- account->drafts_folder_uri, old_uri);
+ for (link = list; link != NULL; link = g_list_next (link)) {
+ ESource *source = E_SOURCE (link->data);
+ ESourceExtension *extension;
+ const gchar *sent_folder_uri;
- if (match) {
- g_free (account->drafts_folder_uri);
- account->drafts_folder_uri = g_strdup (new_uri);
- write_config = TRUE;
+ extension = e_source_get_extension (source, extension_name);
+
+ sent_folder_uri =
+ e_source_mail_submission_get_sent_folder (
+ E_SOURCE_MAIL_SUBMISSION (extension));
+
+ if (class->compare_folder_name (sent_folder_uri, old_uri)) {
+ GError *error = NULL;
+
+ e_source_mail_submission_set_sent_folder (
+ E_SOURCE_MAIL_SUBMISSION (extension),
+ new_uri);
+
+ /* FIXME This is a blocking D-Bus method call. */
+ if (!e_source_write_sync (source, NULL, &error)) {
+ g_warning ("%s", error->message);
+ g_error_free (error);
}
}
-
- e_iterator_next (iterator);
}
- g_object_unref (iterator);
+ g_list_free (list);
- if (write_config)
- mail_config_write ();
+ g_free (old_uri);
+ g_free (new_uri);
/* Rename GalView files. */
@@ -565,9 +629,6 @@ mail_backend_folder_renamed_cb (MailFolderCache *folder_cache,
g_free (newname);
}
- g_free (old_uri);
- g_free (new_uri);
-
/* This does something completely different.
* XXX Make it a separate signal handler? */
mail_filter_rename_folder (
@@ -606,10 +667,8 @@ mail_backend_folder_changed_cb (MailFolderCache *folder_cache,
g_object_unref (folder);
}
- g_free (folder_uri);
-
target = em_event_target_new_folder (
- event, store, folder_name, new_messages,
+ event, store, folder_uri, new_messages,
msg_uid, msg_sender, msg_subject);
folder_type = (flags & CAMEL_FOLDER_TYPE_MASK);
@@ -939,6 +998,7 @@ mail_backend_constructed (GObject *object)
EShell *shell;
EShellBackend *shell_backend;
MailFolderCache *folder_cache;
+ ESourceRegistry *registry;
priv = E_MAIL_BACKEND_GET_PRIVATE (object);
@@ -948,9 +1008,8 @@ mail_backend_constructed (GObject *object)
if (camel_init (e_get_user_data_dir (), TRUE) != 0)
exit (0);
- camel_provider_init ();
-
- priv->session = e_mail_ui_session_new ();
+ registry = e_shell_get_registry (shell);
+ priv->session = e_mail_ui_session_new (registry);
g_signal_connect (
priv->session, "flush-outbox",
@@ -978,10 +1037,6 @@ mail_backend_constructed (GObject *object)
G_CALLBACK (mail_backend_job_finished_cb),
shell_backend);
- /* FIXME This is an evil hack that needs to die.
- * Give EAccountComboBox a CamelSession property. */
- e_account_combo_box_set_session (CAMEL_SESSION (priv->session));
-
g_signal_connect (
priv->session, "store-added",
G_CALLBACK (mail_backend_add_store),
@@ -1029,7 +1084,6 @@ mail_backend_constructed (GObject *object)
G_CALLBACK (mail_backend_folder_changed_cb), shell_backend);
mail_config_init (priv->session);
- mail_msg_init ();
mail_msg_register_activities (
mail_mt_create_activity,
diff --git a/mail/e-mail-config-auth-check.c b/mail/e-mail-config-auth-check.c
new file mode 100644
index 0000000..612a56d
--- /dev/null
+++ b/mail/e-mail-config-auth-check.c
@@ -0,0 +1,503 @@
+/*
+ * e-mail-config-auth-check.c
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) version 3.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with the program; if not, see <http://www.gnu.org/licenses/>
+ *
+ */
+
+#include "e-mail-config-auth-check.h"
+
+#include <config.h>
+#include <glib/gi18n-lib.h>
+
+#include <libevolution-utils/e-alert.h>
+#include <e-util/e-mktemp.h>
+#include <misc/e-auth-combo-box.h>
+
+#define E_MAIL_CONFIG_AUTH_CHECK_GET_PRIVATE(obj) \
+ (G_TYPE_INSTANCE_GET_PRIVATE \
+ ((obj), E_TYPE_MAIL_CONFIG_AUTH_CHECK, EMailConfigAuthCheckPrivate))
+
+typedef struct _AsyncContext AsyncContext;
+
+struct _EMailConfigAuthCheckPrivate {
+ EMailConfigBackend *backend;
+ ESource *scratch_source;
+ gchar *active_mechanism;
+
+ GtkWidget *combo_box; /* not referenced */
+};
+
+struct _AsyncContext {
+ EMailConfigAuthCheck *auth_check;
+ CamelSession *temporary_session;
+ EActivity *activity;
+};
+
+enum {
+ PROP_0,
+ PROP_ACTIVE_MECHANISM,
+ PROP_BACKEND,
+ PROP_SCRATCH_SOURCE
+};
+
+G_DEFINE_TYPE (
+ EMailConfigAuthCheck,
+ e_mail_config_auth_check,
+ GTK_TYPE_BOX)
+
+static void
+async_context_free (AsyncContext *async_context)
+{
+ if (async_context->auth_check != NULL)
+ g_object_unref (async_context->auth_check);
+
+ if (async_context->temporary_session != NULL)
+ g_object_unref (async_context->temporary_session);
+
+ if (async_context->activity != NULL)
+ g_object_unref (async_context->activity);
+
+ g_slice_free (AsyncContext, async_context);
+}
+
+static void
+mail_config_auth_check_update_done_cb (GObject *source_object,
+ GAsyncResult *result,
+ gpointer user_data)
+{
+ AsyncContext *async_context = user_data;
+ EMailConfigAuthCheck *auth_check;
+ EAlertSink *alert_sink;
+ GList *available_authtypes;
+ GError *error = NULL;
+
+ auth_check = async_context->auth_check;
+ alert_sink = e_activity_get_alert_sink (async_context->activity);
+
+ available_authtypes = camel_service_query_auth_types_finish (
+ CAMEL_SERVICE (source_object), result, &error);
+
+ if (e_activity_handle_cancellation (async_context->activity, error)) {
+ g_warn_if_fail (available_authtypes == NULL);
+ g_error_free (error);
+
+ } else if (error != NULL) {
+ g_warn_if_fail (available_authtypes == NULL);
+ e_alert_submit (
+ alert_sink,
+ "mail:checking-service-error",
+ error->message, NULL);
+ g_error_free (error);
+
+ } else {
+ e_auth_combo_box_update_available (
+ E_AUTH_COMBO_BOX (auth_check->priv->combo_box),
+ available_authtypes);
+ g_list_free (available_authtypes);
+ }
+
+ gtk_widget_set_sensitive (GTK_WIDGET (auth_check), TRUE);
+
+ async_context_free (async_context);
+}
+
+static void
+mail_config_auth_check_update (EMailConfigAuthCheck *auth_check)
+{
+ EActivity *activity;
+ EMailConfig *config;
+ EMailConfigBackend *backend;
+ ESource *source;
+ CamelService *service;
+ CamelSession *session;
+ CamelSettings *settings;
+ GCancellable *cancellable;
+ CamelProviderType provider_type;
+ AsyncContext *async_context;
+ const gchar *backend_name;
+ gchar *temp_dir;
+ GError *error = NULL;
+
+ backend = e_mail_config_auth_check_get_backend (auth_check);
+ source = e_mail_config_auth_check_get_scratch_source (auth_check);
+ config = e_mail_config_backend_get_config (backend);
+ settings = e_mail_config_get_settings (config, source);
+
+ provider_type = E_MAIL_CONFIG_GET_CLASS (config)->provider_type;
+ backend_name = E_MAIL_CONFIG_BACKEND_GET_CLASS (backend)->backend_name;
+
+ temp_dir = e_mkdtemp ("evolution-auth-check-XXXXXX");
+
+ /* Create a temporary session for our temporary service.
+ * Use the same temporary directory for "user-data-dir" and
+ * "user-cache-dir". For our purposes it shouldn't matter. */
+ session = g_object_new (
+ CAMEL_TYPE_SESSION,
+ "user-data-dir", temp_dir,
+ "user-cache-dir", temp_dir,
+ NULL);
+
+ /* This returns a BORROWED reference to the CamelService. */
+ service = camel_session_add_service (
+ session, "fake-uid", backend_name, provider_type, &error);
+
+ g_free (temp_dir);
+
+ if (error != NULL) {
+ g_warn_if_fail (service == NULL);
+ e_alert_submit (
+ E_ALERT_SINK (config),
+ "mail:checking-service-error",
+ error->message, NULL);
+ g_error_free (error);
+ return;
+ }
+
+ g_return_if_fail (CAMEL_IS_SERVICE (service));
+
+ camel_service_set_settings (service, settings);
+
+ activity = e_mail_config_new_activity (config);
+ cancellable = e_activity_get_cancellable (activity);
+
+ gtk_widget_set_sensitive (GTK_WIDGET (auth_check), FALSE);
+
+ async_context = g_slice_new (AsyncContext);
+ async_context->auth_check = g_object_ref (auth_check);
+ async_context->temporary_session = session; /* takes ownership */
+ async_context->activity = activity; /* takes ownership */
+
+ camel_service_query_auth_types (
+ service, G_PRIORITY_DEFAULT, cancellable,
+ mail_config_auth_check_update_done_cb, async_context);
+}
+
+static void
+mail_config_auth_check_clicked_cb (GtkButton *button,
+ EMailConfigAuthCheck *auth_check)
+{
+ mail_config_auth_check_update (auth_check);
+}
+
+static void
+mail_config_auth_check_init_mechanism (EMailConfigAuthCheck *auth_check)
+{
+ ESource *source;
+ EMailConfig *config;
+ EMailConfigBackend *backend;
+ CamelProvider *provider;
+ CamelSettings *settings;
+ const gchar *auth_mechanism = NULL;
+
+ /* Pick an initial active mechanism name by examining both
+ * the corresponding CamelNetworkSettings and CamelProvider. */
+
+ backend = e_mail_config_auth_check_get_backend (auth_check);
+ source = e_mail_config_auth_check_get_scratch_source (auth_check);
+
+ config = e_mail_config_backend_get_config (backend);
+ provider = e_mail_config_backend_get_provider (backend);
+
+ settings = e_mail_config_get_settings (config, source);
+ g_return_if_fail (CAMEL_IS_NETWORK_SETTINGS (settings));
+
+ auth_mechanism =
+ camel_network_settings_get_auth_mechanism (
+ CAMEL_NETWORK_SETTINGS (settings));
+
+ /* If CamelNetworkSettings does not have a mechanism name set,
+ * choose from the CamelProvider's list of supported mechanisms. */
+ if (auth_mechanism == NULL && provider != NULL) {
+ if (provider->authtypes != NULL) {
+ CamelServiceAuthType *auth_type;
+ auth_type = provider->authtypes->data;
+ auth_mechanism = auth_type->authproto;
+ }
+ }
+
+ if (auth_mechanism != NULL)
+ e_mail_config_auth_check_set_active_mechanism (
+ auth_check, auth_mechanism);
+}
+
+static void
+mail_config_auth_check_set_backend (EMailConfigAuthCheck *auth_check,
+ EMailConfigBackend *backend)
+{
+ g_return_if_fail (E_IS_MAIL_CONFIG_BACKEND (backend));
+ g_return_if_fail (auth_check->priv->backend == NULL);
+
+ auth_check->priv->backend = g_object_ref (backend);
+}
+
+static void
+mail_config_auth_check_set_scratch_source (EMailConfigAuthCheck *auth_check,
+ ESource *scratch_source)
+{
+ g_return_if_fail (E_IS_SOURCE (scratch_source));
+ g_return_if_fail (auth_check->priv->scratch_source == NULL);
+
+ auth_check->priv->scratch_source = g_object_ref (scratch_source);
+}
+
+static void
+mail_config_auth_check_set_property (GObject *object,
+ guint property_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ switch (property_id) {
+ case PROP_ACTIVE_MECHANISM:
+ e_mail_config_auth_check_set_active_mechanism (
+ E_MAIL_CONFIG_AUTH_CHECK (object),
+ g_value_get_string (value));
+ return;
+
+ case PROP_BACKEND:
+ mail_config_auth_check_set_backend (
+ E_MAIL_CONFIG_AUTH_CHECK (object),
+ g_value_get_object (value));
+ return;
+
+ case PROP_SCRATCH_SOURCE:
+ mail_config_auth_check_set_scratch_source (
+ E_MAIL_CONFIG_AUTH_CHECK (object),
+ g_value_get_object (value));
+ return;
+ }
+
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+}
+
+static void
+mail_config_auth_check_get_property (GObject *object,
+ guint property_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ switch (property_id) {
+ case PROP_ACTIVE_MECHANISM:
+ g_value_set_string (
+ value,
+ e_mail_config_auth_check_get_active_mechanism (
+ E_MAIL_CONFIG_AUTH_CHECK (object)));
+ return;
+
+ case PROP_BACKEND:
+ g_value_set_object (
+ value,
+ e_mail_config_auth_check_get_backend (
+ E_MAIL_CONFIG_AUTH_CHECK (object)));
+ return;
+
+ case PROP_SCRATCH_SOURCE:
+ g_value_set_object (
+ value,
+ e_mail_config_auth_check_get_scratch_source (
+ E_MAIL_CONFIG_AUTH_CHECK (object)));
+ return;
+ }
+
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+}
+
+static void
+mail_config_auth_check_dispose (GObject *object)
+{
+ EMailConfigAuthCheckPrivate *priv;
+
+ priv = E_MAIL_CONFIG_AUTH_CHECK_GET_PRIVATE (object);
+
+ if (priv->backend != NULL) {
+ g_object_unref (priv->backend);
+ priv->backend = NULL;
+ }
+
+ if (priv->scratch_source != NULL) {
+ g_object_unref (priv->scratch_source);
+ priv->scratch_source = NULL;
+ }
+
+ /* Chain up to parent's dispose() method. */
+ G_OBJECT_CLASS (e_mail_config_auth_check_parent_class)->
+ dispose (object);
+}
+
+static void
+mail_config_auth_check_finalize (GObject *object)
+{
+ EMailConfigAuthCheckPrivate *priv;
+
+ priv = E_MAIL_CONFIG_AUTH_CHECK_GET_PRIVATE (object);
+
+ g_free (priv->active_mechanism);
+
+ /* Chain up to parent's finalize() method. */
+ G_OBJECT_CLASS (e_mail_config_auth_check_parent_class)->
+ finalize (object);
+}
+
+static void
+mail_config_auth_check_constructed (GObject *object)
+{
+ EMailConfigAuthCheck *auth_check;
+ EMailConfigBackend *backend;
+ CamelProvider *provider;
+ GtkWidget *widget;
+ const gchar *text;
+
+ /* Chain up to parent's constructed() method. */
+ G_OBJECT_CLASS (e_mail_config_auth_check_parent_class)->
+ constructed (object);
+
+ auth_check = E_MAIL_CONFIG_AUTH_CHECK (object);
+ backend = e_mail_config_auth_check_get_backend (auth_check);
+ provider = e_mail_config_backend_get_provider (backend);
+
+ widget = e_auth_combo_box_new ();
+ e_auth_combo_box_set_provider (E_AUTH_COMBO_BOX (widget), provider);
+ gtk_box_pack_start (GTK_BOX (object), widget, FALSE, FALSE, 0);
+ auth_check->priv->combo_box = widget; /* do not reference */
+ gtk_widget_show (widget);
+
+ g_object_bind_property (
+ widget, "active-id",
+ auth_check, "active-mechanism",
+ G_BINDING_BIDIRECTIONAL |
+ G_BINDING_SYNC_CREATE);
+
+ text = _("Check for Supported Types");
+ widget = gtk_button_new_with_label (text);
+ gtk_box_pack_start (GTK_BOX (object), widget, FALSE, FALSE, 0);
+ gtk_widget_show (widget);
+
+ g_signal_connect (
+ widget, "clicked",
+ G_CALLBACK (mail_config_auth_check_clicked_cb),
+ auth_check);
+
+ mail_config_auth_check_init_mechanism (auth_check);
+}
+
+static void
+e_mail_config_auth_check_class_init (EMailConfigAuthCheckClass *class)
+{
+ GObjectClass *object_class;
+
+ g_type_class_add_private (class, sizeof (EMailConfigAuthCheckPrivate));
+
+ object_class = G_OBJECT_CLASS (class);
+ object_class->set_property = mail_config_auth_check_set_property;
+ object_class->get_property = mail_config_auth_check_get_property;
+ object_class->dispose = mail_config_auth_check_dispose;
+ object_class->finalize = mail_config_auth_check_finalize;
+ object_class->constructed = mail_config_auth_check_constructed;
+
+ g_object_class_install_property (
+ object_class,
+ PROP_ACTIVE_MECHANISM,
+ g_param_spec_string (
+ "active-mechanism",
+ "Active Mechanism",
+ "Active authentication mechanism",
+ NULL,
+ G_PARAM_READWRITE |
+ G_PARAM_STATIC_STRINGS));
+
+ g_object_class_install_property (
+ object_class,
+ PROP_BACKEND,
+ g_param_spec_object (
+ "backend",
+ "Backend",
+ "Mail configuration backend",
+ E_TYPE_MAIL_CONFIG_BACKEND,
+ G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT_ONLY |
+ G_PARAM_STATIC_STRINGS));
+
+ g_object_class_install_property (
+ object_class,
+ PROP_SCRATCH_SOURCE,
+ g_param_spec_object (
+ "scratch-source",
+ "Scratch Source",
+ "The ESource being edited",
+ E_TYPE_SOURCE,
+ G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT_ONLY |
+ G_PARAM_STATIC_STRINGS));
+}
+
+static void
+e_mail_config_auth_check_init (EMailConfigAuthCheck *auth_check)
+{
+ auth_check->priv = E_MAIL_CONFIG_AUTH_CHECK_GET_PRIVATE (auth_check);
+
+ gtk_orientable_set_orientation (
+ GTK_ORIENTABLE (auth_check),
+ GTK_ORIENTATION_HORIZONTAL);
+
+ gtk_box_set_spacing (GTK_BOX (auth_check), 6);
+}
+
+GtkWidget *
+e_mail_config_auth_check_new (EMailConfigBackend *backend,
+ ESource *scratch_source)
+{
+ g_return_val_if_fail (E_IS_MAIL_CONFIG_BACKEND (backend), NULL);
+ g_return_val_if_fail (E_IS_SOURCE (scratch_source), NULL);
+
+ return g_object_new (
+ E_TYPE_MAIL_CONFIG_AUTH_CHECK,
+ "backend", backend, "scratch-source", scratch_source, NULL);
+}
+
+EMailConfigBackend *
+e_mail_config_auth_check_get_backend (EMailConfigAuthCheck *auth_check)
+{
+ g_return_val_if_fail (E_IS_MAIL_CONFIG_AUTH_CHECK (auth_check), NULL);
+
+ return auth_check->priv->backend;
+}
+
+ESource *
+e_mail_config_auth_check_get_scratch_source (EMailConfigAuthCheck *auth_check)
+{
+ g_return_val_if_fail (E_IS_MAIL_CONFIG_AUTH_CHECK (auth_check), NULL);
+
+ return auth_check->priv->scratch_source;
+}
+
+const gchar *
+e_mail_config_auth_check_get_active_mechanism (EMailConfigAuthCheck *auth_check)
+{
+ g_return_val_if_fail (E_IS_MAIL_CONFIG_AUTH_CHECK (auth_check), NULL);
+
+ return auth_check->priv->active_mechanism;
+}
+
+void
+e_mail_config_auth_check_set_active_mechanism (EMailConfigAuthCheck *auth_check,
+ const gchar *active_mechanism)
+{
+ g_return_if_fail (E_IS_MAIL_CONFIG_AUTH_CHECK (auth_check));
+
+ g_free (auth_check->priv->active_mechanism);
+ auth_check->priv->active_mechanism = g_strdup (active_mechanism);
+
+ g_object_notify (G_OBJECT (auth_check), "active-mechanism");
+}
+
diff --git a/mail/e-mail-config-auth-check.h b/mail/e-mail-config-auth-check.h
new file mode 100644
index 0000000..18b170e
--- /dev/null
+++ b/mail/e-mail-config-auth-check.h
@@ -0,0 +1,76 @@
+/*
+ * e-mail-config-auth-check.h
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) version 3.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with the program; if not, see <http://www.gnu.org/licenses/>
+ *
+ */
+
+#ifndef E_MAIL_CONFIG_AUTH_CHECK_H
+#define E_MAIL_CONFIG_AUTH_CHECK_H
+
+#include <mail/e-mail-config-backend.h>
+
+/* Standard GObject macros */
+#define E_TYPE_MAIL_CONFIG_AUTH_CHECK \
+ (e_mail_config_auth_check_get_type ())
+#define E_MAIL_CONFIG_AUTH_CHECK(obj) \
+ (G_TYPE_CHECK_INSTANCE_CAST \
+ ((obj), E_TYPE_MAIL_CONFIG_AUTH_CHECK, EMailConfigAuthCheck))
+#define E_MAIL_CONFIG_AUTH_CHECK_CLASS(cls) \
+ (G_TYPE_CHECK_CLASS_CAST \
+ ((cls), E_TYPE_MAIL_CONFIG_AUTH_CHECK, EMailConfigAuthCheckClass))
+#define E_IS_MAIL_CONFIG_AUTH_CHECK(obj) \
+ (G_TYPE_CHECK_INSTANCE_TYPE \
+ ((obj), E_TYPE_MAIL_CONFIG_AUTH_CHECK))
+#define E_IS_MAIL_CONFIG_AUTH_CHECK_CLASS(cls) \
+ (G_TYPE_CHECK_CLASS_TYPE \
+ ((cls), E_TYPE_MAIL_CONFIG_AUTH_CHECK))
+#define E_MAIL_CONFIG_AUTH_CHECK_GET_CLASS(obj) \
+ (G_TYPE_INSTANCE_GET_CLASS \
+ ((obj), E_TYPE_MAIL_CONFIG_AUTH_CHECK, EMailConfigAuthCheckClass))
+
+G_BEGIN_DECLS
+
+typedef struct _EMailConfigAuthCheck EMailConfigAuthCheck;
+typedef struct _EMailConfigAuthCheckClass EMailConfigAuthCheckClass;
+typedef struct _EMailConfigAuthCheckPrivate EMailConfigAuthCheckPrivate;
+
+struct _EMailConfigAuthCheck {
+ GtkBox parent;
+ EMailConfigAuthCheckPrivate *priv;
+};
+
+struct _EMailConfigAuthCheckClass {
+ GtkBoxClass parent_class;
+};
+
+GType e_mail_config_auth_check_get_type
+ (void) G_GNUC_CONST;
+GtkWidget * e_mail_config_auth_check_new
+ (EMailConfigBackend *backend,
+ ESource *scratch_source);
+EMailConfigBackend *
+ e_mail_config_auth_check_get_backend
+ (EMailConfigAuthCheck *auth_check);
+ESource * e_mail_config_auth_check_get_scratch_source
+ (EMailConfigAuthCheck *auth_check);
+const gchar * e_mail_config_auth_check_get_active_mechanism
+ (EMailConfigAuthCheck *auth_check);
+void e_mail_config_auth_check_set_active_mechanism
+ (EMailConfigAuthCheck *auth_check,
+ const gchar *active_mechanism);
+
+G_END_DECLS
+
+#endif /* E_MAIL_CONFIG_AUTH_CHECK_H */
diff --git a/mail/e-mail-config-backend.c b/mail/e-mail-config-backend.c
new file mode 100644
index 0000000..0f9fdb8
--- /dev/null
+++ b/mail/e-mail-config-backend.c
@@ -0,0 +1,139 @@
+/*
+ * e-mail-config-backend.c
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) version 3.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with the program; if not, see <http://www.gnu.org/licenses/>
+ *
+ */
+
+#include "e-mail-config-backend.h"
+
+#include <mail/e-mail-config.h>
+
+G_DEFINE_TYPE (
+ EMailConfigBackend,
+ e_mail_config_backend,
+ E_TYPE_EXTENSION)
+
+static void
+mail_config_backend_insert_widgets (EMailConfigBackend *backend,
+ ESource *scratch_source,
+ GtkBox *page)
+{
+ /* does nothing */
+}
+
+static gboolean
+mail_config_backend_check_complete (EMailConfigBackend *backend,
+ ESource *scratch_source)
+{
+ return TRUE;
+}
+
+static void
+mail_config_backend_commit_changes (EMailConfigBackend *backend,
+ ESource *scratch_source)
+{
+ /* does nothing */
+}
+
+static void
+e_mail_config_backend_class_init (EMailConfigBackendClass *class)
+{
+ EExtensionClass *extension_class;
+
+ extension_class = E_EXTENSION_CLASS (class);
+ extension_class->extensible_type = E_TYPE_MAIL_CONFIG;
+
+ class->insert_widgets = mail_config_backend_insert_widgets;
+ class->check_complete = mail_config_backend_check_complete;
+ class->commit_changes = mail_config_backend_commit_changes;
+}
+
+static void
+e_mail_config_backend_init (EMailConfigBackend *backend)
+{
+}
+
+EMailConfig *
+e_mail_config_backend_get_config (EMailConfigBackend *backend)
+{
+ EExtensible *extensible;
+
+ g_return_val_if_fail (E_IS_MAIL_CONFIG_BACKEND (backend), NULL);
+
+ extensible = e_extension_get_extensible (E_EXTENSION (backend));
+
+ return E_MAIL_CONFIG (extensible);
+}
+
+CamelProvider *
+e_mail_config_backend_get_provider (EMailConfigBackend *backend)
+{
+ EMailConfigBackendClass *class;
+
+ g_return_val_if_fail (E_IS_MAIL_CONFIG_BACKEND (backend), NULL);
+
+ class = E_MAIL_CONFIG_BACKEND_GET_CLASS (backend);
+ g_return_val_if_fail (class->backend_name != NULL, NULL);
+
+ return camel_provider_get (class->backend_name, NULL);
+}
+
+void
+e_mail_config_backend_insert_widgets (EMailConfigBackend *backend,
+ ESource *scratch_source,
+ GtkBox *page)
+{
+ EMailConfigBackendClass *class;
+
+ g_return_if_fail (E_IS_MAIL_CONFIG_BACKEND (backend));
+ g_return_if_fail (E_IS_SOURCE (scratch_source));
+ g_return_if_fail (GTK_IS_BOX (page));
+
+ class = E_MAIL_CONFIG_BACKEND_GET_CLASS (backend);
+ g_return_if_fail (class->insert_widgets != NULL);
+
+ return class->insert_widgets (backend, scratch_source, page);
+}
+
+gboolean
+e_mail_config_backend_check_complete (EMailConfigBackend *backend,
+ ESource *scratch_source)
+{
+ EMailConfigBackendClass *class;
+
+ g_return_val_if_fail (E_IS_MAIL_CONFIG_BACKEND (backend), FALSE);
+ g_return_val_if_fail (E_IS_SOURCE (scratch_source), FALSE);
+
+ class = E_MAIL_CONFIG_BACKEND_GET_CLASS (backend);
+ g_return_val_if_fail (class->check_complete != NULL, FALSE);
+
+ return class->check_complete (backend, scratch_source);
+}
+
+void
+e_mail_config_backend_commit_changes (EMailConfigBackend *backend,
+ ESource *scratch_source)
+{
+ EMailConfigBackendClass *class;
+
+ g_return_if_fail (E_IS_MAIL_CONFIG_BACKEND (backend));
+ g_return_if_fail (E_IS_SOURCE (scratch_source));
+
+ class = E_MAIL_CONFIG_BACKEND_GET_CLASS (backend);
+ g_return_if_fail (class->commit_changes != NULL);
+
+ class->commit_changes (backend, scratch_source);
+}
+
diff --git a/mail/e-mail-config-backend.h b/mail/e-mail-config-backend.h
new file mode 100644
index 0000000..e5dbe07
--- /dev/null
+++ b/mail/e-mail-config-backend.h
@@ -0,0 +1,92 @@
+/*
+ * e-mail-config-backend.h
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) version 3.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with the program; if not, see <http://www.gnu.org/licenses/>
+ *
+ */
+
+#ifndef E_MAIL_CONFIG_BACKEND_H
+#define E_MAIL_CONFIG_BACKEND_H
+
+#include <gtk/gtk.h>
+#include <libebackend/e-extension.h>
+#include <libedataserver/e-source.h>
+
+#include <mail/e-mail-config.h>
+
+/* Standard GObject macros */
+#define E_TYPE_MAIL_CONFIG_BACKEND \
+ (e_mail_config_backend_get_type ())
+#define E_MAIL_CONFIG_BACKEND(obj) \
+ (G_TYPE_CHECK_INSTANCE_CAST \
+ ((obj), E_TYPE_MAIL_CONFIG_BACKEND, EMailConfigBackend))
+#define E_MAIL_CONFIG_BACKEND_CLASS(cls) \
+ (G_TYPE_CHECK_CLASS_CAST \
+ ((cls), E_TYPE_MAIL_CONFIG_BACKEND, EMailConfigBackendClass))
+#define E_IS_MAIL_CONFIG_BACKEND(obj) \
+ (G_TYPE_CHECK_INSTANCE_TYPE \
+ ((obj), E_TYPE_MAIL_CONFIG_BACKEND))
+#define E_IS_MAIL_CONFIG_BACKEND_CLASS(cls) \
+ (G_TYPE_CHECK_CLASS_TYPE \
+ ((cls), E_TYPE_MAIL_CONFIG_BACKEND))
+#define E_MAIL_CONFIG_BACKEND_GET_CLASS(obj) \
+ (G_TYPE_INSTANCE_GET_CLASS \
+ ((obj), E_TYPE_MAIL_CONFIG_BACKEND, EMailConfigBackendClass))
+
+G_BEGIN_DECLS
+
+typedef struct _EMailConfigBackend EMailConfigBackend;
+typedef struct _EMailConfigBackendClass EMailConfigBackendClass;
+typedef struct _EMailConfigBackendPrivate EMailConfigBackendPrivate;
+
+struct _EMailConfigBackend {
+ EExtension parent;
+ EMailConfigBackendPrivate *priv;
+};
+
+struct _EMailConfigBackendClass {
+ EExtensionClass parent_class;
+
+ const gchar *backend_name;
+
+ /* Signals */
+ void (*insert_widgets) (EMailConfigBackend *backend,
+ ESource *scratch_source,
+ GtkBox *page);
+ gboolean (*check_complete) (EMailConfigBackend *backend,
+ ESource *scratch_source);
+ void (*commit_changes) (EMailConfigBackend *backend,
+ ESource *scratch_source);
+};
+
+GType e_mail_config_backend_get_type (void) G_GNUC_CONST;
+EMailConfig * e_mail_config_backend_get_config
+ (EMailConfigBackend *backend);
+CamelProvider * e_mail_config_backend_get_provider
+ (EMailConfigBackend *backend);
+void e_mail_config_backend_insert_widgets
+ (EMailConfigBackend *backend,
+ ESource *scratch_source,
+ GtkBox *page);
+gboolean e_mail_config_backend_check_complete
+ (EMailConfigBackend *backend,
+ ESource *scratch_source);
+void e_mail_config_backend_commit_changes
+ (EMailConfigBackend *backend,
+ ESource *scratch_source);
+
+G_END_DECLS
+
+#endif /* E_MAIL_CONFIG_BACKEND_H */
+
diff --git a/mail/e-mail-config-identity.c b/mail/e-mail-config-identity.c
new file mode 100644
index 0000000..e95e90d
--- /dev/null
+++ b/mail/e-mail-config-identity.c
@@ -0,0 +1,723 @@
+/*
+ * e-mail-config-identity.c
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) version 3.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with the program; if not, see <http://www.gnu.org/licenses/>
+ *
+ */
+
+#include "e-mail-config-identity.h"
+
+#include <config.h>
+#include <glib/gi18n-lib.h>
+
+#include <libedataserver/e-source-mail-identity.h>
+
+#include <e-util/e-marshal.h>
+#include <misc/e-mail-signature-combo-box.h>
+#include <misc/e-mail-signature-editor.h>
+
+#define E_MAIL_CONFIG_IDENTITY_GET_PRIVATE(obj) \
+ (G_TYPE_INSTANCE_GET_PRIVATE \
+ ((obj), E_TYPE_MAIL_CONFIG_IDENTITY, EMailConfigIdentityPrivate))
+
+struct _EMailConfigIdentityPrivate {
+ ESource *scratch_source;
+ ESourceRegistry *registry;
+ gboolean show_account_info;
+ gboolean show_signatures;
+};
+
+enum {
+ PROP_0,
+ PROP_REGISTRY,
+ PROP_SCRATCH_SOURCE,
+ PROP_SHOW_ACCOUNT_INFO,
+ PROP_SHOW_SIGNATURES
+};
+
+enum {
+ CHANGED,
+ CHECK_COMPLETE,
+ LAST_SIGNAL
+};
+
+static guint signals[LAST_SIGNAL];
+
+G_DEFINE_TYPE (
+ EMailConfigIdentity,
+ e_mail_config_identity,
+ GTK_TYPE_BOX)
+
+static gboolean
+mail_config_identity_is_email (const gchar *email_address)
+{
+ const gchar *cp;
+
+ /* Make sure we have a '@' between a name and domain part. */
+ cp = strchr (email_address, '@');
+
+ return (cp != NULL && cp != email_address && *(cp + 1) != '\0');
+}
+
+static void
+mail_config_identity_add_signature_cb (GtkButton *button,
+ EMailConfigIdentity *config)
+{
+ ESourceRegistry *registry;
+ GtkWidget *editor;
+
+ registry = e_mail_config_identity_get_registry (config);
+
+ editor = e_mail_signature_editor_new (registry, NULL);
+ gtk_window_set_position (GTK_WINDOW (editor), GTK_WIN_POS_CENTER);
+ gtk_widget_show (editor);
+}
+
+static void
+mail_config_identity_set_registry (EMailConfigIdentity *config,
+ ESourceRegistry *registry)
+{
+ g_return_if_fail (E_IS_SOURCE_REGISTRY (registry));
+ g_return_if_fail (config->priv->registry == NULL);
+
+ config->priv->registry = g_object_ref (registry);
+}
+
+static void
+mail_config_identity_set_scratch_source (EMailConfigIdentity *config,
+ ESource *scratch_source)
+{
+ g_return_if_fail (E_IS_SOURCE (scratch_source));
+ g_return_if_fail (config->priv->scratch_source == NULL);
+
+ config->priv->scratch_source = g_object_ref (scratch_source);
+}
+
+static void
+mail_config_identity_set_property (GObject *object,
+ guint property_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ switch (property_id) {
+ case PROP_REGISTRY:
+ mail_config_identity_set_registry (
+ E_MAIL_CONFIG_IDENTITY (object),
+ g_value_get_object (value));
+ return;
+
+ case PROP_SCRATCH_SOURCE:
+ mail_config_identity_set_scratch_source (
+ E_MAIL_CONFIG_IDENTITY (object),
+ g_value_get_object (value));
+ return;
+
+ case PROP_SHOW_ACCOUNT_INFO:
+ e_mail_config_identity_set_show_account_info (
+ E_MAIL_CONFIG_IDENTITY (object),
+ g_value_get_boolean (value));
+ return;
+
+ case PROP_SHOW_SIGNATURES:
+ e_mail_config_identity_set_show_signatures (
+ E_MAIL_CONFIG_IDENTITY (object),
+ g_value_get_boolean (value));
+ return;
+ }
+
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+}
+
+static void
+mail_config_identity_get_property (GObject *object,
+ guint property_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ switch (property_id) {
+ case PROP_REGISTRY:
+ g_value_set_object (
+ value,
+ e_mail_config_identity_get_registry (
+ E_MAIL_CONFIG_IDENTITY (object)));
+ return;
+
+ case PROP_SCRATCH_SOURCE:
+ g_value_set_object (
+ value,
+ e_mail_config_identity_get_scratch_source (
+ E_MAIL_CONFIG_IDENTITY (object)));
+ return;
+
+ case PROP_SHOW_ACCOUNT_INFO:
+ g_value_set_boolean (
+ value,
+ e_mail_config_identity_get_show_account_info (
+ E_MAIL_CONFIG_IDENTITY (object)));
+ return;
+
+ case PROP_SHOW_SIGNATURES:
+ g_value_set_boolean (
+ value,
+ e_mail_config_identity_get_show_signatures (
+ E_MAIL_CONFIG_IDENTITY (object)));
+ return;
+ }
+
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+}
+
+static void
+mail_config_identity_dispose (GObject *object)
+{
+ EMailConfigIdentityPrivate *priv;
+
+ priv = E_MAIL_CONFIG_IDENTITY_GET_PRIVATE (object);
+
+ if (priv->scratch_source != NULL) {
+ g_object_unref (priv->scratch_source);
+ priv->scratch_source = NULL;
+ }
+
+ if (priv->registry != NULL) {
+ g_object_unref (priv->registry);
+ priv->registry = NULL;
+ }
+
+ /* Chain up to parent's dispose() method. */
+ G_OBJECT_CLASS (e_mail_config_identity_parent_class)->dispose (object);
+}
+
+static void
+mail_config_identity_constructed (GObject *object)
+{
+ EMailConfigIdentity *config;
+ ESource *source;
+ ESourceRegistry *registry;
+ ESourceMailIdentity *extension;
+ GtkLabel *label;
+ GtkWidget *widget;
+ GtkWidget *container;
+ GtkSizeGroup *size_group;
+ const gchar *extension_name;
+ const gchar *text;
+ gchar *markup;
+
+ config = E_MAIL_CONFIG_IDENTITY (object);
+
+ /* Chain up to parent's constructed() method. */
+ G_OBJECT_CLASS (e_mail_config_identity_parent_class)->
+ constructed (object);
+
+ extension_name = E_SOURCE_EXTENSION_MAIL_IDENTITY;
+ registry = e_mail_config_identity_get_registry (config);
+ source = e_mail_config_identity_get_scratch_source (config);
+ extension = e_source_get_extension (source, extension_name);
+
+ gtk_orientable_set_orientation (
+ GTK_ORIENTABLE (config), GTK_ORIENTATION_VERTICAL);
+
+ gtk_box_set_spacing (GTK_BOX (config), 12);
+
+ /* This keeps all mnemonic labels the same width. */
+ size_group = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);
+ gtk_size_group_set_ignore_hidden (size_group, TRUE);
+
+ /*** Account Information ***/
+
+ widget = gtk_grid_new ();
+ gtk_grid_set_row_spacing (GTK_GRID (widget), 6);
+ gtk_grid_set_column_spacing (GTK_GRID (widget), 6);
+ gtk_box_pack_start (GTK_BOX (config), widget, FALSE, FALSE, 0);
+
+ g_object_bind_property (
+ config, "show-account-info",
+ widget, "visible",
+ G_BINDING_SYNC_CREATE);
+
+ container = widget;
+
+ text = _("Account Information");
+ markup = g_markup_printf_escaped ("<b>%s</b>", text);
+ widget = gtk_label_new (markup);
+ gtk_label_set_use_markup (GTK_LABEL (widget), TRUE);
+ gtk_misc_set_alignment (GTK_MISC (widget), 0.0, 0.5);
+ gtk_grid_attach (GTK_GRID (container), widget, 0, 0, 2, 1);
+ gtk_widget_show (widget);
+ g_free (markup);
+
+ text = _("Type the name by which you would like to refer to "
+ "this account.\nFor example, \"Work\" or \"Personal\".");
+ widget = gtk_label_new (text);
+ gtk_misc_set_alignment (GTK_MISC (widget), 0.0, 0.5);
+ gtk_grid_attach (GTK_GRID (container), widget, 0, 1, 2, 1);
+ gtk_widget_show (widget);
+
+ text = _("_Name:");
+ widget = gtk_label_new_with_mnemonic (text);
+ gtk_widget_set_margin_left (widget, 12);
+ gtk_size_group_add_widget (size_group, widget);
+ gtk_misc_set_alignment (GTK_MISC (widget), 1.0, 0.5);
+ gtk_grid_attach (GTK_GRID (container), widget, 0, 2, 1, 1);
+ gtk_widget_show (widget);
+
+ label = GTK_LABEL (widget);
+
+ widget = gtk_entry_new ();
+ gtk_widget_set_hexpand (widget, TRUE);
+ gtk_label_set_mnemonic_widget (label, widget);
+ gtk_grid_attach (GTK_GRID (container), widget, 1, 2, 1, 1);
+ gtk_widget_show (widget);
+
+ g_object_bind_property (
+ source, "display-name",
+ widget, "text",
+ G_BINDING_BIDIRECTIONAL |
+ G_BINDING_SYNC_CREATE);
+
+ /* This entry affects the "check-complete" result. */
+ g_signal_connect_swapped (
+ widget, "changed",
+ G_CALLBACK (e_mail_config_identity_changed), config);
+
+ /*** Required Information ***/
+
+ widget = gtk_grid_new ();
+ gtk_grid_set_row_spacing (GTK_GRID (widget), 6);
+ gtk_grid_set_column_spacing (GTK_GRID (widget), 6);
+ gtk_box_pack_start (GTK_BOX (config), widget, FALSE, FALSE, 0);
+ gtk_widget_show (widget);
+
+ container = widget;
+
+ text = _("Required Information");
+ markup = g_markup_printf_escaped ("<b>%s</b>", text);
+ widget = gtk_label_new (markup);
+ gtk_label_set_use_markup (GTK_LABEL (widget), TRUE);
+ gtk_misc_set_alignment (GTK_MISC (widget), 0.0, 0.5);
+ gtk_grid_attach (GTK_GRID (container), widget, 0, 0, 2, 1);
+ gtk_widget_show (widget);
+ g_free (markup);
+
+ text = _("Full Nam_e:");
+ widget = gtk_label_new_with_mnemonic (text);
+ gtk_widget_set_margin_left (widget, 12);
+ gtk_size_group_add_widget (size_group, widget);
+ gtk_misc_set_alignment (GTK_MISC (widget), 1.0, 0.5);
+ gtk_grid_attach (GTK_GRID (container), widget, 0, 1, 1, 1);
+ gtk_widget_show (widget);
+
+ label = GTK_LABEL (widget);
+
+ widget = gtk_entry_new ();
+ gtk_widget_set_hexpand (widget, TRUE);
+ gtk_label_set_mnemonic_widget (label, widget);
+ gtk_grid_attach (GTK_GRID (container), widget, 1, 1, 1, 1);
+ gtk_widget_show (widget);
+
+ g_object_bind_property (
+ extension, "name",
+ widget, "text",
+ G_BINDING_BIDIRECTIONAL |
+ G_BINDING_SYNC_CREATE);
+
+ /* This entry affects the "check-complete" result. */
+ g_signal_connect_swapped (
+ widget, "changed",
+ G_CALLBACK (e_mail_config_identity_changed), config);
+
+ text = _("Email _Address:");
+ widget = gtk_label_new_with_mnemonic (text);
+ gtk_widget_set_margin_left (widget, 12);
+ gtk_size_group_add_widget (size_group, widget);
+ gtk_misc_set_alignment (GTK_MISC (widget), 1.0, 0.5);
+ gtk_grid_attach (GTK_GRID (container), widget, 0, 2, 1, 1);
+ gtk_widget_show (widget);
+
+ label = GTK_LABEL (widget);
+
+ widget = gtk_entry_new ();
+ gtk_widget_set_hexpand (widget, TRUE);
+ gtk_label_set_mnemonic_widget (label, widget);
+ gtk_grid_attach (GTK_GRID (container), widget, 1, 2, 1, 1);
+ gtk_widget_show (widget);
+
+ g_object_bind_property (
+ extension, "address",
+ widget, "text",
+ G_BINDING_BIDIRECTIONAL |
+ G_BINDING_SYNC_CREATE);
+
+ /* This entry affects the "check-complete" result. */
+ g_signal_connect_swapped (
+ widget, "changed",
+ G_CALLBACK (e_mail_config_identity_changed), config);
+
+ /*** Optional Information ***/
+
+ widget = gtk_grid_new ();
+ gtk_grid_set_row_spacing (GTK_GRID (widget), 6);
+ gtk_grid_set_column_spacing (GTK_GRID (widget), 6);
+ gtk_box_pack_start (GTK_BOX (config), widget, FALSE, FALSE, 0);
+ gtk_widget_show (widget);
+
+ container = widget;
+
+ text = _("Optional Information");
+ markup = g_markup_printf_escaped ("<b>%s</b>", text);
+ widget = gtk_label_new (markup);
+ gtk_label_set_use_markup (GTK_LABEL (widget), TRUE);
+ gtk_misc_set_alignment (GTK_MISC (widget), 0.0, 0.5);
+ gtk_grid_attach (GTK_GRID (container), widget, 0, 0, 3, 1);
+ gtk_widget_show (widget);
+
+ text = _("Re_ply-To:");
+ widget = gtk_label_new_with_mnemonic (text);
+ gtk_widget_set_margin_left (widget, 12);
+ gtk_size_group_add_widget (size_group, widget);
+ gtk_misc_set_alignment (GTK_MISC (widget), 1.0, 0.5);
+ gtk_grid_attach (GTK_GRID (container), widget, 0, 1, 1, 1);
+ gtk_widget_show (widget);
+
+ label = GTK_LABEL (widget);
+
+ widget = gtk_entry_new ();
+ gtk_widget_set_hexpand (widget, TRUE);
+ gtk_label_set_mnemonic_widget (label, widget);
+ gtk_grid_attach (GTK_GRID (container), widget, 1, 1, 2, 1);
+ gtk_widget_show (widget);
+
+ g_object_bind_property (
+ extension, "reply-to",
+ widget, "text",
+ G_BINDING_BIDIRECTIONAL |
+ G_BINDING_SYNC_CREATE);
+
+ /* This entry affects the "check-complete" result. */
+ g_signal_connect_swapped (
+ widget, "changed",
+ G_CALLBACK (e_mail_config_identity_changed), config);
+
+ text = _("Or_ganization:");
+ widget = gtk_label_new_with_mnemonic (text);
+ gtk_widget_set_margin_left (widget, 12);
+ gtk_size_group_add_widget (size_group, widget);
+ gtk_misc_set_alignment (GTK_MISC (widget), 1.0, 0.5);
+ gtk_grid_attach (GTK_GRID (container), widget, 0, 2, 1, 1);
+ gtk_widget_show (widget);
+
+ label = GTK_LABEL (widget);
+
+ widget = gtk_entry_new ();
+ gtk_widget_set_hexpand (widget, TRUE);
+ gtk_label_set_mnemonic_widget (label, widget);
+ gtk_grid_attach (GTK_GRID (container), widget, 1, 2, 2, 1);
+ gtk_widget_show (widget);
+
+ g_object_bind_property (
+ extension, "organization",
+ widget, "text",
+ G_BINDING_BIDIRECTIONAL |
+ G_BINDING_SYNC_CREATE);
+
+ text = _("Si_gnature:");
+ widget = gtk_label_new_with_mnemonic (text);
+ gtk_widget_set_margin_left (widget, 12);
+ gtk_size_group_add_widget (size_group, widget);
+ gtk_misc_set_alignment (GTK_MISC (widget), 1.0, 0.5);
+ gtk_grid_attach (GTK_GRID (container), widget, 0, 3, 1, 1);
+ gtk_widget_show (widget);
+
+ g_object_bind_property (
+ config, "show-signatures",
+ widget, "visible",
+ G_BINDING_SYNC_CREATE);
+
+ label = GTK_LABEL (widget);
+
+ widget = e_mail_signature_combo_box_new (registry);
+ gtk_widget_set_hexpand (widget, TRUE);
+ gtk_widget_set_halign (widget, GTK_ALIGN_START);
+ gtk_label_set_mnemonic_widget (label, widget);
+ gtk_grid_attach (GTK_GRID (container), widget, 1, 3, 1, 1);
+ gtk_widget_show (widget);
+
+ g_object_bind_property (
+ extension, "signature-uid",
+ widget, "active-id",
+ G_BINDING_BIDIRECTIONAL |
+ G_BINDING_SYNC_CREATE);
+
+ g_object_bind_property (
+ config, "show-signatures",
+ widget, "visible",
+ G_BINDING_SYNC_CREATE);
+
+ text = _("Add Ne_w Signature...");
+ widget = gtk_button_new_with_mnemonic (text);
+ gtk_grid_attach (GTK_GRID (container), widget, 2, 3, 1, 1);
+ gtk_widget_show (widget);
+
+ g_object_bind_property (
+ config, "show-signatures",
+ widget, "visible",
+ G_BINDING_SYNC_CREATE);
+
+ g_signal_connect (
+ widget, "clicked",
+ G_CALLBACK (mail_config_identity_add_signature_cb), config);
+
+ g_object_unref (size_group);
+}
+
+static gboolean
+mail_config_identity_check_complete (EMailConfigIdentity *config)
+{
+ ESource *source;
+ ESourceMailIdentity *extension;
+ const gchar *extension_name;
+ const gchar *name;
+ const gchar *address;
+ const gchar *reply_to;
+ const gchar *display_name;
+
+ extension_name = E_SOURCE_EXTENSION_MAIL_IDENTITY;
+ source = e_mail_config_identity_get_scratch_source (config);
+ extension = e_source_get_extension (source, extension_name);
+
+ name = e_source_mail_identity_get_name (extension);
+ address = e_source_mail_identity_get_address (extension);
+ reply_to = e_source_mail_identity_get_reply_to (extension);
+
+ display_name = e_source_get_display_name (source);
+
+ /* None of these should ever be NULL. */
+ g_return_val_if_fail (name != NULL, FALSE);
+ g_return_val_if_fail (address != NULL, FALSE);
+ g_return_val_if_fail (reply_to != NULL, FALSE);
+ g_return_val_if_fail (display_name != NULL, FALSE);
+
+ g_debug ("Name: '%s'", name);
+ g_debug ("Address: '%s'", address);
+ g_debug ("ReplyTo: '%s'", reply_to);
+
+ if (*name == '\0')
+ return FALSE;
+
+ if (!mail_config_identity_is_email (address))
+ return FALSE;
+
+ /* An empty reply_to string is allowed. */
+ if (*reply_to != '\0' && !mail_config_identity_is_email (reply_to))
+ return FALSE;
+
+ /* Only enforce when account information is visible. */
+ if (e_mail_config_identity_get_show_account_info (config))
+ if (*display_name == '\0')
+ return FALSE;
+
+ return TRUE;
+}
+
+static gboolean
+mail_config_identity_check_complete_accumulator (GSignalInvocationHint *ihint,
+ GValue *return_accu,
+ const GValue *handler_return,
+ gpointer unused)
+{
+ gboolean v_boolean;
+
+ /* Abort emission if a handler returns FALSE. */
+ v_boolean = g_value_get_boolean (handler_return);
+ g_value_set_boolean (return_accu, v_boolean);
+
+ return v_boolean;
+}
+
+static void
+e_mail_config_identity_class_init (EMailConfigIdentityClass *class)
+{
+ GObjectClass *object_class;
+
+ g_type_class_add_private (class, sizeof (EMailConfigIdentityPrivate));
+
+ object_class = G_OBJECT_CLASS (class);
+ object_class->set_property = mail_config_identity_set_property;
+ object_class->get_property = mail_config_identity_get_property;
+ object_class->dispose = mail_config_identity_dispose;
+ object_class->constructed = mail_config_identity_constructed;
+
+ class->check_complete = mail_config_identity_check_complete;
+
+ g_object_class_install_property (
+ object_class,
+ PROP_REGISTRY,
+ g_param_spec_object (
+ "registry",
+ "Registry",
+ "Registry of data sources",
+ E_TYPE_SOURCE_REGISTRY,
+ G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT_ONLY |
+ G_PARAM_STATIC_STRINGS));
+
+ g_object_class_install_property (
+ object_class,
+ PROP_SCRATCH_SOURCE,
+ g_param_spec_object (
+ "scratch-source",
+ "Scratch Source",
+ "The data source being edited",
+ E_TYPE_SOURCE,
+ G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT_ONLY |
+ G_PARAM_STATIC_STRINGS));
+
+ g_object_class_install_property (
+ object_class,
+ PROP_SHOW_ACCOUNT_INFO,
+ g_param_spec_boolean (
+ "show-account-info",
+ "Show Account Info",
+ "Show the \"Account Information\" section",
+ TRUE,
+ G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT |
+ G_PARAM_STATIC_STRINGS));
+
+ g_object_class_install_property (
+ object_class,
+ PROP_SHOW_SIGNATURES,
+ g_param_spec_boolean (
+ "show-signatures",
+ "Show Signatures",
+ "Show mail signature options",
+ TRUE,
+ G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT |
+ G_PARAM_STATIC_STRINGS));
+
+ signals[CHANGED] = g_signal_new (
+ "changed",
+ G_OBJECT_CLASS_TYPE (class),
+ G_SIGNAL_RUN_FIRST,
+ G_STRUCT_OFFSET (EMailConfigIdentityClass, changed),
+ NULL, NULL,
+ g_cclosure_marshal_VOID__VOID,
+ G_TYPE_NONE, 0);
+
+ signals[CHECK_COMPLETE] = g_signal_new (
+ "check-complete",
+ G_OBJECT_CLASS_TYPE (class),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (EMailConfigIdentityClass, check_complete),
+ mail_config_identity_check_complete_accumulator, NULL,
+ e_marshal_BOOLEAN__VOID,
+ G_TYPE_BOOLEAN, 0);
+}
+
+static void
+e_mail_config_identity_init (EMailConfigIdentity *config)
+{
+ config->priv = E_MAIL_CONFIG_IDENTITY_GET_PRIVATE (config);
+}
+
+GtkWidget *
+e_mail_config_identity_new (ESourceRegistry *registry,
+ ESource *scratch_source)
+{
+ g_return_val_if_fail (E_IS_SOURCE_REGISTRY (registry), NULL);
+ g_return_val_if_fail (E_IS_SOURCE (scratch_source), NULL);
+
+ return g_object_new (
+ E_TYPE_MAIL_CONFIG_IDENTITY,
+ "registry", registry,
+ "scratch-source", scratch_source,
+ NULL);
+}
+
+void
+e_mail_config_identity_changed (EMailConfigIdentity *config)
+{
+ g_return_if_fail (E_IS_MAIL_CONFIG_IDENTITY (config));
+
+ g_signal_emit (config, signals[CHANGED], 0);
+}
+
+gboolean
+e_mail_config_identity_check_complete (EMailConfigIdentity *config)
+{
+ gboolean complete;
+
+ g_return_val_if_fail (E_IS_MAIL_CONFIG_IDENTITY (config), FALSE);
+
+ g_signal_emit (config, signals[CHECK_COMPLETE], 0, &complete);
+
+ return complete;
+}
+
+ESourceRegistry *
+e_mail_config_identity_get_registry (EMailConfigIdentity *config)
+{
+ g_return_val_if_fail (E_IS_MAIL_CONFIG_IDENTITY (config), NULL);
+
+ return config->priv->registry;
+}
+
+ESource *
+e_mail_config_identity_get_scratch_source (EMailConfigIdentity *config)
+{
+ g_return_val_if_fail (E_IS_MAIL_CONFIG_IDENTITY (config), NULL);
+
+ return config->priv->scratch_source;
+}
+
+gboolean
+e_mail_config_identity_get_show_account_info (EMailConfigIdentity *config)
+{
+ g_return_val_if_fail (E_IS_MAIL_CONFIG_IDENTITY (config), FALSE);
+
+ return config->priv->show_account_info;
+}
+
+void
+e_mail_config_identity_set_show_account_info (EMailConfigIdentity *config,
+ gboolean show_account_info)
+{
+ g_return_if_fail (E_IS_MAIL_CONFIG_IDENTITY (config));
+
+ config->priv->show_account_info = show_account_info;
+
+ g_object_notify (G_OBJECT (config), "show-account-info");
+}
+
+gboolean
+e_mail_config_identity_get_show_signatures (EMailConfigIdentity *config)
+{
+ g_return_val_if_fail (E_IS_MAIL_CONFIG_IDENTITY (config), FALSE);
+
+ return config->priv->show_signatures;
+}
+
+void
+e_mail_config_identity_set_show_signatures (EMailConfigIdentity *config,
+ gboolean show_signatures)
+{
+ g_return_if_fail (E_IS_MAIL_CONFIG_IDENTITY (config));
+
+ config->priv->show_signatures = show_signatures;
+
+ g_object_notify (G_OBJECT (config), "show-signatures");
+}
+
diff --git a/mail/e-mail-config-identity.h b/mail/e-mail-config-identity.h
new file mode 100644
index 0000000..b3a40a7
--- /dev/null
+++ b/mail/e-mail-config-identity.h
@@ -0,0 +1,87 @@
+/*
+ * e-mail-config-identity.h
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) version 3.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with the program; if not, see <http://www.gnu.org/licenses/>
+ *
+ */
+
+#ifndef E_MAIL_CONFIG_IDENTITY_H
+#define E_MAIL_CONFIG_IDENTITY_H
+
+#include <gtk/gtk.h>
+#include <libedataserver/e-source-registry.h>
+
+/* Standard GObject macros */
+#define E_TYPE_MAIL_CONFIG_IDENTITY \
+ (e_mail_config_identity_get_type ())
+#define E_MAIL_CONFIG_IDENTITY(obj) \
+ (G_TYPE_CHECK_INSTANCE_CAST \
+ ((obj), E_TYPE_MAIL_CONFIG_IDENTITY, EMailConfigIdentity))
+#define E_MAIL_CONFIG_IDENTITY_CLASS(cls) \
+ (G_TYPE_CHECK_CLASS_CAST \
+ ((cls), E_TYPE_MAIL_CONFIG_IDENTITY, EMailConfigIdentityClass))
+#define E_IS_MAIL_CONFIG_IDENTITY(obj) \
+ (G_TYPE_CHECK_INSTANCE_TYPE \
+ ((obj), E_TYPE_MAIL_CONFIG_IDENTITY))
+#define E_IS_MAIL_CONFIG_IDENTITY_CLASS(cls) \
+ (G_TYPE_CHECK_CLASS_TYPE \
+ ((cls), E_TYPE_MAIL_CONFIG_IDENTITY))
+#define E_MAIL_CONFIG_IDENTITY_GET_CLASS(obj) \
+ (G_TYPE_INSTANCE_GET_CLASS \
+ ((obj), E_TYPE_MAIL_CONFIG_IDENTITY, EMailConfigIdentityClass))
+
+G_BEGIN_DECLS
+
+typedef struct _EMailConfigIdentity EMailConfigIdentity;
+typedef struct _EMailConfigIdentityClass EMailConfigIdentityClass;
+typedef struct _EMailConfigIdentityPrivate EMailConfigIdentityPrivate;
+
+struct _EMailConfigIdentity {
+ GtkBox parent;
+ EMailConfigIdentityPrivate *priv;
+};
+
+struct _EMailConfigIdentityClass {
+ GtkBoxClass parent_class;
+
+ /* Signals */
+ void (*changed) (EMailConfigIdentity *config);
+ gboolean (*check_complete) (EMailConfigIdentity *config);
+};
+
+GType e_mail_config_identity_get_type (void) G_GNUC_CONST;
+GtkWidget * e_mail_config_identity_new (ESourceRegistry *registry,
+ ESource *scratch_source);
+void e_mail_config_identity_changed (EMailConfigIdentity *config);
+gboolean e_mail_config_identity_check_complete
+ (EMailConfigIdentity *config);
+ESourceRegistry *
+ e_mail_config_identity_get_registry
+ (EMailConfigIdentity *config);
+ESource * e_mail_config_identity_get_scratch_source
+ (EMailConfigIdentity *config);
+gboolean e_mail_config_identity_get_show_account_info
+ (EMailConfigIdentity *config);
+void e_mail_config_identity_set_show_account_info
+ (EMailConfigIdentity *config,
+ gboolean show_account_info);
+gboolean e_mail_config_identity_get_show_signatures
+ (EMailConfigIdentity *config);
+void e_mail_config_identity_set_show_signatures
+ (EMailConfigIdentity *config,
+ gboolean show_signatures);
+
+G_END_DECLS
+
+#endif /* E_MAIL_CONFIG_IDENTITY_H */
diff --git a/mail/e-mail-config-provider.c b/mail/e-mail-config-provider.c
new file mode 100644
index 0000000..bbf407b
--- /dev/null
+++ b/mail/e-mail-config-provider.c
@@ -0,0 +1,645 @@
+/*
+ * e-mail-config-provider.c
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) version 3.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with the program; if not, see <http://www.gnu.org/licenses/>
+ *
+ */
+
+#include "e-mail-config-provider.h"
+
+#include <config.h>
+#include <string.h>
+#include <glib/gi18n-lib.h>
+
+#include <camel/camel.h>
+#include <libedataserver/e-source-camel.h>
+#include <libedataserver/e-source-mail-account.h>
+#include <libedataserver/e-data-server-util.h>
+
+#define E_MAIL_CONFIG_PROVIDER_GET_PRIVATE(obj) \
+ (G_TYPE_INSTANCE_GET_PRIVATE \
+ ((obj), E_TYPE_MAIL_CONFIG_PROVIDER, EMailConfigProviderPrivate))
+
+#define STANDARD_MARGIN 12
+#define DEPENDENCY_MARGIN 24
+
+struct _EMailConfigProviderPrivate {
+ ESource *scratch_source;
+ CamelProvider *provider;
+ CamelSettings *settings;
+ gboolean is_empty;
+};
+
+enum {
+ PROP_0,
+ PROP_SCRATCH_SOURCE
+};
+
+G_DEFINE_TYPE (
+ EMailConfigProvider,
+ e_mail_config_provider,
+ GTK_TYPE_BOX)
+
+static void
+mail_config_provider_handle_dependency (EMailConfigProvider *config,
+ CamelProviderConfEntry *entry,
+ GtkWidget *widget)
+{
+ GBindingFlags binding_flags = G_BINDING_SYNC_CREATE;
+ const gchar *depname = entry->depname;
+ gint margin;
+
+ if (depname == NULL)
+ return;
+
+ if (*depname == '!') {
+ binding_flags |= G_BINDING_INVERT_BOOLEAN;
+ depname++;
+ }
+
+ g_object_bind_property (
+ config->priv->settings, depname,
+ widget, "sensitive",
+ binding_flags);
+
+ /* Further indent the widget to show its dependency. */
+ margin = gtk_widget_get_margin_left (widget);
+ gtk_widget_set_margin_left (widget, margin + DEPENDENCY_MARGIN);
+}
+
+static void
+mail_config_provider_add_section (EMailConfigProvider *config,
+ CamelProviderConfEntry *entry)
+{
+ GtkWidget *widget;
+ gchar *markup;
+
+ g_return_if_fail (entry->text != NULL);
+
+ markup = g_markup_printf_escaped ("<b>%s</b>", entry->text);
+
+ widget = gtk_label_new (markup);
+ gtk_label_set_use_markup (GTK_LABEL (widget), TRUE);
+ gtk_misc_set_alignment (GTK_MISC (widget), 0.0, 0.5);
+ gtk_box_pack_start (GTK_BOX (config), widget, FALSE, FALSE, 0);
+ gtk_widget_show (widget);
+
+ /* Skip the top margin if this is the first entry. */
+ if (entry != config->priv->provider->extra_conf)
+ gtk_widget_set_margin_top (widget, 6);
+
+ g_free (markup);
+}
+
+static void
+mail_config_provider_add_checkbox (EMailConfigProvider *config,
+ CamelProviderConfEntry *entry)
+{
+ GtkWidget *widget;
+
+ g_return_if_fail (entry->text != NULL);
+
+ widget = gtk_check_button_new_with_mnemonic (entry->text);
+ gtk_widget_set_margin_left (widget, STANDARD_MARGIN);
+ gtk_box_pack_start (GTK_BOX (config), widget, FALSE, FALSE, 0);
+ gtk_widget_show (widget);
+
+ g_object_bind_property (
+ config->priv->settings, entry->name,
+ widget, "active",
+ G_BINDING_BIDIRECTIONAL |
+ G_BINDING_SYNC_CREATE);
+
+ mail_config_provider_handle_dependency (config, entry, widget);
+}
+
+static void
+mail_config_provider_add_checkspin (EMailConfigProvider *config,
+ CamelProviderConfEntry *entry)
+{
+ GObjectClass *class;
+ GParamSpec *pspec;
+ GParamSpec *use_pspec;
+ GtkAdjustment *adjustment;
+ GtkWidget *hbox, *spin;
+ GtkWidget *prefix;
+ gchar *use_property_name;
+ gchar *pre, *post;
+
+ g_return_if_fail (entry->text != NULL);
+
+ /* The entry->name property (e.g. "foo") should be numeric for the
+ * spin button. If a "use" boolean property exists (e.g. "use-foo")
+ * then a checkbox is also shown. */
+
+ class = G_OBJECT_GET_CLASS (config->priv->settings);
+ pspec = g_object_class_find_property (class, entry->name);
+ g_return_if_fail (pspec != NULL);
+
+ use_property_name = g_strconcat ("use-", entry->name, NULL);
+ use_pspec = g_object_class_find_property (class, use_property_name);
+ if (use_pspec != NULL && use_pspec->value_type != G_TYPE_BOOLEAN)
+ use_pspec = NULL;
+ g_free (use_property_name);
+
+ /* Make sure we can convert to and from doubles. */
+ g_return_if_fail (
+ g_value_type_transformable (
+ pspec->value_type, G_TYPE_DOUBLE));
+ g_return_if_fail (
+ g_value_type_transformable (
+ G_TYPE_DOUBLE, pspec->value_type));
+
+ if (G_IS_PARAM_SPEC_CHAR (pspec)) {
+ GParamSpecChar *pspec_char;
+ pspec_char = G_PARAM_SPEC_CHAR (pspec);
+ adjustment = gtk_adjustment_new (
+ (gdouble) pspec_char->default_value,
+ (gdouble) pspec_char->minimum,
+ (gdouble) pspec_char->maximum,
+ 1.0, 1.0, 0.0);
+
+ } else if (G_IS_PARAM_SPEC_UCHAR (pspec)) {
+ GParamSpecUChar *pspec_uchar;
+ pspec_uchar = G_PARAM_SPEC_UCHAR (pspec);
+ adjustment = gtk_adjustment_new (
+ (gdouble) pspec_uchar->default_value,
+ (gdouble) pspec_uchar->minimum,
+ (gdouble) pspec_uchar->maximum,
+ 1.0, 1.0, 0.0);
+
+ } else if (G_IS_PARAM_SPEC_INT (pspec)) {
+ GParamSpecInt *pspec_int;
+ pspec_int = G_PARAM_SPEC_INT (pspec);
+ adjustment = gtk_adjustment_new (
+ (gdouble) pspec_int->default_value,
+ (gdouble) pspec_int->minimum,
+ (gdouble) pspec_int->maximum,
+ 1.0, 1.0, 0.0);
+
+ } else if (G_IS_PARAM_SPEC_UINT (pspec)) {
+ GParamSpecUInt *pspec_uint;
+ pspec_uint = G_PARAM_SPEC_UINT (pspec);
+ adjustment = gtk_adjustment_new (
+ (gdouble) pspec_uint->default_value,
+ (gdouble) pspec_uint->minimum,
+ (gdouble) pspec_uint->maximum,
+ 1.0, 1.0, 0.0);
+
+ } else if (G_IS_PARAM_SPEC_LONG (pspec)) {
+ GParamSpecLong *pspec_long;
+ pspec_long = G_PARAM_SPEC_LONG (pspec);
+ adjustment = gtk_adjustment_new (
+ (gdouble) pspec_long->default_value,
+ (gdouble) pspec_long->minimum,
+ (gdouble) pspec_long->maximum,
+ 1.0, 1.0, 0.0);
+
+ } else if (G_IS_PARAM_SPEC_ULONG (pspec)) {
+ GParamSpecULong *pspec_ulong;
+ pspec_ulong = G_PARAM_SPEC_ULONG (pspec);
+ adjustment = gtk_adjustment_new (
+ (gdouble) pspec_ulong->default_value,
+ (gdouble) pspec_ulong->minimum,
+ (gdouble) pspec_ulong->maximum,
+ 1.0, 1.0, 0.0);
+
+ } else if (G_IS_PARAM_SPEC_FLOAT (pspec)) {
+ GParamSpecFloat *pspec_float;
+ pspec_float = G_PARAM_SPEC_FLOAT (pspec);
+ adjustment = gtk_adjustment_new (
+ (gdouble) pspec_float->default_value,
+ (gdouble) pspec_float->minimum,
+ (gdouble) pspec_float->maximum,
+ 1.0, 1.0, 0.0);
+
+ } else if (G_IS_PARAM_SPEC_DOUBLE (pspec)) {
+ GParamSpecDouble *pspec_double;
+ pspec_double = G_PARAM_SPEC_DOUBLE (pspec);
+ adjustment = gtk_adjustment_new (
+ (gdouble) pspec_double->default_value,
+ (gdouble) pspec_double->minimum,
+ (gdouble) pspec_double->maximum,
+ 1.0, 1.0, 0.0);
+
+ } else
+ g_return_if_reached ();
+
+ pre = g_alloca (strlen (entry->text) + 1);
+ strcpy (pre, entry->text);
+ post = strstr (pre, "%s");
+ if (post != NULL) {
+ *post = '\0';
+ post += 2;
+ }
+
+ hbox = gtk_hbox_new (FALSE, 3);
+ gtk_widget_set_margin_left (hbox, STANDARD_MARGIN);
+ gtk_box_pack_start (GTK_BOX (config), hbox, FALSE, FALSE, 0);
+ gtk_widget_show (hbox);
+
+ if (use_pspec != NULL) {
+ prefix = gtk_check_button_new_with_mnemonic (pre);
+
+ g_object_bind_property (
+ config->priv->settings, use_pspec->name,
+ prefix, "active",
+ G_BINDING_BIDIRECTIONAL |
+ G_BINDING_SYNC_CREATE);
+ } else {
+ prefix = gtk_label_new_with_mnemonic (pre);
+ }
+ gtk_box_pack_start (GTK_BOX (hbox), prefix, FALSE, TRUE, 0);
+ gtk_widget_show (prefix);
+
+ spin = gtk_spin_button_new (adjustment, 1.0, 0);
+ gtk_box_pack_start (GTK_BOX (hbox), spin, FALSE, TRUE, 0);
+ gtk_widget_show (spin);
+
+ g_object_bind_property (
+ config->priv->settings, entry->name,
+ spin, "value",
+ G_BINDING_BIDIRECTIONAL |
+ G_BINDING_SYNC_CREATE);
+
+ if (use_pspec != NULL)
+ g_object_bind_property (
+ prefix, "active",
+ spin, "sensitive",
+ G_BINDING_SYNC_CREATE);
+
+ if (post != NULL) {
+ GtkWidget *label = gtk_label_new_with_mnemonic (post);
+ gtk_label_set_mnemonic_widget (GTK_LABEL (label), prefix);
+ gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, TRUE, 0);
+ gtk_widget_show (label);
+ }
+
+ mail_config_provider_handle_dependency (config, entry, hbox);
+}
+
+static void
+mail_config_provider_add_entry (EMailConfigProvider *config,
+ CamelProviderConfEntry *entry)
+{
+ GtkWidget *hbox;
+ GtkWidget *input;
+ GtkWidget *label;
+
+ g_return_if_fail (entry->text != NULL);
+
+ hbox = gtk_hbox_new (FALSE, 0);
+ gtk_box_set_spacing (GTK_BOX (hbox), 6);
+ gtk_widget_set_margin_left (hbox, STANDARD_MARGIN);
+ gtk_box_pack_start (GTK_BOX (config), hbox, FALSE, FALSE, 0);
+ gtk_widget_show (hbox);
+
+ label = gtk_label_new_with_mnemonic (entry->text);
+ gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
+ gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
+ gtk_widget_show (label);
+
+ input = gtk_entry_new ();
+ gtk_label_set_mnemonic_widget (GTK_LABEL (label), input);
+ gtk_box_pack_start (GTK_BOX (hbox), input, TRUE, TRUE, 0);
+ gtk_widget_show (input);
+
+ g_object_bind_property (
+ config->priv->settings, entry->name,
+ input, "text",
+ G_BINDING_BIDIRECTIONAL |
+ G_BINDING_SYNC_CREATE);
+
+ g_object_bind_property (
+ input, "sensitive",
+ label, "sensitive",
+ G_BINDING_SYNC_CREATE);
+
+ mail_config_provider_handle_dependency (config, entry, hbox);
+}
+
+static void
+mail_config_provider_add_options (EMailConfigProvider *config,
+ CamelProviderConfEntry *entry)
+{
+ CamelProvider *provider;
+ GtkCellRenderer *renderer;
+ GtkListStore *store;
+ GtkWidget *hbox;
+ GtkWidget *combo;
+ GtkWidget *label;
+ gchar **tokens;
+ guint length, ii;
+
+ /* The 'value' string is of the format:
+ *
+ * 'nick0:caption0:nick1:caption1:...nickN:captionN'
+ *
+ * where 'nick' is the nickname a GEnumValue and 'caption'
+ * is the localized combo box item displayed to the user. */
+
+ g_return_if_fail (entry->text != NULL);
+ g_return_if_fail (entry->value != NULL);
+
+ provider = config->priv->provider;
+
+ hbox = gtk_hbox_new (FALSE, 0);
+ gtk_box_set_spacing (GTK_BOX (hbox), 6);
+ gtk_widget_set_margin_left (hbox, STANDARD_MARGIN);
+ gtk_box_pack_start (GTK_BOX (config), hbox, FALSE, FALSE, 0);
+ gtk_widget_show (hbox);
+
+ label = gtk_label_new_with_mnemonic (entry->text);
+ gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
+ gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
+ gtk_widget_show (label);
+
+ /* 0: 'nick', 1: caption */
+ store = gtk_list_store_new (2, G_TYPE_STRING, G_TYPE_STRING);
+
+ tokens = g_strsplit (entry->value, ":", -1);
+ length = g_strv_length (tokens);
+
+ /* Take the strings two at a time. */
+ for (ii = 0; ii + 1 < length; ii += 2) {
+ GtkTreeIter iter;
+ const gchar *nick;
+ const gchar *caption;
+
+ nick = tokens[ii + 0];
+ caption = tokens[ii + 1];
+
+ /* Localize the caption. */
+ caption = dgettext (provider->translation_domain, caption);
+
+ gtk_list_store_append (store, &iter);
+ gtk_list_store_set (store, &iter, 0, nick, 1, caption, -1);
+ }
+
+ g_strfreev (tokens);
+
+ combo = gtk_combo_box_new_with_model (GTK_TREE_MODEL (store));
+ gtk_combo_box_set_id_column (GTK_COMBO_BOX (combo), 0);
+ gtk_label_set_mnemonic_widget (GTK_LABEL (label), combo);
+ gtk_box_pack_start (GTK_BOX (hbox), combo, FALSE, FALSE, 0);
+ gtk_widget_show (combo);
+
+ g_object_bind_property_full (
+ config->priv->settings, entry->name,
+ combo, "active-id",
+ G_BINDING_BIDIRECTIONAL |
+ G_BINDING_SYNC_CREATE,
+ e_binding_transform_enum_value_to_nick,
+ e_binding_transform_enum_nick_to_value,
+ NULL, (GDestroyNotify) NULL);
+
+ renderer = gtk_cell_renderer_text_new ();
+ gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (combo), renderer, TRUE);
+ gtk_cell_layout_set_attributes (
+ GTK_CELL_LAYOUT (combo), renderer, "text", 1, NULL);
+
+ mail_config_provider_handle_dependency (config, entry, hbox);
+}
+
+static void
+mail_config_provider_add_widgets (EMailConfigProvider *config)
+{
+ CamelProviderConfEntry *entries;
+ gint ii;
+
+ /* Note the "text" member of each CamelProviderConfEntry is
+ * already localized, so we can use it directly in widgets. */
+
+ entries = config->priv->provider->extra_conf;
+
+ /* Loop until we see CAMEL_PROVIDER_CONF_END. */
+ for (ii = 0; entries[ii].type != CAMEL_PROVIDER_CONF_END; ii++) {
+
+ /* Skip entries with no name. */
+ if (entries[ii].name == NULL)
+ continue;
+
+ switch (entries[ii].type) {
+ case CAMEL_PROVIDER_CONF_SECTION_START:
+ mail_config_provider_add_section (
+ config, &entries[ii]);
+ break;
+
+ case CAMEL_PROVIDER_CONF_CHECKBOX:
+ mail_config_provider_add_checkbox (
+ config, &entries[ii]);
+ break;
+
+ case CAMEL_PROVIDER_CONF_CHECKSPIN:
+ mail_config_provider_add_checkspin (
+ config, &entries[ii]);
+ break;
+
+ case CAMEL_PROVIDER_CONF_ENTRY:
+ mail_config_provider_add_entry (
+ config, &entries[ii]);
+ break;
+
+ case CAMEL_PROVIDER_CONF_OPTIONS:
+ mail_config_provider_add_options (
+ config, &entries[ii]);
+ break;
+
+ default:
+ break; /* skip it */
+ }
+ }
+}
+
+static void
+mail_config_provider_set_scratch_source (EMailConfigProvider *config,
+ ESource *scratch_source)
+{
+ g_return_if_fail (E_IS_SOURCE (scratch_source));
+ g_return_if_fail (config->priv->scratch_source == NULL);
+
+ config->priv->scratch_source = g_object_ref (scratch_source);
+}
+
+static void
+mail_config_provider_set_property (GObject *object,
+ guint property_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ switch (property_id) {
+ case PROP_SCRATCH_SOURCE:
+ mail_config_provider_set_scratch_source (
+ E_MAIL_CONFIG_PROVIDER (object),
+ g_value_get_object (value));
+ return;
+ }
+
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+}
+
+static void
+mail_config_provider_get_property (GObject *object,
+ guint property_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ switch (property_id) {
+ case PROP_SCRATCH_SOURCE:
+ g_value_set_object (
+ value,
+ e_mail_config_provider_get_scratch_source (
+ E_MAIL_CONFIG_PROVIDER (object)));
+ return;
+ }
+
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+}
+
+static void
+mail_config_provider_dispose (GObject *object)
+{
+ EMailConfigProviderPrivate *priv;
+
+ priv = E_MAIL_CONFIG_PROVIDER_GET_PRIVATE (object);
+
+ if (priv->scratch_source != NULL) {
+ g_object_unref (priv->scratch_source);
+ priv->scratch_source = NULL;
+ }
+
+ if (priv->settings != NULL) {
+ g_object_unref (priv->settings);
+ priv->settings = NULL;
+ }
+
+ /* Chain up parent's dispose() method. */
+ G_OBJECT_CLASS (e_mail_config_provider_parent_class)->dispose (object);
+}
+
+static void
+mail_config_provider_constructed (GObject *object)
+{
+ EMailConfigProvider *config;
+ ESource *source;
+ ESourceCamel *camel_extension;
+ ESourceBackend *backend_extension;
+ const gchar *backend_name;
+ const gchar *extension_name;
+ GError *error = NULL;
+
+ config = E_MAIL_CONFIG_PROVIDER (object);
+ source = e_mail_config_provider_get_scratch_source (config);
+
+ /* Chain up parent's constructed() method. */
+ G_OBJECT_CLASS (e_mail_config_provider_parent_class)->
+ constructed (object);
+
+ gtk_box_set_spacing (GTK_BOX (object), 6);
+
+ gtk_orientable_set_orientation (
+ GTK_ORIENTABLE (object), GTK_ORIENTATION_VERTICAL);
+
+ extension_name = E_SOURCE_EXTENSION_MAIL_ACCOUNT;
+ backend_extension = e_source_get_extension (source, extension_name);
+ backend_name = e_source_backend_get_backend_name (backend_extension);
+ config->priv->provider = camel_provider_get (backend_name, &error);
+
+ if (error != NULL) {
+ g_warn_if_fail (config->priv->provider == NULL);
+ g_warning ("%s: %s", G_STRFUNC, error->message);
+ g_clear_error (&error);
+ config->priv->is_empty = TRUE;
+ return;
+ }
+
+ g_return_if_fail (config->priv->provider != NULL);
+
+ if (config->priv->provider->extra_conf == NULL) {
+ config->priv->is_empty = TRUE;
+ return;
+ }
+
+ extension_name = e_source_camel_get_extension_name (backend_name);
+ camel_extension = e_source_get_extension (source, extension_name);
+ config->priv->settings = e_source_camel_get_settings (camel_extension);
+
+ if (config->priv->settings == NULL) {
+ config->priv->is_empty = TRUE;
+ return;
+ }
+
+ g_object_ref (config->priv->settings);
+
+ mail_config_provider_add_widgets (config);
+}
+
+static void
+e_mail_config_provider_class_init (EMailConfigProviderClass *class)
+{
+ GObjectClass *object_class;
+
+ g_type_class_add_private (class, sizeof (EMailConfigProviderPrivate));
+
+ object_class = G_OBJECT_CLASS (class);
+ object_class->set_property = mail_config_provider_set_property;
+ object_class->get_property = mail_config_provider_get_property;
+ object_class->dispose = mail_config_provider_dispose;
+ object_class->constructed = mail_config_provider_constructed;
+
+ g_object_class_install_property (
+ object_class,
+ PROP_SCRATCH_SOURCE,
+ g_param_spec_object (
+ "scratch-source",
+ "Scratch Source",
+ "The data source being edited",
+ E_TYPE_SOURCE,
+ G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT_ONLY |
+ G_PARAM_STATIC_STRINGS));
+}
+
+static void
+e_mail_config_provider_init (EMailConfigProvider *config)
+{
+ config->priv = E_MAIL_CONFIG_PROVIDER_GET_PRIVATE (config);
+}
+
+GtkWidget *
+e_mail_config_provider_new (ESource *scratch_source)
+{
+ g_return_val_if_fail (E_IS_SOURCE (scratch_source), NULL);
+
+ return g_object_new (
+ E_TYPE_MAIL_CONFIG_PROVIDER,
+ "scratch-source", scratch_source, NULL);
+}
+
+gboolean
+e_mail_config_provider_is_empty (EMailConfigProvider *config)
+{
+ g_return_val_if_fail (E_IS_MAIL_CONFIG_PROVIDER (config), TRUE);
+
+ return config->priv->is_empty;
+}
+
+ESource *
+e_mail_config_provider_get_scratch_source (EMailConfigProvider *config)
+{
+ g_return_val_if_fail (E_IS_MAIL_CONFIG_PROVIDER (config), NULL);
+
+ return config->priv->scratch_source;
+}
+
diff --git a/mail/e-mail-config-provider.h b/mail/e-mail-config-provider.h
new file mode 100644
index 0000000..3cd2a72
--- /dev/null
+++ b/mail/e-mail-config-provider.h
@@ -0,0 +1,67 @@
+/*
+ * e-mail-config-provider.h
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) version 3.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with the program; if not, see <http://www.gnu.org/licenses/>
+ *
+ */
+
+#ifndef E_MAIL_CONFIG_PROVIDER_H
+#define E_MAIL_CONFIG_PROVIDER_H
+
+#include <gtk/gtk.h>
+#include <libedataserver/e-source.h>
+
+/* Standard GObject macros */
+#define E_TYPE_MAIL_CONFIG_PROVIDER \
+ (e_mail_config_provider_get_type ())
+#define E_MAIL_CONFIG_PROVIDER(obj) \
+ (G_TYPE_CHECK_INSTANCE_CAST \
+ ((obj), E_TYPE_MAIL_CONFIG_PROVIDER, EMailConfigProvider))
+#define E_MAIL_CONFIG_PROVIDER_CLASS(cls) \
+ (G_TYPE_CHECK_CLASS_CAST \
+ ((cls), E_TYPE_MAIL_CONFIG_PROVIDER, EMailConfigProviderClass))
+#define E_IS_MAIL_CONFIG_PROVIDER(obj) \
+ (G_TYPE_CHECK_INSTANCE_TYPE \
+ ((obj), E_TYPE_MAIL_CONFIG_PROVIDER))
+#define E_IS_MAIL_CONFIG_PROVIDER_CLASS(cls) \
+ (G_TYPE_CHECK_CLASS_TYPE \
+ ((cls), E_TYPE_MAIL_CONFIG_PROVIDER))
+#define E_MAIL_CONFIG_PROVIDER_GET_CLASS(obj) \
+ (G_TYPE_INSTANCE_GET_CLASS \
+ ((obj), E_TYPE_MAIL_CONFIG_PROVIDER, EMailConfigProviderClass))
+
+G_BEGIN_DECLS
+
+typedef struct _EMailConfigProvider EMailConfigProvider;
+typedef struct _EMailConfigProviderClass EMailConfigProviderClass;
+typedef struct _EMailConfigProviderPrivate EMailConfigProviderPrivate;
+
+struct _EMailConfigProvider {
+ GtkBox parent;
+ EMailConfigProviderPrivate *priv;
+};
+
+struct _EMailConfigProviderClass {
+ GtkBoxClass parent_class;
+};
+
+GType e_mail_config_provider_get_type (void) G_GNUC_CONST;
+GtkWidget * e_mail_config_provider_new (ESource *scratch_source);
+gboolean e_mail_config_provider_is_empty (EMailConfigProvider *config);
+ESource * e_mail_config_provider_get_scratch_source
+ (EMailConfigProvider *config);
+
+G_END_DECLS
+
+#endif /* E_MAIL_CONFIG_PROVIDER_H */
diff --git a/mail/e-mail-config.c b/mail/e-mail-config.c
new file mode 100644
index 0000000..3a97a05
--- /dev/null
+++ b/mail/e-mail-config.c
@@ -0,0 +1,809 @@
+/*
+ * e-mail-config.c
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) version 3.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with the program; if not, see <http://www.gnu.org/licenses/>
+ *
+ */
+
+#include "e-mail-config.h"
+
+#include <config.h>
+#include <glib/gi18n-lib.h>
+
+#include <camel/camel.h>
+#include <libebackend/e-extensible.h>
+#include <libedataserver/e-source-camel.h>
+#include <libedataserver/e-source-backend.h>
+
+#include <libevolution-utils/e-alert-sink.h>
+#include <libevolution-utils/e-alert-dialog.h>
+#include <e-util/e-marshal.h>
+#include <misc/e-activity-bar.h>
+#include <misc/e-alert-bar.h>
+#include <misc/e-source-notebook.h>
+
+#include <mail/e-mail-config-backend.h>
+
+#define E_MAIL_CONFIG_GET_PRIVATE(obj) \
+ (G_TYPE_INSTANCE_GET_PRIVATE \
+ ((obj), E_TYPE_MAIL_CONFIG, EMailConfigPrivate))
+
+typedef struct _Candidate Candidate;
+
+struct _EMailConfigPrivate {
+ ESourceRegistry *registry;
+ ESource *active_source;
+
+ GHashTable *backends;
+ GPtrArray *candidates;
+
+ GtkWidget *type_combo;
+ GtkWidget *type_label;
+ GtkWidget *desc_label;
+ GtkWidget *notebook;
+ GtkWidget *activity_bar;
+ GtkWidget *alert_bar;
+
+ gboolean complete;
+};
+
+struct _Candidate {
+ GtkWidget *page;
+ ESource *scratch_source;
+ EMailConfigBackend *backend;
+
+ CamelSettings *settings;
+ gulong settings_notify_handler_id;
+};
+
+enum {
+ PROP_0,
+ PROP_ACTIVE_SOURCE,
+ PROP_COMPLETE,
+ PROP_REGISTRY
+};
+
+enum {
+ CHANGED,
+ CHECK_COMPLETE,
+ LAST_SIGNAL
+};
+
+static guint signals[LAST_SIGNAL];
+
+/* Forward Declarations */
+static void e_mail_config_alert_sink_init (EAlertSinkInterface *interface);
+
+G_DEFINE_ABSTRACT_TYPE_WITH_CODE (
+ EMailConfig,
+ e_mail_config,
+ GTK_TYPE_BOX,
+ G_IMPLEMENT_INTERFACE (
+ E_TYPE_EXTENSIBLE, NULL)
+ G_IMPLEMENT_INTERFACE (
+ E_TYPE_ALERT_SINK,
+ e_mail_config_alert_sink_init))
+
+static void
+mail_config_free_candidate (Candidate *candidate)
+{
+ g_object_unref (candidate->page);
+ g_object_unref (candidate->scratch_source);
+ g_object_unref (candidate->backend);
+
+ g_signal_handler_disconnect (
+ candidate->settings,
+ candidate->settings_notify_handler_id);
+ g_object_unref (candidate->settings);
+
+ g_slice_free (Candidate, candidate);
+}
+
+static void
+mail_config_init_backends (EMailConfig *config)
+{
+ GList *list, *iter;
+
+ config->priv->backends = g_hash_table_new_full (
+ (GHashFunc) g_str_hash,
+ (GEqualFunc) g_str_equal,
+ (GDestroyNotify) g_free,
+ (GDestroyNotify) g_object_unref);
+
+ e_extensible_load_extensions (E_EXTENSIBLE (config));
+
+ list = e_extensible_list_extensions (
+ E_EXTENSIBLE (config), E_TYPE_MAIL_CONFIG_BACKEND);
+
+ for (iter = list; iter != NULL; iter = g_list_next (iter)) {
+ EMailConfigBackend *backend;
+ EMailConfigBackendClass *class;
+
+ backend = E_MAIL_CONFIG_BACKEND (iter->data);
+ class = E_MAIL_CONFIG_BACKEND_GET_CLASS (backend);
+
+ if (class->backend_name != NULL)
+ g_hash_table_insert (
+ config->priv->backends,
+ g_strdup (class->backend_name),
+ g_object_ref (backend));
+ }
+
+ g_list_free (list);
+}
+
+static void
+mail_config_settings_notify_cb (CamelSettings *settings,
+ GParamSpec *pspec,
+ EMailConfig *config)
+{
+ e_mail_config_changed (config);
+}
+
+static gboolean
+mail_config_backend_name_to_description (GBinding *binding,
+ const GValue *source_value,
+ GValue *target_value,
+ gpointer user_data)
+{
+ CamelProvider *provider;
+ const gchar *description;
+ const gchar *backend_name;
+
+ backend_name = g_value_get_string (source_value);
+ provider = camel_provider_get (backend_name, NULL);
+
+ if (provider != NULL && provider->description != NULL)
+ description = g_dgettext (
+ provider->translation_domain,
+ provider->description);
+ else
+ description = "";
+
+ g_value_set_string (target_value, description);
+
+ return TRUE;
+}
+
+static Candidate *
+mail_config_get_active_candidate (EMailConfig *config)
+{
+ GtkComboBox *combo_box;
+ gint active;
+
+ combo_box = GTK_COMBO_BOX (config->priv->type_combo);
+ active = gtk_combo_box_get_active (combo_box);
+ g_return_val_if_fail (active >= 0, NULL);
+
+ return g_ptr_array_index (config->priv->candidates, active);
+}
+
+static void
+mail_config_set_registry (EMailConfig *config,
+ ESourceRegistry *registry)
+{
+ g_return_if_fail (E_IS_SOURCE_REGISTRY (registry));
+ g_return_if_fail (config->priv->registry == NULL);
+
+ config->priv->registry = g_object_ref (registry);
+}
+
+static void
+mail_config_set_property (GObject *object,
+ guint property_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ switch (property_id) {
+ case PROP_ACTIVE_SOURCE:
+ e_mail_config_set_active_source (
+ E_MAIL_CONFIG (object),
+ g_value_get_object (value));
+ return;
+
+ case PROP_REGISTRY:
+ mail_config_set_registry (
+ E_MAIL_CONFIG (object),
+ g_value_get_object (value));
+ return;
+ }
+
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+}
+
+static void
+mail_config_get_property (GObject *object,
+ guint property_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ switch (property_id) {
+ case PROP_ACTIVE_SOURCE:
+ g_value_set_object (
+ value,
+ e_mail_config_get_active_source (
+ E_MAIL_CONFIG (object)));
+ return;
+
+ case PROP_COMPLETE:
+ g_value_set_boolean (
+ value,
+ e_mail_config_check_complete (
+ E_MAIL_CONFIG (object)));
+ return;
+
+ case PROP_REGISTRY:
+ g_value_set_object (
+ value,
+ e_mail_config_get_registry (
+ E_MAIL_CONFIG (object)));
+ return;
+ }
+
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+}
+
+static void
+mail_config_dispose (GObject *object)
+{
+ EMailConfigPrivate *priv;
+
+ priv = E_MAIL_CONFIG_GET_PRIVATE (object);
+
+ if (priv->registry != NULL) {
+ g_object_unref (priv->registry);
+ priv->registry = NULL;
+ }
+
+ if (priv->active_source != NULL) {
+ g_object_unref (priv->active_source);
+ priv->active_source = NULL;
+ }
+
+ g_hash_table_remove_all (priv->backends);
+ g_ptr_array_set_size (priv->candidates, 0);
+
+ /* Chain up to parent's dispose() method. */
+ G_OBJECT_CLASS (e_mail_config_parent_class)->dispose (object);
+}
+
+static void
+mail_config_finalize (GObject *object)
+{
+ EMailConfigPrivate *priv;
+
+ priv = E_MAIL_CONFIG_GET_PRIVATE (object);
+
+ g_hash_table_destroy (priv->backends);
+ g_ptr_array_free (priv->candidates, TRUE);
+
+ /* Chain up to parent's finalize() method. */
+ G_OBJECT_CLASS (e_mail_config_parent_class)->finalize (object);
+}
+
+static void
+mail_config_constructed (GObject *object)
+{
+ EMailConfig *config;
+
+ config = E_MAIL_CONFIG (object);
+
+ mail_config_init_backends (config);
+}
+
+static gboolean
+mail_config_check_complete (EMailConfig *config,
+ ESource *scratch_source)
+{
+ GtkComboBox *type_combo;
+
+ /* Make sure the combo box has an active item. */
+ type_combo = GTK_COMBO_BOX (config->priv->type_combo);
+ return (gtk_combo_box_get_active (type_combo) >= 0);
+}
+
+static gboolean
+mail_config_check_complete_accumulator (GSignalInvocationHint *ihint,
+ GValue *return_accu,
+ const GValue *handler_return,
+ gpointer unused)
+{
+ gboolean v_boolean;
+
+ /* Abort emission if a handler returns FALSE. */
+ v_boolean = g_value_get_boolean (handler_return);
+ g_value_set_boolean (return_accu, v_boolean);
+
+ return v_boolean;
+}
+
+static void
+mail_config_submit_alert (EAlertSink *alert_sink,
+ EAlert *alert)
+{
+ EMailConfigPrivate *priv;
+ EAlertBar *alert_bar;
+ GtkWidget *dialog;
+ GtkWindow *parent;
+
+ priv = E_MAIL_CONFIG_GET_PRIVATE (alert_sink);
+
+ switch (e_alert_get_message_type (alert)) {
+ case GTK_MESSAGE_INFO:
+ case GTK_MESSAGE_WARNING:
+ case GTK_MESSAGE_ERROR:
+ alert_bar = E_ALERT_BAR (priv->alert_bar);
+ e_alert_bar_add_alert (alert_bar, alert);
+ break;
+
+ default:
+ parent = GTK_WINDOW (alert_sink);
+ dialog = e_alert_dialog_new (parent, alert);
+ gtk_dialog_run (GTK_DIALOG (dialog));
+ gtk_widget_destroy (dialog);
+ break;
+ }
+}
+
+static void
+e_mail_config_class_init (EMailConfigClass *class)
+{
+ GObjectClass *object_class;
+
+ g_type_class_add_private (class, sizeof (EMailConfigPrivate));
+
+ object_class = G_OBJECT_CLASS (class);
+ object_class->set_property = mail_config_set_property;
+ object_class->get_property = mail_config_get_property;
+ object_class->dispose = mail_config_dispose;
+ object_class->finalize = mail_config_finalize;
+ object_class->constructed = mail_config_constructed;
+
+ class->check_complete = mail_config_check_complete;
+
+ g_object_class_install_property (
+ object_class,
+ PROP_ACTIVE_SOURCE,
+ g_param_spec_object (
+ "active-source",
+ "Active Source",
+ "The active data source",
+ E_TYPE_SOURCE,
+ G_PARAM_READWRITE |
+ G_PARAM_STATIC_STRINGS));
+
+ g_object_class_install_property (
+ object_class,
+ PROP_COMPLETE,
+ g_param_spec_boolean (
+ "complete",
+ "Complete",
+ "Are the required fields complete?",
+ FALSE,
+ G_PARAM_READABLE |
+ G_PARAM_STATIC_STRINGS));
+
+ g_object_class_install_property (
+ object_class,
+ PROP_REGISTRY,
+ g_param_spec_object (
+ "registry",
+ "Registry",
+ "Data source registry",
+ E_TYPE_SOURCE_REGISTRY,
+ G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT_ONLY |
+ G_PARAM_STATIC_STRINGS));
+
+ signals[CHANGED] = g_signal_new (
+ "changed",
+ G_OBJECT_CLASS_TYPE (class),
+ G_SIGNAL_RUN_FIRST,
+ G_STRUCT_OFFSET (EMailConfigClass, changed),
+ NULL, NULL,
+ g_cclosure_marshal_VOID__VOID,
+ G_TYPE_NONE, 0);
+
+ signals[CHECK_COMPLETE] = g_signal_new (
+ "check-complete",
+ G_OBJECT_CLASS_TYPE (class),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (EMailConfigClass, check_complete),
+ mail_config_check_complete_accumulator, NULL,
+ e_marshal_BOOLEAN__OBJECT,
+ G_TYPE_BOOLEAN, 1,
+ E_TYPE_SOURCE);
+}
+
+static void
+e_mail_config_alert_sink_init (EAlertSinkInterface *interface)
+{
+ interface->submit_alert = mail_config_submit_alert;
+}
+
+static void
+e_mail_config_init (EMailConfig *config)
+{
+ GPtrArray *candidates;
+ PangoAttribute *attr;
+ PangoAttrList *attr_list;
+ GtkLabel *label;
+ GtkWidget *frame;
+ GtkWidget *widget;
+ GtkWidget *container;
+
+ /* The candidates array holds scratch ESources, one for each
+ * item in the "type" combo box. Scratch ESources are never
+ * added to the registry, so backend extensions can make any
+ * changes they want to them. Whichever scratch ESource is
+ * "active" (selected in the "type" combo box) when the user
+ * clicks OK wins and is written to disk. The others are
+ * discarded. */
+ candidates = g_ptr_array_new_with_free_func (
+ (GDestroyNotify) mail_config_free_candidate);
+
+ gtk_box_set_spacing (GTK_BOX (config), 12);
+
+ gtk_orientable_set_orientation (
+ GTK_ORIENTABLE (config), GTK_ORIENTATION_VERTICAL);
+
+ config->priv = E_MAIL_CONFIG_GET_PRIVATE (config);
+ config->priv->candidates = candidates;
+
+ /* Either the combo box or the label is shown, never both.
+ * But we create both widgets and keep them both up-to-date
+ * regardless just because it makes the logic simpler. */
+
+ container = GTK_WIDGET (config);
+
+ widget = gtk_grid_new ();
+ gtk_grid_set_row_spacing (GTK_GRID (widget), 12);
+ gtk_box_pack_start (GTK_BOX (container), widget, FALSE, FALSE, 0);
+ gtk_widget_show (widget);
+
+ container = widget;
+
+ attr_list = pango_attr_list_new ();
+
+ attr = pango_attr_weight_new (PANGO_WEIGHT_BOLD);
+ pango_attr_list_insert (attr_list, attr);
+
+ widget = gtk_label_new_with_mnemonic (_("Server _Type:"));
+ gtk_widget_set_margin_right (widget, 12);
+ gtk_misc_set_alignment (GTK_MISC (widget), 1.0, 0.5);
+ gtk_grid_attach (GTK_GRID (container), widget, 0, 0, 1, 1);
+ gtk_widget_show (widget);
+
+ label = GTK_LABEL (widget);
+
+ widget = gtk_combo_box_text_new ();
+ gtk_widget_set_hexpand (widget, TRUE);
+ gtk_label_set_mnemonic_widget (label, widget);
+ gtk_grid_attach (GTK_GRID (container), widget, 1, 0, 1, 1);
+ config->priv->type_combo = widget; /* not referenced */
+ gtk_widget_show (widget);
+
+ widget = gtk_label_new (NULL);
+ gtk_widget_set_hexpand (widget, TRUE);
+ gtk_misc_set_alignment (GTK_MISC (widget), 0.0, 0.5);
+ gtk_label_set_attributes (GTK_LABEL (widget), attr_list);
+ gtk_grid_attach (GTK_GRID (container), widget, 2, 0, 1, 1);
+ config->priv->type_label = widget; /* not referenced */
+ gtk_widget_show (widget);
+
+ widget = gtk_label_new (_("Description:"));
+ gtk_widget_set_margin_right (widget, 12);
+ gtk_misc_set_alignment (GTK_MISC (widget), 1.0, 0.0);
+ gtk_grid_attach (GTK_GRID (container), widget, 0, 1, 1, 1);
+ gtk_widget_show (widget);
+
+ widget = gtk_label_new (NULL);
+ gtk_label_set_line_wrap (GTK_LABEL (widget), TRUE);
+ gtk_misc_set_alignment (GTK_MISC (widget), 0.0, 0.5);
+ gtk_grid_attach (GTK_GRID (container), widget, 1, 1, 2, 1);
+ config->priv->desc_label = widget; /* not referenced */
+ gtk_widget_show (widget);
+
+ pango_attr_list_unref (attr_list);
+
+ container = GTK_WIDGET (config);
+
+ widget = gtk_separator_new (GTK_ORIENTATION_HORIZONTAL);
+ gtk_box_pack_start (GTK_BOX (container), widget, FALSE, FALSE, 0);
+ gtk_widget_show (widget);
+
+ widget = e_source_notebook_new ();
+ gtk_box_pack_start (GTK_BOX (container), widget, TRUE, TRUE, 0);
+ config->priv->notebook = widget; /* not referenced */
+ gtk_widget_show (widget);
+
+ widget = gtk_frame_new (NULL);
+ gtk_frame_set_shadow_type (GTK_FRAME (widget), GTK_SHADOW_IN);
+ gtk_box_pack_start (GTK_BOX (container), widget, FALSE, FALSE, 0);
+ /* Visibility is bound to the EActivityBar. */
+
+ frame = widget;
+
+ widget = e_activity_bar_new ();
+ gtk_container_add (GTK_CONTAINER (frame), widget);
+ config->priv->activity_bar = widget; /* not referenced */
+ /* EActivityBar controls its own visibility. */
+
+ g_object_bind_property (
+ widget, "visible",
+ frame, "visible",
+ G_BINDING_SYNC_CREATE);
+
+ widget = gtk_frame_new (NULL);
+ gtk_frame_set_shadow_type (GTK_FRAME (widget), GTK_SHADOW_IN);
+ gtk_box_pack_start (GTK_BOX (container), widget, FALSE, FALSE, 0);
+ /* Visibility is bound to the EAlertBar. */
+
+ frame = widget;
+
+ widget = e_alert_bar_new ();
+ gtk_container_add (GTK_CONTAINER (frame), widget);
+ config->priv->alert_bar = widget; /* not referenced */
+ /* EAlertBar controls its own visibility. */
+
+ g_object_bind_property (
+ widget, "visible",
+ frame, "visible",
+ G_BINDING_SYNC_CREATE);
+
+ /* Keep the combo box's active row number synchronized with the
+ * notebook's current page number. Avoid G_BINDING_SYNC_CREATE
+ * since we haven't added any combo box rows. */
+ g_object_bind_property (
+ config->priv->type_combo, "active",
+ config->priv->notebook, "page",
+ G_BINDING_BIDIRECTIONAL);
+
+ /* Keep the active notebook data source synchronized with our
+ * own "active-source" property. Avoid G_BINDING_SYNC_CREATE
+ * since we haven't added any notebook pages. */
+ g_object_bind_property (
+ config, "active-source",
+ config->priv->notebook, "active-source",
+ G_BINDING_BIDIRECTIONAL);
+
+ /* This keeps the description field up-to-date. */
+ g_object_bind_property_full (
+ config->priv->type_combo, "active-id",
+ config->priv->desc_label, "label",
+ G_BINDING_DEFAULT,
+ mail_config_backend_name_to_description,
+ NULL,
+ NULL, (GDestroyNotify) NULL);
+
+ /* For the "Server Type", either the combo
+ * box or the label is visible, never both. */
+ g_object_bind_property (
+ config->priv->type_combo, "visible",
+ config->priv->type_label, "visible",
+ G_BINDING_SYNC_CREATE |
+ G_BINDING_BIDIRECTIONAL |
+ G_BINDING_INVERT_BOOLEAN);
+
+ g_signal_connect_swapped (
+ config->priv->type_combo, "changed",
+ G_CALLBACK (e_mail_config_changed), config);
+}
+
+ESource *
+e_mail_config_get_active_source (EMailConfig *config)
+{
+ g_return_val_if_fail (E_IS_MAIL_CONFIG (config), NULL);
+
+ return config->priv->active_source;
+}
+
+void
+e_mail_config_set_active_source (EMailConfig *config,
+ ESource *scratch_source)
+{
+ g_return_if_fail (E_IS_MAIL_CONFIG (config));
+
+ if (scratch_source != NULL) {
+ g_return_if_fail (E_IS_SOURCE (scratch_source));
+ g_object_ref (scratch_source);
+ }
+
+ if (config->priv->active_source != NULL)
+ g_object_unref (config->priv->active_source);
+
+ config->priv->active_source = scratch_source;
+
+ g_object_notify (G_OBJECT (config), "active-source");
+}
+
+ESourceRegistry *
+e_mail_config_get_registry (EMailConfig *config)
+{
+ g_return_val_if_fail (E_IS_MAIL_CONFIG (config), NULL);
+
+ return config->priv->registry;
+}
+
+CamelSettings *
+e_mail_config_get_settings (EMailConfig *config,
+ ESource *scratch_source)
+{
+ ESourceCamel *camel_ext;
+ ESourceBackend *backend_ext;
+ const gchar *backend_name;
+ const gchar *extension_name;
+
+ g_return_val_if_fail (E_IS_MAIL_CONFIG (config), NULL);
+ g_return_val_if_fail (E_IS_SOURCE (scratch_source), NULL);
+
+ extension_name = E_MAIL_CONFIG_GET_CLASS (config)->extension_name;
+ backend_ext = e_source_get_extension (scratch_source, extension_name);
+ backend_name = e_source_backend_get_backend_name (backend_ext);
+
+ extension_name = e_source_camel_get_extension_name (backend_name);
+ camel_ext = e_source_get_extension (scratch_source, extension_name);
+
+ return e_source_camel_get_settings (camel_ext);
+}
+
+void
+e_mail_config_add_scratch_source (EMailConfig *config,
+ ESource *scratch_source)
+{
+ GtkWidget *page;
+ GtkLabel *type_label;
+ GtkComboBoxText *type_combo;
+ CamelSettings *settings;
+ Candidate *candidate;
+ CamelProvider *provider;
+ ESourceBackend *extension;
+ ESourceNotebook *notebook;
+ EMailConfigBackend *backend;
+ const gchar *extension_name;
+ const gchar *backend_name;
+ const gchar *display_name;
+ gulong handler_id;
+ gint page_num;
+
+ g_return_if_fail (E_IS_MAIL_CONFIG (config));
+ g_return_if_fail (E_IS_SOURCE (scratch_source));
+
+ /* Get the backend name for this scratch source. */
+ extension_name = E_MAIL_CONFIG_GET_CLASS (config)->extension_name;
+ extension = e_source_get_extension (scratch_source, extension_name);
+ backend_name = e_source_backend_get_backend_name (extension);
+ g_return_if_fail (backend_name != NULL);
+
+ /* Make sure we have a corresponding CamelProvider. */
+ provider = camel_provider_get (backend_name, NULL);
+ g_return_if_fail (provider != NULL);
+
+ /* Make sure we have a corresponding CamelSettings. */
+ settings = e_mail_config_get_settings (config, scratch_source);
+ g_return_if_fail (CAMEL_IS_SETTINGS (settings));
+
+ /* Make sure we have a corresponding EMailConfigBackend. */
+ backend = g_hash_table_lookup (config->priv->backends, backend_name);
+ g_return_if_fail (E_IS_MAIL_CONFIG_BACKEND (backend));
+
+ page = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
+ e_mail_config_backend_insert_widgets (
+ backend, scratch_source, GTK_BOX (page));
+ gtk_widget_show (page);
+
+ candidate = g_slice_new0 (Candidate);
+ candidate->page = g_object_ref_sink (page);
+ candidate->backend = g_object_ref (backend);
+ candidate->settings = g_object_ref (settings);
+ candidate->scratch_source = g_object_ref (scratch_source);
+
+ /* Emit "changed" signals for subsequent CamelSettings changes. */
+ handler_id = g_signal_connect (
+ candidate->settings, "notify",
+ G_CALLBACK (mail_config_settings_notify_cb), config);
+ candidate->settings_notify_handler_id = handler_id;
+
+ g_ptr_array_add (config->priv->candidates, candidate);
+
+ display_name = g_dgettext (
+ provider->translation_domain,
+ provider->name);
+
+ notebook = E_SOURCE_NOTEBOOK (config->priv->notebook);
+ page_num = e_source_notebook_add_page (notebook, scratch_source, page);
+
+ type_combo = GTK_COMBO_BOX_TEXT (config->priv->type_combo);
+ gtk_combo_box_text_append (type_combo, backend_name, display_name);
+
+ /* The type label is only visible if we have one scratch source,
+ * so just always set the label text to the most recently added
+ * scratch source. */
+ type_label = GTK_LABEL (config->priv->type_label);
+ gtk_label_set_text (type_label, display_name);
+
+ /* If no combo box row is active yet, choose the new row. */
+ if (gtk_combo_box_get_active_id (GTK_COMBO_BOX (type_combo)) == NULL)
+ gtk_combo_box_set_active_id (
+ GTK_COMBO_BOX (type_combo), backend_name);
+
+ /* If the page number of the newly-added notebook page is zero,
+ * show the "type" label. Otherwise show the "type" combo box.
+ * There's an inverted "visible" binding between the combo box
+ * and label, so we only need to change one of the widgets. */
+ gtk_widget_set_visible (config->priv->type_combo, page_num > 0);
+}
+
+void
+e_mail_config_changed (EMailConfig *config)
+{
+ g_return_if_fail (E_IS_MAIL_CONFIG (config));
+
+ g_signal_emit (config, signals[CHANGED], 0);
+}
+
+gboolean
+e_mail_config_check_complete (EMailConfig *config)
+{
+ Candidate *candidate;
+ gboolean complete;
+
+ g_return_val_if_fail (E_IS_MAIL_CONFIG (config), FALSE);
+
+ candidate = mail_config_get_active_candidate (config);
+ g_return_val_if_fail (candidate != NULL, FALSE);
+
+ g_signal_emit (
+ config, signals[CHECK_COMPLETE], 0,
+ candidate->scratch_source, &complete);
+
+ complete &= e_mail_config_backend_check_complete (
+ candidate->backend, candidate->scratch_source);
+
+ /* XXX Emitting "notify::complete" may cause this function
+ * to be called repeatedly by signal handlers. The IF
+ * check below should break any recursive cycles. Not
+ * very efficient but I think we can live with it. */
+
+ if (complete != config->priv->complete) {
+ config->priv->complete = complete;
+ g_object_notify (G_OBJECT (config), "complete");
+ }
+
+ return complete;
+}
+
+EActivity *
+e_mail_config_new_activity (EMailConfig *config)
+{
+ EActivity *activity;
+ EActivityBar *activity_bar;
+ GCancellable *cancellable;
+
+ g_return_val_if_fail (E_IS_MAIL_CONFIG (config), NULL);
+
+ activity = e_activity_new ();
+
+ e_activity_set_alert_sink (activity, E_ALERT_SINK (config));
+
+ cancellable = camel_operation_new ();
+ e_activity_set_cancellable (activity, cancellable);
+ g_object_unref (cancellable);
+
+ activity_bar = E_ACTIVITY_BAR (config->priv->activity_bar);
+ e_activity_bar_set_activity (activity_bar, activity);
+
+ return activity;
+}
+
diff --git a/mail/e-mail-config.h b/mail/e-mail-config.h
new file mode 100644
index 0000000..b7fbbf9
--- /dev/null
+++ b/mail/e-mail-config.h
@@ -0,0 +1,93 @@
+/*
+ * e-mail-config.h
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) version 3.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with the program; if not, see <http://www.gnu.org/licenses/>
+ *
+ */
+
+/* XXX This is very similar to ESourceConfig for address books and
+ * calendars, but not similar enough to easily unify the APIs.
+ * Probably with more thought and effort it could be done. */
+
+#ifndef E_MAIL_CONFIG_H
+#define E_MAIL_CONFIG_H
+
+#include <gtk/gtk.h>
+#include <camel/camel.h>
+#include <libedataserver/e-source-extension.h>
+#include <libedataserver/e-source-registry.h>
+
+#include <e-util/e-activity.h>
+
+/* Standard GObject macros */
+#define E_TYPE_MAIL_CONFIG \
+ (e_mail_config_get_type ())
+#define E_MAIL_CONFIG(obj) \
+ (G_TYPE_CHECK_INSTANCE_CAST \
+ ((obj), E_TYPE_MAIL_CONFIG, EMailConfig))
+#define E_MAIL_CONFIG_CLASS(cls) \
+ (G_TYPE_CHECK_CLASS_CAST \
+ ((cls), E_TYPE_MAIL_CONFIG, EMailConfigClass))
+#define E_IS_MAIL_CONFIG(obj) \
+ (G_TYPE_CHECK_INSTANCE_TYPE \
+ ((obj), E_TYPE_MAIL_CONFIG))
+#define E_IS_MAIL_CONFIG_CLASS(cls) \
+ (G_TYPE_CHECK_CLASS_TYPE \
+ ((cls), E_TYPE_MAIL_CONFIG))
+#define E_MAIL_CONFIG_GET_CLASS(obj) \
+ (G_TYPE_INSTANCE_GET_CLASS \
+ ((obj), E_TYPE_MAIL_CONFIG, EMailConfigClass))
+
+G_BEGIN_DECLS
+
+typedef struct _EMailConfig EMailConfig;
+typedef struct _EMailConfigClass EMailConfigClass;
+typedef struct _EMailConfigPrivate EMailConfigPrivate;
+
+struct _EMailConfig {
+ GtkBox parent;
+ EMailConfigPrivate *priv;
+};
+
+struct _EMailConfigClass {
+ GtkBoxClass parent_class;
+
+ const gchar *extension_name;
+ CamelProviderType provider_type;
+
+ /* Signals */
+ void (*changed) (EMailConfig *config);
+ gboolean (*check_complete) (EMailConfig *config,
+ ESource *scratch_source);
+};
+
+GType e_mail_config_get_type (void) G_GNUC_CONST;
+ESource * e_mail_config_get_active_source (EMailConfig *config);
+void e_mail_config_set_active_source (EMailConfig *config,
+ ESource *scratch_source);
+ESourceRegistry *
+ e_mail_config_get_registry (EMailConfig *config);
+CamelSettings * e_mail_config_get_settings (EMailConfig *config,
+ ESource *scratch_source);
+void e_mail_config_add_scratch_source
+ (EMailConfig *config,
+ ESource *scratch_source);
+void e_mail_config_changed (EMailConfig *config);
+gboolean e_mail_config_check_complete (EMailConfig *config);
+EActivity * e_mail_config_new_activity (EMailConfig *config);
+
+G_END_DECLS
+
+#endif /* E_MAIL_CONFIG_H */
+
diff --git a/mail/e-mail-folder-pane.c b/mail/e-mail-folder-pane.c
index 7e0457e..03168ce 100644
--- a/mail/e-mail-folder-pane.c
+++ b/mail/e-mail-folder-pane.c
@@ -74,7 +74,10 @@ folder_pane_set_preview_visible (EMailView *view,
static guint
mail_paned_view_open_selected_mail (EMailPanedView *view)
{
+ EShell *shell;
EMailReader *reader;
+ EMailBackend *backend;
+ ESourceRegistry *registry;
GPtrArray *uids;
gint i;
GtkWindow *window;
@@ -88,6 +91,10 @@ mail_paned_view_open_selected_mail (EMailPanedView *view)
uids = e_mail_reader_get_selected_uids (reader);
g_return_val_if_fail (uids != NULL, 0);
+ backend = e_mail_reader_get_backend (reader);
+ shell = e_shell_backend_get_shell (E_SHELL_BACKEND (backend));
+ registry = e_shell_get_registry (shell);
+
/* XXX Either e_mail_reader_get_selected_uids()
* or MessageList should do this itself. */
g_ptr_array_set_free_func (uids, (GDestroyNotify) g_free);
@@ -97,9 +104,9 @@ mail_paned_view_open_selected_mail (EMailPanedView *view)
return 0;
}
- if (em_utils_folder_is_drafts (folder) ||
- em_utils_folder_is_outbox (folder) ||
- em_utils_folder_is_templates (folder)) {
+ if (em_utils_folder_is_drafts (registry, folder) ||
+ em_utils_folder_is_outbox (registry, folder) ||
+ em_utils_folder_is_templates (registry, folder)) {
em_utils_edit_messages (reader, folder, uids, TRUE);
g_ptr_array_unref (uids);
return 0;
@@ -127,8 +134,8 @@ mail_paned_view_open_selected_mail (EMailPanedView *view)
CAMEL_VEE_FOLDER (folder),
(CamelVeeMessageInfo *) info, &real_uid);
- if (em_utils_folder_is_drafts (real_folder) ||
- em_utils_folder_is_outbox (real_folder)) {
+ if (em_utils_folder_is_drafts (registry, real_folder) ||
+ em_utils_folder_is_outbox (registry, real_folder)) {
GPtrArray *edits;
edits = g_ptr_array_new_with_free_func (
diff --git a/mail/e-mail-migrate.c b/mail/e-mail-migrate.c
index b54a764..4bc3610 100644
--- a/mail/e-mail-migrate.c
+++ b/mail/e-mail-migrate.c
@@ -61,9 +61,6 @@
#include <e-util/e-util-private.h>
#include <e-util/e-plugin.h>
-#include <libemail-utils/e-account-utils.h>
-#include <libemail-utils/e-signature-utils.h>
-
#include <libemail-engine/e-mail-folder-utils.h>
#include "e-mail-backend.h"
@@ -229,6 +226,7 @@ cp (const gchar *src,
static void
em_update_accounts_2_11 (void)
{
+#if 0 /* ACCOUNT_MGMT */
EAccountList *accounts;
EIterator *iter;
gboolean changed = FALSE;
@@ -261,6 +259,7 @@ em_update_accounts_2_11 (void)
if (changed)
e_account_list_save (accounts);
+#endif /* ACCOUNT_MGMT */
}
#endif /* !G_OS_WIN32 */
@@ -670,6 +669,7 @@ static gboolean
create_mbox_account (EShellBackend *shell_backend,
EMMigrateSession *session)
{
+#if 0 /* ACCOUNT_MGMT */
EMailBackend *mail_backend;
EMailSession *mail_session;
CamelService *service;
@@ -739,6 +739,7 @@ exit:
g_free (uri);
g_free (name);
g_free (id);
+#endif /* ACCOUNT_MGMT */
return TRUE;
}
@@ -746,6 +747,7 @@ exit:
static void
change_sent_and_drafts_local_folders (EShellBackend *shell_backend)
{
+#if 0 /* ACCOUNT_MGMT */
EMailBackend *backend;
EMailSession *session;
EAccountList *accounts;
@@ -830,243 +832,7 @@ change_sent_and_drafts_local_folders (EShellBackend *shell_backend)
if (changed)
e_account_list_save (accounts);
-}
-
-static void
-em_rename_camel_url_params (CamelURL *url)
-{
- /* This list includes known URL parameters from built-in providers
- * in Camel, as well as from evolution-exchange, evolution-groupwise,
- * and evolution-mapi. Add more as needed. */
- static struct {
- const gchar *url_parameter;
- const gchar *property_name;
- } camel_url_conversion[] = {
- { "ad_auth", "gc-auth-method" },
- { "ad_browse", "gc-allow-browse" },
- { "ad_expand_groups", "gc-expand-groups" },
- { "ad_limit", "gc-results-limit" },
- { "ad_server", "gc-server-name" },
- { "all_headers", "fetch-headers" },
- { "basic_headers", "fetch-headers" },
- { "cachedconn" "concurrent-connections" },
- { "check_all", "check-all" },
- { "check_lsub", "check-subscribed" },
- { "command", "shell-command" },
- { "delete_after", "delete-after-days" },
- { "delete_expunged", "delete-expunged" },
- { "disable_extensions", "disable-extensions" },
- { "dotfolders", "use-dot-folders" },
- { "filter", "filter-inbox" },
- { "filter_junk", "filter-junk" },
- { "filter_junk_inbox", "filter-junk-inbox" },
- { "folder_hierarchy_relative", "folder-hierarchy-relative" },
- { "imap_custom_headers", "fetch-headers-extra" },
- { "keep_on_server", "keep-on-server" },
- { "offline_sync", "stay-synchronized" },
- { "override_namespace", "use-namespace" },
- { "owa_path", "owa-path" },
- { "owa_url", "owa-url" },
- { "password_exp_warn_period", "password-exp-warn-period" },
- { "real_junk_path", "real-junk-path" },
- { "real_trash_path", "real-trash-path" },
- { "show_short_notation", "short-folder-names" },
- { "soap_port", "soap-port" },
- { "ssl", "security-method" },
- { "sync_offline", "stay-synchronized" },
- { "use_command", "use-shell-command" },
- { "use_idle", "use-idle" },
- { "use_lsub", "use-subscriptions" },
- { "use_qresync", "use-qresync" },
- { "use_ssl", "security-method" },
- { "xstatus", "use-xstatus-headers" }
- };
-
- const gchar *param;
- const gchar *use_param;
- gint ii;
-
- for (ii = 0; ii < G_N_ELEMENTS (camel_url_conversion); ii++) {
- const gchar *key;
- gpointer value;
-
- key = camel_url_conversion[ii].url_parameter;
- value = g_datalist_get_data (&url->params, key);
-
- if (value == NULL)
- continue;
-
- g_datalist_remove_no_notify (&url->params, key);
-
- key = camel_url_conversion[ii].property_name;
-
- /* Deal with a few special enum cases where
- * the parameter value also needs renamed. */
-
- if (strcmp (key, "all_headers") == 0) {
- GEnumClass *enum_class;
- GEnumValue *enum_value;
-
- enum_class = g_type_class_ref (
- CAMEL_TYPE_FETCH_HEADERS_TYPE);
- enum_value = g_enum_get_value (
- enum_class, CAMEL_FETCH_HEADERS_ALL);
- if (enum_value != NULL) {
- g_free (value);
- value = g_strdup (enum_value->value_nick);
- } else
- g_warn_if_reached ();
- g_type_class_unref (enum_class);
- }
-
- if (strcmp (key, "basic_headers") == 0) {
- GEnumClass *enum_class;
- GEnumValue *enum_value;
-
- enum_class = g_type_class_ref (
- CAMEL_TYPE_FETCH_HEADERS_TYPE);
- enum_value = g_enum_get_value (
- enum_class, CAMEL_FETCH_HEADERS_BASIC);
- if (enum_value != NULL) {
- g_free (value);
- value = g_strdup (enum_value->value_nick);
- } else
- g_warn_if_reached ();
- g_type_class_unref (enum_class);
- }
-
- if (strcmp (key, "imap_custom_headers") == 0)
- g_strdelimit (value, " ", ',');
-
- if (strcmp (key, "security-method") == 0) {
- CamelNetworkSecurityMethod method;
- GEnumClass *enum_class;
- GEnumValue *enum_value;
-
- if (strcmp (value, "always") == 0)
- method = CAMEL_NETWORK_SECURITY_METHOD_SSL_ON_ALTERNATE_PORT;
- else if (strcmp (value, "1") == 0)
- method = CAMEL_NETWORK_SECURITY_METHOD_SSL_ON_ALTERNATE_PORT;
- else if (strcmp (value, "when-possible") == 0)
- method = CAMEL_NETWORK_SECURITY_METHOD_STARTTLS_ON_STANDARD_PORT;
- else
- method = CAMEL_NETWORK_SECURITY_METHOD_NONE;
-
- enum_class = g_type_class_ref (
- CAMEL_TYPE_NETWORK_SECURITY_METHOD);
- enum_value = g_enum_get_value (enum_class, method);
- if (enum_value != NULL) {
- g_free (value);
- value = g_strdup (enum_value->value_nick);
- } else
- g_warn_if_reached ();
- g_type_class_unref (enum_class);
- }
-
- g_datalist_set_data_full (&url->params, key, value, g_free);
- }
-
- /* A few more adjustments...
- *
- * These are all CAMEL_PROVIDER_CONF_CHECKSPIN settings. The spin
- * button value is bound to "param" and the checkbox state is bound
- * to "use-param". The "use-param" settings are new. If "param"
- * exists but no "use-param", then set "use-param" to "true". */
-
- param = g_datalist_get_data (&url->params, "gc-results-limit");
- use_param = g_datalist_get_data (&url->params, "use-gc-results-limit");
- if (param != NULL && *param != '\0' && use_param == NULL) {
- g_datalist_set_data_full (
- &url->params, "use-gc-results-limit",
- g_strdup ("true"), (GDestroyNotify) g_free);
- }
-
- param = g_datalist_get_data (&url->params, "kerberos");
- if (g_strcmp0 (param, "required") == 0) {
- g_datalist_set_data_full (
- &url->params, "kerberos",
- g_strdup ("true"), (GDestroyNotify) g_free);
- }
-
- param = g_datalist_get_data (
- &url->params, "password-exp-warn-period");
- use_param = g_datalist_get_data (
- &url->params, "use-password-exp-warn-period");
- if (param != NULL && *param != '\0' && use_param == NULL) {
- g_datalist_set_data_full (
- &url->params, "use-password-exp-warn-period",
- g_strdup ("true"), (GDestroyNotify) g_free);
- }
-
- param = g_datalist_get_data (&url->params, "real-junk-path");
- use_param = g_datalist_get_data (&url->params, "use-real-junk-path");
- if (param != NULL && *param != '\0' && use_param == NULL) {
- g_datalist_set_data_full (
- &url->params, "use-real-junk-path",
- g_strdup ("true"), (GDestroyNotify) g_free);
- }
-
- param = g_datalist_get_data (&url->params, "real-trash-path");
- use_param = g_datalist_get_data (&url->params, "use-real-trash-path");
- if (param != NULL && *param != '\0' && use_param == NULL) {
- g_datalist_set_data_full (
- &url->params, "use-real-trash-path",
- g_strdup ("true"), (GDestroyNotify) g_free);
- }
-}
-
-static void
-em_rename_account_params (void)
-{
- EAccountList *account_list;
- EIterator *iterator;
-
- /* XXX As of 3.2, CamelServices store settings in GObject properties,
- * not CamelURL parameters. CamelURL parameters are still used
- * for storage in GConf until we can move account information to
- * key files, but this is only within Evolution. Some of the new
- * GObject property names differ from the old CamelURL parameter
- * names. This routine renames the CamelURL parameter names to
- * the GObject property names for all accounts, both the source
- * and tranport URLs. */
-
- account_list = e_get_account_list ();
- iterator = e_list_get_iterator (E_LIST (account_list));
-
- while (e_iterator_is_valid (iterator)) {
- EAccount *account;
- CamelURL *url = NULL;
-
- /* XXX EIterator misuses const. */
- account = (EAccount *) e_iterator_get (iterator);
-
- if (account->source->url != NULL)
- url = camel_url_new (account->source->url, NULL);
-
- if (url != NULL) {
- em_rename_camel_url_params (url);
- g_free (account->source->url);
- account->source->url = camel_url_to_string (url, 0);
- camel_url_free (url);
- }
-
- url = NULL;
-
- if (account->transport->url != NULL)
- url = camel_url_new (account->transport->url, NULL);
-
- if (url != NULL) {
- em_rename_camel_url_params (url);
- g_free (account->transport->url);
- account->transport->url = camel_url_to_string (url, 0);
- camel_url_free (url);
- }
-
- e_iterator_next (iterator);
- }
-
- g_object_unref (iterator);
- e_account_list_save (account_list);
+#endif /* ACCOUNT_MGMT */
}
static gboolean
@@ -1296,10 +1062,6 @@ e_mail_migrate (EShellBackend *shell_backend,
em_ensure_proxy_ignore_hosts_being_list ();
}
- /* Rename account URL parameters to
- * match CamelSettings property names. */
- em_rename_account_params ();
-
if (!migrate_local_store (shell_backend))
return FALSE;
diff --git a/mail/e-mail-paned-view.c b/mail/e-mail-paned-view.c
index e1779a8..6fe3211 100644
--- a/mail/e-mail-paned-view.c
+++ b/mail/e-mail-paned-view.c
@@ -817,6 +817,7 @@ mail_paned_view_update_view_instance (EMailView *view)
EShellWindow *shell_window;
EShellViewClass *shell_view_class;
EShellSettings *shell_settings;
+ ESourceRegistry *registry;
GalViewCollection *view_collection;
GalViewInstance *view_instance;
CamelFolder *folder;
@@ -834,6 +835,7 @@ mail_paned_view_update_view_instance (EMailView *view)
shell_window = e_shell_view_get_shell_window (shell_view);
shell = e_shell_window_get_shell (shell_window);
+ registry = e_shell_get_registry (shell);
shell_settings = e_shell_get_shell_settings (shell);
reader = E_MAIL_READER (view);
@@ -852,9 +854,9 @@ mail_paned_view_update_view_instance (EMailView *view)
e_filename_make_safe (view_id);
outgoing_folder =
- em_utils_folder_is_drafts (folder) ||
- em_utils_folder_is_outbox (folder) ||
- em_utils_folder_is_sent (folder);
+ em_utils_folder_is_drafts (registry, folder) ||
+ em_utils_folder_is_outbox (registry, folder) ||
+ em_utils_folder_is_sent (registry, folder);
if (e_shell_settings_get_boolean (shell_settings, "mail-global-view-setting"))
view_instance = e_shell_view_new_view_instance (
diff --git a/mail/e-mail-reader-utils.c b/mail/e-mail-reader-utils.c
index bc87295..7809270 100644
--- a/mail/e-mail-reader-utils.c
+++ b/mail/e-mail-reader-utils.c
@@ -30,6 +30,7 @@
#include <glib/gi18n.h>
#include <libxml/tree.h>
#include <gtkhtml/gtkhtml.h>
+#include <gconf/gconf-client.h>
#include <camel/camel.h>
#include "libevolution-utils/e-alert-dialog.h"
@@ -344,7 +345,9 @@ copy_tree_state (EMailReader *src_reader,
guint
e_mail_reader_open_selected (EMailReader *reader)
{
+ EShell *shell;
EMailBackend *backend;
+ ESourceRegistry *registry;
CamelFolder *folder;
GtkWindow *window;
GPtrArray *views;
@@ -354,6 +357,9 @@ e_mail_reader_open_selected (EMailReader *reader)
g_return_val_if_fail (E_IS_MAIL_READER (reader), 0);
backend = e_mail_reader_get_backend (reader);
+ shell = e_shell_backend_get_shell (E_SHELL_BACKEND (backend));
+ registry = e_shell_get_registry (shell);
+
folder = e_mail_reader_get_folder (reader);
uids = e_mail_reader_get_selected_uids (reader);
window = e_mail_reader_get_window (reader);
@@ -363,9 +369,9 @@ e_mail_reader_open_selected (EMailReader *reader)
return 0;
}
- if (em_utils_folder_is_drafts (folder) ||
- em_utils_folder_is_outbox (folder) ||
- em_utils_folder_is_templates (folder)) {
+ if (em_utils_folder_is_drafts (registry, folder) ||
+ em_utils_folder_is_outbox (registry, folder) ||
+ em_utils_folder_is_templates (registry, folder)) {
em_utils_edit_messages (reader, folder, uids, TRUE);
return uids->len;
}
@@ -392,8 +398,8 @@ e_mail_reader_open_selected (EMailReader *reader)
CAMEL_VEE_FOLDER (folder),
(CamelVeeMessageInfo *) info, &real_uid);
- if (em_utils_folder_is_drafts (real_folder) ||
- em_utils_folder_is_outbox (real_folder)) {
+ if (em_utils_folder_is_drafts (registry, real_folder) ||
+ em_utils_folder_is_outbox (registry, real_folder)) {
GPtrArray *edits;
edits = g_ptr_array_new ();
@@ -1153,9 +1159,12 @@ void
e_mail_reader_create_filter_from_selected (EMailReader *reader,
gint filter_type)
{
+ EShell *shell;
EActivity *activity;
+ EMailBackend *backend;
AsyncContext *context;
GCancellable *cancellable;
+ ESourceRegistry *registry;
CamelFolder *folder;
GPtrArray *uids;
const gchar *filter_source;
@@ -1163,12 +1172,16 @@ e_mail_reader_create_filter_from_selected (EMailReader *reader,
g_return_if_fail (E_IS_MAIL_READER (reader));
+ backend = e_mail_reader_get_backend (reader);
+ shell = e_shell_backend_get_shell (E_SHELL_BACKEND (backend));
+ registry = e_shell_get_registry (shell);
+
folder = e_mail_reader_get_folder (reader);
g_return_if_fail (CAMEL_IS_FOLDER (folder));
- if (em_utils_folder_is_sent (folder))
+ if (em_utils_folder_is_sent (registry, folder))
filter_source = E_FILTER_SOURCE_OUTGOING;
- else if (em_utils_folder_is_outbox (folder))
+ else if (em_utils_folder_is_outbox (registry, folder))
filter_source = E_FILTER_SOURCE_OUTGOING;
else
filter_source = E_FILTER_SOURCE_INCOMING;
diff --git a/mail/e-mail-reader.c b/mail/e-mail-reader.c
index 53d4c31..ef990ef 100644
--- a/mail/e-mail-reader.c
+++ b/mail/e-mail-reader.c
@@ -28,6 +28,8 @@
#include <glib/gi18n.h>
#include <gdk/gdkkeysyms.h>
+#include <libedataserver/e-source-mail-account.h>
+
#ifdef HAVE_XFREE
#include <X11/XF86keysym.h>
#endif
@@ -39,7 +41,6 @@
#include "widgets/misc/e-popup-action.h"
#include "widgets/misc/e-menu-tool-action.h"
-#include "libemail-utils/e-account-utils.h"
#include "libemail-utils/mail-mt.h"
#include "libemail-engine/mail-ops.h"
@@ -768,6 +769,9 @@ static void
action_mail_message_edit_cb (GtkAction *action,
EMailReader *reader)
{
+ EShell *shell;
+ EMailBackend *backend;
+ ESourceRegistry *registry;
CamelFolder *folder;
GPtrArray *uids;
gboolean replace;
@@ -776,11 +780,15 @@ action_mail_message_edit_cb (GtkAction *action,
uids = e_mail_reader_get_selected_uids (reader);
g_return_if_fail (uids != NULL);
+ backend = e_mail_reader_get_backend (reader);
+ shell = e_shell_backend_get_shell (E_SHELL_BACKEND (backend));
+ registry = e_shell_get_registry (shell);
+
/* XXX Either e_mail_reader_get_selected_uids()
* or MessageList should do this itself. */
g_ptr_array_set_free_func (uids, (GDestroyNotify) g_free);
- replace = em_utils_folder_is_drafts (folder);
+ replace = em_utils_folder_is_drafts (registry, folder);
em_utils_edit_messages (reader, folder, uids, replace);
g_ptr_array_unref (uids);
@@ -2871,6 +2879,7 @@ mail_reader_set_folder (EMailReader *reader,
EMailReaderPrivate *priv;
EMFormatHTML *formatter;
CamelFolder *previous_folder;
+ ESourceRegistry *registry;
GtkWidget *message_list;
EMailBackend *backend;
EShell *shell;
@@ -2878,13 +2887,14 @@ mail_reader_set_folder (EMailReader *reader,
priv = E_MAIL_READER_GET_PRIVATE (reader);
- backend = e_mail_reader_get_backend (reader);
formatter = e_mail_reader_get_formatter (reader);
message_list = e_mail_reader_get_message_list (reader);
previous_folder = e_mail_reader_get_folder (reader);
+ backend = e_mail_reader_get_backend (reader);
shell = e_shell_backend_get_shell (E_SHELL_BACKEND (backend));
+ registry = e_shell_get_registry (shell);
/* Only synchronize the folder if we're online. */
if (previous_folder != NULL && e_shell_get_online (shell))
@@ -2895,9 +2905,9 @@ mail_reader_set_folder (EMailReader *reader,
return;
outgoing = folder != NULL && (
- em_utils_folder_is_drafts (folder) ||
- em_utils_folder_is_outbox (folder) ||
- em_utils_folder_is_sent (folder));
+ em_utils_folder_is_drafts (registry, folder) ||
+ em_utils_folder_is_outbox (registry, folder) ||
+ em_utils_folder_is_sent (registry, folder));
/* FIXME Need to pass a GCancellable. */
em_format_format (EM_FORMAT (formatter), NULL, NULL, NULL, NULL);
@@ -3894,9 +3904,14 @@ e_mail_reader_changed (EMailReader *reader)
guint32
e_mail_reader_check_state (EMailReader *reader)
{
+ EShell *shell;
GPtrArray *uids;
CamelFolder *folder;
CamelStore *store = NULL;
+ EMailBackend *backend;
+ ESourceRegistry *registry;
+ GList *list, *iter;
+ const gchar *extension_name;
const gchar *tag;
gboolean can_clear_flags = FALSE;
gboolean can_flag_completed = FALSE;
@@ -3910,6 +3925,7 @@ e_mail_reader_check_state (EMailReader *reader)
gboolean has_undeleted = FALSE;
gboolean has_unimportant = FALSE;
gboolean has_unread = FALSE;
+ gboolean have_enabled_account = FALSE;
gboolean drafts_or_outbox = FALSE;
gboolean store_supports_vjunk = FALSE;
gboolean is_mailing_list;
@@ -3919,6 +3935,10 @@ e_mail_reader_check_state (EMailReader *reader)
g_return_val_if_fail (E_IS_MAIL_READER (reader), 0);
+ backend = e_mail_reader_get_backend (reader);
+ shell = e_shell_backend_get_shell (E_SHELL_BACKEND (backend));
+ registry = e_shell_get_registry (shell);
+
folder = e_mail_reader_get_folder (reader);
uids = e_mail_reader_get_selected_uids (reader);
@@ -3928,8 +3948,8 @@ e_mail_reader_check_state (EMailReader *reader)
is_junk_folder =
(folder->folder_flags & CAMEL_FOLDER_IS_JUNK) != 0;
drafts_or_outbox =
- em_utils_folder_is_drafts (folder) ||
- em_utils_folder_is_outbox (folder);
+ em_utils_folder_is_drafts (registry, folder) ||
+ em_utils_folder_is_outbox (registry, folder);
}
/* Initialize this flag based on whether there are any
@@ -4014,7 +4034,21 @@ e_mail_reader_check_state (EMailReader *reader)
camel_folder_free_message_info (folder, info);
}
- if (e_get_any_enabled_account () != NULL)
+ extension_name = E_SOURCE_EXTENSION_MAIL_ACCOUNT;
+ list = e_source_registry_list_sources (registry, extension_name);
+
+ for (iter = list; iter != NULL; iter = g_list_next (iter)) {
+ ESource *source = E_SOURCE (iter->data);
+
+ if (e_source_get_enabled (source)) {
+ have_enabled_account = TRUE;
+ break;
+ }
+ }
+
+ g_list_free (list);
+
+ if (have_enabled_account)
state |= E_MAIL_READER_HAVE_ENABLED_ACCOUNT;
if (uids->len == 1)
state |= E_MAIL_READER_SELECTION_SINGLE;
diff --git a/mail/e-mail-transport-config.c b/mail/e-mail-transport-config.c
new file mode 100644
index 0000000..0b9ccb8
--- /dev/null
+++ b/mail/e-mail-transport-config.c
@@ -0,0 +1,52 @@
+/*
+ * e-mail-transport-config.c
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) version 3.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with the program; if not, see <http://www.gnu.org/licenses/>
+ *
+ */
+
+#include "e-mail-transport-config.h"
+
+#include <libedataserver/e-source-mail-transport.h>
+
+G_DEFINE_TYPE (
+ EMailTransportConfig,
+ e_mail_transport_config,
+ E_TYPE_MAIL_CONFIG)
+
+static void
+e_mail_transport_config_class_init (EMailTransportConfigClass *class)
+{
+ EMailConfigClass *mail_config_class;
+
+ mail_config_class = E_MAIL_CONFIG_CLASS (class);
+ mail_config_class->extension_name = E_SOURCE_EXTENSION_MAIL_TRANSPORT;
+ mail_config_class->provider_type = CAMEL_PROVIDER_TRANSPORT;
+}
+
+static void
+e_mail_transport_config_init (EMailTransportConfig *config)
+{
+}
+
+GtkWidget *
+e_mail_transport_config_new (ESourceRegistry *registry)
+{
+ g_return_val_if_fail (E_IS_SOURCE_REGISTRY (registry), NULL);
+
+ return g_object_new (
+ E_TYPE_MAIL_TRANSPORT_CONFIG,
+ "registry", registry, NULL);
+}
+
diff --git a/mail/e-mail-transport-config.h b/mail/e-mail-transport-config.h
new file mode 100644
index 0000000..ebb5ff0
--- /dev/null
+++ b/mail/e-mail-transport-config.h
@@ -0,0 +1,64 @@
+/*
+ * e-mail-transport-config.h
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) version 3.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with the program; if not, see <http://www.gnu.org/licenses/>
+ *
+ */
+
+#ifndef E_MAIL_TRANSPORT_CONFIG_H
+#define E_MAIL_TRANSPORT_CONFIG_H
+
+#include <mail/e-mail-config.h>
+
+/* Standard GObject macros */
+#define E_TYPE_MAIL_TRANSPORT_CONFIG \
+ (e_mail_transport_config_get_type ())
+#define E_MAIL_TRANSPORT_CONFIG(obj) \
+ (G_TYPE_CHECK_INSTANCE_CAST \
+ ((obj), E_TYPE_MAIL_TRANSPORT_CONFIG, EMailTransportConfig))
+#define E_MAIL_TRANSPORT_CONFIG_CLASS(cls) \
+ (G_TYPE_CHECK_CLASS_CAST \
+ ((cls), E_TYPE_MAIL_TRANSPORT_CONFIG, EMailTransportConfigClass))
+#define E_IS_MAIL_TRANSPORT_CONFIG(obj) \
+ (G_TYPE_CHECK_INSTANCE_TYPE \
+ ((obj), E_TYPE_MAIL_TRANSPORT_CONFIG))
+#define E_IS_MAIL_TRANSPORT_CONFIG_CLASS(cls) \
+ (G_TYPE_CHECK_CLASS_TYPE \
+ ((cls), E_TYPE_MAIL_TRANSPORT_CONFIG))
+#define E_MAIL_TRANSPORT_CONFIG_GET_CLASS(obj) \
+ (G_TYPE_INSTANCE_GET_CLASS \
+ ((obj), E_TYPE_MAIL_TRANSPORT_CONFIG, EMailTransportConfigClass))
+
+G_BEGIN_DECLS
+
+typedef struct _EMailTransportConfig EMailTransportConfig;
+typedef struct _EMailTransportConfigClass EMailTransportConfigClass;
+typedef struct _EMailTransportConfigPrivate EMailTransportConfigPrivate;
+
+struct _EMailTransportConfig {
+ EMailConfig parent;
+};
+
+struct _EMailTransportConfigClass {
+ EMailConfigClass parent_class;
+};
+
+GType e_mail_transport_config_get_type
+ (void) G_GNUC_CONST;
+GtkWidget * e_mail_transport_config_new (ESourceRegistry *registry);
+
+G_END_DECLS
+
+#endif /* E_MAIL_TRANSPORT_CONFIG_H */
+
diff --git a/mail/e-mail-ui-session.c b/mail/e-mail-ui-session.c
index fd9a4a9..f5f5bdd 100644
--- a/mail/e-mail-ui-session.c
+++ b/mail/e-mail-ui-session.c
@@ -44,13 +44,13 @@
#include <libedataserver/e-flag.h>
#include <libedataserver/e-proxy.h>
+#include <libedataserver/e-source-mail-account.h>
#include <libebackend/e-extensible.h>
#include <libedataserverui/e-passwords.h>
#include "e-mail-account-store.h"
#include "e-util/e-util.h"
-#include "libemail-utils/e-account-utils.h"
#include "libevolution-utils/e-alert-dialog.h"
#include "e-util/e-util-private.h"
@@ -82,11 +82,11 @@ typedef struct _SourceContext SourceContext;
struct _EMailUISessionPrivate {
FILE *filter_logfile;
+ ESourceRegistry *registry;
EMailAccountStore *account_store;
EMailLabelListStore *label_store;
- EAccountList *account_list;
- gulong account_changed_handler_id;
+ gulong source_changed_handler_id;
};
enum {
@@ -475,62 +475,28 @@ source_context_free (SourceContext *context)
}
static void
-mail_ui_session_dispose (GObject *object)
-{
- EMailUISessionPrivate *priv;
-
- priv = E_MAIL_UI_SESSION_GET_PRIVATE (object);
-
- if (priv->account_store != NULL) {
- e_mail_account_store_clear (priv->account_store);
- g_object_unref (priv->account_store);
- priv->account_store = NULL;
- }
-
- if (priv->label_store != NULL) {
- g_object_unref (priv->label_store);
- priv->label_store = NULL;
- }
-
- if (priv->account_list != NULL) {
- g_signal_handler_disconnect (
- priv->account_list,
- priv->account_changed_handler_id);
- g_object_unref (priv->account_list);
- priv->account_list = NULL;
- }
-
- /* Chain up to parent's dispose() method. */
- G_OBJECT_CLASS (e_mail_ui_session_parent_class)->dispose (object);
-}
-
-static void
-mail_ui_session_account_changed_cb (EAccountList *account_list,
- EAccount *account,
- EMailSession *session)
+mail_ui_session_source_changed_cb (ESourceRegistry *registry,
+ ESource *source,
+ EMailSession *session)
{
EMFolderTreeModel *folder_tree_model;
CamelService *service;
+ const gchar *extension_name;
+ const gchar *uid;
- service = camel_session_get_service (
- CAMEL_SESSION (session), account->uid);
+ uid = e_source_get_uid (source);
- if (!CAMEL_IS_STORE (service))
+ /* We're only interested in mail account data sources. */
+ extension_name = E_SOURCE_EXTENSION_MAIL_ACCOUNT;
+ if (!e_source_has_extension (source, extension_name))
return;
- /* Update the display name of the corresponding CamelStore.
- * EMailAccountStore listens for "notify" signals from each
- * service so it will detect this and update the model.
- *
- * XXX If EAccount defined GObject properties we could just
- * bind EAccount:name to CamelService:display-name and
- * be done with it. Oh well.
- */
-
- camel_service_set_display_name (service, account->name);
+ /* There should be a CamelStore with the same UID. */
+ service = camel_session_get_service (CAMEL_SESSION (session), uid);
+ g_return_if_fail (CAMEL_IS_STORE (service));
/* Remove the store from the folder tree model and, if the
- * account is still enabled, re-add it. Easier than trying
+ * source is still enabled, re-add it. Easier than trying
* to update the model with the store in place.
*
* em_folder_tree_model_add_store() already knows which types
@@ -542,34 +508,76 @@ mail_ui_session_account_changed_cb (EAccountList *account_list,
em_folder_tree_model_remove_store (
folder_tree_model, CAMEL_STORE (service));
- if (account->enabled)
+ if (e_source_get_enabled (source))
em_folder_tree_model_add_store (
folder_tree_model, CAMEL_STORE (service));
}
static gboolean
-mail_ui_session_initialize_stores_idle (gpointer user_data)
+mail_ui_session_add_service_cb (SourceContext *context)
{
- EMailUISession *session = user_data;
- EMailAccountStore *account_store;
- EAccount *account;
+ EMailAccountStore *store;
+
+ /* The CamelService should be fully initialized by now. */
+ store = e_mail_ui_session_get_account_store (context->session);
+ e_mail_account_store_add_service (store, context->service);
+
+ return FALSE;
+}
+
+static void
+mail_ui_session_get_property (GObject *object,
+ guint property_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ switch (property_id) {
+ case PROP_ACCOUNT_STORE:
+ g_value_set_object (
+ value,
+ e_mail_ui_session_get_account_store (
+ E_MAIL_UI_SESSION (object)));
+ return;
+
+ case PROP_LABEL_STORE:
+ g_value_set_object (
+ value,
+ e_mail_ui_session_get_label_store (
+ E_MAIL_UI_SESSION (object)));
+ return;
+ }
+
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+}
+
+static void
+mail_ui_session_dispose (GObject *object)
+{
+ EMailUISessionPrivate *priv;
- g_return_val_if_fail (session != NULL, FALSE);
+ priv = E_MAIL_UI_SESSION_GET_PRIVATE (object);
- account_store = e_mail_ui_session_get_account_store (session);
+ if (priv->registry != NULL) {
+ g_signal_handler_disconnect (
+ priv->registry,
+ priv->source_changed_handler_id);
+ g_object_unref (priv->registry);
+ priv->registry = NULL;
+ }
- /* Initialize which account is default. */
- account = e_get_default_account ();
- if (account != NULL) {
- CamelService *service;
+ if (priv->account_store != NULL) {
+ e_mail_account_store_clear (priv->account_store);
+ g_object_unref (priv->account_store);
+ priv->account_store = NULL;
+ }
- service = camel_session_get_service (
- CAMEL_SESSION (session), account->uid);
- e_mail_account_store_set_default_service (
- account_store, service);
+ if (priv->label_store != NULL) {
+ g_object_unref (priv->label_store);
+ priv->label_store = NULL;
}
- return FALSE;
+ /* Chain up to parent's dispose() method. */
+ G_OBJECT_CLASS (e_mail_ui_session_parent_class)->dispose (object);
}
static void
@@ -577,19 +585,19 @@ mail_ui_session_constructed (GObject *object)
{
EMailUISessionPrivate *priv;
EMFolderTreeModel *folder_tree_model;
+ ESourceRegistry *registry;
EMailSession *session;
- EMailUISession *uisession;
- EAccountList *account_list;
gulong handler_id;
session = E_MAIL_SESSION (object);
- uisession = E_MAIL_UI_SESSION (object);
- uisession->priv = priv = E_MAIL_UI_SESSION_GET_PRIVATE (object);
+ priv = E_MAIL_UI_SESSION_GET_PRIVATE (object);
priv->account_store = e_mail_account_store_new (session);
- account_list = e_get_account_list ();
- uisession->priv->account_list = g_object_ref (account_list);
+ /* Keep our own reference to the ESourceRegistry so we
+ * can easily disconnect signal handlers in dispose(). */
+ registry = e_mail_session_get_registry (session);
+ priv->registry = g_object_ref (registry);
/* XXX Make sure the folder tree model is created before we
* add built-in CamelStores so it gets signals from the
@@ -601,19 +609,62 @@ mail_ui_session_constructed (GObject *object)
* FIXME EMailSession should just own the default instance.
*/
folder_tree_model = em_folder_tree_model_get_default ();
+ em_folder_tree_model_set_session (folder_tree_model, session);
/* Chain up to parent's constructed() method. */
G_OBJECT_CLASS (e_mail_ui_session_parent_class)->constructed (object);
- em_folder_tree_model_set_session (folder_tree_model, session);
-
- g_idle_add (mail_ui_session_initialize_stores_idle, object);
+ /* Listen for registry changes. */
handler_id = g_signal_connect (
- account_list, "account-changed",
- G_CALLBACK (mail_ui_session_account_changed_cb), session);
- priv->account_changed_handler_id = handler_id;
+ registry, "source-changed",
+ G_CALLBACK (mail_ui_session_source_changed_cb), session);
+ priv->source_changed_handler_id = handler_id;
+}
+
+static CamelService *
+mail_ui_session_add_service (CamelSession *session,
+ const gchar *uid,
+ const gchar *protocol,
+ CamelProviderType type,
+ GError **error)
+{
+ CamelService *service;
+
+ /* Chain up to parent's constructed() method. */
+ service = CAMEL_SESSION_CLASS (e_mail_ui_session_parent_class)->
+ add_service (session, uid, protocol, type, error);
+
+ /* Inform the EMailAccountStore of the new CamelService
+ * from an idle callback so the service has a chance to
+ * fully initialize first. */
+ if (CAMEL_IS_STORE (service)) {
+ SourceContext *context;
+ context = g_slice_new0 (SourceContext);
+ context->session = g_object_ref (session);
+ context->service = g_object_ref (service);
+
+ g_idle_add_full (
+ G_PRIORITY_DEFAULT_IDLE,
+ (GSourceFunc) mail_ui_session_add_service_cb,
+ context, (GDestroyNotify) source_context_free);
+ }
+
+ return service;
+}
+
+static void
+mail_ui_session_remove_service (CamelSession *session,
+ CamelService *service)
+{
+ EMailAccountStore *store;
+ EMailUISession *ui_session;
+
+ /* Passing a NULL parent window skips confirmation prompts. */
+ ui_session = E_MAIL_UI_SESSION (session);
+ store = e_mail_ui_session_get_account_store (ui_session);
+ e_mail_account_store_remove_service (store, NULL, service);
}
static gint
@@ -659,8 +710,8 @@ mail_ui_session_alert_user (CamelSession *session,
static CamelFilterDriver *
mail_ui_session_get_filter_driver (CamelSession *session,
- const gchar *type,
- GError **error)
+ const gchar *type,
+ GError **error)
{
return (CamelFilterDriver *) mail_call_main (
MAIL_CALL_p_ppp, (MailMainFunc) main_get_filter_driver,
@@ -668,80 +719,14 @@ mail_ui_session_get_filter_driver (CamelSession *session,
}
static void
-mail_ui_session_set_property (GObject *object,
- guint property_id,
- const GValue *value,
- GParamSpec *pspec)
+mail_ui_session_refresh_service (EMailSession *session,
+ CamelService *service)
{
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
-}
+ g_debug ("*** Refreshing %s ***",
+ camel_service_get_display_name (service));
-static void
-mail_ui_session_get_property (GObject *object,
- guint property_id,
- GValue *value,
- GParamSpec *pspec)
-{
- switch (property_id) {
- case PROP_ACCOUNT_STORE:
- g_value_set_object (
- value,
- e_mail_ui_session_get_account_store (
- E_MAIL_UI_SESSION (object)));
- return;
-
- case PROP_LABEL_STORE:
- g_value_set_object (
- value,
- e_mail_ui_session_get_label_store (
- E_MAIL_UI_SESSION (object)));
- return;
- }
-
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
-}
-
-static gboolean
-mail_ui_session_add_service_cb (SourceContext *context)
-{
- EMailAccountStore *store;
-
- store = e_mail_ui_session_get_account_store (context->session);
- e_mail_account_store_add_service (store, context->service);
-
- return FALSE;
-}
-
-static CamelService *
-mail_ui_session_add_service (CamelSession *session,
- const gchar *uid,
- const gchar *protocol,
- CamelProviderType type,
- GError **error)
-{
- CamelService *service;
-
- /* Chain up to parent's constructed() method. */
- service = CAMEL_SESSION_CLASS (e_mail_ui_session_parent_class)->
- add_service (session, uid, protocol, type, error);
-
- /* Inform the EMailAccountStore of the new CamelService
- * from an idle callback so the service has a chance to
- * fully initialize first. */
- if (CAMEL_IS_STORE (service)) {
- SourceContext *context;
-
- context = g_slice_new0 (SourceContext);
- context->session = g_object_ref (session);
- context->service = g_object_ref (service);
-
- g_idle_add_full (
- G_PRIORITY_DEFAULT_IDLE,
- (GSourceFunc) mail_ui_session_add_service_cb,
- context, (GDestroyNotify) source_context_free);
- }
-
- return service;
+ if (camel_session_get_online (CAMEL_SESSION (session)))
+ mail_receive_service (service);
}
static EMVFolderContext *
@@ -755,23 +740,24 @@ e_mail_ui_session_class_init (EMailUISessionClass *class)
{
GObjectClass *object_class;
CamelSessionClass *session_class;
- EMailSessionClass *emailsession_class;
+ EMailSessionClass *mail_session_class;
g_type_class_add_private (class, sizeof (EMailUISessionPrivate));
object_class = G_OBJECT_CLASS (class);
- object_class->set_property = mail_ui_session_set_property;
object_class->get_property = mail_ui_session_get_property;
object_class->dispose = mail_ui_session_dispose;
object_class->constructed = mail_ui_session_constructed;
session_class = CAMEL_SESSION_CLASS (class);
+ session_class->add_service = mail_ui_session_add_service;
+ session_class->remove_service = mail_ui_session_remove_service;
session_class->alert_user = mail_ui_session_alert_user;
session_class->get_filter_driver = mail_ui_session_get_filter_driver;
- session_class->add_service = mail_ui_session_add_service;
- emailsession_class = E_MAIL_SESSION_CLASS (class);
- emailsession_class->create_vfolder_context = mail_ui_session_create_vfolder_context;
+ mail_session_class = E_MAIL_SESSION_CLASS (class);
+ mail_session_class->create_vfolder_context = mail_ui_session_create_vfolder_context;
+ mail_session_class->refresh_service = mail_ui_session_refresh_service;
g_object_class_install_property (
object_class,
@@ -803,16 +789,19 @@ e_mail_ui_session_init (EMailUISession *session)
}
EMailSession *
-e_mail_ui_session_new (void)
+e_mail_ui_session_new (ESourceRegistry *registry)
{
const gchar *user_data_dir;
const gchar *user_cache_dir;
+ g_return_val_if_fail (E_IS_SOURCE_REGISTRY (registry), NULL);
+
user_data_dir = mail_session_get_data_dir ();
user_cache_dir = mail_session_get_cache_dir ();
return g_object_new (
E_TYPE_MAIL_UI_SESSION,
+ "registry", registry,
"user-data-dir", user_data_dir,
"user-cache-dir", user_cache_dir,
NULL);
@@ -826,6 +815,14 @@ e_mail_ui_session_get_account_store (EMailUISession *session)
return session->priv->account_store;
}
+EMailLabelListStore *
+e_mail_ui_session_get_label_store (EMailUISession *session)
+{
+ g_return_val_if_fail (E_IS_MAIL_UI_SESSION (session), NULL);
+
+ return session->priv->label_store;
+}
+
void
e_mail_ui_session_add_activity (EMailUISession *session,
EActivity *activity)
@@ -836,11 +833,3 @@ e_mail_ui_session_add_activity (EMailUISession *session,
g_signal_emit (session, signals[ACTIVITY_ADDED], 0, activity);
}
-EMailLabelListStore *
-e_mail_ui_session_get_label_store (EMailUISession *session)
-{
- g_return_val_if_fail (E_IS_MAIL_UI_SESSION (session), NULL);
-
- return session->priv->label_store;
-}
-
diff --git a/mail/e-mail-ui-session.h b/mail/e-mail-ui-session.h
index f6ef4b4..ebab600 100644
--- a/mail/e-mail-ui-session.h
+++ b/mail/e-mail-ui-session.h
@@ -75,16 +75,16 @@ struct _EMailUISessionClass {
};
-GType e_mail_ui_session_get_type (void);
-EMailSession * e_mail_ui_session_new (void);
+GType e_mail_ui_session_get_type (void);
+EMailSession * e_mail_ui_session_new (ESourceRegistry *registry);
EMailAccountStore *
e_mail_ui_session_get_account_store
(EMailUISession *session);
-void e_mail_ui_session_add_activity (EMailUISession *session,
- EActivity *activity);
EMailLabelListStore *
e_mail_ui_session_get_label_store
(EMailUISession *session);
+void e_mail_ui_session_add_activity (EMailUISession *session,
+ EActivity *activity);
G_END_DECLS
diff --git a/mail/e-mail.h b/mail/e-mail.h
index 3b0d02d..694b8e3 100644
--- a/mail/e-mail.h
+++ b/mail/e-mail.h
@@ -20,6 +20,7 @@
#define E_MAIL_H
#include <mail/e-mail-attachment-bar.h>
+#include <mail/e-mail-authenticator.h>
#include <mail/e-mail-backend.h>
#include <mail/e-mail-browser.h>
#include <mail/e-mail-display.h>
diff --git a/mail/em-account-editor.c b/mail/em-account-editor.c
index 21dea7d..0417d9d 100644
--- a/mail/em-account-editor.c
+++ b/mail/em-account-editor.c
@@ -22,28 +22,18 @@
*
*/
-/*
- * work before merge can occur:
- *
- * verify behaviour.
- * work out what to do with the startup assistant.
- *
- * also need to work out:
- * how to remove unecessary items from a service url once
- * configured (removing settings from other types).
- */
-
-#ifdef HAVE_CONFIG_H
#include <config.h>
-#endif
+#include <string.h>
+#include <stdarg.h>
#include <glib/gi18n.h>
#include <glib/gstdio.h>
-#include <string.h>
-#include <stdarg.h>
-
-#include <libedataserverui/e-passwords.h>
+#include <libedataserver/e-source-mail-account.h>
+#include <libedataserver/e-source-mail-composition.h>
+#include <libedataserver/e-source-mail-identity.h>
+#include <libedataserver/e-source-mail-submission.h>
+#include <libedataserver/e-source-mail-transport.h>
#include <shell/e-shell.h>
@@ -52,21 +42,22 @@
#include <e-util/e-dialog-utils.h>
#include <e-util/e-util-private.h>
-#include <libemail-utils/e-account-utils.h>
-#include <libemail-utils/e-signature-list.h>
-#include <libemail-utils/e-signature-utils.h>
#include <libemail-utils/mail-mt.h>
#include <libemail-engine/e-mail-folder-utils.h>
#include <libemail-engine/mail-ops.h>
#include <widgets/misc/e-auth-combo-box.h>
-#include <widgets/misc/e-signature-editor.h>
#include <widgets/misc/e-port-entry.h>
+#include <widgets/misc/e-source-notebook.h>
+#include "e-mail-account-config.h"
#include "e-mail-account-store.h"
#include "e-mail-backend.h"
+#include "e-mail-config-identity.h"
+#include "e-mail-config-provider.h"
#include "e-mail-junk-options.h"
+#include "e-mail-transport-config.h"
#include "e-mail-ui-session.h"
#include "em-account-editor.h"
#include "em-config.h"
@@ -92,16 +83,10 @@
(G_TYPE_INSTANCE_GET_PRIVATE \
((obj), EM_TYPE_ACCOUNT_EDITOR, EMAccountEditorPrivate))
-#define d(x)
-
-/* econfig item for the extra config hings */
-struct _receive_options_item {
- EMConfigItem item;
+#define DEFAULT_ACCOUNT_BACKEND_NAME "imapx"
+#define DEFAULT_TRANSPORT_BACKEND_NAME "smtp"
- /* Only CAMEL_PROVIDER_CONF_ENTRYs GtkEntrys are stored here.
- * The auto-detect camel provider code will probably be removed */
- GHashTable *extra_table;
-};
+#define d(x)
typedef struct _EMAccountEditorService {
EMAccountEditor *emae; /* parent pointer, for callbacks */
@@ -127,12 +112,8 @@ typedef struct _EMAccountEditorService {
GtkWidget *ssl_hbox;
GtkWidget *no_ssl;
- GtkWidget *auth_frame;
- GtkComboBox *authtype;
-
GtkWidget *authitem;
GtkToggleButton *remember;
- GtkButton *check_supported;
GtkToggleButton *needs_auth;
gboolean requires_auth;
@@ -152,27 +133,31 @@ typedef struct _EMAccountEditorService {
struct _EMAccountEditorPrivate {
- EMailBackend *backend;
- EAccount *modified_account;
- EAccount *original_account;
- gboolean new_account;
+ EMailSession *session;
+ ESource *original_source;
+ ESource *mail_account_source;
+ ESource *mail_identity_source;
+ ESource *mail_transport_source;
+
+ EMailConfig *mail_account_config;
+ EMailConfig *mail_transport_config;
+ EMailConfigIdentity *mail_config_identity;
+ ESourceNotebook *receive_options_notebook;
+
+ /* Candidate ESources by backend name. */
+ GHashTable *mail_account_candidates;
+ GHashTable *mail_transport_candidates;
+
+ GNode *candidate_source_tree;
struct _EMConfig *config;
GList *providers;
- /* signatures */
- GtkComboBox *signatures_dropdown;
- guint sig_added_id;
- guint sig_removed_id;
- guint sig_changed_id;
- const gchar *sig_uid;
-
/* incoming mail */
EMAccountEditorService source;
/* extra incoming config */
CamelProvider *extra_provider;
- GSList *extra_items; /* this is freed by the econfig automatically */
/* outgoing mail */
EMAccountEditorService transport;
@@ -235,24 +220,22 @@ struct _EMAccountEditorPrivate {
GtkWidget *yahoo_cal_box;
GtkWidget *yahoo_cal_entry;
- /* for e-config callbacks, each page sets up its widgets, then they are dealed out by the get_widget callback in order*/
- GHashTable *widgets;
-
/* for assistant page preparation */
- guint identity_set : 1;
- guint receive_set : 1;
- guint receive_opt_set : 1;
- guint send_set : 1;
- guint review_set : 1;
+ gboolean receive_set;
+ gboolean receive_opt_set;
+ gboolean send_set;
+ gboolean review_set;
ServerData *selected_server;
};
enum {
PROP_0,
- PROP_BACKEND,
- PROP_MODIFIED_ACCOUNT,
- PROP_ORIGINAL_ACCOUNT,
+ PROP_MAIL_ACCOUNT_SOURCE,
+ PROP_MAIL_IDENTITY_SOURCE,
+ PROP_MAIL_TRANSPORT_SOURCE,
+ PROP_ORIGINAL_SOURCE,
+ PROP_SESSION,
PROP_STORE_PROVIDER,
PROP_STORE_REQUIRES_AUTH,
PROP_STORE_SETTINGS,
@@ -354,49 +337,335 @@ emae_list_providers (void)
return list;
}
+/* Helper for emae_setup_candidates() */
static void
-emae_set_original_account (EMAccountEditor *emae,
- EAccount *original_account)
+emae_setup_transport_candidates (EMAccountEditor *emae,
+ GNode *parent)
{
- EAccount *modified_account;
+ GList *list, *link;
- g_return_if_fail (emae->priv->original_account == NULL);
+ list = emae_list_providers ();
- /* Editing an existing account. */
- if (original_account != NULL) {
- gchar *xml;
+ for (link = list; link != NULL; link = g_list_next (link)) {
+ CamelProvider *provider = link->data;
+ ESource *candidate = NULL;
+ const gchar *backend_name;
+
+ /* ESource uses "backend name" and CamelProvider
+ * uses "protocol", but the terms are synonymous. */
+ backend_name = provider->protocol;
+
+ /* Transports correspond to ESourceMailTransport. */
+ if (provider->object_types[CAMEL_PROVIDER_TRANSPORT] != 0)
+ candidate = g_hash_table_lookup (
+ emae->priv->mail_transport_candidates,
+ backend_name);
+
+ if (candidate == NULL)
+ continue;
+
+ g_node_append_data (parent, candidate);
+ }
+}
+
+/* Helper for emae_setup_candidates() */
+static void
+emae_add_candidate (GHashTable *hash_table,
+ const gchar *backend_name,
+ const gchar *extension_name)
+{
+ ESource *source;
+ ESourceBackend *extension;
+
+ source = e_source_new (NULL, NULL);
+ extension = e_source_get_extension (source, extension_name);
+ e_source_backend_set_backend_name (extension, backend_name);
+
+ g_hash_table_insert (hash_table, g_strdup (backend_name), source);
+}
+
+static void
+emae_setup_candidates (EMAccountEditor *emae)
+{
+ GList *list, *link;
+ GNode *root, *node;
+
+ list = emae_list_providers ();
+
+ /* Populate two hash tables of ESources by backend name.
+ * One for mail accounts, another for mail transports. */
+
+ for (link = list; link != NULL; link = g_list_next (link)) {
+ CamelProvider *provider = link->data;
+ const gchar *backend_name;
+
+ /* ESource uses "backend name" and CamelProvider
+ * uses "protocol", but the terms are synonymous. */
+ backend_name = provider->protocol;
+
+ /* Stores correspond to ESourceMailAccount. */
+ if (provider->object_types[CAMEL_PROVIDER_STORE] != 0)
+ emae_add_candidate (
+ emae->priv->mail_account_candidates,
+ backend_name,
+ E_SOURCE_EXTENSION_MAIL_ACCOUNT);
+
+ /* Transports correspond to ESourceMailTransport. */
+ if (provider->object_types[CAMEL_PROVIDER_TRANSPORT] != 0)
+ emae_add_candidate (
+ emae->priv->mail_transport_candidates,
+ backend_name,
+ E_SOURCE_EXTENSION_MAIL_TRANSPORT);
+ }
+
+ /* Construct a three-level tree of GNodes pointing at the
+ * candidate ESources we just added to the two hash tables.
+ *
+ * - Depth 1 (root) is an empty placeholder.
+ *
+ * - Depth 2 is all available mail account ESources.
+ *
+ * - Depth 3 is all available mail transport ESources for its
+ * parent mail account. So lots of repetition at this depth.
+ *
+ * Use this tree to populate account and transport combo boxes.
+ */
+
+ root = g_node_new (NULL);
+
+ for (link = list; link != NULL; link = g_list_next (link)) {
+ CamelProvider *provider = link->data;
+ ESource *candidate = NULL;
+ const gchar *backend_name;
+
+ /* ESource uses "backend name" and CamelProvider
+ * uses "protocol", but the terms are synonymous. */
+ backend_name = provider->protocol;
+
+ /* Stores correspond to ESourceMailAccount. */
+ if (provider->object_types[CAMEL_PROVIDER_STORE] != 0)
+ candidate = g_hash_table_lookup (
+ emae->priv->mail_account_candidates,
+ backend_name);
+
+ if (candidate == NULL)
+ continue;
+
+ node = g_node_append_data (root, candidate);
+
+ /* If this provider acts as both a store and transport,
+ * then we can skip the "Sending Email" tab altogether.
+ * This is common in groupware providers like Exchange. */
+ if (CAMEL_PROVIDER_IS_STORE_AND_TRANSPORT (provider))
+ continue;
+
+ /* Add available mail transport candidates as child
+ * nodes. These will be the mail transport choices
+ * presented for this mail account candidate. */
+ emae_setup_transport_candidates (emae, node);
+ }
+
+ emae->priv->candidate_source_tree = root;
+
+ g_list_free (list);
+}
+
+static void
+emae_setup_working_sources (EMAccountEditor *emae)
+{
+ EMailSession *session;
+ ESourceRegistry *registry;
+ ESource *source;
+ ESourceExtension *extension;
+ ESourceMailAccount *mail_account_extension;
+ ESourceMailComposition *mail_composition_extension;
+ ESourceMailSubmission *mail_submission_extension;
+ EDBusObject *dbus_object;
+ const gchar *display_name;
+ const gchar *extension_name;
+ const gchar *mail_identity_uid = NULL;
+ const gchar *mail_transport_uid = NULL;
+ gboolean existing_account;
+
+ g_return_if_fail (emae->priv->mail_account_source == NULL);
+ g_return_if_fail (emae->priv->mail_identity_source == NULL);
+ g_return_if_fail (emae->priv->mail_transport_source == NULL);
+
+ session = em_account_editor_get_session (emae);
+ registry = e_mail_session_get_registry (session);
+
+ /*** Mail Account ***/
+
+ source = em_account_editor_get_original_source (emae);
+ existing_account = (source != NULL);
+
+ if (existing_account) {
+ display_name = e_source_get_display_name (source);
+ dbus_object = e_source_get_dbus_object (source);
+ source = e_source_new (dbus_object, NULL);
+ } else {
+ /* This display name should never get used,
+ * just want to give it some non-NULL value. */
+ display_name = "(new account)";
+ emae_setup_candidates (emae);
+ source = g_hash_table_lookup (
+ emae->priv->mail_account_candidates,
+ DEFAULT_ACCOUNT_BACKEND_NAME);
+ g_return_if_fail (source != NULL);
+ g_object_ref (source);
+ }
- xml = e_account_to_xml (original_account);
- modified_account = e_account_new_from_xml (xml);
- g_free (xml);
+ emae->priv->mail_account_source = source;
+
+ extension_name = E_SOURCE_EXTENSION_MAIL_ACCOUNT;
+ extension = e_source_get_extension (source, extension_name);
+ mail_account_extension = E_SOURCE_MAIL_ACCOUNT (extension);
+
+ /*** Mail Identity ***/
+
+ source = NULL;
+
+ if (existing_account) {
+ mail_identity_uid =
+ e_source_mail_account_get_identity_uid (
+ mail_account_extension);
+ source = e_source_registry_lookup_by_uid (
+ registry, mail_identity_uid);
+ }
+
+ if (existing_account && source == NULL)
+ g_critical (
+ "Failed to find mail identity source '%s' "
+ "for account '%s', reverting mail identity "
+ "settings to defaults.",
+ display_name, mail_identity_uid);
+
+ if (source != NULL)
+ dbus_object = e_source_get_dbus_object (source);
+ else
+ dbus_object = NULL;
+
+ /* Skip passing a GError here. If dbus_object is NULL, this should
+ * never fail. If dbus_object is non-NULL, then its data should have
+ * been produced by a GKeyFile on the server-side, so the chances of
+ * it failing to load this time are slim. */
+ source = e_source_new (dbus_object, NULL);
+ emae->priv->mail_identity_source = source;
+ mail_identity_uid = e_source_get_uid (source);
+
+ extension_name = E_SOURCE_EXTENSION_MAIL_COMPOSITION;
+ extension = e_source_get_extension (source, extension_name);
+ mail_composition_extension = E_SOURCE_MAIL_COMPOSITION (extension);
+
+ extension_name = E_SOURCE_EXTENSION_MAIL_SUBMISSION;
+ extension = e_source_get_extension (source, extension_name);
+ mail_submission_extension = E_SOURCE_MAIL_SUBMISSION (extension);
+
+ /* Extra configuration steps for new accounts. */
+ if (dbus_object == NULL) {
+ e_source_mail_composition_set_drafts_folder (
+ mail_composition_extension,
+ e_mail_session_get_local_folder_uri (
+ session, E_MAIL_LOCAL_FOLDER_DRAFTS));
+
+ e_source_mail_composition_set_templates_folder (
+ mail_composition_extension,
+ e_mail_session_get_local_folder_uri (
+ session, E_MAIL_LOCAL_FOLDER_TEMPLATES));
+
+ e_source_mail_submission_set_sent_folder (
+ mail_submission_extension,
+ e_mail_session_get_local_folder_uri (
+ session, E_MAIL_LOCAL_FOLDER_SENT));
+ }
- g_object_ref (original_account);
- if (emae->type != EMAE_PAGES)
- emae->do_signature = TRUE;
+ /*** Mail Transport ***/
- /* thus the emae_setup_service() will pick protocols from the account */
- emae->priv->source.protocol = NULL;
- emae->priv->transport.protocol = NULL;
+ source = NULL;
- /* Creating a new account. */
+ if (existing_account) {
+ mail_transport_uid =
+ e_source_mail_submission_get_transport_uid (
+ mail_submission_extension);
+ source = e_source_registry_lookup_by_uid (
+ registry, mail_transport_uid);
+ if (source != NULL) {
+ dbus_object = e_source_get_dbus_object (source);
+ source = e_source_new (dbus_object, NULL);
+ } else {
+ g_critical (
+ "Failed to find mail transport source '%s' "
+ "for account '%s', reverting mail transport "
+ "settings to defaults.",
+ display_name, mail_transport_uid);
+ }
} else {
- modified_account = e_account_new ();
- modified_account->enabled = TRUE;
- emae->priv->new_account = TRUE;
+ source = g_hash_table_lookup (
+ emae->priv->mail_transport_candidates,
+ DEFAULT_TRANSPORT_BACKEND_NAME);
+ g_return_if_fail (source != NULL);
+ g_object_ref (source);
+ }
+
+ emae->priv->mail_transport_source = source;
+}
+
+static void
+emae_set_mail_account_source (EMAccountEditor *emae,
+ ESource *mail_account_source)
+{
+ if (mail_account_source != NULL) {
+ g_return_if_fail (E_IS_SOURCE (mail_account_source));
+ g_object_ref (mail_account_source);
+ }
+
+ if (emae->priv->mail_account_source != NULL)
+ g_object_unref (emae->priv->mail_account_source);
+
+ emae->priv->mail_account_source = mail_account_source;
+
+ g_object_notify (G_OBJECT (emae), "mail-account-source");
+}
+
+static void
+emae_set_mail_transport_source (EMAccountEditor *emae,
+ ESource *mail_transport_source)
+{
+ if (mail_transport_source != NULL) {
+ g_return_if_fail (E_IS_SOURCE (mail_transport_source));
+ g_object_ref (mail_transport_source);
}
- emae->priv->original_account = original_account;
- emae->priv->modified_account = modified_account;
+ if (emae->priv->mail_transport_source != NULL)
+ g_object_unref (emae->priv->mail_transport_source);
+
+ emae->priv->mail_transport_source = mail_transport_source;
+
+ g_object_notify (G_OBJECT (emae), "mail-transport-source");
+}
+
+static void
+emae_set_original_source (EMAccountEditor *emae,
+ ESource *original_source)
+{
+ g_return_if_fail (emae->priv->original_source == NULL);
+
+ if (original_source != NULL) {
+ g_return_if_fail (E_IS_SOURCE (original_source));
+ g_object_ref (original_source);
+ }
+
+ emae->priv->original_source = original_source;
}
static void
-emae_set_backend (EMAccountEditor *emae,
- EMailBackend *backend)
+emae_set_session (EMAccountEditor *emae,
+ EMailSession *session)
{
- g_return_if_fail (E_IS_MAIL_BACKEND (backend));
- g_return_if_fail (emae->priv->backend == NULL);
+ g_return_if_fail (E_IS_MAIL_SESSION (session));
+ g_return_if_fail (emae->priv->session == NULL);
- emae->priv->backend = g_object_ref (backend);
+ emae->priv->session = g_object_ref (session);
}
static CamelProvider *
@@ -664,14 +933,20 @@ emae_set_property (GObject *object,
GParamSpec *pspec)
{
switch (property_id) {
- case PROP_BACKEND:
- emae_set_backend (
+ case PROP_MAIL_ACCOUNT_SOURCE:
+ emae_set_mail_account_source (
+ EM_ACCOUNT_EDITOR (object),
+ g_value_get_object (value));
+ return;
+
+ case PROP_MAIL_TRANSPORT_SOURCE:
+ emae_set_mail_transport_source (
EM_ACCOUNT_EDITOR (object),
g_value_get_object (value));
return;
- case PROP_ORIGINAL_ACCOUNT:
- emae_set_original_account (
+ case PROP_ORIGINAL_SOURCE:
+ emae_set_original_source (
EM_ACCOUNT_EDITOR (object),
g_value_get_object (value));
return;
@@ -682,6 +957,12 @@ emae_set_property (GObject *object,
g_value_get_boolean (value));
return;
+ case PROP_SESSION:
+ emae_set_session (
+ EM_ACCOUNT_EDITOR (object),
+ g_value_get_object (value));
+ return;
+
case PROP_STORE_SETTINGS:
emae_set_store_settings (
EM_ACCOUNT_EDITOR (object),
@@ -771,24 +1052,38 @@ emae_get_property (GObject *object,
GParamSpec *pspec)
{
switch (property_id) {
- case PROP_BACKEND:
+ case PROP_MAIL_ACCOUNT_SOURCE:
+ g_value_set_object (
+ value,
+ em_account_editor_get_mail_account_source (
+ EM_ACCOUNT_EDITOR (object)));
+ return;
+
+ case PROP_MAIL_IDENTITY_SOURCE:
+ g_value_set_object (
+ value,
+ em_account_editor_get_mail_identity_source (
+ EM_ACCOUNT_EDITOR (object)));
+ return;
+
+ case PROP_MAIL_TRANSPORT_SOURCE:
g_value_set_object (
value,
- em_account_editor_get_backend (
+ em_account_editor_get_mail_transport_source (
EM_ACCOUNT_EDITOR (object)));
return;
- case PROP_MODIFIED_ACCOUNT:
+ case PROP_ORIGINAL_SOURCE:
g_value_set_object (
value,
- em_account_editor_get_modified_account (
+ em_account_editor_get_original_source (
EM_ACCOUNT_EDITOR (object)));
return;
- case PROP_ORIGINAL_ACCOUNT:
+ case PROP_SESSION:
g_value_set_object (
value,
- em_account_editor_get_original_account (
+ em_account_editor_get_session (
EM_ACCOUNT_EDITOR (object)));
return;
@@ -915,24 +1210,61 @@ emae_dispose (GObject *object)
priv = EM_ACCOUNT_EDITOR_GET_PRIVATE (object);
- if (priv->backend != NULL) {
- g_object_unref (priv->backend);
- priv->backend = NULL;
+ if (priv->session != NULL) {
+ g_object_unref (priv->session);
+ priv->session = NULL;
}
- if (priv->modified_account != NULL) {
- g_signal_handlers_disconnect_by_func (
- priv->modified_account,
- emae_config_target_changed_cb, object);
- g_object_unref (priv->modified_account);
- priv->modified_account = NULL;
+ if (priv->original_source != NULL) {
+ g_object_unref (priv->original_source);
+ priv->original_source = NULL;
+ }
+
+ if (priv->mail_account_source != NULL) {
+ g_object_unref (priv->mail_account_source);
+ priv->mail_account_source = NULL;
+ }
+
+ if (priv->mail_identity_source != NULL) {
+ g_object_unref (priv->mail_identity_source);
+ priv->mail_identity_source = NULL;
+ }
+
+ if (priv->mail_transport_source != NULL) {
+ g_object_unref (priv->mail_transport_source);
+ priv->mail_transport_source = NULL;
+ }
+
+ if (priv->mail_account_config != NULL) {
+ g_object_unref (priv->mail_account_config);
+ priv->mail_account_config = NULL;
+ }
+
+ if (priv->mail_transport_config != NULL) {
+ g_object_unref (priv->mail_transport_config);
+ priv->mail_transport_config = NULL;
+ }
+
+ if (priv->mail_config_identity != NULL) {
+ g_object_unref (priv->mail_config_identity);
+ priv->mail_config_identity = NULL;
+ }
+
+ if (priv->receive_options_notebook != NULL) {
+ g_object_unref (priv->receive_options_notebook);
+ priv->receive_options_notebook = NULL;
}
- if (priv->original_account != NULL) {
- g_object_unref (priv->original_account);
- priv->original_account = NULL;
+ /* Destroy the candidate tree here since the nodes point to
+ * ESources in the hash tables we're about to empty out. */
+ if (priv->candidate_source_tree != NULL) {
+ g_node_destroy (priv->candidate_source_tree);
+ priv->candidate_source_tree = NULL;
}
+ g_hash_table_remove_all (priv->mail_account_candidates);
+ g_hash_table_remove_all (priv->mail_transport_candidates);
+
if (priv->source.settings != NULL) {
g_signal_handlers_disconnect_by_func (
priv->source.settings,
@@ -959,17 +1291,13 @@ emae_finalize (GObject *object)
EMAccountEditor *emae = EM_ACCOUNT_EDITOR (object);
EMAccountEditorPrivate *priv = emae->priv;
+ g_hash_table_destroy (priv->mail_account_candidates);
+ g_hash_table_destroy (priv->mail_transport_candidates);
+
+#if 0 /* ACCOUNT_MGMT */
if (priv->config)
g_object_weak_unref ((GObject *) priv->config, emae_config_gone_cb, emae);
-
- if (priv->sig_added_id) {
- ESignatureList *signatures;
-
- signatures = e_get_signature_list ();
- g_signal_handler_disconnect (signatures, priv->sig_added_id);
- g_signal_handler_disconnect (signatures, priv->sig_removed_id);
- g_signal_handler_disconnect (signatures, priv->sig_changed_id);
- }
+#endif /* ACCOUNT_MGMT */
g_list_free (priv->providers);
@@ -981,48 +1309,19 @@ static void
emae_constructed (GObject *object)
{
EMAccountEditor *emae;
+ ESource *source;
emae = EM_ACCOUNT_EDITOR (object);
/* Chain up to parent's constructed() method. */
G_OBJECT_CLASS (em_account_editor_parent_class)->constructed (object);
- emae->priv->providers = emae_list_providers ();
+ source = em_account_editor_get_original_source (emae);
- /* Set some defaults on the new account before we get started. */
- if (emae->priv->new_account) {
- EMailBackend *backend;
- EMailSession *session;
-
- backend = em_account_editor_get_backend (emae);
- session = e_mail_backend_get_session (backend);
-
- /* Pick local Drafts folder. */
- e_account_set_string (
- emae->priv->modified_account,
- E_ACCOUNT_DRAFTS_FOLDER_URI,
- e_mail_session_get_local_folder_uri (
- session, E_MAIL_LOCAL_FOLDER_DRAFTS));
-
- /* Pick local Sent folder. */
- e_account_set_string (
- emae->priv->modified_account,
- E_ACCOUNT_SENT_FOLDER_URI,
- e_mail_session_get_local_folder_uri (
- session, E_MAIL_LOCAL_FOLDER_SENT));
+ if (source != NULL && emae->type != EMAE_PAGES)
+ emae->do_signature = TRUE;
- /* Encrypt to self by default. */
- e_account_set_bool (
- emae->priv->modified_account,
- E_ACCOUNT_PGP_ENCRYPT_TO_SELF, TRUE);
- e_account_set_bool (
- emae->priv->modified_account,
- E_ACCOUNT_SMIME_ENCRYPT_TO_SELF, TRUE);
- }
-
- g_signal_connect_swapped (
- emae->priv->modified_account, "changed",
- G_CALLBACK (emae_config_target_changed_cb), emae);
+ emae_setup_working_sources (emae);
}
static void
@@ -1041,35 +1340,57 @@ em_account_editor_class_init (EMAccountEditorClass *class)
g_object_class_install_property (
object_class,
- PROP_BACKEND,
+ PROP_MAIL_ACCOUNT_SOURCE,
g_param_spec_object (
- "backend",
- "Mail Backend",
- NULL,
- E_TYPE_MAIL_BACKEND,
+ "mail-account-source",
+ "Mail Account Source",
+ "Cloned mail account source for editing",
+ E_TYPE_SOURCE,
G_PARAM_READWRITE |
- G_PARAM_CONSTRUCT_ONLY |
G_PARAM_STATIC_STRINGS));
g_object_class_install_property (
object_class,
- PROP_MODIFIED_ACCOUNT,
+ PROP_MAIL_IDENTITY_SOURCE,
g_param_spec_object (
- "modified-account",
- "Modified Account",
- NULL,
- E_TYPE_ACCOUNT,
+ "mail-identity-source",
+ "Mail Identity Source",
+ "Cloned mail identity source for editing",
+ E_TYPE_SOURCE,
G_PARAM_READABLE |
G_PARAM_STATIC_STRINGS));
g_object_class_install_property (
object_class,
- PROP_ORIGINAL_ACCOUNT,
+ PROP_MAIL_TRANSPORT_SOURCE,
+ g_param_spec_object (
+ "mail-transport-source",
+ "Mail Transport Source",
+ "Cloned mail transport source for editing",
+ E_TYPE_SOURCE,
+ G_PARAM_READWRITE |
+ G_PARAM_STATIC_STRINGS));
+
+ g_object_class_install_property (
+ object_class,
+ PROP_ORIGINAL_SOURCE,
+ g_param_spec_object (
+ "original-source",
+ "Original Source",
+ "Original mail account source",
+ E_TYPE_SOURCE,
+ G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT_ONLY |
+ G_PARAM_STATIC_STRINGS));
+
+ g_object_class_install_property (
+ object_class,
+ PROP_SESSION,
g_param_spec_object (
- "original-account",
- "Original Account",
- NULL,
- E_TYPE_ACCOUNT,
+ "session",
+ "Session",
+ "Mail session",
+ E_TYPE_MAIL_SESSION,
G_PARAM_READWRITE |
G_PARAM_CONSTRUCT_ONLY |
G_PARAM_STATIC_STRINGS));
@@ -1264,12 +1585,29 @@ em_account_editor_class_init (EMAccountEditorClass *class)
static void
em_account_editor_init (EMAccountEditor *emae)
{
+ GHashTable *mail_account_candidates;
+ GHashTable *mail_transport_candidates;
+
+ mail_account_candidates = g_hash_table_new_full (
+ (GHashFunc) g_str_hash,
+ (GEqualFunc) g_str_equal,
+ (GDestroyNotify) g_free,
+ (GDestroyNotify) g_object_unref);
+
+ mail_transport_candidates = g_hash_table_new_full (
+ (GHashFunc) g_str_hash,
+ (GEqualFunc) g_str_equal,
+ (GDestroyNotify) g_free,
+ (GDestroyNotify) g_object_unref);
+
emae->priv = EM_ACCOUNT_EDITOR_GET_PRIVATE (emae);
+ emae->priv->mail_account_candidates = mail_account_candidates;
+ emae->priv->mail_transport_candidates = mail_transport_candidates;
+
emae->priv->selected_server = NULL;
emae->priv->source.emae = emae;
emae->priv->transport.emae = emae;
- emae->priv->widgets = g_hash_table_new (g_str_hash, g_str_equal);
/* Pick default storage and transport protocols. */
emae->priv->source.protocol = "imapx";
@@ -1281,29 +1619,29 @@ em_account_editor_init (EMAccountEditor *emae)
/**
* em_account_editor_new:
- * @account:
+ * @source:
* @type:
*
- * Create a new account editor. If @account is NULL then this is to
- * create a new account, else @account is copied to a working
+ * Create a new account editor. If @source is NULL then this is to
+ * create a new account, else @source is copied to a working
* structure and is for editing an existing account.
*
* Return value:
**/
EMAccountEditor *
-em_account_editor_new (EAccount *account,
+em_account_editor_new (ESource *source,
EMAccountEditorType type,
- EMailBackend *backend,
+ EMailSession *session,
const gchar *id)
{
EMAccountEditor *emae;
- g_return_val_if_fail (E_IS_MAIL_BACKEND (backend), NULL);
+ g_return_val_if_fail (E_IS_MAIL_SESSION (session), NULL);
emae = g_object_new (
EM_TYPE_ACCOUNT_EDITOR,
- "original-account", account,
- "backend", backend, NULL);
+ "original-source", source,
+ "session", session, NULL);
em_account_editor_construct (emae, type, id);
@@ -1312,30 +1650,30 @@ em_account_editor_new (EAccount *account,
/**
* em_account_editor_new_for_pages:
- * @account:
+ * @source:
* @type:
*
- * Create a new account editor. If @account is NULL then this is to
- * create a new account, else @account is copied to a working
+ * Create a new account editor. If @source is NULL then this is to
+ * create a new account, else @source is copied to a working
* structure and is for editing an existing account.
*
* Return value:
**/
EMAccountEditor *
-em_account_editor_new_for_pages (EAccount *account,
+em_account_editor_new_for_pages (ESource *source,
EMAccountEditorType type,
- EMailBackend *backend,
+ EMailSession *session,
const gchar *id,
GtkWidget **pages)
{
EMAccountEditor *emae;
- g_return_val_if_fail (E_IS_MAIL_BACKEND (backend), NULL);
+ g_return_val_if_fail (E_IS_MAIL_SESSION (session), NULL);
emae = g_object_new (
EM_TYPE_ACCOUNT_EDITOR,
- "original-account", account,
- "backend", backend, NULL);
+ "original-source", source,
+ "session", session, NULL);
emae->pages = pages;
em_account_editor_construct (emae, type, id);
@@ -1343,28 +1681,44 @@ em_account_editor_new_for_pages (EAccount *account,
return emae;
}
-EMailBackend *
-em_account_editor_get_backend (EMAccountEditor *emae)
+EMailSession *
+em_account_editor_get_session (EMAccountEditor *emae)
+{
+ g_return_val_if_fail (EM_IS_ACCOUNT_EDITOR (emae), NULL);
+
+ return emae->priv->session;
+}
+
+ESource *
+em_account_editor_get_mail_account_source (EMAccountEditor *emae)
+{
+ g_return_val_if_fail (EM_IS_ACCOUNT_EDITOR (emae), NULL);
+
+ return emae->priv->mail_account_source;
+}
+
+ESource *
+em_account_editor_get_mail_identity_source (EMAccountEditor *emae)
{
g_return_val_if_fail (EM_IS_ACCOUNT_EDITOR (emae), NULL);
- return emae->priv->backend;
+ return emae->priv->mail_identity_source;
}
-EAccount *
-em_account_editor_get_modified_account (EMAccountEditor *emae)
+ESource *
+em_account_editor_get_mail_transport_source (EMAccountEditor *emae)
{
g_return_val_if_fail (EM_IS_ACCOUNT_EDITOR (emae), NULL);
- return emae->priv->modified_account;
+ return emae->priv->mail_transport_source;
}
-EAccount *
-em_account_editor_get_original_account (EMAccountEditor *emae)
+ESource *
+em_account_editor_get_original_source (EMAccountEditor *emae)
{
g_return_val_if_fail (EM_IS_ACCOUNT_EDITOR (emae), NULL);
- return emae->priv->original_account;
+ return emae->priv->original_source;
}
/* ********************************************************************** */
@@ -1388,6 +1742,7 @@ static CamelURL *
emae_account_url (EMAccountEditor *emae,
gint urlid)
{
+#if 0 /* ACCOUNT_MGMT */
EAccount *account;
CamelURL *url = NULL;
const gchar *uri;
@@ -1410,6 +1765,9 @@ emae_account_url (EMAccountEditor *emae,
}
return url;
+#endif /* ACCOUNT_MGMT */
+
+ return NULL;
}
/* ********************************************************************** */
@@ -1418,14 +1776,13 @@ static void
default_folders_clicked (GtkButton *button,
gpointer user_data)
{
+#if 0 /* ACCOUNT_MGMT */
EMAccountEditor *emae = user_data;
EMFolderSelectionButton *folder_button;
- EMailBackend *backend;
EMailSession *session;
const gchar *folder_uri;
- backend = em_account_editor_get_backend (emae);
- session = e_mail_backend_get_session (backend);
+ session = em_account_editor_get_session (emae);
folder_button =
EM_FOLDER_SELECTION_BUTTON (
@@ -1445,6 +1802,7 @@ default_folders_clicked (GtkButton *button,
gtk_toggle_button_set_active (emae->priv->trash_folder_check, FALSE);
gtk_toggle_button_set_active (emae->priv->junk_folder_check, FALSE);
+#endif /* ACCOUNT_MGMT */
}
/* The camel provider auto-detect interface should be deprecated.
@@ -1462,6 +1820,7 @@ emae_auto_detect_free (gpointer key,
static void
emae_auto_detect (EMAccountEditor *emae)
{
+#if 0 /* ACCOUNT_MGMT */
EMAccountEditorPrivate *priv = emae->priv;
EMAccountEditorService *service = &priv->source;
CamelProvider *provider;
@@ -1513,231 +1872,53 @@ emae_auto_detect (EMAccountEditor *emae)
g_hash_table_foreach (auto_detected, emae_auto_detect_free, NULL);
g_hash_table_destroy (auto_detected);
-}
-
-static void
-emae_signature_added (ESignatureList *signatures,
- ESignature *sig,
- EMAccountEditor *emae)
-{
- GtkTreeModel *model;
- GtkTreeIter iter;
- const gchar *name;
- const gchar *uid;
-
- name = e_signature_get_name (sig);
- uid = e_signature_get_uid (sig);
-
- model = gtk_combo_box_get_model (emae->priv->signatures_dropdown);
-
- gtk_list_store_append ((GtkListStore *) model, &iter);
- gtk_list_store_set ((GtkListStore *) model, &iter, 0, name, 1, uid, -1);
-
- gtk_combo_box_set_active (
- emae->priv->signatures_dropdown,
- gtk_tree_model_iter_n_children (model, NULL) - 1);
+#endif /* ACCOUNT_MGMT */
}
static gint
-emae_signature_get_iter (EMAccountEditor *emae,
- ESignature *sig,
- GtkTreeModel **modelp,
- GtkTreeIter *iter)
-{
- GtkTreeModel *model;
- gint found = 0;
-
- model = gtk_combo_box_get_model (emae->priv->signatures_dropdown);
- *modelp = model;
- if (!gtk_tree_model_get_iter_first (model, iter))
- return FALSE;
-
- do {
- const gchar *signature_uid;
- gchar *uid;
-
- signature_uid = e_signature_get_uid (sig);
-
- gtk_tree_model_get (model, iter, 1, &uid, -1);
- if (uid && !strcmp (uid, signature_uid))
- found = TRUE;
- g_free (uid);
- } while (!found && gtk_tree_model_iter_next (model, iter));
-
- return found;
-}
-
-static void
-emae_signature_removed (ESignatureList *signatures,
- ESignature *sig,
- EMAccountEditor *emae)
+provider_compare (const CamelProvider *p1,
+ const CamelProvider *p2)
{
- GtkTreeIter iter;
- GtkTreeModel *model;
-
- if (emae_signature_get_iter (emae, sig, &model, &iter))
- gtk_list_store_remove ((GtkListStore *) model, &iter);
-}
-
-static void
-emae_signature_changed (ESignatureList *signatures,
- ESignature *sig,
- EMAccountEditor *emae)
-{
- GtkTreeIter iter;
- GtkTreeModel *model;
- const gchar *name;
-
- name = e_signature_get_name (sig);
-
- if (emae_signature_get_iter (emae, sig, &model, &iter))
- gtk_list_store_set ((GtkListStore *) model, &iter, 0, name, -1);
+ /* sort providers based on "location" (ie. local or remote) */
+ if (p1->flags & CAMEL_PROVIDER_IS_REMOTE) {
+ if (p2->flags & CAMEL_PROVIDER_IS_REMOTE)
+ return 0;
+ return -1;
+ } else {
+ if (p2->flags & CAMEL_PROVIDER_IS_REMOTE)
+ return 1;
+ return 0;
+ }
}
static void
-emae_signaturetype_changed (GtkComboBox *dropdown,
- EMAccountEditor *emae)
+emae_receipt_policy_changed (GtkComboBox *dropdown,
+ EMAccountEditor *emae)
{
+#if 0 /* ACCOUNT_MGMT */
EAccount *account;
gint id = gtk_combo_box_get_active (dropdown);
GtkTreeModel *model;
GtkTreeIter iter;
- gchar *uid = NULL;
+ EAccountReceiptPolicy policy;
account = em_account_editor_get_modified_account (emae);
if (id != -1) {
model = gtk_combo_box_get_model (dropdown);
- if (gtk_tree_model_iter_nth_child (model, &iter, NULL, id))
- gtk_tree_model_get (model, &iter, 1, &uid, -1);
- }
-
- e_account_set_string (account, E_ACCOUNT_ID_SIGNATURE, uid);
- g_free (uid);
-}
-
-static void
-emae_signature_new (GtkWidget *widget,
- EMAccountEditor *emae)
-{
- GtkWidget *editor;
- gpointer parent;
-
- parent = gtk_widget_get_toplevel (widget);
- parent = gtk_widget_is_toplevel (parent) ? parent : NULL;
-
- editor = e_signature_editor_new ();
- gtk_window_set_transient_for (GTK_WINDOW (editor), parent);
- gtk_widget_show (editor);
-}
-
-static GtkWidget *
-emae_setup_signatures (EMAccountEditor *emae,
- GtkBuilder *builder)
-{
- EMAccountEditorPrivate *p = emae->priv;
- EAccount *account;
- GtkComboBox *dropdown = (GtkComboBox *)e_builder_get_widget (builder, "signature_dropdown");
- GtkCellRenderer *cell = gtk_cell_renderer_text_new ();
- GtkListStore *store;
- gint i, active = 0;
- GtkTreeIter iter;
- ESignatureList *signatures;
- EIterator *it;
- const gchar *current;
- GtkWidget *button;
-
- account = em_account_editor_get_modified_account (emae);
- current = e_account_get_string (account, E_ACCOUNT_ID_SIGNATURE);
-
- emae->priv->signatures_dropdown = dropdown;
- gtk_widget_show ((GtkWidget *) dropdown);
-
- store = gtk_list_store_new (2, G_TYPE_STRING, G_TYPE_STRING);
-
- gtk_list_store_append (store, &iter);
- /* Translators: "None" as an option for a default signature of an account, part of "Signature: None" */
- gtk_list_store_set (store, &iter, 0, C_("mail-signature", "None"), 1, NULL, -1);
-
- signatures = e_get_signature_list ();
-
- if (p->sig_added_id == 0) {
- p->sig_added_id = g_signal_connect (
- signatures, "signature-added",
- G_CALLBACK (emae_signature_added), emae);
- p->sig_removed_id = g_signal_connect (
- signatures, "signature-removed",
- G_CALLBACK (emae_signature_removed), emae);
- p->sig_changed_id = g_signal_connect (
- signatures, "signature-changed",
- G_CALLBACK (emae_signature_changed), emae);
- }
-
- /* we need to count the 'none' entry before using the index */
- i = 1;
- it = e_list_get_iterator ((EList *) signatures);
- while (e_iterator_is_valid (it)) {
- ESignature *sig = (ESignature *) e_iterator_get (it);
- const gchar *name;
- const gchar *uid;
-
- name = e_signature_get_name (sig);
- uid = e_signature_get_uid (sig);
-
- gtk_list_store_append (store, &iter);
- gtk_list_store_set (store, &iter, 0, name, 1, uid, -1);
-
- if (current && !strcmp (current, uid))
- active = i;
-
- e_iterator_next (it);
- i++;
- }
- g_object_unref (it);
-
- gtk_cell_layout_pack_start ((GtkCellLayout *) dropdown, cell, TRUE);
- gtk_cell_layout_set_attributes ((GtkCellLayout *)dropdown, cell, "text", 0, NULL);
-
- gtk_combo_box_set_model (dropdown, (GtkTreeModel *) store);
- gtk_combo_box_set_active (dropdown, active);
-
- g_signal_connect (
- dropdown, "changed",
- G_CALLBACK (emae_signaturetype_changed), emae);
-
- button = e_builder_get_widget (builder, "sigAddNew");
- g_signal_connect (
- button, "clicked",
- G_CALLBACK (emae_signature_new), emae);
-
- return (GtkWidget *) dropdown;
-}
-
-static void
-emae_receipt_policy_changed (GtkComboBox *dropdown,
- EMAccountEditor *emae)
-{
- EAccount *account;
- gint id = gtk_combo_box_get_active (dropdown);
- GtkTreeModel *model;
- GtkTreeIter iter;
- EAccountReceiptPolicy policy;
-
- account = em_account_editor_get_modified_account (emae);
-
- if (id != -1) {
- model = gtk_combo_box_get_model (dropdown);
- if (gtk_tree_model_iter_nth_child (model, &iter, NULL, id)) {
- gtk_tree_model_get (model, &iter, 1, &policy, -1);
- e_account_set_int (account, E_ACCOUNT_RECEIPT_POLICY, policy);
- }
+ if (gtk_tree_model_iter_nth_child (model, &iter, NULL, id)) {
+ gtk_tree_model_get (model, &iter, 1, &policy, -1);
+ e_account_set_int (account, E_ACCOUNT_RECEIPT_POLICY, policy);
+ }
}
+#endif /* ACCOUNT_MGMT */
}
static GtkWidget *
emae_setup_receipt_policy (EMAccountEditor *emae,
GtkBuilder *builder)
{
+#if 0 /* ACCOUNT_MGMT */
EAccount *account;
GtkComboBox *dropdown = (GtkComboBox *)e_builder_get_widget (builder, "receipt_policy_dropdown");
GtkListStore *store;
@@ -1784,12 +1965,16 @@ emae_setup_receipt_policy (EMAccountEditor *emae,
G_CALLBACK (emae_receipt_policy_changed), emae);
return (GtkWidget *) dropdown;
+#endif /* ACCOUNT_MGMT */
+
+ return NULL;
}
static void
emae_account_entry_changed (GtkEntry *entry,
EMAccountEditor *emae)
{
+#if 0 /* ACCOUNT_MGMT */
EAccount *account;
gchar *text;
gpointer data;
@@ -1803,6 +1988,7 @@ emae_account_entry_changed (GtkEntry *entry,
e_account_set_string (account, GPOINTER_TO_INT (data), text);
g_free (text);
+#endif /* ACCOUNT_MGMT */
}
static GtkEntry *
@@ -1811,6 +1997,7 @@ emae_account_entry (EMAccountEditor *emae,
gint item,
GtkBuilder *builder)
{
+#if 0 /* ACCOUNT_MGMT */
EAccount *account;
GtkEntry *entry;
const gchar *text;
@@ -1826,12 +2013,16 @@ emae_account_entry (EMAccountEditor *emae,
G_CALLBACK (emae_account_entry_changed), emae);
return entry;
+#endif /* ACCOUNT_MGMT */
+
+ return NULL;
}
static void
emae_account_toggle_changed (GtkToggleButton *toggle,
EMAccountEditor *emae)
{
+#if 0 /* ACCOUNT_MGMT */
EAccount *account;
gboolean active;
gpointer data;
@@ -1841,6 +2032,7 @@ emae_account_toggle_changed (GtkToggleButton *toggle,
active = gtk_toggle_button_get_active (toggle);
e_account_set_bool (account, GPOINTER_TO_INT (data), active);
+#endif /* ACCOUNT_MGMT */
}
static void
@@ -1848,6 +2040,7 @@ emae_account_toggle_widget (EMAccountEditor *emae,
GtkToggleButton *toggle,
gint item)
{
+#if 0 /* ACCOUNT_MGMT */
EAccount *account;
gboolean active;
@@ -1863,6 +2056,7 @@ emae_account_toggle_widget (EMAccountEditor *emae,
g_signal_connect (
toggle, "toggled",
G_CALLBACK (emae_account_toggle_changed), emae);
+#endif /* ACCOUNT_MGMT */
}
static GtkToggleButton *
@@ -1883,6 +2077,7 @@ static void
emae_account_spinint_changed (GtkSpinButton *spin,
EMAccountEditor *emae)
{
+#if 0 /* ACCOUNT_MGMT */
EAccount *account;
gpointer data;
gint value;
@@ -1892,6 +2087,7 @@ emae_account_spinint_changed (GtkSpinButton *spin,
value = gtk_spin_button_get_value (spin);
e_account_set_int (account, GPOINTER_TO_INT (data), value);
+#endif /* ACCOUNT_MGMT */
}
static void
@@ -1899,6 +2095,7 @@ emae_account_spinint_widget (EMAccountEditor *emae,
GtkSpinButton *spin,
gint item)
{
+#if 0 /* ACCOUNT_MGMT */
EAccount *account;
gint v_int;
@@ -1914,8 +2111,10 @@ emae_account_spinint_widget (EMAccountEditor *emae,
g_signal_connect (
spin, "value-changed",
G_CALLBACK (emae_account_spinint_changed), emae);
+#endif /* ACCOUNT_MGMT */
}
+#if 0
static void
emae_account_folder_changed (EMFolderSelectionButton *folder,
EMAccountEditor *emae)
@@ -1940,13 +2139,11 @@ emae_account_folder (EMAccountEditor *emae,
{
EAccount *account;
EMFolderSelectionButton *folder;
- EMailBackend *backend;
EMailSession *session;
const gchar *uri;
account = em_account_editor_get_modified_account (emae);
- backend = em_account_editor_get_backend (emae);
- session = e_mail_backend_get_session (backend);
+ session = em_account_editor_get_session (emae);
folder = (EMFolderSelectionButton *) e_builder_get_widget (builder, name);
em_folder_selection_button_set_session (folder, session);
@@ -1968,6 +2165,7 @@ emae_account_folder (EMAccountEditor *emae,
return folder;
}
+#endif
#if defined (HAVE_NSS) && defined (ENABLE_SMIME)
static void
@@ -2077,6 +2275,13 @@ smime_encrypt_key_clear (GtkWidget *w,
}
#endif
+#if 1 /* ACCOUNT_MGMT - Remove this. */
+#define E_ACCOUNT_SOURCE_URL 0
+#define E_ACCOUNT_SOURCE_SAVE_PASSWD 0
+#define E_ACCOUNT_TRANSPORT_URL 0
+#define E_ACCOUNT_TRANSPORT_SAVE_PASSWD 0
+#endif
+
/* This is used to map each of the two services in a typical account to
* the widgets that represent each service. i.e. the receiving (source)
* service, and the sending (transport) service. It is used throughout
@@ -2193,38 +2398,9 @@ emae_file_chooser_changed (GtkFileChooser *file_chooser,
}
static void
-emae_ensure_auth_mechanism (CamelProvider *provider,
- CamelSettings *settings)
-{
- CamelServiceAuthType *auth_type;
- const gchar *auth_mechanism;
-
- auth_mechanism =
- camel_network_settings_get_auth_mechanism (
- CAMEL_NETWORK_SETTINGS (settings));
-
- /* If a mechanism name is already set, we're fine. */
- if (auth_mechanism != NULL)
- return;
-
- /* Check that the CamelProvider defines some auth mechanisms.
- * If not, it's reasonable to leave the mechanism name unset. */
- if (provider->authtypes == NULL)
- return;
-
- /* No authentication mechanism has been chosen, so we'll choose
- * one from the CamelProvider's list of available mechanisms. */
-
- auth_type = provider->authtypes->data;
- auth_mechanism = auth_type->authproto;
-
- camel_network_settings_set_auth_mechanism (
- CAMEL_NETWORK_SETTINGS (settings), auth_mechanism);
-}
-
-static void
emae_setup_settings (EMAccountEditorService *service)
{
+#if 0 /* ACCOUNT_MGMT */
CamelServiceClass *class;
CamelProvider *provider;
CamelSettings *settings = NULL;
@@ -2286,12 +2462,6 @@ emae_setup_settings (EMAccountEditorService *service)
emae_ensure_auth_mechanism (provider, settings);
g_object_bind_property (
- settings, "auth-mechanism",
- service->authtype, "active-id",
- G_BINDING_BIDIRECTIONAL |
- G_BINDING_SYNC_CREATE);
-
- g_object_bind_property (
settings, "host",
service->hostname, "text",
G_BINDING_BIDIRECTIONAL |
@@ -2335,6 +2505,7 @@ emae_setup_settings (EMAccountEditorService *service)
}
g_object_unref (settings);
+#endif /* ACCOUNT_MGMT */
}
static void
@@ -2431,7 +2602,6 @@ emae_service_provider_changed (EMAccountEditorService *service)
#endif
} else {
gtk_widget_hide (service->frame);
- gtk_widget_hide (service->auth_frame);
gtk_widget_hide (service->ssl_frame);
}
@@ -2442,7 +2612,11 @@ emae_service_provider_changed (EMAccountEditorService *service)
em_config_target_update_settings (
config, target,
+#if 0 /* ACCOUNT_MGMT */
service->emae->priv->modified_account->id->address,
+#else
+ NULL,
+#endif /* ACCOUNT_MGMT */
service->emae->priv->source.protocol,
service->emae->priv->source.settings,
service->emae->priv->transport.protocol,
@@ -2453,6 +2627,7 @@ static void
emae_provider_changed (GtkComboBox *combo_box,
EMAccountEditorService *service)
{
+#if 0 /* ACCOUNT_MGMT */
const gchar *active_protocol;
active_protocol = gtk_combo_box_get_active_id (combo_box);
@@ -2482,12 +2657,14 @@ emae_provider_changed (GtkComboBox *combo_box,
e_config_target_changed (
(EConfig *) service->emae->priv->config,
E_CONFIG_TARGET_CHANGED_REBUILD);
+#endif /* ACCOUNT_MGMT */
}
static void
emae_refresh_providers (EMAccountEditor *emae,
EMAccountEditorService *service)
{
+#if 0 /* ACCOUNT_MGMT */
GtkComboBoxText *combo_box;
GList *link;
@@ -2521,165 +2698,7 @@ emae_refresh_providers (EMAccountEditor *emae,
gtk_combo_box_set_active_id (
GTK_COMBO_BOX (combo_box), service->protocol);
-}
-
-static void
-emae_authtype_changed (GtkComboBox *combo_box,
- EMAccountEditorService *service)
-{
- CamelServiceAuthType *authtype = NULL;
- const gchar *mechanism;
- gboolean sensitive = FALSE;
-
- mechanism = gtk_combo_box_get_active_id (combo_box);
-
- if (mechanism != NULL && *mechanism != '\0') {
- authtype = camel_sasl_authtype (mechanism);
- g_warn_if_fail (authtype != NULL);
- }
-
- sensitive = (authtype == NULL) || (authtype->need_password);
- gtk_widget_set_sensitive (GTK_WIDGET (service->remember), sensitive);
-}
-
-static void emae_check_authtype (GtkWidget *w, EMAccountEditorService *service);
-
-static void
-emae_check_authtype_done (CamelService *camel_service,
- GAsyncResult *result,
- EMAccountEditorService *service)
-{
- EMailBackend *backend;
- EMailSession *session;
- GtkWidget *editor;
- GList *available_authtypes;
- GError *error = NULL;
-
- available_authtypes = camel_service_query_auth_types_finish (
- camel_service, result, &error);
-
- editor = NULL;
- if (service->emae && service->emae->config && E_IS_CONFIG (service->emae->config))
- editor = E_CONFIG (service->emae->config)->window;
-
- if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) {
- g_warn_if_fail (available_authtypes == NULL);
- g_error_free (error);
-
- } else if (error != NULL) {
- g_warn_if_fail (available_authtypes == NULL);
- if (service->check_dialog)
- e_alert_run_dialog_for_args (
- GTK_WINDOW (service->check_dialog),
- "mail:checking-service-error",
- error->message, NULL);
- g_error_free (error);
-
- } else {
- e_auth_combo_box_update_available (
- E_AUTH_COMBO_BOX (service->authtype),
- available_authtypes);
- g_list_free (available_authtypes);
- }
-
- if (service->check_dialog) {
- g_object_weak_unref (G_OBJECT (service->check_dialog), (GWeakNotify) g_nullify_pointer, &service->check_dialog);
- gtk_widget_destroy (service->check_dialog);
- }
- service->check_dialog = NULL;
-
- if (editor != NULL)
- gtk_widget_set_sensitive (editor, TRUE);
-
- backend = em_account_editor_get_backend (service->emae);
- session = e_mail_backend_get_session (backend);
-
- /* drop the temporary CamelService */
- camel_session_remove_service (
- CAMEL_SESSION (session), camel_service);
-
- g_object_unref (service->emae);
-}
-
-static void
-emae_check_authtype_response (GtkDialog *dialog,
- gint button,
- GCancellable *cancellable)
-{
- g_cancellable_cancel (cancellable);
-}
-
-static void
-emae_check_authtype (GtkWidget *w,
- EMAccountEditorService *service)
-{
- CamelService *camel_service;
- EMailBackend *backend;
- EMailSession *session;
- GtkWidget *editor;
- gpointer parent;
- gchar *uid;
- GError *error = NULL;
-
- editor = E_CONFIG (service->emae->config)->window;
-
- backend = em_account_editor_get_backend (service->emae);
- session = e_mail_backend_get_session (backend);
-
- uid = g_strdup_printf ("emae-check-authtype-%p", service);
-
- /* to test on actual data, not on previously used */
- camel_service = camel_session_add_service (
- CAMEL_SESSION (session), uid,
- service->protocol, service->type, &error);
-
- g_free (uid);
-
- if (camel_service != NULL && service->settings != NULL)
- camel_service_set_settings (camel_service, service->settings);
-
- if (editor != NULL)
- parent = gtk_widget_get_toplevel (editor);
- else
- parent = gtk_widget_get_toplevel (w);
-
- if (error) {
- e_alert_run_dialog_for_args (
- parent, "mail:checking-service-error",
- error->message, NULL);
- g_clear_error (&error);
- return;
- }
-
- g_return_if_fail (CAMEL_IS_SERVICE (camel_service));
-
- if (service->checking != NULL) {
- g_cancellable_cancel (service->checking);
- g_object_unref (service->checking);
- }
-
- service->checking = g_cancellable_new ();
-
- service->check_dialog = e_alert_dialog_new_for_args (
- parent, "mail:checking-service", NULL);
- g_object_weak_ref (G_OBJECT (service->check_dialog), (GWeakNotify) g_nullify_pointer, &service->check_dialog);
-
- g_object_ref (service->emae);
-
- camel_service_query_auth_types (
- camel_service, G_PRIORITY_DEFAULT,
- service->checking, (GAsyncReadyCallback)
- emae_check_authtype_done, service);
-
- g_signal_connect (
- service->check_dialog, "response",
- G_CALLBACK (emae_check_authtype_response),
- service->checking);
-
- gtk_widget_show (service->check_dialog);
-
- if (editor != NULL)
- gtk_widget_set_sensitive (editor, FALSE);
+#endif /* ACCOUNT_MGMT */
}
static void
@@ -2733,9 +2752,6 @@ emae_setup_service (EMAccountEditor *emae,
service->use_ssl = (GtkComboBox *) e_builder_get_widget (builder, info->use_ssl);
service->no_ssl = e_builder_get_widget (builder, info->ssl_disabled);
- service->auth_frame = e_builder_get_widget (builder, info->auth_frame);
- service->check_supported = (GtkButton *) e_builder_get_widget (builder, info->authtype_check);
- service->authtype = (GtkComboBox *) e_builder_get_widget (builder, info->authtype);
service->providers = (GtkComboBox *) e_builder_get_widget (builder, info->type_dropdown);
/* XXX GtkComboBoxText, when loaded from a GtkBuilder file,
@@ -2764,21 +2780,8 @@ emae_setup_service (EMAccountEditor *emae,
service->pathentry, "selection-changed",
G_CALLBACK (emae_file_chooser_changed), service);
- g_signal_connect (
- service->authtype, "changed",
- G_CALLBACK (emae_authtype_changed), service);
-
- g_signal_connect (
- service->check_supported, "clicked",
- G_CALLBACK (emae_check_authtype), service);
-
switch (service->type) {
case CAMEL_PROVIDER_STORE:
- g_object_bind_property (
- emae, "store-provider",
- service->authtype, "provider",
- G_BINDING_SYNC_CREATE);
-
if (service->needs_auth != NULL) {
g_object_set (emae, "store-requires-auth", requires_auth, NULL);
g_object_bind_property (
@@ -2786,18 +2789,9 @@ emae_setup_service (EMAccountEditor *emae,
service->needs_auth, "active",
G_BINDING_BIDIRECTIONAL |
G_BINDING_SYNC_CREATE);
- g_object_bind_property (
- emae, "store-requires-auth",
- service->auth_frame, "sensitive",
- G_BINDING_SYNC_CREATE);
}
g_object_bind_property (
- emae, "store-visible-auth",
- service->auth_frame, "visible",
- G_BINDING_SYNC_CREATE);
-
- g_object_bind_property (
emae, "store-visible-host",
service->hostname, "visible",
G_BINDING_SYNC_CREATE);
@@ -2840,11 +2834,6 @@ emae_setup_service (EMAccountEditor *emae,
break;
case CAMEL_PROVIDER_TRANSPORT:
- g_object_bind_property (
- emae, "transport-provider",
- service->authtype, "provider",
- G_BINDING_SYNC_CREATE);
-
if (service->needs_auth != NULL) {
g_object_set (emae, "transport-requires-auth", requires_auth, NULL);
g_object_bind_property (
@@ -2852,18 +2841,9 @@ emae_setup_service (EMAccountEditor *emae,
service->needs_auth, "active",
G_BINDING_BIDIRECTIONAL |
G_BINDING_SYNC_CREATE);
- g_object_bind_property (
- emae, "transport-requires-auth",
- service->auth_frame, "sensitive",
- G_BINDING_SYNC_CREATE);
}
g_object_bind_property (
- emae, "transport-visible-auth",
- service->auth_frame, "visible",
- G_BINDING_SYNC_CREATE);
-
- g_object_bind_property (
emae, "transport-visible-host",
service->hostname, "visible",
G_BINDING_SYNC_CREATE);
@@ -2983,9 +2963,6 @@ emae_create_basic_assistant_page (EMAccountEditor *emae,
gtk_box_pack_start (GTK_BOX (vbox), lbl, fill_space, fill_space, 0);
gtk_widget_show (lbl);
- if (g_ascii_strcasecmp (page_id, "start_page") == 0)
- g_hash_table_insert (emae->priv->widgets, (gchar *)"start_page_label", lbl);
-
gtk_assistant_insert_page (assistant, vbox, position);
gtk_assistant_set_page_title (assistant, vbox, title);
gtk_assistant_set_page_type (assistant, vbox, page_type);
@@ -2993,34 +2970,6 @@ emae_create_basic_assistant_page (EMAccountEditor *emae,
return vbox;
}
-/* do not re-order these, the order is used by various code to look up emae->priv->identity_entries[] */
-static struct {
- const gchar *name;
- gint item;
-} emae_identity_entries[] = {
- { "management_name", E_ACCOUNT_NAME },
- { "identity_full_name", E_ACCOUNT_ID_NAME },
- { "identity_address", E_ACCOUNT_ID_ADDRESS },
- { "identity_reply_to", E_ACCOUNT_ID_REPLY_TO },
- { "identity_organization", E_ACCOUNT_ID_ORGANIZATION },
-};
-
-static void
-emae_queue_widgets (EMAccountEditor *emae,
- GtkBuilder *builder,
- const gchar *first,
- ...)
-{
- va_list ap;
-
- va_start (ap, first);
- while (first) {
- g_hash_table_insert (emae->priv->widgets, (gchar *) first, e_builder_get_widget (builder, first));
- first = va_arg (ap, const gchar *);
- }
- va_end (ap);
-}
-
static GtkWidget *
emae_identity_page (EConfig *ec,
EConfigItem *item,
@@ -3030,696 +2979,239 @@ emae_identity_page (EConfig *ec,
gpointer data)
{
EMAccountEditor *emae = data;
- EMAccountEditorPrivate *priv = emae->priv;
- EAccount *account;
- gint i;
- GtkWidget *w;
- GtkBuilder *builder;
-
- if (old && emae->type == EMAE_PAGES)
- return old;
-
- account = em_account_editor_get_modified_account (emae);
-
- /* Make sure our custom widget classes are registered with
- * GType before we load the GtkBuilder definition file. */
- E_TYPE_MAIL_JUNK_OPTIONS;
- EM_TYPE_FOLDER_SELECTION_BUTTON;
-
- builder = gtk_builder_new ();
- e_load_ui_builder_definition (builder, "mail-config.ui");
-
- /* Management & Identity fields, in the assistant the management frame is relocated to the last page later on */
- for (i = 0; i < G_N_ELEMENTS (emae_identity_entries); i++)
- priv->identity_entries[i] = emae_account_entry (emae, emae_identity_entries[i].name, emae_identity_entries[i].item, builder);
-
- priv->management_frame = e_builder_get_widget (builder, "management-section");
-
- priv->default_account = GTK_TOGGLE_BUTTON (e_builder_get_widget (builder, "management_default"));
- if (!e_get_default_account ()
- || (account == e_get_default_account ())
- || (GPOINTER_TO_INT(g_object_get_data (G_OBJECT (account), "default_flagged"))) )
- gtk_toggle_button_set_active (priv->default_account, TRUE);
-
- if (emae->do_signature) {
- emae_setup_signatures (emae, builder);
- } else {
- /* TODO: this could/should probably be neater */
- gtk_widget_hide (e_builder_get_widget (builder, "sigLabel"));
-#if 0
- gtk_widget_hide (e_builder_get_widget (builder, "sigOption"));
-#endif
- gtk_widget_hide (e_builder_get_widget (builder, "signature_dropdown"));
- gtk_widget_hide (e_builder_get_widget (builder, "sigAddNew"));
- }
-
- w = e_builder_get_widget (builder, item->label);
- if (emae->type == EMAE_PAGES) {
- GtkWidget *page = emae_create_basic_assistant_page (emae, GTK_ASSISTANT (parent), "identity_page", position);
-
- gtk_box_pack_start ((GtkBox *) emae->pages[0], w, TRUE, TRUE, 0);
- w = page;
- } else if (((EConfig *) priv->config)->type == E_CONFIG_ASSISTANT) {
- GtkWidget *page;
-
- page = emae_create_basic_assistant_page (
- emae, GTK_ASSISTANT (parent),
- "identity_page", position);
-
- gtk_box_pack_start (GTK_BOX (page), w, TRUE, TRUE, 0);
-
- w = page;
- } else {
- gtk_notebook_insert_page (
- GTK_NOTEBOOK (parent), w,
- gtk_label_new (_("Identity")),
- position);
- gtk_container_child_set (
- GTK_CONTAINER (parent), w,
- "tab-fill", FALSE, "tab-expand", FALSE, NULL);
- }
-
- emae_queue_widgets (
- emae, builder,
- "account_vbox",
- "identity-required-table",
- "identity-optional-table",
- "identity-optional-section",
- "identity_address",
- NULL);
+ ESourceRegistry *registry;
+ EMailSession *session;
+ EConfig *config;
+ ESource *source;
+ GtkWidget *widget;
- g_object_unref (builder);
+ config = E_CONFIG (emae->priv->config);
- return w;
-}
+ session = em_account_editor_get_session (emae);
+ registry = e_mail_session_get_registry (session);
-static GtkWidget *
-emae_receive_page (EConfig *ec,
- EConfigItem *item,
- GtkWidget *parent,
- GtkWidget *old,
- gint position,
- gpointer data)
-{
- EMAccountEditor *emae = data;
- EMAccountEditorPrivate *priv = emae->priv;
- GtkWidget *w;
- GtkBuilder *builder;
+ if (emae->priv->mail_config_identity != NULL)
+ g_object_unref (emae->priv->mail_config_identity);
- /*if (old)
- return old;*/
-
- builder = gtk_builder_new ();
- e_load_ui_builder_definition (builder, "mail-config.ui");
+ source = emae->priv->mail_identity_source;
+ widget = e_mail_config_identity_new (registry, source);
+ emae->priv->mail_config_identity = g_object_ref (widget);
+ gtk_widget_show (widget);
- priv->source.type = CAMEL_PROVIDER_STORE;
- emae_setup_service (emae, &priv->source, builder);
+ g_signal_connect_swapped (
+ widget, "changed",
+ G_CALLBACK (emae_config_target_changed_cb), emae);
- w = e_builder_get_widget (builder, item->label);
if (emae->type == EMAE_PAGES) {
- GtkWidget *page = emae_create_basic_assistant_page (emae, GTK_ASSISTANT (parent), "source_page", position);
- GtkWidget *vbox, *child;
-
- child = (GtkWidget *)g_object_get_data ((GObject *)emae->pages[1], "old-child");
- if (child)
- gtk_container_remove ((GtkContainer *) emae->pages[1], child);
-
- vbox = gtk_vbox_new (FALSE, 12);
- gtk_container_set_border_width (GTK_CONTAINER (vbox), 12);
- gtk_widget_show (vbox);
- gtk_box_pack_start ((GtkBox *) vbox, w, TRUE, TRUE, 0);
- g_object_set_data ((GObject *)emae->pages[1], "old-child", vbox);
- gtk_box_pack_start ((GtkBox *) emae->pages[1], vbox, TRUE, TRUE, 0);
-
- w = page;
- } else if (((EConfig *) priv->config)->type == E_CONFIG_ASSISTANT) {
GtkWidget *page;
- page = emae_create_basic_assistant_page (
- emae, GTK_ASSISTANT (parent),
- "source_page", position);
-
- gtk_box_pack_start (GTK_BOX (page), w, TRUE, TRUE, 0);
-
- w = page;
- } else {
- gtk_notebook_insert_page (
- GTK_NOTEBOOK (parent), w,
- gtk_label_new (_("Receiving Email")),
- position);
- gtk_container_child_set (
- GTK_CONTAINER (parent), w,
- "tab-fill", FALSE, "tab-expand", FALSE, NULL);
- }
-
- emae_queue_widgets (
- emae, builder,
- "source-type-table",
- "source-config-table",
- "source-security-vbox",
- "source-auth-vbox",
- NULL);
-
- g_object_unref (builder);
-
- return w;
-}
-
-static void
-emae_set_option_dependency (EMAccountEditorService *service,
- CamelProviderConfEntry *conf,
- GtkWidget *widget)
-{
- if (conf->depname != NULL) {
- const gchar *depname = conf->depname;
-
- if (*depname == '!')
- depname++;
-
- g_object_bind_property (
- service->settings, depname,
- widget, "sensitive",
- G_BINDING_SYNC_CREATE |
- (depname == conf->depname ? 0 : G_BINDING_INVERT_BOOLEAN));
- gtk_widget_set_margin_left (widget, INDENT_MARGIN);
- }
-}
-
-static GtkWidget *
-emae_option_toggle (EMAccountEditorService *service,
- CamelProviderConfEntry *conf)
-{
- GtkWidget *widget;
-
- widget = gtk_check_button_new_with_mnemonic (conf->text);
-
- g_object_bind_property (
- service->settings, conf->name,
- widget, "active",
- G_BINDING_BIDIRECTIONAL |
- G_BINDING_SYNC_CREATE);
-
- emae_set_option_dependency (service, conf, widget);
-
- return widget;
-}
-
-static GtkWidget *
-emae_option_entry (EMAccountEditorService *service,
- CamelProviderConfEntry *conf,
- GtkLabel *label_for_mnemonic)
-{
- GtkWidget *widget;
-
- widget = gtk_entry_new ();
- gtk_label_set_mnemonic_widget (label_for_mnemonic, widget);
-
- g_object_bind_property (
- service->settings, conf->name,
- widget, "text",
- G_BINDING_BIDIRECTIONAL |
- G_BINDING_SYNC_CREATE);
-
- emae_set_option_dependency (service, conf, widget);
-
- g_object_bind_property (
- widget, "sensitive",
- label_for_mnemonic, "sensitive",
- G_BINDING_SYNC_CREATE);
-
- return widget;
-}
+ page = emae_create_basic_assistant_page (
+ emae, GTK_ASSISTANT (parent),
+ "identity_page", position);
-static GtkWidget *
-emae_option_checkspin (EMAccountEditorService *service,
- CamelProviderConfEntry *conf)
-{
- GObjectClass *class;
- GParamSpec *pspec;
- GParamSpec *use_pspec;
- GtkAdjustment *adjustment;
- GtkWidget *hbox, *spin;
- GtkWidget *prefix;
- gchar *use_property_name;
- gchar *pre, *post;
-
- /* The conf->name property (e.g. "foo") should be numeric for the
- * spin button. If a "use" boolean property exists (e.g. "use-foo")
- * then a checkbox is also shown. */
-
- g_return_val_if_fail (conf->name != NULL, NULL);
-
- class = G_OBJECT_GET_CLASS (service->settings);
- pspec = g_object_class_find_property (class, conf->name);
- g_return_val_if_fail (pspec != NULL, NULL);
-
- use_property_name = g_strconcat ("use-", conf->name, NULL);
- use_pspec = g_object_class_find_property (class, use_property_name);
- if (use_pspec != NULL && use_pspec->value_type != G_TYPE_BOOLEAN)
- use_pspec = NULL;
- g_free (use_property_name);
-
- /* Make sure we can convert to and from doubles. */
- g_return_val_if_fail (
- g_value_type_transformable (
- pspec->value_type, G_TYPE_DOUBLE), NULL);
- g_return_val_if_fail (
- g_value_type_transformable (
- G_TYPE_DOUBLE, pspec->value_type), NULL);
-
- if (G_IS_PARAM_SPEC_CHAR (pspec)) {
- GParamSpecChar *pspec_char;
- pspec_char = G_PARAM_SPEC_CHAR (pspec);
- adjustment = gtk_adjustment_new (
- (gdouble) pspec_char->default_value,
- (gdouble) pspec_char->minimum,
- (gdouble) pspec_char->maximum,
- 1.0, 1.0, 0.0);
-
- } else if (G_IS_PARAM_SPEC_UCHAR (pspec)) {
- GParamSpecUChar *pspec_uchar;
- pspec_uchar = G_PARAM_SPEC_UCHAR (pspec);
- adjustment = gtk_adjustment_new (
- (gdouble) pspec_uchar->default_value,
- (gdouble) pspec_uchar->minimum,
- (gdouble) pspec_uchar->maximum,
- 1.0, 1.0, 0.0);
-
- } else if (G_IS_PARAM_SPEC_INT (pspec)) {
- GParamSpecInt *pspec_int;
- pspec_int = G_PARAM_SPEC_INT (pspec);
- adjustment = gtk_adjustment_new (
- (gdouble) pspec_int->default_value,
- (gdouble) pspec_int->minimum,
- (gdouble) pspec_int->maximum,
- 1.0, 1.0, 0.0);
-
- } else if (G_IS_PARAM_SPEC_UINT (pspec)) {
- GParamSpecUInt *pspec_uint;
- pspec_uint = G_PARAM_SPEC_UINT (pspec);
- adjustment = gtk_adjustment_new (
- (gdouble) pspec_uint->default_value,
- (gdouble) pspec_uint->minimum,
- (gdouble) pspec_uint->maximum,
- 1.0, 1.0, 0.0);
-
- } else if (G_IS_PARAM_SPEC_LONG (pspec)) {
- GParamSpecLong *pspec_long;
- pspec_long = G_PARAM_SPEC_LONG (pspec);
- adjustment = gtk_adjustment_new (
- (gdouble) pspec_long->default_value,
- (gdouble) pspec_long->minimum,
- (gdouble) pspec_long->maximum,
- 1.0, 1.0, 0.0);
-
- } else if (G_IS_PARAM_SPEC_ULONG (pspec)) {
- GParamSpecULong *pspec_ulong;
- pspec_ulong = G_PARAM_SPEC_ULONG (pspec);
- adjustment = gtk_adjustment_new (
- (gdouble) pspec_ulong->default_value,
- (gdouble) pspec_ulong->minimum,
- (gdouble) pspec_ulong->maximum,
- 1.0, 1.0, 0.0);
-
- } else if (G_IS_PARAM_SPEC_FLOAT (pspec)) {
- GParamSpecFloat *pspec_float;
- pspec_float = G_PARAM_SPEC_FLOAT (pspec);
- adjustment = gtk_adjustment_new (
- (gdouble) pspec_float->default_value,
- (gdouble) pspec_float->minimum,
- (gdouble) pspec_float->maximum,
- 1.0, 1.0, 0.0);
-
- } else if (G_IS_PARAM_SPEC_DOUBLE (pspec)) {
- GParamSpecDouble *pspec_double;
- pspec_double = G_PARAM_SPEC_DOUBLE (pspec);
- adjustment = gtk_adjustment_new (
- (gdouble) pspec_double->default_value,
- (gdouble) pspec_double->minimum,
- (gdouble) pspec_double->maximum,
- 1.0, 1.0, 0.0);
-
- } else
- g_return_val_if_reached (NULL);
+ gtk_box_pack_start (
+ GTK_BOX (emae->pages[0]), widget, TRUE, TRUE, 0);
- pre = g_alloca (strlen (conf->text) + 1);
- strcpy (pre, conf->text);
- post = strstr (pre, "%s");
- if (post != NULL) {
- *post = '\0';
- post += 2;
- }
+ widget = page;
- hbox = gtk_hbox_new (FALSE, 3);
+ } else if (config->type == E_CONFIG_ASSISTANT) {
+ GtkWidget *page;
- if (use_pspec != NULL) {
- prefix = gtk_check_button_new_with_mnemonic (pre);
+ e_mail_config_identity_set_show_account_info (
+ E_MAIL_CONFIG_IDENTITY (widget), FALSE);
- g_object_bind_property (
- service->settings, use_pspec->name,
- prefix, "active",
- G_BINDING_BIDIRECTIONAL |
- G_BINDING_SYNC_CREATE);
- } else {
- prefix = gtk_label_new_with_mnemonic (pre);
- }
- gtk_box_pack_start (GTK_BOX (hbox), prefix, FALSE, TRUE, 0);
- gtk_widget_show (prefix);
+ e_mail_config_identity_set_show_signatures (
+ E_MAIL_CONFIG_IDENTITY (widget), FALSE);
- spin = gtk_spin_button_new (adjustment, 1.0, 0);
- gtk_box_pack_start (GTK_BOX (hbox), spin, FALSE, TRUE, 0);
- gtk_widget_show (spin);
+ page = emae_create_basic_assistant_page (
+ emae, GTK_ASSISTANT (parent),
+ "identity_page", position);
- g_object_bind_property (
- service->settings, conf->name,
- spin, "value",
- G_BINDING_BIDIRECTIONAL |
- G_BINDING_SYNC_CREATE);
+ gtk_box_pack_start (GTK_BOX (page), widget, TRUE, TRUE, 0);
- if (use_pspec != NULL)
- g_object_bind_property (
- prefix, "active",
- spin, "sensitive",
- G_BINDING_SYNC_CREATE);
+ widget = page;
- if (post != NULL) {
- GtkWidget *label = gtk_label_new_with_mnemonic (post);
- gtk_label_set_mnemonic_widget (GTK_LABEL (label), prefix);
- gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, TRUE, 0);
- gtk_widget_show (label);
+ } else {
+ gtk_notebook_insert_page (
+ GTK_NOTEBOOK (parent), widget,
+ gtk_label_new (_("Identity")),
+ position);
+ gtk_container_child_set (
+ GTK_CONTAINER (parent), widget,
+ "tab-fill", FALSE, "tab-expand", FALSE, NULL);
}
- emae_set_option_dependency (service, conf, hbox);
-
- return hbox;
+ return widget;
}
-/* 'values' is in format "nick0:caption0:nick1:caption1:...nickN:captionN"
- * where 'nick' is the nickname of a GEnumValue belonging to a GEnumClass
- * determined by the type of the GObject property named "name". */
static GtkWidget *
-emae_option_options (EMAccountEditorService *service,
- CamelProviderConfEntry *conf,
- GtkLabel *label)
+emae_receive_page (EConfig *ec,
+ EConfigItem *item,
+ GtkWidget *parent,
+ GtkWidget *old,
+ gint position,
+ gpointer data)
{
- CamelProvider *provider;
+ EMAccountEditor *emae = data;
+ ESourceRegistry *registry;
+ EMailSession *session;
+ EConfig *config;
GtkWidget *widget;
- GtkListStore *store;
- GtkTreeIter iter;
- const gchar *p;
- GtkCellRenderer *renderer;
+ GNode *node;
- provider = camel_provider_get (service->protocol, NULL);
- g_return_val_if_fail (provider != NULL, NULL);
+ config = E_CONFIG (emae->priv->config);
- /* nick and caption */
- store = gtk_list_store_new (2, G_TYPE_STRING, G_TYPE_STRING);
+ emae->priv->source.type = CAMEL_PROVIDER_STORE;
- p = conf->value;
- while (p != NULL) {
- const gchar *nick;
- const gchar *caption;
- gchar *vl, *cp;
+ session = em_account_editor_get_session (emae);
+ registry = e_mail_session_get_registry (session);
- nick = p;
- caption = strchr (p, ':');
- if (caption) {
- caption++;
- } else {
- g_warning (G_STRLOC ": expected ':' not found at '%s'", p);
- break;
- }
- p = strchr (caption, ':');
+ if (emae->priv->mail_account_config != NULL)
+ g_object_unref (emae->priv->mail_account_config);
- vl = g_strndup (nick, caption - nick - 1);
- if (p) {
- p++;
- cp = g_strndup (caption, p - caption - 1);
- } else
- cp = g_strdup (caption);
+ widget = e_mail_account_config_new (registry);
+ emae->priv->mail_account_config = g_object_ref_sink (widget);
+ gtk_widget_show (widget);
- gtk_list_store_append (store, &iter);
- gtk_list_store_set (
- store, &iter, 0, vl, 1, dgettext (
- provider->translation_domain, cp), -1);
+ node = g_node_first_child (emae->priv->candidate_source_tree);
- g_free (vl);
- g_free (cp);
+ while (node != NULL) {
+ e_mail_config_add_scratch_source (
+ E_MAIL_CONFIG (widget),
+ E_SOURCE (node->data));
+ node = g_node_next_sibling (node);
}
- widget = gtk_combo_box_new_with_model (GTK_TREE_MODEL (store));
- gtk_combo_box_set_id_column (GTK_COMBO_BOX (widget), 0);
- gtk_widget_show (widget);
-
- g_object_bind_property_full (
- service->settings, conf->name,
- widget, "active-id",
+ g_object_bind_property (
+ emae, "mail-account-source",
+ emae->priv->mail_account_config, "active-source",
G_BINDING_BIDIRECTIONAL |
- G_BINDING_SYNC_CREATE,
- e_binding_transform_enum_value_to_nick,
- e_binding_transform_enum_nick_to_value,
- NULL, (GDestroyNotify) NULL);
+ G_BINDING_SYNC_CREATE);
- renderer = gtk_cell_renderer_text_new ();
- gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (widget), renderer, TRUE);
- gtk_cell_layout_set_attributes (
- GTK_CELL_LAYOUT (widget), renderer, "text", 1, NULL);
+ g_signal_connect_swapped (
+ widget, "changed",
+ G_CALLBACK (emae_config_target_changed_cb), emae);
- gtk_label_set_mnemonic_widget (label, widget);
+ if (emae->type == EMAE_PAGES) {
+ GtkBox *box;
- return widget;
-}
+ box = GTK_BOX (emae->pages[1]);
+ gtk_box_pack_start (box, widget, TRUE, TRUE, 0);
-static GtkWidget *
-emae_receive_options_item (EConfig *ec,
- EConfigItem *item,
- GtkWidget *parent,
- GtkWidget *old,
- gint position,
- gpointer data)
-{
- EMAccountEditor *emae = data;
- CamelProvider *provider;
- GtkWidget *w, *box, *spin;
- guint row;
+ } else if (config->type == E_CONFIG_ASSISTANT) {
+ GtkWidget *page;
- provider = emae_get_store_provider (emae);
+ page = emae_create_basic_assistant_page (
+ emae, GTK_ASSISTANT (parent),
+ "source_page", position);
- if (provider == NULL || provider->extra_conf == NULL)
- return NULL;
+ gtk_box_pack_start (GTK_BOX (page), widget, TRUE, TRUE, 0);
- if (old) {
- if (emae->type == EMAE_PAGES) {
- GtkWidget *box = gtk_hbox_new (FALSE, 12);
- gtk_widget_reparent (old, box);
- gtk_widget_show (box);
- gtk_box_set_child_packing ((GtkBox *) box, old, TRUE, TRUE, 12, GTK_PACK_START);
- gtk_box_pack_end ((GtkBox *) emae->pages[2], box, FALSE, FALSE, 0);
- }
- return old;
- }
+ widget = page;
- if (emae->type == EMAE_PAGES) {
- GtkWidget *box = gtk_hbox_new (FALSE, 12);
- gtk_widget_reparent (parent, box);
- gtk_widget_show (box);
- gtk_box_set_child_packing ((GtkBox *) box, parent, TRUE, TRUE, 12, GTK_PACK_START);
- gtk_box_pack_start ((GtkBox *) emae->pages[2], box, FALSE, FALSE, 0);
+ } else {
+ gtk_notebook_insert_page (
+ GTK_NOTEBOOK (parent), widget,
+ gtk_label_new (_("Receiving Email")),
+ position);
+ gtk_container_child_set (
+ GTK_CONTAINER (parent), widget,
+ "tab-fill", FALSE, "tab-expand", FALSE, NULL);
}
- /* We have to add the automatic mail check item with the rest of the receive options */
- g_object_get (parent, "n-rows", &row, NULL);
-
- box = gtk_hbox_new (FALSE, 4);
- w = gtk_check_button_new_with_mnemonic (_("Check for _new messages every"));
- emae_account_toggle_widget (emae, (GtkToggleButton *) w, E_ACCOUNT_SOURCE_AUTO_CHECK);
- gtk_box_pack_start ((GtkBox *) box, w, FALSE, FALSE, 0);
-
- spin = gtk_spin_button_new_with_range (1.0, 1440.0, 1.0);
- emae_account_spinint_widget (emae, (GtkSpinButton *) spin, E_ACCOUNT_SOURCE_AUTO_CHECK_TIME);
- gtk_box_pack_start ((GtkBox *) box, spin, FALSE, TRUE, 0);
-
- w = gtk_label_new_with_mnemonic (_("minu_tes"));
- gtk_label_set_mnemonic_widget (GTK_LABEL (w), spin);
- gtk_box_pack_start ((GtkBox *) box, w, FALSE, FALSE, 0);
+ return widget;
+}
- gtk_widget_show_all (box);
+static gboolean
+emae_receive_options_skip (EConfig *config,
+ const gchar *pageid,
+ gpointer data)
+{
+ EMAccountEditor *emae = data;
+ GtkNotebook *notebook;
+ GtkWidget *child;
+ gint page_num;
- gtk_table_attach ((GtkTable *) parent, box, 0, 2, row, row + 1, GTK_EXPAND | GTK_FILL, 0, 0, 0);
+ notebook = GTK_NOTEBOOK (emae->priv->receive_options_notebook);
+ page_num = gtk_notebook_get_current_page (notebook);
+ child = gtk_notebook_get_nth_page (notebook, page_num);
+ g_return_val_if_fail (E_IS_MAIL_CONFIG_PROVIDER (child), FALSE);
- return box;
+ return e_mail_config_provider_is_empty (
+ E_MAIL_CONFIG_PROVIDER (child));
}
static GtkWidget *
-emae_receive_options_extra_item (EConfig *ec,
- EConfigItem *eitem,
- GtkWidget *parent,
- GtkWidget *old,
- gint position,
- gpointer data)
+emae_receive_options_page (EConfig *ec,
+ EConfigItem *eitem,
+ GtkWidget *parent,
+ GtkWidget *old,
+ gint position,
+ gpointer data)
{
EMAccountEditor *emae = data;
- EMAccountEditorService *service;
- struct _receive_options_item *item = (struct _receive_options_item *) eitem;
- GtkWidget *box;
GtkWidget *widget;
- GtkLabel *label;
- GtkTable *table;
- CamelProvider *provider;
- CamelProviderConfEntry *entries;
- guint row;
- GHashTable *extra;
- const gchar *section_name;
- gint ii;
-
- service = &emae->priv->source;
- section_name = eitem->user_data;
-
- provider = emae_get_store_provider (emae);
-
- if (provider == NULL || provider->extra_conf == NULL)
- return NULL;
-
- entries = provider->extra_conf;
-
- if (emae->type == EMAE_PAGES) {
- GtkWidget *box;
-
- box = gtk_hbox_new (FALSE, 12);
- gtk_widget_reparent (parent, box);
- gtk_widget_show (box);
- gtk_box_set_child_packing (
- GTK_BOX (box), parent,
- TRUE, TRUE, 12, GTK_PACK_START);
- gtk_box_pack_start (
- GTK_BOX (emae->pages[2]), box, FALSE, FALSE, 0);
- }
-
- for (ii = 0; entries && entries[ii].type != CAMEL_PROVIDER_CONF_END; ii++)
- if (entries[ii].type == CAMEL_PROVIDER_CONF_SECTION_START
- && g_strcmp0 (entries[ii].name, section_name) == 0)
- goto section;
-
- return NULL;
-
-section:
- d (printf ("Building extra section '%s'\n", eitem->path));
- widget = NULL;
- item->extra_table = g_hash_table_new (g_str_hash, g_str_equal);
- extra = g_hash_table_new (g_str_hash, g_str_equal);
-
- table = GTK_TABLE (parent);
- g_object_get (table, "n-rows", &row, NULL);
+ EConfig *config;
+ GNode *node;
- for (; entries[ii].type != CAMEL_PROVIDER_CONF_END && entries[ii].type != CAMEL_PROVIDER_CONF_SECTION_END; ii++) {
- switch (entries[ii].type) {
- case CAMEL_PROVIDER_CONF_SECTION_START:
- case CAMEL_PROVIDER_CONF_SECTION_END:
- break;
+ config = E_CONFIG (emae->priv->config);
- case CAMEL_PROVIDER_CONF_LABEL:
- /* FIXME This is a hack for exchange connector,
- * labels should be removed from confentry. */
- if (!strcmp (entries[ii].name, "hostname"))
- label = emae->priv->source.hostlabel;
- else if (!strcmp (entries[ii].name, "username"))
- label = emae->priv->source.userlabel;
- else
- label = NULL;
-
- if (label != NULL)
- gtk_label_set_text_with_mnemonic (
- label, entries[ii].text);
- break;
+ if (emae->priv->receive_options_notebook != NULL)
+ g_object_unref (emae->priv->receive_options_notebook);
- case CAMEL_PROVIDER_CONF_CHECKBOX:
- widget = emae_option_toggle (service, &entries[ii]);
- gtk_table_attach (
- table, widget, 0, 2,
- row, row + 1, GTK_EXPAND | GTK_FILL, 0, 0, 0);
- gtk_widget_show (widget);
-
- g_hash_table_insert (
- extra, (gpointer) entries[ii].name, widget);
-
- row++;
-
- /* HACK: keep_on_server is stored in the e-account,
- * but is displayed as a properly on the uri, make
- * sure they track/match here. */
- if (strcmp (entries[ii].name, "keep-on-server") == 0)
- emae_account_toggle_widget (
- emae, (GtkToggleButton *) widget,
- E_ACCOUNT_SOURCE_KEEP_ON_SERVER);
- break;
+ widget = e_source_notebook_new ();
+ emae->priv->receive_options_notebook = g_object_ref_sink (widget);
+ gtk_widget_show (widget);
- case CAMEL_PROVIDER_CONF_ENTRY:
- widget = gtk_label_new_with_mnemonic (entries[ii].text);
- gtk_misc_set_alignment (GTK_MISC (widget), 0.0, 0.5);
- gtk_table_attach (
- table, widget, 0, 1,
- row, row + 1, GTK_FILL, 0, 0, 0);
- gtk_widget_show (widget);
-
- label = GTK_LABEL (widget);
-
- widget = emae_option_entry (
- service, &entries[ii], label);
- gtk_table_attach (
- table, widget, 1, 2,
- row, row + 1, GTK_EXPAND | GTK_FILL, 0, 0, 0);
- gtk_widget_show (widget);
-
- row++;
-
- /* FIXME This is another hack for
- * exchange/groupwise connector. */
- g_hash_table_insert (
- item->extra_table,
- (gpointer) entries[ii].name, widget);
- break;
+ node = g_node_first_child (emae->priv->candidate_source_tree);
- case CAMEL_PROVIDER_CONF_CHECKSPIN:
- widget = emae_option_checkspin (service, &entries[ii]);
- gtk_table_attach (
- table, widget, 0, 2,
- row, row + 1, GTK_EXPAND | GTK_FILL, 0, 0, 0);
- gtk_widget_show (widget);
- row++;
- break;
+ while (node != NULL) {
+ ESource *source;
+ GtkWidget *child;
- case CAMEL_PROVIDER_CONF_OPTIONS:
- box = gtk_hbox_new (FALSE, 4);
- gtk_table_attach (
- table, box, 0, 2,
- row, row + 1, GTK_EXPAND | GTK_FILL, 0, 0, 0);
- gtk_widget_show (box);
+ source = E_SOURCE (node->data);
+ child = e_mail_config_provider_new (source);
- widget = gtk_label_new_with_mnemonic (entries[ii].text);
- gtk_misc_set_alignment (GTK_MISC (widget), 0.0, 0.5);
- gtk_box_pack_start (
- GTK_BOX (box), widget, FALSE, FALSE, 0);
- gtk_widget_show (widget);
+ e_source_notebook_add_page (
+ E_SOURCE_NOTEBOOK (widget), source, child);
- label = GTK_LABEL (widget);
+ node = g_node_next_sibling (node);
+ }
- widget = emae_option_options (
- service, &entries[ii], label);
- gtk_box_pack_start (
- GTK_BOX (box), widget, FALSE, FALSE, 0);
- gtk_widget_show (widget);
+ g_object_bind_property (
+ emae, "mail-account-source",
+ widget, "active-source",
+ G_BINDING_SYNC_CREATE);
- row++;
- break;
+ if (emae->type == EMAE_PAGES) {
+ GtkBox *box;
+
+ box = GTK_BOX (emae->pages[2]);
+ gtk_box_pack_start (box, widget, TRUE, TRUE, 0);
+
+ } else if (config->type == E_CONFIG_ASSISTANT) {
+ gtk_assistant_insert_page (
+ GTK_ASSISTANT (parent), widget, position);
+ gtk_assistant_set_page_title (
+ GTK_ASSISTANT (parent),
+ widget, _("Receiving Options"));
+ gtk_assistant_set_page_type (
+ GTK_ASSISTANT (parent),
+ widget, GTK_ASSISTANT_PAGE_CONTENT);
+ e_config_add_skip_check (
+ config, eitem->path,
+ emae_receive_options_skip, emae);
- default:
- break;
- }
+ } else {
+ gtk_notebook_insert_page (
+ GTK_NOTEBOOK (parent), widget,
+ gtk_label_new (_("Receiving Options")),
+ position);
+ gtk_container_child_set (
+ GTK_CONTAINER (parent), widget,
+ "tab-fill", FALSE, "tab-expand", FALSE, NULL);
}
- if (widget != NULL)
- gtk_widget_show (widget);
-
return widget;
}
@@ -3791,14 +3283,6 @@ emae_send_page (EConfig *ec,
"tab-fill", FALSE, "tab-expand", FALSE, NULL);
}
- emae_queue_widgets (
- emae, builder,
- "transport-type-table",
- "transport-server-table",
- "transport-security-table",
- "transport-auth-table",
- NULL);
-
g_object_unref (builder);
return w;
@@ -3812,6 +3296,7 @@ emae_real_url_toggled (GtkToggleButton *check,
em_folder_selection_button_set_folder_uri (button, "");
}
+#if 0 /* ACCOUNT_MGMT */
static void
set_real_folder_path (GtkButton *folder_button,
CamelSettings *settings,
@@ -3893,6 +3378,7 @@ update_real_folder_cb (GtkButton *folder_button,
g_object_set (G_OBJECT (settings), prop_name, path, NULL);
g_free (path);
}
+#endif /* ACCOUNT_MGMT */
static GtkWidget *
emae_defaults_page (EConfig *ec,
@@ -3902,6 +3388,7 @@ emae_defaults_page (EConfig *ec,
gint position,
gpointer data)
{
+#if 0 /* ACCOUNT_MGMT */
EMAccountEditor *emae = data;
EMAccountEditorPrivate *priv = emae->priv;
EMFolderSelectionButton *button;
@@ -3909,7 +3396,6 @@ emae_defaults_page (EConfig *ec,
CamelProvider *provider;
CamelSettings *settings;
CamelStore *store = NULL;
- EMailBackend *backend;
EMailSession *session;
EAccount *account;
GtkWidget *widget;
@@ -3923,9 +3409,7 @@ emae_defaults_page (EConfig *ec,
return NULL;
account = em_account_editor_get_modified_account (emae);
- backend = em_account_editor_get_backend (emae);
-
- session = e_mail_backend_get_session (backend);
+ session = em_account_editor_get_session (emae);
if (account != NULL) {
CamelService *service;
@@ -3940,8 +3424,8 @@ emae_defaults_page (EConfig *ec,
provider = emae_get_store_provider (emae);
settings = emae->priv->source.settings;
- /* Make sure we have a valid EMailBackend. */
- g_return_val_if_fail (E_IS_MAIL_BACKEND (backend), NULL);
+ /* Make sure we have a valid EMailSession. */
+ g_return_val_if_fail (E_IS_MAIL_SESSION (session), NULL);
builder = gtk_builder_new ();
e_load_ui_builder_definition (builder, "mail-config.ui");
@@ -4112,21 +3596,19 @@ emae_defaults_page (EConfig *ec,
"tab-fill", FALSE, "tab-expand", FALSE, NULL);
}
- emae_queue_widgets (
- emae, builder,
- "special-folders-table",
- "composing-messages-table",
- NULL);
-
g_object_unref (builder);
return widget;
+#endif /* ACCOUNT_MGMT */
+
+ return NULL;
}
static void
emae_account_hash_algo_combo_changed_cb (GtkComboBox *combobox,
EMAccountEditor *emae)
{
+#if 0 /* ACCOUNT_MGMT */
EAccount *account;
gpointer data;
const gchar *text = NULL;
@@ -4148,6 +3630,7 @@ emae_account_hash_algo_combo_changed_cb (GtkComboBox *combobox,
}
e_account_set_string (account, GPOINTER_TO_INT (data), text);
+#endif /* ACCOUNT_MGMT */
}
static GtkComboBox *
@@ -4156,6 +3639,7 @@ emae_account_hash_algo_combo (EMAccountEditor *emae,
gint item,
GtkBuilder *builder)
{
+#if 0 /* ACCOUNT_MGMT */
EAccount *account;
GtkComboBox *combobox;
const gchar *text;
@@ -4185,6 +3669,9 @@ emae_account_hash_algo_combo (EMAccountEditor *emae,
G_CALLBACK (emae_account_hash_algo_combo_changed_cb), emae);
return combobox;
+#endif /* ACCOUNT_MGMT */
+
+ return NULL;
}
static GtkWidget *
@@ -4208,6 +3695,7 @@ emae_security_page (EConfig *ec,
builder = gtk_builder_new ();
e_load_ui_builder_definition (builder, "mail-config.ui");
+#if 0 /* ACCOUNT_MGMT */
/* Security */
emae_account_entry (emae, "pgp_key", E_ACCOUNT_PGP_KEY, builder);
emae_account_hash_algo_combo (emae, "pgp_hash_algo", E_ACCOUNT_PGP_HASH_ALGORITHM, builder);
@@ -4215,10 +3703,13 @@ emae_security_page (EConfig *ec,
emae_account_toggle (emae, "pgp_always_sign", E_ACCOUNT_PGP_ALWAYS_SIGN, builder);
emae_account_toggle (emae, "pgp_no_imip_sign", E_ACCOUNT_PGP_NO_IMIP_SIGN, builder);
emae_account_toggle (emae, "pgp_always_trust", E_ACCOUNT_PGP_ALWAYS_TRUST, builder);
+#endif /* ACCOUNT_MGMT */
#if defined (HAVE_NSS) && defined (ENABLE_SMIME)
/* TODO: this should handle its entry separately? */
+#if 0 /* ACCOUNT_MGMT */
priv->smime_sign_key = emae_account_entry (emae, "smime_sign_key", E_ACCOUNT_SMIME_SIGN_KEY, builder);
+#endif /* ACCOUNT_MGMT */
priv->smime_sign_key_select = (GtkButton *)e_builder_get_widget (builder, "smime_sign_key_select");
priv->smime_sign_key_clear = (GtkButton *)e_builder_get_widget (builder, "smime_sign_key_clear");
g_signal_connect (
@@ -4228,10 +3719,12 @@ emae_security_page (EConfig *ec,
priv->smime_sign_key_clear, "clicked",
G_CALLBACK (smime_sign_key_clear), emae);
+#if 0 /* ACCOUNT_MGMT */
emae_account_hash_algo_combo (emae, "smime_hash_algo", E_ACCOUNT_SMIME_HASH_ALGORITHM, builder);
priv->smime_sign_default = emae_account_toggle (emae, "smime_sign_default", E_ACCOUNT_SMIME_SIGN_DEFAULT, builder);
priv->smime_encrypt_key = emae_account_entry (emae, "smime_encrypt_key", E_ACCOUNT_SMIME_ENCRYPT_KEY, builder);
+#endif /* ACCOUNT_MGMT */
priv->smime_encrypt_key_select = (GtkButton *)e_builder_get_widget (builder, "smime_encrypt_key_select");
priv->smime_encrypt_key_clear = (GtkButton *)e_builder_get_widget (builder, "smime_encrypt_key_clear");
g_signal_connect (
@@ -4241,8 +3734,10 @@ emae_security_page (EConfig *ec,
priv->smime_encrypt_key_clear, "clicked",
G_CALLBACK (smime_encrypt_key_clear), emae);
+#if 0 /* ACCOUNT_MGMT */
priv->smime_encrypt_default = emae_account_toggle (emae, "smime_encrypt_default", E_ACCOUNT_SMIME_ENCRYPT_DEFAULT, builder);
priv->smime_encrypt_to_self = emae_account_toggle (emae, "smime_encrypt_to_self", E_ACCOUNT_SMIME_ENCRYPT_TO_SELF, builder);
+#endif /* ACCOUNT_MGMT */
smime_changed (emae);
#else
{
@@ -4268,67 +3763,15 @@ emae_security_page (EConfig *ec,
return w;
}
-/*
- * Allow some level of post creation customisation in plugins.
- */
-GtkWidget *
-em_account_editor_get_widget (EMAccountEditor *emae,
- const gchar *name)
-{
- GtkWidget *wid;
-
- wid = g_hash_table_lookup (emae->priv->widgets, name);
- if (wid)
- return wid;
-
- g_warning ("Mail account widget '%s' not found", name);
-
- return NULL;
-}
-
-static GtkWidget *
-emae_widget_glade (EConfig *ec,
- EConfigItem *item,
- GtkWidget *parent,
- GtkWidget *old,
- gint position,
- gpointer data)
-{
- return em_account_editor_get_widget (data, item->label);
-}
-
/* plugin meta-data for "org.gnome.evolution.mail.config.accountEditor" */
static EMConfigItem emae_editor_items[] = {
{ E_CONFIG_BOOK, (gchar *) "" },
{ E_CONFIG_PAGE, (gchar *) "00.identity", (gchar *) "vboxIdentityBorder", emae_identity_page },
- { E_CONFIG_SECTION, (gchar *) "00.identity/00.name", (gchar *) "account_vbox", emae_widget_glade },
- { E_CONFIG_SECTION_TABLE, (gchar *) "00.identity/10.required", (gchar *) "identity-required-table", emae_widget_glade },
- { E_CONFIG_SECTION_TABLE, (gchar *) "00.identity/20.info", (gchar *) "identity-optional-table", emae_widget_glade },
-
{ E_CONFIG_PAGE, (gchar *) "10.receive", (gchar *) "vboxSourceBorder", emae_receive_page },
- { E_CONFIG_SECTION_TABLE, (gchar *) "10.receive/00.type", (gchar *) "source-type-table", emae_widget_glade },
- { E_CONFIG_SECTION_TABLE, (gchar *) "10.receive/10.config", (gchar *) "source-config-table", emae_widget_glade },
- { E_CONFIG_SECTION, (gchar *) "10.receive/20.security", (gchar *) "source-security-vbox", emae_widget_glade },
- { E_CONFIG_SECTION, (gchar *) "10.receive/30.auth", (gchar *) "source-auth-vbox", emae_widget_glade },
-
- /* Most sections for this is auto-generated from the camel config */
- { E_CONFIG_PAGE, (gchar *) "20.receive_options", (gchar *) N_("Receiving Options"), },
- { E_CONFIG_SECTION_TABLE, (gchar *) "20.receive_options/10.mailcheck", (gchar *) N_("Checking for New Messages"), },
- { E_CONFIG_ITEM_TABLE, (gchar *) "20.receive_options/10.mailcheck/00.autocheck", NULL, emae_receive_options_item, },
-
+ { E_CONFIG_PAGE, (gchar *) "20.receive_options", (gchar *) N_("Receiving Options"), emae_receive_options_page },
{ E_CONFIG_PAGE, (gchar *) "30.send", (gchar *) "vboxTransportBorder", emae_send_page },
- { E_CONFIG_SECTION_TABLE, (gchar *) "30.send/00.type", (gchar *) "transport-type-table", emae_widget_glade },
- { E_CONFIG_SECTION_TABLE, (gchar *) "30.send/10.config", (gchar *) "transport-server-table", emae_widget_glade },
- { E_CONFIG_SECTION_TABLE, (gchar *) "30.send/20.security", (gchar *) "transport-security-table", emae_widget_glade },
- { E_CONFIG_SECTION_TABLE, (gchar *) "30.send/30.auth", (gchar *) "transport-auth-table", emae_widget_glade },
-
{ E_CONFIG_PAGE, (gchar *) "40.defaults", (gchar *) "vboxFoldersBorder", emae_defaults_page },
- { E_CONFIG_SECTION_TABLE, (gchar *) "40.defaults/00.folders", (gchar *) "special-folders-table", emae_widget_glade },
- { E_CONFIG_SECTION_TABLE, (gchar *) "40.defaults/10.composing", (gchar *) "composing-messages-table", emae_widget_glade },
-
{ E_CONFIG_PAGE, (gchar *) "50.security", (gchar *) "vboxSecurityBorder", emae_security_page },
- /* 1x1 table (!) not vbox: { E_CONFIG_SECTION, "50.security/00.gpg", "table19", emae_widget_glade }, */
- /* table not vbox: { E_CONFIG_SECTION, "50.security/10.smime", "smime_table", emae_widget_glade }, */
{ 0 },
};
static gboolean emae_editor_items_translated = FALSE;
@@ -4401,35 +3844,12 @@ emae_widget_assistant_page (EConfig *ec,
static EMConfigItem emae_assistant_items[] = {
{ E_CONFIG_ASSISTANT, (gchar *) "" },
{ E_CONFIG_PAGE_START, (gchar *) "0.start", (gchar *) "start_page", emae_widget_assistant_page },
-
{ E_CONFIG_PAGE, (gchar *) "00.identity", (gchar *) "vboxIdentityBorder", emae_identity_page },
- { E_CONFIG_SECTION, (gchar *) "00.identity/00.name", (gchar *) "account_vbox", emae_widget_glade },
- { E_CONFIG_SECTION_TABLE, (gchar *) "00.identity/10.required", (gchar *) "identity-required-table", emae_widget_glade },
- { E_CONFIG_SECTION_TABLE, (gchar *) "00.identity/20.info", (gchar *) "identity-optional-table", emae_widget_glade },
-
{ E_CONFIG_PAGE, (gchar *) "10.receive", (gchar *) "vboxSourceBorder", emae_receive_page },
- { E_CONFIG_SECTION_TABLE, (gchar *) "10.receive/00.type", (gchar *) "source-type-table", emae_widget_glade },
- { E_CONFIG_SECTION_TABLE, (gchar *) "10.receive/10.config", (gchar *) "source-config-table", emae_widget_glade },
- { E_CONFIG_SECTION, (gchar *) "10.receive/20.security", (gchar *) "source-security-vbox", emae_widget_glade },
- { E_CONFIG_SECTION, (gchar *) "10.receive/30.auth", (gchar *) "source-auth-vbox", emae_widget_glade },
-
- /* Most sections for this is auto-generated fromt the camel config */
- { E_CONFIG_PAGE, (gchar *) "20.receive_options", (gchar *) N_("Receiving Options"), },
- { E_CONFIG_SECTION_TABLE, (gchar *) "20.receive_options/10.mailcheck", (gchar *) N_("Checking for New Messages"), },
- { E_CONFIG_ITEM_TABLE, (gchar *) "20.receive_options/10.mailcheck/00.autocheck", NULL, emae_receive_options_item, },
-
+ { E_CONFIG_PAGE, (gchar *) "20.receive_options", (gchar *) N_("Receiving Options"), emae_receive_options_page },
{ E_CONFIG_PAGE, (gchar *) "30.send", (gchar *) "vboxTransportBorder", emae_send_page },
- { E_CONFIG_SECTION_TABLE, (gchar *) "30.send/00.type", (gchar *) "transport-type-table", emae_widget_glade },
- { E_CONFIG_SECTION_TABLE, (gchar *) "30.send/10.config", (gchar *) "transport-server-table", emae_widget_glade },
- { E_CONFIG_SECTION_TABLE, (gchar *) "30.send/20.security", (gchar *) "transport-security-table", emae_widget_glade },
- { E_CONFIG_SECTION_TABLE, (gchar *) "30.send/30.auth", (gchar *) "transport-auth-table", emae_widget_glade },
-
{ E_CONFIG_PAGE, (gchar *) "40.defaults", (gchar *) "vboxFoldersBorder", emae_defaults_page },
- { E_CONFIG_SECTION_TABLE, (gchar *) "40.defaults/00.folders", (gchar *) "special-folders-table", emae_widget_glade },
- { E_CONFIG_SECTION_TABLE, (gchar *) "40.defaults/10.composing", (gchar *) "composing-messages-table", emae_widget_glade },
-
{ E_CONFIG_PAGE, (gchar *) "50.review", (gchar *) "vboxReviewBorder", emae_review_page },
-
{ E_CONFIG_PAGE_FINISH, (gchar *) "999.end", (gchar *) "finish_page", emae_widget_assistant_page },
{ 0 },
};
@@ -4443,26 +3863,6 @@ emae_free (EConfig *ec,
g_slist_free (items);
}
-static void
-emae_free_auto (EConfig *ec,
- GSList *items,
- gpointer data)
-{
- GSList *l, *n;
-
- for (l = items; l;) {
- struct _receive_options_item *item = l->data;
-
- n = g_slist_next (l);
- g_free (item->item.path);
- if (item->extra_table)
- g_hash_table_destroy (item->extra_table);
- g_free (item);
- g_slist_free_1 (l);
- l = n;
- }
-}
-
static gboolean
emae_check_service_complete (EMAccountEditor *emae,
EMAccountEditorService *service)
@@ -4539,11 +3939,14 @@ emae_check_servers (const gchar *email)
/* FIXME: Find a way to free the provider once given to account settings. */
provider->email = (gchar *) email;
tmp = strchr (email, '@');
- tmp++;
- provider->domain = tmp;
- tmp = strchr (dupe, '@');
- *tmp = 0;
- provider->username = (gchar *) g_quark_to_string (g_quark_from_string (dupe));
+ if (tmp != NULL) {
+ tmp++;
+ provider->domain = tmp;
+ tmp = strchr (dupe, '@');
+ *tmp = 0;
+ provider->username = (gchar *)
+ g_quark_to_string (g_quark_from_string (dupe));
+ }
g_free (dupe);
if (!mail_guess_servers (provider)) {
@@ -4624,26 +4027,62 @@ static gboolean
emae_display_name_in_use (EMAccountEditor *emae,
const gchar *display_name)
{
- EAccount *account;
- EAccount *original_account;
+ EMailSession *session;
+ ESourceRegistry *registry;
+ ESource *original_source;
+ const gchar *extension_name;
+ GList *list, *link;
+ gboolean in_use = FALSE;
+
+ session = em_account_editor_get_session (emae);
+ registry = e_mail_session_get_registry (session);
+
+ original_source = em_account_editor_get_original_source (emae);
+
+ /* Check if another mail account has the given display name. */
- /* XXX Trivial for now, less so when we dump EAccount. */
+ extension_name = E_SOURCE_EXTENSION_MAIL_ACCOUNT;
+ list = e_source_registry_list_sources (registry, extension_name);
- account = e_get_account_by_name (display_name);
- original_account = em_account_editor_get_original_account (emae);
+ for (link = list; link != NULL; link = g_list_next (link)) {
+ ESource *candidate;
+ const gchar *candidate_name;
+
+ candidate = E_SOURCE (link->data);
+ candidate_name = e_source_get_display_name (candidate);
+
+ /* Avoid a false positive. */
+ if (candidate == original_source)
+ continue;
+
+ if (g_utf8_collate (candidate_name, display_name) == 0) {
+ in_use = TRUE;
+ break;
+ }
+ }
- return (account != NULL && account != original_account);
+ g_list_free (list);
+
+ return in_use;
}
static void
emae_init_receive_page_for_new_account (EMAccountEditor *emae)
{
- EAccount *account;
- const gchar *address;
+#if 0 /* ACCOUNT_MGMT */
+ ESource *source;
+ ESourceExtension *extension;
+ ESourceMailIdentity *mail_identity_extension;
+ const gchar *extension_name;
+ gchar *address;
gchar *user;
- account = em_account_editor_get_modified_account (emae);
- address = e_account_get_string (account, E_ACCOUNT_ID_ADDRESS);
+ extension_name = E_SOURCE_EXTENSION_MAIL_IDENTITY;
+ source = em_account_editor_get_mail_identity_source (emae);
+ extension = e_source_get_extension (source, extension_name);
+ mail_identity_extension = E_SOURCE_MAIL_IDENTITY (extension);
+
+ address = e_source_mail_identity_dup_address (mail_identity_extension);
/* Extract an initial username from the email address. */
user = g_strdup (address);
@@ -4655,7 +4094,9 @@ emae_init_receive_page_for_new_account (EMAccountEditor *emae)
gtk_entry_set_text (emae->priv->source.username, user);
+ g_free (address);
g_free (user);
+#endif /* ACCOUNT_MGMT */
}
static void
@@ -4699,22 +4140,24 @@ emae_init_receive_page_for_server_data (EMAccountEditor *emae)
gtk_toggle_button_set_active (emae->priv->source.remember, TRUE);
gtk_entry_set_text (emae->priv->source.hostname, sdata->recv);
-
- if (sdata->recv_auth != NULL && *sdata->recv_auth != '\0')
- gtk_combo_box_set_active_id (
- emae->priv->source.authtype,
- sdata->recv_auth);
}
static void
emae_init_send_page_for_new_account (EMAccountEditor *emae)
{
- EAccount *account;
- const gchar *address;
+ ESource *source;
+ ESourceExtension *extension;
+ ESourceMailIdentity *mail_identity_extension;
+ const gchar *extension_name;
+ gchar *address;
gchar *user;
- account = em_account_editor_get_modified_account (emae);
- address = e_account_get_string (account, E_ACCOUNT_ID_ADDRESS);
+ extension_name = E_SOURCE_EXTENSION_MAIL_IDENTITY;
+ source = em_account_editor_get_mail_identity_source (emae);
+ extension = e_source_get_extension (source, extension_name);
+ mail_identity_extension = E_SOURCE_MAIL_IDENTITY (extension);
+
+ address = e_source_mail_identity_dup_address (mail_identity_extension);
/* Extract an initial username from the email address. */
user = g_strdup (address);
@@ -4726,6 +4169,7 @@ emae_init_send_page_for_new_account (EMAccountEditor *emae)
gtk_entry_set_text (emae->priv->transport.username, user);
+ g_free (address);
g_free (user);
}
@@ -4771,28 +4215,25 @@ emae_init_send_page_for_server_data (EMAccountEditor *emae)
gtk_toggle_button_set_active (emae->priv->transport.remember, TRUE);
gtk_toggle_button_set_active (emae->priv->transport.needs_auth, TRUE);
gtk_entry_set_text (emae->priv->transport.hostname, sdata->send);
-
- if (sdata->send_auth != NULL && *sdata->send_auth != '\0')
- gtk_combo_box_set_active_id (
- emae->priv->source.authtype,
- sdata->send_auth);
- else
- emae_authtype_changed (
- emae->priv->transport.authtype,
- &emae->priv->transport);
}
static void
emae_init_review_page (EMAccountEditor *emae)
{
- EAccount *account;
- const gchar *address;
+ ESource *source;
+ ESourceExtension *extension;
+ ESourceMailIdentity *mail_identity_extension;
+ const gchar *extension_name;
gchar *display_name;
+ gchar *address;
gint ii = 1;
- account = em_account_editor_get_modified_account (emae);
- address = e_account_get_string (account, E_ACCOUNT_ID_ADDRESS);
+ extension_name = E_SOURCE_EXTENSION_MAIL_IDENTITY;
+ source = em_account_editor_get_mail_identity_source (emae);
+ extension = e_source_get_extension (source, extension_name);
+ mail_identity_extension = E_SOURCE_MAIL_IDENTITY (extension);
+ address = e_source_mail_identity_dup_address (mail_identity_extension);
display_name = g_strdup (address);
/* Use the email address as the initial display name for the
@@ -4806,22 +4247,33 @@ emae_init_review_page (EMAccountEditor *emae)
gtk_entry_set_text (emae->priv->identity_entries[0], display_name);
g_free (display_name);
+ g_free (address);
}
static void
emae_update_review_page (EMAccountEditor *emae)
{
- EAccount *account;
- const gchar *name;
- const gchar *address;
+ ESource *source;
+ ESourceExtension *extension;
+ ESourceMailIdentity *mail_identity_extension;
+ const gchar *extension_name;
+ gchar *name;
+ gchar *address;
- account = em_account_editor_get_modified_account (emae);
- name = e_account_get_string (account, E_ACCOUNT_ID_NAME);
- address = e_account_get_string (account, E_ACCOUNT_ID_ADDRESS);
+ extension_name = E_SOURCE_EXTENSION_MAIL_IDENTITY;
+ source = em_account_editor_get_mail_identity_source (emae);
+ extension = e_source_get_extension (source, extension_name);
+ mail_identity_extension = E_SOURCE_MAIL_IDENTITY (extension);
+
+ name = e_source_mail_identity_dup_name (mail_identity_extension);
+ address = e_source_mail_identity_dup_address (mail_identity_extension);
gtk_label_set_text (emae->priv->review_name, name);
gtk_label_set_text (emae->priv->review_email, address);
+ g_free (name);
+ g_free (address);
+
if (CAMEL_IS_NETWORK_SETTINGS (emae->priv->source.settings)) {
CamelNetworkSecurityMethod method;
const gchar *encryption;
@@ -4942,16 +4394,22 @@ emae_update_review_page_for_google (EMAccountEditor *emae)
static void
emae_update_review_page_for_yahoo (EMAccountEditor *emae)
{
- EAccount *account;
+ ESource *source;
+ ESourceExtension *extension;
+ ESourceMailIdentity *mail_identity_extension;
GtkWidget *container;
GtkWidget *widget;
GtkWidget *label;
+ const gchar *extension_name;
gchar *markup;
gchar *name;
- account = em_account_editor_get_modified_account (emae);
- name = g_strdup (e_account_get_string (account, E_ACCOUNT_ID_NAME));
+ extension_name = E_SOURCE_EXTENSION_MAIL_IDENTITY;
+ source = em_account_editor_get_mail_identity_source (emae);
+ extension = e_source_get_extension (source, extension_name);
+ mail_identity_extension = E_SOURCE_MAIL_IDENTITY (extension);
+ name = e_source_mail_identity_dup_name (mail_identity_extension);
g_strdelimit (name, " ", '_');
emae_destroy_widget (emae->priv->calendar);
@@ -5015,42 +4473,16 @@ emae_update_review_page_for_yahoo (EMAccountEditor *emae)
}
static gboolean
-emae_check_identity_complete (EMAccountEditor *emae)
-{
- EAccount *account;
- const gchar *name;
- const gchar *address;
- const gchar *reply_to;
-
- account = em_account_editor_get_modified_account (emae);
-
- name = e_account_get_string (account, E_ACCOUNT_ID_NAME);
- address = e_account_get_string (account, E_ACCOUNT_ID_ADDRESS);
- reply_to = e_account_get_string (account, E_ACCOUNT_ID_REPLY_TO);
-
- if (name == NULL || *name == '\0')
- return FALSE;
-
- if (address == NULL || !is_email (address))
- return FALSE;
-
- /* An empty reply_to string is allowed. */
- if (reply_to != NULL && *reply_to != '\0' && !is_email (reply_to))
- return FALSE;
-
- return TRUE;
-}
-
-static gboolean
emae_check_review_complete (EMAccountEditor *emae)
{
- EAccount *account;
+ ESource *source;
const gchar *display_name;
- account = em_account_editor_get_modified_account (emae);
- display_name = e_account_get_string (account, E_ACCOUNT_NAME);
+ source = em_account_editor_get_mail_account_source (emae);
+ display_name = e_source_get_display_name (source);
+ g_return_val_if_fail (display_name != NULL, FALSE);
- if (display_name == NULL || *display_name == '\0')
+ if (*display_name == '\0')
return FALSE;
if (emae_display_name_in_use (emae, display_name))
@@ -5065,19 +4497,26 @@ emae_check_complete (EConfig *ec,
gpointer data)
{
EMAccountEditor *emae = data;
- EAccount *account;
+ ESource *source;
+ ESourceExtension *extension;
+ ESourceMailIdentity *mail_identity_extension;
+ const gchar *extension_name;
enum _e_config_t config_type;
gboolean refresh = FALSE;
gboolean new_account;
- const gchar *address;
+ gchar *address;
gchar *host = NULL;
gboolean ok = TRUE;
config_type = ((EConfig *) emae->priv->config)->type;
- new_account = (em_account_editor_get_original_account (emae) == NULL);
+ new_account = (em_account_editor_get_original_source (emae) == NULL);
- account = em_account_editor_get_modified_account (emae);
- address = e_account_get_string (account, E_ACCOUNT_ID_ADDRESS);
+ extension_name = E_SOURCE_EXTENSION_MAIL_IDENTITY;
+ source = em_account_editor_get_mail_identity_source (emae);
+ extension = e_source_get_extension (source, extension_name);
+ mail_identity_extension = E_SOURCE_MAIL_IDENTITY (extension);
+
+ address = e_source_mail_identity_dup_address (mail_identity_extension);
if (CAMEL_IS_NETWORK_SETTINGS (emae->priv->source.settings))
host = camel_network_settings_dup_host (
@@ -5176,13 +4615,21 @@ skip_prepare:
* keep track of which account is marked as default in case of
* editing multiple accounts at a time.
*/
+#if 0 /* ACCOUNT_MGMT */
if (gtk_toggle_button_get_active (emae->priv->default_account))
g_object_set_data (G_OBJECT (account), "default_flagged", GINT_TO_POINTER(1));
+#endif /* ACCOUNT_MGMT */
+
+ if (ok && (pageid == NULL || strcmp (pageid, "00.identity") == 0)) {
+ EMailConfigIdentity *config;
- if (ok && (pageid == NULL || strcmp (pageid, "00.identity") == 0))
- ok = emae_check_identity_complete (emae);
+ config = emae->priv->mail_config_identity;
+ ok = e_mail_config_identity_check_complete (config);
+ }
if (ok && (pageid == NULL || strcmp (pageid, "10.receive") == 0)) {
+ EMailConfig *config;
+
if (emae->type != EMAE_NOTEBOOK && refresh) {
emae_refresh_providers (
emae, &emae->priv->source);
@@ -5190,7 +4637,9 @@ skip_prepare:
emae->priv->source.providers,
&emae->priv->source);
}
- ok = emae_check_service_complete (emae, &emae->priv->source);
+
+ config = emae->priv->mail_account_config;
+ ok = e_mail_config_check_complete (config);
}
if (ok && (pageid == NULL || strcmp (pageid, "30.send") == 0)) {
@@ -5213,6 +4662,7 @@ skip_prepare:
if (ok && (pageid == NULL || strcmp (pageid, "50.review") == 0))
ok = emae_check_review_complete (emae);
+ g_free (address);
g_free (host);
return ok;
@@ -5225,6 +4675,7 @@ em_account_editor_check (EMAccountEditor *emae,
return emae_check_complete ((EConfig *) emae->config, page, emae);
}
+#if 0 /* ACCOUNT_MGMT */
static void
forget_password_if_needed (EAccount *original_account,
EAccount *modified_account,
@@ -5263,6 +4714,7 @@ forget_password_if_needed (EAccount *original_account,
camel_url_free (url);
}
}
+#endif /* ACCOUNT_MGMT */
#define CALENDAR_CALDAV_URI "caldav://%s www google com/calendar/dav/%s/events"
#define GMAIL_CALENDAR_LOCATION "://www.google.com/calendar/feeds/"
@@ -5295,6 +4747,7 @@ sanitize_user_mail (const gchar *user)
static void
setup_google_addressbook (EMAccountEditor *emae)
{
+#if 0 /* ACCOUNT_MGMT */
GConfClient *gconf;
ESourceList *slist;
ESourceGroup *sgrp;
@@ -5343,11 +4796,13 @@ setup_google_addressbook (EMAccountEditor *emae)
g_object_unref (slist);
g_object_unref (sgrp);
g_object_unref (gconf);
+#endif /* ACCOUNT_MGMT */
}
static void
setup_google_calendar (EMAccountEditor *emae)
{
+#if 0 /* ACCOUNT_MGMT */
GConfClient *gconf;
ESourceList *slist;
ESourceGroup *sgrp;
@@ -5412,11 +4867,13 @@ setup_google_calendar (EMAccountEditor *emae)
g_object_unref (sgrp);
g_object_unref (calendar);
g_object_unref (gconf);
+#endif /* ACCOUNT_MGMT */
}
static void
setup_yahoo_calendar (EMAccountEditor *emae)
{
+#if 0 /* ACCOUNT_MGMT */
GConfClient *gconf;
ESourceList *slist;
ESourceGroup *sgrp;
@@ -5483,25 +4940,25 @@ setup_yahoo_calendar (EMAccountEditor *emae)
g_object_unref (sgrp);
g_object_unref (calendar);
g_object_unref (gconf);
+#endif /* ACCOUNT_MGMT */
}
static void
emae_commit (EConfig *ec,
EMAccountEditor *emae)
{
+#if 0 /* ACCOUNT_MGMT */
EAccountList *accounts = e_get_account_list ();
EAccount *account;
- EAccount *modified_account;
- EAccount *original_account;
- CamelProvider *provider;
+ ESource *modified_source;
+ ESource *original_source;
CamelSettings *settings;
CamelURL *url;
const gchar *protocol;
gboolean requires_auth;
- modified_account = em_account_editor_get_modified_account (emae);
- original_account = em_account_editor_get_original_account (emae);
- provider = emae_get_store_provider (emae);
+ modified_source = em_account_editor_get_modified_source (emae);
+ original_source = em_account_editor_get_original_source (emae);
/* check for google and yahoo specific settings */
if (!original_account && emae->priv->is_gmail) {
@@ -5588,13 +5045,11 @@ emae_commit (EConfig *ec,
}
if (gtk_toggle_button_get_active (emae->priv->default_account)) {
- EMailBackend *backend;
EMailSession *session;
EMailAccountStore *store;
CamelService *service;
- backend = em_account_editor_get_backend (emae);
- session = e_mail_backend_get_session (backend);
+ session = em_account_editor_get_session (emae);
service = camel_session_get_service (
CAMEL_SESSION (session), account->uid);
@@ -5604,6 +5059,7 @@ emae_commit (EConfig *ec,
}
e_account_list_save (accounts);
+#endif /* ACCOUNT_MGMT */
}
void
@@ -5618,13 +5074,15 @@ em_account_editor_construct (EMAccountEditor *emae,
const gchar *id)
{
EMAccountEditorPrivate *priv = emae->priv;
- gint i, index;
+ ESource *source;
+ ESourceExtension *extension;
+ gint i;
GSList *l;
- GList *prov;
EMConfig *ec;
EMConfigTargetSettings *target;
- GHashTable *have;
EConfigItem *items;
+ const gchar *extension_name;
+ gchar *address;
emae->type = type;
@@ -5663,59 +5121,22 @@ em_account_editor_construct (EMAccountEditor *emae,
l = g_slist_prepend (l, &items[i]);
e_config_add_items ((EConfig *) ec, l, emae_free, emae);
- /* This is kinda yuck, we're dynamically mapping from the 'old style' extensibility api to the new one */
- l = NULL;
- have = g_hash_table_new (g_str_hash, g_str_equal);
- index = 20;
- for (prov = priv->providers; prov; prov = g_list_next (prov)) {
- CamelProviderConfEntry *entries = ((CamelProvider *) prov->data)->extra_conf;
-
- for (i = 0; entries && entries[i].type != CAMEL_PROVIDER_CONF_END; i++) {
- struct _receive_options_item *item;
- const gchar *name = entries[i].name;
- gint myindex = index;
-
- if (entries[i].type != CAMEL_PROVIDER_CONF_SECTION_START
- || name == NULL
- || g_hash_table_lookup (have, name))
- continue;
-
- /* override mailcheck since we also insert our own mailcheck item at this index */
- if (name && !strcmp (name, "mailcheck"))
- myindex = 10;
-
- item = g_malloc0 (sizeof (*item));
- item->item.type = E_CONFIG_SECTION_TABLE;
- item->item.path = g_strdup_printf ("20.receive_options/%02d.%s", myindex, name?name:"unnamed");
- item->item.label = g_strdup (entries[i].text);
-
- l = g_slist_prepend (l, item);
-
- item = g_malloc0 (sizeof (*item));
- item->item.type = E_CONFIG_ITEM_TABLE;
- item->item.path = g_strdup_printf ("20.receive_options/%02d.%s/80.camelitem", myindex, name?name:"unnamed");
- item->item.factory = emae_receive_options_extra_item;
- item->item.user_data = g_strdup (entries[i].name);
-
- l = g_slist_prepend (l, item);
-
- index += 10;
- g_hash_table_insert (have, (gpointer) entries[i].name, have);
- }
- }
- g_hash_table_destroy (have);
- e_config_add_items ((EConfig *) ec, l, emae_free_auto, emae);
- priv->extra_items = l;
-
e_config_add_page_check ((EConfig *) ec, NULL, emae_check_complete, emae);
+ source = emae->priv->mail_identity_source;
+ extension_name = E_SOURCE_EXTENSION_MAIL_IDENTITY;
+ extension = e_source_get_extension (source, extension_name);
+
+ address = e_source_mail_identity_dup_address (
+ E_SOURCE_MAIL_IDENTITY (extension));
+
target = em_config_target_new_settings (
- ec,
- emae->priv->modified_account->id->address,
+ ec, address,
emae->priv->source.protocol,
emae->priv->source.settings,
emae->priv->transport.protocol,
emae->priv->transport.settings);
e_config_set_target ((EConfig *) ec, (EConfigTarget *) target);
-}
+ g_free (address);
+}
diff --git a/mail/em-account-editor.h b/mail/em-account-editor.h
index 18d4b91..426d76e 100644
--- a/mail/em-account-editor.h
+++ b/mail/em-account-editor.h
@@ -26,9 +26,7 @@
#include <gtk/gtk.h>
#include <mail/em-config.h>
-#include <mail/e-mail-backend.h>
-
-#include <libedataserver/e-account.h>
+#include <libemail-engine/e-mail-session.h>
/* Standard GObject macros */
#define EM_TYPE_ACCOUNT_EDITOR \
@@ -98,26 +96,28 @@ struct _EMAccountEditorClass {
GType em_account_editor_get_type (void);
EMAccountEditor *
- em_account_editor_new (EAccount *account,
+ em_account_editor_new (ESource *source,
EMAccountEditorType type,
- EMailBackend *backend,
+ EMailSession *session,
const gchar *id);
EMAccountEditor *
- em_account_editor_new_for_pages (EAccount *account,
+ em_account_editor_new_for_pages (ESource *source,
EMAccountEditorType type,
- EMailBackend *backend,
+ EMailSession *session,
const gchar *id,
GtkWidget **pages);
-EMailBackend * em_account_editor_get_backend (EMAccountEditor *emae);
-EAccount * em_account_editor_get_modified_account
+EMailSession * em_account_editor_get_session (EMAccountEditor *emae);
+ESource * em_account_editor_get_mail_account_source
+ (EMAccountEditor *emae);
+ESource * em_account_editor_get_mail_identity_source
+ (EMAccountEditor *emae);
+ESource * em_account_editor_get_mail_transport_source
(EMAccountEditor *emae);
-EAccount * em_account_editor_get_original_account
+ESource * em_account_editor_get_original_source
(EMAccountEditor *emae);
void em_account_editor_commit (EMAccountEditor *emae);
gboolean em_account_editor_check (EMAccountEditor *emae,
const gchar *page);
-GtkWidget * em_account_editor_get_widget (EMAccountEditor *emae,
- const gchar *name);
G_END_DECLS
diff --git a/mail/em-composer-utils.c b/mail/em-composer-utils.c
index 745609f..62d2f1e 100644
--- a/mail/em-composer-utils.c
+++ b/mail/em-composer-utils.c
@@ -31,12 +31,16 @@
#include <glib/gi18n.h>
#include <libedataserver/e-data-server-util.h>
+#include <libedataserver/e-source-mail-account.h>
+#include <libedataserver/e-source-mail-composition.h>
+#include <libedataserver/e-source-mail-identity.h>
+#include <libedataserver/e-source-mail-submission.h>
+#include <libedataserver/e-source-mdn.h>
#include <libevolution-utils/e-alert-dialog.h>
#include <libevolution-utils/e-alert-sink.h>
#include <e-util/e-util.h>
-#include <libemail-utils/e-account-utils.h>
#include <libemail-utils/mail-mt.h>
#include <libemail-engine/e-mail-folder-utils.h>
@@ -364,23 +368,27 @@ finished:
}
static gboolean
-composer_presend_check_account (EMsgComposer *composer,
- EMailSession *session)
+composer_presend_check_identity (EMsgComposer *composer,
+ EMailSession *session)
{
EComposerHeaderTable *table;
- EAccount *account;
- gboolean check_passed;
+ ESourceRegistry *registry;
+ ESource *source;
+ const gchar *uid;
table = e_msg_composer_get_header_table (composer);
- account = e_composer_header_table_get_account (table);
- check_passed = (account != NULL && account->enabled);
+ registry = e_composer_header_table_get_registry (table);
+ uid = e_composer_header_table_get_identity_uid (table);
+ source = e_source_registry_lookup_by_uid (registry, uid);
- if (!check_passed)
+ if (!em_utils_mail_identity_is_enabled (registry, source)) {
e_alert_submit (
E_ALERT_SINK (composer),
"mail:send-no-account-enabled", NULL);
+ return FALSE;
+ }
- return check_passed;
+ return TRUE;
}
static gboolean
@@ -810,9 +818,11 @@ em_utils_composer_save_to_drafts_cb (EMsgComposer *composer,
{
AsyncContext *context;
EComposerHeaderTable *table;
+ ESourceRegistry *registry;
+ ESource *source;
const gchar *drafts_folder_uri = NULL;
const gchar *local_drafts_folder_uri;
- EAccount *account;
+ const gchar *identity_uid;
context = g_slice_new0 (AsyncContext);
context->message = g_object_ref (message);
@@ -820,18 +830,29 @@ em_utils_composer_save_to_drafts_cb (EMsgComposer *composer,
context->composer = g_object_ref (composer);
context->activity = g_object_ref (activity);
- local_drafts_folder_uri =
- e_mail_session_get_local_folder_uri (
- session, E_MAIL_LOCAL_FOLDER_DRAFTS);
-
table = e_msg_composer_get_header_table (composer);
- account = e_composer_header_table_get_account (table);
- if (account != NULL && account->enabled)
- drafts_folder_uri = account->drafts_folder_uri;
+ registry = e_composer_header_table_get_registry (table);
+ identity_uid = e_composer_header_table_get_identity_uid (table);
+ source = e_source_registry_lookup_by_uid (registry, identity_uid);
+
+ /* Get the selected identity's preferred Drafts folder. */
+ if (source != NULL) {
+ ESourceMailComposition *extension;
+ const gchar *extension_name;
+ const gchar *uri;
- if (g_strcmp0 (drafts_folder_uri, local_drafts_folder_uri) == 0)
- drafts_folder_uri = NULL;
+ extension_name = E_SOURCE_EXTENSION_MAIL_COMPOSITION;
+ extension = e_source_get_extension (source, extension_name);
+ uri = e_source_mail_composition_get_drafts_folder (extension);
+
+ if (uri != NULL && *uri != '\0')
+ drafts_folder_uri = uri;
+ }
+
+ local_drafts_folder_uri =
+ e_mail_session_get_local_folder_uri (
+ session, E_MAIL_LOCAL_FOLDER_DRAFTS);
if (drafts_folder_uri == NULL) {
composer_save_to_drafts_append_mail (context, NULL);
@@ -950,12 +971,15 @@ create_new_composer (EShell *shell,
CamelFolder *folder)
{
EMsgComposer *composer;
+ ESourceRegistry *registry;
EComposerHeaderTable *table;
- EAccount *account = NULL;
+ ESource *source = NULL;
+ const gchar *identity = NULL;
composer = e_msg_composer_new (shell);
table = e_msg_composer_get_header_table (composer);
+ registry = e_composer_header_table_get_registry (table);
if (folder != NULL) {
CamelStore *store;
@@ -965,7 +989,7 @@ create_new_composer (EShell *shell,
store = camel_folder_get_parent_store (folder);
uid = camel_service_get_uid (CAMEL_SERVICE (store));
- account = e_get_account_by_uid (uid);
+ source = e_source_registry_lookup_by_uid (registry, uid);
folder_uri = e_mail_folder_uri_from_folder (folder);
@@ -976,8 +1000,17 @@ create_new_composer (EShell *shell,
g_free (folder_uri);
}
- e_composer_header_table_set_account (table, account);
+ if (source != NULL) {
+ ESourceMailAccount *extension;
+ const gchar *extension_name;
+
+ extension_name = E_SOURCE_EXTENSION_MAIL_ACCOUNT;
+ extension = e_source_get_extension (source, extension_name);
+ identity = e_source_mail_account_get_identity_uid (extension);
+ }
+
e_composer_header_table_set_subject (table, subject);
+ e_composer_header_table_set_identity_uid (table, identity);
return composer;
}
@@ -1023,8 +1056,8 @@ em_utils_compose_new_message_with_mailto (EShell *shell,
CamelFolder *folder)
{
EMsgComposer *composer;
+ ESourceRegistry *registry;
EComposerHeaderTable *table;
- CamelService *service = NULL;
g_return_val_if_fail (E_IS_SHELL (shell), NULL);
@@ -1037,25 +1070,37 @@ em_utils_compose_new_message_with_mailto (EShell *shell,
composer = e_msg_composer_new (shell);
table = e_msg_composer_get_header_table (composer);
+ registry = e_composer_header_table_get_registry (table);
+
+ composer_set_no_change (composer);
+
+ gtk_window_present (GTK_WINDOW (composer));
+
+ /* If a CamelFolder was given, we need to backtrack and find
+ * the corresponding ESource with a Mail Identity extension. */
if (folder != NULL) {
+ ESource *source;
CamelStore *store;
+ ESourceMailAccount *extension;
+ const gchar *extension_name;
+ const gchar *uid;
store = camel_folder_get_parent_store (folder);
- service = CAMEL_SERVICE (store);
- }
+ uid = camel_service_get_uid (CAMEL_SERVICE (store));
+ source = e_source_registry_lookup_by_uid (registry, uid);
+ g_return_val_if_fail (source != NULL, composer);
- if (service != NULL) {
- const gchar *display_name;
+ extension_name = E_SOURCE_EXTENSION_MAIL_ACCOUNT;
+ if (e_source_has_extension (source, extension_name))
+ goto exit;
- display_name = camel_service_get_display_name (service);
- e_composer_header_table_set_account_name (table, display_name);
+ extension = e_source_get_extension (source, extension_name);
+ uid = e_source_mail_account_get_identity_uid (extension);
+ e_composer_header_table_set_identity_uid (table, uid);
}
- composer_set_no_change (composer);
-
- gtk_window_present (GTK_WINDOW (composer));
-
+exit:
return composer;
}
@@ -1276,6 +1321,7 @@ em_utils_edit_message (EShell *shell,
const gchar *message_uid)
{
EMsgComposer *composer;
+ ESourceRegistry *registry;
gboolean folder_is_drafts;
gboolean folder_is_outbox;
gboolean folder_is_templates;
@@ -1284,9 +1330,10 @@ em_utils_edit_message (EShell *shell,
g_return_val_if_fail (CAMEL_IS_FOLDER (folder), NULL);
g_return_val_if_fail (CAMEL_IS_MIME_MESSAGE (message), NULL);
- folder_is_drafts = em_utils_folder_is_drafts (folder);
- folder_is_outbox = em_utils_folder_is_outbox (folder);
- folder_is_templates = em_utils_folder_is_templates (folder);
+ registry = e_shell_get_registry (shell);
+ folder_is_drafts = em_utils_folder_is_drafts (registry, folder);
+ folder_is_outbox = em_utils_folder_is_outbox (registry, folder);
+ folder_is_templates = em_utils_folder_is_templates (registry, folder);
/* Template specific code follows. */
if (folder_is_templates) {
@@ -1313,10 +1360,12 @@ em_utils_edit_message (EShell *shell,
}
composer = e_msg_composer_new_with_message (shell, message, NULL);
- if (folder && !folder_is_templates) {
+ if (!folder_is_templates) {
EComposerHeaderTable *table;
- EAccount *account;
+ ESourceMailAccount *extension;
+ ESource *source;
CamelStore *store;
+ const gchar *extension_name;
const gchar *uid;
gchar *folder_uri;
GList *list;
@@ -1325,7 +1374,11 @@ em_utils_edit_message (EShell *shell,
store = camel_folder_get_parent_store (folder);
uid = camel_service_get_uid (CAMEL_SERVICE (store));
- account = e_get_account_by_uid (uid);
+ source = e_source_registry_lookup_by_uid (registry, uid);
+
+ extension_name = E_SOURCE_EXTENSION_MAIL_ACCOUNT;
+ extension = e_source_get_extension (source, extension_name);
+ uid = e_source_mail_account_get_identity_uid (extension);
folder_uri = e_mail_folder_uri_from_folder (folder);
@@ -1335,7 +1388,7 @@ em_utils_edit_message (EShell *shell,
g_free (folder_uri);
- e_composer_header_table_set_account (table, account);
+ e_composer_header_table_set_identity_uid (table, uid);
}
e_msg_composer_remove_header (
@@ -1869,8 +1922,10 @@ static EMsgComposer *
redirect_get_composer (EShell *shell,
CamelMimeMessage *message)
{
+ ESourceRegistry *registry;
CamelMedium *medium;
- EAccount *account;
+ ESource *source;
+ const gchar *identity_uid = NULL;
medium = CAMEL_MEDIUM (message);
@@ -1886,10 +1941,15 @@ redirect_get_composer (EShell *shell,
while (camel_medium_get_header (medium, "Resent-Bcc"))
camel_medium_remove_header (medium, "Resent-Bcc");
- account = em_utils_guess_account_with_recipients (message, NULL);
+ registry = e_shell_get_registry (shell);
+
+ source = em_utils_guess_mail_identity_with_recipients (
+ registry, message, NULL);
+ if (source != NULL)
+ identity_uid = e_source_get_uid (source);
return e_msg_composer_new_redirect (
- shell, message, account ? account->name : NULL, NULL);
+ shell, message, identity_uid, NULL);
}
/**
@@ -1956,7 +2016,7 @@ em_utils_camel_address_to_destination (CamelInternetAddress *iaddr)
static EMsgComposer *
reply_get_composer (EShell *shell,
CamelMimeMessage *message,
- EAccount *account,
+ const gchar *identity_uid,
CamelInternetAddress *to,
CamelInternetAddress *cc,
CamelFolder *folder,
@@ -1997,9 +2057,9 @@ reply_get_composer (EShell *shell,
}
table = e_msg_composer_get_header_table (composer);
- e_composer_header_table_set_account (table, account);
e_composer_header_table_set_subject (table, subject);
e_composer_header_table_set_destinations_to (table, tov);
+ e_composer_header_table_set_identity_uid (table, identity_uid);
/* Add destinations instead of setting, so we don't remove
* automatic CC addresses that have already been added. */
@@ -2278,64 +2338,6 @@ get_reply_recipient (CamelMimeMessage *message,
}
-static GHashTable *
-generate_recipient_hash (void)
-{
- GHashTable *rcpt_hash;
- EAccount *account, *def;
- EAccountList *account_list;
- EIterator *iterator;
-
- account_list = e_get_account_list ();
- rcpt_hash = g_hash_table_new (camel_strcase_hash, camel_strcase_equal);
-
- def = e_get_default_account ();
-
- iterator = e_list_get_iterator (E_LIST (account_list));
-
- while (e_iterator_is_valid (iterator)) {
- account = (EAccount *) e_iterator_get (iterator);
-
- if (account->id->address) {
- EAccount *acnt;
-
- /* Accounts with identical email addresses that are
- * enabled take precedence over the accounts that
- * aren't. If all accounts with matching email
- * addresses are disabled, then the first one in
- * the list takes precedence. The default account
- * always takes precedence no matter what. */
- acnt = g_hash_table_lookup (
- rcpt_hash, account->id->address);
- if (acnt && acnt != def && !acnt->enabled && account->enabled) {
- g_hash_table_remove (
- rcpt_hash, acnt->id->address);
- acnt = NULL;
- }
-
- if (!acnt)
- g_hash_table_insert (
- rcpt_hash, (gchar *)
- account->id->address,
- (gpointer) account);
- }
-
- e_iterator_next (iterator);
- }
-
- g_object_unref (iterator);
-
- /* The default account has to be there if none
- * of the enabled accounts are present. */
- if (g_hash_table_size (rcpt_hash) == 0 && def && def->id->address)
- g_hash_table_insert (
- rcpt_hash, (gchar *)
- def->id->address,
- (gpointer) def);
-
- return rcpt_hash;
-}
-
static void
concat_unique_addrs (CamelInternetAddress *dest,
CamelInternetAddress *src,
@@ -2352,8 +2354,96 @@ concat_unique_addrs (CamelInternetAddress *dest,
}
}
+static GHashTable *
+generate_recipient_hash (ESourceRegistry *registry)
+{
+ GHashTable *rcpt_hash;
+ ESource *default_source;
+ GList *list, *link;
+ const gchar *extension_name;
+
+ g_return_val_if_fail (E_IS_SOURCE_REGISTRY (registry), NULL);
+
+ rcpt_hash = g_hash_table_new (
+ (GHashFunc) camel_strcase_hash,
+ (GEqualFunc) camel_strcase_equal);
+
+ default_source = e_source_registry_get_default_mail_account (registry);
+
+ extension_name = E_SOURCE_EXTENSION_MAIL_ACCOUNT;
+ list = e_source_registry_list_sources (registry, extension_name);
+
+ for (link = list; link != NULL; link = g_list_next (link)) {
+ ESource *source = E_SOURCE (link->data);
+ ESource *cached_source;
+ ESource *identity_source;
+ ESourceExtension *extension;
+ const gchar *address;
+ gboolean insert_source;
+ gboolean cached_is_default;
+ gboolean cached_is_enabled;
+ gboolean source_is_default;
+ gboolean source_is_enabled;
+
+ source_is_default = e_source_equal (source, default_source);
+ source_is_enabled = e_source_get_enabled (source);
+
+ extension_name = E_SOURCE_EXTENSION_MAIL_ACCOUNT;
+ extension = e_source_get_extension (source, extension_name);
+
+ identity_source = e_source_mail_account_get_identity (
+ E_SOURCE_MAIL_ACCOUNT (extension));
+
+ if (identity_source == NULL)
+ continue;
+
+ extension_name = E_SOURCE_EXTENSION_MAIL_IDENTITY;
+ extension = e_source_get_extension (
+ identity_source, extension_name);
+
+ address = e_source_mail_identity_get_address (
+ E_SOURCE_MAIL_IDENTITY (extension));
+
+ if (address == NULL)
+ continue;
+
+ cached_source = g_hash_table_lookup (rcpt_hash, address);
+
+ if (cached_source != NULL) {
+ cached_is_default = e_source_equal (
+ cached_source, default_source);
+ cached_is_enabled =
+ e_source_get_enabled (cached_source);
+ } else {
+ cached_is_default = FALSE;
+ cached_is_enabled = FALSE;
+ }
+
+ /* Accounts with identical email addresses that are enabled
+ * take precedence over disabled accounts. If all accounts
+ * with matching email addresses are disabled, the first
+ * one in the list takes precedence. The default account
+ * always takes precedence no matter what. */
+ insert_source =
+ source_is_default ||
+ cached_source == NULL ||
+ (source_is_enabled &&
+ !cached_is_enabled &&
+ !cached_is_default);
+
+ if (insert_source)
+ g_hash_table_insert (
+ rcpt_hash, (gchar *) address, source);
+ }
+
+ g_list_free (list);
+
+ return rcpt_hash;
+}
+
void
-em_utils_get_reply_all (CamelMimeMessage *message,
+em_utils_get_reply_all (ESourceRegistry *registry,
+ CamelMimeMessage *message,
CamelInternetAddress *to,
CamelInternetAddress *cc,
CamelNNTPAddress *postto)
@@ -2366,6 +2456,7 @@ em_utils_get_reply_all (CamelMimeMessage *message,
const gchar *posthdr = NULL;
GHashTable *rcpt_hash;
+ g_return_if_fail (E_IS_SOURCE_REGISTRY (registry));
g_return_if_fail (CAMEL_IS_MIME_MESSAGE (message));
g_return_if_fail (CAMEL_IS_INTERNET_ADDRESS (to));
g_return_if_fail (CAMEL_IS_INTERNET_ADDRESS (cc));
@@ -2382,7 +2473,7 @@ em_utils_get_reply_all (CamelMimeMessage *message,
if (postto != NULL && posthdr != NULL)
camel_address_decode (CAMEL_ADDRESS (postto), posthdr);
- rcpt_hash = generate_recipient_hash ();
+ rcpt_hash = generate_recipient_hash (registry);
reply_to = get_reply_to (message);
to_addrs = camel_mime_message_get_recipients (
@@ -2765,10 +2856,12 @@ em_utils_reply_to_message (EShell *shell,
EMFormat *source_formatter,
CamelInternetAddress *address)
{
+ ESourceRegistry *registry;
CamelInternetAddress *to, *cc;
CamelNNTPAddress *postto = NULL;
EMsgComposer *composer;
- EAccount *account;
+ ESource *source;
+ const gchar *identity_uid = NULL;
guint32 flags;
g_return_val_if_fail (E_IS_SHELL (shell), NULL);
@@ -2777,7 +2870,11 @@ em_utils_reply_to_message (EShell *shell,
to = camel_internet_address_new ();
cc = camel_internet_address_new ();
- account = em_utils_guess_account_with_recipients (message, folder);
+ registry = e_shell_get_registry (shell);
+ source = em_utils_guess_mail_identity_with_recipients (
+ registry, message, folder);
+ if (source != NULL)
+ identity_uid = e_source_get_uid (source);
flags = CAMEL_MESSAGE_ANSWERED | CAMEL_MESSAGE_SEEN;
switch (type) {
@@ -2809,12 +2906,12 @@ em_utils_reply_to_message (EShell *shell,
if (folder)
postto = camel_nntp_address_new ();
- em_utils_get_reply_all (message, to, cc, postto);
+ em_utils_get_reply_all (registry, message, to, cc, postto);
break;
}
composer = reply_get_composer (
- shell, message, account, to, cc, folder, postto);
+ shell, message, identity_uid, to, cc, folder, postto);
e_msg_composer_add_message_attachments (composer, message, TRUE);
if (postto)
@@ -2926,7 +3023,7 @@ em_configure_new_composer (EMsgComposer *composer,
g_signal_connect (
composer, "presend",
- G_CALLBACK (composer_presend_check_account), session);
+ G_CALLBACK (composer_presend_check_identity), session);
g_signal_connect (
composer, "presend",
diff --git a/mail/em-composer-utils.h b/mail/em-composer-utils.h
index 5b3d3a4..c4c1bad 100644
--- a/mail/em-composer-utils.h
+++ b/mail/em-composer-utils.h
@@ -65,7 +65,8 @@ gboolean em_utils_is_munged_list_message (CamelMimeMessage *message);
void em_utils_get_reply_sender (CamelMimeMessage *message,
CamelInternetAddress *to,
CamelNNTPAddress *postto);
-void em_utils_get_reply_all (CamelMimeMessage *message,
+void em_utils_get_reply_all (ESourceRegistry *registry,
+ CamelMimeMessage *message,
CamelInternetAddress *to,
CamelInternetAddress *cc,
CamelNNTPAddress *postto);
diff --git a/mail/em-filter-source-element.c b/mail/em-filter-source-element.c
index 5848f93..0f9a625 100644
--- a/mail/em-filter-source-element.c
+++ b/mail/em-filter-source-element.c
@@ -32,23 +32,18 @@
#include <gtk/gtk.h>
#include <camel/camel.h>
+#include <libedataserver/e-source-mail-account.h>
+#include <libedataserver/e-source-mail-identity.h>
+
+#include <shell/e-shell.h>
#include <filter/e-filter-part.h>
-#include <libemail-utils/e-account-utils.h>
#define EM_FILTER_SOURCE_ELEMENT_GET_PRIVATE(obj) \
(G_TYPE_INSTANCE_GET_PRIVATE \
((obj), EM_TYPE_FILTER_SOURCE_ELEMENT, EMFilterSourceElementPrivate))
-typedef struct _SourceInfo {
- gchar *account_name;
- gchar *name;
- gchar *address;
- gchar *uid;
-} SourceInfo;
-
struct _EMFilterSourceElementPrivate {
EMailSession *session;
- GList *sources;
gchar *active_id;
};
@@ -63,16 +58,6 @@ enum {
};
static void
-source_info_free (SourceInfo *info)
-{
- g_free (info->account_name);
- g_free (info->name);
- g_free (info->address);
- g_free (info->uid);
- g_free (info);
-}
-
-static void
filter_source_element_source_changed (GtkComboBox *combo_box,
EMFilterSourceElement *fs)
{
@@ -85,52 +70,6 @@ filter_source_element_source_changed (GtkComboBox *combo_box,
}
static void
-filter_source_element_add_source (EMFilterSourceElement *fs,
- const gchar *account_name,
- const gchar *name,
- const gchar *addr,
- const gchar *uid)
-{
- SourceInfo *info;
-
- g_return_if_fail (EM_IS_FILTER_SOURCE_ELEMENT (fs));
-
- info = g_new0 (SourceInfo, 1);
- info->account_name = g_strdup (account_name);
- info->name = g_strdup (name);
- info->address = g_strdup (addr);
- info->uid = g_strdup (uid);
-
- fs->priv->sources = g_list_append (fs->priv->sources, info);
-}
-
-static void
-filter_source_element_get_sources (EMFilterSourceElement *fs)
-{
- EAccountList *accounts;
- const EAccount *account;
- EIterator *it;
-
- /* should this get the global object from mail? */
- accounts = e_get_account_list ();
-
- for (it = e_list_get_iterator ((EList *) accounts);
- e_iterator_is_valid (it);
- e_iterator_next (it)) {
- account = (const EAccount *) e_iterator_get (it);
-
- if (account->source == NULL)
- continue;
-
- filter_source_element_add_source (
- fs, account->name, account->id->name,
- account->id->address, account->uid);
- }
-
- g_object_unref (it);
-}
-
-static void
filter_source_element_set_session (EMFilterSourceElement *element,
EMailSession *session)
{
@@ -198,8 +137,6 @@ filter_source_element_finalize (GObject *object)
priv = EM_FILTER_SOURCE_ELEMENT_GET_PRIVATE (object);
- g_list_foreach (priv->sources, (GFunc) source_info_free, NULL);
- g_list_free (priv->sources);
g_free (priv->active_id);
/* Chain up to parent's finalize() method. */
@@ -305,7 +242,6 @@ filter_source_element_clone (EFilterElement *fe)
EMFilterSourceElement *fs = (EMFilterSourceElement *) fe;
EMFilterSourceElement *cpy;
EMailSession *session;
- GList *i;
session = em_filter_source_element_get_session (fs);
cpy = (EMFilterSourceElement *) em_filter_source_element_new (session);
@@ -313,13 +249,6 @@ filter_source_element_clone (EFilterElement *fe)
cpy->priv->active_id = g_strdup (fs->priv->active_id);
- for (i = fs->priv->sources; i != NULL; i = g_list_next (i)) {
- SourceInfo *info = (SourceInfo *) i->data;
- filter_source_element_add_source (
- cpy, info->account_name, info->name,
- info->address, info->uid);
- }
-
return (EFilterElement *) cpy;
}
@@ -327,29 +256,39 @@ static GtkWidget *
filter_source_element_get_widget (EFilterElement *fe)
{
EMFilterSourceElement *fs = (EMFilterSourceElement *) fe;
+ EMailSession *session;
+ ESourceRegistry *registry;
+ GList *list, *link;
GtkWidget *widget;
GtkComboBox *combo_box;
- GList *i;
-
- if (fs->priv->sources == NULL)
- filter_source_element_get_sources (fs);
+ const gchar *extension_name;
widget = gtk_combo_box_text_new ();
combo_box = GTK_COMBO_BOX (widget);
- for (i = fs->priv->sources; i != NULL; i = g_list_next (i)) {
- SourceInfo *info = (SourceInfo *) i->data;
+ session = em_filter_source_element_get_session (fs);
+ registry = e_mail_session_get_registry (session);
+
+ extension_name = E_SOURCE_EXTENSION_MAIL_ACCOUNT;
+ list = e_source_registry_list_sources (registry, extension_name);
+
+ for (link = list; link != NULL; link = g_list_next (link)) {
+ ESource *source = E_SOURCE (link->data);
+ ESourceMailIdentity *extension;
const gchar *display_name;
const gchar *address;
const gchar *name;
const gchar *uid;
gchar *label;
- uid = info->uid;
- display_name = info->account_name;
+ uid = e_source_get_uid (source);
+ display_name = e_source_get_display_name (source);
- name = info->name;
- address = info->address;
+ extension_name = E_SOURCE_EXTENSION_MAIL_IDENTITY;
+ extension = e_source_get_extension (source, extension_name);
+
+ name = e_source_mail_identity_get_name (extension);
+ address = e_source_mail_identity_get_address (extension);
if (g_strcmp0 (display_name, address) == 0)
label = g_strdup_printf (
@@ -365,6 +304,8 @@ filter_source_element_get_widget (EFilterElement *fe)
g_free (label);
}
+ g_list_free (link);
+
if (fs->priv->active_id != NULL) {
gtk_combo_box_set_active_id (combo_box, fs->priv->active_id);
} else {
diff --git a/mail/em-folder-tree-model.c b/mail/em-folder-tree-model.c
index 623fd55..9ade232 100644
--- a/mail/em-folder-tree-model.c
+++ b/mail/em-folder-tree-model.c
@@ -36,10 +36,14 @@
#include <glib/gi18n.h>
+#include <libedataserver/e-source-mail-account.h>
+#include <libedataserver/e-source-mail-composition.h>
+#include <libedataserver/e-source-mail-identity.h>
+#include <libedataserver/e-source-mail-submission.h>
+
#include <e-util/e-util.h>
#include <shell/e-shell.h>
-#include <libemail-utils/e-account-utils.h>
#include <libemail-utils/mail-mt.h>
#include <libemail-engine/e-mail-folder-utils.h>
@@ -627,8 +631,9 @@ em_folder_tree_model_set_folder_info (EMFolderTreeModel *model,
GtkTreeRowReference *uri_row, *path_row;
GtkTreeStore *tree_store;
MailFolderCache *folder_cache;
+ ESourceRegistry *registry;
EMailSession *session;
- EAccount *account;
+ ESource *source;
guint unread;
GtkTreePath *path;
GtkTreeIter sub;
@@ -654,10 +659,11 @@ em_folder_tree_model_set_folder_info (EMFolderTreeModel *model,
session = em_folder_tree_model_get_session (model);
folder_cache = e_mail_session_get_folder_cache (session);
+ registry = e_mail_session_get_registry (session);
uid = camel_service_get_uid (CAMEL_SERVICE (si->store));
+ source = e_source_registry_lookup_by_uid (registry, uid);
store_is_local = (g_strcmp0 (uid, E_MAIL_SESSION_LOCAL_UID) == 0);
- account = e_get_account_by_uid (uid);
if (!fully_loaded)
load = (fi->child == NULL) && !(fi->flags &
@@ -684,8 +690,8 @@ em_folder_tree_model_set_folder_info (EMFolderTreeModel *model,
unread = fi->unread;
if (mail_folder_cache_get_folder_from_uri (
folder_cache, uri, &folder) && folder) {
- folder_is_drafts = em_utils_folder_is_drafts (folder);
- folder_is_outbox = em_utils_folder_is_outbox (folder);
+ folder_is_drafts = em_utils_folder_is_drafts (registry, folder);
+ folder_is_outbox = em_utils_folder_is_outbox (registry, folder);
if (folder_is_drafts || folder_is_outbox) {
gint total;
@@ -728,17 +734,43 @@ em_folder_tree_model_set_folder_info (EMFolderTreeModel *model,
}
}
- if (account != NULL && (flags & CAMEL_FOLDER_TYPE_MASK) == 0) {
- if (!folder_is_drafts && account->drafts_folder_uri != NULL) {
+ if (source != NULL && (flags & CAMEL_FOLDER_TYPE_MASK) == 0) {
+ ESource *identity;
+ ESourceExtension *extension;
+ const gchar *extension_name;
+ const gchar *drafts_folder_uri;
+ const gchar *sent_folder_uri;
+
+ extension_name = E_SOURCE_EXTENSION_MAIL_ACCOUNT;
+ extension = e_source_get_extension (source, extension_name);
+
+ identity = e_source_mail_account_get_identity (
+ E_SOURCE_MAIL_ACCOUNT (extension));
+
+ extension_name = E_SOURCE_EXTENSION_MAIL_COMPOSITION;
+ extension = e_source_get_extension (identity, extension_name);
+
+ drafts_folder_uri =
+ e_source_mail_composition_get_drafts_folder (
+ E_SOURCE_MAIL_COMPOSITION (extension));
+
+ extension_name = E_SOURCE_EXTENSION_MAIL_SUBMISSION;
+ extension = e_source_get_extension (identity, extension_name);
+
+ sent_folder_uri =
+ e_source_mail_submission_get_sent_folder (
+ E_SOURCE_MAIL_SUBMISSION (extension));
+
+ if (!folder_is_drafts && drafts_folder_uri != NULL) {
folder_is_drafts = e_mail_folder_uri_equal (
- CAMEL_SESSION (session), uri,
- account->drafts_folder_uri);
+ CAMEL_SESSION (session),
+ uri, drafts_folder_uri);
}
- if (account->sent_folder_uri != NULL) {
+ if (sent_folder_uri != NULL) {
if (e_mail_folder_uri_equal (
- CAMEL_SESSION (session), uri,
- account->sent_folder_uri)) {
+ CAMEL_SESSION (session),
+ uri, sent_folder_uri)) {
add_flags = CAMEL_FOLDER_TYPE_SENT;
}
}
diff --git a/mail/em-format-html.c b/mail/em-format-html.c
index 3c130e6..bc9ddf0 100644
--- a/mail/em-format-html.c
+++ b/mail/em-format-html.c
@@ -1594,6 +1594,8 @@ static void
emfh_gethttp (struct _EMFormatHTMLJob *job,
GCancellable *cancellable)
{
+ CamelSession *session;
+ ESourceRegistry *registry;
CamelStream *cistream = NULL, *costream = NULL, *instream = NULL;
CamelURL *url;
CamelHttpStream *tmp_stream;
@@ -1605,20 +1607,27 @@ emfh_gethttp (struct _EMFormatHTMLJob *job,
|| (url = camel_url_new (job->u.uri, NULL)) == NULL)
goto badurl;
+ session = EM_FORMAT (job->format)->session;
+ registry = e_mail_session_get_registry (E_MAIL_SESSION (session));
+
d(printf(" running load uri task: %s\n", job->u.uri));
if (emfh_http_cache)
instream = cistream = camel_data_cache_get (emfh_http_cache, EMFH_HTTP_CACHE_PATH, job->u.uri, NULL);
if (instream == NULL) {
+ CamelMimeMessage *message;
+ CamelInternetAddress *address;
EMailImageLoadingPolicy policy;
+ message = job->format->parent.message;
+ address = camel_mime_message_get_from (message);
policy = em_format_html_get_image_loading_policy (job->format);
if (!(job->format->priv->load_images_now
|| policy == E_MAIL_IMAGE_LOADING_POLICY_ALWAYS
|| (policy == E_MAIL_IMAGE_LOADING_POLICY_SOMETIMES
- && em_utils_in_addressbook ((CamelInternetAddress *) camel_mime_message_get_from (job->format->parent.message), FALSE)))) {
+ && em_utils_in_addressbook (registry, address, FALSE)))) {
/* TODO: Ideally we would put the http requests into
* another queue and only send them out if the user
* selects 'load images', when they do. The problem
@@ -1629,7 +1638,7 @@ emfh_gethttp (struct _EMFormatHTMLJob *job,
goto done;
}
- instream = camel_http_stream_new (CAMEL_HTTP_METHOD_GET, ((EMFormat *) job->format)->session, url);
+ instream = camel_http_stream_new (CAMEL_HTTP_METHOD_GET, session, url);
camel_http_stream_set_user_agent((CamelHttpStream *) instream, "CamelHttpStream/1.0 Evolution/" VERSION);
emfh_configure_stream_for_proxy ((CamelHttpStream *) instream, job->u.uri);
@@ -2954,6 +2963,8 @@ efh_format_headers (EMFormatHTML *efh,
CamelMedium *part,
GCancellable *cancellable)
{
+ CamelSession *session;
+ ESourceRegistry *registry;
EMFormat *emf = (EMFormat *) efh;
const gchar *charset;
CamelContentType *ct;
@@ -2972,6 +2983,9 @@ efh_format_headers (EMFormatHTML *efh,
if (!part)
return;
+ session = EM_FORMAT (efh)->session;
+ registry = e_mail_session_get_registry (E_MAIL_SESSION (session));
+
ct = camel_mime_part_get_content_type ((CamelMimePart *) part);
charset = camel_content_type_param (ct, "charset");
charset = camel_iconv_charset_name (charset);
@@ -3249,7 +3263,8 @@ efh_format_headers (EMFormatHTML *efh,
cia = camel_internet_address_new ();
camel_address_decode ((CamelAddress *) cia, (const gchar *) photo_name);
only_local_photo = em_format_html_get_only_local_photos (efh);
- photopart = em_utils_contact_photo (cia, only_local_photo);
+ photopart = em_utils_contact_photo (
+ registry, cia, only_local_photo);
if (photopart) {
contact_has_photo = TRUE;
diff --git a/mail/em-subscription-editor.c b/mail/em-subscription-editor.c
index f695a88..438d8ef 100644
--- a/mail/em-subscription-editor.c
+++ b/mail/em-subscription-editor.c
@@ -25,7 +25,6 @@
#include <string.h>
#include <glib/gi18n-lib.h>
-#include <libemail-utils/e-account-utils.h>
#include <libemail-utils/mail-mt.h>
#include <libemail-engine/mail-tools.h>
#include <libemail-engine/mail-ops.h>
@@ -1555,16 +1554,19 @@ subscription_editor_constructed (GObject *object)
/* Pick an initial store based on the default mail account, if
* one wasn't already given in em_subscription_editor_new(). */
if (editor->priv->initial_store == NULL) {
- EAccount *account;
+ ESource *source;
+ ESourceRegistry *registry;
CamelService *service;
EMailSession *session;
- account = e_get_default_account ();
-
session = em_subscription_editor_get_session (editor);
+ registry = e_mail_session_get_registry (session);
+
+ source = e_source_registry_get_default_mail_account (registry);
service = camel_session_get_service (
- CAMEL_SESSION (session), account->uid);
+ CAMEL_SESSION (session),
+ e_source_get_uid (source));
if (CAMEL_IS_SUBSCRIBABLE (service))
editor->priv->initial_store = g_object_ref (service);
diff --git a/mail/em-utils.c b/mail/em-utils.c
index 4d74b80..980d919 100644
--- a/mail/em-utils.c
+++ b/mail/em-utils.c
@@ -52,6 +52,15 @@
#include <libedataserver/e-data-server-util.h>
#include <libedataserver/e-flag.h>
#include <libedataserver/e-proxy.h>
+#include <libedataserver/e-source-address-book.h>
+#include <libedataserver/e-source-autocomplete.h>
+#include <libedataserver/e-source-mail-account.h>
+#include <libedataserver/e-source-mail-composition.h>
+#include <libedataserver/e-source-mail-identity.h>
+#include <libedataserver/e-source-mail-submission.h>
+#include <libedataserver/e-data-server-util.h>
+#include <libedataserver/e-flag.h>
+#include <libedataserver/e-proxy.h>
#include <e-util/e-util.h>
#include <e-util/e-util-private.h>
@@ -62,7 +71,6 @@
#include <shell/e-shell.h>
#include <widgets/misc/e-attachment.h>
-#include <libemail-utils/e-account-utils.h>
#include <libemail-utils/mail-mt.h>
#include <libemail-engine/e-mail-folder-utils.h>
@@ -1217,10 +1225,13 @@ void
em_utils_empty_trash (GtkWidget *parent,
EMailSession *session)
{
+ ESourceRegistry *registry;
GList *list, *link;
g_return_if_fail (E_IS_MAIL_SESSION (session));
+ registry = e_mail_session_get_registry (session);
+
if (!em_utils_prompt_user ((GtkWindow *) parent,
"prompt-on-empty-trash",
"mail:ask-empty-trash", NULL))
@@ -1229,9 +1240,9 @@ em_utils_empty_trash (GtkWidget *parent,
list = camel_session_list_services (CAMEL_SESSION (session));
for (link = list; link != NULL; link = g_list_next (link)) {
- EAccount *account;
CamelProvider *provider;
CamelService *service;
+ ESource *source;
const gchar *uid;
service = CAMEL_SERVICE (link->data);
@@ -1244,14 +1255,10 @@ em_utils_empty_trash (GtkWidget *parent,
if ((provider->flags & CAMEL_PROVIDER_IS_STORAGE) == 0)
continue;
- account = e_get_account_by_uid (uid);
+ source = e_source_registry_lookup_by_uid (registry, uid);
- /* The local store has no corresponding
- * EAccount, so skip the enabled check. */
- if (account != NULL) {
- if (!account->enabled)
- continue;
- }
+ if (source != NULL && !e_source_get_enabled (source))
+ continue;
mail_empty_trash (CAMEL_STORE (service));
}
@@ -1261,29 +1268,6 @@ em_utils_empty_trash (GtkWidget *parent,
/* ********************************************************************** */
-void
-em_utils_clear_get_password_canceled_accounts_flag (void)
-{
- EAccountList *account_list;
- EIterator *iterator;
-
- account_list = e_get_account_list ();
-
- for (iterator = e_list_get_iterator (E_LIST (account_list));
- e_iterator_is_valid (iterator);
- e_iterator_next (iterator)) {
- EAccount *account = (EAccount *) e_iterator_get (iterator);
-
- if (account && account->source)
- account->source->get_password_canceled = FALSE;
-
- if (account && account->transport)
- account->transport->get_password_canceled = FALSE;
- }
-
- g_object_unref (iterator);
-}
-
gchar *
em_utils_url_unescape_amp (const gchar *url)
{
diff --git a/mail/em-utils.h b/mail/em-utils.h
index 09ae4a5..4fe0277 100644
--- a/mail/em-utils.h
+++ b/mail/em-utils.h
@@ -27,7 +27,6 @@
#include <sys/types.h>
#include <camel/camel.h>
#include <libedataserver/e-proxy.h>
-#include <libedataserver/e-account.h>
#include <libemail-engine/e-mail-session.h>
#include <libemail-engine/e-mail-utils.h>
@@ -73,14 +72,9 @@ gchar *em_utils_message_to_html (CamelMimeMessage *msg, const gchar *credits, gu
void em_utils_empty_trash (GtkWidget *parent,
EMailSession *session);
-/* clears flag 'get_password_canceled' at every known accounts, so if needed, get_password will show dialog */
-void em_utils_clear_get_password_canceled_accounts_flag (void);
-
/* Unescapes & back to a real & in URIs */
gchar *em_utils_url_unescape_amp (const gchar *url);
-void emu_free_mail_account_sort_order_cache (void);
-
void emu_restore_folder_tree_state (EMFolderTree *folder_tree);
gboolean em_utils_is_re_in_subject (struct _EShell *shell,
diff --git a/mail/mail-config.ui b/mail/mail-config.ui
index 0d906ed..91ed611 100644
--- a/mail/mail-config.ui
+++ b/mail/mail-config.ui
@@ -845,56 +845,6 @@ for display purposes only. </property>
<property name="position">0</property>
</packing>
</child>
- <child>
- <object class="GtkVBox" id="signature-preview-section">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="spacing">6</property>
- <child>
- <object class="GtkLabel" id="signature-preview-header">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="xalign">0</property>
- <property name="label" translatable="yes">Preview</property>
- <attributes>
- <attribute name="weight" value="bold"/>
- </attributes>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- <property name="position">0</property>
- </packing>
- </child>
- <child>
- <object class="GtkAlignment" id="signature-preview-alignment">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="left_padding">12</property>
- <child>
- <object class="GtkScrolledWindow" id="signature-preview-scrolled-window">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="shadow_type">in</property>
- <child>
- <placeholder/>
- </child>
- </object>
- </child>
- </object>
- <packing>
- <property name="expand">True</property>
- <property name="fill">True</property>
- <property name="position">1</property>
- </packing>
- </child>
- </object>
- <packing>
- <property name="expand">True</property>
- <property name="fill">True</property>
- <property name="position">1</property>
- </packing>
- </child>
</object>
<packing>
<property name="position">1</property>
diff --git a/mail/mail-send-recv.c b/mail/mail-send-recv.c
index 9cfbb86..6b93cf2 100644
--- a/mail/mail-send-recv.c
+++ b/mail/mail-send-recv.c
@@ -29,12 +29,12 @@
#include <glib/gi18n.h>
-#include <libedataserver/e-account-list.h>
+#include <libedataserver/e-source-mail-account.h>
+#include <libedataserver/e-source-mail-submission.h>
#include <shell/e-shell.h>
#include <e-util/e-util.h>
-#include <libemail-utils/e-account-utils.h>
#include <libemail-utils/mail-mt.h>
/* This is our hack, not part of libcamel. */
@@ -489,7 +489,7 @@ static struct _send_data *
build_dialog (GtkWindow *parent,
EMailSession *session,
CamelFolder *outbox,
- EAccount *outgoing_account,
+ CamelService *transport,
gboolean allow_send)
{
GtkDialog *gd;
@@ -506,7 +506,6 @@ build_dialog (GtkWindow *parent,
GtkWidget *progress_bar;
GtkWidget *cancel_button;
EMailAccountStore *account_store;
- CamelService *transport = NULL;
struct _send_info *info;
gchar *pretty_url;
EMEventTargetSendReceive *target;
@@ -514,17 +513,6 @@ build_dialog (GtkWindow *parent,
account_store = e_mail_ui_session_get_account_store (E_MAIL_UI_SESSION (session));
- /* Convert the outgoing account to a CamelTransport. */
- if (outgoing_account != NULL) {
- gchar *transport_uid;
-
- transport_uid = g_strdup_printf (
- "%s-transport", outgoing_account->uid);
- transport = camel_session_get_service (
- CAMEL_SESSION (session), transport_uid);
- g_free (transport_uid);
- }
-
send_recv_dialog = gtk_dialog_new ();
gd = GTK_DIALOG (send_recv_dialog);
@@ -1132,14 +1120,59 @@ receive_update_got_store (CamelStore *store,
}
}
+static CamelService *
+get_default_transport (EMailSession *session)
+{
+ ESource *source;
+ ESourceRegistry *registry;
+ const gchar *extension_name;
+
+ registry = e_mail_session_get_registry (session);
+ source = e_source_registry_get_default_mail_account (registry);
+
+ if (source == NULL)
+ return NULL;
+
+ extension_name = E_SOURCE_EXTENSION_MAIL_ACCOUNT;
+ if (e_source_has_extension (source, extension_name)) {
+ ESourceMailAccount *extension;
+ const gchar *uid;
+
+ extension = e_source_get_extension (source, extension_name);
+ uid = e_source_mail_account_get_identity_uid (extension);
+ source = e_source_registry_lookup_by_uid (registry, uid);
+ } else
+ source = NULL;
+
+ if (source == NULL)
+ return NULL;
+
+ extension_name = E_SOURCE_EXTENSION_MAIL_SUBMISSION;
+ if (e_source_has_extension (source, extension_name)) {
+ ESourceMailSubmission *extension;
+ const gchar *uid;
+
+ extension = e_source_get_extension (source, extension_name);
+ uid = e_source_mail_submission_get_transport_uid (extension);
+ source = e_source_registry_lookup_by_uid (registry, uid);
+ } else
+ source = NULL;
+
+ if (source == NULL)
+ return NULL;
+
+ return camel_session_get_service (
+ CAMEL_SESSION (session), e_source_get_uid (source));
+}
+
static GtkWidget *
send_receive (GtkWindow *parent,
EMailSession *session,
gboolean allow_send)
{
CamelFolder *local_outbox;
+ CamelService *transport;
struct _send_data *data;
- EAccount *account;
GList *scan;
if (send_recv_dialog != NULL) {
@@ -1152,16 +1185,14 @@ send_receive (GtkWindow *parent,
if (!camel_session_get_online (CAMEL_SESSION (session)))
return send_recv_dialog;
- account = e_get_default_account ();
- if (!account || !account->transport->url)
- return send_recv_dialog;
+ transport = get_default_transport (session);
local_outbox =
e_mail_session_get_local_folder (
session, E_MAIL_LOCAL_FOLDER_OUTBOX);
data = build_dialog (
- parent, session, local_outbox, account, allow_send);
+ parent, session, local_outbox, transport, allow_send);
for (scan = data->infos; scan != NULL; scan = scan->next) {
struct _send_info *info = scan->data;
@@ -1173,7 +1204,6 @@ send_receive (GtkWindow *parent,
case SEND_RECEIVE:
mail_fetch_mail (
CAMEL_STORE (info->service),
- info->keep_on_server,
E_FILTER_SOURCE_INCOMING,
info->cancellable,
receive_get_folder, info,
@@ -1217,201 +1247,6 @@ mail_receive (GtkWindow *parent,
return send_receive (parent, session, FALSE);
}
-struct _auto_data {
- EAccount *account;
- EMailSession *session;
- gint period; /* in seconds */
- gint timeout_id;
-};
-
-static GHashTable *auto_active;
-
-static gboolean
-auto_timeout (gpointer data)
-{
- CamelService *service;
- CamelSession *session;
- struct _auto_data *info = data;
-
- session = CAMEL_SESSION (info->session);
-
- service = camel_session_get_service (
- session, info->account->uid);
- g_return_val_if_fail (CAMEL_IS_SERVICE (service), TRUE);
-
- if (camel_session_get_online (session))
- mail_receive_service (service);
-
- return TRUE;
-}
-
-static void
-auto_account_removed (EAccountList *eal,
- EAccount *ea,
- gpointer dummy)
-{
- struct _auto_data *info = g_object_get_data((GObject *)ea, "mail-autoreceive");
-
- g_return_if_fail (info != NULL);
-
- if (info->timeout_id) {
- g_source_remove (info->timeout_id);
- info->timeout_id = 0;
- }
-}
-
-static void
-auto_account_finalized (struct _auto_data *info)
-{
- if (info->session != NULL)
- g_object_unref (info->session);
- if (info->timeout_id)
- g_source_remove (info->timeout_id);
- g_free (info);
-}
-
-static void
-auto_account_commit (struct _auto_data *info)
-{
- gint period, check;
-
- check = info->account->enabled
- && e_account_get_bool (info->account, E_ACCOUNT_SOURCE_AUTO_CHECK)
- && e_account_get_string (info->account, E_ACCOUNT_SOURCE_URL);
- period = e_account_get_int (info->account, E_ACCOUNT_SOURCE_AUTO_CHECK_TIME) * 60;
- period = MAX (60, period);
-
- if (info->timeout_id
- && (!check
- || period != info->period)) {
- g_source_remove (info->timeout_id);
- info->timeout_id = 0;
- }
- info->period = period;
- if (check && info->timeout_id == 0)
- info->timeout_id = g_timeout_add_seconds (info->period, auto_timeout, info);
-}
-
-static void
-auto_account_added (EAccountList *eal,
- EAccount *ea,
- EMailSession *session)
-{
- struct _auto_data *info;
-
- info = g_malloc0 (sizeof (*info));
- info->account = ea;
- info->session = g_object_ref (session);
- g_object_set_data_full (
- G_OBJECT (ea), "mail-autoreceive", info,
- (GDestroyNotify) auto_account_finalized);
- auto_account_commit (info);
-}
-
-static void
-auto_account_changed (EAccountList *eal,
- EAccount *ea,
- gpointer dummy)
-{
- struct _auto_data *info;
-
- info = g_object_get_data (G_OBJECT (ea), "mail-autoreceive");
-
- if (info != NULL)
- auto_account_commit (info);
-}
-
-static void
-auto_online (EShell *shell)
-{
- EIterator *iter;
- EAccountList *accounts;
- EShellSettings *shell_settings;
- struct _auto_data *info;
- gboolean can_update_all;
-
- if (!e_shell_get_online (shell))
- return;
-
- shell_settings = e_shell_get_shell_settings (shell);
-
- can_update_all =
- e_shell_settings_get_boolean (
- shell_settings, "mail-check-on-start") &&
- e_shell_settings_get_boolean (
- shell_settings, "mail-check-all-on-start");
-
- accounts = e_get_account_list ();
- for (iter = e_list_get_iterator ((EList *) accounts);
- e_iterator_is_valid (iter);
- e_iterator_next (iter)) {
- EAccount *account = (EAccount *) e_iterator_get (iter);
-
- if (!account || !account->enabled)
- continue;
-
- info = g_object_get_data (
- G_OBJECT (account), "mail-autoreceive");
- if (info && (info->timeout_id || can_update_all))
- auto_timeout (info);
- }
-
- if (iter)
- g_object_unref (iter);
-}
-
-/* call to setup initial, and after changes are made to the config */
-/* FIXME: Need a cleanup funciton for when object is deactivated */
-void
-mail_autoreceive_init (EMailSession *session)
-{
- EShell *shell;
- EShellSettings *shell_settings;
- EAccountList *accounts;
- EIterator *iter;
-
- g_return_if_fail (E_IS_MAIL_SESSION (session));
-
- if (auto_active)
- return;
-
- accounts = e_get_account_list ();
- auto_active = g_hash_table_new (g_str_hash, g_str_equal);
-
- g_signal_connect (
- accounts, "account-added",
- G_CALLBACK (auto_account_added), session);
- g_signal_connect (
- accounts, "account-removed",
- G_CALLBACK (auto_account_removed), NULL);
- g_signal_connect (
- accounts, "account-changed",
- G_CALLBACK (auto_account_changed), NULL);
-
- for (iter = e_list_get_iterator ((EList *) accounts);
- e_iterator_is_valid (iter);
- e_iterator_next (iter))
- auto_account_added (
- accounts, (EAccount *)
- e_iterator_get (iter), session);
-
- shell = e_shell_get_default ();
- shell_settings = e_shell_get_shell_settings (shell);
-
- if (e_shell_settings_get_boolean (
- shell_settings, "mail-check-on-start")) {
- auto_online (shell);
-
- /* also flush outbox on start */
- if (e_shell_get_online (shell))
- mail_send (session);
- }
-
- g_signal_connect (
- shell, "notify::online",
- G_CALLBACK (auto_online), NULL);
-}
-
/* We setup the download info's in a hashtable, if we later
* need to build the gui, we insert them in to add them. */
void
@@ -1465,7 +1300,6 @@ mail_receive_service (CamelService *service)
case SEND_RECEIVE:
mail_fetch_mail (
CAMEL_STORE (service),
- info->keep_on_server,
E_FILTER_SOURCE_INCOMING,
info->cancellable,
receive_get_folder, info,
@@ -1501,17 +1335,14 @@ mail_send (EMailSession *session)
{
CamelFolder *local_outbox;
CamelService *service;
- EAccount *account;
struct _send_info *info;
struct _send_data *data;
send_info_t type = SEND_INVALID;
- gchar *transport_uid;
g_return_if_fail (E_IS_MAIL_SESSION (session));
- account = e_get_default_transport ();
- if (account == NULL || account->transport->url == NULL)
- return;
+ service = get_default_transport (session);
+ g_return_if_fail (CAMEL_IS_TRANSPORT (service));
data = setup_send_data (session);
info = g_hash_table_lookup (data->active, SEND_URI_KEY);
@@ -1521,24 +1352,12 @@ mail_send (EMailSession *session)
return;
}
- transport_uid = g_strconcat (account->uid, "-transport", NULL);
-
- service = camel_session_get_service (
- CAMEL_SESSION (session), transport_uid);
-
- if (!CAMEL_IS_TRANSPORT (service)) {
- g_free (transport_uid);
- return;
- }
-
d(printf("starting non-interactive send of '%s'\n", transport->url));
type = get_receive_type (service);
- if (type == SEND_INVALID) {
- g_free (transport_uid);
+ if (type == SEND_INVALID)
return;
- }
info = g_malloc0 (sizeof (*info));
info->type = SEND_SEND;
@@ -1562,10 +1381,6 @@ mail_send (EMailSession *session)
e_mail_session_get_local_folder (
session, E_MAIL_LOCAL_FOLDER_OUTBOX);
- g_free (transport_uid);
-
- g_return_if_fail (CAMEL_IS_TRANSPORT (service));
-
mail_send_queue (
session, local_outbox,
CAMEL_TRANSPORT (service),
diff --git a/mail/mail.error.xml b/mail/mail.error.xml
index 118acc1..9fa1b92 100644
--- a/mail/mail.error.xml
+++ b/mail/mail.error.xml
@@ -300,24 +300,6 @@ all proxy information will be deleted permanently.</_secondary>
<button _label="_Disable" response="GTK_RESPONSE_YES"/>
</error>
- <error id="no-save-signature" type="error">
- <_primary>Could not save signature file.</_primary>
- <secondary xml:space="preserve">{0}.</secondary>
- </error>
-
- <error id="signature-notscript" type="error">
- <_primary>Cannot set signature script "{0}".</_primary>
- <_secondary xml:space="preserve">The script file must exist and be executable.</_secondary>
- </error>
-
- <error id="ask-signature-changed" type="question" default="GTK_RESPONSE_YES">
- <_primary>Do you wish to save your changes?</_primary>
- <_secondary xml:space="preserve">This signature has been changed, but has not been saved.</_secondary>
- <button _label="_Discard changes" response="GTK_RESPONSE_NO"/>
- <button stock="gtk-cancel" response="GTK_RESPONSE_CANCEL"/>
- <button stock="gtk-save" response="GTK_RESPONSE_YES"/>
- </error>
-
<error id="vfolder-notexist" type="error">
<_primary>Cannot edit Search Folder "{0}" as it does not exist.</_primary>
<_secondary xml:space="preserve">This folder may have been added implicitly,
@@ -426,16 +408,6 @@ An mbox account will be created to preserve the old mbox folders. You can delete
<button _label="N_ever" response="GTK_RESPONSE_CANCEL"/>
</error>
- <error id="signature-already-exists" type="error" modal="true">
- <_primary>Signature Already Exists</_primary>
- <_secondary>A signature already exists with the name "{0}". Please specify a different name. </_secondary>
- </error>
-
- <error id="blank-signature" type="error" modal="true">
- <_primary>Blank Signature</_primary>
- <_secondary>Please provide an unique name to identify this signature.</_secondary>
- </error>
-
<error id="send-no-account-enabled" type="warning">
<_primary>This message cannot be sent because the account you chose to send with is not enabled</_primary>
<_secondary xml:space="preserve">Please enable the account or send using another account.</_secondary>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]