All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH BlueZ 1/2] gdbus: Make GDBusClient work without ObjectManager
@ 2015-03-24 12:10 Luiz Augusto von Dentz
  2015-03-24 12:10 ` [PATCH BlueZ 2/2] unit/test-dbus-client: Add client_no_object_manager test Luiz Augusto von Dentz
  2015-03-25 10:39 ` [PATCH BlueZ 1/2] gdbus: Make GDBusClient work without ObjectManager Luiz Augusto von Dentz
  0 siblings, 2 replies; 3+ messages in thread
From: Luiz Augusto von Dentz @ 2015-03-24 12:10 UTC (permalink / raw)
  To: linux-bluetooth

From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>

This makes GDBusClient work normally without ObjectManager.
---
 gdbus/client.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/gdbus/client.c b/gdbus/client.c
index fe0c0db..48711ae 100644
--- a/gdbus/client.c
+++ b/gdbus/client.c
@@ -1111,7 +1111,8 @@ static void get_managed_objects(GDBusClient *client)
 	if (!client->connected)
 		return;
 
-	if (!client->proxy_added && !client->proxy_removed) {
+	if ((!client->proxy_added && !client->proxy_removed) ||
+							!client->root_path) {
 		refresh_properties(client);
 		return;
 	}
@@ -1212,7 +1213,7 @@ GDBusClient *g_dbus_client_new_full(DBusConnection *connection,
 	GDBusClient *client;
 	unsigned int i;
 
-	if (!connection || !service || !root_path)
+	if (!connection || !service)
 		return NULL;
 
 	client = g_try_new0(GDBusClient, 1);
@@ -1238,6 +1239,10 @@ GDBusClient *g_dbus_client_new_full(DBusConnection *connection,
 						service_connect,
 						service_disconnect,
 						client, NULL);
+
+	if (!root_path)
+		return g_dbus_client_ref(client);
+
 	client->added_watch = g_dbus_add_signal_watch(connection, service,
 						client->root_path,
 						DBUS_INTERFACE_OBJECT_MANAGER,
-- 
2.1.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [PATCH BlueZ 2/2] unit/test-dbus-client: Add client_no_object_manager test
  2015-03-24 12:10 [PATCH BlueZ 1/2] gdbus: Make GDBusClient work without ObjectManager Luiz Augusto von Dentz
@ 2015-03-24 12:10 ` Luiz Augusto von Dentz
  2015-03-25 10:39 ` [PATCH BlueZ 1/2] gdbus: Make GDBusClient work without ObjectManager Luiz Augusto von Dentz
  1 sibling, 0 replies; 3+ messages in thread
From: Luiz Augusto von Dentz @ 2015-03-24 12:10 UTC (permalink / raw)
  To: linux-bluetooth

From: Michael Janssen <jamuraa@chromium.org>

Adds a test for the functionality of g_dbus_client_new_full passing NULL
as root_path.
---
 unit/test-gdbus-client.c | 55 +++++++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 54 insertions(+), 1 deletion(-)

diff --git a/unit/test-gdbus-client.c b/unit/test-gdbus-client.c
index 11ad1f7..ad426fe 100644
--- a/unit/test-gdbus-client.c
+++ b/unit/test-gdbus-client.c
@@ -353,7 +353,7 @@ static void proxy_get_string(GDBusProxy *proxy, void *user_data)
 	g_assert(dbus_message_iter_get_arg_type(&iter) == DBUS_TYPE_STRING);
 
 	dbus_message_iter_get_basic(&iter, &string);
-	g_assert(g_strcmp0(string, "value") == 0);
+	g_assert_cmpstr(string, ==, "value");
 
 	g_dbus_client_unref(context->dbus_client);
 }
@@ -908,6 +908,56 @@ static void client_proxy_removed(void)
 	destroy_context(context);
 }
 
+static void client_no_object_manager(void)
+{
+	struct context *context = create_context();
+	DBusConnection *conn;
+	DBusMessageIter iter;
+	static const GDBusPropertyTable string_properties[] = {
+		{ "String", "s", get_string, set_string, string_exists },
+		{ },
+	};
+
+	if (context == NULL)
+		return;
+
+	conn = g_dbus_setup_private(DBUS_BUS_SESSION, SERVICE_NAME1, NULL);
+	g_assert(conn != NULL);
+
+	context->data = g_strdup("value");
+
+	g_dbus_register_interface(conn,
+				SERVICE_PATH, SERVICE_NAME1,
+				methods, signals, string_properties,
+				context, NULL);
+
+	context->dbus_client = g_dbus_client_new_full(context->dbus_conn,
+						SERVICE_NAME1, SERVICE_PATH,
+						NULL);
+
+	g_dbus_client_set_disconnect_watch(context->dbus_client,
+						disconnect_handler, context);
+
+	context->proxy = g_dbus_proxy_new(context->dbus_client, SERVICE_PATH,
+								SERVICE_NAME1);
+
+	g_dbus_client_set_proxy_handlers(context->dbus_client, proxy_get_string,
+						NULL, NULL, context);
+
+	g_assert(!g_dbus_proxy_get_property(context->proxy, "String", &iter));
+
+	g_main_loop_run(context->main_loop);
+
+	g_dbus_proxy_unref(context->proxy);
+	g_dbus_unregister_interface(conn, SERVICE_PATH, SERVICE_NAME1);
+
+	dbus_connection_flush(conn);
+	dbus_connection_close(conn);
+	dbus_connection_unref(conn);
+
+	destroy_context(context);
+}
+
 static void proxy_force_disconnect(GDBusProxy *proxy, void *user_data)
 {
 	struct context *context = user_data;
@@ -1051,6 +1101,9 @@ int main(int argc, char *argv[])
 
 	g_test_add_func("/gdbus/client_proxy_removed", client_proxy_removed);
 
+	g_test_add_func("/gdbus/client_no_object_manager",
+						client_no_object_manager);
+
 	g_test_add_func("/gdbus/client_force_disconnect",
 						client_force_disconnect);
 
-- 
2.1.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH BlueZ 1/2] gdbus: Make GDBusClient work without ObjectManager
  2015-03-24 12:10 [PATCH BlueZ 1/2] gdbus: Make GDBusClient work without ObjectManager Luiz Augusto von Dentz
  2015-03-24 12:10 ` [PATCH BlueZ 2/2] unit/test-dbus-client: Add client_no_object_manager test Luiz Augusto von Dentz
@ 2015-03-25 10:39 ` Luiz Augusto von Dentz
  1 sibling, 0 replies; 3+ messages in thread
From: Luiz Augusto von Dentz @ 2015-03-25 10:39 UTC (permalink / raw)
  To: linux-bluetooth

Hi,

On Tue, Mar 24, 2015 at 2:10 PM, Luiz Augusto von Dentz
<luiz.dentz@gmail.com> wrote:
> From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
>
> This makes GDBusClient work normally without ObjectManager.
> ---
>  gdbus/client.c | 9 +++++++--
>  1 file changed, 7 insertions(+), 2 deletions(-)
>
> diff --git a/gdbus/client.c b/gdbus/client.c
> index fe0c0db..48711ae 100644
> --- a/gdbus/client.c
> +++ b/gdbus/client.c
> @@ -1111,7 +1111,8 @@ static void get_managed_objects(GDBusClient *client)
>         if (!client->connected)
>                 return;
>
> -       if (!client->proxy_added && !client->proxy_removed) {
> +       if ((!client->proxy_added && !client->proxy_removed) ||
> +                                                       !client->root_path) {
>                 refresh_properties(client);
>                 return;
>         }
> @@ -1212,7 +1213,7 @@ GDBusClient *g_dbus_client_new_full(DBusConnection *connection,
>         GDBusClient *client;
>         unsigned int i;
>
> -       if (!connection || !service || !root_path)
> +       if (!connection || !service)
>                 return NULL;
>
>         client = g_try_new0(GDBusClient, 1);
> @@ -1238,6 +1239,10 @@ GDBusClient *g_dbus_client_new_full(DBusConnection *connection,
>                                                 service_connect,
>                                                 service_disconnect,
>                                                 client, NULL);
> +
> +       if (!root_path)
> +               return g_dbus_client_ref(client);
> +
>         client->added_watch = g_dbus_add_signal_watch(connection, service,
>                                                 client->root_path,
>                                                 DBUS_INTERFACE_OBJECT_MANAGER,
> --
> 2.1.0

Applied.


-- 
Luiz Augusto von Dentz

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2015-03-25 10:39 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-03-24 12:10 [PATCH BlueZ 1/2] gdbus: Make GDBusClient work without ObjectManager Luiz Augusto von Dentz
2015-03-24 12:10 ` [PATCH BlueZ 2/2] unit/test-dbus-client: Add client_no_object_manager test Luiz Augusto von Dentz
2015-03-25 10:39 ` [PATCH BlueZ 1/2] gdbus: Make GDBusClient work without ObjectManager Luiz Augusto von Dentz

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.