mirror of
https://github.com/AsamK/signal-cli
synced 2025-08-29 10:30:38 +00:00
Refactor dbus client mode to improve maintainability
This commit is contained in:
parent
d72b838560
commit
593cd7d8ca
10 changed files with 531 additions and 291 deletions
|
@ -8,7 +8,6 @@ import net.sourceforge.argparse4j.inf.Namespace;
|
|||
import org.asamk.Signal;
|
||||
import org.asamk.signal.commands.Command;
|
||||
import org.asamk.signal.commands.Commands;
|
||||
import org.asamk.signal.commands.DbusCommand;
|
||||
import org.asamk.signal.commands.ExtendedDbusCommand;
|
||||
import org.asamk.signal.commands.LocalCommand;
|
||||
import org.asamk.signal.commands.MultiLocalCommand;
|
||||
|
@ -19,6 +18,7 @@ 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.DbusManagerImpl;
|
||||
import org.asamk.signal.manager.Manager;
|
||||
import org.asamk.signal.manager.NotRegisteredException;
|
||||
import org.asamk.signal.manager.ProvisioningManager;
|
||||
|
@ -29,6 +29,7 @@ import org.asamk.signal.manager.storage.identities.TrustNewIdentity;
|
|||
import org.asamk.signal.util.IOUtils;
|
||||
import org.freedesktop.dbus.connections.impl.DBusConnection;
|
||||
import org.freedesktop.dbus.exceptions.DBusException;
|
||||
import org.freedesktop.dbus.exceptions.DBusExecutionException;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.whispersystems.signalservice.api.util.PhoneNumberFormatter;
|
||||
|
@ -346,8 +347,14 @@ public class App {
|
|||
) throws CommandException {
|
||||
if (command instanceof ExtendedDbusCommand) {
|
||||
((ExtendedDbusCommand) command).handleCommand(ns, ts, dBusConn, outputWriter);
|
||||
} else if (command instanceof DbusCommand) {
|
||||
((DbusCommand) command).handleCommand(ns, ts, outputWriter);
|
||||
} else if (command instanceof LocalCommand) {
|
||||
try {
|
||||
((LocalCommand) command).handleCommand(ns, new DbusManagerImpl(ts), outputWriter);
|
||||
} catch (UnsupportedOperationException e) {
|
||||
throw new UserErrorException("Command is not yet implemented via dbus", e);
|
||||
} catch (DBusExecutionException e) {
|
||||
throw new UnexpectedErrorException(e.getMessage(), e);
|
||||
}
|
||||
} else {
|
||||
throw new UserErrorException("Command is not yet implemented via dbus");
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue