Package org.eclipse.ecf.filetransfer
Interface ISendFileTransferContainerAdapter
- All Superinterfaces:
org.eclipse.core.runtime.IAdaptable
- All Known Subinterfaces:
ISendFileTransfer
- All Known Implementing Classes:
AbstractOutgoingFileTransfer,AbstractUrlConnectionOutgoingFileTransfer,LocalFileOutgoingFileTransfer,MultiProtocolOutgoingAdapter
public interface ISendFileTransferContainerAdapter
extends org.eclipse.core.runtime.IAdaptable
Entry point outgoing file transfer container adapter. This adapter interface
allows providers to expose file sending semantics to clients in a transport
independent manner. To be used, a non-null adapter reference must be returned
from a call to
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:
IOutgoingFileTransferResponseEventIOutgoingFileTransferSendDataEventIOutgoingFileTransferSendDoneEvent
IIncomingFileTransferRequestListener events
delivered will be:
-
Method Summary
Modifier and TypeMethodDescriptionvoidAdd incoming file transfer listener.Get namespace for outgoing file transfer.booleanRemove incoming file transfer listenervoidsendOutgoingRequest(IFileID targetReceiver, File localFileToSend, IFileTransferListener transferListener, Map options) Send request for outgoing file transfer.voidsendOutgoingRequest(IFileID targetReceiver, IFileTransferInfo localFileToSend, IFileTransferListener transferListener, Map options) Send request for outgoing file transfer.voidsetConnectContextForAuthentication(IConnectContext connectContext) Set connect context for authentication upon subsequentsendOutgoingRequest(IFileID, IFileTransferInfo, IFileTransferListener, Map).voidSet proxy for use upon subsequentsendOutgoingRequest(IFileID, IFileTransferInfo, IFileTransferListener, Map).Methods inherited from interface org.eclipse.core.runtime.IAdaptable
getAdapter
-
Method Details
-
sendOutgoingRequest
void sendOutgoingRequest(IFileID targetReceiver, IFileTransferInfo localFileToSend, IFileTransferListener transferListener, Map options) throws SendFileTransferException Send request for outgoing file transfer. This method is used to initiate a file transfer to a targetReceiver (first parameter) of the localFileToSend (second parameter). File transfer events are asynchronously delivered to the file transferListener (third parameter)- Parameters:
targetReceiver- the ID of the remote to receive the file transfer request. Must not be should not benull.localFileToSend- theIFileTransferInfofor the local file to send. Must not be should not benull.transferListener- aIFileTransferListenerfor responding to file transfer events. Must not be should not benull.. If the target receiver responds then anIOutgoingFileTransferResponseEventwill 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 benull..- Throws:
SendFileTransferException- if the provider is not connected or is not in the correct state for initiating file transfer
-
sendOutgoingRequest
void sendOutgoingRequest(IFileID targetReceiver, File localFileToSend, IFileTransferListener transferListener, Map options) throws SendFileTransferException Send request for outgoing file transfer. This method is used to initiate a file transfer to a targetReceiver (first parameter) of the localFileToSend (second parameter). File transfer events are asynchronously delivered to the file transferListener (third parameter)- Parameters:
targetReceiver- the ID of the remote to receive the file transfer request. Must not benull.localFileToSend- theFilefor the local file to send. Must not benull.transferListener- aIFileTransferListenerfor responding to file transfer events. Must not benull. 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 benull.- Throws:
SendFileTransferException- if the provider is not connected or is not in the correct state for initiating file transfer
-
addListener
Add incoming file transfer listener. If the underlying provider supports receiving file transfer requests- Parameters:
listener- to receive incoming file transfer request events. Must not benull.
-
removeListener
Remove incoming file transfer listener- Parameters:
listener- the listener to remove. Must not benull.- Returns:
- true if listener actually removed, false otherwise
-
getOutgoingNamespace
Namespace getOutgoingNamespace()Get namespace for outgoing file transfer.- Returns:
- Namespace for outgoing IFileID instances. Will not return
null.
-
setConnectContextForAuthentication
Set connect context for authentication upon subsequentsendOutgoingRequest(IFileID, IFileTransferInfo, IFileTransferListener, Map). This method should be called with a non-null connectContext in order to allow authentication to occur during call tosendOutgoingRequest(IFileID, IFileTransferInfo, IFileTransferListener, Map).- Parameters:
connectContext- the connect context to use for authenticating during subsequent call tosendOutgoingRequest(IFileID, IFileTransferInfo, IFileTransferListener, Map). Ifnull, then no authentication will be attempted.
-
setProxy
Set proxy for use upon subsequentsendOutgoingRequest(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 tosendOutgoingRequest(IFileID, IFileTransferInfo, IFileTransferListener, Map).- Parameters:
proxy- the proxy to use for subsequent calls tosendOutgoingRequest(IFileID, IFileTransferInfo, IFileTransferListener, Map). Ifnull, then no proxy will be used.
-