|
1 /* |
|
2 * Copyright (c) 2009 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: Music Player media key handler. |
|
15 * Helper class for sending response back to Remote Controller Framework. |
|
16 * |
|
17 */ |
|
18 |
|
19 // INCLUDE FILES |
|
20 #include "mpmediakeyremconresponse.h" |
|
21 #include "mptrace.h" |
|
22 |
|
23 |
|
24 /*! |
|
25 \internal |
|
26 C++ default constructor can NOT contain any code, that |
|
27 might leave. |
|
28 */ |
|
29 MpMediaKeyRemConResponse::MpMediaKeyRemConResponse( |
|
30 CRemConCoreApiTarget& aRemConCoreApiTarget ) |
|
31 : CActive( CActive::EPriorityStandard ), |
|
32 iRemConCoreApiTarget( aRemConCoreApiTarget ) |
|
33 { |
|
34 TX_ENTRY |
|
35 CActiveScheduler::Add( this ); |
|
36 TX_EXIT |
|
37 } |
|
38 |
|
39 /*! |
|
40 \internal |
|
41 Two-phased constructor. |
|
42 */ |
|
43 MpMediaKeyRemConResponse* MpMediaKeyRemConResponse::NewL( |
|
44 CRemConCoreApiTarget& aRemConCoreApiTarget ) |
|
45 { |
|
46 MpMediaKeyRemConResponse* self = |
|
47 new (ELeave) MpMediaKeyRemConResponse( aRemConCoreApiTarget ); |
|
48 |
|
49 return self; |
|
50 } |
|
51 |
|
52 /*! |
|
53 \internal |
|
54 Destructor |
|
55 */ |
|
56 MpMediaKeyRemConResponse::~MpMediaKeyRemConResponse() |
|
57 { |
|
58 TX_ENTRY |
|
59 Cancel(); |
|
60 iResponseArray.Close(); |
|
61 TX_EXIT |
|
62 } |
|
63 |
|
64 /*! |
|
65 \internal |
|
66 Send the any key response back to Remcon server |
|
67 */ |
|
68 void MpMediaKeyRemConResponse::CompleteAnyKey( |
|
69 TRemConCoreApiOperationId aOperationId ) |
|
70 { |
|
71 TX_ENTRY_ARGS(" OperationId: " << aOperationId ); |
|
72 if ( !IsActive() ) { |
|
73 switch ( aOperationId ) |
|
74 { |
|
75 case ERemConCoreApiPausePlayFunction: |
|
76 { |
|
77 iRemConCoreApiTarget.PausePlayFunctionResponse( iStatus, KErrNone ); |
|
78 SetActive(); |
|
79 break; |
|
80 } |
|
81 case ERemConCoreApiPlay: |
|
82 { |
|
83 iRemConCoreApiTarget.PlayResponse( iStatus, KErrNone ); |
|
84 SetActive(); |
|
85 break; |
|
86 } |
|
87 case ERemConCoreApiStop: |
|
88 { |
|
89 iRemConCoreApiTarget.StopResponse( iStatus, KErrNone ); |
|
90 SetActive(); |
|
91 break; |
|
92 } |
|
93 case ERemConCoreApiPause: |
|
94 { |
|
95 iRemConCoreApiTarget.PauseResponse( iStatus, KErrNone ); |
|
96 SetActive(); |
|
97 break; |
|
98 } |
|
99 case ERemConCoreApiRewind: |
|
100 { |
|
101 iRemConCoreApiTarget.RewindResponse( iStatus, KErrNone ); |
|
102 SetActive(); |
|
103 break; |
|
104 } |
|
105 case ERemConCoreApiFastForward: |
|
106 { |
|
107 iRemConCoreApiTarget.FastForwardResponse( iStatus, KErrNone ); |
|
108 SetActive(); |
|
109 break; |
|
110 } |
|
111 case ERemConCoreApiBackward: |
|
112 { |
|
113 iRemConCoreApiTarget.BackwardResponse( iStatus, KErrNone ); |
|
114 SetActive(); |
|
115 break; |
|
116 } |
|
117 case ERemConCoreApiForward: |
|
118 { |
|
119 iRemConCoreApiTarget.ForwardResponse( iStatus, KErrNone ); |
|
120 SetActive(); |
|
121 break; |
|
122 } |
|
123 case ERemConCoreApiVolumeUp: |
|
124 { |
|
125 iRemConCoreApiTarget.VolumeUpResponse( iStatus, KErrNone ); |
|
126 SetActive(); |
|
127 break; |
|
128 } |
|
129 case ERemConCoreApiVolumeDown: |
|
130 { |
|
131 iRemConCoreApiTarget.VolumeDownResponse( iStatus, KErrNone ); |
|
132 SetActive(); |
|
133 break; |
|
134 } |
|
135 default: |
|
136 { |
|
137 TInt error = KErrNone; |
|
138 iRemConCoreApiTarget.SendResponse( |
|
139 iStatus, aOperationId, error ); |
|
140 SetActive(); |
|
141 break; |
|
142 } |
|
143 } |
|
144 } |
|
145 // already active. Append to array and complete later. |
|
146 else |
|
147 { |
|
148 iResponseArray.Append( aOperationId ); |
|
149 } |
|
150 TX_EXIT |
|
151 } |
|
152 |
|
153 /*! |
|
154 \internal |
|
155 Implements cancellation of an outstanding request. |
|
156 */ |
|
157 void MpMediaKeyRemConResponse::DoCancel() |
|
158 { |
|
159 } |
|
160 |
|
161 /*! |
|
162 \internal |
|
163 Handles an active object's request completion event. |
|
164 */ |
|
165 void MpMediaKeyRemConResponse::RunL() |
|
166 { |
|
167 TX_ENTRY_ARGS( "iStatus=" << iStatus.Int() ); |
|
168 // if any existing -> Send response |
|
169 if ( iResponseArray.Count() ) { |
|
170 CompleteAnyKey( iResponseArray[0] ); |
|
171 // Remove already completed key |
|
172 iResponseArray.Remove( 0 ); |
|
173 iResponseArray.Compress(); |
|
174 } |
|
175 TX_EXIT |
|
176 } |
|
177 |
|
178 // End of File |