summaryrefslogtreecommitdiff
path: root/src/libtracker-common
diff options
context:
space:
mode:
authorCarlos Garnacho <carlosg@gnome.org>2017-06-18 18:18:16 +0200
committerCarlos Garnacho <carlosg@gnome.org>2017-06-29 20:49:06 +0200
commit9831c10218f49550e23f2ea02c8d8a96fe63a761 (patch)
tree6994186c667bc662e3e20b2d42bd8a16a2fedead /src/libtracker-common
parent3d9e10bdb953e6002e0ab234dba79952752a6434 (diff)
downloadtracker-9831c10218f49550e23f2ea02c8d8a96fe63a761.tar.gz
libtracker-miner: Add TrackerMinerProxy object
And shift all miner dbus handling from TrackerMiner. This object takes a TrackerMiner and implements the org.freedesktop.Tracker1.Miner interface for it on DBus. One notable difference in handling here is that libtracker-miner does not try to own DBus names anymore, that is left up to the caller. The registered object will be available on whatever dbus name the caller does register. For compatibility, all TrackerMiner implementations around have been made to request their usual name.
Diffstat (limited to 'src/libtracker-common')
-rw-r--r--src/libtracker-common/tracker-dbus.c42
-rw-r--r--src/libtracker-common/tracker-dbus.h4
2 files changed, 46 insertions, 0 deletions
diff --git a/src/libtracker-common/tracker-dbus.c b/src/libtracker-common/tracker-dbus.c
index e8c43d202..5907d29fa 100644
--- a/src/libtracker-common/tracker-dbus.c
+++ b/src/libtracker-common/tracker-dbus.c
@@ -497,3 +497,45 @@ tracker_g_dbus_request_begin (GDBusMethodInvocation *invocation,
return request;
}
+
+gboolean
+tracker_dbus_request_name (GDBusConnection *connection,
+ const gchar *name,
+ GError **error)
+{
+ GError *inner_error = NULL;
+ GVariant *reply;
+ gint rval;
+
+ reply = g_dbus_connection_call_sync (connection,
+ "org.freedesktop.DBus",
+ "/org/freedesktop/DBus",
+ "org.freedesktop.DBus",
+ "RequestName",
+ g_variant_new ("(su)",
+ name,
+ 0x4 /* DBUS_NAME_FLAG_DO_NOT_QUEUE */),
+ G_VARIANT_TYPE ("(u)"),
+ 0, -1, NULL, &inner_error);
+ if (inner_error) {
+ g_propagate_prefixed_error (error, inner_error,
+ "Could not acquire name:'%s'. ",
+ name);
+ return FALSE;
+ }
+
+ g_variant_get (reply, "(u)", &rval);
+ g_variant_unref (reply);
+
+ if (rval != 1 /* DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER */) {
+ g_set_error (error,
+ G_DBUS_ERROR,
+ G_DBUS_ERROR_ADDRESS_IN_USE,
+ "D-Bus service name:'%s' is already taken, "
+ "perhaps the application is already running?",
+ name);
+ return FALSE;
+ }
+
+ return TRUE;
+}
diff --git a/src/libtracker-common/tracker-dbus.h b/src/libtracker-common/tracker-dbus.h
index 6ea5bb888..bfbff9bb3 100644
--- a/src/libtracker-common/tracker-dbus.h
+++ b/src/libtracker-common/tracker-dbus.h
@@ -92,6 +92,10 @@ void tracker_dbus_request_debug (TrackerDBusRequest
void tracker_dbus_enable_client_lookup (gboolean enable);
+gboolean tracker_dbus_request_name (GDBusConnection *connection,
+ const gchar *name,
+ GError **error);
+
/* GDBus convenience API */
TrackerDBusRequest *tracker_g_dbus_request_begin (GDBusMethodInvocation *invocation,
const gchar *format,