aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/de/pixart/messenger/crypto
diff options
context:
space:
mode:
authorChristian Schneppe <christian@pix-art.de>2017-08-01 13:24:24 +0200
committerChristian Schneppe <christian@pix-art.de>2017-08-01 13:24:24 +0200
commit793a50fb376cb2c9f1b97fb606e1db949127e277 (patch)
tree98feff99582a4e4a24c7906472298f786d2eabb2 /src/main/java/de/pixart/messenger/crypto
parentd7bc205420bc07578aee49087b3988429e22372b (diff)
provide upgrade path for accounts with publish-options
Diffstat (limited to 'src/main/java/de/pixart/messenger/crypto')
-rw-r--r--src/main/java/de/pixart/messenger/crypto/axolotl/AxolotlService.java16
1 files changed, 13 insertions, 3 deletions
diff --git a/src/main/java/de/pixart/messenger/crypto/axolotl/AxolotlService.java b/src/main/java/de/pixart/messenger/crypto/axolotl/AxolotlService.java
index 5dc37e4c9..7f15f692e 100644
--- a/src/main/java/de/pixart/messenger/crypto/axolotl/AxolotlService.java
+++ b/src/main/java/de/pixart/messenger/crypto/axolotl/AxolotlService.java
@@ -81,6 +81,7 @@ public class AxolotlService implements OnAdvancedStreamFeaturesLoaded {
private int numPublishTriesOnEmptyPep = 0;
private boolean pepBroken = false;
private AtomicBoolean ownPushPending = new AtomicBoolean(false);
+ private AtomicBoolean changeAccessMode = new AtomicBoolean(false);
@Override
public void onAdvancedStreamFeaturesAvailable(Account account) {
@@ -408,6 +409,7 @@ public class AxolotlService implements OnAdvancedStreamFeaturesLoaded {
if (Config.OMEMO_AUTO_EXPIRY != 0) {
needsPublishing |= deviceIds.removeAll(getExpiredDevices());
}
+ needsPublishing |= this.changeAccessMode.get();
for (Integer deviceId : deviceIds) {
SignalProtocolAddress ownDeviceAddress = new SignalProtocolAddress(jid.toBareJid().toPreppedString(), deviceId);
if (sessions.get(ownDeviceAddress) == null) {
@@ -530,6 +532,11 @@ public class AxolotlService implements OnAdvancedStreamFeaturesLoaded {
}
});
} else {
+ if (AxolotlService.this.changeAccessMode.compareAndSet(true, false)) {
+ Log.d(Config.LOGTAG, account.getJid().toBareJid() + ": done changing access mode");
+ account.setOption(Account.OPTION_REQURIES_ACCESS_MODE_CHANGE, false);
+ mXmppConnectionService.databaseBackend.updateAccount(account);
+ }
ownPushPending.set(false);
if (packet.getType() == IqPacket.TYPE.ERROR) {
pepBroken = true;
@@ -583,6 +590,10 @@ public class AxolotlService implements OnAdvancedStreamFeaturesLoaded {
Log.d(Config.LOGTAG, getLogprefix(account) + "publishBundlesIfNeeded called, but PEP is broken. Ignoring... ");
return;
}
+ this.changeAccessMode.set(account.isOptionSet(Account.OPTION_REQURIES_ACCESS_MODE_CHANGE) && account.getXmppConnection().getFeatures().pepPublishOptions());
+ if (this.changeAccessMode.get()) {
+ Log.d(Config.LOGTAG, account.getJid().toBareJid() + ": server gained publish-options capabilities. changing access model");
+ }
IqPacket packet = mXmppConnectionService.getIqGenerator().retrieveBundlesForDevice(account.getJid().toBareJid(), getOwnDeviceId());
mXmppConnectionService.sendIqPacket(account, packet, new OnIqPacketReceived() {
@Override
@@ -667,7 +678,7 @@ public class AxolotlService implements OnAdvancedStreamFeaturesLoaded {
}
- if (changed) {
+ if (changed || changeAccessMode.get()) {
if (account.getPrivateKeyAlias() != null && Config.X509_VERIFICATION) {
mXmppConnectionService.publishDisplayName(account);
publishDeviceVerificationAndBundle(signedPreKeyRecord, preKeyRecords, announce, wipe);
@@ -725,8 +736,7 @@ public class AxolotlService implements OnAdvancedStreamFeaturesLoaded {
publishDeviceBundle(signedPreKeyRecord, preKeyRecords, announceAfter, wipe, false);
}
});
- }
- if (packet.getType() == IqPacket.TYPE.RESULT) {
+ } else if (packet.getType() == IqPacket.TYPE.RESULT) {
Log.d(Config.LOGTAG, AxolotlService.getLogprefix(account) + "Successfully published bundle. ");
if (wipe) {
wipeOtherPepDevices();