contentstorage/casrv/cawidgetscanner/src/cawidgetdescription.cpp
changeset 103 b99b84bcd2d1
parent 83 156f692b1687
child 104 9b022b1f357c
equal deleted inserted replaced
83:156f692b1687 103:b99b84bcd2d1
    15  *
    15  *
    16 */
    16 */
    17 
    17 
    18 
    18 
    19 // INCLUDE FILES
    19 // INCLUDE FILES
       
    20 #include <hbtextresolversymbian.h>
    20 
    21 
    21 #include "cadef.h"
    22 #include "cadef.h"
    22 #include "cawidgetdescription.h"
    23 #include "cawidgetdescription.h"
    23 #include "cainnerentry.h"
    24 #include "cainnerentry.h"
    24 #include "widgetscannerutils.h"
    25 #include "widgetscannerutils.h"
    25 #include "hbtextresolversymbian.h"
       
    26 
       
    27 #include "cawidgetscannerdef.h"
    26 #include "cawidgetscannerdef.h"
    28 // ============================ MEMBER FUNCTIONS ===============================
    27 // ============================ MEMBER FUNCTIONS ===============================
    29 
    28 
    30 // -----------------------------------------------------------------------------
    29 // -----------------------------------------------------------------------------
    31 // CCaWidgetDescription::CCaWidgetDescription
    30 // CCaWidgetDescription::CCaWidgetDescription
    32 // C++ default constructor can NOT contain any code, that
    31 // C++ default constructor can NOT contain any code, that
    33 // might leave.
    32 // might leave.
    34 // -----------------------------------------------------------------------------
    33 // -----------------------------------------------------------------------------
    35 //
    34 //
    36 CCaWidgetDescription::CCaWidgetDescription() :
    35 CCaWidgetDescription::CCaWidgetDescription() :
    37     iEntryId(KNoId), iMmcId()
    36     iEntryId( KNoId ), iValid ( EFalse )
    38     {
    37     {
    39     }
    38     }
    40 
    39 
    41 // -----------------------------------------------------------------------------
    40 // -----------------------------------------------------------------------------
    42 // CCaWidgetDescription::ConstructL
    41 // CCaWidgetDescription::ConstructL
    63         {
    62         {
    64         TLex uidLex(uidDesc);
    63         TLex uidLex(uidDesc);
    65         User::LeaveIfError( uidLex.Val( iPackageUid, EHex ));
    64         User::LeaveIfError( uidLex.Val( iPackageUid, EHex ));
    66         }
    65         }
    67     iTitle.CreateL( aEntry->GetText() );
    66     iTitle.CreateL( aEntry->GetText() );
       
    67     
    68     iIconUri.CreateL( aEntry->Icon()->FileName() );
    68     iIconUri.CreateL( aEntry->Icon()->FileName() );
       
    69     
       
    70     TPtrC attribute;
       
    71     aEntry->FindAttribute( KPreviewImageAttrName, attribute );
       
    72     iPreviewImageName.CreateL( attribute.Length() );
       
    73     iPreviewImageName = attribute;
       
    74     
    69     //library
    75     //library
    70     iLibrary.CreateL( KCaMaxAttrValueLen );
    76     iLibrary.CreateL( KCaMaxAttrValueLen );
    71     aEntry->FindAttribute( KAttrWidgetLibrary, iLibrary );
    77     aEntry->FindAttribute( KAttrWidgetLibrary, iLibrary );
    72     //path
       
    73     iPath.CreateL( KCaMaxAttrValueLen );
       
    74     aEntry->FindAttribute( KAttrWidgetPath, iPath );
       
    75     //uri
    78     //uri
    76     iUri.CreateL( KCaMaxAttrValueLen );
    79     iUri.CreateL( KCaMaxAttrValueLen );
    77     aEntry->FindAttribute( KAttrWidgetUri, iUri );
    80     aEntry->FindAttribute( KAttrWidgetUri, iUri );
    78     //mmc id
    81     //mmc id
    79     iMmcId.CreateL(KMassStorageIdLength);
    82     iMmcId.CreateL(KMassStorageIdLength);
   129 // Destructor
   132 // Destructor
   130 // -----------------------------------------------------------------------------
   133 // -----------------------------------------------------------------------------
   131 //
   134 //
   132 CCaWidgetDescription::~CCaWidgetDescription()
   135 CCaWidgetDescription::~CCaWidgetDescription()
   133     {
   136     {
       
   137 
       
   138     iModificationTime.Close();
       
   139     iServiceXml.Close();
       
   140     iMmcId.Close();
       
   141     iUri.Close();
       
   142     iLibrary.Close();
       
   143     iPreviewImageName.Close();
       
   144     iIconUri.Close();
   134     iTitle.Close();
   145     iTitle.Close();
   135     iDescription.Close();
   146     iDescription.Close();
   136     iUri.Close();
       
   137     iIconUri.Close();
       
   138     iLibrary.Close();
       
   139     iPath.Close();
       
   140     iModificationTime.Close();
       
   141     iMmcId.Close();
       
   142     iServiceXml.Close();
       
   143     iManifestFilePathName.Close();
       
   144     iStringIdTitle.Close();
   147     iStringIdTitle.Close();
   145     iStringIdDescription.Close();
   148     iStringIdDescription.Close();
       
   149     iManifestFilePathName.Close();
       
   150     
   146     }
   151     }
   147 
   152 
   148 // ----------------------------------------------------------------------------
   153 // ----------------------------------------------------------------------------
   149 //
   154 //
   150 // ----------------------------------------------------------------------------
   155 // ----------------------------------------------------------------------------
   151 //
   156 //
   152 TBool CCaWidgetDescription::Compare(
   157 TBool CCaWidgetDescription::Compare(
   153         const CCaWidgetDescription& aFirst,const CCaWidgetDescription& aSecond)
   158         const CCaWidgetDescription& aFirst,const CCaWidgetDescription& aSecond)
   154     {
   159     {
       
   160     TBool result = EFalse;
   155     if( aFirst.GetUri() == aSecond.GetUri() )
   161     if( aFirst.GetUri() == aSecond.GetUri() )
   156         {
   162         {
   157         return ETrue;
   163         result = ETrue;
   158         }
   164         }
   159     else
   165     else
   160         {
   166         {
   161         return EFalse;
   167         result = EFalse;
   162         }
   168         }
       
   169     return result;
   163     }
   170     }
   164 
   171 
   165 // ----------------------------------------------------------------------------
   172 // ----------------------------------------------------------------------------
   166 //
   173 //
   167 // ----------------------------------------------------------------------------
   174 // ----------------------------------------------------------------------------
   168 //
   175 //
   169 TBool CCaWidgetDescription::Compare( const CCaWidgetDescription& aToCompare )
   176 TBool CCaWidgetDescription::Compare( const CCaWidgetDescription& aToCompare )
   170     {
   177     {
       
   178     TBool result = EFalse;
   171     if( aToCompare.GetLibrary() == GetLibrary() &&
   179     if( aToCompare.GetLibrary() == GetLibrary() &&
   172             aToCompare.GetDescription() == GetDescription() &&
   180             aToCompare.GetDescription() == GetDescription() &&
   173             aToCompare.GetUri() == GetUri() &&
   181             aToCompare.GetUri() == GetUri() &&
   174             aToCompare.GetIconUri() == GetIconUri() &&
   182             aToCompare.GetIconUri() == GetIconUri() &&
       
   183             aToCompare.GetPreviewImageName() == GetPreviewImageName() &&
   175             aToCompare.GetTitle() == GetTitle() &&
   184             aToCompare.GetTitle() == GetTitle() &&
   176             aToCompare.GetLibrary() != KNoLibrary &&
   185             aToCompare.GetLibrary() != KNoLibrary &&
   177             aToCompare.GetModificationTime() == GetModificationTime() &&
   186             aToCompare.GetModificationTime() == GetModificationTime() &&
   178             aToCompare.GetServiceXml() == GetServiceXml()
   187             aToCompare.GetServiceXml() == GetServiceXml()
   179             )
   188             )
   180         {
   189         {
   181         return ETrue;
   190         result = ETrue;
   182         }
   191         }
   183     else
   192     else
   184         {
   193         {
   185         return EFalse;
   194         result = EFalse;
   186         }
   195         }
   187     }
   196     return result;
       
   197     }
       
   198 
   188 
   199 
   189 // -----------------------------------------------------------------------------
   200 // -----------------------------------------------------------------------------
   190 //
   201 //
   191 // -----------------------------------------------------------------------------
   202 // -----------------------------------------------------------------------------
   192 //
   203 //
   208 
   219 
   209 // -----------------------------------------------------------------------------
   220 // -----------------------------------------------------------------------------
   210 //
   221 //
   211 // -----------------------------------------------------------------------------
   222 // -----------------------------------------------------------------------------
   212 //
   223 //
       
   224 TUint CCaWidgetDescription::GetPackageUidL()
       
   225     {
       
   226     return iPackageUid;
       
   227     }
       
   228 
       
   229 // -----------------------------------------------------------------------------
       
   230 //
       
   231 // -----------------------------------------------------------------------------
       
   232 //
   213 void CCaWidgetDescription::SetTitleL( const TDesC& aTitle )
   233 void CCaWidgetDescription::SetTitleL( const TDesC& aTitle )
   214     {
   234     {
   215     iTitle.Close();
   235     iTitle.Close();
   216     iTitle.CreateL(aTitle);
   236     iTitle.CreateL(aTitle);
   217     }
   237     }
   246     }
   266     }
   247 // -----------------------------------------------------------------------------
   267 // -----------------------------------------------------------------------------
   248 //
   268 //
   249 // -----------------------------------------------------------------------------
   269 // -----------------------------------------------------------------------------
   250 //
   270 //
       
   271 void CCaWidgetDescription::SetPreviewImageNameL( const TDesC& aPreviewName )
       
   272     {
       
   273     iPreviewImageName.Close();
       
   274     iPreviewImageName.CreateL( aPreviewName );
       
   275     }
       
   276 // -----------------------------------------------------------------------------
       
   277 //
       
   278 // -----------------------------------------------------------------------------
       
   279 //
   251 void CCaWidgetDescription::SetLibraryL( const TDesC& aLibrary )
   280 void CCaWidgetDescription::SetLibraryL( const TDesC& aLibrary )
   252     {
   281     {
   253     iLibrary.Close();
   282     iLibrary.Close();
   254     iLibrary.CreateL(aLibrary);
   283     iLibrary.CreateL(aLibrary);
   255     }
   284     }
   256 
   285 
   257 // -----------------------------------------------------------------------------
   286 // -----------------------------------------------------------------------------
   258 //
   287 //
   259 // -----------------------------------------------------------------------------
   288 // -----------------------------------------------------------------------------
   260 //
   289 //
   261 void CCaWidgetDescription::SetMissing( TBool aMissing )
       
   262     {
       
   263     SetFlag( EMissing, aMissing );
       
   264     }
       
   265 
       
   266 // -----------------------------------------------------------------------------
       
   267 //
       
   268 // -----------------------------------------------------------------------------
       
   269 //
       
   270 void CCaWidgetDescription::SetVisible( TBool aVisible )
       
   271     {
       
   272     SetFlag( EVisible, aVisible );
       
   273     }
       
   274 
       
   275 // -----------------------------------------------------------------------------
       
   276 //
       
   277 // -----------------------------------------------------------------------------
       
   278 //
       
   279 void CCaWidgetDescription::SetUsed( TBool aUsed )
       
   280     {
       
   281     SetFlag( EUsed, aUsed );
       
   282     }
       
   283 
       
   284 // -----------------------------------------------------------------------------
       
   285 //
       
   286 // -----------------------------------------------------------------------------
       
   287 //
       
   288 void CCaWidgetDescription::SetFlag( TInt aFlag, TBool aValue )
   290 void CCaWidgetDescription::SetFlag( TInt aFlag, TBool aValue )
   289     {
   291     {
   290     if( aValue )
   292     if( aValue )
   291         {
   293         {
   292         iFlags = iFlags | aFlag;
   294         iFlags = iFlags | aFlag;
   373     }
   375     }
   374 // -----------------------------------------------------------------------------
   376 // -----------------------------------------------------------------------------
   375 //
   377 //
   376 // -----------------------------------------------------------------------------
   378 // -----------------------------------------------------------------------------
   377 //
   379 //
   378 TPtrC CCaWidgetDescription::GetPath( ) const
       
   379     {
       
   380     return iPath;
       
   381     }
       
   382 // -----------------------------------------------------------------------------
       
   383 //
       
   384 // -----------------------------------------------------------------------------
       
   385 //
       
   386 void CCaWidgetDescription::SetPathL( const TDesC& aPath )
       
   387     {
       
   388 	iPath.Close();
       
   389 	iPath.CreateL(aPath);
       
   390     }
       
   391 // -----------------------------------------------------------------------------
       
   392 //
       
   393 // -----------------------------------------------------------------------------
       
   394 //
       
   395 TPtrC CCaWidgetDescription::GetDescription( ) const
   380 TPtrC CCaWidgetDescription::GetDescription( ) const
   396     {
   381     {
   397     return iDescription;
   382     return iDescription;
   398     }
   383     }
   399 
   384 
   417 
   402 
   418 // -----------------------------------------------------------------------------
   403 // -----------------------------------------------------------------------------
   419 //
   404 //
   420 // -----------------------------------------------------------------------------
   405 // -----------------------------------------------------------------------------
   421 //
   406 //
       
   407 TPtrC CCaWidgetDescription::GetPreviewImageName( ) const
       
   408     {
       
   409     return iPreviewImageName;
       
   410     }
       
   411 
       
   412 // -----------------------------------------------------------------------------
       
   413 //
       
   414 // -----------------------------------------------------------------------------
       
   415 //
   422 TPtrC CCaWidgetDescription::GetTitle( ) const
   416 TPtrC CCaWidgetDescription::GetTitle( ) const
   423     {
   417     {
       
   418     TPtrC result ;
   424     if ( iTitle == KNullDesC )
   419     if ( iTitle == KNullDesC )
   425         {
   420         {
   426         return GetLibraryName();
   421         result.Set( GetLibraryName() );
   427         }
   422         }
   428     else
   423     else
   429         {
   424         {
   430         return iTitle;
   425         result.Set( iTitle );
   431         }
   426         }
       
   427     return result;
   432     }
   428     }
   433 
   429 
   434 // -----------------------------------------------------------------------------
   430 // -----------------------------------------------------------------------------
   435 //
   431 //
   436 // -----------------------------------------------------------------------------
   432 // -----------------------------------------------------------------------------
   502                 DriveInfo::EDefaultRom ) )
   498                 DriveInfo::EDefaultRom ) )
   503             {
   499             {
   504             entry->SetFlags( entry->GetFlags() & ~ERemovable );
   500             entry->SetFlags( entry->GetFlags() & ~ERemovable );
   505             }
   501             }
   506         }
   502         }
   507     if ( iPath != KNullDesC )
       
   508         {
       
   509         entry->AddAttributeL(KAttrWidgetPath, iPath);
       
   510         }
       
   511     if ( iTitle != KNullDesC )
   503     if ( iTitle != KNullDesC )
   512         {
   504         {
   513         entry->SetTextL(iTitle);
   505         entry->SetTextL(iTitle);
   514         entry->AddAttributeL(KCaAttrLongName, iTitle);
       
   515         }
   506         }
   516     else
   507     else
   517         {
   508         {
   518         TPtrC libraryName( GetLibraryName() );
   509         TPtrC libraryName( GetLibraryName() );
   519         entry->SetTextL( libraryName );
   510         entry->SetTextL( libraryName );
   520         entry->AddAttributeL( KCaAttrLongName, libraryName );
       
   521         }
   511         }
   522 
   512 
   523     if ( iDescription != KNullDesC )
   513     if ( iDescription != KNullDesC )
   524         {
   514         {
   525         entry->SetDescriptionL( iDescription );
   515         entry->SetDescriptionL( iDescription );
   529         entry->AddAttributeL(KAttrWidgetUri, iUri);
   519         entry->AddAttributeL(KAttrWidgetUri, iUri);
   530         }
   520         }
   531     if ( iIconUri != KNullDesC)
   521     if ( iIconUri != KNullDesC)
   532         {
   522         {
   533         // aSkinId and AppId not used for widgets - KNullDesC
   523         // aSkinId and AppId not used for widgets - KNullDesC
   534         entry->SetIconDataL(iIconUri, KNullDesC, KNullDesC);
   524         entry->SetIconDataL( iIconUri, KNullDesC, KNullDesC );
   535         }
   525         }
   536 
   526     if ( iPreviewImageName != KNullDesC )
       
   527         {
       
   528         entry->AddAttributeL( KPreviewImageAttrName, iPreviewImageName );
       
   529         }
   537     if( iModificationTime != KNullDesC )
   530     if( iModificationTime != KNullDesC )
   538         {
   531         {
   539         entry->AddAttributeL( KCaAttrInstallationTime, iModificationTime );
   532         entry->AddAttributeL( KCaAttrInstallationTime, iModificationTime );
   540         }
   533         }
   541     if ( iServiceXml != KNullDesC )
   534     if ( iServiceXml != KNullDesC )
   589 TPtrC CCaWidgetDescription::GetServiceXml() const
   582 TPtrC CCaWidgetDescription::GetServiceXml() const
   590     {
   583     {
   591     return iServiceXml;
   584     return iServiceXml;
   592     }
   585     }
   593 
   586 
       
   587 // -----------------------------------------------------------------------------
       
   588 //
       
   589 // -----------------------------------------------------------------------------
       
   590 //
   594 void CCaWidgetDescription::LocalizeTextsL()
   591 void CCaWidgetDescription::LocalizeTextsL()
   595 	{
   592 	{
   596     
   593     
   597     
   594     
   598 	if( iUri.Length() )
   595 	if( iUri.Length() )
   657 	    	}
   654 	    	}
   658 	    CleanupStack::PopAndDestroy( &uri );
   655 	    CleanupStack::PopAndDestroy( &uri );
   659 		}
   656 		}
   660 	}
   657 	}
   661 
   658 
   662 /*
   659 // -----------------------------------------------------------------------------
   663  * Set manifest file path name
   660 //
   664  * @param aManifestFilePt
   661 // -----------------------------------------------------------------------------
   665  */
   662 // 
       
   663 TBool CCaWidgetDescription::IsValid()
       
   664     {
       
   665     return iValid;
       
   666     }
       
   667 
       
   668 // -----------------------------------------------------------------------------
       
   669 //
       
   670 // -----------------------------------------------------------------------------
       
   671 //
       
   672 void CCaWidgetDescription::SetValid(TBool aVal)
       
   673     {
       
   674     iValid = aVal;
       
   675     }
       
   676 
       
   677 // -----------------------------------------------------------------------------
       
   678 //
       
   679 // -----------------------------------------------------------------------------
       
   680 //
   666 void CCaWidgetDescription::SetManifestFilePathNameL( 
   681 void CCaWidgetDescription::SetManifestFilePathNameL( 
   667     const TDesC& aManifestFilePathName )
   682     const TDesC& aManifestFilePathName )
   668     {
   683     {
   669     iManifestFilePathName.Close();
   684     iManifestFilePathName.Close();
   670     iManifestFilePathName.CreateL( aManifestFilePathName );
   685     iManifestFilePathName.CreateL( aManifestFilePathName );
   671     }
   686     }
   672 
   687 
   673 /*
   688 // -----------------------------------------------------------------------------
   674  * Get service fw xml filename
   689 //
   675  * @return Service xml filename
   690 // -----------------------------------------------------------------------------
   676  */
   691 //
   677 TPtrC CCaWidgetDescription::GetManifestFilePathName() const
   692 TPtrC CCaWidgetDescription::GetManifestFilePathName() const
   678     {
   693     {
   679     return iManifestFilePathName;
   694     return iManifestFilePathName;
   680     }
   695     }
   681 //  End of File
   696 //  End of File