public interface ISendFileTransferContainerAdapter
extends org.eclipse.core.runtime.IAdaptable
IContainer.getAdapter(Class). Once a non-null
reference is retrieved, then it may be used to request to send a file to a
remote user. Events will then be asynchronously delivered to the provided
listener to complete file transfer.
To request and initiate sending a local file to a remote user:
// Get ISendFileTransferContainerAdapter adapter
ISendFileTransferContainerAdapter ftc = (ISendFileTransferContainerAdapter) container.getAdapter(ISendFileTransferContainerAdapter.class);
if (ftc != null) {
// Create listener for receiving/responding to asynchronous file transfer events
IFileTransferListener listener = new IFileTransferListener() {
public void handleTransferEvent(IFileTransferEvent event) {
// If this event is a response to the transfer request, check if file transfer rejected
if (event instanceof IOutgoingFileTransferResponseEvent) {
IOutgoingFileTransferResponseEvent oftr = (IOutgoingFileTransferResponseEvent) event;
if (!oftr.requestAccepted()) {
// request rejected...tell user
}
}
}
};
// Specify the target file ID
// This following specifies the path: ~/path/filename.ext
ID targetID = FileIDFactory.getDefault().createFileID(ftc.getOutgoingNamespace(),new URL("scp://user@host/path/filename.ext"));
// This following specifies the path: /path/filename.ext
// ID targetID = FileIDFactory.getDefault().createFileID(ftc.getOutgoingNamespace(),new URL("scp://user@host//path/filename.ext"));
// Specify the local file to send
File localFileToSend = new File("filename");
// Actually send outgoing file request to remote user.
ftc.sendOutgoingRequest(targetID, localFileToSend, listener, null);
}
For the sender the delivered events will be:
IOutgoingFileTransferResponseEventIOutgoingFileTransferSendDataEventIOutgoingFileTransferSendDoneEventIIncomingFileTransferRequestListener events
delivered will be:
| Modifier and Type | Method and Description |
|---|---|
void |
addListener(IIncomingFileTransferRequestListener listener)
Add incoming file transfer listener.
|
Namespace |
getOutgoingNamespace()
Get namespace for outgoing file transfer.
|
boolean |
removeListener(IIncomingFileTransferRequestListener listener)
Remove incoming file transfer listener
|
void |
sendOutgoingRequest(IFileID targetReceiver,
File localFileToSend,
IFileTransferListener transferListener,
Map options)
Send request for outgoing file transfer.
|
void |
sendOutgoingRequest(IFileID targetReceiver,
IFileTransferInfo localFileToSend,
IFileTransferListener transferListener,
Map options)
Send request for outgoing file transfer.
|
void |
setConnectContextForAuthentication(IConnectContext connectContext)
Set connect context for authentication upon subsequent
sendOutgoingRequest(IFileID, IFileTransferInfo, IFileTransferListener, Map). |
void |
setProxy(Proxy proxy)
Set proxy for use upon subsequent
sendOutgoingRequest(IFileID, IFileTransferInfo, IFileTransferListener, Map). |
void sendOutgoingRequest(IFileID targetReceiver, IFileTransferInfo localFileToSend, IFileTransferListener transferListener, Map options) throws SendFileTransferException
targetReceiver - the ID of the remote to receive the file transfer request.
Must not be should not be null.localFileToSend - the IFileTransferInfo for the local file to send. Must
not be should not be null.transferListener - a IFileTransferListener for responding to file
transfer events. Must not be should not be null..
If the target receiver responds then an
IOutgoingFileTransferResponseEvent will be delivered
to the listeneroptions - a Map of options associated with sendOutgoingRequest. The
particular name/value pairs will be unique to the individual
providers. May be should not be null..SendFileTransferException - if the provider is not connected or is not in the correct
state for initiating file transfervoid sendOutgoingRequest(IFileID targetReceiver, File localFileToSend, IFileTransferListener transferListener, Map options) throws SendFileTransferException
targetReceiver - the ID of the remote to receive the file transfer request.
Must not be null.localFileToSend - the File for the local file to send. Must not be
null.transferListener - a IFileTransferListener for responding to file
transfer events. Must not be null. If the
target receiver responds then an IOutgoingFileTransfer will be
delivered to the listeneroptions - a Map of options associated with sendOutgoingRequest. The
particular name/value pairs will be unique to the individual
providers. May be null.SendFileTransferException - if the provider is not connected or is not in the correct
state for initiating file transfervoid addListener(IIncomingFileTransferRequestListener listener)
listener - to receive incoming file transfer request events. Must not be
null.boolean removeListener(IIncomingFileTransferRequestListener listener)
listener - the listener to remove. Must not be null.Namespace getOutgoingNamespace()
null.void setConnectContextForAuthentication(IConnectContext connectContext)
sendOutgoingRequest(IFileID, IFileTransferInfo, IFileTransferListener, Map). This
method should be called with a non-null connectContext in order to allow
authentication to occur during call to
sendOutgoingRequest(IFileID, IFileTransferInfo, IFileTransferListener, Map).connectContext - the connect context to use for authenticating during
subsequent call to
sendOutgoingRequest(IFileID, IFileTransferInfo, IFileTransferListener, Map).
If null, then no authentication will be
attempted.void setProxy(Proxy proxy)
sendOutgoingRequest(IFileID, IFileTransferInfo, IFileTransferListener, Map). This
method should be called with a non-null proxy to allow the given proxy to
be used in subsequent calls to
sendOutgoingRequest(IFileID, IFileTransferInfo, IFileTransferListener, Map).proxy - the proxy to use for subsequent calls to
sendOutgoingRequest(IFileID, IFileTransferInfo, IFileTransferListener, Map).
If null, then no proxy will be used.Copyright © 2004–2020 Eclipse Foundation. All rights reserved.