org.eclipse.ecf.filetransfer
Interface IOutgoingFileTransferContainerAdapter

All Known Subinterfaces:
ISendFileTransfer

public interface IOutgoingFileTransferContainerAdapter

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 IOutgoingFileTransferContainerAdapter adapter
       IOutgoingFileTransferContainerAdapter ftc = (IOutgoingFileTransferContainerAdapter) container.getAdapter(IOutgoingFileTransferContainerAdapter.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 user to receive file being sent
           ID userID = target user id to receive file;
           // Specify the local file to send
           File localFileToSend = new File("filename");
           // Actually send outgoing file request to remote user.  
           ftc.sendOutgoingRequest(userID, localFileToSend, listener, null);
       }
 
For the sender the delivered events will be: and for the IIncomingFileTransferRequestListener events delivered will be:


Method Summary
 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, java.io.File localFileToSend, IFileTransferListener transferListener, java.util.Map options)
          Send request for outgoing file transfer.
 void sendOutgoingRequest(IFileID targetReceiver, IFileTransferInfo localFileToSend, IFileTransferListener transferListener, java.util.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).
 

Method Detail

sendOutgoingRequest

void sendOutgoingRequest(IFileID targetReceiver,
                         IFileTransferInfo localFileToSend,
                         IFileTransferListener transferListener,
                         java.util.Map options)
                         throws OutgoingFileTransferException
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 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 listener
options - 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..
Throws:
OutgoingFileTransferException - if the provider is not connected or is not in the correct state for initiating file transfer

sendOutgoingRequest

void sendOutgoingRequest(IFileID targetReceiver,
                         java.io.File localFileToSend,
                         IFileTransferListener transferListener,
                         java.util.Map options)
                         throws OutgoingFileTransferException
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 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 listener
options - a Map of options associated with sendOutgoingRequest. The particular name/value pairs will be unique to the individual providers. May be null.
Throws:
OutgoingFileTransferException - if the provider is not connected or is not in the correct state for initiating file transfer

addListener

void addListener(IIncomingFileTransferRequestListener listener)
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 be null.

removeListener

boolean removeListener(IIncomingFileTransferRequestListener listener)
Remove incoming file transfer listener

Parameters:
listener - the listener to remove. Must not be null.
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

void setConnectContextForAuthentication(IConnectContext connectContext)
Set connect context for authentication upon subsequent 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).

Parameters:
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.

setProxy

void setProxy(Proxy proxy)
Set proxy for use upon subsequent 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).

Parameters:
proxy - the proxy to use for subsequent calls to sendOutgoingRequest(IFileID, IFileTransferInfo, IFileTransferListener, Map). If null, then no proxy will be used.