homescreenpluginsrv/inc/hspsodt.h
branchRCL_3
changeset 114 a5a39a295112
equal deleted inserted replaced
113:0efa10d348c0 114:a5a39a295112
       
     1 /*
       
     2 * Copyright (c) 2008 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:  Class represents an ODT (Object Description Tree).
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef hspsODT_H
       
    20 #define hspsODT_H
       
    21 
       
    22 #include <e32base.h>
       
    23 
       
    24 class RWriteStream;
       
    25 class RReadStream;
       
    26 class ChspsDomDocument;
       
    27 class ChspsResource;
       
    28 
       
    29 const TInt KArrayGranularity = 5;
       
    30 const TInt KHeaderDataLength = KMaxFileName;
       
    31 const TInt KMaxDescLength = 255;
       
    32 
       
    33 /**
       
    34 *  Class represents an Object Description Tree of HSPS.
       
    35 *  ODT is cabable of marshaling itself into HBufC8 descriptor and unmarshaling
       
    36 *  from descriptor stream.
       
    37 *  A Header is an ODT instance which has not internalized it's resources 
       
    38 *  nor it's DOM (XML payload).
       
    39 *
       
    40 *  @lib hspsODT.lib
       
    41 *  @since S60 5.0
       
    42 *  @ingroup group_hspsodt 
       
    43 */
       
    44 class ChspsODT : public CBase
       
    45     {
       
    46     public:  // Constructors and destructor
       
    47         
       
    48         /**
       
    49         * Two-phased constructor.
       
    50         * 
       
    51         * @since S60 5.0
       
    52         */
       
    53         IMPORT_C static ChspsODT* NewL();
       
    54         
       
    55         /**
       
    56         * Two-phased constructor.
       
    57         * 
       
    58         * @since S60 5.0
       
    59         * @param aStreamData The read stream.
       
    60         */
       
    61         IMPORT_C static ChspsODT* NewLC( const TDesC8& aStreamData );
       
    62         
       
    63         /**
       
    64         * Destructor.
       
    65         */
       
    66         virtual ~ChspsODT();
       
    67     
       
    68     public:        
       
    69         /**
       
    70         * Externalizes the object.
       
    71         * 
       
    72         * @since S60 5.0
       
    73         * @param aStream The write stream.
       
    74         */ 
       
    75         IMPORT_C void ExternalizeL( RWriteStream& aStream) const;
       
    76         
       
    77         /**
       
    78         * Internalizes the object.
       
    79         * 
       
    80         * @since S60 5.0
       
    81         * @param aStream The read stream.
       
    82         */ 
       
    83         IMPORT_C void InternalizeL( RReadStream& aStream);
       
    84 
       
    85     public: // New functions
       
    86         
       
    87         /**
       
    88         * Marshals the ODT header into descriptor stream.
       
    89         * 
       
    90         * @since S60 5.0
       
    91         * @return HBufC8* A descriptor object containing the ODT header.
       
    92         */ 
       
    93         IMPORT_C HBufC8* MarshalHeaderL() const;
       
    94         
       
    95         /**
       
    96         * Unmarshals the header information from the stream and returns
       
    97         * ODT instance.
       
    98         * 
       
    99         * @since S60 5.0
       
   100         * @param aStreamData Descriptor stream containing the ODT header data.
       
   101         * @return ChspsODT* An ODT object prefilled with the header information.
       
   102         */ 
       
   103         IMPORT_C static ChspsODT* UnMarshalHeaderLC( const TDesC8& aStreamData );
       
   104         
       
   105         /**
       
   106         * Unmarshals the header information from the stream and saves the data
       
   107         * into same instance.
       
   108         * 
       
   109         * @since S60 5.0
       
   110         * @param aStreamData Descriptor stream containing the ODT header data.
       
   111         */ 
       
   112         IMPORT_C void UnMarshalHeaderL( const TDesC8& aStreamData );
       
   113         
       
   114         /**
       
   115         * Externalizes the ODT header.
       
   116         * 
       
   117         * @since S60 5.0
       
   118         * @param aStream The read stream.
       
   119         */ 
       
   120         IMPORT_C void ExternalizeHeaderL( RWriteStream& aStream ) const;
       
   121         
       
   122         /**
       
   123         * Internalizes the ODT header.
       
   124         * 
       
   125         * @since S60 5.0
       
   126         * @param aStream The read stream.
       
   127         */ 
       
   128         IMPORT_C void InternalizeHeaderL( RReadStream& aStream );
       
   129         
       
   130         /**
       
   131         * Adds a resource-object into ODT.
       
   132         * 
       
   133         * @since S60 5.0
       
   134         * @param aResource ChspsResource to add. ODT takes ownership.
       
   135         */ 
       
   136         IMPORT_C void AddResourceL( ChspsResource* aResource );
       
   137         
       
   138         /**
       
   139          * Checks duplicates.
       
   140          * 
       
   141          * @since S60 5.0
       
   142          * @param aResource ChspsResource to check.
       
   143          * @return 0 if there were no duplicate resources, index otherwise.
       
   144          */
       
   145         TInt CheckResourceL( ChspsResource* aResource );
       
   146         
       
   147         /**
       
   148         * Deletes a resource from the ODT.
       
   149         * 
       
   150         * @since S60 5.0
       
   151         * @param aIndex Index of the resource to be deleted.
       
   152         */ 
       
   153         IMPORT_C void DeleteResourceL( TInt aIndex );
       
   154 
       
   155         /**
       
   156         * Deletes all resources from the ODT.
       
   157         * 
       
   158         * @since S60 5.0
       
   159         */ 
       
   160         IMPORT_C void DeleteAllResources();        
       
   161         
       
   162         /**
       
   163         * Gets a resource.
       
   164         * 
       
   165         * @since S60 5.0
       
   166         * @param aIndex Index of the resource to be retrieved.
       
   167         * @return A ChspsResource-object to be accessed. Ownership remains.
       
   168         */ 
       
   169         IMPORT_C ChspsResource& ResourceL( TInt aIndex ) const;
       
   170         
       
   171         /**
       
   172         * Amount of resources in ODT.
       
   173         * 
       
   174         * @since S60 5.0
       
   175         * @return TInt Amount of elements.
       
   176         */ 
       
   177         IMPORT_C TInt ResourceCount() const;
       
   178         
       
   179         /**
       
   180         * Externalizes the Resource List.
       
   181         * 
       
   182         * @since S60 5.0
       
   183         * @param aStream The read stream.
       
   184         */ 
       
   185         IMPORT_C void ExternalizeResourceListL( RWriteStream& aStream ) const;
       
   186         
       
   187         /**
       
   188         * Internalizes the Resource List.
       
   189         * 
       
   190         * @since S60 5.0
       
   191         * @param aStream The read stream.
       
   192         */ 
       
   193         IMPORT_C void InternalizeResourceListL( RReadStream& aStream );
       
   194        
       
   195         
       
   196         /**
       
   197         * Set Uid of the application or interface, which uses the theme.
       
   198         * 
       
   199         * @since S60 5.0
       
   200         * @param aUid The root UID.
       
   201         */ 
       
   202         IMPORT_C void SetRootUid( TInt aUid );
       
   203         
       
   204         /**
       
   205         * Get RootUid.
       
   206         * 
       
   207         * @since S60 5.0
       
   208         * @return TInt The root UID.
       
   209         */ 
       
   210         IMPORT_C TInt RootUid() const;
       
   211         
       
   212         /**
       
   213         * Set providerUid.
       
   214         * 
       
   215         * @since S60 5.0
       
   216         * @param aUid The UID of the theme provider.
       
   217         */ 
       
   218         IMPORT_C void SetProviderUid( TInt aUid );
       
   219         
       
   220         /**
       
   221         * Get ProviderUid
       
   222         * 
       
   223         * @since S60 5.0
       
   224         * @return TInt The UID of the theme provider.
       
   225         */ 
       
   226         IMPORT_C TInt ProviderUid() const;
       
   227         
       
   228         /**
       
   229         * Set ThemeUid.
       
   230         * 
       
   231         * @since S60 5.0
       
   232         * @param aUid Theme UID.
       
   233         */ 
       
   234         IMPORT_C void SetThemeUid( TInt aUid );
       
   235         
       
   236         /**
       
   237         * Get ThemeUid.
       
   238         * 
       
   239         * @since S60 5.0
       
   240         * @return TInt Theme UID.
       
   241         */ 
       
   242         IMPORT_C TInt ThemeUid() const;
       
   243         
       
   244         /**
       
   245         * Set ProviderName.
       
   246         * 
       
   247         * @since S60 5.0
       
   248         * @param aName The name of the theme provider.
       
   249         */ 
       
   250         IMPORT_C void SetProviderNameL( const TDesC& aName );
       
   251         
       
   252         /**
       
   253         * Get ProviderName.
       
   254         * 
       
   255         * @since S60 5.0
       
   256         * @return TDesC& The name of the theme provider.
       
   257         */ 
       
   258         IMPORT_C const TDesC& ProviderName() const;
       
   259         
       
   260         /**
       
   261         * Set ThemeFullName.
       
   262         * 
       
   263         * @since S60 5.0
       
   264         * @param aName Themes' name.
       
   265         */ 
       
   266         IMPORT_C void SetThemeFullNameL( const TDesC& aName );
       
   267         
       
   268         /**
       
   269         * Get ThemeFullName.
       
   270         * 
       
   271         * @since S60 5.0
       
   272         * @return TDesC& The name of the theme.
       
   273         */ 
       
   274         IMPORT_C const TDesC& ThemeFullName() const;
       
   275         
       
   276         /**
       
   277         * Set ThemeShortName.
       
   278         * 
       
   279         * @since S60 5.0
       
   280         * @param aName Themes' short name.
       
   281         */ 
       
   282         IMPORT_C void SetThemeShortNameL( const TDesC& aName );
       
   283         
       
   284         /**
       
   285         * Get ThemeShortName
       
   286         * 
       
   287         * @since S60 5.0
       
   288         * @return TDesC& The short name of the theme.
       
   289         */ 
       
   290         IMPORT_C const TDesC& ThemeShortName() const;
       
   291         
       
   292         /**
       
   293         * Set ThemeVersion.
       
   294         * 
       
   295         * @since S60 5.0
       
   296         * @param aVersion Themes' version.
       
   297         */ 
       
   298         IMPORT_C void SetThemeVersionL( const TDesC& aVersion );
       
   299         
       
   300         /**
       
   301         * Get ThemeVersion.
       
   302         * @since S60 5.0
       
   303         * @return TDesC& The version of the theme.
       
   304         */ 
       
   305         IMPORT_C const TDesC& ThemeVersion() const;
       
   306         
       
   307         /**
       
   308         * Set OdtLanguage.
       
   309         * 
       
   310         * @since S60 5.0
       
   311         * @param aLanguage Themes' language.
       
   312         */ 
       
   313         IMPORT_C void SetOdtLanguage( TInt aLanguage );
       
   314         
       
   315         /**
       
   316         * Get OdtLanguage.
       
   317         * 
       
   318         * @since S60 5.0
       
   319         * @return TInt OdtLanguage.
       
   320         */ 
       
   321         IMPORT_C TInt OdtLanguage() const;
       
   322         
       
   323         /**
       
   324         * Set status flag-definitions for themes.
       
   325         * 
       
   326         * @since S60 5.0
       
   327         * @param aFlags Flags to be set.
       
   328         */ 
       
   329         IMPORT_C void SetFlags( TUint aFlags );
       
   330         
       
   331         /**
       
   332         * Get status flag-definitions for themes.
       
   333         * 
       
   334         * @since S60 5.0
       
   335         * @return TUint status flag-definitions.
       
   336         */ 
       
   337         IMPORT_C TUint Flags() const;
       
   338         
       
   339         /**
       
   340         * Get the DomDocument.
       
   341         * 
       
   342         * @since S60 5.0
       
   343         * @return ChspsDomDocument& Dom document.
       
   344         */ 
       
   345         IMPORT_C ChspsDomDocument& DomDocument() const;
       
   346         
       
   347 
       
   348         /**
       
   349         * Clones this ChspsODT.
       
   350         * 
       
   351         * @since S60 5.0
       
   352         * @return ChspsODT* pointer to the cloned ODT.
       
   353         */ 
       
   354         IMPORT_C ChspsODT* CloneL() const;
       
   355 
       
   356         /**
       
   357         * Clones given ODT to this ODT.
       
   358         * 
       
   359         * @since S60 5.0
       
   360         * @param	aODT	Source ODT.
       
   361         */         
       
   362         IMPORT_C void CloneL( ChspsODT& aODT );        
       
   363         
       
   364         /**
       
   365         * Clones the aDom and sets it as this ChspsODT's DomDocument.
       
   366         * 
       
   367         * @since S60 5.0
       
   368         * @param aDom Dom to be cloned.  
       
   369         */ 
       
   370         IMPORT_C void CopyDomDocumentL( ChspsDomDocument& aDom );
       
   371         
       
   372         /**
       
   373         * Set configurationt type.
       
   374         * 
       
   375         * @since S60 5.0
       
   376         * @param aType Type. 
       
   377         */ 
       
   378         IMPORT_C void SetConfigurationType( TUint aType );
       
   379         
       
   380         /**
       
   381         * Get configuration type.
       
   382         * 
       
   383         * @since S60 5.0
       
   384         * @return TUint configuration type.
       
   385         */ 
       
   386         IMPORT_C TUint ConfigurationType() const;
       
   387         
       
   388         /**
       
   389         * Set family.
       
   390         * Identifies the resolution and user interface for which 
       
   391         * the resource/widget was designed for (e.g. vga, qhd_tch).
       
   392         * 
       
   393         * @since S60 5.0
       
   394         * @param aFamily Family mask (supported resolution bits set)
       
   395         */ 
       
   396         IMPORT_C void SetFamily( const TUint32 aFamilyMask );
       
   397         
       
   398         /**
       
   399         * Get family.
       
   400         * 
       
   401         * @since S60 5.0
       
   402         * @return The family mask
       
   403         */ 
       
   404         IMPORT_C TUint32 Family() const;
       
   405 
       
   406         /**
       
   407         * Set Widget instance count
       
   408         * 
       
   409         * @since S60 5.0
       
   410         * @param aMultiInstance multiinstance.
       
   411         */ 
       
   412         IMPORT_C void SetMultiInstance( TInt aMultiInstance );
       
   413 
       
   414         /**
       
   415         * Get Widget instance count
       
   416         * 
       
   417         * @since S60 5.0
       
   418         * @return TInt multiinstance.
       
   419         */ 
       
   420         IMPORT_C TInt MultiInstance() const;
       
   421         
       
   422         /**
       
   423          * Sets description of the widget
       
   424          * @since S60 5.0
       
   425          * @param aDesc Text
       
   426          */
       
   427         IMPORT_C void SetDescriptionL( const TDesC& aDesc );
       
   428 
       
   429         /**
       
   430          * Gets description of the widget
       
   431          * @since S60 5.0
       
   432          * @return text
       
   433          */
       
   434         IMPORT_C const TDesC& Description() const;
       
   435         
       
   436         /**
       
   437          * Sets path of the logo file         
       
   438          * @since S60 5.0
       
   439          * @param aPath Path to the file
       
   440          */
       
   441         IMPORT_C void SetLogoFileL( const TDesC& aPath );
       
   442         
       
   443         /**
       
   444          * Gets path to the logo file         
       
   445          * @since S60 5.0
       
   446          * @return path
       
   447          */
       
   448         IMPORT_C const TDesC& LogoFile() const;
       
   449         
       
   450         /**
       
   451          * Sets path of the preview file         
       
   452          * @since S60 5.0
       
   453          * @param aPath Path to the file
       
   454          */
       
   455         IMPORT_C void SetPreviewFileL( const TDesC& aPath );
       
   456         
       
   457         /**
       
   458          * Gets path to the preview file         
       
   459          * @since S60 5.0
       
   460          * @return path
       
   461          */
       
   462         IMPORT_C const TDesC& PreviewFile() const;
       
   463         
       
   464     private:
       
   465 
       
   466         /**
       
   467         * C++ default constructor.
       
   468         */
       
   469         ChspsODT();
       
   470 
       
   471         /**
       
   472         * By default Symbian 2nd phase constructor is private.
       
   473         */
       
   474         void ConstructL();
       
   475 
       
   476     private:
       
   477         /**
       
   478         * Helper to ODT cloning. Prevents duplicate code in two clone methods.
       
   479         * 
       
   480         * @param aSource    Source ODT
       
   481         * @param aTarget    Target ODT
       
   482         */
       
   483         static void CopyODTDataL( const ChspsODT& aSource, ChspsODT& aTarget );
       
   484         
       
   485         /**
       
   486         * Calculate header size in bytes.
       
   487         * 
       
   488         * @return TInt  Header size.
       
   489         */
       
   490         TInt HeaderSize() const;
       
   491         
       
   492     private:    // Data        
       
   493         // Identifies specific configuration
       
   494         TUint  iThemeUid;
       
   495         HBufC* iProviderName;
       
   496         HBufC* iThemeFullName;
       
   497         HBufC* iThemeShortName;
       
   498         
       
   499         // Revision number
       
   500         HBufC* iThemeVersion;        
       
   501                 
       
   502         // Description of the widget
       
   503         HBufC* iDescription;
       
   504         
       
   505         // Path to the logo file
       
   506         HBufC* iLogoFile;
       
   507         
       
   508         // Path to the preview file
       
   509         HBufC* iPreviewFile;
       
   510 
       
   511         // Family mask (bits for e.g. vga, qhd_tch etc resolutions)
       
   512         TUint32 iFamilyMask;
       
   513         
       
   514         // Configuration type
       
   515         TUint   iConfigurationType;
       
   516         
       
   517         // Application or interface uid
       
   518         TUint  iRootUid;
       
   519         
       
   520         // The publisher
       
   521         TUint  iProviderUid;
       
   522 
       
   523         // ThspsThemeStatus
       
   524         TUint  iFlags;        
       
   525         
       
   526         // Language of the ODT instance
       
   527         TInt   iLanguage;
       
   528         
       
   529         // Multiple instances allowed/not
       
   530         TInt   iMultiInstance;        
       
   531         
       
   532         // Pointer to list of unlocalized resources
       
   533         CArrayPtrSeg<ChspsResource>* iResourceList;
       
   534                 
       
   535         ChspsDomDocument* iDomDocument;
       
   536         
       
   537         // Reserved pointer for future extension
       
   538         TAny* iReserved;
       
   539     };
       
   540 
       
   541 #endif      // hspsODT_H   
       
   542             
       
   543 // End of File