iaupdate/IAD/ui/src/iaupdatemainview.cpp
changeset 29 26b6f0522fd8
parent 25 98b66e4fb0be
child 33 8110bf1194d1
equal deleted inserted replaced
25:98b66e4fb0be 29:26b6f0522fd8
     1 /*
     1 /*
     2 * Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies).
     2 * Copyright (c) 2009-2010 Nokia Corporation and/or its subsidiary(-ies).
     3 * All rights reserved.
     3 * All rights reserved.
     4 * This component and the accompanying materials are made available
     4 * This component and the accompanying materials are made available
     5 * under the terms of "Eclipse Public License v1.0"
     5 * under the terms of "Eclipse Public License v1.0"
     6 * which accompanies this distribution, and is available
     6 * which accompanies this distribution, and is available
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
     9 * Initial Contributors:
     9 * Initial Contributors:
    10 * Nokia Corporation - initial contribution.
    10 * Nokia Corporation - initial contribution.
    11 *
    11 *
    12 * Contributors:
    12 * Contributors:
    13 *
    13 *
    14 * Description:   This module contains the implementation of CIAUpdateMainView class 
    14 * Description:   This module contains the implementation of IAUpdateMainView
    15 *                member functions.
    15 *                class member functions.
    16 *
    16 *
    17 */
    17 */
    18 
    18 
    19 
    19 #include <hbaction.h>
    20  
    20 #include <qgraphicswidget>
    21 #include <eikmenup.h>
    21 //#include <hblistview.h>
    22 #include <aknViewAppUi.h> 
    22 #include <hblistwidget.h>
    23 #include <akntitle.h> 
    23 #include <hblistviewitem.h>
    24 #include <aknnavi.h> // CAknNavigationControlContainer
    24 #include <hblistwidgetitem.h>
    25 #include <aknnavide.h> // CAknNavigationDecorator
    25 #include <hbtoolbar.h>
    26 #include <AknUtils.h>
    26 #include <hbmenu.h>
    27 #include <aknmessagequerydialog.h>      // CAknMessageQueryDialog
    27 #include <hbdocumentloader.h>
    28 #include <akntoolbar.h> 
    28 #include <xqconversions.h>
    29 #include <StringLoader.h>
    29 
    30 #include <featmgr.h>  
       
    31 #include <iaupdate.rsg>
       
    32 
       
    33 #include "iaupdate.hrh"
       
    34 #include "iaupdatemainview.h"
    30 #include "iaupdatemainview.h"
    35 #include "iaupdatemaincontainer.h"
    31 #include "iaupdateagreement.h"
    36 #include "iaupdatenode.h"
    32 
    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"
    33 #include "iaupdatedebug.h"
    45 #include "iaupdatefwupdatehandler.h"
    34 
    46 
    35 const int KKiloByte = 1024;
    47 //CONSTANTS
    36 const int KMegaByte = 1024 * 1024;
    48 const TInt KKiloByte = 1024;
    37 const int KMaxShownInKiloBytes = 10 * KMegaByte;
    49 const TInt KMegaByte = 1024 * 1024;
    38 
    50 const TInt KMaxShownInKiloBytes = 10 * KMegaByte;
    39 
    51 const TInt KSelInfoArrayGranularity = 3;
    40 IAUpdateMainView::IAUpdateMainView()
    52 
    41 {
    53 //MACROS
    42     HbDocumentLoader loader;
    54 _LIT( KSpace, " " );
    43     bool ok = false;
    55 
    44     loader.load(":/xml/iaupdate_mainview.docml", &ok);
    56 // ============================ MEMBER FUNCTIONS ===============================
    45         
    57 
    46     // Exit if the file format is invalid
    58 
    47     Q_ASSERT_X(ok, "Software update", "Invalid docml file");
       
    48     // Create the view from DocML
       
    49     
       
    50     //QGraphicsWidget* widget = loader.findWidget("view");
       
    51     HbView* widget = qobject_cast<HbView*>(loader.findWidget("view"));
       
    52     Q_ASSERT_X(widget != 0, "Software update", "View not found");
       
    53     QString viewTitle(widget->title());
       
    54     // Set the IAUpdateMainView view to be the widget that was loaded from the xml
       
    55     setWidget(widget);
       
    56     setTitle(viewTitle);
       
    57       
       
    58     HbToolBar *toolBar = qobject_cast< HbToolBar*>( loader.findWidget("viewToolbar") );
       
    59     setToolBar(toolBar);
       
    60     
       
    61     HbMenu *menu = qobject_cast< HbMenu*>( loader.findWidget("viewMenu") );
       
    62     setMenu(menu);
       
    63     
       
    64     //Get the Action objects from the docml file
       
    65     HbAction *action = qobject_cast<HbAction*>(loader.findObject("action"));
       
    66     HbAction *action_1 = qobject_cast<HbAction*>(loader.findObject("action_1"));
       
    67     HbAction *action_2 = qobject_cast<HbAction*>(loader.findObject("action_2"));
       
    68     
       
    69     connect(action, SIGNAL(triggered()), this, SLOT(handleStartUpdate()));
       
    70     connect(action_1, SIGNAL(triggered()), this, SLOT(handleSettings()));
       
    71     connect(action_2, SIGNAL(triggered()), this, SLOT(handleDisclaimer()));
       
    72 
       
    73     //mListView = qobject_cast<HbListView*>( loader.findWidget("listView") ); 
       
    74     mListView = qobject_cast<HbListWidget*>( loader.findWidget("listWidget") );
       
    75     //mListView = loader.findWidget("listWidget");
       
    76     mListView->setSelectionMode( HbAbstractItemView::MultiSelection );
       
    77     
       
    78     HbListViewItem *prototype = mListView->listItemPrototype();
       
    79 
       
    80     prototype->setGraphicsSize(HbListViewItem::LargeIcon);
       
    81     //prototype->setStretchingStyle(HbListViewItem::StretchLandscape);
       
    82     //prototype->setSecondaryTextRowCount(1,1);
       
    83 
       
    84     
       
    85         
       
    86     /*HbListWidgetItem* item = new HbListWidgetItem();
       
    87     QStringList data;
       
    88     data << "Test application" << "Critical";
       
    89     item->setData(QVariant(data), Qt::DisplayRole);
       
    90     mListWidget->addItem(item);*/
       
    91 }
       
    92     
       
    93 IAUpdateMainView::~IAUpdateMainView()
       
    94 {
       
    95 }
    59 
    96 
    60 // -----------------------------------------------------------------------------
    97 // -----------------------------------------------------------------------------
    61 // CIAUpdateMainView::NewL
    98 // IAUpdateMainView::refresh
    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
    99 // Refreshes update list
   129 // -----------------------------------------------------------------------------
   100 // -----------------------------------------------------------------------------
   130 //    
   101 //    
   131 void CIAUpdateMainView::RefreshL( const RPointerArray<MIAUpdateNode>& aNodes,
   102 void IAUpdateMainView::refresh( const RPointerArray<MIAUpdateNode>& nodes,
   132                                   const RPointerArray<MIAUpdateFwNode>& aFwNodes,
   103                                 const RPointerArray<MIAUpdateFwNode>& fwNodes,
   133                                   TInt aError  )
   104                                 int /*error*/ )
   134     {   
   105     {   
   135     IAUPDATE_TRACE("[IAUPDATE] CIAUpdateMainView::RefreshL begin");
   106     IAUPDATE_TRACE("[IAUPDATE] IAUpdateMainView::refresh begin");
   136     iRefreshError = aError;    
   107        
   137     iAllNodes.Reset();
   108     mAllNodes.Reset();
   138         
   109         
   139     if ( aFwNodes.Count() > 0 )
   110     if ( fwNodes.Count() > 0 )
   140         {
   111         {
   141         IAUPDATE_TRACE("[IAUPDATE] CIAUpdateMainView::RefreshL hard code importance");
   112         IAUPDATE_TRACE("[IAUPDATE] IAUpdateMainView::refresh hard code importance");
   142         //hardcode the importance of firmware as Critical
   113         //hardcode the importance of firmware as Critical
   143         for ( TInt i = 0; i < aFwNodes.Count(); i++ )
   114         for ( TInt i = 0; i < fwNodes.Count(); i++ )
   144              {
   115              {
   145              aFwNodes[i]->Base().SetImportance( MIAUpdateBaseNode::ECritical );
   116              fwNodes[i]->Base().SetImportance( MIAUpdateBaseNode::ECritical );
   146              }
   117              }
   147          
   118          
   148         //either NSU or FOTA available
   119         //either NSU or FOTA available
   149         if ( aFwNodes.Count() == 1 )
   120         if ( fwNodes.Count() == 1 )
   150             {
   121             {
   151             IAUPDATE_TRACE("[IAUPDATE] CIAUpdateMainView::RefreshL either NSU or FOTA available");
   122             IAUPDATE_TRACE("[IAUPDATE] IAUpdateMainView::refresh either NSU or FOTA available");
   152             MIAUpdateAnyNode* node = aFwNodes[0];
   123             MIAUpdateAnyNode* node = fwNodes[0];
   153             User::LeaveIfError( iAllNodes.Append( node ) );
   124             mAllNodes.Append( node );
   154             }
   125             }
   155         
   126         
   156         //both NSU and FOTA available, show only FOTA node
   127         //both NSU and FOTA available, show only FOTA node
   157         if ( aFwNodes.Count() == 2 )
   128         if ( fwNodes.Count() == 2 )
   158             {
   129             {
   159             IAUPDATE_TRACE("[IAUPDATE] CIAUpdateMainView::RefreshL both NSU and FOTA available");
   130             IAUPDATE_TRACE("[IAUPDATE] IAUpdateMainView::refresh both NSU and FOTA available");
   160             MIAUpdateAnyNode* node1 = aFwNodes[0];
   131             MIAUpdateAnyNode* node1 = fwNodes[0];
   161             MIAUpdateFwNode* fwnode = static_cast<MIAUpdateFwNode*>( node1 );
   132             MIAUpdateFwNode* fwnode = static_cast<MIAUpdateFwNode*>( node1 );
   162             if ( fwnode->FwType() == MIAUpdateFwNode::EFotaDp2  )
   133             if ( fwnode->FwType() == MIAUpdateFwNode::EFotaDp2  )
   163                 {
   134                 {
   164                 User::LeaveIfError( iAllNodes.Append( node1 ) );
   135                 mAllNodes.Append( node1 );
   165                 }
   136                 }
   166             else
   137             else
   167                 {
   138                 {
   168                 MIAUpdateAnyNode* node2 = aFwNodes[1];
   139                 MIAUpdateAnyNode* node2 = fwNodes[1];
   169                 User::LeaveIfError( iAllNodes.Append( node2 ) );
   140                 mAllNodes.Append( node2 );
   170                 }
   141                 }
   171             }
   142             }
   172         }
   143         }
   173     
   144     
   174    
   145    
   175     for( TInt i = 0; i < aNodes.Count(); ++i ) 
   146     for( int i = 0; i < nodes.Count(); ++i ) 
   176         {
   147         {
   177         MIAUpdateAnyNode* node = aNodes[i];
   148         MIAUpdateAnyNode* node = nodes[i];
   178         User::LeaveIfError( iAllNodes.Append( node ) );
   149         mAllNodes.Append( node );
   179         }
   150         }
   180         
   151         
   181     if( iContainer )
   152     mListView->clear();
   182         {        
   153     QItemSelectionModel *selectionModel = mListView->selectionModel();  
   183         iContainer->RefreshL( iAllNodes, iRefreshError );  
   154     selectionModel->clear();
   184         SetSelectedIndicesL();     
   155     HbIcon icon(QString(":/icons/qgn_menu_swupdate"));
   185         DynInitToolbarL( R_IAUPDATE_MAIN_TOOLBAR, Toolbar() );
   156     
   186         }    
   157     for( int j = 0; j < mAllNodes.Count(); ++j ) 
   187      Toolbar()->SetItemDimmed( EIAUpdateCmdUpdateHistory, EFalse, ETrue );
   158         {
       
   159         MIAUpdateAnyNode* node = mAllNodes[j];
       
   160         int sizeInBytes = node->Base().ContentSizeL();
       
   161 
       
   162         int size = 0;
       
   163         TBool shownInMegabytes = EFalse;        
       
   164         if ( sizeInBytes >= KMaxShownInKiloBytes )
       
   165             {
       
   166             shownInMegabytes = ETrue;
       
   167             size = sizeInBytes / KMegaByte;
       
   168             if ( sizeInBytes % KMegaByte != 0 )
       
   169                 {
       
   170                 size++;
       
   171                 }
       
   172             }
       
   173         else 
       
   174             {
       
   175             size = sizeInBytes / KKiloByte;
       
   176             if ( sizeInBytes % KKiloByte != 0 )
       
   177                 {
       
   178                 size++;
       
   179                 }  
       
   180             }
       
   181         QString sizeString;
       
   182         sizeString.setNum(size);        
       
   183         QString importanceDescription;
       
   184         switch( node->Base().Importance() )
       
   185             {        
       
   186             case MIAUpdateBaseNode::EMandatory:
       
   187                 {
       
   188                 importanceDescription = "Required ";
       
   189                 importanceDescription.append(sizeString);
       
   190                 if ( shownInMegabytes )
       
   191                     {
       
   192                     importanceDescription.append(" MB" );
       
   193                     }
       
   194                 else 
       
   195                     {
       
   196                     importanceDescription.append(" kB" );
       
   197                     }  
       
   198                 break;
       
   199                 }
       
   200             
       
   201             
       
   202             case MIAUpdateBaseNode::ECritical:
       
   203                 {
       
   204                 bool isNSU = false;
       
   205                 if( node->NodeType() == MIAUpdateAnyNode::ENodeTypeFw )
       
   206                     {
       
   207                     MIAUpdateFwNode* fwnode = static_cast<MIAUpdateFwNode*>( node );          
       
   208                     if ( fwnode->FwType() == MIAUpdateFwNode::EFotiNsu )
       
   209                         {
       
   210                         isNSU = true;
       
   211                         }
       
   212                     }
       
   213                 
       
   214                 importanceDescription = "Important ";
       
   215                 if ( !size || isNSU )
       
   216                     {
       
   217                     //for firmware when size info is not provided by server
       
   218                     }
       
   219                 else
       
   220                     {
       
   221                     importanceDescription.append(sizeString);
       
   222                     if ( shownInMegabytes )
       
   223                         {
       
   224                         importanceDescription.append(" MB" );
       
   225                         }
       
   226                     else 
       
   227                         {
       
   228                         importanceDescription.append(" kB" );
       
   229                         } 
       
   230                     }
       
   231      
       
   232                 break;
       
   233                 }
       
   234         
       
   235             case MIAUpdateBaseNode::ERecommended:
       
   236                 {
       
   237                 importanceDescription = "Recommended ";
       
   238                 importanceDescription.append(sizeString);
       
   239                 if ( shownInMegabytes )
       
   240                     {
       
   241                     importanceDescription.append(" MB" );
       
   242                     }
       
   243                 else 
       
   244                     {
       
   245                     importanceDescription.append(" kB" );
       
   246                     }  
       
   247                 break;
       
   248                 }
       
   249         
       
   250             case MIAUpdateBaseNode::ENormal:
       
   251                 {
       
   252                 importanceDescription = "Optional ";
       
   253                 importanceDescription.append(sizeString);
       
   254                 if ( shownInMegabytes )
       
   255                     {
       
   256                      importanceDescription.append(" MB" );
       
   257                     }
       
   258                 else 
       
   259                     {
       
   260                     importanceDescription.append(" kB" );
       
   261                     }  
       
   262                 break;
       
   263                 }
       
   264 
       
   265             default:
       
   266                 {
       
   267                 break;
       
   268                 }
       
   269             }
       
   270             
       
   271             //AknTextUtils::DisplayTextLanguageSpecificNumberConversion( ptr );    
       
   272             
       
   273             HbListWidgetItem *item = new HbListWidgetItem();    
       
   274             QString name = XQConversions::s60DescToQString(node->Base().Name());
       
   275             if ( node->NodeType() == MIAUpdateAnyNode::ENodeTypeFw ) 
       
   276                 {
       
   277                 name.append(" DEVICE SOFTWARE");
       
   278                 }
       
   279             item->setText(name);
       
   280             item->setSecondaryText(importanceDescription);
       
   281             item->setIcon(icon);
       
   282              mListView->addItem(item); 
       
   283  
       
   284             if ( node-> Base().IsSelected() )
       
   285                 {
       
   286                 int count = mListView->indexCount();
       
   287                 QModelIndex modelIndex = mListView->model()->index(count-1,0);
       
   288                 selectionModel->select(modelIndex, QItemSelectionModel::Select);
       
   289                 }
       
   290 
       
   291                
       
   292             
       
   293         /*if ( nodes.Count() == 0 )
       
   294             {
       
   295             HBufC* emptyText = NULL;
       
   296             if ( aError )
       
   297                 {
       
   298                 if ( aError == KErrCancel || aError == KErrAbort )
       
   299                     {
       
   300                     emptyText = KNullDesC().AllocLC();
       
   301                     }
       
   302                 else
       
   303                     {
       
   304                     emptyText = StringLoader::LoadLC( R_IAUPDATE_REFRESH_FAILED );  
       
   305                     }
       
   306                 }
       
   307             else
       
   308                 {
       
   309                 emptyText = StringLoader::LoadLC( R_IAUPDATE_TEXT_NO_UPDATES ); 
       
   310                 }
       
   311             
       
   312             iListBox->View()->SetListEmptyTextL( *emptyText );
       
   313             CleanupStack::PopAndDestroy( emptyText );
       
   314             iListBox->ScrollBarFrame()->SetScrollBarVisibilityL( 
       
   315                     CEikScrollBarFrame::EOff, CEikScrollBarFrame::EOff );  
       
   316             }
       
   317         else
       
   318             {
       
   319             if ( iListBox->CurrentItemIndex() == KErrNotFound )
       
   320                 {
       
   321                 iListBox->SetCurrentItemIndex( aNodes.Count() - 1 );
       
   322                 }
       
   323             }*/
       
   324             
       
   325         //iListBox->HandleItemAdditionL();
       
   326         }
       
   327      connect(selectionModel, SIGNAL(selectionChanged(QItemSelection,QItemSelection)),
       
   328                     this, SLOT(handleSelectionChanged(QItemSelection)));     
       
   329     
       
   330      IAUPDATE_TRACE("[IAUPDATE] IAUpdateMainView::refresh end");
   188      }
   331      }
   189     
   332 
   190 
   333 
   191 // -----------------------------------------------------------------------------
   334 
   192 // CIAUpdateMainView::GetCurrentNode
   335 
   193 // 
   336 void IAUpdateMainView::handleStartUpdate()
   194 // -----------------------------------------------------------------------------
   337 {
   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      
   338      
   940         CArrayFix<TInt>* numberArray = 
   339 }
   941                  new ( ELeave ) CArrayFixFlat<TInt>( KSelInfoArrayGranularity );
   340 
   942         CleanupStack::PushL( numberArray );
   341 
   943         numberArray->AppendL( CountOfSelectedItems() ); 
   342 void IAUpdateMainView::handleSettings()
   944         numberArray->AppendL( iAllNodes.Count() );
   343 {
   945         numberArray->AppendL( selectedSize );
   344 }
   946     
   345 
   947         HBufC* selectionInfo = StringLoader::LoadLC( resourceId, 
   346 void IAUpdateMainView::handleDisclaimer()
   948                                                      *numberArray );
   347 {
   949         TPtr ptr = selectionInfo->Des();
   348     CIAUpdateAgreement* agreement = CIAUpdateAgreement::NewLC();
   950         AknTextUtils::DisplayTextLanguageSpecificNumberConversion( ptr ); 
   349     agreement->ShowAgreementL();
   951             
   350     CleanupStack::PopAndDestroy( agreement);
   952         iDecorator = iNaviPane->CreateNavigationLabelL( *selectionInfo );
   351 }
   953 
   352 
   954         iNaviPane->PushL( *iDecorator );
   353 void IAUpdateMainView::handleSelectionChanged(QItemSelection)
   955         
   354 {
   956         CleanupStack::PopAndDestroy( selectionInfo ); 
   355 
   957         CleanupStack::PopAndDestroy( numberArray );	
   356 }
   958         }
   357 
   959     }
   358 
   960 
   359 
   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