menufw/menufwui/mmextensions/mmextensionmanager/src/mmecomobserver.cpp
branchv5backport
changeset 14 1abc632eb502
parent 13 6205fd287e8a
child 20 636d517f67e6
equal deleted inserted replaced
13:6205fd287e8a 14:1abc632eb502
     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:   Interface of the Ecom observer
       
    15 *
       
    16 */
       
    17 
       
    18 #include <ecom/ecom.h>
       
    19 #include "mmecomobserver.h"
       
    20 
       
    21 // ---------------------------------------------------------------------------
       
    22 // 
       
    23 // ---------------------------------------------------------------------------
       
    24 //
       
    25 CMMEcomObserver::CMMEcomObserver() :
       
    26     CActive(EPriorityStandard) // Standard priority
       
    27     {
       
    28     }
       
    29 
       
    30 // ---------------------------------------------------------------------------
       
    31 // 
       
    32 // ---------------------------------------------------------------------------
       
    33 //
       
    34 CMMEcomObserver* CMMEcomObserver::NewLC( 
       
    35                                     MHNEcomInstallNotifierCallback* aCallback )
       
    36     {
       
    37     CMMEcomObserver* self = new ( ELeave ) CMMEcomObserver();
       
    38     CleanupStack::PushL(self);
       
    39     self->ConstructL( aCallback );
       
    40     return self;
       
    41     }
       
    42 
       
    43 // ---------------------------------------------------------------------------
       
    44 // 
       
    45 // ---------------------------------------------------------------------------
       
    46 //
       
    47 CMMEcomObserver* CMMEcomObserver::NewL( 
       
    48                                     MHNEcomInstallNotifierCallback* aCallback )
       
    49     {
       
    50     CMMEcomObserver* self = CMMEcomObserver::NewLC( aCallback );
       
    51     CleanupStack::Pop(); // self;
       
    52     return self;
       
    53     }
       
    54 
       
    55 // ---------------------------------------------------------------------------
       
    56 // 
       
    57 // ---------------------------------------------------------------------------
       
    58 //
       
    59 void CMMEcomObserver::ConstructL( MHNEcomInstallNotifierCallback* aCallback )
       
    60     {
       
    61     iCallback = aCallback;
       
    62     iSession = &REComSession::OpenL();
       
    63     iSession->NotifyOnChange( iStatus );
       
    64     CActiveScheduler::Add( this );
       
    65     SetActive();
       
    66     }
       
    67 
       
    68 // ---------------------------------------------------------------------------
       
    69 // 
       
    70 // ---------------------------------------------------------------------------
       
    71 //
       
    72 CMMEcomObserver::~CMMEcomObserver()
       
    73     {
       
    74     Cancel(); // Cancel any request, if outstanding
       
    75     if( iSession )
       
    76         {
       
    77         iSession->Close();
       
    78         }
       
    79     REComSession::FinalClose( );
       
    80     }
       
    81 
       
    82 // ---------------------------------------------------------------------------
       
    83 // 
       
    84 // ---------------------------------------------------------------------------
       
    85 //
       
    86 void CMMEcomObserver::DoCancel()
       
    87     {
       
    88     iSession->CancelNotifyOnChange( iStatus );
       
    89     }
       
    90 
       
    91 // ---------------------------------------------------------------------------
       
    92 // 
       
    93 // ---------------------------------------------------------------------------
       
    94 //
       
    95 void CMMEcomObserver::RunL()
       
    96     {
       
    97     iCallback->EcomChangedL();
       
    98     iSession->NotifyOnChange( iStatus );
       
    99     SetActive(); // Tell scheduler a request is active
       
   100     }
       
   101 
       
   102 // ---------------------------------------------------------------------------
       
   103 // 
       
   104 // ---------------------------------------------------------------------------
       
   105 //
       
   106 TInt CMMEcomObserver::RunError( TInt /*aError*/ )
       
   107     {
       
   108     return KErrNone;
       
   109     }