Details
-
Bug
-
Resolution: Invalid
-
Not Evaluated
-
None
-
5.10.1
-
None
-
* Qt 5.10.1
* QrchLinux x64
* geoclue2
Description
As I understand, the QDBusServiceWatcher is an equivalent of g_bus_watch_name() function from Glib. But, it does not watch e.g. for the "org.freedesktop.GeoClue2" service name.
e.g. this Qt code does not work at all:
int main(int argc, char *argv[]) { QCoreApplication a(argc, argv); QDBusServiceWatcher serviceWatcher( "org.freedesktop.GeoClue2", QDBusConnection::systemBus(), QDBusServiceWatcher::WatchForRegistration | QDBusServiceWatcher::WatchForUnregistration | QDBusServiceWatcher::WatchForOwnerChange); QObject::connect(&serviceWatcher, &QDBusServiceWatcher::serviceRegistered, [](const QString &service) { qDebug() << "Registered:" << service; }); QObject::connect(&serviceWatcher, &QDBusServiceWatcher::serviceUnregistered, [](const QString &service) { qDebug() << "Unregistered:" << service; }); QObject::connect(&serviceWatcher, &QDBusServiceWatcher::serviceOwnerChanged, [](const QString &service, const QString &oldOwner, const QString &newOwner) { qDebug() << "Owner changed:" << service << oldOwner << newOwner; }); return a.exec(); }
but, this Glib code does work:
#include <gio/gio.h> static void on_name_appeared(GDBusConnection *connection, const gchar *name, const gchar *name_owner, gpointer user_data) { g_print ("Name %s on the system bus is owned by %s\n", name, name_owner); } static void on_name_vanished(GDBusConnection *connection, const gchar *name, gpointer user_data) { g_print ("Name %s does not exist on the system bus\n", name); } int main(int argc, char *argv[]) { const guint watcher_id = g_bus_watch_name( G_BUS_TYPE_SYSTEM, "org.freedesktop.GeoClue2", G_BUS_NAME_WATCHER_FLAGS_AUTO_START, on_name_appeared, on_name_vanished, NULL, NULL); GMainLoop *loop = g_main_loop_new(NULL, FALSE); g_main_loop_run(loop); g_bus_unwatch_name(watcher_id); return 0; }
please see a full code in an attached projects.
PS: And I do not know, is it possible to do any workaround, using Qt?