fotaapplication/fotaserver/FotaServer/src/DevEncProgressObserver.cpp
changeset 50 a36219ae6585
parent 49 689a71addb96
child 51 2e64dc50f295
equal deleted inserted replaced
49:689a71addb96 50:a36219ae6585
     1 /*
       
     2  * Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies). 
       
     3  * All rights reserved.
       
     4  * This component and the accompanying materials are made available
       
     5  * under the terms of "Eclipse Public License v1.0"
       
     6  * which accompanies this distribution, and is available
       
     7  * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8  *
       
     9  * Initial Contributors:
       
    10  * Nokia Corporation - initial contribution.
       
    11  *
       
    12  * Contributors:
       
    13  *
       
    14  * Description:   
       
    15  *
       
    16  */
       
    17 
       
    18 
       
    19 
       
    20 // INCLUDE FILES
       
    21 
       
    22 //User Includes
       
    23 
       
    24 #include "DevEncProgressObserver.h"
       
    25 #include "DevEncController.h"
       
    26 #include "DevEncProgressDlg.h"
       
    27 #include "FotaSrvDebug.h"
       
    28 #include <eikprogi.h>
       
    29 #include <fotaConst.h>
       
    30 // -----------------------------------------------------------------------------
       
    31 // CDevEncProgressObserver::NewL
       
    32 // Symbian 2-Phase construction, NewL used for creating object of this class
       
    33 // This method can leave
       
    34 // -----------------------------------------------------------------------------
       
    35 
       
    36 EXPORT_C CDevEncProgressObserver* CDevEncProgressObserver::NewL(CDevEncController* aObserver, TInt aResource)
       
    37     {
       
    38     CDevEncProgressObserver* self = CDevEncProgressObserver::NewLC(aObserver, aResource);
       
    39     CleanupStack::Pop(self);
       
    40     return self;	
       
    41     }
       
    42 
       
    43 // -----------------------------------------------------------------------------
       
    44 // CDevEncProgressObserver::NewLC
       
    45 // Symbian 2-Phase construction, NewLC used for creating object of this class
       
    46 // This method can leave
       
    47 // -----------------------------------------------------------------------------
       
    48 
       
    49 EXPORT_C CDevEncProgressObserver* CDevEncProgressObserver::NewLC(CDevEncController* aObserver, TInt aResource)
       
    50     {
       
    51     CDevEncProgressObserver* self = new (ELeave) CDevEncProgressObserver (aObserver);
       
    52     CleanupStack::PushL(self);
       
    53     self->ConstructL(aResource);
       
    54 
       
    55     return self;
       
    56     }
       
    57 
       
    58 // -----------------------------------------------------------------------------
       
    59 // CDevEncProgressObserver::ConstructL
       
    60 // Symbian 2-Phase construction, ConstructL used for constructing the members of this class
       
    61 // This method can leave
       
    62 // -----------------------------------------------------------------------------
       
    63 
       
    64 void CDevEncProgressObserver::ConstructL(TInt aResource)
       
    65     {
       
    66     FLOG(_L("CDevEncProgressObserver::ConstructL >>"));
       
    67     
       
    68     iProgressDlg = CDevEncProgressDlg::NewL(this, aResource);
       
    69     
       
    70     FLOG(_L("CDevEncProgressObserver::ConstructL <<"));
       
    71     }
       
    72 
       
    73 // -----------------------------------------------------------------------------
       
    74 // CDevEncProgressObserver::CDevEncProgressObserver
       
    75 // C++ Constructor
       
    76 // This method shouldn't leave
       
    77 // -----------------------------------------------------------------------------
       
    78 
       
    79 CDevEncProgressObserver::CDevEncProgressObserver(CDevEncController* aObserver) : 
       
    80 iObserver(aObserver), iProgressDlg (NULL), iPeriodicTimer(NULL), iEncMemorySession (NULL)
       
    81             {
       
    82 
       
    83             }
       
    84 
       
    85 // -----------------------------------------------------------------------------
       
    86 // CDevEncProgressObserver::~CDevEncProgressObserver
       
    87 // C++ Desctructor
       
    88 // This method shouldn't leave
       
    89 // -----------------------------------------------------------------------------
       
    90 
       
    91 CDevEncProgressObserver::~CDevEncProgressObserver()
       
    92     {
       
    93     FLOG(_L("CDevEncProgressObserver::~CDevEncProgressObserver >>"));
       
    94 
       
    95     iEncMemorySession = NULL;
       
    96 
       
    97     if (iPeriodicTimer)
       
    98         {
       
    99         FLOG(_L("1..........."));
       
   100         iPeriodicTimer->Cancel();
       
   101         FLOG(_L("2..........."));
       
   102         delete iPeriodicTimer;
       
   103         iPeriodicTimer = NULL;
       
   104         }
       
   105 
       
   106     if (iProgressDlg)
       
   107         {
       
   108         iProgressDlg->ProgressFinished();
       
   109         delete iProgressDlg;
       
   110         iProgressDlg = NULL;
       
   111         }
       
   112 
       
   113     FLOG(_L("CDevEncProgressObserver::~CDevEncProgressObserver <<"));
       
   114     }
       
   115 
       
   116 static TInt StaticTimerExpiry(TAny *aPtr)
       
   117     {
       
   118     FLOG(_L("CDevEncProgressObserver StaticTimerExpiry() >>"));
       
   119 
       
   120     CDevEncProgressObserver* obj = (CDevEncProgressObserver*) aPtr;
       
   121     TRAPD( err,  obj->CheckProgressL());
       
   122     FLOG(_L("ERROR =  %d"),err);
       
   123     
       
   124     FLOG(_L("CDevEncProgressObserver StaticTimerExpiry() <<"));
       
   125     return err;
       
   126     }
       
   127 
       
   128 // -----------------------------------------------------------------------------
       
   129 // CDevEncProgressObserver::StartMonitoringL
       
   130 // Monitors for connection status
       
   131 // This method don't leave
       
   132 // -----------------------------------------------------------------------------
       
   133 
       
   134 void CDevEncProgressObserver::StartMonitoringL(CDevEncSession* aSession)
       
   135     {
       
   136     FLOG(_L("CDevEncProgressObserver::StartMonitoringL >>"));
       
   137 
       
   138     __ASSERT_ALWAYS( aSession, User::Panic(KFotaPanic, KErrArgument) );
       
   139     
       
   140     iEncMemorySession = aSession;
       
   141     iProgressDlg->ShowProgressDialogL();
       
   142 
       
   143     iPeriodicTimer = CPeriodic::NewL (EPriorityMore) ;
       
   144     iPeriodicTimer->Start (
       
   145             TTimeIntervalMicroSeconds32(KNfeTimeInterval)
       
   146             ,TTimeIntervalMicroSeconds32(KNfeTimeInterval)
       
   147             ,TCallBack(StaticTimerExpiry,this) );
       
   148 
       
   149     FLOG(_L("CDevEncProgressObserver::StartMonitoringL <<"));
       
   150     }
       
   151 
       
   152 // -----------------------------------------------------------------------------
       
   153 // CDevEncProgressObserver::RunL()
       
   154 // Called when event accomplished
       
   155 // -----------------------------------------------------------------------------
       
   156 //
       
   157 void CDevEncProgressObserver::CheckProgressL()
       
   158     {
       
   159     FLOG(_L("CDevEncProgressObserver::CheckProgressL >>"));
       
   160 
       
   161     TInt progress = GetStatusL();
       
   162     FLOG(_L("NFE Progress = %d"),progress);
       
   163     if (progress != KProgressComplete)
       
   164         {
       
   165         iProgressDlg->UpdateProgressDialogL(progress, 100);
       
   166         FLOG(_L("nfe progress = %d"), progress);
       
   167         }
       
   168     else
       
   169         {
       
   170         FLOG(_L("nfe progress complete"));
       
   171 
       
   172         if (iPeriodicTimer && iPeriodicTimer->IsActive())
       
   173             {
       
   174             iPeriodicTimer->Cancel();
       
   175             }
       
   176 
       
   177         iProgressDlg->UpdateProgressDialogL(progress, 100);
       
   178         iProgressDlg->ProgressFinished();
       
   179 
       
   180         delete iProgressDlg; iProgressDlg = NULL;
       
   181 
       
   182         iObserver->ReportDevEncOpnCompleteL(KErrNone);
       
   183         }
       
   184     FLOG(_L("CDevEncProgressObserver::CheckProgressL <<"));
       
   185     }
       
   186 
       
   187 
       
   188 
       
   189 
       
   190 TInt CDevEncProgressObserver::GetStatusL()
       
   191     {
       
   192     FLOG(_L("CDevEncProgressObserver::GetStatus >>"));
       
   193     TInt ret (0);
       
   194     User::LeaveIfError(iEncMemorySession->Progress(ret));
       
   195 
       
   196     FLOG(_L("CDevEncProgressObserver::GetStatus << progress = %d"), ret);
       
   197     return ret;
       
   198     }
       
   199 
       
   200 TBool CDevEncProgressObserver::HandleDEProgressDialogExitL(TInt aButtonId)
       
   201     {
       
   202     //Do nothing
       
   203     return ETrue;
       
   204     }
       
   205 // End of File