Commit 06475e45 authored by Milan Crha's avatar Milan Crha
Browse files

Bug 772572 - Allow creating Receive-only mail accounts

parent fdbd5810
......@@ -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);
......
......@@ -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);
......
......@@ -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);
}
......@@ -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 */
......@@ -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
......
......@@ -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));
......
......@@ -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);
......
......@@ -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;
}
......
......@@ -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
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment