- try (DBusConnection dBusConn = DBusConnection.getConnection(busType)) {
- Signal ts = dBusConn.getRemoteObject(DbusConfig.getBusname(),
- DbusConfig.getObjectPath(username),
- Signal.class);
+ try (var dBusConn = DBusConnection.getConnection(busType)) {
+ var accountObjectPath = account == null ? tryGetSingleAccountObjectPath(dBusConn) : null;
+ if (accountObjectPath == null) {
+ accountObjectPath = DbusConfig.getObjectPath(account);
+ }
+ var ts = dBusConn.getRemoteObject(DbusConfig.getBusname(), accountObjectPath, Signal.class);
+
+ handleCommand(command, ts, dBusConn, outputWriter);
+ }
+ } catch (ServiceUnknown e) {
+ throw new UserErrorException("signal-cli DBus daemon not running on "
+ + (systemBus ? "system" : "session")
+ + " bus: "
+ + e.getMessage(), e);
+ } catch (DBusExecutionException | DBusException | IOException e) {
+ throw new UnexpectedErrorException("Dbus client failed: " + e.getMessage(), e);
+ }
+ }