contentstorage/casrv/cawidgetscanner/src/cawidgetdescription.cpp
changeset 104 9b022b1f357c
parent 103 b99b84bcd2d1
child 109 e0aa398e6810
equal deleted inserted replaced
103:b99b84bcd2d1 104:9b022b1f357c
    69     
    69     
    70     TPtrC attribute;
    70     TPtrC attribute;
    71     aEntry->FindAttribute( KPreviewImageAttrName, attribute );
    71     aEntry->FindAttribute( KPreviewImageAttrName, attribute );
    72     iPreviewImageName.CreateL( attribute.Length() );
    72     iPreviewImageName.CreateL( attribute.Length() );
    73     iPreviewImageName = attribute;
    73     iPreviewImageName = attribute;
    74     
    74 
    75     //library
    75     //library
    76     iLibrary.CreateL( KCaMaxAttrValueLen );
    76     iLibrary.CreateL( KCaMaxAttrValueLen );
    77     aEntry->FindAttribute( KAttrWidgetLibrary, iLibrary );
    77     aEntry->FindAttribute( KAttrWidgetLibrary, iLibrary );
       
    78     //path
       
    79     iPath.CreateL( KCaMaxAttrValueLen );
       
    80     aEntry->FindAttribute( KAttrWidgetPath, iPath );
    78     //uri
    81     //uri
    79     iUri.CreateL( KCaMaxAttrValueLen );
    82     iUri.CreateL( KCaMaxAttrValueLen );
    80     aEntry->FindAttribute( KAttrWidgetUri, iUri );
    83     aEntry->FindAttribute( KAttrWidgetUri, iUri );
       
    84     //translation filename
       
    85     iTranslationFileName.CreateL( KCaMaxAttrValueLen );
       
    86     aEntry->FindAttribute( KAttrWidgetTranslationFileName, iTranslationFileName );
    81     //mmc id
    87     //mmc id
    82     iMmcId.CreateL(KMassStorageIdLength);
    88     iMmcId.CreateL(KMassStorageIdLength);
    83     aEntry->FindAttribute( KCaAttrMmcId, iMmcId );
    89     aEntry->FindAttribute( KCaAttrMmcId, iMmcId );
    84     //service xml
    90     //service xml
    85     iServiceXml.CreateL( KCaMaxAttrValueLen );
    91     iServiceXml.CreateL( KCaMaxAttrValueLen );
   132 // Destructor
   138 // Destructor
   133 // -----------------------------------------------------------------------------
   139 // -----------------------------------------------------------------------------
   134 //
   140 //
   135 CCaWidgetDescription::~CCaWidgetDescription()
   141 CCaWidgetDescription::~CCaWidgetDescription()
   136     {
   142     {
   137 
   143     iPath.Close();
   138     iModificationTime.Close();
   144     iModificationTime.Close();
   139     iServiceXml.Close();
   145     iServiceXml.Close();
   140     iMmcId.Close();
   146     iMmcId.Close();
   141     iUri.Close();
   147     iUri.Close();
       
   148     iTranslationFileName.Close();
   142     iLibrary.Close();
   149     iLibrary.Close();
   143     iPreviewImageName.Close();
   150     iPreviewImageName.Close();
   144     iIconUri.Close();
   151     iIconUri.Close();
   145     iTitle.Close();
   152     iTitle.Close();
   146     iDescription.Close();
   153     iDescription.Close();
   180             aToCompare.GetDescription() == GetDescription() &&
   187             aToCompare.GetDescription() == GetDescription() &&
   181             aToCompare.GetUri() == GetUri() &&
   188             aToCompare.GetUri() == GetUri() &&
   182             aToCompare.GetIconUri() == GetIconUri() &&
   189             aToCompare.GetIconUri() == GetIconUri() &&
   183             aToCompare.GetPreviewImageName() == GetPreviewImageName() &&
   190             aToCompare.GetPreviewImageName() == GetPreviewImageName() &&
   184             aToCompare.GetTitle() == GetTitle() &&
   191             aToCompare.GetTitle() == GetTitle() &&
       
   192             aToCompare.GetTranslationFileName() == GetTranslationFileName() &&
   185             aToCompare.GetLibrary() != KNoLibrary &&
   193             aToCompare.GetLibrary() != KNoLibrary &&
   186             aToCompare.GetModificationTime() == GetModificationTime() &&
   194             aToCompare.GetModificationTime() == GetModificationTime() &&
   187             aToCompare.GetServiceXml() == GetServiceXml()
   195             aToCompare.GetServiceXml() == GetServiceXml()
   188             )
   196             )
   189         {
   197         {
   253 void CCaWidgetDescription::SetUriL( const TDesC& aUri )
   261 void CCaWidgetDescription::SetUriL( const TDesC& aUri )
   254     {
   262     {
   255     iUri.Close();
   263     iUri.Close();
   256     iUri.CreateL(aUri);
   264     iUri.CreateL(aUri);
   257     }
   265     }
       
   266 
       
   267 // -----------------------------------------------------------------------------
       
   268 //
       
   269 // -----------------------------------------------------------------------------
       
   270 //
       
   271 void CCaWidgetDescription::SetTranslationFileNameL(
       
   272         const TDesC& aTranslationFileName )
       
   273     {
       
   274     iTranslationFileName.Close();
       
   275     iTranslationFileName.CreateL( aTranslationFileName );
       
   276     }
       
   277 
   258 // -----------------------------------------------------------------------------
   278 // -----------------------------------------------------------------------------
   259 //
   279 //
   260 // -----------------------------------------------------------------------------
   280 // -----------------------------------------------------------------------------
   261 //
   281 //
   262 void CCaWidgetDescription::SetIconUriL( const TDesC& aIconUri )
   282 void CCaWidgetDescription::SetIconUriL( const TDesC& aIconUri )
   371 //
   391 //
   372 TPtrC CCaWidgetDescription::GetLibrary( ) const
   392 TPtrC CCaWidgetDescription::GetLibrary( ) const
   373     {
   393     {
   374     return iLibrary;
   394     return iLibrary;
   375     }
   395     }
       
   396 
       
   397 // -----------------------------------------------------------------------------
       
   398 //
       
   399 // -----------------------------------------------------------------------------
       
   400 //
       
   401 TPtrC CCaWidgetDescription::GetPath( ) const
       
   402     {
       
   403     return iPath;
       
   404     }
       
   405 // -----------------------------------------------------------------------------
       
   406 //
       
   407 // -----------------------------------------------------------------------------
       
   408 //
       
   409 void CCaWidgetDescription::SetPathL( const TDesC& aPath )
       
   410     {
       
   411 	iPath.Close();
       
   412 	iPath.CreateL(aPath);
       
   413     }
       
   414 
   376 // -----------------------------------------------------------------------------
   415 // -----------------------------------------------------------------------------
   377 //
   416 //
   378 // -----------------------------------------------------------------------------
   417 // -----------------------------------------------------------------------------
   379 //
   418 //
   380 TPtrC CCaWidgetDescription::GetDescription( ) const
   419 TPtrC CCaWidgetDescription::GetDescription( ) const
   387 // -----------------------------------------------------------------------------
   426 // -----------------------------------------------------------------------------
   388 //
   427 //
   389 TPtrC CCaWidgetDescription::GetUri( ) const
   428 TPtrC CCaWidgetDescription::GetUri( ) const
   390     {
   429     {
   391     return iUri;
   430     return iUri;
       
   431     }
       
   432 
       
   433 // -----------------------------------------------------------------------------
       
   434 //
       
   435 // -----------------------------------------------------------------------------
       
   436 //
       
   437 TPtrC CCaWidgetDescription::GetTranslationFileName() const
       
   438     {
       
   439     return iTranslationFileName;
   392     }
   440     }
   393 
   441 
   394 // -----------------------------------------------------------------------------
   442 // -----------------------------------------------------------------------------
   395 //
   443 //
   396 // -----------------------------------------------------------------------------
   444 // -----------------------------------------------------------------------------
   498                 DriveInfo::EDefaultRom ) )
   546                 DriveInfo::EDefaultRom ) )
   499             {
   547             {
   500             entry->SetFlags( entry->GetFlags() & ~ERemovable );
   548             entry->SetFlags( entry->GetFlags() & ~ERemovable );
   501             }
   549             }
   502         }
   550         }
       
   551     if ( iPath != KNullDesC )
       
   552         {
       
   553         entry->AddAttributeL(KAttrWidgetPath, iPath);
       
   554         }
   503     if ( iTitle != KNullDesC )
   555     if ( iTitle != KNullDesC )
   504         {
   556         {
   505         entry->SetTextL(iTitle);
   557         entry->SetTextL(iTitle);
   506         }
   558         }
   507     else
   559     else
   532         entry->AddAttributeL( KCaAttrInstallationTime, iModificationTime );
   584         entry->AddAttributeL( KCaAttrInstallationTime, iModificationTime );
   533         }
   585         }
   534     if ( iServiceXml != KNullDesC )
   586     if ( iServiceXml != KNullDesC )
   535         {
   587         {
   536         entry->AddAttributeL( KAttrWidgetServiceXml, iServiceXml);
   588         entry->AddAttributeL( KAttrWidgetServiceXml, iServiceXml);
       
   589         }
       
   590     if( iTranslationFileName != KNullDesC )
       
   591         {
       
   592         entry->AddAttributeL( KAttrWidgetTranslationFileName,
       
   593                 iTranslationFileName );
   537         }
   594         }
   538     return entry;
   595     return entry;
   539     }
   596     }
   540 
   597 
   541 // -----------------------------------------------------------------------------
   598 // -----------------------------------------------------------------------------
   587 // -----------------------------------------------------------------------------
   644 // -----------------------------------------------------------------------------
   588 //
   645 //
   589 // -----------------------------------------------------------------------------
   646 // -----------------------------------------------------------------------------
   590 //
   647 //
   591 void CCaWidgetDescription::LocalizeTextsL()
   648 void CCaWidgetDescription::LocalizeTextsL()
   592 	{
   649     {
   593     
   650     if( iTranslationFileName.Length() )
   594     
   651         {
   595 	if( iUri.Length() )
   652         RBuf translationFileName;
   596 		{
   653         translationFileName.Create( iTranslationFileName.Length() + 1 );
   597 	    RBuf uri;
   654         CleanupClosePushL( translationFileName );
   598 	    uri.Create( iUri.Length() + 1 );
   655         translationFileName.Copy( iTranslationFileName );
   599 	    CleanupClosePushL( uri );
   656         translationFileName.Append( KWidgetScannerUnderline );
   600 	    uri.Copy( iUri );
   657            
   601 	    uri.Append( KWidgetScannerUnderline );
   658         
   602 	       
   659         if( !HbTextResolverSymbian::Init( translationFileName, KLocalizationFilepathC ) )
   603 	    
   660           {
   604 	    if( !HbTextResolverSymbian::Init( uri, KLocalizationFilepathC ) )
   661           if( !HbTextResolverSymbian::Init( translationFileName, KLocalizationFilepathZ ) )
   605 	      {
   662               {
   606 	      if( !HbTextResolverSymbian::Init( uri, KLocalizationFilepathZ ) )
   663               // this should not be called too often 
   607 	          {
       
   608 	          // this should not be called too often 
       
   609               TChar currentDriveLetter;
   664               TChar currentDriveLetter;
   610 	          TDriveList driveList;
   665               TDriveList driveList;
   611 	          RFs fs;
   666               RFs fs;
   612 	          User::LeaveIfError( fs.Connect() );
   667               User::LeaveIfError( fs.Connect() );
   613 	          User::LeaveIfError( fs.DriveList( driveList ) );
   668               User::LeaveIfError( fs.DriveList( driveList ) );
   614 
   669 
   615 	          RBuf path;
   670               RBuf path;
   616 	          path.Create( KLocalizationFilepath().Length() + 1 );
   671               path.Create( KLocalizationFilepath().Length() + 1 );
   617 	          CleanupClosePushL( path );
   672               CleanupClosePushL( path );
   618 	          
   673               
   619   	          for ( TInt driveNr=EDriveY; driveNr >= EDriveA; driveNr-- )
   674               for( TInt driveNr=EDriveY; driveNr >= EDriveA; driveNr-- )
   620 	              {
   675                   {
   621 	              if ( driveList[driveNr] )
   676                   if( driveList[driveNr] )
   622 	                  {
   677                       {
   623 	                  User::LeaveIfError( fs.DriveToChar( driveNr,
   678                       User::LeaveIfError( fs.DriveToChar( driveNr,
   624 	                          currentDriveLetter ) );
   679                               currentDriveLetter ) );
   625 	                  path.Append( currentDriveLetter );
   680                       path.Append( currentDriveLetter );
   626 	                  path.Append( KLocalizationFilepath );
   681                       path.Append( KLocalizationFilepath );
   627 	                  if( HbTextResolverSymbian::Init( uri, path ) )
   682                       if( HbTextResolverSymbian::Init( translationFileName, path ) )
   628 	                      {
   683                           {
   629 	                      break;
   684                           break;
   630 	                      }
   685                           }
   631 	                  }
   686                       }
   632 	              path.Zero();
   687                   path.Zero();
   633 	              }
   688                   }
   634   	          CleanupStack::PopAndDestroy( &path );
   689               CleanupStack::PopAndDestroy( &path );
   635   	          fs.Close();
   690               fs.Close();
   636 	          }
   691               }
   637 	       }
   692            }
   638 	    
   693         
   639 	    HBufC* tmp;
   694         HBufC* tmp;
   640 	    
   695         
   641 	    if( iTitle.Length() )
   696         if( iTitle.Length() )
   642 	    	{
   697             {
   643 	        SetStringidTitleL( iTitle );
   698             SetStringidTitleL( iTitle );
   644 	        tmp = HbTextResolverSymbian::LoadLC( iTitle );
   699             tmp = HbTextResolverSymbian::LoadLC( iTitle );
   645 	        SetTitleL( *tmp );
   700             SetTitleL( *tmp );
   646 	        CleanupStack::PopAndDestroy( tmp );
   701             CleanupStack::PopAndDestroy( tmp );
   647 	    	}
   702             }
   648 	    if( iDescription.Length() )
   703         if( iDescription.Length() )
   649 	    	{
   704             {
   650 	        SetStringIdDescriptionL( iDescription );
   705             SetStringIdDescriptionL( iDescription );
   651 	        tmp = HbTextResolverSymbian::LoadLC( iDescription );
   706             tmp = HbTextResolverSymbian::LoadLC( iDescription );
   652 	        SetDescriptionL( *tmp );
   707             SetDescriptionL( *tmp );
   653 	        CleanupStack::PopAndDestroy( tmp );
   708             CleanupStack::PopAndDestroy( tmp );
   654 	    	}
   709             }
   655 	    CleanupStack::PopAndDestroy( &uri );
   710         CleanupStack::PopAndDestroy( &translationFileName );
   656 		}
   711         }
   657 	}
   712     }
   658 
   713 
   659 // -----------------------------------------------------------------------------
   714 // -----------------------------------------------------------------------------
   660 //
   715 //
   661 // -----------------------------------------------------------------------------
   716 // -----------------------------------------------------------------------------
   662 // 
   717 //