diff --git a/smack-experimental/src/main/java/org/jivesoftware/smackx/jet/JetManager.java b/smack-experimental/src/main/java/org/jivesoftware/smackx/jet/JetManager.java index 26c1e131b..a80fa35d5 100644 --- a/smack-experimental/src/main/java/org/jivesoftware/smackx/jet/JetManager.java +++ b/smack-experimental/src/main/java/org/jivesoftware/smackx/jet/JetManager.java @@ -34,14 +34,15 @@ import javax.crypto.spec.SecretKeySpec; import org.jivesoftware.smack.Manager; import org.jivesoftware.smack.XMPPConnection; import org.jivesoftware.smack.packet.ExtensionElement; +import org.jivesoftware.smack.util.StringUtils; import org.jivesoftware.smackx.jet.element.JetSecurityElement; -import org.jivesoftware.smackx.jingle.transport.legacy.JingleUtil; +import org.jivesoftware.smackx.jingle.JingleManager; +import org.jivesoftware.smackx.jingle.element.JingleContentDescriptionChildElement; import org.jivesoftware.smackx.jingle.element.JingleContentElement; import org.jivesoftware.smackx.jingle.element.JingleElement; -import org.jivesoftware.smackx.jingle.element.JingleContentDescriptionChildElement; import org.jivesoftware.smackx.jingle_filetransfer.OutgoingJingleFileOffer; -import org.jivesoftware.smackx.jingle_filetransfer.element.JingleFileTransfer; -import org.jivesoftware.smackx.jingle_filetransfer.element.JingleFileTransferChild; +import org.jivesoftware.smackx.jft.element.JingleFileTransferElement; +import org.jivesoftware.smackx.jft.element.JingleFileTransferChildElement; import org.jivesoftware.smackx.jingle_filetransfer.handler.FileTransferHandler; import org.jxmpp.jid.FullJid; @@ -53,16 +54,12 @@ public final class JetManager extends Manager { private static final Logger LOGGER = Logger.getLogger(JetManager.class.getName()); - public static final String NAMESPACE = "urn:xmpp:jingle:jet:0"; - private static final WeakHashMap INSTANCES = new WeakHashMap<>(); - private final JingleUtil jutil; private static final Map encryptionMethods = new HashMap<>(); private JetManager(XMPPConnection connection) { super(connection); - jutil = new JingleUtil(connection); } public static JetManager getInstanceFor(XMPPConnection connection) { @@ -139,15 +136,15 @@ public final class JetManager extends Manager { return null; } - String contentName = JingleManager.randomId(); + String contentName = StringUtils.randomString(24); ExtensionElement encryptionExtension = encryptionMethod.encryptJingleTransfer(recipient, keyAndIv); JetSecurityElement securityElement = new JetSecurityElement(contentName, encryptionExtension); OutgoingJingleFileOffer offer = new OutgoingJingleFileOffer(connection(), recipient); - JingleFileTransferChild fileTransferChild = JingleFileTransferChild.getBuilder().setFile(file).build(); - JingleFileTransfer fileTransfer = new JingleFileTransfer(Collections.singletonList(fileTransferChild)); + JingleFileTransferChildElement fileTransferChild = JingleFileTransferChildElement.getBuilder().setFile(file).build(); + JingleFileTransferElement fileTransfer = new JingleFileTransferElement(Collections.singletonList(fileTransferChild)); JingleContentElement content = JingleContentElement.getBuilder() .setCreator(JingleContentElement.Creator.initiator) diff --git a/smack-experimental/src/main/java/org/jivesoftware/smackx/jet/element/JetSecurityElement.java b/smack-experimental/src/main/java/org/jivesoftware/smackx/jet/element/JetSecurityElement.java index 32c7d9ec9..f34c8aeec 100644 --- a/smack-experimental/src/main/java/org/jivesoftware/smackx/jet/element/JetSecurityElement.java +++ b/smack-experimental/src/main/java/org/jivesoftware/smackx/jet/element/JetSecurityElement.java @@ -18,7 +18,7 @@ package org.jivesoftware.smackx.jet.element; import org.jivesoftware.smack.packet.ExtensionElement; import org.jivesoftware.smack.util.XmlStringBuilder; -import org.jivesoftware.smackx.jet.JetManager; +import org.jivesoftware.smackx.jet.internal.JetSecurity; import org.jivesoftware.smackx.jingle.element.JingleContentSecurityElement; /** @@ -55,6 +55,6 @@ public class JetSecurityElement extends JingleContentSecurityElement { @Override public String getNamespace() { - return JetManager.NAMESPACE; + return JetSecurity.NAMESPACE; } } diff --git a/smack-experimental/src/main/java/org/jivesoftware/smackx/jet/internal/JetSecurity.java b/smack-experimental/src/main/java/org/jivesoftware/smackx/jet/internal/JetSecurity.java new file mode 100644 index 000000000..8b4c5b810 --- /dev/null +++ b/smack-experimental/src/main/java/org/jivesoftware/smackx/jet/internal/JetSecurity.java @@ -0,0 +1,28 @@ +package org.jivesoftware.smackx.jet.internal; + +import org.jivesoftware.smack.packet.ExtensionElement; +import org.jivesoftware.smackx.jet.element.JetSecurityElement; +import org.jivesoftware.smackx.jingle.element.JingleContentSecurityInfoElement; +import org.jivesoftware.smackx.jingle.element.JingleElement; +import org.jivesoftware.smackx.jingle.internal.JingleSecurity; + +/** + * Created by vanitas on 22.07.17. + */ +public class JetSecurity extends JingleSecurity { + + public static final String NAMESPACE_V0 = "urn:xmpp:jingle:jet:0"; + public static final String NAMESPACE = NAMESPACE_V0; + + private ExtensionElement child; + + @Override + public JetSecurityElement getElement() { + return new JetSecurityElement(getParent().getName(), child); + } + + @Override + public JingleElement handleSecurityInfo(JingleContentSecurityInfoElement element, JingleElement wrapping) { + return null; + } +} diff --git a/smack-experimental/src/main/java/org/jivesoftware/smackx/jft/JingleFileTransferManager.java b/smack-experimental/src/main/java/org/jivesoftware/smackx/jft/JingleFileTransferManager.java new file mode 100644 index 000000000..aa7a41a1b --- /dev/null +++ b/smack-experimental/src/main/java/org/jivesoftware/smackx/jft/JingleFileTransferManager.java @@ -0,0 +1,53 @@ +package org.jivesoftware.smackx.jft; + +import java.util.WeakHashMap; + +import org.jivesoftware.smack.Manager; +import org.jivesoftware.smack.XMPPConnection; +import org.jivesoftware.smackx.disco.ServiceDiscoveryManager; +import org.jivesoftware.smackx.jft.internal.JingleFileTransfer; +import org.jivesoftware.smackx.jft.provider.JingleFileTransferProvider; +import org.jivesoftware.smackx.jingle.JingleDescriptionManager; +import org.jivesoftware.smackx.jingle.JingleManager; +import org.jivesoftware.smackx.jingle.callbacks.ContentAddCallback; +import org.jivesoftware.smackx.jingle.element.JingleElement; +import org.jivesoftware.smackx.jingle.internal.JingleContent; +import org.jivesoftware.smackx.jingle.provider.JingleContentProviderManager; + +/** + * Created by vanitas on 22.07.17. + */ +public final class JingleFileTransferManager extends Manager implements JingleDescriptionManager { + + private static final WeakHashMap INSTANCES = new WeakHashMap<>(); + private final JingleManager jingleManager; + + private JingleFileTransferManager(XMPPConnection connection) { + super(connection); + ServiceDiscoveryManager.getInstanceFor(connection).addFeature(getNamespace()); + jingleManager = JingleManager.getInstanceFor(connection); + jingleManager.addJingleDescriptionManager(this); + JingleContentProviderManager.addJingleContentDescriptionProvider(getNamespace(), new JingleFileTransferProvider()); + } + + public static JingleFileTransferManager getInstanceFor(XMPPConnection connection) { + JingleFileTransferManager manager = INSTANCES.get(connection); + + if (manager == null) { + manager = new JingleFileTransferManager(connection); + INSTANCES.put(connection, manager); + } + + return manager; + } + + @Override + public String getNamespace() { + return JingleFileTransfer.NAMESPACE; + } + + @Override + public JingleElement notifyContentListeners(JingleContent content, ContentAddCallback callback) { + return null; + } +} diff --git a/smack-experimental/src/main/java/org/jivesoftware/smackx/jingle_filetransfer/element/Checksum.java b/smack-experimental/src/main/java/org/jivesoftware/smackx/jft/element/ChecksumElement.java similarity index 84% rename from smack-experimental/src/main/java/org/jivesoftware/smackx/jingle_filetransfer/element/Checksum.java rename to smack-experimental/src/main/java/org/jivesoftware/smackx/jft/element/ChecksumElement.java index 3d6a004bd..54df1504e 100644 --- a/smack-experimental/src/main/java/org/jivesoftware/smackx/jingle_filetransfer/element/Checksum.java +++ b/smack-experimental/src/main/java/org/jivesoftware/smackx/jft/element/ChecksumElement.java @@ -14,7 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.jivesoftware.smackx.jingle_filetransfer.element; +package org.jivesoftware.smackx.jft.element; import org.jivesoftware.smack.packet.ExtensionElement; import org.jivesoftware.smack.util.Objects; @@ -24,16 +24,16 @@ import org.jivesoftware.smackx.jingle.element.JingleContentElement; /** * Checksum element. */ -public class Checksum implements ExtensionElement { +public class ChecksumElement implements ExtensionElement { public static final String ELEMENT = "checksum"; public static final String ATTR_CREATOR = "creator"; public static final String ATTR_NAME = "name"; private final JingleContentElement.Creator creator; private final String name; - private final JingleFileTransferChild file; + private final JingleFileTransferChildElement file; - public Checksum(JingleContentElement.Creator creator, String name, JingleFileTransferChild file) { + public ChecksumElement(JingleContentElement.Creator creator, String name, JingleFileTransferChildElement file) { this.creator = creator; this.name = name; this.file = Objects.requireNonNull(file, "file MUST NOT be null."); @@ -58,6 +58,6 @@ public class Checksum implements ExtensionElement { @Override public String getNamespace() { - return JingleFileTransfer.NAMESPACE_V5; + return JingleFileTransferElement.NAMESPACE_V5; } } diff --git a/smack-experimental/src/main/java/org/jivesoftware/smackx/jingle_filetransfer/element/JingleFileTransferChild.java b/smack-experimental/src/main/java/org/jivesoftware/smackx/jft/element/JingleFileTransferChildElement.java similarity index 91% rename from smack-experimental/src/main/java/org/jivesoftware/smackx/jingle_filetransfer/element/JingleFileTransferChild.java rename to smack-experimental/src/main/java/org/jivesoftware/smackx/jft/element/JingleFileTransferChildElement.java index ed20b38d8..f9aed7017 100644 --- a/smack-experimental/src/main/java/org/jivesoftware/smackx/jingle_filetransfer/element/JingleFileTransferChild.java +++ b/smack-experimental/src/main/java/org/jivesoftware/smackx/jft/element/JingleFileTransferChildElement.java @@ -14,7 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.jivesoftware.smackx.jingle_filetransfer.element; +package org.jivesoftware.smackx.jft.element; import java.io.File; import java.util.Date; @@ -26,7 +26,7 @@ import org.jivesoftware.smackx.jingle.element.JingleContentDescriptionChildEleme /** * Content of type File. */ -public class JingleFileTransferChild extends JingleContentDescriptionChildElement { +public class JingleFileTransferChildElement extends JingleContentDescriptionChildElement { public static final String ELEMENT = "file"; public static final String ELEM_DATE = "date"; public static final String ELEM_DESC = "desc"; @@ -42,7 +42,7 @@ public class JingleFileTransferChild extends JingleContentDescriptionChildElemen private final int size; private final Range range; - public JingleFileTransferChild(Date date, String desc, HashElement hash, String mediaType, String name, int size, Range range) { + public JingleFileTransferChildElement(Date date, String desc, HashElement hash, String mediaType, String name, int size, Range range) { this.date = date; this.desc = desc; this.hash = hash; @@ -162,8 +162,8 @@ public class JingleFileTransferChild extends JingleContentDescriptionChildElemen return this; } - public JingleFileTransferChild build() { - return new JingleFileTransferChild(date, desc, hash, mediaType, name, size, range); + public JingleFileTransferChildElement build() { + return new JingleFileTransferChildElement(date, desc, hash, mediaType, name, size, range); } public Builder setFile(File file) { diff --git a/smack-experimental/src/main/java/org/jivesoftware/smackx/jingle_filetransfer/element/JingleFileTransfer.java b/smack-experimental/src/main/java/org/jivesoftware/smackx/jft/element/JingleFileTransferElement.java similarity index 72% rename from smack-experimental/src/main/java/org/jivesoftware/smackx/jingle_filetransfer/element/JingleFileTransfer.java rename to smack-experimental/src/main/java/org/jivesoftware/smackx/jft/element/JingleFileTransferElement.java index 77149660b..3cb671e98 100644 --- a/smack-experimental/src/main/java/org/jivesoftware/smackx/jingle_filetransfer/element/JingleFileTransfer.java +++ b/smack-experimental/src/main/java/org/jivesoftware/smackx/jft/element/JingleFileTransferElement.java @@ -14,25 +14,26 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.jivesoftware.smackx.jingle_filetransfer.element; +package org.jivesoftware.smackx.jft.element; import java.util.List; +import org.jivesoftware.smackx.jft.internal.JingleFileTransfer; import org.jivesoftware.smackx.jingle.element.JingleContentDescriptionElement; import org.jivesoftware.smackx.jingle.element.JingleContentDescriptionChildElement; /** * File element. */ -public class JingleFileTransfer extends JingleContentDescriptionElement { - public static final String NAMESPACE_V5 = "urn:xmpp:jingle:apps:file-transfer:5"; +public class JingleFileTransferElement extends JingleContentDescriptionElement { - public JingleFileTransfer(List payloads) { + + public JingleFileTransferElement(List payloads) { super(payloads); } @Override public String getNamespace() { - return NAMESPACE_V5; + return JingleFileTransfer.NAMESPACE; } } diff --git a/smack-experimental/src/main/java/org/jivesoftware/smackx/jingle_filetransfer/element/Range.java b/smack-experimental/src/main/java/org/jivesoftware/smackx/jft/element/Range.java similarity index 98% rename from smack-experimental/src/main/java/org/jivesoftware/smackx/jingle_filetransfer/element/Range.java rename to smack-experimental/src/main/java/org/jivesoftware/smackx/jft/element/Range.java index 811685f9a..39138dd5e 100644 --- a/smack-experimental/src/main/java/org/jivesoftware/smackx/jingle_filetransfer/element/Range.java +++ b/smack-experimental/src/main/java/org/jivesoftware/smackx/jft/element/Range.java @@ -14,7 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.jivesoftware.smackx.jingle_filetransfer.element; +package org.jivesoftware.smackx.jft.element; import org.jivesoftware.smack.packet.NamedElement; import org.jivesoftware.smack.util.XmlStringBuilder; diff --git a/smack-experimental/src/main/java/org/jivesoftware/smackx/jingle_filetransfer/element/package-info.java b/smack-experimental/src/main/java/org/jivesoftware/smackx/jft/element/package-info.java similarity index 92% rename from smack-experimental/src/main/java/org/jivesoftware/smackx/jingle_filetransfer/element/package-info.java rename to smack-experimental/src/main/java/org/jivesoftware/smackx/jft/element/package-info.java index da2e22582..2736a1e31 100644 --- a/smack-experimental/src/main/java/org/jivesoftware/smackx/jingle_filetransfer/element/package-info.java +++ b/smack-experimental/src/main/java/org/jivesoftware/smackx/jft/element/package-info.java @@ -19,4 +19,4 @@ * Smack's API for XEP-0234: Jingle File Transfer. * Elements. */ -package org.jivesoftware.smackx.jingle_filetransfer.element; +package org.jivesoftware.smackx.jft.element; diff --git a/smack-experimental/src/main/java/org/jivesoftware/smackx/jft/internal/JingleFileOffer.java b/smack-experimental/src/main/java/org/jivesoftware/smackx/jft/internal/JingleFileOffer.java new file mode 100644 index 000000000..448e78acb --- /dev/null +++ b/smack-experimental/src/main/java/org/jivesoftware/smackx/jft/internal/JingleFileOffer.java @@ -0,0 +1,7 @@ +package org.jivesoftware.smackx.jft.internal; + +/** + * Created by vanitas on 22.07.17. + */ +public class JingleFileOffer extends JingleFileTransfer { +} diff --git a/smack-experimental/src/main/java/org/jivesoftware/smackx/jft/internal/JingleFileRequest.java b/smack-experimental/src/main/java/org/jivesoftware/smackx/jft/internal/JingleFileRequest.java new file mode 100644 index 000000000..94a986601 --- /dev/null +++ b/smack-experimental/src/main/java/org/jivesoftware/smackx/jft/internal/JingleFileRequest.java @@ -0,0 +1,7 @@ +package org.jivesoftware.smackx.jft.internal; + +/** + * Created by vanitas on 22.07.17. + */ +public class JingleFileRequest extends JingleFileTransfer { +} diff --git a/smack-experimental/src/main/java/org/jivesoftware/smackx/jft/internal/JingleFileTransfer.java b/smack-experimental/src/main/java/org/jivesoftware/smackx/jft/internal/JingleFileTransfer.java new file mode 100644 index 000000000..f52efe9f0 --- /dev/null +++ b/smack-experimental/src/main/java/org/jivesoftware/smackx/jft/internal/JingleFileTransfer.java @@ -0,0 +1,18 @@ +package org.jivesoftware.smackx.jft.internal; + +import org.jivesoftware.smackx.jingle.internal.JingleDescription; +import org.jivesoftware.smackx.jft.element.JingleFileTransferElement; + +/** + * Created by vanitas on 22.07.17. + */ +public abstract class JingleFileTransfer extends JingleDescription { + + public static final String NAMESPACE_V5 = "urn:xmpp:jingle:apps:file-transfer:5"; + public static final String NAMESPACE = NAMESPACE_V5; + + @Override + public JingleFileTransferElement getElement() { + return null; + } +} diff --git a/smack-experimental/src/main/java/org/jivesoftware/smackx/jingle_filetransfer/provider/ChecksumProvider.java b/smack-experimental/src/main/java/org/jivesoftware/smackx/jft/provider/ChecksumProvider.java similarity index 80% rename from smack-experimental/src/main/java/org/jivesoftware/smackx/jingle_filetransfer/provider/ChecksumProvider.java rename to smack-experimental/src/main/java/org/jivesoftware/smackx/jft/provider/ChecksumProvider.java index f34bc7a05..2681f0af4 100644 --- a/smack-experimental/src/main/java/org/jivesoftware/smackx/jingle_filetransfer/provider/ChecksumProvider.java +++ b/smack-experimental/src/main/java/org/jivesoftware/smackx/jft/provider/ChecksumProvider.java @@ -14,7 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.jivesoftware.smackx.jingle_filetransfer.provider; +package org.jivesoftware.smackx.jft.provider; import static org.xmlpull.v1.XmlPullParser.END_TAG; import static org.xmlpull.v1.XmlPullParser.START_TAG; @@ -24,27 +24,27 @@ import org.jivesoftware.smack.util.ParserUtils; import org.jivesoftware.smackx.hashes.element.HashElement; import org.jivesoftware.smackx.hashes.provider.HashElementProvider; import org.jivesoftware.smackx.jingle.element.JingleContentElement; -import org.jivesoftware.smackx.jingle_filetransfer.element.Checksum; -import org.jivesoftware.smackx.jingle_filetransfer.element.JingleFileTransferChild; -import org.jivesoftware.smackx.jingle_filetransfer.element.Range; +import org.jivesoftware.smackx.jft.element.ChecksumElement; +import org.jivesoftware.smackx.jft.element.JingleFileTransferChildElement; +import org.jivesoftware.smackx.jft.element.Range; import org.xmlpull.v1.XmlPullParser; /** * Provider for the Checksum element. */ -public class ChecksumProvider extends ExtensionElementProvider { +public class ChecksumProvider extends ExtensionElementProvider { @Override - public Checksum parse(XmlPullParser parser, int initialDepth) throws Exception { + public ChecksumElement parse(XmlPullParser parser, int initialDepth) throws Exception { JingleContentElement.Creator creator = null; - String creatorString = parser.getAttributeValue(null, Checksum.ATTR_CREATOR); + String creatorString = parser.getAttributeValue(null, ChecksumElement.ATTR_CREATOR); if (creatorString != null) { creator = JingleContentElement.Creator.valueOf(creatorString); } - String name = parser.getAttributeValue(null, Checksum.ATTR_NAME); + String name = parser.getAttributeValue(null, ChecksumElement.ATTR_NAME); - JingleFileTransferChild.Builder cb = JingleFileTransferChild.getBuilder(); + JingleFileTransferChildElement.Builder cb = JingleFileTransferChildElement.getBuilder(); HashElement hashElement = null; Range range = null; @@ -73,7 +73,7 @@ public class ChecksumProvider extends ExtensionElementProvider { } break; - case JingleFileTransferChild.ELEMENT: + case JingleFileTransferChildElement.ELEMENT: if (hashElement != null) { cb.setHash(hashElement); } @@ -84,6 +84,6 @@ public class ChecksumProvider extends ExtensionElementProvider { } } } - return new Checksum(creator, name, cb.build()); + return new ChecksumElement(creator, name, cb.build()); } } diff --git a/smack-experimental/src/main/java/org/jivesoftware/smackx/jingle_filetransfer/provider/JingleFileTransferProvider.java b/smack-experimental/src/main/java/org/jivesoftware/smackx/jft/provider/JingleFileTransferProvider.java similarity index 76% rename from smack-experimental/src/main/java/org/jivesoftware/smackx/jingle_filetransfer/provider/JingleFileTransferProvider.java rename to smack-experimental/src/main/java/org/jivesoftware/smackx/jft/provider/JingleFileTransferProvider.java index 9b4883ae0..b11cc245d 100644 --- a/smack-experimental/src/main/java/org/jivesoftware/smackx/jingle_filetransfer/provider/JingleFileTransferProvider.java +++ b/smack-experimental/src/main/java/org/jivesoftware/smackx/jft/provider/JingleFileTransferProvider.java @@ -14,7 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.jivesoftware.smackx.jingle_filetransfer.provider; +package org.jivesoftware.smackx.jft.provider; import static org.xmlpull.v1.XmlPullParser.END_TAG; import static org.xmlpull.v1.XmlPullParser.START_TAG; @@ -26,9 +26,9 @@ import org.jivesoftware.smackx.hashes.element.HashElement; import org.jivesoftware.smackx.hashes.provider.HashElementProvider; import org.jivesoftware.smackx.jingle.element.JingleContentDescriptionChildElement; import org.jivesoftware.smackx.jingle.provider.JingleContentDescriptionProvider; -import org.jivesoftware.smackx.jingle_filetransfer.element.JingleFileTransfer; -import org.jivesoftware.smackx.jingle_filetransfer.element.JingleFileTransferChild; -import org.jivesoftware.smackx.jingle_filetransfer.element.Range; +import org.jivesoftware.smackx.jft.element.JingleFileTransferElement; +import org.jivesoftware.smackx.jft.element.JingleFileTransferChildElement; +import org.jivesoftware.smackx.jft.element.Range; import org.jxmpp.util.XmppDateTime; import org.xmlpull.v1.XmlPullParser; @@ -37,13 +37,13 @@ import org.xmlpull.v1.XmlPullParser; * Provider for JingleContentDescriptionFileTransfer elements. */ public class JingleFileTransferProvider - extends JingleContentDescriptionProvider { + extends JingleContentDescriptionProvider { @Override - public JingleFileTransfer parse(XmlPullParser parser, int initialDepth) throws Exception { + public JingleFileTransferElement parse(XmlPullParser parser, int initialDepth) throws Exception { ArrayList payloads = new ArrayList<>(); boolean inRange = false; - JingleFileTransferChild.Builder builder = JingleFileTransferChild.getBuilder(); + JingleFileTransferChildElement.Builder builder = JingleFileTransferChildElement.getBuilder(); HashElement inRangeHash = null; Long length = null, offset = null; while (true) { @@ -53,23 +53,23 @@ public class JingleFileTransferProvider if (tag == START_TAG) { switch (elem) { - case JingleFileTransferChild.ELEM_DATE: + case JingleFileTransferChildElement.ELEM_DATE: builder.setDate(XmppDateTime.parseXEP0082Date(parser.nextText())); break; - case JingleFileTransferChild.ELEM_DESC: + case JingleFileTransferChildElement.ELEM_DESC: builder.setDescription(parser.nextText()); break; - case JingleFileTransferChild.ELEM_MEDIA_TYPE: + case JingleFileTransferChildElement.ELEM_MEDIA_TYPE: builder.setMediaType(parser.nextText()); break; - case JingleFileTransferChild.ELEM_NAME: + case JingleFileTransferChildElement.ELEM_NAME: builder.setName(parser.nextText()); break; - case JingleFileTransferChild.ELEM_SIZE: + case JingleFileTransferChildElement.ELEM_SIZE: builder.setSize(Integer.parseInt(parser.nextText())); break; @@ -102,13 +102,13 @@ public class JingleFileTransferProvider inRangeHash = null; break; - case JingleFileTransferChild.ELEMENT: + case JingleFileTransferChildElement.ELEMENT: payloads.add(builder.build()); - builder = JingleFileTransferChild.getBuilder(); + builder = JingleFileTransferChildElement.getBuilder(); break; - case JingleFileTransfer.ELEMENT: - return new JingleFileTransfer(payloads); + case JingleFileTransferElement.ELEMENT: + return new JingleFileTransferElement(payloads); } } } diff --git a/smack-experimental/src/main/java/org/jivesoftware/smackx/jingle_filetransfer/provider/package-info.java b/smack-experimental/src/main/java/org/jivesoftware/smackx/jft/provider/package-info.java similarity index 92% rename from smack-experimental/src/main/java/org/jivesoftware/smackx/jingle_filetransfer/provider/package-info.java rename to smack-experimental/src/main/java/org/jivesoftware/smackx/jft/provider/package-info.java index 85163fdeb..c0dd9d116 100644 --- a/smack-experimental/src/main/java/org/jivesoftware/smackx/jingle_filetransfer/provider/package-info.java +++ b/smack-experimental/src/main/java/org/jivesoftware/smackx/jft/provider/package-info.java @@ -19,4 +19,4 @@ * Smack's API for XEP-0234: Jingle File Transfer. * Providers. */ -package org.jivesoftware.smackx.jingle_filetransfer.provider; +package org.jivesoftware.smackx.jft.provider; diff --git a/smack-experimental/src/main/java/org/jivesoftware/smackx/jingle_filetransfer/IncomingJingleFileOffer.java b/smack-experimental/src/main/java/org/jivesoftware/smackx/jingle_filetransfer/IncomingJingleFileOffer.java index 6fdfc6630..29dce4667 100644 --- a/smack-experimental/src/main/java/org/jivesoftware/smackx/jingle_filetransfer/IncomingJingleFileOffer.java +++ b/smack-experimental/src/main/java/org/jivesoftware/smackx/jingle_filetransfer/IncomingJingleFileOffer.java @@ -32,7 +32,7 @@ import org.jivesoftware.smackx.jingle.element.JingleReasonElement; import org.jivesoftware.smackx.jingle.transports.JingleTransportInitiationCallback; import org.jivesoftware.smackx.jingle.transports.JingleTransportManager; import org.jivesoftware.smackx.jingle_filetransfer.callback.IncomingFileOfferCallback; -import org.jivesoftware.smackx.jingle_filetransfer.element.JingleFileTransfer; +import org.jivesoftware.smackx.jft.element.JingleFileTransferElement; import org.jivesoftware.smackx.jingle_filetransfer.handler.FileTransferHandler; import org.jxmpp.jid.FullJid; @@ -91,7 +91,7 @@ public class IncomingJingleFileOffer extends JingleFileTransferSession implement } this.contents.addAll(initiate.getContents()); - this.file = (JingleFileTransfer) contents.get(0).getDescription(); + this.file = (JingleFileTransferElement) contents.get(0).getDescription(); JingleTransportManager transportManager = tm.getTransportManager(initiate); if (transportManager == null) { @@ -120,7 +120,7 @@ public class IncomingJingleFileOffer extends JingleFileTransferSession implement state = State.pending; - JingleFileTransferManager.getInstanceFor(connection).notifyIncomingFileOffer(initiate, + JingleFileTransferManagerAlt.getInstanceFor(connection).notifyIncomingFileOffer(initiate, IncomingJingleFileOffer.this); return jutil.createAck(initiate); @@ -183,7 +183,7 @@ public class IncomingJingleFileOffer extends JingleFileTransferSession implement return jutil.createErrorOutOfOrder(transportAccept); } - JingleFileTransferManager.getInstanceFor(connection) + JingleFileTransferManagerAlt.getInstanceFor(connection) .notifyIncomingFileOffer(pendingSessionInitiate, this); transportSession.processJingle(transportAccept); state = State.pending; diff --git a/smack-experimental/src/main/java/org/jivesoftware/smackx/jingle_filetransfer/JingleFileTransferManager.java b/smack-experimental/src/main/java/org/jivesoftware/smackx/jingle_filetransfer/JingleFileTransferManagerAlt.java similarity index 82% rename from smack-experimental/src/main/java/org/jivesoftware/smackx/jingle_filetransfer/JingleFileTransferManager.java rename to smack-experimental/src/main/java/org/jivesoftware/smackx/jingle_filetransfer/JingleFileTransferManagerAlt.java index b66a9e56f..113b52334 100644 --- a/smack-experimental/src/main/java/org/jivesoftware/smackx/jingle_filetransfer/JingleFileTransferManager.java +++ b/smack-experimental/src/main/java/org/jivesoftware/smackx/jingle_filetransfer/JingleFileTransferManagerAlt.java @@ -29,45 +29,46 @@ import org.jivesoftware.smack.XMPPConnection; import org.jivesoftware.smack.XMPPException; import org.jivesoftware.smack.packet.IQ; import org.jivesoftware.smackx.disco.ServiceDiscoveryManager; -import org.jivesoftware.smackx.jingle.transport.legacy.JingleUtil; -import org.jivesoftware.smackx.jingle.element.JingleContentElement; -import org.jivesoftware.smackx.jingle.element.JingleElement; +import org.jivesoftware.smackx.jft.element.JingleFileTransferChildElement; +import org.jivesoftware.smackx.jft.element.JingleFileTransferElement; +import org.jivesoftware.smackx.jft.internal.JingleFileTransfer; +import org.jivesoftware.smackx.jft.provider.JingleFileTransferProvider; +import org.jivesoftware.smackx.jingle.JingleManager; import org.jivesoftware.smackx.jingle.element.JingleAction; import org.jivesoftware.smackx.jingle.element.JingleContentDescriptionChildElement; +import org.jivesoftware.smackx.jingle.element.JingleContentElement; +import org.jivesoftware.smackx.jingle.element.JingleElement; import org.jivesoftware.smackx.jingle.provider.JingleContentProviderManager; +import org.jivesoftware.smackx.jingle.transport.legacy.JingleUtil; import org.jivesoftware.smackx.jingle_filetransfer.callback.IncomingFileOfferCallback; -import org.jivesoftware.smackx.jingle_filetransfer.element.JingleFileTransfer; -import org.jivesoftware.smackx.jingle_filetransfer.element.JingleFileTransferChild; import org.jivesoftware.smackx.jingle_filetransfer.handler.FileTransferHandler; import org.jivesoftware.smackx.jingle_filetransfer.listener.JingleFileTransferOfferListener; -import org.jivesoftware.smackx.jingle_filetransfer.provider.JingleFileTransferProvider; import org.jxmpp.jid.FullJid; /** * Manager for JingleFileTransfer (XEP-0234). */ -public final class JingleFileTransferManager extends Manager implements JingleHandler { - private static final Logger LOGGER = Logger.getLogger(JingleFileTransferManager.class.getName()); +public final class JingleFileTransferManagerAlt extends Manager { + private static final Logger LOGGER = Logger.getLogger(JingleFileTransferManagerAlt.class.getName()); - private static final WeakHashMap INSTANCES = new WeakHashMap<>(); + private static final WeakHashMap INSTANCES = new WeakHashMap<>(); private final ArrayList jingleFileTransferOfferListeners = new ArrayList<>(); - private final JingleUtil jutil; - private JingleFileTransferManager(XMPPConnection connection) { + private JingleFileTransferManagerAlt(XMPPConnection connection) { super(connection); ServiceDiscoveryManager.getInstanceFor(connection).addFeature(JingleFileTransfer.NAMESPACE_V5); JingleManager jingleManager = JingleManager.getInstanceFor(connection); - jingleManager.registerDescriptionHandler(JingleFileTransfer.NAMESPACE_V5, this); + jingleManager.addJingleDescriptionManager(this); JingleContentProviderManager.addJingleContentDescriptionProvider( - JingleFileTransfer.NAMESPACE_V5, new JingleFileTransferProvider()); + JingleFileTransferElement.NAMESPACE_V5, new JingleFileTransferProvider()); jutil = new JingleUtil(connection); } - public static JingleFileTransferManager getInstanceFor(XMPPConnection connection) { - JingleFileTransferManager manager = INSTANCES.get(connection); + public static JingleFileTransferManagerAlt getInstanceFor(XMPPConnection connection) { + JingleFileTransferManagerAlt manager = INSTANCES.get(connection); if (manager == null) { - manager = new JingleFileTransferManager(connection); + manager = new JingleFileTransferManagerAlt(connection); INSTANCES.put(connection, manager); } return manager; @@ -141,12 +142,12 @@ public final class JingleFileTransferManager extends Manager implements JingleHa jingleFileTransferOfferListeners.remove(listener); } - public static JingleFileTransfer fileTransferFromFile(File file) { - JingleFileTransferChild.Builder fb = JingleFileTransferChild.getBuilder(); + public static JingleFileTransferElement fileTransferFromFile(File file) { + JingleFileTransferChildElement.Builder fb = JingleFileTransferChildElement.getBuilder(); fb.setFile(file) .setDescription("A file.") .setMediaType("application/octet-stream"); - return new JingleFileTransfer(Collections.singletonList(fb.build())); + return new JingleFileTransferElement(Collections.singletonList(fb.build())); } } diff --git a/smack-experimental/src/main/java/org/jivesoftware/smackx/jingle_filetransfer/JingleFileTransferSession.java b/smack-experimental/src/main/java/org/jivesoftware/smackx/jingle_filetransfer/JingleFileTransferSession.java index 5a8e430e5..adffc7512 100644 --- a/smack-experimental/src/main/java/org/jivesoftware/smackx/jingle_filetransfer/JingleFileTransferSession.java +++ b/smack-experimental/src/main/java/org/jivesoftware/smackx/jingle_filetransfer/JingleFileTransferSession.java @@ -21,7 +21,7 @@ import java.util.ArrayList; import org.jivesoftware.smack.XMPPConnection; import org.jivesoftware.smackx.jingle.transport.legacy.JingleUtil; import org.jivesoftware.smackx.jingle.element.JingleReasonElement; -import org.jivesoftware.smackx.jingle_filetransfer.element.JingleFileTransfer; +import org.jivesoftware.smackx.jft.element.JingleFileTransferElement; import org.jivesoftware.smackx.jingle_filetransfer.handler.FileTransferHandler; import org.jxmpp.jid.FullJid; @@ -45,7 +45,7 @@ public abstract class JingleFileTransferSession extends JingleSession implements protected final XMPPConnection connection; protected final JingleUtil jutil; - protected JingleFileTransfer file; + protected JingleFileTransferElement file; private final Type type; diff --git a/smack-experimental/src/main/java/org/jivesoftware/smackx/jingle_filetransfer/OutgoingJingleFileOffer.java b/smack-experimental/src/main/java/org/jivesoftware/smackx/jingle_filetransfer/OutgoingJingleFileOffer.java index 3487ced50..726faccb6 100644 --- a/smack-experimental/src/main/java/org/jivesoftware/smackx/jingle_filetransfer/OutgoingJingleFileOffer.java +++ b/smack-experimental/src/main/java/org/jivesoftware/smackx/jingle_filetransfer/OutgoingJingleFileOffer.java @@ -33,7 +33,7 @@ import org.jivesoftware.smackx.jingle.element.JingleContentElement; import org.jivesoftware.smackx.jingle.element.JingleReasonElement; import org.jivesoftware.smackx.jingle.transports.JingleTransportInitiationCallback; import org.jivesoftware.smackx.jingle.transports.JingleTransportManager; -import org.jivesoftware.smackx.jingle_filetransfer.element.JingleFileTransfer; +import org.jivesoftware.smackx.jft.element.JingleFileTransferElement; import org.jxmpp.jid.FullJid; @@ -91,7 +91,7 @@ public class OutgoingJingleFileOffer extends JingleFileTransferSession { SmackException.NotConnectedException, SmackException.NoResponseException { source = file; String contentName = JingleManager.randomId(); - JingleFileTransfer transfer = JingleFileTransferManager.fileTransferFromFile(file); + JingleFileTransferElement transfer = JingleFileTransferManagerAlt.fileTransferFromFile(file); initiateFileOffer(transfer, JingleContentElement.Creator.initiator, contentName); } @@ -99,11 +99,11 @@ public class OutgoingJingleFileOffer extends JingleFileTransferSession { public SmackFuture sendAsync(File file) { source = file; String contentName = "jft-" + StringUtils.randomString(20); - JingleFileTransfer transfer = JingleFileTransferManager.fileTransferFromFile(file); + JingleFileTransferElement transfer = JingleFileTransferManagerAlt.fileTransferFromFile(file); return null; //TODO } - public void initiateFileOffer(JingleFileTransfer file, JingleContentElement.Creator creator, String name) throws InterruptedException, XMPPException.XMPPErrorException, SmackException.NotConnectedException, SmackException.NoResponseException { + public void initiateFileOffer(JingleFileTransferElement file, JingleContentElement.Creator creator, String name) throws InterruptedException, XMPPException.XMPPErrorException, SmackException.NotConnectedException, SmackException.NoResponseException { if (state != State.fresh) { throw new IllegalStateException("This session is not fresh."); } diff --git a/smack-experimental/src/main/java/org/jivesoftware/smackx/jingle_filetransfer/ReceiveTask.java b/smack-experimental/src/main/java/org/jivesoftware/smackx/jingle_filetransfer/ReceiveTask.java index 1dd952a60..8f834c7cc 100644 --- a/smack-experimental/src/main/java/org/jivesoftware/smackx/jingle_filetransfer/ReceiveTask.java +++ b/smack-experimental/src/main/java/org/jivesoftware/smackx/jingle_filetransfer/ReceiveTask.java @@ -25,8 +25,8 @@ import java.util.logging.Logger; import org.jivesoftware.smackx.bytestreams.BytestreamSession; import org.jivesoftware.smackx.jingle.element.JingleReasonElement; -import org.jivesoftware.smackx.jingle_filetransfer.element.JingleFileTransfer; -import org.jivesoftware.smackx.jingle_filetransfer.element.JingleFileTransferChild; +import org.jivesoftware.smackx.jft.element.JingleFileTransferElement; +import org.jivesoftware.smackx.jft.element.JingleFileTransferChildElement; /** * Thread for receiving data. @@ -35,11 +35,11 @@ public class ReceiveTask implements Runnable { private static final Logger LOGGER = Logger.getLogger(ReceiveTask.class.getName()); private final BytestreamSession byteStream; - private final JingleFileTransfer fileTransfer; + private final JingleFileTransferElement fileTransfer; private final File target; private final JingleFileTransferSession session; - public ReceiveTask(JingleFileTransferSession session, BytestreamSession byteStream, JingleFileTransfer fileTransfer, File target) { + public ReceiveTask(JingleFileTransferSession session, BytestreamSession byteStream, JingleFileTransferElement fileTransfer, File target) { this.byteStream = byteStream; this.fileTransfer = fileTransfer; this.target = target; @@ -48,7 +48,7 @@ public class ReceiveTask implements Runnable { @Override public void run() { - JingleFileTransferChild transfer = (JingleFileTransferChild) fileTransfer.getJingleContentDescriptionChildren().get(0); + JingleFileTransferChildElement transfer = (JingleFileTransferChildElement) fileTransfer.getJingleContentDescriptionChildren().get(0); FileOutputStream outputStream = null; InputStream inputStream; diff --git a/smack-experimental/src/test/java/org/jivesoftware/smackx/jingle_filetransfer/ChecksumTest.java b/smack-experimental/src/test/java/org/jivesoftware/smackx/jingle_filetransfer/ChecksumTest.java index f43579360..64a0e6cca 100644 --- a/smack-experimental/src/test/java/org/jivesoftware/smackx/jingle_filetransfer/ChecksumTest.java +++ b/smack-experimental/src/test/java/org/jivesoftware/smackx/jingle_filetransfer/ChecksumTest.java @@ -23,10 +23,10 @@ import org.jivesoftware.smack.test.util.TestUtils; import org.jivesoftware.smackx.hashes.HashManager; import org.jivesoftware.smackx.hashes.element.HashElement; import org.jivesoftware.smackx.jingle.element.JingleContentElement; -import org.jivesoftware.smackx.jingle_filetransfer.element.Checksum; -import org.jivesoftware.smackx.jingle_filetransfer.element.JingleFileTransferChild; -import org.jivesoftware.smackx.jingle_filetransfer.element.Range; -import org.jivesoftware.smackx.jingle_filetransfer.provider.ChecksumProvider; +import org.jivesoftware.smackx.jft.element.ChecksumElement; +import org.jivesoftware.smackx.jft.element.JingleFileTransferChildElement; +import org.jivesoftware.smackx.jft.element.Range; +import org.jivesoftware.smackx.jft.provider.ChecksumProvider; import org.junit.Test; @@ -38,8 +38,8 @@ public class ChecksumTest extends SmackTestSuite { @Test public void parserTest() throws Exception { HashElement hash = new HashElement(HashManager.ALGORITHM.SHA_256, "f4OxZX/x/FO5LcGBSKHWXfwtSx+j1ncoSt3SABJtkGk="); - JingleFileTransferChild file = new JingleFileTransferChild(null, null, hash, null, null, -1, null); - Checksum checksum = new Checksum(JingleContentElement.Creator.initiator, "name", file); + JingleFileTransferChildElement file = new JingleFileTransferChildElement(null, null, hash, null, null, -1, null); + ChecksumElement checksum = new ChecksumElement(JingleContentElement.Creator.initiator, "name", file); String xml = "" + "" + @@ -51,8 +51,8 @@ public class ChecksumTest extends SmackTestSuite { assertXMLEqual(xml, new ChecksumProvider().parse(TestUtils.getParser(xml)).toXML().toString()); Range range = new Range(12L,34L); - file = new JingleFileTransferChild(null, null, hash, null, null, -1, range); - checksum = new Checksum(JingleContentElement.Creator.initiator, "name", file); + file = new JingleFileTransferChildElement(null, null, hash, null, null, -1, range); + checksum = new ChecksumElement(JingleContentElement.Creator.initiator, "name", file); xml = "" + "" + diff --git a/smack-experimental/src/test/java/org/jivesoftware/smackx/jingle_filetransfer/JingleUtilFileTransferTest.java b/smack-experimental/src/test/java/org/jivesoftware/smackx/jingle_filetransfer/JingleUtilFileTransferTest.java index 77af11e37..0ada909e7 100644 --- a/smack-experimental/src/test/java/org/jivesoftware/smackx/jingle_filetransfer/JingleUtilFileTransferTest.java +++ b/smack-experimental/src/test/java/org/jivesoftware/smackx/jingle_filetransfer/JingleUtilFileTransferTest.java @@ -36,9 +36,9 @@ import org.jivesoftware.smackx.jingle.element.JingleElement; import org.jivesoftware.smackx.jingle.element.JingleAction; import org.jivesoftware.smackx.jingle.element.JingleContentDescriptionChildElement; import org.jivesoftware.smackx.jingle.transports.jingle_ibb.element.JingleIBBTransport; -import org.jivesoftware.smackx.jingle_filetransfer.element.JingleFileTransfer; -import org.jivesoftware.smackx.jingle_filetransfer.element.JingleFileTransferChild; -import org.jivesoftware.smackx.jingle_filetransfer.provider.JingleFileTransferProvider; +import org.jivesoftware.smackx.jft.element.JingleFileTransferElement; +import org.jivesoftware.smackx.jft.element.JingleFileTransferChildElement; +import org.jivesoftware.smackx.jft.provider.JingleFileTransferProvider; import org.junit.Before; import org.junit.Test; @@ -74,8 +74,8 @@ public class JingleUtilFileTransferTest extends SmackTestSuite { JingleIBBTransport transport = new JingleIBBTransport("transid"); Date date = new Date(); HashElement hash = new HashElement(HashManager.ALGORITHM.SHA_256, "f4OxZX/x/FO5LcGBSKHWXfwtSx+j1ncoSt3SABJtkGk="); - JingleFileTransferChild file = new JingleFileTransferChild(date, "desc", hash, "application/octet-stream", "name", 1337, null); - JingleFileTransfer description = new JingleFileTransfer(Collections.singletonList(file)); + JingleFileTransferChildElement file = new JingleFileTransferChildElement(date, "desc", hash, "application/octet-stream", "name", 1337, null); + JingleFileTransferElement description = new JingleFileTransferElement(Collections.singletonList(file)); String contentName = "content"; @@ -108,8 +108,8 @@ public class JingleUtilFileTransferTest extends SmackTestSuite { assertEquals(1, description.getJingleContentDescriptionChildren().size()); assertEquals(file, description.getJingleContentDescriptionChildren().get(0)); - assertEquals(JingleFileTransferChild.ELEMENT, file.getElementName()); - assertEquals(JingleFileTransfer.NAMESPACE_V5, description.getNamespace()); + assertEquals(JingleFileTransferChildElement.ELEMENT, file.getElementName()); + assertEquals(JingleFileTransferElement.NAMESPACE_V5, description.getNamespace()); assertEquals(date, file.getDate()); assertEquals(hash, file.getHash()); assertEquals("application/octet-stream", file.getMediaType()); @@ -142,7 +142,7 @@ public class JingleUtilFileTransferTest extends SmackTestSuite { ""; assertXMLEqual(descriptionXML, description.toXML().toString()); - JingleFileTransfer parsed = new JingleFileTransferProvider().parse(TestUtils.getParser(descriptionXML)); + JingleFileTransferElement parsed = new JingleFileTransferProvider().parse(TestUtils.getParser(descriptionXML)); assertEquals(1, parsed.getJingleContentDescriptionChildren().size()); assertEquals(file.toXML().toString(), parsed.getJingleContentDescriptionChildren().get(0).toXML().toString()); diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/jingle/internal/JingleSecurity.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/jingle/internal/JingleSecurity.java index d7bbdc4b2..03095682c 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/jingle/internal/JingleSecurity.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/jingle/internal/JingleSecurity.java @@ -29,7 +29,7 @@ public abstract class JingleSecurity { public abstract D getElement(); - public abstract JingleElement handleSecurityInfo(JingleContentSecurityInfoElement element); + public abstract JingleElement handleSecurityInfo(JingleContentSecurityInfoElement element, JingleElement wrapping); public void setParent(JingleContent parent) { if (this.parent != parent) { diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/jingle/transport/jingle_ibb/JingleIBBTransportManager.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/jingle/transport/jingle_ibb/JingleIBBTransportManager.java index 67bfd4d96..30cd1f27e 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/jingle/transport/jingle_ibb/JingleIBBTransportManager.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/jingle/transport/jingle_ibb/JingleIBBTransportManager.java @@ -1,10 +1,16 @@ package org.jivesoftware.smackx.jingle.transport.jingle_ibb; +import java.util.WeakHashMap; + import org.jivesoftware.smack.Manager; import org.jivesoftware.smack.XMPPConnection; +import org.jivesoftware.smackx.disco.ServiceDiscoveryManager; +import org.jivesoftware.smackx.jingle.JingleManager; import org.jivesoftware.smackx.jingle.JingleTransportManager; import org.jivesoftware.smackx.jingle.internal.JingleContent; import org.jivesoftware.smackx.jingle.internal.JingleTransport; +import org.jivesoftware.smackx.jingle.provider.JingleContentProviderManager; +import org.jivesoftware.smackx.jingle.transport.jingle_ibb.provider.JingleIBBTransportProvider; /** * Created by vanitas on 21.07.17. @@ -13,8 +19,25 @@ public class JingleIBBTransportManager extends Manager implements JingleTranspor public static final short MAX_BLOCKSIZE = 8192; + private static final WeakHashMap INSTANCES = new WeakHashMap<>(); + private JingleIBBTransportManager(XMPPConnection connection) { super(connection); + ServiceDiscoveryManager.getInstanceFor(connection).addFeature(getNamespace()); + JingleManager jingleManager = JingleManager.getInstanceFor(connection); + jingleManager.addJingleTransportManager(this); + JingleContentProviderManager.addJingleContentTransportProvider(getNamespace(), new JingleIBBTransportProvider()); + } + + public static JingleIBBTransportManager getInstanceFor(XMPPConnection connection) { + JingleIBBTransportManager manager = INSTANCES.get(connection); + + if (manager == null) { + manager = new JingleIBBTransportManager(connection); + INSTANCES.put(connection, manager); + } + + return manager; } @Override diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/jingle/transport/jingle_s5b/JingleS5BTransport.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/jingle/transport/jingle_s5b/JingleS5BTransport.java index 75d007976..9e8e73c80 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/jingle/transport/jingle_s5b/JingleS5BTransport.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/jingle/transport/jingle_s5b/JingleS5BTransport.java @@ -151,7 +151,7 @@ public class JingleS5BTransport extends JingleTransport