iaupdate/IAD/ui/src/iaupdatemaincontainer.cpp
changeset 4 32704c33136d
equal deleted inserted replaced
-1:000000000000 4:32704c33136d
       
     1 /*
       
     2 * Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:   This module contains the implementation of CIAUpdateMainContainer class 
       
    15 *                member functions.
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 
       
    21 //INCLUDES
       
    22 #include <barsread.h>
       
    23 #include <coemain.h>
       
    24 #include <aknlists.h>
       
    25 #include <badesca.h> // CDesCArray
       
    26 #include <iaupdate.rsg>
       
    27 #include <avkon.mbg>
       
    28 #include <iaupdate.mbg>
       
    29 #include <AknIconArray.h> 
       
    30 #include <gulicon.h>
       
    31 #include <StringLoader.h>
       
    32 #include <data_caging_path_literals.hrh>
       
    33 #include <e32property.h>
       
    34 #include <featmgr.h>
       
    35 
       
    36 #include "iaupdatefwnode.h"
       
    37 #include "iaupdatemaincontainer.h"
       
    38 #include "iaupdatecontainerobserver.h"
       
    39 #include "iaupdateapplication.h"
       
    40 #include "iaupdatenode.h"
       
    41 #include "iaupdatebasenode.h"
       
    42 #include "iaupdateversion.h"
       
    43 #include "iaupdatefwnsmlpskeys.h"
       
    44 
       
    45 //MACROS
       
    46 _LIT( KTabulator, "\t" );
       
    47 _LIT( KOne, "1");
       
    48 _LIT( KTwo, "2");
       
    49 _LIT( KSpace, " ");
       
    50 
       
    51 //CONSTANTS
       
    52 const TInt KKiloByte = 1024;
       
    53 const TInt KMegaByte = 1024 * 1024;
       
    54 const TInt KMaxShownInKiloBytes = 10 * KMegaByte;
       
    55 
       
    56 _LIT( KSWUPDATE_HLP_MAIN, "SWUPDATE_HLP_MAIN" ); 
       
    57 
       
    58 // MACROS
       
    59 _LIT(KIAUpdateIconFileName, "IAUpdate.mif");
       
    60 
       
    61 //CONST
       
    62 
       
    63 const TUid KFOTAUid = {0x102072C4};
       
    64 
       
    65 // -----------------------------------------------------------------------------
       
    66 // CIAUpdateMainContainer::NewL
       
    67 // Two-phased constructor.
       
    68 // -----------------------------------------------------------------------------
       
    69 //
       
    70 CIAUpdateMainContainer* CIAUpdateMainContainer::NewL( 
       
    71                                          const TRect& aRect, 
       
    72                                          MIAUpdateContainerObserver& aObserver )
       
    73     {
       
    74     CIAUpdateMainContainer* self = CIAUpdateMainContainer::NewLC(aRect,aObserver);
       
    75     CleanupStack::Pop(self);
       
    76     return self;
       
    77     }
       
    78 
       
    79 // -----------------------------------------------------------------------------
       
    80 // CIAUpdateMainContainer::NewLC
       
    81 // 
       
    82 // -----------------------------------------------------------------------------
       
    83 //
       
    84 CIAUpdateMainContainer* CIAUpdateMainContainer::NewLC( 
       
    85                                           const TRect& aRect, 
       
    86                                           MIAUpdateContainerObserver& aObserver )
       
    87     {
       
    88     CIAUpdateMainContainer* self = new (ELeave) CIAUpdateMainContainer(aObserver);
       
    89     CleanupStack::PushL(self);
       
    90     self->ConstructL(aRect);
       
    91     return self;
       
    92     }
       
    93 // -----------------------------------------------------------------------------
       
    94 // CIAUpdateMainContainer::CIAUpdateMainContainer
       
    95 // C++ default constructor can NOT contain any code, that
       
    96 // might leave.
       
    97 // -----------------------------------------------------------------------------
       
    98 //
       
    99 CIAUpdateMainContainer::CIAUpdateMainContainer(MIAUpdateContainerObserver& aObserver)
       
   100     : iObserver( aObserver )
       
   101     {
       
   102     }
       
   103 
       
   104 // -----------------------------------------------------------------------------
       
   105 // CIAUpdateMainContainer::~CIAUpdateMainContainer
       
   106 // Destructor
       
   107 // -----------------------------------------------------------------------------
       
   108 //
       
   109 CIAUpdateMainContainer::~CIAUpdateMainContainer()
       
   110     {
       
   111 	delete iListBox;
       
   112     }
       
   113     
       
   114 // -----------------------------------------------------------------------------
       
   115 // CIAUpdateMainContainer::ConstructL
       
   116 // Symbian 2nd phase constructor can leave.
       
   117 // -----------------------------------------------------------------------------
       
   118 //
       
   119 void CIAUpdateMainContainer::ConstructL(const TRect& aRect )
       
   120     {
       
   121     // Create a window for this application view
       
   122     CreateWindowL();
       
   123 
       
   124     // Create list box
       
   125     iListBox = new (ELeave) CAknDoubleGraphicStyleListBox();
       
   126     iListBox->SetContainerWindowL( *this );
       
   127     
       
   128     TResourceReader reader;
       
   129     iEikonEnv->CreateResourceReaderLC( reader, R_IAUPDATE_UPDATES_LIST );
       
   130     iListBox->ConstructFromResourceL( reader );
       
   131     CleanupStack::PopAndDestroy();
       
   132     
       
   133     iListBox->ItemDrawer()->ColumnData()->EnableMarqueeL( ETrue );
       
   134 
       
   135     // Setup scroll bars
       
   136     iListBox->CreateScrollBarFrameL( ETrue );
       
   137     iListBox->ScrollBarFrame()->SetScrollBarVisibilityL( 
       
   138         CEikScrollBarFrame::EOn, CEikScrollBarFrame::EAuto );    
       
   139 
       
   140     // Create item text array
       
   141     iItemTextArray = new (ELeave) CDesCArrayFlat(2);    
       
   142     iListBox->Model()->SetItemTextArray( iItemTextArray );
       
   143     iListBox->Model()->SetOwnershipType( ELbmOwnsItemArray) ;
       
   144     
       
   145     HBufC* text = KNullDesC().AllocLC();    
       
   146     iListBox->View()->SetListEmptyTextL( *text );
       
   147     CleanupStack::PopAndDestroy( text );
       
   148    
       
   149     // Create icon array
       
   150     
       
   151     CFbsBitmap* bitmap = 0;
       
   152     CFbsBitmap* mask = 0;
       
   153 
       
   154     CArrayPtr<CGulIcon>* iconArray = new (ELeave) CAknIconArray( 3 );    
       
   155     CleanupStack::PushL( iconArray );
       
   156     
       
   157     AknIconUtils::CreateIconLC(
       
   158         bitmap, 
       
   159         mask, 
       
   160         AknIconUtils::AvkonIconFileName(), 
       
   161         EMbmAvkonQgn_prop_checkbox_on, 
       
   162         EMbmAvkonQgn_prop_checkbox_on_mask );
       
   163     CGulIcon* icon = CGulIcon::NewLC();
       
   164     icon->SetBitmap( bitmap );
       
   165     icon->SetMask( mask );
       
   166     icon->SetBitmapsOwnedExternally( EFalse );
       
   167     iconArray->AppendL( icon );
       
   168     
       
   169     CleanupStack::Pop( icon );
       
   170     CleanupStack::Pop( mask );
       
   171     CleanupStack::Pop( bitmap );
       
   172 
       
   173     AknIconUtils::CreateIconLC(
       
   174         bitmap, 
       
   175         mask, 
       
   176         AknIconUtils::AvkonIconFileName(), 
       
   177         EMbmAvkonQgn_prop_checkbox_off, 
       
   178         EMbmAvkonQgn_prop_checkbox_off_mask );
       
   179     icon = CGulIcon::NewLC();
       
   180     icon->SetBitmap( bitmap );
       
   181     icon->SetMask( mask );
       
   182     icon->SetBitmapsOwnedExternally( EFalse );
       
   183     iconArray->AppendL( icon );
       
   184     
       
   185     CleanupStack::Pop( icon );
       
   186     CleanupStack::Pop( mask );
       
   187     CleanupStack::Pop( bitmap );
       
   188     
       
   189     HBufC* iconFilePath = HBufC::NewLC( KDC_APP_BITMAP_DIR().Length() + 
       
   190                                         KIAUpdateIconFileName().Length() +2 );
       
   191     TPtr ptr = iconFilePath->Des();
       
   192     ptr.Append( KDC_APP_BITMAP_DIR );
       
   193     ptr.Append( KIAUpdateIconFileName );
       
   194           
       
   195     TRAPD( err, CreateIconL( bitmap, 
       
   196                              mask, 
       
   197                              *iconFilePath, 
       
   198                              EMbmIaupdateQgn_indi_important_add, 
       
   199                              EMbmIaupdateQgn_indi_important_add_mask ) ); 
       
   200     if ( err == KErrNone ) 
       
   201         {
       
   202         CleanupStack::PushL( bitmap );
       
   203         CleanupStack::PushL( mask );
       
   204         }
       
   205     else if ( err == KErrEof )
       
   206         {
       
   207         // icon does not exist in Z drive. I.e IAD eclipsed over phase 1 version.
       
   208         // So icon to be retrieved from C drive. 
       
   209         ptr.Zero();
       
   210     	ptr.Append( _L("C:") );
       
   211     	ptr.Append( KDC_APP_BITMAP_DIR );
       
   212         ptr.Append( KIAUpdateIconFileName );
       
   213         AknIconUtils::CreateIconLC(
       
   214                       bitmap, 
       
   215                       mask, 
       
   216                       *iconFilePath, 
       
   217                       EMbmIaupdateQgn_indi_important_add, 
       
   218                       EMbmIaupdateQgn_indi_important_add_mask );
       
   219         }
       
   220     else
       
   221         {
       
   222         User::Leave( err );	
       
   223         }
       
   224 
       
   225     icon = CGulIcon::NewLC();
       
   226     icon->SetBitmap( bitmap );
       
   227     icon->SetMask( mask );
       
   228     icon->SetBitmapsOwnedExternally( EFalse );
       
   229     iconArray->AppendL( icon );
       
   230     
       
   231     CleanupStack::Pop( icon );
       
   232     CleanupStack::Pop( mask );
       
   233     CleanupStack::Pop( bitmap );
       
   234     CleanupStack::PopAndDestroy( iconFilePath );
       
   235     
       
   236     CleanupStack::Pop( iconArray ); 
       
   237     iListBox->ItemDrawer()->ColumnData()->SetIconArray( iconArray );
       
   238 
       
   239     iListBox->SetListBoxObserver( this );
       
   240     
       
   241     // Set the windows size
       
   242     SetRect( aRect );
       
   243 
       
   244     // Activate the window, which makes it ready to be drawn
       
   245     ActivateL();
       
   246     }
       
   247 
       
   248 // -----------------------------------------------------------------------------
       
   249 // CIAUpdateMainContainer::HandleMarkCommandL
       
   250 // Handles Mark/Unmark commnds
       
   251 // -----------------------------------------------------------------------------
       
   252 //
       
   253 void CIAUpdateMainContainer::HandleMarkCommandL( TInt aCommand )
       
   254     {
       
   255     TInt index = iListBox->CurrentItemIndex();
       
   256        
       
   257     TBool markingAccepted = EFalse;
       
   258     if( !iListBox->View()->ItemIsSelected( index ) )                                                                                             
       
   259         {
       
   260         // aCommand is set to EAknCmdMark if current item is not selected.
       
   261         // That's because passed command id may be wrong when using touch UI 
       
   262         aCommand = EAknCmdMark;                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             
       
   263         markingAccepted = iObserver.MarkListItemL( ETrue, index );
       
   264         }
       
   265     else 
       
   266         {
       
   267         // aCommand is set to EAknCmdUnmark if current item is selected.
       
   268         // That's because passed command id may be wrong when using touch UI    
       
   269         aCommand = EAknCmdUnmark;
       
   270         markingAccepted = iObserver.MarkListItemL( EFalse, index ); 
       
   271         }
       
   272         
       
   273 	if ( markingAccepted )
       
   274 	    {
       
   275         AknSelectionService::HandleMarkableListProcessCommandL( aCommand, iListBox );
       
   276 	    }
       
   277     }
       
   278 
       
   279 // -----------------------------------------------------------------------------
       
   280 // CIAUpdateMainContainer::RefreshL
       
   281 // Refresh list
       
   282 // -----------------------------------------------------------------------------
       
   283 //
       
   284 void CIAUpdateMainContainer::RefreshL( const RPointerArray<MIAUpdateAnyNode>& aNodes,
       
   285                                        TInt aError )
       
   286     {
       
   287     iItemTextArray->Reset();
       
   288         
       
   289     for( TInt i = 0; i < aNodes.Count(); ++i ) 
       
   290         {
       
   291         MIAUpdateAnyNode* node = aNodes[i];
       
   292         TInt sizeInBytes = node->Base().ContentSizeL();
       
   293 
       
   294         TInt size = 0;
       
   295         TBool shownInMegabytes = EFalse;        
       
   296         if ( sizeInBytes >= KMaxShownInKiloBytes )
       
   297             {
       
   298     	    shownInMegabytes = ETrue;
       
   299     	    size = sizeInBytes / KMegaByte;
       
   300     	    if ( sizeInBytes % KMegaByte != 0 )
       
   301     	        {
       
   302     	    	size++;
       
   303     	        }
       
   304             }
       
   305         else 
       
   306             {
       
   307     	    size = sizeInBytes / KKiloByte;
       
   308     	    if ( sizeInBytes % KKiloByte != 0 )
       
   309     	        {
       
   310     	    	size++;
       
   311     	        }  
       
   312             }
       
   313             
       
   314         HBufC* importanceDescription( NULL );        
       
   315         switch( node->Base().Importance() )
       
   316         {        
       
   317         case MIAUpdateBaseNode::EMandatory:
       
   318             {
       
   319             if ( shownInMegabytes )
       
   320                 {
       
   321                 importanceDescription = StringLoader::LoadLC(
       
   322                                    R_IAUPDATE_DES_REQUIRED_UPDATE_MB, size );
       
   323                 }
       
   324             else 
       
   325                 {
       
   326                 importanceDescription = StringLoader::LoadLC(
       
   327                                    R_IAUPDATE_DES_REQUIRED_UPDATE_KB, size );   
       
   328                 }  
       
   329             break;
       
   330             }
       
   331         
       
   332         
       
   333         case MIAUpdateBaseNode::ECritical:
       
   334             {
       
   335             TBool isNSU = EFalse;
       
   336             if( node->NodeType() == MIAUpdateAnyNode::ENodeTypeFw )
       
   337                 {
       
   338                 MIAUpdateFwNode* fwnode = static_cast<MIAUpdateFwNode*>( node );          
       
   339                 if ( fwnode->FwType() == MIAUpdateFwNode::EFotiNsu )
       
   340                     {
       
   341                     isNSU = ETrue;
       
   342                     }
       
   343                 }
       
   344 
       
   345             if ( !size || isNSU )
       
   346                 {
       
   347                 //for firmware when size info is not provided by server
       
   348                 importanceDescription = StringLoader::LoadLC(
       
   349                                                        R_IAUPDATE_DES_CRITICAL_UPDATE_NO_SIZE );
       
   350                 }
       
   351             else
       
   352                 {
       
   353                 if ( shownInMegabytes )
       
   354                     {
       
   355                     importanceDescription = StringLoader::LoadLC(
       
   356                                        R_IAUPDATE_DES_CRITICAL_UPDATE_MB, size );
       
   357                     }
       
   358                 else 
       
   359                     {
       
   360                     importanceDescription = StringLoader::LoadLC(
       
   361                                        R_IAUPDATE_DES_CRITICAL_UPDATE_KB, size );   
       
   362                     } 
       
   363                 }
       
   364  
       
   365             break;
       
   366             }
       
   367     
       
   368         case MIAUpdateBaseNode::ERecommended:
       
   369             {
       
   370             if ( shownInMegabytes )
       
   371                 {
       
   372             	importanceDescription = StringLoader::LoadLC(
       
   373             	                   R_IAUPDATE_DES_RECOMMENDED_UPDATE_MB, size );
       
   374                 }
       
   375             else 
       
   376                 {
       
   377                 importanceDescription = StringLoader::LoadLC(
       
   378             	                   R_IAUPDATE_DES_RECOMMENDED_UPDATE_KB, size );	
       
   379                 }  
       
   380             break;
       
   381             }
       
   382     
       
   383         case MIAUpdateBaseNode::ENormal:
       
   384             {
       
   385             if ( shownInMegabytes )
       
   386                 {
       
   387             	importanceDescription = StringLoader::LoadLC(
       
   388             	                   R_IAUPDATE_DES_NORMAL_UPDATE_MB, size );
       
   389                 }
       
   390             else 
       
   391                 {
       
   392                 importanceDescription = StringLoader::LoadLC(
       
   393             	                   R_IAUPDATE_DES_NORMAL_UPDATE_KB, size );	
       
   394                 }  
       
   395             break;
       
   396             }
       
   397 
       
   398         default:
       
   399             {
       
   400             importanceDescription = KNullDesC().AllocLC();
       
   401             break;
       
   402             }
       
   403         }
       
   404         
       
   405         TPtr ptr = importanceDescription->Des();
       
   406         AknTextUtils::DisplayTextLanguageSpecificNumberConversion( ptr );    
       
   407         
       
   408         
       
   409         
       
   410         if ( node->NodeType() == MIAUpdateAnyNode::ENodeTypeNormal )  
       
   411             {       
       
   412             HBufC* name = node->Base().Name().AllocLC();
       
   413             HBufC* buffer = HBufC::NewLC( KOne.iTypeLength +
       
   414                                           KTabulator.iTypeLength + 
       
   415                                           name->Length() + 
       
   416                                           KTabulator.iTypeLength +
       
   417                                           importanceDescription->Length() );
       
   418             buffer->Des() = KOne();
       
   419             buffer->Des() += KTabulator();
       
   420             buffer->Des() += *name;
       
   421             buffer->Des() += KTabulator();
       
   422             buffer->Des() += *importanceDescription;        
       
   423             
       
   424             iItemTextArray->AppendL( *buffer );
       
   425             
       
   426             CleanupStack::PopAndDestroy( buffer );
       
   427             CleanupStack::PopAndDestroy( name );
       
   428             }
       
   429 
       
   430         
       
   431         if ( node->NodeType() == MIAUpdateAnyNode::ENodeTypeFw ) 
       
   432             {
       
   433             MIAUpdateFwNode* fwnode = static_cast<MIAUpdateFwNode*>( node );
       
   434             HBufC* firmwarename = HBufC::NewLC( node->Base().Name().Length() +
       
   435                                                 KSpace.iTypeLength +
       
   436                                                 fwnode->FwVersion1().Length() );  
       
   437             firmwarename->Des() = node->Base().Name();
       
   438             firmwarename->Des() += KSpace();
       
   439             firmwarename->Des() += fwnode->FwVersion1();
       
   440             
       
   441             
       
   442             HBufC* buffer = HBufC::NewLC( KOne.iTypeLength +
       
   443                                           KTabulator.iTypeLength + 
       
   444                                           firmwarename->Length() + 
       
   445                                           KTabulator.iTypeLength +
       
   446                                           importanceDescription->Length() +
       
   447                                           KTabulator.iTypeLength +
       
   448                                           KTwo.iTypeLength );
       
   449             buffer->Des() = KOne();
       
   450             buffer->Des() += KTabulator();
       
   451             buffer->Des() += *firmwarename;
       
   452             buffer->Des() += KTabulator();
       
   453             buffer->Des() += *importanceDescription;        
       
   454             buffer->Des() += KTabulator();
       
   455             buffer->Des() += KTwo();
       
   456             
       
   457             iItemTextArray->AppendL( *buffer );
       
   458             CleanupStack::PopAndDestroy( buffer );
       
   459             CleanupStack::PopAndDestroy( firmwarename );
       
   460             }
       
   461         
       
   462         CleanupStack::PopAndDestroy( importanceDescription );
       
   463         }    
       
   464     
       
   465     if ( aNodes.Count() == 0 )
       
   466         {
       
   467     	HBufC* emptyText = NULL;
       
   468         if ( aError )
       
   469             {
       
   470             if ( aError == KErrCancel || aError == KErrAbort )
       
   471                 {
       
   472         	    emptyText = KNullDesC().AllocLC();
       
   473                 }
       
   474             else
       
   475                 {
       
   476                 emptyText = StringLoader::LoadLC( R_IAUPDATE_REFRESH_FAILED );	
       
   477                 }
       
   478     	    }
       
   479         else
       
   480             {
       
   481             emptyText = StringLoader::LoadLC( R_IAUPDATE_TEXT_NO_UPDATES );	
       
   482             }
       
   483         
       
   484         iListBox->View()->SetListEmptyTextL( *emptyText );
       
   485         CleanupStack::PopAndDestroy( emptyText );
       
   486         iListBox->ScrollBarFrame()->SetScrollBarVisibilityL( 
       
   487                 CEikScrollBarFrame::EOff, CEikScrollBarFrame::EOff );  
       
   488         }
       
   489     else
       
   490         {
       
   491         if ( iListBox->CurrentItemIndex() == KErrNotFound )
       
   492             {
       
   493            	iListBox->SetCurrentItemIndex( aNodes.Count() - 1 );
       
   494             }
       
   495         }
       
   496         
       
   497     iListBox->HandleItemAdditionL();
       
   498     }
       
   499     
       
   500 // -----------------------------------------------------------------------------
       
   501 // CIAUpdateMainContainer::GetCurrentNode
       
   502 // 
       
   503 // -----------------------------------------------------------------------------
       
   504 //
       
   505 MIAUpdateAnyNode* CIAUpdateMainContainer::GetCurrentNode( 
       
   506                                     const RPointerArray<MIAUpdateAnyNode>& aNodes )    
       
   507     {
       
   508     MIAUpdateAnyNode* currentNode = NULL;
       
   509     
       
   510     TInt currentIndex = iListBox->CurrentItemIndex();
       
   511     
       
   512     if( currentIndex != -1 )
       
   513         {
       
   514         
       
   515         currentNode = aNodes[currentIndex];
       
   516         
       
   517         }
       
   518     return currentNode;
       
   519     }
       
   520 
       
   521 
       
   522 // -----------------------------------------------------------------------------
       
   523 // CIAUpdateMainContainer::SetSelectedIndicesL
       
   524 // 
       
   525 // -----------------------------------------------------------------------------
       
   526 //    
       
   527 void CIAUpdateMainContainer::SetSelectedIndicesL( 
       
   528                             const RArray<TInt>& aIndices )
       
   529     {    
       
   530     CArrayFixFlat<TInt>* indexes = new(ELeave) CArrayFixFlat<TInt>( aIndices.Count() + 1 );
       
   531     
       
   532     CleanupStack::PushL( indexes );
       
   533     
       
   534     for( TInt i = 0; i < aIndices.Count(); ++i )
       
   535         {
       
   536         indexes->AppendL( aIndices[i] );
       
   537         }
       
   538         
       
   539     iListBox->View()->SetSelectionIndexesL( indexes );
       
   540     
       
   541     UpdateMSKTextL();  
       
   542     CleanupStack::PopAndDestroy( indexes );
       
   543     }
       
   544 
       
   545 
       
   546 // -----------------------------------------------------------------------------
       
   547 // CIAUpdateMainContainer::CleanAllSelectionL
       
   548 // 
       
   549 // -----------------------------------------------------------------------------
       
   550 // 
       
   551 void CIAUpdateMainContainer::CleanAllSelection()
       
   552     {
       
   553     iListBox->View()->ClearSelection();
       
   554     }
       
   555 
       
   556 // -----------------------------------------------------------------------------
       
   557 // CIAUpdateMainContainer::OfferKeyEventL
       
   558 // Some key events are passed to the list componenent 
       
   559 // -----------------------------------------------------------------------------
       
   560 //       
       
   561 TKeyResponse CIAUpdateMainContainer::OfferKeyEventL( const TKeyEvent& aKeyEvent, 
       
   562                                                      TEventCode aType )
       
   563     {
       
   564     TKeyResponse response = EKeyWasNotConsumed;    
       
   565 
       
   566 
       
   567     if( FeatureManager::FeatureSupported( KFeatureIdSyncMlDmFota ) ) //NFUI
       
   568         {
       
   569         if (aKeyEvent.iScanCode == EStdKeyDevice0 
       
   570                 || aKeyEvent.iScanCode == EStdKeyDevice3 
       
   571                 || aKeyEvent.iScanCode ==   EStdKeyHash )
       
   572             {
       
   573          
       
   574             TBool value (EFalse);
       
   575             TInt err = RProperty::Get( KPSUidNSmlDMSyncApp, KFotaDLStatus, value );
       
   576             if (!err && value == 1)
       
   577                 {
       
   578     
       
   579                 TApaTaskList taskList(CEikonEnv::Static()->WsSession());
       
   580                 TApaTask task=taskList.FindApp( KFOTAUid );
       
   581            
       
   582                 if(task.Exists())
       
   583                     {
       
   584                     task.BringToForeground();
       
   585                     }
       
   586                 return EKeyWasConsumed;
       
   587                 }
       
   588             }
       
   589         }
       
   590  
       
   591     if( aType == EEventKey )
       
   592         {
       
   593         switch( aKeyEvent.iCode )
       
   594             {
       
   595             case EKeyUpArrow:
       
   596             case EKeyDownArrow:
       
   597                 {                    
       
   598                 response = iListBox->OfferKeyEventL(aKeyEvent, aType); 
       
   599                 UpdateMSKTextL();   
       
   600                 break;    
       
   601                 }
       
   602             default:
       
   603                 {
       
   604                 break;
       
   605                 }
       
   606              
       
   607             }
       
   608         }
       
   609     return response;        
       
   610     }
       
   611 
       
   612 // -----------------------------------------------------------------------------
       
   613 // CIAUpdateMainContainer::SizeChanged
       
   614 //  
       
   615 // -----------------------------------------------------------------------------
       
   616 //  
       
   617 void CIAUpdateMainContainer::SizeChanged()
       
   618     {
       
   619     iListBox->SetRect( Rect() );
       
   620     }
       
   621 
       
   622 // -----------------------------------------------------------------------------
       
   623 // CIAUpdateMainContainer::CountComponentControls
       
   624 //  
       
   625 // -----------------------------------------------------------------------------
       
   626 //  
       
   627 TInt CIAUpdateMainContainer::CountComponentControls() const
       
   628     {
       
   629     if ( iListBox )
       
   630         {
       
   631     	return 1;
       
   632         }
       
   633     else
       
   634         {
       
   635         return 0;	
       
   636         }
       
   637     }
       
   638 
       
   639 // -----------------------------------------------------------------------------
       
   640 // CIAUpdateMainContainer::ComponentControl
       
   641 //  
       
   642 // -----------------------------------------------------------------------------
       
   643 // 
       
   644 CCoeControl* CIAUpdateMainContainer::ComponentControl( TInt aIndex ) const
       
   645     {
       
   646     CCoeControl* control = 0;
       
   647 
       
   648     switch( aIndex )
       
   649         {
       
   650         case 0:
       
   651             control = iListBox;
       
   652             break;
       
   653         default:
       
   654             break;
       
   655         }
       
   656     return control;
       
   657     }
       
   658 
       
   659 
       
   660 // ---------------------------------------------------------------------------
       
   661 // CIAUpdateMainContainer::GetHelpContext
       
   662 // 
       
   663 // ---------------------------------------------------------------------------
       
   664 //
       
   665 void CIAUpdateMainContainer::GetHelpContext( TCoeHelpContext& aContext ) const
       
   666     {
       
   667     aContext.iMajor = KUidIAUpdateApp;
       
   668     aContext.iContext = KSWUPDATE_HLP_MAIN;    
       
   669     }
       
   670 
       
   671 // ---------------------------------------------------------------------------
       
   672 // CIAUpdateMainContainer::HandleResourceChange
       
   673 // 
       
   674 // ---------------------------------------------------------------------------
       
   675 //
       
   676 void CIAUpdateMainContainer::HandleResourceChange( TInt aType )
       
   677     {
       
   678 	CCoeControl::HandleResourceChange( aType );
       
   679 
       
   680     if ( aType == KEikDynamicLayoutVariantSwitch ) //Handle change in layout orientation
       
   681         {
       
   682         TRect mainPaneRect;
       
   683         AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EMainPane, mainPaneRect );
       
   684         SetRect( mainPaneRect );
       
   685 		DrawNow();
       
   686 		}
       
   687     }
       
   688 
       
   689 // -----------------------------------------------------------------------------
       
   690 // CIAUpdateMainContainer::UpdateMSKTextL
       
   691 //  
       
   692 // -----------------------------------------------------------------------------
       
   693 //        
       
   694 void CIAUpdateMainContainer::UpdateMSKTextL()
       
   695 	{
       
   696 	TInt index = iListBox->CurrentItemIndex();
       
   697 	if (index < 0 )
       
   698 	    {
       
   699 		iObserver.SetMiddleSKTextL( EFalse, EFalse );
       
   700 	    }
       
   701 	else if ( iListBox->View()->ItemIsSelected( index ) )
       
   702 	    {
       
   703 		iObserver.SetMiddleSKTextL( ETrue, ETrue );
       
   704 	    }
       
   705 	else
       
   706 	    {
       
   707 	    iObserver.SetMiddleSKTextL( ETrue, EFalse );	
       
   708 	    }    
       
   709 	}
       
   710 
       
   711 
       
   712 // -----------------------------------------------------------------------------
       
   713 // CIAUpdateMainContainer::HandleListBoxEventL
       
   714 //  
       
   715 // -----------------------------------------------------------------------------
       
   716 //  
       
   717 void CIAUpdateMainContainer::HandleListBoxEventL( CEikListBox* /*aListBox*/,
       
   718                                                   TListBoxEvent aEventType )
       
   719     {
       
   720 
       
   721     switch  ( aEventType )
       
   722         {
       
   723         case EEventItemSingleClicked:
       
   724         case EEventEnterKeyPressed:
       
   725             {
       
   726             TInt index = iListBox->CurrentItemIndex();
       
   727             if( iListBox->View()->ItemIsSelected( index ) )
       
   728                 {
       
   729                 HandleMarkCommandL( EAknCmdUnmark );
       
   730                 }
       
   731             else
       
   732                 {
       
   733                 HandleMarkCommandL( EAknCmdMark );
       
   734                 }            
       
   735             break;
       
   736             }        
       
   737         default:
       
   738             {
       
   739             break;
       
   740             }
       
   741         }
       
   742     }
       
   743 
       
   744 // -----------------------------------------------------------------------------
       
   745 // CIAUpdateMainContainer::CreateIconL
       
   746 //  
       
   747 // -----------------------------------------------------------------------------
       
   748 // 
       
   749 void CIAUpdateMainContainer::CreateIconL( CFbsBitmap*& aBitmap,
       
   750                                           CFbsBitmap*& aMask,
       
   751                                           const TDesC& aFileName,
       
   752                                           TInt aBitmapId,
       
   753                                           TInt aMaskId )
       
   754     {
       
   755 	AknIconUtils::CreateIconLC( aBitmap,
       
   756                                 aMask, 
       
   757                                 aFileName,  
       
   758                                 aBitmapId,
       
   759                                 aMaskId );
       
   760     CleanupStack::Pop( aMask );
       
   761     CleanupStack::Pop( aBitmap );
       
   762     }