|
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 implementation of CIAUpdateMainView class |
|
15 * member functions. |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 |
|
21 #include <eikmenup.h> |
|
22 #include <aknViewAppUi.h> |
|
23 #include <akntitle.h> |
|
24 #include <aknnavi.h> // CAknNavigationControlContainer |
|
25 #include <aknnavide.h> // CAknNavigationDecorator |
|
26 #include <AknUtils.h> |
|
27 #include <aknmessagequerydialog.h> // CAknMessageQueryDialog |
|
28 #include <akntoolbar.h> |
|
29 #include <StringLoader.h> |
|
30 #include <featmgr.h> |
|
31 #include <iaupdate.rsg> |
|
32 |
|
33 #include "iaupdate.hrh" |
|
34 #include "iaupdatemainview.h" |
|
35 #include "iaupdatemaincontainer.h" |
|
36 #include "iaupdatenode.h" |
|
37 #include "iaupdatefwnode.h" |
|
38 #include "iaupdatebasenode.h" |
|
39 #include "iaupdatedialogutil.h" |
|
40 #include "iaupdatestatusdialog.h" |
|
41 #include "iaupdateappui.h" |
|
42 #include "iaupdateuicontroller.h" |
|
43 #include "iaupdatedeputils.h" |
|
44 #include "iaupdatedebug.h" |
|
45 #include "iaupdatefwupdatehandler.h" |
|
46 |
|
47 //CONSTANTS |
|
48 const TInt KKiloByte = 1024; |
|
49 const TInt KMegaByte = 1024 * 1024; |
|
50 const TInt KMaxShownInKiloBytes = 10 * KMegaByte; |
|
51 const TInt KSelInfoArrayGranularity = 3; |
|
52 |
|
53 //MACROS |
|
54 _LIT( KSpace, " " ); |
|
55 |
|
56 // ============================ MEMBER FUNCTIONS =============================== |
|
57 |
|
58 |
|
59 |
|
60 // ----------------------------------------------------------------------------- |
|
61 // CIAUpdateMainView::NewL |
|
62 // Two-phased constructor. |
|
63 // ----------------------------------------------------------------------------- |
|
64 // |
|
65 CIAUpdateMainView* CIAUpdateMainView::NewL( const TRect& aRect ) |
|
66 { |
|
67 CIAUpdateMainView* self = CIAUpdateMainView::NewLC( aRect ); |
|
68 CleanupStack::Pop(self); |
|
69 return self; |
|
70 } |
|
71 |
|
72 // ----------------------------------------------------------------------------- |
|
73 // CIAUpdateMainView::NewLC |
|
74 // |
|
75 // ----------------------------------------------------------------------------- |
|
76 // |
|
77 CIAUpdateMainView* CIAUpdateMainView::NewLC( const TRect& aRect ) |
|
78 { |
|
79 CIAUpdateMainView* self = new (ELeave) CIAUpdateMainView(); |
|
80 CleanupStack::PushL( self ); |
|
81 self->ConstructL( aRect ); |
|
82 return self; |
|
83 } |
|
84 |
|
85 // ----------------------------------------------------------------------------- |
|
86 // CIAUpdateMainView::CIAUpdateMainView |
|
87 // C++ default constructor can NOT contain any code, that |
|
88 // might leave. |
|
89 // ----------------------------------------------------------------------------- |
|
90 // |
|
91 CIAUpdateMainView::CIAUpdateMainView() |
|
92 { |
|
93 } |
|
94 |
|
95 // ----------------------------------------------------------------------------- |
|
96 // CIAUpdateMainView::~CIAUpdateMainView |
|
97 // Destructor |
|
98 // ----------------------------------------------------------------------------- |
|
99 // |
|
100 CIAUpdateMainView::~CIAUpdateMainView() |
|
101 { |
|
102 delete iDecorator; |
|
103 iAllNodes.Close(); |
|
104 if ( iContainer ) |
|
105 { |
|
106 AppUi()->RemoveFromStack( iContainer ); |
|
107 delete iContainer; |
|
108 } |
|
109 delete iFwUpdateHandler; |
|
110 } |
|
111 // ----------------------------------------------------------------------------- |
|
112 // CIAUpdateMainView::ConstructL |
|
113 // Symbian 2nd phase constructor can leave. |
|
114 // ----------------------------------------------------------------------------- |
|
115 // |
|
116 void CIAUpdateMainView::ConstructL( const TRect& /*aRect*/ ) |
|
117 { |
|
118 BaseConstructL( R_IAUPDATE_MAIN_VIEW ); |
|
119 Toolbar()->SetItemDimmed( EIAUpdateCmdStartUpdate, ETrue, ETrue ); |
|
120 Toolbar()->SetItemDimmed( EIAUpdateCmdMarkedUpdateDetails, ETrue, ETrue ); |
|
121 Toolbar()->SetItemDimmed( EIAUpdateCmdUpdateHistory, ETrue, ETrue ); |
|
122 Toolbar()->SetToolbarObserver( this ); |
|
123 iFwUpdateHandler = CIAUpdateFWUpdateHandler::NewL(); |
|
124 } |
|
125 |
|
126 // ----------------------------------------------------------------------------- |
|
127 // CIAUpdateMainView::RefreshL |
|
128 // Refreshes update list |
|
129 // ----------------------------------------------------------------------------- |
|
130 // |
|
131 void CIAUpdateMainView::RefreshL( const RPointerArray<MIAUpdateNode>& aNodes, |
|
132 const RPointerArray<MIAUpdateFwNode>& aFwNodes, |
|
133 TInt aError ) |
|
134 { |
|
135 IAUPDATE_TRACE("[IAUPDATE] CIAUpdateMainView::RefreshL begin"); |
|
136 iRefreshError = aError; |
|
137 iAllNodes.Reset(); |
|
138 |
|
139 if ( aFwNodes.Count() > 0 ) |
|
140 { |
|
141 IAUPDATE_TRACE("[IAUPDATE] CIAUpdateMainView::RefreshL hard code importance"); |
|
142 //hardcode the importance of firmware as Critical |
|
143 for ( TInt i = 0; i < aFwNodes.Count(); i++ ) |
|
144 { |
|
145 aFwNodes[i]->Base().SetImportance( MIAUpdateBaseNode::ECritical ); |
|
146 } |
|
147 |
|
148 //either NSU or FOTA available |
|
149 if ( aFwNodes.Count() == 1 ) |
|
150 { |
|
151 IAUPDATE_TRACE("[IAUPDATE] CIAUpdateMainView::RefreshL either NSU or FOTA available"); |
|
152 MIAUpdateAnyNode* node = aFwNodes[0]; |
|
153 User::LeaveIfError( iAllNodes.Append( node ) ); |
|
154 } |
|
155 |
|
156 //both NSU and FOTA available, show only FOTA node |
|
157 if ( aFwNodes.Count() == 2 ) |
|
158 { |
|
159 IAUPDATE_TRACE("[IAUPDATE] CIAUpdateMainView::RefreshL both NSU and FOTA available"); |
|
160 MIAUpdateAnyNode* node1 = aFwNodes[0]; |
|
161 MIAUpdateFwNode* fwnode = static_cast<MIAUpdateFwNode*>( node1 ); |
|
162 if ( fwnode->FwType() == MIAUpdateFwNode::EFotaDp2 ) |
|
163 { |
|
164 User::LeaveIfError( iAllNodes.Append( node1 ) ); |
|
165 } |
|
166 else |
|
167 { |
|
168 MIAUpdateAnyNode* node2 = aFwNodes[1]; |
|
169 User::LeaveIfError( iAllNodes.Append( node2 ) ); |
|
170 } |
|
171 } |
|
172 } |
|
173 |
|
174 |
|
175 for( TInt i = 0; i < aNodes.Count(); ++i ) |
|
176 { |
|
177 MIAUpdateAnyNode* node = aNodes[i]; |
|
178 User::LeaveIfError( iAllNodes.Append( node ) ); |
|
179 } |
|
180 |
|
181 if( iContainer ) |
|
182 { |
|
183 iContainer->RefreshL( iAllNodes, iRefreshError ); |
|
184 SetSelectedIndicesL(); |
|
185 DynInitToolbarL( R_IAUPDATE_MAIN_TOOLBAR, Toolbar() ); |
|
186 } |
|
187 Toolbar()->SetItemDimmed( EIAUpdateCmdUpdateHistory, EFalse, ETrue ); |
|
188 } |
|
189 |
|
190 |
|
191 // ----------------------------------------------------------------------------- |
|
192 // CIAUpdateMainView::GetCurrentNode |
|
193 // |
|
194 // ----------------------------------------------------------------------------- |
|
195 // |
|
196 MIAUpdateAnyNode* CIAUpdateMainView::GetCurrentNode() |
|
197 { |
|
198 if ( iContainer ) |
|
199 { |
|
200 return iContainer->GetCurrentNode( iAllNodes ); |
|
201 } |
|
202 return NULL; |
|
203 } |
|
204 |
|
205 // ----------------------------------------------------------------------------- |
|
206 // CIAUpdateMainView::GetSelectedNode |
|
207 // |
|
208 // ----------------------------------------------------------------------------- |
|
209 // |
|
210 MIAUpdateAnyNode* CIAUpdateMainView::GetSelectedNode() |
|
211 { |
|
212 MIAUpdateAnyNode* selectedNode = NULL; |
|
213 for( TInt i = 0; i < iAllNodes.Count() && !selectedNode ; ++i ) |
|
214 { |
|
215 if ( iAllNodes[i]->Base().IsSelected() ) |
|
216 { |
|
217 selectedNode = iAllNodes[i]; |
|
218 } |
|
219 } |
|
220 return selectedNode; |
|
221 } |
|
222 |
|
223 // ----------------------------------------------------------------------------- |
|
224 // CIAUpdateMainView::Id |
|
225 // Get Uid of this view |
|
226 // ----------------------------------------------------------------------------- |
|
227 // |
|
228 TUid CIAUpdateMainView::Id() const |
|
229 { |
|
230 return TUid::Uid( EIAUpdateMainViewId ); |
|
231 } |
|
232 |
|
233 // ----------------------------------------------------------------------------- |
|
234 // CIAUpdateMainView::HandleCommandL |
|
235 // |
|
236 // ----------------------------------------------------------------------------- |
|
237 // |
|
238 void CIAUpdateMainView::HandleCommandL( TInt aCommand ) |
|
239 { |
|
240 switch( aCommand ) |
|
241 { |
|
242 case EIAUpdateCmdStartUpdate: |
|
243 { |
|
244 RPointerArray<MIAUpdateAnyNode> selectedNodes; |
|
245 CleanupClosePushL( selectedNodes ); |
|
246 GetSelectedNodesL( selectedNodes ); |
|
247 if ( selectedNodes[0]->NodeType() == MIAUpdateAnyNode::ENodeTypeFw ) |
|
248 { |
|
249 //the marking logic will make sure firmware won't be marked with normal sis updates |
|
250 //at the same time. |
|
251 iFwUpdateHandler->FirmWareUpdatewithFOTA(); |
|
252 } |
|
253 else |
|
254 { |
|
255 AppUi()->HandleCommandL( aCommand ); |
|
256 } |
|
257 CleanupStack::PopAndDestroy( &selectedNodes ); |
|
258 break; |
|
259 } |
|
260 case EIAUpdateCmdUpdateWithPC: |
|
261 { |
|
262 iFwUpdateHandler->FirmWareUpdatewithNSU(); |
|
263 break; |
|
264 } |
|
265 case EIAUpdateCmdSettings: |
|
266 { |
|
267 Toolbar()->SetToolbarVisibility( EFalse ); |
|
268 AppUi()->HandleCommandL( aCommand ); |
|
269 Toolbar()->SetToolbarVisibility( ETrue ); |
|
270 break; |
|
271 } |
|
272 case EAknSoftkeyMark: |
|
273 { |
|
274 iContainer->HandleMarkCommandL( EAknCmdMark ); |
|
275 break; |
|
276 } |
|
277 case EAknSoftkeyUnmark: |
|
278 { |
|
279 iContainer->HandleMarkCommandL( EAknCmdUnmark ); |
|
280 break; |
|
281 } |
|
282 case EAknCmdMark: |
|
283 case EAknCmdUnmark: |
|
284 { |
|
285 iContainer->HandleMarkCommandL( aCommand ); |
|
286 break; |
|
287 } |
|
288 default: |
|
289 { |
|
290 AppUi()->HandleCommandL( aCommand ); |
|
291 break; |
|
292 } |
|
293 } |
|
294 } |
|
295 |
|
296 // ----------------------------------------------------------------------------- |
|
297 // CIAUpdateMainView::DynInitMenuPaneL |
|
298 // Dim options which are not availble in empty list. |
|
299 // Set Mark/Unmark option |
|
300 // ----------------------------------------------------------------------------- |
|
301 // |
|
302 void CIAUpdateMainView::DynInitMenuPaneL( TInt aResourceId, CEikMenuPane* aMenuPane ) |
|
303 { |
|
304 if( aResourceId == R_IAUPDATE_MAIN_MENU ) |
|
305 { |
|
306 if ( !FeatureManager::FeatureSupported( KFeatureIdHelp ) ) |
|
307 { |
|
308 aMenuPane->SetItemDimmed( EAknCmdHelp, ETrue ); |
|
309 } |
|
310 RPointerArray<MIAUpdateAnyNode> selectedNodes; |
|
311 CleanupClosePushL( selectedNodes ); |
|
312 GetSelectedNodesL( selectedNodes ); |
|
313 |
|
314 if ( selectedNodes.Count() ) |
|
315 { |
|
316 if ( selectedNodes[0]->NodeType() == MIAUpdateAnyNode::ENodeTypeFw ) |
|
317 { |
|
318 //firmware is selected |
|
319 MIAUpdateFwNode* node = static_cast<MIAUpdateFwNode*>( selectedNodes[0] ); |
|
320 |
|
321 if ( node->FwType() == MIAUpdateFwNode::EFotaDp2 ) |
|
322 { |
|
323 aMenuPane->SetItemDimmed( EIAUpdateCmdUpdateWithPC, ETrue ); |
|
324 } |
|
325 |
|
326 if ( node->FwType() == MIAUpdateFwNode::EFotiNsu ) |
|
327 { |
|
328 aMenuPane->SetItemDimmed( EIAUpdateCmdStartUpdate, ETrue ); |
|
329 } |
|
330 } |
|
331 else |
|
332 { |
|
333 //firmware is not selected, only sis |
|
334 aMenuPane->SetItemDimmed( EIAUpdateCmdUpdateWithPC, ETrue ); |
|
335 } |
|
336 } |
|
337 else |
|
338 { |
|
339 aMenuPane->SetItemDimmed( EIAUpdateCmdStartUpdate, ETrue ); |
|
340 aMenuPane->SetItemDimmed( EIAUpdateCmdUpdateWithPC, ETrue ); |
|
341 } |
|
342 CleanupStack::PopAndDestroy( &selectedNodes ); |
|
343 } |
|
344 } |
|
345 |
|
346 // ----------------------------------------------------------------------------- |
|
347 // CIAUpdateMainView::DoActivateL |
|
348 // Activate view |
|
349 // ----------------------------------------------------------------------------- |
|
350 // |
|
351 void CIAUpdateMainView::DoActivateL( const TVwsViewId& /*aPrevViewId*/, |
|
352 TUid /*aCustomMessageId*/, |
|
353 const TDesC8& /*aCustomMessage*/ ) |
|
354 { |
|
355 UpdateStatusPaneL(); |
|
356 if( !iContainer ) |
|
357 { |
|
358 iContainer = CIAUpdateMainContainer::NewL( ClientRect(), *this ); |
|
359 |
|
360 if( iAllNodes.Count() > 0 ) |
|
361 { |
|
362 iContainer->RefreshL( iAllNodes, iRefreshError ); |
|
363 } |
|
364 |
|
365 SetSelectedIndicesL(); |
|
366 DynInitToolbarL( R_IAUPDATE_MAIN_TOOLBAR, Toolbar() ); |
|
367 AppUi()->AddToStackL( iContainer ); |
|
368 } |
|
369 else |
|
370 { |
|
371 UpdateSelectionInfoInNaviPaneL(); |
|
372 } |
|
373 } |
|
374 |
|
375 // ----------------------------------------------------------------------------- |
|
376 // CIAUpdateMainView::DoDeactivate() |
|
377 // Container is deleted in deactivation |
|
378 // ----------------------------------------------------------------------------- |
|
379 // |
|
380 void CIAUpdateMainView::DoDeactivate() |
|
381 { |
|
382 RemoveSelectionInfoInNaviPane(); |
|
383 } |
|
384 |
|
385 // ----------------------------------------------------------------------------- |
|
386 // CIAUpdateMainView::DynInitToolbarL() |
|
387 // |
|
388 // ----------------------------------------------------------------------------- |
|
389 // |
|
390 void CIAUpdateMainView::DynInitToolbarL( TInt aResourceId, CAknToolbar* aToolbar ) |
|
391 { |
|
392 if ( aResourceId == R_IAUPDATE_MAIN_TOOLBAR ) |
|
393 { |
|
394 if ( iContainer ) |
|
395 { |
|
396 if ( CountOfSelectedItems() > 0 ) |
|
397 { |
|
398 aToolbar->SetItemDimmed( EIAUpdateCmdStartUpdate, EFalse, ETrue ); |
|
399 } |
|
400 else |
|
401 { |
|
402 aToolbar->SetItemDimmed( EIAUpdateCmdStartUpdate, ETrue, ETrue ); |
|
403 } |
|
404 if ( CountOfSelectedItems() == 1 ) |
|
405 { |
|
406 aToolbar->SetItemDimmed( EIAUpdateCmdMarkedUpdateDetails, EFalse, ETrue ); |
|
407 } |
|
408 else |
|
409 { |
|
410 aToolbar->SetItemDimmed( EIAUpdateCmdMarkedUpdateDetails, ETrue, ETrue ); |
|
411 } |
|
412 } |
|
413 } |
|
414 } |
|
415 |
|
416 // ----------------------------------------------------------------------------- |
|
417 // CIAUpdateMainView::OfferToolbarEventL() |
|
418 // |
|
419 // ----------------------------------------------------------------------------- |
|
420 // |
|
421 void CIAUpdateMainView::OfferToolbarEventL( TInt aCommand ) |
|
422 { |
|
423 if ( aCommand == EIAUpdateCmdStartUpdate ) |
|
424 { |
|
425 RPointerArray<MIAUpdateAnyNode> selectedNodes; |
|
426 CleanupClosePushL( selectedNodes ); |
|
427 GetSelectedNodesL( selectedNodes ); |
|
428 |
|
429 if ( selectedNodes.Count() ) |
|
430 { |
|
431 if ( selectedNodes[0]->NodeType() == MIAUpdateAnyNode::ENodeTypeFw ) |
|
432 { |
|
433 //firmware is selected |
|
434 MIAUpdateFwNode* node = static_cast<MIAUpdateFwNode*>( selectedNodes[0] ); |
|
435 |
|
436 if ( node->FwType() == MIAUpdateFwNode::EFotaDp2 ) |
|
437 { |
|
438 aCommand = EIAUpdateCmdStartUpdate; |
|
439 } |
|
440 |
|
441 if ( node->FwType() == MIAUpdateFwNode::EFotiNsu ) |
|
442 { |
|
443 aCommand = EIAUpdateCmdUpdateWithPC; |
|
444 } |
|
445 } |
|
446 else |
|
447 { |
|
448 //firmware is not selected, only sis |
|
449 aCommand = EIAUpdateCmdStartUpdate; |
|
450 } |
|
451 } |
|
452 else |
|
453 { |
|
454 MIAUpdateAnyNode* currentNode = GetCurrentNode(); |
|
455 if ( currentNode->NodeType() == MIAUpdateAnyNode::ENodeTypeFw ) |
|
456 { |
|
457 MIAUpdateFwNode* node = static_cast<MIAUpdateFwNode*>( currentNode ); |
|
458 if ( node->FwType() == MIAUpdateFwNode::EFotiNsu ) |
|
459 { |
|
460 aCommand = EIAUpdateCmdUpdateWithPC; |
|
461 } |
|
462 } |
|
463 } |
|
464 |
|
465 CleanupStack::PopAndDestroy( &selectedNodes ); |
|
466 } |
|
467 HandleCommandL( aCommand ); |
|
468 } |
|
469 |
|
470 |
|
471 |
|
472 // ----------------------------------------------------------------------------- |
|
473 // CIAUpdateMainView::MarkListItemL |
|
474 // Mark list item |
|
475 // ----------------------------------------------------------------------------- |
|
476 // |
|
477 TBool CIAUpdateMainView::MarkListItemL( TBool aMark, TInt aIndex ) |
|
478 { |
|
479 if ( aMark ) |
|
480 { |
|
481 //It's Mark Command |
|
482 RPointerArray<MIAUpdateAnyNode> selectedNodes; |
|
483 CleanupClosePushL( selectedNodes ); |
|
484 GetSelectedNodesL( selectedNodes ); |
|
485 |
|
486 //There are selected items already and type are different with the current one |
|
487 if ( selectedNodes.Count() > 0 && (iAllNodes[aIndex]->NodeType() != selectedNodes[0]->NodeType() ) ) |
|
488 { |
|
489 HBufC* msgText = StringLoader::LoadLC(R_IAUPDATE_FIRMWARE_WITH_OTHERS); |
|
490 |
|
491 CAknQueryDialog* dlg = CAknQueryDialog::NewL(); |
|
492 |
|
493 dlg->ExecuteLD( R_IAUPDATE_INFORMATION_QUERY, *msgText ); |
|
494 |
|
495 CleanupStack::PopAndDestroy( msgText ); |
|
496 |
|
497 //clean all of the current selection(s) |
|
498 iContainer->CleanAllSelection(); |
|
499 |
|
500 // firmware item and normal sis items can't be selected at the same time |
|
501 // unmark the selected nodes. |
|
502 for ( TInt i = 0; i < selectedNodes.Count(); i++ ) |
|
503 { |
|
504 TInt index = iAllNodes.Find( selectedNodes[i]); |
|
505 iAllNodes[index]->Base().SetSelected( EFalse ); |
|
506 } |
|
507 } |
|
508 |
|
509 CleanupStack::PopAndDestroy( &selectedNodes ); |
|
510 } |
|
511 |
|
512 //there is no selected items or the type is the same with the current one |
|
513 |
|
514 if ( iAllNodes[aIndex]->NodeType() == MIAUpdateAnyNode::ENodeTypeFw ) |
|
515 { |
|
516 iAllNodes[aIndex]->Base().SetSelected( aMark ); |
|
517 |
|
518 if ( aMark ) |
|
519 { |
|
520 SetMiddleSKTextL( ETrue, ETrue ); |
|
521 } |
|
522 else |
|
523 { |
|
524 SetMiddleSKTextL( ETrue, EFalse ); |
|
525 } |
|
526 UpdateSelectionInfoInNaviPaneL(); |
|
527 DynInitToolbarL( R_IAUPDATE_MAIN_TOOLBAR, Toolbar() ); |
|
528 return ETrue; |
|
529 } |
|
530 |
|
531 if ( iAllNodes[aIndex]->NodeType() == MIAUpdateAnyNode::ENodeTypeNormal ) |
|
532 { |
|
533 TBool accepted = EFalse; |
|
534 |
|
535 if( aIndex > -1 ) |
|
536 { |
|
537 accepted = ETrue; |
|
538 |
|
539 MIAUpdateNode* node = static_cast<MIAUpdateNode*>( iAllNodes[aIndex] ); |
|
540 RPointerArray<MIAUpdateAnyNode> mands; |
|
541 RPointerArray<MIAUpdateNode> deps; |
|
542 |
|
543 if ( aMark ) |
|
544 { |
|
545 CleanupClosePushL( mands ); |
|
546 CleanupClosePushL( deps ); |
|
547 IAUpdateDepUtils::GetDependenciesL( *node, iAllNodes, deps ); |
|
548 GetMandatoryNodesL( mands ); |
|
549 } |
|
550 else |
|
551 { |
|
552 //mandatory item is not allowed to be unmarked |
|
553 if ( iAllNodes[aIndex]->Base().Importance() == MIAUpdateBaseNode::EMandatory ) |
|
554 { |
|
555 //show dialog |
|
556 ShowUpdateCannotOmitDialogL(); |
|
557 return EFalse; |
|
558 } |
|
559 |
|
560 CleanupClosePushL( deps ); |
|
561 IAUpdateDepUtils::GetDependantsL( *node, iAllNodes, deps ); |
|
562 // item is not allowed to be unmarked if its dependant is mandatory |
|
563 TBool mandatoryDependantFound = EFalse; |
|
564 for( TInt i = 0; i < deps.Count() && !mandatoryDependantFound; i++ ) |
|
565 { |
|
566 if ( deps[i]->Base().Importance() == MIAUpdateBaseNode::EMandatory ) |
|
567 { |
|
568 mandatoryDependantFound = ETrue; |
|
569 } |
|
570 } |
|
571 if ( mandatoryDependantFound ) |
|
572 { |
|
573 ShowUpdateCannotOmitDialogL(); |
|
574 CleanupStack::PopAndDestroy( &deps ); |
|
575 return EFalse; |
|
576 } |
|
577 } |
|
578 |
|
579 TInt depCount = deps.Count(); |
|
580 |
|
581 if ( depCount > 0 ) |
|
582 { |
|
583 HBufC* text = NULL; |
|
584 HBufC* names = NULL; |
|
585 MIAUpdateNode* depNode = NULL; |
|
586 HBufC* separator = NULL; |
|
587 |
|
588 if ( depCount > 1 ) |
|
589 { |
|
590 separator = StringLoader::LoadLC( R_IAUPDATE_SEPARATOR ); |
|
591 } |
|
592 |
|
593 names = HBufC::NewLC( 0 ); |
|
594 |
|
595 for( TInt i = 0; i < depCount; i++ ) |
|
596 { |
|
597 depNode = deps[i]; |
|
598 HBufC* temp = NULL; |
|
599 if ( separator ) |
|
600 { |
|
601 temp = names->ReAllocL( names->Length() + |
|
602 depNode->Base().Name().Length() + |
|
603 separator->Length() + |
|
604 KSpace.iTypeLength ); |
|
605 } |
|
606 else |
|
607 { |
|
608 temp = names->ReAllocL( names->Length() + |
|
609 depNode->Base().Name().Length() + |
|
610 KSpace.iTypeLength ); |
|
611 } |
|
612 |
|
613 CleanupStack::Pop( names ); |
|
614 names = temp; |
|
615 CleanupStack::PushL( names ); |
|
616 |
|
617 if ( i > 0 ) |
|
618 { |
|
619 names->Des() += *separator; |
|
620 names->Des() += KSpace; |
|
621 } |
|
622 names->Des() += depNode->Base().Name(); |
|
623 } |
|
624 |
|
625 TInt resourceId = 0; |
|
626 if ( aMark ) |
|
627 { |
|
628 if ( depCount > 1 ) |
|
629 { |
|
630 resourceId = R_IAUPDATE_DEPENDENCY_MARK_MANY; |
|
631 } |
|
632 else |
|
633 { |
|
634 resourceId = R_IAUPDATE_DEPENDENCY_MARK_ONE; |
|
635 } |
|
636 } |
|
637 else |
|
638 { |
|
639 if ( depCount > 1 ) |
|
640 { |
|
641 resourceId = R_IAUPDATE_DEPENDENCY_UNMARK_MANY; |
|
642 } |
|
643 else |
|
644 { |
|
645 resourceId = R_IAUPDATE_DEPENDENCY_UNMARK_ONE; |
|
646 } |
|
647 } |
|
648 text = StringLoader::LoadLC( resourceId, *names ); |
|
649 |
|
650 if ( aMark && iAllNodes[aIndex]->Base().Importance() == MIAUpdateBaseNode::EMandatory ) |
|
651 { |
|
652 // depencencies of mandatory update are also selected without showing dialog |
|
653 accepted = ETrue; |
|
654 } |
|
655 else |
|
656 { |
|
657 accepted = ShowDependenciesFoundDialogL( *text ); |
|
658 } |
|
659 CleanupStack::PopAndDestroy( text ); |
|
660 CleanupStack::PopAndDestroy( names ); |
|
661 |
|
662 if ( separator ) |
|
663 { |
|
664 CleanupStack::PopAndDestroy( separator ); |
|
665 } |
|
666 } |
|
667 |
|
668 if ( accepted ) |
|
669 { |
|
670 for( TInt j = 0; j < depCount; j++ ) |
|
671 { |
|
672 TInt depNodeInd = iAllNodes.Find( deps[j] ); |
|
673 iAllNodes[depNodeInd]->Base().SetSelected( aMark ); |
|
674 } |
|
675 CleanupStack::PopAndDestroy( &deps ); |
|
676 |
|
677 TInt nodeInd = iAllNodes.Find( node ); |
|
678 iAllNodes[nodeInd]->Base().SetSelected( aMark ); |
|
679 } |
|
680 else |
|
681 { |
|
682 //user rejects the dependency dialog |
|
683 CleanupStack::PopAndDestroy( &deps ); |
|
684 if ( aMark ) |
|
685 { |
|
686 CleanupStack::PopAndDestroy( &mands ); |
|
687 } |
|
688 return EFalse; |
|
689 } |
|
690 |
|
691 //mark all of the mandatory items |
|
692 TInt mandCount = mands.Count(); |
|
693 if ( mandCount > 0 && aMark ) |
|
694 { |
|
695 for( TInt j = 0; j < mandCount; j++ ) |
|
696 { |
|
697 TInt mandNodeInd = iAllNodes.Find( mands[j] ); |
|
698 iAllNodes[mandNodeInd]->Base().SetSelected( aMark ); |
|
699 if ( iAllNodes[mandNodeInd]->NodeType() == MIAUpdateAnyNode::ENodeTypeNormal ) |
|
700 { |
|
701 // mark also all dependencies of a mandatory item |
|
702 MIAUpdateNode* dependencyNode = static_cast<MIAUpdateNode*>( iAllNodes[mandNodeInd] ); |
|
703 RPointerArray<MIAUpdateNode> dependencies; |
|
704 CleanupClosePushL( dependencies ); |
|
705 IAUpdateDepUtils::GetDependenciesL( *dependencyNode, iAllNodes, dependencies ); |
|
706 for( TInt k = 0; k < dependencies.Count(); k++ ) |
|
707 { |
|
708 TInt depNodeInd = iAllNodes.Find( dependencies[k] ); |
|
709 iAllNodes[depNodeInd]->Base().SetSelected( ETrue ); |
|
710 } |
|
711 CleanupStack::PopAndDestroy( &dependencies ); |
|
712 } |
|
713 } |
|
714 } |
|
715 if ( aMark ) |
|
716 { |
|
717 CleanupStack::PopAndDestroy( &mands ); |
|
718 } |
|
719 |
|
720 if ( depCount > 0 || mandCount > 0 ) |
|
721 { |
|
722 SetSelectedIndicesL(); |
|
723 } |
|
724 else |
|
725 { |
|
726 UpdateSelectionInfoInNaviPaneL(); |
|
727 } |
|
728 |
|
729 if ( aMark ) |
|
730 { |
|
731 SetMiddleSKTextL( ETrue, ETrue ); |
|
732 } |
|
733 else |
|
734 { |
|
735 SetMiddleSKTextL( ETrue, EFalse ); |
|
736 } |
|
737 } |
|
738 DynInitToolbarL( R_IAUPDATE_MAIN_TOOLBAR, Toolbar() ); |
|
739 return ETrue; |
|
740 } |
|
741 return EFalse; |
|
742 } |
|
743 |
|
744 |
|
745 |
|
746 |
|
747 // ----------------------------------------------------------------------------- |
|
748 // CIAUpdateMainView::SetMiddleSKTextL |
|
749 // Middle soft key label to be set |
|
750 // ----------------------------------------------------------------------------- |
|
751 // |
|
752 void CIAUpdateMainView::SetMiddleSKTextL( TBool aVisible, TBool aSelected ) |
|
753 { |
|
754 CEikButtonGroupContainer* cbaGroup = Cba(); |
|
755 if ( cbaGroup ) |
|
756 { |
|
757 cbaGroup->RemoveCommandFromStack( CEikButtonGroupContainer::EMiddleSoftkeyPosition, iLastCommandId ); |
|
758 if ( aVisible ) |
|
759 { |
|
760 HBufC* middleSKText = NULL; |
|
761 if ( aSelected ) |
|
762 { |
|
763 middleSKText = StringLoader::LoadLC( R_IAUPDATE_MSK_UNMARK ); |
|
764 TPtr mskPtr = middleSKText->Des(); |
|
765 cbaGroup->AddCommandToStackL( |
|
766 CEikButtonGroupContainer::EMiddleSoftkeyPosition, |
|
767 EAknSoftkeyUnmark, |
|
768 mskPtr ); |
|
769 iLastCommandId = EAknSoftkeyUnmark; |
|
770 } |
|
771 else |
|
772 { |
|
773 middleSKText = StringLoader::LoadLC( R_IAUPDATE_MSK_MARK ); |
|
774 TPtr mskPtr = middleSKText->Des(); |
|
775 cbaGroup->AddCommandToStackL( |
|
776 CEikButtonGroupContainer::EMiddleSoftkeyPosition, |
|
777 EAknSoftkeyMark, |
|
778 mskPtr ); |
|
779 iLastCommandId = EAknSoftkeyMark; |
|
780 } |
|
781 CleanupStack::PopAndDestroy( middleSKText ); |
|
782 } |
|
783 } |
|
784 } |
|
785 |
|
786 // ----------------------------------------------------------------------------- |
|
787 // CIAUpdateMainView::GetSelectedNodesL |
|
788 // Get selected (marked) nodes |
|
789 // ----------------------------------------------------------------------------- |
|
790 // |
|
791 void CIAUpdateMainView::GetSelectedNodesL( RPointerArray<MIAUpdateAnyNode>& aSelectedNodes ) const |
|
792 { |
|
793 for( TInt i = 0; i < iAllNodes.Count(); ++i ) |
|
794 { |
|
795 if ( iAllNodes[i]->Base().IsSelected() ) |
|
796 { |
|
797 User::LeaveIfError( aSelectedNodes.Append( iAllNodes[i] ) ); |
|
798 } |
|
799 } |
|
800 } |
|
801 |
|
802 // ----------------------------------------------------------------------------- |
|
803 // CIAUpdateMainView::GetMandatoryItemsL |
|
804 // Get selected (marked) nodes |
|
805 // ----------------------------------------------------------------------------- |
|
806 // |
|
807 void CIAUpdateMainView::GetMandatoryNodesL( RPointerArray<MIAUpdateAnyNode>& aMandNodes ) const |
|
808 { |
|
809 for( TInt i = 0; i < iAllNodes.Count(); ++i ) |
|
810 { |
|
811 if ( iAllNodes[i]->Base().Importance() == MIAUpdateBaseNode::EMandatory ) |
|
812 { |
|
813 User::LeaveIfError( aMandNodes.Append( iAllNodes[i] ) ); |
|
814 } |
|
815 } |
|
816 } |
|
817 |
|
818 |
|
819 |
|
820 // ----------------------------------------------------------------------------- |
|
821 // CIAUpdateMainView::SetSelectedIndicesL |
|
822 // Indices of selected items are passed to container |
|
823 // ----------------------------------------------------------------------------- |
|
824 // |
|
825 void CIAUpdateMainView::SetSelectedIndicesL() |
|
826 { |
|
827 RArray<TInt> indices; |
|
828 |
|
829 CleanupClosePushL( indices ); |
|
830 |
|
831 for( TInt i = 0; i < iAllNodes.Count(); ++i ) |
|
832 { |
|
833 if ( iAllNodes[i]->Base().IsSelected() ) |
|
834 { |
|
835 User::LeaveIfError( indices.Append( i ) ); |
|
836 } |
|
837 } |
|
838 |
|
839 iContainer->SetSelectedIndicesL( indices ); |
|
840 UpdateSelectionInfoInNaviPaneL(); |
|
841 |
|
842 CleanupStack::PopAndDestroy( &indices ); |
|
843 } |
|
844 |
|
845 // ----------------------------------------------------------------------------- |
|
846 // CIAUpdateMainView::NodeIndex |
|
847 // Get index of node |
|
848 // ----------------------------------------------------------------------------- |
|
849 // |
|
850 TInt CIAUpdateMainView::NodeIndex( const MIAUpdateAnyNode& aNode ) const |
|
851 { |
|
852 TInt result = -1; |
|
853 |
|
854 for( TInt i = 0; i < iAllNodes.Count(); ++i ) |
|
855 { |
|
856 if( &aNode == iAllNodes[i] ) |
|
857 { |
|
858 result = i; |
|
859 break; |
|
860 } |
|
861 } |
|
862 return result; |
|
863 } |
|
864 |
|
865 // ----------------------------------------------------------------------------- |
|
866 // CIAUpdateMainView::UpdateStatusPaneL |
|
867 // Update title in status pane |
|
868 // ----------------------------------------------------------------------------- |
|
869 // |
|
870 |
|
871 void CIAUpdateMainView::UpdateStatusPaneL() |
|
872 { |
|
873 CAknTitlePane* titlePane = |
|
874 static_cast< CAknTitlePane* >( StatusPane()->ControlL( |
|
875 TUid::Uid( EEikStatusPaneUidTitle ) ) ); |
|
876 HBufC* text = StringLoader::LoadLC( R_IAUPDATE_TEXT_TITLE_MAIN_VIEW ); |
|
877 titlePane->SetTextL( *text ); |
|
878 CleanupStack::PopAndDestroy( text ); |
|
879 } |
|
880 |
|
881 |
|
882 // ----------------------------------------------------------------------------- |
|
883 // CIAUpdateMainView::UpdateSelectionInfoInNaviPaneL |
|
884 // Update selection information in status pane |
|
885 // ----------------------------------------------------------------------------- |
|
886 // |
|
887 // |
|
888 void CIAUpdateMainView::UpdateSelectionInfoInNaviPaneL() |
|
889 { |
|
890 RemoveSelectionInfoInNaviPane(); |
|
891 |
|
892 if ( iAllNodes.Count() > 0 ) |
|
893 { |
|
894 //show empty navi pane when firmware is selected but no size info or it is NSU |
|
895 if ( (iAllNodes[0]->NodeType() == MIAUpdateAnyNode::ENodeTypeFw) && iAllNodes[0]->Base().IsSelected() ) |
|
896 { |
|
897 MIAUpdateFwNode* fwnode = static_cast<MIAUpdateFwNode*>( iAllNodes[0] ); |
|
898 if ( (iAllNodes[0]->Base().ContentSizeL() == 0) || (fwnode->FwType() == MIAUpdateFwNode::EFotiNsu) ) |
|
899 { |
|
900 return; |
|
901 } |
|
902 } |
|
903 |
|
904 if ( !iNaviPane ) |
|
905 { |
|
906 iNaviPane = static_cast<CAknNavigationControlContainer*> |
|
907 ( StatusPane()->ControlL( TUid::Uid(EEikStatusPaneUidNavi ) ) ); |
|
908 } |
|
909 TInt selectedSizeInBytes = 0; |
|
910 for( TInt i = 0; i < iAllNodes.Count(); ++i ) |
|
911 { |
|
912 if ( iAllNodes[i]->Base().IsSelected() ) |
|
913 { |
|
914 selectedSizeInBytes += iAllNodes[i]->Base().ContentSizeL(); |
|
915 } |
|
916 } |
|
917 |
|
918 |
|
919 TInt resourceId = 0; |
|
920 TInt selectedSize; |
|
921 if ( selectedSizeInBytes >= KMaxShownInKiloBytes ) |
|
922 { |
|
923 resourceId = R_IAUPDATE_NAVIPANE_MEGABYTE; |
|
924 selectedSize = selectedSizeInBytes / KMegaByte; |
|
925 if ( selectedSizeInBytes % KMegaByte != 0 ) |
|
926 { |
|
927 selectedSize++; |
|
928 } |
|
929 } |
|
930 else |
|
931 { |
|
932 resourceId = R_IAUPDATE_NAVIPANE_KILOBYTE; |
|
933 selectedSize = selectedSizeInBytes / KKiloByte; |
|
934 if ( selectedSizeInBytes % KKiloByte != 0 ) |
|
935 { |
|
936 selectedSize++; |
|
937 } |
|
938 } |
|
939 |
|
940 CArrayFix<TInt>* numberArray = |
|
941 new ( ELeave ) CArrayFixFlat<TInt>( KSelInfoArrayGranularity ); |
|
942 CleanupStack::PushL( numberArray ); |
|
943 numberArray->AppendL( CountOfSelectedItems() ); |
|
944 numberArray->AppendL( iAllNodes.Count() ); |
|
945 numberArray->AppendL( selectedSize ); |
|
946 |
|
947 HBufC* selectionInfo = StringLoader::LoadLC( resourceId, |
|
948 *numberArray ); |
|
949 TPtr ptr = selectionInfo->Des(); |
|
950 AknTextUtils::DisplayTextLanguageSpecificNumberConversion( ptr ); |
|
951 |
|
952 iDecorator = iNaviPane->CreateNavigationLabelL( *selectionInfo ); |
|
953 |
|
954 iNaviPane->PushL( *iDecorator ); |
|
955 |
|
956 CleanupStack::PopAndDestroy( selectionInfo ); |
|
957 CleanupStack::PopAndDestroy( numberArray ); |
|
958 } |
|
959 } |
|
960 |
|
961 // ----------------------------------------------------------------------------- |
|
962 // CIAUpdateMainView::RemoveSelectionInfoInNaviPane |
|
963 // Remove existing selection info (created by main view) from navi pane |
|
964 // ----------------------------------------------------------------------------- |
|
965 // |
|
966 |
|
967 void CIAUpdateMainView::RemoveSelectionInfoInNaviPane() |
|
968 { |
|
969 if ( iNaviPane && iDecorator ) |
|
970 { |
|
971 iNaviPane->Pop( iDecorator ); |
|
972 delete iDecorator; |
|
973 iDecorator = NULL; |
|
974 } |
|
975 } |
|
976 |
|
977 // ----------------------------------------------------------------------------- |
|
978 // CIAUpdateMainView::ShowDependenciesFoundDialogL |
|
979 // |
|
980 // ----------------------------------------------------------------------------- |
|
981 // |
|
982 TBool CIAUpdateMainView::ShowDependenciesFoundDialogL( TDesC& aText ) const |
|
983 { |
|
984 CAknMessageQueryDialog* dlg = CAknMessageQueryDialog::NewL( aText ); |
|
985 dlg->PrepareLC( R_IAUPDATE_MESSAGE_QUERY ); |
|
986 CAknPopupHeadingPane* headingPane = dlg->Heading(); |
|
987 HBufC* title = StringLoader::LoadLC( R_IAUPDATE_DEPENDENCY_TITLE ); |
|
988 headingPane->SetTextL( *title ); |
|
989 CleanupStack::PopAndDestroy( title ); |
|
990 |
|
991 dlg->ButtonGroupContainer().SetCommandSetL( |
|
992 R_IAUPDATE_SOFTKEYS_CONTINUE_CANCEL__CONTINUE ); |
|
993 |
|
994 return( dlg->RunLD() == EAknSoftkeyOk ); |
|
995 } |
|
996 |
|
997 // --------------------------------------------------------------------------- |
|
998 // CIAUpdateMainView::CountOfSelectedItems |
|
999 // |
|
1000 // --------------------------------------------------------------------------- |
|
1001 // |
|
1002 TInt CIAUpdateMainView::CountOfSelectedItems() const |
|
1003 { |
|
1004 TInt countOfSelectedItems = 0; |
|
1005 for( TInt i = 0; i < iAllNodes.Count(); ++i ) |
|
1006 { |
|
1007 if ( iAllNodes[i]->Base().IsSelected() ) |
|
1008 { |
|
1009 countOfSelectedItems++; |
|
1010 } |
|
1011 } |
|
1012 return countOfSelectedItems; |
|
1013 } |
|
1014 |
|
1015 // --------------------------------------------------------------------------- |
|
1016 // CIAUpdateMainView::ShowUpdateCannotOmitDialogL |
|
1017 // |
|
1018 // --------------------------------------------------------------------------- |
|
1019 // |
|
1020 void CIAUpdateMainView::ShowUpdateCannotOmitDialogL() const |
|
1021 { |
|
1022 HBufC* msgText = StringLoader::LoadLC( R_IAUPDATE_CANNOT_OMIT ); |
|
1023 CAknQueryDialog* dlg = CAknQueryDialog::NewL(); |
|
1024 dlg->ExecuteLD( R_IAUPDATE_INFORMATION_QUERY, *msgText ); |
|
1025 CleanupStack::PopAndDestroy( msgText ); |
|
1026 } |
|
1027 |
|
1028 // End of File |
|
1029 |