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