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 "cmtppbcresetdevicepropvalue.h"
|
|
22 |
#include "mtpplaybackcontroldpconst.h"
|
|
23 |
#include "cmtpplaybackcontroldp.h"
|
|
24 |
#include "cmtpplaybackproperty.h"
|
|
25 |
#include "cmtpplaybackcommand.h"
|
|
26 |
#include "mtpplaybackcontrolpanic.h"
|
49
|
27 |
#include "OstTraceDefinitions.h"
|
|
28 |
#ifdef OST_TRACE_COMPILER_IN_USE
|
|
29 |
#include "cmtppbcresetdevicepropvalueTraces.h"
|
|
30 |
#endif
|
29
|
31 |
|
|
32 |
|
|
33 |
/**
|
|
34 |
Two-phase constructor.
|
|
35 |
@param aPlugin The data provider plugin
|
|
36 |
@param aFramework The data provider framework
|
|
37 |
@param aConnection The connection from which the request comes
|
|
38 |
@return a pointer to the created request processor object.
|
|
39 |
*/
|
|
40 |
MMTPRequestProcessor* CMTPPbcResetDevicePropValue::NewL(MMTPDataProviderFramework& aFramework,
|
|
41 |
MMTPConnection& aConnection,
|
|
42 |
CMTPPlaybackControlDataProvider& aDataProvider)
|
|
43 |
{
|
49
|
44 |
OstTraceFunctionEntry0( CMTPPBCRESETDEVICEPROPVALUE_NEWL_ENTRY );
|
29
|
45 |
CMTPPbcResetDevicePropValue* self = new (ELeave) CMTPPbcResetDevicePropValue(aFramework, aConnection, aDataProvider);
|
49
|
46 |
OstTraceFunctionExit0( CMTPPBCRESETDEVICEPROPVALUE_NEWL_EXIT );
|
29
|
47 |
return self;
|
|
48 |
}
|
|
49 |
|
|
50 |
/**
|
|
51 |
Destructor
|
|
52 |
*/
|
|
53 |
CMTPPbcResetDevicePropValue::~CMTPPbcResetDevicePropValue()
|
|
54 |
{
|
49
|
55 |
OstTraceFunctionEntry0( CMTPPBCRESETDEVICEPROPVALUE_CMTPPBCRESETDEVICEPROPVALUE_ENTRY );
|
29
|
56 |
delete iPbCmd;
|
49
|
57 |
OstTraceFunctionExit0( CMTPPBCRESETDEVICEPROPVALUE_CMTPPBCRESETDEVICEPROPVALUE_EXIT );
|
29
|
58 |
}
|
|
59 |
|
|
60 |
/**
|
|
61 |
Standard c++ constructor
|
|
62 |
*/
|
|
63 |
CMTPPbcResetDevicePropValue::CMTPPbcResetDevicePropValue(MMTPDataProviderFramework& aFramework,
|
|
64 |
MMTPConnection& aConnection,
|
|
65 |
CMTPPlaybackControlDataProvider& aDataProvider):
|
|
66 |
CMTPRequestProcessor(aFramework, aConnection, 0, NULL),
|
|
67 |
iPlaybackControlDp(aDataProvider)
|
|
68 |
{
|
49
|
69 |
OstTraceFunctionEntry0( DUP1_CMTPPBCRESETDEVICEPROPVALUE_CMTPPBCRESETDEVICEPROPVALUE_ENTRY );
|
|
70 |
OstTraceFunctionExit0( DUP1_CMTPPBCRESETDEVICEPROPVALUE_CMTPPBCRESETDEVICEPROPVALUE_EXIT );
|
29
|
71 |
}
|
|
72 |
|
|
73 |
/**
|
|
74 |
SetDevicePropValue request validator.
|
|
75 |
@return EMTPRespCodeOK if request is verified, otherwise one of the error response codes
|
|
76 |
*/
|
|
77 |
TMTPResponseCode CMTPPbcResetDevicePropValue::CheckRequestL()
|
|
78 |
{
|
49
|
79 |
OstTraceFunctionEntry0( CMTPPBCRESETDEVICEPROPVALUE_CHECKREQUESTL_ENTRY );
|
29
|
80 |
TMTPResponseCode respCode = CMTPRequestProcessor::CheckRequestL();
|
|
81 |
if(respCode == EMTPRespCodeOK)
|
|
82 |
{
|
|
83 |
respCode = EMTPRespCodeDevicePropNotSupported;
|
|
84 |
TUint32 propCode = Request().Uint32(TMTPTypeRequest::ERequestParameter1);
|
|
85 |
const TInt count = sizeof(KMTPPlaybackControlDpSupportedProperties) / sizeof(KMTPPlaybackControlDpSupportedProperties[0]);
|
|
86 |
for (TUint i(0); (i < count); i++)
|
|
87 |
{
|
|
88 |
if (propCode == KMTPPlaybackControlDpSupportedProperties[i])
|
|
89 |
{
|
|
90 |
respCode = EMTPRespCodeOK;
|
|
91 |
break;
|
|
92 |
}
|
|
93 |
}
|
|
94 |
}
|
49
|
95 |
OstTraceFunctionExit0( CMTPPBCRESETDEVICEPROPVALUE_CHECKREQUESTL_EXIT );
|
29
|
96 |
return respCode;
|
|
97 |
}
|
|
98 |
/**
|
|
99 |
ResetDevicePropValue request handler.
|
|
100 |
*/
|
|
101 |
void CMTPPbcResetDevicePropValue::ServiceL()
|
|
102 |
{
|
49
|
103 |
OstTraceFunctionEntry0( CMTPPBCRESETDEVICEPROPVALUE_SERVICEL_ENTRY );
|
29
|
104 |
|
|
105 |
CMTPPlaybackMap& map(iPlaybackControlDp.GetPlaybackMap());
|
|
106 |
//Destroy the previous playback command.
|
|
107 |
delete iPbCmd;
|
|
108 |
iPbCmd = NULL;
|
|
109 |
|
|
110 |
//Get a new playback command.
|
|
111 |
iData.iOptCode = EMTPOpCodeResetDevicePropValue;
|
|
112 |
TMTPDevicePropertyCode propCode(static_cast<TMTPDevicePropertyCode>(Request().
|
|
113 |
Uint32(TMTPTypeRequest::ERequestParameter1)));
|
|
114 |
iData.iDevPropCode = propCode;
|
|
115 |
CMTPPlaybackProperty& property(iPlaybackControlDp.GetPlaybackProperty());
|
|
116 |
property.GetDefaultPropertyValueL(iData);
|
|
117 |
|
|
118 |
TInt result = map.GetPlaybackControlCommand(iData, &iPbCmd);
|
|
119 |
|
|
120 |
if(KErrNone == result)
|
|
121 |
{
|
|
122 |
MMTPPlaybackControl& control(iPlaybackControlDp.GetPlaybackControlL());
|
|
123 |
TRAPD(err, control.CommandL(*iPbCmd, this));
|
|
124 |
__ASSERT_ALWAYS((err == KErrNone), SendResponseL(EMTPRespCodeParameterNotSupported));
|
|
125 |
}
|
|
126 |
else if(KErrNotSupported == result)
|
|
127 |
{
|
|
128 |
SendResponseL(EMTPRespCodeDevicePropNotSupported);
|
|
129 |
}
|
|
130 |
else
|
|
131 |
{
|
|
132 |
SendResponseL(EMTPRespCodeParameterNotSupported);
|
|
133 |
}
|
49
|
134 |
OstTraceFunctionExit0( CMTPPBCRESETDEVICEPROPVALUE_SERVICEL_EXIT );
|
29
|
135 |
}
|
|
136 |
|
|
137 |
void CMTPPbcResetDevicePropValue::HandlePlaybackCommandCompleteL(CMTPPlaybackCommand* aCmd, TInt aErr)
|
|
138 |
{
|
49
|
139 |
OstTraceFunctionEntry0( CMTPPBCRESETDEVICEPROPVALUE_HANDLEPLAYBACKCOMMANDCOMPLETEL_ENTRY );
|
|
140 |
OstTrace1( TRACE_NORMAL, CMTPPBCRESETDEVICEPROPVALUE_HANDLEPLAYBACKCOMMANDCOMPLETEL, "aErr %d", aErr );
|
29
|
141 |
|
|
142 |
//Handle error response.
|
|
143 |
TMTPResponseCode response;
|
|
144 |
switch(aErr)
|
|
145 |
{
|
|
146 |
case KPlaybackErrNone:
|
|
147 |
{
|
|
148 |
response = EMTPRespCodeOK;
|
|
149 |
}
|
|
150 |
break;
|
|
151 |
case KPlaybackErrDeviceUnavailable:
|
|
152 |
{
|
|
153 |
response = EMTPRespCodeDeviceBusy;
|
|
154 |
iPlaybackControlDp.RequestToResetPbCtrl();
|
|
155 |
}
|
|
156 |
break;
|
|
157 |
case KPlaybackErrContextInvalid:
|
|
158 |
{
|
|
159 |
response = EMTPRespCodeAccessDenied;
|
|
160 |
}
|
|
161 |
break;
|
|
162 |
default:
|
|
163 |
{
|
|
164 |
response = EMTPRespCodeDeviceBusy;
|
|
165 |
}
|
|
166 |
break;
|
|
167 |
}
|
|
168 |
|
|
169 |
SendResponseL(response);
|
|
170 |
|
|
171 |
if(aCmd != NULL)
|
|
172 |
{
|
|
173 |
__ASSERT_DEBUG((aCmd->PlaybackCommand() == iPbCmd->PlaybackCommand()), Panic(EMTPPBArgumentErr));
|
49
|
174 |
OstTrace1( TRACE_NORMAL, DUP1_CMTPPBCRESETDEVICEPROPVALUE_HANDLEPLAYBACKCOMMANDCOMPLETEL, "aCmd %d", aCmd->PlaybackCommand() );
|
29
|
175 |
}
|
|
176 |
|
49
|
177 |
OstTraceFunctionExit0( CMTPPBCRESETDEVICEPROPVALUE_HANDLEPLAYBACKCOMMANDCOMPLETEL_EXIT );
|
29
|
178 |
}
|