[evolution-data-server] EServerSideSource: Add an "exported" property.



commit 1d00bd4960e296a32810ca920d78d26245e9bc09
Author: Matthew Barnes <mbarnes redhat com>
Date:   Thu Jun 21 08:40:54 2012 -0400

    EServerSideSource: Add an "exported" property.
    
    Read-only boolean property indicates whether the source has been
    exported over D-Bus.  Basically just queries the registry server
    for itself.

 .../reference/libebackend/libebackend-sections.txt |    1 +
 libebackend/e-server-side-source.c                 |   58 ++++++++++++++++++++
 libebackend/e-server-side-source.h                 |    2 +
 libebackend/e-source-registry-server.c             |    4 ++
 4 files changed, 65 insertions(+), 0 deletions(-)
---
diff --git a/docs/reference/libebackend/libebackend-sections.txt b/docs/reference/libebackend/libebackend-sections.txt
index 4619a18..fb9752b 100644
--- a/docs/reference/libebackend/libebackend-sections.txt
+++ b/docs/reference/libebackend/libebackend-sections.txt
@@ -335,6 +335,7 @@ e_server_side_source_get_node
 e_server_side_source_get_server
 e_server_side_source_get_allow_auth_prompt
 e_server_side_source_set_allow_auth_prompt
+e_server_side_source_get_exported
 e_server_side_source_get_write_directory
 e_server_side_source_set_write_directory
 e_server_side_source_set_removable
diff --git a/libebackend/e-server-side-source.c b/libebackend/e-server-side-source.c
index 0c586aa..133ccad 100644
--- a/libebackend/e-server-side-source.c
+++ b/libebackend/e-server-side-source.c
@@ -66,6 +66,7 @@ struct _AsyncClosure {
 enum {
 	PROP_0,
 	PROP_ALLOW_AUTH_PROMPT,
+	PROP_EXPORTED,
 	PROP_FILE,
 	PROP_REMOVABLE,
 	PROP_SERVER,
@@ -406,6 +407,13 @@ server_side_source_get_property (GObject *object,
 				E_SERVER_SIDE_SOURCE (object)));
 			return;
 
+		case PROP_EXPORTED:
+			g_value_set_boolean (
+				value,
+				e_server_side_source_get_exported (
+				E_SERVER_SIDE_SOURCE (object)));
+			return;
+
 		case PROP_FILE:
 			g_value_set_object (
 				value,
@@ -846,6 +854,17 @@ e_server_side_source_class_init (EServerSideSourceClass *class)
 
 	g_object_class_install_property (
 		object_class,
+		PROP_EXPORTED,
+		g_param_spec_boolean (
+			"exported",
+			"Exported",
+			"Whether the source has been exported over D-Bus",
+			FALSE,
+			G_PARAM_READABLE |
+			G_PARAM_STATIC_STRINGS));
+
+	g_object_class_install_property (
+		object_class,
 		PROP_FILE,
 		g_param_spec_object (
 			"file",
@@ -1342,6 +1361,45 @@ e_server_side_source_set_allow_auth_prompt (EServerSideSource *source,
 }
 
 /**
+ * e_server_side_source_get_exported:
+ * @source: an #EServerSideSource
+ *
+ * Returns whether @source has been exported over D-Bus.
+ *
+ * The function returns %FALSE after @source is initially created, %TRUE
+ * after passing @source to e_source_registry_add_source() (provided that
+ * @source's #ESource:parent is also exported), and %FALSE after passing
+ * @source to e_source_registry_remove_source().
+ *
+ * Returns: whether @source has been exported
+ *
+ * Since: 3.6
+ **/
+gboolean
+e_server_side_source_get_exported (EServerSideSource *source)
+{
+	ESourceRegistryServer *server;
+	ESource *exported_source;
+	gboolean exported = FALSE;
+	const gchar *uid;
+
+	g_return_val_if_fail (E_IS_SERVER_SIDE_SOURCE (source), FALSE);
+
+	uid = e_source_get_uid (E_SOURCE (source));
+	server = e_server_side_source_get_server (source);
+
+	/* We're exported if we can look ourselves up in the registry. */
+
+	exported_source = e_source_registry_server_ref_source (server, uid);
+	if (exported_source != NULL) {
+		exported = TRUE;
+		g_object_unref (exported_source);
+	}
+
+	return exported;
+}
+
+/**
  * e_server_side_source_get_write_directory:
  * @source: an #EServerSideSource
  *
diff --git a/libebackend/e-server-side-source.h b/libebackend/e-server-side-source.h
index 597d782..cdb5277 100644
--- a/libebackend/e-server-side-source.h
+++ b/libebackend/e-server-side-source.h
@@ -96,6 +96,8 @@ gboolean	e_server_side_source_get_allow_auth_prompt
 void		e_server_side_source_set_allow_auth_prompt
 						(EServerSideSource *source,
 						 gboolean allow_auth_prompt);
+gboolean	e_server_side_source_get_exported
+						(EServerSideSource *source);
 const gchar *	e_server_side_source_get_write_directory
 						(EServerSideSource *source);
 void		e_server_side_source_set_write_directory
diff --git a/libebackend/e-source-registry-server.c b/libebackend/e-source-registry-server.c
index 4311b5e..b06a1a6 100644
--- a/libebackend/e-source-registry-server.c
+++ b/libebackend/e-source-registry-server.c
@@ -975,6 +975,8 @@ source_registry_server_source_added (ESourceRegistryServer *server,
 		server->priv->object_manager,
 		G_DBUS_OBJECT_SKELETON (dbus_object));
 
+	g_object_notify (G_OBJECT (source), "exported");
+
 	uid = e_source_get_uid (source);
 
 	g_dbus_object = G_DBUS_OBJECT (dbus_object);
@@ -1007,6 +1009,8 @@ source_registry_server_source_removed (ESourceRegistryServer *server,
 	g_dbus_object_manager_server_unexport (
 		server->priv->object_manager, object_path);
 
+	g_object_notify (G_OBJECT (source), "exported");
+
 	g_object_unref (dbus_object);
 }
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]