mirror of
https://github.com/AsamK/signal-cli
synced 2025-09-02 20:40:38 +00:00
Added better depricated warning message and clarified some java doc stuff
This commit is contained in:
parent
eb401df4a2
commit
ca7754f554
3 changed files with 30 additions and 7 deletions
|
@ -8,6 +8,8 @@ import net.sourceforge.argparse4j.inf.Namespace;
|
||||||
import net.sourceforge.argparse4j.inf.Subparser;
|
import net.sourceforge.argparse4j.inf.Subparser;
|
||||||
|
|
||||||
import org.asamk.signal.manager.Manager;
|
import org.asamk.signal.manager.Manager;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
|
@ -17,6 +19,9 @@ import java.util.stream.Collectors;
|
||||||
|
|
||||||
public class GetUserStatusCommand implements LocalCommand {
|
public class GetUserStatusCommand implements LocalCommand {
|
||||||
|
|
||||||
|
// TODO delete later when "json" variable is removed
|
||||||
|
final static Logger logger = LoggerFactory.getLogger(GetUserStatusCommand.class);
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void attachToSubparser(final Subparser subparser) {
|
public void attachToSubparser(final Subparser subparser) {
|
||||||
subparser.addArgument("number").help("Phone number").nargs("+");
|
subparser.addArgument("number").help("Phone number").nargs("+");
|
||||||
|
@ -32,6 +37,13 @@ public class GetUserStatusCommand implements LocalCommand {
|
||||||
ObjectMapper jsonProcessor = new ObjectMapper();
|
ObjectMapper jsonProcessor = new ObjectMapper();
|
||||||
jsonProcessor.disable(JsonGenerator.Feature.AUTO_CLOSE_TARGET);
|
jsonProcessor.disable(JsonGenerator.Feature.AUTO_CLOSE_TARGET);
|
||||||
|
|
||||||
|
boolean inJson = ns.getString("output").equals("json");
|
||||||
|
|
||||||
|
// TODO delete later when "json" variable is removed
|
||||||
|
if (ns.getBoolean("json")) {
|
||||||
|
logger.warn("\"--json\" option has been deprecated, please use \"output\" instead.");
|
||||||
|
}
|
||||||
|
|
||||||
// Get a map of registration statuses
|
// Get a map of registration statuses
|
||||||
Map<String, Boolean> registered;
|
Map<String, Boolean> registered;
|
||||||
try {
|
try {
|
||||||
|
@ -41,12 +53,6 @@ public class GetUserStatusCommand implements LocalCommand {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean inJson = ns.getString("output").equals("json");
|
|
||||||
if (ns.getBoolean("json")) {
|
|
||||||
inJson = true;
|
|
||||||
System.out.println("WARNING: This parameter is now deprecated! Please use the \"output\" parameter instead.");
|
|
||||||
}
|
|
||||||
|
|
||||||
// Output
|
// Output
|
||||||
if (inJson) {
|
if (inJson) {
|
||||||
List<JsonIsRegistered> objects = registered.entrySet()
|
List<JsonIsRegistered> objects = registered.entrySet()
|
||||||
|
|
|
@ -20,6 +20,10 @@ import org.freedesktop.dbus.connections.impl.DBusConnection;
|
||||||
import org.freedesktop.dbus.exceptions.DBusException;
|
import org.freedesktop.dbus.exceptions.DBusException;
|
||||||
import org.whispersystems.util.Base64;
|
import org.whispersystems.util.Base64;
|
||||||
|
|
||||||
|
// TODO delete later when "json" variable is removed
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
|
@ -27,6 +31,9 @@ import static org.asamk.signal.util.ErrorUtils.handleAssertionError;
|
||||||
|
|
||||||
public class ReceiveCommand implements ExtendedDbusCommand, LocalCommand {
|
public class ReceiveCommand implements ExtendedDbusCommand, LocalCommand {
|
||||||
|
|
||||||
|
// TODO delete later when "json" variable is removed
|
||||||
|
final static Logger logger = LoggerFactory.getLogger(ReceiveCommand.class);
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void attachToSubparser(final Subparser subparser) {
|
public void attachToSubparser(final Subparser subparser) {
|
||||||
subparser.addArgument("-t", "--timeout")
|
subparser.addArgument("-t", "--timeout")
|
||||||
|
@ -45,6 +52,11 @@ public class ReceiveCommand implements ExtendedDbusCommand, LocalCommand {
|
||||||
|
|
||||||
boolean inJson = ns.getString("output").equals("json") || ns.getBoolean("json");
|
boolean inJson = ns.getString("output").equals("json") || ns.getBoolean("json");
|
||||||
|
|
||||||
|
// TODO delete later when "json" variable is removed
|
||||||
|
if (ns.getBoolean("json")) {
|
||||||
|
logger.warn("\"--json\" option has been deprecated, please use \"output\" instead.");
|
||||||
|
}
|
||||||
|
|
||||||
if (inJson) {
|
if (inJson) {
|
||||||
jsonProcessor = new ObjectMapper();
|
jsonProcessor = new ObjectMapper();
|
||||||
jsonProcessor.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.ANY);
|
jsonProcessor.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.ANY);
|
||||||
|
@ -151,6 +163,11 @@ public class ReceiveCommand implements ExtendedDbusCommand, LocalCommand {
|
||||||
public int handleCommand(final Namespace ns, final Manager m) {
|
public int handleCommand(final Namespace ns, final Manager m) {
|
||||||
boolean inJson = ns.getString("output").equals("json") || ns.getBoolean("json");
|
boolean inJson = ns.getString("output").equals("json") || ns.getBoolean("json");
|
||||||
|
|
||||||
|
// TODO delete later when "json" variable is removed
|
||||||
|
if (ns.getBoolean("json")) {
|
||||||
|
logger.warn("\"--json\" option has been deprecated, please use \"output\" instead.");
|
||||||
|
}
|
||||||
|
|
||||||
double timeout = 5;
|
double timeout = 5;
|
||||||
if (ns.getDouble("timeout") != null) {
|
if (ns.getDouble("timeout") != null) {
|
||||||
timeout = ns.getDouble("timeout");
|
timeout = ns.getDouble("timeout");
|
||||||
|
|
|
@ -340,7 +340,7 @@ public class Manager implements Closeable {
|
||||||
*
|
*
|
||||||
* @param numbers The set of phone number in question
|
* @param numbers The set of phone number in question
|
||||||
* @return A map of numbers to booleans. True if registered, false otherwise. Should never be null
|
* @return A map of numbers to booleans. True if registered, false otherwise. Should never be null
|
||||||
* @throws IOException if its unable to check if the users are registered
|
* @throws IOException if its unable to get the contacts to check if they're registered
|
||||||
*/
|
*/
|
||||||
public Map<String, Boolean> areUsersRegistered(Set<String> numbers) throws IOException {
|
public Map<String, Boolean> areUsersRegistered(Set<String> numbers) throws IOException {
|
||||||
// Note "contactDetails" has no optionals. It only gives us info on users who are registered
|
// Note "contactDetails" has no optionals. It only gives us info on users who are registered
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue