Remove workaround for getBoolean from JsonRpcLocalCommand

This commit is contained in:
AsamK 2021-09-30 19:33:57 +02:00
parent f44b148946
commit c9f5550d18
17 changed files with 22 additions and 31 deletions

View file

@ -117,8 +117,8 @@ public class App {
var username = ns.getString("username");
final var useDbus = ns.getBoolean("dbus");
final var useDbusSystem = ns.getBoolean("dbus-system");
final var useDbus = Boolean.TRUE.equals(ns.getBoolean("dbus"));
final var useDbusSystem = Boolean.TRUE.equals(ns.getBoolean("dbus-system"));
if (useDbus || useDbusSystem) {
// If username is null, it will connect to the default object path
initDbusClient(command, username, useDbusSystem, outputWriter);

View file

@ -80,7 +80,7 @@ public class Main {
return false;
}
return ns.getBoolean("verbose");
return Boolean.TRUE.equals(ns.getBoolean("verbose"));
}
private static void configureLogging(final boolean verbose) {

View file

@ -54,10 +54,10 @@ public class DaemonCommand implements MultiLocalCommand {
public void handleCommand(
final Namespace ns, final Manager m, final OutputWriter outputWriter
) throws CommandException {
boolean ignoreAttachments = ns.getBoolean("ignore-attachments");
boolean ignoreAttachments = Boolean.TRUE.equals(ns.getBoolean("ignore-attachments"));
DBusConnection.DBusBusType busType;
if (ns.getBoolean("system")) {
if (Boolean.TRUE.equals(ns.getBoolean("system"))) {
busType = DBusConnection.DBusBusType.SYSTEM;
} else {
busType = DBusConnection.DBusBusType.SESSION;
@ -83,10 +83,10 @@ public class DaemonCommand implements MultiLocalCommand {
public void handleCommand(
final Namespace ns, final List<Manager> managers, final SignalCreator c, final OutputWriter outputWriter
) throws CommandException {
boolean ignoreAttachments = ns.getBoolean("ignore-attachments");
boolean ignoreAttachments = Boolean.TRUE.equals(ns.getBoolean("ignore-attachments"));
DBusConnection.DBusBusType busType;
if (ns.getBoolean("system")) {
if (Boolean.TRUE.equals(ns.getBoolean("system"))) {
busType = DBusConnection.DBusBusType.SYSTEM;
} else {
busType = DBusConnection.DBusBusType.SESSION;

View file

@ -65,7 +65,7 @@ public class JsonRpcDispatcherCommand implements LocalCommand {
public void handleCommand(
final Namespace ns, final Manager m, final OutputWriter outputWriter
) throws CommandException {
final boolean ignoreAttachments = ns.getBoolean("ignore-attachments");
final boolean ignoreAttachments = Boolean.TRUE.equals(ns.getBoolean("ignore-attachments"));
final var objectMapper = Util.createJsonObjectMapper();
final var jsonRpcSender = new JsonRpcSender((JsonWriter) outputWriter);

View file

@ -64,14 +64,5 @@ public interface JsonRpcLocalCommand extends JsonRpcCommand<Map<String, Object>>
return super.getList(dest + "s");
}
@Override
public Boolean getBoolean(String dest) {
Boolean maybeGotten = this.get(dest);
if (maybeGotten == null) {
maybeGotten = false;
}
return maybeGotten;
}
}
}

View file

@ -102,7 +102,7 @@ public class ListGroupsCommand implements JsonRpcLocalCommand {
jsonWriter.write(jsonGroups);
} else {
final var writer = (PlainTextWriter) outputWriter;
boolean detailed = ns.getBoolean("detailed");
boolean detailed = Boolean.TRUE.equals(ns.getBoolean("detailed"));
for (var group : groups) {
printGroupPlainText(writer, group, detailed);
}

View file

@ -61,7 +61,7 @@ public class QuitGroupCommand implements JsonRpcLocalCommand {
} catch (NotAGroupMemberException e) {
logger.info("User is not a group member");
}
if (ns.getBoolean("delete")) {
if (Boolean.TRUE.equals(ns.getBoolean("delete"))) {
logger.debug("Deleting group {}", groupId);
m.deleteGroup(groupId);
}

View file

@ -147,7 +147,7 @@ public class ReceiveCommand implements ExtendedDbusCommand, LocalCommand {
returnOnTimeout = false;
timeout = 3600;
}
boolean ignoreAttachments = ns.getBoolean("ignore-attachments");
boolean ignoreAttachments = Boolean.TRUE.equals(ns.getBoolean("ignore-attachments"));
try {
final var handler = outputWriter instanceof JsonWriter ? new JsonReceiveMessageHandler(m,
(JsonWriter) outputWriter) : new ReceiveMessageHandler(m, (PlainTextWriter) outputWriter);

View file

@ -31,7 +31,7 @@ public class RegisterCommand implements RegistrationCommand {
@Override
public void handleCommand(final Namespace ns, final RegistrationManager m) throws CommandException {
final boolean voiceVerification = ns.getBoolean("voice");
final boolean voiceVerification = Boolean.TRUE.equals(ns.getBoolean("voice"));
final var captchaString = ns.getString("captcha");
final var captcha = captchaString == null ? null : captchaString.replace("signalcaptcha://", "");

View file

@ -43,7 +43,7 @@ public class RemoteDeleteCommand implements JsonRpcLocalCommand {
public void handleCommand(
final Namespace ns, final Manager m, final OutputWriter outputWriter
) throws CommandException {
final var isNoteToSelf = ns.getBoolean("note-to-self");
final var isNoteToSelf = Boolean.TRUE.equals(ns.getBoolean("note-to-self"));
final var recipientStrings = ns.<String>getList("recipient");
final var groupIdStrings = ns.<String>getList("group-id");

View file

@ -58,7 +58,7 @@ public class SendCommand implements JsonRpcLocalCommand {
public void handleCommand(
final Namespace ns, final Manager m, final OutputWriter outputWriter
) throws CommandException {
final var isNoteToSelf = ns.getBoolean("note-to-self");
final var isNoteToSelf = Boolean.TRUE.equals(ns.getBoolean("note-to-self"));
final var recipientStrings = ns.<String>getList("recipient");
final var groupIdStrings = ns.<String>getList("group-id");
@ -67,7 +67,7 @@ public class SendCommand implements JsonRpcLocalCommand {
recipientStrings,
groupIdStrings);
final var isEndSession = ns.getBoolean("end-session");
final var isEndSession = Boolean.TRUE.equals(ns.getBoolean("end-session"));
if (isEndSession) {
final var singleRecipients = recipientIdentifiers.stream()
.filter(r -> r instanceof RecipientIdentifier.Single)

View file

@ -52,7 +52,7 @@ public class SendReactionCommand implements JsonRpcLocalCommand {
public void handleCommand(
final Namespace ns, final Manager m, final OutputWriter outputWriter
) throws CommandException {
final var isNoteToSelf = ns.getBoolean("note-to-self");
final var isNoteToSelf = Boolean.TRUE.equals(ns.getBoolean("note-to-self"));
final var recipientStrings = ns.<String>getList("recipient");
final var groupIdStrings = ns.<String>getList("group-id");
@ -62,7 +62,7 @@ public class SendReactionCommand implements JsonRpcLocalCommand {
groupIdStrings);
final var emoji = ns.getString("emoji");
final var isRemove = ns.getBoolean("remove");
final var isRemove = Boolean.TRUE.equals(ns.getBoolean("remove"));
final var targetAuthor = ns.getString("target-author");
final var targetTimestamp = ns.getLong("target-timestamp");

View file

@ -41,7 +41,7 @@ public class SendTypingCommand implements JsonRpcLocalCommand {
) throws CommandException {
final var recipientStrings = ns.<String>getList("recipient");
final var groupIdStrings = ns.<String>getList("group-id");
final var action = ns.getBoolean("stop") ? TypingAction.STOP : TypingAction.START;
final var action = Boolean.TRUE.equals(ns.getBoolean("stop")) ? TypingAction.STOP : TypingAction.START;
final var recipientIdentifiers = new HashSet<RecipientIdentifier>();
if (recipientStrings != null) {

View file

@ -39,7 +39,7 @@ public class TrustCommand implements JsonRpcLocalCommand {
) throws CommandException {
var recipentString = ns.getString("recipient");
var recipient = CommandUtil.getSingleRecipientIdentifier(recipentString, m.getSelfNumber());
if (ns.getBoolean("trust-all-known-keys")) {
if (Boolean.TRUE.equals(ns.getBoolean("trust-all-known-keys"))) {
boolean res = m.trustIdentityAllKeys(recipient);
if (!res) {
throw new UserErrorException("Failed to set the trust for this number, make sure the number is correct.");

View file

@ -31,7 +31,7 @@ public class UnregisterCommand implements LocalCommand {
final Namespace ns, final Manager m, final OutputWriter outputWriter
) throws CommandException {
try {
if (ns.getBoolean("delete-account")) {
if (Boolean.TRUE.equals(ns.getBoolean("delete-account"))) {
m.deleteAccount();
} else {
m.unregister();

View file

@ -121,7 +121,7 @@ public class UpdateGroupCommand implements JsonRpcLocalCommand {
var groupAdmins = CommandUtil.getSingleRecipientIdentifiers(ns.getList("admin"), localNumber);
var groupRemoveAdmins = CommandUtil.getSingleRecipientIdentifiers(ns.getList("remove-admin"), localNumber);
var groupAvatar = ns.getString("avatar");
var groupResetLink = ns.getBoolean("reset-link");
var groupResetLink = Boolean.TRUE.equals(ns.getBoolean("reset-link"));
var groupLinkState = getGroupLinkState(ns.getString("link"));
var groupExpiration = ns.getInt("expiration");
var groupAddMemberPermission = getGroupPermission(ns.getString("set-permission-add-member"));

View file

@ -42,7 +42,7 @@ public class UpdateProfileCommand implements JsonRpcLocalCommand {
var about = ns.getString("about");
var aboutEmoji = ns.getString("about-emoji");
var avatarPath = ns.getString("avatar");
boolean removeAvatar = ns.getBoolean("remove-avatar");
boolean removeAvatar = Boolean.TRUE.equals(ns.getBoolean("remove-avatar"));
Optional<File> avatarFile = removeAvatar
? Optional.absent()