tstaskmonitor/backstepping/src/tsbacksteppingactivation.cpp
changeset 102 8b8b34fa9751
parent 100 0920c6a9b6c8
child 106 e78d6e055a5b
equal deleted inserted replaced
100:0920c6a9b6c8 102:8b8b34fa9751
     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 <e32property.h>
       
    19 #include <startupdomainpskeys.h>
       
    20 #include <flogger.h>
       
    21 #include <w32std.h>
       
    22 
       
    23 #include "tsbacksteppingactivation.h"
       
    24 #include "tsbackstepping.h"
       
    25 
       
    26  // ============================ MEMBER FUNCTIONS ===============================
       
    27 // -----------------------------------------------------------------------------
       
    28 // CBacksteppingActivation::NewL
       
    29 // Two-phased constructor.
       
    30 // -----------------------------------------------------------------------------
       
    31 //
       
    32 CTsBacksteppingActivation* CTsBacksteppingActivation::NewL(MTsWindowGroupsMonitor &monitor)
       
    33 {
       
    34     RDebug::Print(_L("CBacksteppingActivation::NewL"));
       
    35     CTsBacksteppingActivation* self = new( ELeave ) CTsBacksteppingActivation(monitor);
       
    36     self->ConstructL();
       
    37     return self;
       
    38 }
       
    39 
       
    40 // -----------------------------------------------------------------------------
       
    41 // CBacksteppingWaitingIdle::CBacksteppingWaitingIdle
       
    42 // C++ default constructor can NOT contain any code, that
       
    43 // might leave.
       
    44 // -----------------------------------------------------------------------------
       
    45 //
       
    46 CTsBacksteppingActivation::CTsBacksteppingActivation(MTsWindowGroupsMonitor &monitor) 
       
    47 :
       
    48     CActive(EPriorityLow),
       
    49     mMonitor(monitor)
       
    50 {
       
    51     CActiveScheduler::Add(this);
       
    52 }
       
    53 
       
    54 // -----------------------------------------------------------------------------
       
    55 // CBacksteppingActivation::ConstructL()
       
    56 // -----------------------------------------------------------------------------
       
    57 //
       
    58 void CTsBacksteppingActivation::ConstructL() 
       
    59 {
       
    60     User::LeaveIfError(mProperty.Attach(KPSUidStartup, KPSIdlePhase1Ok));
       
    61     iStatus = KRequestPending;
       
    62     SetActive();
       
    63     TRequestStatus* status(&iStatus);
       
    64     User::RequestComplete(status);
       
    65 }
       
    66 
       
    67 // -----------------------------------------------------------------------------
       
    68 // CBacksteppingActivation::~CBacksteppingActivation
       
    69 // Destructor
       
    70 // -----------------------------------------------------------------------------
       
    71 //
       
    72 CTsBacksteppingActivation::~CTsBacksteppingActivation()
       
    73 {
       
    74     Cancel();
       
    75     delete mEngine;
       
    76     mProperty.Close();
       
    77 }
       
    78 
       
    79 // -----------------------------------------------------------------------------
       
    80 // CBacksteppingActivation::DoCancel
       
    81 // 
       
    82 // -----------------------------------------------------------------------------
       
    83 //
       
    84 void CTsBacksteppingActivation::DoCancel()
       
    85 {
       
    86     if ( IsActive() && mProperty.Handle() ) {
       
    87         mProperty.Cancel();
       
    88     }
       
    89 }
       
    90 
       
    91 // -----------------------------------------------------------------------------
       
    92 // CBacksteppingActivation::RunL
       
    93 // 
       
    94 // -----------------------------------------------------------------------------
       
    95 //
       
    96 void CTsBacksteppingActivation::RunL()
       
    97 {
       
    98     User::LeaveIfError(iStatus.Int());
       
    99     
       
   100     TInt state(~EIdlePhase1Ok);
       
   101     User::LeaveIfError(mProperty.Get(state));
       
   102     
       
   103     if (EIdlePhase1Ok == state) {
       
   104         if (0 == mEngine) {
       
   105             mEngine = CTsBackstepping::NewL(mMonitor);
       
   106         }
       
   107     } else {
       
   108         delete mEngine;
       
   109         mEngine = 0;
       
   110     }
       
   111     Subscribe();
       
   112 }
       
   113 
       
   114 // -----------------------------------------------------------------------------
       
   115 // CBacksteppingActivation::RunError
       
   116 // 
       
   117 // -----------------------------------------------------------------------------
       
   118 //
       
   119 TInt CTsBacksteppingActivation::RunError(TInt error)
       
   120 {
       
   121     if (KErrCancel != error) {
       
   122         Subscribe();
       
   123     }
       
   124     return KErrNone;
       
   125 }
       
   126 
       
   127 // -----------------------------------------------------------------------------
       
   128 // CBacksteppingActivation::Subscribe
       
   129 // 
       
   130 // -----------------------------------------------------------------------------
       
   131 //
       
   132 void CTsBacksteppingActivation::Subscribe()
       
   133 {
       
   134     mProperty.Subscribe(iStatus);
       
   135     SetActive();
       
   136 }
       
   137 // end of file