brandingserver/tools/bsimport/inc/cbsimportstorage.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:  Stores element data and writes it to stream
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef CBSIMPORTSTORAGE_H
       
    20 #define CBSIMPORTSTORAGE_H
       
    21 
       
    22 #include <e32base.h>
       
    23 
       
    24 class MBSElement;
       
    25 class RWriteStream;
       
    26 
       
    27 
       
    28 /**
       
    29  *  Stores element data and writes it to stream
       
    30  *
       
    31  *  @lib brandimporter.exe
       
    32  *  @since S60 v3.2
       
    33  */
       
    34 class CBSImportStorage : public CBase
       
    35 {
       
    36 public:
       
    37 
       
    38     static CBSImportStorage* NewL();
       
    39     
       
    40     static CBSImportStorage* NewLC();
       
    41     
       
    42     ~CBSImportStorage();
       
    43     
       
    44     /**
       
    45      * Set version of brand storage
       
    46      *
       
    47      * @since S60 3.2
       
    48      * @param aVersion version
       
    49      */
       
    50     void SetVersion( TInt aVersion );
       
    51     
       
    52     /**
       
    53      * Set application ID of brand storage
       
    54      *
       
    55      * @since S60 3.2
       
    56      * @param aAppId application ID
       
    57      * @return none
       
    58      */
       
    59     void SetApplicationIdL( const TDesC& aAppId );
       
    60     
       
    61     /**
       
    62      * Set storage ID of brand storage
       
    63      *
       
    64      * @since S60 3.2
       
    65      * @param aStorageId storage ID
       
    66      * @return none
       
    67      */
       
    68     void SetStorageIdL( const TDesC& aStorageId );
       
    69     
       
    70     /**
       
    71      * Set language of brand storage
       
    72      *
       
    73      * @since S60 3.2
       
    74      * @param aLanguage language
       
    75      * @return none
       
    76      */
       
    77     void SetLanguageL( TLanguage aLanguage );
       
    78     
       
    79     /**
       
    80      * Store element to storage. Storage takes the ownership of element.
       
    81      *
       
    82      * @since S60 3.2
       
    83      * @param aElement element to store.
       
    84      * @return General Symbian errorcode. 
       
    85      */
       
    86     TInt AppendElement( MBSElement* aElement );
       
    87     
       
    88     /**
       
    89      * Return the count of elements in storage
       
    90      *
       
    91      * @since S60 3.2
       
    92      * @return count of elements
       
    93      */
       
    94     TInt ElementCount();
       
    95 
       
    96     /**
       
    97      * Return one element
       
    98      *
       
    99      * @since S60 3.2
       
   100      * @return requested element
       
   101      */
       
   102     MBSElement* Element( TInt aIndex );
       
   103     
       
   104     /**
       
   105      * Externalize storage into stream
       
   106      *
       
   107      * @since S60 3.2
       
   108      * @param aWriteStream output stream
       
   109      * @return none
       
   110      */
       
   111     void ExternalizeL( RWriteStream& aWriteStream );
       
   112     void FlushToServerL();
       
   113 
       
   114     /**
       
   115      * Gives a full filename which is constructed from header data
       
   116      *
       
   117      * @since S60 3.2
       
   118      * @return filename
       
   119      */
       
   120     TPtrC ProposeFileNameL();
       
   121 
       
   122     /**
       
   123      * Scan through all elements in storage and find EFile items.
       
   124      * Appends all found items to aFileList array.
       
   125      *
       
   126      * @since S60 3.2
       
   127      * @param aFileList filelist array
       
   128      */
       
   129     void GetListOfFiles( RArray<TPtrC>& aFileList );
       
   130 
       
   131     /**
       
   132      * Compare storages header data to another storage.
       
   133      *
       
   134      * @since S60 3.2
       
   135      * @param aStorage storage to compare
       
   136      * @return ETrue  - storages match
       
   137      *         EFalse - storages don't match
       
   138      */
       
   139     TBool Compare( const CBSImportStorage* aStorage ) const;
       
   140     
       
   141     /**
       
   142      * Take content of one storage into this storage. Will delete
       
   143      * elements in aStorage!
       
   144      *
       
   145      * @since S60 3.2
       
   146      * @param aStorage storage to append
       
   147      */
       
   148     void TakeElements( CBSImportStorage* aStorage );
       
   149 
       
   150 private:
       
   151 
       
   152     CBSImportStorage();
       
   153 
       
   154     void ConstructL();
       
   155     
       
   156     /**
       
   157      * Check that header information is complete
       
   158      *
       
   159      * @since S60 3.2
       
   160      * @return ETrue  - header information ok
       
   161      *         EFalse - header information missing or incomplete
       
   162      */
       
   163     TBool VerifyHeader();
       
   164 
       
   165     /**
       
   166      * Check that data information is correct.
       
   167      *  - verify that elements have unique ID's
       
   168      *
       
   169      * @since S60 3.2
       
   170      * @param aArray array of elements to check
       
   171      * @param aIgnoreEmptyID ETrue: empty id's are considered as unique
       
   172      *                       EFalse: 2 empty id's will fail this check
       
   173      * @return ETrue  - data ok.
       
   174      *         EFalse - bad data.
       
   175      */
       
   176     TBool VerifyDataL( TArray<MBSElement*> aArray, 
       
   177                        TBool aIgnoreEmptyID = EFalse );
       
   178     
       
   179     /**
       
   180      * Creates a filename from given header data.
       
   181      * \[application_id]\[brand_id]\[def_filename][language_id]
       
   182      *
       
   183      * @since S60 3.2
       
   184      */
       
   185     void ConstructFileNameL();
       
   186     
       
   187     
       
   188     /**
       
   189      * Check element for EFile items.
       
   190      * Appends all found items to aFileList array.
       
   191      *
       
   192      * @since S60 3.2
       
   193      * @param aElement element to check
       
   194      * @param aFileList filelist array
       
   195      */
       
   196     void AppendFiles( MBSElement* aElement, RArray<TPtrC>& aFileList );
       
   197     
       
   198 private: // Data
       
   199 
       
   200     // Own. Array of stored elements.
       
   201     RPointerArray<MBSElement> iElements;
       
   202     
       
   203     // Own. Proposed file name
       
   204     HBufC* iFilename;
       
   205     
       
   206     // HEADER DATA
       
   207     
       
   208     // Version number of storage
       
   209     TInt iVersion;
       
   210     
       
   211     // Language ID of storage
       
   212     TLanguage iLanguage;
       
   213     
       
   214     // Own. Application ID of storage
       
   215     HBufC8* iAppId;
       
   216     
       
   217     // Own. Storage ID.of storage
       
   218     HBufC8* iStorageId;
       
   219 };
       
   220 
       
   221 #endif //CBSIMPORTSTORAGE_H