mirror of
https://github.com/AsamK/signal-cli
synced 2025-08-30 02:50:39 +00:00
Move all dbus interaction to dbus package
This commit is contained in:
parent
7e9940be4a
commit
9741c93ce9
4 changed files with 31 additions and 31 deletions
|
@ -16,7 +16,6 @@ import org.asamk.signal.commands.exceptions.CommandException;
|
|||
import org.asamk.signal.commands.exceptions.IOErrorException;
|
||||
import org.asamk.signal.commands.exceptions.UnexpectedErrorException;
|
||||
import org.asamk.signal.commands.exceptions.UserErrorException;
|
||||
import org.asamk.signal.dbus.DbusCommandHandler;
|
||||
import org.asamk.signal.manager.Manager;
|
||||
import org.asamk.signal.manager.RegistrationManager;
|
||||
import org.asamk.signal.manager.Settings;
|
||||
|
@ -29,11 +28,6 @@ import org.asamk.signal.output.JsonWriterImpl;
|
|||
import org.asamk.signal.output.OutputWriter;
|
||||
import org.asamk.signal.output.PlainTextWriterImpl;
|
||||
import org.asamk.signal.util.IOUtils;
|
||||
import org.freedesktop.dbus.connections.impl.DBusConnection;
|
||||
import org.freedesktop.dbus.connections.impl.DBusConnectionBuilder;
|
||||
import org.freedesktop.dbus.errors.ServiceUnknown;
|
||||
import org.freedesktop.dbus.exceptions.DBusException;
|
||||
import org.freedesktop.dbus.exceptions.DBusExecutionException;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
|
@ -44,6 +38,7 @@ import java.io.OutputStreamWriter;
|
|||
import java.util.Set;
|
||||
|
||||
import static net.sourceforge.argparse4j.DefaultSettings.VERSION_0_9_0_DEFAULT_SETTINGS;
|
||||
import static org.asamk.signal.dbus.DbusCommandHandler.initDbusClient;
|
||||
|
||||
public class App {
|
||||
|
||||
|
@ -331,24 +326,6 @@ public class App {
|
|||
}
|
||||
}
|
||||
|
||||
private void initDbusClient(
|
||||
final Command command, final String account, final boolean systemBus, final CommandHandler commandHandler
|
||||
) throws CommandException {
|
||||
try {
|
||||
final var busType = systemBus ? DBusConnection.DBusBusType.SYSTEM : DBusConnection.DBusBusType.SESSION;
|
||||
try (var dBusConn = DBusConnectionBuilder.forType(busType).build()) {
|
||||
DbusCommandHandler.handleCommand(command, account, dBusConn, commandHandler);
|
||||
}
|
||||
} 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);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the default data directory to be used by signal-cli.
|
||||
*/
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue