mirror of
https://github.com/AsamK/signal-cli
synced 2025-08-29 18:40:39 +00:00
Update dependencies
Sets the complete flag for contacts message, Fixes #81
This commit is contained in:
parent
d270ea8c2e
commit
0f1d0597ae
6 changed files with 36 additions and 19 deletions
|
@ -19,7 +19,7 @@ repositories {
|
|||
}
|
||||
|
||||
dependencies {
|
||||
compile 'com.github.turasa:signal-service-java:2.5.5_unofficial_1'
|
||||
compile 'com.github.turasa:signal-service-java:2.5.7_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'
|
||||
|
|
|
@ -938,8 +938,13 @@ public class Main {
|
|||
SignalServiceSyncMessage syncMessage = content.getSyncMessage().get();
|
||||
|
||||
if (syncMessage.getContacts().isPresent()) {
|
||||
System.out.println("Received sync contacts");
|
||||
printAttachment(syncMessage.getContacts().get());
|
||||
final ContactsMessage contactsMessage = syncMessage.getContacts().get();
|
||||
if (contactsMessage.isComplete()) {
|
||||
System.out.println("Received complete sync contacts");
|
||||
} else {
|
||||
System.out.println("Received sync contacts");
|
||||
}
|
||||
printAttachment(contactsMessage.getContactsStream());
|
||||
}
|
||||
if (syncMessage.getGroups().isPresent()) {
|
||||
System.out.println("Received sync groups");
|
||||
|
@ -1051,6 +1056,7 @@ public class Main {
|
|||
System.out.println(" Id: " + pointer.getId() + " Key length: " + pointer.getKey().length + (pointer.getRelay().isPresent() ? " Relay: " + pointer.getRelay().get() : ""));
|
||||
System.out.println(" Filename: " + (pointer.getFileName().isPresent() ? pointer.getFileName().get() : "-"));
|
||||
System.out.println(" Size: " + (pointer.getSize().isPresent() ? pointer.getSize().get() + " bytes" : "<unavailable>") + (pointer.getPreview().isPresent() ? " (Preview is available: " + pointer.getPreview().get().length + " bytes)" : ""));
|
||||
System.out.println(" Voice note: " + (pointer.getVoiceNote() ? "yes" : "no"));
|
||||
File file = m.getAttachmentFile(pointer.getId());
|
||||
if (file.exists()) {
|
||||
System.out.println(" Stored plaintext in: " + file);
|
||||
|
|
|
@ -558,7 +558,8 @@ class Manager implements Signal {
|
|||
if (mime == null) {
|
||||
mime = "application/octet-stream";
|
||||
}
|
||||
return new SignalServiceAttachmentStream(attachmentStream, mime, attachmentSize, Optional.of(attachmentFile.getName()), null);
|
||||
// TODO mabybe add a parameter to set the voiceNote and preview option
|
||||
return new SignalServiceAttachmentStream(attachmentStream, mime, attachmentSize, Optional.of(attachmentFile.getName()), false, Optional.<byte[]>absent(),null);
|
||||
}
|
||||
|
||||
private Optional<SignalServiceAttachmentStream> createGroupAvatarAttachment(byte[] groupId) throws IOException {
|
||||
|
@ -1251,7 +1252,11 @@ class Manager implements Signal {
|
|||
File tmpFile = null;
|
||||
try {
|
||||
tmpFile = Util.createTempFile();
|
||||
DeviceContactsInputStream s = new DeviceContactsInputStream(retrieveAttachmentAsStream(syncMessage.getContacts().get().asPointer(), tmpFile));
|
||||
final ContactsMessage contactsMessage = syncMessage.getContacts().get();
|
||||
DeviceContactsInputStream s = new DeviceContactsInputStream(retrieveAttachmentAsStream(contactsMessage.getContactsStream().asPointer(), tmpFile));
|
||||
if (contactsMessage.isComplete()) {
|
||||
contactStore.clear();
|
||||
}
|
||||
DeviceContact c;
|
||||
while ((c = s.read()) != null) {
|
||||
ContactInfo contact = contactStore.getContact(c.getNumber());
|
||||
|
@ -1506,7 +1511,7 @@ class Manager implements Signal {
|
|||
.withLength(contactsFile.length())
|
||||
.build();
|
||||
|
||||
sendSyncMessage(SignalServiceSyncMessage.forContacts(attachmentStream));
|
||||
sendSyncMessage(SignalServiceSyncMessage.forContacts(new ContactsMessage(attachmentStream, true)));
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
|
|
|
@ -33,6 +33,13 @@ public class JsonContactsStore {
|
|||
return new ArrayList<>(contacts.values());
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove all contacts from the store
|
||||
*/
|
||||
public void clear() {
|
||||
contacts.clear();
|
||||
}
|
||||
|
||||
public static class MapToListSerializer extends JsonSerializer<Map<?, ?>> {
|
||||
@Override
|
||||
public void serialize(final Map<?, ?> value, final JsonGenerator jgen, final SerializerProvider provider) throws IOException {
|
||||
|
|
|
@ -39,8 +39,8 @@ public class JsonIdentityKeyStore implements IdentityKeyStore {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void saveIdentity(SignalProtocolAddress address, IdentityKey identityKey) {
|
||||
saveIdentity(address.getName(), identityKey, TrustLevel.TRUSTED_UNVERIFIED, null);
|
||||
public boolean saveIdentity(SignalProtocolAddress address, IdentityKey identityKey) {
|
||||
return saveIdentity(address.getName(), identityKey, TrustLevel.TRUSTED_UNVERIFIED, null);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -51,7 +51,7 @@ public class JsonIdentityKeyStore implements IdentityKeyStore {
|
|||
* @param trustLevel
|
||||
* @param added Added timestamp, if null and the key is newly added, the current time is used.
|
||||
*/
|
||||
public void saveIdentity(String name, IdentityKey identityKey, TrustLevel trustLevel, Date added) {
|
||||
public boolean saveIdentity(String name, IdentityKey identityKey, TrustLevel trustLevel, Date added) {
|
||||
List<Identity> identities = trustedKeys.get(name);
|
||||
if (identities == null) {
|
||||
identities = new ArrayList<>();
|
||||
|
@ -67,14 +67,16 @@ public class JsonIdentityKeyStore implements IdentityKeyStore {
|
|||
if (added != null) {
|
||||
id.added = added;
|
||||
}
|
||||
return;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
identities.add(new Identity(identityKey, trustLevel, added != null ? added : new Date()));
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isTrustedIdentity(SignalProtocolAddress address, IdentityKey identityKey) {
|
||||
public boolean isTrustedIdentity(SignalProtocolAddress address, IdentityKey identityKey, Direction direction) {
|
||||
// TODO implement possibility for different handling of incoming/outgoing trust decisions
|
||||
List<Identity> identities = trustedKeys.get(address.getName());
|
||||
if (identities == null) {
|
||||
// Trust on first use
|
||||
|
|
|
@ -8,10 +8,7 @@ import org.whispersystems.libsignal.IdentityKey;
|
|||
import org.whispersystems.libsignal.IdentityKeyPair;
|
||||
import org.whispersystems.libsignal.InvalidKeyIdException;
|
||||
import org.whispersystems.libsignal.SignalProtocolAddress;
|
||||
import org.whispersystems.libsignal.state.PreKeyRecord;
|
||||
import org.whispersystems.libsignal.state.SessionRecord;
|
||||
import org.whispersystems.libsignal.state.SignalProtocolStore;
|
||||
import org.whispersystems.libsignal.state.SignedPreKeyRecord;
|
||||
import org.whispersystems.libsignal.state.*;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
@ -66,8 +63,8 @@ public class JsonSignalProtocolStore implements SignalProtocolStore {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void saveIdentity(SignalProtocolAddress address, IdentityKey identityKey) {
|
||||
identityKeyStore.saveIdentity(address, identityKey);
|
||||
public boolean saveIdentity(SignalProtocolAddress address, IdentityKey identityKey) {
|
||||
return identityKeyStore.saveIdentity(address, identityKey);
|
||||
}
|
||||
|
||||
public void saveIdentity(String name, IdentityKey identityKey, TrustLevel trustLevel) {
|
||||
|
@ -83,8 +80,8 @@ public class JsonSignalProtocolStore implements SignalProtocolStore {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean isTrustedIdentity(SignalProtocolAddress address, IdentityKey identityKey) {
|
||||
return identityKeyStore.isTrustedIdentity(address, identityKey);
|
||||
public boolean isTrustedIdentity(SignalProtocolAddress address, IdentityKey identityKey, Direction direction) {
|
||||
return identityKeyStore.isTrustedIdentity(address, identityKey, direction);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue