ncdengine/provider/storage/inc/ncdstoragemanagerimpl.h
changeset 0 ba25891c3a9e
equal deleted inserted replaced
-1:000000000000 0:ba25891c3a9e
       
     1 /*
       
     2 * Copyright (c) 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:  
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef C_NCDSTORAGEMANAGER_H
       
    20 #define C_NCDSTORAGEMANAGER_H
       
    21 
       
    22 #include <e32base.h>
       
    23 #include <f32file.h>
       
    24 
       
    25 #include "ncdstoragemanager.h"
       
    26 #include "ncdstorageowner.h"
       
    27 
       
    28 class MNcdStorage;
       
    29 class CNcdStorage;
       
    30 class CNcdStorageClient;
       
    31 
       
    32 
       
    33 /**
       
    34  *  Manager for all provider's storages
       
    35  *
       
    36  *  @note UIDs and namespace can, in fact, contain any text that can
       
    37  *  be used in a directory/filename. 
       
    38  *
       
    39  */
       
    40 class CNcdStorageManager : public CBase, public MNcdStorageManager,
       
    41     public MNcdStorageOwner
       
    42     {
       
    43 public: 
       
    44 
       
    45     /**
       
    46      * Storage manager creator. 
       
    47      *
       
    48      * Also creates the provider storage
       
    49      *
       
    50      * @param 
       
    51      * @param aRootDirectory Root directory where all of the provider's 
       
    52      * storages will be created to. The directory name must end with a \    
       
    53      * @return A new storage manager
       
    54      * @throw KErrArgument if either of the parameters were empty or
       
    55      * the path was invalid
       
    56      */
       
    57     static CNcdStorageManager* NewL( 
       
    58         RFs& aFs, 
       
    59         const TDesC& aRootDirectory );
       
    60 
       
    61 
       
    62     virtual ~CNcdStorageManager();
       
    63 
       
    64 
       
    65 public: // From MNcdStorageManager
       
    66 
       
    67     /**
       
    68      * @see MNcdStorageManager::CreateOrGetStorageL()
       
    69      */
       
    70     MNcdStorage& CreateOrGetStorageL( const TDesC& aClientUid, 
       
    71         const TDesC& aNamespace );
       
    72 
       
    73 
       
    74     /**
       
    75      * @see MNcdStorageManager::CreateStorageL()
       
    76      */
       
    77     MNcdStorage& CreateStorageL( const TDesC& aClientUid, const TDesC& aNamespace );
       
    78 
       
    79 
       
    80     /**
       
    81      * @see MNcdStorageManager::ProviderStorage
       
    82      */
       
    83     MNcdStorage& ProviderStorageL( const TDesC& aClientUid );
       
    84     
       
    85     
       
    86     /**
       
    87      * @see MNcdStorageManager::StorageL()
       
    88      */
       
    89     MNcdStorage& StorageL( const TDesC& aClientUid, const TDesC& aNamespace );
       
    90     
       
    91     /**
       
    92      * @see MNcdStorageManager::StorageNamespacesLC()
       
    93      */
       
    94     MDesCArray* StorageNamespacesLC( const TDesC& aClientUid ) const;
       
    95     
       
    96     /**
       
    97      * @see MNcdStorageManager::StorageClientL()
       
    98      */
       
    99     MNcdStorageClient& StorageClientL( const TDesC& aClientUid );
       
   100     
       
   101     /**
       
   102      * @see MNcdStorageManager::RemoveClientL()
       
   103      */
       
   104     //void RemoveClientL( const TDesC& aClientUid );    
       
   105     
       
   106     
       
   107     /**
       
   108      * @see MNcdStorageManager::RemoveStorageL()
       
   109      */
       
   110     void RemoveStorageL( const TDesC& aClientUid, const TDesC& aNamespace );
       
   111     
       
   112     
       
   113     void CloseClient( const TDesC& aClientUid );
       
   114     
       
   115     
       
   116 public: // From MNcdStorageOwner
       
   117 
       
   118     /**
       
   119      * @see MNcdStorageOwner::FileSession()
       
   120      */
       
   121     RFs& FileSession();
       
   122            
       
   123     /**
       
   124      * @see MNcdStorageOwner::AppendRoot()
       
   125      */
       
   126     void AppendRoot( TDes& aPath ) const;
       
   127     
       
   128     /**
       
   129      * @see MNcdStorageOwner::FileManager()
       
   130      */
       
   131     CFileMan& FileManager();
       
   132     
       
   133 public: // New methods
       
   134 
       
   135     /**
       
   136      * Utility function for removing a directory
       
   137      */
       
   138     static void RemoveDirectoryL( RFs& aFileSession, const TDesC& aDirectory );
       
   139         
       
   140     
       
   141 private: // Private methods
       
   142  
       
   143 
       
   144     CNcdStorageManager( RFs& aFs );
       
   145 
       
   146     void ConstructL( const TDesC& aRootDirectory );
       
   147 
       
   148     
       
   149     /**
       
   150     * Searches for the client by UID
       
   151     * 
       
   152     * @param aUid Client's UID
       
   153     * @return Index in iClients
       
   154     * @throw KErrNotFound if the client was not found
       
   155     */
       
   156     TInt FindClientByUidL( const TDesC& aUid ) const;
       
   157 
       
   158     TInt FindClientByUid( const TDesC& aUid ) const;
       
   159     
       
   160 private: // data
       
   161 
       
   162     RBuf iRootDir;
       
   163     
       
   164     RPointerArray<CNcdStorageClient> iClients;    
       
   165     RFs& iFs;
       
   166     
       
   167     CFileMan* iFileMan;
       
   168     };
       
   169 
       
   170 
       
   171 #endif // C_NCDSTORAGEMANAGER_H