homescreenpluginsrv/inc/hspsodt.h
changeset 0 79c6a41cd166
child 11 bd874ee5e5e2
equal deleted inserted replaced
-1:000000000000 0:79c6a41cd166
       
     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         * Gets a resource.
       
   157         * 
       
   158         * @since S60 5.0
       
   159         * @param aIndex Index of the resource to be retrieved.
       
   160         * @return A ChspsResource-object to be accessed. Ownership remains.
       
   161         */ 
       
   162         IMPORT_C ChspsResource& ResourceL( TInt aIndex ) const;
       
   163         
       
   164         /**
       
   165         * Amount of resources in ODT.
       
   166         * 
       
   167         * @since S60 5.0
       
   168         * @return TInt Amount of elements.
       
   169         */ 
       
   170         IMPORT_C TInt ResourceCount() const;
       
   171         
       
   172         /**
       
   173         * Externalizes the Resource List.
       
   174         * 
       
   175         * @since S60 5.0
       
   176         * @param aStream The read stream.
       
   177         */ 
       
   178         IMPORT_C void ExternalizeResourceListL( RWriteStream& aStream ) const;
       
   179         
       
   180         /**
       
   181         * Internalizes the Resource List.
       
   182         * 
       
   183         * @since S60 5.0
       
   184         * @param aStream The read stream.
       
   185         */ 
       
   186         IMPORT_C void InternalizeResourceListL( RReadStream& aStream );
       
   187        
       
   188         
       
   189         /**
       
   190         * Set Uid of the application or interface, which uses the theme.
       
   191         * 
       
   192         * @since S60 5.0
       
   193         * @param aUid The root UID.
       
   194         */ 
       
   195         IMPORT_C void SetRootUid( TInt aUid );
       
   196         
       
   197         /**
       
   198         * Get RootUid.
       
   199         * 
       
   200         * @since S60 5.0
       
   201         * @return TInt The root UID.
       
   202         */ 
       
   203         IMPORT_C TInt RootUid() const;
       
   204         
       
   205         /**
       
   206         * Set providerUid.
       
   207         * 
       
   208         * @since S60 5.0
       
   209         * @param aUid The UID of the theme provider.
       
   210         */ 
       
   211         IMPORT_C void SetProviderUid( TInt aUid );
       
   212         
       
   213         /**
       
   214         * Get ProviderUid
       
   215         * 
       
   216         * @since S60 5.0
       
   217         * @return TInt The UID of the theme provider.
       
   218         */ 
       
   219         IMPORT_C TInt ProviderUid() const;
       
   220         
       
   221         /**
       
   222         * Set ThemeUid.
       
   223         * 
       
   224         * @since S60 5.0
       
   225         * @param aUid Theme UID.
       
   226         */ 
       
   227         IMPORT_C void SetThemeUid( TInt aUid );
       
   228         
       
   229         /**
       
   230         * Get ThemeUid.
       
   231         * 
       
   232         * @since S60 5.0
       
   233         * @return TInt Theme UID.
       
   234         */ 
       
   235         IMPORT_C TInt ThemeUid() const;
       
   236         
       
   237         /**
       
   238         * Set ProviderName.
       
   239         * 
       
   240         * @since S60 5.0
       
   241         * @param aName The name of the theme provider.
       
   242         */ 
       
   243         IMPORT_C void SetProviderNameL( const TDesC& aName );
       
   244         
       
   245         /**
       
   246         * Get ProviderName.
       
   247         * 
       
   248         * @since S60 5.0
       
   249         * @return TDesC& The name of the theme provider.
       
   250         */ 
       
   251         IMPORT_C const TDesC& ProviderName() const;
       
   252         
       
   253         /**
       
   254         * Set ThemeFullName.
       
   255         * 
       
   256         * @since S60 5.0
       
   257         * @param aName Themes' name.
       
   258         */ 
       
   259         IMPORT_C void SetThemeFullNameL( const TDesC& aName );
       
   260         
       
   261         /**
       
   262         * Get ThemeFullName.
       
   263         * 
       
   264         * @since S60 5.0
       
   265         * @return TDesC& The name of the theme.
       
   266         */ 
       
   267         IMPORT_C const TDesC& ThemeFullName() const;
       
   268         
       
   269         /**
       
   270         * Set ThemeShortName.
       
   271         * 
       
   272         * @since S60 5.0
       
   273         * @param aName Themes' short name.
       
   274         */ 
       
   275         IMPORT_C void SetThemeShortNameL( const TDesC& aName );
       
   276         
       
   277         /**
       
   278         * Get ThemeShortName
       
   279         * 
       
   280         * @since S60 5.0
       
   281         * @return TDesC& The short name of the theme.
       
   282         */ 
       
   283         IMPORT_C const TDesC& ThemeShortName() const;
       
   284         
       
   285         /**
       
   286         * Set ThemeVersion.
       
   287         * 
       
   288         * @since S60 5.0
       
   289         * @param aVersion Themes' version.
       
   290         */ 
       
   291         IMPORT_C void SetThemeVersionL( const TDesC& aVersion );
       
   292         
       
   293         /**
       
   294         * Get ThemeVersion.
       
   295         * @since S60 5.0
       
   296         * @return TDesC& The version of the theme.
       
   297         */ 
       
   298         IMPORT_C const TDesC& ThemeVersion() const;
       
   299         
       
   300         /**
       
   301         * Set OdtLanguage.
       
   302         * 
       
   303         * @since S60 5.0
       
   304         * @param aLanguage Themes' language.
       
   305         */ 
       
   306         IMPORT_C void SetOdtLanguage( TInt aLanguage );
       
   307         
       
   308         /**
       
   309         * Get OdtLanguage.
       
   310         * 
       
   311         * @since S60 5.0
       
   312         * @return TInt OdtLanguage.
       
   313         */ 
       
   314         IMPORT_C TInt OdtLanguage() const;
       
   315         
       
   316         /**
       
   317         * Set status flag-definitions for themes.
       
   318         * 
       
   319         * @since S60 5.0
       
   320         * @param aFlags Flags to be set.
       
   321         */ 
       
   322         IMPORT_C void SetFlags( TUint aFlags );
       
   323         
       
   324         /**
       
   325         * Get status flag-definitions for themes.
       
   326         * 
       
   327         * @since S60 5.0
       
   328         * @return TUint status flag-definitions.
       
   329         */ 
       
   330         IMPORT_C TUint Flags() const;
       
   331         
       
   332         /**
       
   333         * Get the DomDocument.
       
   334         * 
       
   335         * @since S60 5.0
       
   336         * @return ChspsDomDocument& Dom document.
       
   337         */ 
       
   338         IMPORT_C ChspsDomDocument& DomDocument() const;
       
   339         
       
   340 
       
   341         /**
       
   342         * Clones this ChspsODT.
       
   343         * 
       
   344         * @since S60 5.0
       
   345         * @return ChspsODT* pointer to the cloned ODT.
       
   346         */ 
       
   347         IMPORT_C ChspsODT* CloneL();
       
   348         
       
   349         
       
   350         /**
       
   351         * Clones the aDom and sets it as this ChspsODT's DomDocument.
       
   352         * 
       
   353         * @since S60 5.0
       
   354         * @param aDom Dom to be cloned.  
       
   355         */ 
       
   356         IMPORT_C void CopyDomDocumentL( ChspsDomDocument& aDom );
       
   357         
       
   358         /**
       
   359         * Set configurationt type.
       
   360         * 
       
   361         * @since S60 5.0
       
   362         * @param aType Type. 
       
   363         */ 
       
   364         IMPORT_C void SetConfigurationType( TUint aType );
       
   365         
       
   366         /**
       
   367         * Get configuration type.
       
   368         * 
       
   369         * @since S60 5.0
       
   370         * @return TUint configuration type.
       
   371         */ 
       
   372         IMPORT_C TUint ConfigurationType() const;
       
   373 
       
   374         /**
       
   375         * Set package version.
       
   376         * 
       
   377         * @since S60 5.0
       
   378         * @param aVersion Version. 
       
   379         */ 
       
   380         IMPORT_C void SetPackageVersionL( const TDesC& aVersion );
       
   381         
       
   382         /**
       
   383         * Get configuration type.
       
   384         * 
       
   385         * @since S60 5.0
       
   386         * @return TDesC package version
       
   387         */ 
       
   388         IMPORT_C const TDesC& PackageVersion() const;
       
   389         
       
   390         /**
       
   391         * Set family.
       
   392         * Identifies the resolution and user interface for which 
       
   393         * the resource/widget was designed for (e.g. vga, qhd_tch).
       
   394         * 
       
   395         * @since S60 5.0
       
   396         * @param aFamily Family mask (supported resolution bits set)
       
   397         */ 
       
   398         IMPORT_C void SetFamily( const TUint32 aFamilyMask );
       
   399         
       
   400         /**
       
   401         * Get family.
       
   402         * 
       
   403         * @since S60 5.0
       
   404         * @return The family mask
       
   405         */ 
       
   406         IMPORT_C TUint32 Family() const;
       
   407 
       
   408         /**
       
   409         * Set Widget instance count
       
   410         * 
       
   411         * @since S60 5.0
       
   412         * @param aMultiInstance multiinstance.
       
   413         */ 
       
   414         IMPORT_C void SetMultiInstance( TInt aMultiInstance );
       
   415 
       
   416         /**
       
   417         * Get Widget instance count
       
   418         * 
       
   419         * @since S60 5.0
       
   420         * @return TInt multiinstance.
       
   421         */ 
       
   422         IMPORT_C TInt MultiInstance() const;
       
   423         
       
   424         /**
       
   425          * Sets description of the widget
       
   426          * @since S60 5.0
       
   427          * @param aDesc Text
       
   428          */
       
   429         IMPORT_C void SetDescriptionL( const TDesC& aDesc );
       
   430 
       
   431         /**
       
   432          * Gets description of the widget
       
   433          * @since S60 5.0
       
   434          * @return text
       
   435          */
       
   436         IMPORT_C const TDesC& Description() const;
       
   437         
       
   438         /**
       
   439          * Sets path of the logo file         
       
   440          * @since S60 5.0
       
   441          * @param aPath Path to the file
       
   442          */
       
   443         IMPORT_C void SetLogoFileL( const TDesC& aPath );
       
   444         
       
   445         /**
       
   446          * Gets path to the logo file         
       
   447          * @since S60 5.0
       
   448          * @return path
       
   449          */
       
   450         IMPORT_C const TDesC& LogoFile() const;
       
   451         
       
   452         /**
       
   453          * Sets path of the preview file         
       
   454          * @since S60 5.0
       
   455          * @param aPath Path to the file
       
   456          */
       
   457         IMPORT_C void SetPreviewFileL( const TDesC& aPath );
       
   458         
       
   459         /**
       
   460          * Gets path to the preview file         
       
   461          * @since S60 5.0
       
   462          * @return path
       
   463          */
       
   464         IMPORT_C const TDesC& PreviewFile() const;
       
   465         
       
   466     private:
       
   467 
       
   468         /**
       
   469         * C++ default constructor.
       
   470         */
       
   471         ChspsODT();
       
   472 
       
   473         /**
       
   474         * By default Symbian 2nd phase constructor is private.
       
   475         */
       
   476         void ConstructL();
       
   477 
       
   478     private:    // Data
       
   479 
       
   480         // Family mask (bits for e.g. vga, qhd_tch etc resolutions)
       
   481         TUint32 iFamilyMask;
       
   482         
       
   483     	// Configuration type
       
   484     	TUint	iConfigurationType;
       
   485     	
       
   486     	// Application or interface uid
       
   487         TUint  iRootUid;
       
   488         
       
   489         // The publisher
       
   490         TUint  iProviderUid;
       
   491         
       
   492         // Identifies specific configuration
       
   493         TUint  iThemeUid;
       
   494         HBufC* iProviderName;
       
   495         HBufC* iThemeFullName;
       
   496         HBufC* iThemeShortName;
       
   497         
       
   498         // Revision number
       
   499         HBufC* iThemeVersion;
       
   500         
       
   501         // Indicates whether we are able to internalize the instance        
       
   502         HBufC* iPackageVersion;
       
   503         
       
   504         // Language of the ODT instance
       
   505         TInt   iLanguage;
       
   506         
       
   507         // Multiple instances allowed/not
       
   508         TInt   iMultiInstance;
       
   509         
       
   510         // Description of the widget
       
   511         HBufC* iDescription;
       
   512         
       
   513         // Path to the logo file
       
   514         HBufC* iLogoFile;
       
   515         
       
   516         // Path to the preview file
       
   517         HBufC* iPreviewFile;
       
   518         
       
   519         // ThspsThemeStatus
       
   520         TUint  iFlags;
       
   521                         
       
   522         // Pointer to list of unlocalized resources
       
   523         CArrayPtrSeg<ChspsResource>* iResourceList;
       
   524                 
       
   525         ChspsDomDocument* iDomDocument;
       
   526         
       
   527         // Reserved pointer for future extension
       
   528         TAny* iReserved;
       
   529     };
       
   530 
       
   531 #endif      // hspsODT_H   
       
   532             
       
   533 // End of File