change access model of omemo pep nodes after every publish

This commit is contained in:
Daniel Gultsch 2017-06-28 10:21:06 +02:00
parent 6c95897f09
commit 25e993693f
2 changed files with 34 additions and 15 deletions

View file

@ -51,6 +51,7 @@ import eu.siacs.conversations.xmpp.OnAdvancedStreamFeaturesLoaded;
import eu.siacs.conversations.xmpp.OnIqPacketReceived;
import eu.siacs.conversations.xmpp.jid.InvalidJidException;
import eu.siacs.conversations.xmpp.jid.Jid;
import eu.siacs.conversations.xmpp.pep.PublishOptions;
import eu.siacs.conversations.xmpp.stanzas.IqPacket;
public class AxolotlService implements OnAdvancedStreamFeaturesLoaded {
@ -436,7 +437,14 @@ public class AxolotlService implements OnAdvancedStreamFeaturesLoaded {
deviceIds.add(getOwnDeviceId());
IqPacket publish = mXmppConnectionService.getIqGenerator().publishDeviceIds(deviceIds);
Log.d(Config.LOGTAG, AxolotlService.getLogprefix(account) + "Wiping all other devices from Pep:" + publish);
mXmppConnectionService.sendIqPacket(account, publish, null);
mXmppConnectionService.sendIqPacket(account, publish, new OnIqPacketReceived() {
@Override
public void onIqPacketReceived(Account account, IqPacket packet) {
if (packet.getType() == IqPacket.TYPE.RESULT) {
mXmppConnectionService.pushNodeConfiguration(account, AxolotlService.PEP_DEVICE_LIST, PublishOptions.openAccess(), null);
}
}
});
}
public void distrustFingerprint(final String fingerprint) {
@ -512,6 +520,8 @@ public class AxolotlService implements OnAdvancedStreamFeaturesLoaded {
if (packet.getType() == IqPacket.TYPE.ERROR) {
pepBroken = true;
Log.d(Config.LOGTAG, getLogprefix(account) + "Error received while publishing own device id" + packet.findChild("error"));
} else if (packet.getType() != IqPacket.TYPE.TIMEOUT) {
mXmppConnectionService.pushNodeConfiguration(account, AxolotlService.PEP_DEVICE_LIST, PublishOptions.openAccess(), null);
}
}
});
@ -535,9 +545,7 @@ public class AxolotlService implements OnAdvancedStreamFeaturesLoaded {
@Override
public void onIqPacketReceived(final Account account, IqPacket packet) {
String node = AxolotlService.PEP_VERIFICATION+":"+getOwnDeviceId();
Bundle pubsubOptions = new Bundle();
pubsubOptions.putString("pubsub#access_model","open");
mXmppConnectionService.pushNodeConfiguration(account, account.getJid().toBareJid(), node, pubsubOptions, new XmppConnectionService.OnConfigurationPushed() {
mXmppConnectionService.pushNodeConfiguration(account, node, PublishOptions.openAccess(), new XmppConnectionService.OnConfigurationPushed() {
@Override
public void onPushSucceeded() {
Log.d(Config.LOGTAG,getLogprefix(account) + "configured verification node to be world readable");
@ -679,8 +687,12 @@ public class AxolotlService implements OnAdvancedStreamFeaturesLoaded {
Log.d(Config.LOGTAG, AxolotlService.getLogprefix(account) + ": Bundle " + getOwnDeviceId() + " in PEP not current. Publishing...");
mXmppConnectionService.sendIqPacket(account, publish, new OnIqPacketReceived() {
@Override
public void onIqPacketReceived(Account account, IqPacket packet) {
public void onIqPacketReceived(final Account account, IqPacket packet) {
if (packet.getType() == IqPacket.TYPE.RESULT) {
final String node = AxolotlService.PEP_BUNDLES + ":" + getOwnDeviceId();
mXmppConnectionService.pushNodeConfiguration(account, node, PublishOptions.openAccess(), new XmppConnectionService.OnConfigurationPushed() {
@Override
public void onPushSucceeded() {
Log.d(Config.LOGTAG, AxolotlService.getLogprefix(account) + "Successfully published bundle. ");
if (wipe) {
wipeOtherPepDevices();
@ -688,6 +700,13 @@ public class AxolotlService implements OnAdvancedStreamFeaturesLoaded {
Log.d(Config.LOGTAG, getLogprefix(account) + "Announcing device " + getOwnDeviceId());
publishOwnDeviceIdIfNeeded();
}
}
@Override
public void onPushFailed() {
Log.d(Config.LOGTAG,"unable to change access model for pubsub node");
}
});
} else if (packet.getType() == IqPacket.TYPE.ERROR) {
pepBroken = true;
Log.d(Config.LOGTAG, getLogprefix(account) + "Error received while publishing bundle: " + packet.findChild("error"));

View file

@ -2607,17 +2607,17 @@ public class XmppConnectionService extends Service {
sendIqPacket(account, mIqGenerator.publishPubsubConfiguration(jid, node, data), new OnIqPacketReceived() {
@Override
public void onIqPacketReceived(Account account, IqPacket packet) {
if (packet.getType() == IqPacket.TYPE.RESULT) {
if (packet.getType() == IqPacket.TYPE.RESULT && callback != null) {
callback.onPushSucceeded();
} else {
Log.d(Config.LOGTAG,packet.toString());
}
}
});
} else {
} else if (callback !=null) {
callback.onPushFailed();
}
} else {
} else if (callback != null){
callback.onPushFailed();
}
}