Skip to content

Commit

Permalink
Update libsignal-service-java
Browse files Browse the repository at this point in the history
  • Loading branch information
AsamK committed Sep 7, 2017
1 parent 9b56aa6 commit e36a2f8
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 15 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ repositories {
}

dependencies {
compile 'com.github.turasa:signal-service-java:2.5.17_unofficial_1'
compile 'com.github.turasa:signal-service-java:2.6.5_unofficial_1'
compile 'org.bouncycastle:bcprov-jdk15on:1.55'
compile 'net.sourceforge.argparse4j:argparse4j:0.7.0'
compile 'org.freedesktop.dbus:dbus-java:2.7.0'
Expand Down
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
3 changes: 1 addition & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#Thu Aug 17 20:18:16 CEST 2017
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.0.2-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-bin.zip
33 changes: 21 additions & 12 deletions src/main/java/org/asamk/signal/Manager.java
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,10 @@
import org.whispersystems.signalservice.api.push.exceptions.*;
import org.whispersystems.signalservice.api.util.InvalidNumberException;
import org.whispersystems.signalservice.api.util.PhoneNumberFormatter;
import org.whispersystems.signalservice.internal.configuration.SignalCdnUrl;
import org.whispersystems.signalservice.internal.configuration.SignalServiceConfiguration;
import org.whispersystems.signalservice.internal.configuration.SignalServiceUrl;
import org.whispersystems.signalservice.internal.push.SignalServiceProtos;
import org.whispersystems.signalservice.internal.push.SignalServiceUrl;
import org.whispersystems.signalservice.internal.util.Base64;

import java.io.*;
Expand All @@ -87,8 +89,12 @@

class Manager implements Signal {
private final static String URL = "https://textsecure-service.whispersystems.org";
private final static String CDN_URL = "https://cdn.signal.org";
private final static TrustStore TRUST_STORE = new WhisperTrustStore();
private final static SignalServiceUrl[] serviceUrls = new SignalServiceUrl[]{new SignalServiceUrl(URL, TRUST_STORE)};
private final static SignalServiceConfiguration serviceConfiguration = new SignalServiceConfiguration(
new SignalServiceUrl[]{new SignalServiceUrl(URL, TRUST_STORE)},
new SignalCdnUrl[]{new SignalCdnUrl(CDN_URL, TRUST_STORE)}
);

public final static String PROJECT_NAME = Manager.class.getPackage().getImplementationTitle();
public final static String PROJECT_VERSION = Manager.class.getPackage().getImplementationVersion();
Expand Down Expand Up @@ -231,7 +237,7 @@ public void init() throws IOException {

migrateLegacyConfigs();

accountManager = new SignalServiceAccountManager(serviceUrls, username, password, deviceId, USER_AGENT);
accountManager = new SignalServiceAccountManager(serviceConfiguration, username, password, deviceId, USER_AGENT);
try {
if (registered && accountManager.getPreKeysCount() < PREKEY_MINIMUM_COUNT) {
refreshPreKeys();
Expand Down Expand Up @@ -356,7 +362,7 @@ public boolean isRegistered() {
public void register(boolean voiceVerification) throws IOException {
password = Util.getSecret(18);

accountManager = new SignalServiceAccountManager(serviceUrls, username, password, USER_AGENT);
accountManager = new SignalServiceAccountManager(serviceConfiguration, username, password, USER_AGENT);

if (voiceVerification)
accountManager.requestVoiceVerificationCode();
Expand All @@ -381,7 +387,7 @@ public void unregister() throws IOException {
public URI getDeviceLinkUri() throws TimeoutException, IOException {
password = Util.getSecret(18);

accountManager = new SignalServiceAccountManager(serviceUrls, username, password, USER_AGENT);
accountManager = new SignalServiceAccountManager(serviceConfiguration, username, password, USER_AGENT);
String uuid = accountManager.getNewDeviceUuid();

registered = false;
Expand Down Expand Up @@ -460,7 +466,8 @@ private void addDevice(String deviceIdentifier, ECPublicKey deviceKey) throws IO
IdentityKeyPair identityKeyPair = signalProtocolStore.getIdentityKeyPair();
String verificationCode = accountManager.getNewDeviceVerificationCode();

accountManager.addDevice(deviceIdentifier, deviceKey, identityKeyPair, verificationCode);
// TODO send profile key
accountManager.addDevice(deviceIdentifier, deviceKey, identityKeyPair, Optional.<byte[]>absent(), verificationCode);
}

private List<PreKeyRecord> generatePreKeys() {
Expand Down Expand Up @@ -856,7 +863,7 @@ private void requestSyncContacts() throws IOException {

private void sendSyncMessage(SignalServiceSyncMessage message)
throws IOException, UntrustedIdentityException {
SignalServiceMessageSender messageSender = new SignalServiceMessageSender(serviceUrls, username, password,
SignalServiceMessageSender messageSender = new SignalServiceMessageSender(serviceConfiguration, username, password,
deviceId, signalProtocolStore, USER_AGENT, Optional.fromNullable(messagePipe), Optional.<SignalServiceMessageSender.EventListener>absent());
try {
messageSender.sendMessage(message);
Expand All @@ -873,7 +880,7 @@ private void sendMessage(SignalServiceDataMessage.Builder messageBuilder, Collec

SignalServiceDataMessage message = null;
try {
SignalServiceMessageSender messageSender = new SignalServiceMessageSender(serviceUrls, username, password,
SignalServiceMessageSender messageSender = new SignalServiceMessageSender(serviceConfiguration, username, password,
deviceId, signalProtocolStore, USER_AGENT, Optional.fromNullable(messagePipe), Optional.<SignalServiceMessageSender.EventListener>absent());

message = messageBuilder.build();
Expand Down Expand Up @@ -1104,7 +1111,7 @@ public void retryFailedReceivedMessages(ReceiveMessageHandler handler, boolean i

public void receiveMessages(long timeout, TimeUnit unit, boolean returnOnTimeout, boolean ignoreAttachments, ReceiveMessageHandler handler) throws IOException {
retryFailedReceivedMessages(handler, ignoreAttachments);
final SignalServiceMessageReceiver messageReceiver = new SignalServiceMessageReceiver(serviceUrls, username, password, deviceId, signalingKey, USER_AGENT);
final SignalServiceMessageReceiver messageReceiver = new SignalServiceMessageReceiver(serviceConfiguration, username, password, deviceId, signalingKey, USER_AGENT);

try {
if (messagePipe == null) {
Expand Down Expand Up @@ -1406,7 +1413,7 @@ private File retrieveAttachment(SignalServiceAttachmentPointer pointer, File out
}
}

final SignalServiceMessageReceiver messageReceiver = new SignalServiceMessageReceiver(serviceUrls, username, password, deviceId, signalingKey, USER_AGENT);
final SignalServiceMessageReceiver messageReceiver = new SignalServiceMessageReceiver(serviceConfiguration, username, password, deviceId, signalingKey, USER_AGENT);

File tmpFile = Util.createTempFile();
try (InputStream input = messageReceiver.retrieveAttachment(pointer, tmpFile, MAX_ATTACHMENT_SIZE)) {
Expand All @@ -1432,7 +1439,7 @@ private File retrieveAttachment(SignalServiceAttachmentPointer pointer, File out
}

private InputStream retrieveAttachmentAsStream(SignalServiceAttachmentPointer pointer, File tmpFile) throws IOException, InvalidMessageException {
final SignalServiceMessageReceiver messageReceiver = new SignalServiceMessageReceiver(serviceUrls, username, password, deviceId, signalingKey, USER_AGENT);
final SignalServiceMessageReceiver messageReceiver = new SignalServiceMessageReceiver(serviceConfiguration, username, password, deviceId, signalingKey, USER_AGENT);
return messageReceiver.retrieveAttachment(pointer, tmpFile, MAX_ATTACHMENT_SIZE);
}

Expand Down Expand Up @@ -1504,8 +1511,10 @@ private void sendContacts() throws IOException, UntrustedIdentityException {
}
}

// TODO include profile key
out.write(new DeviceContact(record.number, Optional.fromNullable(record.name),
createContactAvatarAttachment(record.number), Optional.fromNullable(record.color), Optional.fromNullable(verifiedMessage)));
createContactAvatarAttachment(record.number), Optional.fromNullable(record.color),
Optional.fromNullable(verifiedMessage), Optional.<byte[]>absent()));
}
}

Expand Down

0 comments on commit e36a2f8

Please sign in to comment.