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 "cmtpplaybackcommandchecker.h"
|
|
22 |
#include "cmtpplaybackcontrolimpl.h"
|
49
|
23 |
#include "OstTraceDefinitions.h"
|
|
24 |
#ifdef OST_TRACE_COMPILER_IN_USE
|
|
25 |
#include "cmtpplaybackcommandcheckerTraces.h"
|
|
26 |
#endif
|
29
|
27 |
|
|
28 |
|
|
29 |
// ======== MEMBER FUNCTIONS ========
|
|
30 |
|
|
31 |
// ---------------------------------------------------------------------------
|
|
32 |
// CMTPPlaybackCommandChecker::NewL
|
|
33 |
// ---------------------------------------------------------------------------
|
|
34 |
//
|
|
35 |
CMTPPlaybackCommandChecker* CMTPPlaybackCommandChecker::NewL(
|
|
36 |
CMTPPlaybackControlImpl& aControlImpl )
|
|
37 |
{
|
49
|
38 |
OstTraceFunctionEntry0( CMTPPLAYBACKCOMMANDCHECKER_NEWL_ENTRY );
|
29
|
39 |
CMTPPlaybackCommandChecker* self = new ( ELeave )
|
|
40 |
CMTPPlaybackCommandChecker( aControlImpl );
|
49
|
41 |
OstTraceFunctionExit0( CMTPPLAYBACKCOMMANDCHECKER_NEWL_EXIT );
|
29
|
42 |
return self;
|
|
43 |
}
|
|
44 |
|
|
45 |
// ---------------------------------------------------------------------------
|
|
46 |
// CMTPPlaybackCommandChecker::~CMTPPlaybackCommandChecker
|
|
47 |
// ---------------------------------------------------------------------------
|
|
48 |
//
|
|
49 |
CMTPPlaybackCommandChecker::~CMTPPlaybackCommandChecker()
|
|
50 |
{
|
49
|
51 |
OstTraceFunctionEntry0( CMTPPLAYBACKCOMMANDCHECKER_CMTPPLAYBACKCOMMANDCHECKER_ENTRY );
|
|
52 |
OstTraceFunctionExit0( CMTPPLAYBACKCOMMANDCHECKER_CMTPPLAYBACKCOMMANDCHECKER_EXIT );
|
29
|
53 |
}
|
|
54 |
|
|
55 |
// ---------------------------------------------------------------------------
|
|
56 |
// CMTPPlaybackCommandChecker::CheckPlaybackCommandContextL
|
|
57 |
// ---------------------------------------------------------------------------
|
|
58 |
//
|
|
59 |
void CMTPPlaybackCommandChecker::CheckPlaybackCommandContextL( TMTPPlaybackCommand aMTPPBCommand )
|
|
60 |
{
|
49
|
61 |
OstTraceFunctionEntry0( CMTPPLAYBACKCOMMANDCHECKER_CHECKPLAYBACKCOMMANDCONTEXTL_ENTRY );
|
29
|
62 |
|
|
63 |
MTPPlaybackControlImpl().SetMTPPBCmd( aMTPPBCommand );
|
|
64 |
|
|
65 |
switch ( aMTPPBCommand )
|
|
66 |
{
|
|
67 |
case EPlaybackCmdInitObject:
|
|
68 |
case EPlaybackCmdGetVolumeSet:
|
|
69 |
case EPlaybackCmdGetVolume:
|
|
70 |
case EPlaybackCmdGetState:
|
|
71 |
case EPlaybackCmdSetVolume:
|
|
72 |
{
|
49
|
73 |
OstTrace0( TRACE_NORMAL, CMTPPLAYBACKCOMMANDCHECKER_CHECKPLAYBACKCOMMANDCONTEXTL, "no context check for init object command" );
|
29
|
74 |
}
|
|
75 |
break;
|
|
76 |
case EPlaybackCmdInitIndex:
|
|
77 |
case EPlaybackCmdSkip:
|
|
78 |
case EPlaybackCmdGetIndex:
|
|
79 |
{
|
|
80 |
if ( MTPPlaybackControlImpl().SongCount() < 0 )
|
|
81 |
{
|
49
|
82 |
LEAVEIFERROR(KPlaybackErrContextInvalid,
|
|
83 |
OstTrace0( TRACE_ERROR, DUP2_CMTPPLAYBACKCOMMANDCHECKER_CHECKPLAYBACKCOMMANDCONTEXTL, "Context invalid" ));
|
29
|
84 |
}
|
|
85 |
}
|
|
86 |
break;
|
|
87 |
case EPlaybackCmdPlay:
|
|
88 |
case EPlaybackCmdPause:
|
|
89 |
case EPlaybackCmdStop:
|
|
90 |
case EPlaybackCmdSeekForward:
|
|
91 |
case EPlaybackCmdSeekBackward:
|
|
92 |
case EPlaybackCmdGetObject:
|
|
93 |
case EPlaybackCmdSetPosition:
|
|
94 |
case EPlaybackCmdGetPosition:
|
|
95 |
{
|
|
96 |
switch ( MTPPlaybackControlImpl().CurrentState())
|
|
97 |
{
|
|
98 |
case EPbStateNotInitialised:
|
|
99 |
{
|
49
|
100 |
LEAVEIFERROR(KPlaybackErrContextInvalid,
|
|
101 |
OstTrace0( TRACE_ERROR, DUP3_CMTPPLAYBACKCOMMANDCHECKER_CHECKPLAYBACKCOMMANDCONTEXTL, "Context invalid" ));
|
29
|
102 |
}
|
|
103 |
default:
|
|
104 |
break;
|
|
105 |
}
|
|
106 |
}
|
|
107 |
break;
|
|
108 |
default:
|
|
109 |
{
|
49
|
110 |
OstTrace0( TRACE_NORMAL, DUP1_CMTPPLAYBACKCOMMANDCHECKER_CHECKPLAYBACKCOMMANDCONTEXTL, "Not support command!" );
|
|
111 |
|
|
112 |
LEAVEIFERROR(KPlaybackErrParamInvalid,
|
|
113 |
OstTrace0( TRACE_ERROR, DUP4_CMTPPLAYBACKCOMMANDCHECKER_CHECKPLAYBACKCOMMANDCONTEXTL, "Parameter invalid" ));
|
29
|
114 |
}
|
|
115 |
break;
|
|
116 |
}
|
|
117 |
|
49
|
118 |
OstTraceFunctionExit0( CMTPPLAYBACKCOMMANDCHECKER_CHECKPLAYBACKCOMMANDCONTEXTL_EXIT );
|
29
|
119 |
}
|
|
120 |
|
|
121 |
// ---------------------------------------------------------------------------
|
|
122 |
// CMTPPlaybackCommandChecker::CheckAndUpdatePlaybackParamL
|
|
123 |
// ---------------------------------------------------------------------------
|
|
124 |
//
|
|
125 |
void CMTPPlaybackCommandChecker::CheckAndUpdatePlaybackParamL( CMTPPlaybackCommand& aMTPPPBSourceCmd,
|
|
126 |
CMTPPbCmdParam** aMTPPPBTargetParam )
|
|
127 |
{
|
49
|
128 |
OstTraceFunctionEntry0( CMTPPLAYBACKCOMMANDCHECKER_CHECKANDUPDATEPLAYBACKPARAML_ENTRY );
|
29
|
129 |
|
|
130 |
delete *aMTPPPBTargetParam;
|
|
131 |
*aMTPPPBTargetParam = NULL;
|
|
132 |
|
|
133 |
switch ( aMTPPPBSourceCmd.PlaybackCommand())
|
|
134 |
{
|
|
135 |
case EPlaybackCmdInitObject:
|
|
136 |
{
|
|
137 |
const TMTPPbCategory category = aMTPPPBSourceCmd.ParamL().SuidSetL().Category();
|
|
138 |
TFileName suid = aMTPPPBSourceCmd.ParamL().SuidSetL().Suid();
|
|
139 |
*aMTPPPBTargetParam = CMTPPbCmdParam::NewL( category, suid );
|
|
140 |
}
|
|
141 |
break;
|
|
142 |
case EPlaybackCmdInitIndex:
|
|
143 |
{
|
|
144 |
TUint32 songIndex = aMTPPPBSourceCmd.ParamL().Uint32L();
|
|
145 |
if ( songIndex > ( MTPPlaybackControlImpl().SongCount()-1 ))
|
|
146 |
{
|
49
|
147 |
LEAVEIFERROR(KPlaybackErrParamInvalid,
|
|
148 |
OstTrace0( TRACE_ERROR, DUP1_CMTPPLAYBACKCOMMANDCHECKER_CHECKANDUPDATEPLAYBACKPARAML, "Parameter invalid" ));
|
29
|
149 |
}
|
|
150 |
*aMTPPPBTargetParam = CMTPPbCmdParam::NewL( songIndex );
|
|
151 |
}
|
|
152 |
break;
|
|
153 |
case EPlaybackCmdSkip:
|
|
154 |
{
|
|
155 |
TInt32 songIndex = MTPPlaybackControlImpl().SongIndex() + aMTPPPBSourceCmd.ParamL().Int32L();
|
|
156 |
TUint32 songCount = MTPPlaybackControlImpl().SongCount();
|
|
157 |
|
|
158 |
if ( songIndex < 0 )
|
|
159 |
{
|
|
160 |
songIndex = ( - songIndex ) % songCount;
|
|
161 |
songIndex = ( songCount - songIndex ) % songCount;
|
|
162 |
}
|
|
163 |
else
|
|
164 |
{
|
|
165 |
songIndex = songIndex % songCount;
|
|
166 |
}
|
|
167 |
|
|
168 |
*aMTPPPBTargetParam = CMTPPbCmdParam::NewL( songIndex);
|
|
169 |
}
|
|
170 |
break;
|
|
171 |
case EPlaybackCmdSetVolume:
|
|
172 |
{
|
|
173 |
TUint32 volume = aMTPPPBSourceCmd.ParamL().Uint32L();
|
|
174 |
if( volume > KPbPlaybackVolumeLevelMax )
|
|
175 |
{
|
49
|
176 |
LEAVEIFERROR(KPlaybackErrParamInvalid,
|
|
177 |
OstTrace0( TRACE_ERROR, DUP2_CMTPPLAYBACKCOMMANDCHECKER_CHECKANDUPDATEPLAYBACKPARAML, "Parameter invalid" ));
|
29
|
178 |
}
|
|
179 |
*aMTPPPBTargetParam = CMTPPbCmdParam::NewL( volume );
|
|
180 |
}
|
|
181 |
break;
|
|
182 |
case EPlaybackCmdSetPosition:
|
|
183 |
{
|
|
184 |
TUint32 position= aMTPPPBSourceCmd.ParamL().Uint32L();
|
|
185 |
*aMTPPPBTargetParam = CMTPPbCmdParam::NewL( position );
|
|
186 |
}
|
|
187 |
break;
|
|
188 |
default:
|
|
189 |
{
|
49
|
190 |
OstTrace0( TRACE_NORMAL, CMTPPLAYBACKCOMMANDCHECKER_CHECKANDUPDATEPLAYBACKPARAML, "No param, just cache command" );
|
29
|
191 |
}
|
|
192 |
break;
|
|
193 |
}
|
|
194 |
|
49
|
195 |
OstTraceFunctionExit0( CMTPPLAYBACKCOMMANDCHECKER_CHECKANDUPDATEPLAYBACKPARAML_EXIT );
|
29
|
196 |
}
|
|
197 |
|
|
198 |
// ---------------------------------------------------------------------------
|
|
199 |
// CMTPPlaybackCommandChecker::CMTPPlaybackCommandChecker
|
|
200 |
// ---------------------------------------------------------------------------
|
|
201 |
//
|
|
202 |
CMTPPlaybackCommandChecker::CMTPPlaybackCommandChecker(
|
|
203 |
CMTPPlaybackControlImpl& aControlImpl )
|
|
204 |
: iMTPPlaybackControl( aControlImpl )
|
|
205 |
{
|
49
|
206 |
OstTraceFunctionEntry0( DUP1_CMTPPLAYBACKCOMMANDCHECKER_CMTPPLAYBACKCOMMANDCHECKER_ENTRY );
|
|
207 |
OstTraceFunctionExit0( DUP1_CMTPPLAYBACKCOMMANDCHECKER_CMTPPLAYBACKCOMMANDCHECKER_EXIT );
|
29
|
208 |
}
|
|
209 |
|
|
210 |
// ---------------------------------------------------------------------------
|
|
211 |
// CMTPPlaybackCommandChecker::MTPPlaybackControlImpl
|
|
212 |
// ---------------------------------------------------------------------------
|
|
213 |
//
|
|
214 |
CMTPPlaybackControlImpl& CMTPPlaybackCommandChecker::MTPPlaybackControlImpl()
|
|
215 |
{
|
49
|
216 |
OstTraceFunctionEntry0( CMTPPLAYBACKCOMMANDCHECKER_MTPPLAYBACKCONTROLIMPL_ENTRY );
|
|
217 |
OstTraceFunctionExit0( CMTPPLAYBACKCOMMANDCHECKER_MTPPLAYBACKCONTROLIMPL_EXIT );
|
29
|
218 |
return iMTPPlaybackControl;
|
|
219 |
}
|
|
220 |
|
|
221 |
|