iaupdate/IAD/api/client/src/iaupdatemanager.cpp
branchRCL_3
changeset 65 7333d7932ef7
parent 36 f9033e605ee2
child 66 8b7f4e561641
equal deleted inserted replaced
62:5cc91383ab1e 65:7333d7932ef7
    18 
    18 
    19 
    19 
    20 
    20 
    21 // INCLUDES
    21 // INCLUDES
    22 #include <eikenv.h>
    22 #include <eikenv.h>
    23 #include <iaupdateobserver.h>
       
    24 #include <iaupdateresult.h>
       
    25 #include <iaupdateparameters.h>
       
    26 
    23 
    27 #include "iaupdatemanager.h"
    24 #include "iaupdatemanager.h"
    28 #include "iaupdateclient.h"
    25 #include "iaupdateclient.h"
    29 #include "iaupdatedebug.h"
    26 #include "iaupdatedebug.h"
       
    27 
    30 
    28 
    31 
    29 
    32 // -----------------------------------------------------------------------------
    30 // -----------------------------------------------------------------------------
    33 // CIAUpdateManager::NewL
    31 // CIAUpdateManager::NewL
    34 // 
    32 // 
    49 // -----------------------------------------------------------------------------
    47 // -----------------------------------------------------------------------------
    50 //    
    48 //    
    51 CIAUpdateManager* CIAUpdateManager::NewLC( MIAUpdateObserver& aObserver )
    49 CIAUpdateManager* CIAUpdateManager::NewLC( MIAUpdateObserver& aObserver )
    52     {
    50     {
    53     IAUPDATE_TRACE("[IAUPDATE] CIAUpdateManager::NewLC() begin");
    51     IAUPDATE_TRACE("[IAUPDATE] CIAUpdateManager::NewLC() begin");
    54     CIAUpdateManager* self = new( ELeave ) CIAUpdateManager( aObserver );
    52     CIAUpdateManager* self = new( ELeave ) CIAUpdateManager();
    55     CleanupStack::PushL( self );
    53     CleanupStack::PushL( self );
    56     self->ConstructL();
    54     self->ConstructL( aObserver );
    57     IAUPDATE_TRACE("[IAUPDATE] CIAUpdateManager::NewLC() end");
    55     IAUPDATE_TRACE("[IAUPDATE] CIAUpdateManager::NewLC() end");
    58     return self;
    56     return self;
    59     }
    57     }
    60 
    58 
    61 // -----------------------------------------------------------------------------
    59 // -----------------------------------------------------------------------------
    62 // CIAUpdateManager::CIAUpdateManager
    60 // CIAUpdateManager::CIAUpdateManager
    63 // 
    61 // 
    64 // -----------------------------------------------------------------------------
    62 // -----------------------------------------------------------------------------
    65 //    
    63 //    
    66 CIAUpdateManager::CIAUpdateManager( MIAUpdateObserver& aObserver )
    64 CIAUpdateManager::CIAUpdateManager()
    67 : CActive( CActive::EPriorityStandard ),
       
    68   iObserver( aObserver ),
       
    69   iUpdateType( EIAUpdateIdle )
       
    70     {
    65     {
    71     IAUPDATE_TRACE("[IAUPDATE] CIAUpdateManager::CIAUpdateManager()");
    66     IAUPDATE_TRACE("[IAUPDATE] CIAUpdateManager::CIAUpdateManager()");
    72     iEikEnv = CEikonEnv::Static();
    67     iEikEnv = CEikonEnv::Static();
    73     }
    68     }
    74 
    69 
    75 // -----------------------------------------------------------------------------
    70 // -----------------------------------------------------------------------------
    76 // CIAUpdateManager::ConstructL()
    71 // CIAUpdateManager::ConstructL()
    77 // 
    72 // 
    78 // -----------------------------------------------------------------------------
    73 // -----------------------------------------------------------------------------
    79 //    
    74 //    
    80 void CIAUpdateManager::ConstructL()
    75 void CIAUpdateManager::ConstructL( MIAUpdateObserver& aObserver )
    81     {
    76     {
    82     IAUPDATE_TRACE("[IAUPDATE] CIAUpdateManager::ConstructL() begin");
    77     IAUPDATE_TRACE("[IAUPDATE] CIAUpdateManager::ConstructL() begin");
    83     CActiveScheduler::Add( this );
    78     iUpdateClient = new IAUpdateClient( aObserver );
       
    79     if ( !iUpdateClient )
       
    80         {
       
    81         User::Leave(KErrNoMemory);
       
    82         }
    84     if ( iEikEnv )
    83     if ( iEikEnv )
    85         {
    84         {
    86     	iEikEnv->AddForegroundObserverL(*this);
    85     	iEikEnv->AddForegroundObserverL(*this);
    87         }
    86         }
    88     IAUPDATE_TRACE("[IAUPDATE] CIAUpdateManager::ConstructL() end");
    87     IAUPDATE_TRACE("[IAUPDATE] CIAUpdateManager::ConstructL() end");
    94 // -----------------------------------------------------------------------------
    93 // -----------------------------------------------------------------------------
    95 //
    94 //
    96 CIAUpdateManager::~CIAUpdateManager()
    95 CIAUpdateManager::~CIAUpdateManager()
    97     {
    96     {
    98     IAUPDATE_TRACE("[IAUPDATE] CIAUpdateManager::~CIAUpdateManager() begin");
    97     IAUPDATE_TRACE("[IAUPDATE] CIAUpdateManager::~CIAUpdateManager() begin");
    99     delete iUpdateParameters;
    98     delete iUpdateClient;
   100     iUpdateParameters = NULL;
       
   101     // If an operation is still active, 
       
   102     // then DoCancel will cancel ongoing request
       
   103     Cancel();
       
   104     UpdateClient().Close();
       
   105     if ( iEikEnv )
    99     if ( iEikEnv )
   106         {
   100         {
   107     	iEikEnv->RemoveForegroundObserver(*this);
   101     	iEikEnv->RemoveForegroundObserver(*this);
   108         }
   102         }
   109     IAUPDATE_TRACE("[IAUPDATE] CIAUpdateManager::~CIAUpdateManager() end");
   103     IAUPDATE_TRACE("[IAUPDATE] CIAUpdateManager::~CIAUpdateManager() end");
   115 // -----------------------------------------------------------------------------
   109 // -----------------------------------------------------------------------------
   116 //
   110 //
   117 void CIAUpdateManager::CheckUpdates( const CIAUpdateParameters& aUpdateParameters )
   111 void CIAUpdateManager::CheckUpdates( const CIAUpdateParameters& aUpdateParameters )
   118     {
   112     {
   119     IAUPDATE_TRACE("[IAUPDATE] CIAUpdateManager::CheckUpdates() begin");
   113     IAUPDATE_TRACE("[IAUPDATE] CIAUpdateManager::CheckUpdates() begin");
   120     if ( BusyCheck() )
   114     
   121         {
   115     iUpdateClient->checkUpdates( aUpdateParameters );
   122         // An operation is already going on.
       
   123         // Do not continue with this new operation.
       
   124         // Only, inform the observer with the error code.
       
   125         // Notice that the callback is called synchronously here 
       
   126         // because there is no better way to do it. Asynchronous way 
       
   127         // would be really cumbersome because this object is already active. 
       
   128         // This error is users fault. Therefore we, could also panic here.
       
   129         Observer().CheckUpdatesComplete( KErrServerBusy, 0 );
       
   130         return;
       
   131         }
       
   132 
   116 
   133     // Reset result values because we are starting a new operation.
       
   134     ResetResults();
       
   135 
       
   136     //
       
   137     delete iUpdateParameters;
       
   138     iUpdateParameters = NULL;
       
   139     TInt error = KErrNone;
       
   140     TRAP(error,CopyUpdateParamsL( aUpdateParameters ) );
       
   141     if ( error == KErrNone )
       
   142         {
       
   143         // Set the update type. 
       
   144         // So, we know later in RunL what operation was requested.
       
   145         SetUpdateType( EIAUpdateStartServer );   
       
   146         error = UpdateClient().OpenToBackroundAsync( iStatus);
       
   147         }
       
   148  
       
   149     if ( error == KErrNone )
       
   150         {
       
   151         // Set this object active.
       
   152         // Because everything went ok, 
       
   153         // the operation will be handled asynchronously
       
   154         // and the service provider will inform us when the operation
       
   155         // is finished.
       
   156         SetActive();        
       
   157         }
       
   158     else
       
   159         {
       
   160         // Because we are going to activate this active object,
       
   161         // set the status pending.
       
   162         iStatus = KRequestPending;
       
   163         
       
   164         // An error occurred above. 
       
   165         // Therefore, the operation did not proceed any further.
       
   166         // Set this object active for asynchronous error handling.
       
   167         SetActive();
       
   168                 
       
   169         // Now, that everything is ready, just inform the active scheduler
       
   170         // that operation is finished. Pass the error code for the observer.
       
   171         TRequestStatus* status( &iStatus );
       
   172         User::RequestComplete( status, error );                
       
   173         }
       
   174     IAUPDATE_TRACE("[IAUPDATE] CIAUpdateManager::CheckUpdates() end");
   117     IAUPDATE_TRACE("[IAUPDATE] CIAUpdateManager::CheckUpdates() end");
   175     }
   118     }
   176 
   119 
   177 // -----------------------------------------------------------------------------
   120 // -----------------------------------------------------------------------------
   178 // CIAUpdateManager::ShowUpdates
   121 // CIAUpdateManager::ShowUpdates
   180 // -----------------------------------------------------------------------------
   123 // -----------------------------------------------------------------------------
   181 // 
   124 // 
   182 void CIAUpdateManager::ShowUpdates( const CIAUpdateParameters& aUpdateParameters )
   125 void CIAUpdateManager::ShowUpdates( const CIAUpdateParameters& aUpdateParameters )
   183     {
   126     {
   184     IAUPDATE_TRACE("[IAUPDATE] CIAUpdateManager::ShowUpdates() begin");
   127     IAUPDATE_TRACE("[IAUPDATE] CIAUpdateManager::ShowUpdates() begin");
   185     if ( BusyCheck() )
   128     iUpdateClient->showUpdates( aUpdateParameters );
   186          {
       
   187          // An update operation is already going on.
       
   188          // Do not continue with this new operation.
       
   189          // Only, inform the observer with the error code.
       
   190          // Notice that the callback is called synchronously here 
       
   191          // because there is no better way to do it. Asynchronous way 
       
   192          // would be really cumbersome because this object is already active. 
       
   193          // This error is users fault. Therefore we, could also panic here.
       
   194          Observer().UpdateComplete( KErrServerBusy, NULL );
       
   195          return;
       
   196          }
       
   197 
   129 
   198     // Reset result values because we are starting a new operation.
       
   199     ResetResults();
       
   200 
       
   201     // Set the update type. 
       
   202     // So, we know later in RunL what operation was requested.
       
   203     SetUpdateType( EIAUpdateUpdate );
       
   204     
       
   205     TInt error( UpdateClient().Open() );
       
   206     if ( error == KErrNone )
       
   207         {    
       
   208         error =
       
   209             UpdateClient().ShowUpdates( aUpdateParameters, 
       
   210                                         iSuccessCount,
       
   211                                         iFailCount,
       
   212                                         iCancelCount,  
       
   213                                         iStatus );
       
   214         }        
       
   215 
       
   216     if ( error == KErrNone )
       
   217         {
       
   218         // Set this object active.
       
   219         // Because everything went ok, 
       
   220         // the operation will be handled asynchronously
       
   221         // and the service provider will inform us when the operation
       
   222         // is finished.
       
   223         SetActive();        
       
   224         }
       
   225     else
       
   226         {
       
   227         // Because we are going to activate this active object,
       
   228         // set the status pending.
       
   229         iStatus = KRequestPending;
       
   230         
       
   231         // An error occurred above. 
       
   232         // Therefore, the operation did not proceed any further.
       
   233         // Set this object active for asynchronous error handling.
       
   234         SetActive();
       
   235                 
       
   236         // Now, that everything is ready, just inform the active scheduler
       
   237         // that operation is finished. Pass the error code for the observer.
       
   238         TRequestStatus* status( &iStatus );
       
   239         User::RequestComplete( status, error );                
       
   240         }
       
   241     IAUPDATE_TRACE("[IAUPDATE] CIAUpdateManager::ShowUpdates() end");
   130     IAUPDATE_TRACE("[IAUPDATE] CIAUpdateManager::ShowUpdates() end");
   242     }
   131     }
   243     
   132     
   244 // -----------------------------------------------------------------------------
   133 // -----------------------------------------------------------------------------
   245 // CIAUpdateManager::Update
   134 // CIAUpdateManager::Update
   247 // -----------------------------------------------------------------------------
   136 // -----------------------------------------------------------------------------
   248 // 
   137 // 
   249 void CIAUpdateManager::Update( const CIAUpdateParameters& /*aUpdateParameters*/ )
   138 void CIAUpdateManager::Update( const CIAUpdateParameters& /*aUpdateParameters*/ )
   250     {
   139     {
   251     IAUPDATE_TRACE("[IAUPDATE] CIAUpdateManager::Update() begin");
   140     IAUPDATE_TRACE("[IAUPDATE] CIAUpdateManager::Update() begin");
   252     Observer().UpdateComplete( KErrNotSupported, NULL );
   141 
   253     
   142     iUpdateClient->update();
   254     
   143    
   255     IAUPDATE_TRACE("[IAUPDATE] CIAUpdateManager::Update() begin");
   144     IAUPDATE_TRACE("[IAUPDATE] CIAUpdateManager::Update() begin");
   256     }
   145     }
   257 
   146 
   258 // -----------------------------------------------------------------------------
   147 // -----------------------------------------------------------------------------
   259 // CIAUpdateManager::UpdateQuery
   148 // CIAUpdateManager::UpdateQuery
   261 // -----------------------------------------------------------------------------
   150 // -----------------------------------------------------------------------------
   262 //   
   151 //   
   263 void CIAUpdateManager::UpdateQuery()
   152 void CIAUpdateManager::UpdateQuery()
   264     {
   153     {
   265     IAUPDATE_TRACE("[IAUPDATE] CIAUpdateManager::UpdateQuery() begin");
   154     IAUPDATE_TRACE("[IAUPDATE] CIAUpdateManager::UpdateQuery() begin");
   266     if ( BusyCheck() )
       
   267         {
       
   268         // An update operation is already going on.
       
   269         // Do not continue with this new operation.
       
   270         // Only, inform the observer with the error code.
       
   271         // Notice that the callback is called synchronously here 
       
   272         // because there is no better way to do it. Asynchronous way 
       
   273         // would be really cumbersome because this object is already active. 
       
   274         // This error is users fault. Therefore we, could also panic here.
       
   275         Observer().UpdateQueryComplete( KErrServerBusy, EFalse );
       
   276         return;
       
   277     }
       
   278 
       
   279     // Reset result values because we are starting a new operation.
       
   280     ResetResults();
       
   281 
       
   282     // Set the update type. 
       
   283     // So, we know later in RunL what operation was requested.
       
   284     SetUpdateType( EIAUpdateQuery );
       
   285     
       
   286     TInt error( UpdateClient().Open() );
       
   287     if ( error == KErrNone )
       
   288         {    
       
   289         error =
       
   290             UpdateClient().UpdateQuery( iUpdateNow, iStatus );
       
   291         }        
       
   292 
       
   293     if ( error == KErrNone )
       
   294         {
       
   295         // Set this object active.
       
   296         // Because everything went ok, 
       
   297         // the operation will be handled asynchronously
       
   298         // and the service provider will inform us when the operation
       
   299         // is finished.
       
   300         SetActive();        
       
   301         }
       
   302     else
       
   303         {
       
   304         // Because we are going to activate this active object,
       
   305         // set the status pending.
       
   306         iStatus = KRequestPending;
       
   307         
   155         
   308         // An error occurred above. 
   156     iUpdateClient->updateQuery();
   309         // Therefore, the operation did not proceed any further.
   157           
   310         // Set this object active for asynchronous error handling.
       
   311         SetActive();
       
   312                 
       
   313         // Now, that everything is ready, just inform the active scheduler
       
   314         // that operation is finished. Pass the error code for the observer.
       
   315         TRequestStatus* status( &iStatus );
       
   316         User::RequestComplete( status, error );                
       
   317         }
       
   318     IAUPDATE_TRACE("[IAUPDATE] CIAUpdateManager::UpdateQuery() end");
   158     IAUPDATE_TRACE("[IAUPDATE] CIAUpdateManager::UpdateQuery() end");
   319     }
   159     }
   320 
   160 
   321 // -----------------------------------------------------------------------------
       
   322 // CIAUpdateManager::DoCancel
       
   323 // 
       
   324 // -----------------------------------------------------------------------------
       
   325 //
       
   326 void CIAUpdateManager::DoCancel()
       
   327     {
       
   328     IAUPDATE_TRACE("[IAUPDATE] CIAUpdateManager::DoCancel() begin");
       
   329     UpdateClient().CancelAsyncRequest();
       
   330 
   161 
   331     // Reset result values because we are starting a new operation.
       
   332     ResetResults();
       
   333     IAUPDATE_TRACE("[IAUPDATE] CIAUpdateManager::DoCancel() end");
       
   334     }
       
   335 
       
   336 // -----------------------------------------------------------------------------
       
   337 // CIAUpdateManager::RunL
       
   338 // 
       
   339 // -----------------------------------------------------------------------------
       
   340 //
       
   341 void CIAUpdateManager::RunL()
       
   342     {
       
   343     IAUPDATE_TRACE("[IAUPDATE] CIAUpdateManager::RunL() begin");
       
   344     // Update operation error code
       
   345     TInt errorCode( iStatus.Int() );
       
   346     IAUPDATE_TRACE_1("[IAUPDATE] error code: %d", errorCode );
       
   347     if ( errorCode == KErrServerTerminated )
       
   348         {
       
   349     	// Handle is released if server is terminated
       
   350         UpdateClient().Close();
       
   351         }
       
   352 
       
   353     // Variables for operation and result information.
       
   354     TIAUpdateType updateType( UpdateType() );
       
   355     IAUPDATE_TRACE_1("[IAUPDATE] update type: %d", updateType );
       
   356     CIAUpdateResult* updateResult( NULL );
       
   357         
       
   358     if ( updateType == EIAUpdateUpdate )
       
   359         {
       
   360         // Update result object is required.
       
   361         // Notice that the ownership is transferred later.
       
   362         // So, this function does not need to delete updateResult object.
       
   363         TRAPD( trapError, updateResult = CIAUpdateResult::NewL() );
       
   364         if ( updateResult )
       
   365             {
       
   366             updateResult->SetSuccessCount( iSuccessCount );
       
   367             updateResult->SetFailCount( iFailCount );
       
   368             updateResult->SetCancelCount( iCancelCount );
       
   369             }
       
   370         else
       
   371             {
       
   372             // Something went wrong when creating update result object.
       
   373             // Update the error code accordingly.
       
   374             errorCode = trapError;
       
   375             }
       
   376         // Let's assume that connection is not needed anymore
       
   377         UpdateClient().Close();
       
   378         }
       
   379 
       
   380     
       
   381     // Inform that no operation is going on anymore.
       
   382     // This is required for busy check.
       
   383     SetUpdateType( EIAUpdateIdle );    
       
   384     
       
   385     // Use the update type of the ongoing operation to check what callback
       
   386     // function to call.
       
   387     switch ( updateType )
       
   388         {
       
   389         case EIAUpdateStartServer:
       
   390             if ( errorCode == KErrNone )
       
   391                 {
       
   392                 CheckUpdatesContinue();            
       
   393                 }
       
   394             else
       
   395                 {
       
   396                 UpdateClient().Close();
       
   397                 Observer().CheckUpdatesComplete( errorCode, 0);
       
   398                 }
       
   399             break;
       
   400             
       
   401         case EIAUpdateCheck:
       
   402             if ( iSuccessCount == 0 )
       
   403                 {
       
   404             	// Let's assume that connection is not needed anymore
       
   405                 UpdateClient().Close();
       
   406                 }
       
   407             IAUPDATE_TRACE_1("[IAUPDATE] success count: %d", iSuccessCount );
       
   408             Observer().CheckUpdatesComplete( errorCode, iSuccessCount );
       
   409             break;
       
   410 
       
   411         case EIAUpdateUpdate:
       
   412             // Notice that ownership of result object is transferred here.
       
   413             IAUPDATE_TRACE_3("[IAUPDATE] success count: %d failed count: %d cancelled count: %d", iSuccessCount, iFailCount, iCancelCount );
       
   414             Observer().UpdateComplete( errorCode, updateResult );
       
   415             break;
       
   416             
       
   417         case EIAUpdateQuery:
       
   418             if ( !iUpdateNow )
       
   419                 {
       
   420             	// Let's assume that connection is not needed anymore
       
   421                 UpdateClient().Close();
       
   422                 } 
       
   423             IAUPDATE_TRACE_1("[IAUPDATE] update now: %d", iUpdateNow );
       
   424             Observer().UpdateQueryComplete( errorCode, iUpdateNow );
       
   425             break;
       
   426          
       
   427         default:
       
   428             // Should not ever come here.
       
   429             break;
       
   430         }
       
   431         
       
   432     // Do not anything else than return after callback function is called because 
       
   433     // this instance can be deleted by a client in a callback function
       
   434     // 
       
   435     IAUPDATE_TRACE("[IAUPDATE] CIAUpdateManager::RunL() end");
       
   436     }
       
   437 
       
   438 // -----------------------------------------------------------------------------
       
   439 // CIAUpdateManager::ResetResults
       
   440 // 
       
   441 // -----------------------------------------------------------------------------
       
   442 //
       
   443 void CIAUpdateManager::ResetResults()
       
   444     {
       
   445     IAUPDATE_TRACE("[IAUPDATE] CIAUpdateManager::ResetResults() begin");
       
   446     // Set the member variables to their default values.
       
   447     iSuccessCount = 0;
       
   448     iFailCount = 0;
       
   449     iCancelCount = 0;
       
   450     iUpdateNow = EFalse;
       
   451     IAUPDATE_TRACE("[IAUPDATE] CIAUpdateManager::ResetResults() end");
       
   452     }
       
   453 
       
   454 // -----------------------------------------------------------------------------
       
   455 // CIAUpdateManager::BusyCheck
       
   456 // 
       
   457 // -----------------------------------------------------------------------------
       
   458 //
       
   459 TBool CIAUpdateManager::BusyCheck() const
       
   460     {
       
   461     IAUPDATE_TRACE("[IAUPDATE] CIAUpdateManager::BusyCheck()");
       
   462     if ( UpdateType() == EIAUpdateIdle )
       
   463         {
       
   464         return EFalse;
       
   465         }
       
   466     else
       
   467         {
       
   468         return ETrue; 
       
   469         }
       
   470     }
       
   471     
       
   472 // -----------------------------------------------------------------------------
       
   473 // CIAUpdateManager::UpdateClient 
       
   474 // 
       
   475 // -----------------------------------------------------------------------------
       
   476 //
       
   477 RIAUpdateClient& CIAUpdateManager::UpdateClient()
       
   478     {
       
   479     IAUPDATE_TRACE("[IAUPDATE] CIAUpdateManager::UpdateClient()");
       
   480     return iUpdateClient;
       
   481     }
       
   482 
       
   483 // -----------------------------------------------------------------------------
       
   484 // CIAUpdateManager::Observer
       
   485 // 
       
   486 // -----------------------------------------------------------------------------
       
   487 //
       
   488 MIAUpdateObserver& CIAUpdateManager::Observer() const
       
   489     {
       
   490     IAUPDATE_TRACE("[IAUPDATE] CIAUpdateManager::Observer()");
       
   491     return iObserver;
       
   492     }
       
   493 
       
   494 // -----------------------------------------------------------------------------
       
   495 // CIAUpdateManager::UpdateType
       
   496 // 
       
   497 // -----------------------------------------------------------------------------
       
   498 //
       
   499 CIAUpdateManager::TIAUpdateType CIAUpdateManager::UpdateType() const
       
   500     {
       
   501     IAUPDATE_TRACE("[IAUPDATE] CIAUpdateManager::UpdateType()");
       
   502     return iUpdateType;
       
   503     }
       
   504 
       
   505 
       
   506 // -----------------------------------------------------------------------------
       
   507 // CIAUpdateManager::SetUpdateType
       
   508 // 
       
   509 // -----------------------------------------------------------------------------
       
   510 // 
       
   511 void CIAUpdateManager::SetUpdateType( CIAUpdateManager::TIAUpdateType aUpdateType )
       
   512     {
       
   513     IAUPDATE_TRACE("[IAUPDATE] CIAUpdateManager::SetUpdateType() begin");
       
   514     IAUPDATE_TRACE_1("[IAUPDATE] update type: %d", aUpdateType );
       
   515     iUpdateType = aUpdateType;
       
   516     IAUPDATE_TRACE("[IAUPDATE] CIAUpdateManager::SetUpdateType() end");
       
   517     }
       
   518  
       
   519 // -----------------------------------------------------------------------------
   162 // -----------------------------------------------------------------------------
   520 // CIAUpdateManager::HandleGainingForeground
   163 // CIAUpdateManager::HandleGainingForeground
   521 //  iaupdate.exe is brought to foreground if visible request is ongoing
   164 //  iaupdate.exe is brought to foreground if visible request is ongoing
   522 // -----------------------------------------------------------------------------
   165 // -----------------------------------------------------------------------------
   523 //     
   166 //     
   524 void CIAUpdateManager::HandleGainingForeground()
   167 void CIAUpdateManager::HandleGainingForeground()
   525     {
   168     {
   526     IAUPDATE_TRACE("[IAUPDATE] CIAUpdateManager::HandleGainingForeground() begin");
   169     IAUPDATE_TRACE("[IAUPDATE] CIAUpdateManager::HandleGainingForeground() begin");
   527 	iUpdateClient.BroughtToForeground();   
   170 	//iUpdateClient->broughtToForeground();   
   528 	IAUPDATE_TRACE("[IAUPDATE] CIAUpdateManager::HandleGainingForeground() end");  
   171 	IAUPDATE_TRACE("[IAUPDATE] CIAUpdateManager::HandleGainingForeground() end");  
   529     }
   172     }
   530 
   173 
   531 // -----------------------------------------------------------------------------
   174 // -----------------------------------------------------------------------------
   532 // CIAUpdateManager::HandleLosingForeground
   175 // CIAUpdateManager::HandleLosingForeground
   535 // 
   178 // 
   536 void CIAUpdateManager::HandleLosingForeground()
   179 void CIAUpdateManager::HandleLosingForeground()
   537     {
   180     {
   538     }
   181     }
   539 
   182 
   540 // -----------------------------------------------------------------------------
       
   541 // CIAUpdateManager::CheckUpdatesContinue
       
   542 // 
       
   543 // -----------------------------------------------------------------------------
       
   544 // 
       
   545 void CIAUpdateManager::CheckUpdatesContinue()
       
   546     {
       
   547     IAUPDATE_TRACE("[IAUPDATE] CIAUpdateManager::CheckUpdatesContinue() begin");
       
   548     TInt error = KErrNone;
       
   549     SetUpdateType( EIAUpdateCheck );
       
   550     error = UpdateClient().ConnectToApp();
       
   551     if ( error == KErrNone )
       
   552         {
       
   553         error = UpdateClient().CheckUpdates( *iUpdateParameters, 
       
   554                                              iSuccessCount, 
       
   555                                              iStatus ); 
       
   556         }
       
   557     
       
   558     if ( error == KErrNone )
       
   559         {
       
   560         // Set this object active.
       
   561         // Because everything went ok, 
       
   562         // the operation will be handled asynchronously
       
   563         // and the service provider will inform us when the operation
       
   564         // is finished.
       
   565         SetActive();        
       
   566         }
       
   567     else
       
   568         {
       
   569         // Because we are going to activate this active object,
       
   570         // set the status pending.
       
   571         iStatus = KRequestPending;
       
   572         
       
   573         // An error occurred above. 
       
   574         // Therefore, the operation did not proceed any further.
       
   575         // Set this object active for asynchronous error handling.
       
   576         SetActive();
       
   577                 
       
   578         // Now, that everything is ready, just inform the active scheduler
       
   579         // that operation is finished. Pass the error code for the observer.
       
   580         TRequestStatus* status( &iStatus );
       
   581         User::RequestComplete( status, error );                
       
   582         }
       
   583     IAUPDATE_TRACE("[IAUPDATE] CIAUpdateManager::CheckUpdatesContinue() end");
       
   584     }
       
   585 
       
   586 // -----------------------------------------------------------------------------
       
   587 // CIAUpdateManager::CopyUpdateParamsL
       
   588 // 
       
   589 // -----------------------------------------------------------------------------
       
   590 // 
       
   591 void CIAUpdateManager::CopyUpdateParamsL( const CIAUpdateParameters& aUpdateParameters )
       
   592     {
       
   593     IAUPDATE_TRACE("[IAUPDATE] CIAUpdateManager::CopyUpdateParamsL() begin");
       
   594     iUpdateParameters = CIAUpdateParameters::NewL();
       
   595     iUpdateParameters->SetCommandLineArgumentsL( aUpdateParameters.CommandLineArguments() );
       
   596     iUpdateParameters->SetCommandLineExecutableL( aUpdateParameters.CommandLineExecutable() );
       
   597     iUpdateParameters->SetImportance( aUpdateParameters.Importance() );
       
   598     iUpdateParameters->SetRefresh( aUpdateParameters.Refresh() );
       
   599     iUpdateParameters->SetSearchCriteriaL( aUpdateParameters.SearchCriteria() );
       
   600     iUpdateParameters->SetShowProgress( aUpdateParameters.ShowProgress() );
       
   601     iUpdateParameters->SetType( aUpdateParameters.Type() );
       
   602     iUpdateParameters->SetUid( aUpdateParameters.Uid() );
       
   603     IAUPDATE_TRACE("[IAUPDATE] CIAUpdateManager::CopyUpdateParamsL() end");
       
   604     }
       
   605 
   183 
   606 
   184 
   607 
   185 
       
   186 
       
   187