summaryrefslogtreecommitdiff
path: root/libebackend
diff options
context:
space:
mode:
authorMatthew Barnes <mbarnes@redhat.com>2013-02-01 13:23:48 -0500
committerMatthew Barnes <mbarnes@redhat.com>2013-02-01 14:15:04 -0500
commite0d50ce93c07a12ccac8031c12abe24735d05655 (patch)
treec18b1df5a2bd189769307a086878e86e29483edc /libebackend
parent48b9d17d16be9f0ecb6066036cc83d08b3cca817 (diff)
downloadevolution-data-server-e0d50ce93c07a12ccac8031c12abe24735d05655.tar.gz
EServerSideSource: Add an "auth-session-type" property.
This will allow modules -- particularly the online accounts modules -- to subclass and customize EAuthenticationSession, and then register the subclass to be used for data sources under their purview. Care must be taken when subclassing, however, to comply with the D-Bus interaction protocol that clients will be expecting, lest the client be left hanging during its authenticate() call.
Diffstat (limited to 'libebackend')
-rw-r--r--libebackend/e-server-side-source.c89
-rw-r--r--libebackend/e-server-side-source.h5
2 files changed, 94 insertions, 0 deletions
diff --git a/libebackend/e-server-side-source.c b/libebackend/e-server-side-source.c
index 2b63346fd..2daf021b9 100644
--- a/libebackend/e-server-side-source.c
+++ b/libebackend/e-server-side-source.c
@@ -54,6 +54,7 @@ struct _EServerSideSourcePrivate {
gchar *file_contents;
gboolean allow_auth_prompt;
+ GType auth_session_type;
gchar *write_directory;
};
@@ -67,6 +68,7 @@ struct _AsyncContext {
enum {
PROP_0,
PROP_ALLOW_AUTH_PROMPT,
+ PROP_AUTH_SESSION_TYPE,
PROP_EXPORTED,
PROP_FILE,
PROP_OAUTH2_SUPPORT,
@@ -509,6 +511,12 @@ server_side_source_set_property (GObject *object,
g_value_get_boolean (value));
return;
+ case PROP_AUTH_SESSION_TYPE:
+ e_server_side_source_set_auth_session_type (
+ E_SERVER_SIDE_SOURCE (object),
+ g_value_get_gtype (value));
+ return;
+
case PROP_FILE:
server_side_source_set_file (
E_SERVER_SIDE_SOURCE (object),
@@ -575,6 +583,13 @@ server_side_source_get_property (GObject *object,
E_SERVER_SIDE_SOURCE (object)));
return;
+ case PROP_AUTH_SESSION_TYPE:
+ g_value_set_boolean (
+ value,
+ e_server_side_source_get_auth_session_type (
+ E_SERVER_SIDE_SOURCE (object)));
+ return;
+
case PROP_EXPORTED:
g_value_set_boolean (
value,
@@ -1171,6 +1186,18 @@ e_server_side_source_class_init (EServerSideSourceClass *class)
g_object_class_install_property (
object_class,
+ PROP_AUTH_SESSION_TYPE,
+ g_param_spec_gtype (
+ "auth-session-type",
+ "Auth Session Type",
+ "The type of authentication session "
+ "to instantiate for this source",
+ E_TYPE_AUTHENTICATION_SESSION,
+ G_PARAM_READWRITE |
+ G_PARAM_STATIC_STRINGS));
+
+ g_object_class_install_property (
+ object_class,
PROP_EXPORTED,
g_param_spec_boolean (
"exported",
@@ -1302,6 +1329,8 @@ e_server_side_source_init (EServerSideSource *source)
user_dir = e_server_side_source_get_user_dir ();
source->priv->write_directory = g_strdup (user_dir);
+
+ source->priv->auth_session_type = E_TYPE_AUTHENTICATION_SESSION;
}
/**
@@ -1712,6 +1741,66 @@ e_server_side_source_set_allow_auth_prompt (EServerSideSource *source,
}
/**
+ * e_server_side_source_get_auth_session_type:
+ * @source: an #EServerSideSource
+ *
+ * Returns the type of authentication session to use for @source,
+ * which will get passed to e_source_registry_server_authenticate().
+ *
+ * This defaults to the #GType for #EAuthenticationSession.
+ *
+ * Returns: the type of authentication session to use for @source
+ *
+ * Since: 3.8
+ **/
+GType
+e_server_side_source_get_auth_session_type (EServerSideSource *source)
+{
+ g_return_val_if_fail (
+ E_IS_SERVER_SIDE_SOURCE (source),
+ E_TYPE_AUTHENTICATION_SESSION);
+
+ return source->priv->auth_session_type;
+}
+
+/**
+ * e_server_side_source_set_auth_session_type:
+ * @source: an #EServerSideSource
+ * @auth_session_type: the type of authentication session to use for @source
+ *
+ * Sets the type of authentication session to use for @source, which will
+ * get passed to e_source_registry_server_authenticate().
+ *
+ * @auth_session_type must be derived from #EAuthenticationSession, or else
+ * the function will reject the #GType with a runtime warning.
+ *
+ * This defaults to the #GType for #EAuthenticationSession.
+ *
+ * Since: 3.8
+ **/
+void
+e_server_side_source_set_auth_session_type (EServerSideSource *source,
+ GType auth_session_type)
+{
+ g_return_if_fail (E_IS_SERVER_SIDE_SOURCE (source));
+
+ if (!g_type_is_a (auth_session_type, E_TYPE_AUTHENTICATION_SESSION)) {
+ g_warning (
+ "Invalid auth session type '%s' for source '%s'",
+ g_type_name (auth_session_type),
+ e_source_get_display_name (E_SOURCE (source)));
+ return;
+ }
+
+ if (auth_session_type == source->priv->auth_session_type)
+ return;
+
+ source->priv->auth_session_type = auth_session_type;
+
+ g_object_notify (G_OBJECT (source), "auth-session-type");
+}
+
+/**
* e_server_side_source_get_exported:
* @source: an #EServerSideSource
*
diff --git a/libebackend/e-server-side-source.h b/libebackend/e-server-side-source.h
index f25a7648d..bed3f61b3 100644
--- a/libebackend/e-server-side-source.h
+++ b/libebackend/e-server-side-source.h
@@ -97,6 +97,11 @@ gboolean e_server_side_source_get_allow_auth_prompt
void e_server_side_source_set_allow_auth_prompt
(EServerSideSource *source,
gboolean allow_auth_prompt);
+GType e_server_side_source_get_auth_session_type
+ (EServerSideSource *source);
+void e_server_side_source_set_auth_session_type
+ (EServerSideSource *source,
+ GType auth_session_type);
gboolean e_server_side_source_get_exported
(EServerSideSource *source);
const gchar * e_server_side_source_get_write_directory