phoneengine/phonemodel/src/cpeidlestatusmonitor.cpp
branchGCC_SURGE
changeset 51 f39ed5e045e0
parent 40 bab96b7ed1a4
parent 46 bc5a64e5bc3c
equal deleted inserted replaced
40:bab96b7ed1a4 51:f39ed5e045e0
     1 /*
       
     2 * Copyright (c) 2007 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:  This module contains the implementation of CPEIdleStatusMonitor class 
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 // INCLUDES
       
    20 #include <talogger.h>
       
    21 #include "cpephonemodel.h"
       
    22 #include "cpeidlestatusmonitor.h"
       
    23 #include <activeidle2domainpskeys.h>
       
    24 
       
    25 
       
    26 // ================= MEMBER FUNCTIONS =======================
       
    27 
       
    28 // -----------------------------------------------------------------------------
       
    29 // CPEIdleStatusMonitor::NewL
       
    30 // Two-phased constructor.
       
    31 // -----------------------------------------------------------------------------
       
    32 CPEIdleStatusMonitor* CPEIdleStatusMonitor::NewL(
       
    33         CPEPhoneModel& aOwner ) 
       
    34     {
       
    35     TEFLOGSTRING( KTAOBJECT, "PE CPEIdleStatusMonitor::NewL ");
       
    36     CPEIdleStatusMonitor* self = new (ELeave) CPEIdleStatusMonitor( 
       
    37         aOwner );
       
    38     CleanupStack::PushL( self );
       
    39     self->ConstructL();
       
    40     CleanupStack::Pop( self );
       
    41     return( self );
       
    42     }
       
    43 
       
    44 // Destructor
       
    45 CPEIdleStatusMonitor::~CPEIdleStatusMonitor()
       
    46     {
       
    47     TEFLOGSTRING( KTAOBJECT, "PE CPEIdleStatusMonitor::~CPEIdleStatusMonitor, start ");
       
    48     Cancel();
       
    49     iProperty.Close();
       
    50     TEFLOGSTRING( KTAOBJECT, "PE CPEIdleStatusMonitor::~CPEIdleStatusMonitor, complete ");
       
    51     }
       
    52                                        
       
    53 // -----------------------------------------------------------------------------
       
    54 // CPEIdleStatusMonitor::CPEIdleStatusMonitor
       
    55 // C++ default constructor can NOT contain any code, that
       
    56 // might leave.
       
    57 // -----------------------------------------------------------------------------
       
    58 //
       
    59 CPEIdleStatusMonitor::CPEIdleStatusMonitor(
       
    60         CPEPhoneModel& aOwner
       
    61         ): CActive( EPriorityStandard ),
       
    62            iOwner( aOwner )
       
    63     {
       
    64     CActiveScheduler::Add( this );
       
    65     }
       
    66 
       
    67 // -----------------------------------------------------------------------------
       
    68 // CPEIdleStatusMonitor::ConstructL
       
    69 // Symbian 2nd phase constructor can leave.
       
    70 // -----------------------------------------------------------------------------
       
    71 //
       
    72 void CPEIdleStatusMonitor::ConstructL()
       
    73     {
       
    74     TEFLOGSTRING( KTAOBJECT, "PE CPEIdleStatusMonitor::ConstructL");
       
    75     User::LeaveIfError( iProperty.Attach( KPSUidAiInformation, KActiveIdleState ) );
       
    76        
       
    77     TInt value;
       
    78     iProperty.Get( KPSUidAiInformation, KActiveIdleState, value );
       
    79     
       
    80     if ( value == EPSAiForeground )
       
    81         {
       
    82         // Don't implement any new code that reserver anything after this.
       
    83         iOwner.ConstructContactHandlingPhaseTwoL();
       
    84         }
       
    85     else
       
    86         {
       
    87         iProperty.Subscribe( iStatus );
       
    88         SetActive();
       
    89         }
       
    90     }
       
    91 
       
    92 // -----------------------------------------------------------------------------
       
    93 // CPEIdleStatusMonitor::DoCancel
       
    94 // Callback method from CActive.
       
    95 // -----------------------------------------------------------------------------
       
    96 //
       
    97 void CPEIdleStatusMonitor::DoCancel()
       
    98     {   
       
    99     TEFLOGSTRING( KTAREQOUT, "PE CPEIdleStatusMonitor::DoCancel()" );
       
   100     iProperty.Cancel();
       
   101     }
       
   102 
       
   103 // -----------------------------------------------------------------------------
       
   104 // CPECenRepMonitor::RunL
       
   105 // -----------------------------------------------------------------------------
       
   106 //
       
   107 void CPEIdleStatusMonitor::RunL()
       
   108     {
       
   109     TEFLOGSTRING2( KTAREQEND, 
       
   110         "PE CPEIdleStatusMonitor::RunL,iStatus: %d", iStatus.Int() );
       
   111    
       
   112     //  Now retrieve the value
       
   113     TInt value;
       
   114     iProperty.Get( KPSUidAiInformation, KActiveIdleState, value );
       
   115         
       
   116     if ( value == EPSAiForeground )
       
   117         {
       
   118         TEFLOGSTRING( KTAOBJECT, 
       
   119             "PE CPEIdleStatusMonitor::RunL, starting contact handling creation");
       
   120         // Don't implement any new code that reserver anything after this.
       
   121         iOwner.ConstructContactHandlingPhaseTwoL();
       
   122         TEFLOGSTRING( KTAOBJECT, 
       
   123             "PE CPEIdleStatusMonitor::RunL, starting contact handling creation done ");
       
   124         }
       
   125     else
       
   126         {
       
   127         iProperty.Subscribe( iStatus );
       
   128         SetActive();
       
   129         }
       
   130     }
       
   131     
       
   132 // End of file