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