brandingserver/bsserver/cbsstoragemanager.h
changeset 0 e6b17d312c8b
child 21 cfd5c2994f10
equal deleted inserted replaced
-1:000000000000 0:e6b17d312c8b
       
     1 /*
       
     2 * Copyright (c) 2006-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:  Storage handler
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef CBSSTORAGEMANAGER_H
       
    20 #define CBSSTORAGEMANAGER_H
       
    21 
       
    22 #include <e32base.h>
       
    23 #include <f32file.h>
       
    24 
       
    25 class CBSSession;
       
    26 class CBSIBYWriter;
       
    27 class MBSElement;
       
    28 class CBSStorage;
       
    29 class RWriteStream;
       
    30 
       
    31 
       
    32 /**
       
    33  *  Storage handler
       
    34  *
       
    35  *  @lib .exe
       
    36  *  @since S60 v3.2
       
    37  */
       
    38 class CBSStorageManager : public CBase
       
    39 {
       
    40 public:
       
    41 
       
    42     static CBSStorageManager* NewL( CBSSession* aSession, const TDesC& aAppId );
       
    43 
       
    44     static CBSStorageManager* NewLC( CBSSession* aSession, const TDesC& aAppId );
       
    45 
       
    46     ~CBSStorageManager();
       
    47 
       
    48 
       
    49     /**
       
    50      * Initializes the transaction to the
       
    51      * storagemanager
       
    52      *
       
    53      * @since S60 3.2
       
    54      * @return none
       
    55      */
       
    56     void ConnectTransactionL(const TDesC& aAppId,
       
    57     					   const TDesC& aBrandId,
       
    58     					   TLanguage aLanguageId,
       
    59     					   TBool aAppending = EFalse,
       
    60     					   TInt aReserved = 0 );
       
    61 
       
    62 
       
    63     /**
       
    64      * Create a new storage and set it to current.
       
    65      *
       
    66      * @since S60 3.2
       
    67      * @return none
       
    68      */
       
    69     void CreateStorageL();
       
    70 
       
    71     /**
       
    72      * Return the count of storages
       
    73      *
       
    74      * @since S60 3.2
       
    75      * @return count of elements
       
    76      */
       
    77     TInt StorageCount();
       
    78 
       
    79     /**
       
    80      * Get stored storage at index or current storage.
       
    81      *
       
    82      * @since S60 3.2
       
    83      * @param aIndex index of storage to fetch.
       
    84      * @return Stored storage
       
    85      */
       
    86     CBSStorage* Storage( TInt aIndex );
       
    87     CBSStorage* Storage();
       
    88 
       
    89     /**
       
    90      * Externalize storage files into file system
       
    91      *
       
    92      * @since S60 3.2
       
    93      * @param aFs filesystem handle
       
    94      * @param aBaseDir Base directory for writing
       
    95      * @return the new brand version
       
    96      */
       
    97     TInt WriteStorageFilesL();
       
    98 
       
    99 	void CancelTransactionL();
       
   100 
       
   101     void BrandHandleL( const TDesC& aAppId,
       
   102 					   const TDesC& aBrandId,
       
   103 					   TLanguage aLanguageId,
       
   104 					   RFile& aFile, 
       
   105 					   TInt aReserved );
       
   106 
       
   107     void FileElementHandleL( const TDesC& aAppId,
       
   108 						     const TDesC& aBrandId,
       
   109 						     const TDesC& aFileName,
       
   110 						     const TDesC& aLanguageBuf,
       
   111 						     RFile& aFile );
       
   112 
       
   113     void CleanupFileL( const TDesC& aFileName );
       
   114 
       
   115 	TPtrC FilenameWithoutVersion( const TDesC& aFileName );
       
   116 
       
   117     /**
       
   118      * Externalize storage files into file system
       
   119      *
       
   120      * @since S60 3.2
       
   121      * @param aFileName the name of the installed file
       
   122      * 		  including path
       
   123      * @return the filename without path component
       
   124      */
       
   125 	HBufC* InstallFileLC( const TDesC& aFileName );
       
   126 
       
   127 	void RemoveBrandL(  const TDesC& aAppId,
       
   128 						const TDesC& aBrandId,
       
   129 						TLanguage aLanguageId,
       
   130 						TInt aReserved = 0);
       
   131 
       
   132 	void RemoveApplicationL(  const TDesC& aAppId );
       
   133 
       
   134 	TInt NextAvailableVersionL();
       
   135 	void SetVersion( TInt aVersionId );
       
   136 
       
   137 	TInt GetNewestVersionL( const TDesC& aAppId,
       
   138 							const TDesC& aBrandId,
       
   139 							TLanguage aLanguageId,
       
   140 						    TPtr* aDrive = NULL);
       
   141 	TInt WriteIbyFiles();
       
   142     
       
   143     void LockStorage();
       
   144     
       
   145     void ReleaseLockL();
       
   146     
       
   147     TBool CheckBrandDiscarded(const TDesC& aAppId,
       
   148 							const TDesC& aBrandId) ;
       
   149 	static HBufC* ConstructDiscardBrandFileNameL( const TDesC& aAppId,
       
   150 										      const TDesC& aBrandId );
       
   151 										      
       
   152 	static HBufC* FullDiscardBrandFileNameLC( TDesC& aFilename ) ;
       
   153 							
       
   154     TInt isActualBrandInstalledL ( const TDesC& aAppId, const TDesC& aBrandId, TLanguage aLanguage);
       
   155 private:
       
   156 
       
   157     CBSStorageManager();
       
   158 
       
   159     void ConstructL( CBSSession* aSession, const TDesC& aAppId );
       
   160     
       
   161     HBufC* ConstructFileNameL( TInt aVersion = 0 );
       
   162     
       
   163     HBufC* ConstructFileNameL( const TDesC& aAppId,
       
   164 						       const TDesC& aBrandId,
       
   165 						       TLanguage aLanguage,
       
   166 						       TInt aReserved = 0 );
       
   167     
       
   168 	void CleanupTransaction();
       
   169 	
       
   170 	HBufC* FullFileNameLC( const TDesC& aFilename, TBool aForceCDrive = EFalse );
       
   171 	
       
   172 	TInt ReadVersionL( const TDesC& aFilename );
       
   173 	
       
   174 	HBufC* FindAvailableVersionL( TInt aCurrentVersion, TInt& aNewVersion );
       
   175 
       
   176 	TBool IsBaseFileL( const TDesC& aFileName );
       
   177 
       
   178 	
       
   179 	/**
       
   180      * Mark a brand package as discarded. Future attempts to create an 
       
   181      * access to this brand package will fail.
       
   182      *
       
   183      * @since S60 3.2
       
   184      * @param aAppId a application id
       
   185      * @param aBrandId a brand id
       
   186      */
       
   187 	void MarkBrandAsDiscardedL( const TDesC& aAppId,
       
   188 		                        const TDesC& aBrandId );
       
   189 
       
   190 private: // Data
       
   191 
       
   192     // Own. Array of stored storages.
       
   193     RPointerArray<CBSStorage> iStorages;
       
   194 
       
   195     // Index of currently active storage
       
   196     TInt iCurrent;
       
   197 
       
   198     // IBY writer
       
   199     CBSIBYWriter* iWriter;
       
   200     
       
   201     RFs		iFs;
       
   202     TBool	iActive;
       
   203     
       
   204     HBufC* iAppId;
       
   205 	HBufC* iBrandId;
       
   206 	HBufC*  iLanguageId;
       
   207 	TLanguage iLanguageIdNum;
       
   208 	
       
   209     // Own. Proposed file name
       
   210     HBufC* iFilename;
       
   211 
       
   212     // Proposed directory (points to iFilename)
       
   213     TPtrC iDir;
       
   214 	
       
   215 	// doesn't own: the server
       
   216 	CBSSession* iSession;
       
   217 	
       
   218 	TBool iAppending;
       
   219 	
       
   220 	HBufC* iIbyFile;
       
   221 	TInt  iReserved;
       
   222 	
       
   223 };
       
   224 
       
   225 #endif //CBSSTORAGEMANAGER_H