connectivitymodules/SeCon/services/pcd/src/sconqueue.cpp
changeset 40 b63e67867dcd
parent 37 74081e1a0272
equal deleted inserted replaced
39:9905f7d46607 40:b63e67867dcd
    20 
    20 
    21 #include "sconqueue.h"
    21 #include "sconqueue.h"
    22 #include "sconpcdconsts.h"
    22 #include "sconpcdconsts.h"
    23 #include "debug.h"
    23 #include "debug.h"
    24 #include <SWInstDefs.h> // installer errors
    24 #include <SWInstDefs.h> // installer errors
       
    25 #include <usif/usiferror.h>
    25 
    26 
    26 // ============================= MEMBER FUNCTIONS ===============================
    27 // ============================= MEMBER FUNCTIONS ===============================
    27 
    28 
    28 
    29 
    29 // -----------------------------------------------------------------------------
    30 // -----------------------------------------------------------------------------
   163 // -----------------------------------------------------------------------------
   164 // -----------------------------------------------------------------------------
   164 // CSConTaskQueue::CompleteTask( TInt aTask, TInt aError )
   165 // CSConTaskQueue::CompleteTask( TInt aTask, TInt aError )
   165 // Set the task to completed -mode
   166 // Set the task to completed -mode
   166 // -----------------------------------------------------------------------------
   167 // -----------------------------------------------------------------------------
   167 //
   168 //
   168 void CSConTaskQueue::CompleteTask( TInt aTask, TInt aError )
   169 TInt CSConTaskQueue::CompleteTask( TInt aTask, TInt aError )
   169     {
   170     {
   170     LOGGER_WRITE_1( "CSConTaskQueue::CompleteTask aError: %d", aError );
   171     LOGGER_WRITE_1( "CSConTaskQueue::CompleteTask aError: %d", aError );
       
   172     TInt ret(KErrNone);
   171     TInt index( KErrNotFound );
   173     TInt index( KErrNotFound );
   172     
   174     
   173     CSConTask* temp = new CSConTask();
   175     CSConTask* temp = new CSConTask();
       
   176     if (!temp)
       
   177         return KErrNoMemory;
       
   178     
   174     temp->iTaskId = aTask;
   179     temp->iTaskId = aTask;
   175     index = iQueue.Find( temp, CSConTaskQueue::Match );
   180     index = iQueue.Find( temp, CSConTaskQueue::Match );
   176     delete temp;
   181     delete temp;
   177     
   182     
   178     if ( index != KErrNotFound )
   183     if ( index != KErrNotFound )
   201             	LOGGER_WRITE("User cancelled the operation");
   206             	LOGGER_WRITE("User cancelled the operation");
   202             	iQueue[index]->SetCompleteValue( complete );
   207             	iQueue[index]->SetCompleteValue( complete );
   203             	progress = KSConCodeInstErrUserCancel;
   208             	progress = KSConCodeInstErrUserCancel;
   204             	break;
   209             	break;
   205             case SwiUI::KSWInstErrFileCorrupted:
   210             case SwiUI::KSWInstErrFileCorrupted:
       
   211             case KErrSifCorruptedPackage:
   206             	LOGGER_WRITE("File is corrupted");
   212             	LOGGER_WRITE("File is corrupted");
   207             	iQueue[index]->SetCompleteValue( complete );
   213             	iQueue[index]->SetCompleteValue( complete );
   208             	progress = KSConCodeInstErrFileCorrupted;
   214             	progress = KSConCodeInstErrFileCorrupted;
   209             	break;
   215             	break;
   210             case SwiUI::KSWInstErrInsufficientMemory:
   216             case SwiUI::KSWInstErrInsufficientMemory:
       
   217             case KErrSifNotEnoughSpace:
   211             	LOGGER_WRITE("Insufficient free memory in the drive to perform the operation");
   218             	LOGGER_WRITE("Insufficient free memory in the drive to perform the operation");
   212 	            iQueue[index]->SetCompleteValue( complete );
   219 	            iQueue[index]->SetCompleteValue( complete );
   213 	            progress = KSConCodeInstErrInsufficientMemory;	
   220 	            progress = KSConCodeInstErrInsufficientMemory;	
   214 	            break;
   221 	            break;
   215             case SwiUI::KSWInstErrPackageNotSupported:
   222             case SwiUI::KSWInstErrPackageNotSupported:
       
   223             case KErrSifUnsupportedSoftwareType:
   216             	LOGGER_WRITE("Installation of the package is not supported");
   224             	LOGGER_WRITE("Installation of the package is not supported");
   217             	iQueue[index]->SetCompleteValue( complete );
   225             	iQueue[index]->SetCompleteValue( complete );
   218             	progress = KSConCodeInstErrPackageNotSupported;
   226             	progress = KSConCodeInstErrPackageNotSupported;
   219             	break;
   227             	break;
   220             case SwiUI::KSWInstErrSecurityFailure:
   228             case SwiUI::KSWInstErrSecurityFailure:
   221             	LOGGER_WRITE("Package cannot be installed due to security error");
   229             	LOGGER_WRITE("Package cannot be installed due to security error");
   222             	iQueue[index]->SetCompleteValue( complete );
   230             	iQueue[index]->SetCompleteValue( complete );
   223             	progress = KSConCodeInstErrSecurityFailure;
   231             	progress = KSConCodeInstErrSecurityFailure;
   224             	break;
   232             	break;
   225             case SwiUI::KSWInstErrMissingDependency:
   233             case SwiUI::KSWInstErrMissingDependency:
       
   234             case KErrSifMissingDependencies:
   226             	LOGGER_WRITE("Package cannot be installed due to missing dependency");
   235             	LOGGER_WRITE("Package cannot be installed due to missing dependency");
   227             	iQueue[index]->SetCompleteValue( complete );
   236             	iQueue[index]->SetCompleteValue( complete );
   228             	progress = KSConCodeInstErrMissingDependency;
   237             	progress = KSConCodeInstErrMissingDependency;
   229             	break;
   238             	break;
   230             case SwiUI::KSWInstErrFileInUse:
   239             case SwiUI::KSWInstErrFileInUse:
   231             	LOGGER_WRITE("Mandatory file is in use and prevents the operation");
   240             	LOGGER_WRITE("Mandatory file is in use and prevents the operation");
   232             	iQueue[index]->SetCompleteValue( complete );
   241             	iQueue[index]->SetCompleteValue( complete );
   233             	progress = KSConCodeInstErrFileInUse;
   242             	progress = KSConCodeInstErrFileInUse;
   234             	break;
   243             	break;
   235             case SwiUI::KSWInstErrGeneralError:
   244             case SwiUI::KSWInstErrGeneralError:
       
   245             case KErrSifUnknown:
   236             	LOGGER_WRITE("Unknown error");
   246             	LOGGER_WRITE("Unknown error");
   237             	iQueue[index]->SetCompleteValue( complete );
   247             	iQueue[index]->SetCompleteValue( complete );
   238             	progress = KSConCodeInstErrGeneralError;
   248             	progress = KSConCodeInstErrGeneralError;
   239             	break;
   249             	break;
   240             case SwiUI::KSWInstErrNoRights:
   250             case SwiUI::KSWInstErrNoRights:
   260             case SwiUI::KSWInstUpgradeError:
   270             case SwiUI::KSWInstUpgradeError:
   261             	LOGGER_WRITE("The package is an invalid upgrade");
   271             	LOGGER_WRITE("The package is an invalid upgrade");
   262             	iQueue[index]->SetCompleteValue( complete );
   272             	iQueue[index]->SetCompleteValue( complete );
   263             	progress = KSConCodeInstUpgradeError;
   273             	progress = KSConCodeInstUpgradeError;
   264             	break;
   274             	break;
       
   275             	
       
   276             case KErrSifMissingBasePackage:
       
   277                 LOGGER_WRITE("KErrSifMissingBasePackage");
       
   278                 iQueue[index]->SetCompleteValue( complete );
       
   279                 progress = KSConCodeInstErrSifMissingBasePackage;
       
   280                 break;
       
   281             case KErrSifOverflow:
       
   282                 LOGGER_WRITE("KErrSifOverflow");
       
   283                 iQueue[index]->SetCompleteValue( complete );
       
   284                 progress = KSConCodeInstErrSifOverflow;
       
   285                 break;
       
   286             case KErrSifSameVersionAlreadyInstalled:
       
   287                 LOGGER_WRITE("KErrSifSameVersionAlreadyInstalled");
       
   288                 iQueue[index]->SetCompleteValue( complete );
       
   289                 progress = KSConCodeInstErrSifSameVersionAlreadyInstalled;
       
   290                 break;
       
   291             case KErrSifNewerVersionAlreadyInstalled:
       
   292                 LOGGER_WRITE("KErrSifNewerVersionAlreadyInstalled");
       
   293                 iQueue[index]->SetCompleteValue( complete );
       
   294                 progress = KSConCodeInstErrSifNewerVersionAlreadyInstalled;
       
   295                 break;
       
   296             case KErrSifAlreadyActivated:
       
   297                 LOGGER_WRITE("KErrSifAlreadyActivated");
       
   298                 iQueue[index]->SetCompleteValue( complete );
       
   299                 progress = KSConCodeInstErrSifAlreadyActivated;
       
   300                 break;
       
   301             case KErrSifAlreadyDeactivated:
       
   302                 LOGGER_WRITE("KErrSifAlreadyDeactivated");
       
   303                 iQueue[index]->SetCompleteValue( complete );
       
   304                 progress = KSConCodeInstErrSifAlreadyDeactivated;
       
   305                 break;
       
   306             case KErrSifBadComponentId:
       
   307                 LOGGER_WRITE("KErrSifBadComponentId");
       
   308                 iQueue[index]->SetCompleteValue( complete );
       
   309                 progress = KSConCodeInstErrSifBadComponentId;
       
   310                 break;
       
   311             case KErrSifBadInstallerConfiguration:
       
   312                 LOGGER_WRITE("KErrSifBadInstallerConfiguration");
       
   313                 iQueue[index]->SetCompleteValue( complete );
       
   314                 progress = KSConCodeInstErrSifBadInstallerConfiguration;
       
   315                 break;
       
   316             case KErrSifPackageCannotBeInstalledOnThisDevice:
       
   317                 LOGGER_WRITE("KErrSifPackageCannotBeInstalledOnThisDevice");
       
   318                 iQueue[index]->SetCompleteValue( complete );
       
   319                 progress = KSConCodeInstErrSifPackageCannotBeInstalledOnThisDevice;
       
   320                 break;
       
   321             case KErrSifUnsupportedLanguage:
       
   322                 LOGGER_WRITE("KErrSifUnsupportedLanguage");
       
   323                 iQueue[index]->SetCompleteValue( complete );
       
   324                 progress = KSConCodeInstErrSifUnsupportedLanguage;
       
   325                 break;
       
   326             case KErrScrWriteOperationInProgress:
       
   327                 LOGGER_WRITE("KErrScrWriteOperationInProgress");
       
   328                 iQueue[index]->SetCompleteValue( complete );
       
   329                 progress = KSConCodeInstErrScrWriteOperationInProgress;
       
   330                 break;
       
   331             case KErrScrReadOperationInProgress:
       
   332                 LOGGER_WRITE("KErrScrReadOperationInProgress");
       
   333                 iQueue[index]->SetCompleteValue( complete );
       
   334                 progress = KSConCodeInstErrScrReadOperationInProgress;
       
   335                 break;
       
   336             case KErrScrNoActiveTransaction:
       
   337                 LOGGER_WRITE("KErrScrNoActiveTransaction");
       
   338                 iQueue[index]->SetCompleteValue( complete );
       
   339                 progress = KSConCodeInstErrScrNoActiveTransaction;
       
   340                 break;
       
   341             case KErrScrUnsupportedLocale:
       
   342                 LOGGER_WRITE("KErrScrUnsupportedLocale");
       
   343                 iQueue[index]->SetCompleteValue( complete );
       
   344                 progress = KSConCodeInstErrScrUnsupportedLocale;
       
   345                 break;
   265             
   346             
   266             default :
   347             default :
   267                 iQueue[index]->SetCompleteValue( complete );
   348                 iQueue[index]->SetCompleteValue( complete );
   268                 if ( aError < KErrNone && aError >= KErrCorruptSurrogateFound )
   349                 if ( aError < KErrNone && aError >= KErrCorruptSurrogateFound )
   269                     {
   350                     {
   279                 break;
   360                 break;
   280             }
   361             }
   281             
   362             
   282         iQueue[index]->SetProgressValue( progress );
   363         iQueue[index]->SetProgressValue( progress );
   283         }
   364         }
       
   365     else
       
   366         {
       
   367         ret = KErrNotFound;
       
   368         }
   284     StartQueue();
   369     StartQueue();
       
   370     return ret;
   285     }
   371     }
   286     
   372     
   287 // -----------------------------------------------------------------------------
   373 // -----------------------------------------------------------------------------
   288 // CSConTaskQueue::SetTaskProgress( TInt aTask, TInt aProgressValue )
   374 // CSConTaskQueue::SetTaskProgress( TInt aTask, TInt aProgressValue )
   289 // Set the task progress value
   375 // Set the task progress value
   290 // -----------------------------------------------------------------------------
   376 // -----------------------------------------------------------------------------
   291 //
   377 //
   292 void CSConTaskQueue::SetTaskProgress( TInt aTask, TInt aProgressValue )
   378 TInt CSConTaskQueue::SetTaskProgress( TInt aTask, TInt aProgressValue )
   293     {
   379     {
       
   380     TInt ret( KErrNone );
   294     TInt index( KErrNotFound );
   381     TInt index( KErrNotFound );
   295 
   382 
   296     CSConTask* temp = new CSConTask();
   383     CSConTask* temp = new CSConTask();
   297     temp->iTaskId = aTask;
   384     if (temp)
   298     index = iQueue.Find( temp, CSConTaskQueue::Match );
   385         {
   299     delete temp;
   386         temp->iTaskId = aTask;
   300     
   387         index = iQueue.Find( temp, CSConTaskQueue::Match );
   301     if ( index != KErrNotFound )
   388         delete temp;
   302         {
   389         
   303         iQueue[index]->SetProgressValue( aProgressValue );
   390         if ( index != KErrNotFound )
   304         }
   391             {
       
   392             iQueue[index]->SetProgressValue( aProgressValue );
       
   393             }
       
   394         else
       
   395             {
       
   396             ret = KErrNotFound;
       
   397             }
       
   398         }
       
   399     else
       
   400         {
       
   401         ret = KErrNoMemory;
       
   402         }
       
   403     return ret;
   305     }
   404     }
   306     
   405     
   307 // -----------------------------------------------------------------------------
   406 // -----------------------------------------------------------------------------
   308 // CSConTaskQueue::GetTask( TInt aTaskId, CSConTask*& aTask )
   407 // CSConTaskQueue::GetTask( TInt aTaskId, CSConTask*& aTask )
   309 // Receives a specified task
   408 // Receives a specified task
   313     {
   412     {
   314     TInt ret( KErrNone );
   413     TInt ret( KErrNone );
   315     TInt index;
   414     TInt index;
   316     
   415     
   317     CSConTask* temp = new CSConTask();
   416     CSConTask* temp = new CSConTask();
   318     temp->iTaskId = aTaskId;
   417     if (temp)
   319     index = iQueue.Find( temp, CSConTaskQueue::Match );
   418         {
   320     delete temp;
   419         temp->iTaskId = aTaskId;
   321 
   420         index = iQueue.Find( temp, CSConTaskQueue::Match );
   322     if ( index != KErrNotFound )
   421         delete temp;
   323         {
   422     
   324         aTask = iQueue[index];
   423         if ( index != KErrNotFound )
       
   424             {
       
   425             aTask = iQueue[index];
       
   426             }
       
   427         else
       
   428             {
       
   429             ret = KErrNotFound;
       
   430             }
   325         }
   431         }
   326     else
   432     else
   327         {
   433         {
   328         ret = KErrNotFound;
   434         ret = KErrNoMemory;
   329         }
   435         }
   330     return ret;
   436     return ret;
   331     }
   437     }
   332     
   438     
   333 // -----------------------------------------------------------------------------
   439 // -----------------------------------------------------------------------------
   334 // CSConTaskQueue::RemoveTask( TInt aTask )
   440 // CSConTaskQueue::RemoveTask( TInt aTask )
   335 // Removes a task from the queue
   441 // Removes a task from the queue
   336 // -----------------------------------------------------------------------------
   442 // -----------------------------------------------------------------------------
   337 //
   443 //
   338 void CSConTaskQueue::RemoveTask( TInt aTask )
   444 TInt CSConTaskQueue::RemoveTask( TInt aTask )
   339     {
   445     {
       
   446     TInt ret(KErrNone);
   340     TInt index( KErrNotFound );
   447     TInt index( KErrNotFound );
   341     
   448     
   342     CSConTask* temp = new CSConTask();
   449     CSConTask* temp = new CSConTask();
   343     temp->iTaskId = aTask;
   450     if (temp)
   344     index = iQueue.Find( temp, CSConTaskQueue::Match );
   451         {
   345     delete temp;
   452         temp->iTaskId = aTask;
   346     
   453         index = iQueue.Find( temp, CSConTaskQueue::Match );
   347     if ( index != KErrNotFound ) 
   454         delete temp;
   348         {
   455         
   349         delete iQueue[index];
   456         if ( index != KErrNotFound ) 
   350         iQueue.Remove( index );
   457             {
   351         iQueue.Compress();
   458             delete iQueue[index];
   352         }
   459             iQueue.Remove( index );
   353     
   460             iQueue.Compress();
   354     if ( iQueue.Count() == 0 )
   461             }
   355         {
   462         else
   356         StopQueue();
   463             {
   357         iQueue.Reset();
   464             ret = KErrNotFound;
   358         }
   465             }
       
   466         
       
   467         if ( iQueue.Count() == 0 )
       
   468             {
       
   469             StopQueue();
       
   470             iQueue.Reset();
       
   471             }
       
   472         }
       
   473     else
       
   474         {
       
   475         ret = KErrNoMemory;
       
   476         }
       
   477     return ret;
   359     }
   478     }
   360     
   479     
   361 // -----------------------------------------------------------------------------
   480 // -----------------------------------------------------------------------------
   362 // CSConTaskQueue::CancelTask( TInt aTask, TBool aAllTasks )
   481 // CSConTaskQueue::CancelTask( TInt aTask, TBool aAllTasks )
   363 // Cancels a task
   482 // Cancels a task