mirror of
https://github.com/AsamK/signal-cli
synced 2025-08-30 02:50:39 +00:00
Add PlainTextWriter interface
This commit is contained in:
parent
641dc7577c
commit
15e8029715
16 changed files with 69 additions and 66 deletions
|
@ -6,7 +6,7 @@ import net.sourceforge.argparse4j.inf.Subparser;
|
|||
import org.asamk.signal.JsonWriter;
|
||||
import org.asamk.signal.OutputType;
|
||||
import org.asamk.signal.OutputWriter;
|
||||
import org.asamk.signal.PlainTextWriterImpl;
|
||||
import org.asamk.signal.PlainTextWriter;
|
||||
import org.asamk.signal.commands.exceptions.CommandException;
|
||||
import org.asamk.signal.commands.exceptions.IOErrorException;
|
||||
import org.asamk.signal.manager.Manager;
|
||||
|
@ -60,7 +60,7 @@ public class GetUserStatusCommand implements LocalCommand {
|
|||
|
||||
jsonWriter.write(jsonUserStatuses);
|
||||
} else {
|
||||
final var writer = (PlainTextWriterImpl) outputWriter;
|
||||
final var writer = (PlainTextWriter) outputWriter;
|
||||
|
||||
for (var entry : registered.entrySet()) {
|
||||
writer.println("{}: {}", entry.getKey(), entry.getValue());
|
||||
|
|
|
@ -4,7 +4,7 @@ import net.sourceforge.argparse4j.inf.Namespace;
|
|||
import net.sourceforge.argparse4j.inf.Subparser;
|
||||
|
||||
import org.asamk.signal.OutputWriter;
|
||||
import org.asamk.signal.PlainTextWriterImpl;
|
||||
import org.asamk.signal.PlainTextWriter;
|
||||
import org.asamk.signal.commands.exceptions.CommandException;
|
||||
import org.asamk.signal.commands.exceptions.IOErrorException;
|
||||
import org.asamk.signal.commands.exceptions.UnexpectedErrorException;
|
||||
|
@ -49,7 +49,7 @@ public class JoinGroupCommand implements LocalCommand {
|
|||
}
|
||||
|
||||
try {
|
||||
final var writer = (PlainTextWriterImpl) outputWriter;
|
||||
final var writer = (PlainTextWriter) outputWriter;
|
||||
|
||||
final var results = m.joinGroup(linkUrl);
|
||||
var newGroupId = results.first();
|
||||
|
|
|
@ -4,7 +4,7 @@ import net.sourceforge.argparse4j.inf.Namespace;
|
|||
import net.sourceforge.argparse4j.inf.Subparser;
|
||||
|
||||
import org.asamk.signal.OutputWriter;
|
||||
import org.asamk.signal.PlainTextWriterImpl;
|
||||
import org.asamk.signal.PlainTextWriter;
|
||||
import org.asamk.signal.commands.exceptions.CommandException;
|
||||
import org.asamk.signal.commands.exceptions.IOErrorException;
|
||||
import org.asamk.signal.commands.exceptions.UserErrorException;
|
||||
|
@ -32,7 +32,7 @@ public class LinkCommand implements ProvisioningCommand {
|
|||
|
||||
@Override
|
||||
public void handleCommand(final Namespace ns, final ProvisioningManager m) throws CommandException {
|
||||
final var writer = (PlainTextWriterImpl) outputWriter;
|
||||
final var writer = (PlainTextWriter) outputWriter;
|
||||
|
||||
var deviceName = ns.getString("name");
|
||||
if (deviceName == null) {
|
||||
|
|
|
@ -4,7 +4,7 @@ import net.sourceforge.argparse4j.inf.Namespace;
|
|||
import net.sourceforge.argparse4j.inf.Subparser;
|
||||
|
||||
import org.asamk.signal.OutputWriter;
|
||||
import org.asamk.signal.PlainTextWriterImpl;
|
||||
import org.asamk.signal.PlainTextWriter;
|
||||
import org.asamk.signal.manager.Manager;
|
||||
|
||||
import static org.asamk.signal.util.Util.getLegacyIdentifier;
|
||||
|
@ -23,7 +23,7 @@ public class ListContactsCommand implements LocalCommand {
|
|||
|
||||
@Override
|
||||
public void handleCommand(final Namespace ns, final Manager m) {
|
||||
final var writer = (PlainTextWriterImpl) outputWriter;
|
||||
final var writer = (PlainTextWriter) outputWriter;
|
||||
|
||||
var contacts = m.getContacts();
|
||||
for (var c : contacts) {
|
||||
|
|
|
@ -4,7 +4,7 @@ import net.sourceforge.argparse4j.inf.Namespace;
|
|||
import net.sourceforge.argparse4j.inf.Subparser;
|
||||
|
||||
import org.asamk.signal.OutputWriter;
|
||||
import org.asamk.signal.PlainTextWriterImpl;
|
||||
import org.asamk.signal.PlainTextWriter;
|
||||
import org.asamk.signal.commands.exceptions.CommandException;
|
||||
import org.asamk.signal.commands.exceptions.IOErrorException;
|
||||
import org.asamk.signal.manager.Manager;
|
||||
|
@ -31,7 +31,7 @@ public class ListDevicesCommand implements LocalCommand {
|
|||
|
||||
@Override
|
||||
public void handleCommand(final Namespace ns, final Manager m) throws CommandException {
|
||||
final var writer = (PlainTextWriterImpl) outputWriter;
|
||||
final var writer = (PlainTextWriter) outputWriter;
|
||||
|
||||
List<Device> devices;
|
||||
try {
|
||||
|
|
|
@ -5,7 +5,6 @@ import net.sourceforge.argparse4j.inf.Subparser;
|
|||
|
||||
import org.asamk.signal.OutputWriter;
|
||||
import org.asamk.signal.PlainTextWriter;
|
||||
import org.asamk.signal.PlainTextWriterImpl;
|
||||
import org.asamk.signal.commands.exceptions.CommandException;
|
||||
import org.asamk.signal.commands.exceptions.UserErrorException;
|
||||
import org.asamk.signal.manager.Manager;
|
||||
|
@ -46,7 +45,7 @@ public class ListIdentitiesCommand implements LocalCommand {
|
|||
|
||||
@Override
|
||||
public void handleCommand(final Namespace ns, final Manager m) throws CommandException {
|
||||
final var writer = (PlainTextWriterImpl) outputWriter;
|
||||
final var writer = (PlainTextWriter) outputWriter;
|
||||
|
||||
var number = ns.getString("number");
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@ import net.sourceforge.argparse4j.inf.Namespace;
|
|||
import net.sourceforge.argparse4j.inf.Subparser;
|
||||
|
||||
import org.asamk.signal.OutputWriter;
|
||||
import org.asamk.signal.PlainTextWriterImpl;
|
||||
import org.asamk.signal.PlainTextWriter;
|
||||
import org.asamk.signal.commands.exceptions.CommandException;
|
||||
import org.asamk.signal.commands.exceptions.IOErrorException;
|
||||
import org.asamk.signal.commands.exceptions.UserErrorException;
|
||||
|
@ -48,7 +48,7 @@ public class QuitGroupCommand implements LocalCommand {
|
|||
|
||||
@Override
|
||||
public void handleCommand(final Namespace ns, final Manager m) throws CommandException {
|
||||
final var writer = (PlainTextWriterImpl) outputWriter;
|
||||
final var writer = (PlainTextWriter) outputWriter;
|
||||
|
||||
final GroupId groupId;
|
||||
try {
|
||||
|
|
|
@ -10,7 +10,6 @@ import org.asamk.signal.JsonWriter;
|
|||
import org.asamk.signal.OutputType;
|
||||
import org.asamk.signal.OutputWriter;
|
||||
import org.asamk.signal.PlainTextWriter;
|
||||
import org.asamk.signal.PlainTextWriterImpl;
|
||||
import org.asamk.signal.ReceiveMessageHandler;
|
||||
import org.asamk.signal.commands.exceptions.CommandException;
|
||||
import org.asamk.signal.commands.exceptions.IOErrorException;
|
||||
|
@ -79,7 +78,7 @@ public class ReceiveCommand implements ExtendedDbusCommand, LocalCommand {
|
|||
jsonWriter.write(object);
|
||||
});
|
||||
} else {
|
||||
final var writer = (PlainTextWriterImpl) outputWriter;
|
||||
final var writer = (PlainTextWriter) outputWriter;
|
||||
|
||||
dbusconnection.addSigHandler(Signal.MessageReceived.class, signal, messageReceived -> {
|
||||
writer.println("Envelope from: {}", messageReceived.getSender());
|
||||
|
|
|
@ -5,7 +5,7 @@ import net.sourceforge.argparse4j.inf.Subparser;
|
|||
|
||||
import org.asamk.Signal;
|
||||
import org.asamk.signal.OutputWriter;
|
||||
import org.asamk.signal.PlainTextWriterImpl;
|
||||
import org.asamk.signal.PlainTextWriter;
|
||||
import org.asamk.signal.commands.exceptions.CommandException;
|
||||
import org.asamk.signal.commands.exceptions.UnexpectedErrorException;
|
||||
import org.asamk.signal.commands.exceptions.UserErrorException;
|
||||
|
@ -49,7 +49,7 @@ public class RemoteDeleteCommand implements DbusCommand {
|
|||
|
||||
final long targetTimestamp = ns.getLong("target-timestamp");
|
||||
|
||||
final var writer = (PlainTextWriterImpl) outputWriter;
|
||||
final var writer = (PlainTextWriter) outputWriter;
|
||||
|
||||
byte[] groupId = null;
|
||||
if (groupIdString != null) {
|
||||
|
|
|
@ -6,7 +6,7 @@ import net.sourceforge.argparse4j.inf.Subparser;
|
|||
|
||||
import org.asamk.Signal;
|
||||
import org.asamk.signal.OutputWriter;
|
||||
import org.asamk.signal.PlainTextWriterImpl;
|
||||
import org.asamk.signal.PlainTextWriter;
|
||||
import org.asamk.signal.commands.exceptions.CommandException;
|
||||
import org.asamk.signal.commands.exceptions.UnexpectedErrorException;
|
||||
import org.asamk.signal.commands.exceptions.UserErrorException;
|
||||
|
@ -60,7 +60,7 @@ public class SendReactionCommand implements DbusCommand {
|
|||
final var targetAuthor = ns.getString("target-author");
|
||||
final long targetTimestamp = ns.getLong("target-timestamp");
|
||||
|
||||
final var writer = (PlainTextWriterImpl) outputWriter;
|
||||
final var writer = (PlainTextWriter) outputWriter;
|
||||
|
||||
byte[] groupId = null;
|
||||
if (groupIdString != null) {
|
||||
|
|
|
@ -32,7 +32,6 @@ public class UnregisterCommand implements LocalCommand {
|
|||
m.unregister();
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
throw new IOErrorException("Unregister error: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,7 +8,7 @@ import org.asamk.Signal;
|
|||
import org.asamk.signal.GroupLinkState;
|
||||
import org.asamk.signal.GroupPermission;
|
||||
import org.asamk.signal.OutputWriter;
|
||||
import org.asamk.signal.PlainTextWriterImpl;
|
||||
import org.asamk.signal.PlainTextWriter;
|
||||
import org.asamk.signal.commands.exceptions.CommandException;
|
||||
import org.asamk.signal.commands.exceptions.UnexpectedErrorException;
|
||||
import org.asamk.signal.commands.exceptions.UserErrorException;
|
||||
|
@ -74,7 +74,7 @@ public class UpdateGroupCommand implements DbusCommand, LocalCommand {
|
|||
|
||||
@Override
|
||||
public void handleCommand(final Namespace ns, final Manager m) throws CommandException {
|
||||
final var writer = (PlainTextWriterImpl) outputWriter;
|
||||
final var writer = (PlainTextWriter) outputWriter;
|
||||
GroupId groupId = null;
|
||||
final var groupIdString = ns.getString("group");
|
||||
if (groupIdString != null) {
|
||||
|
@ -142,7 +142,7 @@ public class UpdateGroupCommand implements DbusCommand, LocalCommand {
|
|||
|
||||
@Override
|
||||
public void handleCommand(final Namespace ns, final Signal signal) throws CommandException {
|
||||
final var writer = (PlainTextWriterImpl) outputWriter;
|
||||
final var writer = (PlainTextWriter) outputWriter;
|
||||
byte[] groupId = null;
|
||||
if (ns.getString("group") != null) {
|
||||
try {
|
||||
|
|
|
@ -4,7 +4,7 @@ import net.sourceforge.argparse4j.inf.Namespace;
|
|||
import net.sourceforge.argparse4j.inf.Subparser;
|
||||
|
||||
import org.asamk.signal.OutputWriter;
|
||||
import org.asamk.signal.PlainTextWriterImpl;
|
||||
import org.asamk.signal.PlainTextWriter;
|
||||
import org.asamk.signal.commands.exceptions.CommandException;
|
||||
import org.asamk.signal.commands.exceptions.IOErrorException;
|
||||
import org.asamk.signal.commands.exceptions.UserErrorException;
|
||||
|
@ -33,7 +33,7 @@ public class UploadStickerPackCommand implements LocalCommand {
|
|||
|
||||
@Override
|
||||
public void handleCommand(final Namespace ns, final Manager m) throws CommandException {
|
||||
final var writer = (PlainTextWriterImpl) outputWriter;
|
||||
final var writer = (PlainTextWriter) outputWriter;
|
||||
var path = new File(ns.getString("path"));
|
||||
|
||||
try {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue