|
1 // Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // |
|
15 |
|
16 #include "mmrcclientmsgqueuehandler.h" |
|
17 #include "mmrcmsgqueuehandlerobserver.h" |
|
18 |
|
19 /** |
|
20 */ |
|
21 CMMRCClientMsgQueueHandler* CMMRCClientMsgQueueHandler::NewL( |
|
22 RMsgQueue<TMMRCQueueItem>& aMsgQueue, |
|
23 MMMRCMsgQueueHandlerObserver& aObserver) |
|
24 { |
|
25 CMMRCClientMsgQueueHandler* self = new(ELeave) CMMRCClientMsgQueueHandler(aMsgQueue,aObserver); |
|
26 CleanupStack::PushL(self); |
|
27 self->ConstructL(); |
|
28 CleanupStack::Pop(); |
|
29 return self; |
|
30 } |
|
31 |
|
32 /** |
|
33 */ |
|
34 CMMRCClientMsgQueueHandler::CMMRCClientMsgQueueHandler( |
|
35 RMsgQueue<TMMRCQueueItem>& aMsgQueue, |
|
36 MMMRCMsgQueueHandlerObserver& aObserver) |
|
37 :CActive(EPriorityStandard), |
|
38 iMsgQueue(aMsgQueue), |
|
39 iObserver(aObserver) |
|
40 { |
|
41 CActiveScheduler::Add(this); |
|
42 } |
|
43 |
|
44 /** |
|
45 */ |
|
46 void CMMRCClientMsgQueueHandler::ConstructL() |
|
47 { |
|
48 ReceiveEvents(); |
|
49 } |
|
50 |
|
51 /** |
|
52 */ |
|
53 CMMRCClientMsgQueueHandler::~CMMRCClientMsgQueueHandler() |
|
54 { |
|
55 Cancel(); |
|
56 iMsgQueue.Close(); |
|
57 } |
|
58 |
|
59 /** |
|
60 */ |
|
61 void CMMRCClientMsgQueueHandler::ReceiveEvents() |
|
62 { |
|
63 if(!IsActive()) |
|
64 { |
|
65 iMsgQueue.NotifyDataAvailable(iStatus); |
|
66 SetActive(); |
|
67 } |
|
68 } |
|
69 |
|
70 /** |
|
71 */ |
|
72 void CMMRCClientMsgQueueHandler::RunL() |
|
73 { |
|
74 TMMRCQueueItem message; |
|
75 TInt error = iMsgQueue.Receive(message); |
|
76 iObserver.HandleMessage(message); |
|
77 ReceiveEvents(); |
|
78 } |
|
79 |
|
80 /** |
|
81 */ |
|
82 TInt CMMRCClientMsgQueueHandler::RunError(TInt /*aError*/) |
|
83 { |
|
84 return KErrNone; |
|
85 } |
|
86 |
|
87 /** |
|
88 */ |
|
89 void CMMRCClientMsgQueueHandler::DoCancel() |
|
90 { |
|
91 iMsgQueue.CancelDataAvailable(); |
|
92 } |
|
93 |
|
94 //EOF |