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/cmtptypedevicepropdesc.h>
|
|
22 |
|
|
23 |
#include "cmtppbcgetdevicepropdesc.h"
|
|
24 |
#include "mtpplaybackcontroldpconst.h"
|
|
25 |
#include "cmtpplaybackcontroldp.h"
|
|
26 |
#include "cmtpplaybackproperty.h"
|
|
27 |
#include "cmtpplaybackmap.h"
|
|
28 |
#include "cmtpplaybackcommand.h"
|
|
29 |
#include "mtpplaybackcontrolpanic.h"
|
49
|
30 |
#include "OstTraceDefinitions.h"
|
|
31 |
#ifdef OST_TRACE_COMPILER_IN_USE
|
|
32 |
#include "cmtppbcgetdevicepropdescTraces.h"
|
|
33 |
#endif
|
29
|
34 |
|
|
35 |
|
|
36 |
/**
|
|
37 |
Two-phase constructor.
|
|
38 |
@param aPlugin The data provider plugin
|
|
39 |
@param aFramework The data provider framework
|
|
40 |
@param aConnection The connection from which the request comes
|
|
41 |
@return a pointer to the created request processor object
|
|
42 |
*/
|
|
43 |
MMTPRequestProcessor* CMTPPbcGetDevicePropDesc::NewL(MMTPDataProviderFramework& aFramework,
|
|
44 |
MMTPConnection& aConnection,
|
|
45 |
CMTPPlaybackControlDataProvider& aDataProvider)
|
|
46 |
{
|
49
|
47 |
OstTraceFunctionEntry0( CMTPPBCGETDEVICEPROPDESC_NEWL_ENTRY );
|
29
|
48 |
CMTPPbcGetDevicePropDesc* self = new (ELeave) CMTPPbcGetDevicePropDesc(aFramework, aConnection, aDataProvider);
|
49
|
49 |
OstTraceFunctionExit0( CMTPPBCGETDEVICEPROPDESC_NEWL_EXIT );
|
29
|
50 |
return self;
|
|
51 |
}
|
|
52 |
|
|
53 |
/**
|
|
54 |
Destructor.
|
|
55 |
*/
|
|
56 |
CMTPPbcGetDevicePropDesc::~CMTPPbcGetDevicePropDesc()
|
|
57 |
{
|
49
|
58 |
OstTraceFunctionEntry0( CMTPPBCGETDEVICEPROPDESC_CMTPPBCGETDEVICEPROPDESC_ENTRY );
|
29
|
59 |
delete iPropDesc;
|
|
60 |
delete iPbCmd;
|
49
|
61 |
OstTraceFunctionExit0( CMTPPBCGETDEVICEPROPDESC_CMTPPBCGETDEVICEPROPDESC_EXIT );
|
29
|
62 |
}
|
|
63 |
|
|
64 |
/**
|
|
65 |
Constructor.
|
|
66 |
*/
|
|
67 |
CMTPPbcGetDevicePropDesc::CMTPPbcGetDevicePropDesc(MMTPDataProviderFramework& aFramework,
|
|
68 |
MMTPConnection& aConnection,
|
|
69 |
CMTPPlaybackControlDataProvider& aDataProvider) :
|
|
70 |
CMTPRequestProcessor(aFramework, aConnection, 0, NULL),
|
|
71 |
iPlaybackControlDp(aDataProvider)
|
|
72 |
{
|
49
|
73 |
OstTraceFunctionEntry0( DUP1_CMTPPBCGETDEVICEPROPDESC_CMTPPBCGETDEVICEPROPDESC_ENTRY );
|
|
74 |
OstTraceFunctionExit0( DUP1_CMTPPBCGETDEVICEPROPDESC_CMTPPBCGETDEVICEPROPDESC_EXIT );
|
29
|
75 |
}
|
|
76 |
|
|
77 |
/**
|
|
78 |
GetDevicePropDesc request validator.
|
|
79 |
@return EMTPRespCodeOK if request is verified, otherwise one of the error response codes
|
|
80 |
*/
|
|
81 |
TMTPResponseCode CMTPPbcGetDevicePropDesc::CheckRequestL()
|
|
82 |
{
|
49
|
83 |
OstTraceFunctionEntry0( CMTPPBCGETDEVICEPROPDESC_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) / sizeof(KMTPPlaybackControlDpSupportedProperties[0]);
|
|
90 |
for (TUint i(0); (i < count); i++)
|
|
91 |
{
|
|
92 |
if (propCode == KMTPPlaybackControlDpSupportedProperties[i])
|
|
93 |
{
|
|
94 |
respCode = EMTPRespCodeOK;
|
|
95 |
break;
|
|
96 |
}
|
|
97 |
}
|
|
98 |
}
|
|
99 |
|
49
|
100 |
OstTraceFunctionExit0( CMTPPBCGETDEVICEPROPDESC_CHECKREQUESTL_EXIT );
|
29
|
101 |
return respCode;
|
|
102 |
}
|
|
103 |
|
|
104 |
/**
|
|
105 |
GetDevicePropDesc request handler.
|
|
106 |
*/
|
|
107 |
void CMTPPbcGetDevicePropDesc::ServiceL()
|
|
108 |
{
|
49
|
109 |
OstTraceFunctionEntry0( CMTPPBCGETDEVICEPROPDESC_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 = EMTPOpCodeGetDevicePropDesc;
|
|
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 |
}
|
|
140 |
|
49
|
141 |
OstTraceFunctionExit0( CMTPPBCGETDEVICEPROPDESC_SERVICEL_EXIT );
|
29
|
142 |
}
|
|
143 |
|
|
144 |
void CMTPPbcGetDevicePropDesc::HandlePlaybackCommandCompleteL(CMTPPlaybackCommand* aCmd, TInt aErr)
|
|
145 |
{
|
49
|
146 |
OstTraceFunctionEntry0( CMTPPBCGETDEVICEPROPDESC_HANDLEPLAYBACKCOMMANDCOMPLETEL_ENTRY );
|
|
147 |
OstTrace1( TRACE_NORMAL, CMTPPBCGETDEVICEPROPDESC_HANDLEPLAYBACKCOMMANDCOMPLETEL, "aErr %d", aErr );
|
|
148 |
|
29
|
149 |
|
|
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_CMTPPBCGETDEVICEPROPDESC_HANDLEPLAYBACKCOMMANDCOMPLETEL, "Error argument" ), User::Leave(KErrArgument));
|
|
158 |
__ASSERT_ALWAYS_OST((aCmd->PlaybackCommand() == iPbCmd->PlaybackCommand()), OstTrace0( TRACE_ERROR, DUP3_CMTPPBCGETDEVICEPROPDESC_HANDLEPLAYBACKCOMMANDCOMPLETEL, "Error argument" ), User::Leave(KErrArgument));
|
|
159 |
OstTrace1( TRACE_NORMAL, DUP1_CMTPPBCGETDEVICEPROPDESC_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( CMTPPBCGETDEVICEPROPDESC_HANDLEPLAYBACKCOMMANDCOMPLETEL_EXIT );
|
29
|
173 |
return;
|
|
174 |
|
|
175 |
default:
|
|
176 |
{
|
|
177 |
SendResponseL(EMTPRespCodeDeviceBusy);
|
|
178 |
}
|
49
|
179 |
OstTraceFunctionExit0( DUP1_CMTPPBCGETDEVICEPROPDESC_HANDLEPLAYBACKCOMMANDCOMPLETEL_EXIT );
|
29
|
180 |
return;
|
|
181 |
}
|
|
182 |
|
|
183 |
delete iPropDesc;
|
|
184 |
iPropDesc = NULL;
|
|
185 |
|
|
186 |
CMTPPlaybackProperty& property(iPlaybackControlDp.GetPlaybackProperty());
|
|
187 |
TMTPDevicePropertyCode propCode = static_cast<TMTPDevicePropertyCode>
|
|
188 |
(Request().Uint32(TMTPTypeRequest::ERequestParameter1));
|
|
189 |
|
|
190 |
switch (propCode)
|
|
191 |
{
|
|
192 |
case EMTPDevicePropCodeVolume:
|
|
193 |
{
|
|
194 |
TMTPPbDataVolume volSet(1,0,1,1,1);
|
|
195 |
if(useDefault)
|
|
196 |
{
|
|
197 |
property.GetDefaultVolSet(volSet);
|
|
198 |
}
|
|
199 |
else
|
|
200 |
{
|
|
201 |
volSet = aCmd->ParamL().VolumeSetL();
|
|
202 |
property.SetDefaultVolSetL(volSet);
|
|
203 |
}
|
|
204 |
|
|
205 |
CMTPTypeDevicePropDescRangeForm* form = CMTPTypeDevicePropDescRangeForm::NewLC(EMTPTypeUINT32);
|
|
206 |
form->SetUint32L(CMTPTypeDevicePropDescRangeForm::EMaximumValue, volSet.MaxVolume());
|
|
207 |
form->SetUint32L(CMTPTypeDevicePropDescRangeForm::EMinimumValue, volSet.MinVolume());
|
|
208 |
form->SetUint32L(CMTPTypeDevicePropDescRangeForm::EStepSize, volSet.Step());
|
|
209 |
iPropDesc = CMTPTypeDevicePropDesc::NewL(propCode,
|
|
210 |
CMTPTypeDevicePropDesc::EReadWrite,
|
|
211 |
CMTPTypeDevicePropDesc::ERangeForm,
|
|
212 |
form);
|
|
213 |
|
|
214 |
iPropDesc->SetUint32L(CMTPTypeDevicePropDesc::EFactoryDefaultValue, volSet.DefaultVolume());
|
|
215 |
iPropDesc->SetUint32L(CMTPTypeDevicePropDesc::ECurrentValue, volSet.CurrentVolume());
|
|
216 |
CleanupStack::PopAndDestroy(form);
|
|
217 |
SendDataL(*iPropDesc);
|
|
218 |
}
|
|
219 |
break;
|
|
220 |
|
|
221 |
case EMTPDevicePropCodePlaybackRate:
|
|
222 |
{
|
|
223 |
CMTPTypeDevicePropDescEnumerationForm* form = CMTPTypeDevicePropDescEnumerationForm::
|
|
224 |
NewLC(EMTPTypeINT32);
|
|
225 |
CMTPPlaybackMap& map(iPlaybackControlDp.GetPlaybackMap());
|
|
226 |
|
|
227 |
TInt32 val = map.PlaybackRateL(EPlayStateBackwardSeeking);
|
|
228 |
TMTPTypeInt32 value(val);
|
|
229 |
form->AppendSupportedValueL(value);
|
|
230 |
|
|
231 |
val = map.PlaybackRateL(EPlayStatePaused);
|
|
232 |
value.Set(val);
|
|
233 |
form->AppendSupportedValueL(value);
|
|
234 |
|
|
235 |
val = map.PlaybackRateL(EPlayStatePlaying);
|
|
236 |
value.Set(val);
|
|
237 |
form->AppendSupportedValueL(value);
|
|
238 |
|
|
239 |
val = map.PlaybackRateL(EPlayStateForwardSeeking);
|
|
240 |
value.Set(val);
|
|
241 |
form->AppendSupportedValueL(value);
|
|
242 |
|
|
243 |
iPropDesc = CMTPTypeDevicePropDesc::NewL(propCode,
|
|
244 |
CMTPTypeDevicePropDesc::EReadWrite,
|
|
245 |
CMTPTypeDevicePropDesc::EEnumerationForm,
|
|
246 |
form);
|
|
247 |
|
|
248 |
property.GetDefaultPropertyValueL(propCode, val);
|
|
249 |
iPropDesc->SetInt32L(CMTPTypeDevicePropDesc::EFactoryDefaultValue, val);
|
|
250 |
|
|
251 |
if(!useDefault)
|
|
252 |
{
|
|
253 |
TMTPPlaybackState state = static_cast<TMTPPlaybackState>(aCmd->ParamL().Uint32L());
|
|
254 |
val = map.PlaybackRateL(state);
|
|
255 |
}
|
|
256 |
iPropDesc->SetInt32L(CMTPTypeDevicePropDesc::ECurrentValue, val);
|
|
257 |
CleanupStack::PopAndDestroy(form);
|
|
258 |
|
|
259 |
SendDataL(*iPropDesc);
|
|
260 |
}
|
|
261 |
break;
|
|
262 |
|
|
263 |
case EMTPDevicePropCodePlaybackObject:
|
|
264 |
{
|
|
265 |
iPropDesc = CMTPTypeDevicePropDesc::NewL(propCode);
|
|
266 |
TUint32 val = 0;
|
|
267 |
property.GetDefaultPropertyValueL(propCode, val);
|
|
268 |
iPropDesc->SetUint32L(CMTPTypeDevicePropDesc::EFactoryDefaultValue, val);
|
|
269 |
CMTPPlaybackMap& map(iPlaybackControlDp.GetPlaybackMap());
|
|
270 |
if(!useDefault)
|
|
271 |
{
|
|
272 |
val = map.ObjectHandleL(aCmd->ParamL().SuidSetL().Suid());
|
|
273 |
}
|
|
274 |
iPropDesc->SetUint32L(CMTPTypeDevicePropDesc::ECurrentValue, val);
|
|
275 |
SendDataL(*iPropDesc);
|
|
276 |
}
|
|
277 |
break;
|
|
278 |
|
|
279 |
case EMTPDevicePropCodePlaybackContainerIndex:
|
|
280 |
{
|
|
281 |
iPropDesc = CMTPTypeDevicePropDesc::NewL(propCode);
|
|
282 |
TUint32 val = 0;
|
|
283 |
property.GetDefaultPropertyValueL(propCode, val);
|
|
284 |
iPropDesc->SetUint32L(CMTPTypeDevicePropDesc::EFactoryDefaultValue, val);
|
|
285 |
if(!useDefault)
|
|
286 |
{
|
|
287 |
val = aCmd->ParamL().Uint32L();
|
|
288 |
}
|
|
289 |
iPropDesc->SetUint32L(CMTPTypeDevicePropDesc::ECurrentValue, val);
|
|
290 |
SendDataL(*iPropDesc);
|
|
291 |
}
|
|
292 |
break;
|
|
293 |
|
|
294 |
case EMTPDevicePropCodePlaybackPosition:
|
|
295 |
{
|
|
296 |
iPropDesc = CMTPTypeDevicePropDesc::NewL(propCode);
|
|
297 |
TUint32 val = 0;
|
|
298 |
CMTPPlaybackProperty& property(iPlaybackControlDp.GetPlaybackProperty());
|
|
299 |
property.GetDefaultPropertyValueL(propCode, val);
|
|
300 |
iPropDesc->SetUint32L(CMTPTypeDevicePropDesc::EFactoryDefaultValue, val);
|
|
301 |
if(!useDefault)
|
|
302 |
{
|
|
303 |
val = aCmd->ParamL().Uint32L();
|
|
304 |
}
|
|
305 |
iPropDesc->SetUint32L(CMTPTypeDevicePropDesc::ECurrentValue, val);
|
|
306 |
SendDataL(*iPropDesc);
|
|
307 |
}
|
|
308 |
break;
|
|
309 |
|
|
310 |
default:
|
|
311 |
{
|
49
|
312 |
LEAVEIFERROR( KErrArgument,
|
|
313 |
OstTrace0( TRACE_ERROR, DUP4_CMTPPBCGETDEVICEPROPDESC_HANDLEPLAYBACKCOMMANDCOMPLETEL, "Error argument" ));
|
29
|
314 |
}
|
|
315 |
break;
|
|
316 |
}
|
|
317 |
|
49
|
318 |
OstTraceFunctionExit0( DUP2_CMTPPBCGETDEVICEPROPDESC_HANDLEPLAYBACKCOMMANDCOMPLETEL_EXIT );
|
29
|
319 |
}
|