os/mm/devsoundextensions/effects/DistAtten/DistanceAttenuationProxy/Src/DistanceAttenuationEventObserver.cpp
Update contrib.
2 * Copyright (c) 2004 Nokia Corporation and/or its subsidiary(-ies).
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".
9 * Initial Contributors:
10 * Nokia Corporation - initial contribution.
14 * Description: Implementation of the active event observer.
26 #include "DistanceAttenuationEventObserver.h"
29 // ============================ MEMBER FUNCTIONS ===============================
31 // -----------------------------------------------------------------------------
32 // CDistanceAttenuationEventObserver::CDistanceAttenuationEventObserver
33 // C++ default constructor can NOT contain any code, that
35 // -----------------------------------------------------------------------------
37 CDistanceAttenuationEventObserver::CDistanceAttenuationEventObserver()
38 : CActive(CActive::EPriorityStandard),
43 // -----------------------------------------------------------------------------
44 // CDistanceAttenuationEventObserver::ConstructL
45 // Symbian 2nd phase constructor can leave.
46 // -----------------------------------------------------------------------------
48 void CDistanceAttenuationEventObserver::ConstructL(
49 TMMFMessageDestinationPckg aMessageHandler,
50 MCustomCommand& aCustomCommand,
51 MDistanceAttenuationCallback& aCallback )
53 CActiveScheduler::Add(this);
54 iMessageHandler = aMessageHandler;
55 iCustomCommand = &aCustomCommand;
56 iCallback = &aCallback;
59 // -----------------------------------------------------------------------------
60 // CDistanceAttenuationEventObserver::NewL
61 // Two-phased constructor.
62 // -----------------------------------------------------------------------------
64 CDistanceAttenuationEventObserver* CDistanceAttenuationEventObserver::NewL(
65 TMMFMessageDestinationPckg aMessageHandler,
66 MCustomCommand& aCustomCommand,
67 MDistanceAttenuationCallback& aCallback )
69 CDistanceAttenuationEventObserver* self = new(ELeave) CDistanceAttenuationEventObserver();
70 CleanupStack::PushL(self);
71 self->ConstructL(aMessageHandler, aCustomCommand, aCallback);
72 CleanupStack::Pop(self);
77 // -----------------------------------------------------------------------------
78 // CDistanceAttenuationEventObserver::~CDistanceAttenuationEventObserver
80 // -----------------------------------------------------------------------------
82 CDistanceAttenuationEventObserver::~CDistanceAttenuationEventObserver()
84 // We should not have to cancel the outstanding request because the message
85 // handler will complete our request with KErrCancel in its destructor.
89 // -----------------------------------------------------------------------------
90 // CDistanceAttenuationEventObserver::Start
91 // Kickoff the event observer by issuing the first observation message.
92 // -----------------------------------------------------------------------------
94 void CDistanceAttenuationEventObserver::Start()
96 if( !iStopped && !IsActive() )
98 iCustomCommand->CustomCommandAsync(iMessageHandler, (TInt)EDaefObserve, KNullDesC8, KNullDesC8, iDataPckgFrom, iStatus);
104 // -----------------------------------------------------------------------------
105 // CDistanceAttenuationEventObserver::Stop
106 // -----------------------------------------------------------------------------
108 void CDistanceAttenuationEventObserver::Stop()
113 // -----------------------------------------------------------------------------
114 // CDistanceAttenuationEventObserver::RunL
115 // Invoke by the active scheduler when a request completes, In this case, our
116 // observation message has completed.
117 // The proxy is notified. Afterwards, reissue the request to continue observation.
118 // -----------------------------------------------------------------------------
120 void CDistanceAttenuationEventObserver::RunL()
123 RDebug::Print(_L("CDistanceAttenuationEventObserver::RunL()\n"));
126 if( iStatus == KErrNone )
128 iCallback->DistanceAttenuationEvent(iDataPckgFrom);
137 // -----------------------------------------------------------------------------
138 // CDistanceAttenuationEventObserver::DoCancel
139 // Cancels the current and any on going requests/tasks.
140 // -----------------------------------------------------------------------------
142 void CDistanceAttenuationEventObserver::DoCancel()
145 RDebug::Print(_L("CDistanceAttenuationEventObserver::DoCancel()\n"));