From: Luiz Augusto von Dentz <luiz.dentz@gmail.com>
To: linux-bluetooth@vger.kernel.org
Subject: [PATCH BlueZ] gdbus: Force service to start if proxy is created while not connected
Date: Tue, 28 Nov 2017 12:57:46 +0200 [thread overview]
Message-ID: <20171128105746.13000-1-luiz.dentz@gmail.com> (raw)
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Because GetAll is no longer send right away the service may never be
started.
---
gdbus/client.c | 30 +++++++++++++++++++++++++++++-
1 file changed, 29 insertions(+), 1 deletion(-)
diff --git a/gdbus/client.c b/gdbus/client.c
index 9b0f7f7a9..3d7105ef8 100644
--- a/gdbus/client.c
+++ b/gdbus/client.c
@@ -484,6 +484,28 @@ 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);
+ dbus_message_unref(msg);
+ return;
+}
+
GDBusProxy *g_dbus_proxy_new(GDBusClient *client, const char *path,
const char *interface)
{
@@ -500,7 +522,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);
--
2.13.6
next reply other threads:[~2017-11-28 10:57 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-11-28 10:57 Luiz Augusto von Dentz [this message]
2017-11-28 13:47 ` [PATCH BlueZ] gdbus: Force service to start if proxy is created while not connected Bastien Nocera
2017-11-28 13:49 ` Luiz Augusto von Dentz
2017-11-28 13:58 ` Bastien Nocera
2017-11-28 14:23 ` Luiz Augusto von Dentz
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20171128105746.13000-1-luiz.dentz@gmail.com \
--to=luiz.dentz@gmail.com \
--cc=linux-bluetooth@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox