|
1 /* |
|
2 * Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: This module contains the description of CIAUpdateNodeFilter |
|
15 * class member functions. |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 #include <e32property.h> |
|
21 #include <iaupdateparameters.h> |
|
22 #include <centralrepository.h> |
|
23 |
|
24 #include "iaupdatenodefilter.h" |
|
25 #include "iaupdatebasenode.h" |
|
26 #include "iaupdatenode.h" |
|
27 #include "iaupdatefwnode.h" |
|
28 #include "iaupdateutils.h" |
|
29 #include "iaupdatedeputils.h" |
|
30 #include "iaupdateuids.h" |
|
31 #include "iaupdatedebug.h" |
|
32 #include "iaupdatefwnsmlpskeys.h" |
|
33 #include "iaupdatefwupdatehandler.h" |
|
34 #include "iaupdateprivatecrkeys.h" |
|
35 |
|
36 // ----------------------------------------------------------------------------- |
|
37 // CIAUpdateNodeFilter::NewL |
|
38 // Two-phased constructor. |
|
39 // ----------------------------------------------------------------------------- |
|
40 // |
|
41 CIAUpdateNodeFilter* CIAUpdateNodeFilter::NewL() |
|
42 { |
|
43 CIAUpdateNodeFilter* self = |
|
44 CIAUpdateNodeFilter::NewLC(); |
|
45 CleanupStack::Pop( self ); |
|
46 return self; |
|
47 } |
|
48 |
|
49 |
|
50 // ----------------------------------------------------------------------------- |
|
51 // CIAUpdateNodeFilter::NewLC |
|
52 // Two-phased constructor. |
|
53 // ----------------------------------------------------------------------------- |
|
54 // |
|
55 CIAUpdateNodeFilter* CIAUpdateNodeFilter::NewLC() |
|
56 { |
|
57 CIAUpdateNodeFilter* self = |
|
58 new( ELeave ) CIAUpdateNodeFilter(); |
|
59 CleanupStack::PushL( self ); |
|
60 self->ConstructL(); |
|
61 return self; |
|
62 } |
|
63 |
|
64 |
|
65 // ----------------------------------------------------------------------------- |
|
66 // CIAUpdateNodeFilter::~CIAUpdateNodeFilter |
|
67 // Destructor |
|
68 // ----------------------------------------------------------------------------- |
|
69 // |
|
70 CIAUpdateNodeFilter::~CIAUpdateNodeFilter() |
|
71 { |
|
72 IAUPDATE_TRACE("[IAUPDATE] CIAUpdateNodeFilter::~CIAUpdateNodeFilter() begin"); |
|
73 |
|
74 delete iFilterParams; |
|
75 |
|
76 IAUPDATE_TRACE("[IAUPDATE] CIAUpdateNodeFilter::~CIAUpdateNodeFilter() end"); |
|
77 } |
|
78 |
|
79 |
|
80 // ----------------------------------------------------------------------------- |
|
81 // CIAUpdateNodeFilter::CIAUpdateNodeFilter |
|
82 // c++ constructor |
|
83 // ----------------------------------------------------------------------------- |
|
84 // |
|
85 CIAUpdateNodeFilter::CIAUpdateNodeFilter() |
|
86 : CBase() |
|
87 { |
|
88 IAUPDATE_TRACE("[IAUPDATE] CIAUpdateNodeFilter::CIAUpdateNodeFilter()"); |
|
89 } |
|
90 |
|
91 |
|
92 // ----------------------------------------------------------------------------- |
|
93 // CIAUpdateNodeFilter::ConstructL |
|
94 // |
|
95 // ----------------------------------------------------------------------------- |
|
96 // |
|
97 void CIAUpdateNodeFilter::ConstructL() |
|
98 { |
|
99 IAUPDATE_TRACE("[IAUPDATE] CIAUpdateNodeFilter::ConstructL()"); |
|
100 } |
|
101 |
|
102 |
|
103 // ----------------------------------------------------------------------------- |
|
104 // CIAUpdateNodeFilter::SetFilterParams |
|
105 // |
|
106 // ----------------------------------------------------------------------------- |
|
107 // |
|
108 void CIAUpdateNodeFilter::SetFilterParams( CIAUpdateParameters* aParams ) |
|
109 { |
|
110 IAUPDATE_TRACE("[IAUPDATE] CIAUpdateNodeFilter::SetFilterParams() begin"); |
|
111 |
|
112 delete iFilterParams; |
|
113 iFilterParams = aParams; |
|
114 |
|
115 IAUPDATE_TRACE("[IAUPDATE] CIAUpdateNodeFilter::SetFilterParams() end"); |
|
116 } |
|
117 |
|
118 |
|
119 // ----------------------------------------------------------------------------- |
|
120 // CIAUpdateNodeFilter::FilterParams |
|
121 // |
|
122 // ----------------------------------------------------------------------------- |
|
123 // |
|
124 CIAUpdateParameters* CIAUpdateNodeFilter::FilterParams() const |
|
125 { |
|
126 return iFilterParams; |
|
127 } |
|
128 |
|
129 |
|
130 // ----------------------------------------------------------------------------- |
|
131 // CIAUpdateNodeFilter::FilterAndSortNodesL |
|
132 // |
|
133 // ----------------------------------------------------------------------------- |
|
134 // |
|
135 void CIAUpdateNodeFilter::FilterAndSortNodesL( |
|
136 RPointerArray< MIAUpdateNode >& aNodes, |
|
137 RPointerArray< MIAUpdateFwNode >& aFwNodes ) |
|
138 { |
|
139 IAUPDATE_TRACE("[IAUPDATE] CIAUpdateNodeFilter::FilterAndSortNodesL() begin"); |
|
140 |
|
141 // Just to make sure that filter has the correct UID set. |
|
142 // Checks if the filter UID was SID and changes it to pUID if possible. |
|
143 |
|
144 TUid pUid( PackageUidL( aNodes ) ); |
|
145 |
|
146 // Use bubble sort to sort the array |
|
147 TInt tmpIndex( aNodes.Count() ); |
|
148 |
|
149 if ( tmpIndex == 1 ) |
|
150 { |
|
151 IAUPDATE_TRACE("[IAUPDATE] Only one node."); |
|
152 // If the array has only one node, no need to do sorting. |
|
153 // Instead, just check if the node needs to be marked or not. |
|
154 MarkFilterNodeL( *aNodes[ 0 ], pUid ); |
|
155 } |
|
156 else if ( tmpIndex > 1 ) |
|
157 { |
|
158 IAUPDATE_TRACE_1("[IAUPDATE] Multiple nodes: %d", tmpIndex); |
|
159 // There are multiple nodes in the array. |
|
160 // So, sorting may be required. |
|
161 TBool swapped( EFalse ); |
|
162 do |
|
163 { |
|
164 swapped = EFalse; |
|
165 --tmpIndex; |
|
166 for ( TInt i = 0; i < tmpIndex; ++i ) |
|
167 { |
|
168 // Check if the aNodes[ i ] should be after aNodes[ i + 1 ] |
|
169 // in the array. |
|
170 if ( CompareAndMarkFilterNodesL( |
|
171 *aNodes[ i ], |
|
172 *aNodes[ i + 1 ], |
|
173 pUid ) ) |
|
174 { |
|
175 // Swap the nodes |
|
176 MIAUpdateNode* tmpNode( aNodes[ i ] ); |
|
177 aNodes[ i ] = aNodes[ i + 1 ]; |
|
178 aNodes[ i + 1 ] = tmpNode; |
|
179 swapped = ETrue; |
|
180 } |
|
181 } |
|
182 } while( swapped ); |
|
183 } |
|
184 // When dependant is marked, all dependencies to be marked also |
|
185 for ( TInt i = 0; i < aNodes.Count(); ++i ) |
|
186 { |
|
187 MIAUpdateNode* node( aNodes[ i ] ); |
|
188 if ( node->Base().IsSelected() ) |
|
189 { |
|
190 SetDependenciesSelectedL( *node, aNodes ); |
|
191 } |
|
192 } |
|
193 |
|
194 // Now update nodes were handled |
|
195 // Let's handle firmware updates |
|
196 if ( aFwNodes.Count() > 0 && DMSupportL() ) |
|
197 { |
|
198 if ( iFilterParams ) |
|
199 { |
|
200 if ( iFilterParams->Uid() != TUid::Null() || |
|
201 iFilterParams->SearchCriteria() != KNullDesC() ) |
|
202 { //UID or search criteria given, firmware updates are not shown at all |
|
203 aFwNodes.Reset(); |
|
204 } |
|
205 else |
|
206 { |
|
207 for ( TInt i = 0; i < aFwNodes.Count(); ++i ) |
|
208 { |
|
209 aFwNodes[i]->Base().SetSelected( ETrue ); |
|
210 } |
|
211 for ( TInt i = 0; i < aNodes.Count(); ++i ) |
|
212 { |
|
213 aNodes[i]->Base().SetSelected( EFalse ); |
|
214 } |
|
215 } |
|
216 } |
|
217 else |
|
218 { |
|
219 for ( TInt i = 0; i < aFwNodes.Count(); ++i ) |
|
220 { |
|
221 aFwNodes[i]->Base().SetSelected( ETrue ); |
|
222 } |
|
223 for ( TInt i = 0; i < aNodes.Count(); ++i ) |
|
224 { |
|
225 aNodes[i]->Base().SetSelected( EFalse ); |
|
226 } |
|
227 } |
|
228 } |
|
229 else |
|
230 { |
|
231 aFwNodes.Reset(); |
|
232 } |
|
233 |
|
234 |
|
235 IAUPDATE_TRACE("[IAUPDATE] CIAUpdateNodeFilter::FilterAndSortNodesL() end"); |
|
236 } |
|
237 |
|
238 |
|
239 // ----------------------------------------------------------------------------- |
|
240 // CIAUpdateNodeFilter::CountOfAvailableUpdatesL |
|
241 // |
|
242 // ----------------------------------------------------------------------------- |
|
243 // |
|
244 void CIAUpdateNodeFilter::CountOfAvailableUpdatesL( |
|
245 const RPointerArray< MIAUpdateNode >& aNodes, |
|
246 const RPointerArray< MIAUpdateFwNode >& aFwNodes, |
|
247 TInt& aCount ) |
|
248 { |
|
249 IAUPDATE_TRACE("[IAUPDATE] CIAUpdateNodeFilter::CountOfAvailableUpdatesL() begin"); |
|
250 |
|
251 aCount = 0; |
|
252 |
|
253 IAUPDATE_TRACE_1("[IAUPDATE] CIAUpdateNodeFilter::CountOfAvailableUpdatesL() Node count (only MIAUpdateNodes): %d", aNodes.Count() ); |
|
254 |
|
255 if ( iFilterParams->Type() & CIAUpdateParameters::ESis ) |
|
256 { |
|
257 IAUPDATE_TRACE("[IAUPDATE] CIAUpdateNodeFilter::CountOfAvailableUpdatesL() ESis included in type parameter"); |
|
258 if ( iFilterParams->Uid() == TUid::Null() |
|
259 && iFilterParams->SearchCriteria() == KNullDesC() |
|
260 && !FilteredByImportance() ) |
|
261 { |
|
262 IAUPDATE_TRACE("[IAUPDATE] CIAUpdateNodeFilter::CountOfAvailableUpdatesL() No filter values. Count all nodes."); |
|
263 // Because no filter values were given, |
|
264 // all nodes should be counted. |
|
265 aCount = aNodes.Count(); |
|
266 } |
|
267 else |
|
268 { |
|
269 IAUPDATE_TRACE("[IAUPDATE] CIAUpdateNodeFilter::CountOfAvailableUpdatesL() Some filter values given."); |
|
270 // Some filter values were given. |
|
271 // So, filter nodes. |
|
272 for ( TInt i = 0; i < aNodes.Count(); ++i ) |
|
273 { |
|
274 if ( ImportanceMatches( *aNodes[ i ] ) ) |
|
275 { |
|
276 if ( iFilterParams->Uid() == TUid::Null() && iFilterParams->SearchCriteria() == KNullDesC() ) |
|
277 { |
|
278 ++aCount; |
|
279 } |
|
280 // If UID was given, filter by using UID. |
|
281 // If UID was not given, filter by using search criteria. |
|
282 else if ( iFilterParams->Uid() != TUid::Null() && iFilterParams->Uid() == aNodes[ i ]->Base().Uid() |
|
283 || ( iFilterParams->Uid() == TUid::Null() |
|
284 && aNodes[ i ]->Base().SearchCriteria() != KNullDesC() |
|
285 && SearchCriteriaMatches( iFilterParams->SearchCriteria(), aNodes[ i ]->Base().SearchCriteria() ) ) ) |
|
286 { |
|
287 IAUPDATE_TRACE("[IAUPDATE] CIAUpdateNodeFilter::CountOfAvailableUpdatesL() Filter parameters matched the node"); |
|
288 // Filter parameters matched the node. |
|
289 ++aCount; |
|
290 } |
|
291 else if ( FilterCheckForServicePackL( *aNodes[ i ], |
|
292 iFilterParams->Uid(), |
|
293 iFilterParams->SearchCriteria() ) ) |
|
294 { |
|
295 ++aCount; |
|
296 } |
|
297 } |
|
298 } |
|
299 |
|
300 |
|
301 if ( iFilterParams->Uid() != TUid::Null() && aCount == 0 ) |
|
302 { |
|
303 IAUPDATE_TRACE("[IAUPDATE] CIAUpdateNodeFilter::CountOfAvailableUpdatesL() Uid did not match. Is it SID?"); |
|
304 // Uid did not match to anything in the list. |
|
305 // Maybe it was not a package UID but SID. |
|
306 // So, check if we can find out the package UID and use it. |
|
307 TUid newUid( |
|
308 IAUpdateUtils::AppPackageUidL( iFilterParams->Uid() ) ); |
|
309 IAUPDATE_TRACE_2("[IAUPDATE] [IAUPDATE] CIAUpdateNodeFilter::CountOfAvailableUpdatesL() NewUid: %d, Old uid: %d", |
|
310 newUid.iUid, iFilterParams->Uid() ); |
|
311 if ( newUid != TUid::Null() && newUid != iFilterParams->Uid() ) |
|
312 { |
|
313 IAUPDATE_TRACE("[IAUPDATE] CIAUpdateNodeFilter::CountOfAvailableUpdatesL() New UID found."); |
|
314 // It was SID but now we know pUID. |
|
315 // So, retry the search. |
|
316 for ( TInt i = 0; i < aNodes.Count(); ++i ) |
|
317 { |
|
318 if ( ImportanceMatches( *aNodes[ i ] ) ) |
|
319 { |
|
320 if ( newUid == aNodes[ i ]->Base().Uid() ) |
|
321 { |
|
322 IAUPDATE_TRACE("[IAUPDATE] CIAUpdateNodeFilter::CountOfAvailableUpdatesL() New UID matched."); |
|
323 // New uid matched with the node uid. |
|
324 ++aCount; |
|
325 } |
|
326 else if ( FilterCheckForServicePackL( *aNodes[ i ], |
|
327 newUid, |
|
328 iFilterParams->SearchCriteria() ) ) |
|
329 { |
|
330 ++aCount; |
|
331 } |
|
332 } |
|
333 } |
|
334 } |
|
335 } |
|
336 } |
|
337 } |
|
338 |
|
339 |
|
340 |
|
341 // Firmware updates are not counted if UID or search criteria parameter exists |
|
342 if ( iFilterParams->Uid() == TUid::Null() && |
|
343 iFilterParams->SearchCriteria() == KNullDesC() ) |
|
344 { |
|
345 TBool dmsupport = DMSupportL(); |
|
346 IAUPDATE_TRACE("[IAUPDATE] CIAUpdateNodeFilter::CountOfAvailableUpdatesL() Checking DM support"); |
|
347 //take firmware into account when dm support is available |
|
348 if ( dmsupport ) |
|
349 { |
|
350 IAUPDATE_TRACE("[IAUPDATE] CIAUpdateNodeFilter::CountOfAvailableUpdatesL() DM is supported"); |
|
351 for ( TInt i = 0; i < aFwNodes.Count(); ++i ) |
|
352 { |
|
353 if ( aFwNodes[i]->FwType() == MIAUpdateFwNode::EFotaDp2 ) |
|
354 { |
|
355 if ( iFilterParams->Type() & CIAUpdateParameters::EFota ) |
|
356 { |
|
357 ++aCount; |
|
358 IAUPDATE_TRACE("[IAUPDATE] CIAUpdateNodeFilter::CountOfAvailableUpdatesL() FOTA node found"); |
|
359 } |
|
360 } |
|
361 else if ( aFwNodes[i]->FwType() == MIAUpdateFwNode::EFotiNsu ) |
|
362 { |
|
363 if ( iFilterParams->Type() & CIAUpdateParameters::ENsu ) |
|
364 { |
|
365 ++aCount; |
|
366 IAUPDATE_TRACE("[IAUPDATE] CIAUpdateNodeFilter::CountOfAvailableUpdatesL() NSU node found"); |
|
367 } |
|
368 } |
|
369 } |
|
370 } |
|
371 } |
|
372 |
|
373 IAUPDATE_TRACE_1("[IAUPDATE] CIAUpdateNodeFilter::CountOfAvailableUpdatesL() end count: %d", |
|
374 aCount ); |
|
375 } |
|
376 |
|
377 // ----------------------------------------------------------------------------- |
|
378 // CIAUpdateNodeFilter::SetDependenciesSelectedL(); |
|
379 // |
|
380 // ----------------------------------------------------------------------------- |
|
381 // |
|
382 void CIAUpdateNodeFilter::SetDependenciesSelectedL( MIAUpdateNode& aNode, |
|
383 const RPointerArray<MIAUpdateNode>& aAllNodes ) |
|
384 { |
|
385 IAUPDATE_TRACE("[IAUPDATE] CIAUpdateNodeFilter::SetDependenciesSelectedL() begin"); |
|
386 RPointerArray<MIAUpdateNode> deps; |
|
387 CleanupClosePushL( deps ); |
|
388 |
|
389 RPointerArray<MIAUpdateAnyNode> allNodes; |
|
390 CleanupClosePushL( allNodes ); |
|
391 for( TInt i = 0; i < aAllNodes.Count(); ++i ) |
|
392 { |
|
393 MIAUpdateAnyNode* node = aAllNodes[i]; |
|
394 User::LeaveIfError( allNodes.Append( node ) ); |
|
395 } |
|
396 |
|
397 IAUpdateDepUtils::GetDependenciesL( aNode, allNodes, deps ); |
|
398 CleanupStack::PopAndDestroy( &allNodes ); |
|
399 TInt depCount = deps.Count(); |
|
400 for( TInt i = 0; i < depCount; i++ ) |
|
401 { |
|
402 TInt depNodeInd = aAllNodes.Find( deps[i] ); |
|
403 aAllNodes[depNodeInd]->Base().SetSelected( ETrue ); |
|
404 } |
|
405 CleanupStack::PopAndDestroy( &deps ); |
|
406 |
|
407 IAUPDATE_TRACE("[IAUPDATE] CIAUpdateNodeFilter::SetDependenciesSelectedL() end"); |
|
408 } |
|
409 |
|
410 |
|
411 |
|
412 |
|
413 // ----------------------------------------------------------------------------- |
|
414 // CIAUpdateNodeFilter::CompareAndMarkFilterNodesL |
|
415 // |
|
416 // ----------------------------------------------------------------------------- |
|
417 // |
|
418 TBool CIAUpdateNodeFilter::CompareAndMarkFilterNodesL( |
|
419 MIAUpdateNode& aNode1, |
|
420 MIAUpdateNode& aNode2, |
|
421 const TUid& aPackageUid ) |
|
422 { |
|
423 IAUPDATE_TRACE("[IAUPDATE] CIAUpdateNodeFilter::CompareAndMarkFilterNodesL() begin"); |
|
424 |
|
425 TBool filterCheck1( MarkFilterNodeL( aNode1, aPackageUid ) ); |
|
426 TBool filterCheck2( MarkFilterNodeL( aNode2, aPackageUid ) ); |
|
427 |
|
428 // 1. The one node that matches filter should be first. |
|
429 // 2. More ciritical should be first. |
|
430 // 3. Alphabetical order inside critical sets. |
|
431 if ( filterCheck1 && !filterCheck2 ) |
|
432 { |
|
433 IAUPDATE_TRACE("[IAUPDATE] Only node 1 marked for filter."); |
|
434 // The Node1 should be before Node2 |
|
435 // if Node1 matches the filter check |
|
436 // but Node2 does not. |
|
437 // Then, the importance or name does not have effect. |
|
438 IAUPDATE_TRACE("[IAUPDATE] CIAUpdateNodeFilter::CompareAndMarkFilterNodesL() end: EFalse"); |
|
439 return EFalse; |
|
440 } |
|
441 else if ( !filterCheck1 && filterCheck2 |
|
442 || aNode1.Base().Importance() < aNode2.Base().Importance() |
|
443 || ( aNode1.Base().Importance() == aNode2.Base().Importance() |
|
444 && aNode1.Base().Name().CompareC( aNode2.Base().Name() ) > 0 ) ) |
|
445 { |
|
446 // Node2 should be before Node1. |
|
447 // Notice, that when comparing the node names, the comparison is thought |
|
448 // case-insensitive. Also, CompareC is used instead of CompareF because CompareC |
|
449 // uses collation method for narrow text appropriate to the current locale. CompareF |
|
450 // would be locale-independent behaviour. |
|
451 IAUPDATE_TRACE("[IAUPDATE] CIAUpdateNodeFilter::CompareAndMarkFilterNodesL() end: ETrue"); |
|
452 return ETrue; |
|
453 } |
|
454 else |
|
455 { |
|
456 // Node1 should be before Node2. |
|
457 IAUPDATE_TRACE("[IAUPDATE] CIAUpdateNodeFilter::CompareAndMarkFilterNodesL() end: EFalse"); |
|
458 return EFalse; |
|
459 } |
|
460 } |
|
461 |
|
462 |
|
463 // ----------------------------------------------------------------------------- |
|
464 // CIAUpdateNodeFilter::MarkFilterNodeL |
|
465 // |
|
466 // ----------------------------------------------------------------------------- |
|
467 // |
|
468 TBool CIAUpdateNodeFilter::MarkFilterNodeL( |
|
469 MIAUpdateNode& aNode, |
|
470 const TUid& aPackageUid ) |
|
471 { |
|
472 IAUPDATE_TRACE("[IAUPDATE] CIAUpdateNodeFilter::MarkFilterNodeL() begin"); |
|
473 |
|
474 // This describes if the node matches the filter parameter. |
|
475 TBool filterCheck( EFalse ); |
|
476 |
|
477 if ( iFilterParams ) |
|
478 { |
|
479 // Notice, that when filtering was started the UID check was also done. |
|
480 // So, if the SID was given and it did not result to any matches, |
|
481 // then the filter UID was changed to corresponding package UID if |
|
482 // it was possible. |
|
483 |
|
484 // Notice, that if UID is given then use it for filtering. |
|
485 // If UID is not given, then use search criteria if it is given. |
|
486 if ( aPackageUid != TUid::Null() ) |
|
487 { |
|
488 // Because uid was given, filter by using that value |
|
489 if ( aPackageUid == aNode.Base().Uid() ) |
|
490 { |
|
491 // Because this matches the filter, set the node as selected |
|
492 aNode.Base().SetSelected( ETrue ); |
|
493 filterCheck = ETrue; |
|
494 } |
|
495 else if ( FilterCheckForServicePackL( aNode, aPackageUid, iFilterParams->SearchCriteria() ) ) |
|
496 { |
|
497 aNode.Base().SetSelected( ETrue ); |
|
498 filterCheck = ETrue; |
|
499 } |
|
500 } |
|
501 else if ( iFilterParams->SearchCriteria() != KNullDesC() ) |
|
502 { |
|
503 // Because search criteria was given, use it for filtering |
|
504 if ( SearchCriteriaMatches( iFilterParams->SearchCriteria(), aNode.Base().SearchCriteria() ) ) |
|
505 { |
|
506 // Because this matches the filter, set the node as selected |
|
507 aNode.Base().SetSelected( ETrue ); |
|
508 filterCheck = ETrue; |
|
509 } |
|
510 else if ( FilterCheckForServicePackL( aNode, aPackageUid, iFilterParams->SearchCriteria() ) ) |
|
511 { |
|
512 aNode.Base().SetSelected( ETrue ); |
|
513 filterCheck = ETrue; |
|
514 } |
|
515 } |
|
516 |
|
517 // If the node did not match the filter parameter, it should not be selected. |
|
518 // unless it is a mandatory node |
|
519 if ( !filterCheck ) |
|
520 { |
|
521 if ( aNode.Base().Importance() == MIAUpdateBaseNode::EMandatory ) |
|
522 { |
|
523 //if the node importance is mandatory, then select it eventhough it doesn't match |
|
524 //the filter |
|
525 |
|
526 //here only handle the case of normal packages. For the case of firmware available, it will be |
|
527 //handled in ui controller |
|
528 aNode.Base().SetSelected( ETrue ); |
|
529 } |
|
530 else |
|
531 { |
|
532 // Set node as not selected. |
|
533 // Just in case the filter has changed but node has remained, |
|
534 // since last time. |
|
535 |
|
536 aNode.Base().SetSelected( EFalse ); |
|
537 } |
|
538 } |
|
539 } |
|
540 else |
|
541 { |
|
542 // Filtering is not on. Set as selected unless importance is ENormal. |
|
543 if ( aNode.Base().Importance() == MIAUpdateBaseNode::ENormal ) |
|
544 { |
|
545 aNode.Base().SetSelected( EFalse ); |
|
546 } |
|
547 else |
|
548 { |
|
549 aNode.Base().SetSelected( ETrue ); |
|
550 } |
|
551 } |
|
552 |
|
553 IAUPDATE_TRACE_1("[IAUPDATE] CIAUpdateNodeFilter::MarkFilterNodeL() end: %d", |
|
554 filterCheck); |
|
555 |
|
556 return filterCheck; |
|
557 } |
|
558 |
|
559 // ----------------------------------------------------------------------------- |
|
560 // CIAUpdateNodeFilter::FilteredByImportance |
|
561 // |
|
562 // ----------------------------------------------------------------------------- |
|
563 // |
|
564 TBool CIAUpdateNodeFilter::FilteredByImportance() const |
|
565 { |
|
566 return !( iFilterParams->Importance() & CIAUpdateParameters::ENormal && |
|
567 iFilterParams->Importance() & CIAUpdateParameters::ERecommended && |
|
568 iFilterParams->Importance() & CIAUpdateParameters::ECritical && |
|
569 iFilterParams->Importance() & CIAUpdateParameters::EMandatory && |
|
570 iFilterParams->Importance() & CIAUpdateParameters::EHidden); |
|
571 } |
|
572 |
|
573 // ----------------------------------------------------------------------------- |
|
574 // CIAUpdateNodeFilter::ImportanceMatches |
|
575 // |
|
576 // ----------------------------------------------------------------------------- |
|
577 // |
|
578 TBool CIAUpdateNodeFilter::ImportanceMatches( MIAUpdateNode& aNode ) const |
|
579 { |
|
580 IAUPDATE_TRACE("[IAUPDATE] CIAUpdateNodeFilter::ImportanceMatches() begin"); |
|
581 TBool matches( EFalse); |
|
582 if ( aNode.NodeType() == MIAUpdateAnyNode::ENodeTypeNormal && iFilterParams ) |
|
583 { |
|
584 IAUPDATE_TRACE_1("[IAUPDATE] CIAUpdateNodeFilter::ImportanceMatches() importance: %d", aNode.Base().Importance() ); |
|
585 switch( aNode.Base().Importance() ) |
|
586 { |
|
587 case MIAUpdateBaseNode::ENormal: |
|
588 if ( iFilterParams->Importance() & CIAUpdateParameters::ENormal ) |
|
589 { |
|
590 matches = ETrue; |
|
591 } |
|
592 break; |
|
593 case MIAUpdateBaseNode::ERecommended: |
|
594 if ( iFilterParams->Importance() & CIAUpdateParameters::ERecommended ) |
|
595 { |
|
596 matches = ETrue; |
|
597 } |
|
598 break; |
|
599 case MIAUpdateBaseNode::ECritical: |
|
600 if ( iFilterParams->Importance() & CIAUpdateParameters::ECritical ) |
|
601 { |
|
602 matches = ETrue; |
|
603 } |
|
604 break; |
|
605 case MIAUpdateBaseNode::EMandatory: |
|
606 if ( iFilterParams->Importance() & CIAUpdateParameters::EMandatory ) |
|
607 { |
|
608 matches = ETrue; |
|
609 } |
|
610 break; |
|
611 case MIAUpdateBaseNode::EHidden: |
|
612 if ( iFilterParams->Importance() & CIAUpdateParameters::EHidden ) |
|
613 { |
|
614 matches = ETrue; |
|
615 } |
|
616 break; |
|
617 default: |
|
618 break; |
|
619 } |
|
620 } |
|
621 else |
|
622 { |
|
623 // firmware updates are not filtered by importance |
|
624 matches = ETrue; |
|
625 } |
|
626 IAUPDATE_TRACE_1("[IAUPDATE] CIAUpdateNodeFilter::ImportanceMatches() end, matches: %d", matches); |
|
627 return matches; |
|
628 } |
|
629 |
|
630 // ----------------------------------------------------------------------------- |
|
631 // CIAUpdateNodeFilter::DMSupportL(); |
|
632 // |
|
633 // ----------------------------------------------------------------------------- |
|
634 // |
|
635 TBool CIAUpdateNodeFilter::DMSupportL() |
|
636 { |
|
637 if ( !iDmSupportAsked ) |
|
638 { |
|
639 TInt err = RProperty::Get( KUidSystemCategory, KIAUpdateUiUid, iDmSupport ); |
|
640 |
|
641 if ( err != KErrNone ) |
|
642 { |
|
643 if ( err == KErrNotFound ) |
|
644 { |
|
645 IAUPDATE_TRACE("[IAUPDATE] CIAUpdateNodeFilter::DMSupportL() DM support is not defined in P&S"); |
|
646 |
|
647 CIAUpdateFWUpdateHandler* fw = CIAUpdateFWUpdateHandler::NewL(); |
|
648 CleanupStack::PushL( fw ); |
|
649 TBool isDMSupported = fw->IsDMSupportAvailableL(); |
|
650 |
|
651 if ( isDMSupported ) |
|
652 { |
|
653 IAUPDATE_TRACE("[IAUPDATE] CIAUpdateNodeFilter::DMSupportL() DM is supported"); |
|
654 } |
|
655 |
|
656 TBool FWEnable = EFalse; |
|
657 CRepository* cenrep = CRepository::NewL( KCRUidIAUpdateSettings ); |
|
658 CleanupStack::PushL( cenrep ); |
|
659 err = cenrep->Get( KIAUpdateEnableFWFeature, FWEnable ); |
|
660 |
|
661 if ( err != KErrNone ) |
|
662 { |
|
663 IAUPDATE_TRACE("[IAUPDATE] CIAUpdateNodeFilter::DMSupportL() Cenrep failed"); |
|
664 } |
|
665 |
|
666 if ( FWEnable ) |
|
667 { |
|
668 IAUPDATE_TRACE("[IAUPDATE] CIAUpdateNodeFilter::DMSupportL() firmware feature enabled"); |
|
669 } |
|
670 else |
|
671 { |
|
672 IAUPDATE_TRACE("[IAUPDATE] CIAUpdateNodeFilter::DMSupportL() firmware feature disabled"); |
|
673 isDMSupported = EFalse; |
|
674 } |
|
675 |
|
676 CleanupStack::PopAndDestroy( 2 ); //fwhandle, cenrep |
|
677 |
|
678 TSecureId secureid( KIAUpdateUiUid ); |
|
679 const TSecurityPolicy readPolicy (secureid); |
|
680 const TSecurityPolicy writePolicy (secureid); |
|
681 |
|
682 // define first property to be integer type |
|
683 err = RProperty::Define( KUidSystemCategory, KIAUpdateUiUid, RProperty::EInt, readPolicy, writePolicy ); |
|
684 |
|
685 IAUPDATE_TRACE_1("[IAUPDATE] CIAUpdateNodeFilter::DMSupportL() define P&S err = %d", err ); |
|
686 |
|
687 err = RProperty::Set( KUidSystemCategory, KIAUpdateUiUid, isDMSupported ); |
|
688 IAUPDATE_TRACE_1("[IAUPDATE] CIAUpdateNodeFilter::DMSupportL() Set P&S err = %d", err ); |
|
689 |
|
690 iDmSupport = isDMSupported; |
|
691 } |
|
692 else |
|
693 { |
|
694 iDmSupport = EFalse; |
|
695 } |
|
696 } |
|
697 |
|
698 iDmSupportAsked = ETrue; |
|
699 } |
|
700 return iDmSupport; |
|
701 } |
|
702 |
|
703 |
|
704 // ----------------------------------------------------------------------------- |
|
705 // CIAUpdateNodeFilter::PackageUidL |
|
706 // |
|
707 // ----------------------------------------------------------------------------- |
|
708 // |
|
709 TUid CIAUpdateNodeFilter::PackageUidL( |
|
710 const RPointerArray< MIAUpdateNode >& aNodes ) |
|
711 { |
|
712 IAUPDATE_TRACE("[IAUPDATE] CIAUpdateNodeFilter::PackageUidL() begin"); |
|
713 |
|
714 TUid retUid( TUid::Null() ); |
|
715 |
|
716 if ( !iFilterParams ) |
|
717 { |
|
718 IAUPDATE_TRACE("[IAUPDATE] CIAUpdateNodeFilter::PackageUidL() end. No filter set. Return null uid."); |
|
719 return retUid; |
|
720 } |
|
721 |
|
722 if ( iFilterParams->Uid() == TUid::Null() ) |
|
723 { |
|
724 IAUPDATE_TRACE("[IAUPDATE] CIAUpdateNodeFilter::PackageUidL() end. Parameter UID set is to null"); |
|
725 return iFilterParams->Uid(); |
|
726 } |
|
727 |
|
728 retUid = iFilterParams->Uid(); |
|
729 |
|
730 IAUPDATE_TRACE("[IAUPDATE] CIAUpdateNodeFilter::PackageUidL() Parameter UID value given."); |
|
731 |
|
732 // UID value was given. |
|
733 // So, filter nodes. |
|
734 TBool uidMatches = EFalse; |
|
735 for ( TInt i = 0; i < aNodes.Count() && !uidMatches ; ++i ) |
|
736 { |
|
737 if ( ImportanceMatches( *aNodes[ i ] ) ) |
|
738 { |
|
739 // If UID was given, filter by using UID. |
|
740 // If UID was not given, filter by using search criteria. |
|
741 |
|
742 if ( retUid == aNodes[ i ]->Base().Uid() ) |
|
743 { |
|
744 IAUPDATE_TRACE("[IAUPDATE] CIAUpdateNodeFilter::PackageUidL() Filter parameter UID matched the node"); |
|
745 uidMatches = ETrue; |
|
746 } |
|
747 } |
|
748 } |
|
749 |
|
750 if ( !uidMatches ) |
|
751 { |
|
752 IAUPDATE_TRACE("[IAUPDATE] CIAUpdateNodeFilter::PackageUidL() Uid did not match. Is it SID?"); |
|
753 // Uid did not match to anything in the list. |
|
754 // Maybe it was not a package UID but SID. |
|
755 // So, check if we can find out the package UID and use it. |
|
756 TUid newUid( |
|
757 IAUpdateUtils::AppPackageUidL( retUid ) ); |
|
758 IAUPDATE_TRACE_2("[IAUPDATE] CIAUpdateNodeFilter::PackageUidL() NewUid: %d, Old uid: %d", |
|
759 newUid.iUid, retUid.iUid); |
|
760 if ( newUid != TUid::Null() && newUid != retUid ) |
|
761 { |
|
762 IAUPDATE_TRACE("[IAUPDATE] CIAUpdateNodeFilter::PackageUidL() New UID found."); |
|
763 // It was SID but now we know pUID. |
|
764 // So, retry the search. |
|
765 for ( TInt i = 0; i < aNodes.Count() && !uidMatches ; ++i ) |
|
766 { |
|
767 if ( newUid == aNodes[ i ]->Base().Uid() && ImportanceMatches( *aNodes[ i ] ) ) |
|
768 { |
|
769 IAUPDATE_TRACE("[IAUPDATE] CIAUpdateNodeFilter::PackageUidL() New UID matched."); |
|
770 // New uid matched with the node uid. |
|
771 uidMatches = ETrue; |
|
772 } |
|
773 } |
|
774 |
|
775 if ( uidMatches ) |
|
776 { |
|
777 IAUPDATE_TRACE("[IAUPDATE] CIAUpdateNodeFilter::PackageUidL() Start using new pUID."); |
|
778 // The new uid actually found something. So, the check mattered. |
|
779 // Update the retUid. So, others can use the packageUid instead of |
|
780 // SID. |
|
781 // Notice, do not update the filter params here. The old value maybe |
|
782 // used for some comparisons outside of this class. So, it should not |
|
783 // be changed. |
|
784 // Note, that FilterAndSortNodes function calls this function to get the |
|
785 // correct uid for filter. So, this setting is required for that. |
|
786 retUid = newUid; |
|
787 } |
|
788 } |
|
789 } |
|
790 |
|
791 IAUPDATE_TRACE_1("[IAUPDATE] CIAUpdateNodeFilter::PackageUidL( end UID: %d", retUid); |
|
792 |
|
793 return retUid; |
|
794 } |
|
795 |
|
796 |
|
797 // ----------------------------------------------------------------------------- |
|
798 // CIAUpdateNodeFilter::FilterCheckForServicePackL |
|
799 // |
|
800 // ----------------------------------------------------------------------------- |
|
801 // |
|
802 TBool CIAUpdateNodeFilter::FilterCheckForServicePackL( const MIAUpdateNode& aNode, |
|
803 const TUid& aPUid, |
|
804 const TDesC& aSearchCriteria ) |
|
805 { |
|
806 IAUPDATE_TRACE("[IAUPDATE] CIAUpdateNodeFilter::FilterCheckForServicePackL() begin"); |
|
807 TBool filterCheck = EFalse; |
|
808 if ( aNode.Type() == MIAUpdateNode::EPackageTypeServicePack ) |
|
809 { |
|
810 RPointerArray<MIAUpdateNode> dependencies; |
|
811 CleanupClosePushL( dependencies ); |
|
812 aNode.GetDependenciesL( dependencies, ETrue ); |
|
813 for ( TInt i = 0; i < dependencies.Count() && !filterCheck; ++i ) |
|
814 { |
|
815 if ( !dependencies[ i ]->IsInstalled() ) |
|
816 { |
|
817 if ( aPUid != TUid::Null() ) |
|
818 { |
|
819 if ( aPUid == dependencies[ i ]->Base().Uid() ) |
|
820 { |
|
821 filterCheck = ETrue; |
|
822 } |
|
823 } |
|
824 else if ( aSearchCriteria != KNullDesC() ) |
|
825 { |
|
826 if ( SearchCriteriaMatches( aSearchCriteria, dependencies[ i ]->Base().SearchCriteria() ) ) |
|
827 { |
|
828 filterCheck = ETrue; |
|
829 } |
|
830 } |
|
831 } |
|
832 |
|
833 CleanupStack::PopAndDestroy( &dependencies ); |
|
834 } |
|
835 } |
|
836 IAUPDATE_TRACE("[IAUPDATE] CIAUpdateNodeFilter::FilterCheckForServicePackL() end"); |
|
837 return filterCheck; |
|
838 } |
|
839 |
|
840 // ----------------------------------------------------------------------------- |
|
841 // CIAUpdateNodeFilter::SearchCriteriaMatches |
|
842 // |
|
843 // ----------------------------------------------------------------------------- |
|
844 // |
|
845 TBool CIAUpdateNodeFilter::SearchCriteriaMatches( const TDesC& aParamSearchCriteria, |
|
846 const TDesC& aNodeSearchCriteria ) const |
|
847 { |
|
848 TBool matches = EFalse; |
|
849 if ( aNodeSearchCriteria.Length() >= aParamSearchCriteria.Length() ) |
|
850 { |
|
851 matches = aParamSearchCriteria == aNodeSearchCriteria.Mid( 0, aParamSearchCriteria.Length() ); |
|
852 } |
|
853 return matches; |
|
854 } |