appinstaller/AppinstUi/sisxsifplugin/src/sisxsifuiselectioncache.cpp
branchRCL_3
changeset 25 7333d7932ef7
equal deleted inserted replaced
24:5cc91383ab1e 25:7333d7932ef7
       
     1 /*
       
     2 * Copyright (c) 2002-2010 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: CSisxSifUiSelectionCache saves user-selections so that
       
    15 *              they can be re-used without displaying the same UI
       
    16 *              dialog again.
       
    17 */
       
    18 
       
    19 
       
    20 #include "sisxsifuiselectioncache.h"        // CSisxSifUiSelectionCache
       
    21 
       
    22 
       
    23 // ======== MEMBER FUNCTIONS ========
       
    24 
       
    25 // -----------------------------------------------------------------------------
       
    26 // CSisxSifUiSelectionCache::CSisxSifUiSelectionCache()
       
    27 // -----------------------------------------------------------------------------
       
    28 //
       
    29 CSisxSifUiSelectionCache::CSisxSifUiSelectionCache()
       
    30     {
       
    31     }
       
    32 
       
    33 // -----------------------------------------------------------------------------
       
    34 // CSisxSifUiSelectionCache::ConstructL()
       
    35 // -----------------------------------------------------------------------------
       
    36 //
       
    37 void CSisxSifUiSelectionCache::ConstructL()
       
    38     {
       
    39     }
       
    40 
       
    41 // -----------------------------------------------------------------------------
       
    42 // CSisxSifUiSelectionCache::NewL()
       
    43 // -----------------------------------------------------------------------------
       
    44 //
       
    45 CSisxSifUiSelectionCache* CSisxSifUiSelectionCache::NewL()
       
    46     {
       
    47     CSisxSifUiSelectionCache* self = new( ELeave ) CSisxSifUiSelectionCache();
       
    48     CleanupStack::PushL( self );
       
    49     self->ConstructL();
       
    50     CleanupStack::Pop( self );
       
    51     return self;    
       
    52     }
       
    53     
       
    54 // -----------------------------------------------------------------------------
       
    55 // CSisxSifUiSelectionCache::~CSisxSifUiSelectionCache()
       
    56 // -----------------------------------------------------------------------------
       
    57 //
       
    58 CSisxSifUiSelectionCache::~CSisxSifUiSelectionCache()
       
    59     {
       
    60     iOptions.ResetAndDestroy();
       
    61     iSelections.Reset(); 
       
    62     }
       
    63 
       
    64 // -----------------------------------------------------------------------------
       
    65 // CSisxUISelectionCacheAppInfo::LanguageCached()
       
    66 // -----------------------------------------------------------------------------
       
    67 //
       
    68 TBool CSisxSifUiSelectionCache::LanguageCached() const
       
    69     {
       
    70     return iLanguageCached;    
       
    71     }
       
    72        
       
    73 // -----------------------------------------------------------------------------
       
    74 // CSisxUISelectionCacheAppInfo::Language()
       
    75 // -----------------------------------------------------------------------------
       
    76 //
       
    77 TLanguage CSisxSifUiSelectionCache::Language() const
       
    78     {
       
    79     return iLanguage;    
       
    80     }
       
    81 
       
    82 // -----------------------------------------------------------------------------
       
    83 // CSisxUISelectionCacheAppInfo::SetLanguage()
       
    84 // -----------------------------------------------------------------------------
       
    85 //
       
    86 void CSisxSifUiSelectionCache::SetLanguage( const TLanguage& aLanguage )
       
    87     {
       
    88     iLanguage = aLanguage;   
       
    89     iLanguageCached = ETrue;    
       
    90     }
       
    91      
       
    92 // -----------------------------------------------------------------------------
       
    93 // CSisxUISelectionCacheAppInfo::DriveCached()
       
    94 // -----------------------------------------------------------------------------
       
    95 //
       
    96 TBool CSisxSifUiSelectionCache::DriveCached() const
       
    97     {
       
    98     TBool result( EFalse );
       
    99     
       
   100     if( iDrive != 0 )
       
   101         {
       
   102         result = ETrue;        
       
   103         }
       
   104     return result;    
       
   105     }
       
   106   
       
   107 // -----------------------------------------------------------------------------
       
   108 // CSisxUISelectionCacheAppInfo::Drive()
       
   109 // -----------------------------------------------------------------------------
       
   110 //
       
   111 TDriveUnit CSisxSifUiSelectionCache::Drive() const
       
   112     {
       
   113     return iDrive;    
       
   114     }
       
   115 
       
   116 // -----------------------------------------------------------------------------
       
   117 // CSisxUISelectionCacheAppInfo::SetDrive()
       
   118 // -----------------------------------------------------------------------------
       
   119 //
       
   120 void CSisxSifUiSelectionCache::SetDrive( TDriveUnit aDrive )
       
   121     {
       
   122     iDrive = aDrive;    
       
   123     }
       
   124 
       
   125 // -----------------------------------------------------------------------------
       
   126 // CSisxUISelectionCacheAppInfo::OptionsCached()
       
   127 // -----------------------------------------------------------------------------
       
   128 //
       
   129 TBool CSisxSifUiSelectionCache::OptionsCached( const RPointerArray<TDesC>& aOptions ) const
       
   130     {
       
   131     TBool result( EFalse );
       
   132     
       
   133     if( iOptions.Count() > 0 && aOptions.Count() == iOptions.Count() )
       
   134         {        
       
   135         for( TInt index = 0; index < iOptions.Count(); ++index )
       
   136             {
       
   137             if( aOptions[ index ] != iOptions[ index ] )
       
   138                 {
       
   139                 result = EFalse;
       
   140                 break;                
       
   141                 }            
       
   142             }        
       
   143         result = ETrue;        
       
   144         }    
       
   145 
       
   146     return result;    
       
   147     }
       
   148 
       
   149 // -----------------------------------------------------------------------------
       
   150 // CSisxUISelectionCacheAppInfo::Options()
       
   151 // -----------------------------------------------------------------------------
       
   152 //
       
   153 void CSisxSifUiSelectionCache::Options( RArray<TBool>& aSelections )
       
   154     {
       
   155     for( TInt index = 0; index < aSelections.Count(); ++index )
       
   156         {
       
   157         aSelections[ index ] = iSelections[ index ];
       
   158         }    
       
   159     }
       
   160 
       
   161 // -----------------------------------------------------------------------------
       
   162 // CSisxUISelectionCacheAppInfo::SetOptionsL()
       
   163 // -----------------------------------------------------------------------------
       
   164 //
       
   165 void CSisxSifUiSelectionCache::SetOptionsL( const RPointerArray<TDesC>& aOptions,
       
   166         const RArray<TBool>& aSelections )
       
   167     {
       
   168     TInt index( 0 );
       
   169     
       
   170     iOptions.ResetAndDestroy();
       
   171     iSelections.Reset();    
       
   172 
       
   173     for( index = 0; index < aOptions.Count(); ++index )
       
   174         {
       
   175         HBufC* tmp = aOptions[ index ]->AllocLC();
       
   176         iOptions.Append( tmp );        
       
   177         }
       
   178     
       
   179     for( index = 0; index < aSelections.Count(); ++index )
       
   180         {
       
   181         iSelections.Append( aSelections[ index ] );
       
   182         }
       
   183     }
       
   184