From c8a6b051639528f4e8e39ff09e4bda36e3191f10 Mon Sep 17 00:00:00 2001 From: iNPUTmice Date: Mon, 10 Nov 2014 11:37:31 +0100 Subject: made Jid class parse otr session ids --- src/main/java/eu/siacs/conversations/xmpp/jid/Jid.java | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'src/main/java/eu') diff --git a/src/main/java/eu/siacs/conversations/xmpp/jid/Jid.java b/src/main/java/eu/siacs/conversations/xmpp/jid/Jid.java index 8e9e0400..3ad3015d 100644 --- a/src/main/java/eu/siacs/conversations/xmpp/jid/Jid.java +++ b/src/main/java/eu/siacs/conversations/xmpp/jid/Jid.java @@ -1,5 +1,7 @@ package eu.siacs.conversations.xmpp.jid; +import net.java.otr4j.session.SessionID; + import java.net.IDN; import gnu.inet.encoding.Stringprep; @@ -30,6 +32,14 @@ public final class Jid { return resourcepart; } + public static Jid fromSessionID(SessionID id) throws InvalidJidException{ + if (id.getUserID().isEmpty()) { + return Jid.fromString(id.getAccountID()); + } else { + return Jid.fromString(id.getAccountID()+"/"+id.getUserID()); + } + } + public static Jid fromString(final String jid) throws InvalidJidException { return new Jid(jid); } -- cgit v1.2.3