1 /* |
1 /* |
2 * Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). |
2 * Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). |
3 * All rights reserved. |
3 * All rights reserved. |
4 * This component and the accompanying materials are made available |
4 * This component and the accompanying materials are made available |
5 * under the terms of "Eclipse Public License v1.0" |
5 * under the terms of "Eclipse Public License v1.0" |
6 * which accompanies this distribution, and is available |
6 * which accompanies this distribution, and is available |
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
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 * |
8 * |
16 */ |
9 * Initial Contributors: |
17 |
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * |
|
16 */ |
18 |
17 |
19 // INCLUDE FILES |
18 // INCLUDE FILES |
20 |
19 |
21 #include <driveinfo.h> |
20 #include <driveinfo.h> |
22 #include <xmlengnodelist.h> |
21 #include <xml/dom/xmlengnodelist.h> |
23 #include <xmlengdomparser.h> |
22 #include <xml/dom/xmlengdomparser.h> |
24 #include <xmlengdocument.h> |
23 #include <xml/dom/xmlengdocument.h> |
|
24 #include <xml/dom/xmlengelement.h> |
25 #include <utf.h> |
25 #include <utf.h> |
|
26 #include <e32base.h> |
26 |
27 |
27 #include "cadef.h" |
28 #include "cadef.h" |
28 #include "cawidgetscannerparser.h" |
29 #include "cawidgetscannerparser.h" |
29 #include "widgetscannerutils.h" |
30 #include "widgetscannerutils.h" |
30 |
|
31 #include "cawidgetscannerdef.h" |
31 #include "cawidgetscannerdef.h" |
32 |
32 |
33 |
|
34 // ============================ MEMBER FUNCTIONS =============================== |
33 // ============================ MEMBER FUNCTIONS =============================== |
35 |
34 |
36 // ----------------------------------------------------------------------------- |
35 // ----------------------------------------------------------------------------- |
37 // CCaWidgetScannerParser::CCaWidgetScannerParser |
36 // |
38 // C++ default constructor can NOT contain any code, that |
37 // ----------------------------------------------------------------------------- |
39 // might leave. |
38 // |
40 // ----------------------------------------------------------------------------- |
39 CCaWidgetScannerParser::CCaWidgetScannerParser( RFs& aFs ) : |
41 // |
|
42 CCaWidgetScannerParser::CCaWidgetScannerParser( RFs& aFs ): |
|
43 iFs( aFs ) |
40 iFs( aFs ) |
44 { |
41 { |
45 } |
42 } |
46 |
43 |
47 // ----------------------------------------------------------------------------- |
44 // ----------------------------------------------------------------------------- |
48 // CCaWidgetScannerParser::ConstructL |
45 // |
49 // Symbian 2nd phase constructor can leave. |
46 // ----------------------------------------------------------------------------- |
50 // ----------------------------------------------------------------------------- |
47 // |
51 // |
48 void CCaWidgetScannerParser::ConstructL() |
52 void CCaWidgetScannerParser::ConstructL( ) |
|
53 { |
49 { |
54 iImportPath.CreateL( KMaxPath ); |
50 iImportPath.CreateL( KMaxPath ); |
55 //iFs.PrivatePath( iImportPath ); |
|
56 iImportPath.Append( KImportDir ); |
51 iImportPath.Append( KImportDir ); |
57 iDomImpl.OpenL(); |
52 iDomImpl.OpenL(); |
58 } |
53 } |
59 |
54 |
60 // ----------------------------------------------------------------------------- |
55 // ----------------------------------------------------------------------------- |
61 // CCaWidgetScannerParser::NewL |
56 // |
62 // Two-phased constructor. |
|
63 // ----------------------------------------------------------------------------- |
57 // ----------------------------------------------------------------------------- |
64 // |
58 // |
65 CCaWidgetScannerParser* CCaWidgetScannerParser::NewL( RFs& aFs ) |
59 CCaWidgetScannerParser* CCaWidgetScannerParser::NewL( RFs& aFs ) |
66 { |
60 { |
67 CCaWidgetScannerParser* self = NewLC( aFs ); |
61 CCaWidgetScannerParser* self = NewLC( aFs ); |
68 CleanupStack::Pop( self ); |
62 CleanupStack::Pop( self ); |
69 return self; |
63 return self; |
70 } |
64 } |
71 |
65 |
72 // ----------------------------------------------------------------------------- |
66 // ----------------------------------------------------------------------------- |
73 // CCaWidgetScannerParser::NewLC |
67 // |
74 // Two-phased constructor. |
|
75 // ----------------------------------------------------------------------------- |
68 // ----------------------------------------------------------------------------- |
76 // |
69 // |
77 CCaWidgetScannerParser* CCaWidgetScannerParser::NewLC( RFs& aFs ) |
70 CCaWidgetScannerParser* CCaWidgetScannerParser::NewLC( RFs& aFs ) |
78 { |
71 { |
79 CCaWidgetScannerParser* self = new( ELeave ) CCaWidgetScannerParser( aFs ); |
72 CCaWidgetScannerParser* self = new ( ELeave ) CCaWidgetScannerParser( aFs ); |
80 CleanupStack::PushL( self ); |
73 CleanupStack::PushL( self ); |
81 self->ConstructL( ); |
74 self->ConstructL(); |
82 return self; |
75 return self; |
83 } |
76 } |
84 |
77 |
85 // ----------------------------------------------------------------------------- |
78 // ----------------------------------------------------------------------------- |
86 // Destructor |
79 // |
87 // ----------------------------------------------------------------------------- |
80 // ----------------------------------------------------------------------------- |
88 // |
81 // |
89 CCaWidgetScannerParser::~CCaWidgetScannerParser() |
82 CCaWidgetScannerParser::~CCaWidgetScannerParser() |
90 { |
83 { |
91 delete iWidgetDescriptor; |
|
92 iImportPath.Close(); |
84 iImportPath.Close(); |
93 iWidgets.ResetAndDestroy(); |
85 iWidgets.ResetAndDestroy(); |
94 iDomImpl.Close(); |
86 iDomImpl.Close(); |
95 } |
87 } |
96 |
88 |
97 // ---------------------------------------------------------------------------- |
89 // ---------------------------------------------------------------------------- |
98 // |
90 // |
99 // ---------------------------------------------------------------------------- |
91 // ---------------------------------------------------------------------------- |
100 // |
92 // |
101 RWidgetArray& CCaWidgetScannerParser::WidgetsScanL( ) |
93 RWidgetArray& CCaWidgetScannerParser::WidgetsScanL( |
|
94 const RWidgetArray& aWidgets ) |
102 { |
95 { |
103 TDriveList driveList; |
96 TDriveList driveList; |
|
97 TChar currentDriveLetter; |
104 User::LeaveIfError( iFs.DriveList( driveList ) ); |
98 User::LeaveIfError( iFs.DriveList( driveList ) ); |
105 iWidgets.ResetAndDestroy(); |
99 iWidgets.ResetAndDestroy(); |
106 |
100 |
107 for ( TInt driveNumber=EDriveZ; driveNumber >= EDriveA; driveNumber-- ) |
101 iFetchedWidgets = aWidgets; |
|
102 |
|
103 for ( TInt driveNumber = EDriveZ; driveNumber >= EDriveA; driveNumber-- ) |
108 { |
104 { |
109 if ( driveList[driveNumber] ) |
105 if ( driveList[driveNumber] ) |
110 { |
106 { |
111 User::LeaveIfError( iFs.DriveToChar( driveNumber, |
107 User::LeaveIfError( iFs.DriveToChar( driveNumber, |
112 iCurrentDriveLetter ) ); |
108 currentDriveLetter ) ); |
113 ScanOnDriveL( ); |
109 ScanOnDriveL( currentDriveLetter ); |
114 } |
110 } |
115 } |
111 } |
|
112 |
|
113 |
116 return iWidgets; |
114 return iWidgets; |
117 } |
115 } |
118 |
116 |
119 |
117 // ---------------------------------------------------------------------------- |
120 // ---------------------------------------------------------------------------- |
118 // |
121 // |
119 // ---------------------------------------------------------------------------- |
122 // ---------------------------------------------------------------------------- |
120 // |
123 // |
121 void CCaWidgetScannerParser::ScanOnDriveL( TChar& aDrive ) |
124 void CCaWidgetScannerParser::ScanOnDriveL( ) |
122 { |
125 { |
123 CDir* directories = GetDirectoriesLC( aDrive ); |
126 CDir* directories = GetDirectoriesLC( ); |
|
127 if ( directories ) |
124 if ( directories ) |
128 { |
125 { |
129 for ( TInt i(0); i<directories->Count( ); i++ ) |
126 for ( TInt i( 0 ); i < directories->Count(); i++ ) |
130 { |
127 { |
131 if((*directories)[i].IsDir()) |
128 if ( ( *directories )[i].IsDir() ) |
132 { |
129 { |
133 ParseDirectoryL((*directories)[i].iName); |
130 ParseDirectoryL( ( *directories )[i].iName, aDrive ); |
134 } |
131 } |
135 } |
132 } |
136 } |
133 } |
137 CleanupStack::PopAndDestroy( directories ); |
134 CleanupStack::PopAndDestroy( directories ); |
138 } |
135 } |
139 |
136 |
140 // ---------------------------------------------------------------------------- |
137 // ---------------------------------------------------------------------------- |
141 // |
138 // |
142 // ---------------------------------------------------------------------------- |
139 // ---------------------------------------------------------------------------- |
143 // |
140 // |
144 void CCaWidgetScannerParser::ParseDirectoryL( const TDesC& aDirectoryName ) |
141 void CCaWidgetScannerParser::ParseDirectoryL( const TDesC& aDirectoryName, |
145 { |
142 TChar& aDrive ) |
146 HBufC* manifestDirectoryPath = |
143 { |
147 GetManifestDirectoryPathLC( aDirectoryName ); |
144 HBufC* manifestDirectoryPath = GetManifestDirectoryPathLC( aDirectoryName, |
|
145 aDrive ); |
148 |
146 |
149 CDir* fileList = NULL; |
147 CDir* fileList = NULL; |
150 |
148 |
151 User::LeaveIfError( iFs.GetDir( *manifestDirectoryPath, |
149 User::LeaveIfError( iFs.GetDir( *manifestDirectoryPath, |
152 KEntryAttMatchExclude|KEntryAttDir, |
150 KEntryAttMatchExclude | KEntryAttDir, ESortByDate, fileList ) ); |
153 ESortByDate, fileList ) ); |
|
154 CleanupStack::PushL( fileList ); |
151 CleanupStack::PushL( fileList ); |
155 |
152 |
156 for ( TInt i = 0; i<fileList->Count( ); i++ ) |
153 for ( TInt i = 0; i < fileList->Count(); i++ ) |
157 { |
154 { |
158 if( (*fileList)[i].iName.Find( KManifest ) != KErrNotFound ) |
155 if ( ( *fileList )[i].iName.Find( KManifest ) != KErrNotFound ) |
159 { |
156 { |
160 RBuf fullFilePath; |
157 RBuf fullFilePath; |
161 CleanupClosePushL( fullFilePath ); |
158 CleanupClosePushL( fullFilePath ); |
162 fullFilePath.CreateL( manifestDirectoryPath->Length() + |
159 fullFilePath.CreateL( manifestDirectoryPath->Length() |
163 (*fileList)[i].iName.Length() ); |
160 + ( *fileList )[i].iName.Length() ); |
164 fullFilePath.Append( *manifestDirectoryPath ); |
161 fullFilePath.Append( *manifestDirectoryPath ); |
165 fullFilePath.Append( (*fileList)[i].iName ); |
162 fullFilePath.Append( ( *fileList )[i].iName ); |
166 //if file is corrupted we go to the next one |
163 |
167 TRAP_IGNORE(ParseManifestFileL( fullFilePath, aDirectoryName )); |
164 TPtrC packageUidPtr = manifestDirectoryPath->Mid( |
|
165 manifestDirectoryPath->Length() - KPackageUidPosition, |
|
166 KPackageUidLength); |
|
167 TUint packageUid; |
|
168 TLex lexer( packageUidPtr ); |
|
169 User::LeaveIfError( lexer.Val( packageUid, EHex ) ); |
|
170 |
|
171 CCaWidgetDescription* compareWidget = NULL; |
|
172 for ( TInt j = 0; j < iFetchedWidgets.Count(); j++ ) |
|
173 { |
|
174 if ( iFetchedWidgets[j]->GetPackageUidL() == packageUid ) |
|
175 { |
|
176 compareWidget = iFetchedWidgets[j]; |
|
177 compareWidget->SetValid( ETrue ); //do not remove from db |
|
178 break; // once found we dont iterate anymore |
|
179 } |
|
180 } |
|
181 |
|
182 if ( compareWidget ) |
|
183 { |
|
184 TTime modificationTime = ( *fileList )[i].iModified; |
|
185 TInt64 modificationIntTime = modificationTime.Int64(); |
|
186 TLex lex( compareWidget->GetModificationTime() ); |
|
187 TInt64 uintTimeDB( 0 ); |
|
188 User::LeaveIfError( lex.Val( uintTimeDB ) ); |
|
189 |
|
190 if ( uintTimeDB != modificationIntTime ) |
|
191 { |
|
192 TRAP_IGNORE( ParseManifestFileL( fullFilePath, |
|
193 aDirectoryName, aDrive ) ); |
|
194 } |
|
195 } |
|
196 else |
|
197 { |
|
198 TRAP_IGNORE( ParseManifestFileL( fullFilePath, aDirectoryName, |
|
199 aDrive ) ); |
|
200 } |
168 CleanupStack::PopAndDestroy( &fullFilePath ); |
201 CleanupStack::PopAndDestroy( &fullFilePath ); |
169 } |
202 } |
170 } |
203 } |
171 CleanupStack::PopAndDestroy( fileList ); |
204 CleanupStack::PopAndDestroy( fileList ); |
172 CleanupStack::PopAndDestroy( manifestDirectoryPath ); |
205 CleanupStack::PopAndDestroy( manifestDirectoryPath ); |
174 |
207 |
175 // ---------------------------------------------------------------------------- |
208 // ---------------------------------------------------------------------------- |
176 // |
209 // |
177 // ---------------------------------------------------------------------------- |
210 // ---------------------------------------------------------------------------- |
178 // |
211 // |
179 void CCaWidgetScannerParser::ParseManifestFileL( |
212 void CCaWidgetScannerParser::ParseManifestFileL( const TDesC& aFilePath, |
180 const TDesC& aFilePath, const TDesC& aPackageUid ) |
213 const TDesC& aPackageUid, TChar& aDrive ) |
181 { |
214 { |
182 RXmlEngDOMParser parser; |
215 RXmlEngDOMParser parser; |
183 CleanupClosePushL(parser); |
216 CleanupClosePushL( parser ); |
184 User::LeaveIfError(parser.Open(iDomImpl)); |
217 User::LeaveIfError( parser.Open( iDomImpl ) ); |
185 RXmlEngDocument doc = parser.ParseFileL(aFilePath, KChunkSize); |
218 RXmlEngDocument doc = parser.ParseFileL( aFilePath, KChunkSize ); |
186 CleanupClosePushL(doc); |
219 CleanupClosePushL( doc ); |
187 TXmlEngElement docElement = doc.DocumentElement(); |
220 TXmlEngElement docElement = doc.DocumentElement(); |
188 |
221 |
189 if (docElement.Name() == KWidgetProvider) { |
222 if ( docElement.Name() == KWidgetProvider ) |
|
223 { |
190 TXmlEngElement element; |
224 TXmlEngElement element; |
191 RXmlEngNodeList<TXmlEngElement> elementList; |
225 RXmlEngNodeList<TXmlEngElement> elementList; |
192 CleanupClosePushL(elementList); |
226 CleanupClosePushL( elementList ); |
193 docElement.GetElementsByTagNameL(elementList, KWidget); |
227 docElement.GetElementsByTagNameL( elementList, KWidget ); |
194 |
228 |
195 while (elementList.HasNext()) |
229 while ( elementList.HasNext() ) |
196 { |
230 { |
197 element = elementList.Next(); |
231 element = elementList.Next(); |
198 if ( element.HasAttributes() ) |
232 if ( element.HasAttributes() ) |
199 { |
233 { |
200 ParseWidgetL( aFilePath, element, aPackageUid ); |
234 ParseWidgetL( aFilePath, element, aPackageUid, aDrive ); |
201 } |
235 } |
202 } |
236 } |
203 CleanupStack::PopAndDestroy(&elementList); |
237 CleanupStack::PopAndDestroy( &elementList ); |
204 } else if (docElement.Name() == KWidgetManifest) { |
238 } |
205 |
239 else if ( docElement.Name() == KWidgetManifest ) |
206 delete iWidgetDescriptor; |
240 { |
207 iWidgetDescriptor = NULL; |
241 CCaWidgetDescription* widgetDescriptor = CCaWidgetDescription::NewL(); |
208 iWidgetDescriptor = CCaWidgetDescription::NewL(); |
242 widgetDescriptor->SetPackageUidL( aPackageUid ); |
209 iWidgetDescriptor->SetPackageUidL(aPackageUid); |
243 widgetDescriptor->SetFlag( EVisible, ETrue ); |
210 iWidgetDescriptor->SetVisible(ETrue); |
244 widgetDescriptor->SetManifestFilePathNameL( aFilePath ); |
211 iWidgetDescriptor->SetManifestFilePathNameL( aFilePath ); |
245 |
212 |
246 SetMmcIdL( widgetDescriptor, aDrive ); |
213 SetMmcIdL( iWidgetDescriptor ); |
247 |
214 |
|
215 RXmlEngNodeList<TXmlEngElement> childElementList; |
248 RXmlEngNodeList<TXmlEngElement> childElementList; |
216 CleanupClosePushL(childElementList); |
249 CleanupClosePushL( childElementList ); |
217 docElement.GetChildElements(childElementList); |
250 docElement.GetChildElements( childElementList ); |
218 TXmlEngElement element; |
251 TXmlEngElement element; |
219 |
252 |
220 while (childElementList.HasNext()) |
253 while ( childElementList.HasNext() ) |
221 { |
254 { |
222 element = childElementList.Next(); |
255 element = childElementList.Next(); |
223 if (element.Name() == KUri) |
256 if ( element.Name() == KUri ) |
224 { |
257 { |
225 ParseUriL(element); |
258 ParseUriL( element, widgetDescriptor ); |
226 } |
259 } |
227 else if (element.Name() == KTitle) |
260 else if ( element.Name() == KTitle ) |
228 { |
261 { |
229 ParseTitleL(element); |
262 ParseTitleL( element, widgetDescriptor ); |
230 } |
263 } |
231 else if (element.Name() == KIcon) |
264 else if ( element.Name() == KIcon ) |
232 { |
265 { |
233 ParseIconL(element,aPackageUid); |
266 ParseIconL( element, aPackageUid, widgetDescriptor, aDrive ); |
234 } |
267 } |
235 else if (element.Name() == KDescription) |
268 else if ( element.Name() == KDescription ) |
236 { |
269 { |
237 ParseDescriptionL(element); |
270 ParseDescriptionL( element, widgetDescriptor ); |
238 } |
271 } |
239 else if (element.Name() == KHidden) |
272 else if ( element.Name() == KHidden ) |
240 { |
273 { |
241 ParseHiddenL(element); |
274 ParseHiddenL( element, widgetDescriptor ); |
242 } |
275 } |
243 else if (element.Name() == KServiceXml) |
276 else if ( element.Name() == KServiceXml ) |
244 { |
277 { |
245 ParseServiceXmlL(element); |
278 ParseServiceXmlL( element, widgetDescriptor ); |
246 } |
279 } |
247 } |
280 else if ( element.Name() == KPreviewImageElementName ) |
248 CleanupStack::PopAndDestroy(&childElementList); |
281 { |
249 |
282 ParsePreviewImageNameL( element, aPackageUid, widgetDescriptor, aDrive ); |
250 //set path for hs to use, trim last 2 chars (doubleslash) |
283 } |
251 HBufC *libraryPath = GetManifestDirectoryPathLC( aPackageUid ); |
284 } |
252 iWidgetDescriptor->SetPathL(libraryPath->Mid(0,libraryPath->Length()-1)); |
285 CleanupStack::PopAndDestroy( &childElementList ); |
253 CleanupStack::PopAndDestroy(libraryPath); |
286 |
254 |
287 HBufC *libraryPath2 = GetManifestDirectoryPathLC( aPackageUid, aDrive ); |
255 HBufC *libraryPath2 = GetManifestDirectoryPathLC( aPackageUid ); |
288 libraryPath2 = libraryPath2->ReAllocL( libraryPath2->Length() |
256 libraryPath2 = libraryPath2->ReAllocL(libraryPath2->Length() + iWidgetDescriptor->GetUri().Length()); |
289 + widgetDescriptor->GetUri().Length() ); |
257 CleanupStack::Pop(1); |
290 libraryPath2->Des().Append( widgetDescriptor->GetUri() ); |
258 CleanupStack::PushL(libraryPath2); |
291 widgetDescriptor->SetLibraryL( *libraryPath2 ); |
259 libraryPath2->Des().Append(iWidgetDescriptor->GetUri()); |
292 CleanupStack::PopAndDestroy( libraryPath2 ); |
260 iWidgetDescriptor->SetLibraryL(*libraryPath2); |
293 |
261 CleanupStack::PopAndDestroy(libraryPath2); |
294 SetModificationTimeL( aFilePath, widgetDescriptor ); |
262 |
295 |
263 |
296 TInt index = iWidgets.Find( widgetDescriptor, |
264 TTime modificationTime; |
297 CCaWidgetDescription::Compare ); |
265 iFs.Modified( aFilePath, modificationTime); |
|
266 TInt64 modificationIntTime = modificationTime.Int64(); |
|
267 RBuf16 rBuf; |
|
268 rBuf.CleanupClosePushL(); |
|
269 rBuf.CreateL( KModificationTimeLength ); |
|
270 rBuf.AppendNum( modificationIntTime ); |
|
271 iWidgetDescriptor->SetModificationTimeL( rBuf ); |
|
272 CleanupStack::PopAndDestroy( &rBuf ); |
|
273 |
|
274 TInt index = iWidgets.Find( iWidgetDescriptor, CCaWidgetDescription::Compare ); |
|
275 if ( index != KErrNotFound ) |
298 if ( index != KErrNotFound ) |
276 { |
299 { |
277 delete iWidgets[index]; |
300 delete iWidgets[index]; |
278 iWidgets.Remove( index ); |
301 iWidgets.Remove( index ); |
279 } |
302 } |
280 iWidgets.AppendL( iWidgetDescriptor );//ownership transfer |
303 iWidgets.AppendL( widgetDescriptor );//ownership transfer |
281 iWidgetDescriptor = NULL; |
304 widgetDescriptor = NULL; |
282 } |
305 } |
283 |
306 |
284 CleanupStack::PopAndDestroy(&doc); |
307 CleanupStack::PopAndDestroy( &doc ); |
285 CleanupStack::PopAndDestroy(&parser); |
308 CleanupStack::PopAndDestroy( &parser ); |
286 } |
309 } |
287 |
310 |
288 // ---------------------------------------------------------------------------- |
311 // ---------------------------------------------------------------------------- |
289 // |
312 // |
290 // ---------------------------------------------------------------------------- |
313 // ---------------------------------------------------------------------------- |
291 // |
314 // |
292 void CCaWidgetScannerParser::ParseWidgetL( |
315 void CCaWidgetScannerParser::ParseWidgetL( const TDesC& aFilePath, |
293 const TDesC& aFilePath, TXmlEngElement aElement, |
316 TXmlEngElement& aElement, const TDesC& aPackageUid, TChar& aDrive ) |
294 const TDesC& aPackageUid ) |
|
295 { |
317 { |
296 CCaWidgetDescription* widget = CCaWidgetDescription::NewLC(); |
318 CCaWidgetDescription* widget = CCaWidgetDescription::NewLC(); |
297 |
319 |
298 SetUriL( aElement, widget ); |
320 SetUriL( aElement, widget ); |
299 SetLibraryL( aElement, aPackageUid, widget); |
321 SetLibraryL( aElement, aPackageUid, widget, aDrive ); |
300 SetTitleL( aElement, widget ); |
322 SetTitleL( aElement, widget ); |
301 SetDescriptionL( aElement, widget ); |
323 SetDescriptionL( aElement, widget ); |
302 SetVisibilityL( aElement, widget ); |
324 SetVisibilityL( aElement, widget ); |
303 SetIconUriL( aElement, aPackageUid, widget); |
325 SetIconUriL( aElement, aPackageUid, widget, aDrive ); |
304 widget->SetPackageUidL( aPackageUid ); |
326 widget->SetPackageUidL( aPackageUid ); |
305 widget->SetManifestFilePathNameL( aFilePath ); |
327 widget->SetManifestFilePathNameL( aFilePath ); |
306 SetMmcIdL( widget ); |
328 SetMmcIdL( widget, aDrive ); |
307 |
329 |
|
330 SetModificationTimeL( aFilePath, widget ); |
|
331 |
|
332 TInt index = iWidgets.Find( widget, CCaWidgetDescription::Compare ); |
|
333 if ( index != KErrNotFound ) |
|
334 { |
|
335 delete iWidgets[index]; |
|
336 iWidgets.Remove( index ); |
|
337 } |
|
338 iWidgets.AppendL( widget );//ownership transfer |
|
339 CleanupStack::Pop( widget ); |
|
340 } |
|
341 |
|
342 // ---------------------------------------------------------------------------- |
|
343 // |
|
344 // ---------------------------------------------------------------------------- |
|
345 // |
|
346 void CCaWidgetScannerParser::SetUriL( TXmlEngElement& aElement, |
|
347 CCaWidgetDescription* aWidget ) |
|
348 { |
|
349 HBufC *attributeValue = CnvUtfConverter::ConvertToUnicodeFromUtf8L( |
|
350 aElement.AttributeValueL( KUri ) ); |
|
351 CleanupStack::PushL( attributeValue ); |
|
352 |
|
353 if ( attributeValue->Compare( KNullDesC ) != 0 ) |
|
354 { |
|
355 aWidget->SetUriL( *attributeValue ); |
|
356 } |
|
357 CleanupStack::PopAndDestroy( attributeValue ); |
|
358 } |
|
359 |
|
360 // ---------------------------------------------------------------------------- |
|
361 // |
|
362 // ---------------------------------------------------------------------------- |
|
363 // |
|
364 void CCaWidgetScannerParser::SetLibraryL( TXmlEngElement& aElement, |
|
365 const TDesC& aPackageUid, CCaWidgetDescription* aWidget, TChar& aDrive ) |
|
366 { |
|
367 HBufC *attributeValue = CnvUtfConverter::ConvertToUnicodeFromUtf8L( |
|
368 aElement.AttributeValueL( KLibrary ) ); |
|
369 CleanupStack::PushL( attributeValue ); |
|
370 |
|
371 if ( attributeValue->Compare( KNullDesC ) != 0 ) |
|
372 { |
|
373 HBufC *libraryPath = GetManifestDirectoryPathLC( aPackageUid, aDrive ); |
|
374 |
|
375 libraryPath->ReAllocL( libraryPath->Length() + attributeValue->Length() ); |
|
376 |
|
377 TPtr libraryPathModifier( libraryPath->Des() ); |
|
378 libraryPathModifier.Append( *attributeValue ); |
|
379 aWidget->SetLibraryL( *libraryPath ); |
|
380 |
|
381 CleanupStack::PopAndDestroy( libraryPath ); |
|
382 } |
|
383 else |
|
384 { |
|
385 aWidget->SetLibraryL( KNoLibrary ); |
|
386 } |
|
387 CleanupStack::PopAndDestroy( attributeValue ); |
|
388 } |
|
389 |
|
390 // ---------------------------------------------------------------------------- |
|
391 // |
|
392 // ---------------------------------------------------------------------------- |
|
393 // |
|
394 void CCaWidgetScannerParser::SetTitleL( TXmlEngElement& aElement, |
|
395 CCaWidgetDescription* aWidget ) |
|
396 { |
|
397 HBufC *attributeValue = CnvUtfConverter::ConvertToUnicodeFromUtf8L( |
|
398 aElement.AttributeValueL( KTitle ) ); |
|
399 CleanupStack::PushL( attributeValue ); |
|
400 |
|
401 if ( attributeValue->Compare( KNullDesC ) != 0 ) |
|
402 { |
|
403 aWidget->SetTitleL( *attributeValue ); |
|
404 } |
|
405 CleanupStack::PopAndDestroy( attributeValue ); |
|
406 } |
|
407 |
|
408 // ---------------------------------------------------------------------------- |
|
409 // |
|
410 // ---------------------------------------------------------------------------- |
|
411 // |
|
412 void CCaWidgetScannerParser::SetDescriptionL( TXmlEngElement& aElement, |
|
413 CCaWidgetDescription* aWidget ) |
|
414 { |
|
415 HBufC *attributeValue = CnvUtfConverter::ConvertToUnicodeFromUtf8L( |
|
416 aElement.AttributeValueL( KDescription ) ); |
|
417 CleanupStack::PushL( attributeValue ); |
|
418 |
|
419 if ( attributeValue->Compare( KNullDesC ) != 0 ) |
|
420 { |
|
421 aWidget->SetDescriptionL( *attributeValue ); |
|
422 } |
|
423 CleanupStack::PopAndDestroy( attributeValue ); |
|
424 } |
|
425 |
|
426 // ---------------------------------------------------------------------------- |
|
427 // |
|
428 // ---------------------------------------------------------------------------- |
|
429 // |
|
430 void CCaWidgetScannerParser::SetVisibilityL( TXmlEngElement& aElement, |
|
431 CCaWidgetDescription* aWidget ) |
|
432 { |
|
433 HBufC *hidden = CnvUtfConverter::ConvertToUnicodeFromUtf8L( |
|
434 aElement.AttributeValueL( KHidden ) ); |
|
435 CleanupStack::PushL( hidden ); |
|
436 |
|
437 if ( hidden->Compare( KTrue ) == 0 ) |
|
438 { |
|
439 aWidget->SetFlag( EVisible, EFalse ); |
|
440 } |
|
441 else |
|
442 { |
|
443 aWidget->SetFlag( EVisible, ETrue ); |
|
444 } |
|
445 CleanupStack::PopAndDestroy( hidden ); |
|
446 } |
|
447 |
|
448 // ---------------------------------------------------------------------------- |
|
449 // |
|
450 // ---------------------------------------------------------------------------- |
|
451 // |
|
452 void CCaWidgetScannerParser::SetIconUriL( TXmlEngElement& aElement, |
|
453 const TDesC& aPackageUid, CCaWidgetDescription* aWidget, TChar& aDrive ) |
|
454 { |
|
455 HBufC *attributeValue = CnvUtfConverter::ConvertToUnicodeFromUtf8L( |
|
456 aElement.AttributeValueL( KIconUri ) ); |
|
457 CleanupStack::PushL( attributeValue ); |
|
458 |
|
459 if ( attributeValue->Compare( KNullDesC ) != 0 ) |
|
460 { |
|
461 HBufC* iconUriPath = GetManifestDirectoryPathLC( aPackageUid, aDrive ); |
|
462 iconUriPath->ReAllocL( iconUriPath->Length() + attributeValue->Length() ); |
|
463 |
|
464 TPtr iconUriPathModifier( iconUriPath->Des() ); |
|
465 iconUriPathModifier.Append( *attributeValue ); |
|
466 aWidget->SetIconUriL( *iconUriPath ); |
|
467 |
|
468 CleanupStack::PopAndDestroy( iconUriPath ); |
|
469 } |
|
470 CleanupStack::PopAndDestroy( attributeValue ); |
|
471 } |
|
472 |
|
473 // ---------------------------------------------------------------------------- |
|
474 // |
|
475 // ---------------------------------------------------------------------------- |
|
476 // |
|
477 void CCaWidgetScannerParser::SetMmcIdL( CCaWidgetDescription* aWidget, |
|
478 TChar& aDrive ) |
|
479 { |
|
480 TChar removableDrive; |
|
481 User::LeaveIfError( DriveInfo::GetDefaultDrive( |
|
482 DriveInfo::EDefaultRemovableMassStorage, removableDrive ) ); |
|
483 |
|
484 TChar massStorageDrive; |
|
485 User::LeaveIfError( DriveInfo::GetDefaultDrive( |
|
486 DriveInfo::EDefaultMassStorage, massStorageDrive ) ); |
|
487 if ( aDrive == removableDrive ) |
|
488 { |
|
489 RBuf mmcId; |
|
490 mmcId.CleanupClosePushL(); |
|
491 mmcId.CreateL( KMassStorageIdLength ); |
|
492 WidgetScannerUtils::CurrentMmcId( iFs, mmcId ); |
|
493 aWidget->SetMmcIdL( mmcId ); |
|
494 CleanupStack::PopAndDestroy( &mmcId ); |
|
495 } |
|
496 else if ( aDrive == massStorageDrive ) |
|
497 { |
|
498 aWidget->SetMmcIdL( KCaMassStorage ); |
|
499 } |
|
500 } |
|
501 // ---------------------------------------------------------------------------- |
|
502 // |
|
503 // ---------------------------------------------------------------------------- |
|
504 // |
|
505 void CCaWidgetScannerParser::SetModificationTimeL( const TDesC& aFilePath, |
|
506 CCaWidgetDescription* aWidgetDescriptor ) |
|
507 { |
308 TTime modificationTime; |
508 TTime modificationTime; |
309 iFs.Modified( aFilePath, modificationTime); |
509 iFs.Modified( aFilePath, modificationTime ); |
310 TInt64 modificationIntTime = modificationTime.Int64(); |
510 TInt64 modificationIntTime = modificationTime.Int64(); |
311 RBuf16 rBuf; |
511 RBuf16 rBuf; |
312 rBuf.CleanupClosePushL(); |
512 rBuf.CleanupClosePushL(); |
313 rBuf.CreateL( KModificationTimeLength ); |
513 rBuf.CreateL( KModificationTimeLength ); |
314 rBuf.AppendNum( modificationIntTime ); |
514 rBuf.AppendNum( modificationIntTime ); |
315 widget->SetModificationTimeL( rBuf ); |
515 aWidgetDescriptor->SetModificationTimeL( rBuf ); |
316 CleanupStack::PopAndDestroy( &rBuf ); |
516 CleanupStack::PopAndDestroy( &rBuf ); |
317 |
517 } |
318 TInt index = iWidgets.Find( widget, CCaWidgetDescription::Compare ); |
518 |
319 if ( index != KErrNotFound ) |
519 // ---------------------------------------------------------------------------- |
320 { |
520 // |
321 delete iWidgets[index]; |
521 // ---------------------------------------------------------------------------- |
322 iWidgets.Remove( index ); |
522 // |
323 } |
523 CDir* CCaWidgetScannerParser::GetDirectoriesLC( TChar& aDrive ) |
324 iWidgets.AppendL( widget );//ownership transfer |
|
325 CleanupStack::Pop( widget ); |
|
326 } |
|
327 |
|
328 |
|
329 // ---------------------------------------------------------------------------- |
|
330 // |
|
331 // ---------------------------------------------------------------------------- |
|
332 // |
|
333 void CCaWidgetScannerParser::SetUriL( |
|
334 TXmlEngElement & aElement, CCaWidgetDescription * aWidget ) |
|
335 { |
|
336 HBufC *attributeValue = CnvUtfConverter::ConvertToUnicodeFromUtf8L( |
|
337 aElement.AttributeValueL( KUri ) ); |
|
338 CleanupStack::PushL( attributeValue ); |
|
339 |
|
340 if( attributeValue->Compare( KNullDesC ) != 0 ) |
|
341 { |
|
342 aWidget->SetUriL( *attributeValue ); |
|
343 } |
|
344 CleanupStack::PopAndDestroy( attributeValue ); |
|
345 } |
|
346 |
|
347 // ---------------------------------------------------------------------------- |
|
348 // keep in mind that setLibrary also setsPath |
|
349 // ---------------------------------------------------------------------------- |
|
350 // |
|
351 void CCaWidgetScannerParser::SetLibraryL( TXmlEngElement & aElement, |
|
352 const TDesC & aPackageUid, CCaWidgetDescription * aWidget ) |
|
353 { |
|
354 HBufC *attributeValue = CnvUtfConverter::ConvertToUnicodeFromUtf8L( |
|
355 aElement.AttributeValueL( KLibrary ) ); |
|
356 CleanupStack::PushL( attributeValue ); |
|
357 |
|
358 if( attributeValue->Compare( KNullDesC ) != 0 ) |
|
359 { |
|
360 HBufC *libraryPath = GetManifestDirectoryPathLC( aPackageUid ); |
|
361 |
|
362 //set path for hs to use, trim last 2 chars (doubleslash) |
|
363 aWidget->SetPathL(libraryPath->Mid(0,libraryPath->Length()-1)); |
|
364 |
|
365 libraryPath->ReAllocL( |
|
366 libraryPath->Length() + attributeValue->Length()); |
|
367 |
|
368 TPtr libraryPathModifier( libraryPath->Des() ); |
|
369 libraryPathModifier.Append( *attributeValue ); |
|
370 aWidget->SetLibraryL( *libraryPath ); |
|
371 |
|
372 CleanupStack::PopAndDestroy( libraryPath ); |
|
373 } |
|
374 else |
|
375 { |
|
376 aWidget->SetLibraryL( KNoLibrary ); |
|
377 } |
|
378 CleanupStack::PopAndDestroy( attributeValue ); |
|
379 } |
|
380 |
|
381 // ---------------------------------------------------------------------------- |
|
382 // |
|
383 // ---------------------------------------------------------------------------- |
|
384 // |
|
385 void CCaWidgetScannerParser::SetTitleL( |
|
386 TXmlEngElement & aElement, CCaWidgetDescription * aWidget ) |
|
387 { |
|
388 HBufC *attributeValue = CnvUtfConverter::ConvertToUnicodeFromUtf8L( |
|
389 aElement.AttributeValueL( KTitle ) ); |
|
390 CleanupStack::PushL( attributeValue ); |
|
391 |
|
392 if( attributeValue->Compare( KNullDesC ) != 0 ) |
|
393 { |
|
394 aWidget->SetTitleL( *attributeValue ); |
|
395 } |
|
396 CleanupStack::PopAndDestroy( attributeValue ); |
|
397 } |
|
398 |
|
399 // ---------------------------------------------------------------------------- |
|
400 // |
|
401 // ---------------------------------------------------------------------------- |
|
402 // |
|
403 void CCaWidgetScannerParser::SetDescriptionL( |
|
404 TXmlEngElement & aElement, CCaWidgetDescription * aWidget ) |
|
405 { |
|
406 HBufC *attributeValue = CnvUtfConverter::ConvertToUnicodeFromUtf8L( |
|
407 aElement.AttributeValueL( KDescription ) ); |
|
408 CleanupStack::PushL( attributeValue ); |
|
409 |
|
410 if( attributeValue->Compare( KNullDesC ) != 0 ) |
|
411 { |
|
412 aWidget->SetDescriptionL( *attributeValue ); |
|
413 } |
|
414 CleanupStack::PopAndDestroy( attributeValue ); |
|
415 } |
|
416 |
|
417 // ---------------------------------------------------------------------------- |
|
418 // |
|
419 // ---------------------------------------------------------------------------- |
|
420 // |
|
421 void CCaWidgetScannerParser::SetVisibilityL( |
|
422 TXmlEngElement & aElement, CCaWidgetDescription * aWidget ) |
|
423 { |
|
424 HBufC *hidden = CnvUtfConverter::ConvertToUnicodeFromUtf8L( |
|
425 aElement.AttributeValueL( KHidden ) ); |
|
426 CleanupStack::PushL( hidden ); |
|
427 |
|
428 if( hidden->Compare( KTrue ) == 0 ) |
|
429 { |
|
430 aWidget->SetVisible( EFalse ); |
|
431 } |
|
432 else |
|
433 { |
|
434 aWidget->SetVisible( ETrue ); |
|
435 } |
|
436 CleanupStack::PopAndDestroy( hidden ); |
|
437 } |
|
438 |
|
439 // ---------------------------------------------------------------------------- |
|
440 // |
|
441 // ---------------------------------------------------------------------------- |
|
442 // |
|
443 void CCaWidgetScannerParser::SetIconUriL( TXmlEngElement & aElement, |
|
444 const TDesC & aPackageUid, CCaWidgetDescription * aWidget ) |
|
445 { |
|
446 HBufC *attributeValue = CnvUtfConverter::ConvertToUnicodeFromUtf8L( |
|
447 aElement.AttributeValueL( KIconUri ) ); |
|
448 CleanupStack::PushL( attributeValue ); |
|
449 |
|
450 if( attributeValue->Compare( KNullDesC ) != 0 ) |
|
451 { |
|
452 HBufC* iconUriPath = GetManifestDirectoryPathLC( aPackageUid ); |
|
453 iconUriPath->ReAllocL( |
|
454 iconUriPath->Length() + attributeValue->Length() ); |
|
455 |
|
456 TPtr iconUriPathModifier( iconUriPath->Des() ); |
|
457 iconUriPathModifier.Append( *attributeValue ); |
|
458 aWidget->SetIconUriL( *iconUriPath ); |
|
459 |
|
460 CleanupStack::PopAndDestroy( iconUriPath ); |
|
461 } |
|
462 CleanupStack::PopAndDestroy( attributeValue ); |
|
463 } |
|
464 |
|
465 // ---------------------------------------------------------------------------- |
|
466 // |
|
467 // ---------------------------------------------------------------------------- |
|
468 // |
|
469 void CCaWidgetScannerParser::SetMmcIdL( CCaWidgetDescription * widget ) |
|
470 { |
|
471 TChar removableDrive; |
|
472 User::LeaveIfError( DriveInfo::GetDefaultDrive( |
|
473 DriveInfo::EDefaultRemovableMassStorage, removableDrive ) ); |
|
474 |
|
475 TChar massStorageDrive; |
|
476 User::LeaveIfError( DriveInfo::GetDefaultDrive( |
|
477 DriveInfo::EDefaultMassStorage, massStorageDrive ) ); |
|
478 if( iCurrentDriveLetter == removableDrive ) |
|
479 { |
|
480 RBuf mmcId; |
|
481 mmcId.CreateL(KMassStorageIdLength); |
|
482 mmcId.CleanupClosePushL(); |
|
483 WidgetScannerUtils::CurrentMmcId( iFs, mmcId ); |
|
484 widget->SetMmcIdL( mmcId ); |
|
485 CleanupStack::PopAndDestroy( &mmcId ); |
|
486 } |
|
487 else if( iCurrentDriveLetter == massStorageDrive ) |
|
488 { |
|
489 widget->SetMmcIdL( KCaMassStorage ); |
|
490 } |
|
491 } |
|
492 |
|
493 // ---------------------------------------------------------------------------- |
|
494 // |
|
495 // ---------------------------------------------------------------------------- |
|
496 // |
|
497 CDir* CCaWidgetScannerParser::GetDirectoriesLC( ) |
|
498 { |
524 { |
499 CDir* result = NULL; |
525 CDir* result = NULL; |
500 HBufC* path = FullPathLC( ); |
526 HBufC* path = FullPathLC( aDrive ); |
501 iFs.GetDir( *path, KEntryAttDir, ESortByName, result ); |
527 iFs.GetDir( *path, KEntryAttDir, ESortByName, result ); |
502 CleanupStack::PopAndDestroy( path ); |
528 CleanupStack::PopAndDestroy( path ); |
503 CleanupStack::PushL( result ); |
529 CleanupStack::PushL( result ); |
504 return result; |
530 return result; |
505 } |
531 } |
506 |
532 |
507 // ---------------------------------------------------------------------------- |
533 // ---------------------------------------------------------------------------- |
508 // |
534 // |
509 // ---------------------------------------------------------------------------- |
535 // ---------------------------------------------------------------------------- |
510 // |
536 // |
511 HBufC* CCaWidgetScannerParser::FullPathLC( ) |
537 HBufC* CCaWidgetScannerParser::FullPathLC( TChar& aDrive ) const |
512 { |
538 { |
513 HBufC* result = |
539 HBufC* result = HBufC16::NewLC( iImportPath.Length() + KDriveLetterLength ); |
514 HBufC16::NewLC( iImportPath.Length() + KDriveLetterLength ); |
|
515 TPtr modifier( result->Des() ); |
540 TPtr modifier( result->Des() ); |
516 modifier.Append( iCurrentDriveLetter ); |
541 modifier.Append( aDrive ); |
517 modifier.Append( KColen ); |
542 modifier.Append( KColen ); |
518 modifier.Append( iImportPath ); |
543 modifier.Append( iImportPath ); |
519 return result; |
544 return result; |
520 } |
545 } |
521 |
546 |
522 // ---------------------------------------------------------------------------- |
547 // ---------------------------------------------------------------------------- |
523 // |
548 // |
524 // ---------------------------------------------------------------------------- |
549 // ---------------------------------------------------------------------------- |
525 // |
550 // |
526 HBufC* CCaWidgetScannerParser::GetManifestDirectoryPathLC( |
551 HBufC* CCaWidgetScannerParser::GetManifestDirectoryPathLC( |
527 const TDesC& aDirectoryName ) |
552 const TDesC& aDirectoryName, TChar& aDrive ) const |
528 { |
553 { |
529 HBufC* result = HBufC16::NewLC( KMaxPath ); |
554 HBufC* result = HBufC16::NewLC( KMaxPath ); |
530 TPtr modifier( result->Des() ); |
555 TPtr modifier( result->Des() ); |
531 HBufC* path = FullPathLC( ); |
556 HBufC* path = FullPathLC( aDrive ); |
532 modifier.Append( *path ); |
557 modifier.Append( *path ); |
533 CleanupStack::PopAndDestroy( path ); |
558 CleanupStack::PopAndDestroy( path ); |
534 modifier.Append( aDirectoryName ); |
559 modifier.Append( aDirectoryName ); |
535 modifier.Append( KDoubleSlash ); |
560 modifier.Append( KDoubleSlash ); |
536 return result; |
561 return result; |
537 } |
562 } |
538 |
563 |
539 void CCaWidgetScannerParser::ParseUriL(TXmlEngElement & aElement) |
564 // ---------------------------------------------------------------------------- |
540 { |
565 // |
541 if (aElement.Text().Length()) |
566 // ---------------------------------------------------------------------------- |
542 { |
567 // |
543 HBufC *utf16 = |
568 void CCaWidgetScannerParser::ParseUriL( TXmlEngElement& aElement, |
544 CnvUtfConverter::ConvertToUnicodeFromUtf8L( aElement.Text() ); |
569 CCaWidgetDescription* aWidgetDescriptor ) |
545 CleanupStack::PushL( utf16 ); |
570 { |
546 iWidgetDescriptor->SetUriL( *utf16 ); |
571 aWidgetDescriptor->SetUriL( *GetElementTextLC( aElement ) ); |
547 CleanupStack::PopAndDestroy( utf16 ); |
572 CleanupStack::PopAndDestroy( ); |
548 } |
573 } |
549 |
574 |
550 } |
575 // ---------------------------------------------------------------------------- |
551 void CCaWidgetScannerParser::ParseTitleL(TXmlEngElement & aElement) |
576 // |
552 { |
577 // ---------------------------------------------------------------------------- |
553 if (aElement.Text().Length()) |
578 // |
554 { |
579 void CCaWidgetScannerParser::ParseTitleL( TXmlEngElement& aElement, |
555 HBufC *utf16 = |
580 CCaWidgetDescription* aWidgetDescriptor ) |
556 CnvUtfConverter::ConvertToUnicodeFromUtf8L( aElement.Text() ); |
581 { |
557 CleanupStack::PushL( utf16 ); |
582 aWidgetDescriptor->SetTitleL( *GetElementTextLC( aElement ) ); |
558 iWidgetDescriptor->SetTitleL( *utf16 ); |
583 CleanupStack::PopAndDestroy( ); |
559 CleanupStack::PopAndDestroy( utf16 ); |
584 } |
560 } |
585 |
561 } |
586 // ---------------------------------------------------------------------------- |
562 void CCaWidgetScannerParser::ParseIconL(TXmlEngElement & aElement, |
587 // |
563 const TDesC & aPackageUid ) |
588 // ---------------------------------------------------------------------------- |
564 { |
589 // |
565 HBufC *utf16 = |
590 void CCaWidgetScannerParser::ParseIconL( TXmlEngElement& aElement, |
|
591 const TDesC& aPackageUid, CCaWidgetDescription* aWidgetDescriptor, |
|
592 TChar& aDrive ) |
|
593 { |
|
594 aWidgetDescriptor->SetIconUriL( |
|
595 *GetThemableGraphicsNameLC(aElement, aPackageUid, aDrive ) ); |
|
596 |
|
597 CleanupStack::PopAndDestroy( ); |
|
598 } |
|
599 |
|
600 // ---------------------------------------------------------------------------- |
|
601 // |
|
602 // ---------------------------------------------------------------------------- |
|
603 // |
|
604 void CCaWidgetScannerParser::ParsePreviewImageNameL( |
|
605 TXmlEngElement & aElement, |
|
606 const TDesC & aPackageUid, |
|
607 CCaWidgetDescription* aWidgetDescriptor, |
|
608 TChar& aDrive ) |
|
609 { |
|
610 aWidgetDescriptor->SetPreviewImageNameL( |
|
611 *GetThemableGraphicsNameLC(aElement, aPackageUid, aDrive ) ); |
|
612 |
|
613 CleanupStack::PopAndDestroy( ); |
|
614 } |
|
615 |
|
616 // ---------------------------------------------------------------------------- |
|
617 // |
|
618 // ---------------------------------------------------------------------------- |
|
619 // |
|
620 void CCaWidgetScannerParser::ParseDescriptionL( TXmlEngElement& aElement, |
|
621 CCaWidgetDescription* aWidgetDescriptor ) |
|
622 { |
|
623 aWidgetDescriptor->SetDescriptionL( *GetElementTextLC( aElement ) ); |
|
624 CleanupStack::PopAndDestroy(); |
|
625 } |
|
626 |
|
627 // ---------------------------------------------------------------------------- |
|
628 // |
|
629 // ---------------------------------------------------------------------------- |
|
630 // |
|
631 void CCaWidgetScannerParser::ParseHiddenL( TXmlEngElement& aElement, |
|
632 CCaWidgetDescription* aWidgetDescriptor ) |
|
633 { |
|
634 if( aElement.Text().Compare( _L8("true") ) == 0 ) |
|
635 { |
|
636 aWidgetDescriptor->SetFlag( EVisible, EFalse ); |
|
637 } |
|
638 } |
|
639 |
|
640 // ---------------------------------------------------------------------------- |
|
641 // |
|
642 // ---------------------------------------------------------------------------- |
|
643 // |
|
644 void CCaWidgetScannerParser::ParseServiceXmlL( TXmlEngElement& aElement, |
|
645 CCaWidgetDescription* aWidgetDescriptor ) |
|
646 { |
|
647 aWidgetDescriptor->SetServiceXmlL( *GetElementTextLC( aElement ) ); |
|
648 CleanupStack::PopAndDestroy( ); |
|
649 } |
|
650 |
|
651 // ---------------------------------------------------------------------------- |
|
652 // |
|
653 // ---------------------------------------------------------------------------- |
|
654 // |
|
655 HBufC* CCaWidgetScannerParser::GetElementTextLC( |
|
656 const TXmlEngElement& aElement ) const |
|
657 { |
|
658 HBufC* const elementText = |
566 CnvUtfConverter::ConvertToUnicodeFromUtf8L( aElement.Text() ); |
659 CnvUtfConverter::ConvertToUnicodeFromUtf8L( aElement.Text() ); |
567 CleanupStack::PushL( utf16 ); |
660 CleanupStack::PushL( elementText ); |
568 if ( utf16->Compare( KNullDesC ) ) |
661 return elementText; |
569 { |
662 } |
570 HBufC* iconUriPath = GetManifestDirectoryPathLC( aPackageUid ); |
663 |
571 iconUriPath = iconUriPath->ReAllocL( iconUriPath->Length() + utf16->Length() ); |
664 |
572 CleanupStack::Pop(1); |
665 // ---------------------------------------------------------------------------- |
573 CleanupStack::PushL(iconUriPath); |
666 // |
574 TPtr iconUriPathModifier( iconUriPath->Des() ); |
667 // ---------------------------------------------------------------------------- |
575 iconUriPathModifier.Append( *utf16 ); |
668 // |
576 iWidgetDescriptor->SetIconUriL( *iconUriPath ); |
669 HBufC* CCaWidgetScannerParser::GetThemableGraphicsNameLC( |
577 CleanupStack::PopAndDestroy( iconUriPath ); |
670 const TXmlEngElement& aElement, |
578 } |
671 const TDesC& aPackageUid, |
579 |
672 TChar& aDrive ) const |
580 CleanupStack::PopAndDestroy( utf16 ); |
673 { |
581 } |
674 RBuf graphicsName; |
582 |
675 graphicsName.CleanupClosePushL(); |
583 void CCaWidgetScannerParser::ParseDescriptionL(TXmlEngElement & aElement) |
676 HBufC* result; |
584 { |
677 |
585 HBufC *desc = |
678 |
586 CnvUtfConverter::ConvertToUnicodeFromUtf8L( aElement.Text() ); |
679 if ( aElement.Text() != KNullDesC8 ) |
587 CleanupStack::PushL( desc ); |
680 { |
588 |
681 RBuf elementText; |
589 if( desc->Compare( KNullDesC ) != 0 ) |
682 elementText.CleanupClosePushL(); |
590 { |
683 |
591 iWidgetDescriptor->SetDescriptionL( *desc ); |
684 elementText.Assign( |
592 } |
685 CnvUtfConverter::ConvertToUnicodeFromUtf8L( aElement.Text() ) ); |
593 CleanupStack::PopAndDestroy( desc ); |
686 |
594 } |
687 if ( TParsePtrC(elementText).Ext() != KNullDesC ) |
595 void CCaWidgetScannerParser::ParseHiddenL( TXmlEngElement& aElement ) |
688 { |
596 { |
689 HBufC* const manifestDirectoryPath( |
597 if( aElement.Text().Compare( _L8("true") ) == 0 ) |
690 GetManifestDirectoryPathLC( aPackageUid, aDrive ) ); |
598 { |
691 |
599 iWidgetDescriptor->SetVisible( EFalse ); |
692 graphicsName.CreateL( manifestDirectoryPath->Length() + |
600 } |
693 elementText.Length() ); |
601 |
694 graphicsName.Append( *manifestDirectoryPath ); |
602 } |
695 |
603 void CCaWidgetScannerParser::ParseServiceXmlL( TXmlEngElement& aElement ) |
696 CleanupStack::PopAndDestroy( manifestDirectoryPath ); |
604 { |
697 } |
605 HBufC *serviceXml = CnvUtfConverter::ConvertToUnicodeFromUtf8L( aElement.Text() ); |
698 else |
606 CleanupStack::PushL( serviceXml ); |
699 { |
607 |
700 graphicsName.CreateL( elementText.Length() ); |
608 if (serviceXml->Compare(KNullDesC) != 0) |
701 } |
609 { |
702 |
610 iWidgetDescriptor->SetServiceXmlL( *serviceXml ); |
703 graphicsName.Append( elementText ); |
611 } |
704 result = HBufC::NewL( graphicsName.Length() ) ; |
612 CleanupStack::PopAndDestroy( serviceXml ); |
705 *result = graphicsName; |
613 } |
706 |
|
707 CleanupStack::PopAndDestroy( &elementText ); |
|
708 } |
|
709 else |
|
710 { |
|
711 result = HBufC::NewL( 1 ) ; |
|
712 } |
|
713 CleanupStack::PopAndDestroy( &graphicsName ); |
|
714 CleanupStack::PushL( result ); |
|
715 |
|
716 return result; |
|
717 } |
|
718 |
|
719 |
614 // End of File |
720 // End of File |