idlehomescreen/xmluirendering/uiresource/src/xnresource.cpp
changeset 0 f72a12da539e
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:  Resource definition of Xuikon Application Theme Management Services.
       
    15 *                See XnResource.h.
       
    16 *
       
    17 *
       
    18 */
       
    19 
       
    20 
       
    21 #include "xnresource.h"
       
    22 
       
    23 // ============================ MEMBER FUNCTIONS ===============================
       
    24 
       
    25 // -----------------------------------------------------------------------------
       
    26 // CXnResource::CXnResource()
       
    27 // C++ default constructor can NOT contain any code, that
       
    28 // might leave.
       
    29 // -----------------------------------------------------------------------------
       
    30 //
       
    31 CXnResource::CXnResource()
       
    32     {
       
    33     }
       
    34 
       
    35 // -----------------------------------------------------------------------------
       
    36 // CXnResource::ConstructL
       
    37 // Symbian 2nd phase constructor can leave.
       
    38 // -----------------------------------------------------------------------------
       
    39 //
       
    40 void CXnResource::ConstructL()
       
    41     {
       
    42     }
       
    43 
       
    44 // -----------------------------------------------------------------------------
       
    45 // CXnResource::NewL
       
    46 // Two-phased constructor.
       
    47 // -----------------------------------------------------------------------------
       
    48 //
       
    49 EXPORT_C CXnResource* CXnResource::NewL()
       
    50     {
       
    51     CXnResource* self = new( ELeave ) CXnResource;
       
    52     CleanupStack::PushL( self );
       
    53     self->ConstructL();
       
    54     CleanupStack::Pop();
       
    55     return self;
       
    56     }
       
    57 
       
    58 // -----------------------------------------------------------------------------
       
    59 // CXnResource::NewLC
       
    60 // Two-phased constructor.
       
    61 // -----------------------------------------------------------------------------
       
    62 //
       
    63 EXPORT_C CXnResource* CXnResource::NewLC( RReadStream& aStream )
       
    64     {
       
    65     CXnResource* resource = CXnResource::NewL();
       
    66     CleanupStack::PushL( resource );
       
    67     resource->InternalizeL( aStream );
       
    68     return resource;
       
    69     }
       
    70    
       
    71    
       
    72 // -----------------------------------------------------------------------------
       
    73 // CXnResource::CloneL()
       
    74 // Returns an exact copy of this CXnResource object.
       
    75 // (other items were commented in a header).
       
    76 // -----------------------------------------------------------------------------
       
    77 //
       
    78 EXPORT_C CXnResource* CXnResource::CloneL()
       
    79     {
       
    80     CXnResource* clone = CXnResource::NewL();
       
    81     CleanupStack::PushL( clone );
       
    82     clone->SetLockingPolicy( iLockingPolicy );
       
    83     clone->SetCacheType( iCacheType );
       
    84     clone->SetResourceType( iResourceType );
       
    85       
       
    86     clone->SetResourceIdL( *iResourceID );
       
    87     clone->SetNameSpaceL( *iNameSpace );
       
    88     clone->SetFileNameL( *iFileName );
       
    89     clone->SetMimeTypeL( iMimeType );
       
    90     
       
    91     CleanupStack::Pop( clone );
       
    92     return clone;
       
    93     }
       
    94 
       
    95 // Destructor
       
    96 CXnResource::~CXnResource()
       
    97     {
       
    98     iWriteStream.Close();
       
    99     iReadStream.Close();
       
   100     delete iResourceID;
       
   101     delete iNameSpace;
       
   102     delete iFileName;
       
   103     }
       
   104 
       
   105 
       
   106 // -----------------------------------------------------------------------------
       
   107 // CXnResource::ExternalizeL().
       
   108 // (other items were commented in a header).
       
   109 // -----------------------------------------------------------------------------
       
   110 //
       
   111 EXPORT_C void CXnResource::ExternalizeL( RWriteStream& aStream ) const
       
   112     {
       
   113     aStream.WriteUint32L( iLockingPolicy );
       
   114     aStream.WriteUint32L( iCacheType );
       
   115     aStream.WriteUint32L( iResourceType );
       
   116     
       
   117     if ( iResourceID )
       
   118         {
       
   119         aStream << *iResourceID;
       
   120         }
       
   121     else
       
   122         {
       
   123         aStream << KNullDesC;
       
   124         }
       
   125   
       
   126     if ( iNameSpace )
       
   127         {
       
   128         aStream << *iNameSpace;
       
   129         }
       
   130     else 
       
   131         {
       
   132         aStream << KNullDesC;
       
   133         }
       
   134         
       
   135     if ( iFileName )
       
   136         {
       
   137         aStream << *iFileName;
       
   138         }
       
   139     else 
       
   140         {
       
   141         aStream << KNullDesC;
       
   142         }
       
   143     
       
   144      
       
   145     iMimeType.ExternalizeL(aStream);    
       
   146  
       
   147     // replacement of unimplemented buffer size
       
   148     TInt size = 0;
       
   149     aStream.WriteUint32L( size );  
       
   150     
       
   151     aStream.WriteUint32L( iOffset );
       
   152     }
       
   153        
       
   154 // -----------------------------------------------------------------------------
       
   155 // CXnResource::InternalizeL().
       
   156 // (other items were commented in a header).
       
   157 // -----------------------------------------------------------------------------
       
   158 //
       
   159 EXPORT_C void CXnResource::InternalizeL( RReadStream& aStream )
       
   160     {
       
   161     iLockingPolicy = (TXnLockingPolicy)aStream.ReadUint32L();
       
   162     iCacheType = (TXnCacheType)aStream.ReadUint32L();
       
   163     iResourceType = (TXnResourceType)aStream.ReadUint32L();
       
   164 
       
   165     delete iResourceID;
       
   166     iResourceID = NULL;
       
   167     iResourceID = HBufC::NewL(aStream, KMaxFileName );
       
   168  
       
   169     delete iNameSpace;
       
   170     iNameSpace = NULL;
       
   171     iNameSpace = HBufC::NewL(aStream, KMaxFileName );
       
   172     
       
   173     delete iFileName;
       
   174     iFileName = NULL;
       
   175     iFileName = HBufC::NewL(aStream, KMaxFileName );
       
   176     
       
   177 
       
   178     iMimeType.InternalizeL(aStream);
       
   179     
       
   180     TInt size = aStream.ReadUint32L();
       
   181     iOffset = aStream.ReadUint32L();
       
   182     }
       
   183     
       
   184 // -----------------------------------------------------------------------------
       
   185 // CXnResource::SetLockingPolicy().
       
   186 // (other items were commented in a header).
       
   187 // -----------------------------------------------------------------------------
       
   188 //
       
   189 EXPORT_C void CXnResource::SetLockingPolicy( TXnLockingPolicy aLockingPolicy )
       
   190     {
       
   191     iLockingPolicy = aLockingPolicy;
       
   192     }
       
   193     
       
   194 // -----------------------------------------------------------------------------
       
   195 // CXnResource::LockingPolicy().
       
   196 // (other items were commented in a header).
       
   197 // -----------------------------------------------------------------------------
       
   198 //
       
   199 EXPORT_C TXnLockingPolicy CXnResource::LockingPolicy() const
       
   200     {
       
   201     return iLockingPolicy;        
       
   202     }
       
   203 
       
   204 // -----------------------------------------------------------------------------
       
   205 // CXnResource::SetCacheType().
       
   206 // (other items were commented in a header).
       
   207 // -----------------------------------------------------------------------------
       
   208 //
       
   209 EXPORT_C void CXnResource::SetCacheType( TXnCacheType aCacheType )
       
   210     {
       
   211     iCacheType = aCacheType;
       
   212     }
       
   213     
       
   214 // -----------------------------------------------------------------------------
       
   215 // CXnResource::CacheType()
       
   216 // (other items were commented in a header).
       
   217 // -----------------------------------------------------------------------------
       
   218 //
       
   219 EXPORT_C TXnCacheType CXnResource::CacheType() const
       
   220     {
       
   221     return iCacheType;        
       
   222     }
       
   223 
       
   224 // -----------------------------------------------------------------------------
       
   225 // CXnResource::SetResourceType().
       
   226 // (other items were commented in a header).
       
   227 // -----------------------------------------------------------------------------
       
   228 //
       
   229 EXPORT_C void CXnResource::SetResourceType( TXnResourceType aResourceType )
       
   230     {
       
   231     iResourceType = aResourceType;
       
   232     }
       
   233     
       
   234 // -----------------------------------------------------------------------------
       
   235 // CXnResource::ResourceType().
       
   236 // (other items were commented in a header).
       
   237 // -----------------------------------------------------------------------------
       
   238 //
       
   239 EXPORT_C TXnResourceType CXnResource::ResourceType() const
       
   240     {
       
   241     return iResourceType;        
       
   242     }
       
   243 
       
   244 
       
   245 // -----------------------------------------------------------------------------
       
   246 // CXnResource::SetResourceIdL().
       
   247 // (other items were commented in a header).
       
   248 // -----------------------------------------------------------------------------
       
   249 //
       
   250 EXPORT_C void CXnResource::SetResourceIdL( const TDesC& aResourceId )
       
   251     {
       
   252     delete iResourceID;
       
   253     iResourceID = NULL;
       
   254     iResourceID = aResourceId.AllocL();
       
   255     }
       
   256     
       
   257 // -----------------------------------------------------------------------------
       
   258 // CXnResource::ResourceId().
       
   259 // (other items were commented in a header).
       
   260 // -----------------------------------------------------------------------------
       
   261 //
       
   262 EXPORT_C const TDesC& CXnResource::ResourceId() const
       
   263     {
       
   264     if ( iResourceID )
       
   265         {
       
   266         return *iResourceID;
       
   267         }
       
   268     else
       
   269         {
       
   270         return KNullDesC;
       
   271         }
       
   272     }
       
   273 
       
   274 // -----------------------------------------------------------------------------
       
   275 // CXnResource::SetNameSpaceL().
       
   276 // (other items were commented in a header).
       
   277 // -----------------------------------------------------------------------------
       
   278 //
       
   279 EXPORT_C void CXnResource::SetNameSpaceL( const TDesC& aNameSpace )
       
   280     {
       
   281     delete iNameSpace;
       
   282     iNameSpace = NULL;
       
   283     iNameSpace = aNameSpace.AllocL();
       
   284     }
       
   285     
       
   286 // -----------------------------------------------------------------------------
       
   287 // CXnResource::NameSpace().
       
   288 // (other items were commented in a header).
       
   289 // -----------------------------------------------------------------------------
       
   290 //
       
   291 EXPORT_C const TDesC& CXnResource::NameSpace() const
       
   292     {
       
   293     if ( iNameSpace )
       
   294         {
       
   295         return *iNameSpace;
       
   296         }
       
   297     else
       
   298         {
       
   299         return KNullDesC;
       
   300         }
       
   301     }
       
   302     
       
   303 // -----------------------------------------------------------------------------
       
   304 // CXnResource::SetFileNameL().
       
   305 // (other items were commented in a header).
       
   306 // -----------------------------------------------------------------------------
       
   307 //
       
   308 EXPORT_C void CXnResource::SetFileNameL( const TDesC& aFileName )
       
   309     {
       
   310     delete iFileName;
       
   311     iFileName = NULL;
       
   312     iFileName = aFileName.AllocL();
       
   313     }
       
   314     
       
   315 // -----------------------------------------------------------------------------
       
   316 // CXnResource::FileName().
       
   317 // (other items were commented in a header).
       
   318 // -----------------------------------------------------------------------------
       
   319 //
       
   320 EXPORT_C const TDesC& CXnResource::FileName() const
       
   321     {
       
   322     if ( iFileName )
       
   323         {
       
   324         return *iFileName;
       
   325         }
       
   326     else
       
   327         {
       
   328         return KNullDesC;
       
   329         }
       
   330     }
       
   331     
       
   332     
       
   333 // -----------------------------------------------------------------------------
       
   334 // CXnResource::SetMimeTypeL().
       
   335 // (other items were commented in a header).
       
   336 // -----------------------------------------------------------------------------
       
   337 //
       
   338 EXPORT_C void CXnResource::SetMimeTypeL( const TDataType aDataType )
       
   339     {
       
   340     iMimeType = aDataType;
       
   341     }
       
   342     
       
   343 // -----------------------------------------------------------------------------
       
   344 // CXnResource::MimeType().
       
   345 // (other items were commented in a header).
       
   346 // -----------------------------------------------------------------------------
       
   347 //
       
   348 EXPORT_C TDataType CXnResource::MimeType() const
       
   349     {
       
   350     return iMimeType;
       
   351     }    
       
   352     
       
   353 // -----------------------------------------------------------------------------
       
   354 // CXnResource::WriteStream().
       
   355 // (other items were commented in a header).
       
   356 // -----------------------------------------------------------------------------
       
   357 //
       
   358 EXPORT_C RBufWriteStream& CXnResource::WriteStream( TUint aOffset )
       
   359     {
       
   360     iWriteStream.Open( *iBuffer, aOffset );
       
   361     return iWriteStream;
       
   362     }
       
   363 
       
   364 // -----------------------------------------------------------------------------
       
   365 // CXnResource::ReadStream().
       
   366 // (other items were commented in a header).
       
   367 // -----------------------------------------------------------------------------
       
   368 //
       
   369 EXPORT_C RBufReadStream& CXnResource::ReadStream(TUint aOffset )
       
   370     {
       
   371     // constructing read stream on buffer 
       
   372     iReadStream.Open( *iBuffer, aOffset );
       
   373     return iReadStream;
       
   374     }
       
   375 
       
   376 // -----------------------------------------------------------------------------
       
   377 // CXnResource::SetOffset().
       
   378 // (other items were commented in a header).
       
   379 // -----------------------------------------------------------------------------
       
   380 //
       
   381 EXPORT_C void CXnResource::SetOffset( TUint aOffset )
       
   382     {
       
   383     iOffset = aOffset;
       
   384     }
       
   385 
       
   386 
       
   387 // -----------------------------------------------------------------------------
       
   388 // CXnResource::Offset().
       
   389 // (other items were commented in a header).
       
   390 // -----------------------------------------------------------------------------
       
   391 //
       
   392 EXPORT_C TUint CXnResource::Offset() const
       
   393     {
       
   394     return iOffset;
       
   395     }
       
   396 
       
   397 // -----------------------------------------------------------------------------
       
   398 // CXnResource::GetDataStreamLength().
       
   399 // (other items were commented in a header).
       
   400 // -----------------------------------------------------------------------------
       
   401 //
       
   402 EXPORT_C TInt CXnResource::GetDataStreamLength() const
       
   403     {
       
   404     TInt len = sizeof( iLockingPolicy );
       
   405     len += sizeof(iCacheType);
       
   406     len += sizeof(iResourceType);
       
   407     len += iResourceID->Size();
       
   408     len += iNameSpace->Size();
       
   409     len += iFileName->Size();
       
   410     len += sizeof(iMimeType);
       
   411     len += sizeof(iOffset);
       
   412     return len;
       
   413     }
       
   414     
       
   415 //  End of File