iaupdate/IAD/ui/src/iaupdatemaincontainer.cpp
changeset 0 ba25891c3a9e
child 2 661f3784fe57
equal deleted inserted replaced
-1:000000000000 0:ba25891c3a9e
       
     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 
       
   413             MIAUpdateNode* normalnode = static_cast<MIAUpdateNode*>( node );
       
   414 
       
   415             HBufC* nameAndVersion = NULL;
       
   416 
       
   417             if ( normalnode->Type() == MIAUpdateNode::EPackageTypeServicePack )
       
   418                 {
       
   419                 nameAndVersion = node->Base().Name().AllocLC();
       
   420                 }
       
   421             else
       
   422                 {
       
   423                 CDesCArray* stringArray = new ( ELeave ) CDesCArrayFlat( 1 );  
       
   424                 CleanupStack::PushL( stringArray );  
       
   425             
       
   426                 stringArray->AppendL( node->Base().Name() );  
       
   427             
       
   428                 CArrayFixFlat<TInt>* numberArray = new ( ELeave ) CArrayFixFlat<TInt>( 2 );
       
   429                 CleanupStack::PushL( numberArray );
       
   430             
       
   431                 numberArray->AppendL( node->Base().Version().iMajor ); 
       
   432                 numberArray->AppendL( node->Base().Version().iMinor );  
       
   433               
       
   434                     
       
   435                 nameAndVersion = StringLoader::LoadL( R_IAUPDATE_NAME_WITH_VERSION, 
       
   436                                                           *stringArray, 
       
   437                                                           *numberArray );
       
   438 
       
   439                 CleanupStack::PopAndDestroy( numberArray );
       
   440                 CleanupStack::PopAndDestroy( stringArray );
       
   441                 
       
   442                 CleanupStack::PushL( nameAndVersion ); 
       
   443                 }
       
   444 
       
   445             
       
   446             TPtr nameAndVersionPtr = nameAndVersion->Des();
       
   447             AknTextUtils::DisplayTextLanguageSpecificNumberConversion( nameAndVersionPtr );
       
   448             
       
   449             HBufC* buffer = HBufC::NewLC( KOne.iTypeLength +
       
   450                                           KTabulator.iTypeLength + 
       
   451                                           nameAndVersion->Length() + 
       
   452                                           KTabulator.iTypeLength +
       
   453                                           importanceDescription->Length() );
       
   454             buffer->Des() = KOne();
       
   455             buffer->Des() += KTabulator();
       
   456             buffer->Des() += *nameAndVersion;
       
   457             buffer->Des() += KTabulator();
       
   458             buffer->Des() += *importanceDescription;        
       
   459             
       
   460             iItemTextArray->AppendL( *buffer );
       
   461             
       
   462             CleanupStack::PopAndDestroy( buffer );
       
   463             CleanupStack::PopAndDestroy( nameAndVersion );
       
   464             }
       
   465 
       
   466         
       
   467         if ( node->NodeType() == MIAUpdateAnyNode::ENodeTypeFw ) 
       
   468             {
       
   469             MIAUpdateFwNode* fwnode = static_cast<MIAUpdateFwNode*>( node );
       
   470             HBufC* firmwarename = HBufC::NewLC( node->Base().Name().Length() +
       
   471                                                 KSpace.iTypeLength +
       
   472                                                 fwnode->FwVersion1().Length() );  
       
   473             firmwarename->Des() = node->Base().Name();
       
   474             firmwarename->Des() += KSpace();
       
   475             firmwarename->Des() += fwnode->FwVersion1();
       
   476             
       
   477             
       
   478             HBufC* buffer = HBufC::NewLC( KOne.iTypeLength +
       
   479                                           KTabulator.iTypeLength + 
       
   480                                           firmwarename->Length() + 
       
   481                                           KTabulator.iTypeLength +
       
   482                                           importanceDescription->Length() +
       
   483                                           KTabulator.iTypeLength +
       
   484                                           KTwo.iTypeLength );
       
   485             buffer->Des() = KOne();
       
   486             buffer->Des() += KTabulator();
       
   487             buffer->Des() += *firmwarename;
       
   488             buffer->Des() += KTabulator();
       
   489             buffer->Des() += *importanceDescription;        
       
   490             buffer->Des() += KTabulator();
       
   491             buffer->Des() += KTwo();
       
   492             
       
   493             iItemTextArray->AppendL( *buffer );
       
   494             CleanupStack::PopAndDestroy( buffer );
       
   495             CleanupStack::PopAndDestroy( firmwarename );
       
   496             }
       
   497 
       
   498         
       
   499 
       
   500         
       
   501         CleanupStack::PopAndDestroy( importanceDescription );
       
   502         }    
       
   503     
       
   504     if ( aNodes.Count() == 0 )
       
   505         {
       
   506     	HBufC* emptyText = NULL;
       
   507         if ( aError )
       
   508             {
       
   509             if ( aError == KErrCancel || aError == KErrAbort )
       
   510                 {
       
   511         	    emptyText = KNullDesC().AllocLC();
       
   512                 }
       
   513             else
       
   514                 {
       
   515                 emptyText = StringLoader::LoadLC( R_IAUPDATE_REFRESH_FAILED );	
       
   516                 }
       
   517     	    }
       
   518         else
       
   519             {
       
   520             emptyText = StringLoader::LoadLC( R_IAUPDATE_TEXT_NO_UPDATES );	
       
   521             }
       
   522         
       
   523         iListBox->View()->SetListEmptyTextL( *emptyText );
       
   524         CleanupStack::PopAndDestroy( emptyText );
       
   525         iListBox->ScrollBarFrame()->SetScrollBarVisibilityL( 
       
   526                 CEikScrollBarFrame::EOff, CEikScrollBarFrame::EOff );  
       
   527         }
       
   528     else
       
   529         {
       
   530         if ( iListBox->CurrentItemIndex() == KErrNotFound )
       
   531             {
       
   532            	iListBox->SetCurrentItemIndex( aNodes.Count() - 1 );
       
   533             }
       
   534         }
       
   535         
       
   536     iListBox->HandleItemAdditionL();
       
   537     }
       
   538     
       
   539 // -----------------------------------------------------------------------------
       
   540 // CIAUpdateMainContainer::GetCurrentNode
       
   541 // 
       
   542 // -----------------------------------------------------------------------------
       
   543 //
       
   544 MIAUpdateAnyNode* CIAUpdateMainContainer::GetCurrentNode( 
       
   545                                     const RPointerArray<MIAUpdateAnyNode>& aNodes )    
       
   546     {
       
   547     MIAUpdateAnyNode* currentNode = NULL;
       
   548     
       
   549     TInt currentIndex = iListBox->CurrentItemIndex();
       
   550     
       
   551     if( currentIndex != -1 )
       
   552         {
       
   553         
       
   554         currentNode = aNodes[currentIndex];
       
   555         
       
   556         }
       
   557     return currentNode;
       
   558     }
       
   559 
       
   560 
       
   561 // -----------------------------------------------------------------------------
       
   562 // CIAUpdateMainContainer::SetSelectedIndicesL
       
   563 // 
       
   564 // -----------------------------------------------------------------------------
       
   565 //    
       
   566 void CIAUpdateMainContainer::SetSelectedIndicesL( 
       
   567                             const RArray<TInt>& aIndices )
       
   568     {    
       
   569     CArrayFixFlat<TInt>* indexes = new(ELeave) CArrayFixFlat<TInt>( aIndices.Count() + 1 );
       
   570     
       
   571     CleanupStack::PushL( indexes );
       
   572     
       
   573     for( TInt i = 0; i < aIndices.Count(); ++i )
       
   574         {
       
   575         indexes->AppendL( aIndices[i] );
       
   576         }
       
   577         
       
   578     iListBox->View()->SetSelectionIndexesL( indexes );
       
   579     
       
   580     UpdateMSKTextL();  
       
   581     CleanupStack::PopAndDestroy( indexes );
       
   582     }
       
   583 
       
   584 
       
   585 // -----------------------------------------------------------------------------
       
   586 // CIAUpdateMainContainer::CleanAllSelectionL
       
   587 // 
       
   588 // -----------------------------------------------------------------------------
       
   589 // 
       
   590 void CIAUpdateMainContainer::CleanAllSelection()
       
   591     {
       
   592     iListBox->View()->ClearSelection();
       
   593     }
       
   594 
       
   595 // -----------------------------------------------------------------------------
       
   596 // CIAUpdateMainContainer::OfferKeyEventL
       
   597 // Some key events are passed to the list componenent 
       
   598 // -----------------------------------------------------------------------------
       
   599 //       
       
   600 TKeyResponse CIAUpdateMainContainer::OfferKeyEventL( const TKeyEvent& aKeyEvent, 
       
   601                                                      TEventCode aType )
       
   602     {
       
   603     TKeyResponse response = EKeyWasNotConsumed;    
       
   604 
       
   605 
       
   606     if( FeatureManager::FeatureSupported( KFeatureIdSyncMlDmFota ) ) //NFUI
       
   607         {
       
   608         if (aKeyEvent.iScanCode == EStdKeyDevice0 
       
   609                 || aKeyEvent.iScanCode == EStdKeyDevice3 
       
   610                 || aKeyEvent.iScanCode ==   EStdKeyHash )
       
   611             {
       
   612          
       
   613             TBool value (EFalse);
       
   614             TInt err = RProperty::Get( KPSUidNSmlDMSyncApp, KFotaDLStatus, value );
       
   615             if (!err && value == 1)
       
   616                 {
       
   617     
       
   618                 TApaTaskList taskList(CEikonEnv::Static()->WsSession());
       
   619                 TApaTask task=taskList.FindApp( KFOTAUid );
       
   620            
       
   621                 if(task.Exists())
       
   622                     {
       
   623                     task.BringToForeground();
       
   624                     }
       
   625                 return EKeyWasConsumed;
       
   626                 }
       
   627             }
       
   628         }
       
   629  
       
   630     if( aType == EEventKey )
       
   631         {
       
   632         switch( aKeyEvent.iCode )
       
   633             {
       
   634             case EKeyUpArrow:
       
   635             case EKeyDownArrow:
       
   636                 {                    
       
   637                 response = iListBox->OfferKeyEventL(aKeyEvent, aType); 
       
   638                 UpdateMSKTextL();   
       
   639                 break;    
       
   640                 }
       
   641             default:
       
   642                 {
       
   643                 break;
       
   644                 }
       
   645              
       
   646             }
       
   647         }
       
   648     return response;        
       
   649     }
       
   650 
       
   651 // -----------------------------------------------------------------------------
       
   652 // CIAUpdateMainContainer::SizeChanged
       
   653 //  
       
   654 // -----------------------------------------------------------------------------
       
   655 //  
       
   656 void CIAUpdateMainContainer::SizeChanged()
       
   657     {
       
   658     iListBox->SetRect( Rect() );
       
   659     }
       
   660 
       
   661 // -----------------------------------------------------------------------------
       
   662 // CIAUpdateMainContainer::CountComponentControls
       
   663 //  
       
   664 // -----------------------------------------------------------------------------
       
   665 //  
       
   666 TInt CIAUpdateMainContainer::CountComponentControls() const
       
   667     {
       
   668     if ( iListBox )
       
   669         {
       
   670     	return 1;
       
   671         }
       
   672     else
       
   673         {
       
   674         return 0;	
       
   675         }
       
   676     }
       
   677 
       
   678 // -----------------------------------------------------------------------------
       
   679 // CIAUpdateMainContainer::ComponentControl
       
   680 //  
       
   681 // -----------------------------------------------------------------------------
       
   682 // 
       
   683 CCoeControl* CIAUpdateMainContainer::ComponentControl( TInt aIndex ) const
       
   684     {
       
   685     CCoeControl* control = 0;
       
   686 
       
   687     switch( aIndex )
       
   688         {
       
   689         case 0:
       
   690             control = iListBox;
       
   691             break;
       
   692         default:
       
   693             break;
       
   694         }
       
   695     return control;
       
   696     }
       
   697 
       
   698 
       
   699 // ---------------------------------------------------------------------------
       
   700 // CIAUpdateMainContainer::GetHelpContext
       
   701 // 
       
   702 // ---------------------------------------------------------------------------
       
   703 //
       
   704 void CIAUpdateMainContainer::GetHelpContext( TCoeHelpContext& aContext ) const
       
   705     {
       
   706     aContext.iMajor = KUidIAUpdateApp;
       
   707     aContext.iContext = KSWUPDATE_HLP_MAIN;    
       
   708     }
       
   709 
       
   710 // ---------------------------------------------------------------------------
       
   711 // CIAUpdateMainContainer::HandleResourceChange
       
   712 // 
       
   713 // ---------------------------------------------------------------------------
       
   714 //
       
   715 void CIAUpdateMainContainer::HandleResourceChange( TInt aType )
       
   716     {
       
   717 	CCoeControl::HandleResourceChange( aType );
       
   718 
       
   719     if ( aType == KEikDynamicLayoutVariantSwitch ) //Handle change in layout orientation
       
   720         {
       
   721         TRect mainPaneRect;
       
   722         AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EMainPane, mainPaneRect );
       
   723         SetRect( mainPaneRect );
       
   724 		DrawNow();
       
   725 		}
       
   726     }
       
   727 
       
   728 // -----------------------------------------------------------------------------
       
   729 // CIAUpdateMainContainer::UpdateMSKTextL
       
   730 //  
       
   731 // -----------------------------------------------------------------------------
       
   732 //        
       
   733 void CIAUpdateMainContainer::UpdateMSKTextL()
       
   734 	{
       
   735 	TInt index = iListBox->CurrentItemIndex();
       
   736 	if (index < 0 )
       
   737 	    {
       
   738 		iObserver.SetMiddleSKTextL( EFalse, EFalse );
       
   739 	    }
       
   740 	else if ( iListBox->View()->ItemIsSelected( index ) )
       
   741 	    {
       
   742 		iObserver.SetMiddleSKTextL( ETrue, ETrue );
       
   743 	    }
       
   744 	else
       
   745 	    {
       
   746 	    iObserver.SetMiddleSKTextL( ETrue, EFalse );	
       
   747 	    }    
       
   748 	}
       
   749 
       
   750 
       
   751 // -----------------------------------------------------------------------------
       
   752 // CIAUpdateMainContainer::HandleListBoxEventL
       
   753 //  
       
   754 // -----------------------------------------------------------------------------
       
   755 //  
       
   756 void CIAUpdateMainContainer::HandleListBoxEventL( CEikListBox* /*aListBox*/,
       
   757                                                   TListBoxEvent aEventType )
       
   758     {
       
   759 
       
   760     switch  ( aEventType )
       
   761         {
       
   762         case EEventItemSingleClicked:
       
   763         case EEventEnterKeyPressed:
       
   764             {
       
   765             TInt index = iListBox->CurrentItemIndex();
       
   766             if( iListBox->View()->ItemIsSelected( index ) )
       
   767                 {
       
   768                 HandleMarkCommandL( EAknCmdUnmark );
       
   769                 }
       
   770             else
       
   771                 {
       
   772                 HandleMarkCommandL( EAknCmdMark );
       
   773                 }            
       
   774             break;
       
   775             }        
       
   776         default:
       
   777             {
       
   778             break;
       
   779             }
       
   780         }
       
   781     }
       
   782 
       
   783 // -----------------------------------------------------------------------------
       
   784 // CIAUpdateMainContainer::CreateIconL
       
   785 //  
       
   786 // -----------------------------------------------------------------------------
       
   787 // 
       
   788 void CIAUpdateMainContainer::CreateIconL( CFbsBitmap*& aBitmap,
       
   789                                           CFbsBitmap*& aMask,
       
   790                                           const TDesC& aFileName,
       
   791                                           TInt aBitmapId,
       
   792                                           TInt aMaskId )
       
   793     {
       
   794 	AknIconUtils::CreateIconLC( aBitmap,
       
   795                                 aMask, 
       
   796                                 aFileName,  
       
   797                                 aBitmapId,
       
   798                                 aMaskId );
       
   799     CleanupStack::Pop( aMask );
       
   800     CleanupStack::Pop( aBitmap );
       
   801     }