fotaapplication/fotaserver/src/FotaServer.cpp
changeset 73 ae69c2e8bc34
parent 54 085438c28042
equal deleted inserted replaced
71:d2517372cc44 73:ae69c2e8bc34
    13  *
    13  *
    14  * Description:   Fota server update and download functionality 
    14  * Description:   Fota server update and download functionality 
    15  *
    15  *
    16  */
    16  */
    17 // INCLUDE FILES
    17 // INCLUDE FILES
       
    18 #include <eikenv.h>
    18 #include <apgtask.h>
    19 #include <apgtask.h>
    19 #include <apgwgnam.h>
    20 #include <apgwgnam.h>
    20 #include <schtime.h>
    21 #include <schtime.h>
    21 #include <csch_cli.h>
    22 #include <csch_cli.h>
    22 #include <e32property.h>
    23 #include <e32property.h>
   197     FLOG(_L("CFotaServer::StartDownloadDialog >>"));
   198     FLOG(_L("CFotaServer::StartDownloadDialog >>"));
   198     //The dialog should not timeout here.
   199     //The dialog should not timeout here.
   199     if (!iFullScreenDialog)
   200     if (!iFullScreenDialog)
   200         {
   201         {
   201         //ConstructApplicationUI(ETrue);
   202         //ConstructApplicationUI(ETrue);
   202         iFullScreenDialog = new FotaFullscreenDialog(this);
   203         iFullScreenDialog = new HbFotaFullscreenDialog(this);
   203         }
   204         }
   204 
   205 
   205     iFullScreenDialog->SetSoftwareDetails(aSize, aVersion, aName);
   206     iFullScreenDialog->setSoftwareDetails(aSize, aVersion, aName);
   206 
   207 
   207     iFullScreenDialog->SetWarningDetails(EHbFotaDownload);
   208     iFullScreenDialog->setWarningDetails(EHbFotaDownload);
   208 
   209 
   209     TBool postpone = IsUserPostponeAllowed();
   210     TBool postpone = IsUserPostponeAllowed();
   210     if (!postpone)
   211     if (!postpone)
   211         {
   212         {
   212         FLOG(_L("Disabling option to resume later!"));
   213         FLOG(_L("Disabling option to resume later!"));
   213         iFullScreenDialog->DisableRSK(ETrue);
   214         iFullScreenDialog->disableRSK(ETrue);
   214         }
   215         }
   215     
   216     
   216     FLOG(_L("CFotaServer::StartDownloadDialog <<"));
   217     FLOG(_L("CFotaServer::StartDownloadDialog <<"));
   217     }
   218     }
   218 
   219 
   227                 iPackageState.iPkgVersion);
   228                 iPackageState.iPkgVersion);
   228         StartDownloadDialog(name, version, iPackageState.iPkgSize);
   229         StartDownloadDialog(name, version, iPackageState.iPkgSize);
   229         ConstructApplicationUI(ETrue);
   230         ConstructApplicationUI(ETrue);
   230         }
   231         }
   231 
   232 
   232     iFullScreenDialog->UpdateProgressBar(aProgress);
   233     iFullScreenDialog->updateProgressBar(aProgress);
   233     FLOG(_L("CFotaServer::UpdateDownloadDialog <<"));
   234     FLOG(_L("CFotaServer::UpdateDownloadDialog <<"));
   234     }
   235     }
   235 
   236 
   236 void CFotaServer::ShowDialogL(TFwUpdNoteTypes adialogid)
   237 void CFotaServer::ShowDialogL(TFwUpdNoteTypes adialogid)
   237     {
   238     {
   242         FLOG(_L("Deleting the open device dialog!!"));
   243         FLOG(_L("Deleting the open device dialog!!"));
   243         iNotifier->Cancel();
   244         iNotifier->Cancel();
   244         }
   245         }
   245 
   246 
   246     ServerCanShut(EFalse);
   247     ServerCanShut(EFalse);
   247     iDialogId = (TInt) adialogid;
       
   248 
   248 
   249     iNotifParams = CHbSymbianVariantMap::NewL();
   249     iNotifParams = CHbSymbianVariantMap::NewL();
   250 
   250 
   251     HBufC* keyDialog = HBufC::NewL(10);
   251     HBufC* keyDialog = HBufC::NewL(10);
   252     CleanupStack::PushL(keyDialog);
   252     CleanupStack::PushL(keyDialog);
   268     CleanupStack::PushL(keyParam4);
   268     CleanupStack::PushL(keyParam4);
   269     *keyParam4 = KKeyParam4;
   269     *keyParam4 = KKeyParam4;
   270 
   270 
   271     CHbSymbianVariant* dialogId = CHbSymbianVariant::NewL(&adialogid,
   271     CHbSymbianVariant* dialogId = CHbSymbianVariant::NewL(&adialogid,
   272             CHbSymbianVariant::EInt);
   272             CHbSymbianVariant::EInt);
   273     CleanupStack::PushL(dialogId);
   273     //CleanupStack::PushL(dialogId);
   274     iNotifParams->Add(*keyDialog, dialogId);
   274     iNotifParams->Add(*keyDialog, dialogId);
   275 
       
   276     if (!iNotifier)
       
   277         iNotifier = CFotaDownloadNotifHandler::NewL(this);
       
   278 
   275 
   279     switch (adialogid)
   276     switch (adialogid)
   280         {
   277         {
   281         case EFwUpdNotEnoughBattery:
   278         case EFwUpdNotEnoughBattery:
   282         case EFwUpdDeviceBusy:
   279         case EFwUpdDeviceBusy:
   289         case EFwUpdResumeDownload:
   286         case EFwUpdResumeDownload:
   290             {
   287             {
   291             FLOG(_L("CFotaServer::EFwUpdResumeUpdate / EFwUpdResumeDownload"));
   288             FLOG(_L("CFotaServer::EFwUpdResumeUpdate / EFwUpdResumeDownload"));
   292             CHbSymbianVariant* param1Val = CHbSymbianVariant::NewL(
   289             CHbSymbianVariant* param1Val = CHbSymbianVariant::NewL(
   293                     &iPackageState.iPkgSize, CHbSymbianVariant::EInt);
   290                     &iPackageState.iPkgSize, CHbSymbianVariant::EInt);
   294             CleanupStack::PushL(param1Val);
   291             //CleanupStack::PushL(param1Val);
   295             iNotifParams->Add(*keyParam1, param1Val);
   292             iNotifParams->Add(*keyParam1, param1Val);
   296             TBuf16<KFotaMaxPkgNameLength>    temp1;
   293             TBuf16<KFotaMaxPkgNameLength>    temp1;
   297             temp1.Copy(iPackageState.iPkgVersion);
   294             temp1.Copy(iPackageState.iPkgVersion);
   298             CHbSymbianVariant* param2Val = CHbSymbianVariant::NewL(
   295             CHbSymbianVariant* param2Val = CHbSymbianVariant::NewL(
   299                     //&iPackageState.iPkgVersion, CHbSymbianVariant::EDes);
   296                     //&iPackageState.iPkgVersion, CHbSymbianVariant::EDes);
   300                     &temp1, CHbSymbianVariant::EDes);
   297                     &temp1, CHbSymbianVariant::EDes);
   301             CleanupStack::PushL(param2Val);
   298             //CleanupStack::PushL(param2Val);
   302             iNotifParams->Add(*keyParam2, param2Val);
   299             iNotifParams->Add(*keyParam2, param2Val);
   303             TBuf16<KFotaMaxPkgNameLength>    temp2;
   300             TBuf16<KFotaMaxPkgNameLength>    temp2;
   304             temp2.Copy(iPackageState.iPkgName);
   301             temp2.Copy(iPackageState.iPkgName);
   305             CHbSymbianVariant* param3Val = CHbSymbianVariant::NewL(
   302             CHbSymbianVariant* param3Val = CHbSymbianVariant::NewL(
   306                     &temp2, CHbSymbianVariant::EDes);
   303                     &temp2, CHbSymbianVariant::EDes);
   307             CleanupStack::PushL(param3Val);
   304             //CleanupStack::PushL(param3Val);
   308             iNotifParams->Add(*keyParam3, param3Val);
   305             iNotifParams->Add(*keyParam3, param3Val);
   309             TBool postpone = IsUserPostponeAllowed();
   306             TBool postpone = IsUserPostponeAllowed();
   310             CHbSymbianVariant* param4Val = CHbSymbianVariant::NewL(&postpone,
   307             CHbSymbianVariant* param4Val = CHbSymbianVariant::NewL(&postpone,
   311                     CHbSymbianVariant::EInt);
   308                     CHbSymbianVariant::EInt);
   312             CleanupStack::PushL(param4Val);
   309             //CleanupStack::PushL(param4Val);
   313             iNotifParams->Add(*keyParam4, param4Val);
   310             iNotifParams->Add(*keyParam4, param4Val);
   314             iNotifier->LaunchNotifierL(iNotifParams, adialogid);
   311             iNotifier->LaunchNotifierL(iNotifParams, adialogid);
   315             CleanupStack::PopAndDestroy(4);
   312             //CleanupStack::PopAndDestroy(4);
   316 
   313 
   317             }
   314             }
   318             break;
   315             break;
   319 
   316 
   320         default:
   317         default:
   322             FLOG(_L("CFotaServer::default"));
   319             FLOG(_L("CFotaServer::default"));
   323             //Do nothing
   320             //Do nothing
   324             }
   321             }
   325             break;
   322             break;
   326         }
   323         }
   327     CleanupStack::PopAndDestroy(6);
   324     CleanupStack::PopAndDestroy(5);
   328     FLOG(_L("CFotaServer::ShowDialogL >>"));
   325     FLOG(_L("CFotaServer::ShowDialogL >>"));
   329 
   326 
   330     }
   327     }
   331 
   328 
   332 void CFotaServer::HandleDialogResponse(int response, TInt aDialogId)
   329 void CFotaServer::HandleDialogResponse(int response, TInt aDialogId)
   408             {
   405             {
   409             //Do nothing
   406             //Do nothing
   410             }
   407             }
   411             break;
   408             break;
   412         }
   409         }
   413     /*
   410 
   414      if(iNotifParams)
       
   415      {
       
   416      delete iNotifParams; iNotifParams = NULL;
       
   417      }
       
   418      
       
   419      if(iNotifier)
       
   420      {
       
   421      delete iNotifier; iNotifier = NULL;
       
   422      }*/
       
   423     iDialogId = 0;
       
   424     FLOG(_L("CFotaServer::HandleDialogResponse<<"));
   411     FLOG(_L("CFotaServer::HandleDialogResponse<<"));
   425     }
   412     }
   426 
   413 
   427 void CFotaServer::SetServerActive(TBool aValue)
   414 void CFotaServer::SetServerActive(TBool aValue)
   428     {
   415     {
   451 
   438 
   452     if (!iFullScreenDialog)
   439     if (!iFullScreenDialog)
   453         {
   440         {
   454         const QString  ver =   QString::fromUtf8( reinterpret_cast<const char*> (iPackageState.iPkgVersion.Ptr()), iPackageState.iPkgVersion.Length());
   441         const QString  ver =   QString::fromUtf8( reinterpret_cast<const char*> (iPackageState.iPkgVersion.Ptr()), iPackageState.iPkgVersion.Length());
   455         const QString name =   QString::fromUtf8( reinterpret_cast<const char*> (iPackageState.iPkgName.Ptr()), iPackageState.iPkgName.Length());
   442         const QString name =   QString::fromUtf8( reinterpret_cast<const char*> (iPackageState.iPkgName.Ptr()), iPackageState.iPkgName.Length());
   456         iFullScreenDialog = new FotaFullscreenDialog(this);
   443         iFullScreenDialog = new HbFotaFullscreenDialog(this);
   457 
   444 
   458         iFullScreenDialog->SetSoftwareDetails(iPackageState.iPkgSize, ver, name);
   445         iFullScreenDialog->setSoftwareDetails(iPackageState.iPkgSize, ver, name);
   459         iFullScreenDialog->SetWarningDetails(EHbFotaDownload);
   446         iFullScreenDialog->setWarningDetails(EHbFotaDownload);
   460         ConstructApplicationUI(ETrue);
   447         ConstructApplicationUI(ETrue);
   461         }
   448         }
   462 
   449 
   463     if (aType == EHbFotaUpdate)
   450     if (aType == EHbFotaUpdate)
   464         {
   451         {
   465         iFullScreenDialog->UpdateProgressBar(100);
   452         iFullScreenDialog->updateProgressBar(100);
   466         TBool postpone = IsUserPostponeAllowed();
   453         TBool postpone = IsUserPostponeAllowed();
   467         if (!postpone)
   454         if (!postpone)
   468             {
   455             {
   469             FLOG(_L("Disabling option to resume later!"));
   456             FLOG(_L("Disabling option to resume later!"));
   470             iFullScreenDialog->DisableRSK(ETrue);
   457             iFullScreenDialog->disableRSK(ETrue);
   471             }
   458             }
   472 
   459 
   473         iFullScreenDialog->ShowUpdateDialog();
   460         iFullScreenDialog->showUpdateDialog();
   474         }
   461         }
   475     else if (aType == EHbFotaLowBattery)
   462     else if (aType == EHbFotaLowBattery)
   476         {
   463         {
   477         iFullScreenDialog->UpdateProgressBar(100);
   464         iFullScreenDialog->updateProgressBar(100);
   478         iFullScreenDialog->DisableRSK(EFalse);
   465         iFullScreenDialog->disableRSK(EFalse);
   479         iFullScreenDialog->SetWarningDetails(EHbFotaLowBattery);
   466         iFullScreenDialog->setWarningDetails(EHbFotaLowBattery);
   480         }
   467         }
   481 
   468 
   482     FLOG(_L("CFotaServer::ShowFullScreenDialog <<"));
   469     FLOG(_L("CFotaServer::ShowFullScreenDialog <<"));
   483     }
   470     }
   484 
   471 
   605     CServer2(EPriorityStandard, EUnsharableSessions) /*CServer2(0)*/,
   592     CServer2(EPriorityStandard, EUnsharableSessions) /*CServer2(0)*/,
   606             iDatabase(0), iInitialized(EFalse), iDownloader(0), iUpdater(0),
   593             iDatabase(0), iInitialized(EFalse), iDownloader(0), iUpdater(0),
   607             iDownloadFinalizer(0), iUpdateFinalizer(0), iTimedExecuteResultFile(0), iTimedSMLSessionClose(0),
   594             iDownloadFinalizer(0), iUpdateFinalizer(0), iTimedExecuteResultFile(0), iTimedSMLSessionClose(0),
   608             iAppShutter(0), iMonitor(NULL), iSyncMLAttempts(0), iSyncJobId(-1),iRetryingGASend(EFalse),
   595             iAppShutter(0), iMonitor(NULL), iSyncMLAttempts(0), iSyncJobId(-1),iRetryingGASend(EFalse),
   609             iNetworkAvailable(EFalse),iFullScreenDialog(NULL), iNotifParams(NULL), iNotifier(NULL),
   596             iNetworkAvailable(EFalse),iFullScreenDialog(NULL), iNotifParams(NULL), iNotifier(NULL),
   610             iServerCanShut(EFalse), iAsyncOperation(EFalse),iDialogId (0), iConstructed(EFalse), iMainwindow(mainwindow)
   597             iServerCanShut(EFalse), iAsyncOperation(EFalse), iConstructed(EFalse), iMainwindow(mainwindow)
   611     {
   598     {
   612     RProcess pr;
   599     RProcess pr;
   613     TFullName fn = pr.FullName();
   600     TFullName fn = pr.FullName();
   614     TUint prid = pr.Id();
   601     TUint prid = pr.Id();
   615     FLOG(_L( "CFotaServer::CFotaServer process(id %d)%S. this 0x%x"), prid,
   602     FLOG(_L( "CFotaServer::CFotaServer process(id %d)%S. this 0x%x"), prid,
   669     TInt err;
   656     TInt err;
   670     iLastFwUrl.Zero();
   657     iLastFwUrl.Zero();
   671     StartL(KFotaServerName);
   658     StartL(KFotaServerName);
   672 
   659 
   673     __LEAVE_IF_ERROR(iFs.Connect());
   660     __LEAVE_IF_ERROR(iFs.Connect());
       
   661     
       
   662     iNotifier = CFotaDownloadNotifHandler::NewL(this);
   674 
   663 
   675     err = iFs.CreatePrivatePath(EDriveC);
   664     err = iFs.CreatePrivatePath(EDriveC);
   676     if (err != KErrNone && err != KErrAlreadyExists)
   665     if (err != KErrNone && err != KErrAlreadyExists)
   677         {
   666         {
   678         __LEAVE_IF_ERROR(err);
   667         __LEAVE_IF_ERROR(err);
   750         FLOG(_L("   1 got state id:%d state:%d result:%d"), tmp.iPkgId,
   739         FLOG(_L("   1 got state id:%d state:%d result:%d"), tmp.iPkgId,
   751                 tmp.iState, tmp.iResult);
   740                 tmp.iState, tmp.iResult);
   752 
   741 
   753         //Download was started earlier and was interrupted.
   742         //Download was started earlier and was interrupted.
   754         if (tmp.iState == RFotaEngineSession::EStartingUpdate || tmp.iState
   743         if (tmp.iState == RFotaEngineSession::EStartingUpdate || tmp.iState
   755                 == RFotaEngineSession::EDownloadProgressing || tmp.iState
       
   756                 == RFotaEngineSession::EDownloadProgressing)
   744                 == RFotaEngineSession::EDownloadProgressing)
   757 
   745 
   758             {
   746             {
   759             TBool ispkgvalid = ETrue;
   747             TBool ispkgvalid = ETrue;
   760             //Software version check from the time download started.
   748             //Software version check from the time download started.
   935     else if (iPackageState.iState == RFotaEngineSession::EDownloadProgressing)
   923     else if (iPackageState.iState == RFotaEngineSession::EDownloadProgressing)
   936         {
   924         {
   937         FLOG(_L("Download has paused due to an error. Invoking FMS..."));
   925         FLOG(_L("Download has paused due to an error. Invoking FMS..."));
   938         if (iFullScreenDialog)
   926         if (iFullScreenDialog)
   939             {
   927             {
   940             iFullScreenDialog->Close();
   928             iFullScreenDialog->close();
   941             iFullScreenDialog->deleteLater();
   929             iFullScreenDialog->deleteLater();
   942             iFullScreenDialog = NULL;
   930             iFullScreenDialog = NULL;
   943             }
   931             }
   944         SetStartupReason(EFotaDownloadInterrupted);
   932         SetStartupReason(EFotaDownloadInterrupted);
   945         InvokeFmsL();
   933         InvokeFmsL();
   949         }
   937         }
   950     else
   938     else
   951         {
   939         {
   952         if (iFullScreenDialog)
   940         if (iFullScreenDialog)
   953             {
   941             {
   954             iFullScreenDialog->Close();
   942             iFullScreenDialog->close();
   955             iFullScreenDialog->deleteLater();
   943             iFullScreenDialog->deleteLater();
   956             iFullScreenDialog = NULL;
   944             iFullScreenDialog = NULL;
   957             }
   945             }
   958         ConstructApplicationUI(EFalse);
   946         ConstructApplicationUI(EFalse);
   959         ReportFwUpdateStatusL(iPackageState);
   947         ReportFwUpdateStatusL(iPackageState);
  1209                 }
  1197                 }
  1210                 break;
  1198                 break;
  1211             case RFotaEngineSession::EResLowBattery:
  1199             case RFotaEngineSession::EResLowBattery:
  1212                 {
  1200                 {
  1213                 reason = EUpdMonitorbattery;
  1201                 reason = EUpdMonitorbattery;
       
  1202                 break;
  1214                 }
  1203                 }
  1215             default:
  1204             default:
  1216                 {
  1205                 {
  1217                 break;
  1206                 break;
  1218                 }
  1207                 }
  1375     if (iFullScreenDialog)
  1364     if (iFullScreenDialog)
  1376         {
  1365         {
  1377         iFullScreenDialog->deleteLater();
  1366         iFullScreenDialog->deleteLater();
  1378         }
  1367         }
  1379 
  1368 
  1380 		/*
  1369     
       
  1370     if (iNotifier)
       
  1371         {
       
  1372         delete iNotifier;
       
  1373         iNotifier = NULL;
       
  1374         }
       
  1375         
  1381     if (iNotifParams)
  1376     if (iNotifParams)
  1382         {
  1377         {
  1383         delete iNotifParams;
  1378         delete iNotifParams;
  1384         iNotifParams = NULL;
  1379         iNotifParams = NULL;
  1385         }
  1380         }            
  1386 
       
  1387     if (iNotifier)
       
  1388         {
       
  1389         delete iNotifier;
       
  1390         iNotifier = NULL;
       
  1391         }*/
       
  1392 
  1381 
  1393     FLOG(_L("CFotaServer::~CFotaServer  <<"));
  1382     FLOG(_L("CFotaServer::~CFotaServer  <<"));
  1394     }
  1383     }
  1395 
  1384 
  1396 // ---------------------------------------------------------------------------
  1385 // ---------------------------------------------------------------------------
  1638     StopServerWhenPossible();
  1627     StopServerWhenPossible();
  1639     FLOG(_L("CFotaServer::FinalizeUpdate <<"));
  1628     FLOG(_L("CFotaServer::FinalizeUpdate <<"));
  1640     }
  1629     }
  1641 
  1630 
  1642 
  1631 
  1643 FotaFullscreenDialog* CFotaServer::FullScreenDialog()
  1632 HbFotaFullscreenDialog* CFotaServer::FullScreenDialog()
  1644     {
  1633     {
  1645     return iFullScreenDialog;
  1634     return iFullScreenDialog;
  1646     }
  1635     }
  1647 
  1636 
  1648 void CFotaServer::HandleFullScreenDialogResponse(TInt aResponse)
  1637 void CFotaServer::HandleFullScreenDialogResponse(TInt aResponse)
  1749             FLOG(_L("CONTINUE LATER is pressed on update dialog"));
  1738             FLOG(_L("CONTINUE LATER is pressed on update dialog"));
  1750             ConstructApplicationUI(EFalse);
  1739             ConstructApplicationUI(EFalse);
  1751 
  1740 
  1752             iUpdater->CancelMonitor();
  1741             iUpdater->CancelMonitor();
  1753 
  1742 
  1754             if (iFullScreenDialog->IsLSKEnabled())
  1743             if (iFullScreenDialog->isLSKEnabled())
  1755                 {
  1744                 {
  1756                 DecrementUserPostponeCount();
  1745                 DecrementUserPostponeCount();
  1757                 }
  1746                 }
  1758 
  1747 
  1759             iPackageState.iState = RFotaEngineSession::EStartingUpdate;
  1748             iPackageState.iState = RFotaEngineSession::EStartingUpdate;
  2698 void CFotaServer::SetVisible(TBool aVisible)
  2687 void CFotaServer::SetVisible(TBool aVisible)
  2699 {
  2688 {
  2700     FLOG(_L("CFotaServer::SetVisible >>"));
  2689     FLOG(_L("CFotaServer::SetVisible >>"));
  2701 
  2690 
  2702     if(iFullScreenDialog)
  2691     if(iFullScreenDialog)
  2703 	iFullScreenDialog->SetVisible(aVisible);
  2692 	iFullScreenDialog->setVisible(aVisible);
  2704 
  2693 
  2705     FLOG(_L("CFotaServer::SetVisible <<"));
  2694     FLOG(_L("CFotaServer::SetVisible <<"));
  2706 }
  2695 }
  2707 
  2696 
  2708 //End of file
  2697 //End of file