--- a/contentstorage/casrv/causifscanner/src/causifscanner.cpp Fri Mar 26 13:00:55 2010 +0200
+++ b/contentstorage/casrv/causifscanner/src/causifscanner.cpp Fri Apr 16 14:45:49 2010 +0300
@@ -31,17 +31,14 @@
using namespace Usif;
-_LIT( KUsifPluginCollection, "Usif collection");
-_LIT( KCaAttrComponentId, "component_id" );
-
// ---------------------------------------------------------------------------
//
// ---------------------------------------------------------------------------
//
CCaUsifScanner* CCaUsifScanner::NewL( TPluginParams* aPluginParams )
{
- CCaUsifScanner* self = new ( ELeave )
- CCaUsifScanner( *aPluginParams->storageProxy );
+ CCaUsifScanner* self = new ( ELeave ) CCaUsifScanner(
+ *aPluginParams->storageProxy );
CleanupStack::PushL( self );
self->ConstructL();
CleanupStack::Pop( self );
@@ -55,7 +52,6 @@
CCaUsifScanner::CCaUsifScanner( CCaStorageProxy& aStorageProxy ) :
iStorageProxy( aStorageProxy )
{
-
}
// ---------------------------------------------------------------------------
@@ -64,8 +60,21 @@
//
void CCaUsifScanner::ConstructL()
{
- AddCollectionUsifL();
- AddNativeAppsL();
+ iSystemInstallNotifier = CCaInstallNotifier::NewL( *this,
+ CCaInstallNotifier::ESisInstallNotification );
+
+ iUsifUninstallNotifier = CCaInstallNotifier::NewL( *this,
+ CCaInstallNotifier::EUsifUninstallNotification );
+
+ iJavaInstallNotifier = CCaInstallNotifier::NewL( *this,
+ CCaInstallNotifier::EJavaInstallNotification );
+
+ User::LeaveIfError( iFs.Connect() );
+ iMmcWatcher = CCaMmcWatcher::NewL( iFs, this );
+
+ User::LeaveIfError( iSoftwareRegistry.Connect() );
+
+ UpdateUsifListL();
}
// ---------------------------------------------------------------------------
@@ -74,84 +83,65 @@
//
CCaUsifScanner::~CCaUsifScanner()
{
- }
-
-// ---------------------------------------------------------------------------
-//
-// ---------------------------------------------------------------------------
-//
-void CCaUsifScanner::InstallL( const TDesC& aFileName )
- {
- RSoftwareInstall sif;
- CleanupClosePushL( sif );
- User::LeaveIfError( sif.Connect());
-
- // Install the component
- TRequestStatus status;
- sif.Install( aFileName, status, EFalse );
- User::WaitForRequest( status );
- User::LeaveIfError(status.Int());
-
- // Disconnect from the SIF server
- CleanupStack::PopAndDestroy( &sif );
+ delete iMmcWatcher;
+ delete iSystemInstallNotifier;
+ delete iUsifUninstallNotifier;
+ delete iJavaInstallNotifier;
+ iFs.Close();
+ iSoftwareRegistry.Close();
}
// ---------------------------------------------------------------------------
//
// ---------------------------------------------------------------------------
//
-void CCaUsifScanner::AddCollectionUsifL()
+/*void CCaUsifScanner::InstallL( const TDesC& aFileName )
+ {
+ RSoftwareInstall sif;
+ CleanupClosePushL( sif );
+ User::LeaveIfError( sif.Connect());
+
+ // Install the component
+ TRequestStatus status;
+ sif.Install( aFileName, status, EFalse );
+ User::WaitForRequest( status );
+ User::LeaveIfError(status.Int());
+
+ // Disconnect from the SIF server
+ CleanupStack::PopAndDestroy( &sif );
+ }*/
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void CCaUsifScanner::HandleInstallNotifyL( TInt /*aUid*/)
{
- if( GetCollectionUsifIdL() == 0 )
- {
- CCaInnerEntry *entry = CCaInnerEntry::NewLC();
- entry->SetRole( EGroupEntryRole );
- entry->SetEntryTypeNameL( KCaTypeCollection );
- entry->SetFlags( ERemovable | EVisible );
- entry->SetTextL( KUsifPluginCollection );
- iStorageProxy.AddL( entry );
- iCollectionUsifId = entry->GetId();
- CleanupStack::PopAndDestroy( entry );
-
- TCaOperationParams params =
- {
- TCaOperationParams::EPrepend, 2, 0
- };
- RArray<TInt> ids;
- CleanupClosePushL( ids );
- ids.AppendL( iCollectionUsifId );
- iStorageProxy.OrganizeL( ids, params );
- CleanupStack::PopAndDestroy( &ids );
- }
+ UpdateUsifListL();
}
// ---------------------------------------------------------------------------
//
// ---------------------------------------------------------------------------
//
-TInt CCaUsifScanner::GetCollectionUsifIdL()
+#ifdef COVERAGE_MEASUREMENT
+#pragma CTC SKIP
+#endif //COVERAGE_MEASUREMENT
+void CCaUsifScanner::MmcChangeL()
{
- if( iCollectionUsifId == 0 )
- {
- RPointerArray<CCaInnerEntry> resultArray;
- CleanupResetAndDestroyPushL( resultArray );
- CCaInnerQuery* allAppQuery = CCaInnerQuery::NewLC();
- CDesC16ArrayFlat* appType = new ( ELeave ) CDesC16ArrayFlat( 1 );
- CleanupStack::PushL( appType );
- appType->AppendL( KCaTypeCollection );
- allAppQuery->SetEntryTypeNames( appType );
- allAppQuery->SetRole(CCaInnerQuery::Group);
- CleanupStack::Pop( appType );
- iStorageProxy.GetEntriesL( allAppQuery, resultArray );
- CleanupStack::PopAndDestroy( allAppQuery );
- for(TInt i(0); i< resultArray.Count(); i++ )
- {
- if(!resultArray[i]->GetText().Compare(KUsifPluginCollection))
- iCollectionUsifId = resultArray[i]->GetId();
- }
- CleanupStack::PopAndDestroy( &resultArray );
- }
- return iCollectionUsifId;
+ UpdateUsifListL();
+ }
+#ifdef COVERAGE_MEASUREMENT
+#pragma CTC ENDSKIP
+#endif //COVERAGE_MEASUREMENT
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void CCaUsifScanner::UpdateUsifListL()
+ {
+ AddPackageL();
+ UpdatePackagesL();
}
// ---------------------------------------------------------------------------
@@ -162,10 +152,19 @@
const CComponentEntry* aEntry, CCaInnerEntry* aCaEntry )
{
aCaEntry->SetRole( EItemEntryRole );
- aCaEntry->SetEntryTypeNameL(KCaTypeApp);
- if( aEntry->Name().Compare(KNullDesC))
+ aCaEntry->SetEntryTypeNameL( KCaTypePackage );
+ if( !aEntry->SoftwareType().Compare( KSoftwareTypeNative ) )
+ {
+ aCaEntry->AddAttributeL( KCaAttrAppType, KCaAttrAppTypeValueNative );
+ }
+ else if( !aEntry->SoftwareType().Compare( KSoftwareTypeJava ) )
{
- aCaEntry->SetTextL(aEntry->Name());
+ aCaEntry->AddAttributeL( KCaAttrAppType, KCaAttrAppTypeValueJava );
+ }
+ if( aEntry->Name().Compare( KNullDesC ) )
+ {
+ aCaEntry->SetTextL( aEntry->Name() );
+ aCaEntry->AddAttributeL( KCaAttrLongName, aEntry->Name() );
}
if( !aEntry->IsHidden() )
{
@@ -175,92 +174,77 @@
{
aCaEntry->SetFlags( aCaEntry->GetFlags() | ERemovable );
}
- if( aEntry->GlobalId().Compare( KNullDesC ) )
- {
- TLex lex( aEntry->GlobalId() );
- TUint uint( 0 );
- User::LeaveIfError( lex.Val( uint, EHex ) );
- aCaEntry->SetUid( uint );
- }
+ // entries obtained with usif should have component id.
+ //it's needed for uninstalling
RBuf compIdDesc;
- CleanupClosePushL(compIdDesc);
- compIdDesc.CreateL(KCaMaxAttrValueLen);
- compIdDesc.Num(aEntry->ComponentId());
+ CleanupClosePushL( compIdDesc );
+ compIdDesc.CreateL( KCaMaxAttrValueLen );
+ compIdDesc.Num( aEntry->ComponentId() );
aCaEntry->AddAttributeL( KCaAttrComponentId, compIdDesc );
CleanupStack::PopAndDestroy( &compIdDesc );
-
}
// ---------------------------------------------------------------------------
//
// ---------------------------------------------------------------------------
//
-void CCaUsifScanner::AddNativeAppsL()
+void CCaUsifScanner::AddPackageL()
{
- TLanguage locale = TLanguage(-1);
-
- CComponentFilter *filter = CComponentFilter::NewL();
- CleanupStack::PushL(filter);
- filter->SetSoftwareTypeL( KSoftwareTypeNative );
- filter->SetRemovable(ETrue);
-
- // Connect to the SCR server
- RSoftwareComponentRegistry *scr = new RSoftwareComponentRegistry();
- CleanupClosePushL(*scr);
- User::LeaveIfError( scr->Connect() );
-
- // Create an SCR view
- RSoftwareComponentRegistryView *scrView =
- new RSoftwareComponentRegistryView();
- CleanupClosePushL(*scrView);
- scrView->OpenViewL( *scr, filter );
-
- // Iterate over the matching components
- CComponentEntry* entry = CComponentEntry::NewLC();
-
RPointerArray<CCaInnerEntry> entries;
CleanupResetAndDestroyPushL( entries );
- GetCaAppEntriesL(entries);
+ GetCaPackageEntriesL( entries );
- RArray<TInt> entryIds;
- CleanupClosePushL(entryIds);
- while( scrView->NextComponentL( *entry, locale ) )
+ RPointerArray<CComponentEntry> resultUsifArray;
+ CleanupResetAndDestroyPushL( resultUsifArray );
+ GetUsifPackageEntriesL( resultUsifArray );
+
+ for( TInt idx(0); idx < resultUsifArray.Count(); idx++ )
{
- CCaInnerEntry *caEntry = CCaInnerEntry::NewLC();
- CreateCaEntryFromEntryL( entry, caEntry );
-
- if( !AppExist(entries, caEntry))
+ if( PackageExistL( entries, resultUsifArray[idx] ) == KErrNotFound )
{
+ CCaInnerEntry *caEntry = CCaInnerEntry::NewLC();
+ CreateCaEntryFromEntryL( resultUsifArray[idx], caEntry );
iStorageProxy.AddL( caEntry );
- entryIds.Append( caEntry->GetId() );
+ CleanupStack::PopAndDestroy( caEntry );
}
- CleanupStack::PopAndDestroy( caEntry );
}
- TCaOperationParams params =
- {
- TCaOperationParams::EAppend, iCollectionUsifId, 0
- };
- iStorageProxy.OrganizeL( entryIds, params );
- CleanupStack::PopAndDestroy( &entryIds );
+ CleanupStack::PopAndDestroy( &resultUsifArray );
CleanupStack::PopAndDestroy( &entries );
- CleanupStack::PopAndDestroy( entry );
- CleanupStack::PopAndDestroy(scrView);
- CleanupStack::PopAndDestroy(scr);
- CleanupStack::PopAndDestroy(filter);
}
// ---------------------------------------------------------------------------
//
// ---------------------------------------------------------------------------
//
-void CCaUsifScanner::GetCaAppEntriesL(
+void CCaUsifScanner::UpdatePackagesL()
+ {
+ RPointerArray<CCaInnerEntry> resultCaArray;
+ CleanupResetAndDestroyPushL( resultCaArray );
+ GetCaPackageEntriesL( resultCaArray );
+
+ RPointerArray<CComponentEntry> resultUsifArray;
+ CleanupResetAndDestroyPushL( resultUsifArray );
+ GetUsifPackageEntriesL( resultUsifArray );
+
+ FindDeletedEntriesL( resultCaArray, resultUsifArray );
+ RemoveEntriesFromDbL( resultCaArray );
+
+ CleanupStack::PopAndDestroy( &resultUsifArray );
+ CleanupStack::PopAndDestroy( &resultCaArray );
+ }
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void CCaUsifScanner::GetCaPackageEntriesL(
RPointerArray<CCaInnerEntry>& aArray )
{
CCaInnerQuery* allAppQuery = CCaInnerQuery::NewLC();
CDesC16ArrayFlat* appType = new ( ELeave ) CDesC16ArrayFlat( 1 );
CleanupStack::PushL( appType );
- appType->AppendL( KCaTypeApp );
+ appType->AppendL( KCaTypePackage );
allAppQuery->SetEntryTypeNames( appType );
CleanupStack::Pop( appType );
iStorageProxy.GetEntriesL( allAppQuery, aArray );
@@ -271,13 +255,108 @@
//
// ---------------------------------------------------------------------------
//
-TInt CCaUsifScanner::AppExist( RPointerArray<CCaInnerEntry>& aArray,
- CCaInnerEntry* aEntry )
+void CCaUsifScanner::GetUsifPackageEntriesL(
+ RPointerArray<CComponentEntry>& aArray )
{
- for (TInt i(0); i < aArray.Count(); i++)
+ CComponentFilter *filter = CComponentFilter::NewL();
+ CleanupStack::PushL( filter );
+ filter->SetRemovable( ETrue );
+ filter->SetHidden( EFalse );
+
+ // Create an SCR view
+ RSoftwareComponentRegistryView scrView;
+ CleanupClosePushL( scrView );
+ scrView.OpenViewL( iSoftwareRegistry, filter );
+
+ // Iterate over the matching components
+ //The ownership is transferred to the calling client.
+ CComponentEntry* entry = scrView.NextComponentL();
+ while( entry )
+ {
+ CleanupStack::PushL( entry );
+ if( iSoftwareRegistry.IsComponentPresentL( entry->ComponentId() ) )
+ {
+ aArray.AppendL( entry );
+ CleanupStack::Pop( entry );
+ }
+ else
+ {
+ CleanupStack::PopAndDestroy( entry );
+ }
+ entry = scrView.NextComponentL();
+ }
+ CleanupStack::PopAndDestroy( &scrView );
+ CleanupStack::PopAndDestroy( filter );
+ }
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+TInt CCaUsifScanner::PackageExistL( RPointerArray<CCaInnerEntry>& aArray,
+ const CComponentEntry* aEntry )
+ {
+ for( TInt idx( 0 ); idx < aArray.Count(); idx++ )
{
- if( aArray[i]->GetUid() == aEntry->GetUid())
- return KErrAlreadyExists;
+ TBuf<KMaxUnits> compIdDes;
+ if( aArray[idx]->FindAttribute( KCaAttrComponentId, compIdDes ) )
+ {
+ TLex lex( compIdDes );
+ TUint uint( 0 );
+ User::LeaveIfError( lex.Val( uint ) );
+ if( aEntry->ComponentId() == uint )
+ {
+ return idx;
+ }
+ }
}
- return KErrNone;
+ return KErrNotFound;
}
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void CCaUsifScanner::FindDeletedEntriesL(
+ RPointerArray<CCaInnerEntry>& aCaArray, const RPointerArray<
+ CComponentEntry>& aUsifArray )
+ {
+ for( TInt idx( aCaArray.Count() - 1 ); idx >= 0; idx-- )
+ {
+ TBuf<KMaxUnits> compIdDes;
+ if( aCaArray[idx]->FindAttribute( KCaAttrComponentId, compIdDes ) )
+ {
+ TLex lex( compIdDes );
+ TUint uint( 0 );
+ User::LeaveIfError( lex.Val( uint ) );
+ //for each usif entry check if entry has to be removed
+ for( TInt k( 0 ); k < aUsifArray.Count(); k++ )
+ {
+ if( aUsifArray[k]->ComponentId() == uint
+ && iSoftwareRegistry.IsComponentPresentL( uint ) )
+ {
+ delete aCaArray[idx];
+ aCaArray.Remove( idx );
+ break;
+ }
+ }
+ }
+ }
+ }
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void CCaUsifScanner::RemoveEntriesFromDbL(
+ RPointerArray<CCaInnerEntry>& aCaArray )
+ {
+ RArray<TInt> entriesId;
+ CleanupClosePushL( entriesId );
+ for( TInt i( 0 ); i < aCaArray.Count(); i++ )
+ {
+ entriesId.Append( aCaArray[i]->GetId() );
+ }
+ iStorageProxy.RemoveL( entriesId );
+ CleanupStack::PopAndDestroy( &entriesId );
+ }