114
|
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: Utility for common code.
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
|
|
19 |
#include "hspsthememanagement.h"
|
|
20 |
#include "hspsserverutil.h"
|
|
21 |
#include "hspsodt.h"
|
|
22 |
#include "hspsdomdepthiterator.h"
|
|
23 |
#include "hspsdomnode.h"
|
|
24 |
#include "hspsdomdocument.h"
|
|
25 |
#include "hspsconfiguration.h"
|
|
26 |
#include "hspsdomlist.h"
|
|
27 |
#include "hspsresource.h"
|
|
28 |
#include "hspsdomattribute.h"
|
|
29 |
#include "hspsmanifest.h"
|
|
30 |
#include "bautils.h"
|
|
31 |
#include "sysutil.h"
|
|
32 |
#include <syslangutil.h>
|
|
33 |
#include <driveinfo.h>
|
|
34 |
|
|
35 |
|
|
36 |
_LIT(KHspsFolder, "\\200159c0\\themes\\" );
|
|
37 |
_LIT(KSourcesFolder, "\\sources\\");
|
|
38 |
_LIT( KThemesFolder, "\\themes\\" );
|
|
39 |
_LIT( KDoubleBackSlash, "\\" );
|
|
40 |
_LIT8( KHexPrefix8, "0x" );
|
|
41 |
_LIT( KClientSources, "c:\\private\\%x\\%D\\%D\\%D\\%S\\sources\\%S" );
|
|
42 |
|
|
43 |
// -----------------------------------------------------------------------------
|
|
44 |
// hspsServerUtil::GenerateConfigurationAttributesL
|
|
45 |
// -----------------------------------------------------------------------------
|
|
46 |
//
|
|
47 |
void hspsServerUtil::GenerateConfigurationAttributesL( ChspsODT& aOdt )
|
|
48 |
{
|
|
49 |
ChspsDomDocument& dom = aOdt.DomDocument();
|
|
50 |
ChspsDomDepthIterator* iter = ChspsDomDepthIterator::NewL( *dom.RootNode() );
|
|
51 |
CleanupStack::PushL( iter );
|
|
52 |
|
|
53 |
ChspsDomNode* prevNode = NULL;
|
|
54 |
ChspsDomNode* node = iter->First();
|
|
55 |
while( node && prevNode != node )
|
|
56 |
{
|
|
57 |
const TDesC8& name = node->Name();
|
|
58 |
|
|
59 |
// Configuration element
|
|
60 |
if ( name == KConfigurationElement )
|
|
61 |
{
|
|
62 |
// Add attributes for the configuration node
|
|
63 |
// NOTE! ID attribute is not set here
|
|
64 |
TPtrC8 ptr = KManifestTypeApp().Ptr();
|
|
65 |
switch ( aOdt.ConfigurationType() )
|
|
66 |
{
|
|
67 |
case EhspsViewConfiguration:
|
|
68 |
{
|
|
69 |
ptr.Set( KManifestTypeView );
|
|
70 |
}
|
|
71 |
break;
|
|
72 |
case EhspsWidgetConfiguration:
|
|
73 |
{
|
|
74 |
ptr.Set( KManifestTypeWidget );
|
|
75 |
}
|
|
76 |
break;
|
|
77 |
case EhspsTemplateConfiguration:
|
|
78 |
{
|
|
79 |
ptr.Set( KManifestTypeTemplate );
|
|
80 |
}
|
|
81 |
break;
|
|
82 |
default:
|
|
83 |
{
|
|
84 |
}
|
|
85 |
}
|
|
86 |
|
|
87 |
AddAttributeDescL( *node, KConfigurationAttrType, ptr );
|
|
88 |
|
|
89 |
AddAttributeNumericL( *node, KConfigurationAttrInterface, aOdt.RootUid(), EHex );
|
|
90 |
|
|
91 |
AddAttributeNumericL( *node, KConfigurationAttrUid, aOdt.ThemeUid(), EHex );
|
|
92 |
|
|
93 |
// Create "name" and "_name" attributes, of which latter holds the entity reference
|
|
94 |
// (logical key for finding localizad strings)
|
|
95 |
HBufC8* nameBuf = HBufC8::NewLC( aOdt.ThemeFullName().Length() );
|
|
96 |
TPtr8 namePtr( nameBuf->Des() );
|
|
97 |
namePtr.Copy( aOdt.ThemeFullName() );
|
|
98 |
AddAttributeDescL( *node, KConfigurationAttrName, namePtr ); // will be updated when localized
|
|
99 |
AddAttributeDescL( *node, KConfigurationAttrNameEntity, namePtr ); // logical id
|
|
100 |
CleanupStack::PopAndDestroy( nameBuf );
|
|
101 |
|
|
102 |
// Create theme version attribute
|
|
103 |
HBufC8* tv = HBufC8::NewLC( aOdt.ThemeVersion().Length() );
|
|
104 |
TPtr8 tvPtr( tv->Des() );
|
|
105 |
tvPtr.Copy( aOdt.ThemeVersion() );
|
|
106 |
AddAttributeDescL( *node, KConfigurationAttrVersion, tvPtr );
|
|
107 |
CleanupStack::PopAndDestroy( tv );
|
|
108 |
|
|
109 |
AddAttributeNumericL ( *node, KConfigurationAttrMultiInstance,
|
|
110 |
aOdt.MultiInstance(), EDecimal );
|
|
111 |
|
|
112 |
AddAttributeDescL( *node, KConfigurationAttrState, KConfStateNotConfirmed );
|
|
113 |
|
|
114 |
const TInt descLength = aOdt.Description().Length();
|
|
115 |
if ( descLength )
|
|
116 |
{
|
|
117 |
// Add description of the widget (16 > 8bit conversion)
|
|
118 |
HBufC8* buf = HBufC8::NewLC( descLength );
|
|
119 |
TPtr8 bufPtr( buf->Des() );
|
|
120 |
bufPtr.Copy( aOdt.Description() );
|
|
121 |
AddAttributeDescL( *node, KConfigurationAttrDesc, bufPtr ); // will be updated when localized
|
|
122 |
AddAttributeDescL( *node, KConfigurationAttrDescEntity, bufPtr ); // logical id
|
|
123 |
CleanupStack::PopAndDestroy( buf );
|
|
124 |
}
|
|
125 |
else
|
|
126 |
{
|
|
127 |
AddAttributeDescL( *node, KConfigurationAttrDesc, KNullDesC8 );
|
|
128 |
}
|
|
129 |
|
|
130 |
}
|
|
131 |
|
|
132 |
prevNode = node;
|
|
133 |
node = iter->NextL();
|
|
134 |
}
|
|
135 |
CleanupStack::PopAndDestroy( iter );
|
|
136 |
}
|
|
137 |
|
|
138 |
// -----------------------------------------------------------------------------
|
|
139 |
// ChspsInstallationHandler::GenerateObjectAttributesL()
|
|
140 |
// -----------------------------------------------------------------------------
|
|
141 |
//
|
|
142 |
void hspsServerUtil::GenerateObjectAttributesL( ChspsODT& aOdt )
|
|
143 |
{
|
|
144 |
// Find the configuration node
|
|
145 |
ChspsDomDocument& dom = aOdt.DomDocument();
|
|
146 |
ChspsDomNode* configurationNode = dom.RootNode();
|
|
147 |
if ( !configurationNode )
|
|
148 |
{
|
|
149 |
#ifdef _hsps_DEBUG_
|
|
150 |
RDebug::Print( _L("hspsServerUtil::GenerateObjectAttributesL(): - invalid ODT!") );
|
|
151 |
#endif
|
|
152 |
User::Leave( KErrGeneral );
|
|
153 |
}
|
|
154 |
|
|
155 |
// Find resources node from the XML definition (child of the configuration node)
|
|
156 |
ChspsDomList& childsList = configurationNode->ChildNodes();
|
|
157 |
ChspsDomNode* resourcesNode = (ChspsDomNode *)childsList.FindByName( KResourcesElement );
|
|
158 |
TInt popResources = EFalse;
|
|
159 |
if ( !resourcesNode )
|
|
160 |
{
|
|
161 |
// Create a node and add it into the configuration node
|
|
162 |
resourcesNode = dom.CreateElementNSL(
|
|
163 |
KResourcesElement,
|
|
164 |
configurationNode->Namespace()
|
|
165 |
);
|
|
166 |
CleanupStack::PushL( resourcesNode );
|
|
167 |
popResources = ETrue;
|
|
168 |
configurationNode->AddChildL( resourcesNode );
|
|
169 |
resourcesNode->SetParent( configurationNode );
|
|
170 |
}
|
|
171 |
|
|
172 |
// Loop ODT's resources (parsed ealier from the manifest file)
|
|
173 |
const TInt resourceCount = aOdt.ResourceCount();
|
|
174 |
TBool addResource = EFalse;
|
|
175 |
for( TInt resourceIndex=0; resourceIndex < resourceCount; resourceIndex++ )
|
|
176 |
{
|
|
177 |
ChspsResource& resource = aOdt.ResourceL( resourceIndex );
|
|
178 |
|
|
179 |
addResource = EFalse;
|
|
180 |
|
|
181 |
// If resource is located under the sources folder
|
|
182 |
if ( resource.FileName().FindF( KSourcesFolder ) > 0 )
|
|
183 |
{
|
|
184 |
// If resource is for the active device language or it's a locale independent resource
|
|
185 |
addResource = ( resource.Language() == aOdt.OdtLanguage() || resource.Language() == ELangNone );
|
|
186 |
}
|
|
187 |
|
|
188 |
if ( addResource )
|
|
189 |
{
|
|
190 |
// Create an object node and add the object into the resources list
|
|
191 |
ChspsDomNode* objectNode = dom.CreateElementNSL(
|
|
192 |
KObjectElement,
|
|
193 |
resourcesNode->Namespace()
|
|
194 |
);
|
|
195 |
CleanupStack::PushL( objectNode );
|
|
196 |
resourcesNode->AddChildL( objectNode );
|
|
197 |
objectNode->SetParent( resourcesNode );
|
|
198 |
|
|
199 |
// Name (16->8bit conversion)
|
|
200 |
HBufC8* nameBuf = HBufC8::NewLC( resource.ResourceId().Length() );
|
|
201 |
TPtr8 namePtr( nameBuf->Des() );
|
|
202 |
namePtr.Copy( GetFixedOdtName( resource.ResourceId() ) );
|
|
203 |
|
|
204 |
AddAttributeDescL( *objectNode, KObjectAttrFilename, namePtr );
|
|
205 |
CleanupStack::PopAndDestroy( nameBuf );
|
|
206 |
|
|
207 |
// Media type
|
|
208 |
TPtrC8 mimePtr( resource.MimeType().Des8() );
|
|
209 |
if ( mimePtr.Length() )
|
|
210 |
{
|
|
211 |
AddAttributeDescL( *objectNode, KObjectAttrMediatype, mimePtr );
|
|
212 |
}
|
|
213 |
|
|
214 |
// Tag
|
|
215 |
TPtrC tagPtr( resource.Tags() );
|
|
216 |
if ( tagPtr.Length() )
|
|
217 |
{
|
|
218 |
// (16->8bit conversion)
|
|
219 |
HBufC8* buf = HBufC8::NewLC( tagPtr.Length() );
|
|
220 |
TPtr8 bufPtr( buf->Des() );
|
|
221 |
bufPtr.Copy( tagPtr );
|
|
222 |
AddAttributeDescL( *objectNode, KObjectAttrTag, bufPtr );
|
|
223 |
CleanupStack::PopAndDestroy( buf );
|
|
224 |
}
|
|
225 |
|
|
226 |
// Path
|
|
227 |
TInt pos = resource.FileName().FindF( KHspsFolder );
|
|
228 |
if ( pos > 0 )
|
|
229 |
{
|
|
230 |
// Remove filename and extension from the path
|
|
231 |
TParsePtrC parserPtr( resource.FileName() );
|
|
232 |
TFileName path( parserPtr.DriveAndPath() );
|
|
233 |
|
|
234 |
// Remove path to the Definition repository
|
|
235 |
path.Copy( path.Mid( pos + KHspsFolder().Length() ) );
|
|
236 |
|
|
237 |
// Fix path references for localized resources
|
|
238 |
GetLocaleIndependentResourcePath( resource.Language(), path );
|
|
239 |
|
|
240 |
// 16->8bit conversion
|
|
241 |
HBufC8 *pathBuf = HBufC8::NewLC( path.Length() );
|
|
242 |
pathBuf->Des().Copy( path );
|
|
243 |
|
|
244 |
AddAttributeDescL( *objectNode, KObjectAttrPath, pathBuf->Des() );
|
|
245 |
CleanupStack::PopAndDestroy( pathBuf );
|
|
246 |
}
|
|
247 |
|
|
248 |
// Now the document has an ownership of the objectnode
|
|
249 |
CleanupStack::Pop( objectNode );
|
|
250 |
|
|
251 |
}
|
|
252 |
|
|
253 |
} // for loop
|
|
254 |
|
|
255 |
if ( popResources )
|
|
256 |
{
|
|
257 |
// Now the document has an ownership of the resourcesNode
|
|
258 |
CleanupStack::Pop( resourcesNode );
|
|
259 |
}
|
|
260 |
}
|
|
261 |
|
|
262 |
|
|
263 |
TFileName hspsServerUtil::GetFixedOdtName(
|
|
264 |
const TDesC& aNameAndExtension )
|
|
265 |
{
|
|
266 |
TParsePtrC parsePtr( aNameAndExtension );
|
|
267 |
TPtrC fileExtension = parsePtr.Ext();
|
|
268 |
if ( fileExtension.Length() > 2 && fileExtension.Left(2).CompareF( _L(".o") ) == 0 )
|
|
269 |
{
|
|
270 |
// Strip the first letter
|
|
271 |
TInt odtIndex(0);
|
|
272 |
TLex lex( fileExtension.Mid(3) );
|
|
273 |
if ( lex.Val( odtIndex ) == KErrNone && odtIndex >= 0 )
|
|
274 |
{
|
|
275 |
fileExtension.Set( _L(".o0000") );
|
|
276 |
}
|
|
277 |
}
|
|
278 |
|
|
279 |
TFileName fileName( parsePtr.Name() );
|
|
280 |
fileName.Append( fileExtension );
|
|
281 |
return fileName;
|
|
282 |
}
|
|
283 |
|
|
284 |
// -----------------------------------------------------------------------------
|
|
285 |
// hspsServerUtil::GetLocaleIndependentResourcePath
|
|
286 |
// -----------------------------------------------------------------------------
|
|
287 |
//
|
|
288 |
void hspsServerUtil::GetLocaleIndependentResourcePath(
|
|
289 |
const TLanguage& aResourceLanguage,
|
|
290 |
TFileName& aPath )
|
|
291 |
{
|
|
292 |
TBool isLocaleSpecificResource = ( aResourceLanguage != ELangNone );
|
|
293 |
|
|
294 |
// If locale specific resource
|
|
295 |
if ( isLocaleSpecificResource )
|
|
296 |
{
|
|
297 |
// Remove locale specific subfolder from the path
|
|
298 |
TInt pos = aPath.FindF( KSourcesFolder );
|
|
299 |
if ( pos )
|
|
300 |
{
|
|
301 |
aPath.Copy( aPath.Left( pos + KSourcesFolder().Length() ) );
|
|
302 |
}
|
|
303 |
}
|
|
304 |
}
|
|
305 |
|
|
306 |
// -----------------------------------------------------------------------------
|
|
307 |
// hspsServerUtil::GetRelativeResourcePath
|
|
308 |
// -----------------------------------------------------------------------------
|
|
309 |
//
|
|
310 |
void hspsServerUtil::GetRelativeResourcePath(
|
|
311 |
const TFileName& aSourceFile,
|
|
312 |
TPath& aRelativePath )
|
|
313 |
{
|
|
314 |
// find last part (structure after "/themes/")
|
|
315 |
TInt pos = aSourceFile.FindF( KThemesFolder );
|
|
316 |
if( pos != KErrNotFound )
|
|
317 |
{
|
|
318 |
pos += KThemesFolder().Length();
|
|
319 |
TInt len( aSourceFile.Length() - pos );
|
|
320 |
aRelativePath.Copy( aSourceFile.Right( len ) );
|
|
321 |
}
|
|
322 |
}
|
|
323 |
|
|
324 |
// -----------------------------------------------------------------------------
|
|
325 |
// hspsServerUtil::AddAttributeNumericL
|
|
326 |
// -----------------------------------------------------------------------------
|
|
327 |
//
|
|
328 |
TInt hspsServerUtil::AddAttributeNumericL(
|
|
329 |
ChspsDomNode& aNode,
|
|
330 |
const TDesC8& aAttrName,
|
|
331 |
const TInt aValue,
|
|
332 |
const TRadix aFormat )
|
|
333 |
{
|
|
334 |
// Format change
|
|
335 |
// Value string, 10 -> Max decimal 4294967295 , max hexadecimal 0xXXXXXXXX
|
|
336 |
const TInt KMaxLength = 10;
|
|
337 |
TBuf8<KMaxLength> attValueDes8;
|
|
338 |
|
|
339 |
if ( aFormat == EHex )
|
|
340 |
{
|
|
341 |
_LIT8( KFormat8, "%X" );
|
|
342 |
_LIT8( KHexPrefix, "0x" );
|
|
343 |
attValueDes8.Append( KHexPrefix );
|
|
344 |
attValueDes8.AppendFormat( KFormat8, aValue );
|
|
345 |
}
|
|
346 |
else // EDecimal
|
|
347 |
{
|
|
348 |
_LIT8( KFormat8, "%d" );
|
|
349 |
attValueDes8.AppendFormat( KFormat8, aValue );
|
|
350 |
}
|
|
351 |
|
|
352 |
ChspsDomList& attrList = aNode.AttributeList();
|
|
353 |
ChspsDomAttribute* attr = static_cast<ChspsDomAttribute*>( attrList.FindByName(aAttrName) );
|
|
354 |
if ( attr )
|
|
355 |
{
|
|
356 |
// Replace value of the attribute
|
|
357 |
attr->SetValueL( attValueDes8 );
|
|
358 |
}
|
|
359 |
else
|
|
360 |
{
|
|
361 |
// Add an attribute
|
|
362 |
ChspsDomAttribute* attr = ChspsDomAttribute::NewL( aAttrName, aNode.StringPool() );
|
|
363 |
CleanupStack::PushL( attr );
|
|
364 |
attr->SetValueL( attValueDes8 );
|
|
365 |
ChspsDomList& attrList = aNode.AttributeList();
|
|
366 |
attrList.AddItemL( attr ); //takes ownership
|
|
367 |
CleanupStack::Pop( attr );
|
|
368 |
}
|
|
369 |
|
|
370 |
return KErrNone;
|
|
371 |
}
|
|
372 |
|
|
373 |
// -----------------------------------------------------------------------------
|
|
374 |
// hspsServerUtil::AddAttributeDescL
|
|
375 |
// -----------------------------------------------------------------------------
|
|
376 |
//
|
|
377 |
void hspsServerUtil::AddAttributeDescL(
|
|
378 |
ChspsDomNode& aNode,
|
|
379 |
const TDesC8& aAttrName,
|
|
380 |
const TDesC8& aValue )
|
|
381 |
{
|
|
382 |
ChspsDomList& attrList = aNode.AttributeList();
|
|
383 |
ChspsDomAttribute* attr = static_cast<ChspsDomAttribute*>( attrList.FindByName(aAttrName) );
|
|
384 |
if ( attr )
|
|
385 |
{
|
|
386 |
// Replace value of the attribute
|
|
387 |
attr->SetValueL( aValue );
|
|
388 |
}
|
|
389 |
else
|
|
390 |
{
|
|
391 |
// Add an attribute
|
|
392 |
ChspsDomAttribute* attr = ChspsDomAttribute::NewL( aAttrName, aNode.StringPool() );
|
|
393 |
CleanupStack::PushL( attr );
|
|
394 |
attr->SetValueL( aValue );
|
|
395 |
ChspsDomList& attrList = aNode.AttributeList();
|
|
396 |
attrList.AddItemL( attr ); //takes ownership
|
|
397 |
CleanupStack::Pop( attr );
|
|
398 |
}
|
|
399 |
}
|
|
400 |
|
|
401 |
|
|
402 |
// -----------------------------------------------------------------------------
|
|
403 |
// Finds a configuration node with the provided id attribute
|
|
404 |
// -----------------------------------------------------------------------------
|
|
405 |
//
|
|
406 |
ChspsDomNode* hspsServerUtil::FindConfigurationNodeL(
|
|
407 |
ChspsODT& aOdt,
|
|
408 |
const TInt aConfigurationId )
|
|
409 |
{
|
|
410 |
__UHEAP_MARK;
|
|
411 |
|
|
412 |
ChspsDomNode *configurationNode = NULL;
|
|
413 |
|
|
414 |
ChspsDomDocument& dom = aOdt.DomDocument();
|
|
415 |
ChspsDomDepthIterator* iter = ChspsDomDepthIterator::NewL( *dom.RootNode() );
|
|
416 |
CleanupStack::PushL( iter );
|
|
417 |
|
|
418 |
// Find a configuration node with an id attribute that matches the provided id
|
|
419 |
ChspsDomNode* node = iter->First();
|
|
420 |
ChspsDomNode* prevNode = NULL;
|
|
421 |
TBool jobDone = EFalse;
|
|
422 |
while( node && !jobDone && prevNode != node )
|
|
423 |
{
|
|
424 |
const TDesC8& name = node->Name();
|
|
425 |
|
|
426 |
// An element was found
|
|
427 |
if ( name == KConfigurationElement )
|
|
428 |
{
|
|
429 |
ChspsDomList& attrList = node->AttributeList();
|
|
430 |
ChspsDomAttribute* idAttr = static_cast<ChspsDomAttribute*>( attrList.FindByName(KConfigurationAttrId) );
|
|
431 |
if ( !idAttr )
|
|
432 |
{
|
|
433 |
// Return with NULL
|
|
434 |
jobDone = ETrue;
|
|
435 |
}
|
|
436 |
else
|
|
437 |
{
|
|
438 |
TInt id(0);
|
|
439 |
const TDesC8& idValue = idAttr->Value();
|
|
440 |
TLex8 lex( idValue );
|
|
441 |
lex.Val( id );
|
|
442 |
if ( aConfigurationId == id )
|
|
443 |
{
|
|
444 |
configurationNode = node;
|
|
445 |
jobDone = ETrue;
|
|
446 |
}
|
|
447 |
}
|
|
448 |
}
|
|
449 |
|
|
450 |
prevNode = node;
|
|
451 |
node = iter->NextL();
|
|
452 |
}
|
|
453 |
CleanupStack::PopAndDestroy( iter );
|
|
454 |
|
|
455 |
#ifdef _hsps_DEBUG_
|
|
456 |
if ( !configurationNode )
|
|
457 |
{
|
|
458 |
RDebug::Print( _L("hspsServerUtil::FindConfigurationNodeL(): failed to find the configuration node") );
|
|
459 |
}
|
|
460 |
#endif
|
|
461 |
|
|
462 |
__UHEAP_MARKEND;
|
|
463 |
|
|
464 |
return configurationNode;
|
|
465 |
}
|
|
466 |
|
|
467 |
// -----------------------------------------------------------------------------
|
|
468 |
// Finds a plugin node with the provided id
|
|
469 |
// -----------------------------------------------------------------------------
|
|
470 |
//
|
|
471 |
ChspsDomNode* hspsServerUtil::FindPluginNodeL(
|
|
472 |
ChspsODT& aOdt,
|
|
473 |
const TInt aPluginId )
|
|
474 |
{
|
|
475 |
__UHEAP_MARK;
|
|
476 |
|
|
477 |
ChspsDomNode* pluginNode = NULL;
|
|
478 |
|
|
479 |
ChspsDomDocument& dom = aOdt.DomDocument();
|
|
480 |
ChspsDomDepthIterator* iter = ChspsDomDepthIterator::NewL( *dom.RootNode() );
|
|
481 |
CleanupStack::PushL( iter );
|
|
482 |
|
|
483 |
// Find a plugin node with the provided id attribute
|
|
484 |
ChspsDomNode* node = iter->First();
|
|
485 |
ChspsDomNode* prevNode = NULL;
|
|
486 |
TBool jobDone = EFalse;
|
|
487 |
while( node && !jobDone && prevNode != node )
|
|
488 |
{
|
|
489 |
const TDesC8& name = node->Name();
|
|
490 |
|
|
491 |
// Plugin element was found
|
|
492 |
if ( name == KPluginElement )
|
|
493 |
{
|
|
494 |
ChspsDomList& attrList = node->AttributeList();
|
|
495 |
ChspsDomAttribute* idAttr = static_cast<ChspsDomAttribute*>( attrList.FindByName(KPluginAttrId) );
|
|
496 |
if ( !idAttr )
|
|
497 |
{
|
|
498 |
// Mandatory information is missing for some reason (should be set at installation handler)!
|
|
499 |
// Exit with NULL
|
|
500 |
jobDone = ETrue;
|
|
501 |
}
|
|
502 |
else
|
|
503 |
{
|
|
504 |
TInt id(0);
|
|
505 |
const TDesC8& idValue = idAttr->Value();
|
|
506 |
TLex8 lex( idValue );
|
|
507 |
lex.Val( id );
|
|
508 |
if ( aPluginId == id )
|
|
509 |
{
|
|
510 |
pluginNode = node;
|
|
511 |
jobDone = ETrue;
|
|
512 |
}
|
|
513 |
}
|
|
514 |
}
|
|
515 |
|
|
516 |
prevNode = node;
|
|
517 |
node = iter->NextL();
|
|
518 |
}
|
|
519 |
CleanupStack::PopAndDestroy( iter );
|
|
520 |
|
|
521 |
#ifdef _hsps_DEBUG_
|
|
522 |
if ( !pluginNode )
|
|
523 |
{
|
|
524 |
RDebug::Print( _L("hspsServerUtil::FindPluginNodeL(): failed to find the plugin node") );
|
|
525 |
}
|
|
526 |
#endif
|
|
527 |
|
|
528 |
__UHEAP_MARKEND;
|
|
529 |
|
|
530 |
return pluginNode;
|
|
531 |
}
|
|
532 |
|
|
533 |
// -----------------------------------------------------------------------------
|
|
534 |
// hspsServerUtil::GetConfigurationNameFromDomL
|
|
535 |
// -----------------------------------------------------------------------------
|
|
536 |
//
|
|
537 |
TPtrC8 hspsServerUtil::FindConfigurationAttrL(
|
|
538 |
const ChspsODT& aOdt,
|
|
539 |
const TDesC8& aAttr )
|
|
540 |
{
|
|
541 |
TPtrC8 ptr;
|
|
542 |
|
|
543 |
// Get ODT's DOM and find the 1st configuration node
|
|
544 |
ChspsDomNode* confNode = aOdt.DomDocument().RootNode();
|
|
545 |
if( !confNode || confNode->Name().CompareF( KConfigurationElement) != 0 )
|
|
546 |
{
|
|
547 |
User::Leave( KErrGeneral );
|
|
548 |
}
|
|
549 |
|
|
550 |
// Find the name attribute and return it's value
|
|
551 |
ChspsDomList& attrList = confNode->AttributeList();
|
|
552 |
ChspsDomAttribute* attr = static_cast<ChspsDomAttribute*>( attrList.FindByName(aAttr) );
|
|
553 |
if ( !attr )
|
|
554 |
{
|
|
555 |
User::Leave( KErrGeneral );
|
|
556 |
}
|
|
557 |
ptr.Set( attr->Value() );
|
|
558 |
|
|
559 |
return ptr;
|
|
560 |
}
|
|
561 |
|
|
562 |
// -----------------------------------------------------------------------------
|
|
563 |
// hspsServerUtil::RemoveResourceFilesL
|
|
564 |
// -----------------------------------------------------------------------------
|
|
565 |
void hspsServerUtil::RemoveResourceFilesL(
|
|
566 |
CFileMan& aFilemanager,
|
|
567 |
RFs& aFs,
|
|
568 |
const TInt aAppUid,
|
|
569 |
const ChspsODT& aPluginODT )
|
|
570 |
{
|
|
571 |
// Remove all plug-in resources
|
|
572 |
for( TInt i=0; i< aPluginODT.ResourceCount(); i++ )
|
|
573 |
{
|
|
574 |
ChspsResource& r = aPluginODT.ResourceL( i );
|
|
575 |
if( r.FileName().Find( KSourcesFolder ) > 0 )
|
|
576 |
{
|
|
577 |
TPtrC id( GetFixedOdtName( r.ResourceId() ) );
|
|
578 |
const TDesC& ver( aPluginODT.ThemeVersion() );
|
|
579 |
TFileName resource;
|
|
580 |
resource.Format(
|
|
581 |
KClientSources,
|
|
582 |
aAppUid,
|
|
583 |
aPluginODT.RootUid(),
|
|
584 |
aPluginODT.ProviderUid(),
|
|
585 |
aPluginODT.ThemeUid(),
|
|
586 |
&ver,
|
|
587 |
&id );
|
|
588 |
if( BaflUtils::FileExists( aFs, resource ) )
|
|
589 |
{
|
|
590 |
aFilemanager.Delete( resource, 0 );
|
|
591 |
}
|
|
592 |
}
|
|
593 |
}
|
|
594 |
}
|
|
595 |
|
|
596 |
|
|
597 |
// -----------------------------------------------------------------------------
|
|
598 |
// hspsServerUtil::CopyResourceFilesL
|
|
599 |
// -----------------------------------------------------------------------------
|
|
600 |
TInt hspsServerUtil::CopyResourceFilesL(
|
|
601 |
ChspsODT& aAppODT,
|
|
602 |
RFs& aFs,
|
|
603 |
CFileMan& aFilemanager,
|
|
604 |
const TInt aDeviceLanguage,
|
|
605 |
const TInt aConfUid,
|
|
606 |
const TDesC& aDestination,
|
|
607 |
const TBool aIsRelevant )
|
|
608 |
{
|
|
609 |
TInt error( KErrNone );
|
|
610 |
RPointerArray<ChspsResource> widgetResources; // Objects are not owned.
|
|
611 |
CleanupClosePushL( widgetResources );
|
|
612 |
|
|
613 |
// Find resources for the language or common to all languages or test resources
|
|
614 |
// if others couldn't be found
|
|
615 |
GetResourcesForLanguageL(
|
|
616 |
aAppODT,
|
|
617 |
aConfUid,
|
|
618 |
(TLanguage)aDeviceLanguage,
|
|
619 |
widgetResources );
|
|
620 |
|
|
621 |
// Copy the resources found
|
|
622 |
for( TInt i = 0; ( i < widgetResources.Count() && !error ); i++ )
|
|
623 |
{
|
|
624 |
ChspsResource* resource = widgetResources[i];
|
|
625 |
if( !resource )
|
|
626 |
{
|
|
627 |
continue;
|
|
628 |
}
|
|
629 |
|
|
630 |
// Get relative path under the themes folder
|
|
631 |
TPath relativePath;
|
|
632 |
GetRelativeResourcePath(
|
|
633 |
resource->FileName(),
|
|
634 |
relativePath );
|
|
635 |
|
|
636 |
// Strip language indicator from the relative path
|
|
637 |
GetLocaleIndependentResourcePath(
|
|
638 |
resource->Language(),
|
|
639 |
relativePath );
|
|
640 |
|
|
641 |
// Finalize target path
|
|
642 |
TPath targetPath;
|
|
643 |
targetPath.Copy( aDestination );
|
|
644 |
targetPath.Append( relativePath );
|
|
645 |
|
|
646 |
// Create target path and copy files when required
|
|
647 |
error = CopyResourceFileL(
|
|
648 |
aFs,
|
|
649 |
aFilemanager,
|
|
650 |
targetPath,
|
|
651 |
resource->FileName(),
|
|
652 |
aIsRelevant );
|
|
653 |
if ( error == KErrAlreadyExists )
|
|
654 |
{
|
|
655 |
error = KErrNone;
|
|
656 |
}
|
|
657 |
|
|
658 |
} // copy loop
|
|
659 |
|
|
660 |
widgetResources.Reset();
|
|
661 |
CleanupStack::PopAndDestroy( 1, &widgetResources );
|
|
662 |
|
|
663 |
return error;
|
|
664 |
}
|
|
665 |
|
|
666 |
// -----------------------------------------------------------------------------
|
|
667 |
// hspsServerUtil::CopyResourceFileL
|
|
668 |
// -----------------------------------------------------------------------------
|
|
669 |
//
|
|
670 |
TInt hspsServerUtil::CopyResourceFileL(
|
|
671 |
RFs& aFs,
|
|
672 |
CFileMan& aFilemanager,
|
|
673 |
const TPath& aTargetPath,
|
|
674 |
const TFileName& aSourceFile,
|
|
675 |
const TBool aIsRelevant )
|
|
676 |
{
|
|
677 |
// Construct target file with full path.
|
|
678 |
TFileName targetFile;
|
|
679 |
|
|
680 |
TParse targetParser;
|
|
681 |
targetParser.Set( aTargetPath, NULL, NULL );
|
|
682 |
|
|
683 |
if( targetParser.NamePresent() )
|
|
684 |
{
|
|
685 |
targetFile = aTargetPath;
|
|
686 |
}
|
|
687 |
else
|
|
688 |
{
|
|
689 |
TParse sourceParser;
|
|
690 |
sourceParser.Set( aSourceFile, NULL, NULL );
|
|
691 |
targetFile = targetParser.DriveAndPath();
|
|
692 |
targetFile.Append( sourceParser.NameAndExt() );
|
|
693 |
}
|
|
694 |
|
|
695 |
TInt error = KErrNone;
|
|
696 |
|
|
697 |
if ( aIsRelevant
|
|
698 |
|| hspsServerUtil::ResourceCopyIsRelevantL(
|
|
699 |
aSourceFile,
|
|
700 |
targetFile,
|
|
701 |
aFs )
|
|
702 |
)
|
|
703 |
{
|
|
704 |
// Make target folder
|
|
705 |
error = aFs.MkDirAll( aTargetPath );
|
|
706 |
if( error == KErrAlreadyExists )
|
|
707 |
{
|
|
708 |
// lets ignore error if directory already exists
|
|
709 |
error = KErrNone;
|
|
710 |
}
|
|
711 |
|
|
712 |
if( !error )
|
|
713 |
{
|
|
714 |
// Slowish operation
|
|
715 |
error = aFilemanager.Copy(
|
|
716 |
aSourceFile,
|
|
717 |
aTargetPath );
|
|
718 |
}
|
|
719 |
|
|
720 |
if( !error )
|
|
721 |
{
|
|
722 |
// Clear readonly file attribs that might be inherited from the source file
|
|
723 |
aFilemanager.Attribs(
|
|
724 |
aTargetPath,
|
|
725 |
0,
|
|
726 |
KEntryAttReadOnly,
|
|
727 |
TTime( 0 ) ); // TTime(0) = preserve original time stamp.
|
|
728 |
}
|
|
729 |
}
|
|
730 |
|
|
731 |
return error;
|
|
732 |
}
|
|
733 |
|
|
734 |
// -----------------------------------------------------------------------------
|
|
735 |
// hspsServerUtil::ResourceCopyIsRelevant
|
|
736 |
// -----------------------------------------------------------------------------
|
|
737 |
//
|
|
738 |
TBool hspsServerUtil::ResourceCopyIsRelevantL(
|
|
739 |
const TDesC& aSource,
|
|
740 |
const TDesC& aTarget,
|
|
741 |
RFs& aFs )
|
|
742 |
{
|
|
743 |
// Basic sanity check.
|
|
744 |
if( aSource.Length() == 0 || aTarget.Length() == 0 )
|
|
745 |
{
|
|
746 |
return EFalse;
|
|
747 |
}
|
|
748 |
|
|
749 |
// Collect data from files.
|
|
750 |
|
|
751 |
TEntry targetEntry;
|
|
752 |
TInt entryError = aFs.Entry( aTarget, targetEntry );
|
|
753 |
if( entryError == KErrNotFound ||
|
|
754 |
entryError == KErrPathNotFound )
|
|
755 |
{
|
|
756 |
// Target does not exist. Copy needed.
|
|
757 |
return ETrue;
|
|
758 |
}
|
|
759 |
else if( entryError != KErrNone )
|
|
760 |
{
|
|
761 |
// All other errors handled here. Better not to copy.
|
|
762 |
return EFalse;
|
|
763 |
}
|
|
764 |
|
|
765 |
TEntry sourceEntry;
|
|
766 |
entryError = aFs.Entry( aSource, sourceEntry );
|
|
767 |
if( entryError != KErrNone )
|
|
768 |
{
|
|
769 |
// Problem. Do not copy.
|
|
770 |
return EFalse;
|
|
771 |
}
|
|
772 |
|
|
773 |
TParse sourceParser;
|
|
774 |
sourceParser.Set( aSource, NULL, NULL );
|
|
775 |
|
|
776 |
TParse targetParser;
|
|
777 |
targetParser.Set( aTarget, NULL, NULL );
|
|
778 |
|
|
779 |
// We have tdesc of target drive but SysUtils need TDriveNumber instead
|
|
780 |
// so extract it from tdesc. default to C.
|
|
781 |
TInt targetDriveNumber = EDriveC;
|
|
782 |
|
|
783 |
// Sanity checks before accessing descriptor (prevent "out of bounds" panic).
|
|
784 |
if( targetParser.DrivePresent() &&
|
|
785 |
targetParser.Drive().Length() > 0 )
|
|
786 |
{
|
|
787 |
// Use tmp variable so that CharToDrive does not mess our fallback
|
|
788 |
// value. (it should not do that in case of error... but better
|
|
789 |
// to do fool-proof.)
|
|
790 |
TInt tmpDriveNumber = EDriveC;
|
|
791 |
|
|
792 |
// Convert from TDesC to enumeration of drives.
|
|
793 |
if( RFs::CharToDrive( targetParser.Drive()[0], tmpDriveNumber ) == KErrNone )
|
|
794 |
{
|
|
795 |
targetDriveNumber = tmpDriveNumber;
|
|
796 |
}
|
|
797 |
}
|
|
798 |
|
|
799 |
// Size and time stamp identical?
|
|
800 |
if( sourceEntry.iSize == targetEntry.iSize &&
|
|
801 |
sourceEntry.iModified == targetEntry.iModified )
|
|
802 |
{
|
|
803 |
return EFalse;
|
|
804 |
}
|
|
805 |
|
|
806 |
// Check required disk space.
|
|
807 |
TInt requiredDiskSpace = 0;
|
|
808 |
if( sourceEntry.iSize > targetEntry.iSize )
|
|
809 |
{
|
|
810 |
requiredDiskSpace = sourceEntry.iSize - targetEntry.iSize;
|
|
811 |
}
|
|
812 |
else
|
|
813 |
{
|
|
814 |
requiredDiskSpace = sourceEntry.iSize;
|
|
815 |
}
|
|
816 |
|
|
817 |
if( requiredDiskSpace != 0 )
|
|
818 |
{
|
|
819 |
if( SysUtil::DiskSpaceBelowCriticalLevelL( &aFs, requiredDiskSpace, targetDriveNumber ) )
|
|
820 |
{
|
|
821 |
return EFalse;
|
|
822 |
}
|
|
823 |
}
|
|
824 |
|
|
825 |
// All tests passed.
|
|
826 |
return ETrue;
|
|
827 |
}
|
|
828 |
|
|
829 |
// -----------------------------------------------------------------------------
|
|
830 |
// hspsServerUtil::UpdateConfigurationStateL
|
|
831 |
// -----------------------------------------------------------------------------
|
|
832 |
//
|
|
833 |
void hspsServerUtil::UpdateConfigurationStateL(
|
|
834 |
ChspsODT& aOdt,
|
|
835 |
TDesC8& aConfState,
|
|
836 |
TDesC8& aNextConfState,
|
|
837 |
TBool& aOdtUpdated )
|
|
838 |
{
|
|
839 |
aOdtUpdated = EFalse;
|
|
840 |
ChspsDomDocument& dom = aOdt.DomDocument();
|
|
841 |
ChspsDomDepthIterator* iter = ChspsDomDepthIterator::NewL( *dom.RootNode() );
|
|
842 |
CleanupStack::PushL( iter );
|
|
843 |
ChspsDomNode* prevNode = NULL;
|
|
844 |
ChspsDomNode* node = iter->First();
|
|
845 |
|
|
846 |
while( node && prevNode != node )
|
|
847 |
{
|
|
848 |
const TDesC8& name = node->Name();
|
|
849 |
|
|
850 |
// Configuration element
|
|
851 |
if ( name == KConfigurationElement )
|
|
852 |
{
|
|
853 |
ChspsDomList& attrList = node->AttributeList();
|
|
854 |
ChspsDomAttribute* attr = static_cast<ChspsDomAttribute*>(
|
|
855 |
attrList.FindByName( KConfigurationAttrState ) );
|
|
856 |
if ( attr && attr->Value().CompareF( aConfState ) == 0 )
|
|
857 |
{
|
|
858 |
attr->SetValueL( aNextConfState );
|
|
859 |
aOdtUpdated = ETrue;
|
|
860 |
}
|
|
861 |
}
|
|
862 |
|
|
863 |
prevNode = node;
|
|
864 |
node = iter->NextL();
|
|
865 |
}
|
|
866 |
|
|
867 |
CleanupStack::PopAndDestroy( iter );
|
|
868 |
|
|
869 |
}
|
|
870 |
|
|
871 |
// -----------------------------------------------------------------------------
|
|
872 |
// hspsServerUtil::UpdateAppConfigurationStateL
|
|
873 |
// -----------------------------------------------------------------------------
|
|
874 |
//
|
|
875 |
void hspsServerUtil::UpdateAppConfigurationStateL(
|
|
876 |
ChspsODT& aAppOdt,
|
|
877 |
const TDesC8& aConfState,
|
|
878 |
const TDesC8& aNextConfState )
|
|
879 |
{
|
|
880 |
__ASSERT_DEBUG( aConfState.Length() > 0, User::Leave( KErrArgument) );
|
|
881 |
__ASSERT_DEBUG( aNextConfState.Length() > 0, User::Leave( KErrArgument) );
|
|
882 |
|
|
883 |
// Update application configuration state
|
|
884 |
ChspsDomNode* appConfNode = hspsServerUtil::FindNodeByAttributeL(
|
|
885 |
aAppOdt,
|
|
886 |
KConfigurationElement,
|
|
887 |
KConfigurationAttrType,
|
|
888 |
KConfTypeApp );
|
|
889 |
ChspsDomList& attrList = appConfNode->AttributeList();
|
|
890 |
ChspsDomAttribute* attr = static_cast<ChspsDomAttribute*>(
|
|
891 |
attrList.FindByName( KConfigurationAttrState ) );
|
|
892 |
if ( attr && attr->Value().CompareF( aConfState ) == 0 )
|
|
893 |
{
|
|
894 |
attr->SetValueL( aNextConfState );
|
|
895 |
}
|
|
896 |
}
|
|
897 |
|
|
898 |
// -----------------------------------------------------------------------------
|
|
899 |
// hspsServerUtil::FindNodeByAttributeL
|
|
900 |
// -----------------------------------------------------------------------------
|
|
901 |
//
|
|
902 |
ChspsDomNode* hspsServerUtil::FindNodeByAttributeL(
|
|
903 |
ChspsODT& aOdt,
|
|
904 |
const TDesC8& aNodeName,
|
|
905 |
const TDesC8& aAttrName,
|
|
906 |
const TDesC8& aAttrValue)
|
|
907 |
{
|
|
908 |
__UHEAP_MARK;
|
|
909 |
|
|
910 |
ChspsDomDocument& dom = aOdt.DomDocument();
|
|
911 |
ChspsDomDepthIterator* iter = ChspsDomDepthIterator::NewL( *dom.RootNode() );
|
|
912 |
CleanupStack::PushL( iter );
|
|
913 |
|
|
914 |
ChspsDomNode* foundNode( NULL );
|
|
915 |
ChspsDomNode* prevNode( NULL );
|
|
916 |
ChspsDomNode* node = iter->First();
|
|
917 |
while( node &&
|
|
918 |
prevNode != node &&
|
|
919 |
foundNode == NULL )
|
|
920 |
{
|
|
921 |
const TDesC8& name = node->Name();
|
|
922 |
if ( name.CompareF( aNodeName ) == 0 )
|
|
923 |
{
|
|
924 |
// Node name match
|
|
925 |
ChspsDomList& attrList = node->AttributeList();
|
|
926 |
ChspsDomAttribute* attr = static_cast<ChspsDomAttribute*>(
|
|
927 |
attrList.FindByName( aAttrName ) );
|
|
928 |
if ( attr && attr->Value().CompareF( aAttrValue ) == 0 )
|
|
929 |
{
|
|
930 |
// Attribute name and value match
|
|
931 |
foundNode = node;
|
|
932 |
}
|
|
933 |
}
|
|
934 |
// Get next node
|
|
935 |
prevNode = node;
|
|
936 |
node = iter->NextL();
|
|
937 |
}
|
|
938 |
|
|
939 |
CleanupStack::PopAndDestroy( iter );
|
|
940 |
|
|
941 |
__UHEAP_MARKEND;
|
|
942 |
|
|
943 |
return foundNode;
|
|
944 |
}
|
|
945 |
|
|
946 |
// -----------------------------------------------------------------------------
|
|
947 |
// hspsServerUtil::FindUniquePluginsL
|
|
948 |
// -----------------------------------------------------------------------------
|
|
949 |
//
|
|
950 |
void hspsServerUtil::FindUniquePluginsL(
|
|
951 |
ChspsODT& aOdt,
|
|
952 |
RArray<TInt>& aPluginArray )
|
|
953 |
{
|
|
954 |
aPluginArray.Reset();
|
|
955 |
ChspsDomDocument& dom = aOdt.DomDocument();
|
|
956 |
ChspsDomDepthIterator* iter = ChspsDomDepthIterator::NewL( *dom.RootNode() );
|
|
957 |
CleanupStack::PushL( iter );
|
|
958 |
|
|
959 |
ChspsDomNode* node = iter->First();
|
|
960 |
ChspsDomNode* prevNode = NULL;
|
|
961 |
while( node && prevNode != node )
|
|
962 |
{
|
|
963 |
const TDesC8& name = node->Name();
|
|
964 |
|
|
965 |
// Plugin element was found
|
|
966 |
if ( name == KPluginElement )
|
|
967 |
{
|
|
968 |
ChspsDomList& attrList = node->AttributeList();
|
|
969 |
ChspsDomAttribute* uidAttr = static_cast<ChspsDomAttribute*>( attrList.FindByName(KPluginAttrUid) );
|
|
970 |
if ( uidAttr )
|
|
971 |
{
|
|
972 |
// Convert from hex to int
|
|
973 |
const TUid pluginUid = ConvertDescIntoUid( uidAttr->Value() );
|
|
974 |
if ( pluginUid.iUid > 0 )
|
|
975 |
{
|
|
976 |
TBool isUnique = ETrue;
|
|
977 |
for( TInt i=0; isUnique && i<aPluginArray.Count();i++ )
|
|
978 |
{
|
|
979 |
if ( aPluginArray[i] == pluginUid.iUid )
|
|
980 |
{
|
|
981 |
isUnique=EFalse;
|
|
982 |
}
|
|
983 |
}
|
|
984 |
if ( isUnique )
|
|
985 |
{
|
|
986 |
aPluginArray.Append( pluginUid.iUid );
|
|
987 |
}
|
|
988 |
}
|
|
989 |
}
|
|
990 |
}
|
|
991 |
|
|
992 |
prevNode = node;
|
|
993 |
node = iter->NextL();
|
|
994 |
}
|
|
995 |
CleanupStack::PopAndDestroy( iter );
|
|
996 |
}
|
|
997 |
|
|
998 |
//----------------------------------------------------------------------------
|
|
999 |
// CHspsServiceUtilities::HexString2Uint
|
|
1000 |
// ----------------------------------------------------------------------------
|
|
1001 |
//
|
|
1002 |
TInt hspsServerUtil::HexString2Uint(
|
|
1003 |
const TDesC8& aStr,
|
|
1004 |
TUint& aTrg )
|
|
1005 |
{
|
|
1006 |
// Assign to lexer.
|
|
1007 |
TLex8 lex( aStr );
|
|
1008 |
|
|
1009 |
// Ignore preceding "0x" if it exists. TLex does not know how to handle that
|
|
1010 |
// and returns just zero.
|
|
1011 |
if( aStr.Length() >= KHexPrefix8().Length() &&
|
|
1012 |
aStr.FindF( KHexPrefix8() ) == 0 )
|
|
1013 |
{
|
|
1014 |
lex.Inc( KHexPrefix8().Length() );
|
|
1015 |
}
|
|
1016 |
|
|
1017 |
// Actual conversion.
|
|
1018 |
TInt status = KErrNone;
|
|
1019 |
TUint val = 0;
|
|
1020 |
status = lex.Val( val, EHex );
|
|
1021 |
|
|
1022 |
// Error check.
|
|
1023 |
if( status == KErrNone )
|
|
1024 |
{
|
|
1025 |
aTrg = val;
|
|
1026 |
}
|
|
1027 |
|
|
1028 |
return status;
|
|
1029 |
}
|
|
1030 |
|
|
1031 |
//----------------------------------------------------------------------------
|
|
1032 |
// CHspsServiceUtilities::DecString2Int
|
|
1033 |
// ----------------------------------------------------------------------------
|
|
1034 |
//
|
|
1035 |
TInt hspsServerUtil::DecString2Int(
|
|
1036 |
const TDesC8& aStr )
|
|
1037 |
{
|
|
1038 |
TLex8 lex( aStr );
|
|
1039 |
TUint value;
|
|
1040 |
lex.Mark();
|
|
1041 |
|
|
1042 |
while ( lex.Peek().IsDigit() )
|
|
1043 |
{
|
|
1044 |
lex.Inc();
|
|
1045 |
}
|
|
1046 |
TPtrC8 uidToken = lex.MarkedToken();
|
|
1047 |
TLex8 uidLex( uidToken );
|
|
1048 |
TInt err = uidLex.Val( value, EDecimal );
|
|
1049 |
|
|
1050 |
return value;
|
|
1051 |
}
|
|
1052 |
// -----------------------------------------------------------------------------
|
|
1053 |
// Returns a count of plugin instances.
|
|
1054 |
// -----------------------------------------------------------------------------
|
|
1055 |
//
|
|
1056 |
void hspsServerUtil::PluginInstanceCountL(
|
|
1057 |
const ChspsODT& aAppODT,
|
|
1058 |
const TInt aPluginUid,
|
|
1059 |
TInt& aInstanceCount )
|
|
1060 |
{
|
|
1061 |
aInstanceCount = 0;
|
|
1062 |
|
|
1063 |
ChspsDomDocument& dom = aAppODT.DomDocument();
|
|
1064 |
ChspsDomDepthIterator* iter = ChspsDomDepthIterator::NewL( *dom.RootNode() );
|
|
1065 |
CleanupStack::PushL( iter );
|
|
1066 |
|
|
1067 |
// Find a plugin node with the provided id attribute
|
|
1068 |
ChspsDomNode* node = iter->First();
|
|
1069 |
ChspsDomNode* prevNode = NULL;
|
|
1070 |
TBool jobDone = EFalse;
|
|
1071 |
while( node && !jobDone && prevNode != node )
|
|
1072 |
{
|
|
1073 |
const TDesC8& name = node->Name();
|
|
1074 |
|
|
1075 |
// Plugin element was found
|
|
1076 |
if ( name == KPluginElement )
|
|
1077 |
{
|
|
1078 |
ChspsDomList& attrList = node->AttributeList();
|
|
1079 |
ChspsDomAttribute* attr = static_cast<ChspsDomAttribute*>( attrList.FindByName(KPluginAttrUid) );
|
|
1080 |
if ( !attr )
|
|
1081 |
{
|
|
1082 |
// Mandatory information is missing for some reason (should be set at installation handler)!
|
|
1083 |
// Exit with NULL
|
|
1084 |
jobDone = ETrue;
|
|
1085 |
}
|
|
1086 |
else
|
|
1087 |
{
|
|
1088 |
// Convert from (hex?) string into TUid presentation
|
|
1089 |
const TUid uid = ConvertDescIntoUid( attr->Value() );
|
|
1090 |
if ( aPluginUid == uid.iUid )
|
|
1091 |
{
|
|
1092 |
aInstanceCount++;
|
|
1093 |
}
|
|
1094 |
}
|
|
1095 |
}
|
|
1096 |
|
|
1097 |
prevNode = node;
|
|
1098 |
node = iter->NextL();
|
|
1099 |
}
|
|
1100 |
CleanupStack::PopAndDestroy( iter );
|
|
1101 |
}
|
|
1102 |
// -----------------------------------------------------------------------------
|
|
1103 |
// hspsServerUtil::ConvertDescIntoUid()
|
|
1104 |
//----------------------------------------------------------------------------
|
|
1105 |
//
|
|
1106 |
TUid hspsServerUtil::ConvertDescIntoUid(
|
|
1107 |
const TDesC8& aStr )
|
|
1108 |
{
|
|
1109 |
TLex8 lex(aStr);
|
|
1110 |
TUint pluginUid;
|
|
1111 |
lex.Mark();
|
|
1112 |
|
|
1113 |
if(lex.Peek() == '0')
|
|
1114 |
{
|
|
1115 |
lex.Inc();
|
|
1116 |
}
|
|
1117 |
if(lex.Peek() == 'x')
|
|
1118 |
{
|
|
1119 |
lex.Inc();
|
|
1120 |
}
|
|
1121 |
lex.Mark();
|
|
1122 |
while (lex.Peek().IsHexDigit())
|
|
1123 |
{
|
|
1124 |
lex.Inc();
|
|
1125 |
}
|
|
1126 |
TPtrC8 uidToken = lex.MarkedToken();
|
|
1127 |
TLex8 uidLex(uidToken);
|
|
1128 |
TInt err = uidLex.Val(pluginUid,EHex);
|
|
1129 |
|
|
1130 |
return TUid::Uid(pluginUid);
|
|
1131 |
}
|
|
1132 |
//----------------------------------------------------------------------------
|
|
1133 |
// hspsServerUtil::FindChildNodeByTagL()
|
|
1134 |
// ----------------------------------------------------------------------------
|
|
1135 |
//
|
|
1136 |
ChspsDomNode* hspsServerUtil::FindChildNodeByTagL(
|
|
1137 |
const TDesC8& aNodeTag,
|
|
1138 |
ChspsDomNode& aParentNode,
|
|
1139 |
TInt& aIndex )
|
|
1140 |
{
|
|
1141 |
ChspsDomNode* node( NULL );
|
|
1142 |
ChspsDomList& items = aParentNode.ChildNodes();
|
|
1143 |
TInt length = items.Length();
|
|
1144 |
node = NULL;
|
|
1145 |
for ( TInt i = aIndex; i < length && node == NULL; i++ )
|
|
1146 |
{
|
|
1147 |
node = static_cast<ChspsDomNode*>( items.Item( i ) );
|
|
1148 |
const TDesC8& name = node->Name();
|
|
1149 |
if( name.Compare( aNodeTag ) != 0 )
|
|
1150 |
{
|
|
1151 |
node = NULL;
|
|
1152 |
}
|
|
1153 |
else
|
|
1154 |
{
|
|
1155 |
aIndex = i;
|
|
1156 |
}
|
|
1157 |
}
|
|
1158 |
|
|
1159 |
return node;
|
|
1160 |
}
|
|
1161 |
|
|
1162 |
//----------------------------------------------------------------------------
|
|
1163 |
// hspsServerUtil::FindFilesL()
|
|
1164 |
// ----------------------------------------------------------------------------
|
|
1165 |
//
|
|
1166 |
void hspsServerUtil::FindFilesL(
|
|
1167 |
const TDesC& aDirName,
|
|
1168 |
const TDesC& aFileName,
|
|
1169 |
RArray <TFileName>& aFiles )
|
|
1170 |
{
|
|
1171 |
RFs fs;
|
|
1172 |
CleanupClosePushL( fs );
|
|
1173 |
User::LeaveIfError( fs.Connect() );
|
|
1174 |
|
|
1175 |
// Find files from root directory
|
|
1176 |
hspsServerUtil::FindFilesFromDirL(
|
|
1177 |
aDirName,
|
|
1178 |
aFileName,
|
|
1179 |
aFiles );
|
|
1180 |
|
|
1181 |
// Directory scanner to browse directory structure
|
|
1182 |
CDirScan* dirScan = CDirScan::NewL( fs );
|
|
1183 |
CleanupStack::PushL( dirScan );
|
|
1184 |
dirScan->SetScanDataL(
|
|
1185 |
aDirName,
|
|
1186 |
( KEntryAttDir | KEntryAttMatchExclusive ),
|
|
1187 |
ESortNone );
|
|
1188 |
|
|
1189 |
// Directory path where installation files are searched
|
|
1190 |
TFileName dirName;
|
|
1191 |
|
|
1192 |
// Get first directory list
|
|
1193 |
CDir* dirList( NULL );
|
|
1194 |
dirScan->NextL( dirList );
|
|
1195 |
// Find files from root directories
|
|
1196 |
while ( dirList )
|
|
1197 |
{
|
|
1198 |
CleanupStack::PushL( dirList );
|
|
1199 |
for ( TInt i = 0; i < dirList->Count(); i++ )
|
|
1200 |
{
|
|
1201 |
// Get directory path
|
|
1202 |
dirName = dirScan->FullPath();
|
|
1203 |
// Append directory entry
|
|
1204 |
const TEntry& dirEntry = ( *dirList )[ i ];
|
|
1205 |
dirName.Append( dirEntry.iName );
|
|
1206 |
dirName.Append( KDoubleBackSlash );
|
|
1207 |
hspsServerUtil::FindFilesFromDirL(
|
|
1208 |
dirName,
|
|
1209 |
aFileName,
|
|
1210 |
aFiles );
|
|
1211 |
}
|
|
1212 |
// Get next directory list
|
|
1213 |
CleanupStack::PopAndDestroy( dirList );
|
|
1214 |
dirScan->NextL( dirList );
|
|
1215 |
}
|
|
1216 |
|
|
1217 |
CleanupStack::PopAndDestroy( dirScan );
|
|
1218 |
|
|
1219 |
CleanupStack::PopAndDestroy(); // fs
|
|
1220 |
|
|
1221 |
}
|
|
1222 |
|
|
1223 |
//----------------------------------------------------------------------------
|
|
1224 |
// hspsServerUtil::FindFilesFromDirL()
|
|
1225 |
// ----------------------------------------------------------------------------
|
|
1226 |
//
|
|
1227 |
void hspsServerUtil::FindFilesFromDirL(
|
|
1228 |
const TDesC& aDirName,
|
|
1229 |
const TDesC& aFileName,
|
|
1230 |
RArray <TFileName>& aFiles )
|
|
1231 |
{
|
|
1232 |
RFs fs;
|
|
1233 |
CleanupClosePushL( fs );
|
|
1234 |
User::LeaveIfError( fs.Connect() );
|
|
1235 |
|
|
1236 |
// File finder to search files from a directory
|
|
1237 |
TFindFile fileFinder( fs );
|
|
1238 |
|
|
1239 |
// Define drives where files are searched
|
|
1240 |
TInt driveNumber;
|
|
1241 |
TParse dirParser;
|
|
1242 |
dirParser.Set( aDirName, NULL, NULL );
|
|
1243 |
// Default drives C: and Z:
|
|
1244 |
TInt findMask(
|
|
1245 |
KDriveAttExclude |
|
|
1246 |
KDriveAttRemovable |
|
|
1247 |
KDriveAttRemote );
|
|
1248 |
if( RFs::CharToDrive( dirParser.Drive()[0], driveNumber ) == KErrNone )
|
|
1249 |
{
|
|
1250 |
if ( driveNumber == EDriveC )
|
|
1251 |
{
|
|
1252 |
// Search from C: drive
|
|
1253 |
findMask = (
|
|
1254 |
KDriveAttExclude |
|
|
1255 |
KDriveAttRemovable |
|
|
1256 |
KDriveAttRemote |
|
|
1257 |
KDriveAttRom );
|
|
1258 |
}
|
|
1259 |
else if ( driveNumber == EDriveZ )
|
|
1260 |
{
|
|
1261 |
// Search from Z: drive
|
|
1262 |
findMask = KDriveAttRom;
|
|
1263 |
}
|
|
1264 |
}
|
|
1265 |
fileFinder.SetFindMask( findMask );
|
|
1266 |
|
|
1267 |
// Find files from the directory entry
|
|
1268 |
CDir* fileList( NULL );
|
|
1269 |
fileFinder.FindWildByDir( aFileName, aDirName, fileList );
|
|
1270 |
CleanupStack::PushL( fileList );
|
|
1271 |
for ( TInt k = 0; fileList && k < fileList->Count(); k++ )
|
|
1272 |
{
|
|
1273 |
// Add found file with full path to file array
|
|
1274 |
const TEntry& fileEntry = (*fileList)[k];
|
|
1275 |
TFileName file;
|
|
1276 |
file.Append( aDirName );
|
|
1277 |
file.Append( fileEntry.iName );
|
|
1278 |
aFiles.Append( file );
|
|
1279 |
}
|
|
1280 |
CleanupStack::PopAndDestroy( fileList );
|
|
1281 |
|
|
1282 |
CleanupStack::PopAndDestroy(); // fs
|
|
1283 |
}
|
|
1284 |
|
|
1285 |
// -----------------------------------------------------------------------------
|
|
1286 |
// hspsServerUtil::SetAttributeValueL
|
|
1287 |
// -----------------------------------------------------------------------------
|
|
1288 |
//
|
|
1289 |
void hspsServerUtil::SetAttributeValueL(
|
|
1290 |
const ChspsODT& aOdt,
|
|
1291 |
const TDesC8& aNodeName,
|
|
1292 |
const TDesC8& aAttrName,
|
|
1293 |
const TDesC8& aAttrValue,
|
|
1294 |
const TDesC8& aSetAttrName,
|
|
1295 |
const TDesC8& aSetAttrValue )
|
|
1296 |
{
|
|
1297 |
|
|
1298 |
ChspsDomDocument& dom = aOdt.DomDocument();
|
|
1299 |
ChspsDomDepthIterator* iter = ChspsDomDepthIterator::NewL( *dom.RootNode() );
|
|
1300 |
CleanupStack::PushL( iter );
|
|
1301 |
|
|
1302 |
TBool nodeFound( EFalse );
|
|
1303 |
ChspsDomNode* prevNode( NULL );
|
|
1304 |
ChspsDomNode* node = iter->First();
|
|
1305 |
while( node &&
|
|
1306 |
prevNode != node )
|
|
1307 |
{
|
|
1308 |
const TDesC8& name = node->Name();
|
|
1309 |
if ( name.CompareF( aNodeName ) == 0 )
|
|
1310 |
{
|
|
1311 |
// Node name match
|
|
1312 |
ChspsDomList& attrList = node->AttributeList();
|
|
1313 |
ChspsDomAttribute* attr = static_cast<ChspsDomAttribute*>(
|
|
1314 |
attrList.FindByName( aAttrName ) );
|
|
1315 |
if ( attr && attr->Value().CompareF( aAttrValue ) == 0 )
|
|
1316 |
{
|
|
1317 |
// Attribute name and value match - Defined node found
|
|
1318 |
attr = static_cast<ChspsDomAttribute*>(
|
|
1319 |
attrList.FindByName( aSetAttrName ) );
|
|
1320 |
if ( attr )
|
|
1321 |
{
|
|
1322 |
// Updated attribute found - Update attribute value
|
|
1323 |
attr->SetValueL( aSetAttrValue );
|
|
1324 |
}
|
|
1325 |
else
|
|
1326 |
{
|
|
1327 |
// Add new attribute
|
|
1328 |
AddAttributeDescL( *node, aSetAttrName, aSetAttrValue );
|
|
1329 |
}
|
|
1330 |
nodeFound = ETrue;
|
|
1331 |
}
|
|
1332 |
}
|
|
1333 |
// Get next node
|
|
1334 |
prevNode = node;
|
|
1335 |
node = iter->NextL();
|
|
1336 |
}
|
|
1337 |
|
|
1338 |
if ( !nodeFound )
|
|
1339 |
{
|
|
1340 |
User::Leave( KErrNotFound );
|
|
1341 |
}
|
|
1342 |
|
|
1343 |
CleanupStack::PopAndDestroy( iter );
|
|
1344 |
|
|
1345 |
}
|
|
1346 |
|
|
1347 |
// -----------------------------------------------------------------------------
|
|
1348 |
// hspsServerUtil::GetAttributeValueL
|
|
1349 |
// -----------------------------------------------------------------------------
|
|
1350 |
//
|
|
1351 |
void hspsServerUtil::GetAttributeValueL(
|
|
1352 |
const ChspsODT& aOdt,
|
|
1353 |
const TDesC8& aNodeName,
|
|
1354 |
const TDesC8& aAttrName,
|
|
1355 |
const TDesC8& aAttrValue,
|
|
1356 |
const TDesC8& aGetAttrName,
|
|
1357 |
TPtrC8& aGetAttrValue )
|
|
1358 |
{
|
|
1359 |
__UHEAP_MARK;
|
|
1360 |
|
|
1361 |
ChspsDomDocument& dom = aOdt.DomDocument();
|
|
1362 |
ChspsDomDepthIterator* iter = ChspsDomDepthIterator::NewL( *dom.RootNode() );
|
|
1363 |
CleanupStack::PushL( iter );
|
|
1364 |
|
|
1365 |
TBool nodeFound( EFalse );
|
|
1366 |
ChspsDomNode* prevNode( NULL );
|
|
1367 |
ChspsDomNode* node = iter->First();
|
|
1368 |
while( node &&
|
|
1369 |
prevNode != node &&
|
|
1370 |
!nodeFound )
|
|
1371 |
{
|
|
1372 |
const TDesC8& name = node->Name();
|
|
1373 |
if ( name.CompareF( aNodeName ) == 0 )
|
|
1374 |
{
|
|
1375 |
// Node name match
|
|
1376 |
ChspsDomList& attrList = node->AttributeList();
|
|
1377 |
ChspsDomAttribute* attr = static_cast<ChspsDomAttribute*>(
|
|
1378 |
attrList.FindByName( aAttrName ) );
|
|
1379 |
if ( attr && attr->Value().CompareF( aAttrValue ) == 0 )
|
|
1380 |
{
|
|
1381 |
// Attribute name and value match - Defined node found
|
|
1382 |
attr = static_cast<ChspsDomAttribute*>(
|
|
1383 |
attrList.FindByName( aGetAttrName ) );
|
|
1384 |
if ( attr )
|
|
1385 |
{
|
|
1386 |
// Updated
|
|
1387 |
aGetAttrValue.Set( attr->Value() );
|
|
1388 |
nodeFound = ETrue;
|
|
1389 |
}
|
|
1390 |
}
|
|
1391 |
}
|
|
1392 |
// Get next node
|
|
1393 |
prevNode = node;
|
|
1394 |
node = iter->NextL();
|
|
1395 |
}
|
|
1396 |
|
|
1397 |
if ( !nodeFound )
|
|
1398 |
{
|
|
1399 |
User::Leave( KErrNotFound );
|
|
1400 |
}
|
|
1401 |
|
|
1402 |
CleanupStack::PopAndDestroy( iter );
|
|
1403 |
|
|
1404 |
__UHEAP_MARKEND;
|
|
1405 |
|
|
1406 |
}
|
|
1407 |
|
|
1408 |
// -----------------------------------------------------------------------------
|
|
1409 |
// hspsServerUtil::CheckResourceFilesL
|
|
1410 |
// -----------------------------------------------------------------------------
|
|
1411 |
//
|
|
1412 |
void hspsServerUtil::CheckResourceFilesL(
|
|
1413 |
const ChspsODT& aOdt,
|
|
1414 |
const TInt aConfUid )
|
|
1415 |
{
|
|
1416 |
__UHEAP_MARK;
|
|
1417 |
|
|
1418 |
// Convert configuration UID to decimal string
|
|
1419 |
TBuf<10> confUid;
|
|
1420 |
_LIT( KFormat, "%D" );
|
|
1421 |
confUid.AppendFormat( KFormat, aConfUid );
|
|
1422 |
|
|
1423 |
RFs fs;
|
|
1424 |
CleanupClosePushL( fs );
|
|
1425 |
User::LeaveIfError( fs.Connect() );
|
|
1426 |
|
|
1427 |
TInt resCount = aOdt.ResourceCount();
|
|
1428 |
for ( TInt i = 0; i < resCount; i++ )
|
|
1429 |
{
|
|
1430 |
// Check if resource file belongs to defined configuration
|
|
1431 |
// (file path contains configuration UID string)
|
|
1432 |
ChspsResource& res = aOdt.ResourceL( i );
|
|
1433 |
TPtrC resFile = res.FileName();
|
|
1434 |
if ( resFile.FindC( confUid ) != KErrNotFound )
|
|
1435 |
{
|
|
1436 |
// Check that resource files exists
|
|
1437 |
if ( !BaflUtils::FileExists( fs, resFile ) )
|
|
1438 |
{
|
|
1439 |
User::Leave( KErrNotFound );
|
|
1440 |
}
|
|
1441 |
}
|
|
1442 |
}
|
|
1443 |
|
|
1444 |
CleanupStack::PopAndDestroy(); // fs
|
|
1445 |
|
|
1446 |
__UHEAP_MARKEND;
|
|
1447 |
|
|
1448 |
}
|
|
1449 |
|
|
1450 |
// -----------------------------------------------------------------------------
|
|
1451 |
// hspsServerUtil::GetConfigurationVersionL
|
|
1452 |
// -----------------------------------------------------------------------------
|
|
1453 |
//
|
|
1454 |
void hspsServerUtil::CheckConfigurationVersionL(
|
|
1455 |
ChspsODT& aOdt,
|
|
1456 |
const TInt aConfUid,
|
|
1457 |
const TDesC& aVersion )
|
|
1458 |
{
|
|
1459 |
__UHEAP_MARK;
|
|
1460 |
|
|
1461 |
// Create configuration UID string
|
|
1462 |
TBuf8<10> confUid;
|
|
1463 |
_LIT8( KFormat8, "%X" );
|
|
1464 |
_LIT8( KHexPrefix, "0x" );
|
|
1465 |
confUid.Append( KHexPrefix );
|
|
1466 |
confUid.AppendFormat( KFormat8, aConfUid );
|
|
1467 |
|
|
1468 |
// Find configuration node
|
|
1469 |
ChspsDomNode* confNode = hspsServerUtil::FindNodeByAttributeL(
|
|
1470 |
aOdt,
|
|
1471 |
KConfigurationElement,
|
|
1472 |
KConfigurationAttrUid,
|
|
1473 |
confUid );
|
|
1474 |
|
|
1475 |
if ( confNode )
|
|
1476 |
{
|
|
1477 |
ChspsDomList& attrList = confNode->AttributeList();
|
|
1478 |
ChspsDomAttribute* attr = static_cast<ChspsDomAttribute*>(
|
|
1479 |
attrList.FindByName( KConfigurationAttrVersion ) );
|
|
1480 |
if ( attr )
|
|
1481 |
{
|
|
1482 |
HBufC8* tv = HBufC8::NewLC( aVersion.Length() );
|
|
1483 |
TPtr8 tvPtr( tv->Des() );
|
|
1484 |
tvPtr.Copy( aVersion );
|
|
1485 |
// Check configuration version
|
|
1486 |
if ( attr->Value().Compare( tvPtr ) != 0 )
|
|
1487 |
{
|
|
1488 |
// Configuration not supported
|
|
1489 |
User::Leave( KErrNotSupported );
|
|
1490 |
}
|
|
1491 |
CleanupStack::PopAndDestroy( tv );
|
|
1492 |
}
|
|
1493 |
else
|
|
1494 |
{
|
|
1495 |
// Invalid configuration
|
|
1496 |
User::Leave( KErrGeneral );
|
|
1497 |
}
|
|
1498 |
}
|
|
1499 |
else
|
|
1500 |
{
|
|
1501 |
// Configuration not found
|
|
1502 |
User::Leave( KErrNotFound );
|
|
1503 |
}
|
|
1504 |
|
|
1505 |
__UHEAP_MARKEND;
|
|
1506 |
}
|
|
1507 |
|
|
1508 |
// -----------------------------------------------------------------------------
|
|
1509 |
// hspsServerUtil::EditPluginNodeActivityL
|
|
1510 |
// -----------------------------------------------------------------------------
|
|
1511 |
//
|
|
1512 |
void hspsServerUtil::EditPluginNodeActivityL( ChspsDomNode* aRootNode,
|
|
1513 |
const TNodeEditMode aEditMode,
|
|
1514 |
TInt aDepth )
|
|
1515 |
{
|
|
1516 |
// This wrapper exists to prevent modification of original aDepth
|
|
1517 |
// (_EditPluginNodeActivityL uses TInt reference for depth count and
|
|
1518 |
// modifies it).
|
|
1519 |
hspsServerUtil::_EditPluginNodeActivityL( aRootNode, aEditMode, aDepth );
|
|
1520 |
}
|
|
1521 |
|
|
1522 |
// -----------------------------------------------------------------------------
|
|
1523 |
// hspsServerUtil::_EditPluginNodeActivityL
|
|
1524 |
// -----------------------------------------------------------------------------
|
|
1525 |
//
|
|
1526 |
void hspsServerUtil::_EditPluginNodeActivityL( ChspsDomNode* aRootNode,
|
|
1527 |
const TNodeEditMode aEditMode,
|
|
1528 |
TInt& aDepth )
|
|
1529 |
{
|
|
1530 |
// Sanity check.
|
|
1531 |
if( !aRootNode )
|
|
1532 |
{
|
|
1533 |
return;
|
|
1534 |
}
|
|
1535 |
|
|
1536 |
// Recursion depth logic.
|
|
1537 |
if( aDepth == RECURSION_DEPTH_INFINITE )
|
|
1538 |
{
|
|
1539 |
// Work as normal. Recurse as far as object tree exists.
|
|
1540 |
}
|
|
1541 |
else if( aDepth > 0 )
|
|
1542 |
{
|
|
1543 |
// Depth was defined. Decrement by one.
|
|
1544 |
aDepth--;
|
|
1545 |
}
|
|
1546 |
else if( aDepth == 0 )
|
|
1547 |
{
|
|
1548 |
// No more recursion.
|
|
1549 |
return;
|
|
1550 |
}
|
|
1551 |
|
|
1552 |
// Iterate childs
|
|
1553 |
ChspsDomList& childs = aRootNode->ChildNodes();
|
|
1554 |
for( int i = 0; i < childs.Length(); i++ )
|
|
1555 |
{
|
|
1556 |
ChspsDomNode* child = static_cast<ChspsDomNode*>( childs.Item( i ) );
|
|
1557 |
|
|
1558 |
// Modify node activity based on selected edit mode.
|
|
1559 |
if( child->Name().CompareF( KPluginElement ) == 0 )
|
|
1560 |
{
|
|
1561 |
if( aEditMode == EActivateFirst && i == 0 )
|
|
1562 |
{
|
|
1563 |
hspsServerUtil::AddAttributeDescL( *child,
|
|
1564 |
KPluginAttrActive,
|
|
1565 |
KPluginActiveStateActive );
|
|
1566 |
}
|
|
1567 |
else
|
|
1568 |
{
|
|
1569 |
hspsServerUtil::AddAttributeDescL( *child,
|
|
1570 |
KPluginAttrActive,
|
|
1571 |
KPluginActiveStateNotActive );
|
|
1572 |
}
|
|
1573 |
}
|
|
1574 |
|
|
1575 |
// Recurse.
|
|
1576 |
_EditPluginNodeActivityL( child,
|
|
1577 |
aEditMode,
|
|
1578 |
aDepth );
|
|
1579 |
}
|
|
1580 |
}
|
|
1581 |
|
|
1582 |
// -----------------------------------------------------------------------------
|
|
1583 |
// hspsServerUtil::GetActivePluginNode
|
|
1584 |
// -----------------------------------------------------------------------------
|
|
1585 |
//
|
|
1586 |
ChspsDomNode* hspsServerUtil::GetActivePluginNode( ChspsDomNode* aParentNode )
|
|
1587 |
{
|
|
1588 |
// Sanity check.
|
|
1589 |
if( !aParentNode )
|
|
1590 |
{
|
|
1591 |
return NULL;
|
|
1592 |
}
|
|
1593 |
|
|
1594 |
// Return structure.
|
|
1595 |
ChspsDomNode* activeNode = NULL;
|
|
1596 |
|
|
1597 |
// Iterate childs
|
|
1598 |
ChspsDomList& childs = aParentNode->ChildNodes();
|
|
1599 |
for( int i = 0; i < childs.Length(); i++ )
|
|
1600 |
{
|
|
1601 |
ChspsDomNode* child = static_cast<ChspsDomNode*>( childs.Item( i ) );
|
|
1602 |
|
|
1603 |
// Only for plugin elements.
|
|
1604 |
if( child->Name().CompareF( KPluginElement ) == 0 )
|
|
1605 |
{
|
|
1606 |
// 1. Check if has activity attribute.
|
|
1607 |
ChspsDomList& attrList = child->AttributeList();
|
|
1608 |
ChspsDomAttribute* pluginActivityAttr =
|
|
1609 |
static_cast<ChspsDomAttribute*>( attrList.FindByName( KPluginAttrActive ) );
|
|
1610 |
if( pluginActivityAttr )
|
|
1611 |
{
|
|
1612 |
// 2. Check whether node is active.
|
|
1613 |
if( pluginActivityAttr->Value().CompareF( KPluginActiveStateActive ) == 0 )
|
|
1614 |
{
|
|
1615 |
// 3. Active node found. assign and break.
|
|
1616 |
activeNode = child;
|
|
1617 |
break;
|
|
1618 |
}
|
|
1619 |
}
|
|
1620 |
}
|
|
1621 |
}
|
|
1622 |
|
|
1623 |
return activeNode;
|
|
1624 |
}
|
|
1625 |
|
|
1626 |
// -----------------------------------------------------------------------------
|
|
1627 |
// hspsServerUtil::GetPluginId
|
|
1628 |
// -----------------------------------------------------------------------------
|
|
1629 |
//
|
|
1630 |
TInt hspsServerUtil::GetPluginId( ChspsDomNode* aNode )
|
|
1631 |
{
|
|
1632 |
// Sanity check.
|
|
1633 |
if( !aNode )
|
|
1634 |
{
|
|
1635 |
return KErrArgument;
|
|
1636 |
}
|
|
1637 |
|
|
1638 |
// Return value.
|
|
1639 |
TInt pluginId = KErrNotFound;
|
|
1640 |
|
|
1641 |
// Find out plugin id.
|
|
1642 |
ChspsDomList& attrList = aNode->AttributeList();
|
|
1643 |
ChspsDomAttribute* pluginIdAttr =
|
|
1644 |
static_cast<ChspsDomAttribute*> ( attrList.FindByName( KPluginAttrId ) );
|
|
1645 |
if( pluginIdAttr )
|
|
1646 |
{
|
|
1647 |
// Found.
|
|
1648 |
const TDesC8& pluginIdValue = pluginIdAttr->Value();
|
|
1649 |
pluginId = DecString2Int( pluginIdValue );
|
|
1650 |
}
|
|
1651 |
|
|
1652 |
return pluginId;
|
|
1653 |
}
|
|
1654 |
|
|
1655 |
// -----------------------------------------------------------------------------
|
|
1656 |
// hspsServerUtil::GetPluginUid
|
|
1657 |
// -----------------------------------------------------------------------------
|
|
1658 |
//
|
|
1659 |
TUid hspsServerUtil::GetPluginUid( ChspsDomNode* aNode )
|
|
1660 |
{
|
|
1661 |
// Sanity check.
|
|
1662 |
if( !aNode )
|
|
1663 |
{
|
|
1664 |
return KNullUid;
|
|
1665 |
}
|
|
1666 |
|
|
1667 |
// Read Uid from attribute list.
|
|
1668 |
ChspsDomList& attrList = aNode->AttributeList();
|
|
1669 |
ChspsDomAttribute* pluginUidAttr =
|
|
1670 |
static_cast<ChspsDomAttribute*> ( attrList.FindByName( KPluginAttrUid ) );
|
|
1671 |
|
|
1672 |
// Sanity check.
|
|
1673 |
if( !pluginUidAttr )
|
|
1674 |
{
|
|
1675 |
return KNullUid;
|
|
1676 |
}
|
|
1677 |
|
|
1678 |
// Convert uids from string to numeric format
|
|
1679 |
const TDesC8& pluginUidValue = pluginUidAttr->Value();
|
|
1680 |
const TUid pluginUid = hspsServerUtil::ConvertDescIntoUid(pluginUidValue);
|
|
1681 |
|
|
1682 |
// Return result.
|
|
1683 |
return pluginUid;
|
|
1684 |
}
|
|
1685 |
|
|
1686 |
// -----------------------------------------------------------------------------
|
|
1687 |
// hspsServerUtil::GetPluginIdsByUidL
|
|
1688 |
// -----------------------------------------------------------------------------
|
|
1689 |
//
|
|
1690 |
void hspsServerUtil::GetPluginIdsByUidL(
|
|
1691 |
const ChspsODT& aAppODT,
|
|
1692 |
const TUid aPluginUid,
|
|
1693 |
RArray<TInt>& aPluginIds )
|
|
1694 |
{
|
|
1695 |
ChspsDomDocument& dom = aAppODT.DomDocument();
|
|
1696 |
ChspsDomDepthIterator* iter = ChspsDomDepthIterator::NewL( *dom.RootNode() );
|
|
1697 |
CleanupStack::PushL( iter );
|
|
1698 |
|
|
1699 |
// Find a plugin node with the provided id attribute
|
|
1700 |
ChspsDomNode* node = iter->First();
|
|
1701 |
ChspsDomNode* prevNode = NULL;
|
|
1702 |
TBool jobDone = EFalse;
|
|
1703 |
while( node && !jobDone && prevNode != node )
|
|
1704 |
{
|
|
1705 |
const TDesC8& name = node->Name();
|
|
1706 |
|
|
1707 |
// Plugin element was found
|
|
1708 |
if ( name == KPluginElement )
|
|
1709 |
{
|
|
1710 |
ChspsDomList& attrList = node->AttributeList();
|
|
1711 |
ChspsDomAttribute* attr = static_cast<ChspsDomAttribute*>( attrList.FindByName(KPluginAttrUid) );
|
|
1712 |
if ( !attr )
|
|
1713 |
{
|
|
1714 |
// Mandatory information is missing for some reason (should be set at installation handler)!
|
|
1715 |
// Exit with NULL
|
|
1716 |
jobDone = ETrue;
|
|
1717 |
}
|
|
1718 |
else
|
|
1719 |
{
|
|
1720 |
// Convert from (hex?) string into TUid presentation
|
|
1721 |
const TUid uid = ConvertDescIntoUid( attr->Value() );
|
|
1722 |
if ( aPluginUid == uid )
|
|
1723 |
{
|
|
1724 |
const TDesC8& strPluginId = node->AttributeValue(KPluginAttrId);
|
|
1725 |
TInt pluginId = DecString2Int( strPluginId );
|
|
1726 |
aPluginIds.AppendL( pluginId );
|
|
1727 |
}
|
|
1728 |
}
|
|
1729 |
}
|
|
1730 |
|
|
1731 |
prevNode = node;
|
|
1732 |
node = iter->NextL();
|
|
1733 |
}
|
|
1734 |
|
|
1735 |
CleanupStack::PopAndDestroy( iter );
|
|
1736 |
}
|
|
1737 |
|
|
1738 |
// -----------------------------------------------------------------------------
|
|
1739 |
// hspsServerUtil::GetParentNode
|
|
1740 |
// -----------------------------------------------------------------------------
|
|
1741 |
//
|
|
1742 |
ChspsDomNode* hspsServerUtil::GetParentNode(
|
|
1743 |
const ChspsDomNode& aNode,
|
|
1744 |
const TDesC8& aNodeName,
|
|
1745 |
const TDesC8& aAttrName,
|
|
1746 |
const TDesC8& aAttrValue )
|
|
1747 |
{
|
|
1748 |
ChspsDomNode* parent = aNode.Parent();
|
|
1749 |
TBool found( EFalse );
|
|
1750 |
while ( parent && !found )
|
|
1751 |
{
|
|
1752 |
if ( parent->Name().CompareF( aNodeName ) == 0 )
|
|
1753 |
{
|
|
1754 |
ChspsDomList& attrList = parent->AttributeList();
|
|
1755 |
ChspsDomAttribute* attr = static_cast<ChspsDomAttribute*>( attrList.FindByName( aAttrName ) );
|
|
1756 |
if ( attr && attr->Value().CompareF( aAttrValue ) == 0 )
|
|
1757 |
{
|
|
1758 |
found = ETrue;
|
|
1759 |
}
|
|
1760 |
}
|
|
1761 |
if ( !found )
|
|
1762 |
{
|
|
1763 |
// Get next level parent node
|
|
1764 |
parent = parent->Parent();
|
|
1765 |
}
|
|
1766 |
}
|
|
1767 |
|
|
1768 |
return parent;
|
|
1769 |
}
|
|
1770 |
|
|
1771 |
// -----------------------------------------------------------------------------
|
|
1772 |
// hspsServerUtil::IsLogoFile
|
|
1773 |
// -----------------------------------------------------------------------------
|
|
1774 |
//
|
|
1775 |
TBool hspsServerUtil::IsLogoFile(
|
|
1776 |
const TDesC& aFileDeclaration,
|
|
1777 |
TFileName& aFilename )
|
|
1778 |
{
|
|
1779 |
_LIT(KDeclarationSkin, "SKIN("); // prefixes for filelogo/filepreview values
|
|
1780 |
_LIT(KDeclarationMif, "MIF(");
|
|
1781 |
_LIT(KDeclarationUid, "UID(");
|
|
1782 |
|
|
1783 |
aFilename = KNullDesC();
|
|
1784 |
if ( aFileDeclaration.FindF( KDeclarationSkin ) >= 0
|
|
1785 |
|| aFileDeclaration.FindF( KDeclarationMif ) >= 0
|
|
1786 |
|| aFileDeclaration.FindF( KDeclarationUid ) >= 0 )
|
|
1787 |
{
|
|
1788 |
// pick filename from the mif declaration if it's available (e.g. "skin(<id> <id>):mif(<path> <id> <id>)")
|
|
1789 |
TInt mifOffset = aFileDeclaration.FindF( KDeclarationMif );
|
|
1790 |
if ( mifOffset >= 0 )
|
|
1791 |
{
|
|
1792 |
aFilename = aFileDeclaration.Mid( mifOffset + KDeclarationMif().Length() );
|
|
1793 |
aFilename.TrimAll();
|
|
1794 |
|
|
1795 |
// drop everything before the first bitmap index
|
|
1796 |
TInt endPos = aFilename.Locate( ' ' );
|
|
1797 |
if ( endPos > 1 )
|
|
1798 |
{
|
|
1799 |
aFilename = aFilename.Left( endPos );
|
|
1800 |
}
|
|
1801 |
}
|
|
1802 |
}
|
|
1803 |
else
|
|
1804 |
{
|
|
1805 |
// store possible icon path
|
|
1806 |
aFilename.Copy( aFileDeclaration );
|
|
1807 |
}
|
|
1808 |
|
|
1809 |
return ( aFilename.Length() > 0 );
|
|
1810 |
}
|
|
1811 |
|
|
1812 |
// -----------------------------------------------------------------------------
|
|
1813 |
// hspsServerUtil::GetResourcesForLanguageL
|
|
1814 |
// -----------------------------------------------------------------------------
|
|
1815 |
void hspsServerUtil::GetResourcesForLanguageL(
|
|
1816 |
ChspsODT& aODT,
|
|
1817 |
const TInt aConfUid,
|
|
1818 |
const TLanguage aActiveLanguage,
|
|
1819 |
RPointerArray<ChspsResource>& aWidgetResources )
|
|
1820 |
{
|
|
1821 |
const TInt resourceCount = aODT.ResourceCount();
|
|
1822 |
|
|
1823 |
// pick resources with the active language
|
|
1824 |
for( TInt resourceIndex = 0; resourceIndex < resourceCount; resourceIndex++ )
|
|
1825 |
{
|
|
1826 |
ChspsResource& resource = aODT.ResourceL( resourceIndex );
|
|
1827 |
if ( resource.ConfigurationUid() == aConfUid &&
|
|
1828 |
resource.Language() == aActiveLanguage &&
|
|
1829 |
resource.FileName().FindF( KSourcesFolder ) > 0 )
|
|
1830 |
{
|
|
1831 |
aWidgetResources.Append( &resource );
|
|
1832 |
}
|
|
1833 |
}
|
|
1834 |
|
|
1835 |
// Resources for language none or language test.
|
|
1836 |
for( TInt resourceIndex = 0; resourceIndex < resourceCount; resourceIndex++ )
|
|
1837 |
{
|
|
1838 |
ChspsResource& resource = aODT.ResourceL( resourceIndex );
|
|
1839 |
if ( resource.ConfigurationUid() == aConfUid &&
|
|
1840 |
resource.FileName().FindF( KSourcesFolder ) > 0 )
|
|
1841 |
{
|
|
1842 |
if( resource.Language() == ELangTest || resource.Language() == ELangNone )
|
|
1843 |
{
|
|
1844 |
// Checking also that not going to overwrite existing localized resource.
|
|
1845 |
TBool localizedVersionAvailable = EFalse;
|
|
1846 |
for( TInt checkIndex = 0; checkIndex < aWidgetResources.Count(); checkIndex++ )
|
|
1847 |
{
|
|
1848 |
ChspsResource* checkResource = aWidgetResources[ checkIndex ];
|
|
1849 |
if( !checkResource )
|
|
1850 |
{
|
|
1851 |
continue;
|
|
1852 |
}
|
|
1853 |
|
|
1854 |
TParsePtrC resource1FullPath( resource.FileName() );
|
|
1855 |
TParsePtrC resource2FullPath( checkResource->FileName() );
|
|
1856 |
|
|
1857 |
if( resource1FullPath.NameAndExt().CompareF( resource2FullPath.NameAndExt() ) == 0 )
|
|
1858 |
{
|
|
1859 |
localizedVersionAvailable = ETrue;
|
|
1860 |
break;
|
|
1861 |
}
|
|
1862 |
}
|
|
1863 |
|
|
1864 |
if( !localizedVersionAvailable )
|
|
1865 |
{
|
|
1866 |
aWidgetResources.Append( &resource );
|
|
1867 |
}
|
|
1868 |
}
|
|
1869 |
}
|
|
1870 |
}
|
|
1871 |
}
|
|
1872 |
|
|
1873 |
// -----------------------------------------------------------------------------
|
|
1874 |
// hspsServerUtil::EnoughDiskSpaceAvailable
|
|
1875 |
// -----------------------------------------------------------------------------
|
|
1876 |
TInt hspsServerUtil::EnoughDiskSpaceAvailableL(
|
|
1877 |
ChspsODT& aODT,
|
|
1878 |
const TLanguage aActiveLanguage,
|
|
1879 |
RFs& aFs,
|
|
1880 |
const TDriveNumber aDriveNumber,
|
|
1881 |
const TInt aAdditionalDiskSpace )
|
|
1882 |
{
|
|
1883 |
__UHEAP_MARK;
|
|
1884 |
|
|
1885 |
TInt err = KErrNone;
|
|
1886 |
|
|
1887 |
// Retrieve data for needed resource files.
|
|
1888 |
RPointerArray<ChspsResource> widgetResources; // Objects are not owned.
|
|
1889 |
CleanupClosePushL( widgetResources );
|
|
1890 |
|
|
1891 |
GetResourcesForLanguageL(
|
|
1892 |
aODT,
|
|
1893 |
aODT.ThemeUid(),
|
|
1894 |
aActiveLanguage,
|
|
1895 |
widgetResources );
|
|
1896 |
|
|
1897 |
TInt requiredDiskSpace = aAdditionalDiskSpace;
|
|
1898 |
|
|
1899 |
// Calculate disk space required for resources.
|
|
1900 |
for( TInt i = 0; i < widgetResources.Count() && !err; i++ )
|
|
1901 |
{
|
|
1902 |
ChspsResource* resource = widgetResources[i];
|
|
1903 |
if( !resource )
|
|
1904 |
{
|
|
1905 |
continue;
|
|
1906 |
}
|
|
1907 |
|
|
1908 |
TEntry entryData;
|
|
1909 |
err = aFs.Entry( resource->FileName(), entryData );
|
|
1910 |
requiredDiskSpace += entryData.iSize;
|
|
1911 |
}
|
|
1912 |
|
|
1913 |
widgetResources.Reset();
|
|
1914 |
CleanupStack::PopAndDestroy( 1, &widgetResources );
|
|
1915 |
|
|
1916 |
// Check if calculated space is available.
|
|
1917 |
if( !err &&
|
|
1918 |
SysUtil::DiskSpaceBelowCriticalLevelL( &aFs,
|
|
1919 |
requiredDiskSpace,
|
|
1920 |
aDriveNumber ) )
|
|
1921 |
{
|
|
1922 |
err = KErrDiskFull;
|
|
1923 |
}
|
|
1924 |
|
|
1925 |
__UHEAP_MARKEND;
|
|
1926 |
|
|
1927 |
return err;
|
|
1928 |
}
|
|
1929 |
// -----------------------------------------------------------------------------
|
|
1930 |
// Finds a node from a dom document.
|
|
1931 |
// Looks for the next node tag.
|
|
1932 |
// -----------------------------------------------------------------------------
|
|
1933 |
ChspsDomNode* hspsServerUtil::FindNodeByTagL(
|
|
1934 |
const TDesC8& aNodeTag,
|
|
1935 |
ChspsDomNode& aDomNode )
|
|
1936 |
{
|
|
1937 |
ChspsDomDepthIterator* iter = ChspsDomDepthIterator::NewL( aDomNode );
|
|
1938 |
CleanupStack::PushL( iter );
|
|
1939 |
ChspsDomNode* targetNode( NULL );
|
|
1940 |
ChspsDomNode* node = iter->First();
|
|
1941 |
TBool found = EFalse;
|
|
1942 |
while( !found && node )
|
|
1943 |
{
|
|
1944 |
const TDesC8& name = node->Name();
|
|
1945 |
if ( name.Compare( aNodeTag ) == 0 )
|
|
1946 |
{
|
|
1947 |
found = ETrue;
|
|
1948 |
targetNode = node;
|
|
1949 |
}
|
|
1950 |
node = iter->NextL();
|
|
1951 |
}
|
|
1952 |
CleanupStack::PopAndDestroy( iter );
|
|
1953 |
return targetNode;
|
|
1954 |
}
|
|
1955 |
|
|
1956 |
|
|
1957 |
// -----------------------------------------------------------------------------
|
|
1958 |
// hspsServerUtil::FindFile
|
|
1959 |
// Eclipsing support for customization
|
|
1960 |
// -----------------------------------------------------------------------------
|
|
1961 |
//
|
|
1962 |
TInt hspsServerUtil::FindFile(
|
|
1963 |
RFs& aFs,
|
|
1964 |
const TDesC& aPath,
|
|
1965 |
const TDesC& aFilename,
|
|
1966 |
const TBool aFindFromUdaEmmcDrives,
|
|
1967 |
TFileName& aDrivePathName )
|
|
1968 |
{
|
|
1969 |
TInt err = KErrNotFound;
|
|
1970 |
|
|
1971 |
TParsePtrC parser( aPath );
|
|
1972 |
const TPath path = parser.Path();
|
|
1973 |
|
|
1974 |
TFileName filename( aFilename );
|
|
1975 |
if( filename.Length() == 0 )
|
|
1976 |
{
|
|
1977 |
filename.Copy( parser.NameAndExt() );
|
|
1978 |
}
|
|
1979 |
|
|
1980 |
if( filename.Length() > 0 && path.Length() > 0 )
|
|
1981 |
{
|
|
1982 |
// Find the input file, search from the user area (UDA) first,
|
|
1983 |
// exclude external/remote drives from the search - otherwise end-users
|
|
1984 |
// could introduce fixed configurations (e.g. operator locks wouldn't work)
|
|
1985 |
TFindFile fileFinder( aFs );
|
|
1986 |
fileFinder.SetFindMask(
|
|
1987 |
KDriveAttExclude|KDriveAttRemovable|KDriveAttRemote|KDriveAttSubsted );
|
|
1988 |
if( aFindFromUdaEmmcDrives )
|
|
1989 |
{
|
|
1990 |
TInt drive = hspsServerUtil::GetEmmcDrivePath( aFs );
|
|
1991 |
if ( drive != KErrNotFound )
|
|
1992 |
{
|
|
1993 |
aFs.SetSessionToPrivate( drive );
|
|
1994 |
}
|
|
1995 |
}
|
|
1996 |
else
|
|
1997 |
{
|
|
1998 |
aFs.SetSessionToPrivate( EDriveZ );
|
|
1999 |
}
|
|
2000 |
err = fileFinder.FindByDir( filename, path );
|
|
2001 |
aFs.SetSessionToPrivate( EDriveC );
|
|
2002 |
if( !err )
|
|
2003 |
{
|
|
2004 |
// Return the path with a drive reference
|
|
2005 |
aDrivePathName = fileFinder.File();
|
|
2006 |
TParsePtrC drvParser( aDrivePathName );
|
|
2007 |
if( !drvParser.DrivePresent() )
|
|
2008 |
{
|
|
2009 |
err = KErrNotFound;
|
|
2010 |
}
|
|
2011 |
}
|
|
2012 |
}
|
|
2013 |
|
|
2014 |
return err;
|
|
2015 |
}
|
|
2016 |
|
|
2017 |
// -----------------------------------------------------------------------------
|
|
2018 |
// hspsServerUtil::ResolveLogoPathL
|
|
2019 |
// -----------------------------------------------------------------------------
|
|
2020 |
void hspsServerUtil::PopulateLogoPathsL(
|
|
2021 |
const TDesC& aLogoDeclaration,
|
|
2022 |
const TUint aAppUid,
|
|
2023 |
RBuf& aTargetPath,
|
|
2024 |
RBuf& aSourcePath,
|
|
2025 |
RBuf& aUpdatedDeclaration)
|
|
2026 |
{
|
|
2027 |
// Process widget types only
|
|
2028 |
if ( aLogoDeclaration.Length() && aAppUid > 0 )
|
|
2029 |
{
|
|
2030 |
// Get possible file name from the optional logo declaration
|
|
2031 |
// and if found, populate the paths and update the declaration
|
|
2032 |
TFileName filename;
|
|
2033 |
if( IsLogoFile( aLogoDeclaration, filename ) )
|
|
2034 |
{
|
|
2035 |
// Get client's private directory
|
|
2036 |
_LIT( KClientPrivatePath, "c:\\private\\%X\\");
|
|
2037 |
TPath clientPath;
|
|
2038 |
clientPath.Format( KClientPrivatePath, aAppUid );
|
|
2039 |
|
|
2040 |
// Updated logo declaration
|
|
2041 |
TInt offset = aLogoDeclaration.FindF( filename );
|
|
2042 |
__ASSERT_DEBUG( offset != KErrNotFound, User::Leave( KErrCorrupt ) );
|
|
2043 |
if( aLogoDeclaration.Length() + aLogoDeclaration.Mid( offset ).Length() < KMaxFileName )
|
|
2044 |
{
|
|
2045 |
aUpdatedDeclaration.Copy( aLogoDeclaration );
|
|
2046 |
aUpdatedDeclaration.Insert( offset, clientPath );
|
|
2047 |
|
|
2048 |
// Set path and name of the target file
|
|
2049 |
if( clientPath.Length() + filename.Length() < KMaxFileName )
|
|
2050 |
{
|
|
2051 |
aTargetPath.Copy( clientPath );
|
|
2052 |
aTargetPath.Append( filename );
|
|
2053 |
|
|
2054 |
// Set name of the source file
|
|
2055 |
_LIT( KServerPrivateFolder, "c:\\private\\200159c0\\themes\\" );
|
|
2056 |
if( KServerPrivateFolder().Length() + filename.Length() < KMaxFileName )
|
|
2057 |
{
|
|
2058 |
aSourcePath.Copy( KServerPrivateFolder );
|
|
2059 |
aSourcePath.Append( filename );
|
|
2060 |
}
|
|
2061 |
}
|
|
2062 |
}
|
|
2063 |
|
|
2064 |
}
|
|
2065 |
}
|
|
2066 |
}
|
|
2067 |
|
|
2068 |
// -----------------------------------------------------------------------------
|
|
2069 |
// hspsServerUtil::FindResourcesL
|
|
2070 |
// -----------------------------------------------------------------------------
|
|
2071 |
void hspsServerUtil::FindResourcesL(
|
|
2072 |
RFs& aFs,
|
|
2073 |
const RArray<TInt>& aDriveArray,
|
|
2074 |
const TDesC& aPath,
|
|
2075 |
RPointerArray<HBufC>& aFileArray,
|
|
2076 |
CArrayFixFlat<TInt>* aDeviceLanguages,
|
|
2077 |
TBool aRecursive )
|
|
2078 |
{
|
|
2079 |
// Scan internal drives only
|
|
2080 |
TFindFile fileFinder( aFs );
|
|
2081 |
fileFinder.SetFindMask( KDriveAttExclude|KDriveAttRemovable|KDriveAttRemote|KDriveAttSubsted );
|
|
2082 |
|
|
2083 |
TParsePtrC parser( aPath );
|
|
2084 |
|
|
2085 |
// Loop the provided disk drives
|
|
2086 |
for( TInt driveIndex=0; driveIndex < aDriveArray.Count(); driveIndex++ )
|
|
2087 |
{
|
|
2088 |
TChar driveChar;
|
|
2089 |
User::LeaveIfError( RFs::DriveToChar( aDriveArray[driveIndex], driveChar ) );
|
|
2090 |
TBuf16<2> driveBuf(2);
|
|
2091 |
driveBuf[0] = TUint( driveChar );
|
|
2092 |
driveBuf[1] = TUint( TChar(':') );
|
|
2093 |
|
|
2094 |
TPath path;
|
|
2095 |
path.Copy( driveBuf );
|
|
2096 |
path.Append( parser.Path() );
|
|
2097 |
|
|
2098 |
// Find files from the drive and path
|
|
2099 |
CDir* dirList( NULL );
|
|
2100 |
fileFinder.FindWildByPath( path, NULL, dirList );
|
|
2101 |
if ( dirList )
|
|
2102 |
{
|
|
2103 |
CleanupStack::PushL( dirList );
|
|
2104 |
|
|
2105 |
const TInt count = dirList->Count();
|
|
2106 |
for( TInt entryIndex = 0; entryIndex < count; entryIndex++ )
|
|
2107 |
{
|
|
2108 |
const TEntry& entry = (*dirList)[ entryIndex ];
|
|
2109 |
|
|
2110 |
TFileName file( path );
|
|
2111 |
file.Append( entry.iName );
|
|
2112 |
|
|
2113 |
if( entry.IsDir() )
|
|
2114 |
{
|
|
2115 |
if( aDeviceLanguages )
|
|
2116 |
{
|
|
2117 |
TInt dirLanguage = 0;
|
|
2118 |
TLex lex( entry.iName );
|
|
2119 |
TBool skipDir = ETrue;
|
|
2120 |
if( lex.Val( dirLanguage ) == KErrNone && dirLanguage >= ELangTest )
|
|
2121 |
{
|
|
2122 |
for( TInt i=0; i < aDeviceLanguages->Count(); i++ )
|
|
2123 |
{
|
|
2124 |
TInt supportedLanguage = aDeviceLanguages->At( i );
|
|
2125 |
if( supportedLanguage == dirLanguage )
|
|
2126 |
{
|
|
2127 |
skipDir = EFalse;
|
|
2128 |
break;
|
|
2129 |
}
|
|
2130 |
}
|
|
2131 |
}
|
|
2132 |
if( skipDir )
|
|
2133 |
{
|
|
2134 |
continue;
|
|
2135 |
}
|
|
2136 |
}
|
|
2137 |
|
|
2138 |
file.Append( KDoubleBackSlash );
|
|
2139 |
}
|
|
2140 |
|
|
2141 |
if( entry.IsDir() && aRecursive )
|
|
2142 |
{
|
|
2143 |
// Find files from the directory and drive
|
|
2144 |
RArray<TInt> driveArray;
|
|
2145 |
CleanupClosePushL( driveArray );
|
|
2146 |
driveArray.Append( aDriveArray[driveIndex] );
|
|
2147 |
FindResourcesL( aFs, driveArray, file, aFileArray, NULL );
|
|
2148 |
CleanupStack::PopAndDestroy( &driveArray );
|
|
2149 |
}
|
|
2150 |
else
|
|
2151 |
{
|
|
2152 |
HBufC* nameBuf = file.AllocLC();
|
|
2153 |
aFileArray.AppendL( nameBuf );
|
|
2154 |
CleanupStack::Pop( nameBuf );
|
|
2155 |
}
|
|
2156 |
}
|
|
2157 |
|
|
2158 |
CleanupStack::PopAndDestroy( dirList );
|
|
2159 |
dirList = 0;
|
|
2160 |
} // dirlist
|
|
2161 |
|
|
2162 |
} // driveIndex
|
|
2163 |
}
|
|
2164 |
|
|
2165 |
// -----------------------------------------------------------------------------
|
|
2166 |
// hspsServerUtil::GetInstalledLanguagesL
|
|
2167 |
// -----------------------------------------------------------------------------
|
|
2168 |
void hspsServerUtil::GetInstalledLanguagesL(
|
|
2169 |
CArrayFixFlat<TInt>*& aLanguages )
|
|
2170 |
{
|
|
2171 |
User::LeaveIfError( SysLangUtil::GetInstalledLanguages( aLanguages ) );
|
|
2172 |
CleanupStack::PushL( aLanguages );
|
|
2173 |
|
|
2174 |
const TInt testLang = (TInt)ELangTest;
|
|
2175 |
|
|
2176 |
TBool isIncluded = EFalse;
|
|
2177 |
for( TInt i = 0; i < aLanguages->Count(); i++ )
|
|
2178 |
{
|
|
2179 |
if( aLanguages->At( i ) == testLang )
|
|
2180 |
{
|
|
2181 |
isIncluded = ETrue;
|
|
2182 |
break;
|
|
2183 |
}
|
|
2184 |
}
|
|
2185 |
|
|
2186 |
if( !isIncluded )
|
|
2187 |
{
|
|
2188 |
aLanguages->InsertL( 0, testLang );
|
|
2189 |
}
|
|
2190 |
|
|
2191 |
CleanupStack::Pop( aLanguages );
|
|
2192 |
}
|
|
2193 |
|
|
2194 |
|
|
2195 |
// -----------------------------------------------------------------------------
|
|
2196 |
// hspsServerUtil::GetEmmcDrivePathL
|
|
2197 |
// -----------------------------------------------------------------------------
|
|
2198 |
//
|
|
2199 |
TInt hspsServerUtil::GetEmmcDrivePath( RFs& aFs )
|
|
2200 |
{
|
|
2201 |
TInt drive = KErrNotFound;
|
|
2202 |
if ( DriveInfo::GetDefaultDrive(
|
|
2203 |
DriveInfo::EDefaultMassStorage, drive ) == KErrNone )
|
|
2204 |
{
|
|
2205 |
TUint status;
|
|
2206 |
if ( DriveInfo::GetDriveStatus( aFs, drive, status ) == KErrNone )
|
|
2207 |
{
|
|
2208 |
if ( status & DriveInfo::EDriveInternal )
|
|
2209 |
{
|
|
2210 |
return drive;
|
|
2211 |
}
|
|
2212 |
}
|
|
2213 |
}
|
|
2214 |
return KErrNotFound;
|
|
2215 |
}
|
|
2216 |
|
|
2217 |
// -----------------------------------------------------------------------------
|
|
2218 |
// Removes plugin resources from the provided ODT
|
|
2219 |
// -----------------------------------------------------------------------------
|
|
2220 |
//
|
|
2221 |
TInt hspsServerUtil::RemovePluginResourcesL(
|
|
2222 |
ChspsODT& aAppODT,
|
|
2223 |
const TInt aPluginUid )
|
|
2224 |
{
|
|
2225 |
// Loop resources of the application configuration
|
|
2226 |
for(TInt aresIndex = 0; aresIndex < aAppODT.ResourceCount(); aresIndex++ )
|
|
2227 |
{
|
|
2228 |
ChspsResource& ares = aAppODT.ResourceL( aresIndex );
|
|
2229 |
|
|
2230 |
// If the plugin resource was found at resource list of the application configuration
|
|
2231 |
if ( ares.ConfigurationUid() == aPluginUid )
|
|
2232 |
{
|
|
2233 |
// Deletes resource from the application configuration
|
|
2234 |
aAppODT.DeleteResourceL( aresIndex );
|
|
2235 |
aresIndex--;
|
|
2236 |
}
|
|
2237 |
|
|
2238 |
}
|
|
2239 |
|
|
2240 |
return KErrNone;
|
|
2241 |
}
|
|
2242 |
|
|
2243 |
// -----------------------------------------------------------------------------
|
|
2244 |
// hspsServerUtil::hspsServerUtil
|
|
2245 |
// -----------------------------------------------------------------------------
|
|
2246 |
//
|
|
2247 |
hspsServerUtil::hspsServerUtil()
|
|
2248 |
{
|
|
2249 |
// Empty. Should never be called.
|
|
2250 |
}
|
|
2251 |
|
|
2252 |
// end of file
|