From 282df8c78941939506b9faee8ec2b22dfccf30b1 Mon Sep 17 00:00:00 2001 From: vanitasvitae Date: Tue, 30 May 2017 18:20:54 +0200 Subject: [PATCH] Add first Jingle File Transfer classes --- .../JingleFileTransferManager.java | 57 +++++++++++++++++++ .../element/JingleContentFile.java | 41 +++++++++++++ .../JingleFileTransferContentDescription.java | 35 ++++++++++++ .../element/package-info.java | 22 +++++++ .../jingle_filetransfer/package-info.java | 21 +++++++ .../provider/package-info.java | 22 +++++++ 6 files changed, 198 insertions(+) create mode 100644 smack-extensions/src/main/java/org/jivesoftware/smackx/jingle_filetransfer/JingleFileTransferManager.java create mode 100644 smack-extensions/src/main/java/org/jivesoftware/smackx/jingle_filetransfer/element/JingleContentFile.java create mode 100644 smack-extensions/src/main/java/org/jivesoftware/smackx/jingle_filetransfer/element/JingleFileTransferContentDescription.java create mode 100644 smack-extensions/src/main/java/org/jivesoftware/smackx/jingle_filetransfer/element/package-info.java create mode 100644 smack-extensions/src/main/java/org/jivesoftware/smackx/jingle_filetransfer/package-info.java create mode 100644 smack-extensions/src/main/java/org/jivesoftware/smackx/jingle_filetransfer/provider/package-info.java diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/jingle_filetransfer/JingleFileTransferManager.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/jingle_filetransfer/JingleFileTransferManager.java new file mode 100644 index 000000000..7cdbbf13e --- /dev/null +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/jingle_filetransfer/JingleFileTransferManager.java @@ -0,0 +1,57 @@ +/** + * + * Copyright 2017 Paul Schaub + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jivesoftware.smackx.jingle_filetransfer; + +import org.jivesoftware.smack.Manager; +import org.jivesoftware.smack.XMPPConnection; + +import java.util.WeakHashMap; + +/** + * Manager for Jingle File Transfers. + * + * @author Paul Schaub + */ +public final class JingleFileTransferManager extends Manager { + + public static final String NAMESPACE = "urn:xmpp:jingle:apps:file-transfer:5"; + + private static final WeakHashMap INSTANCES = new WeakHashMap<>(); + + /** + * Private constructor. + * @param connection connection + */ + private JingleFileTransferManager(XMPPConnection connection) { + super(connection); + } + + /** + * Return a new instance of the FileTransferManager for the given connection. + * + * @param connection XMPPConnection we wish to get a FileTransferManager for. + * @return manager instance. + */ + public static JingleFileTransferManager getInstanceFor(XMPPConnection connection) { + JingleFileTransferManager manager = INSTANCES.get(connection); + if (manager == null) { + manager = new JingleFileTransferManager(connection); + INSTANCES.put(connection, manager); + } + return manager; + } +} diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/jingle_filetransfer/element/JingleContentFile.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/jingle_filetransfer/element/JingleContentFile.java new file mode 100644 index 000000000..09938cbd4 --- /dev/null +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/jingle_filetransfer/element/JingleContentFile.java @@ -0,0 +1,41 @@ +/** + * + * Copyright 2017 Paul Schaub + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jivesoftware.smackx.jingle_filetransfer.element; + +import org.jivesoftware.smack.packet.ExtensionElement; + +/** + * Content of type File. + */ +public class JingleContentFile implements ExtensionElement { + public static final String ELEMENT = "file"; + + @Override + public String getElementName() { + return ELEMENT; + } + + @Override + public CharSequence toXML() { + return null; + } + + @Override + public String getNamespace() { + return null; + } +} diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/jingle_filetransfer/element/JingleFileTransferContentDescription.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/jingle_filetransfer/element/JingleFileTransferContentDescription.java new file mode 100644 index 000000000..0e9b61729 --- /dev/null +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/jingle_filetransfer/element/JingleFileTransferContentDescription.java @@ -0,0 +1,35 @@ +/** + * + * Copyright 2017 Paul Schaub + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jivesoftware.smackx.jingle_filetransfer.element; + +import org.jivesoftware.smackx.jingle.element.JingleContentDescription; +import org.jivesoftware.smackx.jingle_filetransfer.JingleFileTransferManager; + +/** + * Description. + */ +public class JingleFileTransferContentDescription extends JingleContentDescription { + + protected JingleFileTransferContentDescription() { + super(null); + } + + @Override + public String getNamespace() { + return JingleFileTransferManager.NAMESPACE; + } +} diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/jingle_filetransfer/element/package-info.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/jingle_filetransfer/element/package-info.java new file mode 100644 index 000000000..c77215922 --- /dev/null +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/jingle_filetransfer/element/package-info.java @@ -0,0 +1,22 @@ +/** + * + * Copyright 2017 Paul Schaub + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * Smack's API for XEP-0234: Jingle File Transfer. + * Element classes. + */ +package org.jivesoftware.smackx.jingle_filetransfer.element; diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/jingle_filetransfer/package-info.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/jingle_filetransfer/package-info.java new file mode 100644 index 000000000..86fb45ecc --- /dev/null +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/jingle_filetransfer/package-info.java @@ -0,0 +1,21 @@ +/** + * + * Copyright 2017 Paul Schaub + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * Smack's API for XEP-0234: Jingle File Transfer. + */ +package org.jivesoftware.smackx.jingle_filetransfer; diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/jingle_filetransfer/provider/package-info.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/jingle_filetransfer/provider/package-info.java new file mode 100644 index 000000000..6a4aa771b --- /dev/null +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/jingle_filetransfer/provider/package-info.java @@ -0,0 +1,22 @@ +/** + * + * Copyright 2017 Paul Schaub + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * Smack's API for XEP-0234: Jingle File Transfer. + * Provider classes. + */ +package org.jivesoftware.smackx.jingle_filetransfer.provider;