brandingserver/bsserver/cbsstorage.h
changeset 46 860cd8a5168c
parent 35 085f765766a0
equal deleted inserted replaced
35:085f765766a0 46:860cd8a5168c
     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:  Stores element data and writes it to stream
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef CBSSTORAGE_H
       
    20 #define CBSSTORAGE_H
       
    21 
       
    22 #include <e32base.h>
       
    23 
       
    24 #include "rbsobjowningptrarray.h"
       
    25 
       
    26 class MBSElement;
       
    27 class RWriteStream;
       
    28 class MBSImportLogger;
       
    29 
       
    30 
       
    31 /**
       
    32  *  Stores element data and writes it to stream
       
    33  *
       
    34  *  @lib brandimporter.exe
       
    35  *  @since S60 v3.2
       
    36  */
       
    37 class CBSStorage : public CBase
       
    38 {
       
    39 public:
       
    40 
       
    41     static CBSStorage* NewL();
       
    42 
       
    43     static CBSStorage* NewLC();
       
    44 
       
    45     ~CBSStorage();
       
    46 
       
    47     /**
       
    48      * Set version of brand storage
       
    49      *
       
    50      * @since S60 3.2
       
    51      * @param aVersion version
       
    52      */
       
    53     void SetVersion( TInt aVersion );
       
    54 
       
    55     /**
       
    56      * Set application ID of brand storage
       
    57      *
       
    58      * @since S60 3.2
       
    59      * @param aAppId application ID
       
    60      * @return none
       
    61      */
       
    62     void SetApplicationIdL( const TDesC& aAppId );
       
    63 
       
    64     /**
       
    65      * Set storage ID of brand storage
       
    66      *
       
    67      * @since S60 3.2
       
    68      * @param aStorageId storage ID
       
    69      * @return none
       
    70      */
       
    71     void SetStorageIdL( const TDesC& aStorageId );
       
    72 
       
    73     /**
       
    74      * Set language of brand storage
       
    75      *
       
    76      * @since S60 3.2
       
    77      * @param aLanguage language
       
    78      * @return none
       
    79      */
       
    80     void SetLanguageL( TLanguage aLanguage );
       
    81 
       
    82     /**
       
    83      * Store element to storage. Storage takes the ownership of element.
       
    84      *
       
    85      * @since S60 3.2
       
    86      * @param aElement element to store.
       
    87      * @return General Symbian errorcode.
       
    88      */
       
    89     void AppendElementsL( MBSElement* aElement );
       
    90 
       
    91     /**
       
    92      * Return the count of elements in storage
       
    93      *
       
    94      * @since S60 3.2
       
    95      * @return count of elements
       
    96      */
       
    97     TInt ElementCount();
       
    98 
       
    99     /**
       
   100      * Externalize storage into stream
       
   101      *
       
   102      * @since S60 3.2
       
   103      * @param aWriteStream output stream
       
   104      * @return none
       
   105      */
       
   106     void ExternalizeL( RWriteStream& aWriteStream );
       
   107 
       
   108     /**
       
   109      * Replaces an element in the storage
       
   110      *
       
   111      * @since S60 3.2
       
   112      * @param aElement the element to be replaced
       
   113      */
       
   114     void ReplaceElementL( MBSElement* aElement );
       
   115 	
       
   116 
       
   117     TPtrC ProposeFileNameL();
       
   118     TPtrC ProposedDirL();
       
   119     void GetListOfFilesL( RArray<TPtrC>& aFileList );
       
   120 
       
   121 private:
       
   122 
       
   123     CBSStorage();
       
   124 
       
   125     void ConstructL();
       
   126 
       
   127     /**
       
   128      * Check that header information is complete
       
   129      *
       
   130      * @since S60 3.2
       
   131      * @return ETrue  - header information ok
       
   132      *         EFalse - header information missing or incomplete
       
   133      */
       
   134     TBool VerifyHeader();
       
   135 
       
   136     TBool VerifyDataL( TArray<MBSElement*> aArray,
       
   137                       TBool aIgnoreEmptyID = EFalse );
       
   138 	TBool VerifyDataL( RBSObjOwningPtrArray<MBSElement>& aArray,
       
   139                       TBool aIgnoreEmptyID = EFalse );
       
   140 
       
   141     void HandleIfErrorL( TInt aError, const TDesC& aText );
       
   142 
       
   143     void AppendFilesL( MBSElement* aElement, RArray<TPtrC>& aFileList );
       
   144 
       
   145 private: // Data
       
   146 
       
   147     // Own. Array of stored elements.
       
   148     RBSObjOwningPtrArray<MBSElement> iElements;
       
   149 
       
   150     // Own. Proposed file name
       
   151     HBufC* iFilename;
       
   152 
       
   153     // Proposed directory (points to iFilename)
       
   154     TPtrC iDir;
       
   155 
       
   156     // HEADER DATA
       
   157 
       
   158     // Version number of storage
       
   159     TInt iVersion;
       
   160 
       
   161     // Own. Language ID of storage
       
   162     HBufC* iLanguage;
       
   163 
       
   164     // Own. Application ID of storage
       
   165     HBufC* iAppId;
       
   166 
       
   167     // Own. Storage ID.of storage
       
   168     HBufC* iStorageId;
       
   169 };
       
   170 
       
   171 #endif //CBSSTORAGE_H