[tracker/wip/carlosg/sandboxed-notifiers: 4/10] libtracker-sparql: Add private call to get remote DBus service details
- From: Carlos Garnacho <carlosg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [tracker/wip/carlosg/sandboxed-notifiers: 4/10] libtracker-sparql: Add private call to get remote DBus service details
- Date: Sat, 20 Feb 2021 22:30:44 +0000 (UTC)
commit 38b4de262d814bef71f41877791532ad8379e113
Author: Carlos Garnacho <carlosg gnome org>
Date: Sat Feb 20 18:09:29 2021 +0100
libtracker-sparql: Add private call to get remote DBus service details
When subscribing a TrackerNotifier to notifications from a remote DBus
service, we may need to perform translation of dbus names and object
paths, as this connection may be sandboxed.
Implement this plumbing so we may ask the TrackerSparqlConnection
about the real DBus details behind a SPARQL DBus endpoint.
Fixes: https://gitlab.gnome.org/GNOME/tracker/-/issues/287
src/libtracker-sparql/tracker-connection.c | 23 +++++++++++++++++++++++
src/libtracker-sparql/tracker-notifier.c | 15 +++++++++++++--
src/libtracker-sparql/tracker-private.h | 12 ++++++++++++
3 files changed, 48 insertions(+), 2 deletions(-)
---
diff --git a/src/libtracker-sparql/tracker-connection.c b/src/libtracker-sparql/tracker-connection.c
index 5dcc3d226..c6284d46e 100644
--- a/src/libtracker-sparql/tracker-connection.c
+++ b/src/libtracker-sparql/tracker-connection.c
@@ -93,6 +93,29 @@ tracker_sparql_connection_class_init (TrackerSparqlConnectionClass *klass)
object_class->dispose = tracker_sparql_connection_dispose;
}
+gboolean
+tracker_sparql_connection_lookup_dbus_service (TrackerSparqlConnection *connection,
+ const gchar *dbus_name,
+ const gchar *dbus_path,
+ gchar **name,
+ gchar **path)
+{
+ TrackerSparqlConnectionClass *connection_class;
+
+ g_return_val_if_fail (TRACKER_IS_SPARQL_CONNECTION (connection), FALSE);
+ g_return_val_if_fail (dbus_name != NULL, FALSE);
+
+ connection_class = TRACKER_SPARQL_CONNECTION_GET_CLASS (connection);
+ if (!connection_class->lookup_dbus_service)
+ return FALSE;
+
+ return TRACKER_SPARQL_CONNECTION_GET_CLASS (connection)->lookup_dbus_service (connection,
+ dbus_name,
+ dbus_path,
+ name,
+ path);
+}
+
/* The constructor functions are defined in the libtracker-sparql-backend, but
* documented here. */
diff --git a/src/libtracker-sparql/tracker-notifier.c b/src/libtracker-sparql/tracker-notifier.c
index cf1c9a9dd..fce0cbde5 100644
--- a/src/libtracker-sparql/tracker-notifier.c
+++ b/src/libtracker-sparql/tracker-notifier.c
@@ -50,6 +50,7 @@
#include "tracker-private.h"
#include "tracker-sparql-enum-types.h"
#include <libtracker-common/tracker-common.h>
+#include <direct/tracker-direct.h>
typedef struct _TrackerNotifierPrivate TrackerNotifierPrivate;
typedef struct _TrackerNotifierSubscription TrackerNotifierSubscription;
@@ -811,6 +812,7 @@ tracker_notifier_signal_subscribe (TrackerNotifier *notifier,
{
TrackerNotifierSubscription *subscription;
TrackerNotifierPrivate *priv;
+ gchar *dbus_name = NULL, *dbus_path = NULL;
g_return_val_if_fail (TRACKER_IS_NOTIFIER (notifier), 0);
g_return_val_if_fail (G_IS_DBUS_CONNECTION (connection), 0);
@@ -821,15 +823,21 @@ tracker_notifier_signal_subscribe (TrackerNotifier *notifier,
if (!object_path)
object_path = DEFAULT_OBJECT_PATH;
+ tracker_sparql_connection_lookup_dbus_service (priv->connection,
+ service,
+ object_path,
+ &dbus_name,
+ &dbus_path);
+
subscription = tracker_notifier_subscription_new (notifier, connection,
service, object_path);
subscription->handler_id =
g_dbus_connection_signal_subscribe (connection,
- service,
+ dbus_name ? dbus_name : service,
"org.freedesktop.Tracker3.Endpoint",
"GraphUpdated",
- object_path,
+ dbus_path ? dbus_path : object_path,
graph,
G_DBUS_SIGNAL_FLAGS_NONE,
graph_updated_cb,
@@ -839,6 +847,9 @@ tracker_notifier_signal_subscribe (TrackerNotifier *notifier,
GUINT_TO_POINTER (subscription->handler_id),
subscription);
+ g_free (dbus_name);
+ g_free (dbus_path);
+
return subscription->handler_id;
}
diff --git a/src/libtracker-sparql/tracker-private.h b/src/libtracker-sparql/tracker-private.h
index da93ac862..b8c6381ec 100644
--- a/src/libtracker-sparql/tracker-private.h
+++ b/src/libtracker-sparql/tracker-private.h
@@ -106,6 +106,12 @@ struct _TrackerSparqlConnectionClass
GAsyncResult *res,
GError **error);
TrackerBatch * (* create_batch) (TrackerSparqlConnection *connection);
+
+ gboolean (* lookup_dbus_service) (TrackerSparqlConnection *connection,
+ const gchar *dbus_name,
+ const gchar *dbus_path,
+ gchar **name,
+ gchar **path);
};
typedef struct _TrackerSparqlCursorClass TrackerSparqlCursorClass;
@@ -262,6 +268,12 @@ struct _TrackerSerializerClass {
GInputStreamClass parent_class;
};
+gboolean
+tracker_sparql_connection_lookup_dbus_service (TrackerSparqlConnection *connection,
+ const gchar *dbus_name,
+ const gchar *dbus_path,
+ gchar **name,
+ gchar **path);
void tracker_sparql_cursor_set_connection (TrackerSparqlCursor *cursor,
TrackerSparqlConnection *connection);
GError * _translate_internal_error (GError *error);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]