All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH BlueZ v1 v6] tools/obexctl: Add support for system/session bus
@ 2024-12-12 12:49 quic_dgangire
  2024-12-12 14:20 ` [BlueZ,v1,v6] " bluez.test.bot
  2024-12-12 18:10 ` [PATCH BlueZ v1 v6] " patchwork-bot+bluetooth
  0 siblings, 2 replies; 3+ messages in thread
From: quic_dgangire @ 2024-12-12 12:49 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: quic_mohamull, quic_hbandi, quic_anubhavg

From: Damodar Reddy GangiReddy <quic_dgangire@quicinc.com>

Currently obexctl only uses session bus.
As obexd has been enabled support for both session and system bus.
Configuring obexctl to use session/system bus during the runtime
if the name is available over session or system bus.

---
 tools/obexctl.c | 49 ++++++++++++++++++++++++++++++++++++++++++-------
 1 file changed, 42 insertions(+), 7 deletions(-)

diff --git a/tools/obexctl.c b/tools/obexctl.c
index a398b095b..9adf8088a 100644
--- a/tools/obexctl.c
+++ b/tools/obexctl.c
@@ -43,8 +43,10 @@
 #define OBEX_PBAP_INTERFACE "org.bluez.obex.PhonebookAccess1"
 #define OBEX_MAP_INTERFACE "org.bluez.obex.MessageAccess1"
 #define OBEX_MSG_INTERFACE "org.bluez.obex.Message1"
+#define OBEXD_SERVICE  "org.bluez.obex"
 
-static DBusConnection *dbus_conn;
+static DBusConnection *dbus_session_conn;
+static DBusConnection *dbus_system_conn;
 static GDBusProxy *default_session;
 static GList *sessions = NULL;
 static GList *opps = NULL;
@@ -2149,19 +2151,47 @@ static void property_changed(GDBusProxy *proxy, const char *name,
 		session_property_changed(proxy, name, iter);
 }
 
+static bool check_obexd_service(DBusConnection *conn)
+{
+	DBusError err;
+	bool has_owner;
+
+	dbus_error_init(&err);
+	has_owner = dbus_bus_name_has_owner(conn, OBEXD_SERVICE, &err);
+
+	if (dbus_error_is_set(&err))
+		dbus_error_free(&err);
+
+	return has_owner;
+}
+
 int main(int argc, char *argv[])
 {
-	GDBusClient *client;
+	GDBusClient *client = NULL;
 	int status;
+	bool session_bus_active;
+	bool system_bus_active;
 
 	bt_shell_init(argc, argv, NULL);
 	bt_shell_set_menu(&main_menu);
 	bt_shell_set_prompt(PROMPT, NULL);
 
-	dbus_conn = g_dbus_setup_bus(DBUS_BUS_SESSION, NULL, NULL);
+	session_bus_active = false;
+	system_bus_active = false;
+	dbus_session_conn = g_dbus_setup_bus(DBUS_BUS_SESSION, NULL, NULL);
+	if (dbus_session_conn)
+		session_bus_active = check_obexd_service(dbus_session_conn);
 
-	client = g_dbus_client_new(dbus_conn, "org.bluez.obex",
-							"/org/bluez/obex");
+	dbus_system_conn = g_dbus_setup_bus(DBUS_BUS_SYSTEM, NULL, NULL);
+	if (dbus_system_conn)
+		system_bus_active = check_obexd_service(dbus_system_conn);
+
+	if (session_bus_active)
+		client = g_dbus_client_new(dbus_session_conn, OBEXD_SERVICE,
+								"/org/bluez/obex");
+	else if (system_bus_active)
+		client = g_dbus_client_new(dbus_system_conn, OBEXD_SERVICE,
+								"/org/bluez/obex");
 
 	g_dbus_client_set_connect_watch(client, connect_handler, NULL);
 	g_dbus_client_set_disconnect_watch(client, disconnect_handler, NULL);
@@ -2171,9 +2201,14 @@ int main(int argc, char *argv[])
 
 	status = bt_shell_run();
 
-	g_dbus_client_unref(client);
+	if (client)
+		g_dbus_client_unref(client);
+
+	if (dbus_session_conn)
+		dbus_connection_unref(dbus_session_conn);
 
-	dbus_connection_unref(dbus_conn);
+	if (dbus_system_conn)
+		dbus_connection_unref(dbus_system_conn);
 
 	return status;
 }
-- 
2.34.1


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

* RE: [BlueZ,v1,v6] tools/obexctl: Add support for system/session bus
  2024-12-12 12:49 [PATCH BlueZ v1 v6] tools/obexctl: Add support for system/session bus quic_dgangire
@ 2024-12-12 14:20 ` bluez.test.bot
  2024-12-12 18:10 ` [PATCH BlueZ v1 v6] " patchwork-bot+bluetooth
  1 sibling, 0 replies; 3+ messages in thread
From: bluez.test.bot @ 2024-12-12 14:20 UTC (permalink / raw)
  To: linux-bluetooth, quic_dgangire

[-- Attachment #1: Type: text/plain, Size: 1260 bytes --]

This is automated email and please do not reply to this email!

Dear submitter,

Thank you for submitting the patches to the linux bluetooth mailing list.
This is a CI test results with your patch series:
PW Link:https://patchwork.kernel.org/project/bluetooth/list/?series=917182

---Test result---

Test Summary:
CheckPatch                    PENDING   0.27 seconds
GitLint                       PENDING   0.38 seconds
BuildEll                      PASS      20.43 seconds
BluezMake                     PASS      1540.41 seconds
MakeCheck                     PASS      13.47 seconds
MakeDistcheck                 PASS      158.08 seconds
CheckValgrind                 PASS      214.11 seconds
CheckSmatch                   PASS      271.75 seconds
bluezmakeextell               PASS      98.61 seconds
IncrementalBuild              PENDING   0.40 seconds
ScanBuild                     PASS      846.43 seconds

Details
##############################
Test: CheckPatch - PENDING
Desc: Run checkpatch.pl script
Output:

##############################
Test: GitLint - PENDING
Desc: Run gitlint
Output:

##############################
Test: IncrementalBuild - PENDING
Desc: Incremental build with the patches in the series
Output:



---
Regards,
Linux Bluetooth


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

* Re: [PATCH BlueZ v1 v6] tools/obexctl: Add support for system/session bus
  2024-12-12 12:49 [PATCH BlueZ v1 v6] tools/obexctl: Add support for system/session bus quic_dgangire
  2024-12-12 14:20 ` [BlueZ,v1,v6] " bluez.test.bot
@ 2024-12-12 18:10 ` patchwork-bot+bluetooth
  1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+bluetooth @ 2024-12-12 18:10 UTC (permalink / raw)
  To: Damodar Reddy GangiReddy
  Cc: linux-bluetooth, quic_mohamull, quic_hbandi, quic_anubhavg

Hello:

This patch was applied to bluetooth/bluez.git (master)
by Luiz Augusto von Dentz <luiz.von.dentz@intel.com>:

On Thu, 12 Dec 2024 18:19:03 +0530 you wrote:
> From: Damodar Reddy GangiReddy <quic_dgangire@quicinc.com>
> 
> Currently obexctl only uses session bus.
> As obexd has been enabled support for both session and system bus.
> Configuring obexctl to use session/system bus during the runtime
> if the name is available over session or system bus.
> 
> [...]

Here is the summary with links:
  - [BlueZ,v1,v6] tools/obexctl: Add support for system/session bus
    https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=40e5ebd0cb2c

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



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

end of thread, other threads:[~2024-12-12 18:10 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-12-12 12:49 [PATCH BlueZ v1 v6] tools/obexctl: Add support for system/session bus quic_dgangire
2024-12-12 14:20 ` [BlueZ,v1,v6] " bluez.test.bot
2024-12-12 18:10 ` [PATCH BlueZ v1 v6] " patchwork-bot+bluetooth

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.