iaupdate/IAD/ui/src/iaupdatemainview.cpp
changeset 29 26b6f0522fd8
parent 25 98b66e4fb0be
child 33 8110bf1194d1
--- a/iaupdate/IAD/ui/src/iaupdatemainview.cpp	Fri Apr 16 15:05:20 2010 +0300
+++ b/iaupdate/IAD/ui/src/iaupdatemainview.cpp	Mon May 03 12:38:03 2010 +0300
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies).
+* Copyright (c) 2009-2010 Nokia Corporation and/or its subsidiary(-ies).
 * All rights reserved.
 * This component and the accompanying materials are made available
 * under the terms of "Eclipse Public License v1.0"
@@ -11,1019 +11,349 @@
 *
 * Contributors:
 *
-* Description:   This module contains the implementation of CIAUpdateMainView class 
-*                member functions.
+* Description:   This module contains the implementation of IAUpdateMainView
+*                class member functions.
 *
 */
 
+#include <hbaction.h>
+#include <qgraphicswidget>
+//#include <hblistview.h>
+#include <hblistwidget.h>
+#include <hblistviewitem.h>
+#include <hblistwidgetitem.h>
+#include <hbtoolbar.h>
+#include <hbmenu.h>
+#include <hbdocumentloader.h>
+#include <xqconversions.h>
 
- 
-#include <eikmenup.h>
-#include <aknViewAppUi.h> 
-#include <akntitle.h> 
-#include <aknnavi.h> // CAknNavigationControlContainer
-#include <aknnavide.h> // CAknNavigationDecorator
-#include <AknUtils.h>
-#include <aknmessagequerydialog.h>      // CAknMessageQueryDialog
-#include <akntoolbar.h> 
-#include <StringLoader.h>
-#include <featmgr.h>  
-#include <iaupdate.rsg>
-
-#include "iaupdate.hrh"
 #include "iaupdatemainview.h"
-#include "iaupdatemaincontainer.h"
-#include "iaupdatenode.h"
-#include "iaupdatefwnode.h"
-#include "iaupdatebasenode.h"
-#include "iaupdatedialogutil.h"
-#include "iaupdatestatusdialog.h"
-#include "iaupdateappui.h"
-#include "iaupdateuicontroller.h"
-#include "iaupdatedeputils.h"
+#include "iaupdateagreement.h"
+
 #include "iaupdatedebug.h"
-#include "iaupdatefwupdatehandler.h"
 
-//CONSTANTS
-const TInt KKiloByte = 1024;
-const TInt KMegaByte = 1024 * 1024;
-const TInt KMaxShownInKiloBytes = 10 * KMegaByte;
-const TInt KSelInfoArrayGranularity = 3;
-
-//MACROS
-_LIT( KSpace, " " );
-
-// ============================ MEMBER FUNCTIONS ===============================
+const int KKiloByte = 1024;
+const int KMegaByte = 1024 * 1024;
+const int KMaxShownInKiloBytes = 10 * KMegaByte;
 
 
+IAUpdateMainView::IAUpdateMainView()
+{
+    HbDocumentLoader loader;
+    bool ok = false;
+    loader.load(":/xml/iaupdate_mainview.docml", &ok);
+        
+    // Exit if the file format is invalid
+    Q_ASSERT_X(ok, "Software update", "Invalid docml file");
+    // Create the view from DocML
+    
+    //QGraphicsWidget* widget = loader.findWidget("view");
+    HbView* widget = qobject_cast<HbView*>(loader.findWidget("view"));
+    Q_ASSERT_X(widget != 0, "Software update", "View not found");
+    QString viewTitle(widget->title());
+    // Set the IAUpdateMainView view to be the widget that was loaded from the xml
+    setWidget(widget);
+    setTitle(viewTitle);
+      
+    HbToolBar *toolBar = qobject_cast< HbToolBar*>( loader.findWidget("viewToolbar") );
+    setToolBar(toolBar);
+    
+    HbMenu *menu = qobject_cast< HbMenu*>( loader.findWidget("viewMenu") );
+    setMenu(menu);
+    
+    //Get the Action objects from the docml file
+    HbAction *action = qobject_cast<HbAction*>(loader.findObject("action"));
+    HbAction *action_1 = qobject_cast<HbAction*>(loader.findObject("action_1"));
+    HbAction *action_2 = qobject_cast<HbAction*>(loader.findObject("action_2"));
+    
+    connect(action, SIGNAL(triggered()), this, SLOT(handleStartUpdate()));
+    connect(action_1, SIGNAL(triggered()), this, SLOT(handleSettings()));
+    connect(action_2, SIGNAL(triggered()), this, SLOT(handleDisclaimer()));
 
-// -----------------------------------------------------------------------------
-// CIAUpdateMainView::NewL
-// Two-phased constructor.
-// -----------------------------------------------------------------------------
-//
-CIAUpdateMainView* CIAUpdateMainView::NewL( const TRect& aRect )
-    {
-    CIAUpdateMainView* self = CIAUpdateMainView::NewLC( aRect );
-    CleanupStack::Pop(self);
-    return self;
-    }
+    //mListView = qobject_cast<HbListView*>( loader.findWidget("listView") ); 
+    mListView = qobject_cast<HbListWidget*>( loader.findWidget("listWidget") );
+    //mListView = loader.findWidget("listWidget");
+    mListView->setSelectionMode( HbAbstractItemView::MultiSelection );
+    
+    HbListViewItem *prototype = mListView->listItemPrototype();
+
+    prototype->setGraphicsSize(HbListViewItem::LargeIcon);
+    //prototype->setStretchingStyle(HbListViewItem::StretchLandscape);
+    //prototype->setSecondaryTextRowCount(1,1);
+
+    
+        
+    /*HbListWidgetItem* item = new HbListWidgetItem();
+    QStringList data;
+    data << "Test application" << "Critical";
+    item->setData(QVariant(data), Qt::DisplayRole);
+    mListWidget->addItem(item);*/
+}
+    
+IAUpdateMainView::~IAUpdateMainView()
+{
+}
 
 // -----------------------------------------------------------------------------
-// CIAUpdateMainView::NewLC
-// 
-// -----------------------------------------------------------------------------
-//
-CIAUpdateMainView* CIAUpdateMainView::NewLC( const TRect& aRect )
-    {
-    CIAUpdateMainView* self = new (ELeave) CIAUpdateMainView();
-    CleanupStack::PushL( self );
-    self->ConstructL( aRect );
-    return self;
-    }
-
-// -----------------------------------------------------------------------------
-// CIAUpdateMainView::CIAUpdateMainView
-// C++ default constructor can NOT contain any code, that
-// might leave.
-// -----------------------------------------------------------------------------
-//
-CIAUpdateMainView::CIAUpdateMainView()
-    {
-    }
-
-// -----------------------------------------------------------------------------
-// CIAUpdateMainView::~CIAUpdateMainView
-// Destructor
-// -----------------------------------------------------------------------------
-//
-CIAUpdateMainView::~CIAUpdateMainView()
-    {
-    delete iDecorator;
-    iAllNodes.Close();
-    if ( iContainer )
-        {
-    	AppUi()->RemoveFromStack( iContainer );
-    	delete iContainer;
-        }
-    delete iFwUpdateHandler;
-    }
-// -----------------------------------------------------------------------------
-// CIAUpdateMainView::ConstructL
-// Symbian 2nd phase constructor can leave.
-// -----------------------------------------------------------------------------
-//
-void CIAUpdateMainView::ConstructL( const TRect& /*aRect*/ )
-    {
-    BaseConstructL( R_IAUPDATE_MAIN_VIEW );
-    Toolbar()->SetItemDimmed( EIAUpdateCmdStartUpdate, ETrue, ETrue );
-    Toolbar()->SetItemDimmed( EIAUpdateCmdMarkedUpdateDetails, ETrue, ETrue );
-    Toolbar()->SetItemDimmed( EIAUpdateCmdUpdateHistory, ETrue, ETrue );
-    Toolbar()->SetToolbarObserver( this ); 
-    iFwUpdateHandler = CIAUpdateFWUpdateHandler::NewL();
-    }
-
-// -----------------------------------------------------------------------------
-// CIAUpdateMainView::RefreshL
+// IAUpdateMainView::refresh
 // Refreshes update list
 // -----------------------------------------------------------------------------
 //    
-void CIAUpdateMainView::RefreshL( const RPointerArray<MIAUpdateNode>& aNodes,
-                                  const RPointerArray<MIAUpdateFwNode>& aFwNodes,
-                                  TInt aError  )
+void IAUpdateMainView::refresh( const RPointerArray<MIAUpdateNode>& nodes,
+                                const RPointerArray<MIAUpdateFwNode>& fwNodes,
+                                int /*error*/ )
     {   
-    IAUPDATE_TRACE("[IAUPDATE] CIAUpdateMainView::RefreshL begin");
-    iRefreshError = aError;    
-    iAllNodes.Reset();
+    IAUPDATE_TRACE("[IAUPDATE] IAUpdateMainView::refresh begin");
+       
+    mAllNodes.Reset();
         
-    if ( aFwNodes.Count() > 0 )
+    if ( fwNodes.Count() > 0 )
         {
-        IAUPDATE_TRACE("[IAUPDATE] CIAUpdateMainView::RefreshL hard code importance");
+        IAUPDATE_TRACE("[IAUPDATE] IAUpdateMainView::refresh hard code importance");
         //hardcode the importance of firmware as Critical
-        for ( TInt i = 0; i < aFwNodes.Count(); i++ )
+        for ( TInt i = 0; i < fwNodes.Count(); i++ )
              {
-             aFwNodes[i]->Base().SetImportance( MIAUpdateBaseNode::ECritical );
+             fwNodes[i]->Base().SetImportance( MIAUpdateBaseNode::ECritical );
              }
          
         //either NSU or FOTA available
-        if ( aFwNodes.Count() == 1 )
+        if ( fwNodes.Count() == 1 )
             {
-            IAUPDATE_TRACE("[IAUPDATE] CIAUpdateMainView::RefreshL either NSU or FOTA available");
-            MIAUpdateAnyNode* node = aFwNodes[0];
-            User::LeaveIfError( iAllNodes.Append( node ) );
+            IAUPDATE_TRACE("[IAUPDATE] IAUpdateMainView::refresh either NSU or FOTA available");
+            MIAUpdateAnyNode* node = fwNodes[0];
+            mAllNodes.Append( node );
             }
         
         //both NSU and FOTA available, show only FOTA node
-        if ( aFwNodes.Count() == 2 )
+        if ( fwNodes.Count() == 2 )
             {
-            IAUPDATE_TRACE("[IAUPDATE] CIAUpdateMainView::RefreshL both NSU and FOTA available");
-            MIAUpdateAnyNode* node1 = aFwNodes[0];
+            IAUPDATE_TRACE("[IAUPDATE] IAUpdateMainView::refresh both NSU and FOTA available");
+            MIAUpdateAnyNode* node1 = fwNodes[0];
             MIAUpdateFwNode* fwnode = static_cast<MIAUpdateFwNode*>( node1 );
             if ( fwnode->FwType() == MIAUpdateFwNode::EFotaDp2  )
                 {
-                User::LeaveIfError( iAllNodes.Append( node1 ) );
+                mAllNodes.Append( node1 );
                 }
             else
                 {
-                MIAUpdateAnyNode* node2 = aFwNodes[1];
-                User::LeaveIfError( iAllNodes.Append( node2 ) );
+                MIAUpdateAnyNode* node2 = fwNodes[1];
+                mAllNodes.Append( node2 );
                 }
             }
         }
     
    
-    for( TInt i = 0; i < aNodes.Count(); ++i ) 
+    for( int i = 0; i < nodes.Count(); ++i ) 
         {
-        MIAUpdateAnyNode* node = aNodes[i];
-        User::LeaveIfError( iAllNodes.Append( node ) );
+        MIAUpdateAnyNode* node = nodes[i];
+        mAllNodes.Append( node );
         }
         
-    if( iContainer )
-        {        
-        iContainer->RefreshL( iAllNodes, iRefreshError );  
-        SetSelectedIndicesL();     
-        DynInitToolbarL( R_IAUPDATE_MAIN_TOOLBAR, Toolbar() );
-        }    
-     Toolbar()->SetItemDimmed( EIAUpdateCmdUpdateHistory, EFalse, ETrue );
-     }
+    mListView->clear();
+    QItemSelectionModel *selectionModel = mListView->selectionModel();  
+    selectionModel->clear();
+    HbIcon icon(QString(":/icons/qgn_menu_swupdate"));
     
-
-// -----------------------------------------------------------------------------
-// CIAUpdateMainView::GetCurrentNode
-// 
-// -----------------------------------------------------------------------------
-//    
-MIAUpdateAnyNode* CIAUpdateMainView::GetCurrentNode()
-   {
-   if ( iContainer )
-      {
-   	  return iContainer->GetCurrentNode( iAllNodes ); 	 
-      }
-   return NULL;   
-   }
+    for( int j = 0; j < mAllNodes.Count(); ++j ) 
+        {
+        MIAUpdateAnyNode* node = mAllNodes[j];
+        int sizeInBytes = node->Base().ContentSizeL();
 
-// -----------------------------------------------------------------------------
-// CIAUpdateMainView::GetSelectedNode
-// 
-// -----------------------------------------------------------------------------
-//    
-MIAUpdateAnyNode* CIAUpdateMainView::GetSelectedNode()
-   {
-   MIAUpdateAnyNode* selectedNode = NULL;
-   for( TInt i = 0; i < iAllNodes.Count() && !selectedNode ; ++i )
-       {
-       if ( iAllNodes[i]->Base().IsSelected() )
-           {
-           selectedNode = iAllNodes[i];
-           }
-       }
-    return selectedNode;   
-   }
-
-// -----------------------------------------------------------------------------
-// CIAUpdateMainView::Id
-// Get Uid of this view
-// -----------------------------------------------------------------------------
-//       
-TUid CIAUpdateMainView::Id() const
-    {
-    return TUid::Uid( EIAUpdateMainViewId );
-    }
-
-// -----------------------------------------------------------------------------
-// CIAUpdateMainView::HandleCommandL
-// 
-// -----------------------------------------------------------------------------
-// 
-void CIAUpdateMainView::HandleCommandL( TInt aCommand )
-    {
-    switch( aCommand ) 
-        {  
-        case EIAUpdateCmdStartUpdate:
+        int size = 0;
+        TBool shownInMegabytes = EFalse;        
+        if ( sizeInBytes >= KMaxShownInKiloBytes )
             {
-            RPointerArray<MIAUpdateAnyNode> selectedNodes;
-            CleanupClosePushL( selectedNodes );
-            GetSelectedNodesL( selectedNodes ); 
-            if ( selectedNodes[0]->NodeType() == MIAUpdateAnyNode::ENodeTypeFw )
-                {
-                //the marking logic will make sure firmware won't be marked with normal sis updates
-                //at the same time.
-                iFwUpdateHandler->FirmWareUpdatewithFOTA();
-                }
-            else
+            shownInMegabytes = ETrue;
+            size = sizeInBytes / KMegaByte;
+            if ( sizeInBytes % KMegaByte != 0 )
                 {
-                AppUi()->HandleCommandL( aCommand );
-                }
-            CleanupStack::PopAndDestroy( &selectedNodes );
-            break;    
-            }
-        case EIAUpdateCmdUpdateWithPC:
-            {
-            iFwUpdateHandler->FirmWareUpdatewithNSU();
-            break;
-            }
-        case EIAUpdateCmdSettings:
-            {
-            Toolbar()->SetToolbarVisibility( EFalse );
-            AppUi()->HandleCommandL( aCommand );
-            Toolbar()->SetToolbarVisibility( ETrue );
-            break;
-            }
-        case EAknSoftkeyMark:
-            {
-            iContainer->HandleMarkCommandL( EAknCmdMark );
-            break;	
-            }
-        case EAknSoftkeyUnmark:
-            {
-            iContainer->HandleMarkCommandL( EAknCmdUnmark );
-            break;	
-            }
-        case EAknCmdMark:        
-        case EAknCmdUnmark:
-            {
-            iContainer->HandleMarkCommandL( aCommand );
-            break;	
-            }
-        default:
-            { 
-            AppUi()->HandleCommandL( aCommand );
-            break;
-            }
-        }
-    }
-
-// -----------------------------------------------------------------------------
-// CIAUpdateMainView::DynInitMenuPaneL
-// Dim options which are not availble in empty list.
-// Set Mark/Unmark option
-// -----------------------------------------------------------------------------
-//    
-void CIAUpdateMainView::DynInitMenuPaneL( TInt aResourceId, CEikMenuPane* aMenuPane )
-    {
-    if( aResourceId == R_IAUPDATE_MAIN_MENU ) 
-        {
-        if ( !FeatureManager::FeatureSupported( KFeatureIdHelp ) )
-            {
-            aMenuPane->SetItemDimmed( EAknCmdHelp, ETrue );
-            }
-        RPointerArray<MIAUpdateAnyNode> selectedNodes;
-        CleanupClosePushL( selectedNodes );
-        GetSelectedNodesL( selectedNodes ); 
-                    
-        if ( selectedNodes.Count() )
-            {
-            if ( selectedNodes[0]->NodeType() == MIAUpdateAnyNode::ENodeTypeFw )
-                {
-                //firmware is selected
-                MIAUpdateFwNode* node = static_cast<MIAUpdateFwNode*>( selectedNodes[0] );
-            
-                if ( node->FwType() == MIAUpdateFwNode::EFotaDp2 )
-                    {
-                    aMenuPane->SetItemDimmed( EIAUpdateCmdUpdateWithPC, ETrue );
-                    }
-                    
-                if ( node->FwType() == MIAUpdateFwNode::EFotiNsu )
-                    {
-                    aMenuPane->SetItemDimmed( EIAUpdateCmdStartUpdate, ETrue );
-                    }
-                }
-            else
-                {
-                //firmware is not selected, only sis
-                aMenuPane->SetItemDimmed( EIAUpdateCmdUpdateWithPC, ETrue );
+                size++;
                 }
             }
-        else
+        else 
             {
-            aMenuPane->SetItemDimmed( EIAUpdateCmdStartUpdate, ETrue );
-            aMenuPane->SetItemDimmed( EIAUpdateCmdUpdateWithPC, ETrue );
-            }
-        CleanupStack::PopAndDestroy( &selectedNodes );
-        }
-    }
-    
-// -----------------------------------------------------------------------------
-// CIAUpdateMainView::DoActivateL
-// Activate view
-// -----------------------------------------------------------------------------
-// 
-void  CIAUpdateMainView::DoActivateL( const TVwsViewId& /*aPrevViewId*/, 
-                                      TUid /*aCustomMessageId*/, 
-                                      const TDesC8& /*aCustomMessage*/ )
-    {
-    UpdateStatusPaneL();
-    if( !iContainer )
-        {    
-        iContainer = CIAUpdateMainContainer::NewL( ClientRect(), *this );
-   
-        if( iAllNodes.Count() > 0 )
-            {            
-            iContainer->RefreshL( iAllNodes, iRefreshError );
+            size = sizeInBytes / KKiloByte;
+            if ( sizeInBytes % KKiloByte != 0 )
+                {
+                size++;
+                }  
             }
-  
-        SetSelectedIndicesL();  
-        DynInitToolbarL( R_IAUPDATE_MAIN_TOOLBAR, Toolbar() );
-        AppUi()->AddToStackL( iContainer ); 
-        }
-    else
-        {
-        UpdateSelectionInfoInNaviPaneL();	
-        }
-    }
-
-// -----------------------------------------------------------------------------
-// CIAUpdateMainView::DoDeactivate()
-// Container is deleted in deactivation
-// -----------------------------------------------------------------------------
-//
-void CIAUpdateMainView::DoDeactivate()
-    {
-    RemoveSelectionInfoInNaviPane();
-    }
+        QString sizeString;
+        sizeString.setNum(size);        
+        QString importanceDescription;
+        switch( node->Base().Importance() )
+            {        
+            case MIAUpdateBaseNode::EMandatory:
+                {
+                importanceDescription = "Required ";
+                importanceDescription.append(sizeString);
+                if ( shownInMegabytes )
+                    {
+                    importanceDescription.append(" MB" );
+                    }
+                else 
+                    {
+                    importanceDescription.append(" kB" );
+                    }  
+                break;
+                }
+            
+            
+            case MIAUpdateBaseNode::ECritical:
+                {
+                bool isNSU = false;
+                if( node->NodeType() == MIAUpdateAnyNode::ENodeTypeFw )
+                    {
+                    MIAUpdateFwNode* fwnode = static_cast<MIAUpdateFwNode*>( node );          
+                    if ( fwnode->FwType() == MIAUpdateFwNode::EFotiNsu )
+                        {
+                        isNSU = true;
+                        }
+                    }
+                
+                importanceDescription = "Important ";
+                if ( !size || isNSU )
+                    {
+                    //for firmware when size info is not provided by server
+                    }
+                else
+                    {
+                    importanceDescription.append(sizeString);
+                    if ( shownInMegabytes )
+                        {
+                        importanceDescription.append(" MB" );
+                        }
+                    else 
+                        {
+                        importanceDescription.append(" kB" );
+                        } 
+                    }
+     
+                break;
+                }
+        
+            case MIAUpdateBaseNode::ERecommended:
+                {
+                importanceDescription = "Recommended ";
+                importanceDescription.append(sizeString);
+                if ( shownInMegabytes )
+                    {
+                    importanceDescription.append(" MB" );
+                    }
+                else 
+                    {
+                    importanceDescription.append(" kB" );
+                    }  
+                break;
+                }
+        
+            case MIAUpdateBaseNode::ENormal:
+                {
+                importanceDescription = "Optional ";
+                importanceDescription.append(sizeString);
+                if ( shownInMegabytes )
+                    {
+                     importanceDescription.append(" MB" );
+                    }
+                else 
+                    {
+                    importanceDescription.append(" kB" );
+                    }  
+                break;
+                }
 
-// -----------------------------------------------------------------------------
-// CIAUpdateMainView::DynInitToolbarL()
-//
-// -----------------------------------------------------------------------------
-//
-void CIAUpdateMainView::DynInitToolbarL( TInt aResourceId, CAknToolbar* aToolbar )
-    {
-    if ( aResourceId == R_IAUPDATE_MAIN_TOOLBAR )
-        {
-        if ( iContainer )
-            {
-            if ( CountOfSelectedItems() > 0 )
+            default:
                 {
-                aToolbar->SetItemDimmed( EIAUpdateCmdStartUpdate, EFalse, ETrue );
-                }
-            else
-                {
-                aToolbar->SetItemDimmed( EIAUpdateCmdStartUpdate, ETrue, ETrue );
-                }
-            if ( CountOfSelectedItems() == 1 )
-                {
-                aToolbar->SetItemDimmed( EIAUpdateCmdMarkedUpdateDetails, EFalse, ETrue );
-                }
-            else
-                {
-                aToolbar->SetItemDimmed( EIAUpdateCmdMarkedUpdateDetails, ETrue, ETrue );
+                break;
                 }
             }
-        }
-    }
+            
+            //AknTextUtils::DisplayTextLanguageSpecificNumberConversion( ptr );    
+            
+            HbListWidgetItem *item = new HbListWidgetItem();    
+            QString name = XQConversions::s60DescToQString(node->Base().Name());
+            if ( node->NodeType() == MIAUpdateAnyNode::ENodeTypeFw ) 
+                {
+                name.append(" DEVICE SOFTWARE");
+                }
+            item->setText(name);
+            item->setSecondaryText(importanceDescription);
+            item->setIcon(icon);
+             mListView->addItem(item); 
+ 
+            if ( node-> Base().IsSelected() )
+                {
+                int count = mListView->indexCount();
+                QModelIndex modelIndex = mListView->model()->index(count-1,0);
+                selectionModel->select(modelIndex, QItemSelectionModel::Select);
+                }
 
-// -----------------------------------------------------------------------------
-// CIAUpdateMainView::OfferToolbarEventL()
-//
-// -----------------------------------------------------------------------------
-//            
-void CIAUpdateMainView::OfferToolbarEventL( TInt aCommand )
-    {
-    if ( aCommand == EIAUpdateCmdStartUpdate )
-        {
-        RPointerArray<MIAUpdateAnyNode> selectedNodes;
-        CleanupClosePushL( selectedNodes );
-        GetSelectedNodesL( selectedNodes ); 
-        
-        if ( selectedNodes.Count() )
+               
+            
+        /*if ( nodes.Count() == 0 )
             {
-            if ( selectedNodes[0]->NodeType() == MIAUpdateAnyNode::ENodeTypeFw )
+            HBufC* emptyText = NULL;
+            if ( aError )
                 {
-                //firmware is selected
-                MIAUpdateFwNode* node = static_cast<MIAUpdateFwNode*>( selectedNodes[0] );
-            
-                if ( node->FwType() == MIAUpdateFwNode::EFotaDp2 )
+                if ( aError == KErrCancel || aError == KErrAbort )
                     {
-                    aCommand = EIAUpdateCmdStartUpdate;
+                    emptyText = KNullDesC().AllocLC();
                     }
-                    
-                if ( node->FwType() == MIAUpdateFwNode::EFotiNsu )
+                else
                     {
-                    aCommand = EIAUpdateCmdUpdateWithPC;
+                    emptyText = StringLoader::LoadLC( R_IAUPDATE_REFRESH_FAILED );  
                     }
                 }
             else
                 {
-                //firmware is not selected, only sis
-                aCommand = EIAUpdateCmdStartUpdate;
+                emptyText = StringLoader::LoadLC( R_IAUPDATE_TEXT_NO_UPDATES ); 
                 }
-            }
-        else
-            {
-             MIAUpdateAnyNode* currentNode = GetCurrentNode(); 
-             if ( currentNode->NodeType() == MIAUpdateAnyNode::ENodeTypeFw )
-                 {
-                 MIAUpdateFwNode* node = static_cast<MIAUpdateFwNode*>( currentNode );
-                 if ( node->FwType() == MIAUpdateFwNode::EFotiNsu )
-                     {
-                     aCommand = EIAUpdateCmdUpdateWithPC;
-                     }
-                 } 
-            }
-
-        CleanupStack::PopAndDestroy( &selectedNodes );   
-        }
-    HandleCommandL( aCommand );
-    }
-
-
-
-// -----------------------------------------------------------------------------
-// CIAUpdateMainView::MarkListItemL
-// Mark list item
-// -----------------------------------------------------------------------------
-//    
-TBool CIAUpdateMainView::MarkListItemL( TBool aMark, TInt aIndex )
-    {
-    if ( aMark )
-        {
-        //It's Mark Command
-        RPointerArray<MIAUpdateAnyNode> selectedNodes;
-        CleanupClosePushL( selectedNodes );
-        GetSelectedNodesL( selectedNodes ); 
-        
-        //There are selected items already and type are different with the current one
-        if ( selectedNodes.Count() > 0 && (iAllNodes[aIndex]->NodeType() != selectedNodes[0]->NodeType() ) )
-            {       
-            /*HBufC* msgText = StringLoader::LoadLC(R_IAUPDATE_FIRMWARE_WITH_OTHERS);
-
-            CAknQueryDialog* dlg = CAknQueryDialog::NewL();
-       
-            dlg->ExecuteLD( R_IAUPDATE_INFORMATION_QUERY, *msgText );
             
-            CleanupStack::PopAndDestroy( msgText );*/
-            
-            //clean all of the current selection(s)
-            iContainer->CleanAllSelection();
-            
-            // firmware item and normal sis items can't be selected at the same time
-            // unmark the selected nodes.
-            for ( TInt i = 0; i < selectedNodes.Count(); i++ )
-                {                
-                TInt index = iAllNodes.Find( selectedNodes[i]);
-                iAllNodes[index]->Base().SetSelected( EFalse );
-                }
-            }
-        
-        CleanupStack::PopAndDestroy( &selectedNodes );
-        }
-    
-    //there is no selected items or the type is the same with the current one
-    
-    if ( iAllNodes[aIndex]->NodeType() == MIAUpdateAnyNode::ENodeTypeFw )
-        {
-        iAllNodes[aIndex]->Base().SetSelected( aMark );       
-        
-        if ( aMark )
-            {
-            SetMiddleSKTextL( ETrue, ETrue );
+            iListBox->View()->SetListEmptyTextL( *emptyText );
+            CleanupStack::PopAndDestroy( emptyText );
+            iListBox->ScrollBarFrame()->SetScrollBarVisibilityL( 
+                    CEikScrollBarFrame::EOff, CEikScrollBarFrame::EOff );  
             }
         else
             {
-            SetMiddleSKTextL( ETrue, EFalse );  
-            }  
-        UpdateSelectionInfoInNaviPaneL();
-        DynInitToolbarL( R_IAUPDATE_MAIN_TOOLBAR, Toolbar() );
-        return ETrue;
-        }
-    
-    if ( iAllNodes[aIndex]->NodeType() == MIAUpdateAnyNode::ENodeTypeNormal )
-        {
-        TBool accepted = EFalse;
-        
-        if( aIndex > -1 )
-            {
-            accepted = ETrue;
-            
-            MIAUpdateNode* node = static_cast<MIAUpdateNode*>( iAllNodes[aIndex] );
-            RPointerArray<MIAUpdateAnyNode> mands;
-            RPointerArray<MIAUpdateNode> deps;
-           
-            if ( aMark )
-                {
-                CleanupClosePushL( mands );
-                CleanupClosePushL( deps );
-                IAUpdateDepUtils::GetDependenciesL( *node, iAllNodes, deps );
-                GetMandatoryNodesL( mands );
-                }
-            else
-                {
-                //mandatory item is not allowed to be unmarked
-                if ( iAllNodes[aIndex]->Base().Importance() == MIAUpdateBaseNode::EMandatory )
-                    {
-                    //show dialog  
-                    ShowUpdateCannotOmitDialogL();
-                    return EFalse;
-                    }
-                
-                CleanupClosePushL( deps );
-                IAUpdateDepUtils::GetDependantsL( *node, iAllNodes, deps );  
-                // item is not allowed to be unmarked if its dependant is mandatory
-                TBool mandatoryDependantFound = EFalse;
-                for( TInt i = 0; i < deps.Count() && !mandatoryDependantFound; i++ )
-                     {
-                     if ( deps[i]->Base().Importance() == MIAUpdateBaseNode::EMandatory )
-                         {
-                         mandatoryDependantFound = ETrue;
-                         }
-                     }
-                if ( mandatoryDependantFound )
-                    {
-                    ShowUpdateCannotOmitDialogL();
-                    CleanupStack::PopAndDestroy( &deps );
-                    return EFalse;
-                    }
-                }
-             
-            TInt depCount = deps.Count();
-           
-            if ( depCount > 0 )
-                {
-                HBufC* text = NULL;
-                HBufC* names = NULL;
-                MIAUpdateNode* depNode = NULL;
-                HBufC* separator = NULL;
-                
-                if ( depCount > 1 )
-                    {                                 
-                    separator = StringLoader::LoadLC( R_IAUPDATE_SEPARATOR );
-                    }
-                
-                names = HBufC::NewLC( 0 );
-                       
-                for( TInt i = 0; i < depCount; i++ )  
-                    {
-                    depNode = deps[i];
-                    HBufC* temp = NULL;
-                    if ( separator )
-                        {
-                        temp = names->ReAllocL( names->Length() + 
-                                                depNode->Base().Name().Length() +
-                                                separator->Length() +
-                                                KSpace.iTypeLength );
-                        }
-                    else
-                        {
-                        temp = names->ReAllocL( names->Length() + 
-                                                depNode->Base().Name().Length() +
-                                                KSpace.iTypeLength );
-                        }
-                   
-                    CleanupStack::Pop( names );
-                    names = temp; 
-                    CleanupStack::PushL( names ); 
-                    
-                    if (  i > 0 )
-                        {
-                        names->Des() += *separator;
-                        names->Des() += KSpace; 
-                        }
-                    names->Des() += depNode->Base().Name();
-                    }
-                
-                TInt resourceId = 0;    
-                if ( aMark )
-                    {
-                    if ( depCount > 1 ) 
-                        {
-                        resourceId = R_IAUPDATE_DEPENDENCY_MARK_MANY;
-                        } 
-                    else
-                        {
-                        resourceId = R_IAUPDATE_DEPENDENCY_MARK_ONE;    
-                        }
-                    }
-                else
-                    {
-                    if ( depCount > 1 ) 
-                        {
-                        resourceId = R_IAUPDATE_DEPENDENCY_UNMARK_MANY;
-                        } 
-                    else
-                        {
-                        resourceId = R_IAUPDATE_DEPENDENCY_UNMARK_ONE;  
-                        }   
-                    }
-                text = StringLoader::LoadLC( resourceId, *names );
-                
-                if ( aMark && iAllNodes[aIndex]->Base().Importance() == MIAUpdateBaseNode::EMandatory )
-                    {
-                    // depencencies of mandatory update are also selected without showing dialog
-                    accepted = ETrue;
-                    }
-                else
-                    {
-                    accepted = ShowDependenciesFoundDialogL( *text );
-                    }
-                CleanupStack::PopAndDestroy( text );
-                CleanupStack::PopAndDestroy( names );
-                
-                if ( separator )
-                    {
-                    CleanupStack::PopAndDestroy( separator );
-                    }
-                }
-            
-            if ( accepted )
+            if ( iListBox->CurrentItemIndex() == KErrNotFound )
                 {
-                for( TInt j = 0; j < depCount; j++ )
-                    {
-                    TInt depNodeInd = iAllNodes.Find( deps[j] );
-                    iAllNodes[depNodeInd]->Base().SetSelected( aMark );
-                    }
-                CleanupStack::PopAndDestroy( &deps );
-                
-                TInt nodeInd = iAllNodes.Find( node );
-                iAllNodes[nodeInd]->Base().SetSelected( aMark );
-                }
-            else
-                {
-                //user rejects the dependency dialog
-                CleanupStack::PopAndDestroy( &deps );
-                if ( aMark )
-                    {
-                    CleanupStack::PopAndDestroy( &mands );
-                    }
-                return EFalse;
+                iListBox->SetCurrentItemIndex( aNodes.Count() - 1 );
                 }
-                
-            //mark all of the mandatory items
-            TInt mandCount = mands.Count();
-            if ( mandCount > 0 && aMark )
-                {
-                for( TInt j = 0; j < mandCount; j++ )
-                    {
-                    TInt mandNodeInd = iAllNodes.Find( mands[j] );
-                    iAllNodes[mandNodeInd]->Base().SetSelected( aMark );
-                    if ( iAllNodes[mandNodeInd]->NodeType() == MIAUpdateAnyNode::ENodeTypeNormal )
-                        {
-                        // mark also all dependencies of a mandatory item
-                        MIAUpdateNode* dependencyNode = static_cast<MIAUpdateNode*>( iAllNodes[mandNodeInd] );
-                        RPointerArray<MIAUpdateNode> dependencies;
-                        CleanupClosePushL( dependencies );
-                        IAUpdateDepUtils::GetDependenciesL( *dependencyNode, iAllNodes, dependencies );
-                        for( TInt k = 0; k < dependencies.Count(); k++ )
-                            {
-                            TInt depNodeInd = iAllNodes.Find( dependencies[k] );
-                            iAllNodes[depNodeInd]->Base().SetSelected( ETrue );
-                            }
-                        CleanupStack::PopAndDestroy( &dependencies );
-                        }
-                    }
-                }
-            if ( aMark )
-                {
-                CleanupStack::PopAndDestroy( &mands );
-                }
+            }*/
             
-            if ( depCount > 0 || mandCount > 0 )
-                {
-                SetSelectedIndicesL();
-                }
-            else
-                {
-                UpdateSelectionInfoInNaviPaneL();   
-                }
-               
-            if ( aMark )
-                {
-                SetMiddleSKTextL( ETrue, ETrue );
-                }
-            else
-                {
-                SetMiddleSKTextL( ETrue, EFalse );  
-                }        
-            }  
-        DynInitToolbarL( R_IAUPDATE_MAIN_TOOLBAR, Toolbar() );
-        return ETrue;
+        //iListBox->HandleItemAdditionL();
         }
-    return EFalse;
-    }
+     connect(selectionModel, SIGNAL(selectionChanged(QItemSelection,QItemSelection)),
+                    this, SLOT(handleSelectionChanged(QItemSelection)));     
     
-    
-   
-    
-// -----------------------------------------------------------------------------
-// CIAUpdateMainView::SetMiddleSKTextL
-// Middle soft key label to be set 
-// -----------------------------------------------------------------------------
-//    
-void CIAUpdateMainView::SetMiddleSKTextL( TBool aVisible, TBool aSelected )
-    {
-	CEikButtonGroupContainer* cbaGroup = Cba();
-	if ( cbaGroup )
-        {
-        cbaGroup->RemoveCommandFromStack( CEikButtonGroupContainer::EMiddleSoftkeyPosition, iLastCommandId );
-        if ( aVisible )
-            {
-        	HBufC* middleSKText = NULL;
-    	    if ( aSelected )
-        	    {
-        	    middleSKText = StringLoader::LoadLC( R_IAUPDATE_MSK_UNMARK );
-                TPtr mskPtr = middleSKText->Des();
-    	        cbaGroup->AddCommandToStackL(  
-    	                    CEikButtonGroupContainer::EMiddleSoftkeyPosition, 
-    	                    EAknSoftkeyUnmark, 
-    	                    mskPtr );
-    	        iLastCommandId = EAknSoftkeyUnmark;            
-                }
-            else
-                {
-                middleSKText = StringLoader::LoadLC( R_IAUPDATE_MSK_MARK );
-        	    TPtr mskPtr = middleSKText->Des();
-    	        cbaGroup->AddCommandToStackL( 
-    	                  CEikButtonGroupContainer::EMiddleSoftkeyPosition, 
-    	                  EAknSoftkeyMark, 
-    	                  mskPtr );
-    	        iLastCommandId = EAknSoftkeyMark;
-        	    }
-        	CleanupStack::PopAndDestroy( middleSKText );
-            }
-        }
-    }
+     IAUPDATE_TRACE("[IAUPDATE] IAUpdateMainView::refresh end");
+     }
 
-// -----------------------------------------------------------------------------
-// CIAUpdateMainView::GetSelectedNodesL
-// Get selected (marked) nodes
-// -----------------------------------------------------------------------------
-//
-void CIAUpdateMainView::GetSelectedNodesL( RPointerArray<MIAUpdateAnyNode>& aSelectedNodes ) const
-    {
-    for( TInt i = 0; i < iAllNodes.Count(); ++i )
-        {
-        if ( iAllNodes[i]->Base().IsSelected() )
-            {
-        	User::LeaveIfError( aSelectedNodes.Append( iAllNodes[i] ) );
-            }
-        }
-    }
-
-// -----------------------------------------------------------------------------
-// CIAUpdateMainView::GetMandatoryItemsL
-// Get selected (marked) nodes
-// -----------------------------------------------------------------------------
-//
-void CIAUpdateMainView::GetMandatoryNodesL( RPointerArray<MIAUpdateAnyNode>& aMandNodes ) const
-    {
-    for( TInt i = 0; i < iAllNodes.Count(); ++i )
-        {
-        if ( iAllNodes[i]->Base().Importance() == MIAUpdateBaseNode::EMandatory )
-            {
-            User::LeaveIfError( aMandNodes.Append( iAllNodes[i] ) );
-            }
-        }
-    }
 
 
 
-// -----------------------------------------------------------------------------
-// CIAUpdateMainView::SetSelectedIndicesL
-// Indices of selected items are passed to container 
-// -----------------------------------------------------------------------------
-//  
-void CIAUpdateMainView::SetSelectedIndicesL()
-    {
-    RArray<TInt> indices;
-        
-    CleanupClosePushL( indices );
-
-    for( TInt i = 0; i < iAllNodes.Count(); ++i )
-        {
-    	if ( iAllNodes[i]->Base().IsSelected() )
-    	    {
-    		User::LeaveIfError( indices.Append( i ) );
-    	    }
-        }
-        
-    iContainer->SetSelectedIndicesL( indices );
-    UpdateSelectionInfoInNaviPaneL();
- 
-    CleanupStack::PopAndDestroy( &indices );
-    }
-
-// -----------------------------------------------------------------------------
-// CIAUpdateMainView::NodeIndex
-// Get index of node 
-// -----------------------------------------------------------------------------
-//  
-TInt CIAUpdateMainView::NodeIndex( const MIAUpdateAnyNode& aNode ) const
-    {
-    TInt result = -1;
-    
-    for( TInt i = 0; i < iAllNodes.Count(); ++i )
-        {
-        if( &aNode == iAllNodes[i] )
-            {
-            result = i;
-            break;
-            }
-        }
-    return result;
-    }
-
-// -----------------------------------------------------------------------------
-// CIAUpdateMainView::UpdateStatusPaneL
-// Update title in status pane
-// -----------------------------------------------------------------------------
-// 
-    
-void CIAUpdateMainView::UpdateStatusPaneL()
-    {
-    CAknTitlePane* titlePane = 
-            static_cast< CAknTitlePane* >( StatusPane()->ControlL(
-                                           TUid::Uid( EEikStatusPaneUidTitle ) ) );
-    HBufC* text = StringLoader::LoadLC( R_IAUPDATE_TEXT_TITLE_MAIN_VIEW );
-    titlePane->SetTextL( *text );
-    CleanupStack::PopAndDestroy( text );        
-    }
+void IAUpdateMainView::handleStartUpdate()
+{
+     
+}
 
 
-// -----------------------------------------------------------------------------
-// CIAUpdateMainView::UpdateSelectionInfoInNaviPaneL
-// Update selection information in status pane
-// -----------------------------------------------------------------------------
-// 
-//
-void CIAUpdateMainView::UpdateSelectionInfoInNaviPaneL()
-    {
-    RemoveSelectionInfoInNaviPane();
-    
-    if ( iAllNodes.Count() > 0 )
-        {
-        //show empty navi pane when firmware is selected but no size info or it is NSU
-        if ( (iAllNodes[0]->NodeType() == MIAUpdateAnyNode::ENodeTypeFw) && iAllNodes[0]->Base().IsSelected() )
-            {
-            MIAUpdateFwNode* fwnode = static_cast<MIAUpdateFwNode*>( iAllNodes[0] );
-            if ( (iAllNodes[0]->Base().ContentSizeL() == 0) || (fwnode->FwType() == MIAUpdateFwNode::EFotiNsu)  )
-                {
-                return;
-                }
-            }
-        
-        if ( !iNaviPane )
-            {
-    	    iNaviPane = static_cast<CAknNavigationControlContainer*>
-               ( StatusPane()->ControlL( TUid::Uid(EEikStatusPaneUidNavi ) ) );
-            }
-        TInt selectedSizeInBytes = 0;
-        for( TInt i = 0; i < iAllNodes.Count(); ++i )
-            {
-            if ( iAllNodes[i]->Base().IsSelected() )
-                {
-            	selectedSizeInBytes += iAllNodes[i]->Base().ContentSizeL();
-                }
-            }
-                
-        
-        TInt resourceId = 0;
-        TInt selectedSize;
-        if ( selectedSizeInBytes >= KMaxShownInKiloBytes )
-            {
-    	    resourceId = R_IAUPDATE_NAVIPANE_MEGABYTE;
-    	    selectedSize = selectedSizeInBytes / KMegaByte;
-    	    if ( selectedSizeInBytes % KMegaByte != 0 )
-    	        {
-    	    	selectedSize++;
-    	        }
-            }
-        else 
-            {
-    	    resourceId = R_IAUPDATE_NAVIPANE_KILOBYTE;
-    	    selectedSize = selectedSizeInBytes / KKiloByte;
-    	    if ( selectedSizeInBytes % KKiloByte != 0 )
-    	        {
-    	    	selectedSize++;
-    	        }
-            }
-     
-        CArrayFix<TInt>* numberArray = 
-                 new ( ELeave ) CArrayFixFlat<TInt>( KSelInfoArrayGranularity );
-        CleanupStack::PushL( numberArray );
-        numberArray->AppendL( CountOfSelectedItems() ); 
-        numberArray->AppendL( iAllNodes.Count() );
-        numberArray->AppendL( selectedSize );
-    
-        HBufC* selectionInfo = StringLoader::LoadLC( resourceId, 
-                                                     *numberArray );
-        TPtr ptr = selectionInfo->Des();
-        AknTextUtils::DisplayTextLanguageSpecificNumberConversion( ptr ); 
-            
-        iDecorator = iNaviPane->CreateNavigationLabelL( *selectionInfo );
+void IAUpdateMainView::handleSettings()
+{
+}
 
-        iNaviPane->PushL( *iDecorator );
-        
-        CleanupStack::PopAndDestroy( selectionInfo ); 
-        CleanupStack::PopAndDestroy( numberArray );	
-        }
-    }
-
-// -----------------------------------------------------------------------------
-// CIAUpdateMainView::RemoveSelectionInfoInNaviPane
-// Remove existing selection info (created by main view) from navi pane
-// -----------------------------------------------------------------------------
-// 
+void IAUpdateMainView::handleDisclaimer()
+{
+    CIAUpdateAgreement* agreement = CIAUpdateAgreement::NewLC();
+    agreement->ShowAgreementL();
+    CleanupStack::PopAndDestroy( agreement);
+}
 
-void CIAUpdateMainView::RemoveSelectionInfoInNaviPane()
-    {
-    if ( iNaviPane && iDecorator )
-        {
-    	iNaviPane->Pop( iDecorator );
-    	delete iDecorator;
-    	iDecorator = NULL;
-        }
-    }
- 
-// -----------------------------------------------------------------------------
-// CIAUpdateMainView::ShowDependenciesFoundDialogL
-// 
-// -----------------------------------------------------------------------------
-//  
-TBool CIAUpdateMainView::ShowDependenciesFoundDialogL( TDesC& aText ) const
-    {
-	CAknMessageQueryDialog* dlg = CAknMessageQueryDialog::NewL( aText );
-    dlg->PrepareLC( R_IAUPDATE_MESSAGE_QUERY );
-    CAknPopupHeadingPane* headingPane = dlg->Heading();
-    HBufC* title = StringLoader::LoadLC( R_IAUPDATE_DEPENDENCY_TITLE );
-    headingPane->SetTextL( *title );
-    CleanupStack::PopAndDestroy( title );
-  
-    dlg->ButtonGroupContainer().SetCommandSetL( 
-                                  R_IAUPDATE_SOFTKEYS_CONTINUE_CANCEL__CONTINUE );
+void IAUpdateMainView::handleSelectionChanged(QItemSelection)
+{
 
-    return( dlg->RunLD() == EAknSoftkeyOk );
-    }
-    
-// ---------------------------------------------------------------------------
-// CIAUpdateMainView::CountOfSelectedItems
-// 
-// ---------------------------------------------------------------------------
-//     
-TInt CIAUpdateMainView::CountOfSelectedItems() const
-    {
-    TInt countOfSelectedItems = 0; 
-    for( TInt i = 0; i < iAllNodes.Count(); ++i )
-        {
-        if ( iAllNodes[i]->Base().IsSelected() )
-            {
-        	countOfSelectedItems++;
-            }
-        }
-    return countOfSelectedItems;   	
-    }
+}
 
-// ---------------------------------------------------------------------------
-// CIAUpdateMainView::ShowUpdateCannotOmitDialogL
-// 
-// ---------------------------------------------------------------------------
-//
-void CIAUpdateMainView::ShowUpdateCannotOmitDialogL() const
-    {
-    HBufC* msgText = StringLoader::LoadLC( R_IAUPDATE_CANNOT_OMIT );
-    CAknQueryDialog* dlg = CAknQueryDialog::NewL();
-    dlg->ExecuteLD( R_IAUPDATE_INFORMATION_QUERY, *msgText  );         
-    CleanupStack::PopAndDestroy( msgText );
-    }
-    
-// End of File
-    
+
+