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 "cmtpplaybackcommand.h" |
|
22 #include "mtpplaybackcontrolpanic.h" |
|
23 |
|
24 // Class constants. |
|
25 __FLOG_STMT(_LIT8(KComponent,"CMtpPbCmd");) |
|
26 |
|
27 /********************************************* |
|
28 class TMTPPbDataVolume |
|
29 **********************************************/ |
|
30 TMTPPbDataVolume::TMTPPbDataVolume(TUint32 aMax, TUint32 aMin, TUint32 aDefault, TUint32 aCurrent, TUint32 aStep): |
|
31 iMaxVolume(aMax),iMinVolume(aMin), iDefaultVolume(aDefault), iCurrentVolume(aCurrent), iStep(aStep) |
|
32 { |
|
33 __ASSERT_DEBUG((aMin < aMax), Panic(EMTPPBArgumentErr)); |
|
34 __ASSERT_DEBUG((aMin <= aDefault && aDefault <= aMax), Panic(EMTPPBArgumentErr)); |
|
35 __ASSERT_DEBUG((aMin <= aCurrent && aCurrent <= aMax), Panic(EMTPPBArgumentErr)); |
|
36 __ASSERT_DEBUG((aStep <= (aMax-aMin)), Panic(EMTPPBArgumentErr)); |
|
37 __ASSERT_DEBUG((aStep != 0), Panic(EMTPPBArgumentErr)); |
|
38 } |
|
39 |
|
40 TMTPPbDataVolume::TMTPPbDataVolume(const TMTPPbDataVolume& aVol): |
|
41 iMaxVolume(aVol.MaxVolume()), |
|
42 iMinVolume(aVol.MinVolume()), |
|
43 iDefaultVolume(aVol.DefaultVolume()), |
|
44 iCurrentVolume(aVol.CurrentVolume()), |
|
45 iStep(aVol.Step()) |
|
46 { |
|
47 |
|
48 } |
|
49 |
|
50 void TMTPPbDataVolume::SetVolume(TUint32 aMax, TUint32 aMin, TUint32 aDefault, TUint32 aCurrent, TUint32 aStep) |
|
51 { |
|
52 __ASSERT_DEBUG((aMin < aMax), Panic(EMTPPBArgumentErr)); |
|
53 __ASSERT_DEBUG((aMin <= aDefault && aDefault <= aMax), Panic(EMTPPBArgumentErr)); |
|
54 __ASSERT_DEBUG((aMin <= aCurrent && aCurrent <= aMax), Panic(EMTPPBArgumentErr)); |
|
55 __ASSERT_DEBUG((aStep <= (aMax-aMin)), Panic(EMTPPBArgumentErr)); |
|
56 __ASSERT_DEBUG((aStep != 0), Panic(EMTPPBArgumentErr)); |
|
57 iMaxVolume = aMax; |
|
58 iMinVolume = aMin; |
|
59 iDefaultVolume = aDefault; |
|
60 iCurrentVolume = aCurrent, |
|
61 iStep = aStep; |
|
62 } |
|
63 |
|
64 void TMTPPbDataVolume::operator =(const TMTPPbDataVolume& aVol) |
|
65 { |
|
66 iMaxVolume = aVol.MaxVolume(); |
|
67 iMinVolume = aVol.MinVolume(); |
|
68 iDefaultVolume = aVol.DefaultVolume(); |
|
69 iCurrentVolume = aVol.CurrentVolume(); |
|
70 iStep = aVol.Step(); |
|
71 } |
|
72 |
|
73 TUint32 TMTPPbDataVolume::MaxVolume() const |
|
74 { |
|
75 return iMaxVolume; |
|
76 } |
|
77 |
|
78 TUint32 TMTPPbDataVolume::MinVolume() const |
|
79 { |
|
80 return iMinVolume; |
|
81 } |
|
82 |
|
83 TUint32 TMTPPbDataVolume::DefaultVolume() const |
|
84 { |
|
85 return iDefaultVolume; |
|
86 } |
|
87 |
|
88 TUint32 TMTPPbDataVolume::CurrentVolume() const |
|
89 { |
|
90 return iCurrentVolume; |
|
91 } |
|
92 |
|
93 TUint32 TMTPPbDataVolume::Step() const |
|
94 { |
|
95 return iStep; |
|
96 } |
|
97 |
|
98 /********************************************* |
|
99 class CMTPPbCmdParam |
|
100 **********************************************/ |
|
101 |
|
102 CMTPPbCmdParam* CMTPPbCmdParam::NewL(TMTPPbCategory aCategory, const TDesC& aSuid) |
|
103 { |
|
104 CMTPPbCmdParam* self = new (ELeave) CMTPPbCmdParam(aCategory, aSuid); |
|
105 CleanupStack::PushL(self); |
|
106 self->ConstructL(aCategory, aSuid); |
|
107 CleanupStack::Pop(self); |
|
108 return self; |
|
109 } |
|
110 |
|
111 CMTPPbCmdParam* CMTPPbCmdParam::NewL(TInt32 aValue) |
|
112 { |
|
113 CMTPPbCmdParam* self = new (ELeave) CMTPPbCmdParam(aValue); |
|
114 CleanupStack::PushL(self); |
|
115 self->ConstructL(aValue); |
|
116 CleanupStack::Pop(self); |
|
117 return self; |
|
118 } |
|
119 |
|
120 CMTPPbCmdParam* CMTPPbCmdParam::NewL(TUint32 aValue) |
|
121 { |
|
122 CMTPPbCmdParam* self = new (ELeave) CMTPPbCmdParam(aValue); |
|
123 CleanupStack::PushL(self); |
|
124 self->ConstructL(aValue); |
|
125 CleanupStack::Pop(self); |
|
126 return self; |
|
127 } |
|
128 |
|
129 CMTPPbCmdParam* CMTPPbCmdParam::NewL(const TMTPPbDataVolume& aVolume) |
|
130 { |
|
131 CMTPPbCmdParam* self = new (ELeave) CMTPPbCmdParam(aVolume); |
|
132 CleanupStack::PushL(self); |
|
133 self->ConstructL(aVolume); |
|
134 CleanupStack::Pop(self); |
|
135 return self; |
|
136 } |
|
137 |
|
138 CMTPPbCmdParam* CMTPPbCmdParam::NewL(const CMTPPbCmdParam& aParam) |
|
139 { |
|
140 CMTPPbCmdParam* self = new (ELeave) CMTPPbCmdParam(); |
|
141 CleanupStack::PushL(self); |
|
142 self->ConstructL(aParam); |
|
143 CleanupStack::Pop(self); |
|
144 return self; |
|
145 } |
|
146 |
|
147 CMTPPbCmdParam::~CMTPPbCmdParam() |
|
148 { |
|
149 |
|
150 } |
|
151 |
|
152 CMTPPbCmdParam::CMTPPbCmdParam(): |
|
153 CMTPPbParamBase() |
|
154 { |
|
155 |
|
156 } |
|
157 |
|
158 CMTPPbCmdParam::CMTPPbCmdParam(TMTPPbCategory aCategory, const TDesC& aSuid): |
|
159 CMTPPbParamBase(aCategory, aSuid) |
|
160 { |
|
161 |
|
162 } |
|
163 |
|
164 CMTPPbCmdParam::CMTPPbCmdParam(TInt32 aValue): |
|
165 CMTPPbParamBase(aValue) |
|
166 { |
|
167 |
|
168 } |
|
169 |
|
170 CMTPPbCmdParam::CMTPPbCmdParam(TUint32 aValue): |
|
171 CMTPPbParamBase(aValue) |
|
172 { |
|
173 |
|
174 } |
|
175 |
|
176 CMTPPbCmdParam::CMTPPbCmdParam(const TMTPPbDataVolume& /*aVolume*/): |
|
177 CMTPPbParamBase() |
|
178 { |
|
179 CMTPPbParamBase::SetType(EMTPPbVolumeSet); |
|
180 } |
|
181 |
|
182 void CMTPPbCmdParam::ConstructL(TMTPPbCategory aCategory, const TDesC& aSuid) |
|
183 { |
|
184 CMTPPbParamBase::ConstructL(aCategory, aSuid); |
|
185 } |
|
186 |
|
187 void CMTPPbCmdParam::ConstructL(TInt32 aValue) |
|
188 { |
|
189 CMTPPbParamBase::ConstructL(aValue); |
|
190 } |
|
191 |
|
192 void CMTPPbCmdParam::ConstructL(TUint32 aValue) |
|
193 { |
|
194 CMTPPbParamBase::ConstructL(aValue); |
|
195 } |
|
196 |
|
197 void CMTPPbCmdParam::ConstructL(const TMTPPbDataVolume& aVolume) |
|
198 { |
|
199 TMTPPbDataVolume* val = new (ELeave) TMTPPbDataVolume(aVolume); |
|
200 CMTPPbParamBase::SetData(static_cast<TAny*>(val)); |
|
201 } |
|
202 |
|
203 void CMTPPbCmdParam::ConstructL(const CMTPPbCmdParam& aParam) |
|
204 { |
|
205 TMTPPbDataType type(aParam.Type()); |
|
206 |
|
207 __ASSERT_DEBUG((type > EMTPPbTypeNone && type < EMTPPbTypeEnd), Panic(EMTPPBArgumentErr)); |
|
208 __ASSERT_ALWAYS((type > EMTPPbTypeNone && type < EMTPPbTypeEnd), User::Leave(KErrArgument)); |
|
209 |
|
210 if(type == EMTPPbVolumeSet) |
|
211 { |
|
212 TMTPPbDataVolume* val = new (ELeave) TMTPPbDataVolume(aParam.VolumeSetL()); |
|
213 CMTPPbParamBase::SetData(static_cast<TAny*>(val)); |
|
214 CMTPPbParamBase::SetType(type); |
|
215 } |
|
216 else |
|
217 { |
|
218 CMTPPbParamBase::ConstructL(aParam); |
|
219 } |
|
220 } |
|
221 |
|
222 const TMTPPbDataVolume& CMTPPbCmdParam::VolumeSetL() const |
|
223 { |
|
224 __ASSERT_DEBUG((CMTPPbParamBase::Type() == EMTPPbVolumeSet), Panic(EMTPPBDataTypeErr)); |
|
225 __ASSERT_ALWAYS((CMTPPbParamBase::Type() == EMTPPbVolumeSet), User::Leave(KErrArgument)); |
|
226 return *static_cast<TMTPPbDataVolume*>(CMTPPbParamBase::GetData()); |
|
227 } |
|
228 |
|
229 /********************************************* |
|
230 class CMTPPlaybackCommand |
|
231 **********************************************/ |
|
232 CMTPPlaybackCommand* CMTPPlaybackCommand::NewL(TMTPPlaybackCommand aCmd, CMTPPbCmdParam* aParam) |
|
233 { |
|
234 __ASSERT_DEBUG((aCmd > EPlaybackCmdNone && aCmd < EPlaybackCmdEnd), Panic(EMTPPBArgumentErr)); |
|
235 __ASSERT_ALWAYS((aCmd > EPlaybackCmdNone && aCmd < EPlaybackCmdEnd), User::Leave(KErrArgument)); |
|
236 |
|
237 CMTPPlaybackCommand* self = new (ELeave) CMTPPlaybackCommand(aCmd, aParam); |
|
238 CleanupStack::PushL(self); |
|
239 self->ConstructL(); |
|
240 CleanupStack::Pop(self); |
|
241 return self; |
|
242 } |
|
243 |
|
244 CMTPPlaybackCommand* CMTPPlaybackCommand::NewL(const CMTPPlaybackCommand& aCmd) |
|
245 { |
|
246 CMTPPlaybackCommand* self = new (ELeave) CMTPPlaybackCommand(aCmd.PlaybackCommand(), NULL); |
|
247 CleanupStack::PushL(self); |
|
248 self->ConstructL(aCmd); |
|
249 CleanupStack::Pop(self); |
|
250 return self; |
|
251 } |
|
252 |
|
253 /** |
|
254 Destructor. |
|
255 */ |
|
256 CMTPPlaybackCommand::~CMTPPlaybackCommand() |
|
257 { |
|
258 __FLOG(_L8("~CMTPPlaybackCommand - Entry")); |
|
259 delete iParam; |
|
260 __FLOG(_L8("~CMTPPlaybackCommand - Exit")); |
|
261 __FLOG_CLOSE; |
|
262 } |
|
263 |
|
264 /** |
|
265 Constructor. |
|
266 */ |
|
267 CMTPPlaybackCommand::CMTPPlaybackCommand(TMTPPlaybackCommand aCmd, |
|
268 CMTPPbCmdParam* aParam): |
|
269 iPbCmd(aCmd),iParam(aParam) |
|
270 { |
|
271 } |
|
272 |
|
273 /** |
|
274 Second-phase constructor. |
|
275 */ |
|
276 void CMTPPlaybackCommand::ConstructL() |
|
277 { |
|
278 __FLOG_OPEN(KMTPSubsystem, KComponent); |
|
279 __FLOG(_L8("CMTPPlaybackCommand: ConstructL - Entry")); |
|
280 __FLOG(_L8("CMTPPlaybackCommand: ConstructL - Exit")); |
|
281 } |
|
282 |
|
283 /** |
|
284 Second-phase constructor. |
|
285 */ |
|
286 void CMTPPlaybackCommand::ConstructL(const CMTPPlaybackCommand& aCmd) |
|
287 { |
|
288 __FLOG(_L8("CMTPPlaybackCommand: ConstructL - Entry")); |
|
289 if(aCmd.HasParam()) |
|
290 { |
|
291 iParam = CMTPPbCmdParam::NewL(aCmd.ParamL()); |
|
292 } |
|
293 __FLOG(_L8("CMTPPlaybackCommand: ConstructL - Exit")); |
|
294 } |
|
295 |
|
296 TMTPPlaybackCommand CMTPPlaybackCommand::PlaybackCommand() const |
|
297 { |
|
298 __ASSERT_DEBUG((iPbCmd > EPlaybackCmdNone && iPbCmd < EPlaybackCmdEnd), Panic(EMTPPBArgumentErr)); |
|
299 return iPbCmd; |
|
300 } |
|
301 |
|
302 TBool CMTPPlaybackCommand::HasParam() const |
|
303 { |
|
304 TBool result(iParam != NULL); |
|
305 return result; |
|
306 } |
|
307 |
|
308 const CMTPPbCmdParam& CMTPPlaybackCommand::ParamL() const |
|
309 { |
|
310 __ASSERT_DEBUG((iParam != NULL), Panic(EMTPPBDataNullErr)); |
|
311 __ASSERT_ALWAYS((iParam != NULL), User::Leave(KErrArgument)); |
|
312 return *iParam; |
|
313 } |
|
314 |
|
315 void CMTPPlaybackCommand::SetParam(CMTPPbCmdParam* aParam) |
|
316 { |
|
317 delete iParam; |
|
318 iParam = aParam; |
|
319 } |
|