mirror of
https://github.com/vanitasvitae/Smack.git
synced 2025-09-11 01:59:38 +02:00
Remove errors
This commit is contained in:
parent
3f6df8e6c7
commit
3ed3f53189
58 changed files with 849 additions and 2028 deletions
|
@ -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.<JingleContentDescriptionChildElement>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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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<JetSecurityEle
|
|||
|
||||
@Override
|
||||
public JetSecurityElement parse(XmlPullParser parser, int initialDepth) throws Exception {
|
||||
String name = parser.getAttributeValue(JetManager.NAMESPACE, JetSecurityElement.ATTR_NAME);
|
||||
String type = parser.getAttributeValue(JetManager.NAMESPACE, JetSecurityElement.ATTR_TYPE);
|
||||
String name = parser.getAttributeValue(JetSecurity.NAMESPACE, JetSecurityElement.ATTR_NAME);
|
||||
String type = parser.getAttributeValue(JetSecurity.NAMESPACE, JetSecurityElement.ATTR_TYPE);
|
||||
ExtensionElement child;
|
||||
|
||||
Objects.requireNonNull(type);
|
||||
|
|
|
@ -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;
|
||||
|
||||
import java.io.File;
|
||||
|
@ -11,7 +27,7 @@ import org.jivesoftware.smack.XMPPConnection;
|
|||
import org.jivesoftware.smackx.disco.ServiceDiscoveryManager;
|
||||
import org.jivesoftware.smackx.jft.controller.OutgoingFileOfferController;
|
||||
import org.jivesoftware.smackx.jft.controller.OutgoingFileRequestController;
|
||||
import org.jivesoftware.smackx.jft.internal.AbstractJingleFileTransfer;
|
||||
import org.jivesoftware.smackx.jft.internal.JingleFileTransfer;
|
||||
import org.jivesoftware.smackx.jft.internal.JingleIncomingFileOffer;
|
||||
import org.jivesoftware.smackx.jft.internal.JingleIncomingFileRequest;
|
||||
import org.jivesoftware.smackx.jft.internal.JingleOutgoingFileOffer;
|
||||
|
@ -120,10 +136,10 @@ public final class JingleFileTransferManager extends Manager implements JingleDe
|
|||
|
||||
@Override
|
||||
public String getNamespace() {
|
||||
return AbstractJingleFileTransfer.NAMESPACE;
|
||||
return JingleFileTransfer.NAMESPACE;
|
||||
}
|
||||
|
||||
private void notifyTransfer(AbstractJingleFileTransfer transfer) {
|
||||
private void notifyTransfer(JingleFileTransfer transfer) {
|
||||
if (transfer.isOffer()) {
|
||||
notifyIncomingFileOfferListeners((JingleIncomingFileOffer) transfer);
|
||||
} else {
|
||||
|
@ -134,11 +150,11 @@ public final class JingleFileTransferManager extends Manager implements JingleDe
|
|||
@Override
|
||||
public void notifySessionInitiate(JingleSession session) {
|
||||
JingleContent content = session.getSoleContentOrThrow();
|
||||
notifyTransfer((AbstractJingleFileTransfer) content.getDescription());
|
||||
notifyTransfer((JingleFileTransfer) content.getDescription());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void notifyContentAdd(JingleContent content) {
|
||||
notifyTransfer((AbstractJingleFileTransfer) content.getDescription());
|
||||
notifyTransfer((JingleFileTransfer) content.getDescription());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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.callback;
|
||||
|
||||
import java.io.File;
|
||||
|
|
|
@ -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.controller;
|
||||
|
||||
/**
|
||||
|
|
|
@ -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.controller;
|
||||
|
||||
/**
|
||||
|
|
|
@ -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.controller;
|
||||
|
||||
import org.jivesoftware.smackx.jft.listener.ProgressListener;
|
||||
|
@ -11,4 +27,5 @@ public interface JingleFileTransferController extends JingleDescriptionControlle
|
|||
void addProgressListener(ProgressListener listener);
|
||||
|
||||
void removeProgressListener(ProgressListener listener);
|
||||
|
||||
}
|
||||
|
|
|
@ -1,7 +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.controller;
|
||||
|
||||
/**
|
||||
* Created by vanitas on 27.07.17.
|
||||
*/
|
||||
public interface OutgoingFileOfferController extends JingleFileTransferController {
|
||||
|
||||
}
|
||||
|
|
|
@ -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.controller;
|
||||
|
||||
/**
|
||||
|
|
|
@ -19,6 +19,7 @@ package org.jivesoftware.smackx.jft.element;
|
|||
import org.jivesoftware.smack.packet.ExtensionElement;
|
||||
import org.jivesoftware.smack.util.Objects;
|
||||
import org.jivesoftware.smack.util.XmlStringBuilder;
|
||||
import org.jivesoftware.smackx.jft.internal.JingleFileTransfer;
|
||||
import org.jivesoftware.smackx.jingle.element.JingleContentElement;
|
||||
|
||||
/**
|
||||
|
@ -58,6 +59,6 @@ public class ChecksumElement implements ExtensionElement {
|
|||
|
||||
@Override
|
||||
public String getNamespace() {
|
||||
return JingleFileTransferElement.NAMESPACE_V5;
|
||||
return JingleFileTransfer.NAMESPACE;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,7 +19,7 @@ package org.jivesoftware.smackx.jft.element;
|
|||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import org.jivesoftware.smackx.jft.internal.AbstractJingleFileTransfer;
|
||||
import org.jivesoftware.smackx.jft.internal.JingleFileTransfer;
|
||||
import org.jivesoftware.smackx.jingle.element.JingleContentDescriptionElement;
|
||||
import org.jivesoftware.smackx.jingle.element.JingleContentDescriptionChildElement;
|
||||
|
||||
|
@ -38,6 +38,6 @@ public class JingleFileTransferElement extends JingleContentDescriptionElement {
|
|||
|
||||
@Override
|
||||
public String getNamespace() {
|
||||
return AbstractJingleFileTransfer.NAMESPACE;
|
||||
return JingleFileTransfer.NAMESPACE;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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.jft.element.JingleFileTransferElement;
|
||||
|
@ -6,7 +22,7 @@ import org.jivesoftware.smackx.jft.internal.file.AbstractJingleFileTransferFile;
|
|||
/**
|
||||
* Created by vanitas on 22.07.17.
|
||||
*/
|
||||
public abstract class AbstractJingleFileOffer<D extends AbstractJingleFileTransferFile> extends AbstractJingleFileTransfer {
|
||||
public abstract class AbstractJingleFileOffer<D extends AbstractJingleFileTransferFile> extends JingleFileTransfer {
|
||||
|
||||
protected D jingleFile;
|
||||
|
||||
|
|
|
@ -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 {
|
||||
|
||||
}
|
||||
|
|
|
@ -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<JingleFileTransferElement> implements JingleFileTransferController {
|
||||
public abstract class JingleFileTransfer extends JingleDescription<JingleFileTransferElement> implements JingleFileTransferController {
|
||||
|
||||
public static final String NAMESPACE_V5 = "urn:xmpp:jingle:apps:file-transfer:5";
|
||||
public static final String NAMESPACE = NAMESPACE_V5;
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
||||
/**
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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() {
|
||||
|
||||
}
|
||||
}
|
|
@ -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<XMPPConnection, JingleFileTransferManagerAlt> INSTANCES = new WeakHashMap<>();
|
||||
private final ArrayList<JingleFileTransferOfferListener> 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.<JingleContentDescriptionChildElement>singletonList(fb.build()));
|
||||
}
|
||||
}
|
|
@ -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<EndedListener> endedListeners = new ArrayList<>();
|
||||
protected final ArrayList<StartedListener> 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;
|
||||
}
|
||||
}
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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);
|
||||
}
|
|
@ -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);
|
||||
}
|
|
@ -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 <a href="https://xmpp.org/extensions/xep-0234.html">XEP-0234: Jingle File Transfer</a>.
|
||||
* Callbacks.
|
||||
*/
|
||||
package org.jivesoftware.smackx.jingle_filetransfer.callback;
|
|
@ -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();
|
||||
}
|
||||
}
|
|
@ -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 <a href="https://xmpp.org/extensions/xep-0234.html">XEP-0234: Jingle File Transfer</a>.
|
||||
* Handlers.
|
||||
*/
|
||||
package org.jivesoftware.smackx.jingle_filetransfer.handler;
|
|
@ -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);
|
||||
}
|
|
@ -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 <a href="https://xmpp.org/extensions/xep-0234.html">XEP-0234: Jingle File Transfer</a>.
|
||||
* Listeners.
|
||||
*/
|
||||
package org.jivesoftware.smackx.jingle_filetransfer.listener;
|
|
@ -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 <a href="https://xmpp.org/extensions/xep-0234.html">XEP-0234: Jingle File Transfer</a>.
|
||||
*/
|
||||
package org.jivesoftware.smackx.jingle_filetransfer;
|
|
@ -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;
|
||||
|
|
@ -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.<JingleContentDescriptionChildElement>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 =
|
||||
"<transport xmlns='urn:xmpp:jingle:transports:ibb:1' " +
|
||||
"block-size='4096' " +
|
||||
"sid='transid'/>";
|
||||
assertXMLEqual(transportXML, transport.toXML().toString());
|
||||
|
||||
String descriptionXML =
|
||||
"<description xmlns='urn:xmpp:jingle:apps:file-transfer:5'>" +
|
||||
"<file>" +
|
||||
"<date>" + XmppDateTime.formatXEP0082Date(date) + "</date>" +
|
||||
"<desc>desc</desc>" +
|
||||
"<media-type>application/octet-stream</media-type>" +
|
||||
"<name>name</name>" +
|
||||
//"<range/>" + TODO: insert empty element when null?
|
||||
"<size>1337</size>" +
|
||||
"<hash xmlns='urn:xmpp:hashes:2' " +
|
||||
"algo='sha-256'>f4OxZX/x/FO5LcGBSKHWXfwtSx+j1ncoSt3SABJtkGk=</hash>" +
|
||||
"</file>" +
|
||||
"</description>";
|
||||
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 = "<content creator='initiator' name='content' senders='initiator'>" +
|
||||
descriptionXML +
|
||||
transportXML +
|
||||
"</content>";
|
||||
assertXMLEqual(contentXML, content.toXML().toString());
|
||||
|
||||
String initiateXML =
|
||||
"<jingle xmlns='urn:xmpp:jingle:1' " +
|
||||
"action='session-initiate' " +
|
||||
"initiator='" + romeo + "' " +
|
||||
"sid='letsstart'>" +
|
||||
contentXML +
|
||||
"</jingle>";
|
||||
String xml = JingleUtilTest.getIQXML(romeo, juliet, initiate.getStanzaId(), initiateXML);
|
||||
assertXMLEqual(xml, initiate.toXML().toString());
|
||||
|
||||
String acceptXML =
|
||||
"<jingle xmlns='urn:xmpp:jingle:1' " +
|
||||
"action='session-accept' " +
|
||||
"responder='" + romeo + "' " +
|
||||
"sid='acceptID'>" +
|
||||
contentXML +
|
||||
"</jingle>";
|
||||
xml = JingleUtilTest.getIQXML(romeo, juliet, accept.getStanzaId(), acceptXML);
|
||||
assertXMLEqual(xml, accept.toXML().toString());
|
||||
|
||||
String fileOfferXML =
|
||||
"<jingle xmlns='urn:xmpp:jingle:1' " +
|
||||
"action='session-initiate' " +
|
||||
"initiator='" + romeo + "' " +
|
||||
"sid='fileOffer'>" +
|
||||
contentXML +
|
||||
"</jingle>";
|
||||
xml = JingleUtilTest.getIQXML(romeo, juliet, fileOffer.getStanzaId(), fileOfferXML);
|
||||
assertXMLEqual(xml, fileOffer.toXML().toString());
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue