commsconfig/cscengine/src/cscengecommonitor.cpp
branchRCL_3
changeset 22 d38647835c2e
parent 0 a4daefaec16c
equal deleted inserted replaced
21:f742655b05bf 22:d38647835c2e
       
     1 /*
       
     2 * Copyright (c) 2007-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:  For monitoring ecom events.
       
    15 *
       
    16 */
       
    17 
       
    18 #include "cscenglogger.h"
       
    19 #include "cscengecommonitor.h"
       
    20 #include "mcscengecomobserver.h"
       
    21 
       
    22 // ======== MEMBER FUNCTIONS ========
       
    23 
       
    24 // ---------------------------------------------------------------------------
       
    25 // ---------------------------------------------------------------------------
       
    26 //
       
    27 CCSCEngEcomMonitor::CCSCEngEcomMonitor( MCSCEngEcomObserver& aObserver ) 
       
    28     : CActive( EPriorityStandard ),
       
    29     iObserver( aObserver )
       
    30     {    
       
    31     }
       
    32 
       
    33 
       
    34 // ---------------------------------------------------------------------------
       
    35 // ---------------------------------------------------------------------------
       
    36 //
       
    37 void CCSCEngEcomMonitor::ConstructL()
       
    38     {
       
    39     CSCENGDEBUG( "CCSCEngEcomMonitor::ConstructL - begin" ); 
       
    40     
       
    41     // Open ECom session and start monitoring count of implementations.
       
    42     CActiveScheduler::Add( this );
       
    43     iEcomSession = REComSession::OpenL();
       
    44     StartMonitoring();
       
    45     
       
    46     CSCENGDEBUG( "CCSCEngEcomMonitor::ConstructL - end" ); 
       
    47     }   
       
    48     
       
    49     
       
    50 // ---------------------------------------------------------------------------
       
    51 // ---------------------------------------------------------------------------
       
    52 //
       
    53 CCSCEngEcomMonitor* CCSCEngEcomMonitor::NewL( MCSCEngEcomObserver& aObserver )
       
    54     {    
       
    55     CCSCEngEcomMonitor* self = new ( ELeave ) CCSCEngEcomMonitor( aObserver );
       
    56     CleanupStack::PushL( self );
       
    57     self->ConstructL();
       
    58     CleanupStack::Pop( self );
       
    59     return self;
       
    60     }
       
    61 
       
    62 
       
    63 // ---------------------------------------------------------------------------
       
    64 // ---------------------------------------------------------------------------
       
    65 //
       
    66 CCSCEngEcomMonitor::~CCSCEngEcomMonitor()
       
    67     {
       
    68     CSCENGDEBUG( "CCSCEngEcomMonitor::~CCSCEngEcomMonitor - begin" ); 
       
    69 
       
    70     Cancel();
       
    71     iEcomSession.Close();
       
    72     
       
    73     CSCENGDEBUG( "CCSCEngEcomMonitor::~CCSCEngEcomMonitor - end" ); 
       
    74     }
       
    75 
       
    76 
       
    77 // ---------------------------------------------------------------------------
       
    78 // From CActive
       
    79 // CCSCEngEcomMonitor::RunL
       
    80 // ---------------------------------------------------------------------------
       
    81 //
       
    82 void CCSCEngEcomMonitor::RunL()
       
    83     {
       
    84     CSCENGDEBUG( "CCSCEngEcomMonitor::RunL - begin" );
       
    85     
       
    86     iObserver.NotifyEcomEvent();
       
    87             
       
    88     // Start monitoring changed in ECom session again.    
       
    89     StartMonitoring();
       
    90     
       
    91     CSCENGDEBUG( "CCSCEngEcomMonitor::RunL - end" );
       
    92     }
       
    93     
       
    94     
       
    95 // ---------------------------------------------------------------------------
       
    96 // From CActive
       
    97 // CCSCEngEcomMonitor::DoCancel
       
    98 // ---------------------------------------------------------------------------
       
    99 //
       
   100 void CCSCEngEcomMonitor::DoCancel()
       
   101     {
       
   102     // Cancel ECom session notification service.
       
   103     iEcomSession.CancelNotifyOnChange( iStatus );
       
   104     }    
       
   105 
       
   106 
       
   107 // ---------------------------------------------------------------------------
       
   108 // CCSCEngEcomMonitor::StartMonitoring
       
   109 // Starts monitoring about ECom notifications.
       
   110 // ---------------------------------------------------------------------------
       
   111 //
       
   112 void CCSCEngEcomMonitor::StartMonitoring()
       
   113     {
       
   114     // Attach to ECom session notification service.
       
   115     if ( !IsActive() )
       
   116         {
       
   117         iEcomSession.NotifyOnChange( iStatus );
       
   118         SetActive();
       
   119         }
       
   120     }
       
   121     
       
   122 // ---------------------------------------------------------------------------
       
   123 // CCSCEngEcomMonitor::ResetAndDestroy
       
   124 // Frees memory allocated by array in case of leave.
       
   125 // ---------------------------------------------------------------------------
       
   126 //
       
   127 void CCSCEngEcomMonitor::ResetAndDestroy( TAny* aArray )
       
   128     {
       
   129     CSCENGDEBUG( "CCSCEngEcomMonitor::ResetAndDestroy" );	
       
   130     if ( aArray )
       
   131         {
       
   132         RImplInfoPtrArray* array = 
       
   133             reinterpret_cast<RImplInfoPtrArray*>( aArray );
       
   134         array->ResetAndDestroy();
       
   135         }
       
   136     }