|
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 active status view |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // INCLUDE FILES |
|
20 #include "gssensensorsview.h" |
|
21 #include "gssensensorscontainer.h" |
|
22 #include "gssensorplugin.hrh" |
|
23 #include "gssensorpluginlocalviewids.h" |
|
24 #include "gssensorplugin_debug.h" |
|
25 |
|
26 #include <hlplch.h> // For HlpLauncher |
|
27 #include <AknViewAppUi.h> |
|
28 #include <AknRadioButtonSettingPage.h> |
|
29 #include <FeatMgr.h> |
|
30 #include <gssensorpluginrsc.rsg> |
|
31 #include <GSCommon.hrh> |
|
32 |
|
33 |
|
34 // ========================= MEMBER FUNCTIONS ================================ |
|
35 |
|
36 // --------------------------------------------------------------------------- |
|
37 // CGSSenSensorsView::CGSSenSensorsView |
|
38 // Default constructor |
|
39 // --------------------------------------------------------------------------- |
|
40 // |
|
41 CGSSenSensorsView::CGSSenSensorsView( CGSSensorPluginModel* aModel ) : |
|
42 iModel( aModel ) |
|
43 { |
|
44 TRACE_( "[GSSensorPlugin] CGSSenSensorsView::CGSSenSensorsView()" ); |
|
45 } |
|
46 |
|
47 // --------------------------------------------------------------------------- |
|
48 // CGSSenSensorsView::NewL |
|
49 // Symbian OS two-phased constructor |
|
50 // --------------------------------------------------------------------------- |
|
51 CGSSenSensorsView* CGSSenSensorsView::NewL( CGSSensorPluginModel* aModel ) |
|
52 { |
|
53 TRACE_( "[GSSensorPlugin] CGSSenSensorsView::NewL()" ); |
|
54 CGSSenSensorsView* self = NewLC( aModel ); |
|
55 CleanupStack::Pop( self ); |
|
56 TRACE_( "[GSSensorPlugin] CGSSenSensorsView::NewL() - return" ); |
|
57 return self; |
|
58 } |
|
59 |
|
60 // --------------------------------------------------------------------------- |
|
61 // CGSSenSensorsView::NewLC |
|
62 // Symbian OS two-phased constructor |
|
63 // --------------------------------------------------------------------------- |
|
64 CGSSenSensorsView* CGSSenSensorsView::NewLC( CGSSensorPluginModel* aModel ) |
|
65 { |
|
66 TRACE_( "[GSSensorPlugin] CGSSenSensorsView::NewLC()" ); |
|
67 CGSSenSensorsView* self = new( ELeave ) CGSSenSensorsView( aModel ); |
|
68 CleanupStack::PushL( self ); |
|
69 self->ConstructL(); |
|
70 TRACE_( "[GSSensorPlugin] CGSSenSensorsView::NewLC() - return" ); |
|
71 return self; |
|
72 } |
|
73 |
|
74 // --------------------------------------------------------------------------- |
|
75 // CGSSenSensorsView::~CGSSenSensorsView |
|
76 // Destructor |
|
77 // --------------------------------------------------------------------------- |
|
78 CGSSenSensorsView::~CGSSenSensorsView() |
|
79 { |
|
80 TRACE_( "[GSSensorPlugin] CGSSenSensorsView::~CGSSenSensorsView()" ); |
|
81 iModel = NULL; |
|
82 } |
|
83 |
|
84 // --------------------------------------------------------------------------- |
|
85 // CGSSenSensorsView::ConstructL |
|
86 // Symbian OS two-phased constructor |
|
87 // --------------------------------------------------------------------------- |
|
88 void CGSSenSensorsView::ConstructL() |
|
89 { |
|
90 TRACE_( "[GSSensorPlugin] CGSSenSensorsView::ConstructL()" ); |
|
91 BaseConstructL( R_GS_SENSORS_VIEW ); |
|
92 TRACE_( "[GSSensorPlugin] CGSSenSensorsView::ConstructL() - return" ); |
|
93 } |
|
94 |
|
95 // --------------------------------------------------------------------------- |
|
96 // TUid CGSSenSensorsView::Id |
|
97 // --------------------------------------------------------------------------- |
|
98 TUid CGSSenSensorsView::Id() const |
|
99 { |
|
100 TRACE_1( "[GSSensorPlugin] CGSSenSensorsView::Id() - ID: %i", KSenSensorsViewId ); |
|
101 return KSenSensorsViewId; |
|
102 } |
|
103 |
|
104 // --------------------------------------------------------------------------- |
|
105 // CGSSenSensorsView::HandleCommandL |
|
106 // Command handling for sensor activation status view |
|
107 // --------------------------------------------------------------------------- |
|
108 void CGSSenSensorsView::HandleCommandL( TInt aCommand ) |
|
109 { |
|
110 TRACE_1( "[GSSensorPlugin] CGSSenSensorsView::HandleCommandL() - command: %i", |
|
111 aCommand ); |
|
112 |
|
113 switch ( aCommand ) |
|
114 { |
|
115 case EGSMSKCmdAppChange: |
|
116 case EGSSenMskGeneral: |
|
117 HandleListBoxSelectionL(); |
|
118 break; |
|
119 case EAknSoftkeyBack: |
|
120 iAppUi->ActivateLocalViewL( KGSSensorPluginUid ); |
|
121 break; |
|
122 case EAknCmdHelp: |
|
123 { |
|
124 if( FeatureManager::FeatureSupported( KFeatureIdHelp ) ) |
|
125 { |
|
126 HlpLauncher::LaunchHelpApplicationL( |
|
127 iEikonEnv->WsSession(), iAppUi->AppHelpContextL() ); |
|
128 } |
|
129 break; |
|
130 } |
|
131 default: |
|
132 iAppUi->HandleCommandL( aCommand ); |
|
133 break; |
|
134 } |
|
135 TRACE_( "[GSSensorPlugin] CGSSenSensorsView::HandleCommandL() - return" ); |
|
136 } |
|
137 |
|
138 // --------------------------------------------------------------------------- |
|
139 // CGSSenSensorsView::UpdateListBoxL |
|
140 // --------------------------------------------------------------------------- |
|
141 // |
|
142 void CGSSenSensorsView::UpdateListBoxL( TInt aItemId ) |
|
143 { |
|
144 TRACE_1( "[GSSensorPlugin] CGSSenSensorsView::UpdateListBoxL() - ItemId: %i", aItemId ); |
|
145 Container()->UpdateListBoxL( aItemId ); |
|
146 TRACE_( "[GSSensorPlugin] CGSSenSensorsView::UpdateListBoxL() - return" ); |
|
147 } |
|
148 |
|
149 // --------------------------------------------------------------------------- |
|
150 // CGSSenSensorsView::Container |
|
151 // Returns call container item |
|
152 // --------------------------------------------------------------------------- |
|
153 // |
|
154 CGSSenSensorsContainer* CGSSenSensorsView::Container() |
|
155 { |
|
156 TRACE_( "[GSSensorPlugin] CGSSenSensorsView::Container()" ); |
|
157 return static_cast<CGSSenSensorsContainer*>( iContainer ); |
|
158 } |
|
159 |
|
160 |
|
161 // --------------------------------------------------------------------------- |
|
162 // CGSSenSensorsView::NewContainerL |
|
163 // Creates new iContainer. |
|
164 // --------------------------------------------------------------------------- |
|
165 // |
|
166 void CGSSenSensorsView::NewContainerL() |
|
167 { |
|
168 TRACE_( "[GSSensorPlugin] CGSSenSensorsView::NewContainerL()" ); |
|
169 iContainer = new ( ELeave ) CGSSenSensorsContainer( iModel ); |
|
170 TRACE_( "[GSSensorPlugin] CGSSenSensorsView::NewContainerL() - return" ); |
|
171 } |
|
172 |
|
173 |
|
174 // --------------------------------------------------------------------------- |
|
175 // CGSSenSensorsView::HandleListBoxSelectionL() |
|
176 // --------------------------------------------------------------------------- |
|
177 void CGSSenSensorsView::HandleListBoxSelectionL() |
|
178 { |
|
179 TRACE_( "[GSSensorPlugin] CGSSenSensorsView::HandleListBoxSelectionL()" ); |
|
180 const TInt currentItem = Container()->CurrentFeatureId(); |
|
181 |
|
182 switch ( currentItem ) |
|
183 { |
|
184 case KGSSenorsActive: |
|
185 ChangeSensorActiveSettingL(); |
|
186 break; |
|
187 default: |
|
188 break; |
|
189 } |
|
190 TRACE_( "[GSSensorPlugin] CGSSenSensorsView::HandleListBoxSelectionL() - return" ); |
|
191 } |
|
192 |
|
193 // --------------------------------------------------------------------------- |
|
194 // CGSSenSensorsView::ChangeSensorActiveSettingL |
|
195 // Change sensors active status setting . |
|
196 // --------------------------------------------------------------------------- |
|
197 // |
|
198 void CGSSenSensorsView::ChangeSensorActiveSettingL() |
|
199 { |
|
200 TRACE_( "[GSSensorPlugin] CGSSenSensorsView::ChangeSensorActiveSettingL()" ); |
|
201 TInt currentValue = iModel->SensorActiveStatusL(); |
|
202 |
|
203 if( currentValue == KGSSenOff ) |
|
204 { |
|
205 currentValue = KGSSenOn; |
|
206 } |
|
207 else |
|
208 { |
|
209 currentValue = KGSSenOff; |
|
210 } |
|
211 |
|
212 iModel->SetSensorActiveStatusL( currentValue ); |
|
213 UpdateListBoxL( KGSSenorsActive ); |
|
214 |
|
215 TRACE_( "[GSSensorPlugin] CGSSenSensorsView::ChangeSensorActiveSettingL() - return" ); |
|
216 } |