systemsettings/gssensorplugin/src/gssensensorscontainer.cpp
changeset 0 2e3d3ce01487
equal deleted inserted replaced
-1:000000000000 0:2e3d3ce01487
       
     1 /*
       
     2 * Copyright (c) 2006 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:  Sensors activation status view container
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 // INCLUDE FILES
       
    20 #include "gssensensorscontainer.h" 
       
    21 #include "gssensorpluginmodel.h"
       
    22 #include "gssensorplugin.hrh"
       
    23 #include "gssensorplugin_debug.h"
       
    24 
       
    25 #include <aknlists.h>
       
    26 #include <csxhelp/cp.hlp.hrh>
       
    27 #include <GSFwViewUIDs.h>     // for KUidGS
       
    28 #include <GSListBox.h>
       
    29 #include <gssensorpluginrsc.rsg>
       
    30 
       
    31 
       
    32 // CONSTANTS
       
    33 
       
    34 // ========================= MEMBER FUNCTIONS ================================
       
    35 
       
    36 // ---------------------------------------------------------------------------
       
    37 // CGSSenSensorsContainer::CGSSenSensorsContainer
       
    38 // Default constructor
       
    39 // ---------------------------------------------------------------------------
       
    40 //
       
    41 CGSSenSensorsContainer::CGSSenSensorsContainer( CGSSensorPluginModel* aModel ) :
       
    42     iModel ( aModel )
       
    43     {
       
    44     TRACE_( "[GSSensorPlugin] CGSSenSensorsContainer::CGSSenSensorsContainer()" );
       
    45     }
       
    46 
       
    47 // ---------------------------------------------------------------------------
       
    48 // CGSSenSensorsContainer::ConstructL
       
    49 // Symbian OS two phased constructor
       
    50 // ---------------------------------------------------------------------------
       
    51 //
       
    52 void CGSSenSensorsContainer::ConstructL( const TRect& aRect )
       
    53     {
       
    54     TRACE_( "[GSSensorPlugin] CGSSenSensorsContainer::ConstructL()" );
       
    55     // Has to create listbox before calling BaseConstructL because base class
       
    56     // uses iListBox
       
    57     iListBox = new( ELeave ) CAknSettingStyleListBox;
       
    58     BaseConstructL( aRect, R_GS_SENSORS_VIEW_TITLE, R_GS_SENSORS_STATUS_LBX );
       
    59     TRACE_( "[GSSensorPlugin] CGSSenSensorsContainer::ConstructL() - return" );
       
    60     }
       
    61 
       
    62 // ---------------------------------------------------------------------------
       
    63 // CGSSenSensorsContainer::~CGSSenSensorsContainer()
       
    64 // Destructor
       
    65 // ---------------------------------------------------------------------------
       
    66 //
       
    67 CGSSenSensorsContainer::~CGSSenSensorsContainer()
       
    68     {
       
    69     TRACE_( "[GSSensorPlugin] CGSSenSensorsContainer::~CGSSenSensorsContainer()" );
       
    70     if ( iSensorStatusItems )
       
    71         {
       
    72         delete iSensorStatusItems;
       
    73         }
       
    74     if ( iListboxItemArray )
       
    75         {
       
    76         delete iListboxItemArray;
       
    77         }
       
    78 
       
    79     iModel = NULL;
       
    80     TRACE_( "[GSSensorPlugin] CGSSenSensorsContainer::~CGSSenSensorsContainer() - return" );
       
    81     }
       
    82 
       
    83 // ---------------------------------------------------------------------------
       
    84 // CGSSenSensorsContainer::ConstructListBoxL()
       
    85 // ---------------------------------------------------------------------------
       
    86 //
       
    87 void CGSSenSensorsContainer::ConstructListBoxL( TInt aResLbxId )
       
    88     {
       
    89     TRACE_( "[GSSensorPlugin] CGSSenSensorsContainer::ConstructListBoxL()" );
       
    90     iListBox->ConstructL( this, EAknListBoxSelectionList );
       
    91     iListboxItemArray = CGSListBoxItemTextArray::NewL( 
       
    92         aResLbxId, *iListBox, *iCoeEnv );
       
    93     iListBox->Model()->SetItemTextArray( iListboxItemArray );
       
    94     iListBox->Model()->SetOwnershipType( ELbmDoesNotOwnItemArray );
       
    95     
       
    96     iSensorStatusItems = iCoeEnv->ReadDesC16ArrayResourceL(
       
    97                             R_GS_SENSOR_ACTIVE_STATUS );
       
    98 
       
    99     CreateListBoxItemsL();
       
   100     TRACE_( "[GSSensorPlugin] CGSSenSensorsContainer::ConstructListBoxL() - return" );
       
   101     }
       
   102 
       
   103 // ---------------------------------------------------------------------------
       
   104 // CGSSenSensorsContainer::CreateListBoxItemsL
       
   105 // ---------------------------------------------------------------------------
       
   106 //
       
   107 void CGSSenSensorsContainer::CreateListBoxItemsL()
       
   108     {
       
   109     TRACE_( "[GSSensorPlugin] CGSSenSensorsContainer::CreateListBoxItemsL()" );
       
   110     MakeSensorsSelectionItemL();
       
   111     TRACE_( "[GSSensorPlugin] CGSSenSensorsContainer::CreateListBoxItemsL() - return" );
       
   112     }
       
   113 
       
   114 // ---------------------------------------------------------------------------
       
   115 // CGSSenSensorsContainer::UpdateListBoxL
       
   116 // ---------------------------------------------------------------------------
       
   117 //
       
   118 void CGSSenSensorsContainer::UpdateListBoxL( TInt aFeatureId )
       
   119     {
       
   120     TRACE_( "[GSSensorPlugin] CGSSenSensorsContainer::UpdateListBoxL()" );
       
   121     switch( aFeatureId )
       
   122         {
       
   123         case KGSSenorsActive:
       
   124             MakeSensorsSelectionItemL();
       
   125             break;
       
   126         default:
       
   127             break;
       
   128         }
       
   129     iListBox->HandleItemAdditionL();
       
   130     TRACE_( "[GSSensorPlugin] CGSSenSensorsContainer::UpdateListBoxL() - return" );
       
   131     }
       
   132 
       
   133 // ---------------------------------------------------------------------------
       
   134 // CGSSenSensorsContainer::MakeSensorsSelectionItemL
       
   135 // ---------------------------------------------------------------------------
       
   136 //
       
   137 void CGSSenSensorsContainer::MakeSensorsSelectionItemL()
       
   138     {
       
   139     TRACE_( "[GSSensorPlugin] CGSSenSensorsContainer::MakeSensorsSelectionItemL()" );
       
   140     HBufC* dynamicText = HBufC::NewLC( KGSBufSize128 );
       
   141     TPtr ptrBuffer ( dynamicText->Des() );
       
   142 
       
   143     // Get sensors status and set corresponding text
       
   144     const TInt active = iModel->SensorActiveStatusL();
       
   145     ptrBuffer = ( *iSensorStatusItems )[active];
       
   146 
       
   147     // Finally, set the dynamic text
       
   148     iListboxItemArray->SetDynamicTextL( KGSSenorsActive, ptrBuffer );
       
   149 
       
   150     CleanupStack::PopAndDestroy( dynamicText );
       
   151 
       
   152     // And add to listbox
       
   153     iListboxItemArray->SetItemVisibilityL( KGSSenorsActive, 
       
   154         CGSListBoxItemTextArray::EVisible );
       
   155     TRACE_( "[GSSensorPlugin] CGSSenSensorsContainer::MakeSensorsSelectionItemL() - return" );
       
   156     }
       
   157 
       
   158 // ---------------------------------------------------------------------------
       
   159 // CGSSenSensorsContainer::GetHelpContext
       
   160 // Gets Help context
       
   161 // ---------------------------------------------------------------------------
       
   162 //
       
   163 void CGSSenSensorsContainer::GetHelpContext( TCoeHelpContext& aContext ) const
       
   164     {
       
   165     TRACE_( "[GSSensorPlugin] CGSSenSensorsContainer::GetHelpContext()" );
       
   166     aContext.iMajor = KUidGS;
       
   167     aContext.iContext = KSSET_HLP_MAIN_VIEW;
       
   168     TRACE_( "[GSSensorPlugin] CGSSenSensorsContainer::GetHelpContext() - return" );
       
   169     }
       
   170 
       
   171 // ---------------------------------------------------------------------------
       
   172 // CGSSenSensorsContainer::CurrentFeatureId
       
   173 // ---------------------------------------------------------------------------
       
   174 //
       
   175 TInt CGSSenSensorsContainer::CurrentFeatureId( ) const
       
   176     {
       
   177     TRACE_( "[GSSensorPlugin] CGSSenSensorsContainer::CurrentFeatureId()" );
       
   178     return iListboxItemArray->CurrentFeature( );
       
   179     }