[evolution] Bug 772572 - Allow creating Receive-only mail accounts
- From: Milan Crha <mcrha src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution] Bug 772572 - Allow creating Receive-only mail accounts
- Date: Wed, 28 Jun 2017 11:50:11 +0000 (UTC)
commit 06475e45b318a9905e6cb359519e6aeb2ab1f62b
Author: Milan Crha <mcrha redhat com>
Date: Wed Jun 28 13:49:45 2017 +0200
Bug 772572 - Allow creating Receive-only mail accounts
src/calendar/gui/itip-utils.c | 4 +
src/e-util/e-mail-identity-combo-box.c | 7 ++
src/libemail-engine/camel-null-store.c | 31 +++++++--
src/libemail-engine/camel-null-store.h | 36 +++++++++++
src/mail/e-mail-account-store.c | 64 ++++++++++++++++++++
src/mail/e-mail-config-assistant.c | 3 +-
src/mail/e-mail-config-notebook.c | 28 +++++++--
src/mail/e-mail-config-summary-page.c | 16 +++++
.../mail-config/e-mail-config-local-accounts.c | 7 ++
9 files changed, 183 insertions(+), 13 deletions(-)
---
diff --git a/src/calendar/gui/itip-utils.c b/src/calendar/gui/itip-utils.c
index d808a3c..9cc496d 100644
--- a/src/calendar/gui/itip-utils.c
+++ b/src/calendar/gui/itip-utils.c
@@ -27,6 +27,7 @@
#include <libsoup/soup.h>
#include <composer/e-msg-composer.h>
+#include <libedataserver/libedataserver.h>
#include "calendar-config.h"
#include "comp-util.h"
@@ -176,6 +177,9 @@ itip_get_user_identities (ESourceRegistry *registry)
const gchar *name, *address;
gchar *aliases;
+ if (!e_util_identity_can_send (registry, source))
+ continue;
+
extension = e_source_get_extension (source, extension_name);
name = e_source_mail_identity_get_name (extension);
diff --git a/src/e-util/e-mail-identity-combo-box.c b/src/e-util/e-mail-identity-combo-box.c
index 3bbccfc..3715f85 100644
--- a/src/e-util/e-mail-identity-combo-box.c
+++ b/src/e-util/e-mail-identity-combo-box.c
@@ -577,6 +577,10 @@ e_mail_identity_combo_box_refresh (EMailIdentityComboBox *combo_box)
const gchar *address;
source = E_SOURCE (link->data);
+
+ if (!e_util_identity_can_send (registry, source))
+ continue;
+
extension = e_source_get_extension (source, extension_name);
address = e_source_mail_identity_get_address (extension);
@@ -633,6 +637,9 @@ e_mail_identity_combo_box_refresh (EMailIdentityComboBox *combo_box)
source = E_SOURCE (link->data);
+ if (!e_util_identity_can_send (registry, source))
+ continue;
+
uid = e_source_get_uid (source);
display_name = e_source_get_display_name (source);
extension = e_source_get_extension (source, extension_name);
diff --git a/src/libemail-engine/camel-null-store.c b/src/libemail-engine/camel-null-store.c
index 509c934..fa6ad40 100644
--- a/src/libemail-engine/camel-null-store.c
+++ b/src/libemail-engine/camel-null-store.c
@@ -22,6 +22,7 @@
#include "camel-null-store.h"
G_DEFINE_TYPE (CamelNullStore, camel_null_store, CAMEL_TYPE_STORE)
+G_DEFINE_TYPE (CamelNullTransport, camel_null_transport, CAMEL_TYPE_TRANSPORT)
static CamelProvider null_provider = {
/* protocol: */ "none",
@@ -65,17 +66,33 @@ camel_null_store_init (CamelNullStore *store)
/* nothing to do */
}
+static void
+camel_null_transport_class_init (CamelNullTransportClass *class)
+{
+ CamelServiceClass *service_class;
+
+ /* We should never be invoking methods on a CamelNullTransport,
+ * but thankfully, in case we do, CamelTransport has NULL function
+ * pointer checks in all of its wrapper functions. So it will
+ * emit a runtime warning, which is what we want, and frees us
+ * from having to override any class methods here. */
+
+ service_class = CAMEL_SERVICE_CLASS (class);
+ service_class->settings_type = CAMEL_TYPE_SETTINGS;
+}
+
+static void
+camel_null_transport_init (CamelNullTransport *transport)
+{
+ /* nothing to do */
+}
+
void
camel_null_store_register_provider (void)
{
- GType object_type;
+ null_provider.object_types[CAMEL_PROVIDER_STORE] = CAMEL_TYPE_NULL_STORE;
- object_type = CAMEL_TYPE_NULL_STORE;
- null_provider.object_types[CAMEL_PROVIDER_STORE] = object_type;
-
- object_type = G_TYPE_INVALID;
- null_provider.object_types[CAMEL_PROVIDER_TRANSPORT] = object_type;
+ null_provider.object_types[CAMEL_PROVIDER_TRANSPORT] = CAMEL_TYPE_NULL_TRANSPORT;
camel_provider_register (&null_provider);
}
-
diff --git a/src/libemail-engine/camel-null-store.h b/src/libemail-engine/camel-null-store.h
index e0fda29..f3826c4 100644
--- a/src/libemail-engine/camel-null-store.h
+++ b/src/libemail-engine/camel-null-store.h
@@ -48,6 +48,24 @@
(G_TYPE_INSTANCE_GET_CLASS \
((obj), CAMEL_TYPE_NULL_STORE, CamelNullStoreClass))
+#define CAMEL_TYPE_NULL_TRANSPORT \
+ (camel_null_transport_get_type ())
+#define CAMEL_NULL_TRANSPORT(obj) \
+ (G_TYPE_CHECK_INSTANCE_CAST \
+ ((obj), CAMEL_TYPE_NULL_STORE, CamelNullTransport))
+#define CAMEL_NULL_TRANSPORT_CLASS(cls) \
+ (G_TYPE_CHECK_CLASS_CAST \
+ ((cls), CAMEL_TYPE_NULL_TRANSPORT, CamelNullTransportClass))
+#define CAMEL_IS_NULL_TRANSPORT(obj) \
+ (G_TYPE_CHECK_INSTANCE_TYPE \
+ ((obj), CAMEL_TYPE_NULL_TRANSPORT))
+#define CAMEL_IS_NULL_TRANSPORT_CLASS(cls) \
+ (G_TYPE_CHECK_CLASS_TYPE \
+ ((cls), CAMEL_TYPE_NULL_TRANSPORT))
+#define CAMEL_NULL_TRANSPORT_GET_CLASS(obj) \
+ (G_TYPE_INSTANCE_GET_CLASS \
+ ((obj), CAMEL_TYPE_NULL_TRANSPORT, CamelNullTransportClass))
+
G_BEGIN_DECLS
typedef struct _CamelNullStore CamelNullStore;
@@ -62,6 +80,24 @@ struct _CamelNullStoreClass {
};
GType camel_null_store_get_type (void);
+
+/* ------------------------------------------------------------------------- */
+
+typedef struct _CamelNullTransport CamelNullTransport;
+typedef struct _CamelNullTransportClass CamelNullTransportClass;
+
+struct _CamelNullTransport {
+ CamelTransport parent;
+};
+
+struct _CamelNullTransportClass {
+ CamelTransportClass parent_class;
+};
+
+GType camel_null_transport_get_type (void);
+
+/* ------------------------------------------------------------------------- */
+
void camel_null_store_register_provider (void);
#endif /* CAMEL_NULL_STORE_H */
diff --git a/src/mail/e-mail-account-store.c b/src/mail/e-mail-account-store.c
index ea84c87..4000944 100644
--- a/src/mail/e-mail-account-store.c
+++ b/src/mail/e-mail-account-store.c
@@ -193,6 +193,7 @@ mail_account_store_update_row (EMailAccountStore *store,
gboolean is_default;
const gchar *backend_name;
const gchar *display_name;
+ gchar *from_transport_backend_name = NULL;
is_default = (service == store->priv->default_service);
display_name = camel_service_get_display_name (service);
@@ -200,12 +201,75 @@ mail_account_store_update_row (EMailAccountStore *store,
provider = camel_service_get_provider (service);
backend_name = (provider != NULL) ? provider->protocol : NULL;
+ if (g_strcmp0 (backend_name, "none") == 0) {
+ ESourceRegistry *registry;
+ ESource *mail_source;
+
+ registry = e_mail_session_get_registry (e_mail_account_store_get_session (store));
+ mail_source = e_source_registry_ref_source (registry, camel_service_get_uid (service));
+
+ if (mail_source &&
+ !e_source_has_extension (mail_source, E_SOURCE_EXTENSION_MAIL_SUBMISSION) &&
+ e_source_has_extension (mail_source, E_SOURCE_EXTENSION_MAIL_ACCOUNT)) {
+ ESourceMailAccount *mail_account;
+ ESource *identity_source = NULL;
+ const gchar *identity_uid;
+
+ mail_account = e_source_get_extension (mail_source, E_SOURCE_EXTENSION_MAIL_ACCOUNT);
+
+ e_source_extension_property_lock (E_SOURCE_EXTENSION (mail_account));
+
+ identity_uid = e_source_mail_account_get_identity_uid (mail_account);
+ if (identity_uid && *identity_uid)
+ identity_source = e_source_registry_ref_source (registry, identity_uid);
+
+ e_source_extension_property_unlock (E_SOURCE_EXTENSION (mail_account));
+
+ g_object_unref (mail_source);
+ mail_source = identity_source;
+ }
+
+ if (mail_source &&
+ e_source_has_extension (mail_source, E_SOURCE_EXTENSION_MAIL_SUBMISSION)) {
+ ESourceMailSubmission *mail_submission;
+ ESource *transport_source = NULL;
+ const gchar *transport_uid;
+
+ mail_submission = e_source_get_extension (mail_source,
E_SOURCE_EXTENSION_MAIL_SUBMISSION);
+
+ e_source_extension_property_lock (E_SOURCE_EXTENSION (mail_submission));
+
+ transport_uid = e_source_mail_submission_get_transport_uid (mail_submission);
+ if (transport_uid && *transport_uid)
+ transport_source = e_source_registry_ref_source (registry, transport_uid);
+
+ e_source_extension_property_unlock (E_SOURCE_EXTENSION (mail_submission));
+
+ if (transport_source && e_source_has_extension (transport_source,
E_SOURCE_EXTENSION_MAIL_TRANSPORT)) {
+ ESourceMailTransport *mail_transport;
+
+ mail_transport = e_source_get_extension (transport_source,
E_SOURCE_EXTENSION_MAIL_TRANSPORT);
+
+ from_transport_backend_name = e_source_backend_dup_backend_name
(E_SOURCE_BACKEND (mail_transport));
+
+ if (from_transport_backend_name && *from_transport_backend_name)
+ backend_name = from_transport_backend_name;
+ }
+
+ g_clear_object (&transport_source);
+ }
+
+ g_clear_object (&mail_source);
+ }
+
gtk_list_store_set (
GTK_LIST_STORE (store), iter,
E_MAIL_ACCOUNT_STORE_COLUMN_DEFAULT, is_default,
E_MAIL_ACCOUNT_STORE_COLUMN_BACKEND_NAME, backend_name,
E_MAIL_ACCOUNT_STORE_COLUMN_DISPLAY_NAME, display_name,
-1);
+
+ g_free (from_transport_backend_name);
}
struct ServiceNotifyCbData
diff --git a/src/mail/e-mail-config-assistant.c b/src/mail/e-mail-config-assistant.c
index c6b0027..7b3f456 100644
--- a/src/mail/e-mail-config-assistant.c
+++ b/src/mail/e-mail-config-assistant.c
@@ -230,7 +230,8 @@ mail_config_assistant_notify_account_backend (EMailConfigServicePage *page,
* receiving type defines both a storage and transport service.
* This is common in CamelProviders for groupware products like
* Microsoft Exchange and Novell GroupWise. */
- if (CAMEL_PROVIDER_IS_STORE_AND_TRANSPORT (provider)) {
+ if (CAMEL_PROVIDER_IS_STORE_AND_TRANSPORT (provider) &&
+ g_strcmp0 (provider->protocol, "none") != 0) {
backend = e_mail_config_service_page_lookup_backend (
sending_page, provider->protocol);
gtk_widget_hide (GTK_WIDGET (sending_page));
diff --git a/src/mail/e-mail-config-notebook.c b/src/mail/e-mail-config-notebook.c
index 6310149..7630bfa 100644
--- a/src/mail/e-mail-config-notebook.c
+++ b/src/mail/e-mail-config-notebook.c
@@ -400,6 +400,13 @@ mail_config_notebook_constructed (GObject *object)
E_MAIL_CONFIG_SERVICE_PAGE (page),
notebook->priv->account_source,
notebook->priv->collection_source);
+
+ if (backend != NULL)
+ provider = e_mail_config_service_backend_get_provider (backend);
+
+ if (add_receiving_page)
+ add_receiving_page = provider && g_strcmp0 (provider->protocol, "none") != 0;
+
if (add_receiving_page) {
e_mail_config_notebook_add_page (notebook, page);
@@ -409,9 +416,6 @@ mail_config_notebook_constructed (GObject *object)
G_BINDING_SYNC_CREATE);
}
- if (backend != NULL)
- provider = e_mail_config_service_backend_get_provider (backend);
-
/*** Receiving Options (conditional) ***/
/* Note: We exclude this page if it has no options,
@@ -427,8 +431,22 @@ mail_config_notebook_constructed (GObject *object)
/*** Sending Page (conditional) ***/
add_transport_source =
- (provider != NULL) &&
- (!CAMEL_PROVIDER_IS_STORE_AND_TRANSPORT (provider));
+ provider != NULL &&
+ !CAMEL_PROVIDER_IS_STORE_AND_TRANSPORT (provider);
+
+ if ((add_transport_source || (provider && g_strcmp0 (provider->protocol, "none") == 0)) &&
+ notebook->priv->transport_source &&
+ e_source_has_extension (notebook->priv->transport_source, E_SOURCE_EXTENSION_MAIL_TRANSPORT)) {
+ ESourceBackend *mail_transport;
+
+ mail_transport = e_source_get_extension (notebook->priv->transport_source,
E_SOURCE_EXTENSION_MAIL_TRANSPORT);
+
+ e_source_extension_property_lock (E_SOURCE_EXTENSION (mail_transport));
+
+ add_transport_source = g_strcmp0 (e_source_backend_get_backend_name (mail_transport), "none")
!= 0;
+
+ e_source_extension_property_unlock (E_SOURCE_EXTENSION (mail_transport));
+ }
if (add_transport_source) {
page = e_mail_config_sending_page_new (registry);
diff --git a/src/mail/e-mail-config-summary-page.c b/src/mail/e-mail-config-summary-page.c
index e02df1b..fb0306d 100644
--- a/src/mail/e-mail-config-summary-page.c
+++ b/src/mail/e-mail-config-summary-page.c
@@ -614,6 +614,8 @@ mail_config_summary_page_refresh (EMailConfigSummaryPage *page)
source,
priv->send_security_label);
}
+
+ e_mail_config_page_changed (E_MAIL_CONFIG_PAGE (page));
}
static gboolean
@@ -635,6 +637,20 @@ mail_config_summary_page_check_complete (EMailConfigPage *page)
e_util_set_entry_issue_hint (GTK_WIDGET (priv->account_name_entry), complete ? NULL : _("Account Name
cannot be empty"));
+ if (complete) {
+ gboolean recv_is_none, send_is_none;
+
+ recv_is_none = gtk_widget_get_visible (GTK_WIDGET (priv->recv_backend_label)) &&
+ g_strcmp0 (gtk_label_get_text (priv->recv_backend_label), "none") == 0;
+
+ send_is_none = gtk_widget_get_visible (GTK_WIDGET (priv->send_backend_label)) &&
+ g_strcmp0 (gtk_label_get_text (priv->send_backend_label), "none") == 0;
+
+ complete = !recv_is_none || !send_is_none;
+
+ e_util_set_entry_issue_hint (GTK_WIDGET (priv->account_name_entry), complete ? NULL :
_("Cannot have both receiving and sending parts set to None"));
+ }
+
return complete;
}
diff --git a/src/modules/mail-config/e-mail-config-local-accounts.c
b/src/modules/mail-config/e-mail-config-local-accounts.c
index bd43107..adc2d96 100644
--- a/src/modules/mail-config/e-mail-config-local-accounts.c
+++ b/src/modules/mail-config/e-mail-config-local-accounts.c
@@ -377,10 +377,17 @@ e_mail_config_spool_file_backend_init (EMailConfigLocalBackend *backend)
{
}
+static gboolean
+e_mail_config_none_backend_get_selectable (EMailConfigServiceBackend *backend)
+{
+ return TRUE;
+}
+
static void
e_mail_config_none_backend_class_init (EMailConfigServiceBackendClass *class)
{
class->backend_name = "none";
+ class->get_selectable = e_mail_config_none_backend_get_selectable;
}
static void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]