remotestoragefw/remotefileengine/inc/rsfwsession.h
branchRCL_3
changeset 19 88ee4cf65e19
parent 16 87c71b25c937
child 20 1aa8c82cb4cb
equal deleted inserted replaced
16:87c71b25c937 19:88ee4cf65e19
     1 /*
       
     2 * Copyright (c) 2002-2004 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:  Defines the standard Symbian IPC for using Access API
       
    15  *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef RRSFWSESSION_H
       
    20 #define RRSFWSESSION_H
       
    21 
       
    22 //  INCLUDES
       
    23 #include <e32base.h>
       
    24 //#include <f32file.h>
       
    25 //#include <s32strm.h>
       
    26 
       
    27 //  INTERNAL INCLUDES
       
    28 //#include "rsfwcontrol.h"
       
    29 #include "rsfwcommon.h"
       
    30 //#include "rsfwinterface.h"
       
    31 class TFid;
       
    32 class TEntry;
       
    33 class TDirEntAttr;
       
    34 
       
    35 enum TRequestCodes
       
    36     {
       
    37     ERequestPending
       
    38     };
       
    39 
       
    40 
       
    41 // CLASS DECLARATION
       
    42 /**
       
    43  *  This class provides the client-side interface to the server session.
       
    44  *
       
    45  *  @lib rsfwsession.dll
       
    46  *  @since Series 60 3.1
       
    47  */
       
    48 class RRsfwSession : public RSessionBase
       
    49     {
       
    50 public: // Constructors and destructor
       
    51     /**
       
    52      * Constructor.
       
    53      */
       
    54     IMPORT_C RRsfwSession();
       
    55     
       
    56 public: // New functions
       
    57     /**
       
    58      * Connect to the server and create a session.
       
    59      * @since Series 60 3.1
       
    60      * @param aServerName Server name.
       
    61      * @return Standard error code.
       
    62      */    
       
    63     IMPORT_C TInt Connect();
       
    64     
       
    65      /**
       
    66      * Close the session
       
    67      * @since Series 60 3.1
       
    68      */    
       
    69     IMPORT_C void Close();    
       
    70     
       
    71     /**
       
    72      * Get the server version number.
       
    73      * @since Series 60 3.1
       
    74      * @return The version number of the server.
       
    75      */            
       
    76     IMPORT_C TVersion Version() const;
       
    77         
       
    78      /**
       
    79      * Issue request to rename or replace a file or a directory
       
    80      * @since Series 60 3.1
       
    81      * @param aSourceFid   Fid of the source file's parent directory
       
    82      * @param aSourceName  The name of the object to be renamed
       
    83      *                   (for dirs must have a trailing backslash)
       
    84      * @param aDestFid     Fid of the destination directory
       
    85      * @param aDestName    The name of the target object
       
    86      *                  (for dirs must have a trailing backslash)
       
    87      * @return
       
    88      */
       
    89     IMPORT_C TInt MoveFids( TFid aSourceFid, 
       
    90                              const TDesC& aSourceName, 
       
    91                              TFid aDestFid, 
       
    92                              const TDesC& aDestName,
       
    93                              TBool aOverWrite );
       
    94     
       
    95    /**
       
    96      * Issue request to set entry details for a specified file or directory.
       
    97      * @since Series60 3.1
       
    98      * @param aFid   Fid of the target file or directory
       
    99      * @param aTime  A reference to the time object holding the new universal
       
   100      *               modified time for aName.
       
   101      * @param aSetAttMask   Attribute mask for setting the entry's attributes.
       
   102      * @param aClearAttMask Attribute mask for clearing the entry's attributes.
       
   103      * @return
       
   104      */                              
       
   105     IMPORT_C TInt SetEntry( TFid aFid,
       
   106                              const TTime& aTime,
       
   107                              TUint aSetAttMask,
       
   108                              TUint aClearAttMask);
       
   109                              
       
   110     /**
       
   111      * Issue request to flush an entry from the cache.
       
   112      * @since Series 60 3.1
       
   113      * @param aFid The fid of the file or directory to be flushed.
       
   114      * @return
       
   115      */  
       
   116     IMPORT_C TInt FlushCache( TFid& aFid );                  
       
   117                              
       
   118     /**
       
   119      * Issue request to raise the cache priority of an already
       
   120      * cached file.
       
   121      * @since Series 60 3.1
       
   122      * @param aFid The fid of the file.
       
   123      * @return
       
   124      */      
       
   125     IMPORT_C TInt SetHighCachePriority( TFid& aFid );   
       
   126     
       
   127     /**
       
   128      * Issue request to fetch file or directory attributes.
       
   129      * @since Series 60 3.1
       
   130      * @param aFileFid     Fid of the file.
       
   131      * @param aAttributes  On success, contains the file attributes 
       
   132      *                     (TEntry::iName is not filled)
       
   133      * @return 
       
   134      */                                   
       
   135     IMPORT_C TInt GetAttributes( TFid aFileFid, 
       
   136                                  TEntry& aAttributes );    
       
   137                          
       
   138      /**
       
   139      * Issue request to open this fid and return the path of the container file
       
   140      * Note that this is "OPEN" operation, e.g. if the mode is relevant a lock
       
   141      * will be acquired and will be refreshed until the file is closed.
       
   142      * @since Series 60 3.1
       
   143      * @param aFid        Fid of the file or directory.
       
   144      * @param aContainer  Pointer to descriptor which will, on success, contain 
       
   145      *                    the full path of the container file.
       
   146      * @param aAttr       aAttr.iAtt: Open mode, controls acquiring locks etc. 
       
   147      *                    on return, contains size etc.
       
   148      * @param aTrueOpen   Whether File Server opens the file, or ReadSection was called in
       
   149      *                    which case we also mimic the sequence of opening a file  
       
   150      *                    (file is not candidate for removing from cache if it has been
       
   151      *                     opened by the File Server).         
       
   152      * @return 
       
   153      */             
       
   154     IMPORT_C TInt OpenByPath( TFid aFid, 
       
   155                               TDes& aContainerPath, 
       
   156                               TDirEntAttr* aAttr, 
       
   157                               TBool aTrueOpen);   
       
   158      
       
   159     /**
       
   160      * Issue request to initialize the remote mount.
       
   161      * @since Series 60 3.1
       
   162      * @param   Upon successfull return, will contain the Fid of the root directory
       
   163      * @return 
       
   164      */
       
   165     IMPORT_C TInt RfeInit(TFid& aRootFid);         
       
   166     
       
   167     
       
   168     /**
       
   169      * Issue request to make a directory.
       
   170      * @since Series 60 3.1
       
   171      * @param aParentFid Fid of the parent directory.
       
   172      * @param aDirName   The name of the new directory.
       
   173      * @return
       
   174      */ 
       
   175     IMPORT_C TInt MakeDirectory( TFid aParentFid, 
       
   176                                  const TDesC& aDirName );
       
   177                                     
       
   178     /**
       
   179      * Issue request to remove a directory.
       
   180      * @since Series 60 3.1
       
   181      * @param aParentFid Fid of the parent directory.
       
   182      * @param aDirName   The name of the directory to be removed.
       
   183      * @return
       
   184      */
       
   185     IMPORT_C TInt RemoveDirectory( TFid aParentFid, 
       
   186                                    const TDesC& aDirName );
       
   187                               
       
   188 
       
   189      /**
       
   190      * Issue request to create and open a file.
       
   191      * Note that this is "OPEN" operation, e.g. if the mode is relevant a lock
       
   192      * will be acquired and will be refreshed until the file is closed.
       
   193      * @since Series 60 3.1
       
   194      * @param aParentFid Fid of the parent directory.
       
   195      * @param aFileName  The name of the new file.
       
   196      * @param aMode      The mode in which the file will be opened.
       
   197      * @param aExcl      Boolean indicating whether it is ok to overwrite an existing file.
       
   198      *                   (ETrue = exclusive = no overwriting)
       
   199      * @param aNewFid       Upon successful return, contains the fid of the new file
       
   200      * @return 
       
   201      */        
       
   202     IMPORT_C TInt CreateFile( TFid aParentFid, 
       
   203                       const TDesC& aFileName, 
       
   204                       TUint aMode, 
       
   205                       TUint aExcl,
       
   206                       TFid& aNewFid);
       
   207 
       
   208     /**
       
   209      * Issue request to remove a file.
       
   210      * @since Series 60 3.1
       
   211      * @param aParentFid Fid of the parent directory.
       
   212      * @param aFileName   The name of the file to be removed.
       
   213      * @return
       
   214      */
       
   215     IMPORT_C TInt RemoveFile( TFid aParentFid, 
       
   216                       const TDesC& aFileName );
       
   217 
       
   218 
       
   219     /**
       
   220      * finds the fid of a file system object
       
   221      * @since Series 60 3.1
       
   222      * @param aParentFid fid of the parent directory
       
   223      * @param aName name of the child to be looked up
       
   224      * @param aNodeType is the type of the child, 
       
   225      *                  KNodeTypeUnknown,KNodeTypeFile or KNodeTypeDir
       
   226      *      (also a trailing backslash in the name indicates KNodeTypeDir)
       
   227      * @param aFid upon successful return contains the fid 
       
   228      *        of the object to be looked up
       
   229      * @return
       
   230      */        
       
   231     IMPORT_C TInt Lookup( TFid aParentFid, 
       
   232                   const TDesC& aName, 
       
   233                   TUint aNodeType,
       
   234                   TFid& aFid );
       
   235                   
       
   236      /**
       
   237      * Tells Remote File Engine that a file has been closed
       
   238      * @since Series 60 3.1
       
   239      * @param aFid Fid of the file that was closed
       
   240      * @param aFlags whether the file has been changed
       
   241      * @return 
       
   242      */
       
   243     IMPORT_C void CloseFile( const TFid aFid, 
       
   244                  TUint aFlags); 
       
   245                  
       
   246             
       
   247      /**
       
   248      * Tells Remote File Engine to write a file that has been 
       
   249      * modified back to the server. However, File Server does
       
   250      * not close the file.
       
   251      * @since Series 60 3.1
       
   252      * @param aFid Fid of the file to be flushed
       
   253      * @param aFirstByte the first byte to be flushed
       
   254      * @param aLastByte the first byte to be flushed
       
   255      * @param aTotalSize the full size of the file
       
   256      * @return 
       
   257      */
       
   258     IMPORT_C TInt Flush( const TFid aFid,
       
   259                          TInt aFirstByte,
       
   260                          TInt aDataLength,
       
   261                          TInt aTotalSize );
       
   262         
       
   263     /**
       
   264      * Issue requet to fetch and cache a file or a directory
       
   265      * @since Series 60 3.1
       
   266      * @param aFileFid the fid of the file to be cached
       
   267      * @param aFirstByte the first byte to be cached (0 for dirs)
       
   268      * @param aLastByte the last byte to be cached (0 for dirs)
       
   269      * @param aCachedBytes upon succesful return,
       
   270      *          the number of bytes cached after this fetch
       
   271      * @return
       
   272      */
       
   273     IMPORT_C TInt Fetch( TFid aFileFid, 
       
   274                  TInt aFirstByte, 
       
   275                  TInt aLastByte,
       
   276                  TInt& aCachedBytes );                      
       
   277 
       
   278 
       
   279     /**
       
   280      * Issue request to fetch data without permanent caching.
       
   281      * @since Series 60 3.1
       
   282      * @param aFileFid the fid of the file to be fetched
       
   283      * @param aFirstByte the first byte to be fetched
       
   284      * @param aLastByte the last byte to be fetched
       
   285      * @param aTempFileName the path of the temp file 
       
   286      *        where the data will be stored
       
   287      * @param aUseTempPath FALSE if the caching mode was such
       
   288      *                     that the data was anyway stored into
       
   289      *                     the normal cache file.
       
   290      *        
       
   291      * @return 
       
   292      */    
       
   293     IMPORT_C TInt FetchData( TFid aFileFid, 
       
   294                       TInt aFirstByte, 
       
   295                       TInt aLastByte,
       
   296                       TDes& aTempFileName,
       
   297                       TBool& aUseTempPath);
       
   298 
       
   299     /**
       
   300      * Queries from Remote File Engine whether there is enough local cache 
       
   301      * space to write aBytes of data
       
   302      * @since Series 60 3,1
       
   303      * @param aFid   fid of the file whose data will be written
       
   304      * @param aBytes the number of bytes to be written
       
   305      * @return a boolean value indicating whether the data can be written
       
   306      */
       
   307     IMPORT_C TInt OkToWrite( TFid aFid, 
       
   308                             TUint aBytes,
       
   309                             TBool& aOkToWrite );
       
   310 
       
   311 private:
       
   312     static TInt StartServer( const TDesC& aServerName );
       
   313     static TInt CreateServerProcess( const TDesC& aServerName );
       
   314     TInt SendRequest(TInt aOpCode, TInt aDrive, TIpcArgs aArgs);
       
   315     };
       
   316 
       
   317 #endif // RRSFWSESSION_H
       
   318 
       
   319 // End of File