29
|
1 |
// Copyright (c) 2010 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 |
/**
|
|
17 |
@file
|
|
18 |
@internalComponent
|
|
19 |
*/
|
|
20 |
|
|
21 |
#include <mtp/mmtpdataproviderframework.h>
|
|
22 |
#include <mtp/mtpprotocolconstants.h>
|
|
23 |
#include <mtp/tmtptyperequest.h>
|
|
24 |
|
|
25 |
#include "cmtppbcgetdevicepropvalue.h"
|
|
26 |
#include "mtpplaybackcontroldpconst.h"
|
|
27 |
#include "cmtpplaybackcontroldp.h"
|
|
28 |
#include "cmtpplaybackproperty.h"
|
|
29 |
#include "cmtpplaybackcommand.h"
|
|
30 |
#include "mtpplaybackcontrolpanic.h"
|
49
|
31 |
#include "OstTraceDefinitions.h"
|
|
32 |
#ifdef OST_TRACE_COMPILER_IN_USE
|
|
33 |
#include "cmtppbcgetdevicepropvalueTraces.h"
|
|
34 |
#endif
|
29
|
35 |
|
|
36 |
|
|
37 |
/**
|
|
38 |
Two-phase constructor.
|
|
39 |
@param aPlugin The data provider plugin
|
|
40 |
@param aFramework The data provider framework
|
|
41 |
@param aConnection The connection from which the request comes
|
|
42 |
@return a pointer to the created request processor object.
|
|
43 |
*/
|
|
44 |
MMTPRequestProcessor* CMTPPbcGetDevicePropValue::NewL(MMTPDataProviderFramework& aFramework,
|
|
45 |
MMTPConnection& aConnection,
|
|
46 |
CMTPPlaybackControlDataProvider& aDataProvider)
|
|
47 |
{
|
49
|
48 |
OstTraceFunctionEntry0( CMTPPBCGETDEVICEPROPVALUE_NEWL_ENTRY );
|
29
|
49 |
CMTPPbcGetDevicePropValue* self = new (ELeave) CMTPPbcGetDevicePropValue(aFramework, aConnection, aDataProvider);
|
49
|
50 |
OstTraceFunctionExit0( CMTPPBCGETDEVICEPROPVALUE_NEWL_EXIT );
|
29
|
51 |
return self;
|
|
52 |
}
|
|
53 |
|
|
54 |
/**
|
|
55 |
Destructor.
|
|
56 |
*/
|
|
57 |
CMTPPbcGetDevicePropValue::~CMTPPbcGetDevicePropValue()
|
|
58 |
{
|
49
|
59 |
OstTraceFunctionEntry0( CMTPPBCGETDEVICEPROPVALUE_CMTPPBCGETDEVICEPROPVALUE_ENTRY );
|
29
|
60 |
delete iPbCmd;
|
49
|
61 |
OstTraceFunctionExit0( CMTPPBCGETDEVICEPROPVALUE_CMTPPBCGETDEVICEPROPVALUE_EXIT );
|
29
|
62 |
}
|
|
63 |
|
|
64 |
/**
|
|
65 |
Constructor.
|
|
66 |
*/
|
|
67 |
CMTPPbcGetDevicePropValue::CMTPPbcGetDevicePropValue(MMTPDataProviderFramework& aFramework,
|
|
68 |
MMTPConnection& aConnection,
|
|
69 |
CMTPPlaybackControlDataProvider& aDataProvider):
|
|
70 |
CMTPRequestProcessor(aFramework, aConnection, 0, NULL),
|
|
71 |
iPlaybackControlDp(aDataProvider)
|
|
72 |
{
|
49
|
73 |
OstTraceFunctionEntry0( DUP1_CMTPPBCGETDEVICEPROPVALUE_CMTPPBCGETDEVICEPROPVALUE_ENTRY );
|
|
74 |
OstTraceFunctionExit0( DUP1_CMTPPBCGETDEVICEPROPVALUE_CMTPPBCGETDEVICEPROPVALUE_EXIT );
|
29
|
75 |
}
|
|
76 |
|
|
77 |
/**
|
|
78 |
CMTPPbcGetDevicePropValue request validator.
|
|
79 |
@return EMTPRespCodeOK if request is verified, otherwise one of the error response codes
|
|
80 |
*/
|
|
81 |
TMTPResponseCode CMTPPbcGetDevicePropValue::CheckRequestL()
|
|
82 |
{
|
49
|
83 |
OstTraceFunctionEntry0( CMTPPBCGETDEVICEPROPVALUE_CHECKREQUESTL_ENTRY );
|
29
|
84 |
TMTPResponseCode respCode = CMTPRequestProcessor::CheckRequestL();
|
|
85 |
if(respCode == EMTPRespCodeOK)
|
|
86 |
{
|
|
87 |
respCode = EMTPRespCodeDevicePropNotSupported;
|
|
88 |
TUint32 propCode = Request().Uint32(TMTPTypeRequest::ERequestParameter1);
|
|
89 |
const TInt count = sizeof(KMTPPlaybackControlDpSupportedProperties) /
|
|
90 |
sizeof(KMTPPlaybackControlDpSupportedProperties[0]);
|
|
91 |
for (TUint i(0); (i < count); i++)
|
|
92 |
{
|
|
93 |
if (propCode == KMTPPlaybackControlDpSupportedProperties[i])
|
|
94 |
{
|
|
95 |
respCode = EMTPRespCodeOK;
|
|
96 |
break;
|
|
97 |
}
|
|
98 |
}
|
|
99 |
}
|
49
|
100 |
OstTraceFunctionExit0( CMTPPBCGETDEVICEPROPVALUE_CHECKREQUESTL_EXIT );
|
29
|
101 |
return respCode;
|
|
102 |
}
|
|
103 |
|
|
104 |
/**
|
|
105 |
CMTPPbcGetDevicePropValue request handler.
|
|
106 |
*/
|
|
107 |
void CMTPPbcGetDevicePropValue::ServiceL()
|
|
108 |
{
|
49
|
109 |
OstTraceFunctionEntry0( CMTPPBCGETDEVICEPROPVALUE_SERVICEL_ENTRY );
|
29
|
110 |
//Destroy the previous playback command.
|
|
111 |
delete iPbCmd;
|
|
112 |
iPbCmd = NULL;
|
|
113 |
|
|
114 |
//Get the device property code
|
|
115 |
TMTPDevicePropertyCode propCode(static_cast<TMTPDevicePropertyCode>(Request().
|
|
116 |
Uint32(TMTPTypeRequest::ERequestParameter1)));
|
|
117 |
|
|
118 |
TMTPPbCtrlData data;
|
|
119 |
data.iOptCode = EMTPOpCodeGetDevicePropValue;
|
|
120 |
data.iDevPropCode = propCode;
|
|
121 |
|
|
122 |
//Get a new playback command.
|
|
123 |
CMTPPlaybackMap& map(iPlaybackControlDp.GetPlaybackMap());
|
|
124 |
TInt result = map.GetPlaybackControlCommand(data, &iPbCmd);
|
|
125 |
|
|
126 |
if(KErrNone == result)
|
|
127 |
{
|
|
128 |
MMTPPlaybackControl& control(iPlaybackControlDp.GetPlaybackControlL());
|
|
129 |
TRAPD(err, control.CommandL(*iPbCmd, this));
|
|
130 |
__ASSERT_ALWAYS((err == KErrNone), SendResponseL(EMTPRespCodeParameterNotSupported));
|
|
131 |
}
|
|
132 |
else if(KErrNotSupported == result)
|
|
133 |
{
|
|
134 |
SendResponseL(EMTPRespCodeDevicePropNotSupported);
|
|
135 |
}
|
|
136 |
else
|
|
137 |
{
|
|
138 |
SendResponseL(EMTPRespCodeParameterNotSupported);
|
|
139 |
}
|
49
|
140 |
OstTraceFunctionExit0( CMTPPBCGETDEVICEPROPVALUE_SERVICEL_EXIT );
|
29
|
141 |
}
|
|
142 |
|
|
143 |
void CMTPPbcGetDevicePropValue::HandlePlaybackCommandCompleteL(CMTPPlaybackCommand* aCmd, TInt aErr)
|
|
144 |
{
|
49
|
145 |
OstTraceFunctionEntry0( CMTPPBCGETDEVICEPROPVALUE_HANDLEPLAYBACKCOMMANDCOMPLETEL_ENTRY );
|
|
146 |
OstTrace1( TRACE_NORMAL, CMTPPBCGETDEVICEPROPVALUE_HANDLEPLAYBACKCOMMANDCOMPLETEL, "aErr %d", aErr );
|
|
147 |
|
29
|
148 |
|
|
149 |
//Handle the error
|
|
150 |
TBool useDefault = EFalse;
|
|
151 |
switch(aErr)
|
|
152 |
{
|
|
153 |
case KPlaybackErrNone:
|
|
154 |
{
|
|
155 |
__ASSERT_DEBUG((aCmd != NULL), Panic(EMTPPBDataNullErr));
|
|
156 |
__ASSERT_DEBUG((aCmd->PlaybackCommand() == iPbCmd->PlaybackCommand()), Panic(EMTPPBArgumentErr));
|
49
|
157 |
__ASSERT_ALWAYS_OST((aCmd != NULL), OstTrace0( TRACE_ERROR, DUP2_CMTPPBCGETDEVICEPROPVALUE_HANDLEPLAYBACKCOMMANDCOMPLETEL, "Error argument" ), User::Leave(KErrArgument));
|
|
158 |
__ASSERT_ALWAYS_OST((aCmd->PlaybackCommand() == iPbCmd->PlaybackCommand()), OstTrace0( TRACE_ERROR, DUP3_CMTPPBCGETDEVICEPROPVALUE_HANDLEPLAYBACKCOMMANDCOMPLETEL, "Error argument" ), User::Leave(KErrArgument));
|
|
159 |
OstTrace1( TRACE_NORMAL, DUP1_CMTPPBCGETDEVICEPROPVALUE_HANDLEPLAYBACKCOMMANDCOMPLETEL, "aCmd %d", aCmd->PlaybackCommand() );
|
29
|
160 |
}
|
|
161 |
break;
|
|
162 |
case KPlaybackErrContextInvalid:
|
|
163 |
{
|
|
164 |
useDefault = ETrue;
|
|
165 |
}
|
|
166 |
break;
|
|
167 |
case KPlaybackErrDeviceUnavailable:
|
|
168 |
{
|
|
169 |
iPlaybackControlDp.RequestToResetPbCtrl();
|
|
170 |
SendResponseL(EMTPRespCodeDeviceBusy);
|
|
171 |
}
|
49
|
172 |
OstTraceFunctionExit0( CMTPPBCGETDEVICEPROPVALUE_HANDLEPLAYBACKCOMMANDCOMPLETEL_EXIT );
|
29
|
173 |
return;
|
|
174 |
default:
|
|
175 |
{
|
|
176 |
SendResponseL(EMTPRespCodeDeviceBusy);
|
|
177 |
}
|
49
|
178 |
OstTraceFunctionExit0( DUP1_CMTPPBCGETDEVICEPROPVALUE_HANDLEPLAYBACKCOMMANDCOMPLETEL_EXIT );
|
29
|
179 |
return;
|
|
180 |
}
|
|
181 |
|
|
182 |
CMTPPlaybackProperty& property(iPlaybackControlDp.GetPlaybackProperty());
|
|
183 |
TMTPDevicePropertyCode propCode(static_cast<TMTPDevicePropertyCode>
|
|
184 |
(Request().Uint32(TMTPTypeRequest::ERequestParameter1)));
|
|
185 |
|
|
186 |
switch(propCode)
|
|
187 |
{
|
|
188 |
case EMTPDevicePropCodePlaybackRate:
|
|
189 |
{
|
|
190 |
CMTPPlaybackMap& map(iPlaybackControlDp.GetPlaybackMap());
|
|
191 |
TInt32 val;
|
|
192 |
if(useDefault)
|
|
193 |
{
|
|
194 |
property.GetDefaultPropertyValueL(propCode, val);
|
|
195 |
}
|
|
196 |
else
|
|
197 |
{
|
|
198 |
TMTPPlaybackState state = static_cast<TMTPPlaybackState>(aCmd->ParamL().Uint32L());
|
|
199 |
val = map.PlaybackRateL(state);
|
|
200 |
}
|
|
201 |
iInt32.Set(val);
|
|
202 |
SendDataL(iInt32);
|
|
203 |
}
|
|
204 |
break;
|
|
205 |
|
|
206 |
case EMTPDevicePropCodePlaybackObject:
|
|
207 |
{
|
|
208 |
CMTPPlaybackMap& map(iPlaybackControlDp.GetPlaybackMap());
|
|
209 |
TUint32 val;
|
|
210 |
if(useDefault)
|
|
211 |
{
|
|
212 |
property.GetDefaultPropertyValueL(propCode, val);
|
|
213 |
}
|
|
214 |
else
|
|
215 |
{
|
|
216 |
val = map.ObjectHandleL(aCmd->ParamL().SuidSetL().Suid());
|
|
217 |
}
|
|
218 |
iUint32.Set(val);
|
|
219 |
SendDataL(iUint32);
|
|
220 |
}
|
|
221 |
break;
|
|
222 |
|
|
223 |
case EMTPDevicePropCodeVolume:
|
|
224 |
case EMTPDevicePropCodePlaybackContainerIndex:
|
|
225 |
case EMTPDevicePropCodePlaybackPosition:
|
|
226 |
{
|
|
227 |
TUint32 val;
|
|
228 |
if(useDefault)
|
|
229 |
{
|
|
230 |
property.GetDefaultPropertyValueL(propCode, val);
|
|
231 |
}
|
|
232 |
else
|
|
233 |
{
|
|
234 |
val = aCmd->ParamL().Uint32L();
|
|
235 |
}
|
|
236 |
iUint32.Set(val);
|
|
237 |
SendDataL(iUint32);
|
|
238 |
}
|
|
239 |
break;
|
|
240 |
|
|
241 |
default:
|
|
242 |
SendResponseL(EMTPRespCodeDevicePropNotSupported);
|
|
243 |
break;
|
|
244 |
}
|
49
|
245 |
OstTraceFunctionExit0( DUP2_CMTPPBCGETDEVICEPROPVALUE_HANDLEPLAYBACKCOMMANDCOMPLETEL_EXIT );
|
29
|
246 |
}
|
|
247 |
|