idlehomescreen/inc/xnresource.h
changeset 0 f72a12da539e
child 27 7a8b39b569cb
equal deleted inserted replaced
-1:000000000000 0:f72a12da539e
       
     1 /*
       
     2 * Copyright (c) 2002-2004 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:  
       
    15 *
       
    16 *  Xuikon CXnResource-class defines all information what is needed to maintain
       
    17 *  resources of Application Theme. Every CXnResource-objects defines just one 
       
    18 *  resource source, however, the same resource source could be referenced
       
    19 *  multiple times inside a theme - resources are usually shared. 
       
    20 *  Xuikon Application Theme Management system supports theme resourcing by 
       
    21 *  offering resource conversations and storing services, and offering Rendering
       
    22 *  Engines the following services:
       
    23 *  1) the way to match a resource quoted in xml- or css-module to the 
       
    24 *  corresponding resource source, and 2) a secure way to access a resource 
       
    25 *  through the Symbian Platform Security's process separation wall.
       
    26 *
       
    27 *
       
    28 */
       
    29 
       
    30 
       
    31 #ifndef XNRESOURCE_H
       
    32 #define XNRESOURCE_H
       
    33 
       
    34 #include <e32base.h>
       
    35 #include <apmstd.h> // MIME
       
    36 #include <s32mem.h> // streams
       
    37  
       
    38 /**
       
    39 * TXnLockingPolicy
       
    40 * Locking policy flag-definitions for Xuikon. These are bit-masked.
       
    41 */
       
    42 enum TXnLockingPolicy
       
    43   {
       
    44   EXnUnlocked           = 0x0000, //0b0000000000000000,
       
    45   EXnLocked             = 0x0001  //0b0000000000000001,
       
    46   };
       
    47     
       
    48 /**
       
    49 * TXnCacheType
       
    50 * Cache-type definitions for Xuikon.
       
    51 */
       
    52 enum TXnCacheType
       
    53     {
       
    54     /**
       
    55     * ECacheNone. Resource is not cached = direct file access in resources original format.
       
    56     *
       
    57     */
       
    58     ECacheNone,
       
    59     
       
    60     /**
       
    61     * ECacheFile. Resource is externalized to file stream - it can be internalized from given 
       
    62     *               file stream on construct. 
       
    63     */
       
    64     ECacheFile, 
       
    65     
       
    66     /**
       
    67     * ECacheNone. Resource is externalized in to iBuffer - it can be internalized from this
       
    68     *               buffer on construct.
       
    69     */  
       
    70     ECacheMemory
       
    71     };
       
    72 
       
    73 /**
       
    74 *   Resource file extension definitions for Xuikon.
       
    75 */
       
    76 _LIT(KRLBFileExtension,".r");
       
    77 _LIT(KODTFileExtension,".o");
       
    78 _LIT(KDTDFileExtension,".dtd");
       
    79 _LIT(KXMLFileExtension,".xml");
       
    80 _LIT(KCSSFileExtension,".css");
       
    81 _LIT(KDATFileExtension,".dat");
       
    82 
       
    83 _LIT(KFBSFileExtension,".fbs");
       
    84 _LIT(KMBMFileExtension,".mbm");
       
    85 _LIT(KMIFFileExtension,".mif");
       
    86 _LIT(KBMPFileExtension,".bmp");
       
    87 _LIT(KJPGFileExtension,".jpg");
       
    88 _LIT(KJPEGFileExtension,".jpeg");
       
    89 _LIT(KPNGFileExtension,".png");
       
    90 _LIT(KGIFFileExtension,".gif");
       
    91 _LIT(KAACFileExtension,".aac");
       
    92 _LIT(KWAVFileExtension,".wav");
       
    93 _LIT(KMIDFileExtension,".mid");
       
    94 _LIT(KMP3FileExtension,".mp3");
       
    95 _LIT(KM3GFileExtension,".m3g");
       
    96 _LIT(KSVGFileExtension,".svg");
       
    97 _LIT(KSWFFileExtension,".swf");
       
    98 _LIT(KTXTFileExtension,".txt");
       
    99 
       
   100 /**
       
   101 * TXnResourceType
       
   102 * Resource-type definitions for Xuikon.
       
   103 */
       
   104 enum TXnResourceType
       
   105     {
       
   106     /**
       
   107     * EResourceNone. No type at all - juts a file path.
       
   108     */
       
   109     EResourceNone,
       
   110     
       
   111     /**
       
   112     * EResourceRLB.
       
   113     */
       
   114     EResourceRLB,
       
   115     
       
   116     /**
       
   117     * EResourceODT. Resource is ODT (Xuikon Application Theme's binary format)
       
   118     */
       
   119     EResourceODT,
       
   120     
       
   121     /**
       
   122     * EResourceDTD.
       
   123     */
       
   124     EResourceDTD,
       
   125     
       
   126     /**
       
   127     * EResourceXML.
       
   128     */
       
   129     EResourceXML,
       
   130     
       
   131     /**
       
   132     * EResourceCSS.
       
   133     */
       
   134     EResourceCSS,
       
   135     
       
   136     /**
       
   137     * EResourceDAT.
       
   138     */
       
   139     EResourceDAT,
       
   140     
       
   141     /**
       
   142     * EResourceRES. Resource is some media content.
       
   143     */
       
   144     EResourceRES,
       
   145     
       
   146     /**
       
   147     * EResourceFBS. Resource is externalized CFbsBitmap.
       
   148     */
       
   149     EResourceFBS,
       
   150     
       
   151     /**
       
   152     * EResourceMBM. Resource is Symbian MBM-multiple-image.
       
   153     */
       
   154     EResourceMBM,
       
   155     
       
   156     /**
       
   157     * EResourceMIF. Resource is Symbian MIF.
       
   158     */
       
   159     
       
   160     EResourceMIF,
       
   161     
       
   162     /**
       
   163     * EResourceBMP. Resource is BMP-image.
       
   164     */
       
   165     EResourceBMP,
       
   166     
       
   167     /**
       
   168     * EResourceJPG and EResourceJPEG. Resource is JPEG-compliant image.
       
   169     */
       
   170     EResourceJPG,
       
   171     EResourceJPEG,
       
   172     
       
   173     /**
       
   174     * EResourcePNG. Resource is in PNG-format.
       
   175     */
       
   176     EResourcePNG,
       
   177     
       
   178     /**
       
   179     * EResourceGIF. Resourec is in GIF-format. 
       
   180     */
       
   181     EResourceGIF,  
       
   182     
       
   183     /**
       
   184     * EResourceAAC. Resource is a AAC audio file.
       
   185     */
       
   186     EResourceAAC, 
       
   187     
       
   188     /**
       
   189     * EResourceWAV. Resource is a WAV audio file
       
   190     */
       
   191     EResourceWAV,
       
   192     
       
   193     /**
       
   194     * EResourceMID. Resource is a MID audio file.
       
   195     */
       
   196     EResourceMID,
       
   197     
       
   198     /**
       
   199     * EResourceMP3. Resource is a MP3 audio file.
       
   200     */
       
   201     EResourceMP3,
       
   202         
       
   203     /**
       
   204     * EResourceM3G. Resource is M3G.
       
   205     */
       
   206     EResourceM3G,
       
   207     
       
   208     /**
       
   209     * EResourceSVG. Resource is SVG. 
       
   210     */
       
   211     EResourceSVG,
       
   212        
       
   213     /**
       
   214     * EResourceSWF. Resource is a Macromedia shock wave i.e. flash file
       
   215     */
       
   216     EResourceSWF,
       
   217     
       
   218     /**
       
   219     * EResourceMIME. Resource is in Symbian OS 9.x supported MIME-type format.
       
   220     */
       
   221     EResourceMIME,
       
   222 
       
   223     /**
       
   224     * EResourceTXT. Resource is TXT.
       
   225     */
       
   226     EResourceTXT
       
   227     
       
   228     };
       
   229 
       
   230 
       
   231 /**
       
   232 *  @ingroup group_xnresource
       
   233 *  
       
   234 *  CXnResource is Xuikon-utility class defining resource-structure.
       
   235 *
       
   236 *  @lib XnResource.lib
       
   237 *  @since S60 3.1
       
   238 */
       
   239 class CXnResource : public CBase
       
   240     {
       
   241     public:  // Constructors and destructor
       
   242         
       
   243         /**
       
   244         * Two-phased constructor.
       
   245         */
       
   246         IMPORT_C static CXnResource* NewL();
       
   247         /**
       
   248         * Two-phased constructor.
       
   249         * @param aStream The read stream
       
   250         */
       
   251         IMPORT_C static CXnResource* NewLC( RReadStream& aStream );
       
   252         
       
   253         /**
       
   254         * CXnResource::CloneL(). Makes a clone of this class.
       
   255         * @since S60 3.1
       
   256         * @return void
       
   257         */
       
   258         IMPORT_C CXnResource* CloneL();
       
   259         /**
       
   260         * Destructor.
       
   261         */
       
   262         virtual ~CXnResource();
       
   263 
       
   264     public: // New functions
       
   265         
       
   266         /**
       
   267         * CXnResource::SetLockingPolicy(). Sets value of iLockingPolicy data member.
       
   268         * @since S60 3.1
       
   269         * @param aLockingPolicy is new value for iLockingPolicy data member.
       
   270         * @return void
       
   271         */
       
   272         IMPORT_C void SetLockingPolicy( TXnLockingPolicy aLockingPolicy );
       
   273         
       
   274         /**
       
   275         * CXnResource::LockingPolicy(). Gets value of iLockingPolicy data member.
       
   276         * @since S60 3.1
       
   277         * @return TXnLockingPolicy iLockingPolicy.
       
   278         */
       
   279         IMPORT_C TXnLockingPolicy LockingPolicy() const;
       
   280         
       
   281         /**
       
   282         * CXnResource::SetCacheType(). Sets value of iCacheType data member.
       
   283         * @since S60 3.1
       
   284         * @param aCacheType is new value for iCacheType data member.
       
   285         * @return void
       
   286         */
       
   287         IMPORT_C void SetCacheType( TXnCacheType aCacheType );
       
   288         
       
   289         /**
       
   290         * CXnResource::CacheType(). Gets value of iCacheType data member.
       
   291         * @since S60 3.1
       
   292         * @return TXnCacheType iCacheType.
       
   293         */
       
   294         IMPORT_C TXnCacheType CacheType() const;
       
   295      
       
   296         /**
       
   297         * CXnResource::SetResourceType(). Sets value of iResourceType data member.
       
   298         * @since S60 3.1
       
   299         * @param aResourceType is new value of iResourceType data member.
       
   300         * @return void
       
   301         */    
       
   302         IMPORT_C void SetResourceType( TXnResourceType aResourceType );
       
   303         
       
   304         /**
       
   305         * CXnResource::ResourceType(). Gets value of iResourceType data member..
       
   306         * @since S60 3.1
       
   307         * @return TXnResourceType iResourceType.
       
   308         */
       
   309         IMPORT_C TXnResourceType ResourceType() const;
       
   310         
       
   311         /**
       
   312         * CXnResource::SetResourceIdL(). Sets value of iResourceId data member.
       
   313         * @since S60 3.1
       
   314         * @param aResourceId is new value of iResourceId data member.
       
   315         * @return void
       
   316         */
       
   317         
       
   318         IMPORT_C void SetResourceIdL( const TDesC& aResourceId );
       
   319         
       
   320         /**
       
   321         * CXnResource::ResourceId(). Gets value of iResourceId data member.
       
   322         * @since S60 3.1
       
   323         * @return TDesC& iResourceId.
       
   324         */
       
   325         IMPORT_C const TDesC& ResourceId() const;
       
   326         
       
   327         /**
       
   328         * CXnResource::SetNameSpaceL(). Sets value of iNameSpace data member.
       
   329         * @since S60 3.1
       
   330         * @param aNameSpace is new value of iNameSpace data member.
       
   331         * @return void
       
   332         */
       
   333         IMPORT_C void SetNameSpaceL( const TDesC& aNameSpace );
       
   334         
       
   335         /**
       
   336         * CXnResource::NameSpace(). Gets value of iNameSpace data member.
       
   337         * @since S60 3.1
       
   338         * @return TDesC& iNameSpace
       
   339         */
       
   340         IMPORT_C const TDesC& NameSpace() const;
       
   341         
       
   342         /**
       
   343         * CXnResource::SetFileNameL(). Sets value of iFileName data member.
       
   344         * @since S60 3.1
       
   345         * @param aFileName is new iFileName value.
       
   346         * @return void
       
   347         */
       
   348         IMPORT_C void SetFileNameL( const TDesC& aFileName );
       
   349         
       
   350         /**
       
   351         * CXnResource::FileName(). Gets value of iFileName data member.
       
   352         * @since S60 3.1
       
   353         * @return TDes& iFileName.
       
   354         */
       
   355         IMPORT_C const TDesC& FileName() const;
       
   356         
       
   357         /**
       
   358         * CXnResource::SetMimeTypeL(). Sets value of iMimeType data member. 
       
   359         * @since S60 3.1
       
   360         * @param aDataType is a new value of iMimeType.
       
   361         * @return void
       
   362         */
       
   363         IMPORT_C void SetMimeTypeL( const TDataType aDataType );
       
   364         
       
   365         /**
       
   366         * CXnResource::MimeType(). Get iMimeType of this CXnResource-object.
       
   367         * @since S60 3.1
       
   368         * @return TDataType iMimeType.
       
   369         */
       
   370         IMPORT_C TDataType MimeType() const;
       
   371         
       
   372         /**
       
   373         * CXnResource::WriteStream(). Gets write stream on iBuffer.
       
   374         * @since S60 3.1
       
   375         * @param aOffset a buffer position of iBuffer to write data.
       
   376         * @return RBufWriteStream& write stream.
       
   377         */
       
   378         IMPORT_C RBufWriteStream& CXnResource::WriteStream( TUint aOffset = 0 );      
       
   379         
       
   380         /**
       
   381         * CXnResource::ReadStream(). Gets read stream on iBuffer.
       
   382         * @since S60 3.1
       
   383         * @param aOffset a buffer position of iBuffer to read data. 
       
   384         * @return RBufReadStream& read stream
       
   385         */
       
   386         IMPORT_C RBufReadStream& CXnResource::ReadStream(TUint aOffset = 0 );
       
   387 
       
   388         /**
       
   389         * CXnResource::SetOffset(). Sets internal data pointer of iBuffer.
       
   390         * @since S60 3.1
       
   391         * @param aOffset is new offset of iBuffer data pointer.
       
   392         * @return void
       
   393         */
       
   394         IMPORT_C void SetOffset( TUint aOffset );
       
   395         
       
   396         /**
       
   397         * CXnResource::Offset(). Internal iBuffer data pointer position.
       
   398         * @since S60 3.1
       
   399         * @return TUint iOffset pointing iBuffer data pointer.
       
   400         */
       
   401         IMPORT_C TUint Offset() const;
       
   402         
       
   403         /**
       
   404         * CXnResource::ExternalizeL(). Externalizes CXnResource-object's member data.
       
   405         * @since S60 3.1
       
   406         * @param aStream is a write stream given.
       
   407         * @return void
       
   408         */
       
   409         IMPORT_C void ExternalizeL( RWriteStream& aStream) const;
       
   410         
       
   411         /**
       
   412         * CXnResource::InternalizeL(). Internalizes CXnResource-object's member data.
       
   413         * @since S60 3.1
       
   414         * @param aStream is data read stream given.
       
   415         * @return void
       
   416         */
       
   417         IMPORT_C void InternalizeL( RReadStream& aStream);
       
   418         
       
   419         /**
       
   420         * CXnResource::GetDataStreamLength().
       
   421         * @since S60 3.1
       
   422         * @return TInt data length of CXnResource-data members for streaming functions.
       
   423         */
       
   424         IMPORT_C TInt GetDataStreamLength() const;
       
   425         
       
   426     private:
       
   427 
       
   428         /**
       
   429         * C++ default constructor.
       
   430         */
       
   431         CXnResource();
       
   432 
       
   433         /**
       
   434         * By default Symbian 2nd phase constructor is private.
       
   435         */
       
   436         void ConstructL();
       
   437 
       
   438     private:     // Data
       
   439         TXnLockingPolicy iLockingPolicy;
       
   440         TXnCacheType iCacheType;
       
   441         TXnResourceType iResourceType;
       
   442         TDesC* iResourceID;
       
   443         TDesC* iNameSpace;
       
   444         TDesC* iFileName;
       
   445         TDataType iMimeType;
       
   446         CBufSeg* iBuffer;
       
   447         TUint iOffset;
       
   448         RBufWriteStream iWriteStream;
       
   449         RBufReadStream iReadStream;
       
   450 
       
   451          // Reserved pointer for future extension
       
   452         TAny* iReserved;
       
   453     };
       
   454 
       
   455 #endif      // XNRESOURCE_H   
       
   456 // End of File