|
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 "cmtpplaybackmap.h" |
|
22 #include "cmtpplaybackproperty.h" |
|
23 #include "mtpplaybackcontrolpanic.h" |
|
24 |
|
25 // Class constants. |
|
26 __FLOG_STMT(_LIT8(KComponent,"MTPPlaybackProperty");) |
|
27 |
|
28 const TInt32 KMTPDefaultPlaybackRate = 0; |
|
29 |
|
30 const TUint32 KMTPMaxPlaybackVolume = 100; |
|
31 const TUint32 KMTPMinPlaybackVolume = 0; |
|
32 const TUint32 KMTPDefaultPlaybackVolume = 40; |
|
33 const TUint32 KMTPCurrentPlaybackVolume = 40; |
|
34 const TUint32 KMTPVolumeStep = 1; |
|
35 |
|
36 const TUint32 KMTPDefaultPlaybackObject = 0; |
|
37 const TUint32 KMTPDefaultPlaybackIndex = 0; |
|
38 const TUint32 KMTPDefaultPlaybackPosition = 0; |
|
39 |
|
40 /** |
|
41 Two-phase constructor. |
|
42 @param aPlugin The data provider plugin |
|
43 @return a pointer to the created playback checker object |
|
44 */ |
|
45 CMTPPlaybackProperty* CMTPPlaybackProperty::NewL() |
|
46 { |
|
47 CMTPPlaybackProperty* self = new (ELeave) CMTPPlaybackProperty(); |
|
48 CleanupStack::PushL(self); |
|
49 self->ConstructL(); |
|
50 CleanupStack::Pop(self); |
|
51 return self; |
|
52 } |
|
53 |
|
54 /** |
|
55 Destructor. |
|
56 */ |
|
57 CMTPPlaybackProperty::~CMTPPlaybackProperty() |
|
58 { |
|
59 __FLOG(_L8("~CMTPPlaybackProperty - Entry")); |
|
60 delete iPlaybackVolumeData; |
|
61 __FLOG(_L8("~CMTPPlaybackProperty - Exit")); |
|
62 __FLOG_CLOSE; |
|
63 } |
|
64 |
|
65 /** |
|
66 Constructor. |
|
67 */ |
|
68 CMTPPlaybackProperty::CMTPPlaybackProperty() |
|
69 { |
|
70 } |
|
71 |
|
72 /** |
|
73 Second-phase constructor. |
|
74 */ |
|
75 void CMTPPlaybackProperty::ConstructL() |
|
76 { |
|
77 __FLOG_OPEN(KMTPSubsystem, KComponent); |
|
78 __FLOG(_L8("ConstructL - Entry")); |
|
79 __FLOG(_L8("ConstructL - Exit")); |
|
80 } |
|
81 |
|
82 void CMTPPlaybackProperty::GetDefaultPropertyValueL(TMTPDevicePropertyCode aProp, TInt32& aValue) |
|
83 { |
|
84 __FLOG(_L8("GetDefaultPropertyValueL - Entry")); |
|
85 |
|
86 __ASSERT_ALWAYS((aProp == EMTPDevicePropCodePlaybackRate), User::Leave(KErrArgument)); |
|
87 aValue = KMTPDefaultPlaybackRate; |
|
88 |
|
89 __FLOG(_L8("GetDefaultPropertyValueL - Exit")); |
|
90 } |
|
91 |
|
92 void CMTPPlaybackProperty::GetDefaultPropertyValueL(TMTPDevicePropertyCode aProp, TUint32& aValue) |
|
93 { |
|
94 __FLOG(_L8("GetDefaultPropertyValueL - Entry")); |
|
95 switch(aProp) |
|
96 { |
|
97 case EMTPDevicePropCodeVolume: |
|
98 { |
|
99 if(iPlaybackVolumeData != NULL) |
|
100 { |
|
101 aValue = iPlaybackVolumeData->DefaultVolume(); |
|
102 } |
|
103 else |
|
104 { |
|
105 aValue = KMTPDefaultPlaybackVolume; |
|
106 } |
|
107 } |
|
108 break; |
|
109 |
|
110 case EMTPDevicePropCodePlaybackObject: |
|
111 { |
|
112 aValue = KMTPDefaultPlaybackObject; |
|
113 } |
|
114 break; |
|
115 |
|
116 case EMTPDevicePropCodePlaybackContainerIndex: |
|
117 { |
|
118 aValue = KMTPDefaultPlaybackIndex; |
|
119 } |
|
120 break; |
|
121 |
|
122 case EMTPDevicePropCodePlaybackPosition: |
|
123 { |
|
124 aValue = KMTPDefaultPlaybackPosition; |
|
125 } |
|
126 break; |
|
127 |
|
128 default: |
|
129 User::Leave(KErrArgument); |
|
130 } |
|
131 __FLOG(_L8("GetDefaultPropertyValueL - Exit")); |
|
132 } |
|
133 |
|
134 void CMTPPlaybackProperty::GetDefaultVolSet(TMTPPbDataVolume& aValue) |
|
135 { |
|
136 if(iPlaybackVolumeData == NULL) |
|
137 { |
|
138 aValue.SetVolume(KMTPMaxPlaybackVolume, |
|
139 KMTPMinPlaybackVolume, |
|
140 KMTPDefaultPlaybackVolume, |
|
141 KMTPCurrentPlaybackVolume, |
|
142 KMTPVolumeStep); |
|
143 } |
|
144 else |
|
145 { |
|
146 aValue = (*iPlaybackVolumeData); |
|
147 } |
|
148 } |
|
149 |
|
150 void CMTPPlaybackProperty::SetDefaultVolSetL(const TMTPPbDataVolume& aValue) |
|
151 { |
|
152 if(iPlaybackVolumeData == NULL) |
|
153 { |
|
154 iPlaybackVolumeData = new (ELeave) TMTPPbDataVolume(aValue); |
|
155 } |
|
156 else |
|
157 { |
|
158 (*iPlaybackVolumeData) = aValue; |
|
159 } |
|
160 } |
|
161 |
|
162 void CMTPPlaybackProperty::GetDefaultPropertyValueL(TMTPPbCtrlData& aValue) |
|
163 { |
|
164 __FLOG(_L8("GetDefaultPropertyValueL - Entry")); |
|
165 __ASSERT_DEBUG((aValue.iOptCode == EMTPOpCodeResetDevicePropValue), Panic(EMTPPBArgumentErr)); |
|
166 |
|
167 switch(aValue.iDevPropCode) |
|
168 { |
|
169 case EMTPDevicePropCodePlaybackRate: |
|
170 { |
|
171 TInt32 val; |
|
172 GetDefaultPropertyValueL(aValue.iDevPropCode, val); |
|
173 aValue.iPropValInt32.Set(val); |
|
174 } |
|
175 break; |
|
176 |
|
177 case EMTPDevicePropCodeVolume: |
|
178 case EMTPDevicePropCodePlaybackObject: |
|
179 case EMTPDevicePropCodePlaybackContainerIndex: |
|
180 case EMTPDevicePropCodePlaybackPosition: |
|
181 { |
|
182 TUint32 val; |
|
183 GetDefaultPropertyValueL(aValue.iDevPropCode, val); |
|
184 aValue.iPropValUint32.Set(val); |
|
185 } |
|
186 break; |
|
187 |
|
188 default: |
|
189 User::Leave(KErrArgument); |
|
190 } |
|
191 __FLOG(_L8("GetDefaultPropertyValueL - Exit")); |
|
192 } |
|
193 |
|
194 TBool CMTPPlaybackProperty::IsDefaultPropertyValueL(const TMTPPbCtrlData& aValue) const |
|
195 { |
|
196 __FLOG(_L8("EqualToDefaultPropertyValueL - Entry")); |
|
197 |
|
198 TInt result(EFalse); |
|
199 |
|
200 switch(aValue.iDevPropCode) |
|
201 { |
|
202 case EMTPDevicePropCodePlaybackRate: |
|
203 { |
|
204 if(aValue.iPropValInt32.Value() == KMTPDefaultPlaybackRate) |
|
205 { |
|
206 result = ETrue; |
|
207 } |
|
208 } |
|
209 break; |
|
210 |
|
211 case EMTPDevicePropCodeVolume: |
|
212 { |
|
213 if(iPlaybackVolumeData == NULL) |
|
214 { |
|
215 if(aValue.iPropValUint32.Value() == KMTPDefaultPlaybackVolume) |
|
216 { |
|
217 result = ETrue; |
|
218 } |
|
219 } |
|
220 else |
|
221 { |
|
222 if(aValue.iPropValUint32.Value() == iPlaybackVolumeData->DefaultVolume()) |
|
223 { |
|
224 result = ETrue; |
|
225 } |
|
226 } |
|
227 } |
|
228 break; |
|
229 |
|
230 case EMTPDevicePropCodePlaybackObject: |
|
231 { |
|
232 if(aValue.iPropValUint32.Value() == KMTPDefaultPlaybackObject) |
|
233 { |
|
234 result = ETrue; |
|
235 } |
|
236 } |
|
237 break; |
|
238 |
|
239 case EMTPDevicePropCodePlaybackContainerIndex: |
|
240 { |
|
241 if(aValue.iPropValUint32.Value() == KMTPDefaultPlaybackIndex) |
|
242 { |
|
243 result = ETrue; |
|
244 } |
|
245 } |
|
246 break; |
|
247 |
|
248 case EMTPDevicePropCodePlaybackPosition: |
|
249 { |
|
250 if(aValue.iPropValUint32.Value() == KMTPDefaultPlaybackPosition) |
|
251 { |
|
252 result = ETrue; |
|
253 } |
|
254 } |
|
255 break; |
|
256 |
|
257 default: |
|
258 User::Leave(KErrArgument); |
|
259 } |
|
260 |
|
261 __FLOG(_L8("EqualToDefaultPropertyValueL - Exit")); |
|
262 |
|
263 return result; |
|
264 } |
|
265 |