Commit 38b4de26 authored by Carlos Garnacho's avatar Carlos Garnacho
Browse files

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: #287
parent 17c8fff4
......@@ -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. */
......
......@@ -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;
}
......
......@@ -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);
......
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