homescreenpluginsrv/hspsresource/src/hspsresource.cpp
branchRCL_3
changeset 19 502e5d91ad42
parent 0 79c6a41cd166
equal deleted inserted replaced
18:bd874ee5e5e2 19:502e5d91ad42
    61 // -----------------------------------------------------------------------------
    61 // -----------------------------------------------------------------------------
    62 //
    62 //
    63 EXPORT_C ChspsResource* ChspsResource::CloneL()
    63 EXPORT_C ChspsResource* ChspsResource::CloneL()
    64     {
    64     {
    65     ChspsResource* clone = ChspsResource::NewL();
    65     ChspsResource* clone = ChspsResource::NewL();
       
    66     
    66     CleanupStack::PushL( clone );
    67     CleanupStack::PushL( clone );
       
    68     
    67     clone->SetLockingPolicy( iLockingPolicy );    
    69     clone->SetLockingPolicy( iLockingPolicy );    
    68     clone->SetResourceType( iResourceType );
    70     clone->SetResourceType( iResourceType );
    69     clone->SetLanguage( iLanguage );         
    71     clone->SetLanguage( iLanguage );
    70     clone->SetResourceIdL( *iResourceID );    
    72     clone->SetResourceIdL( ResourceId() );    
    71     clone->SetFileNameL( *iFileName );
    73     clone->SetFileNameL( FileName() );
    72     clone->SetMimeTypeL( iMimeType );
    74     clone->SetMimeTypeL( iMimeType );
    73     clone->SetConfigurationUid( iConfigurationUid );
    75     clone->SetConfigurationUid( iConfigurationUid );
       
    76     clone->SetTagsL( Tags() );
    74     
    77     
    75     CleanupStack::Pop( clone );
    78     CleanupStack::Pop( clone );
       
    79     
    76     return clone;
    80     return clone;
    77     }
    81     }
    78 
    82 
    79 // Destructor
    83 // Destructor
    80 ChspsResource::~ChspsResource()
    84 ChspsResource::~ChspsResource()
    93 EXPORT_C void ChspsResource::ExternalizeL( RWriteStream& aStream ) const
    97 EXPORT_C void ChspsResource::ExternalizeL( RWriteStream& aStream ) const
    94     {
    98     {
    95     aStream.WriteUint32L( iLockingPolicy );    
    99     aStream.WriteUint32L( iLockingPolicy );    
    96     aStream.WriteUint32L( iResourceType );
   100     aStream.WriteUint32L( iResourceType );
    97     aStream.WriteUint32L( iLanguage );
   101     aStream.WriteUint32L( iLanguage );
    98         
   102 
    99     if ( iResourceID )
   103     const TDesC& resourceId = ResourceId();
   100         {
   104     aStream.WriteInt32L( resourceId.Length() );
   101         aStream << *iResourceID;
   105     if ( resourceId.Length() > 0 )
   102         }
   106         {
   103     else
   107         aStream << resourceId;
   104         {
       
   105         aStream << KNullDesC;
       
   106         }
   108         }
   107           
   109           
   108     if ( iFileName )
   110     const TDesC& fileName = FileName(); 
   109         {
   111     aStream.WriteInt32L( fileName.Length() );
   110         aStream << *iFileName;
   112     if ( fileName.Length() > 0 )
   111         }
   113         {
   112     else 
   114         aStream << fileName;
   113         {
   115         }    
   114         aStream << KNullDesC;
       
   115         }
       
   116     
       
   117      
   116      
   118     iMimeType.ExternalizeL(aStream);    
   117     iMimeType.ExternalizeL(aStream);    
   119     
   118     
   120     aStream.WriteUint32L( iConfigurationUid );
   119     aStream.WriteUint32L( iConfigurationUid );
   121     
   120     
   122     if ( iTags )
   121     const TDesC& tags = Tags();
   123         {
   122     aStream.WriteInt32L( tags.Length() );
   124         aStream << *iTags;
   123     if ( tags.Length() > 0 )
   125         }
   124         {
   126     else 
   125         aStream << tags;
   127         {
       
   128         aStream << KNullDesC;
       
   129         }
   126         }
   130     }
   127     }
   131        
   128        
   132 // -----------------------------------------------------------------------------
   129 // -----------------------------------------------------------------------------
   133 // ChspsResource::InternalizeL().
   130 // ChspsResource::InternalizeL().
   139     iLockingPolicy = (ThspsLockingPolicy)aStream.ReadUint32L();    
   136     iLockingPolicy = (ThspsLockingPolicy)aStream.ReadUint32L();    
   140     iResourceType = (ThspsResourceType)aStream.ReadUint32L();
   137     iResourceType = (ThspsResourceType)aStream.ReadUint32L();
   141     iLanguage = (TLanguage)aStream.ReadUint32L();    
   138     iLanguage = (TLanguage)aStream.ReadUint32L();    
   142 
   139 
   143     delete iResourceID;
   140     delete iResourceID;
   144     iResourceID = NULL;
   141     iResourceID = NULL;    
   145     iResourceID = HBufC::NewL(aStream, KMaxFileName );
   142     TInt len = aStream.ReadInt32L();
       
   143     if( len > 0 )
       
   144         {
       
   145         iResourceID = HBufC::NewL( aStream, len );
       
   146         }
   146      
   147      
   147     delete iFileName;
   148     delete iFileName;
   148     iFileName = NULL;
   149     iFileName = NULL;
   149     iFileName = HBufC::NewL(aStream, KMaxFileName );
   150     len = aStream.ReadInt32L();
       
   151     if( len > 0 )
       
   152         {
       
   153         iFileName = HBufC::NewL( aStream, len );
       
   154         }
   150     
   155     
   151     iMimeType.InternalizeL(aStream);          
   156     iMimeType.InternalizeL(aStream);          
   152     
   157     
   153     iConfigurationUid = (TInt)aStream.ReadUint32L();
   158     iConfigurationUid = (TInt)aStream.ReadUint32L();
   154     
   159     
   155     delete iTags;
   160     delete iTags;
   156     iTags = NULL;
   161     iTags = NULL;
   157     iTags = HBufC::NewL(aStream, KMaxTagsLength );
   162     len = aStream.ReadInt32L();
       
   163     if( len > 0 )
       
   164         {
       
   165         iTags = HBufC::NewL( aStream, len );
       
   166         }
   158     }
   167     }
   159     
   168     
   160 // -----------------------------------------------------------------------------
   169 // -----------------------------------------------------------------------------
   161 // ChspsResource::SetLockingPolicy().
   170 // ChspsResource::SetLockingPolicy().
   162 // (other items were commented in a header).
   171 // (other items were commented in a header).
   203 // (other items were commented in a header).
   212 // (other items were commented in a header).
   204 // -----------------------------------------------------------------------------
   213 // -----------------------------------------------------------------------------
   205 //
   214 //
   206 EXPORT_C void ChspsResource::SetResourceIdL( const TDesC& aResourceId )
   215 EXPORT_C void ChspsResource::SetResourceIdL( const TDesC& aResourceId )
   207     {
   216     {
   208     delete iResourceID;
   217     if( iResourceID )
   209     iResourceID = NULL;
   218         {
   210     iResourceID = aResourceId.AllocL();
   219         delete iResourceID;
       
   220         iResourceID = NULL;
       
   221         }
       
   222     
       
   223     if( aResourceId.Length() > 0 )
       
   224         {
       
   225         iResourceID = aResourceId.AllocL();
       
   226         }
   211     }
   227     }
   212     
   228     
   213 // -----------------------------------------------------------------------------
   229 // -----------------------------------------------------------------------------
   214 // ChspsResource::ResourceId().
   230 // ChspsResource::ResourceId().
   215 // (other items were commented in a header).
   231 // (other items were commented in a header).
   232 // (other items were commented in a header).
   248 // (other items were commented in a header).
   233 // -----------------------------------------------------------------------------
   249 // -----------------------------------------------------------------------------
   234 //
   250 //
   235 EXPORT_C void ChspsResource::SetFileNameL( const TDesC& aFileName )
   251 EXPORT_C void ChspsResource::SetFileNameL( const TDesC& aFileName )
   236     {
   252     {
   237     delete iFileName;
   253     if( iFileName )
   238     iFileName = NULL;
   254         {
   239     iFileName = aFileName.AllocL();
   255         delete iFileName;
       
   256         iFileName = NULL;
       
   257         }
       
   258     
       
   259     if( aFileName.Length() > 0 )
       
   260         {
       
   261         iFileName = aFileName.AllocL();
       
   262         }
   240     }
   263     }
   241     
   264     
   242 // -----------------------------------------------------------------------------
   265 // -----------------------------------------------------------------------------
   243 // ChspsResource::FileName().
   266 // ChspsResource::FileName().
   244 // (other items were commented in a header).
   267 // (other items were commented in a header).
   252         }
   275         }
   253     else
   276     else
   254         {
   277         {
   255         return KNullDesC;
   278         return KNullDesC;
   256         }
   279         }
   257     }
   280     }    
   258     
       
   259     
   281     
   260 // -----------------------------------------------------------------------------
   282 // -----------------------------------------------------------------------------
   261 // ChspsResource::SetMimeTypeL().
   283 // ChspsResource::SetMimeTypeL().
   262 // (other items were commented in a header).
   284 // (other items were commented in a header).
   263 // -----------------------------------------------------------------------------
   285 // -----------------------------------------------------------------------------
   320 // (other items were commented in a header).
   342 // (other items were commented in a header).
   321 // -----------------------------------------------------------------------------
   343 // -----------------------------------------------------------------------------
   322 //
   344 //
   323 EXPORT_C void ChspsResource::SetTagsL( const TDesC& aTag )
   345 EXPORT_C void ChspsResource::SetTagsL( const TDesC& aTag )
   324     {
   346     {
   325     delete iTags;
   347     if( iTags )
   326     iTags = NULL;
   348         {
   327     iTags = aTag.AllocL();
   349         delete iTags;
       
   350         iTags = NULL;
       
   351         }
       
   352     
       
   353     if( aTag.Length() > 0 )
       
   354         {
       
   355         iTags = aTag.AllocL();
       
   356         }
   328     }
   357     }
   329     
   358     
   330 // -----------------------------------------------------------------------------
   359 // -----------------------------------------------------------------------------
   331 // ChspsResource::Tags().
   360 // ChspsResource::Tags().
   332 // (other items were commented in a header).
   361 // (other items were commented in a header).