idlefw/src/framework/aiecomobserver.cpp
branchRCL_3
changeset 9 d0529222e3f0
equal deleted inserted replaced
4:1a2a00e78665 9:d0529222e3f0
       
     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:  CAiEcomObserver class implementation.
       
    15 *
       
    16 */
       
    17 
       
    18 // System includes
       
    19 
       
    20 // User incldues
       
    21 #include "aiecomobserver.h"
       
    22 
       
    23 
       
    24 // Constants
       
    25 
       
    26 // ======== LOCAL FUNCTIONS ========
       
    27 
       
    28 // ======== MEMBER FUNCTIONS ========
       
    29 //-----------------------------------------------------------------------------
       
    30 // CAiEcomObserver::CAiEcomObserver
       
    31 //
       
    32 //-----------------------------------------------------------------------------
       
    33 //
       
    34 CAiEcomObserver::CAiEcomObserver()
       
    35     : CActive( EPriorityStandard )
       
    36 	{
       
    37     CActiveScheduler::Add( this );
       
    38 	}
       
    39 
       
    40 //-----------------------------------------------------------------------------
       
    41 // CAiEcomObserver::NewLC
       
    42 //
       
    43 //-----------------------------------------------------------------------------
       
    44 //
       
    45 CAiEcomObserver* CAiEcomObserver::NewLC()
       
    46 	{
       
    47 	CAiEcomObserver* self = new ( ELeave ) CAiEcomObserver();
       
    48 	CleanupStack::PushL( self );
       
    49 	self->ConstructL();
       
    50 	return self;
       
    51 	}
       
    52       
       
    53 //-----------------------------------------------------------------------------
       
    54 // CAiEcomObserver::NewL
       
    55 //
       
    56 //-----------------------------------------------------------------------------
       
    57 //
       
    58 CAiEcomObserver* CAiEcomObserver::NewL()
       
    59 	{
       
    60 	CAiEcomObserver* self = CAiEcomObserver::NewLC();
       
    61 	CleanupStack::Pop( self ); 
       
    62 	return self;
       
    63 	}
       
    64 
       
    65 //-----------------------------------------------------------------------------
       
    66 // CAiEcomObserver::ConstructL
       
    67 //
       
    68 //-----------------------------------------------------------------------------
       
    69 //
       
    70 void CAiEcomObserver::ConstructL()
       
    71 	{
       
    72 	iEComSession = REComSession::OpenL();
       
    73 	StartObserving();
       
    74 	}
       
    75 
       
    76 //-----------------------------------------------------------------------------
       
    77 // CAiEcomObserver::~CAiEcomObserver
       
    78 //
       
    79 //-----------------------------------------------------------------------------
       
    80 //
       
    81 CAiEcomObserver::~CAiEcomObserver()
       
    82 	{
       
    83     // Cancel any request, if outstanding
       
    84 	Cancel();
       
    85     
       
    86     // Clean up memebers
       
    87     iObservers.Close();
       
    88          
       
    89     iEComSession.Close();   
       
    90 	}
       
    91 
       
    92 //-----------------------------------------------------------------------------
       
    93 // CAiEcomObserver::DoCancel
       
    94 //
       
    95 //-----------------------------------------------------------------------------
       
    96 //
       
    97 void CAiEcomObserver::DoCancel()
       
    98 	{
       
    99 	iEComSession.CancelNotifyOnChange( iStatus );
       
   100 	}
       
   101 
       
   102 //-----------------------------------------------------------------------------
       
   103 // CAiEcomObserver::StartObserving
       
   104 //
       
   105 //-----------------------------------------------------------------------------
       
   106 //
       
   107 void CAiEcomObserver::StartObserving()
       
   108 	{       
       
   109 	iEComSession.NotifyOnChange( iStatus );     
       
   110     SetActive();
       
   111 	}
       
   112 
       
   113 //-----------------------------------------------------------------------------
       
   114 // CAiEcomObserver::AddObserverL
       
   115 //
       
   116 //-----------------------------------------------------------------------------
       
   117 //
       
   118 void CAiEcomObserver::AddObserverL( MAiEcomObserver* aObserver )
       
   119     {
       
   120     if ( aObserver )
       
   121         {
       
   122         iObservers.AppendL( aObserver );
       
   123         }    
       
   124     }
       
   125 
       
   126 //-----------------------------------------------------------------------------
       
   127 // CAiEcomObserver::RunL
       
   128 //
       
   129 //-----------------------------------------------------------------------------
       
   130 //
       
   131 void CAiEcomObserver::RunL()
       
   132 	{   
       
   133     // Store completion status
       
   134     TInt status( iStatus.Int() );
       
   135 
       
   136     // Continue request
       
   137     StartObserving();
       
   138 
       
   139     // Notify observers
       
   140     if ( status == KErrNone )
       
   141         {
       
   142         NotifyObservers();
       
   143         }    
       
   144 	}
       
   145 
       
   146 //------------------------------------------------------------------------------
       
   147 // CAiEcomObserver::NotifyObservers
       
   148 //
       
   149 //------------------------------------------------------------------------------
       
   150 //
       
   151 void CAiEcomObserver::NotifyObservers()
       
   152     {
       
   153     TInt count( iObservers.Count() );
       
   154     
       
   155     for ( TInt i = 0; i < count; i++ )
       
   156         {        
       
   157         iObservers[i]->NotifyEcomRegistryChanged();
       
   158         }
       
   159     }
       
   160 
       
   161 // End of file