devsoundextensions/effects/RoomLevel/RoomLevelProxy/Src/RoomLevelEventObserver.cpp
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/devsoundextensions/effects/RoomLevel/RoomLevelProxy/Src/RoomLevelEventObserver.cpp Tue Feb 02 01:56:55 2010 +0200
@@ -0,0 +1,151 @@
+/*
+* Copyright (c) 2004 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: Implementation of the active event observer.
+*
+*/
+
+
+
+
+// INCLUDE FILES
+#ifdef _DEBUG
+#include <e32svr.h>
+#endif
+
+#include "RoomLevelEventObserver.h"
+
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// CRoomLevelEventObserver::CRoomLevelEventObserver
+// C++ default constructor can NOT contain any code, that
+// might leave.
+// -----------------------------------------------------------------------------
+//
+CRoomLevelEventObserver::CRoomLevelEventObserver()
+ : CActive(CActive::EPriorityStandard),
+ iStopped(EFalse)
+ {
+ }
+
+// -----------------------------------------------------------------------------
+// CRoomLevelEventObserver::ConstructL
+// Symbian 2nd phase constructor can leave.
+// -----------------------------------------------------------------------------
+//
+void CRoomLevelEventObserver::ConstructL(
+ TMMFMessageDestinationPckg aMessageHandler,
+ MCustomCommand& aCustomCommand,
+ MRoomLevelCallback& aCallback )
+ {
+ CActiveScheduler::Add(this);
+ iMessageHandler = aMessageHandler;
+ iCustomCommand = &aCustomCommand;
+ iCallback = &aCallback;
+ }
+
+// -----------------------------------------------------------------------------
+// CRoomLevelEventObserver::NewL
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+CRoomLevelEventObserver* CRoomLevelEventObserver::NewL(
+ TMMFMessageDestinationPckg aMessageHandler,
+ MCustomCommand& aCustomCommand,
+ MRoomLevelCallback& aCallback )
+ {
+ CRoomLevelEventObserver* self = new(ELeave) CRoomLevelEventObserver();
+ CleanupStack::PushL(self);
+ self->ConstructL(aMessageHandler, aCustomCommand, aCallback);
+ CleanupStack::Pop(self);
+ return self;
+ }
+
+
+// -----------------------------------------------------------------------------
+// CRoomLevelEventObserver::~CRoomLevelEventObserver
+// Destructor
+// -----------------------------------------------------------------------------
+//
+CRoomLevelEventObserver::~CRoomLevelEventObserver()
+ {
+ // We should not have to cancel the outstanding request because the message
+ // handler will complete our request with KErrCancel in its destructor.
+ Cancel();
+ }
+
+// -----------------------------------------------------------------------------
+// CRoomLevelEventObserver::Start
+// Kickoff the event observer by issuing the first observation message.
+// -----------------------------------------------------------------------------
+//
+void CRoomLevelEventObserver::Start()
+ {
+ if( !iStopped && !IsActive() )
+ {
+ iCustomCommand->CustomCommandAsync(iMessageHandler, (TInt)ERoomObserve, KNullDesC8, KNullDesC8, iDataPckgFrom, iStatus);
+ iStopped = EFalse;
+ SetActive();
+ }
+ }
+
+// -----------------------------------------------------------------------------
+// CRoomLevelEventObserver::Stop
+// -----------------------------------------------------------------------------
+//
+void CRoomLevelEventObserver::Stop()
+ {
+ iStopped = ETrue;
+ }
+
+// -----------------------------------------------------------------------------
+// CRoomLevelEventObserver::RunL
+// Invoke by the active scheduler when a request completes, In this case, our
+// observation message has completed.
+// The proxy is notified. Afterwards, reissue the request to continue observation.
+// -----------------------------------------------------------------------------
+//
+void CRoomLevelEventObserver::RunL()
+ {
+#ifdef _DEBUG
+ RDebug::Print(_L("CRoomLevelEventObserver::RunL()\n"));
+#endif
+
+ if( iStatus == KErrNone )
+ {
+ iCallback->RoomLevelEvent(iDataPckgFrom);
+ Start();
+ }
+ else
+ {
+ iStopped = ETrue;
+ }
+ }
+
+// -----------------------------------------------------------------------------
+// CRoomLevelEventObserver::DoCancel
+// Cancels the current and any on going requests/tasks.
+// -----------------------------------------------------------------------------
+//
+void CRoomLevelEventObserver::DoCancel()
+ {
+#ifdef _DEBUG
+ RDebug::Print(_L("CRoomLevelEventObserver::DoCancel()\n"));
+#endif
+ iStopped = ETrue;
+ }
+
+// End of file
+