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