|
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 ERemConCoreApiVolumeUp: |
|
74 { |
|
75 iRemConCoreApiTarget.VolumeUpResponse( iStatus, KErrNone ); |
|
76 SetActive(); |
|
77 break; |
|
78 } |
|
79 case ERemConCoreApiVolumeDown: |
|
80 { |
|
81 iRemConCoreApiTarget.VolumeDownResponse( iStatus, KErrNone ); |
|
82 SetActive(); |
|
83 break; |
|
84 } |
|
85 default: |
|
86 { |
|
87 TInt error = KErrNone; |
|
88 iRemConCoreApiTarget.SendResponse( |
|
89 iStatus, aOperationId, error ); |
|
90 SetActive(); |
|
91 break; |
|
92 } |
|
93 } |
|
94 } |
|
95 // already active. Append to array and complete later. |
|
96 else |
|
97 { |
|
98 iResponseArray.Append( aOperationId ); |
|
99 } |
|
100 } |
|
101 |
|
102 // --------------------------------------------------------------------------- |
|
103 // Implements cancellation of an outstanding request. |
|
104 // --------------------------------------------------------------------------- |
|
105 // |
|
106 void MpMediaKeyRemConResponse::DoCancel() |
|
107 { |
|
108 } |
|
109 |
|
110 // --------------------------------------------------------------------------- |
|
111 // Handles an active object's request completion event. |
|
112 // --------------------------------------------------------------------------- |
|
113 // |
|
114 void MpMediaKeyRemConResponse::RunL() |
|
115 { |
|
116 MPX_DEBUG2( "MpMediaKeyRemConResponse.RunL() -- iStatus=%d", iStatus.Int() ); |
|
117 |
|
118 // if any existing -> Send response |
|
119 if ( iResponseArray.Count() ) |
|
120 { |
|
121 CompleteAnyKey( iResponseArray[0] ); |
|
122 // Remove already completed key |
|
123 iResponseArray.Remove( 0 ); |
|
124 iResponseArray.Compress(); |
|
125 } |
|
126 } |
|
127 |
|
128 // End of File |