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