This commit is contained in:
Luca Conte 2016-05-18 13:40:17 +00:00
commit 327d43ad2d
3 changed files with 14 additions and 5 deletions

View file

@ -45,6 +45,10 @@ usage: signal-cli [-h] [-v] [--config CONFIG] [-u USERNAME | --dbus | --dbus-sys
signal-cli -u USERNAME send -m "This is a message" -g GROUP_ID
* Leave a group
signal-cli -u USERNAME updateGroup -g GROUP_ID -q
* Linking other devices (Provisioning)
* Connect to another device

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 there is no '-m', use <CR>CTRL+D<CR> (aka EOF) in order to stop reading from STDIN and send 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,6 +63,7 @@ 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();
@ -456,7 +457,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 +483,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));