summaryrefslogtreecommitdiff
path: root/gdbus
diff options
context:
space:
mode:
authorLuiz Augusto von Dentz <luiz.von.dentz@intel.com>2017-11-28 12:54:13 +0200
committerLuiz Augusto von Dentz <luiz.von.dentz@intel.com>2017-11-28 16:22:13 +0200
commit5d71be8de9eb2846e4a9d4b33d6d3fe62d1c128c (patch)
tree7043a4b8f456efcb6c258c01f9d8dceba7ef8b1d /gdbus
parent847337155ee7ff8564b9482a8ffa5025c5f361e9 (diff)
downloadbluez-5d71be8de9eb2846e4a9d4b33d6d3fe62d1c128c.tar.gz
gdbus: Force service to start if proxy is created while not connected
Because GetAll is no longer send right away the service may never be started.
Diffstat (limited to 'gdbus')
-rw-r--r--gdbus/client.c29
1 files changed, 28 insertions, 1 deletions
diff --git a/gdbus/client.c b/gdbus/client.c
index 9b0f7f7a9..ec9b63823 100644
--- a/gdbus/client.c
+++ b/gdbus/client.c
@@ -484,6 +484,27 @@ static void proxy_remove(GDBusClient *client, const char *path,
}
}
+static void start_service(GDBusProxy *proxy)
+{
+ GDBusClient *client = proxy->client;
+ const char *service_name = client->service_name;
+ dbus_uint32_t flags = 0;
+ DBusMessage *msg;
+
+ msg = dbus_message_new_method_call(DBUS_SERVICE_DBUS, DBUS_PATH_DBUS,
+ DBUS_INTERFACE_DBUS,
+ "StartServiceByName");
+ if (msg == NULL)
+ return;
+
+ dbus_message_append_args(msg, DBUS_TYPE_STRING, &service_name,
+ DBUS_TYPE_UINT32, &flags,
+ DBUS_TYPE_INVALID);
+
+ g_dbus_send_message(client->dbus_conn, msg);
+ return;
+}
+
GDBusProxy *g_dbus_proxy_new(GDBusClient *client, const char *path,
const char *interface)
{
@@ -500,7 +521,13 @@ GDBusProxy *g_dbus_proxy_new(GDBusClient *client, const char *path,
if (proxy == NULL)
return NULL;
- if (client->connected && !client->get_objects_call)
+ if (!client->connected) {
+ /* Force service to start */
+ start_service(proxy);
+ return g_dbus_proxy_ref(proxy);
+ }
+
+ if (!client->get_objects_call)
get_all_properties(proxy);
return g_dbus_proxy_ref(proxy);