|
1 /* |
|
2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * |
|
16 */ |
|
17 |
|
18 #include <mtp/cmtptypeinterdependentpropdesc.h> |
|
19 #include <mtp/cmtptypeobjectpropdesc.h> |
|
20 #include <mtp/cmtptypestring.h> |
|
21 |
|
22 #include "cdescriptionutility.h" |
|
23 #include "tobjectdescription.h" |
|
24 |
|
25 #include "mmmtpdplogger.h" |
|
26 |
|
27 |
|
28 _LIT( KMtpObjDescObjFileName, |
|
29 "[a-zA-Z!#\\$%&'\\(\\)\\-0-9@\\^_\\`\\{\\}\\~][a-zA-Z!#\\$%&'\\(\\)\\-0-9@\\^_\\`\\{\\}\\~ ]{0, 7}\\.[[a-zA-Z!#\\$%&'\\(\\)\\-0-9@\\^_\\`\\{\\}\\~][a-zA-Z!#\\$%&'\\(\\)\\-0-9@\\^_\\`\\{\\}\\~ ]{0, 2}]?" ); |
|
30 // RegEx is [a-zA-Z!#\$%&'\(\)\-0-9@\^_\`\{\}\~][a-zA-Z!#\$%&'\(\)\-0-9@\^_\`\{\}\~ ]{0, 7}\.[[a-zA-Z!#\$%&'\(\)\-0-9@\^_\`\{\}\~][a-zA-Z!#\$%&'\(\)\-0-9@\^_\`\{\}\~ ]{0, 2}]? |
|
31 |
|
32 EXPORT_C CDescriptionUtility::CDescriptionUtility() |
|
33 { |
|
34 // Do nothing |
|
35 } |
|
36 |
|
37 EXPORT_C CDescriptionUtility::~CDescriptionUtility() |
|
38 { |
|
39 // Do nothing |
|
40 } |
|
41 |
|
42 EXPORT_C CMTPTypeObjectPropDesc* CDescriptionUtility::NewCommonObjectPropertyL( TUint16 aPropCode ) |
|
43 { |
|
44 CMTPTypeObjectPropDesc* propertyDesc = NULL; |
|
45 |
|
46 switch ( aPropCode ) |
|
47 { |
|
48 case EMTPObjectPropCodeStorageID: |
|
49 case EMTPObjectPropCodeObjectFormat: |
|
50 case EMTPObjectPropCodeObjectSize: |
|
51 case EMTPObjectPropCodeParentObject: |
|
52 case EMTPObjectPropCodePersistentUniqueObjectIdentifier: |
|
53 case EMTPObjectPropCodeName: |
|
54 case EMTPObjectPropCodeDateAdded: |
|
55 case EMTPObjectPropCodeAlbumArtist: |
|
56 propertyDesc = CMTPTypeObjectPropDesc::NewL( aPropCode ); |
|
57 break; |
|
58 |
|
59 // Protection Status (m) |
|
60 case EMTPObjectPropCodeProtectionStatus: |
|
61 propertyDesc = NewProtectionStatusPropDescL(); |
|
62 break; |
|
63 |
|
64 // FileName |
|
65 case EMTPObjectPropCodeObjectFileName: |
|
66 propertyDesc = NewFileNamePropDescL(); |
|
67 break; |
|
68 |
|
69 // Consumable (m) |
|
70 case EMTPObjectPropCodeNonConsumable: |
|
71 propertyDesc = NewNonConsumablePropDescL(); |
|
72 break; |
|
73 |
|
74 case EMTPObjectPropCodeDateModified: // Date Modified |
|
75 case EMTPObjectPropCodeDateCreated: // Date Created |
|
76 { |
|
77 CMTPTypeObjectPropDesc::TPropertyInfo propertyInfo; |
|
78 propertyInfo.iDataType = EMTPTypeString; |
|
79 propertyInfo.iFormFlag = CMTPTypeObjectPropDesc::EDateTimeForm; |
|
80 propertyInfo.iGetSet = CMTPTypeObjectPropDesc::EReadOnly; |
|
81 propertyDesc = CMTPTypeObjectPropDesc::NewL( aPropCode, |
|
82 propertyInfo, |
|
83 NULL ); |
|
84 } |
|
85 break; |
|
86 |
|
87 default: |
|
88 break; |
|
89 } |
|
90 return propertyDesc; |
|
91 } |
|
92 |
|
93 // ----------------------------------------------------------------------------- |
|
94 // CDescriptionUtility::NewRangeFormDescriptionL |
|
95 // |
|
96 // ----------------------------------------------------------------------------- |
|
97 // |
|
98 EXPORT_C CMTPTypeObjectPropDesc* CDescriptionUtility::NewRangeFormDescriptionL( TUint16 aPropertyCode, |
|
99 TUint32 aMinValue, |
|
100 TUint32 aMaxValue, |
|
101 TUint32 aStepValue, |
|
102 TBool aIsReadOnly ) |
|
103 { |
|
104 PRINT1( _L( "MM MTP => CDescriptionUtility::NewRangeFormDescriptionL, aPropertyCode = 0x%x" ), |
|
105 aPropertyCode ); |
|
106 CMTPTypeObjectPropDescRangeForm* form = |
|
107 CMTPTypeObjectPropDescRangeForm::NewLC( EMTPTypeUINT32 ); // + form |
|
108 |
|
109 // Set expected values |
|
110 form->SetUint32L( CMTPTypeObjectPropDescRangeForm::EMinimumValue, aMinValue ); |
|
111 form->SetUint32L( CMTPTypeObjectPropDescRangeForm::EMaximumValue, aMaxValue ); |
|
112 form->SetUint32L( CMTPTypeObjectPropDescRangeForm::EStepSize, aStepValue ); |
|
113 |
|
114 CMTPTypeObjectPropDesc::TPropertyInfo propertyInfo; |
|
115 propertyInfo.iDataType = EMTPTypeUINT32; |
|
116 propertyInfo.iFormFlag = CMTPTypeObjectPropDesc::ERangeForm; |
|
117 propertyInfo.iGetSet = !aIsReadOnly; |
|
118 |
|
119 CMTPTypeObjectPropDesc* propertyDesc = CMTPTypeObjectPropDesc::NewL( aPropertyCode, |
|
120 propertyInfo, |
|
121 form ); // + propertyDesc |
|
122 |
|
123 CleanupStack::PopAndDestroy( form ); // - form |
|
124 PRINT( _L( "MM MTP <= CDescriptionUtility::NewRangeFormDescriptionL" ) ); |
|
125 |
|
126 return propertyDesc; |
|
127 } |
|
128 |
|
129 // ----------------------------------------------------------------------------- |
|
130 // CDescriptionUtility::GetGroupCode |
|
131 // Get MTPTypeObjectPropDesc according to property code |
|
132 // ----------------------------------------------------------------------------- |
|
133 // |
|
134 TUint32 CDescriptionUtility::GetGroupCode( TUint32 aPropCode ) |
|
135 { |
|
136 TInt count = sizeof( KPropGroupMapTable ) / sizeof( KPropGroupMapTable[0] ); |
|
137 // TODO: if need to refine the search approach to improve performance |
|
138 for( TInt i = 0; i < count; i++ ) |
|
139 { |
|
140 if ( aPropCode == KPropGroupMapTable[i].iPropCode ) |
|
141 return KPropGroupMapTable[i].iGroupCode; |
|
142 } |
|
143 return EGroupCodeNotDefined; |
|
144 } |
|
145 |
|
146 // ----------------------------------------------------------------------------- |
|
147 // CDescriptionUtility::NewProtectionStatusPropDescL |
|
148 // New MTPTypeObjectPropDesc protection status |
|
149 // ----------------------------------------------------------------------------- |
|
150 // |
|
151 CMTPTypeObjectPropDesc* CDescriptionUtility::NewProtectionStatusPropDescL() |
|
152 { |
|
153 PRINT( _L( "MM MTP => CDescriptionUtility::NewProtectionStatusPropDescL" ) ); |
|
154 |
|
155 CMTPTypeObjectPropDescEnumerationForm* expectedForm = |
|
156 CMTPTypeObjectPropDescEnumerationForm::NewLC( EMTPTypeUINT16 ); // + expectedForm |
|
157 |
|
158 TUint16 values[] = |
|
159 { |
|
160 EMTPProtectionNoProtection, |
|
161 EMTPProtectionReadOnly |
|
162 }; |
|
163 |
|
164 TInt numValues = sizeof ( values ) / sizeof ( values[0] ) ; |
|
165 for ( TInt i = 0; i < numValues; i++ ) |
|
166 { |
|
167 TMTPTypeUint16 data( values[i] ); |
|
168 expectedForm->AppendSupportedValueL( data ); |
|
169 } |
|
170 |
|
171 CMTPTypeObjectPropDesc* propertyDesc = CMTPTypeObjectPropDesc::NewL( EMTPObjectPropCodeProtectionStatus, *expectedForm ); |
|
172 CleanupStack::PopAndDestroy( expectedForm ); // - expectedForm |
|
173 |
|
174 PRINT( _L( "MM MTP <= CDescriptionUtility::NewProtectionStatusPropDescL" ) ); |
|
175 return propertyDesc; |
|
176 } |
|
177 |
|
178 // ----------------------------------------------------------------------------- |
|
179 // CDescriptionUtility::NewFileNamePropDescL |
|
180 // Get MTPTypeObjectPropDesc New file name |
|
181 // ----------------------------------------------------------------------------- |
|
182 // |
|
183 CMTPTypeObjectPropDesc* CDescriptionUtility::NewFileNamePropDescL() |
|
184 { |
|
185 PRINT( _L( "MM MTP => CDescriptionUtility::NewFileNamePropDescL" ) ); |
|
186 CMTPTypeString* form = CMTPTypeString::NewLC( KMtpObjDescObjFileName ); // + form |
|
187 |
|
188 CMTPTypeObjectPropDesc* ret = CMTPTypeObjectPropDesc::NewL( EMTPObjectPropCodeObjectFileName, |
|
189 CMTPTypeObjectPropDesc::ERegularExpressionForm, |
|
190 form ); |
|
191 |
|
192 CleanupStack::PopAndDestroy( form ); // - form |
|
193 PRINT( _L( "MM MTP <= CDescriptionUtility::NewFileNamePropDescL" ) ); |
|
194 return ret; |
|
195 } |
|
196 |
|
197 // ----------------------------------------------------------------------------- |
|
198 // CDescriptionUtility::NewFileNamePropDescL |
|
199 // Get MTPTypeObjectPropDesc New file name |
|
200 // ----------------------------------------------------------------------------- |
|
201 // |
|
202 CMTPTypeObjectPropDesc* CDescriptionUtility::NewNonConsumablePropDescL() |
|
203 { |
|
204 PRINT( _L( "MM MTP => CDescriptionUtility::NewNonConsumablePropDescL" ) ); |
|
205 CMTPTypeObjectPropDescEnumerationForm* expectedForm = |
|
206 CMTPTypeObjectPropDescEnumerationForm::NewLC( EMTPTypeUINT8 ); // + expectedForm |
|
207 TUint8 values[] = |
|
208 { |
|
209 EMTPConsumable, |
|
210 EMTPNonConsumable |
|
211 }; |
|
212 |
|
213 TInt numValues = sizeof ( values ) / sizeof ( values[0] ); |
|
214 for ( TInt i = 0; i < numValues; i++ ) |
|
215 { |
|
216 TMTPTypeUint8 data( values[i] ); |
|
217 expectedForm->AppendSupportedValueL( data ); |
|
218 } |
|
219 |
|
220 CMTPTypeObjectPropDesc* ret = CMTPTypeObjectPropDesc::NewL( EMTPObjectPropCodeNonConsumable, |
|
221 CMTPTypeObjectPropDesc::EEnumerationForm, |
|
222 expectedForm ); |
|
223 CleanupStack::PopAndDestroy( expectedForm ); // - expectedForm |
|
224 |
|
225 PRINT( _L( "MM MTP <= CDescriptionUtility::NewNonConsumablePropDescL" ) ); |
|
226 return ret; |
|
227 } |
|
228 |
|
229 // end of file |