//File: CosFileTransfer.idl 
#ifndef _COS_FILE_TRANSFER_IDL_ 
#define _COS_FILE_TRANSFER_IDL_ 

#include <CosProperty.idl> 
#pragma prefix "omg.org" 

module CosFileTransfer { 
  
  typedef string Istring; 
  typedef Istring ProtocolAddress; 
  typedef long ContentType; 

  const ContentType FTAM_1  = 1; 
  const ContentType FTAM_2  = 2; 
  const ContentType FTAM_3  = 3; 
  const ContentType FTAM_4  = 4; 
  const ContentType FTAM_5  = 5; 
  const ContentType NBS_9   = 6; 
  const ContentType INTAP_1 = 7; 
  
  exception CommandNotImplementedException { Istring reason; }; 
  exception SessionException { Istring reason; }; 
  exception TransferException { Istring reason; }; 
  exception FileNotFoundException { Istring reason; };
  exception RequestFailureException { Istring reason; }; 
  exception IllegalOperationException { Istring reason; }; 

  interface VirtualFileSystem; 

  struct AccessLevel { 
    boolean read; 
    boolean insert; 
    boolean replace; 
    boolean extend; 
    boolean erase; 
    boolean read_attr; 
    boolean change_attr; 
    boolean delete; 
  }; 

  typedef sequence<ProtocolAddress> ProtocolAddressList; 
  
  struct ProtocolSupport { 
    Istring protocol_name; 
    ProtocolAddressList addresses; 
  }; 

  typedef sequence<ProtocolSupport> SupportedProtocolAddresses; 

  interface Directory; 
  interface FileTransferSession; 

  typedef Istring FileName; 
  typedef sequence<FileName> FileNameList; 

  interface File:CosPropertyService::PropertySetDef { 

    readonly attribute FileName name;
    readonly attribute FileNameList complete_file_name; 
    readonly attribute Directory parent; 
    readonly attribute FileTransferSession associated_session; 

  }; 

  enum FileType {nfile, ndirectory}; 
  
  struct FileWrapper { 
    File the_file; 
    FileType file_type; 
  }; 

  typedef sequence<FileWrapper> FileList; 

  interface FileIterator; 
  interface Directory : File { 

    void list(in unsigned long how_many, out FileList fl, out FileIterator fi); 

  }; 

  interface FileIterator { 
    
    boolean next_one(out FileWrapper f); 
    boolean next_n(in unsigned long how_many, out FileList fl); 

    void destroy(); 
  }; 

  interface FileTransferSession { 

    readonly attribute SupportedProtocolAddresses protocols_supported; 

    void set_directory(in Directory new_directory) 
      raises(SessionException, FileNotFoundException, RequestFailureException, 
	     IllegalOperationException); 

    File create_file(in FileNameList name) 
      raises(SessionException, FileNotFoundException, RequestFailureException, 
	     IllegalOperationException);

    Directory create_directory(in FileNameList name) 
      raises(SessionException, FileNotFoundException, RequestFailureException, 
	     IllegalOperationException); 

    FileWrapper get_file(in FileNameList complete_file_name) 
      raises(SessionException, FileNotFoundException, RequestFailureException, 
	     IllegalOperationException); 

    void delete(in File file) 
      raises(SessionException, FileNotFoundException, RequestFailureException,
	     IllegalOperationException); 

    void transfer(in File src, in File dest) 
      raises(SessionException, TransferException, FileNotFoundException, 
	     RequestFailureException, IllegalOperationException); 

    void append(in File src, in File dest) 
      raises(CommandNotImplementedException, SessionException, TransferException, 
	     FileNotFoundException, RequestFailureException, 
	     IllegalOperationException); 

    void insert(in File src, in File dest, in long offset) 
      raises(CommandNotImplementedException, SessionException, TransferException, 
	     FileNotFoundException, RequestFailureException, 
	     IllegalOperationException); 

    void logout();
    
    // WARNING!!!
    // Theses are Orber specific operations and may only be used internally!!
    // Maybe removed, altered and changed in any way without warning!!
    Directory oe_orber_create_directory_current() 
      raises(SessionException, FileNotFoundException, IllegalOperationException); 
    FileList oe_orber_get_content(in FileNameList complete_file_name,
				  in Directory parent); 
    long oe_orber_count_children(in FileNameList complete_file_name); 

  }; 

  interface VirtualFileSystem { 

    enum NativeFileSystemType { FTAM, FTP, NATIVE }; 

    readonly attribute NativeFileSystemType file_system_type; 

    typedef sequence<ContentType> ContentList; 
    
    readonly attribute ContentList supported_content_types; 

    FileTransferSession login(in Istring username, in Istring password, 
			      in Istring account, out Directory root) 
      raises(SessionException, FileNotFoundException, IllegalOperationException); 
  }; 
}; 

#endif //_COS_FILE_TRANSFER_IDL_
