1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/mm/mmresourcemgmt/mmresctrl/src/mmrcclient/mmrcclientmsgqueuehandler.cpp Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,94 @@
1.4 +// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
1.5 +// All rights reserved.
1.6 +// This component and the accompanying materials are made available
1.7 +// under the terms of "Eclipse Public License v1.0"
1.8 +// which accompanies this distribution, and is available
1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
1.10 +//
1.11 +// Initial Contributors:
1.12 +// Nokia Corporation - initial contribution.
1.13 +//
1.14 +// Contributors:
1.15 +//
1.16 +// Description:
1.17 +//
1.18 +
1.19 +#include "mmrcclientmsgqueuehandler.h"
1.20 +#include "mmrcmsgqueuehandlerobserver.h"
1.21 +
1.22 +/**
1.23 +*/
1.24 +CMMRCClientMsgQueueHandler* CMMRCClientMsgQueueHandler::NewL(
1.25 + RMsgQueue<TMMRCQueueItem>& aMsgQueue,
1.26 + MMMRCMsgQueueHandlerObserver& aObserver)
1.27 + {
1.28 + CMMRCClientMsgQueueHandler* self = new(ELeave) CMMRCClientMsgQueueHandler(aMsgQueue,aObserver);
1.29 + CleanupStack::PushL(self);
1.30 + self->ConstructL();
1.31 + CleanupStack::Pop();
1.32 + return self;
1.33 + }
1.34 +
1.35 +/**
1.36 +*/
1.37 +CMMRCClientMsgQueueHandler::CMMRCClientMsgQueueHandler(
1.38 + RMsgQueue<TMMRCQueueItem>& aMsgQueue,
1.39 + MMMRCMsgQueueHandlerObserver& aObserver)
1.40 + :CActive(EPriorityStandard),
1.41 + iMsgQueue(aMsgQueue),
1.42 + iObserver(aObserver)
1.43 + {
1.44 + CActiveScheduler::Add(this);
1.45 + }
1.46 +
1.47 +/**
1.48 +*/
1.49 +void CMMRCClientMsgQueueHandler::ConstructL()
1.50 + {
1.51 + ReceiveEvents();
1.52 + }
1.53 +
1.54 +/**
1.55 +*/
1.56 +CMMRCClientMsgQueueHandler::~CMMRCClientMsgQueueHandler()
1.57 + {
1.58 + Cancel();
1.59 + iMsgQueue.Close();
1.60 + }
1.61 +
1.62 +/**
1.63 +*/
1.64 +void CMMRCClientMsgQueueHandler::ReceiveEvents()
1.65 + {
1.66 + if(!IsActive())
1.67 + {
1.68 + iMsgQueue.NotifyDataAvailable(iStatus);
1.69 + SetActive();
1.70 + }
1.71 + }
1.72 +
1.73 +/**
1.74 +*/
1.75 +void CMMRCClientMsgQueueHandler::RunL()
1.76 + {
1.77 + TMMRCQueueItem message;
1.78 + TInt error = iMsgQueue.Receive(message);
1.79 + iObserver.HandleMessage(message);
1.80 + ReceiveEvents();
1.81 + }
1.82 +
1.83 +/**
1.84 +*/
1.85 +TInt CMMRCClientMsgQueueHandler::RunError(TInt /*aError*/)
1.86 + {
1.87 + return KErrNone;
1.88 + }
1.89 +
1.90 +/**
1.91 +*/
1.92 +void CMMRCClientMsgQueueHandler::DoCancel()
1.93 + {
1.94 + iMsgQueue.CancelDataAvailable();
1.95 + }
1.96 +
1.97 +//EOF