Added Quit group option

This commit is contained in:
conte 2016-05-18 15:14:38 +02:00
parent be31eed294
commit 11baf18fae
2 changed files with 19 additions and 7 deletions

View file

@ -403,7 +403,7 @@ public class Main {
if (ns.getString("group") != null) {
groupId = decodeGroupId(ns.getString("group"));
}
byte[] newGroupId = m.sendUpdateGroupMessage(groupId, ns.getString("name"), ns.<String>getList("member"), ns.getString("avatar"));
byte[] newGroupId = m.sendUpdateGroupMessage(groupId, ns.getString("name"), ns.<String>getList("member"), ns.getString("avatar"), ns.getString("quit")!=null);
if (groupId == null) {
System.out.println("Creating new group \"" + Base64.encodeBytes(newGroupId) + "\"");
}
@ -504,7 +504,7 @@ public class Main {
.help("Show package version.")
.action(Arguments.version());
parser.addArgument("--config")
.help("Set the path, where to store the config (Default: $HOME/.config/signal-cli).");
.help("Set the path, where to store the config (Default: $HOME/.config/signal).");
MutuallyExclusiveGroup mut = parser.addMutuallyExclusiveGroup();
mut.addArgument("-u", "--username")
@ -550,7 +550,7 @@ public class Main {
Subparser parserSend = subparsers.addParser("send");
parserSend.addArgument("-g", "--group")
.help("Specify the recipient group ID.");
.help("Specify the recipient group ID. If '-m' parameter is not present the messag is read from STDIN and yuo have to type <ENTER>CTRL+D<ENTER> (aka EOF) in order to stop reading and sending the content");
parserSend.addArgument("recipient")
.help("Specify the recipients' phone number.")
.nargs("*");
@ -575,6 +575,9 @@ public class Main {
.help("Specify the new group name.");
parserUpdateGroup.addArgument("-a", "--avatar")
.help("Specify a new group avatar image file");
parserUpdateGroup.addArgument("-q", "--quit")
.help("Quit from the group")
.action(Arguments.storeTrue());
parserUpdateGroup.addArgument("-m", "--member")
.nargs("*")
.help("Specify one or more members to add to the group");

View file

@ -63,8 +63,16 @@ import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
class Manager implements Signal {
private final static String URL = "https://textsecure-service.whispersystems.org";
private final static TrustStore TRUST_STORE = new WhisperTrustStore();
// private final static String URL = "https://10.1.4.252:8080";
// private final static TrustStore TRUST_STORE = new TenOneFourTwohundredfiftyfourTrustStore();
// private final static String URL = "https://127.0.0.1:8080";
// private final static TrustStore TRUST_STORE = new LoopbackTrustStore();
private final static String URL = "https://signal.sinesy.it:8080";
private final static TrustStore TRUST_STORE = new SinesyTrustStore();
//private final static String URL = "https://textsecure-service.whispersystems.org";
//private final static TrustStore TRUST_STORE = new WhisperTrustStore();
public final static String PROJECT_NAME = Manager.class.getPackage().getImplementationTitle();
public final static String PROJECT_VERSION = Manager.class.getPackage().getImplementationVersion();
@ -456,7 +464,7 @@ class Manager implements Signal {
sendMessage(message, g.members);
}
public byte[] sendUpdateGroupMessage(byte[] groupId, String name, Collection<String> members, String avatarFile) throws IOException, EncapsulatedExceptions, GroupNotFoundException, AttachmentInvalidException, UntrustedIdentityException {
public byte[] sendUpdateGroupMessage(byte[] groupId, String name, Collection<String> members, String avatarFile, boolean quit) throws IOException, EncapsulatedExceptions, GroupNotFoundException, AttachmentInvalidException, UntrustedIdentityException {
GroupInfo g;
if (groupId == null) {
// Create new group
@ -482,11 +490,12 @@ class Manager implements Signal {
}
}
SignalServiceGroup.Builder group = SignalServiceGroup.newBuilder(SignalServiceGroup.Type.UPDATE)
SignalServiceGroup.Builder group = SignalServiceGroup.newBuilder(quit?SignalServiceGroup.Type.QUIT:SignalServiceGroup.Type.UPDATE)
.withId(g.groupId)
.withName(g.name)
.withMembers(new ArrayList<>(g.members));
if (avatarFile != null) {
try {
group.withAvatar(createAttachment(avatarFile));