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