epoc32/include/mw/rsfwmountman.h
author William Roberts <williamr@symbian.org>
Wed, 31 Mar 2010 12:33:34 +0100
branchSymbian3
changeset 4 837f303aceeb
parent 2 2fe1408b6811
permissions -rw-r--r--
Current Symbian^3 public API header files (from PDK 3.0.h)
This is the epoc32/include tree with the "platform" subtrees removed, and
all but a selected few mbg and rsg files removed.
     1 /*
     2 * Copyright (c) 2004-2006 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:  RSFW Mount Manager API
    15 *
    16 */
    17 
    18 
    19 #ifndef CRSFWMOUNTMAN_H
    20 #define CRSFWMOUNTMAN_H
    21 
    22 #include <e32cmn.h>
    23 #include <e32base.h>
    24 #include <f32file.h>
    25 #include <s32strm.h>
    26 
    27 #include <rsfwmountentry.h> // mount entry constants
    28 
    29 class TRsfwMountInfo;
    30 
    31 // FORWARD DECLARATIONS
    32 class CRsfwMountEntry;
    33 class CRsfwMountManImpl;
    34 class CDesC16Array;
    35 
    36 // CONSTANTS
    37 // the secure UID of the server, used as a P&S key category
    38 const TUid KRfeServerSecureUid = { 0x101F970D };
    39 //the maximum number of remote drives
    40 const TInt KMaxRemoteDrives = 9;
    41 
    42 // DATA TYPES
    43 // Event types for MRsfwMountManObserver
    44 enum TMountManEvent
    45     {
    46     EMountManEventMountConfigurationChanged = 1,
    47     EMountManEventMounted
    48     };
    49 
    50 // P&S keys
    51 // for notifying UI that a remote drive has been connected or disconnected
    52 enum TRfePSKeys
    53 	{
    54 	ERsfwPSKeyConnect
    55 	};
    56 
    57 // Connection states
    58 const TUint KMountStronglyConnected = 0x01;
    59 const TUint KMountConnecting = 0x02; // temporary state during establishing a connection
    60                                      // to the drive, not to be used via MountMan API
    61 const TUint KMountNotConnected      = 0x03;
    62 
    63 // CLASS DECLARATION
    64 /**
    65  *  Interface for receiving mounting events
    66  *
    67  *  @lib mountman.dll
    68  *  @since Series 60 3.1
    69  */
    70 
    71 class MRsfwMountManObserver
    72     {
    73 public:
    74     /**
    75      * Handles an event emanating from a CRsfwMountMan class
    76      *
    77      * @param aEventType type of the event
    78      * @param aStatus status code
    79      * @param aArg miscellaneous arguments
    80      */
    81     virtual void HandleMountManEventL(TMountManEvent aEvent,
    82                                       TInt aStatus,
    83                                       TAny* aArg) = 0;
    84     };
    85 
    86 /**
    87  *  Encapsulates remote mount configuration.
    88  *
    89  *  @lib rsfwmountman.dll
    90  *  @since Series 60 3.1
    91  */
    92 class TRsfwMountConfig
    93     {
    94 public:   // New functions
    95     IMPORT_C void ExternalizeL(RWriteStream& aStream) const;
    96     IMPORT_C void InternalizeL(RReadStream& aStream);
    97 
    98 public:   // Data
    99     TChar                         iDriveLetter;
   100     TBuf<KMaxMountNameLength>     iName;
   101     TBuf<KMaxMountUriLength>      iUri;
   102     TBuf<KMaxMountUserNameLength> iUserName;
   103     TBuf<KMaxMountPasswordLength> iPassword;
   104     TBuf<KMaxMountAuxDataLength>  iAuxData;
   105     TUint                         iFlags;
   106     TInt                          iInactivityTimeout;
   107     };
   108     
   109 
   110 /**
   111  *  Encapsulates remote mount status information.
   112  *
   113  *  @lib rsfwmountman.dll
   114  *  @since Series 60 3.1
   115  */
   116 class TRsfwMountStatus
   117     {
   118 public:   // Data
   119     TInt                          iVolumeId;
   120     /** iMountState is not used and will be removed */
   121     TUint                         iMountState;  
   122     /** see KMountStronglyConnected and other connection states */
   123     TUint                         iConnectionState; 
   124     TInt                          iCachedSize;
   125     TInt                          iInactivityTime;
   126     TInt                          iInactivityTimeout;
   127     TBool                         iPermanence;
   128     };
   129     
   130 
   131 /**
   132  *  Encapsulates all information about a mount.
   133  *
   134  *  @lib rsfwmountman.dll
   135  *  @since Series 60 3.1
   136  */
   137 class TRsfwMountInfo
   138     {
   139 public:   // New functions
   140     void ExternalizeL(RWriteStream& aStream) const;
   141     void InternalizeL(RReadStream& aStream);
   142 
   143 public:   // Data
   144     TRsfwMountConfig                  iMountConfig;
   145     TRsfwMountStatus                  iMountStatus;
   146     }; 
   147     
   148 
   149 
   150 
   151 // CLASS DECLARATION
   152 
   153 /**
   154  *  Class for managing mounts to remote file repositories
   155  *
   156  *  @lib mountman.dll
   157  *  @since Series 60 3.1
   158  */
   159 
   160 class CRsfwMountMan : public CBase
   161     {
   162 public: // Constructors and destructor
   163     /**
   164      * Two-phased constructor.
   165      *
   166      * @param aDefaultFlags must be set to KMountFlagInteractive
   167      *   if the user is to be prompted during the mount procedure.
   168      *   Otherwise the parameter can be set to zero.
   169      * @param mount event observer
   170      * @return pointer to the created CRsfwMountMan object instance
   171      */
   172     IMPORT_C static CRsfwMountMan* NewL(TUint aDefaultFlags,
   173                                     MRsfwMountManObserver* aMountManObserver);
   174 
   175     /**
   176      * Destructor.
   177      */
   178     IMPORT_C virtual ~CRsfwMountMan();
   179 
   180 public: // New functions
   181     /**
   182      * Returns a list of friendly names of all mount configurations
   183      * in the mount configuration repository.
   184      * The entries are returned in the order that they appear in the
   185      * repository.
   186      * @param aNames friendly names
   187      * @return nothing
   188      */
   189     IMPORT_C void GetMountNamesL(CDesC16Array* aNames) const;
   190 
   191     /**
   192      * Gets the mount configuration entry having the given friendly name.
   193      * The caller must make sure that the name is unique.
   194      * @param aId friendly name
   195      * @return a pointer to the configuration entry or NULL if not found
   196      */
   197     IMPORT_C const CRsfwMountEntry* MountEntryL(const TDesC& aName) const;
   198 
   199     /**
   200      * Gets the mount configuration entry for the given drive letter.
   201      * @param aDriveLetter drive letter
   202      * @return a pointer to the configuration entry or NULL if not found
   203      */
   204     IMPORT_C const CRsfwMountEntry* MountEntryL(TChar aDriveLetter) const;
   205 
   206     /**
   207      * Adds a mount configuration entry in the configurations and
   208      * mounts the drive in the File Server.
   209      * If the drive letter item is not set in the configuration,
   210      * a free letter will be allocated.
   211      * Then the EMountEntryItemDrive value in aMountEntry will be changed.
   212      * The EMountEntryItemIndex item of aMountEntry is used for
   213      * positioning the entry in a specific order in the configuration database
   214      * (the index itself is not stored)
   215      *
   216      * @param aMountEntry mount configuration entry
   217      *  the ownership of the pointer is transferred to CRsfwMountMan
   218      * @return nothing
   219      * @leave KErrInUse selected drive letter already in used
   220      * @leave KErrInUse selected name is in use
   221      * @leave KErrInUse 9 remote drives already define
   222      * (Number of remote drives is limited by default to 9 so that drive 
   223      *  letters are also available for other technologies)
   224      * @leave KErrAccessDenied program does not have sufficient capabilities
   225      *        required capabilities are DiskAdmin (to mount new remote drive in 
   226      *        File Server) and WriteDeviceData (to add new remote drive to
   227      *         Central Repository)
   228      * @leave KErrNotFound
   229      *        File System plug-in, Central Repository table etc. not found
   230      */
   231     IMPORT_C void AddMountEntryL(CRsfwMountEntry* aMountEntry);
   232 
   233     /**
   234      * Deletes a mount entry from the configurations and unmounts the drive.
   235      * Nothing is done if the entry does not exist.
   236      *
   237      * @param aName name
   238      * @return nothing
   239      */
   240     IMPORT_C void DeleteMountEntryL(const TDesC& aName);
   241 
   242     /**
   243      * Deletes a mount entry from the configurations and unmounts the drive.
   244      * Nothing is done if the entry does not exist.
   245      *
   246      * @param aDriveLetter drive letter
   247      * @return nothing
   248      */
   249     IMPORT_C void DeleteMountEntryL(TChar aDriveLetter);
   250 
   251   
   252     /**
   253      * Gets a list of all drives as seen by the File Server
   254      *
   255      * Returns drive letters. 
   256      * Letters for local drives are in the front of the list
   257      * Letters for remote drives in order defined in CenRep
   258      *   The number of the drives is the same as the length of the list
   259      *
   260      * @param aDriveList returned drive list
   261      * @return number of remote drives
   262      */
   263     IMPORT_C TInt GetAllDrivesL(TDriveList& aDriveList) const;
   264 
   265     /**
   266      * Gets a list of all remote drives as seen by the File Server
   267      *
   268      * The list contains the letters of the remote drives.
   269      * Letters for remote drives in order defined in CenRep
   270      *   The number of the drives is the same as the length of the list
   271      *
   272      * @param aDriveList returned drive list
   273      * @return number of remote drives
   274      */
   275     IMPORT_C TInt GetRemoteMountListL(TDriveList& aDriveList) const;
   276     
   277     /**
   278      * Gets mount information for an active remote drive.
   279      *
   280      * The information consists of static configuration information and
   281      *   status information (such as strongly or weakly connected).
   282      * Note that if the drive is not atctive this function will 
   283      * return -1, you need to use MountEntryL to get just the static 
   284      * configuration information
   285      *
   286      * @param aDriveLetter drive letter of the mount
   287      * @param aMountInfo returned information
   288      * @return error code
   289      */
   290     IMPORT_C TInt GetMountInfo(TChar aDriveLetter, TRsfwMountInfo& aMountInfo) const;
   291 
   292     /**
   293      * Sets the connection state of a mount for an active remote drive
   294      *
   295      * @param aDriveLetter drive letter of the mount
   296      * @param aConnectionState
   297      *   The following connection states have been defined:
   298      *     KMountStronglyConnected = strongly connected state
   299      *     KMountWeaklyConnected   = weakly connected state
   300      *     KMountNotConnected      = disconnected state
   301      *
   302      * @return error code
   303      */
   304     IMPORT_C TInt SetMountConnectionState(TChar aDriveLetter,
   305                                           TUint aConnectionState);
   306 
   307     /**
   308      * Changes a mount configuration entry in the configurations
   309      *  
   310      * @param aMountEntry mount configuration entry
   311      *  the ownership of the pointer is transferred to CRsfwMountMan
   312      * @return nothing
   313      * @leave KErrInUse if the name of the mount is used by other mount
   314      * @leave KErrAccessDenied program does not have sufficient capabilities
   315      *        required capabilities are DiskAdmin (to mount new remote drive in 
   316      *        File Server) and WriteDeviceData (to add new remote drive to
   317      *         Central Repository)
   318      * @leave KErrNotFound if mount with given letter not found or
   319      *        File System plug-in, Central Repository table etc. not found
   320      */
   321     IMPORT_C void EditMountEntryL(CRsfwMountEntry* aMountEntry);
   322     
   323     
   324      /**
   325      * Refresh a remote directory
   326      *
   327      * Ensures that contents of a remote directory are up to date.
   328      * Synchronous variant deletes the currently cached version.
   329      * Note that this function intentionally does not return directory
   330      * contents. All data should be read through the File Server instead.
   331      *
   332      * @return KErrArgument Path refers to a file
   333      *         KErrNotFound path is not found from cache
   334      */
   335     IMPORT_C TInt RefreshDirectory(const TDesC& aPath);
   336 
   337     /**
   338      * Some applications have problems with handling remote files.
   339      * Function checks whether app with given UID is one of them.
   340      *  
   341      * @param aUid UID of the application
   342      * @return ETrue if it is on the black list, otherwise EFalse
   343      */    
   344     IMPORT_C TBool IsAppOnBlackList(TUid aUid) const;
   345     
   346     
   347      /**
   348      * Cancels an active remote file upload or download
   349      * 
   350      * @param aFile file name
   351      * @return one of the system wide error codes.
   352      */    
   353     IMPORT_C TInt CancelRemoteTransfer(const TDesC& aFile);
   354     
   355     
   356     /**
   357      * Sets the connection state of a mount for an active remote drive
   358      * sends a bling request, does not wait for reply
   359      *
   360      * @param aDriveLetter drive letter of the mount
   361      * @param aConnectionState
   362      *   The following connection states have been defined:
   363      *     KMountStronglyConnected = strongly connected state
   364      *     KMountWeaklyConnected   = weakly connected state
   365      *     KMountNotConnected      = disconnected state
   366      *
   367      * @return error code
   368      */
   369     IMPORT_C TInt SetMountConnectionStateBlind(TChar aDriveLetter,
   370                                           TUint aConnectionState);
   371 
   372     
   373 private:
   374     /**
   375      * C++ default constructor
   376      */
   377     CRsfwMountMan();
   378     
   379     /**
   380      * Second phase constructor
   381      */
   382     void ConstructL(TUint aDefaultFlags,
   383                     MRsfwMountManObserver* aMountManObserver);
   384 
   385 private: // Data
   386     CRsfwMountManImpl* iMountManImpl; // implementation
   387     };
   388 
   389 #endif // CRSFWMOUNTMAN_H
   390 
   391 // End of File