securitydialogs/simlockui/src/SimLockDataHandlingDelegate.cpp
branchRCL_3
changeset 21 09b1ac925e3f
parent 20 63339781d179
child 22 03674e5abf46
equal deleted inserted replaced
20:63339781d179 21:09b1ac925e3f
     1 /*
       
     2 * ============================================================================
       
     3 *  Name        : SimLockDataHandlingDelegate.cpp
       
     4 *  Part of     : Sim Lock UI Application
       
     5 *  Description : Implementation of Sim Lock UI Application
       
     6 *  Version     :
       
     7 *   
       
     8 * Copyright (c) 2005-2010 Nokia Corporation and/or its subsidiary(-ies).
       
     9 * All rights reserved.
       
    10 * This component and the accompanying materials are made available
       
    11 * under the terms of "Eclipse Public License v1.0"
       
    12 * which accompanies this distribution, and is available
       
    13 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
    14 *
       
    15 * Initial Contributors:
       
    16 * Nokia Corporation - initial contribution.
       
    17 *
       
    18 * Contributors:
       
    19 *
       
    20 * Description:   Build info file for Ado domain appinstall 
       
    21 * ============================================================================
       
    22 */
       
    23 
       
    24 // System Include Files
       
    25 #include <rmmcustomapi.h>           // RMmCustomAPI, RMobilePhone
       
    26 
       
    27 // User Include Files
       
    28 #include "simlockdatahandlingdelegate.h"
       
    29 #include "simlockui.pan"
       
    30 #include "simlockisaserverdefinitions.h"
       
    31 
       
    32 
       
    33 TInt KSimLockTimeoutDelay = 5000000;       // 5 seconds
       
    34 
       
    35 // ===========================================================================
       
    36 // PUBLIC CONSTRUCTORS
       
    37 // ===========================================================================
       
    38 
       
    39 // ---------------------------------------------------------------------------
       
    40 // CSimLockDataHandlingDelegate::NewL
       
    41 // ---------------------------------------------------------------------------
       
    42 CSimLockDataHandlingDelegate* CSimLockDataHandlingDelegate::NewL( RMmCustomAPI& aCustomAPI )
       
    43     {
       
    44     CSimLockDataHandlingDelegate* self = new ( ELeave ) CSimLockDataHandlingDelegate( aCustomAPI );
       
    45     CleanupStack::PushL( self );
       
    46     self->ConstructL();
       
    47     CleanupStack::Pop( self );
       
    48     return self;
       
    49     }
       
    50 
       
    51 // ---------------------------------------------------------------------------
       
    52 // CSimLockDataHandlingDelegate::~CSimLockDataHandlingDelegate
       
    53 // ---------------------------------------------------------------------------
       
    54 CSimLockDataHandlingDelegate::~CSimLockDataHandlingDelegate()
       
    55     {
       
    56     Cancel();
       
    57     delete iTimer;
       
    58     delete iSchedulerWait;
       
    59     }
       
    60 
       
    61 // ===========================================================================
       
    62 // PUBLIC MEMBER FUNCTIONS
       
    63 // ===========================================================================
       
    64 
       
    65 // ---------------------------------------------------------------------------
       
    66 // CSimLockDataHandlingDelegate::OpenSimLock
       
    67 // ---------------------------------------------------------------------------
       
    68 TInt CSimLockDataHandlingDelegate::OpenSimLock( const TDesC& aPassword )
       
    69     {
       
    70     // Use ETel custom API to deactive SimLock
       
    71     return iCustomAPI.DeActivateSimLock( aPassword, RMmCustomAPI::EOperator );
       
    72     }
       
    73 
       
    74 // ---------------------------------------------------------------------------
       
    75 // CSimLockDataHandlingDelegate::IsSimLockOpen
       
    76 // ---------------------------------------------------------------------------
       
    77 TBool CSimLockDataHandlingDelegate::IsSimLockOpen() const
       
    78     {
       
    79 
       
    80     ASSERT( iDataHasBeenRead );
       
    81 
       
    82     return iLockIsOpen;
       
    83     }
       
    84 
       
    85 
       
    86 // ===========================================================================
       
    87 // PRIVATE CONSTRUCTORS
       
    88 // ===========================================================================
       
    89 
       
    90 // ---------------------------------------------------------------------------
       
    91 // CSimLockDataHandlingDelegate::CSimLockDataHandlingDelegate
       
    92 // ---------------------------------------------------------------------------
       
    93 CSimLockDataHandlingDelegate::CSimLockDataHandlingDelegate( RMmCustomAPI& aCustomAPI )
       
    94 :   CActive( EPriorityStandard ),
       
    95     iCustomAPI( aCustomAPI )
       
    96     { //lint !e1403 iIndicators initialized in CBase ctor
       
    97     }
       
    98 
       
    99 // ---------------------------------------------------------------------------
       
   100 // CSimLockDataHandlingDelegate::ConstructL
       
   101 // ---------------------------------------------------------------------------
       
   102 void CSimLockDataHandlingDelegate::ConstructL()
       
   103     {
       
   104     CActiveScheduler::Add(this);
       
   105     iSchedulerWait = new ( ELeave ) CActiveSchedulerWait;
       
   106     iTimer = CPeriodic::NewL(EPriorityHigh);
       
   107     }
       
   108 
       
   109 // ===========================================================================
       
   110 // PRIVATE MEMBER FUNCTIONS
       
   111 // ===========================================================================
       
   112 
       
   113 // ---------------------------------------------------------------------------
       
   114 // CSimLockDataHandlingDelegate::RunL
       
   115 // ---------------------------------------------------------------------------
       
   116 void CSimLockDataHandlingDelegate::RunL()
       
   117     {
       
   118 
       
   119     // Stop the current run sequence
       
   120     iSchedulerWait->AsyncStop();
       
   121     }
       
   122 
       
   123 // ---------------------------------------------------------------------------
       
   124 // CSimLockDataHandlingDelegate::DoCancel
       
   125 // ---------------------------------------------------------------------------
       
   126 void CSimLockDataHandlingDelegate::DoCancel()
       
   127     {
       
   128   
       
   129     // Cancel timer
       
   130     iTimer->Cancel();
       
   131 
       
   132     // Stop the current run sequence so we can continue execution in a
       
   133     // synchronous fashion
       
   134     iSchedulerWait->AsyncStop();
       
   135     }
       
   136 
       
   137 // ---------------------------------------------------------------------------
       
   138 // CSimLockTelephonyProxy::TimerElapsed
       
   139 // ---------------------------------------------------------------------------
       
   140 TInt CSimLockDataHandlingDelegate::TimerElapsed(TAny* /*aUnused*/)
       
   141     {        
       
   142     // Some request did not complete while reading Sim Lock data.
       
   143     // This is not expected, so Panic.
       
   144     Panic( ESimLockUIUnableToReadSimLock );
       
   145     
       
   146     return 0;
       
   147     }
       
   148 
       
   149 // ---------------------------------------------------------------------------
       
   150 // CSimLockDataHandlingDelegate::CompleteRequestWithTimeout
       
   151 // ---------------------------------------------------------------------------
       
   152 void CSimLockDataHandlingDelegate::CompleteRequestWithTimeout()
       
   153     {
       
   154     
       
   155     ASSERT( ! iTimer->IsActive() );
       
   156     
       
   157     if ( ! iTimer->IsActive() )
       
   158         {        
       
   159         iTimer->Cancel();
       
   160         }
       
   161         
       
   162     // Start timer with KSimLockProxyTimeout to protect against requests that
       
   163     // do not complete for some reason.
       
   164     iTimer->Start(KSimLockTimeoutDelay,0,TCallBack(&TimerElapsed));              
       
   165         
       
   166     SetActive();
       
   167 
       
   168     // Wait for request to complete.  Response time is expected to be negligible.
       
   169     iSchedulerWait->Start();
       
   170     iTimer->Cancel();
       
   171     }
       
   172 
       
   173 
       
   174 // end of file.
       
   175