From 942dae9a4ff649f9a36c482f18269a2d38ac2084 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Patrik=20=C3=85kesson?= <66364872+pataxis@users.noreply.github.com> Date: Thu, 12 Oct 2023 18:40:48 +0200 Subject: [PATCH 1/3] docs/develop: Replace g_dbus_proxy_call with g_dbus_connection_call (#224) --- .../VAPIX-access-for-ACAP-applications.md | 35 +++++++------------ 1 file changed, 12 insertions(+), 23 deletions(-) diff --git a/docs/develop/VAPIX-access-for-ACAP-applications.md b/docs/develop/VAPIX-access-for-ACAP-applications.md index d7a3888..869c009 100644 --- a/docs/develop/VAPIX-access-for-ACAP-applications.md +++ b/docs/develop/VAPIX-access-for-ACAP-applications.md @@ -53,35 +53,24 @@ An ACAP application can acquire VAPIX service account credentials through a D-Bu GDBusConnection *connection = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, &error); ``` -2. Create a proxy object for your D-Bus interface: - - This proxy allows users to interact with your D-Bus service or interface. - - ```c - GDBusProxy *proxy = g_dbus_proxy_new_sync(connection, - G_DBUS_PROXY_FLAGS_NONE, - NULL, - "com.axis.HTTPConf1", - "/com/axis/HttpConf1/Auth", - "com.axis.HTTPConf1.Auth1", - NULL, - &error); - ``` - -3. Invoke the D-Bus method using the proxy: +2. Invoke the D-Bus method using the D-Bus connection: The user can effectively call the method that returns the credentials by doing this. ```c GVariant *username = g_variant_new("(s)", "testuser"); - GVariant *result = g_dbus_proxy_call_sync(proxy, - "com.axis.HTTPConf1.Auth1.GetVapixServiceAccountCredentials", - username, - G_DBUS_CALL_FLAGS_NONE, - -1, - NULL, - &error); + GVariant *result = g_dbus_connection_call_sync (connection, + "com.axis.HTTPConf1", + "/com/axis/HttpConf1/Auth", + "com.axis.HTTPConf1.Auth1", + "GetVapixServiceAccountCredentials", + username, + NULL, + G_DBUS_CALL_FLAGS_NONE, + -1, + NULL, + &error); ``` When the `GetVapixServiceAccountCredentials` method is invoked, it generates credentials with the specified username and a random password, which is returned to the ACAP as a string. From 3cd60da25a35bc385ca6bb90b9747a7986fcf892 Mon Sep 17 00:00:00 2001 From: pataxis Date: Thu, 12 Oct 2023 18:47:45 +0200 Subject: [PATCH 2/3] Revert "docs/develop: Replace g_dbus_proxy_call with g_dbus_connection_call (#224)" This reverts commit 942dae9a4ff649f9a36c482f18269a2d38ac2084. --- .../VAPIX-access-for-ACAP-applications.md | 35 ++++++++++++------- 1 file changed, 23 insertions(+), 12 deletions(-) diff --git a/docs/develop/VAPIX-access-for-ACAP-applications.md b/docs/develop/VAPIX-access-for-ACAP-applications.md index 869c009..d7a3888 100644 --- a/docs/develop/VAPIX-access-for-ACAP-applications.md +++ b/docs/develop/VAPIX-access-for-ACAP-applications.md @@ -53,24 +53,35 @@ An ACAP application can acquire VAPIX service account credentials through a D-Bu GDBusConnection *connection = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, &error); ``` -2. Invoke the D-Bus method using the D-Bus connection: +2. Create a proxy object for your D-Bus interface: + + This proxy allows users to interact with your D-Bus service or interface. + + ```c + GDBusProxy *proxy = g_dbus_proxy_new_sync(connection, + G_DBUS_PROXY_FLAGS_NONE, + NULL, + "com.axis.HTTPConf1", + "/com/axis/HttpConf1/Auth", + "com.axis.HTTPConf1.Auth1", + NULL, + &error); + ``` + +3. Invoke the D-Bus method using the proxy: The user can effectively call the method that returns the credentials by doing this. ```c GVariant *username = g_variant_new("(s)", "testuser"); - GVariant *result = g_dbus_connection_call_sync (connection, - "com.axis.HTTPConf1", - "/com/axis/HttpConf1/Auth", - "com.axis.HTTPConf1.Auth1", - "GetVapixServiceAccountCredentials", - username, - NULL, - G_DBUS_CALL_FLAGS_NONE, - -1, - NULL, - &error); + GVariant *result = g_dbus_proxy_call_sync(proxy, + "com.axis.HTTPConf1.Auth1.GetVapixServiceAccountCredentials", + username, + G_DBUS_CALL_FLAGS_NONE, + -1, + NULL, + &error); ``` When the `GetVapixServiceAccountCredentials` method is invoked, it generates credentials with the specified username and a random password, which is returned to the ACAP as a string. From 085df65858a84109f48fae1b7a54ab49dc59d321 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johan=20Bj=C3=A4reholt?= Date: Mon, 2 Oct 2023 10:06:28 +0200 Subject: [PATCH 3/3] docs/develop: Replace g_dbus_proxy_call with g_dbus_connection_call The example in "VAPIX access for ACAP applications" creates a connection to the bus, creates a proxy object and then calls the method. Creating a proxy for this use-case is unnecessary and does one or more D-Bus calls under the hood as you do not pass G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES which is necessary to make this request "lightweight". The better solution is to skip the proxy completely and just use g_dbus_connection_call_sync, as we do not use any of the features of the proxy. Change-Id: I1ba8781ab68492a426e150691b0015fc55be53d0 --- .../VAPIX-access-for-ACAP-applications.md | 35 +++++++------------ 1 file changed, 12 insertions(+), 23 deletions(-) diff --git a/docs/develop/VAPIX-access-for-ACAP-applications.md b/docs/develop/VAPIX-access-for-ACAP-applications.md index d7a3888..869c009 100644 --- a/docs/develop/VAPIX-access-for-ACAP-applications.md +++ b/docs/develop/VAPIX-access-for-ACAP-applications.md @@ -53,35 +53,24 @@ An ACAP application can acquire VAPIX service account credentials through a D-Bu GDBusConnection *connection = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, &error); ``` -2. Create a proxy object for your D-Bus interface: - - This proxy allows users to interact with your D-Bus service or interface. - - ```c - GDBusProxy *proxy = g_dbus_proxy_new_sync(connection, - G_DBUS_PROXY_FLAGS_NONE, - NULL, - "com.axis.HTTPConf1", - "/com/axis/HttpConf1/Auth", - "com.axis.HTTPConf1.Auth1", - NULL, - &error); - ``` - -3. Invoke the D-Bus method using the proxy: +2. Invoke the D-Bus method using the D-Bus connection: The user can effectively call the method that returns the credentials by doing this. ```c GVariant *username = g_variant_new("(s)", "testuser"); - GVariant *result = g_dbus_proxy_call_sync(proxy, - "com.axis.HTTPConf1.Auth1.GetVapixServiceAccountCredentials", - username, - G_DBUS_CALL_FLAGS_NONE, - -1, - NULL, - &error); + GVariant *result = g_dbus_connection_call_sync (connection, + "com.axis.HTTPConf1", + "/com/axis/HttpConf1/Auth", + "com.axis.HTTPConf1.Auth1", + "GetVapixServiceAccountCredentials", + username, + NULL, + G_DBUS_CALL_FLAGS_NONE, + -1, + NULL, + &error); ``` When the `GetVapixServiceAccountCredentials` method is invoked, it generates credentials with the specified username and a random password, which is returned to the ACAP as a string.