memspyui/source/MemSpyDeviceWideOperationDialog.cpp
branchRCL_3
changeset 22 fad26422216a
parent 0 d6fe6244b863
equal deleted inserted replaced
21:b3cee849fa46 22:fad26422216a
       
     1 /*
       
     2 * Copyright (c) 2009 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 #include "MemSpyDeviceWideOperationDialog.h"
       
    19 
       
    20 // System includes
       
    21 #include <eikprogi.h>
       
    22 #include <AknWaitDialog.h>
       
    23 #include <AknQueryDialog.h>
       
    24 #include <coemain.h>
       
    25 #include <eikenv.h>
       
    26 #include <avkon.hrh>
       
    27 #include <memspyui.rsg>
       
    28 
       
    29 
       
    30 CMemSpyDeviceWideOperationDialog::CMemSpyDeviceWideOperationDialog( CMemSpyEngine& aEngine, MMemSpyDeviceWideOperationDialogObserver& aObserver )
       
    31 :   iEngine( aEngine ), iObserver( aObserver )
       
    32     {
       
    33     }
       
    34 
       
    35 
       
    36 CMemSpyDeviceWideOperationDialog::~CMemSpyDeviceWideOperationDialog()
       
    37     {
       
    38 #ifdef _DEBUG
       
    39     RDebug::Printf("[MemSpy] CMemSpyDeviceWideOperationDialog::~CMemSpyDeviceWideOperationDialog() - START - iForcedCancel: %d", iForcedCancel );
       
    40 #endif
       
    41 
       
    42 #ifdef _DEBUG
       
    43     RDebug::Printf("[MemSpy] CMemSpyDeviceWideOperationDialog::~CMemSpyDeviceWideOperationDialog() - deleting operation...: 0x%08x", iOperation );
       
    44 #endif
       
    45     delete iOperation;
       
    46 
       
    47 #ifdef _DEBUG
       
    48     RDebug::Printf("[MemSpy] CMemSpyDeviceWideOperationDialog::~CMemSpyDeviceWideOperationDialog() - deleting dialog...: 0x%08x", iProgressDialog );
       
    49 #endif
       
    50     iProgressInfo = NULL;
       
    51     delete iProgressDialog;
       
    52 
       
    53 #ifdef _DEBUG
       
    54     RDebug::Printf("[MemSpy] CMemSpyDeviceWideOperationDialog::~CMemSpyDeviceWideOperationDialog() - sending EDialogDismissed to observer..." );
       
    55 #endif
       
    56 
       
    57     iObserver.DWOperationCompleted();
       
    58 
       
    59 #ifdef _DEBUG
       
    60     RDebug::Printf("[MemSpy] CMemSpyDeviceWideOperationDialog::~CMemSpyDeviceWideOperationDialog() - END" );
       
    61 #endif
       
    62     }
       
    63 
       
    64 
       
    65 void CMemSpyDeviceWideOperationDialog::ExecuteL( CMemSpyDeviceWideOperations::TOperation aOperation )
       
    66     {
       
    67 #ifdef _DEBUG
       
    68     RDebug::Printf("[MemSpy] CMemSpyDeviceWideOperationDialog::ExecuteL() - START" );
       
    69 #endif
       
    70 
       
    71     iOperation = CMemSpyDeviceWideOperations::NewL( iEngine, *this, aOperation );
       
    72 
       
    73 #ifdef _DEBUG
       
    74     RDebug::Printf("[MemSpy] CMemSpyDeviceWideOperationDialog::ExecuteL() - constructed operation..." );
       
    75 #endif
       
    76 
       
    77     ASSERT( iProgressDialog == NULL );
       
    78     iProgressDialog = new( ELeave ) CAknProgressDialog( reinterpret_cast< CEikDialog** >( &iProgressDialog ), ETrue );
       
    79     iProgressDialog->PrepareLC( R_MEMSPY_DEVICE_WIDE_OPERATION_PROGRESS_DIALOG );
       
    80     iProgressDialog->SetCallback( this );
       
    81     iProgressDialog->SetGloballyCapturing( ETrue );
       
    82     //
       
    83     iProgressInfo = iProgressDialog->GetProgressInfoL();
       
    84     iProgressInfo->SetFinalValue( iOperation->TotalOperationSize() );
       
    85     //
       
    86     iProgressDialog->RunLD();
       
    87 
       
    88 #ifdef _DEBUG
       
    89     RDebug::Printf("[MemSpy] CMemSpyDeviceWideOperationDialog::ExecuteL() - END" );
       
    90 #endif
       
    91     }
       
    92 
       
    93 void CMemSpyDeviceWideOperationDialog::ExecuteLD( CMemSpyEngine& aEngine, MMemSpyDeviceWideOperationDialogObserver& aObserver, CMemSpyDeviceWideOperations::TOperation aOperation )
       
    94     {
       
    95     CMemSpyDeviceWideOperationDialog* self = new(ELeave) CMemSpyDeviceWideOperationDialog( aEngine, aObserver );
       
    96     CleanupStack::PushL( self );
       
    97     self->ExecuteL( aOperation );
       
    98     CleanupStack::PopAndDestroy( self );
       
    99     }
       
   100 
       
   101 
       
   102 void CMemSpyDeviceWideOperationDialog::Cancel()
       
   103     {
       
   104 #ifdef _DEBUG
       
   105     RDebug::Printf("[MemSpy] CMemSpyDeviceWideOperationDialog::Cancel() - START - iOperation: 0x%08x, iForcedCancel: %d", iOperation, iForcedCancel );
       
   106 #endif
       
   107 
       
   108     iForcedCancel = ETrue;
       
   109     //
       
   110     if  ( iOperation )
       
   111         {
       
   112         iOperation->Cancel();
       
   113         }
       
   114     //
       
   115     iObserver.DWOperationCancelled();
       
   116 
       
   117 #ifdef _DEBUG
       
   118     RDebug::Printf("[MemSpy] CMemSpyDeviceWideOperationDialog::Cancel() - END" );
       
   119 #endif
       
   120     }
       
   121 
       
   122 
       
   123 void CMemSpyDeviceWideOperationDialog::DialogDismissedL( TInt aButtonId )
       
   124     {
       
   125 #ifdef _DEBUG
       
   126     RDebug::Printf("[MemSpy] CMemSpyDeviceWideOperationDialog::DialogDismissedL() - START - aButtonId: %d, iForcedCancel: %d", aButtonId, iForcedCancel );
       
   127 #else
       
   128     (void) aButtonId;
       
   129 #endif
       
   130 
       
   131     Cancel();
       
   132 
       
   133 #ifdef _DEBUG
       
   134     RDebug::Printf("[MemSpy] CMemSpyDeviceWideOperationDialog::DialogDismissedL() - END - aButtonId: %d, iForcedCancel: %d", aButtonId, iForcedCancel );
       
   135 #endif
       
   136     }
       
   137 
       
   138 
       
   139 void CMemSpyDeviceWideOperationDialog::HandleDeviceWideOperationEvent( TEvent aEvent, TInt aParam1, const TDesC& aParam2 )
       
   140     {
       
   141 #ifdef _DEBUG
       
   142     RDebug::Print( _L("[MemSpy] CMemSpyDeviceWideOperationDialog::HandleDeviceWideOperationEvent() - START - aEvent: %d, iProgressDialog: 0x%08x, aParam1: %d, aParam2: %S"), aEvent, iProgressDialog, aParam1, &aParam2 );
       
   143 #endif
       
   144 
       
   145     switch( aEvent )
       
   146         {
       
   147     case MMemSpyDeviceWideOperationsObserver::EOperationSized:
       
   148         break;
       
   149     case MMemSpyDeviceWideOperationsObserver::EOperationStarting:
       
   150         iObserver.DWOperationStarted();
       
   151         break;
       
   152     case MMemSpyDeviceWideOperationsObserver::EOperationProgressStart:
       
   153         ASSERT( iProgressDialog != NULL );
       
   154         SetDialogCaptionL( aParam2 );
       
   155         break;
       
   156     case MMemSpyDeviceWideOperationsObserver::EOperationProgressEnd:
       
   157         ASSERT( iProgressDialog != NULL );
       
   158         iProgressInfo->IncrementAndDraw( aParam1 );
       
   159         break;
       
   160     case MMemSpyDeviceWideOperationsObserver::EOperationCancelled:
       
   161         break;
       
   162     case MMemSpyDeviceWideOperationsObserver::EOperationCompleting:
       
   163         {
       
   164         ASSERT( iProgressDialog != NULL );
       
   165         const TInt finalValue = iProgressInfo->Info().iFinalValue;
       
   166         iProgressInfo->SetAndDraw( finalValue );
       
   167         break;
       
   168         }
       
   169     case MMemSpyDeviceWideOperationsObserver::EOperationCompleted:
       
   170         if  ( iProgressDialog )
       
   171             {
       
   172             iProgressDialog->ProcessFinishedL();
       
   173             }
       
   174         break;
       
   175     default:
       
   176         break;
       
   177         }
       
   178 
       
   179 #ifdef _DEBUG
       
   180     RDebug::Print( _L("[MemSpy] CMemSpyDeviceWideOperationDialog::HandleDeviceWideOperationEvent() - END - aEvent: %d, aParam1: %d, aParam2: %S"), aEvent, aParam1, &aParam2 );
       
   181 #endif
       
   182     }
       
   183 
       
   184 
       
   185 void CMemSpyDeviceWideOperationDialog::SetDialogCaptionL( const TDesC& aText )
       
   186     {
       
   187     if  ( aText.Length() )
       
   188         {
       
   189         iProgressDialog->SetTextL( aText );
       
   190         iProgressDialog->DrawNow();
       
   191         }
       
   192     }
       
   193 
       
   194 
       
   195 
       
   196 
       
   197