iaupdate/IAD/firmwareupdate/src/iaupdatefwupdatehandler.cpp
changeset 77 d1838696558c
parent 45 e466b0bdc5ac
--- a/iaupdate/IAD/firmwareupdate/src/iaupdatefwupdatehandler.cpp	Tue Sep 28 14:48:39 2010 +0300
+++ b/iaupdate/IAD/firmwareupdate/src/iaupdatefwupdatehandler.cpp	Thu Oct 14 14:11:30 2010 +0300
@@ -63,25 +63,11 @@
     {
     TInt err = RProperty::Delete(KPSUidNSmlDMSyncApp,KNSmlCurrentFotaUpdateAppName);
     delete iFotaModel;
-    delete iDMEngine;
+    delete iFWSyncAppEngine;
     }
 
 
 // -----------------------------------------------------------------------------
-//  CIAUpdateFWUpdateHandler::FirmWareUpdatewithNSU()
-// -----------------------------------------------------------------------------
-//      
-EXPORT_C void CIAUpdateFWUpdateHandler::FirmWareUpdatewithNSU()
-    {  
-    iRequest = ENSU;
-    iStatus = KRequestPending;
-    TRequestStatus* status = &iStatus;
-
-    SetActive();
-    User::RequestComplete( status, KErrNone );
-    }
-
-// -----------------------------------------------------------------------------
 //  CIAUpdateFWUpdateHandler::IsDMSupportAvailableL()
 // -----------------------------------------------------------------------------
 //
@@ -94,9 +80,9 @@
 //  CIAUpdateFWUpdateHandler::FirmWareUpdatewithFOTA()
 // -----------------------------------------------------------------------------
 //
-EXPORT_C void CIAUpdateFWUpdateHandler::FirmWareUpdatewithFOTA()
+EXPORT_C void CIAUpdateFWUpdateHandler::FirmWareUpdatewithFOTA( MIAUpdateFWUpdateObserver* aObserver )
     {
-    iRequest = EFOTA;
+    iObserver = aObserver;
     iStatus = KRequestPending;
     TRequestStatus* status = &iStatus;
 
@@ -122,7 +108,7 @@
 void CIAUpdateFWUpdateHandler::ConstructL()
     {
     iFotaModel = CIAUpdateFWFotaModel::NewL();    
-    iDMEngine = CIAUpdateFWSyncAppEngine::NewL( iFotaModel );
+    iFWSyncAppEngine = CIAUpdateFWSyncAppEngine::NewL( iFotaModel );
     }
 
 
@@ -132,70 +118,57 @@
 //
 void CIAUpdateFWUpdateHandler::RunL()
     {
-    switch ( iRequest )
-        {
-        case ENSU:
-            {          
-                      
-            break;
-            }
-        case EFOTA:
-            {
-            //check whether FOTA engine is available at the moment
-            TBool isDmActive = EFalse;
+    //check whether FOTA engine is available at the moment
+    TBool isDmActive = EFalse;
 
-            TInt fotamodelstate = iFotaModel->GetCurrentFwUpdState();
+    TInt fotamodelstate = iFotaModel->GetCurrentFwUpdState();
             
-            FLOG_NUM( "[IAUPDATEFW] fota status = %d", fotamodelstate );   
+    FLOG_NUM( "[IAUPDATEFW] fota status = %d", fotamodelstate );   
             
-            if ( fotamodelstate != RFotaEngineSession::EIdle )
-                { 
-                //if status is downloadcomplete or startingupdate
-                //still allow user to continue
-                if ( ( fotamodelstate != RFotaEngineSession::EDownloadComplete ) && ( fotamodelstate != RFotaEngineSession::EStartingUpdate ) )
-                    {
-		                //if download is suspended, try to resume it.
-		                if ( fotamodelstate == RFotaEngineSession::EDownloadProgressing)
-		                    {
-		                    TInt result = iFotaModel->TryResumeFwUpdDownload();
-						            FLOG_NUM( "[IAUPDATEFW] TryResumeFwUpdDownload result  = %d", result );   
-		                    }
-                    //anyway, DM is in use
-                    isDmActive = ETrue;
-                    }
-                }
-                     
-            if ( isDmActive )
+    if ( fotamodelstate != RFotaEngineSession::EIdle )
+        { 
+        //if status is downloadcomplete or startingupdate
+        //still allow user to continue
+        if ( ( fotamodelstate != RFotaEngineSession::EDownloadComplete ) && ( fotamodelstate != RFotaEngineSession::EStartingUpdate ) )
+            {
+            //if download is suspended, try to resume it.
+            if ( fotamodelstate == RFotaEngineSession::EDownloadProgressing)
                 {
-                FLOG( "[IAUPDATEFW] CIAUpdateFWUpdateHandler::RunL DM is activated" );   
-                return;
-                }
-            
-            TInt profileId( KErrNotFound );
-                 
-            profileId = iFotaModel->DefaultFotaProfileIdL();
-            
-            if (KErrNotFound != profileId)          
-                {               
-                // Define the key KNSmlCurrentFotaUpdateAppName
-                TInt err = RProperty::Define( KPSUidNSmlDMSyncApp,
-                                              KNSmlCurrentFotaUpdateAppName,
-                                              RProperty::EInt);
-                
-                RProperty::Set(KPSUidNSmlDMSyncApp,KNSmlCurrentFotaUpdateAppName,1 );
-                
-                iFotaModel->EnableFwUpdRequestL( profileId );
-                StartSyncL( profileId, EFalse );
-                }
-            else
-                {               
-                FLOG( "[IAUPDATEFW] CIAUpdateFWUpdateHandler::RunL no DM profile available!" );                      
-                }            
-            }  
-            break;
+	            TInt result = iFotaModel->TryResumeFwUpdDownload();
+	            FLOG_NUM( "[IAUPDATEFW] TryResumeFwUpdDownload result  = %d", result );   
+		        }
+            //anyway, DM is in use
+            isDmActive = ETrue;
             }
         }
-
+                
+    if ( isDmActive )
+        {
+        FLOG( "[IAUPDATEFW] CIAUpdateFWUpdateHandler::RunL DM is activated" );   
+        return;
+        }
+            
+    TInt profileId( KErrNotFound );
+                 
+    profileId = iFotaModel->DefaultFotaProfileIdL();
+            
+    if (KErrNotFound != profileId)          
+        {               
+        // Define the key KNSmlCurrentFotaUpdateAppName
+        TInt err = RProperty::Define( KPSUidNSmlDMSyncApp,
+                                      KNSmlCurrentFotaUpdateAppName,
+                                      RProperty::EInt);
+                
+        RProperty::Set(KPSUidNSmlDMSyncApp,KNSmlCurrentFotaUpdateAppName,1 );
+                
+        iFotaModel->EnableFwUpdRequestL( profileId );
+        StartSyncL( profileId, EFalse );
+        }
+    else
+        {               
+        FLOG( "[IAUPDATEFW] CIAUpdateFWUpdateHandler::RunL no DM profile available!" );                      
+        }            
+    }  
 
 // -----------------------------------------------------------------------------
 //  CIAUpdateFWUpdateHandler::DoCancel()
@@ -205,16 +178,7 @@
     {
     }
 
-
-// -----------------------------------------------------------------------------
-//  CIAUpdateFWUpdateHandler::ShowDialogL()
-// -----------------------------------------------------------------------------
-//
-void CIAUpdateFWUpdateHandler::ShowDialogL(TDesC& /*aText*/, TDesC& /*aHeading*/ )
-    {  
-    
-    }
-        
+       
 
 // -----------------------------------------------------------------------------
 //  CIAUpdateFWUpdateHandler::StartSyncL()
@@ -225,7 +189,7 @@
     const TBool aUseFotaProgressNote ) // = EFalse
     {
     CIAUpdateFWSyncProfile* profile = 
-                iDMEngine->OpenProfileL( aProfileId, ESmlOpenReadWrite );
+            iFWSyncAppEngine->OpenProfileL( aProfileId, ESmlOpenReadWrite );
 
     TInt connectionBearer = profile->BearerType();
     
@@ -248,23 +212,12 @@
         profile->SaveL(); 
         }
              
-    iDMEngine->CloseProfile();      
-
-    TRAPD( error, iDMEngine->SynchronizeL( serverName, 
-                                           aProfileId, 
-                                           connectionBearer,
-                                           aUseFotaProgressNote ) );
-
-    if (error != KErrNone)
-        {
-
-        //CAknInformationNote* queryDialog = new (ELeave) CAknInformationNote;
-        
-        //HBufC* error = HBufC::NewL(20);
-        //          TPtr ptrerror = error->Des();
-        //          ptrerror.Copy(_L("sync problem")); 
-        //queryDialog->ExecuteLD( *error  );
-        }
+    iFWSyncAppEngine->CloseProfile();    
+    iFWSyncAppEngine->SetObserver( iObserver );
+    TRAP_IGNORE( iFWSyncAppEngine->SynchronizeL( serverName, 
+                                                 aProfileId, 
+                                                 connectionBearer,
+                                                 aUseFotaProgressNote ) );
     }
 
 //EOF