|
1 /* |
|
2 * Copyright (c) 2008-2008 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: Java RemCon Observer Active Object |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include "javaremconobserver.h" |
|
20 #include <jdebug.h> |
|
21 |
|
22 const TInt KMaxQueueSize(32); |
|
23 |
|
24 // ======== MEMBER FUNCTIONS ======== |
|
25 |
|
26 // --------------------------------------------------------------------------- |
|
27 // CJavaRemConObserver::NewL() |
|
28 // --------------------------------------------------------------------------- |
|
29 // |
|
30 EXPORT_C CJavaRemConObserver* CJavaRemConObserver::NewL( |
|
31 MRemConCoreApiTargetObserver& aObserver) |
|
32 { |
|
33 CJavaRemConObserver* self = new(ELeave) CJavaRemConObserver(aObserver); |
|
34 CleanupStack::PushL(self); |
|
35 self->ConstructL(); |
|
36 CleanupStack::Pop(self); |
|
37 return self; |
|
38 } |
|
39 |
|
40 // --------------------------------------------------------------------------- |
|
41 // CJavaRemConObserver::CJavaRemConObserver() |
|
42 // --------------------------------------------------------------------------- |
|
43 // |
|
44 CJavaRemConObserver::CJavaRemConObserver( |
|
45 MRemConCoreApiTargetObserver& aObserver) : |
|
46 CActive(CActive::EPriorityStandard), |
|
47 iObserver(aObserver) |
|
48 { |
|
49 CActiveScheduler::Add(this); |
|
50 } |
|
51 |
|
52 // --------------------------------------------------------------------------- |
|
53 // CJavaRemConObserver::ConstructL() |
|
54 // --------------------------------------------------------------------------- |
|
55 // |
|
56 void CJavaRemConObserver::ConstructL() |
|
57 { |
|
58 iQueue.CreateLocal(KMaxQueueSize); |
|
59 IssueRequest(); |
|
60 } |
|
61 |
|
62 // --------------------------------------------------------------------------- |
|
63 // CJavaRemConObserver::IssueRequest() |
|
64 // --------------------------------------------------------------------------- |
|
65 // |
|
66 void CJavaRemConObserver::IssueRequest() |
|
67 { |
|
68 iQueue.NotifyDataAvailable(iStatus); |
|
69 SetActive(); |
|
70 } |
|
71 |
|
72 // --------------------------------------------------------------------------- |
|
73 // CJavaRemConObserver::~CJavaRemConObserver() |
|
74 // --------------------------------------------------------------------------- |
|
75 // |
|
76 CJavaRemConObserver ::~CJavaRemConObserver() |
|
77 { |
|
78 Cancel(); |
|
79 iQueue.Close(); |
|
80 } |
|
81 |
|
82 // --------------------------------------------------------------------------- |
|
83 // CJavaRemConObserver::DoCancel() |
|
84 // --------------------------------------------------------------------------- |
|
85 // |
|
86 void CJavaRemConObserver::DoCancel() |
|
87 { |
|
88 iQueue.CancelDataAvailable(); |
|
89 } |
|
90 |
|
91 // --------------------------------------------------------------------------- |
|
92 // CJavaRemConObserver::AddPlayMessage() |
|
93 // --------------------------------------------------------------------------- |
|
94 // |
|
95 void CJavaRemConObserver::AddPlayMessage(TRemConCoreApiPlaybackSpeed aSpeed, |
|
96 TRemConCoreApiButtonAction aButtonAct) |
|
97 { |
|
98 DEBUG_INT2("CJavaRemConObserver::SetPlayParameters - aSpeed = %d, aButtonAct = %d", aSpeed, aButtonAct); |
|
99 TJavaRemConMessage message; |
|
100 message.iMethod = EMethodMrccatoPlay; |
|
101 message.iSpeed = aSpeed; |
|
102 message.iButtonAct = aButtonAct; |
|
103 iQueue.Send(message); |
|
104 } |
|
105 |
|
106 // --------------------------------------------------------------------------- |
|
107 // CJavaRemConObserver::AddCommandMessage() |
|
108 // --------------------------------------------------------------------------- |
|
109 // |
|
110 void CJavaRemConObserver::AddCommandMessage( |
|
111 TRemConCoreApiOperationId aOperationId, |
|
112 TRemConCoreApiButtonAction aButtonAct) |
|
113 { |
|
114 DEBUG_INT2("CJavaRemConObserver::SetCommandParameters - aOperationId = %d, aButtonAct = %d", aOperationId, aButtonAct); |
|
115 TJavaRemConMessage message; |
|
116 message.iMethod = EMethodMrccatoCommand; |
|
117 message.iOperationId = aOperationId; |
|
118 message.iButtonAct = aButtonAct; |
|
119 iQueue.Send(message); |
|
120 } |
|
121 |
|
122 // --------------------------------------------------------------------------- |
|
123 // CJavaRemConObserver::RunL() |
|
124 // --------------------------------------------------------------------------- |
|
125 // |
|
126 void CJavaRemConObserver::RunL() |
|
127 { |
|
128 DEBUG("+CJavaRemConObserver::RunL() "); |
|
129 TJavaRemConMessage message; |
|
130 iQueue.Receive(message); |
|
131 switch (message.iMethod) |
|
132 { |
|
133 case EMethodNone: |
|
134 DEBUG("CJavaRemConObserver::RunL - EMethodNone"); |
|
135 break; |
|
136 case EMethodMrccatoCommand: |
|
137 DEBUG_INT2("CJavaRemConObserver::RunL - EMethodMrccatoCommand: aOperationId = %d, aButtonAct = %d", message.iOperationId, message.iButtonAct); |
|
138 iObserver.MrccatoCommand(message.iOperationId, |
|
139 message.iButtonAct); |
|
140 break; |
|
141 case EMethodMrccatoPlay: |
|
142 DEBUG_INT2("CJavaRemConObserver::RunL - EMethodMrccatoPlay: iSpeed = %d, aButtonAct = %d", message.iSpeed, message.iButtonAct); |
|
143 iObserver.MrccatoPlay(message.iSpeed, |
|
144 message.iButtonAct); |
|
145 break; |
|
146 default: |
|
147 break; |
|
148 } |
|
149 IssueRequest(); |
|
150 DEBUG("-CJavaRemConObserver::RunL() "); |
|
151 } |