appinstaller/AppinstUi/Daemon/Src/installationFailedAppsCache.cpp
branchRCL_3
changeset 25 7333d7932ef7
parent 0 ba25891c3a9e
child 26 8b7f4e561641
equal deleted inserted replaced
24:5cc91383ab1e 25:7333d7932ef7
    21 #include <pathinfo.h>
    21 #include <pathinfo.h>
    22 
    22 
    23 #include "sisregistrysession.h"
    23 #include "sisregistrysession.h"
    24 #include "sisregistryentry.h"
    24 #include "sisregistryentry.h"
    25 #include "sisregistrypackage.h"
    25 #include "sisregistrypackage.h"
       
    26 #include "installationFailedAppsCache.h"
       
    27 #include "SWInstDebug.h"
    26 
    28 
    27 using namespace Swi;
    29 using namespace Swi;
    28 
    30 
    29 #include "installationFailedAppsCache.h"
       
    30 
       
    31 _LIT(KInstFaildeApps, "c:\\private\\10202DCE\\instFailedAppsCache.dat");
    31 _LIT(KInstFaildeApps, "c:\\private\\10202DCE\\instFailedAppsCache.dat");
    32 
    32 
    33 #include "SWInstDebug.h"
       
    34 
    33 
    35 // ----------------------------
    34 // ----------------------------
    36 // Borrowed from cleanuputils.h:-
    35 // Borrowed from cleanuputils.h:-
    37 /** 
    36 /** 
    38  * Template class CleanupResetAndDestroy to clean up the array
    37  * Template class CleanupResetAndDestroy to clean up the array
    73 	}
    72 	}
    74 
    73 
    75 // End of code from swi/inc/cleanuputils.h
    74 // End of code from swi/inc/cleanuputils.h
    76 
    75 
    77 
    76 
       
    77 // -----------------------------------------------------------------------
       
    78 // 
       
    79 // -----------------------------------------------------------------------
       
    80 //    
    78 CInstallationFailedAppsCache *CInstallationFailedAppsCache::NewL()
    81 CInstallationFailedAppsCache *CInstallationFailedAppsCache::NewL()
    79 	{
    82 	{
    80 	FLOG( _L("Daemon: CInstallationFailedAppsCache::NewL") ); 
    83 	FLOG( _L("Daemon: CInstallationFailedAppsCache::NewL") ); 
    81 	
    84 	
    82 	CInstallationFailedAppsCache *self = new(ELeave)CInstallationFailedAppsCache;
    85 	CInstallationFailedAppsCache *self = new(ELeave)CInstallationFailedAppsCache;
    84 	self->ConstructL();
    87 	self->ConstructL();
    85 	CleanupStack::Pop(self);
    88 	CleanupStack::Pop(self);
    86 	return self;
    89 	return self;
    87 	}
    90 	}
    88 
    91 
    89 
    92 // -----------------------------------------------------------------------
       
    93 // 
       
    94 // -----------------------------------------------------------------------
       
    95 //   
    90 CInstallationFailedAppsCache::~CInstallationFailedAppsCache()
    96 CInstallationFailedAppsCache::~CInstallationFailedAppsCache()
    91 	{
    97 	{
    92 	iUidsArray.Reset();
    98 	iUidsArray.Reset();
    93 	}
    99 	}
    94 
   100 
    95 
   101 // -----------------------------------------------------------------------
       
   102 // 
       
   103 // -----------------------------------------------------------------------
       
   104 //   
    96 void CInstallationFailedAppsCache::AddPackageUID( TUid aUid )
   105 void CInstallationFailedAppsCache::AddPackageUID( TUid aUid )
    97 	{
   106 	{
    98 	FLOG( _L("Daemon: CInstallationFailedAppsCache::AddPackageUID") );
   107     FLOG( _L("Daemon: CInstallationFailedAppsCache::AddPackageUID") );
       
   108     FLOG_1( _L("Daemon: AddPackageUID: Add UID = 0x%x"), aUid.iUid );
    99 	
   109 	
   100 	(void)iUidsArray.InsertInSignedKeyOrder( aUid );
   110 	(void)iUidsArray.InsertInSignedKeyOrder( aUid );
   101 	// New UID added to array. Let's write cache to disk.
   111 	// New UID added to array. Let's write cache to disk.
   102 	iNewUID = ETrue;		
   112 	iNewUID = ETrue;		
   103 	}
   113 	}
   104 
   114 
   105 
   115 // -----------------------------------------------------------------------
   106 TBool CInstallationFailedAppsCache::HasPreviousInstallationFailed( TUid aUid )
   116 // 
   107 	{
   117 // -----------------------------------------------------------------------
   108 	FLOG( _L("Daemon: CInstallationFailedAppsCache::HasPreviousInstallationFailed") );
   118 //   
       
   119 TBool CInstallationFailedAppsCache::HasPreviousInstallationFailed( 
       
   120         TUid aUid )
       
   121 	{
       
   122 	FLOG( _L("Daemon: FailedAppsCache::HasPreviousInstallationFailed") );
   109 	
   123 	
   110 	if ( iUidsArray.FindInSignedKeyOrder( aUid ) == KErrNotFound )
   124 	if ( iUidsArray.FindInSignedKeyOrder( aUid ) == KErrNotFound )
   111 		{
   125 		{
   112 		FLOG( _L("Daemon: UID not found. No previous install attempt") );
   126 		FLOG( _L("Daemon: UID not found. No previous install attempt") );
   113 		return EFalse;
   127 		return EFalse;
   115 	
   129 	
   116 	FLOG( _L("Daemon: UID found. Previous install attempt FAILED") );	
   130 	FLOG( _L("Daemon: UID found. Previous install attempt FAILED") );	
   117 	return ETrue;
   131 	return ETrue;
   118 	}
   132 	}
   119 
   133 
   120 
   134 // -----------------------------------------------------------------------
       
   135 // 
       
   136 // -----------------------------------------------------------------------
       
   137 //   
   121 CInstallationFailedAppsCache::CInstallationFailedAppsCache()
   138 CInstallationFailedAppsCache::CInstallationFailedAppsCache()
   122 	{
   139 	{
   123 	}
   140 	}
   124 
   141 
   125 
   142 // -----------------------------------------------------------------------
       
   143 // 
       
   144 // -----------------------------------------------------------------------
       
   145 //   
   126 void CInstallationFailedAppsCache::ConstructL()
   146 void CInstallationFailedAppsCache::ConstructL()
   127 	{
   147 	{
   128 	User::LeaveIfError( iFs.Connect() );
   148 	User::LeaveIfError( iFs.Connect() );
   129 	TInt drive = 0;
   149 	TInt drive = 0;
   130     iFs.CharToDrive( TParsePtrC( PathInfo::PhoneMemoryRootPath() ).Drive()[0], drive );
   150     iFs.CharToDrive( TParsePtrC( 
       
   151             PathInfo::PhoneMemoryRootPath() ).Drive()[0], drive );
       
   152     
   131     iFs.CreatePrivatePath( drive );
   153     iFs.CreatePrivatePath( drive );
   132     
   154     
   133     iNewUID = EFalse;
   155     iNewUID = EFalse;
   134 
   156 
   135 	// Read cache file
   157 	// Read cache file
   136 	TRAP_IGNORE( InitFromCacheFileL() );
   158 	TRAP_IGNORE( InitFromCacheFileL() );
   137 	}
   159 	}
   138 
   160 
   139 
   161 // -----------------------------------------------------------------------
       
   162 // 
       
   163 // -----------------------------------------------------------------------
       
   164 //   
   140 void CInstallationFailedAppsCache::InitFromCacheFileL()
   165 void CInstallationFailedAppsCache::InitFromCacheFileL()
   141 	{
   166 	{
   142 	FLOG( _L("Daemon: CInstallationFailedAppsCache::InitFromCacheFileL") );	
   167 	FLOG( _L("Daemon: CInstallationFailedAppsCache::InitFromCacheFileL") );	
   143 	
   168 	
   144 	// Read in existing cache file.
   169 	// Read in existing cache file.
   145 	RFile cacheFile;
   170 	RFile cacheFile;
   146 	
   171 	
   147 	TInt err = cacheFile.Open( iFs, KInstFaildeApps, EFileStream|EFileRead );
   172 	TInt err = cacheFile.Open( iFs, 
       
   173 	                           KInstFaildeApps, 
       
   174 	                           EFileStream|EFileRead );
   148 	
   175 	
   149 	if ( err != KErrNone )
   176 	if ( err != KErrNone )
   150 		{
   177 		{
   151 		FLOG( _L("Daemon: No existing cache file to read.") );
   178 		FLOG( _L("Daemon: No existing cache file to read.") );
   152 		return; // No existing cache file to read.
   179 		return; // No existing cache file to read.
   172 	
   199 	
   173 	CleanupStack::PopAndDestroy(&cacheReadStream);
   200 	CleanupStack::PopAndDestroy(&cacheReadStream);
   174 	CleanupStack::PopAndDestroy(&cacheFile);
   201 	CleanupStack::PopAndDestroy(&cacheFile);
   175     }
   202     }
   176 
   203 
   177 
   204 // -----------------------------------------------------------------------
       
   205 // 
       
   206 // -----------------------------------------------------------------------
       
   207 //   
   178 void CInstallationFailedAppsCache::FlushToDiskL()
   208 void CInstallationFailedAppsCache::FlushToDiskL()
   179 	{
   209 	{
   180     FLOG( _L("Daemon: CInstallationFailedAppsCache::FlushToDiskL") );		
   210     FLOG( _L("Daemon: CInstallationFailedAppsCache::FlushToDiskL") );		
   181 	
   211 	
   182 	// Write to disk if new UID is added to array. 
   212 	// Write to disk if new UID is added to array. 
   183 	if ( iNewUID )
   213 	if ( iNewUID )
   184     	{
   214     	{
   185     	FLOG( _L("Daemon: Write cache to disk") );
   215     	FLOG( _L("Daemon: Write cache to disk") );
   186     	RFile cacheFile;
   216     	RFile cacheFile;
   187     	TInt err = cacheFile.Open( iFs, KInstFaildeApps, EFileStream|EFileWrite );
   217     	TInt err = cacheFile.Open( iFs, 
       
   218     	                           KInstFaildeApps, 
       
   219     	                           EFileStream|EFileWrite );
   188     	
   220     	
   189     	// If cache was not found, create cache file.
   221     	// If cache was not found, create cache file.
   190     	if ( err != KErrNone )
   222     	if ( err != KErrNone )
   191     		{
   223     		{
   192     		FLOG( _L("Daemon: Create cache file.") );
   224     		FLOG( _L("Daemon: Create cache file.") );
   193     	    User::LeaveIfError( cacheFile.Create( iFs, KInstFaildeApps, EFileStream|EFileWrite ) );
   225     	    User::LeaveIfError( cacheFile.Create( iFs, 
       
   226     	                                          KInstFaildeApps, 
       
   227     	                                          EFileStream|EFileWrite ) );
   194     		}
   228     		}
   195     	
   229     	
   196     	CleanupClosePushL(cacheFile);
   230     	CleanupClosePushL(cacheFile);
   197 
   231 
   198     	// Truncate file.
   232     	// Truncate file.