summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/com/isode/stroke/filetransfer/FileTransferManagerImpl.java21
-rw-r--r--src/com/isode/stroke/filetransfer/FileTransferOptions.java15
2 files changed, 33 insertions, 3 deletions
diff --git a/src/com/isode/stroke/filetransfer/FileTransferManagerImpl.java b/src/com/isode/stroke/filetransfer/FileTransferManagerImpl.java
index da5e120..386bfa9 100644
--- a/src/com/isode/stroke/filetransfer/FileTransferManagerImpl.java
+++ b/src/com/isode/stroke/filetransfer/FileTransferManagerImpl.java
@@ -1,13 +1,13 @@
/*
* Copyright (c) 2011 Tobias Markmann
* Licensed under the simplified BSD license.
* See Documentation/Licenses/BSD-simplified.txt for more information.
*/
/*
- * Copyright (c) 2013-2015 Isode Limited.
+ * Copyright (c) 2013-2016 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
/*
* Copyright (c) 2015 Tarun Gupta.
* Licensed under the simplified BSD license.
@@ -29,17 +29,19 @@ import com.isode.stroke.network.NetworkEnvironment;
import com.isode.stroke.presence.PresenceOracle;
import com.isode.stroke.network.TimerFactory;
import com.isode.stroke.base.IDGenerator;
import com.isode.stroke.elements.DiscoInfo;
import com.isode.stroke.elements.Presence;
import com.isode.stroke.elements.JingleFileTransferFileInfo;
+
import java.io.File;
import java.util.Date;
import java.util.TimeZone;
import java.util.Vector;
import java.util.Collection;
+import java.util.logging.Logger;
public class FileTransferManagerImpl extends FileTransferManager {
private OutgoingFileTransferManager outgoingFTManager;
private IncomingFileTransferManager incomingFTManager;
private FileTransferTransporterFactory transporterFactory;
@@ -47,12 +49,14 @@ public class FileTransferManagerImpl extends FileTransferManager {
private EntityCapsProvider capsProvider;
private PresenceOracle presenceOracle;
private IDGenerator idGenerator;
private SOCKS5BytestreamRegistry bytestreamRegistry;
private SOCKS5BytestreamProxiesManager bytestreamProxy;
private SOCKS5BytestreamServerManager s5bServerManager;
+
+ private final Logger logger = Logger.getLogger(this.getClass().getName());
public FileTransferManagerImpl(
final JID ownJID,
JingleSessionManager jingleSessionManager,
IQRouter router,
EntityCapsProvider capsProvider,
@@ -150,12 +154,27 @@ public class FileTransferManagerImpl extends FileTransferManager {
return null;
}
}
assert(!iqRouter.getJID().isBare());
+ DiscoInfo capabilities = capsProvider.getCaps(receipient);
+
+ FileTransferOptions options = new FileTransferOptions(config);
+ if (capabilities != null) {
+ if (!capabilities.hasFeature(DiscoInfo.JingleTransportsS5BFeature)) {
+ options = options.withAssistedAllowed(false).withDirectAllowed(false).withProxiedAllowed(false);
+ }
+ if (!capabilities.hasFeature(DiscoInfo.JingleTransportsIBBFeature)) {
+ options = options.withInBandAllowed(false);
+ }
+ }
+ else {
+ logger.warning("No entity capabilities information for "+receipient.toString()+"\n");
+ }
+
return outgoingFTManager.createOutgoingFileTransfer(iqRouter.getJID(), receipient, bytestream, fileInfo, config);
}
public void start() {
}
diff --git a/src/com/isode/stroke/filetransfer/FileTransferOptions.java b/src/com/isode/stroke/filetransfer/FileTransferOptions.java
index fd529e9..73fe1a1 100644
--- a/src/com/isode/stroke/filetransfer/FileTransferOptions.java
+++ b/src/com/isode/stroke/filetransfer/FileTransferOptions.java
@@ -1,33 +1,44 @@
/*
- * Copyright (c) 2013-2015 Isode Limited.
+ * Copyright (c) 2013-2016 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
/*
* Copyright (c) 2015 Tarun Gupta.
* Licensed under the simplified BSD license.
* See Documentation/Licenses/BSD-simplified.txt for more information.
*/
package com.isode.stroke.filetransfer;
public class FileTransferOptions {
-
+
private boolean allowInBand_;
private boolean allowAssisted_;
private boolean allowProxied_;
private boolean allowDirect_;
public FileTransferOptions() {
allowInBand_ = true;
allowAssisted_ = true;
allowProxied_ = true;
allowDirect_ = true;
}
+ /**
+ * Copy constructor
+ * @param other {@link FileTransferOptions} to copy
+ */
+ public FileTransferOptions(FileTransferOptions other) {
+ this.allowInBand_ = other.allowInBand_;
+ this.allowAssisted_ = other.allowAssisted_;
+ this.allowProxied_ = other.allowProxied_;
+ this.allowDirect_ = other.allowDirect_;
+ }
+
public FileTransferOptions withInBandAllowed(boolean b) {
allowInBand_ = b;
return this;
}
public boolean isInBandAllowed() {