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 |
|
|
24 |
#include "cmtppbcsetdevicepropvalue.h"
|
|
25 |
#include "mtpplaybackcontroldpconst.h"
|
|
26 |
#include "cmtpplaybackcontroldp.h"
|
|
27 |
#include "cmtpplaybackproperty.h"
|
|
28 |
#include "cmtpplaybackcommand.h"
|
|
29 |
#include "mtpplaybackcontrolpanic.h"
|
49
|
30 |
#include "OstTraceDefinitions.h"
|
|
31 |
#ifdef OST_TRACE_COMPILER_IN_USE
|
|
32 |
#include "cmtppbcsetdevicepropvalueTraces.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* CMTPPbcSetDevicePropValue::NewL(MMTPDataProviderFramework& aFramework,
|
|
44 |
MMTPConnection& aConnection,
|
|
45 |
CMTPPlaybackControlDataProvider& aDataProvider)
|
|
46 |
{
|
49
|
47 |
OstTraceFunctionEntry0( CMTPPBCSETDEVICEPROPVALUE_NEWL_ENTRY );
|
29
|
48 |
CMTPPbcSetDevicePropValue* self = new (ELeave) CMTPPbcSetDevicePropValue(aFramework, aConnection, aDataProvider);
|
49
|
49 |
OstTraceFunctionExit0( CMTPPBCSETDEVICEPROPVALUE_NEWL_EXIT );
|
29
|
50 |
return self;
|
|
51 |
}
|
|
52 |
|
|
53 |
/**
|
|
54 |
Destructor
|
|
55 |
*/
|
|
56 |
CMTPPbcSetDevicePropValue::~CMTPPbcSetDevicePropValue()
|
|
57 |
{
|
49
|
58 |
OstTraceFunctionEntry0( CMTPPBCSETDEVICEPROPVALUE_CMTPPBCSETDEVICEPROPVALUE_ENTRY );
|
29
|
59 |
delete iPbCmd;
|
49
|
60 |
OstTraceFunctionExit0( CMTPPBCSETDEVICEPROPVALUE_CMTPPBCSETDEVICEPROPVALUE_EXIT );
|
29
|
61 |
}
|
|
62 |
|
|
63 |
/**
|
|
64 |
Standard c++ constructor
|
|
65 |
*/
|
|
66 |
CMTPPbcSetDevicePropValue::CMTPPbcSetDevicePropValue(MMTPDataProviderFramework& aFramework,
|
|
67 |
MMTPConnection& aConnection,
|
|
68 |
CMTPPlaybackControlDataProvider& aDataProvider):
|
|
69 |
CMTPRequestProcessor(aFramework, aConnection, 0, NULL),
|
|
70 |
iPlaybackControlDp(aDataProvider)
|
|
71 |
{
|
49
|
72 |
OstTraceFunctionEntry0( DUP1_CMTPPBCSETDEVICEPROPVALUE_CMTPPBCSETDEVICEPROPVALUE_ENTRY );
|
|
73 |
OstTraceFunctionExit0( DUP1_CMTPPBCSETDEVICEPROPVALUE_CMTPPBCSETDEVICEPROPVALUE_EXIT );
|
29
|
74 |
}
|
|
75 |
|
|
76 |
/**
|
|
77 |
CMTPPbcSetDevicePropValue request validator.
|
|
78 |
@return EMTPRespCodeOK if request is verified, otherwise one of the error response codes
|
|
79 |
*/
|
|
80 |
TMTPResponseCode CMTPPbcSetDevicePropValue::CheckRequestL()
|
|
81 |
{
|
49
|
82 |
OstTraceFunctionEntry0( CMTPPBCSETDEVICEPROPVALUE_CHECKREQUESTL_ENTRY );
|
29
|
83 |
TMTPResponseCode respCode = CMTPRequestProcessor::CheckRequestL();
|
|
84 |
if(respCode == EMTPRespCodeOK)
|
|
85 |
{
|
|
86 |
respCode = EMTPRespCodeDevicePropNotSupported;
|
|
87 |
TUint32 propCode = Request().Uint32(TMTPTypeRequest::ERequestParameter1);
|
|
88 |
const TInt count = sizeof(KMTPPlaybackControlDpSupportedProperties) / sizeof(KMTPPlaybackControlDpSupportedProperties[0]);
|
|
89 |
for (TUint i(0); (i < count); i++)
|
|
90 |
{
|
|
91 |
if (propCode == KMTPPlaybackControlDpSupportedProperties[i])
|
|
92 |
{
|
|
93 |
respCode = EMTPRespCodeOK;
|
|
94 |
break;
|
|
95 |
}
|
|
96 |
}
|
|
97 |
}
|
|
98 |
|
49
|
99 |
OstTraceFunctionExit0( CMTPPBCSETDEVICEPROPVALUE_CHECKREQUESTL_EXIT );
|
29
|
100 |
return respCode;
|
|
101 |
}
|
|
102 |
|
|
103 |
/**
|
|
104 |
Process the transaction response phase.
|
|
105 |
*/
|
|
106 |
TBool CMTPPbcSetDevicePropValue::DoHandleResponsePhaseL()
|
|
107 |
{
|
49
|
108 |
OstTraceFunctionEntry0( CMTPPBCSETDEVICEPROPVALUE_DOHANDLERESPONSEPHASEL_ENTRY );
|
29
|
109 |
|
|
110 |
CMTPPlaybackMap& map(iPlaybackControlDp.GetPlaybackMap());
|
|
111 |
//Destroy the previous playback command.
|
|
112 |
delete iPbCmd;
|
|
113 |
iPbCmd = NULL;
|
|
114 |
|
|
115 |
//Get a new playback command.
|
|
116 |
TInt result = map.GetPlaybackControlCommand(iData, &iPbCmd);
|
|
117 |
|
|
118 |
if(KErrNone == result)
|
|
119 |
{
|
|
120 |
MMTPPlaybackControl& control(iPlaybackControlDp.GetPlaybackControlL());
|
|
121 |
TRAPD(err, control.CommandL(*iPbCmd, this));
|
|
122 |
__ASSERT_ALWAYS((err == KErrNone), SendResponseL(EMTPRespCodeInvalidDevicePropValue));
|
|
123 |
}
|
|
124 |
else if(KErrNotSupported == result)
|
|
125 |
{
|
|
126 |
SendResponseL(EMTPRespCodeDevicePropNotSupported);
|
|
127 |
}
|
|
128 |
else
|
|
129 |
{
|
|
130 |
SendResponseL(EMTPRespCodeInvalidDevicePropValue);
|
|
131 |
}
|
49
|
132 |
|
|
133 |
OstTraceFunctionExit0( CMTPPBCSETDEVICEPROPVALUE_DOHANDLERESPONSEPHASEL_EXIT );
|
29
|
134 |
return EFalse;
|
|
135 |
}
|
|
136 |
|
|
137 |
void CMTPPbcSetDevicePropValue::ServiceL()
|
|
138 |
{
|
49
|
139 |
OstTraceFunctionEntry0( CMTPPBCSETDEVICEPROPVALUE_SERVICEL_ENTRY );
|
29
|
140 |
TMTPDevicePropertyCode propCode(static_cast<TMTPDevicePropertyCode>(Request().
|
|
141 |
Uint32(TMTPTypeRequest::ERequestParameter1)));
|
|
142 |
iData.iOptCode = EMTPOpCodeSetDevicePropValue;
|
|
143 |
iData.iDevPropCode = propCode;
|
|
144 |
switch(propCode)
|
|
145 |
{
|
|
146 |
case EMTPDevicePropCodePlaybackRate:
|
|
147 |
{
|
|
148 |
ReceiveDataL(iData.iPropValInt32);
|
|
149 |
}
|
|
150 |
break;
|
|
151 |
case EMTPDevicePropCodeVolume:
|
|
152 |
case EMTPDevicePropCodePlaybackObject:
|
|
153 |
case EMTPDevicePropCodePlaybackContainerIndex:
|
|
154 |
case EMTPDevicePropCodePlaybackPosition:
|
|
155 |
{
|
|
156 |
ReceiveDataL(iData.iPropValUint32);
|
|
157 |
}
|
|
158 |
break;
|
|
159 |
|
|
160 |
default:
|
|
161 |
{
|
|
162 |
SendResponseL(EMTPRespCodeDevicePropNotSupported);
|
|
163 |
}
|
|
164 |
break;
|
|
165 |
}
|
49
|
166 |
OstTraceFunctionExit0( CMTPPBCSETDEVICEPROPVALUE_SERVICEL_EXIT );
|
29
|
167 |
}
|
|
168 |
|
|
169 |
void CMTPPbcSetDevicePropValue::HandlePlaybackCommandCompleteL(CMTPPlaybackCommand* aCmd, TInt aErr)
|
|
170 |
{
|
49
|
171 |
OstTraceFunctionEntry0( CMTPPBCSETDEVICEPROPVALUE_HANDLEPLAYBACKCOMMANDCOMPLETEL_ENTRY );
|
|
172 |
OstTrace1( TRACE_NORMAL, CMTPPBCSETDEVICEPROPVALUE_HANDLEPLAYBACKCOMMANDCOMPLETEL, "aErr %d", aErr );
|
29
|
173 |
|
|
174 |
//Handle error response.
|
|
175 |
TMTPResponseCode response;
|
|
176 |
switch(aErr)
|
|
177 |
{
|
|
178 |
case KPlaybackErrNone:
|
|
179 |
{
|
|
180 |
response = EMTPRespCodeOK;
|
|
181 |
}
|
|
182 |
break;
|
|
183 |
case KPlaybackErrDeviceUnavailable:
|
|
184 |
{
|
|
185 |
response = EMTPRespCodeDeviceBusy;
|
|
186 |
iPlaybackControlDp.RequestToResetPbCtrl();
|
|
187 |
}
|
|
188 |
break;
|
|
189 |
case KPlaybackErrContextInvalid:
|
|
190 |
{
|
|
191 |
CMTPPlaybackProperty& prop(iPlaybackControlDp.GetPlaybackProperty());
|
|
192 |
if(prop.IsDefaultPropertyValueL(iData))
|
|
193 |
{
|
|
194 |
response = EMTPRespCodeOK;
|
|
195 |
}
|
|
196 |
else
|
|
197 |
{
|
|
198 |
response = EMTPRespCodeAccessDenied;
|
|
199 |
}
|
|
200 |
}
|
|
201 |
break;
|
|
202 |
case KPlaybackErrParamInvalid:
|
|
203 |
{
|
|
204 |
response = EMTPRespCodeInvalidDevicePropValue;
|
|
205 |
}
|
|
206 |
break;
|
|
207 |
default:
|
|
208 |
{
|
|
209 |
response = EMTPRespCodeDeviceBusy;
|
|
210 |
}
|
|
211 |
break;
|
|
212 |
}
|
|
213 |
|
|
214 |
SendResponseL(response);
|
|
215 |
|
|
216 |
if(aCmd != NULL)
|
|
217 |
{
|
|
218 |
__ASSERT_DEBUG((aCmd->PlaybackCommand() == iPbCmd->PlaybackCommand()), Panic(EMTPPBArgumentErr));
|
49
|
219 |
OstTrace1( TRACE_NORMAL, DUP1_CMTPPBCSETDEVICEPROPVALUE_HANDLEPLAYBACKCOMMANDCOMPLETEL, "aCmd %d", aCmd->PlaybackCommand() );
|
29
|
220 |
}
|
49
|
221 |
OstTraceFunctionExit0( CMTPPBCSETDEVICEPROPVALUE_HANDLEPLAYBACKCOMMANDCOMPLETEL_EXIT );
|
29
|
222 |
}
|