contentstorage/casrv/cawidgetscanner/src/cawidgetdescription.cpp
changeset 93 82b66994846c
parent 92 782e3408c2ab
child 94 dbb8300717f7
equal deleted inserted replaced
92:782e3408c2ab 93:82b66994846c
    34 // C++ default constructor can NOT contain any code, that
    34 // C++ default constructor can NOT contain any code, that
    35 // might leave.
    35 // might leave.
    36 // -----------------------------------------------------------------------------
    36 // -----------------------------------------------------------------------------
    37 //
    37 //
    38 CCaWidgetDescription::CCaWidgetDescription() :
    38 CCaWidgetDescription::CCaWidgetDescription() :
    39     iEntryId(KNoId), iFlags(EVisible)
    39     iEntryId(KNoId), iMmcId()
    40     {
    40     {
    41     }
    41     }
    42 
    42 
    43 // -----------------------------------------------------------------------------
    43 // -----------------------------------------------------------------------------
    44 // CCaWidgetDescription::ConstructL
    44 // CCaWidgetDescription::ConstructL
    76     aEntry->FindAttribute( KAttrWidgetPath, iPath );
    76     aEntry->FindAttribute( KAttrWidgetPath, iPath );
    77     //uri
    77     //uri
    78     iUri.CreateL( KCaMaxAttrValueLen );
    78     iUri.CreateL( KCaMaxAttrValueLen );
    79     aEntry->FindAttribute( KAttrWidgetUri, iUri );
    79     aEntry->FindAttribute( KAttrWidgetUri, iUri );
    80     //mmc id
    80     //mmc id
    81     TBuf<KUidChars> mmcId;
    81     iMmcId.CreateL(KMassStorageIdLength);
    82     if( aEntry->FindAttribute( KCaAttrMmcId, mmcId ) )
    82     aEntry->FindAttribute( KCaAttrMmcId, iMmcId );
    83         {
    83     //service xml
    84         TLex mmcLex( mmcId );
    84     iServiceXml.CreateL( KCaMaxAttrValueLen );
    85         User::LeaveIfError( mmcLex.Val( iMmcId, EHex ));
    85     aEntry->FindAttribute( KAttrWidgetServiceXml,iServiceXml );
    86         }
       
    87     if( aEntry->GetFlags() &  EMissing )
       
    88         {
       
    89         iFlags = iFlags | EMissing;
       
    90         }
       
    91     if( aEntry->GetFlags() &  EUsed )
       
    92         {
       
    93         iFlags = iFlags | EUsed;
       
    94         }
       
    95     
    86     
       
    87     iFlags = aEntry->GetFlags();
    96     iModificationTime.CreateL(KCaMaxAttrValueLen);
    88     iModificationTime.CreateL(KCaMaxAttrValueLen);
    97     aEntry->FindAttribute( KCaAttrInstallationTime, iModificationTime );
    89     aEntry->FindAttribute( KCaAttrInstallationTime, iModificationTime );
    98     }
    90     }
    99 
    91 
   100 // -----------------------------------------------------------------------------
    92 // -----------------------------------------------------------------------------
   146     iUri.Close();
   138     iUri.Close();
   147     iIconUri.Close();
   139     iIconUri.Close();
   148     iLibrary.Close();
   140     iLibrary.Close();
   149     iPath.Close();
   141     iPath.Close();
   150     iModificationTime.Close();
   142     iModificationTime.Close();
       
   143     iMmcId.Close();
       
   144     iServiceXml.Close();
   151     }
   145     }
   152 
   146 
   153 // ----------------------------------------------------------------------------
   147 // ----------------------------------------------------------------------------
   154 //
   148 //
   155 // ----------------------------------------------------------------------------
   149 // ----------------------------------------------------------------------------
   156 //
   150 //
   157 TBool CCaWidgetDescription::Compare(
   151 TBool CCaWidgetDescription::Compare(
   158         const CCaWidgetDescription& aFirst,const CCaWidgetDescription& aSecond)
   152         const CCaWidgetDescription& aFirst,const CCaWidgetDescription& aSecond)
   159     {
   153     {
   160     if( aFirst.GetLibraryName() == aSecond.GetLibraryName() )
   154     if( aFirst.GetUri() == aSecond.GetUri() )
   161         {
   155         {
   162         return ETrue;
   156         return ETrue;
   163         }
   157         }
   164     else
   158     else
   165         {
   159         {
   177             aToCompare.GetDescription() == GetDescription() &&
   171             aToCompare.GetDescription() == GetDescription() &&
   178             aToCompare.GetUri() == GetUri() &&
   172             aToCompare.GetUri() == GetUri() &&
   179             aToCompare.GetIconUri() == GetIconUri() &&
   173             aToCompare.GetIconUri() == GetIconUri() &&
   180             aToCompare.GetTitle() == GetTitle() &&
   174             aToCompare.GetTitle() == GetTitle() &&
   181             aToCompare.GetLibrary() != KNoLibrary &&
   175             aToCompare.GetLibrary() != KNoLibrary &&
   182             aToCompare.GetModificationTime() == GetModificationTime()
   176             aToCompare.GetModificationTime() == GetModificationTime() &&
       
   177             aToCompare.GetServiceXml() == GetServiceXml()
   183             )
   178             )
   184         {
   179         {
   185         return ETrue;
   180         return ETrue;
   186         }
   181         }
   187     else
   182     else
   192 
   187 
   193 // -----------------------------------------------------------------------------
   188 // -----------------------------------------------------------------------------
   194 //
   189 //
   195 // -----------------------------------------------------------------------------
   190 // -----------------------------------------------------------------------------
   196 //
   191 //
   197 void CCaWidgetDescription::SetMmcId( TUint aMmcId )
   192 void CCaWidgetDescription::SetMmcIdL( const TDesC& aMmcId )
   198     {
   193     {
   199     iMmcId = aMmcId;
   194     iMmcId.Close();
       
   195     iMmcId.CreateL( aMmcId );
   200     }
   196     }
   201 
   197 
   202 // -----------------------------------------------------------------------------
   198 // -----------------------------------------------------------------------------
   203 //
   199 //
   204 // -----------------------------------------------------------------------------
   200 // -----------------------------------------------------------------------------
   321 
   317 
   322 // -----------------------------------------------------------------------------
   318 // -----------------------------------------------------------------------------
   323 //
   319 //
   324 // -----------------------------------------------------------------------------
   320 // -----------------------------------------------------------------------------
   325 //
   321 //
   326 TUint CCaWidgetDescription::GetMmcId( ) const
   322 TPtrC CCaWidgetDescription::GetMmcId( ) const
   327     {
   323     {
   328     return iMmcId;
   324     return iMmcId;
   329     }
   325     }
   330 
   326 
   331 // -----------------------------------------------------------------------------
   327 // -----------------------------------------------------------------------------
   421 // -----------------------------------------------------------------------------
   417 // -----------------------------------------------------------------------------
   422 //
   418 //
   423 TBool CCaWidgetDescription::IsUsed( ) const
   419 TBool CCaWidgetDescription::IsUsed( ) const
   424     {
   420     {
   425     return iFlags & EUsed;
   421     return iFlags & EUsed;
       
   422     }
       
   423 
       
   424 
       
   425 // -----------------------------------------------------------------------------
       
   426 //
       
   427 // -----------------------------------------------------------------------------
       
   428 //
       
   429 TBool CCaWidgetDescription::IsVisible( ) const
       
   430     {
       
   431     return iFlags & EVisible;
   426     }
   432     }
   427 
   433 
   428 // -----------------------------------------------------------------------------
   434 // -----------------------------------------------------------------------------
   429 //
   435 //
   430 // -----------------------------------------------------------------------------
   436 // -----------------------------------------------------------------------------
   432 CCaInnerEntry* CCaWidgetDescription::GetEntryLC( ) const
   438 CCaInnerEntry* CCaWidgetDescription::GetEntryLC( ) const
   433     {
   439     {
   434     CCaInnerEntry* entry = CCaInnerEntry::NewLC();
   440     CCaInnerEntry* entry = CCaInnerEntry::NewLC();
   435     entry->SetEntryTypeNameL( KCaTypeWidget );
   441     entry->SetEntryTypeNameL( KCaTypeWidget );
   436     entry->SetRole( EItemEntryRole );
   442     entry->SetRole( EItemEntryRole );
   437     if ( iFlags & EVisible )
   443     entry->SetFlags( iFlags );
   438         {
       
   439         entry->SetFlags( EVisible );
       
   440         }
       
   441     if ( iPackageUid )
   444     if ( iPackageUid )
   442         {
   445         {
   443         TBuf<KMaxUidName> uidDesc;
   446         TBuf<KMaxUidName> uidDesc;
   444         uidDesc.AppendNum( iPackageUid,EHex );
   447         uidDesc.AppendNum( iPackageUid,EHex );
   445         entry->AddAttributeL( KCaPackageUid, uidDesc );
   448         entry->AddAttributeL( KCaPackageUid, uidDesc );
   446         }
   449         }
   447     if ( iEntryId != KNoId )
   450     if ( iEntryId != KNoId )
   448         {
   451         {
   449         entry->SetId( iEntryId );
   452         entry->SetId( iEntryId );
   450         }
   453         }
   451     if ( iMmcId )
   454     if ( iMmcId != KNullDesC )
   452         {
   455         {
   453         TBuf<KMaxUidName> mmcId;
   456         entry->AddAttributeL( KCaAttrMmcId, iMmcId );
   454         mmcId.AppendNum( iMmcId, EHex);
       
   455         entry->AddAttributeL( KCaAttrMmcId, mmcId );
       
   456         }
   457         }
   457     if ( iLibrary != KNullDesC )
   458     if ( iLibrary != KNullDesC )
   458         {
   459         {
   459         entry->AddAttributeL(KAttrWidgetLibrary, iLibrary);
   460         entry->AddAttributeL(KAttrWidgetLibrary, iLibrary);
   460         entry->SetFlags(entry->GetFlags() | ERemovable);
   461         entry->SetFlags(entry->GetFlags() | ERemovable);
   496 
   497 
   497     if( iModificationTime != KNullDesC )
   498     if( iModificationTime != KNullDesC )
   498         {
   499         {
   499         entry->AddAttributeL( KCaAttrInstallationTime, iModificationTime );
   500         entry->AddAttributeL( KCaAttrInstallationTime, iModificationTime );
   500         }
   501         }
   501 
   502     if ( iServiceXml != KNullDesC )
       
   503         {
       
   504         entry->AddAttributeL( KAttrWidgetServiceXml, iServiceXml);
       
   505         }
   502     return entry;
   506     return entry;
   503     }
   507     }
   504 
   508 
   505 // -----------------------------------------------------------------------------
   509 // -----------------------------------------------------------------------------
   506 //
   510 //
   519         {
   523         {
   520         libraryName.Set( libraryName.Mid( 0, pos ));
   524         libraryName.Set( libraryName.Mid( 0, pos ));
   521         }
   525         }
   522     return libraryName;
   526     return libraryName;
   523     }
   527     }
       
   528 
       
   529 // -----------------------------------------------------------------------------
       
   530 //
       
   531 // -----------------------------------------------------------------------------
       
   532 //
       
   533 void CCaWidgetDescription::RemoveMmcId( )
       
   534     {
       
   535     iMmcId.Close();
       
   536     }
       
   537 // -----------------------------------------------------------------------------
       
   538 //
       
   539 // -----------------------------------------------------------------------------
       
   540 //
       
   541 void CCaWidgetDescription::SetServiceXmlL(const TDesC& aServiceXml)
       
   542     {
       
   543     iServiceXml.Close();
       
   544     iServiceXml.CreateL( aServiceXml );
       
   545     }
       
   546 // -----------------------------------------------------------------------------
       
   547 //
       
   548 // -----------------------------------------------------------------------------
       
   549 //
       
   550 TPtrC CCaWidgetDescription::GetServiceXml() const
       
   551     {
       
   552     return iServiceXml;
       
   553     }
   524 //  End of File
   554 //  End of File