[evolution-data-server] Bug 772572 - Allow creating Receive-only mail accounts
- From: Milan Crha <mcrha src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution-data-server] Bug 772572 - Allow creating Receive-only mail accounts
- Date: Wed, 28 Jun 2017 10:41:42 +0000 (UTC)
commit 2c8fdea124b2d9dc5a3bdbeb0579f71558242919
Author: Milan Crha <mcrha redhat com>
Date: Wed Jun 28 12:36:51 2017 +0200
Bug 772572 - Allow creating Receive-only mail accounts
Added a new e_util_identity_can_send() helper function, to check whether
the identity source has defined a transport source and this transport
source is not 'none' backend. It doesn't check whether the identity
or the transport source are enabled, it tests only the transport source
existence and its backend name.
src/libedataserver/e-data-server-util.c | 64 +++++++++++++++++++++++++++++++
src/libedataserver/e-data-server-util.h | 3 +
2 files changed, 67 insertions(+), 0 deletions(-)
---
diff --git a/src/libedataserver/e-data-server-util.c b/src/libedataserver/e-data-server-util.c
index 3bf423b..300b630 100644
--- a/src/libedataserver/e-data-server-util.c
+++ b/src/libedataserver/e-data-server-util.c
@@ -34,8 +34,12 @@
#include "e-source.h"
#include "e-source-authentication.h"
+#include "e-source-backend.h"
#include "e-source-credentials-provider-impl-google.h"
#include "e-source-enumtypes.h"
+#include "e-source-mail-identity.h"
+#include "e-source-mail-submission.h"
+#include "e-source-mail-transport.h"
#include "e-source-registry.h"
#include "camel/camel.h"
@@ -3067,3 +3071,63 @@ e_util_generate_uid (void)
return uid;
}
+
+/**
+ * e_util_identity_can_send:
+ * @registry: an #ESourceRegistry
+ * @identity_source: an #ESource with mail identity extension
+ *
+ * Checks whether the @identity_source can be used for sending, which means
+ * whether it has configures send mail source.
+ *
+ * Returns: Whether @identity_source can be used to send messages
+ *
+ * Since: 3.26
+ **/
+gboolean
+e_util_identity_can_send (ESourceRegistry *registry,
+ ESource *identity_source)
+{
+ ESourceMailSubmission *mail_submission;
+ ESource *transport_source = NULL;
+ const gchar *transport_uid;
+ gboolean can_send = FALSE;
+
+ g_return_val_if_fail (E_IS_SOURCE_REGISTRY (registry), FALSE);
+ g_return_val_if_fail (E_IS_SOURCE (identity_source), FALSE);
+
+ if (!e_source_has_extension (identity_source, E_SOURCE_EXTENSION_MAIL_IDENTITY) ||
+ !e_source_has_extension (identity_source, E_SOURCE_EXTENSION_MAIL_SUBMISSION))
+ return FALSE;
+
+ mail_submission = e_source_get_extension (identity_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)
+ return FALSE;
+
+ if (e_source_has_extension (transport_source, E_SOURCE_EXTENSION_MAIL_TRANSPORT)) {
+ ESourceMailTransport *mail_transport;
+ const gchar *backend_name;
+
+ mail_transport = e_source_get_extension (transport_source, E_SOURCE_EXTENSION_MAIL_TRANSPORT);
+
+ e_source_extension_property_lock (E_SOURCE_EXTENSION (mail_transport));
+
+ backend_name = e_source_backend_get_backend_name (E_SOURCE_BACKEND (mail_transport));
+ can_send = backend_name && *backend_name && g_strcmp0 (backend_name, "none") != 0;
+
+ e_source_extension_property_unlock (E_SOURCE_EXTENSION (mail_transport));
+ }
+
+ g_object_unref (transport_source);
+
+ return can_send;
+}
diff --git a/src/libedataserver/e-data-server-util.h b/src/libedataserver/e-data-server-util.h
index fab7589..a6d0925 100644
--- a/src/libedataserver/e-data-server-util.h
+++ b/src/libedataserver/e-data-server-util.h
@@ -286,6 +286,9 @@ void e_util_unref_in_thread (gpointer object);
gchar * e_util_generate_uid (void);
+gboolean e_util_identity_can_send (struct _ESourceRegistry *registry,
+ struct _ESource *identity_source);
+
G_END_DECLS
#endif /* E_DATA_SERVER_UTIL_H */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]