]> nmode's Git Repositories - signal-cli/commitdiff
Update libsignal-service
authorAsamK <asamk@gmx.de>
Thu, 10 Sep 2020 09:06:33 +0000 (11:06 +0200)
committerAsamK <asamk@gmx.de>
Thu, 10 Sep 2020 09:07:30 +0000 (11:07 +0200)
build.gradle
src/main/java/org/asamk/signal/manager/Manager.java
src/main/java/org/asamk/signal/manager/Utils.java

index b747db4087794d4bfbc24be6581caae2e9a684fd..0f7c9a84ec6ad85efef8299bd37f8987303ed058 100644 (file)
@@ -17,7 +17,7 @@ repositories {
 }
 
 dependencies {
 }
 
 dependencies {
-    implementation 'com.github.turasa:signal-service-java:2.15.3_unofficial_12'
+    implementation 'com.github.turasa:signal-service-java:2.15.3_unofficial_13'
     implementation 'org.bouncycastle:bcprov-jdk15on:1.66'
     implementation 'net.sourceforge.argparse4j:argparse4j:0.8.1'
     implementation 'com.github.hypfvieh:dbus-java:3.2.3'
     implementation 'org.bouncycastle:bcprov-jdk15on:1.66'
     implementation 'net.sourceforge.argparse4j:argparse4j:0.8.1'
     implementation 'com.github.hypfvieh:dbus-java:3.2.3'
index 851b7820ed6f308b5f4eca20014544ae5777ca60..73c2b5c79dd608dcad8c8c6681eb9eac352eb822 100644 (file)
@@ -153,6 +153,7 @@ public class Manager implements Closeable {
     private SignalServiceAccountManager accountManager;
     private SignalServiceMessagePipe messagePipe = null;
     private SignalServiceMessagePipe unidentifiedMessagePipe = null;
     private SignalServiceAccountManager accountManager;
     private SignalServiceMessagePipe messagePipe = null;
     private SignalServiceMessagePipe unidentifiedMessagePipe = null;
+    private boolean discoverableByPhoneNumber = true;
 
     public Manager(SignalAccount account, PathConfig pathConfig, SignalServiceConfiguration serviceConfiguration, String userAgent) {
         this.account = account;
 
     public Manager(SignalAccount account, PathConfig pathConfig, SignalServiceConfiguration serviceConfiguration, String userAgent) {
         this.account = account;
@@ -286,7 +287,7 @@ public class Manager implements Closeable {
     }
 
     public void updateAccountAttributes() throws IOException {
     }
 
     public void updateAccountAttributes() throws IOException {
-        accountManager.setAccountAttributes(account.getSignalingKey(), account.getSignalProtocolStore().getLocalRegistrationId(), true, account.getRegistrationLockPin(), account.getRegistrationLock(), getSelfUnidentifiedAccessKey(), false, ServiceConfig.capabilities);
+        accountManager.setAccountAttributes(account.getSignalingKey(), account.getSignalProtocolStore().getLocalRegistrationId(), true, account.getRegistrationLockPin(), account.getRegistrationLock(), getSelfUnidentifiedAccessKey(), false, ServiceConfig.capabilities, discoverableByPhoneNumber);
     }
 
     public void setProfile(String name, File avatar) throws IOException {
     }
 
     public void setProfile(String name, File avatar) throws IOException {
@@ -371,7 +372,7 @@ public class Manager implements Closeable {
         verificationCode = verificationCode.replace("-", "");
         account.setSignalingKey(KeyUtils.createSignalingKey());
         // TODO make unrestricted unidentified access configurable
         verificationCode = verificationCode.replace("-", "");
         account.setSignalingKey(KeyUtils.createSignalingKey());
         // TODO make unrestricted unidentified access configurable
-        VerifyAccountResponse response = accountManager.verifyAccountWithCode(verificationCode, account.getSignalingKey(), account.getSignalProtocolStore().getLocalRegistrationId(), true, pin, null, getSelfUnidentifiedAccessKey(), false, ServiceConfig.capabilities);
+        VerifyAccountResponse response = accountManager.verifyAccountWithCode(verificationCode, account.getSignalingKey(), account.getSignalProtocolStore().getLocalRegistrationId(), true, pin, null, getSelfUnidentifiedAccessKey(), false, ServiceConfig.capabilities, discoverableByPhoneNumber);
 
         UUID uuid = UuidUtil.parseOrNull(response.getUuid());
         // TODO response.isStorageCapable()
 
         UUID uuid = UuidUtil.parseOrNull(response.getUuid());
         // TODO response.isStorageCapable()
@@ -836,7 +837,8 @@ public class Manager implements Closeable {
                 throw new StickerPackInvalidException("Could not find find " + sticker.file);
             }
 
                 throw new StickerPackInvalidException("Could not find find " + sticker.file);
             }
 
-            StickerInfo stickerInfo = new StickerInfo(data.first(), data.second(), Optional.fromNullable(sticker.emoji).or(""));
+            String contentType = Utils.getFileMimeType(new File(sticker.file), null);
+            StickerInfo stickerInfo = new StickerInfo(data.first(), data.second(), Optional.fromNullable(sticker.emoji).or(""), contentType);
             stickers.add(stickerInfo);
         }
 
             stickers.add(stickerInfo);
         }
 
@@ -853,7 +855,8 @@ public class Manager implements Closeable {
                 throw new StickerPackInvalidException("Could not find find " + pack.cover.file);
             }
 
                 throw new StickerPackInvalidException("Could not find find " + pack.cover.file);
             }
 
-            cover = new StickerInfo(data.first(), data.second(), Optional.fromNullable(pack.cover.emoji).or(""));
+            String contentType = Utils.getFileMimeType(new File(pack.cover.file), null);
+            cover = new StickerInfo(data.first(), data.second(), Optional.fromNullable(pack.cover.emoji).or(""), contentType);
         }
 
         return new SignalServiceStickerManifestUpload(
         }
 
         return new SignalServiceStickerManifestUpload(
@@ -925,10 +928,10 @@ public class Manager implements Closeable {
 
     private byte[] getSenderCertificate() {
         // TODO support UUID capable sender certificates
 
     private byte[] getSenderCertificate() {
         // TODO support UUID capable sender certificates
-        // byte[] certificate = accountManager.getSenderCertificate();
+        // byte[] certificate = accountManager.getSenderCertificateForPhoneNumberPrivacy();
         byte[] certificate;
         try {
         byte[] certificate;
         try {
-            certificate = accountManager.getSenderCertificateLegacy();
+            certificate = accountManager.getSenderCertificate();
         } catch (IOException e) {
             System.err.println("Failed to get sender certificate: " + e);
             return null;
         } catch (IOException e) {
             System.err.println("Failed to get sender certificate: " + e);
             return null;
index 0244d40915da12d70d8c3e47650afdd26e436fa1..05fcfb5ed84f7069f592d7e3c08b321b1e3d1a10 100644 (file)
@@ -58,7 +58,7 @@ class Utils {
         return signalServiceAttachments;
     }
 
         return signalServiceAttachments;
     }
 
-    private static String getFileMimeType(File file) throws IOException {
+    static String getFileMimeType(File file, String defaultMimeType) throws IOException {
         String mime = Files.probeContentType(file.toPath());
         if (mime == null) {
             try (InputStream bufferedStream = new BufferedInputStream(new FileInputStream(file))) {
         String mime = Files.probeContentType(file.toPath());
         if (mime == null) {
             try (InputStream bufferedStream = new BufferedInputStream(new FileInputStream(file))) {
@@ -66,7 +66,7 @@ class Utils {
             }
         }
         if (mime == null) {
             }
         }
         if (mime == null) {
-            mime = "application/octet-stream";
+            return defaultMimeType;
         }
         return mime;
     }
         }
         return mime;
     }
@@ -74,7 +74,7 @@ class Utils {
     static SignalServiceAttachmentStream createAttachment(File attachmentFile) throws IOException {
         InputStream attachmentStream = new FileInputStream(attachmentFile);
         final long attachmentSize = attachmentFile.length();
     static SignalServiceAttachmentStream createAttachment(File attachmentFile) throws IOException {
         InputStream attachmentStream = new FileInputStream(attachmentFile);
         final long attachmentSize = attachmentFile.length();
-        final String mime = getFileMimeType(attachmentFile);
+        final String mime = getFileMimeType(attachmentFile, "application/octet-stream");
         // TODO mabybe add a parameter to set the voiceNote, borderless, preview, width, height and caption option
         final long uploadTimestamp = System.currentTimeMillis();
         Optional<byte[]> preview = Optional.absent();
         // TODO mabybe add a parameter to set the voiceNote, borderless, preview, width, height and caption option
         final long uploadTimestamp = System.currentTimeMillis();
         Optional<byte[]> preview = Optional.absent();