From 8751138e192acb0a35357ab309196631a0e2498f Mon Sep 17 00:00:00 2001 From: Paul Schaub Date: Mon, 15 Jan 2018 12:04:48 +0100 Subject: [PATCH] Add method to establish fresh session --- .../smackx/omemo/OmemoManager.java | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/smack-omemo/src/main/java/org/jivesoftware/smackx/omemo/OmemoManager.java b/smack-omemo/src/main/java/org/jivesoftware/smackx/omemo/OmemoManager.java index aeb803afd..9011fd0e9 100644 --- a/smack-omemo/src/main/java/org/jivesoftware/smackx/omemo/OmemoManager.java +++ b/smack-omemo/src/main/java/org/jivesoftware/smackx/omemo/OmemoManager.java @@ -931,6 +931,30 @@ public final class OmemoManager extends Manager { CarbonManager.getInstanceFor(connection()).removeCarbonCopyReceivedListener(internalOmemoCarbonCopyListener); } + /** + * Build a fresh session with a contacts device. + * This might come in handy if a session is broken. + * + * @param contactsDevice OmemoDevice of a contact. + * + * @throws InterruptedException + * @throws SmackException.NoResponseException + * @throws CorruptedOmemoKeyException if our or their identityKey is corrupted. + * @throws SmackException.NotConnectedException + * @throws CannotEstablishOmemoSessionException if no new session can be established. + * @throws SmackException.NotLoggedInException if the connection is not authenticated. + */ + public void rebuildSessionWith(OmemoDevice contactsDevice) + throws InterruptedException, SmackException.NoResponseException, CorruptedOmemoKeyException, + SmackException.NotConnectedException, CannotEstablishOmemoSessionException, + SmackException.NotLoggedInException + { + if (!connection().isAuthenticated()) { + throw new SmackException.NotLoggedInException(); + } + getOmemoService().buildFreshSessionWithDevice(connection(), getOwnDevice(), contactsDevice); + } + /** * Get our connection. *