mirror of
https://github.com/vanitasvitae/Smack.git
synced 2024-11-01 01:35:59 +01:00
Some refactoring
This commit is contained in:
parent
3915a71824
commit
980c324f27
50 changed files with 401 additions and 161 deletions
|
@ -4,7 +4,7 @@ import org.jivesoftware.smack.packet.ExtensionElement;
|
||||||
import org.jivesoftware.smackx.jet.element.JetSecurityElement;
|
import org.jivesoftware.smackx.jet.element.JetSecurityElement;
|
||||||
import org.jivesoftware.smackx.jingle.element.JingleContentSecurityInfoElement;
|
import org.jivesoftware.smackx.jingle.element.JingleContentSecurityInfoElement;
|
||||||
import org.jivesoftware.smackx.jingle.element.JingleElement;
|
import org.jivesoftware.smackx.jingle.element.JingleElement;
|
||||||
import org.jivesoftware.smackx.jingle.internal.JingleSecurity;
|
import org.jivesoftware.smackx.jingle.components.JingleSecurity;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by vanitas on 22.07.17.
|
* Created by vanitas on 22.07.17.
|
||||||
|
|
|
@ -1,26 +0,0 @@
|
||||||
package org.jivesoftware.smackx.jft;
|
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
|
|
||||||
import org.jivesoftware.smackx.jft.internal.JingleIncomingFileOffer;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Created by vanitas on 26.07.17.
|
|
||||||
*/
|
|
||||||
public class IncomingFileTransferCallback {
|
|
||||||
|
|
||||||
private JingleIncomingFileOffer offer;
|
|
||||||
|
|
||||||
public IncomingFileTransferCallback(JingleIncomingFileOffer offer) {
|
|
||||||
this.offer = offer;
|
|
||||||
}
|
|
||||||
|
|
||||||
public JingleIncomingFileOffer accept(File target) {
|
|
||||||
offer.accept(target);
|
|
||||||
return offer;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void decline() {
|
|
||||||
offer.decline();
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,9 +0,0 @@
|
||||||
package org.jivesoftware.smackx.jft;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Created by vanitas on 26.07.17.
|
|
||||||
*/
|
|
||||||
public interface IncomingFileTransferListener {
|
|
||||||
|
|
||||||
void onIncomingFileTransfer(IncomingFileTransferCallback callback);
|
|
||||||
}
|
|
|
@ -9,20 +9,26 @@ import java.util.WeakHashMap;
|
||||||
import org.jivesoftware.smack.Manager;
|
import org.jivesoftware.smack.Manager;
|
||||||
import org.jivesoftware.smack.XMPPConnection;
|
import org.jivesoftware.smack.XMPPConnection;
|
||||||
import org.jivesoftware.smackx.disco.ServiceDiscoveryManager;
|
import org.jivesoftware.smackx.disco.ServiceDiscoveryManager;
|
||||||
import org.jivesoftware.smackx.jft.internal.JingleFileTransfer;
|
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.JingleIncomingFileOffer;
|
import org.jivesoftware.smackx.jft.internal.JingleIncomingFileOffer;
|
||||||
|
import org.jivesoftware.smackx.jft.internal.JingleIncomingFileRequest;
|
||||||
import org.jivesoftware.smackx.jft.internal.JingleOutgoingFileOffer;
|
import org.jivesoftware.smackx.jft.internal.JingleOutgoingFileOffer;
|
||||||
|
import org.jivesoftware.smackx.jft.internal.JingleOutgoingFileRequest;
|
||||||
|
import org.jivesoftware.smackx.jft.listener.IncomingFileOfferListener;
|
||||||
|
import org.jivesoftware.smackx.jft.listener.IncomingFileRequestListener;
|
||||||
import org.jivesoftware.smackx.jft.provider.JingleFileTransferProvider;
|
import org.jivesoftware.smackx.jft.provider.JingleFileTransferProvider;
|
||||||
import org.jivesoftware.smackx.jingle.JingleDescriptionManager;
|
import org.jivesoftware.smackx.jingle.JingleDescriptionManager;
|
||||||
import org.jivesoftware.smackx.jingle.JingleManager;
|
import org.jivesoftware.smackx.jingle.JingleManager;
|
||||||
import org.jivesoftware.smackx.jingle.Role;
|
import org.jivesoftware.smackx.jingle.util.Role;
|
||||||
import org.jivesoftware.smackx.jingle.callbacks.ContentAddCallback;
|
import org.jivesoftware.smackx.jingle.callbacks.ContentAddCallback;
|
||||||
import org.jivesoftware.smackx.jingle.element.JingleContentElement;
|
import org.jivesoftware.smackx.jingle.element.JingleContentElement;
|
||||||
import org.jivesoftware.smackx.jingle.element.JingleElement;
|
import org.jivesoftware.smackx.jingle.element.JingleElement;
|
||||||
import org.jivesoftware.smackx.jingle.internal.JingleContent;
|
import org.jivesoftware.smackx.jingle.components.JingleContent;
|
||||||
import org.jivesoftware.smackx.jingle.internal.JingleSession;
|
import org.jivesoftware.smackx.jingle.components.JingleSession;
|
||||||
import org.jivesoftware.smackx.jingle.provider.JingleContentProviderManager;
|
import org.jivesoftware.smackx.jingle.provider.JingleContentProviderManager;
|
||||||
import org.jivesoftware.smackx.jingle.transport.JingleTransportManager;
|
import org.jivesoftware.smackx.jingle.JingleTransportManager;
|
||||||
|
|
||||||
import org.jxmpp.jid.FullJid;
|
import org.jxmpp.jid.FullJid;
|
||||||
|
|
||||||
|
@ -34,8 +40,10 @@ public final class JingleFileTransferManager extends Manager implements JingleDe
|
||||||
private static final WeakHashMap<XMPPConnection, JingleFileTransferManager> INSTANCES = new WeakHashMap<>();
|
private static final WeakHashMap<XMPPConnection, JingleFileTransferManager> INSTANCES = new WeakHashMap<>();
|
||||||
private final JingleManager jingleManager;
|
private final JingleManager jingleManager;
|
||||||
|
|
||||||
private final List<IncomingFileTransferListener> listeners =
|
private final List<IncomingFileOfferListener> offerListeners =
|
||||||
Collections.synchronizedList(new ArrayList<IncomingFileTransferListener>());
|
Collections.synchronizedList(new ArrayList<IncomingFileOfferListener>());
|
||||||
|
private final List<IncomingFileRequestListener> requestListeners =
|
||||||
|
Collections.synchronizedList(new ArrayList<IncomingFileRequestListener>());
|
||||||
|
|
||||||
private JingleFileTransferManager(XMPPConnection connection) {
|
private JingleFileTransferManager(XMPPConnection connection) {
|
||||||
super(connection);
|
super(connection);
|
||||||
|
@ -56,7 +64,7 @@ public final class JingleFileTransferManager extends Manager implements JingleDe
|
||||||
return manager;
|
return manager;
|
||||||
}
|
}
|
||||||
|
|
||||||
public OutgoingFileHandler sendFile(File file, FullJid to) {
|
public OutgoingFileOfferController sendFile(File file, FullJid to) {
|
||||||
if (file == null || !file.exists()) {
|
if (file == null || !file.exists()) {
|
||||||
throw new IllegalArgumentException("File MUST NOT be null and MUST exist.");
|
throw new IllegalArgumentException("File MUST NOT be null and MUST exist.");
|
||||||
}
|
}
|
||||||
|
@ -72,34 +80,53 @@ public final class JingleFileTransferManager extends Manager implements JingleDe
|
||||||
JingleTransportManager transportManager = jingleManager.getBestAvailableTransportManager();
|
JingleTransportManager transportManager = jingleManager.getBestAvailableTransportManager();
|
||||||
content.setTransport(transportManager.createTransport(content));
|
content.setTransport(transportManager.createTransport(content));
|
||||||
|
|
||||||
OutgoingFileHandler handler = new OutgoingFileHandler();
|
|
||||||
|
|
||||||
|
|
||||||
//TODO
|
//TODO
|
||||||
return handler;
|
return offer;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addIncomingFileTransferListener(IncomingFileTransferListener listener) {
|
public OutgoingFileRequestController requestFile() {
|
||||||
listeners.add(listener);
|
JingleOutgoingFileRequest request = new JingleOutgoingFileRequest();
|
||||||
|
|
||||||
|
//TODO at some point.
|
||||||
|
|
||||||
|
return request;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void removeIncomingFileTransferListener(IncomingFileTransferListener listener) {
|
public void addIncomingFileOfferListener(IncomingFileOfferListener listener) {
|
||||||
listeners.remove(listener);
|
offerListeners.add(listener);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void notifyIncomingFileTransferListeners(JingleIncomingFileOffer offer) {
|
public void removeIncomingFileOfferListener(IncomingFileOfferListener listener) {
|
||||||
for (IncomingFileTransferListener l : listeners) {
|
offerListeners.remove(listener);
|
||||||
l.onIncomingFileTransfer(new IncomingFileTransferCallback(offer));
|
}
|
||||||
|
|
||||||
|
public void notifyIncomingFileOfferListeners(JingleIncomingFileOffer offer) {
|
||||||
|
for (IncomingFileOfferListener l : offerListeners) {
|
||||||
|
l.onIncomingFileTransfer(offer);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addIncomingFileRequestListener(IncomingFileRequestListener listener) {
|
||||||
|
requestListeners.add(listener);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void removeIncomingFileRequestListener(IncomingFileRequestListener listener) {
|
||||||
|
requestListeners.remove(listener);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void notifyIncomingFileRequestListeners(JingleIncomingFileRequest request) {
|
||||||
|
for (IncomingFileRequestListener l : requestListeners) {
|
||||||
|
l.onIncomingFileRequest(request);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getNamespace() {
|
public String getNamespace() {
|
||||||
return JingleFileTransfer.NAMESPACE;
|
return AbstractJingleFileTransfer.NAMESPACE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public JingleElement notifyContentListeners(JingleContent content, ContentAddCallback callback) {
|
public JingleElement notifyContentListeners(JingleContent content, ContentAddCallback callback) {
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +0,0 @@
|
||||||
package org.jivesoftware.smackx.jft;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Created by vanitas on 26.07.17.
|
|
||||||
*/
|
|
||||||
public class OutgoingFileHandler {
|
|
||||||
}
|
|
|
@ -0,0 +1,9 @@
|
||||||
|
package org.jivesoftware.smackx.jft.controller;
|
||||||
|
|
||||||
|
import org.jivesoftware.smackx.jingle.controller.JingleDescriptionController;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by vanitas on 27.07.17.
|
||||||
|
*/
|
||||||
|
public interface IncomingFileOfferController extends JingleDescriptionController {
|
||||||
|
}
|
|
@ -0,0 +1,10 @@
|
||||||
|
package org.jivesoftware.smackx.jft.controller;
|
||||||
|
|
||||||
|
import org.jivesoftware.smackx.jingle.controller.JingleDescriptionController;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by vanitas on 27.07.17.
|
||||||
|
*/
|
||||||
|
public interface IncomingFileRequestController extends JingleDescriptionController {
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,7 @@
|
||||||
|
package org.jivesoftware.smackx.jft.controller;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by vanitas on 27.07.17.
|
||||||
|
*/
|
||||||
|
public interface OutgoingFileOfferController {
|
||||||
|
}
|
|
@ -0,0 +1,7 @@
|
||||||
|
package org.jivesoftware.smackx.jft.controller;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by vanitas on 27.07.17.
|
||||||
|
*/
|
||||||
|
public interface OutgoingFileRequestController {
|
||||||
|
}
|
|
@ -19,7 +19,7 @@ package org.jivesoftware.smackx.jft.element;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.jivesoftware.smackx.jft.internal.JingleFileTransfer;
|
import org.jivesoftware.smackx.jft.internal.AbstractJingleFileTransfer;
|
||||||
import org.jivesoftware.smackx.jingle.element.JingleContentDescriptionElement;
|
import org.jivesoftware.smackx.jingle.element.JingleContentDescriptionElement;
|
||||||
import org.jivesoftware.smackx.jingle.element.JingleContentDescriptionChildElement;
|
import org.jivesoftware.smackx.jingle.element.JingleContentDescriptionChildElement;
|
||||||
|
|
||||||
|
@ -38,6 +38,6 @@ public class JingleFileTransferElement extends JingleContentDescriptionElement {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getNamespace() {
|
public String getNamespace() {
|
||||||
return JingleFileTransfer.NAMESPACE;
|
return AbstractJingleFileTransfer.NAMESPACE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,15 +1,16 @@
|
||||||
package org.jivesoftware.smackx.jft.internal;
|
package org.jivesoftware.smackx.jft.internal;
|
||||||
|
|
||||||
import org.jivesoftware.smackx.jft.element.JingleFileTransferElement;
|
import org.jivesoftware.smackx.jft.element.JingleFileTransferElement;
|
||||||
|
import org.jivesoftware.smackx.jft.internal.file.AbstractJingleFileTransferFile;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by vanitas on 22.07.17.
|
* Created by vanitas on 22.07.17.
|
||||||
*/
|
*/
|
||||||
public abstract class JingleFileOffer<D extends JingleFileTransferFile> extends JingleFileTransfer {
|
public abstract class AbstractJingleFileOffer<D extends AbstractJingleFileTransferFile> extends AbstractJingleFileTransfer {
|
||||||
|
|
||||||
protected D jingleFile;
|
protected D jingleFile;
|
||||||
|
|
||||||
public JingleFileOffer(D fileTransferFile) {
|
public AbstractJingleFileOffer(D fileTransferFile) {
|
||||||
super();
|
super();
|
||||||
this.jingleFile = fileTransferFile;
|
this.jingleFile = fileTransferFile;
|
||||||
}
|
}
|
|
@ -0,0 +1,8 @@
|
||||||
|
package org.jivesoftware.smackx.jft.internal;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by vanitas on 22.07.17.
|
||||||
|
*/
|
||||||
|
public abstract class AbstractJingleFileRequest extends AbstractJingleFileTransfer {
|
||||||
|
|
||||||
|
}
|
|
@ -1,12 +1,12 @@
|
||||||
package org.jivesoftware.smackx.jft.internal;
|
package org.jivesoftware.smackx.jft.internal;
|
||||||
|
|
||||||
import org.jivesoftware.smackx.jingle.internal.JingleDescription;
|
import org.jivesoftware.smackx.jingle.components.JingleDescription;
|
||||||
import org.jivesoftware.smackx.jft.element.JingleFileTransferElement;
|
import org.jivesoftware.smackx.jft.element.JingleFileTransferElement;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by vanitas on 22.07.17.
|
* Created by vanitas on 22.07.17.
|
||||||
*/
|
*/
|
||||||
public abstract class JingleFileTransfer extends JingleDescription<JingleFileTransferElement> {
|
public abstract class AbstractJingleFileTransfer extends JingleDescription<JingleFileTransferElement> {
|
||||||
|
|
||||||
public static final String NAMESPACE_V5 = "urn:xmpp:jingle:apps:file-transfer:5";
|
public static final String NAMESPACE_V5 = "urn:xmpp:jingle:apps:file-transfer:5";
|
||||||
public static final String NAMESPACE = NAMESPACE_V5;
|
public static final String NAMESPACE = NAMESPACE_V5;
|
|
@ -6,12 +6,14 @@ import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
import org.jivesoftware.smackx.bytestreams.BytestreamSession;
|
import org.jivesoftware.smackx.bytestreams.BytestreamSession;
|
||||||
|
import org.jivesoftware.smackx.jft.controller.IncomingFileOfferController;
|
||||||
import org.jivesoftware.smackx.jft.element.JingleFileTransferChildElement;
|
import org.jivesoftware.smackx.jft.element.JingleFileTransferChildElement;
|
||||||
|
import org.jivesoftware.smackx.jft.internal.file.RemoteFile;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by vanitas on 26.07.17.
|
* Created by vanitas on 26.07.17.
|
||||||
*/
|
*/
|
||||||
public class JingleIncomingFileOffer extends JingleFileOffer<RemoteFile> {
|
public class JingleIncomingFileOffer extends AbstractJingleFileOffer<RemoteFile> implements IncomingFileOfferController {
|
||||||
|
|
||||||
private static final Logger LOGGER = Logger.getLogger(JingleIncomingFileOffer.class.getName());
|
private static final Logger LOGGER = Logger.getLogger(JingleIncomingFileOffer.class.getName());
|
||||||
|
|
||||||
|
|
|
@ -1,13 +1,13 @@
|
||||||
package org.jivesoftware.smackx.jft.internal;
|
package org.jivesoftware.smackx.jft.internal;
|
||||||
|
|
||||||
import org.jivesoftware.smackx.bytestreams.BytestreamSession;
|
import org.jivesoftware.smackx.bytestreams.BytestreamSession;
|
||||||
|
import org.jivesoftware.smackx.jft.controller.IncomingFileRequestController;
|
||||||
import org.jivesoftware.smackx.jft.element.JingleFileTransferElement;
|
import org.jivesoftware.smackx.jft.element.JingleFileTransferElement;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by vanitas on 22.07.17.
|
* Created by vanitas on 27.07.17.
|
||||||
*/
|
*/
|
||||||
public class JingleFileRequest extends JingleFileTransfer {
|
public class JingleIncomingFileRequest extends AbstractJingleFileRequest implements IncomingFileRequestController {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public JingleFileTransferElement getElement() {
|
public JingleFileTransferElement getElement() {
|
||||||
return null;
|
return null;
|
|
@ -3,11 +3,13 @@ package org.jivesoftware.smackx.jft.internal;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
|
||||||
import org.jivesoftware.smackx.bytestreams.BytestreamSession;
|
import org.jivesoftware.smackx.bytestreams.BytestreamSession;
|
||||||
|
import org.jivesoftware.smackx.jft.controller.OutgoingFileOfferController;
|
||||||
|
import org.jivesoftware.smackx.jft.internal.file.LocalFile;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by vanitas on 26.07.17.
|
* Created by vanitas on 26.07.17.
|
||||||
*/
|
*/
|
||||||
public class JingleOutgoingFileOffer extends JingleFileOffer<LocalFile> {
|
public class JingleOutgoingFileOffer extends AbstractJingleFileOffer<LocalFile> implements OutgoingFileOfferController {
|
||||||
|
|
||||||
public JingleOutgoingFileOffer(File file) {
|
public JingleOutgoingFileOffer(File file) {
|
||||||
super(new LocalFile(file));
|
super(new LocalFile(file));
|
||||||
|
|
|
@ -0,0 +1,20 @@
|
||||||
|
package org.jivesoftware.smackx.jft.internal;
|
||||||
|
|
||||||
|
import org.jivesoftware.smackx.bytestreams.BytestreamSession;
|
||||||
|
import org.jivesoftware.smackx.jft.controller.OutgoingFileRequestController;
|
||||||
|
import org.jivesoftware.smackx.jft.element.JingleFileTransferElement;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by vanitas on 27.07.17.
|
||||||
|
*/
|
||||||
|
public class JingleOutgoingFileRequest extends AbstractJingleFileRequest implements OutgoingFileRequestController {
|
||||||
|
@Override
|
||||||
|
public JingleFileTransferElement getElement() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onTransportReady(BytestreamSession bytestreamSession) {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,33 +0,0 @@
|
||||||
package org.jivesoftware.smackx.jft.internal;
|
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.util.Date;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Created by vanitas on 26.07.17.
|
|
||||||
*/
|
|
||||||
public class LocalFile extends JingleFileTransferFile {
|
|
||||||
|
|
||||||
private File file;
|
|
||||||
|
|
||||||
public LocalFile(File file) {
|
|
||||||
super();
|
|
||||||
this.file = file;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Date getDate() {
|
|
||||||
return new Date(file.lastModified());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public long getSize() {
|
|
||||||
return file.length();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getName() {
|
|
||||||
String path = file.getAbsolutePath();
|
|
||||||
return path.substring(path.lastIndexOf(File.pathSeparatorChar)+1);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,15 +1,16 @@
|
||||||
package org.jivesoftware.smackx.jft.internal;
|
package org.jivesoftware.smackx.jft.internal.file;
|
||||||
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
||||||
|
import org.jivesoftware.smackx.hashes.element.HashElement;
|
||||||
import org.jivesoftware.smackx.jft.element.JingleFileTransferChildElement;
|
import org.jivesoftware.smackx.jft.element.JingleFileTransferChildElement;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by vanitas on 26.07.17.
|
* Created by vanitas on 26.07.17.
|
||||||
*/
|
*/
|
||||||
public abstract class JingleFileTransferFile {
|
public abstract class AbstractJingleFileTransferFile {
|
||||||
|
|
||||||
public JingleFileTransferFile() {
|
public AbstractJingleFileTransferFile() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -18,6 +19,9 @@ public abstract class JingleFileTransferFile {
|
||||||
builder.setDate(getDate());
|
builder.setDate(getDate());
|
||||||
builder.setSize(getSize());
|
builder.setSize(getSize());
|
||||||
builder.setName(getName());
|
builder.setName(getName());
|
||||||
|
builder.setDescription(getDescription());
|
||||||
|
builder.setMediaType(getMediaType());
|
||||||
|
builder.setHash(getHashElement());
|
||||||
|
|
||||||
return builder.build();
|
return builder.build();
|
||||||
}
|
}
|
||||||
|
@ -27,4 +31,10 @@ public abstract class JingleFileTransferFile {
|
||||||
public abstract long getSize();
|
public abstract long getSize();
|
||||||
|
|
||||||
public abstract String getName();
|
public abstract String getName();
|
||||||
|
|
||||||
|
public abstract String getDescription();
|
||||||
|
|
||||||
|
public abstract String getMediaType();
|
||||||
|
|
||||||
|
public abstract HashElement getHashElement();
|
||||||
}
|
}
|
|
@ -0,0 +1,75 @@
|
||||||
|
package org.jivesoftware.smackx.jft.internal.file;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
import org.jivesoftware.smackx.hashes.element.HashElement;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by vanitas on 26.07.17.
|
||||||
|
*/
|
||||||
|
public class LocalFile extends AbstractJingleFileTransferFile {
|
||||||
|
|
||||||
|
private File file;
|
||||||
|
private String description;
|
||||||
|
private String mediaType;
|
||||||
|
private HashElement hashElement;
|
||||||
|
|
||||||
|
public LocalFile(File file) {
|
||||||
|
this(file, null, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public LocalFile(File file, String description) {
|
||||||
|
this(file, description, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public LocalFile(File file, String description, String mediaType) {
|
||||||
|
super();
|
||||||
|
this.file = file;
|
||||||
|
this.description = description;
|
||||||
|
this.mediaType = mediaType;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Date getDate() {
|
||||||
|
return new Date(file.lastModified());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public long getSize() {
|
||||||
|
return file.length();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getName() {
|
||||||
|
String path = file.getAbsolutePath();
|
||||||
|
return path.substring(path.lastIndexOf(File.pathSeparatorChar)+1);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getDescription() {
|
||||||
|
return description;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getMediaType() {
|
||||||
|
return mediaType;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public HashElement getHashElement() {
|
||||||
|
return hashElement;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDescription(String description) {
|
||||||
|
this.description = description;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMediaType(String mediaType) {
|
||||||
|
this.mediaType = mediaType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setHashElement(HashElement hashElement) {
|
||||||
|
this.hashElement = hashElement;
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,13 +1,14 @@
|
||||||
package org.jivesoftware.smackx.jft.internal;
|
package org.jivesoftware.smackx.jft.internal.file;
|
||||||
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
||||||
|
import org.jivesoftware.smackx.hashes.element.HashElement;
|
||||||
import org.jivesoftware.smackx.jft.element.JingleFileTransferChildElement;
|
import org.jivesoftware.smackx.jft.element.JingleFileTransferChildElement;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by vanitas on 26.07.17.
|
* Created by vanitas on 26.07.17.
|
||||||
*/
|
*/
|
||||||
public class RemoteFile extends JingleFileTransferFile {
|
public class RemoteFile extends AbstractJingleFileTransferFile {
|
||||||
|
|
||||||
private JingleFileTransferChildElement file;
|
private JingleFileTransferChildElement file;
|
||||||
|
|
||||||
|
@ -16,6 +17,21 @@ public class RemoteFile extends JingleFileTransferFile {
|
||||||
this.file = file;
|
this.file = file;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getDescription() {
|
||||||
|
return file.getDescription();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getMediaType() {
|
||||||
|
return file.getMediaType();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public HashElement getHashElement() {
|
||||||
|
return file.getHash();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Date getDate() {
|
public Date getDate() {
|
||||||
return file.getDate();
|
return file.getDate();
|
|
@ -0,0 +1,11 @@
|
||||||
|
package org.jivesoftware.smackx.jft.listener;
|
||||||
|
|
||||||
|
import org.jivesoftware.smackx.jft.controller.IncomingFileOfferController;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by vanitas on 26.07.17.
|
||||||
|
*/
|
||||||
|
public interface IncomingFileOfferListener {
|
||||||
|
|
||||||
|
void onIncomingFileTransfer(IncomingFileOfferController offer);
|
||||||
|
}
|
|
@ -0,0 +1,11 @@
|
||||||
|
package org.jivesoftware.smackx.jft.listener;
|
||||||
|
|
||||||
|
import org.jivesoftware.smackx.jft.controller.IncomingFileRequestController;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by vanitas on 27.07.17.
|
||||||
|
*/
|
||||||
|
public interface IncomingFileRequestListener {
|
||||||
|
|
||||||
|
void onIncomingFileRequest(IncomingFileRequestController request);
|
||||||
|
}
|
|
@ -18,7 +18,7 @@ package org.jivesoftware.smackx.jingle_filetransfer;
|
||||||
|
|
||||||
import org.jivesoftware.smack.XMPPConnection;
|
import org.jivesoftware.smack.XMPPConnection;
|
||||||
import org.jivesoftware.smackx.jingle.JingleManager;
|
import org.jivesoftware.smackx.jingle.JingleManager;
|
||||||
import org.jivesoftware.smackx.jingle.Role;
|
import org.jivesoftware.smackx.jingle.util.Role;
|
||||||
import org.jivesoftware.smackx.jingle.element.JingleElement;
|
import org.jivesoftware.smackx.jingle.element.JingleElement;
|
||||||
|
|
||||||
import org.jxmpp.jid.FullJid;
|
import org.jxmpp.jid.FullJid;
|
||||||
|
|
|
@ -31,7 +31,7 @@ import org.jivesoftware.smack.packet.IQ;
|
||||||
import org.jivesoftware.smackx.disco.ServiceDiscoveryManager;
|
import org.jivesoftware.smackx.disco.ServiceDiscoveryManager;
|
||||||
import org.jivesoftware.smackx.jft.element.JingleFileTransferChildElement;
|
import org.jivesoftware.smackx.jft.element.JingleFileTransferChildElement;
|
||||||
import org.jivesoftware.smackx.jft.element.JingleFileTransferElement;
|
import org.jivesoftware.smackx.jft.element.JingleFileTransferElement;
|
||||||
import org.jivesoftware.smackx.jft.internal.JingleFileTransfer;
|
import org.jivesoftware.smackx.jft.internal.AbstractJingleFileTransfer;
|
||||||
import org.jivesoftware.smackx.jft.provider.JingleFileTransferProvider;
|
import org.jivesoftware.smackx.jft.provider.JingleFileTransferProvider;
|
||||||
import org.jivesoftware.smackx.jingle.JingleManager;
|
import org.jivesoftware.smackx.jingle.JingleManager;
|
||||||
import org.jivesoftware.smackx.jingle.element.JingleAction;
|
import org.jivesoftware.smackx.jingle.element.JingleAction;
|
||||||
|
@ -57,7 +57,7 @@ public final class JingleFileTransferManagerAlt extends Manager {
|
||||||
|
|
||||||
private JingleFileTransferManagerAlt(XMPPConnection connection) {
|
private JingleFileTransferManagerAlt(XMPPConnection connection) {
|
||||||
super(connection);
|
super(connection);
|
||||||
ServiceDiscoveryManager.getInstanceFor(connection).addFeature(JingleFileTransfer.NAMESPACE_V5);
|
ServiceDiscoveryManager.getInstanceFor(connection).addFeature(AbstractJingleFileTransfer.NAMESPACE_V5);
|
||||||
JingleManager jingleManager = JingleManager.getInstanceFor(connection);
|
JingleManager jingleManager = JingleManager.getInstanceFor(connection);
|
||||||
jingleManager.addJingleDescriptionManager(this);
|
jingleManager.addJingleDescriptionManager(this);
|
||||||
JingleContentProviderManager.addJingleContentDescriptionProvider(
|
JingleContentProviderManager.addJingleContentDescriptionProvider(
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
*/
|
*/
|
||||||
package org.jivesoftware.smackx.jingle;
|
package org.jivesoftware.smackx.jingle;
|
||||||
|
|
||||||
import org.jivesoftware.smackx.jingle.internal.JingleContent;
|
import org.jivesoftware.smackx.jingle.components.JingleContent;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* User callback that the user can use to control a jingle content.
|
* User callback that the user can use to control a jingle content.
|
||||||
|
|
|
@ -0,0 +1,17 @@
|
||||||
|
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.
|
||||||
|
active, //Bytestream initialized and active
|
||||||
|
cancelled, //We/Peer cancelled the transmission
|
||||||
|
ended //Successfully ended
|
||||||
|
}
|
||||||
|
|
||||||
|
State getState();
|
||||||
|
}
|
|
@ -16,9 +16,7 @@
|
||||||
*/
|
*/
|
||||||
package org.jivesoftware.smackx.jingle;
|
package org.jivesoftware.smackx.jingle;
|
||||||
|
|
||||||
import org.jivesoftware.smackx.jingle.callbacks.ContentAddCallback;
|
import org.jivesoftware.smackx.jingle.components.JingleSession;
|
||||||
import org.jivesoftware.smackx.jingle.element.JingleElement;
|
|
||||||
import org.jivesoftware.smackx.jingle.internal.JingleContent;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Manager for JingleDescription components.
|
* Manager for JingleDescription components.
|
||||||
|
@ -27,5 +25,5 @@ public interface JingleDescriptionManager {
|
||||||
|
|
||||||
String getNamespace();
|
String getNamespace();
|
||||||
|
|
||||||
JingleElement notifyContentListeners(JingleContent content, ContentAddCallback callback);
|
void notifySessionInitiate(JingleSession session);
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,11 +39,12 @@ import org.jivesoftware.smackx.jingle.element.JingleReasonElement;
|
||||||
import org.jivesoftware.smackx.jingle.exception.UnsupportedDescriptionException;
|
import org.jivesoftware.smackx.jingle.exception.UnsupportedDescriptionException;
|
||||||
import org.jivesoftware.smackx.jingle.exception.UnsupportedSecurityException;
|
import org.jivesoftware.smackx.jingle.exception.UnsupportedSecurityException;
|
||||||
import org.jivesoftware.smackx.jingle.exception.UnsupportedTransportException;
|
import org.jivesoftware.smackx.jingle.exception.UnsupportedTransportException;
|
||||||
import org.jivesoftware.smackx.jingle.internal.JingleSession;
|
import org.jivesoftware.smackx.jingle.components.JingleSession;
|
||||||
import org.jivesoftware.smackx.jingle.provider.JingleContentDescriptionProvider;
|
import org.jivesoftware.smackx.jingle.provider.JingleContentDescriptionProvider;
|
||||||
import org.jivesoftware.smackx.jingle.provider.JingleContentSecurityProvider;
|
import org.jivesoftware.smackx.jingle.provider.JingleContentSecurityProvider;
|
||||||
import org.jivesoftware.smackx.jingle.provider.JingleContentTransportProvider;
|
import org.jivesoftware.smackx.jingle.provider.JingleContentTransportProvider;
|
||||||
import org.jivesoftware.smackx.jingle.transport.JingleTransportManager;
|
import org.jivesoftware.smackx.jingle.util.FullJidAndSessionId;
|
||||||
|
import org.jivesoftware.smackx.jingle.util.Role;
|
||||||
|
|
||||||
import org.jxmpp.jid.FullJid;
|
import org.jxmpp.jid.FullJid;
|
||||||
|
|
||||||
|
|
|
@ -14,10 +14,10 @@
|
||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package org.jivesoftware.smackx.jingle.transport;
|
package org.jivesoftware.smackx.jingle;
|
||||||
|
|
||||||
import org.jivesoftware.smackx.jingle.internal.JingleContent;
|
import org.jivesoftware.smackx.jingle.components.JingleContent;
|
||||||
import org.jivesoftware.smackx.jingle.internal.JingleTransport;
|
import org.jivesoftware.smackx.jingle.components.JingleTransport;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Manager for JingleTransport components.
|
* Manager for JingleTransport components.
|
|
@ -17,7 +17,7 @@
|
||||||
package org.jivesoftware.smackx.jingle.adapter;
|
package org.jivesoftware.smackx.jingle.adapter;
|
||||||
|
|
||||||
import org.jivesoftware.smackx.jingle.element.JingleContentDescriptionElement;
|
import org.jivesoftware.smackx.jingle.element.JingleContentDescriptionElement;
|
||||||
import org.jivesoftware.smackx.jingle.internal.JingleDescription;
|
import org.jivesoftware.smackx.jingle.components.JingleDescription;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adapter that creates a Description object from an element.
|
* Adapter that creates a Description object from an element.
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
package org.jivesoftware.smackx.jingle.adapter;
|
package org.jivesoftware.smackx.jingle.adapter;
|
||||||
|
|
||||||
import org.jivesoftware.smackx.jingle.element.JingleContentSecurityElement;
|
import org.jivesoftware.smackx.jingle.element.JingleContentSecurityElement;
|
||||||
import org.jivesoftware.smackx.jingle.internal.JingleSecurity;
|
import org.jivesoftware.smackx.jingle.components.JingleSecurity;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adapter that creates a Security object from an element.
|
* Adapter that creates a Security object from an element.
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
package org.jivesoftware.smackx.jingle.adapter;
|
package org.jivesoftware.smackx.jingle.adapter;
|
||||||
|
|
||||||
import org.jivesoftware.smackx.jingle.element.JingleContentTransportElement;
|
import org.jivesoftware.smackx.jingle.element.JingleContentTransportElement;
|
||||||
import org.jivesoftware.smackx.jingle.internal.JingleTransport;
|
import org.jivesoftware.smackx.jingle.components.JingleTransport;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adapter that creates a Transport element from an element.
|
* Adapter that creates a Transport element from an element.
|
||||||
|
|
|
@ -14,14 +14,19 @@
|
||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package org.jivesoftware.smackx.jingle.internal;
|
package org.jivesoftware.smackx.jingle.components;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
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.util.StringUtils;
|
import org.jivesoftware.smack.util.StringUtils;
|
||||||
import org.jivesoftware.smackx.bytestreams.BytestreamSession;
|
import org.jivesoftware.smackx.bytestreams.BytestreamSession;
|
||||||
import org.jivesoftware.smackx.jingle.JingleManager;
|
import org.jivesoftware.smackx.jingle.JingleManager;
|
||||||
|
@ -33,12 +38,17 @@ import org.jivesoftware.smackx.jingle.element.JingleContentTransportElement;
|
||||||
import org.jivesoftware.smackx.jingle.Callback;
|
import org.jivesoftware.smackx.jingle.Callback;
|
||||||
import org.jivesoftware.smackx.jingle.adapter.JingleSecurityAdapter;
|
import org.jivesoftware.smackx.jingle.adapter.JingleSecurityAdapter;
|
||||||
import org.jivesoftware.smackx.jingle.element.JingleContentElement;
|
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.JingleTransportManager;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Internal class that holds the state of a content in a modifiable form.
|
* Internal class that holds the state of a content in a modifiable form.
|
||||||
*/
|
*/
|
||||||
public class JingleContent {
|
public class JingleContent {
|
||||||
|
|
||||||
|
private static final Logger LOGGER = Logger.getLogger(JingleContent.class.getName());
|
||||||
|
|
||||||
private JingleSession parent;
|
private JingleSession parent;
|
||||||
private JingleContentElement.Creator creator;
|
private JingleContentElement.Creator creator;
|
||||||
private String name;
|
private String name;
|
||||||
|
@ -51,8 +61,18 @@ public class JingleContent {
|
||||||
private final List<Callback> callbacks = Collections.synchronizedList(new ArrayList<Callback>());
|
private final List<Callback> callbacks = Collections.synchronizedList(new ArrayList<Callback>());
|
||||||
private final Set<String> transportBlacklist = Collections.synchronizedSet(new HashSet<String>());
|
private final Set<String> transportBlacklist = Collections.synchronizedSet(new HashSet<String>());
|
||||||
|
|
||||||
|
public enum STATE {
|
||||||
|
pending_accept,
|
||||||
|
pending_transmission_start,
|
||||||
|
pending_transport_replace,
|
||||||
|
transmission_in_progress,
|
||||||
|
transmission_successful,
|
||||||
|
transmission_failed,
|
||||||
|
transmission_cancelled
|
||||||
|
}
|
||||||
|
|
||||||
public JingleContent(JingleContentElement.Creator creator, JingleContentElement.Senders senders) {
|
public JingleContent(JingleContentElement.Creator creator, JingleContentElement.Senders senders) {
|
||||||
this(null, null, null, StringUtils.randomString(24), null, creator, senders);
|
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) {
|
||||||
|
@ -181,6 +201,18 @@ public class JingleContent {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean isSending() {
|
||||||
|
return (getSenders() == JingleContentElement.Senders.initiator && getParent().isInitiator()) ||
|
||||||
|
(getSenders() == JingleContentElement.Senders.responder && getParent().isResponder()) ||
|
||||||
|
getSenders() == JingleContentElement.Senders.both;
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean isReceiving() {
|
||||||
|
return (getSenders() == JingleContentElement.Senders.initiator && getParent().isResponder()) ||
|
||||||
|
(getSenders() == JingleContentElement.Senders.responder && getParent().isInitiator()) ||
|
||||||
|
getSenders() == JingleContentElement.Senders.both;
|
||||||
|
}
|
||||||
|
|
||||||
public void onTransportReady() {
|
public void onTransportReady() {
|
||||||
BytestreamSession bytestreamSession = transport.getBytestreamSession();
|
BytestreamSession bytestreamSession = transport.getBytestreamSession();
|
||||||
|
|
||||||
|
@ -192,7 +224,50 @@ public class JingleContent {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onTransportFailed(Exception e) {
|
public void onTransportFailed(Exception e) {
|
||||||
|
//Add current transport to blacklist.
|
||||||
|
getTransportBlacklist().add(transport.getNamespace());
|
||||||
|
|
||||||
|
//Replace transport.
|
||||||
|
if (getParent().isInitiator()) {
|
||||||
|
try {
|
||||||
|
replaceTransport(getTransportBlacklist(), getParent().getJingleManager().getConnection());
|
||||||
|
} catch (SmackException.NotConnectedException | InterruptedException | SmackException.NoResponseException | XMPPException.XMPPErrorException e1) {
|
||||||
|
LOGGER.log(Level.SEVERE, "Could not send transport-replace: " + e, e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void replaceTransport(Set<String> blacklist, XMPPConnection connection)
|
||||||
|
throws SmackException.NotConnectedException, InterruptedException,
|
||||||
|
XMPPException.XMPPErrorException, SmackException.NoResponseException {
|
||||||
|
|
||||||
|
JingleSession session = getParent();
|
||||||
|
JingleManager jingleManager = session.getJingleManager();
|
||||||
|
|
||||||
|
JingleTransportManager rManager = jingleManager.getBestAvailableTransportManager(blacklist);
|
||||||
|
if (rManager == null) {
|
||||||
|
JingleElement failedTransport = JingleElement.createSessionTerminate(session.getPeer(),
|
||||||
|
session.getSessionId(), JingleReasonElement.Reason.failed_transport);
|
||||||
|
connection.createStanzaCollectorAndSend(failedTransport).nextResultOrThrow();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
JingleTransport<?> rTransport = rManager.createTransport(this);
|
||||||
|
|
||||||
|
JingleElement transportReplace = JingleElement.createTransportReplace(session.getInitiator(), session.getPeer(),
|
||||||
|
session.getSessionId(), getCreator(), getName(), rTransport.getElement());
|
||||||
|
|
||||||
|
connection.createStanzaCollectorAndSend(transportReplace).nextResultOrThrow();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void onContentAccept(XMPPConnection connection, )
|
||||||
|
throws SmackException.NotConnectedException, InterruptedException {
|
||||||
|
//Establish transport
|
||||||
|
if (isReceiving()) {
|
||||||
|
getTransport().establishIncomingBytestreamSession(connection);
|
||||||
|
} else if (isSending()) {
|
||||||
|
getTransport().establishOutgoingBytestreamSession(connection);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String randomName() {
|
public static String randomName() {
|
|
@ -14,7 +14,7 @@
|
||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package org.jivesoftware.smackx.jingle.internal;
|
package org.jivesoftware.smackx.jingle.components;
|
||||||
|
|
||||||
import org.jivesoftware.smackx.bytestreams.BytestreamSession;
|
import org.jivesoftware.smackx.bytestreams.BytestreamSession;
|
||||||
import org.jivesoftware.smackx.jingle.element.JingleContentDescriptionElement;
|
import org.jivesoftware.smackx.jingle.element.JingleContentDescriptionElement;
|
|
@ -14,11 +14,11 @@
|
||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package org.jivesoftware.smackx.jingle.internal;
|
package org.jivesoftware.smackx.jingle.components;
|
||||||
|
|
||||||
import org.jivesoftware.smackx.jingle.element.JingleContentSecurityElement;
|
import org.jivesoftware.smackx.jingle.element.JingleContentSecurityElement;
|
||||||
import org.jivesoftware.smackx.jingle.element.JingleElement;
|
|
||||||
import org.jivesoftware.smackx.jingle.element.JingleContentSecurityInfoElement;
|
import org.jivesoftware.smackx.jingle.element.JingleContentSecurityInfoElement;
|
||||||
|
import org.jivesoftware.smackx.jingle.element.JingleElement;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class that represents a contents security component.
|
* Class that represents a contents security component.
|
|
@ -14,7 +14,7 @@
|
||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package org.jivesoftware.smackx.jingle.internal;
|
package org.jivesoftware.smackx.jingle.components;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
|
@ -30,7 +30,7 @@ import org.jivesoftware.smack.SmackException;
|
||||||
import org.jivesoftware.smack.XMPPException;
|
import org.jivesoftware.smack.XMPPException;
|
||||||
import org.jivesoftware.smack.packet.IQ;
|
import org.jivesoftware.smack.packet.IQ;
|
||||||
import org.jivesoftware.smackx.jingle.JingleManager;
|
import org.jivesoftware.smackx.jingle.JingleManager;
|
||||||
import org.jivesoftware.smackx.jingle.Role;
|
import org.jivesoftware.smackx.jingle.util.Role;
|
||||||
import org.jivesoftware.smackx.jingle.adapter.JingleTransportAdapter;
|
import org.jivesoftware.smackx.jingle.adapter.JingleTransportAdapter;
|
||||||
import org.jivesoftware.smackx.jingle.callbacks.ContentAddCallback;
|
import org.jivesoftware.smackx.jingle.callbacks.ContentAddCallback;
|
||||||
import org.jivesoftware.smackx.jingle.element.JingleContentDescriptionElement;
|
import org.jivesoftware.smackx.jingle.element.JingleContentDescriptionElement;
|
||||||
|
@ -161,7 +161,6 @@ public class JingleSession {
|
||||||
responses.add(JingleElement.createTransportReject(getInitiator(), getPeer(), getSessionId(),
|
responses.add(JingleElement.createTransportReject(getInitiator(), getPeer(), getSessionId(),
|
||||||
content.getCreator(), content.getName(), newTransport));
|
content.getCreator(), content.getName(), newTransport));
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
JingleTransportAdapter<?> transportAdapter = JingleManager.getJingleTransportAdapter(
|
JingleTransportAdapter<?> transportAdapter = JingleManager.getJingleTransportAdapter(
|
||||||
|
@ -353,7 +352,7 @@ public class JingleSession {
|
||||||
// TODO: Send content-reject
|
// TODO: Send content-reject
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
descriptionManager.notifyContentListeners(content, callback);
|
descriptionManager.notifySessionInitiate();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package org.jivesoftware.smackx.jingle.internal;
|
package org.jivesoftware.smackx.jingle.components;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
|
@ -14,7 +14,7 @@
|
||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package org.jivesoftware.smackx.jingle.internal;
|
package org.jivesoftware.smackx.jingle.components;
|
||||||
|
|
||||||
import org.jivesoftware.smackx.jingle.element.JingleContentTransportCandidateElement;
|
import org.jivesoftware.smackx.jingle.element.JingleContentTransportCandidateElement;
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package org.jivesoftware.smackx.jingle.internal;
|
package org.jivesoftware.smackx.jingle.components;
|
||||||
|
|
||||||
import org.jivesoftware.smackx.jingle.element.JingleAction;
|
import org.jivesoftware.smackx.jingle.element.JingleAction;
|
||||||
|
|
|
@ -0,0 +1,8 @@
|
||||||
|
package org.jivesoftware.smackx.jingle.controller;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by vanitas on 27.07.17.
|
||||||
|
*/
|
||||||
|
public interface JingleDescriptionController {
|
||||||
|
|
||||||
|
}
|
|
@ -27,9 +27,9 @@ import org.jivesoftware.smackx.bytestreams.ibb.InBandBytestreamManager;
|
||||||
import org.jivesoftware.smackx.bytestreams.ibb.InBandBytestreamRequest;
|
import org.jivesoftware.smackx.bytestreams.ibb.InBandBytestreamRequest;
|
||||||
import org.jivesoftware.smackx.jingle.element.JingleContentTransportInfoElement;
|
import org.jivesoftware.smackx.jingle.element.JingleContentTransportInfoElement;
|
||||||
import org.jivesoftware.smackx.jingle.element.JingleElement;
|
import org.jivesoftware.smackx.jingle.element.JingleElement;
|
||||||
import org.jivesoftware.smackx.jingle.internal.JingleSession;
|
import org.jivesoftware.smackx.jingle.components.JingleSession;
|
||||||
import org.jivesoftware.smackx.jingle.internal.JingleTransport;
|
import org.jivesoftware.smackx.jingle.components.JingleTransport;
|
||||||
import org.jivesoftware.smackx.jingle.internal.JingleTransportCandidate;
|
import org.jivesoftware.smackx.jingle.components.JingleTransportCandidate;
|
||||||
import org.jivesoftware.smackx.jingle.transport.jingle_ibb.element.JingleIBBTransportElement;
|
import org.jivesoftware.smackx.jingle.transport.jingle_ibb.element.JingleIBBTransportElement;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -6,9 +6,9 @@ import org.jivesoftware.smack.Manager;
|
||||||
import org.jivesoftware.smack.XMPPConnection;
|
import org.jivesoftware.smack.XMPPConnection;
|
||||||
import org.jivesoftware.smackx.disco.ServiceDiscoveryManager;
|
import org.jivesoftware.smackx.disco.ServiceDiscoveryManager;
|
||||||
import org.jivesoftware.smackx.jingle.JingleManager;
|
import org.jivesoftware.smackx.jingle.JingleManager;
|
||||||
import org.jivesoftware.smackx.jingle.transport.JingleTransportManager;
|
import org.jivesoftware.smackx.jingle.JingleTransportManager;
|
||||||
import org.jivesoftware.smackx.jingle.internal.JingleContent;
|
import org.jivesoftware.smackx.jingle.components.JingleContent;
|
||||||
import org.jivesoftware.smackx.jingle.internal.JingleTransport;
|
import org.jivesoftware.smackx.jingle.components.JingleTransport;
|
||||||
import org.jivesoftware.smackx.jingle.provider.JingleContentProviderManager;
|
import org.jivesoftware.smackx.jingle.provider.JingleContentProviderManager;
|
||||||
import org.jivesoftware.smackx.jingle.transport.jingle_ibb.provider.JingleIBBTransportProvider;
|
import org.jivesoftware.smackx.jingle.transport.jingle_ibb.provider.JingleIBBTransportProvider;
|
||||||
|
|
||||||
|
|
|
@ -37,10 +37,10 @@ import org.jivesoftware.smackx.jingle.JingleManager;
|
||||||
import org.jivesoftware.smackx.jingle.element.JingleContentTransportInfoElement;
|
import org.jivesoftware.smackx.jingle.element.JingleContentTransportInfoElement;
|
||||||
import org.jivesoftware.smackx.jingle.element.JingleElement;
|
import org.jivesoftware.smackx.jingle.element.JingleElement;
|
||||||
import org.jivesoftware.smackx.jingle.exception.FailedTransportException;
|
import org.jivesoftware.smackx.jingle.exception.FailedTransportException;
|
||||||
import org.jivesoftware.smackx.jingle.internal.JingleContent;
|
import org.jivesoftware.smackx.jingle.components.JingleContent;
|
||||||
import org.jivesoftware.smackx.jingle.internal.JingleSession;
|
import org.jivesoftware.smackx.jingle.components.JingleSession;
|
||||||
import org.jivesoftware.smackx.jingle.internal.JingleTransport;
|
import org.jivesoftware.smackx.jingle.components.JingleTransport;
|
||||||
import org.jivesoftware.smackx.jingle.internal.JingleTransportCandidate;
|
import org.jivesoftware.smackx.jingle.components.JingleTransportCandidate;
|
||||||
import org.jivesoftware.smackx.jingle.transport.jingle_s5b.element.JingleS5BTransportCandidateElement;
|
import org.jivesoftware.smackx.jingle.transport.jingle_s5b.element.JingleS5BTransportCandidateElement;
|
||||||
import org.jivesoftware.smackx.jingle.transport.jingle_s5b.element.JingleS5BTransportElement;
|
import org.jivesoftware.smackx.jingle.transport.jingle_s5b.element.JingleS5BTransportElement;
|
||||||
import org.jivesoftware.smackx.jingle.transport.jingle_s5b.element.JingleS5BTransportInfoElement;
|
import org.jivesoftware.smackx.jingle.transport.jingle_s5b.element.JingleS5BTransportInfoElement;
|
||||||
|
|
|
@ -21,7 +21,7 @@ import java.util.ArrayList;
|
||||||
import org.jivesoftware.smackx.jingle.adapter.JingleTransportAdapter;
|
import org.jivesoftware.smackx.jingle.adapter.JingleTransportAdapter;
|
||||||
import org.jivesoftware.smackx.jingle.element.JingleContentTransportCandidateElement;
|
import org.jivesoftware.smackx.jingle.element.JingleContentTransportCandidateElement;
|
||||||
import org.jivesoftware.smackx.jingle.element.JingleContentTransportElement;
|
import org.jivesoftware.smackx.jingle.element.JingleContentTransportElement;
|
||||||
import org.jivesoftware.smackx.jingle.internal.JingleTransportCandidate;
|
import org.jivesoftware.smackx.jingle.components.JingleTransportCandidate;
|
||||||
import org.jivesoftware.smackx.jingle.transport.jingle_s5b.element.JingleS5BTransportCandidateElement;
|
import org.jivesoftware.smackx.jingle.transport.jingle_s5b.element.JingleS5BTransportCandidateElement;
|
||||||
import org.jivesoftware.smackx.jingle.transport.jingle_s5b.element.JingleS5BTransportElement;
|
import org.jivesoftware.smackx.jingle.transport.jingle_s5b.element.JingleS5BTransportElement;
|
||||||
|
|
||||||
|
|
|
@ -26,8 +26,8 @@ import org.jivesoftware.smackx.bytestreams.socks5.Socks5Client;
|
||||||
import org.jivesoftware.smackx.bytestreams.socks5.Socks5ClientForInitiator;
|
import org.jivesoftware.smackx.bytestreams.socks5.Socks5ClientForInitiator;
|
||||||
import org.jivesoftware.smackx.bytestreams.socks5.packet.Bytestream;
|
import org.jivesoftware.smackx.bytestreams.socks5.packet.Bytestream;
|
||||||
import org.jivesoftware.smackx.jingle.transport.jingle_s5b.element.JingleS5BTransportCandidateElement;
|
import org.jivesoftware.smackx.jingle.transport.jingle_s5b.element.JingleS5BTransportCandidateElement;
|
||||||
import org.jivesoftware.smackx.jingle.internal.JingleSession;
|
import org.jivesoftware.smackx.jingle.components.JingleSession;
|
||||||
import org.jivesoftware.smackx.jingle.internal.JingleTransportCandidate;
|
import org.jivesoftware.smackx.jingle.components.JingleTransportCandidate;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Jingle SOCKS5Bytestream transport candidate.
|
* Jingle SOCKS5Bytestream transport candidate.
|
||||||
|
|
|
@ -37,16 +37,16 @@ import org.jivesoftware.smackx.bytestreams.socks5.packet.Bytestream;
|
||||||
import org.jivesoftware.smackx.disco.ServiceDiscoveryManager;
|
import org.jivesoftware.smackx.disco.ServiceDiscoveryManager;
|
||||||
import org.jivesoftware.smackx.jingle.JingleManager;
|
import org.jivesoftware.smackx.jingle.JingleManager;
|
||||||
import org.jivesoftware.smackx.jingle.element.JingleElement;
|
import org.jivesoftware.smackx.jingle.element.JingleElement;
|
||||||
import org.jivesoftware.smackx.jingle.internal.JingleContent;
|
import org.jivesoftware.smackx.jingle.components.JingleContent;
|
||||||
import org.jivesoftware.smackx.jingle.internal.JingleSession;
|
import org.jivesoftware.smackx.jingle.components.JingleSession;
|
||||||
import org.jivesoftware.smackx.jingle.internal.JingleTransport;
|
import org.jivesoftware.smackx.jingle.components.JingleTransport;
|
||||||
import org.jivesoftware.smackx.jingle.internal.JingleTransportCandidate;
|
import org.jivesoftware.smackx.jingle.components.JingleTransportCandidate;
|
||||||
import org.jivesoftware.smackx.jingle.provider.JingleContentProviderManager;
|
import org.jivesoftware.smackx.jingle.provider.JingleContentProviderManager;
|
||||||
import org.jivesoftware.smackx.jingle.transport.jingle_s5b.element.JingleS5BTransportCandidateElement;
|
import org.jivesoftware.smackx.jingle.transport.jingle_s5b.element.JingleS5BTransportCandidateElement;
|
||||||
import org.jivesoftware.smackx.jingle.transport.jingle_s5b.element.JingleS5BTransportElement;
|
import org.jivesoftware.smackx.jingle.transport.jingle_s5b.element.JingleS5BTransportElement;
|
||||||
import org.jivesoftware.smackx.jingle.transport.jingle_s5b.element.JingleS5BTransportInfoElement;
|
import org.jivesoftware.smackx.jingle.transport.jingle_s5b.element.JingleS5BTransportInfoElement;
|
||||||
import org.jivesoftware.smackx.jingle.transport.jingle_s5b.provider.JingleS5BTransportProvider;
|
import org.jivesoftware.smackx.jingle.transport.jingle_s5b.provider.JingleS5BTransportProvider;
|
||||||
import org.jivesoftware.smackx.jingle.transport.JingleTransportManager;
|
import org.jivesoftware.smackx.jingle.JingleTransportManager;
|
||||||
import org.jivesoftware.smackx.jingle.element.JingleAction;
|
import org.jivesoftware.smackx.jingle.element.JingleAction;
|
||||||
import org.jivesoftware.smackx.jingle.element.JingleContentElement;
|
import org.jivesoftware.smackx.jingle.element.JingleContentElement;
|
||||||
|
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package org.jivesoftware.smackx.jingle;
|
package org.jivesoftware.smackx.jingle.util;
|
||||||
|
|
||||||
import org.jxmpp.jid.FullJid;
|
import org.jxmpp.jid.FullJid;
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package org.jivesoftware.smackx.jingle;
|
package org.jivesoftware.smackx.jingle.util;
|
||||||
|
|
||||||
public enum Role {
|
public enum Role {
|
||||||
initiator,
|
initiator,
|
|
@ -21,6 +21,7 @@ import static junit.framework.TestCase.assertNotSame;
|
||||||
import static junit.framework.TestCase.assertTrue;
|
import static junit.framework.TestCase.assertTrue;
|
||||||
|
|
||||||
import org.jivesoftware.smack.test.util.SmackTestSuite;
|
import org.jivesoftware.smack.test.util.SmackTestSuite;
|
||||||
|
import org.jivesoftware.smackx.jingle.util.FullJidAndSessionId;
|
||||||
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.jxmpp.jid.FullJid;
|
import org.jxmpp.jid.FullJid;
|
||||||
|
|
Loading…
Reference in a new issue