use of org.jivesoftware.smackx.omemo.element.OmemoDeviceListElement in project Smack by igniterealtime.
the class OmemoService method refreshAndRepublishDeviceList.
/**
* Refresh our own device list and publish it to the server.
*
* @param connection XMPPConnection
* @param userDevice our OMEMO device
*
* @throws InterruptedException if the calling thread was interrupted.
* @throws PubSubException.NotALeafNodeException if a PubSub leaf node operation was attempted on a non-leaf node.
* @throws XMPPException.XMPPErrorException if there was an XMPP error returned.
* @throws SmackException.NotConnectedException if the XMPP connection is not connected.
* @throws SmackException.NoResponseException if there was no response from the remote entity.
* @throws IOException if an I/O error occurred.
*/
private void refreshAndRepublishDeviceList(XMPPConnection connection, OmemoDevice userDevice) throws InterruptedException, PubSubException.NotALeafNodeException, XMPPException.XMPPErrorException, SmackException.NotConnectedException, SmackException.NoResponseException, IOException {
// refreshOmemoDeviceList;
OmemoDeviceListElement publishedList;
try {
publishedList = fetchDeviceList(connection, userDevice.getJid());
} catch (PubSubException.NotAPubSubNodeException e) {
// Node is not a PubSub node. This might happen on some ejabberd servers.
publishedList = null;
} catch (XMPPException.XMPPErrorException e) {
if (e.getStanzaError().getCondition() == StanzaError.Condition.item_not_found) {
// Items not found -> items do not exist
publishedList = null;
} else {
// Some other error -> throw
throw e;
}
}
if (publishedList == null) {
publishedList = new OmemoDeviceListElement_VAxolotl(Collections.<Integer>emptySet());
}
getOmemoStoreBackend().mergeCachedDeviceList(userDevice, userDevice.getJid(), publishedList);
OmemoCachedDeviceList cachedList = cleanUpDeviceList(userDevice);
// Republish our deviceId if it is missing from the published list.
if (!publishedList.getDeviceIds().equals(cachedList.getActiveDevices())) {
publishDeviceList(connection, new OmemoDeviceListElement_VAxolotl(cachedList));
}
}
Aggregations