homescreenpluginsrv/hspsresource/src/hspsresource.cpp
changeset 0 79c6a41cd166
child 12 502e5d91ad42
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:  Definition of a file resource
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include "hspsresource.h"
       
    20 
       
    21 // ============================ MEMBER FUNCTIONS ===============================
       
    22 
       
    23 // -----------------------------------------------------------------------------
       
    24 // ChspsResource::ChspsResource()
       
    25 // C++ default constructor can NOT contain any code, that
       
    26 // might leave.
       
    27 // -----------------------------------------------------------------------------
       
    28 //
       
    29 ChspsResource::ChspsResource()
       
    30     {
       
    31     iLanguage = ELangTest;
       
    32     }
       
    33 
       
    34 // -----------------------------------------------------------------------------
       
    35 // ChspsResource::ConstructL
       
    36 // Symbian 2nd phase constructor can leave.
       
    37 // -----------------------------------------------------------------------------
       
    38 //
       
    39 void ChspsResource::ConstructL()
       
    40     {
       
    41     }
       
    42 
       
    43 // -----------------------------------------------------------------------------
       
    44 // ChspsResource::NewL
       
    45 // Two-phased constructor.
       
    46 // -----------------------------------------------------------------------------
       
    47 //
       
    48 EXPORT_C ChspsResource* ChspsResource::NewL()
       
    49     {
       
    50     ChspsResource* self = new( ELeave ) ChspsResource;
       
    51     CleanupStack::PushL( self );
       
    52     self->ConstructL();
       
    53     CleanupStack::Pop();
       
    54     return self;
       
    55     }
       
    56    
       
    57 // -----------------------------------------------------------------------------
       
    58 // ChspsResource::CloneL()
       
    59 // Returns an exact copy of this ChspsResource object.
       
    60 // (other items were commented in a header).
       
    61 // -----------------------------------------------------------------------------
       
    62 //
       
    63 EXPORT_C ChspsResource* ChspsResource::CloneL()
       
    64     {
       
    65     ChspsResource* clone = ChspsResource::NewL();
       
    66     CleanupStack::PushL( clone );
       
    67     clone->SetLockingPolicy( iLockingPolicy );    
       
    68     clone->SetResourceType( iResourceType );
       
    69     clone->SetLanguage( iLanguage );         
       
    70     clone->SetResourceIdL( *iResourceID );    
       
    71     clone->SetFileNameL( *iFileName );
       
    72     clone->SetMimeTypeL( iMimeType );
       
    73     clone->SetConfigurationUid( iConfigurationUid );
       
    74     
       
    75     CleanupStack::Pop( clone );
       
    76     return clone;
       
    77     }
       
    78 
       
    79 // Destructor
       
    80 ChspsResource::~ChspsResource()
       
    81     {    
       
    82     delete iResourceID;    
       
    83     delete iFileName;
       
    84     delete iTags;
       
    85     }
       
    86 
       
    87 
       
    88 // -----------------------------------------------------------------------------
       
    89 // ChspsResource::ExternalizeL().
       
    90 // (other items were commented in a header).
       
    91 // -----------------------------------------------------------------------------
       
    92 //
       
    93 EXPORT_C void ChspsResource::ExternalizeL( RWriteStream& aStream ) const
       
    94     {
       
    95     aStream.WriteUint32L( iLockingPolicy );    
       
    96     aStream.WriteUint32L( iResourceType );
       
    97     aStream.WriteUint32L( iLanguage );
       
    98         
       
    99     if ( iResourceID )
       
   100         {
       
   101         aStream << *iResourceID;
       
   102         }
       
   103     else
       
   104         {
       
   105         aStream << KNullDesC;
       
   106         }
       
   107           
       
   108     if ( iFileName )
       
   109         {
       
   110         aStream << *iFileName;
       
   111         }
       
   112     else 
       
   113         {
       
   114         aStream << KNullDesC;
       
   115         }
       
   116     
       
   117      
       
   118     iMimeType.ExternalizeL(aStream);    
       
   119     
       
   120     aStream.WriteUint32L( iConfigurationUid );
       
   121     
       
   122     if ( iTags )
       
   123         {
       
   124         aStream << *iTags;
       
   125         }
       
   126     else 
       
   127         {
       
   128         aStream << KNullDesC;
       
   129         }
       
   130     }
       
   131        
       
   132 // -----------------------------------------------------------------------------
       
   133 // ChspsResource::InternalizeL().
       
   134 // (other items were commented in a header).
       
   135 // -----------------------------------------------------------------------------
       
   136 //
       
   137 EXPORT_C void ChspsResource::InternalizeL( RReadStream& aStream )
       
   138     {
       
   139     iLockingPolicy = (ThspsLockingPolicy)aStream.ReadUint32L();    
       
   140     iResourceType = (ThspsResourceType)aStream.ReadUint32L();
       
   141     iLanguage = (TLanguage)aStream.ReadUint32L();    
       
   142 
       
   143     delete iResourceID;
       
   144     iResourceID = NULL;
       
   145     iResourceID = HBufC::NewL(aStream, KMaxFileName );
       
   146      
       
   147     delete iFileName;
       
   148     iFileName = NULL;
       
   149     iFileName = HBufC::NewL(aStream, KMaxFileName );
       
   150     
       
   151     iMimeType.InternalizeL(aStream);          
       
   152     
       
   153     iConfigurationUid = (TInt)aStream.ReadUint32L();
       
   154     
       
   155     delete iTags;
       
   156     iTags = NULL;
       
   157     iTags = HBufC::NewL(aStream, KMaxTagsLength );
       
   158     }
       
   159     
       
   160 // -----------------------------------------------------------------------------
       
   161 // ChspsResource::SetLockingPolicy().
       
   162 // (other items were commented in a header).
       
   163 // -----------------------------------------------------------------------------
       
   164 //
       
   165 EXPORT_C void ChspsResource::SetLockingPolicy( ThspsLockingPolicy aLockingPolicy )
       
   166     {
       
   167     iLockingPolicy = aLockingPolicy;
       
   168     }
       
   169     
       
   170 // -----------------------------------------------------------------------------
       
   171 // ChspsResource::LockingPolicy().
       
   172 // (other items were commented in a header).
       
   173 // -----------------------------------------------------------------------------
       
   174 //
       
   175 EXPORT_C ThspsLockingPolicy ChspsResource::LockingPolicy() const
       
   176     {
       
   177     return iLockingPolicy;        
       
   178     }
       
   179 
       
   180 // -----------------------------------------------------------------------------
       
   181 // ChspsResource::SetResourceType().
       
   182 // (other items were commented in a header).
       
   183 // -----------------------------------------------------------------------------
       
   184 //
       
   185 EXPORT_C void ChspsResource::SetResourceType( ThspsResourceType aResourceType )
       
   186     {
       
   187     iResourceType = aResourceType;
       
   188     }
       
   189     
       
   190 // -----------------------------------------------------------------------------
       
   191 // ChspsResource::ResourceType().
       
   192 // (other items were commented in a header).
       
   193 // -----------------------------------------------------------------------------
       
   194 //
       
   195 EXPORT_C ThspsResourceType ChspsResource::ResourceType() const
       
   196     {
       
   197     return iResourceType;        
       
   198     }
       
   199 
       
   200 
       
   201 // -----------------------------------------------------------------------------
       
   202 // ChspsResource::SetResourceIdL().
       
   203 // (other items were commented in a header).
       
   204 // -----------------------------------------------------------------------------
       
   205 //
       
   206 EXPORT_C void ChspsResource::SetResourceIdL( const TDesC& aResourceId )
       
   207     {
       
   208     delete iResourceID;
       
   209     iResourceID = NULL;
       
   210     iResourceID = aResourceId.AllocL();
       
   211     }
       
   212     
       
   213 // -----------------------------------------------------------------------------
       
   214 // ChspsResource::ResourceId().
       
   215 // (other items were commented in a header).
       
   216 // -----------------------------------------------------------------------------
       
   217 //
       
   218 EXPORT_C const TDesC& ChspsResource::ResourceId() const
       
   219     {
       
   220     if ( iResourceID )
       
   221         {
       
   222         return *iResourceID;
       
   223         }
       
   224     else
       
   225         {
       
   226         return KNullDesC;
       
   227         }
       
   228     }
       
   229     
       
   230 // -----------------------------------------------------------------------------
       
   231 // ChspsResource::SetFileNameL().
       
   232 // (other items were commented in a header).
       
   233 // -----------------------------------------------------------------------------
       
   234 //
       
   235 EXPORT_C void ChspsResource::SetFileNameL( const TDesC& aFileName )
       
   236     {
       
   237     delete iFileName;
       
   238     iFileName = NULL;
       
   239     iFileName = aFileName.AllocL();
       
   240     }
       
   241     
       
   242 // -----------------------------------------------------------------------------
       
   243 // ChspsResource::FileName().
       
   244 // (other items were commented in a header).
       
   245 // -----------------------------------------------------------------------------
       
   246 //
       
   247 EXPORT_C const TDesC& ChspsResource::FileName() const
       
   248     {
       
   249     if ( iFileName )
       
   250         {
       
   251         return *iFileName;
       
   252         }
       
   253     else
       
   254         {
       
   255         return KNullDesC;
       
   256         }
       
   257     }
       
   258     
       
   259     
       
   260 // -----------------------------------------------------------------------------
       
   261 // ChspsResource::SetMimeTypeL().
       
   262 // (other items were commented in a header).
       
   263 // -----------------------------------------------------------------------------
       
   264 //
       
   265 EXPORT_C void ChspsResource::SetMimeTypeL( const TDataType aDataType )
       
   266     {
       
   267     iMimeType = aDataType;
       
   268     }
       
   269     
       
   270 // -----------------------------------------------------------------------------
       
   271 // ChspsResource::MimeType().
       
   272 // (other items were commented in a header).
       
   273 // -----------------------------------------------------------------------------
       
   274 //
       
   275 EXPORT_C TDataType ChspsResource::MimeType() const
       
   276     {
       
   277     return iMimeType;
       
   278     }    
       
   279     
       
   280 // -----------------------------------------------------------------------------
       
   281 // ChspsResource::SetLanguage().
       
   282 // (other items were commented in a header).
       
   283 // -----------------------------------------------------------------------------
       
   284 //
       
   285 EXPORT_C void ChspsResource::SetLanguage( const TLanguage& aLanguage )
       
   286 	{
       
   287 	iLanguage = aLanguage;
       
   288 	}
       
   289 
       
   290 // -----------------------------------------------------------------------------
       
   291 // ChspsResource::Language().
       
   292 // (other items were commented in a header).
       
   293 // -----------------------------------------------------------------------------
       
   294 //       
       
   295 EXPORT_C const TLanguage& ChspsResource::Language() const
       
   296 	{
       
   297 	return iLanguage;
       
   298 	}
       
   299 
       
   300 // -----------------------------------------------------------------------------
       
   301 // ChspsResource::SetConfigurationUid().
       
   302 // -----------------------------------------------------------------------------
       
   303 //
       
   304 EXPORT_C void ChspsResource::SetConfigurationUid( const TInt aConfUid )
       
   305     {
       
   306     iConfigurationUid = aConfUid;
       
   307     }
       
   308 
       
   309 // -----------------------------------------------------------------------------
       
   310 // ChspsResource::ConfigurationUid().
       
   311 // -----------------------------------------------------------------------------
       
   312 //
       
   313 EXPORT_C TInt ChspsResource::ConfigurationUid() const
       
   314     {
       
   315     return iConfigurationUid;
       
   316     }
       
   317 
       
   318 // -----------------------------------------------------------------------------
       
   319 // ChspsResource::SetTagsL().
       
   320 // (other items were commented in a header).
       
   321 // -----------------------------------------------------------------------------
       
   322 //
       
   323 EXPORT_C void ChspsResource::SetTagsL( const TDesC& aTag )
       
   324     {
       
   325     delete iTags;
       
   326     iTags = NULL;
       
   327     iTags = aTag.AllocL();
       
   328     }
       
   329     
       
   330 // -----------------------------------------------------------------------------
       
   331 // ChspsResource::Tags().
       
   332 // (other items were commented in a header).
       
   333 // -----------------------------------------------------------------------------
       
   334 //
       
   335 EXPORT_C const TDesC& ChspsResource::Tags() const
       
   336     {
       
   337     if ( iTags )
       
   338         {
       
   339         return *iTags;
       
   340         }
       
   341     else
       
   342         {
       
   343         return KNullDesC;
       
   344         }
       
   345     }
       
   346     
       
   347 
       
   348 //  End of File