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