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 a80fa35d5..69a76b67f 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 @@ -36,14 +36,12 @@ 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.JingleManager; +import org.jivesoftware.smackx.jft.controller.OutgoingFileOfferController; +import org.jivesoftware.smackx.jft.element.JingleFileTransferChildElement; +import org.jivesoftware.smackx.jft.element.JingleFileTransferElement; +import org.jivesoftware.smackx.jft.internal.JingleOutgoingFileOffer; 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_filetransfer.OutgoingJingleFileOffer; -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; @@ -73,7 +71,7 @@ public final class JetManager extends Manager { return manager; } - public FileTransferHandler sendEncryptedFile(FullJid recipient, File file, String encryptionMethodNamespace) throws Exception { + public OutgoingFileOfferController sendEncryptedFile(FullJid recipient, File file, String encryptionMethodNamespace) throws Exception { JingleEncryptionMethod encryptionMethod = getEncryptionMethod(encryptionMethodNamespace); if (encryptionMethod == null) { @@ -141,7 +139,7 @@ public final class JetManager extends Manager { ExtensionElement encryptionExtension = encryptionMethod.encryptJingleTransfer(recipient, keyAndIv); JetSecurityElement securityElement = new JetSecurityElement(contentName, encryptionExtension); - OutgoingJingleFileOffer offer = new OutgoingJingleFileOffer(connection(), recipient); + JingleOutgoingFileOffer offer = new JingleOutgoingFileOffer(file); JingleFileTransferChildElement fileTransferChild = JingleFileTransferChildElement.getBuilder().setFile(file).build(); JingleFileTransferElement fileTransfer = new JingleFileTransferElement(Collections.singletonList(fileTransferChild)); @@ -149,12 +147,11 @@ public final class JetManager extends Manager { JingleContentElement content = JingleContentElement.getBuilder() .setCreator(JingleContentElement.Creator.initiator) .setName(contentName) - .setTransport(offer.getTransportSession().createTransport()) + //.setTransport(offer.getTransportSession().createTransport()) .setSecurity(securityElement) .setDescription(fileTransfer) .build(); - JingleElement initiate = jutil.createSessionInitiate(recipient, JingleManager.randomId(), content); return offer; } diff --git a/smack-experimental/src/main/java/org/jivesoftware/smackx/jet/OutgoingJetOffer.java b/smack-experimental/src/main/java/org/jivesoftware/smackx/jet/OutgoingJetOffer.java index e4a237afb..a44cae7d9 100644 --- a/smack-experimental/src/main/java/org/jivesoftware/smackx/jet/OutgoingJetOffer.java +++ b/smack-experimental/src/main/java/org/jivesoftware/smackx/jet/OutgoingJetOffer.java @@ -18,26 +18,14 @@ package org.jivesoftware.smackx.jet; import java.io.File; -import org.jivesoftware.smack.XMPPConnection; -import org.jivesoftware.smackx.jingle_filetransfer.OutgoingJingleFileOffer; - -import org.jxmpp.jid.FullJid; +import org.jivesoftware.smackx.jft.internal.JingleOutgoingFileOffer; /** * Created by vanitas on 14.07.17. */ -public class OutgoingJetOffer extends OutgoingJingleFileOffer { - - public OutgoingJetOffer(XMPPConnection connection, FullJid responder, String sid) { - super(connection, responder, sid); - } - - public OutgoingJetOffer(XMPPConnection connection, FullJid recipient) { - super(connection, recipient); - } - - @Override - public void send(File file) { +public class OutgoingJetOffer extends JingleOutgoingFileOffer { + public OutgoingJetOffer(File file) { + super(file); } } diff --git a/smack-experimental/src/main/java/org/jivesoftware/smackx/jet/provider/JetSecurityProvider.java b/smack-experimental/src/main/java/org/jivesoftware/smackx/jet/provider/JetSecurityProvider.java index d460692b5..7e817cb8b 100644 --- a/smack-experimental/src/main/java/org/jivesoftware/smackx/jet/provider/JetSecurityProvider.java +++ b/smack-experimental/src/main/java/org/jivesoftware/smackx/jet/provider/JetSecurityProvider.java @@ -22,9 +22,9 @@ import java.util.logging.Logger; import org.jivesoftware.smack.packet.ExtensionElement; import org.jivesoftware.smack.provider.ExtensionElementProvider; import org.jivesoftware.smack.util.Objects; -import org.jivesoftware.smackx.jet.JetManager; import org.jivesoftware.smackx.jet.JingleEncryptionMethodManager; import org.jivesoftware.smackx.jet.element.JetSecurityElement; +import org.jivesoftware.smackx.jet.internal.JetSecurity; import org.xmlpull.v1.XmlPullParser; @@ -36,8 +36,8 @@ public class JetSecurityProvider extends ExtensionElementProvider extends AbstractJingleFileTransfer { +public abstract class AbstractJingleFileOffer extends JingleFileTransfer { protected D jingleFile; diff --git a/smack-experimental/src/main/java/org/jivesoftware/smackx/jft/internal/AbstractJingleFileRequest.java b/smack-experimental/src/main/java/org/jivesoftware/smackx/jft/internal/AbstractJingleFileRequest.java index 8a26f471d..9b2b225f2 100644 --- a/smack-experimental/src/main/java/org/jivesoftware/smackx/jft/internal/AbstractJingleFileRequest.java +++ b/smack-experimental/src/main/java/org/jivesoftware/smackx/jft/internal/AbstractJingleFileRequest.java @@ -1,8 +1,24 @@ +/** + * + * 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.jft.internal; /** * Created by vanitas on 22.07.17. */ -public abstract class AbstractJingleFileRequest extends AbstractJingleFileTransfer { +public abstract class AbstractJingleFileRequest extends JingleFileTransfer { } diff --git a/smack-experimental/src/main/java/org/jivesoftware/smackx/jft/internal/AbstractJingleFileTransfer.java b/smack-experimental/src/main/java/org/jivesoftware/smackx/jft/internal/JingleFileTransfer.java similarity index 65% rename from smack-experimental/src/main/java/org/jivesoftware/smackx/jft/internal/AbstractJingleFileTransfer.java rename to smack-experimental/src/main/java/org/jivesoftware/smackx/jft/internal/JingleFileTransfer.java index 69762f0aa..2531d4449 100644 --- a/smack-experimental/src/main/java/org/jivesoftware/smackx/jft/internal/AbstractJingleFileTransfer.java +++ b/smack-experimental/src/main/java/org/jivesoftware/smackx/jft/internal/JingleFileTransfer.java @@ -1,3 +1,19 @@ +/** + * + * 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.jft.internal; import java.util.ArrayList; @@ -12,7 +28,7 @@ import org.jivesoftware.smackx.jingle.components.JingleDescription; /** * Created by vanitas on 22.07.17. */ -public abstract class AbstractJingleFileTransfer extends JingleDescription implements JingleFileTransferController { +public abstract class JingleFileTransfer extends JingleDescription implements JingleFileTransferController { public static final String NAMESPACE_V5 = "urn:xmpp:jingle:apps:file-transfer:5"; public static final String NAMESPACE = NAMESPACE_V5; diff --git a/smack-experimental/src/main/java/org/jivesoftware/smackx/jft/internal/JingleIncomingFileOffer.java b/smack-experimental/src/main/java/org/jivesoftware/smackx/jft/internal/JingleIncomingFileOffer.java index 76313da7f..0d5901d9e 100644 --- a/smack-experimental/src/main/java/org/jivesoftware/smackx/jft/internal/JingleIncomingFileOffer.java +++ b/smack-experimental/src/main/java/org/jivesoftware/smackx/jft/internal/JingleIncomingFileOffer.java @@ -1,3 +1,19 @@ +/** + * + * 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.jft.internal; import java.io.IOException; diff --git a/smack-experimental/src/main/java/org/jivesoftware/smackx/jft/internal/JingleIncomingFileRequest.java b/smack-experimental/src/main/java/org/jivesoftware/smackx/jft/internal/JingleIncomingFileRequest.java index 53478f990..605142b38 100644 --- a/smack-experimental/src/main/java/org/jivesoftware/smackx/jft/internal/JingleIncomingFileRequest.java +++ b/smack-experimental/src/main/java/org/jivesoftware/smackx/jft/internal/JingleIncomingFileRequest.java @@ -1,3 +1,19 @@ +/** + * + * 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.jft.internal; import org.jivesoftware.smackx.bytestreams.BytestreamSession; diff --git a/smack-experimental/src/main/java/org/jivesoftware/smackx/jft/internal/JingleOutgoingFileOffer.java b/smack-experimental/src/main/java/org/jivesoftware/smackx/jft/internal/JingleOutgoingFileOffer.java index 5e7d11a10..ec8dccbee 100644 --- a/smack-experimental/src/main/java/org/jivesoftware/smackx/jft/internal/JingleOutgoingFileOffer.java +++ b/smack-experimental/src/main/java/org/jivesoftware/smackx/jft/internal/JingleOutgoingFileOffer.java @@ -1,3 +1,19 @@ +/** + * + * 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.jft.internal; import java.io.File; diff --git a/smack-experimental/src/main/java/org/jivesoftware/smackx/jft/internal/JingleOutgoingFileRequest.java b/smack-experimental/src/main/java/org/jivesoftware/smackx/jft/internal/JingleOutgoingFileRequest.java index de7769dde..219273d4c 100644 --- a/smack-experimental/src/main/java/org/jivesoftware/smackx/jft/internal/JingleOutgoingFileRequest.java +++ b/smack-experimental/src/main/java/org/jivesoftware/smackx/jft/internal/JingleOutgoingFileRequest.java @@ -1,3 +1,19 @@ +/** + * + * 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.jft.internal; import org.jivesoftware.smackx.bytestreams.BytestreamSession; diff --git a/smack-experimental/src/main/java/org/jivesoftware/smackx/jft/internal/file/AbstractJingleFileTransferFile.java b/smack-experimental/src/main/java/org/jivesoftware/smackx/jft/internal/file/AbstractJingleFileTransferFile.java index 2aa6f60f8..face210a8 100644 --- a/smack-experimental/src/main/java/org/jivesoftware/smackx/jft/internal/file/AbstractJingleFileTransferFile.java +++ b/smack-experimental/src/main/java/org/jivesoftware/smackx/jft/internal/file/AbstractJingleFileTransferFile.java @@ -1,3 +1,19 @@ +/** + * + * 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.jft.internal.file; import java.util.Date; diff --git a/smack-experimental/src/main/java/org/jivesoftware/smackx/jft/internal/file/LocalFile.java b/smack-experimental/src/main/java/org/jivesoftware/smackx/jft/internal/file/LocalFile.java index 7719a30b4..95ae0a6ec 100644 --- a/smack-experimental/src/main/java/org/jivesoftware/smackx/jft/internal/file/LocalFile.java +++ b/smack-experimental/src/main/java/org/jivesoftware/smackx/jft/internal/file/LocalFile.java @@ -1,3 +1,19 @@ +/** + * + * 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.jft.internal.file; import java.io.File; diff --git a/smack-experimental/src/main/java/org/jivesoftware/smackx/jft/internal/file/RemoteFile.java b/smack-experimental/src/main/java/org/jivesoftware/smackx/jft/internal/file/RemoteFile.java index db5304c93..baaeed511 100644 --- a/smack-experimental/src/main/java/org/jivesoftware/smackx/jft/internal/file/RemoteFile.java +++ b/smack-experimental/src/main/java/org/jivesoftware/smackx/jft/internal/file/RemoteFile.java @@ -1,3 +1,19 @@ +/** + * + * 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.jft.internal.file; import java.util.Date; diff --git a/smack-experimental/src/main/java/org/jivesoftware/smackx/jft/listener/IncomingFileOfferListener.java b/smack-experimental/src/main/java/org/jivesoftware/smackx/jft/listener/IncomingFileOfferListener.java index 75f75c434..a25182bda 100644 --- a/smack-experimental/src/main/java/org/jivesoftware/smackx/jft/listener/IncomingFileOfferListener.java +++ b/smack-experimental/src/main/java/org/jivesoftware/smackx/jft/listener/IncomingFileOfferListener.java @@ -1,3 +1,19 @@ +/** + * + * 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.jft.listener; import org.jivesoftware.smackx.jft.controller.IncomingFileOfferController; diff --git a/smack-experimental/src/main/java/org/jivesoftware/smackx/jft/listener/IncomingFileRequestListener.java b/smack-experimental/src/main/java/org/jivesoftware/smackx/jft/listener/IncomingFileRequestListener.java index ccca0e44e..6928cd29a 100644 --- a/smack-experimental/src/main/java/org/jivesoftware/smackx/jft/listener/IncomingFileRequestListener.java +++ b/smack-experimental/src/main/java/org/jivesoftware/smackx/jft/listener/IncomingFileRequestListener.java @@ -1,3 +1,19 @@ +/** + * + * 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.jft.listener; import org.jivesoftware.smackx.jft.controller.IncomingFileRequestController; diff --git a/smack-experimental/src/main/java/org/jivesoftware/smackx/jft/listener/ProgressListener.java b/smack-experimental/src/main/java/org/jivesoftware/smackx/jft/listener/ProgressListener.java index 4632e7a64..9fe8d8388 100644 --- a/smack-experimental/src/main/java/org/jivesoftware/smackx/jft/listener/ProgressListener.java +++ b/smack-experimental/src/main/java/org/jivesoftware/smackx/jft/listener/ProgressListener.java @@ -1,3 +1,19 @@ +/** + * + * 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.jft.listener; /** diff --git a/smack-experimental/src/main/java/org/jivesoftware/smackx/jft/provider/JingleFileTransferProvider.java b/smack-experimental/src/main/java/org/jivesoftware/smackx/jft/provider/JingleFileTransferProvider.java index b11cc245d..180e12c72 100644 --- a/smack-experimental/src/main/java/org/jivesoftware/smackx/jft/provider/JingleFileTransferProvider.java +++ b/smack-experimental/src/main/java/org/jivesoftware/smackx/jft/provider/JingleFileTransferProvider.java @@ -24,6 +24,7 @@ import java.util.ArrayList; import org.jivesoftware.smack.util.ParserUtils; import org.jivesoftware.smackx.hashes.element.HashElement; import org.jivesoftware.smackx.hashes.provider.HashElementProvider; +import org.jivesoftware.smackx.jft.internal.JingleFileTransfer; import org.jivesoftware.smackx.jingle.element.JingleContentDescriptionChildElement; import org.jivesoftware.smackx.jingle.provider.JingleContentDescriptionProvider; import org.jivesoftware.smackx.jft.element.JingleFileTransferElement; @@ -113,4 +114,9 @@ public class JingleFileTransferProvider } } } + + @Override + public String getNamespace() { + return JingleFileTransfer.NAMESPACE; + } } 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 deleted file mode 100644 index 29dce4667..000000000 --- a/smack-experimental/src/main/java/org/jivesoftware/smackx/jingle_filetransfer/IncomingJingleFileOffer.java +++ /dev/null @@ -1,254 +0,0 @@ -/** - * - * 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 java.io.File; -import java.util.concurrent.Future; -import java.util.logging.Level; -import java.util.logging.Logger; - -import org.jivesoftware.smack.SmackException; -import org.jivesoftware.smack.XMPPConnection; -import org.jivesoftware.smack.XMPPException; -import org.jivesoftware.smack.packet.IQ; -import org.jivesoftware.smackx.bytestreams.BytestreamSession; -import org.jivesoftware.smackx.jingle.element.JingleContentElement; -import org.jivesoftware.smackx.jingle.element.JingleElement; -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.jft.element.JingleFileTransferElement; -import org.jivesoftware.smackx.jingle_filetransfer.handler.FileTransferHandler; - -import org.jxmpp.jid.FullJid; - -/** - * We are the responder and we are the recipient. - */ -public class IncomingJingleFileOffer extends JingleFileTransferSession implements IncomingFileOfferCallback { - private static final Logger LOGGER = Logger.getLogger(IncomingJingleFileOffer.class.getName()); - private JingleElement pendingSessionInitiate = null; - private ReceiveTask receivingThread; - private File target; - - @Override - public void cancel() { - if (state == State.active) { - Future task = queued.get(0); - if (task != null) { - task.cancel(true); - queued.remove(task); - } - - notifyEndedListeners(JingleReasonElement.Reason.cancel); - } - } - - public enum State { - fresh, - pending, - sent_transport_replace, - active, - terminated - } - - private State state; - - public IncomingJingleFileOffer(XMPPConnection connection, FullJid initiator, String sid) { - super(connection, initiator, connection.getUser().asFullJidOrThrow(), Role.responder, sid, Type.offer); - state = State.fresh; - } - - public IncomingJingleFileOffer(XMPPConnection connection, JingleElement request) { - this(connection, request.getInitiator(), request.getSid()); - } - - @Override - public IQ handleSessionInitiate(final JingleElement initiate) - throws InterruptedException, XMPPException.XMPPErrorException, SmackException.NotConnectedException, - SmackException.NoResponseException { - JingleTransportMethodManager tm = JingleTransportMethodManager.getInstanceFor(connection); - - if (state != State.fresh) { - //Out of order (initiate after accept) - LOGGER.log(Level.WARNING, "Action " + initiate.getAction() + " is out of order!"); - return jutil.createErrorOutOfOrder(initiate); - } - - this.contents.addAll(initiate.getContents()); - this.file = (JingleFileTransferElement) contents.get(0).getDescription(); - - JingleTransportManager transportManager = tm.getTransportManager(initiate); - if (transportManager == null) { - //Try fallback. - pendingSessionInitiate = initiate; - transportManager = tm.getBestAvailableTransportManager(); - - if (transportManager == null) { - //No usable transports. - LOGGER.log(Level.WARNING, "No usable transports."); - connection.createStanzaCollectorAndSend(jutil.createSessionTerminateUnsupportedTransports(getInitiator(), getSessionId())); - state = State.terminated; - return jutil.createAck(initiate); - } - - transportSession = transportManager.transportSession(this); - jutil.sendTransportReplace(initiate.getFrom().asFullJidOrThrow(), getInitiator(), - getSessionId(), contents.get(0).getCreator(), contents.get(0).getName(), - transportSession.createTransport()); - state = State.sent_transport_replace; - return jutil.createAck(initiate); - } - - transportSession = transportManager.transportSession(this); - transportSession.processJingle(initiate); - - state = State.pending; - - JingleFileTransferManagerAlt.getInstanceFor(connection).notifyIncomingFileOffer(initiate, - IncomingJingleFileOffer.this); - - return jutil.createAck(initiate); - } - - @Override - public IQ handleTransportReplace(final JingleElement transportReplace) - throws InterruptedException, XMPPException.XMPPErrorException, - SmackException.NotConnectedException, SmackException.NoResponseException { - final JingleTransportManager replacementManager = JingleTransportMethodManager.getInstanceFor(connection) - .getTransportManager(transportReplace); - - queued.add(JingleManager.getThreadPool().submit(new Runnable() { - @Override - public void run() { - try { - if (replacementManager != null) { - LOGGER.log(Level.INFO, "Accept transport-replace."); - IncomingJingleFileOffer.this.transportSession = replacementManager.transportSession(IncomingJingleFileOffer.this); - transportSession.processJingle(transportReplace); - transportSession.initiateIncomingSession(new JingleTransportInitiationCallback() { - @Override - public void onSessionInitiated(BytestreamSession bytestreamSession) { - LOGGER.log(Level.INFO, "Bytestream initiated. Start receiving."); - receivingThread = new ReceiveTask(IncomingJingleFileOffer.this, bytestreamSession, file, target); - queued.add(JingleManager.getThreadPool().submit(receivingThread)); - } - - @Override - public void onException(Exception e) { - LOGGER.log(Level.SEVERE, "EXCEPTION IN INCOMING SESSION: ", e); - } - }); - - jutil.sendTransportAccept(transportReplace.getFrom().asFullJidOrThrow(), - transportReplace.getInitiator(), transportReplace.getSid(), - getContents().get(0).getCreator(), getContents().get(0).getName(), - transportSession.createTransport()); - - } else { - LOGGER.log(Level.INFO, "Unsupported transport. Reject transport-replace."); - jutil.sendTransportReject(transportReplace.getFrom().asFullJidOrThrow(), transportReplace.getInitiator(), - transportReplace.getSid(), getContents().get(0).getCreator(), - getContents().get(0).getName(), transportReplace.getContents().get(0).getTransport()); - } - } catch (InterruptedException | XMPPException.XMPPErrorException | SmackException.NotConnectedException | SmackException.NoResponseException e) { - LOGGER.log(Level.SEVERE, "Help me please!", e); - } - } - })); - - return jutil.createAck(transportReplace); - } - - @Override - public IQ handleTransportAccept(JingleElement transportAccept) { - LOGGER.log(Level.INFO, "Received transport-accept."); - if (state != State.sent_transport_replace) { - LOGGER.log(Level.WARNING, "Session is in state " + state + ", so the transport-accept is out of order."); - return jutil.createErrorOutOfOrder(transportAccept); - } - - JingleFileTransferManagerAlt.getInstanceFor(connection) - .notifyIncomingFileOffer(pendingSessionInitiate, this); - transportSession.processJingle(transportAccept); - state = State.pending; - return jutil.createAck(transportAccept); - } - - @Override - public void onTransportMethodFailed(String namespace) { - //Nothing to do. - } - - @Override - public FileTransferHandler acceptIncomingFileOffer(final JingleElement request, final File target) { - this.target = target; - LOGGER.log(Level.INFO, "Client accepted incoming file offer. Try to start receiving."); - if (transportSession == null) { - //Unsupported transport - LOGGER.log(Level.WARNING, "Unsupported Transport method."); - try { - jutil.sendSessionTerminateUnsupportedTransports(request.getFrom().asFullJidOrThrow(), sid); - } catch (InterruptedException | SmackException.NoResponseException | - SmackException.NotConnectedException | XMPPException.XMPPErrorException e) { - LOGGER.log(Level.SEVERE, "Could not send session-terminate: " + e, e); - } - return null; - } - - state = State.active; - - try { - jutil.sendSessionAccept(getInitiator(), sid, getContents().get(0).getCreator(), - getContents().get(0).getName(), JingleContentElement.Senders.initiator, file, - transportSession.createTransport()); - } catch (SmackException.NotConnectedException | SmackException.NoResponseException | - XMPPException.XMPPErrorException | InterruptedException e) { - LOGGER.log(Level.WARNING, "Could not send session-accept.", e); - } - - transportSession.initiateIncomingSession(new JingleTransportInitiationCallback() { - @Override - public void onSessionInitiated(BytestreamSession bytestreamSession) { - LOGGER.log(Level.INFO, "Bytestream initiated. Start receiving."); - receivingThread = new ReceiveTask(IncomingJingleFileOffer.this, bytestreamSession, file, target); - queued.add(JingleManager.getThreadPool().submit(receivingThread)); - started = true; - notifyStartedListeners(); - } - - @Override - public void onException(Exception e) { - LOGGER.log(Level.SEVERE, "EXCEPTION IN INCOMING SESSION: ", e); - } - }); - - return this; - } - - @Override - public void declineIncomingFileOffer(JingleElement request) { - state = State.terminated; - try { - jutil.sendSessionTerminateDecline(request.getInitiator(), request.getSid()); - } catch (SmackException.NotConnectedException | SmackException.NoResponseException | - XMPPException.XMPPErrorException | InterruptedException e) { - LOGGER.log(Level.SEVERE, "Could not send session-terminate: " + e, e); - } - } -} diff --git a/smack-experimental/src/main/java/org/jivesoftware/smackx/jingle_filetransfer/JingleFileRequest.java b/smack-experimental/src/main/java/org/jivesoftware/smackx/jingle_filetransfer/JingleFileRequest.java deleted file mode 100644 index 71eb9fecd..000000000 --- a/smack-experimental/src/main/java/org/jivesoftware/smackx/jingle_filetransfer/JingleFileRequest.java +++ /dev/null @@ -1,54 +0,0 @@ -/** - * - * 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.XMPPConnection; -import org.jivesoftware.smackx.jingle.JingleManager; -import org.jivesoftware.smackx.jingle.util.Role; -import org.jivesoftware.smackx.jingle.element.JingleElement; - -import org.jxmpp.jid.FullJid; - -/** - * Request. - */ -public class JingleFileRequest extends JingleFileTransferSession { - - public JingleFileRequest(XMPPConnection connection, FullJid initiator, FullJid responder, Role role, String sid) { - super(connection, initiator, responder, role, sid, Type.request); - } - - public static JingleFileRequest createOutgoingFileRequest(XMPPConnection connection, FullJid recipient) { - return new JingleFileRequest(connection, connection.getUser().asFullJidOrThrow(), recipient, Role.initiator, - JingleManager.randomId()); - } - - public static JingleFileRequest createIncomingFileRequest(XMPPConnection connection, JingleElement request) { - return new JingleFileRequest(connection, request.getInitiator(), connection.getUser().asFullJidOrThrow(), Role.responder, - request.getSid()); - } - - @Override - public void onTransportMethodFailed(String namespace) { - //Not implemented - } - - @Override - public void cancel() { - - } -} diff --git a/smack-experimental/src/main/java/org/jivesoftware/smackx/jingle_filetransfer/JingleFileTransferManagerAlt.java b/smack-experimental/src/main/java/org/jivesoftware/smackx/jingle_filetransfer/JingleFileTransferManagerAlt.java deleted file mode 100644 index d29b8bdf4..000000000 --- a/smack-experimental/src/main/java/org/jivesoftware/smackx/jingle_filetransfer/JingleFileTransferManagerAlt.java +++ /dev/null @@ -1,153 +0,0 @@ -/** - * - * 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 java.io.File; -import java.util.ArrayList; -import java.util.Collections; -import java.util.WeakHashMap; -import java.util.logging.Level; -import java.util.logging.Logger; - -import org.jivesoftware.smack.Manager; -import org.jivesoftware.smack.SmackException; -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.jft.element.JingleFileTransferChildElement; -import org.jivesoftware.smackx.jft.element.JingleFileTransferElement; -import org.jivesoftware.smackx.jft.internal.AbstractJingleFileTransfer; -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.handler.FileTransferHandler; -import org.jivesoftware.smackx.jingle_filetransfer.listener.JingleFileTransferOfferListener; - -import org.jxmpp.jid.FullJid; - -/** - * Manager for JingleFileTransfer (XEP-0234). - */ -public final class JingleFileTransferManagerAlt extends Manager { - private static final Logger LOGGER = Logger.getLogger(JingleFileTransferManagerAlt.class.getName()); - - private static final WeakHashMap INSTANCES = new WeakHashMap<>(); - private final ArrayList jingleFileTransferOfferListeners = new ArrayList<>(); - - private JingleFileTransferManagerAlt(XMPPConnection connection) { - super(connection); - ServiceDiscoveryManager.getInstanceFor(connection).addFeature(AbstractJingleFileTransfer.NAMESPACE_V5); - JingleManager jingleManager = JingleManager.getInstanceFor(connection); - jingleManager.addJingleDescriptionManager(this); - JingleContentProviderManager.addJingleContentDescriptionProvider( - JingleFileTransferElement.NAMESPACE_V5, new JingleFileTransferProvider()); - jutil = new JingleUtil(connection); - } - - public static JingleFileTransferManagerAlt getInstanceFor(XMPPConnection connection) { - JingleFileTransferManagerAlt manager = INSTANCES.get(connection); - if (manager == null) { - manager = new JingleFileTransferManagerAlt(connection); - INSTANCES.put(connection, manager); - } - return manager; - } - - public FileTransferHandler sendFile(FullJid recipient, File file) - throws InterruptedException, XMPPException.XMPPErrorException, - SmackException.NotConnectedException, SmackException.NoResponseException { - OutgoingJingleFileOffer offer = new OutgoingJingleFileOffer(connection(), recipient); - JingleManager.getInstanceFor(connection()).registerJingleSessionHandler(recipient, offer.getSessionId(), offer); - offer.send(file); - return offer; - } - - @Override - public IQ handleJingleRequest(JingleElement jingle) { - FullJid fullJid = jingle.getFrom().asFullJidOrThrow(); - String sid = jingle.getSid(); - - //Get handler - JingleFileTransferSession handler; - try { - handler = createSessionHandler(jingle); - } catch (IllegalArgumentException malformed) { - return jutil.createErrorMalformedRequest(jingle); - } - - JingleManager.getInstanceFor(connection()).registerJingleSessionHandler(fullJid, sid, handler); - - return handler.handleJingleSessionRequest(jingle); - } - - /** - * Create a session handler (FileOffer or FileRequest) for the request. - * @param request - * @return - */ - private JingleFileTransferSession createSessionHandler(JingleElement request) { - if (request.getAction() != JingleAction.session_initiate) { - LOGGER.log(Level.WARNING, "First received action must be session-initiate."); - throw new IllegalArgumentException("Requests action MUST be session-initiate."); - } - - JingleContentElement content = request.getContents().get(0); - //File Offer - if (content.getSenders() == JingleContentElement.Senders.initiator) { - return new IncomingJingleFileOffer(connection(), request); - } //File Request - else if (content.getSenders() == JingleContentElement.Senders.responder) { - return JingleFileRequest.createIncomingFileRequest(connection(), request); - } - else { - // If senders is neither initiator, nor responder, consider session malformed. - // See XEP-0166 §6.3 Example 16 and XEP-0234 §4.1 - LOGGER.log(Level.WARNING, "Jingle has invalid sender value. Only initiator and responder are allowed."); - throw new IllegalArgumentException("Requests content.senders MUST be either responder or initiator."); - } - } - - public void notifyIncomingFileOffer(JingleElement initiate, IncomingFileOfferCallback callback) { - for (JingleFileTransferOfferListener l : jingleFileTransferOfferListeners) { - l.onFileOffer(initiate, callback); - } - } - - public void addJingleFileTransferOfferListener(JingleFileTransferOfferListener listener) { - jingleFileTransferOfferListeners.add(listener); - } - - public void removeJingleFileTransferOfferListener(JingleFileTransferOfferListener listener) { - jingleFileTransferOfferListeners.remove(listener); - } - - public static JingleFileTransferElement fileTransferFromFile(File file) { - JingleFileTransferChildElement.Builder fb = JingleFileTransferChildElement.getBuilder(); - fb.setFile(file) - .setDescription("A file.") - .setMediaType("application/octet-stream"); - - 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 deleted file mode 100644 index adffc7512..000000000 --- a/smack-experimental/src/main/java/org/jivesoftware/smackx/jingle_filetransfer/JingleFileTransferSession.java +++ /dev/null @@ -1,119 +0,0 @@ -/** - * - * 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 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.jft.element.JingleFileTransferElement; -import org.jivesoftware.smackx.jingle_filetransfer.handler.FileTransferHandler; - -import org.jxmpp.jid.FullJid; - -/** - * Class representing a Jingle session in the context of Jingle File Transfer (XEP-0234). - */ -public abstract class JingleFileTransferSession extends JingleSession implements FileTransferHandler { - - protected final ArrayList endedListeners = new ArrayList<>(); - protected final ArrayList startedListeners = new ArrayList<>(); - - protected boolean started, ended; - - public enum Type { - offer, - request, - ; - } - - protected final XMPPConnection connection; - protected final JingleUtil jutil; - - protected JingleFileTransferElement file; - - private final Type type; - - public JingleFileTransferSession(XMPPConnection connection, FullJid initiator, FullJid responder, Role role, String sid, Type type) { - super(initiator, responder, role, sid); - this.type = type; - this.connection = connection; - this.jutil = new JingleUtil(connection); - } - - public Type getType() { - return type; - } - - public boolean isOffer() { - return this.type == Type.offer; - } - - public boolean isRequest() { - return this.type == Type.request; - } - - public boolean isSender() { - return (isOffer() && isInitiator()) || (isRequest() && isResponder()); - } - - public boolean isReceiver() { - return (isRequest() && isInitiator()) || (isOffer() && isResponder()); - } - - @Override - public boolean isFinished() { - return ended; - } - - @Override - public boolean isStarted() { - return started; - } - - @Override - public void addEndedListener(EndedListener listener) { - endedListeners.add(listener); - } - - @Override - public void addStartedListener(StartedListener listener) { - startedListeners.add(listener); - } - - @Override - public void notifyEndedListeners(JingleReasonElement.Reason reason) { - ended = true; - for (EndedListener e : endedListeners) { - e.onEnded(reason); - } - } - - @Override - public void notifyStartedListeners() { - started = true; - for (StartedListener s : startedListeners) { - s.onStarted(); - } - } - - @Override - public XMPPConnection getConnection() { - return connection; - } -} 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 deleted file mode 100644 index 726faccb6..000000000 --- a/smack-experimental/src/main/java/org/jivesoftware/smackx/jingle_filetransfer/OutgoingJingleFileOffer.java +++ /dev/null @@ -1,229 +0,0 @@ -/** - * - * 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 java.io.File; -import java.util.concurrent.Future; -import java.util.logging.Level; -import java.util.logging.Logger; - -import org.jivesoftware.smack.SmackException; -import org.jivesoftware.smack.SmackFuture; -import org.jivesoftware.smack.XMPPConnection; -import org.jivesoftware.smack.XMPPException; -import org.jivesoftware.smack.packet.IQ; -import org.jivesoftware.smack.util.StringUtils; -import org.jivesoftware.smackx.bytestreams.BytestreamSession; -import org.jivesoftware.smackx.jingle.element.JingleElement; -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.jft.element.JingleFileTransferElement; - -import org.jxmpp.jid.FullJid; - -/** - * We are the initiator and we are the sender. - */ -public class OutgoingJingleFileOffer extends JingleFileTransferSession { - - private static final Logger LOGGER = Logger.getLogger(OutgoingJingleFileOffer.class.getName()); - - @Override - public void cancel() throws InterruptedException, XMPPException.XMPPErrorException, SmackException.NotConnectedException, SmackException.NoResponseException { - switch (state) { - case terminated: - return; - - case active: - Future task = queued.get(0); - if (task != null) { - task.cancel(true); - queued.remove(task); - } - break; - - default: - } - - jutil.sendSessionTerminateCancel(getRemote(), getSessionId()); - notifyEndedListeners(JingleReasonElement.Reason.cancel); - } - - public enum State { - fresh, - pending, - sent_transport_replace, - active, - terminated - } - - private Runnable sendingThread; - private File source; - private State state; - - - public OutgoingJingleFileOffer(XMPPConnection connection, FullJid responder, String sid) { - super(connection, connection.getUser().asFullJidOrThrow(), responder, Role.initiator, sid, Type.offer); - state = State.fresh; - } - - public OutgoingJingleFileOffer(XMPPConnection connection, FullJid recipient) { - this(connection, recipient, JingleManager.randomId()); - } - - public void send(File file) throws InterruptedException, XMPPException.XMPPErrorException, - SmackException.NotConnectedException, SmackException.NoResponseException { - source = file; - String contentName = JingleManager.randomId(); - JingleFileTransferElement transfer = JingleFileTransferManagerAlt.fileTransferFromFile(file); - - initiateFileOffer(transfer, JingleContentElement.Creator.initiator, contentName); - } - - public SmackFuture sendAsync(File file) { - source = file; - String contentName = "jft-" + StringUtils.randomString(20); - JingleFileTransferElement transfer = JingleFileTransferManagerAlt.fileTransferFromFile(file); - return null; //TODO - } - - 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."); - } - - JingleTransportManager transportManager = JingleTransportMethodManager.getInstanceFor(connection) - .getBestAvailableTransportManager(); - - if (transportManager == null) { - throw new IllegalStateException("There must be at least one workable transport method."); - } - - transportSession = transportManager.transportSession(this); - - state = State.pending; - - JingleElement initiate = jutil.createSessionInitiateFileOffer(getResponder(), getSessionId(), creator, name, file, transportSession.createTransport(), null); - this.contents.addAll(initiate.getContents()); - - connection.sendStanza(initiate); - } - - @Override - public IQ handleSessionAccept(JingleElement sessionAccept) throws SmackException.NotConnectedException, InterruptedException { - // Out of order? - if (state != State.pending) { - LOGGER.log(Level.WARNING, "Session state is " + state + ", so session-accept is out of order."); - return jutil.createErrorOutOfOrder(sessionAccept); - } - - state = State.active; - - transportSession.processJingle(sessionAccept); - - transportSession.initiateOutgoingSession(new JingleTransportInitiationCallback() { - @Override - public void onSessionInitiated(final BytestreamSession byteStream) { - sendingThread = new SendTask(OutgoingJingleFileOffer.this, byteStream, source); - queued.add(JingleManager.getThreadPool().submit(sendingThread)); - notifyStartedListeners(); - } - - @Override - public void onException(Exception e) { - LOGGER.log(Level.SEVERE, "EXCEPTION IN OUTGOING SESSION:", e); - } - }); - - return jutil.createAck(sessionAccept); - } - - @Override - public IQ handleSessionTerminate(JingleElement sessionTerminate) { - state = State.terminated; - return jutil.createAck(sessionTerminate); - } - - @Override - public IQ handleTransportReplace(final JingleElement transportReplace) - throws InterruptedException, XMPPException.XMPPErrorException, - SmackException.NotConnectedException, SmackException.NoResponseException { - final JingleTransportManager replacementManager = JingleTransportMethodManager.getInstanceFor(connection) - .getTransportManager(transportReplace); - - queued.add(JingleManager.getThreadPool().submit(new Runnable() { - @Override - public void run() { - try { - if (replacementManager != null) { - LOGGER.log(Level.INFO, "Accept transport-replace."); - jutil.sendTransportAccept(transportReplace.getFrom().asFullJidOrThrow(), - transportReplace.getInitiator(), transportReplace.getSid(), - getContents().get(0).getCreator(), getContents().get(0).getName(), - transportSession.createTransport()); - } else { - LOGGER.log(Level.INFO, "Unsupported transport. Reject transport-replace."); - jutil.sendTransportReject(transportReplace.getFrom().asFullJidOrThrow(), transportReplace.getInitiator(), - transportReplace.getSid(), getContents().get(0).getCreator(), - getContents().get(0).getName(), transportReplace.getContents().get(0).getTransport()); - } - } catch (InterruptedException | XMPPException.XMPPErrorException | SmackException.NotConnectedException | SmackException.NoResponseException e) { - LOGGER.log(Level.SEVERE, "Help me please!", e); - } - } - })); - - return jutil.createAck(transportReplace); - } - - @Override - public IQ handleTransportAccept(JingleElement transportAccept) - throws SmackException.NotConnectedException, InterruptedException { - - return handleSessionAccept(transportAccept); - } - - @Override - public void onTransportMethodFailed(String namespace) { - state = State.pending; - JingleContentElement content = contents.get(0); - failedTransportMethods.add(namespace); - JingleTransportMethodManager tm = JingleTransportMethodManager.getInstanceFor(getConnection()); - JingleTransportManager next = tm.getBestAvailableTransportManager(failedTransportMethods); - - if (next == null) { - //Failure - try { - jutil.sendSessionTerminateUnsupportedTransports(getRemote(), getSessionId()); - } catch (InterruptedException | SmackException.NoResponseException | SmackException.NotConnectedException | XMPPException.XMPPErrorException e) { - LOGGER.log(Level.WARNING, "Could not send session-terminate.", e); - } - return; - } - - //Replace transport - this.transportSession = next.transportSession(this); - try { - jutil.sendTransportReplace(getRemote(), getInitiator(), getSessionId(), content.getCreator(), content.getName(), - transportSession.createTransport()); - } catch (SmackException.NotConnectedException | SmackException.NoResponseException | XMPPException.XMPPErrorException | InterruptedException e) { - LOGGER.log(Level.WARNING, "Could not send transport-replace.", e); - } - } -} 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 deleted file mode 100644 index 8f834c7cc..000000000 --- a/smack-experimental/src/main/java/org/jivesoftware/smackx/jingle_filetransfer/ReceiveTask.java +++ /dev/null @@ -1,96 +0,0 @@ -/** - * - * 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 java.io.File; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.InputStream; -import java.util.logging.Level; -import java.util.logging.Logger; - -import org.jivesoftware.smackx.bytestreams.BytestreamSession; -import org.jivesoftware.smackx.jingle.element.JingleReasonElement; -import org.jivesoftware.smackx.jft.element.JingleFileTransferElement; -import org.jivesoftware.smackx.jft.element.JingleFileTransferChildElement; - -/** - * Thread for receiving data. - */ -public class ReceiveTask implements Runnable { - private static final Logger LOGGER = Logger.getLogger(ReceiveTask.class.getName()); - - private final BytestreamSession byteStream; - private final JingleFileTransferElement fileTransfer; - private final File target; - private final JingleFileTransferSession session; - - public ReceiveTask(JingleFileTransferSession session, BytestreamSession byteStream, JingleFileTransferElement fileTransfer, File target) { - this.byteStream = byteStream; - this.fileTransfer = fileTransfer; - this.target = target; - this.session = session; - } - - @Override - public void run() { - JingleFileTransferChildElement transfer = (JingleFileTransferChildElement) fileTransfer.getJingleContentDescriptionChildren().get(0); - FileOutputStream outputStream = null; - InputStream inputStream; - - try { - outputStream = new FileOutputStream(target); - inputStream = byteStream.getInputStream(); - - byte[] filebuf = new byte[transfer.getSize()]; - int read = 0; - byte[] bufbuf = new byte[4096]; - LOGGER.log(Level.INFO, "Begin receiving bytes."); - while (read < filebuf.length) { - int r = inputStream.read(bufbuf); - if (r >= 0) { - System.arraycopy(bufbuf, 0, filebuf, read, r); - read += r; - LOGGER.log(Level.INFO, "Read " + r + " (" + read + " of " + filebuf.length + ") bytes."); - } else { - break; - } - } - - outputStream.write(filebuf); - LOGGER.log(Level.INFO, "File successfully received."); - - } catch (IOException e) { - LOGGER.log(Level.SEVERE, "Error while receiving data: ", e); - } finally { - try { - byteStream.close(); - } catch (IOException e) { - LOGGER.log(Level.SEVERE, "Could not close InputStream.", e); - } - if (outputStream != null) { - try { - outputStream.close(); - } catch (IOException e) { - LOGGER.log(Level.SEVERE, "Could not close FileOutputStream.", e); - } - } - - session.notifyEndedListeners(JingleReasonElement.Reason.success); - } - } -} diff --git a/smack-experimental/src/main/java/org/jivesoftware/smackx/jingle_filetransfer/SendTask.java b/smack-experimental/src/main/java/org/jivesoftware/smackx/jingle_filetransfer/SendTask.java deleted file mode 100644 index a4d9542e7..000000000 --- a/smack-experimental/src/main/java/org/jivesoftware/smackx/jingle_filetransfer/SendTask.java +++ /dev/null @@ -1,84 +0,0 @@ -/** - * - * 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 java.io.File; -import java.io.FileInputStream; -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; -import java.util.logging.Level; -import java.util.logging.Logger; - -import org.jivesoftware.smackx.bytestreams.BytestreamSession; -import org.jivesoftware.smackx.jingle.element.JingleReasonElement; - -/** - * Created by vanitas on 21.06.17. - */ -public class SendTask implements Runnable { - private static final Logger LOGGER = Logger.getLogger(SendTask.class.getName()); - - private final BytestreamSession byteStream; - private final JingleFileTransferSession session; - private final File source; - - public SendTask(JingleFileTransferSession session, BytestreamSession byteStream, File source) { - this.byteStream = byteStream; - this.source = source; - this.session = session; - } - - @Override - public void run() { - InputStream inputStream = null; - OutputStream outputStream = null; - - try { - inputStream = new FileInputStream(source); - outputStream = byteStream.getOutputStream(); - - byte[] filebuf = new byte[(int) source.length()]; - int r = inputStream.read(filebuf); - - if (r < 0) { - throw new IOException("Read returned -1"); - } - - LOGGER.log(Level.INFO, "WRITE"); - outputStream.write(filebuf); - outputStream.flush(); - LOGGER.log(Level.INFO, "WRITING FINISHED"); - } - catch (IOException e) { - LOGGER.log(Level.SEVERE, "Could not send file: " + e, e); - } - - finally { - try { - if (inputStream != null) { - inputStream.close(); - LOGGER.log(Level.INFO, "InputStream closed."); - } - } catch (IOException e) { - LOGGER.log(Level.SEVERE, "Could not close session.", e); - } - - session.notifyEndedListeners(JingleReasonElement.Reason.success); - } - } -} diff --git a/smack-experimental/src/main/java/org/jivesoftware/smackx/jingle_filetransfer/callback/IncomingFileOfferCallback.java b/smack-experimental/src/main/java/org/jivesoftware/smackx/jingle_filetransfer/callback/IncomingFileOfferCallback.java deleted file mode 100644 index b3e9068fd..000000000 --- a/smack-experimental/src/main/java/org/jivesoftware/smackx/jingle_filetransfer/callback/IncomingFileOfferCallback.java +++ /dev/null @@ -1,32 +0,0 @@ -/** - * - * 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.callback; - -import java.io.File; - -import org.jivesoftware.smackx.jingle.element.JingleElement; -import org.jivesoftware.smackx.jingle_filetransfer.handler.FileTransferHandler; - -/** - * Callback used to accept/decline file offers. - */ -public interface IncomingFileOfferCallback { - - FileTransferHandler acceptIncomingFileOffer(JingleElement request, File target); - - void declineIncomingFileOffer(JingleElement request); -} diff --git a/smack-experimental/src/main/java/org/jivesoftware/smackx/jingle_filetransfer/callback/IncomingFileRequestCallback.java b/smack-experimental/src/main/java/org/jivesoftware/smackx/jingle_filetransfer/callback/IncomingFileRequestCallback.java deleted file mode 100644 index 18ecaddf7..000000000 --- a/smack-experimental/src/main/java/org/jivesoftware/smackx/jingle_filetransfer/callback/IncomingFileRequestCallback.java +++ /dev/null @@ -1,31 +0,0 @@ -/** - * - * 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.callback; - -import java.io.File; - -import org.jivesoftware.smackx.jingle.element.JingleElement; - -/** - * Callback used to accept/decline file requests. - */ -public interface IncomingFileRequestCallback { - - void acceptIncomingFileRequest(JingleElement request, File source); - - void declineIncomingFileRequest(JingleElement request); -} diff --git a/smack-experimental/src/main/java/org/jivesoftware/smackx/jingle_filetransfer/callback/package-info.java b/smack-experimental/src/main/java/org/jivesoftware/smackx/jingle_filetransfer/callback/package-info.java deleted file mode 100644 index ecb3e301e..000000000 --- a/smack-experimental/src/main/java/org/jivesoftware/smackx/jingle_filetransfer/callback/package-info.java +++ /dev/null @@ -1,22 +0,0 @@ -/** - * - * 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. - * Callbacks. - */ -package org.jivesoftware.smackx.jingle_filetransfer.callback; diff --git a/smack-experimental/src/main/java/org/jivesoftware/smackx/jingle_filetransfer/handler/FileTransferHandler.java b/smack-experimental/src/main/java/org/jivesoftware/smackx/jingle_filetransfer/handler/FileTransferHandler.java deleted file mode 100644 index cbd33671d..000000000 --- a/smack-experimental/src/main/java/org/jivesoftware/smackx/jingle_filetransfer/handler/FileTransferHandler.java +++ /dev/null @@ -1,81 +0,0 @@ -/** - * - * 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.handler; - -import org.jivesoftware.smack.SmackException; -import org.jivesoftware.smack.XMPPException; -import org.jivesoftware.smackx.jingle.element.JingleReasonElement; - -/** - * Handler that provides some control over the JingleFileOffer session. - */ -public interface FileTransferHandler { - - /** - * Cancels the current file transfer. - */ - void cancel() throws InterruptedException, XMPPException.XMPPErrorException, SmackException.NotConnectedException, SmackException.NoResponseException; - - /** - * Returns true, if the file transfer is ended. - * @return true if transfer ended. - */ - boolean isFinished(); - - /** - * Returns true, if the file transfer is started. - * @return true if started. - */ - boolean isStarted(); - - /** - * Add a new FinishedListener. - * @param listener listener - */ - void addEndedListener(EndedListener listener); - - /** - * Add a new AcceptedListener. - * @param listener listener - */ - void addStartedListener(StartedListener listener); - - /** - * Notify all registered FinishedListeners that the file transfer has ended. - */ - void notifyEndedListeners(JingleReasonElement.Reason reason); - - /** - * Notify all registered AcceptedListeners that the file transfer session has been accepted by the remote user. - */ - void notifyStartedListeners(); - - /** - * A FinishedListener will be notified by the SendFileHandler when the corresponding file transfer is ended. - */ - interface EndedListener { - void onEnded(JingleReasonElement.Reason reason); - } - - /** - * An AcceptedListener will be notified by the SendFileHandler when the corresponding pending session has been - * accepted by the remote user. - */ - interface StartedListener { - void onStarted(); - } -} diff --git a/smack-experimental/src/main/java/org/jivesoftware/smackx/jingle_filetransfer/handler/package-info.java b/smack-experimental/src/main/java/org/jivesoftware/smackx/jingle_filetransfer/handler/package-info.java deleted file mode 100644 index e90c28e2c..000000000 --- a/smack-experimental/src/main/java/org/jivesoftware/smackx/jingle_filetransfer/handler/package-info.java +++ /dev/null @@ -1,22 +0,0 @@ -/** - * - * 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. - * Handlers. - */ -package org.jivesoftware.smackx.jingle_filetransfer.handler; diff --git a/smack-experimental/src/main/java/org/jivesoftware/smackx/jingle_filetransfer/listener/JingleFileTransferOfferListener.java b/smack-experimental/src/main/java/org/jivesoftware/smackx/jingle_filetransfer/listener/JingleFileTransferOfferListener.java deleted file mode 100644 index 9b8825eb9..000000000 --- a/smack-experimental/src/main/java/org/jivesoftware/smackx/jingle_filetransfer/listener/JingleFileTransferOfferListener.java +++ /dev/null @@ -1,28 +0,0 @@ -/** - * - * 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.listener; - -import org.jivesoftware.smackx.jingle.element.JingleElement; -import org.jivesoftware.smackx.jingle_filetransfer.callback.IncomingFileOfferCallback; - -/** - * Listener for incoming Jingle File Transfer (XEP-0234) file offers. - */ -public interface JingleFileTransferOfferListener { - - void onFileOffer(JingleElement request, IncomingFileOfferCallback callback); -} diff --git a/smack-experimental/src/main/java/org/jivesoftware/smackx/jingle_filetransfer/listener/package-info.java b/smack-experimental/src/main/java/org/jivesoftware/smackx/jingle_filetransfer/listener/package-info.java deleted file mode 100644 index 438b31b61..000000000 --- a/smack-experimental/src/main/java/org/jivesoftware/smackx/jingle_filetransfer/listener/package-info.java +++ /dev/null @@ -1,22 +0,0 @@ -/** - * - * 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. - * Listeners. - */ -package org.jivesoftware.smackx.jingle_filetransfer.listener; diff --git a/smack-experimental/src/main/java/org/jivesoftware/smackx/jingle_filetransfer/package-info.java b/smack-experimental/src/main/java/org/jivesoftware/smackx/jingle_filetransfer/package-info.java deleted file mode 100644 index 86fb45ecc..000000000 --- a/smack-experimental/src/main/java/org/jivesoftware/smackx/jingle_filetransfer/package-info.java +++ /dev/null @@ -1,21 +0,0 @@ -/** - * - * 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-experimental/src/test/java/org/jivesoftware/smackx/jingle_filetransfer/ChecksumTest.java b/smack-experimental/src/test/java/org/jivesoftware/smackx/jft/ChecksumTest.java similarity index 98% rename from smack-experimental/src/test/java/org/jivesoftware/smackx/jingle_filetransfer/ChecksumTest.java rename to smack-experimental/src/test/java/org/jivesoftware/smackx/jft/ChecksumTest.java index 64a0e6cca..3a6dee704 100644 --- a/smack-experimental/src/test/java/org/jivesoftware/smackx/jingle_filetransfer/ChecksumTest.java +++ b/smack-experimental/src/test/java/org/jivesoftware/smackx/jft/ChecksumTest.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; +package org.jivesoftware.smackx.jft; import static org.custommonkey.xmlunit.XMLAssert.assertXMLEqual; 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 deleted file mode 100644 index 0ada909e7..000000000 --- a/smack-experimental/src/test/java/org/jivesoftware/smackx/jingle_filetransfer/JingleUtilFileTransferTest.java +++ /dev/null @@ -1,185 +0,0 @@ -/** - * - * 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 static junit.framework.TestCase.assertEquals; -import static junit.framework.TestCase.assertNull; -import static org.custommonkey.xmlunit.XMLAssert.assertXMLEqual; - -import java.util.Collections; -import java.util.Date; - -import org.jivesoftware.smack.DummyConnection; -import org.jivesoftware.smack.XMPPConnection; -import org.jivesoftware.smack.test.util.SmackTestSuite; -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.transport.legacy.JingleUtil; -import org.jivesoftware.smackx.jingle.JingleUtilTest; -import org.jivesoftware.smackx.jingle.element.JingleContentElement; -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.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; -import org.jxmpp.jid.FullJid; -import org.jxmpp.jid.impl.JidCreate; -import org.jxmpp.stringprep.XmppStringprepException; -import org.jxmpp.util.XmppDateTime; - -/** - * Created by vanitas on 12.07.17. - */ -public class JingleUtilFileTransferTest extends SmackTestSuite { - private XMPPConnection connection; - private JingleUtil jutil; - - private FullJid romeo; - private FullJid juliet; - - @Before - public void setup() throws XmppStringprepException { - connection = new DummyConnection( - DummyConnection.getDummyConfigurationBuilder() - .setUsernameAndPassword("romeo@montague.lit", - "iluvJulibabe13").build()); - JingleManager jm = JingleManager.getInstanceFor(connection); - jutil = new JingleUtil(connection); - romeo = connection.getUser().asFullJidOrThrow(); - juliet = JidCreate.fullFrom("juliet@capulet.lit/balcony"); - } - - @Test - public void createSessionInitiateTest() throws Exception { - JingleIBBTransport transport = new JingleIBBTransport("transid"); - Date date = new Date(); - HashElement hash = new HashElement(HashManager.ALGORITHM.SHA_256, "f4OxZX/x/FO5LcGBSKHWXfwtSx+j1ncoSt3SABJtkGk="); - JingleFileTransferChildElement file = new JingleFileTransferChildElement(date, "desc", hash, "application/octet-stream", "name", 1337, null); - JingleFileTransferElement description = new JingleFileTransferElement(Collections.singletonList(file)); - - String contentName = "content"; - - JingleElement initiate = jutil.createSessionInitiate(juliet, "letsstart", JingleContentElement.Creator.initiator, contentName, JingleContentElement.Senders.initiator, description, transport); - JingleElement accept = jutil.createSessionAccept(juliet, "acceptID", JingleContentElement.Creator.initiator, contentName, JingleContentElement.Senders.initiator, description, transport); - JingleElement fileOffer = jutil.createSessionInitiateFileOffer(juliet, "fileOffer", JingleContentElement.Creator.initiator, contentName, description, transport); - - assertEquals(JingleAction.session_initiate, initiate.getAction()); - assertEquals(JingleAction.session_accept, accept.getAction()); - - assertEquals(romeo, initiate.getInitiator()); - assertEquals(romeo, accept.getResponder()); - //Must be null - assertNull(initiate.getResponder()); - assertNull(accept.getInitiator()); - - assertEquals("letsstart", initiate.getSid()); - assertEquals("acceptID", accept.getSid()); - - assertEquals(1, initiate.getContents().size()); - assertEquals(1, accept.getContents().size()); - - JingleContentElement content = initiate.getContents().get(0); - assertEquals(content.toXML().toString(), initiate.getContents().get(0).toXML().toString()); - assertEquals(content.toXML().toString(), accept.getContents().get(0).toXML().toString()); - - assertEquals("content", content.getName()); - assertEquals(JingleContentElement.Creator.initiator, content.getCreator()); - assertEquals(JingleContentElement.Senders.initiator, content.getSenders()); - - assertEquals(1, description.getJingleContentDescriptionChildren().size()); - assertEquals(file, description.getJingleContentDescriptionChildren().get(0)); - 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()); - assertEquals("name", file.getName()); - assertEquals(1337, file.getSize()); - assertNull(file.getRange()); - - assertEquals(transport, content.getTransport()); - assertEquals("transid", transport.getSessionId()); - assertEquals(JingleIBBTransport.DEFAULT_BLOCK_SIZE, transport.getBlockSize()); - - String transportXML = - ""; - assertXMLEqual(transportXML, transport.toXML().toString()); - - String descriptionXML = - "" + - "" + - "" + XmppDateTime.formatXEP0082Date(date) + "" + - "desc" + - "application/octet-stream" + - "name" + - //"" + TODO: insert empty element when null? - "1337" + - "f4OxZX/x/FO5LcGBSKHWXfwtSx+j1ncoSt3SABJtkGk=" + - "" + - ""; - assertXMLEqual(descriptionXML, description.toXML().toString()); - - JingleFileTransferElement parsed = new JingleFileTransferProvider().parse(TestUtils.getParser(descriptionXML)); - assertEquals(1, parsed.getJingleContentDescriptionChildren().size()); - assertEquals(file.toXML().toString(), parsed.getJingleContentDescriptionChildren().get(0).toXML().toString()); - - String contentXML = "" + - descriptionXML + - transportXML + - ""; - assertXMLEqual(contentXML, content.toXML().toString()); - - String initiateXML = - "" + - contentXML + - ""; - String xml = JingleUtilTest.getIQXML(romeo, juliet, initiate.getStanzaId(), initiateXML); - assertXMLEqual(xml, initiate.toXML().toString()); - - String acceptXML = - "" + - contentXML + - ""; - xml = JingleUtilTest.getIQXML(romeo, juliet, accept.getStanzaId(), acceptXML); - assertXMLEqual(xml, accept.toXML().toString()); - - String fileOfferXML = - "" + - contentXML + - ""; - xml = JingleUtilTest.getIQXML(romeo, juliet, fileOffer.getStanzaId(), fileOfferXML); - assertXMLEqual(xml, fileOffer.toXML().toString()); - } -} diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/jingle/JingleDescriptionController.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/jingle/JingleDescriptionController.java index 18e993a2e..609b1b6d3 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/jingle/JingleDescriptionController.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/jingle/JingleDescriptionController.java @@ -1,9 +1,26 @@ +/** + * + * 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; /** * Created by vanitas on 27.07.17. */ public interface JingleDescriptionController { + enum State { pending, //Not yet accepted by us/peer negotiating, //Accepted, but still negotiating transports etc. diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/jingle/callbacks/JingleCallback.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/jingle/callbacks/JingleCallback.java index 637174653..2e008434c 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/jingle/callbacks/JingleCallback.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/jingle/callbacks/JingleCallback.java @@ -1,3 +1,19 @@ +/** + * + * 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.callbacks; import org.jivesoftware.smackx.jingle.JingleDescriptionController; diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/jingle/components/JingleContent.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/jingle/components/JingleContent.java index 760b35e55..c81535d49 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/jingle/components/JingleContent.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/jingle/components/JingleContent.java @@ -54,9 +54,9 @@ public class JingleContent { private String name; private String disposition; private JingleContentElement.Senders senders; - private JingleDescription description; - private JingleTransport transport; - private JingleSecurity security; + private JingleDescription description; + private JingleTransport transport; + private JingleSecurity security; private final List callbacks = Collections.synchronizedList(new ArrayList()); private final Set transportBlacklist = Collections.synchronizedSet(new HashSet()); @@ -75,7 +75,7 @@ public class JingleContent { this(null, null, null, randomName(), null, creator, senders); } - public JingleContent(JingleDescription description, JingleTransport transport, JingleSecurity security, String name, String disposition, JingleContentElement.Creator creator, JingleContentElement.Senders senders) { + public JingleContent(JingleDescription description, JingleTransport transport, JingleSecurity security, String name, String disposition, JingleContentElement.Creator creator, JingleContentElement.Senders senders) { this.description = description; this.transport = transport; this.security = security; diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/jingle/components/JingleSecurityBytestreamSession.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/jingle/components/JingleSecurityBytestreamSession.java index 36413adaf..847065163 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/jingle/components/JingleSecurityBytestreamSession.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/jingle/components/JingleSecurityBytestreamSession.java @@ -1,3 +1,19 @@ +/** + * + * 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.components; import java.io.IOException; diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/jingle/components/JingleSession.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/jingle/components/JingleSession.java index 255faa977..035ffaf74 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/jingle/components/JingleSession.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/jingle/components/JingleSession.java @@ -29,21 +29,20 @@ import java.util.logging.Logger; import org.jivesoftware.smack.SmackException; import org.jivesoftware.smack.XMPPException; import org.jivesoftware.smack.packet.IQ; +import org.jivesoftware.smackx.jingle.JingleDescriptionManager; import org.jivesoftware.smackx.jingle.JingleManager; -import org.jivesoftware.smackx.jingle.util.Role; import org.jivesoftware.smackx.jingle.adapter.JingleTransportAdapter; -import org.jivesoftware.smackx.jingle.callbacks.ContentAddCallback; +import org.jivesoftware.smackx.jingle.element.JingleAction; import org.jivesoftware.smackx.jingle.element.JingleContentDescriptionElement; +import org.jivesoftware.smackx.jingle.element.JingleContentElement; import org.jivesoftware.smackx.jingle.element.JingleContentTransportElement; +import org.jivesoftware.smackx.jingle.element.JingleContentTransportInfoElement; import org.jivesoftware.smackx.jingle.element.JingleElement; import org.jivesoftware.smackx.jingle.element.JingleReasonElement; import org.jivesoftware.smackx.jingle.exception.UnsupportedDescriptionException; import org.jivesoftware.smackx.jingle.exception.UnsupportedSecurityException; import org.jivesoftware.smackx.jingle.exception.UnsupportedTransportException; -import org.jivesoftware.smackx.jingle.JingleDescriptionManager; -import org.jivesoftware.smackx.jingle.element.JingleAction; -import org.jivesoftware.smackx.jingle.element.JingleContentElement; -import org.jivesoftware.smackx.jingle.element.JingleContentTransportInfoElement; +import org.jivesoftware.smackx.jingle.util.Role; import org.jxmpp.jid.FullJid; @@ -360,21 +359,6 @@ public class JingleSession { for (final JingleContent content : descriptionCategory.getValue()) { descriptionManager.notifyContentAdd(content); - - ContentAddCallback callback = new ContentAddCallback() { - @Override - public void acceptContentAdd() { - contents.put(content.getName(), content); - acceptedContents.add(content.getElement()); - // TODO: Send content-accept - } - - @Override - public void rejectContentAdd() { - // TODO: Send content-reject - } - }; - descriptionManager } } diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/jingle/components/JingleTransport.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/jingle/components/JingleTransport.java index fe453552a..d18762dc1 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/jingle/components/JingleTransport.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/jingle/components/JingleTransport.java @@ -35,7 +35,7 @@ public abstract class JingleTransport e private JingleContent parent; private final ArrayList> candidates = new ArrayList<>(); - private JingleTransport peersProposal; + private JingleTransport peersProposal; private boolean isPeersProposal; protected BytestreamSession bytestreamSession; @@ -81,7 +81,7 @@ public abstract class JingleTransport e public abstract void establishOutgoingBytestreamSession(XMPPConnection connection) throws SmackException.NotConnectedException, InterruptedException; - public void setPeersProposal(JingleTransport peersProposal) { + public void setPeersProposal(JingleTransport peersProposal) { this.peersProposal = peersProposal; peersProposal.isPeersProposal = true; } 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 bf2a98bd3..6fe7588eb 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 @@ -100,7 +100,7 @@ public class JingleS5BTransport extends JingleTransport candidate : getCandidates()) { builder.addTransportCandidate((JingleS5BTransportCandidateElement) candidate.getElement()); } @@ -156,7 +156,7 @@ public class JingleS5BTransport extends JingleTransport c : getCandidates()) { int _timeout = timeout / getCandidates().size(); //TODO: Wise? try { return ((JingleS5BTransportCandidate) c).connect(_timeout); diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/jingle/transport/jingle_s5b/JingleS5BTransportCandidate.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/jingle/transport/jingle_s5b/JingleS5BTransportCandidate.java index 98bf2ad6b..7d7fb0723 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/jingle/transport/jingle_s5b/JingleS5BTransportCandidate.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/jingle/transport/jingle_s5b/JingleS5BTransportCandidate.java @@ -67,6 +67,7 @@ public class JingleS5BTransportCandidate extends JingleTransportCandidate" + + "" + + "" + + "" + + ""; + String xml = getIQXML(romeo, juliet, terminate.getStanzaId(), jingleXML); + assertXMLEqual(xml, terminate.toXML().toString()); + JingleElement jingle = new JingleProvider().parse(TestUtils.getParser(jingleXML)); assertNotNull(jingle); - assertEquals(romeo, jingle.getInitiator()); - assertEquals(juliet, jingle.getResponder()); - assertEquals(jingle.getAction(), JingleAction.session_initiate); - assertEquals(sessionId, jingle.getSid()); + assertEquals(jingle.getAction(), JingleAction.session_terminate); + assertEquals(jingle.getReason().asEnum(), JingleReasonElement.Reason.decline); + } - String xml = "" + - ""; - assertTrue(jingle.toXML().toString().contains(xml)); + @Test + public void createSessionTerminateSuccessTest() throws Exception { + JingleElement success = JingleElement.createSessionTerminate(juliet, "thisissparta", JingleReasonElement.Reason.success); + String jingleXML = + "" + + "" + + "" + + "" + + ""; + String xml = getIQXML(romeo, juliet, success.getStanzaId(), jingleXML); + assertXMLEqual(xml, success.toXML().toString()); + JingleElement jingle = new JingleProvider().parse(TestUtils.getParser(jingleXML)); + assertNotNull(jingle); + assertEquals(jingle.getAction(), JingleAction.session_terminate); + assertEquals(jingle.getReason().asEnum(), JingleReasonElement.Reason.success); + } + + @Test + public void createSessionTerminateBusyTest() throws Exception { + JingleElement busy = JingleElement.createSessionTerminate(juliet, "thisispatrick", JingleReasonElement.Reason.busy); + String jingleXML = + "" + + "" + + "" + + "" + + ""; + String xml = getIQXML(romeo, juliet, busy.getStanzaId(), jingleXML); + assertXMLEqual(xml, busy.toXML().toString()); + JingleElement jingle = new JingleProvider().parse(TestUtils.getParser(jingleXML)); + assertNotNull(jingle); + assertEquals(jingle.getAction(), JingleAction.session_terminate); + assertEquals(jingle.getReason().asEnum(), JingleReasonElement.Reason.busy); + } + + @Test + public void createSessionTerminateAlternativeSessionTest() throws Exception { + JingleElement busy = JingleElement.createSessionTerminate(juliet, "thisistherhythm", JingleReasonElement.AlternativeSession("ofthenight")); + String jingleXML = + "" + + "" + + "" + + "ofthenight" + + "" + + "" + + ""; + String xml = getIQXML(romeo, juliet, busy.getStanzaId(), jingleXML); + assertXMLEqual(xml, busy.toXML().toString()); + JingleElement jingle = new JingleProvider().parse(TestUtils.getParser(jingleXML)); + assertNotNull(jingle); + assertEquals(jingle.getAction(), JingleAction.session_terminate); + assertEquals(jingle.getReason().asEnum(), JingleReasonElement.Reason.alternative_session); + JingleReasonElement.AlternativeSession alt = (JingleReasonElement.AlternativeSession) jingle.getReason(); + assertEquals("ofthenight", alt.getAlternativeSessionId()); + } + + @Test + public void createSessionTerminateCancelTest() throws Exception { + JingleElement cancel = JingleElement.createSessionTerminate(juliet, "thisistheend", JingleReasonElement.Reason.cancel); + String jingleXML = + "" + + "" + + "" + + "" + + ""; + String xml = getIQXML(romeo, juliet, cancel.getStanzaId(), jingleXML); + assertXMLEqual(xml, cancel.toXML().toString()); + JingleElement jingle = new JingleProvider().parse(TestUtils.getParser(jingleXML)); + assertNotNull(jingle); + assertEquals(jingle.getAction(), JingleAction.session_terminate); + assertEquals(jingle.getReason().asEnum(), JingleReasonElement.Reason.cancel); + } + + @Test + public void createSessionTerminateUnsupportedTransportsTest() throws Exception { + JingleElement unsupportedTransports = JingleElement.createSessionTerminate(juliet, "thisisus", JingleReasonElement.Reason.unsupported_transports); + String jingleXML = + "" + + "" + + "" + + "" + + ""; + String xml = getIQXML(romeo, juliet, unsupportedTransports.getStanzaId(), jingleXML); + assertXMLEqual(xml, unsupportedTransports.toXML().toString()); + JingleElement jingle = new JingleProvider().parse(TestUtils.getParser(jingleXML)); + assertNotNull(jingle); + assertEquals(jingle.getAction(), JingleAction.session_terminate); + assertEquals(jingle.getReason().asEnum(), JingleReasonElement.Reason.unsupported_transports); + } + + @Test + public void createSessionTerminateUnsupportedApplicationsTest() throws Exception { + JingleElement unsupportedApplications = JingleElement.createSessionTerminate(juliet, "thisiswar", JingleReasonElement.Reason.unsupported_applications); + String jingleXML = + "" + + "" + + "" + + "" + + ""; + String xml = getIQXML(romeo, juliet, unsupportedApplications.getStanzaId(), jingleXML); + assertXMLEqual(xml, unsupportedApplications.toXML().toString()); + JingleElement jingle = new JingleProvider().parse(TestUtils.getParser(jingleXML)); + assertNotNull(jingle); + assertEquals(jingle.getAction(), JingleAction.session_terminate); + assertEquals(jingle.getReason().asEnum(), JingleReasonElement.Reason.unsupported_applications); + } + + @Test + public void createSessionTerminateFailedTransportTest() throws IOException, SAXException { + JingleElement failedTransport = JingleElement.createSessionTerminate(juliet, "derailed", JingleReasonElement.Reason.failed_transport); + String jingleXML = + "" + + "" + + "" + + "" + + ""; + String xml = getIQXML(romeo, juliet, failedTransport.getStanzaId(), jingleXML); + assertXMLEqual(xml, failedTransport.toXML().toString()); + assertEquals(JingleAction.session_terminate, failedTransport.getAction()); + assertEquals(JingleReasonElement.Reason.failed_transport, failedTransport.getReason().asEnum()); + } + + @Test + public void createSessionTerminateFailedApplicationTest() throws IOException, SAXException { + JingleElement failedApplication = JingleElement.createSessionTerminate(juliet, "crashed", JingleReasonElement.Reason.failed_application); + String jingleXML = + "" + + "" + + "" + + "" + + ""; + String xml = getIQXML(romeo, juliet, failedApplication.getStanzaId(), jingleXML); + assertXMLEqual(xml, failedApplication.toXML().toString()); + assertEquals(JingleAction.session_terminate, failedApplication.getAction()); + assertEquals(JingleReasonElement.Reason.failed_application, failedApplication.getReason().asEnum()); + } + + @Test + public void createSessionPingTest() throws Exception { + JingleElement ping = JingleElement.createSessionPing(juliet, "thisisit"); + String jingleXML = + ""; + String xml = getIQXML(romeo, juliet, ping.getStanzaId(), jingleXML); + assertXMLEqual(xml, ping.toXML().toString()); + JingleElement jingle = new JingleProvider().parse(TestUtils.getParser(jingleXML)); + assertNotNull(jingle); + assertEquals(JingleAction.session_info, jingle.getAction()); + } + + @Test + public void createSessionTerminateContentCancelTest() throws Exception { + JingleElement cancel = JingleElement.createSessionTerminateContentCancel(juliet, "thisismumbo#5", JingleContentElement.Creator.initiator, "content123"); + String jingleXML = + "" + + "" + + "" + + "" + + "" + + ""; + String xml = getIQXML(romeo, juliet, cancel.getStanzaId(), jingleXML); + assertXMLEqual(xml, cancel.toXML().toString()); + JingleElement jingle = new JingleProvider().parse(TestUtils.getParser(jingleXML)); + assertNotNull(jingle); + assertEquals(JingleAction.session_terminate, jingle.getAction()); + assertEquals(JingleReasonElement.Reason.cancel, jingle.getReason().asEnum()); + assertEquals("thisismumbo#5", jingle.getSid()); + JingleContentElement content = jingle.getContents().get(0); + assertNotNull(content); + assertEquals("content123", content.getName()); + assertEquals(JingleContentElement.Creator.initiator, content.getCreator()); + } + + @Test + public void createSessionTerminateIncompatibleParameters() throws IOException, SAXException { + JingleElement terminate = JingleElement.createSessionTerminate(juliet, "incompatibleSID", JingleReasonElement.Reason.incompatible_parameters); + String jingleXML = + "" + + "" + + "" + + "" + + ""; + String xml = getIQXML(romeo, juliet, terminate.getStanzaId(), jingleXML); + assertXMLEqual(xml, terminate.toXML().toString()); + assertEquals(JingleReasonElement.Reason.incompatible_parameters, terminate.getReason().asEnum()); + assertEquals("incompatibleSID", terminate.getSid()); + } + + @Test + public void createTransportAcceptTest() throws IOException, SAXException { + JingleElement transportAccept = JingleElement.createTransportAccept(juliet, romeo, "transAcc", JingleContentElement.Creator.initiator, "cname", new JingleIBBTransportElement("transid", JingleIBBTransportElement.DEFAULT_BLOCK_SIZE)); + String jingleXML = + "" + + "" + + "" + + "" + + ""; + String xml = getIQXML(romeo, juliet, transportAccept.getStanzaId(), jingleXML); + assertXMLEqual(xml, transportAccept.toXML().toString()); + assertEquals(JingleAction.transport_accept, transportAccept.getAction()); + assertEquals("transAcc", transportAccept.getSid()); + } + + @Test + public void createTransportRejectTest() { + //TODO: Find example + } + + @Test + public void createTransportReplaceTest() throws IOException, SAXException { + JingleElement transportReplace = JingleElement.createTransportReplace(juliet, romeo, "transAcc", JingleContentElement.Creator.initiator, "cname", new JingleIBBTransportElement("transid", JingleIBBTransportElement.DEFAULT_BLOCK_SIZE)); + String jingleXML = + "" + + "" + + "" + + "" + + ""; + String xml = getIQXML(romeo, juliet, transportReplace.getStanzaId(), jingleXML); + assertXMLEqual(xml, transportReplace.toXML().toString()); + assertEquals(JingleAction.transport_replace, transportReplace.getAction()); + assertEquals("transAcc", transportReplace.getSid()); + } + + @Test + public void createErrorMalformedRequestTest() throws Exception { + JingleElement j = defaultJingle(romeo, "error123"); + IQ error = JingleElement.createJingleErrorMalformedRequest(j); + String xml = + "" + + "" + + "" + + "" + + ""; + assertXMLEqual(xml, error.toXML().toString()); + } + + @Test + public void createErrorTieBreakTest() throws IOException, SAXException { + JingleElement j = defaultJingle(romeo, "thisistie"); + IQ error = JingleElement.createJingleErrorTieBreak(j); + String xml = + "" + + "" + + "" + + "" + + "" + + ""; + assertXMLEqual(xml, error.toXML().toString()); + } + + @Test + public void createErrorUnknownSessionTest() throws IOException, SAXException { + JingleElement j = defaultJingle(romeo, "youknownothingjohnsnow"); + IQ error = JingleElement.createJingleErrorUnknownSession(j); + String xml = + "" + + "" + + "" + + "" + + "" + + ""; + assertXMLEqual(xml, error.toXML().toString()); + } + + @Test + public void createErrorUnknownInitiatorTest() throws IOException, SAXException { + JingleElement j = defaultJingle(romeo, "iamyourfather"); + IQ error = JingleElement.createJingleErrorUnknownInitiator(j); + String xml = + "" + + "" + + "" + + "" + + ""; + assertXMLEqual(xml, error.toXML().toString()); + } + + @Test + public void createErrorOutOfOrderTest() throws IOException, SAXException { + JingleElement j = defaultJingle(romeo, "yourfatheriam"); + IQ error = JingleElement.createJingleErrorOutOfOrder(j); + String xml = + "" + + //"" + + "" + //TODO: Why? + "" + + "" + + "" + + ""; + assertXMLEqual(xml, error.toXML().toString()); + } + + @Test + public void createErrorUnsupportedInfoTest() throws IOException, SAXException { + JingleElement j = defaultJingle(romeo, "thisstatementiswrong"); + IQ error = JingleElement.createJingleErrorUnsupportedInfo(j); + String xml = + "" + + "" + + "" + + "" + + "" + + ""; + assertXMLEqual(xml, error.toXML().toString()); + } + + public static String getIQXML(FullJid from, FullJid to, String stanzaId, String jingleXML) { + return "" + + jingleXML + + ""; + } + + private JingleElement defaultJingle(FullJid recipient, String sessionId) { + return JingleElement.createSessionPing(recipient, sessionId); } } diff --git a/smack-extensions/src/test/java/org/jivesoftware/smackx/jingle/JingleUtilTest.java b/smack-extensions/src/test/java/org/jivesoftware/smackx/jingle/JingleUtilTest.java deleted file mode 100644 index d37812da2..000000000 --- a/smack-extensions/src/test/java/org/jivesoftware/smackx/jingle/JingleUtilTest.java +++ /dev/null @@ -1,452 +0,0 @@ -/** - * - * 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; - -import static junit.framework.TestCase.assertEquals; -import static junit.framework.TestCase.assertNotNull; -import static org.custommonkey.xmlunit.XMLAssert.assertXMLEqual; - -import java.io.IOException; - -import org.jivesoftware.smack.DummyConnection; -import org.jivesoftware.smack.XMPPConnection; -import org.jivesoftware.smack.packet.IQ; -import org.jivesoftware.smack.test.util.SmackTestSuite; -import org.jivesoftware.smack.test.util.TestUtils; -import org.jivesoftware.smackx.jingle.element.JingleAction; -import org.jivesoftware.smackx.jingle.element.JingleContentElement; -import org.jivesoftware.smackx.jingle.element.JingleElement; -import org.jivesoftware.smackx.jingle.element.JingleReasonElement; -import org.jivesoftware.smackx.jingle.provider.JingleProvider; -import org.jivesoftware.smackx.jingle.transport.jingle_ibb.element.JingleIBBTransportElement; - -import org.junit.Before; -import org.junit.Test; -import org.jxmpp.jid.FullJid; -import org.jxmpp.jid.impl.JidCreate; -import org.jxmpp.stringprep.XmppStringprepException; -import org.xml.sax.SAXException; - -/** - * Test the JingleUtil class. - */ -public class JingleUtilTest extends SmackTestSuite { - - private FullJid romeo; - private FullJid juliet; - - @Before - public void setup() throws XmppStringprepException { - - XMPPConnection connection = new DummyConnection( - DummyConnection.getDummyConfigurationBuilder() - .setUsernameAndPassword("romeo@montague.lit", - "iluvJulibabe13").build()); - JingleManager jm = JingleManager.getInstanceFor(connection); - romeo = connection.getUser().asFullJidOrThrow(); - juliet = JidCreate.fullFrom("juliet@capulet.lit/balcony"); - } - - @Test - public void createSessionTerminateDeclineTest() throws Exception { - JingleElement terminate = JingleElement.createSessionTerminate(juliet, "thisismadness", JingleReasonElement.Reason.decline); - String jingleXML = - "" + - "" + - "" + - "" + - ""; - String xml = getIQXML(romeo, juliet, terminate.getStanzaId(), jingleXML); - assertXMLEqual(xml, terminate.toXML().toString()); - JingleElement jingle = new JingleProvider().parse(TestUtils.getParser(jingleXML)); - assertNotNull(jingle); - assertEquals(jingle.getAction(), JingleAction.session_terminate); - assertEquals(jingle.getReason().asEnum(), JingleReasonElement.Reason.decline); - } - - @Test - public void createSessionTerminateSuccessTest() throws Exception { - JingleElement success = JingleElement.createSessionTerminate(juliet, "thisissparta", JingleReasonElement.Reason.success); - String jingleXML = - "" + - "" + - "" + - "" + - ""; - String xml = getIQXML(romeo, juliet, success.getStanzaId(), jingleXML); - assertXMLEqual(xml, success.toXML().toString()); - JingleElement jingle = new JingleProvider().parse(TestUtils.getParser(jingleXML)); - assertNotNull(jingle); - assertEquals(jingle.getAction(), JingleAction.session_terminate); - assertEquals(jingle.getReason().asEnum(), JingleReasonElement.Reason.success); - } - - @Test - public void createSessionTerminateBusyTest() throws Exception { - JingleElement busy = JingleElement.createSessionTerminate(juliet, "thisispatrick", JingleReasonElement.Reason.busy); - String jingleXML = - "" + - "" + - "" + - "" + - ""; - String xml = getIQXML(romeo, juliet, busy.getStanzaId(), jingleXML); - assertXMLEqual(xml, busy.toXML().toString()); - JingleElement jingle = new JingleProvider().parse(TestUtils.getParser(jingleXML)); - assertNotNull(jingle); - assertEquals(jingle.getAction(), JingleAction.session_terminate); - assertEquals(jingle.getReason().asEnum(), JingleReasonElement.Reason.busy); - } - - @Test - public void createSessionTerminateAlternativeSessionTest() throws Exception { - JingleElement busy = JingleElement.createSessionTerminate(juliet, "thisistherhythm", JingleReasonElement.AlternativeSession("ofthenight")); - String jingleXML = - "" + - "" + - "" + - "ofthenight" + - "" + - "" + - ""; - String xml = getIQXML(romeo, juliet, busy.getStanzaId(), jingleXML); - assertXMLEqual(xml, busy.toXML().toString()); - JingleElement jingle = new JingleProvider().parse(TestUtils.getParser(jingleXML)); - assertNotNull(jingle); - assertEquals(jingle.getAction(), JingleAction.session_terminate); - assertEquals(jingle.getReason().asEnum(), JingleReasonElement.Reason.alternative_session); - JingleReasonElement.AlternativeSession alt = (JingleReasonElement.AlternativeSession) jingle.getReason(); - assertEquals("ofthenight", alt.getAlternativeSessionId()); - } - - @Test - public void createSessionTerminateCancelTest() throws Exception { - JingleElement cancel = JingleElement.createSessionTerminate(juliet, "thisistheend", JingleReasonElement.Reason.cancel); - String jingleXML = - "" + - "" + - "" + - "" + - ""; - String xml = getIQXML(romeo, juliet, cancel.getStanzaId(), jingleXML); - assertXMLEqual(xml, cancel.toXML().toString()); - JingleElement jingle = new JingleProvider().parse(TestUtils.getParser(jingleXML)); - assertNotNull(jingle); - assertEquals(jingle.getAction(), JingleAction.session_terminate); - assertEquals(jingle.getReason().asEnum(), JingleReasonElement.Reason.cancel); - } - - @Test - public void createSessionTerminateUnsupportedTransportsTest() throws Exception { - JingleElement unsupportedTransports = JingleElement.createSessionTerminate(juliet, "thisisus", JingleReasonElement.Reason.unsupported_transports); - String jingleXML = - "" + - "" + - "" + - "" + - ""; - String xml = getIQXML(romeo, juliet, unsupportedTransports.getStanzaId(), jingleXML); - assertXMLEqual(xml, unsupportedTransports.toXML().toString()); - JingleElement jingle = new JingleProvider().parse(TestUtils.getParser(jingleXML)); - assertNotNull(jingle); - assertEquals(jingle.getAction(), JingleAction.session_terminate); - assertEquals(jingle.getReason().asEnum(), JingleReasonElement.Reason.unsupported_transports); - } - - @Test - public void createSessionTerminateUnsupportedApplicationsTest() throws Exception { - JingleElement unsupportedApplications = JingleElement.createSessionTerminate(juliet, "thisiswar", JingleReasonElement.Reason.unsupported_applications); - String jingleXML = - "" + - "" + - "" + - "" + - ""; - String xml = getIQXML(romeo, juliet, unsupportedApplications.getStanzaId(), jingleXML); - assertXMLEqual(xml, unsupportedApplications.toXML().toString()); - JingleElement jingle = new JingleProvider().parse(TestUtils.getParser(jingleXML)); - assertNotNull(jingle); - assertEquals(jingle.getAction(), JingleAction.session_terminate); - assertEquals(jingle.getReason().asEnum(), JingleReasonElement.Reason.unsupported_applications); - } - - @Test - public void createSessionTerminateFailedTransportTest() throws IOException, SAXException { - JingleElement failedTransport = JingleElement.createSessionTerminate(juliet, "derailed", JingleReasonElement.Reason.failed_transport); - String jingleXML = - "" + - "" + - "" + - "" + - ""; - String xml = getIQXML(romeo, juliet, failedTransport.getStanzaId(), jingleXML); - assertXMLEqual(xml, failedTransport.toXML().toString()); - assertEquals(JingleAction.session_terminate, failedTransport.getAction()); - assertEquals(JingleReasonElement.Reason.failed_transport, failedTransport.getReason().asEnum()); - } - - @Test - public void createSessionTerminateFailedApplicationTest() throws IOException, SAXException { - JingleElement failedApplication = JingleElement.createSessionTerminate(juliet, "crashed", JingleReasonElement.Reason.failed_application); - String jingleXML = - "" + - "" + - "" + - "" + - ""; - String xml = getIQXML(romeo, juliet, failedApplication.getStanzaId(), jingleXML); - assertXMLEqual(xml, failedApplication.toXML().toString()); - assertEquals(JingleAction.session_terminate, failedApplication.getAction()); - assertEquals(JingleReasonElement.Reason.failed_application, failedApplication.getReason().asEnum()); - } - - @Test - public void createSessionPingTest() throws Exception { - JingleElement ping = JingleElement.createSessionPing(juliet, "thisisit"); - String jingleXML = - ""; - String xml = getIQXML(romeo, juliet, ping.getStanzaId(), jingleXML); - assertXMLEqual(xml, ping.toXML().toString()); - JingleElement jingle = new JingleProvider().parse(TestUtils.getParser(jingleXML)); - assertNotNull(jingle); - assertEquals(JingleAction.session_info, jingle.getAction()); - } - - @Test - public void createSessionTerminateContentCancelTest() throws Exception { - JingleElement cancel = JingleElement.createSessionTerminateContentCancel(juliet, "thisismumbo#5", JingleContentElement.Creator.initiator, "content123"); - String jingleXML = - "" + - "" + - "" + - "" + - "" + - ""; - String xml = getIQXML(romeo, juliet, cancel.getStanzaId(), jingleXML); - assertXMLEqual(xml, cancel.toXML().toString()); - JingleElement jingle = new JingleProvider().parse(TestUtils.getParser(jingleXML)); - assertNotNull(jingle); - assertEquals(JingleAction.session_terminate, jingle.getAction()); - assertEquals(JingleReasonElement.Reason.cancel, jingle.getReason().asEnum()); - assertEquals("thisismumbo#5", jingle.getSid()); - JingleContentElement content = jingle.getContents().get(0); - assertNotNull(content); - assertEquals("content123", content.getName()); - assertEquals(JingleContentElement.Creator.initiator, content.getCreator()); - } - - @Test - public void createSessionTerminateIncompatibleParameters() throws IOException, SAXException { - JingleElement terminate = JingleElement.createSessionTerminate(juliet, "incompatibleSID", JingleReasonElement.Reason.incompatible_parameters); - String jingleXML = - "" + - "" + - "" + - "" + - ""; - String xml = getIQXML(romeo, juliet, terminate.getStanzaId(), jingleXML); - assertXMLEqual(xml, terminate.toXML().toString()); - assertEquals(JingleReasonElement.Reason.incompatible_parameters, terminate.getReason().asEnum()); - assertEquals("incompatibleSID", terminate.getSid()); - } - - @Test - public void createTransportAcceptTest() throws IOException, SAXException { - JingleElement transportAccept = JingleElement.createTransportAccept(juliet, romeo, "transAcc", JingleContentElement.Creator.initiator, "cname", new JingleIBBTransportElement("transid", JingleIBBTransportElement.DEFAULT_BLOCK_SIZE)); - String jingleXML = - "" + - "" + - "" + - "" + - ""; - String xml = getIQXML(romeo, juliet, transportAccept.getStanzaId(), jingleXML); - assertXMLEqual(xml, transportAccept.toXML().toString()); - assertEquals(JingleAction.transport_accept, transportAccept.getAction()); - assertEquals("transAcc", transportAccept.getSid()); - } - - @Test - public void createTransportRejectTest() { - //TODO: Find example - } - - @Test - public void createTransportReplaceTest() throws IOException, SAXException { - JingleElement transportReplace = JingleElement.createTransportReplace(juliet, romeo, "transAcc", JingleContentElement.Creator.initiator, "cname", new JingleIBBTransportElement("transid", JingleIBBTransportElement.DEFAULT_BLOCK_SIZE)); - String jingleXML = - "" + - "" + - "" + - "" + - ""; - String xml = getIQXML(romeo, juliet, transportReplace.getStanzaId(), jingleXML); - assertXMLEqual(xml, transportReplace.toXML().toString()); - assertEquals(JingleAction.transport_replace, transportReplace.getAction()); - assertEquals("transAcc", transportReplace.getSid()); - } - - @Test - public void createErrorMalformedRequestTest() throws Exception { - JingleElement j = defaultJingle(romeo, "error123"); - IQ error = JingleElement.createJingleErrorMalformedRequest(j); - String xml = - "" + - "" + - "" + - "" + - ""; - assertXMLEqual(xml, error.toXML().toString()); - } - - @Test - public void createErrorTieBreakTest() throws IOException, SAXException { - JingleElement j = defaultJingle(romeo, "thisistie"); - IQ error = JingleElement.createJingleErrorTieBreak(j); - String xml = - "" + - "" + - "" + - "" + - "" + - ""; - assertXMLEqual(xml, error.toXML().toString()); - } - - @Test - public void createErrorUnknownSessionTest() throws IOException, SAXException { - JingleElement j = defaultJingle(romeo, "youknownothingjohnsnow"); - IQ error = JingleElement.createJingleErrorUnknownSession(j); - String xml = - "" + - "" + - "" + - "" + - "" + - ""; - assertXMLEqual(xml, error.toXML().toString()); - } - - @Test - public void createErrorUnknownInitiatorTest() throws IOException, SAXException { - JingleElement j = defaultJingle(romeo, "iamyourfather"); - IQ error = JingleElement.createJingleErrorUnknownInitiator(j); - String xml = - "" + - "" + - "" + - "" + - ""; - assertXMLEqual(xml, error.toXML().toString()); - } - - @Test - public void createErrorOutOfOrderTest() throws IOException, SAXException { - JingleElement j = defaultJingle(romeo, "yourfatheriam"); - IQ error = JingleElement.createJingleErrorOutOfOrder(j); - String xml = - "" + - //"" + - "" + //TODO: Why? - "" + - "" + - "" + - ""; - assertXMLEqual(xml, error.toXML().toString()); - } - - @Test - public void createErrorUnsupportedInfoTest() throws IOException, SAXException { - JingleElement j = defaultJingle(romeo, "thisstatementiswrong"); - IQ error = JingleElement.createJingleErrorUnsupportedInfo(j); - String xml = - "" + - "" + - "" + - "" + - "" + - ""; - assertXMLEqual(xml, error.toXML().toString()); - } - - public static String getIQXML(FullJid from, FullJid to, String stanzaId, String jingleXML) { - return "" + - jingleXML + - ""; - } - - private JingleElement defaultJingle(FullJid recipient, String sessionId) { - return JingleElement.createSessionPing(recipient, sessionId); - } -} diff --git a/smack-extensions/src/test/java/org/jivesoftware/smackx/jingle/transport/jingle_ibb/JingleIBBTransportTest.java b/smack-extensions/src/test/java/org/jivesoftware/smackx/jingle/transport/jingle_ibb/JingleIBBTransportTest.java index 8ce4c1130..7c93820cb 100644 --- a/smack-extensions/src/test/java/org/jivesoftware/smackx/jingle/transport/jingle_ibb/JingleIBBTransportTest.java +++ b/smack-extensions/src/test/java/org/jivesoftware/smackx/jingle/transport/jingle_ibb/JingleIBBTransportTest.java @@ -17,16 +17,13 @@ package org.jivesoftware.smackx.jingle.transport.jingle_ibb; import static junit.framework.TestCase.assertEquals; -import static junit.framework.TestCase.assertFalse; -import static junit.framework.TestCase.assertNotSame; import static junit.framework.TestCase.assertTrue; import org.jivesoftware.smack.test.util.SmackTestSuite; import org.jivesoftware.smack.test.util.TestUtils; import org.jivesoftware.smack.util.StringUtils; - -import org.jivesoftware.smackx.jingle.transports.jingle_ibb.element.JingleIBBTransport; -import org.jivesoftware.smackx.jingle.transports.jingle_ibb.provider.JingleIBBTransportProvider; +import org.jivesoftware.smackx.jingle.transport.jingle_ibb.element.JingleIBBTransportElement; +import org.jivesoftware.smackx.jingle.transport.jingle_ibb.provider.JingleIBBTransportProvider; import org.junit.Test; @@ -42,17 +39,17 @@ public class JingleIBBTransportTest extends SmackTestSuite { String xml = ""; - JingleIBBTransport transport = new JingleIBBTransport(size, sid); - assertEquals(xml, transport.toXML().toString()); - assertEquals(size, transport.getBlockSize()); - assertEquals(sid, transport.getSessionId()); + JingleIBBTransport transport = new JingleIBBTransport(sid, size); + assertEquals(xml, transport.getElement().toXML().toString()); + assertEquals(size, (short) transport.getBlockSize()); + assertEquals(sid, transport.getSid()); - JingleIBBTransport parsed = new JingleIBBTransportProvider() + JingleIBBTransportElement parsed = new JingleIBBTransportProvider() .parse(TestUtils.getParser(xml)); - assertEquals(transport, parsed); - assertTrue(transport.equals(parsed)); + assertEquals(transport.getElement(), parsed); + assertTrue(transport.getElement().equals(parsed)); assertEquals(xml, parsed.toXML().toString()); - + /* JingleIBBTransport transport1 = new JingleIBBTransport((short) 1024); assertEquals((short) 1024, transport1.getBlockSize()); assertNotSame(transport, transport1); @@ -72,5 +69,6 @@ public class JingleIBBTransportTest extends SmackTestSuite { JingleIBBTransport transport4 = new JingleIBBTransport("session-id"); assertEquals(JingleIBBTransport.DEFAULT_BLOCK_SIZE, transport4.getBlockSize()); + */ } } diff --git a/smack-extensions/src/test/java/org/jivesoftware/smackx/jingle/transport/jingle_s5b/JingleS5BTransportTest.java b/smack-extensions/src/test/java/org/jivesoftware/smackx/jingle/transport/jingle_s5b/JingleS5BTransportTest.java index e1d6c90d3..3170f554e 100644 --- a/smack-extensions/src/test/java/org/jivesoftware/smackx/jingle/transport/jingle_s5b/JingleS5BTransportTest.java +++ b/smack-extensions/src/test/java/org/jivesoftware/smackx/jingle/transport/jingle_s5b/JingleS5BTransportTest.java @@ -77,7 +77,7 @@ public class JingleS5BTransportTest extends SmackTestSuite { ""; JingleS5BTransportElement transport = new JingleS5BTransportProvider().parse(TestUtils.getParser(xml)); assertEquals("972b7bf47291ca609517f67f86b5081086052dad", transport.getDestinationAddress()); - assertEquals("vj3hs98y", transport.getStreamId()); + assertEquals("vj3hs98y", transport.getSid()); assertEquals(Bytestream.Mode.tcp, transport.getMode()); assertEquals(3, transport.getCandidates().size()); @@ -126,7 +126,7 @@ public class JingleS5BTransportTest extends SmackTestSuite { .parse(TestUtils.getParser(candidateError)); assertNull(candidateErrorTransport.getDestinationAddress()); assertNotNull(candidateErrorTransport.getInfo()); - assertEquals("vj3hs98y", candidateErrorTransport.getStreamId()); + assertEquals("vj3hs98y", candidateErrorTransport.getSid()); assertEquals(JingleS5BTransportInfoElement.CandidateError(), candidateErrorTransport.getInfo()); assertEquals(candidateError, candidateErrorTransport.toXML().toString()); @@ -140,7 +140,7 @@ public class JingleS5BTransportTest extends SmackTestSuite { assertNull(proxyErrorTransport.getDestinationAddress()); assertNotNull(proxyErrorTransport.getInfo()); assertNotNull(candidateErrorTransport.getInfo()); - assertEquals("vj3hs98y", proxyErrorTransport.getStreamId()); + assertEquals("vj3hs98y", proxyErrorTransport.getSid()); assertEquals(JingleS5BTransportInfoElement.ProxyError(), proxyErrorTransport.getInfo()); assertEquals(proxyError, proxyErrorTransport.toXML().toString()); diff --git a/smack-integration-test/src/main/java/org/jivesoftware/smackx/jingle_filetransfer/FileTransferTest.java b/smack-integration-test/src/main/java/org/jivesoftware/smackx/jft/FileTransferTest.java similarity index 84% rename from smack-integration-test/src/main/java/org/jivesoftware/smackx/jingle_filetransfer/FileTransferTest.java rename to smack-integration-test/src/main/java/org/jivesoftware/smackx/jft/FileTransferTest.java index ab59e68eb..32c194444 100644 --- a/smack-integration-test/src/main/java/org/jivesoftware/smackx/jingle_filetransfer/FileTransferTest.java +++ b/smack-integration-test/src/main/java/org/jivesoftware/smackx/jft/FileTransferTest.java @@ -14,32 +14,17 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.jivesoftware.smackx.jingle_filetransfer; - -import static junit.framework.TestCase.fail; -import static org.junit.Assert.assertArrayEquals; +package org.jivesoftware.smackx.jft; import java.io.File; -import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; -import java.util.logging.Level; -import org.jivesoftware.smack.SmackException; -import org.jivesoftware.smack.XMPPException; import org.jivesoftware.smackx.bytestreams.socks5.Socks5Proxy; -import org.jivesoftware.smackx.jingle.element.JingleElement; -import org.jivesoftware.smackx.jingle.element.JingleReasonElement; -import org.jivesoftware.smackx.jingle_filetransfer.callback.IncomingFileOfferCallback; -import org.jivesoftware.smackx.jingle_filetransfer.handler.FileTransferHandler; -import org.jivesoftware.smackx.jingle_filetransfer.listener.JingleFileTransferOfferListener; import org.igniterealtime.smack.inttest.AbstractSmackIntegrationTest; -import org.igniterealtime.smack.inttest.SmackIntegrationTest; import org.igniterealtime.smack.inttest.SmackIntegrationTestEnvironment; -import org.igniterealtime.smack.inttest.util.SimpleResultSyncPoint; import org.junit.AfterClass; -import org.jxmpp.jid.FullJid; /** * Created by vanitas on 29.06.17. @@ -62,6 +47,7 @@ public class FileTransferTest extends AbstractSmackIntegrationTest { super(environment); } + /* @SmackIntegrationTest public void basicFileTransferTest() { final SimpleResultSyncPoint resultSyncPoint1 = new SimpleResultSyncPoint(); @@ -130,7 +116,8 @@ public class FileTransferTest extends AbstractSmackIntegrationTest { LOGGER.log(Level.INFO, "SUCCESSFULLY SENT AND RECEIVED"); } - + */ + private File prepareNewTestFile(String name) { File testFile = new File(tempDir, name); try { diff --git a/smack-integration-test/src/main/java/org/jivesoftware/smackx/jingle_filetransfer/package-info.java b/smack-integration-test/src/main/java/org/jivesoftware/smackx/jft/package-info.java similarity index 92% rename from smack-integration-test/src/main/java/org/jivesoftware/smackx/jingle_filetransfer/package-info.java rename to smack-integration-test/src/main/java/org/jivesoftware/smackx/jft/package-info.java index e65e6d846..3e5cc80f9 100644 --- a/smack-integration-test/src/main/java/org/jivesoftware/smackx/jingle_filetransfer/package-info.java +++ b/smack-integration-test/src/main/java/org/jivesoftware/smackx/jft/package-info.java @@ -18,4 +18,4 @@ /** * TODO describe me. */ -package org.jivesoftware.smackx.jingle_filetransfer; +package org.jivesoftware.smackx.jft;