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

@ -44,6 +44,10 @@ usage: signal-cli [-h] [-v] [--config CONFIG] [-u USERNAME | --dbus | --dbus-sys
* Send a message to a group * Send a message to a group
signal-cli -u USERNAME send -m "This is a message" -g GROUP_ID 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) * Linking other devices (Provisioning)

View file

@ -403,7 +403,7 @@ public class Main {
if (ns.getString("group") != null) { if (ns.getString("group") != null) {
groupId = decodeGroupId(ns.getString("group")); 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) { if (groupId == null) {
System.out.println("Creating new group \"" + Base64.encodeBytes(newGroupId) + "\""); System.out.println("Creating new group \"" + Base64.encodeBytes(newGroupId) + "\"");
} }
@ -504,7 +504,7 @@ public class Main {
.help("Show package version.") .help("Show package version.")
.action(Arguments.version()); .action(Arguments.version());
parser.addArgument("--config") 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(); MutuallyExclusiveGroup mut = parser.addMutuallyExclusiveGroup();
mut.addArgument("-u", "--username") mut.addArgument("-u", "--username")
@ -550,7 +550,7 @@ public class Main {
Subparser parserSend = subparsers.addParser("send"); Subparser parserSend = subparsers.addParser("send");
parserSend.addArgument("-g", "--group") 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") parserSend.addArgument("recipient")
.help("Specify the recipients' phone number.") .help("Specify the recipients' phone number.")
.nargs("*"); .nargs("*");
@ -575,6 +575,9 @@ public class Main {
.help("Specify the new group name."); .help("Specify the new group name.");
parserUpdateGroup.addArgument("-a", "--avatar") parserUpdateGroup.addArgument("-a", "--avatar")
.help("Specify a new group avatar image file"); .help("Specify a new group avatar image file");
parserUpdateGroup.addArgument("-q", "--quit")
.help("Quit from the group")
.action(Arguments.storeTrue());
parserUpdateGroup.addArgument("-m", "--member") parserUpdateGroup.addArgument("-m", "--member")
.nargs("*") .nargs("*")
.help("Specify one or more members to add to the group"); .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; import java.util.concurrent.TimeoutException;
class Manager implements Signal { class Manager implements Signal {
private final static String URL = "https://textsecure-service.whispersystems.org"; private final static String URL = "https://textsecure-service.whispersystems.org";
private final static TrustStore TRUST_STORE = new WhisperTrustStore(); private final static TrustStore TRUST_STORE = new WhisperTrustStore();
@ -456,7 +457,7 @@ class Manager implements Signal {
sendMessage(message, g.members); 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; GroupInfo g;
if (groupId == null) { if (groupId == null) {
// Create new group // 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) .withId(g.groupId)
.withName(g.name) .withName(g.name)
.withMembers(new ArrayList<>(g.members)); .withMembers(new ArrayList<>(g.members));
if (avatarFile != null) { if (avatarFile != null) {
try { try {
group.withAvatar(createAttachment(avatarFile)); group.withAvatar(createAttachment(avatarFile));