Update signal-service-java to 2.8.0

This commit is contained in:
AsamK 2018-08-12 21:34:55 +02:00
parent cafba8579f
commit bb342babba
3 changed files with 21 additions and 9 deletions

View file

@ -20,7 +20,7 @@ repositories {
} }
dependencies { dependencies {
compile 'com.github.turasa:signal-service-java:2.7.5_unofficial_1' compile 'com.github.turasa:signal-service-java:2.8.0_unofficial_1'
compile 'org.bouncycastle:bcprov-jdk15on:1.59' compile 'org.bouncycastle:bcprov-jdk15on:1.59'
compile 'net.sourceforge.argparse4j:argparse4j:0.8.1' compile 'net.sourceforge.argparse4j:argparse4j:0.8.1'
compile 'org.freedesktop.dbus:dbus-java:2.7.0' compile 'org.freedesktop.dbus:dbus-java:2.7.0'

View file

@ -61,6 +61,8 @@ import org.whispersystems.signalservice.api.push.TrustStore;
import org.whispersystems.signalservice.api.push.exceptions.*; import org.whispersystems.signalservice.api.push.exceptions.*;
import org.whispersystems.signalservice.api.util.InvalidNumberException; import org.whispersystems.signalservice.api.util.InvalidNumberException;
import org.whispersystems.signalservice.api.util.PhoneNumberFormatter; import org.whispersystems.signalservice.api.util.PhoneNumberFormatter;
import org.whispersystems.signalservice.api.util.SleepTimer;
import org.whispersystems.signalservice.api.util.UptimeSleepTimer;
import org.whispersystems.signalservice.internal.configuration.SignalCdnUrl; import org.whispersystems.signalservice.internal.configuration.SignalCdnUrl;
import org.whispersystems.signalservice.internal.configuration.SignalServiceConfiguration; import org.whispersystems.signalservice.internal.configuration.SignalServiceConfiguration;
import org.whispersystems.signalservice.internal.configuration.SignalServiceUrl; import org.whispersystems.signalservice.internal.configuration.SignalServiceUrl;
@ -130,6 +132,8 @@ class Manager implements Signal {
private JsonThreadStore threadStore; private JsonThreadStore threadStore;
private SignalServiceMessagePipe messagePipe = null; private SignalServiceMessagePipe messagePipe = null;
private SleepTimer timer = new UptimeSleepTimer();
public Manager(String username, String settingsPath) { public Manager(String username, String settingsPath) {
this.username = username; this.username = username;
this.settingsPath = settingsPath; this.settingsPath = settingsPath;
@ -238,7 +242,7 @@ class Manager implements Signal {
migrateLegacyConfigs(); migrateLegacyConfigs();
accountManager = new SignalServiceAccountManager(serviceConfiguration, username, password, deviceId, USER_AGENT); accountManager = new SignalServiceAccountManager(serviceConfiguration, username, password, deviceId, USER_AGENT, timer);
try { try {
if (registered && accountManager.getPreKeysCount() < PREKEY_MINIMUM_COUNT) { if (registered && accountManager.getPreKeysCount() < PREKEY_MINIMUM_COUNT) {
refreshPreKeys(); refreshPreKeys();
@ -366,7 +370,7 @@ class Manager implements Signal {
public void register(boolean voiceVerification) throws IOException { public void register(boolean voiceVerification) throws IOException {
password = Util.getSecret(18); password = Util.getSecret(18);
accountManager = new SignalServiceAccountManager(serviceConfiguration, username, password, USER_AGENT); accountManager = new SignalServiceAccountManager(serviceConfiguration, username, password, USER_AGENT, timer);
if (voiceVerification) if (voiceVerification)
accountManager.requestVoiceVerificationCode(); accountManager.requestVoiceVerificationCode();
@ -391,7 +395,7 @@ class Manager implements Signal {
public URI getDeviceLinkUri() throws TimeoutException, IOException { public URI getDeviceLinkUri() throws TimeoutException, IOException {
password = Util.getSecret(18); password = Util.getSecret(18);
accountManager = new SignalServiceAccountManager(serviceConfiguration, username, password, USER_AGENT); accountManager = new SignalServiceAccountManager(serviceConfiguration, username, password, USER_AGENT, timer);
String uuid = accountManager.getNewDeviceUuid(); String uuid = accountManager.getNewDeviceUuid();
registered = false; registered = false;
@ -1135,7 +1139,7 @@ class Manager implements Signal {
public void receiveMessages(long timeout, TimeUnit unit, boolean returnOnTimeout, boolean ignoreAttachments, ReceiveMessageHandler handler) throws IOException { public void receiveMessages(long timeout, TimeUnit unit, boolean returnOnTimeout, boolean ignoreAttachments, ReceiveMessageHandler handler) throws IOException {
retryFailedReceivedMessages(handler, ignoreAttachments); retryFailedReceivedMessages(handler, ignoreAttachments);
final SignalServiceMessageReceiver messageReceiver = new SignalServiceMessageReceiver(serviceConfiguration, username, password, deviceId, signalingKey, USER_AGENT, null); final SignalServiceMessageReceiver messageReceiver = new SignalServiceMessageReceiver(serviceConfiguration, username, password, deviceId, signalingKey, USER_AGENT, null, timer);
try { try {
if (messagePipe == null) { if (messagePipe == null) {
@ -1244,6 +1248,9 @@ class Manager implements Signal {
} }
syncGroup.members.addAll(g.getMembers()); syncGroup.members.addAll(g.getMembers());
syncGroup.active = g.isActive(); syncGroup.active = g.isActive();
if (g.getColor().isPresent()) {
syncGroup.color = g.getColor().get();
}
if (g.getAvatar().isPresent()) { if (g.getAvatar().isPresent()) {
retrieveGroupAvatarAttachment(g.getAvatar().get(), syncGroup.groupId); retrieveGroupAvatarAttachment(g.getAvatar().get(), syncGroup.groupId);
@ -1437,7 +1444,7 @@ class Manager implements Signal {
} }
} }
final SignalServiceMessageReceiver messageReceiver = new SignalServiceMessageReceiver(serviceConfiguration, username, password, deviceId, signalingKey, USER_AGENT, null); final SignalServiceMessageReceiver messageReceiver = new SignalServiceMessageReceiver(serviceConfiguration, username, password, deviceId, signalingKey, USER_AGENT, null, timer);
File tmpFile = Util.createTempFile(); File tmpFile = Util.createTempFile();
try (InputStream input = messageReceiver.retrieveAttachment(pointer, tmpFile, MAX_ATTACHMENT_SIZE)) { try (InputStream input = messageReceiver.retrieveAttachment(pointer, tmpFile, MAX_ATTACHMENT_SIZE)) {
@ -1463,7 +1470,7 @@ class Manager implements Signal {
} }
private InputStream retrieveAttachmentAsStream(SignalServiceAttachmentPointer pointer, File tmpFile) throws IOException, InvalidMessageException { private InputStream retrieveAttachmentAsStream(SignalServiceAttachmentPointer pointer, File tmpFile) throws IOException, InvalidMessageException {
final SignalServiceMessageReceiver messageReceiver = new SignalServiceMessageReceiver(serviceConfiguration, username, password, deviceId, signalingKey, USER_AGENT, null); final SignalServiceMessageReceiver messageReceiver = new SignalServiceMessageReceiver(serviceConfiguration, username, password, deviceId, signalingKey, USER_AGENT, null, timer);
return messageReceiver.retrieveAttachment(pointer, tmpFile, MAX_ATTACHMENT_SIZE); return messageReceiver.retrieveAttachment(pointer, tmpFile, MAX_ATTACHMENT_SIZE);
} }
@ -1492,7 +1499,8 @@ class Manager implements Signal {
ThreadInfo info = threadStore.getThread(Base64.encodeBytes(record.groupId)); ThreadInfo info = threadStore.getThread(Base64.encodeBytes(record.groupId));
out.write(new DeviceGroup(record.groupId, Optional.fromNullable(record.name), out.write(new DeviceGroup(record.groupId, Optional.fromNullable(record.name),
new ArrayList<>(record.members), createGroupAvatarAttachment(record.groupId), new ArrayList<>(record.members), createGroupAvatarAttachment(record.groupId),
record.active, Optional.fromNullable(info != null ? info.messageExpirationTime : null))); record.active, Optional.fromNullable(info != null ? info.messageExpirationTime : null),
Optional.fromNullable(record.color)));
} }
} }

View file

@ -27,14 +27,18 @@ public class GroupInfo {
@JsonProperty @JsonProperty
public boolean active; public boolean active;
@JsonProperty
public String color;
public GroupInfo(byte[] groupId) { public GroupInfo(byte[] groupId) {
this.groupId = groupId; this.groupId = groupId;
} }
public GroupInfo(@JsonProperty("groupId") byte[] groupId, @JsonProperty("name") String name, @JsonProperty("members") Collection<String> members, @JsonProperty("avatarId") long avatarId) { public GroupInfo(@JsonProperty("groupId") byte[] groupId, @JsonProperty("name") String name, @JsonProperty("members") Collection<String> members, @JsonProperty("avatarId") long avatarId, @JsonProperty("color") String color) {
this.groupId = groupId; this.groupId = groupId;
this.name = name; this.name = name;
this.members.addAll(members); this.members.addAll(members);
this.avatarId = avatarId; this.avatarId = avatarId;
this.color = color;
} }
} }