aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/eu/siacs/conversations/crypto/axolotl/AxolotlServiceImpl.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/eu/siacs/conversations/crypto/axolotl/AxolotlServiceImpl.java')
-rw-r--r--src/main/java/eu/siacs/conversations/crypto/axolotl/AxolotlServiceImpl.java22
1 files changed, 12 insertions, 10 deletions
diff --git a/src/main/java/eu/siacs/conversations/crypto/axolotl/AxolotlServiceImpl.java b/src/main/java/eu/siacs/conversations/crypto/axolotl/AxolotlServiceImpl.java
index 73974652..364898b6 100644
--- a/src/main/java/eu/siacs/conversations/crypto/axolotl/AxolotlServiceImpl.java
+++ b/src/main/java/eu/siacs/conversations/crypto/axolotl/AxolotlServiceImpl.java
@@ -49,7 +49,7 @@ import eu.siacs.conversations.xmpp.jid.InvalidJidException;
import eu.siacs.conversations.xmpp.jid.Jid;
import eu.siacs.conversations.xmpp.stanzas.IqPacket;
-public class AxolotlServiceImpl implements AxolotlService {
+public class AxolotlServiceImpl implements OnAdvancedStreamFeaturesLoaded, AxolotlService {
public static final int publishTriesThreshold = 3;
@@ -224,6 +224,7 @@ public class AxolotlServiceImpl implements AxolotlService {
return axolotlStore.getIdentityKeyPair().getPublicKey().getFingerprint().replaceAll("\\s", "");
}
+ @Override
public Set<IdentityKey> getKeysWithTrust(XmppAxolotlSession.Trust trust) {
return axolotlStore.getContactKeysWithTrust(account.getJid().toBareJid().toString(), trust);
}
@@ -242,12 +243,10 @@ public class AxolotlServiceImpl implements AxolotlService {
return keys;
}
- @Override
public long getNumTrustedKeys(Jid jid) {
return axolotlStore.getContactNumTrustedKeys(jid.toBareJid().toString());
}
- @Override
public boolean anyTargetHasNoTrustedKeys(List<Jid> jids) {
for(Jid jid : jids) {
if (axolotlStore.getContactNumTrustedKeys(jid.toBareJid().toString()) == 0) {
@@ -303,6 +302,11 @@ public class AxolotlServiceImpl implements AxolotlService {
return this.pepBroken;
}
+ public void resetBrokenness() {
+ this.pepBroken = false;
+ numPublishTriesOnEmptyPep = 0;
+ }
+
public void regenerateKeys(boolean wipeOther) {
axolotlStore.regenerate();
sessions.clear();
@@ -437,7 +441,8 @@ public class AxolotlServiceImpl implements AxolotlService {
mXmppConnectionService.sendIqPacket(account, publish, new OnIqPacketReceived() {
@Override
public void onIqPacketReceived(Account account, IqPacket packet) {
- if (packet.getType() != IqPacket.TYPE.RESULT) {
+ if (packet.getType() == IqPacket.TYPE.ERROR) {
+ pepBroken = true;
Log.d(Config.LOGTAG, getLogprefix(account) + "Error received while publishing own device id" + packet.findChild("error"));
}
}
@@ -601,14 +606,14 @@ public class AxolotlServiceImpl implements AxolotlService {
Log.d(Config.LOGTAG, getLogprefix(account) + "Announcing device " + getOwnDeviceId());
publishOwnDeviceIdIfNeeded();
}
- } else {
+ } else if (packet.getType() == IqPacket.TYPE.ERROR) {
+ pepBroken = true;
Log.d(Config.LOGTAG, getLogprefix(account) + "Error received while publishing bundle: " + packet.findChild("error"));
}
}
});
}
- @Override
public boolean isConversationAxolotlCapable(Conversation conversation) {
final List<Jid> jids = getCryptoTargets(conversation);
for(Jid jid : jids) {
@@ -619,7 +624,6 @@ public class AxolotlServiceImpl implements AxolotlService {
return jids.size() > 0;
}
- @Override
public List<Jid> getCryptoTargets(Conversation conversation) {
final List<Jid> jids;
if (conversation.getMode() == Conversation.MODE_SINGLE) {
@@ -871,7 +875,6 @@ public class AxolotlServiceImpl implements AxolotlService {
return verified;
}
- @Override
public boolean hasPendingKeyFetches(Account account, List<Jid> jids) {
AxolotlAddress ownAddress = new AxolotlAddress(account.getJid().toBareJid().toString(), 0);
if (fetchStatusMap.getAll(ownAddress).containsValue(FetchStatus.PENDING)) {
@@ -949,7 +952,6 @@ public class AxolotlServiceImpl implements AxolotlService {
});
}
- @Override
public void prepareKeyTransportMessage(final Conversation conversation, final OnMessageCreatedCallback onMessageCreatedCallback) {
executor.execute(new Runnable() {
@Override
@@ -1038,4 +1040,4 @@ public class AxolotlServiceImpl implements AxolotlService {
}
}
}
-} \ No newline at end of file
+}