ncdengine/provider/deviceinteraction/src/ncdactiveoperationobserver.cpp
changeset 0 ba25891c3a9e
equal deleted inserted replaced
-1:000000000000 0:ba25891c3a9e
       
     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:   CNcdActiveOperationObserver
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include "ncdactiveoperationobserver.h"
       
    20 #include "ncdasyncoperationobserver.h"
       
    21 
       
    22 
       
    23 CNcdActiveOperationObserver* CNcdActiveOperationObserver::NewL( MNcdAsyncOperationObserver& aObserver )
       
    24     {
       
    25     CNcdActiveOperationObserver* self = 
       
    26         CNcdActiveOperationObserver::NewLC( aObserver ); 
       
    27     CleanupStack::Pop( self );
       
    28     return self;
       
    29     }
       
    30 
       
    31 
       
    32 CNcdActiveOperationObserver* CNcdActiveOperationObserver::NewLC( MNcdAsyncOperationObserver& aObserver )
       
    33     {
       
    34     CNcdActiveOperationObserver* self = 
       
    35         new( ELeave ) CNcdActiveOperationObserver( aObserver );
       
    36     CleanupStack::PushL( self );
       
    37     self->ConstructL();
       
    38     return self;    
       
    39     }
       
    40 
       
    41 
       
    42 CNcdActiveOperationObserver::CNcdActiveOperationObserver( MNcdAsyncOperationObserver& aObserver )
       
    43 : CActive( CActive::EPriorityStandard ), 
       
    44   iObserver( aObserver )
       
    45     {
       
    46     
       
    47     }
       
    48 
       
    49 
       
    50 void CNcdActiveOperationObserver::ConstructL()
       
    51     {
       
    52     CActiveScheduler::Add( this );
       
    53     }
       
    54 
       
    55 
       
    56 CNcdActiveOperationObserver::~CNcdActiveOperationObserver()
       
    57     {
       
    58     // This is always good and safe to do in CActive objects.
       
    59     Cancel();
       
    60     }
       
    61 
       
    62 
       
    63 void CNcdActiveOperationObserver::DoCancel()
       
    64     {
       
    65     // Because this is just an observer itself.
       
    66     // Do not do anything. Do not even inform the observer
       
    67     // of this class object about this cancellation. 
       
    68     // Because the observer is not observing the events of 
       
    69     // this active object. It is observing the operations of 
       
    70     // some other object.
       
    71     }
       
    72 
       
    73 
       
    74 void CNcdActiveOperationObserver::StartToObserve()
       
    75     {
       
    76     SetActive();
       
    77     }
       
    78 
       
    79 
       
    80 void CNcdActiveOperationObserver::RunL()
       
    81     {
       
    82     // Just forward the information to the observer.
       
    83     AsyncObserver().AsyncOperationComplete( iStatus.Int() );
       
    84     }
       
    85 
       
    86 
       
    87 MNcdAsyncOperationObserver& CNcdActiveOperationObserver::AsyncObserver() const
       
    88     {
       
    89     return iObserver;
       
    90     }