remotestoragefw/mountstore/inc/rsfwmountstore.h
changeset 13 6b4fc789785b
parent 2 c32dc0be5eb4
equal deleted inserted replaced
2:c32dc0be5eb4 13:6b4fc789785b
     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:  Mount configuration repository management
       
    15  *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef CRSFWMOUNTSTORE_H
       
    20 #define CRSFWMOUNTSTORE_H
       
    21 
       
    22 // INCLUDES
       
    23 #include <cenrepnotifyhandler.h>
       
    24 
       
    25 // DATA TYPES
       
    26 // Event types for MMountStoreObserver
       
    27 enum TMountStoreEvent
       
    28     {
       
    29     EMountStoreEventMountConfigurationChanged = 1
       
    30     };
       
    31 
       
    32 // FORWARD DECLARATIONS
       
    33 class CRepository;
       
    34 class CDesC16Array;
       
    35 class CRsfwMountEntry;
       
    36 
       
    37 // CLASS DECLARATION
       
    38 /**
       
    39  *  Interface for receiving mounting events
       
    40  *
       
    41  *  @lib mountman.dll
       
    42  *  @since Series 60 3.1
       
    43  */
       
    44 
       
    45 class MRsfwMountStoreObserver
       
    46     {
       
    47 public:
       
    48     /**
       
    49      * Handles an event emanating from a CRsfwMountStore class.
       
    50      * Used for notifying about changes in the configurations
       
    51      *
       
    52      * @param aEventType type of the event
       
    53      * @param aStatus status code
       
    54      * @param aArg miscellaneous arguments
       
    55      */
       
    56     virtual void HandleMountStoreEvent(TMountStoreEvent aEvent,
       
    57                                        TInt aStatus,
       
    58                                        TAny* aArg) = 0;
       
    59     };
       
    60 
       
    61 // CLASS DECLARATION
       
    62 /**
       
    63  *  Maintain permanent storage of mount configuration entries
       
    64  *
       
    65  *  @lib mountstore.lib
       
    66  *  @since Series 60 3.1
       
    67  */
       
    68 class CRsfwMountStore: public CBase, public MCenRepNotifyHandlerCallback
       
    69     {
       
    70 public: // Constructors and destructor
       
    71     /**
       
    72      * Two-phased constructor.
       
    73      * At the construction phase, all mount configurations are loaded
       
    74      * into memory (that is, LoadEntries() is called).
       
    75      * @param aMountStoreObserver store change notification handler
       
    76      */
       
    77     IMPORT_C static CRsfwMountStore* NewL(
       
    78         MRsfwMountStoreObserver* aMountStoreObserver);
       
    79 
       
    80     CRsfwMountStore();
       
    81 
       
    82     /**
       
    83      * Destructor.
       
    84      */
       
    85     IMPORT_C virtual ~CRsfwMountStore();
       
    86 
       
    87 public: // New functions
       
    88     /**
       
    89      * (Re)loads the mount configurations into memory from the repository.
       
    90      * 
       
    91      */
       
    92     IMPORT_C void LoadEntriesL();
       
    93 
       
    94     /**
       
    95      * Gets a list of friendly names of all mount configurations stored
       
    96      * in Central Repository
       
    97      *
       
    98      * @param aNames returned information
       
    99      * @return nothing
       
   100      *  this array must be created by the caller
       
   101      */
       
   102     IMPORT_C void GetNamesL(CDesC16Array* aNames);
       
   103     
       
   104      /**
       
   105      * Gets remote drive letters of all mount configurations stored
       
   106      * in Central Repository (in correct order)
       
   107      *
       
   108      * @param aDriveList returned information
       
   109      * @return nothing
       
   110      *  this array must be created by the caller
       
   111      */
       
   112     IMPORT_C void GetDriveLettersL(TDriveList& aDriveList);
       
   113 
       
   114 
       
   115     /**
       
   116      * Finds the configuration configuration entry by drive letter.
       
   117      * @param aDrive drive letter
       
   118      * @return a pointer to the configuration entry or NULL if not found
       
   119      */
       
   120     IMPORT_C const CRsfwMountEntry* LookupEntryByDriveL(TChar aDriveLetter);
       
   121 
       
   122     /**
       
   123      * Finds the mount configuration entry by friendly name.
       
   124      * The ownership of the entry is not moved
       
   125      * @param aName friendly name
       
   126      * @return a pointer to the configuration entry or NULL if not found
       
   127      *  the ownership of the pointer is NOT transferred
       
   128      */
       
   129     IMPORT_C const CRsfwMountEntry* LookupEntryByNameL(const TDesC& aName);
       
   130 
       
   131     /**
       
   132      * Adds a new mount configuration entry in the list of entries.
       
   133      * If an entry with the same name already exists,
       
   134      * that entry is replaced with the new entry.
       
   135      * The entry is positioned among the existing entries
       
   136      * according to the EMountEntryItemIndex value
       
   137      * The drive letter in aMountEntry must be set before calling.
       
   138      * @param aMountEntry mount configuration entry -
       
   139      *  the ownership of the pointer is transferred to CMountStore
       
   140      * @leave KErrArgument drive letter not set
       
   141      * @leave KErrInUse all nine allowed remote drives are in use
       
   142      *
       
   143      */
       
   144     IMPORT_C void AddEntryL(CRsfwMountEntry* aMountEntry);
       
   145 
       
   146     /**
       
   147      * Removes a mount configuration entry from the list of entries.
       
   148      * Nothing is done if no entry with the name is found
       
   149      * @param aDriveLetter name of the entry to be removed
       
   150      */
       
   151     IMPORT_C void RemoveEntryL(const TDesC& aName);
       
   152 
       
   153     /**
       
   154      * Removes a mount configuration entry from the list of entries.
       
   155      * Nothing is done if no entry with the drive letter is found.
       
   156      * @param aDriveLetter name of the entry to be removed
       
   157      */
       
   158     IMPORT_C void RemoveEntryL(const TChar aDriveLetter);
       
   159 
       
   160     /**
       
   161      * Saves the mount configuration entries permanently.
       
   162      * This function must be called after changes have been made in the
       
   163      * mount configuration entries in order to store the cahnges permanently.
       
   164      */
       
   165     IMPORT_C void CommitL();
       
   166     
       
   167 private:
       
   168     void ConstructL(MRsfwMountStoreObserver* aMountStoreObserver);
       
   169     void ReloadEntriesL();
       
   170     void AddToRepositoryL(const CRsfwMountEntry* aMountEntry);
       
   171     void RemoveFromRepositoryL(const CRsfwMountEntry* aMountEntry);
       
   172     void ClearRepositoryL();
       
   173     void SynchronizeIndexesL();
       
   174     // From MCenRepNotifyHandlerCallback
       
   175     void HandleNotifyError(TUint32 aId,
       
   176                            TInt aError,
       
   177                            CCenRepNotifyHandler* aHandler);
       
   178     void HandleNotifyGeneric(TUint32 aId);
       
   179     TInt MapDriveLetterToRecordIdL(const HBufC* drive);
       
   180 
       
   181 
       
   182 private: // Data
       
   183     RPointerArray<CRsfwMountEntry> iMountEntries;
       
   184     CRepository*                   iRepository;
       
   185     CCenRepNotifyHandler*          iCenRepNotifyHandler;
       
   186     TBool                          iReceivingCenRepNotifications;
       
   187     TBool                          iCenRepChanged;
       
   188     MRsfwMountStoreObserver*       iMountStoreObserver;
       
   189     };
       
   190 
       
   191 #endif // CRSFWMOUNTSTORE_H
       
   192 
       
   193 // End of File