userlibandfileserver/fileserver/inc/F32plugin.h
changeset 9 96e5fb8b040d
child 8 538db54a451d
equal deleted inserted replaced
-1:000000000000 9:96e5fb8b040d
       
     1 // Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of the License "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 // f32\inc\f32plugin.h
       
    15 // 
       
    16 // WARNING: This file contains some APIs which are internal and are subject
       
    17 //          to change without notice. Such APIs should therefore not be used
       
    18 //          outside the Kernel and Hardware Services package.
       
    19 //
       
    20 
       
    21 /**
       
    22  @file
       
    23  @internalTechnology
       
    24 */
       
    25 
       
    26 
       
    27 #if !defined(__F32PLUGIN_H__)
       
    28 #define __F32PLUGIN_H__
       
    29 
       
    30 #include <f32file.h>
       
    31 #include <f32file_private.h>
       
    32 #include <f32fsys.h>
       
    33 
       
    34 const TInt KPluginMessageForward  = 1; ///< Returned from ::Dispatch() to indicate that a request has been processed synchronously and should be passed down the stack.
       
    35 const TInt KPluginMessageComplete = 2; ///< Returned from ::Dispatch() to indicate that a request has been processed synchronously and should be passed back up the stack.
       
    36 
       
    37 const TInt KCountNeeded=KMinTInt;
       
    38 
       
    39 /**
       
    40 List of file server operations 
       
    41 */
       
    42 enum TFsMessage
       
    43 	{
       
    44 	EFsAddFileSystem,           ///< Adds a file system
       
    45 	EFsRemoveFileSystem,        ///< Removes a file system
       
    46 	EFsMountFileSystem,         ///< Mounts a file system
       
    47 	EFsNotifyChange,            ///< Notifies file and/or directory change
       
    48 	EFsNotifyChangeCancel,      ///< Cancels change notification
       
    49 	EFsDriveList,               ///< Gets a list of the available drive
       
    50 	EFsDrive,                   ///< Gets information about a drive and the medium mounted on it
       
    51 	EFsVolume,                  ///< Gets volume information for a formatted device
       
    52 	EFsSetVolume,               ///< Sets the label for a volume
       
    53     EFsSubst,                   ///< Gets the path assigned to a drive letter
       
    54 	EFsSetSubst,				///< -- 10, Assigns a path to a drive letter
       
    55 	EFsRealName,                ///< Gets the real name of a file
       
    56 	EFsDefaultPath,             ///< Gets the system default path
       
    57 	EFsSetDefaultPath,          ///< Sets the system default path
       
    58 	EFsSessionPath,             ///< Gets the session path
       
    59 	EFsSetSessionPath,          ///< Sets the session path for the current file server client
       
    60 	EFsMkDir,                   ///< Makes directory
       
    61 	EFsRmDir,                   ///< Removes a directory
       
    62 	EFsParse,                   ///< Parses a filename specification
       
    63 	EFsDelete,                  ///< Deletes file
       
    64 	EFsRename,					///< -- 20 Renames a single file or directory
       
    65 	EFsReplace,                 ///< Replaces a single file with another
       
    66 	EFsEntry,                   ///< Gets a file's attributes
       
    67 	EFsSetEntry,                ///< Sets both the attributes and the last modified date and time for a file or directory
       
    68 	EFsGetDriveName,            ///<  Gets the name of a drive
       
    69 	EFsSetDriveName,            ///< Sets the name of a drive
       
    70 	EFsFormatSubClose,          ///< Closes the Format subsession
       
    71 	EFsDirSubClose,             ///< Closes the directory.
       
    72 	EFsFileSubClose,            ///< Closes the file
       
    73 	EFsRawSubClose,             ///< Closes the direct access channel to the disk 
       
    74 	EFsFileOpen,				///< -- 30 Opens file
       
    75 	EFsFileCreate,				///< Creates and opens a new file
       
    76 	EFsFileReplace,             ///< Replaces a file of the same name or creates a new file
       
    77 	EFsFileTemp,				///< Creates and opens a temporary file
       
    78 	EFsFileRead,                ///< Reads from the file
       
    79 	EFsFileWrite,               ///< Writes to the file
       
    80 	EFsFileLock,                ///< Locks a region within the file
       
    81 	EFsFileUnLock,              ///< Unlocks a region within the file
       
    82 	EFsFileSeek,                ///< Sets the the current file position
       
    83 	EFsFileFlush,               ///< Commits data to the storage device
       
    84 	EFsFileSize,				///< -- 40 Gets the current file size
       
    85 	EFsFileSetSize,             ///< Sets the file size
       
    86 	EFsFileAtt,                 ///< Gets the file's attributes
       
    87 	EFsFileSetAtt,				///< Sets or clears file attributes
       
    88 	EFsFileModified,            ///< Gets local date and time the file was last modified
       
    89 	EFsFileSetModified,         ///< Sets the date and time the file was last modified
       
    90 	EFsFileSet,                 ///< Sets the file’s attributes, last modification date/time
       
    91 	EFsFileChangeMode,          ///< Switches an open file's access mode
       
    92 	EFsFileRename,              ///< Renames a file
       
    93 	EFsDirOpen,                 ///< Opens a directory
       
    94 	EFsDirReadOne,				///< -- 50 Reads a single directory entry
       
    95 	EFsDirReadPacked,           ///< Reads all filtered directory entries
       
    96 	EFsFormatOpen,              ///< Opens a device for formatting
       
    97 	EFsFormatNext,              ///< Executes the next format step
       
    98 	EFsRawDiskOpen,             ///< Opens a direct access channel to the disk */
       
    99 	EFsRawDiskRead,             ///< Reads directly from the disk
       
   100 	EFsRawDiskWrite,            ///< Writes directly to the disk
       
   101 	EFsResourceCountMarkStart,  ///< Marks the start of resource count checking
       
   102 	EFsResourceCountMarkEnd,    ///< Ends resource count checking
       
   103 	EFsResourceCount,           ///< Gets the number of currently open resources
       
   104 	EFsCheckDisk,				///< -- 60 Checks the integrity of the disk on the specified drive
       
   105 	EFsGetShortName,            ///< Gets the short filename
       
   106 	EFsGetLongName,             ///< Gets the long filename
       
   107 	EFsIsFileOpen,              ///< Tests whether a file is open
       
   108 	EFsListOpenFiles,           ///< get a list of open files */
       
   109 	EFsGetNotifyUser,           ///< Tests user notification of file access failure is in effect
       
   110 	EFsSetNotifyUser,           ///< Sets if the user should be notified of file access failure
       
   111 	EFsIsFileInRom,             ///< Gets a pointer to the specified file, if it is in ROM
       
   112 	EFsIsValidName,             ///< Tests whether a filename and path are syntactically correct
       
   113 	EFsDebugFunction,           ///< Different debugging info
       
   114 	EFsReadFileSection,			///< -- 70 Reads data from a file without opening it
       
   115 	EFsNotifyChangeEx,          ///< Requests a notification of change to files or directories
       
   116 	EFsNotifyChangeCancelEx,    ///< Cancels all outstanding requests for notification of change
       
   117 	EFsDismountFileSystem,		///< Dismounts the file system from the specified drive
       
   118 	EFsFileSystemName,          ///< Gets the name of the file system mounted on the specified drive
       
   119 	EFsScanDrive,               ///< Checks the specified drive for specific errors and corrects them
       
   120 	EFsControlIo,               ///< General purpose test interface
       
   121 	EFsLockDrive,               ///< Locks a MultiMedia card in the specified drive
       
   122 	EFsUnlockDrive,             ///< Unlocks the MultiMedia card in the specified drive
       
   123 	EFsClearPassword,           ///< Clears the password from the locked MultiMedia card
       
   124 	EFsNotifyDiskSpace,			///< -- 80 Disk space change notification
       
   125 	EFsNotifyDiskSpaceCancel,   ///< Cancels a specific outstanding notification
       
   126 	EFsFileDrive,               ///< Gets drive information on which this file resides
       
   127 	EFsRemountDrive,            ///< Forces a remount of the specified drive
       
   128 	EFsMountFileSystemScan,     ///< Mounts a file system and performs a scan on a drive
       
   129 	EFsSessionToPrivate,        ///< Sets the session path to point to the private path
       
   130 	EFsPrivatePath,             ///< Creates the text defining the private path
       
   131 	EFsCreatePrivatePath,       ///< Creates the private path for a process
       
   132 	EFsAddExtension,            ///< Adds the specified extension
       
   133 	EFsMountExtension,          ///< Mounts the the specified extension
       
   134 	EFsDismountExtension,		///< -- 90 Dismounts the specified extension
       
   135 	EFsRemoveExtension,         ///< Removes the specified extension
       
   136 	EFsExtensionName,	        ///< Gets the name of the extension on the specified drive
       
   137 	EFsStartupInitComplete,		///< Noifies the file server of startup initialisation completion
       
   138 	EFsSetLocalDriveMapping,    ///< Set the local drive mapping
       
   139 	EFsFinaliseDrive,           ///< Finalise a specific drive
       
   140 	EFsFileDuplicate,           ///< Makes a duplicate of this file handle
       
   141 	EFsFileAdopt,               ///< Adopts an already open file
       
   142 	EFsSwapFileSystem,          ///< Swaps file systems
       
   143 	EFsErasePassword,           ///< Erase the password from the locked MultiMedia card
       
   144 	EFsReserveDriveSpace,		///< -- 100 Reserves an area of a drive
       
   145 	EFsGetReserveAccess,        ///< Get exclusive access to reserved area 
       
   146 	EFsReleaseReserveAccess,    ///< Release exclusive access to reserved area
       
   147 	EFsFileName,                ///< Gets the final part of a filename
       
   148     EFsGetMediaSerialNumber,    ///<  Gets the serial number of media
       
   149 	EFsFileFullName,            ///< Gets the full filename
       
   150 	EFsAddPlugin,               ///< Adds the specified plugin
       
   151 	EFsRemovePlugin,            ///< Removes the specified plugin
       
   152 	EFsMountPlugin,			    ///< Mounts the specified plugin
       
   153 	EFsDismountPlugin,	        ///< Dismounts the specified plugin
       
   154 	EFsPluginName,				///<-- 110 Gets a plugin's name in specific position and drive 
       
   155 	EFsPluginOpen,              ///< Opens the plugin
       
   156 	EFsPluginSubClose,          ///< Closes the plugin
       
   157 	EFsPluginDoRequest,         ///< Issues an asynchronous plugin request
       
   158 	EFsPluginDoControl,         ///< Issues a synchronous plugin request
       
   159 	EFsPluginDoCancel,          ///< Cancels an synchronous plugin request
       
   160 	EFsNotifyDismount,          ///< Issues a request to asynchronously dismount the file system
       
   161 	EFsNotifyDismountCancel,    ///< Cancels a request to asynchronously dismount the file system
       
   162 	EFsAllowDismount,           ///< Notifies that it is safe to dismount the file system
       
   163     EFsSetStartupConfiguration, ///< Configures file server at startup
       
   164     EFsFileReadCancel,          ///< -- 120 Cancels an outstanding asynchronous read request
       
   165     EFsAddCompositeMount,       ///< Add a mount to the composite file system
       
   166     EFsSetSessionFlags,         ///< Set/Clear session specific flags
       
   167     EFsSetSystemDrive,			///< Set SystemDrive
       
   168 	EFsBlockMap,				///< Fetches the BlockMap of a file
       
   169     EFsUnclamp,					///< Re-enable modification of a specified file in storage media
       
   170     EFsFileClamp,				///< Disable modification of a specified file in storage media
       
   171 	EFsQueryVolumeInfoExt,		///< Query interface to retrieve extended volume information
       
   172 	EFsInitialisePropertiesFile,///< Read in the F32 properties file provided by ESTART
       
   173 	EFsFileWriteDirty,			///< Writes dirty data to disk. Used when write caching enabled
       
   174 	EFsSynchroniseDriveThread,	///< -- 130 Synchronises the asynchronous operation which executes in driver thread
       
   175 	EFsAddProxyDrive,			///< Loads  a proxy drive
       
   176 	EFsRemoveProxyDrive,		///< Unloads a proxy drive
       
   177 	EFsMountProxyDrive,			///< Mounts a proxy drive
       
   178 	EFsDismountProxyDrive,		///< Dismounts a proxy drive
       
   179 	EFsNotificationOpen,		///< Opens the notification
       
   180 	EFsNotificationBuffer,		///< Communicates buffer to file server
       
   181 	EFsNotificationRequest,		///< Sends the notification request 
       
   182 	EFsNotificationCancel,		///< Cancels the notification request 
       
   183 	EFsNotificationSubClose,	///< -- 140 Closes the notification 
       
   184 	EFsNotificationAdd,			///< Adds filter to the server, comprising a path and notification type
       
   185 	EFsNotificationRemove,		///< Removes filters from Server-Side
       
   186 	EFsLoadCodePage,			///< Loads a code page library
       
   187 	EMaxClientOperations		///< This must always be the last operation insert above
       
   188 	};
       
   189 
       
   190 class CFsRequest;
       
   191 
       
   192 /**
       
   193 Request wrapper for plugins 
       
   194 */
       
   195 class TFsPluginRequest
       
   196 	{
       
   197 public:
       
   198 	
       
   199 	/**
       
   200 	@publishedPartner
       
   201 	@released
       
   202 	
       
   203 	Used for getting parameters from
       
   204 	a CFsRequest by a F32 plugin.
       
   205 	*/
       
   206 	enum TF32ArgType
       
   207 		{
       
   208 		EPosition,
       
   209 		ELength,
       
   210 		EData,
       
   211 		ESize,
       
   212 		EName,
       
   213 		ENewName,
       
   214 		EEntry,
       
   215 		ETime,
       
   216 		ESetAtt,
       
   217 		EClearAtt,
       
   218 		EMode,
       
   219 		EAtt,
       
   220 		EAttMask,
       
   221 		EUid,
       
   222 		EEntryArray,
       
   223 		ENewPosition,
       
   224 		};
       
   225 	
       
   226 	IMPORT_C TFsPluginRequest(CFsRequest* aRequest);
       
   227 	
       
   228 	/**
       
   229 	@publishedPartner
       
   230 	@released
       
   231 	
       
   232 	Get the current Function number, as defined in TFsMessage
       
   233 	*/
       
   234 	IMPORT_C TInt Function() const;
       
   235 	
       
   236 	/**
       
   237 	@publishedPartner
       
   238 	@released
       
   239 	
       
   240 	Returns the drive number of the current request
       
   241 	*/
       
   242 	IMPORT_C TInt DriveNumber() const;
       
   243 	IMPORT_C TParse& Src() const;
       
   244 	IMPORT_C TParse& Dest() const;
       
   245 	IMPORT_C TDrive* Drive() const;
       
   246 	IMPORT_C TDrive* SubstedDrive() const;
       
   247 	IMPORT_C const RMessage2& Message() const;
       
   248 	IMPORT_C CFsRequest* Request() const;
       
   249 	IMPORT_C TUint ScratchValue() const;
       
   250 	IMPORT_C TInt64 ScratchValue64() const;
       
   251 	IMPORT_C TBool IsPostOperation() const;
       
   252 	
       
   253 	/**
       
   254 	@publishedPartner
       
   255 	@released
       
   256 	
       
   257 	Utility function for returning a TInt type of TF32ArgType value from the current request.
       
   258 	i.e. ELength.
       
   259 	
       
   260 	To obtain EPosition, authors should use ::Read(TF32ArgType,TInt64&)
       
   261 	*/
       
   262 	IMPORT_C TInt Read(TF32ArgType aType, TInt& aVal);
       
   263 	
       
   264 	/**
       
   265 	@publishedPartner
       
   266 	@released
       
   267 	
       
   268 	Utility function for returning a TUint type of TF32ArgType value from the current request.
       
   269 	
       
   270 	To obtain EPosition, authors should use ::Read(TF32ArgType,TInt64&)
       
   271 	*/
       
   272 	IMPORT_C TInt Read(TF32ArgType aType, TUint& aVal);
       
   273 	
       
   274 	/**
       
   275 	@publishedPartner
       
   276 	@released
       
   277 	
       
   278 	Utility function for returning a TInt64 type of TF32ArgType value from the current request.
       
   279 	i.e. EPosition.
       
   280 	*/
       
   281 	IMPORT_C TInt Read(TF32ArgType aType, TInt64& aVal);
       
   282 
       
   283 	/**
       
   284 	@publishedPartner
       
   285 	@released
       
   286 	
       
   287 	Utility function for receving descriptor or packaged paramters of the current request.
       
   288 	For non-descriptor types such a TEntry, plugin authors should pass an object of type TPckg<TEntry> in to aDes.
       
   289 	*/
       
   290 	IMPORT_C TInt Read(TF32ArgType aType, TDes8& aDes,  TInt aOffset = 0);
       
   291 	
       
   292 	/**
       
   293 	@publishedPartner
       
   294 	@released
       
   295 	
       
   296 	Utility function for receving descriptor or packaged paramters of the current request.
       
   297 	For non-descriptor types such a TEntry, plugin authors should pass an object of type TPckg<TEntry> in to aDes.
       
   298 	*/
       
   299 	IMPORT_C TInt Read(TF32ArgType aType, TDes16& aDes, TInt aOffset = 0);
       
   300 
       
   301 	/**
       
   302 	@publishedPartner
       
   303 	@released
       
   304 	
       
   305 	Utilty function for writing data back to the request.
       
   306 	Non-descriptor values should be packaged i.e TPckg<TUidType>
       
   307 	*/
       
   308 	IMPORT_C TInt Write(TF32ArgType aType, const TDesC8& aDes,  TInt aOffset = 0);
       
   309 	
       
   310 	/**
       
   311 	@publishedPartner
       
   312 	@released
       
   313 	
       
   314 	Utilty function for writing data back to the request.
       
   315 	Non-descriptor values should be packaged i.e TPckg<TUidType>
       
   316 	*/
       
   317 	IMPORT_C TInt Write(TF32ArgType aType, const TDesC16& aDes, TInt aOffset = 0);
       
   318 
       
   319 	/**
       
   320 	@publishedPartner
       
   321 	@released
       
   322 	*/
       
   323 	IMPORT_C TInt FileName(TDes& aName);
       
   324 	
       
   325 	/**
       
   326 	@publishedPartner
       
   327 	@released
       
   328 	
       
   329 	When plugin authors perform early completion of read or write requests, then SetSharePos should be called in order to
       
   330 	update the share position to the client.
       
   331 	*/
       
   332 	IMPORT_C TInt SetSharePos(TInt64& aPos);
       
   333 
       
   334 private:
       
   335 	TInt ClientSubSessionHandle(TInt& aHandle);
       
   336 	TInt ShareFromClientHandle(CFileShare*& aShare);
       
   337 
       
   338 	void NameFromShare(CFileShare& aFileShare, TDes& aName);
       
   339 
       
   340 private:
       
   341 	CFsRequest* iFsRequest;
       
   342 
       
   343 	friend class RFilePlugin;
       
   344 	};
       
   345 
       
   346 /**
       
   347 @publishedPartner
       
   348 @released
       
   349 
       
   350 Helper class for plugins to use to access TEntryArray data
       
   351 */
       
   352 class TRawEntryArray : public TEntryArray
       
   353 	{
       
   354 public:
       
   355 	IMPORT_C TDes8& Buf();
       
   356 	IMPORT_C void SetBuf(TDes8& aBuf);
       
   357 	IMPORT_C TInt EntrySize(TInt aIdx);
       
   358 	};
       
   359 
       
   360 class CFsPlugin;
       
   361 class CPluginThread;
       
   362 class CFsPluginConn;
       
   363 
       
   364 /**
       
   365 Plugin factory class. It is created when RFs::AddPlugin is called.
       
   366 */
       
   367 class CFsPluginFactory : public CFsObject
       
   368 	{
       
   369 public:
       
   370 	IMPORT_C CFsPluginFactory();
       
   371 	IMPORT_C ~CFsPluginFactory();
       
   372 	IMPORT_C virtual TInt Remove();
       
   373 	IMPORT_C void SetLibrary(RLibrary aLib);
       
   374 	IMPORT_C RLibrary Library() const;
       
   375 public:
       
   376 	/**
       
   377 	@internalTechnology 
       
   378 	Installs the plugin factory 
       
   379 	@return KErrNone or one of the system wide errors
       
   380 	*/
       
   381 	virtual TInt Install()=0;
       
   382 	/** 
       
   383 	@internalTechnology
       
   384 	Creates a new plugin 
       
   385 	@return plugin object
       
   386 	*/
       
   387 	virtual CFsPlugin* NewPluginL()=0;
       
   388 	/**	
       
   389 	@internalTechnology
       
   390 	Returns unique position of the plugin
       
   391 	@return unique position of the plugin
       
   392 	*/
       
   393 	virtual TInt UniquePosition()=0;
       
   394 public:
       
   395 	TBool IsDriveSupported(TInt aDrive);
       
   396 	inline TInt MountedPlugins();
       
   397 	inline TInt SupportedDrives(); //aSupportedDrives is a bit mask
       
   398 private:
       
   399 	inline void IncrementMounted();
       
   400 	inline void DecrementMounted();
       
   401 protected:
       
   402 	TInt iSupportedDrives;
       
   403 	inline void SetSupportedDrives(TInt aSupportedDrives); //aSupportedDrives is a bit mask
       
   404 private:
       
   405 	TInt iMountedPlugins;
       
   406 	TInt iUniquePos;
       
   407 	RLibrary iLibrary;
       
   408 	friend class FsPluginManager;
       
   409 	};
       
   410 
       
   411 /**
       
   412     A base class for File Server Plugins
       
   413 */
       
   414 class CFsPlugin : public CFsObject
       
   415 	{
       
   416 protected:
       
   417 	
       
   418     /** Intercept attribute to specify the order of request handling */
       
   419 	enum TInterceptAtts
       
   420 		{
       
   421 		EPreIntercept     = 0x01, ///< handles the request before the next plugin in chain
       
   422 		EPostIntercept    = 0x02, ///< handles the request after the next plugin in chain
       
   423 		EPrePostIntercept = EPreIntercept | EPostIntercept ///< covers both pre and post intercept
       
   424 		};
       
   425 public:
       
   426 	IMPORT_C CFsPlugin();
       
   427 	IMPORT_C ~CFsPlugin();
       
   428 	inline TInt Drive();
       
   429 	inline void SetDrive(TInt aDrive);
       
   430 	inline virtual TInt SessionDisconnect(CSessionFs* aSession);
       
   431 protected:
       
   432 	IMPORT_C virtual void InitialiseL();
       
   433 	IMPORT_C virtual TInt Deliver(TFsPluginRequest& aRequest);	
       
   434 	virtual TInt DoRequestL(TFsPluginRequest& aRequest) = 0;
       
   435 	
       
   436 	IMPORT_C virtual CFsPluginConn* NewPluginConnL();
       
   437 
       
   438 	IMPORT_C TInt RegisterIntercept(TInt aMessage, TInterceptAtts aInterceptAtts);
       
   439 	IMPORT_C TInt UnregisterIntercept(TInt aMessage, TInterceptAtts aInterceptAtts);
       
   440 
       
   441 	/** @prototype */
       
   442 	IMPORT_C TInt FileRead(TFsPluginRequest& aRequest, TDes8& aDes, TInt64 aPos);
       
   443 	IMPORT_C TInt FileWrite(TFsPluginRequest& aRequest, const TDesC8& aDes, TInt64 aPos);
       
   444 	IMPORT_C static TInt ClientRead(TFsPluginRequest& aRequest, TDes8& aDes,TInt aOffset=0);
       
   445 	IMPORT_C static TInt ClientWrite(TFsPluginRequest& aRequest, const TDesC8& aDes,TInt aOffset=0);
       
   446 
       
   447 	//Overloaded function - checks all types of TInterceptAtts
       
   448 	TBool IsRegistered(TInt aMessage);
       
   449 	TBool IsRegistered(TInt aMessage, TInterceptAtts aInterceptAtts);
       
   450 	TBool IsPluginThread(CFsRequest& aMessage);
       
   451 	TBool IsMounted(TInt aDrive);
       
   452 
       
   453 private:
       
   454 	TInt DispatchOperation(TFsPluginRequest& aRequest, TDes8& aDes, TInt64 aPos, TInt aFunction);
       
   455 	static TInt Complete(CFsRequest* aRequest, TInt aError);
       
   456 	static TInt Complete(CFsRequest* aRequest);
       
   457 	TInt WaitForRequest();
       
   458 
       
   459 protected:
       
   460 	TThreadId iThreadId;
       
   461 private:
       
   462 	CPluginThread* iThreadP;
       
   463 	TInt iDrive;
       
   464 
       
   465 	/**
       
   466 	The remaining space in this base class in release 9.1 is defined as follows:
       
   467 		TUint8 iRegisteredIntercepts[EMaxClientOperations << 1];	244 bytes
       
   468 		TInt iUniquePos;											  4 bytes
       
   469 															TOTAL	248 bytes 
       
   470 	where EMaxClientOperations = 122.
       
   471 
       
   472 	Unfortunately, the remaining space in release 9.2+ WAS defined as follows:
       
   473 	    enum {KIntcArrSize = 123*2};
       
   474 	    TUint8  iRegisteredIntercepts[KIntcArrSize];				246 bytes
       
   475 																	  2 bytes (padding)
       
   476 		TInt iUniquePos;											  4 bytes
       
   477 															TOTAL:	252 bytes
       
   478   
       
   479 	This meant that a 9.1-compiled plugin running on 9.2+ would have it's first data 
       
   480 	member overwritten when the base class (CFsPlugin) wrote to iUniquePos.
       
   481 
       
   482 	To maintain Binary Compatibility (BC), we need to preserve both the (smaller) 9.1 
       
   483 	and (larger) 9.2+ class sizes. 
       
   484 	To allow 9.1 plugins to work unchanged on 9.2+ iUniquePos has been moved to BEFORE
       
   485 	the iRegisteredIntercepts byte array
       
   486 
       
   487 	N.B. - the iRegisteredIntercepts array uses only 2 bits per function, so the 
       
   488 	array size only needs to be >= EMaxClientOperations/4. 
       
   489 	*/
       
   490     enum {KIntcArrSize = 132};
       
   491 	TInt iUniquePos;									//			  4 bytes
       
   492     TUint8 iRegisteredIntercepts[KIntcArrSize];			//			132 bytes
       
   493 	TInt iLastError;									//            4 bytes
       
   494 	TInt iMountedOn;	//bitmask						//			  4 bytes
       
   495     TUint iSpare[26];									//			104 bytes
       
   496 	// extra 4 bytes to preserve BC with 9.1 plugins. Don't move !
       
   497 	const TUint iReadOnly;								//			  4 bytes
       
   498 														// TOTAL:	252
       
   499 	friend class FsPluginManager;
       
   500 	friend class CFsRequest;
       
   501 	friend class CFsMessageRequest;
       
   502 	friend class CFsInternalRequest;
       
   503 	friend class CPluginThread;
       
   504 	friend class TFsDismountPlugin;
       
   505 	friend class TPluginSessionHelper;
       
   506 	friend class TFsDirOpen; //For access to TInterceptAtts
       
   507 	};
       
   508 
       
   509 class TPluginSessionHelper
       
   510 	{
       
   511 public:
       
   512 	TPluginSessionHelper();
       
   513 	TPluginSessionHelper(TFsPluginRequest* aRequest, TBool aDirectToDrive);
       
   514 	TInt CreateSubSession(const RSessionBase& aSession,TInt aFunction,const TIpcArgs& aArgs, TInt* aReply);
       
   515 	TInt SendReceive(TInt aFunction, const TIpcArgs& aArgs) const;
       
   516 	TInt SendReceive(TInt aFunction, const TIpcArgs& aArgs, TInt aSubSessionHandle) const;
       
   517 	inline TFsPluginRequest* Request();
       
   518 private:
       
   519 	TInt Dispatch(TInt aFunction, TIpcArgs& aArgs) const;
       
   520 private:
       
   521     CFsPlugin* iPlugin;     // owner; used for setting iCurrentPlugin in CFsMessageRequest
       
   522 	CSessionFs* iSession;
       
   523 	RLocalMessage iMessage;
       
   524     TBool iDirectToDrive;
       
   525 	TFsPluginRequest* iRequest;
       
   526 	TUint iSpare[4];
       
   527 	};
       
   528 
       
   529 /**
       
   530 @publishedPartner
       
   531 @released
       
   532 */
       
   533 class RFsPlugin : private RFs
       
   534    {
       
   535 public:
       
   536 	IMPORT_C  RFsPlugin(TFsPluginRequest& aRequest, TBool aDirectToDrive = EFalse);
       
   537 	IMPORT_C ~RFsPlugin();
       
   538 
       
   539 	IMPORT_C TInt Connect();
       
   540 	IMPORT_C void Close();
       
   541 
       
   542 	IMPORT_C TInt Delete(const TDesC& aName);
       
   543 	IMPORT_C TInt Rename(const TDesC& anOldName,const TDesC& aNewName);
       
   544 	IMPORT_C TInt Replace(const TDesC& anOldName,const TDesC& aNewName);
       
   545 	IMPORT_C TInt Entry(const TDesC& aName,TEntry& anEntry) const;
       
   546 	IMPORT_C TInt SetEntry(const TDesC& aName,const TTime& aTime,TUint aSetAttMask,TUint aClearAttMask);
       
   547 	IMPORT_C TInt ReadFileSection(const TDesC& aName,TInt64 aPos,TDes8& aDes,TInt aLength) const;
       
   548 
       
   549 protected:
       
   550 	TInt SendReceive(TInt aFunction,const TIpcArgs& aArgs) const;
       
   551 
       
   552 private:
       
   553 	RFsPlugin();
       
   554 	RFsPlugin(const RFsPlugin&);
       
   555 	RFsPlugin& operator=(const RFsPlugin&);
       
   556 	void SetHandle(TInt aHandle);
       
   557 
       
   558 private:
       
   559 	TPluginSessionHelper iSessionHelper;
       
   560 	friend class RFs;
       
   561     };
       
   562 
       
   563 /**
       
   564 @publishedPartner
       
   565 @released
       
   566 */
       
   567 #ifndef SYMBIAN_ENABLE_64_BIT_FILE_SERVER_API
       
   568 class RFilePlugin : private RFile
       
   569 #else
       
   570 class RFilePlugin : private RFile64
       
   571 #endif
       
   572 	{
       
   573 public:
       
   574 	IMPORT_C  RFilePlugin(TFsPluginRequest& aRequest, TBool aDirectToDrive = EFalse);
       
   575 	IMPORT_C ~RFilePlugin();
       
   576 
       
   577     // open a NEW file using same session as passed request
       
   578 	IMPORT_C TInt Open(const TDesC& aName,TUint aMode);
       
   579 	IMPORT_C TInt Create(const TDesC& aName,TUint aFileMode);
       
   580     IMPORT_C TInt Replace(const TDesC& aName,TUint aFileMode);
       
   581     IMPORT_C TInt Temp(const TDesC& aPath,TFileName& aName,TUint aFileMode);
       
   582        
       
   583     // re-open SAME file as client's request
       
   584     IMPORT_C TInt AdoptFromClient();
       
   585 
       
   586     // Transfer the plugin's open file to the client
       
   587 	IMPORT_C TInt TransferToClient();
       
   588 	
       
   589 	IMPORT_C void Close();
       
   590 
       
   591     // RFile overloads
       
   592     IMPORT_C TInt Read(TInt64 aPos,TDes8& aDes) const;
       
   593 	IMPORT_C TInt Read(TInt64 aPos,TDes8& aDes,TInt aLength) const;
       
   594     IMPORT_C TInt Write(TInt64 aPos,const TDesC8& aDes);
       
   595     IMPORT_C TInt Write(TInt64 aPos,const TDesC8& aDes,TInt aLength);
       
   596 	IMPORT_C TInt Lock(TInt64 aPos,TInt64 aLength) const;
       
   597 	IMPORT_C TInt UnLock(TInt64 aPos,TInt64 aLength) const;
       
   598 	IMPORT_C TInt Seek(TSeek aMode,TInt64& aPos) const;
       
   599 	IMPORT_C TInt Flush();
       
   600 	IMPORT_C TInt Size(TInt64& aSize) const;
       
   601 	IMPORT_C TInt SetSize(TInt64 aSize);
       
   602 	IMPORT_C TInt Att(TUint& aAttValue) const;
       
   603 	IMPORT_C TInt SetAtt(TUint aSetAttMask,TUint aClearAttMask);
       
   604 	IMPORT_C TInt Modified(TTime& aTime) const;
       
   605 	IMPORT_C TInt SetModified(const TTime& aTime);
       
   606 	IMPORT_C TInt Set(const TTime& aTime,TUint aSetAttMask,TUint aClearAttMask);
       
   607 	IMPORT_C TInt ChangeMode(TFileMode aNewMode);
       
   608 	IMPORT_C TInt Rename(const TDesC& aNewName);
       
   609 
       
   610 protected:
       
   611 	// RSubSessionBase overrides
       
   612 	TInt CreateSubSession(const RSessionBase& aSession,TInt aFunction,const TIpcArgs& aArgs);
       
   613 	TInt SendReceive(TInt aFunction,const TIpcArgs& aArgs) const;
       
   614 	void CloseSubSession(TInt aFunction);
       
   615 
       
   616 private:
       
   617 	RFilePlugin();
       
   618 	RFilePlugin(const RFilePlugin&);
       
   619 	RFilePlugin& operator=(const RFilePlugin&);
       
   620 
       
   621 	void SetHandle(TInt aHandle);
       
   622 	void SetSubSessionHandle(TInt aHandle);
       
   623 
       
   624 private:
       
   625 	TPluginSessionHelper iSessionHelper;
       
   626 	friend class RFile;
       
   627 #ifdef SYMBIAN_ENABLE_64_BIT_FILE_SERVER_API
       
   628 	friend class RFile64;
       
   629 #endif
       
   630 	};
       
   631 
       
   632 /**
       
   633 @publishedPartner
       
   634 @released
       
   635 */
       
   636 class RDirPlugin : private RDir
       
   637    {
       
   638 public:
       
   639    	IMPORT_C  RDirPlugin(TFsPluginRequest& aRequest, TBool aDirectToDrive = EFalse);
       
   640    	IMPORT_C ~RDirPlugin();
       
   641 
       
   642 	IMPORT_C TInt Open(const TDesC& aMatchName,const TUidType& aUidType);
       
   643 	IMPORT_C TInt Open(const TDesC& aMatchName,TUint anAttMask);
       
   644 	IMPORT_C void Close();
       
   645 
       
   646 	/**
       
   647 	Plugin authors should pass in a TRawEntryArray if their intent is to modify the data.
       
   648 	*/
       
   649 	IMPORT_C TInt Read(TEntryArray& aArray);
       
   650 	IMPORT_C TInt Read(TEntry& aEntry);
       
   651 
       
   652 protected:
       
   653 	// RSubSessionBase overrides
       
   654 	TInt CreateSubSession(const RSessionBase& aSession,TInt aFunction,const TIpcArgs& aArgs);
       
   655 	TInt SendReceive(TInt aFunction,const TIpcArgs& aArgs) const;
       
   656 	void CloseSubSession(TInt aFunction);
       
   657 
       
   658 private:
       
   659 	RDirPlugin();
       
   660 	RDirPlugin(const RDirPlugin&);
       
   661 	RDirPlugin& operator=(const RDirPlugin&);
       
   662 
       
   663 	void SetHandle(TInt aHandle);
       
   664 	void SetSubSessionHandle(TInt aHandle);
       
   665 
       
   666 private:
       
   667 	TPluginSessionHelper iSessionHelper;
       
   668 	friend class RDir;
       
   669 	};
       
   670 
       
   671 
       
   672 class CFsRequest;
       
   673 class CFsPluginConnRequest : public CBase
       
   674 	{
       
   675 public:
       
   676 	CFsPluginConnRequest(CFsPluginConn* aPluginConn);
       
   677 public:
       
   678 	inline TInt Function() const;
       
   679 	inline TDes8* Param1() const;
       
   680 	inline TDes8* Param2() const;
       
   681 	inline void WriteParam1L(const TDesC8& aDes) const;
       
   682 	inline void WriteParam2L(const TDesC8& aDes) const;
       
   683 	inline void ReadParam1L(TDes8& aDes) const;
       
   684 	inline void ReadParam2L(TDes8& aDes) const;
       
   685 	inline const RMessagePtr2& Message() const;
       
   686 public:
       
   687 	TInt DoControl();
       
   688 	void DoRequest();
       
   689 	inline void Complete(TInt aError);
       
   690 public:
       
   691 	TInt InitControl(CFsRequest* aRequest);
       
   692 	TInt InitRequest(CFsRequest* aRequest);
       
   693 private:	
       
   694 	TDblQueLink iLink;
       
   695 	CFsPluginConn& iPluginConn;
       
   696 	TInt iFunction;
       
   697 	TDes8* iParam1;
       
   698 	TDes8* iParam2;
       
   699 public:
       
   700 	RMessagePtr2 iMessage;
       
   701 
       
   702 	friend class TPluginConnRequestQue;
       
   703 	friend class CFsPluginConn;
       
   704 	};
       
   705 
       
   706 class TPluginConnRequestQue
       
   707 	{
       
   708 public:
       
   709 	 TPluginConnRequestQue();
       
   710 	~TPluginConnRequestQue();
       
   711 	void DoAddRequest(CFsPluginConnRequest* aRequest);
       
   712 	IMPORT_C void DoCancelAll(TInt aCompletionCode);
       
   713 protected:
       
   714 	TDblQue<CFsPluginConnRequest> iHeader;
       
   715 	};
       
   716 
       
   717 /**
       
   718 Plugin connection object
       
   719 */
       
   720 class CFsPluginConn : public CFsObject
       
   721 	{
       
   722 public:
       
   723 	IMPORT_C CFsPluginConn();
       
   724 	IMPORT_C ~CFsPluginConn();
       
   725 
       
   726 	virtual TInt DoControl(CFsPluginConnRequest& aRequest) = 0;
       
   727 	virtual void DoRequest(CFsPluginConnRequest& aRequest) = 0;
       
   728 	virtual void DoCancel(TInt aReqMask) = 0;
       
   729 
       
   730 	inline CFsPlugin* Plugin() const;
       
   731 	inline TThreadId ClientId() const;
       
   732 private:
       
   733 	IMPORT_C void Close();
       
   734 	CFsPlugin* iPluginP;
       
   735 	TThreadId iClientId;
       
   736 public:
       
   737 	TPluginConnRequestQue iRequestQue;
       
   738 	friend class FsPluginManager;
       
   739 	};
       
   740 
       
   741 #include <f32plugin.inl>
       
   742 
       
   743 #endif // __F32PLUGIN_H
       
   744