25
|
1 |
/*
|
|
2 |
* Copyright (c) 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: Container for GSOpticalJoystickPlugin
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
|
|
19 |
// INCLUDE FILES
|
|
20 |
#include "GSOpticalJoystickPluginContainer.h"
|
|
21 |
#include "GSOpticalJoystickPlugin.hrh"
|
|
22 |
#include "GsLogger.h"
|
|
23 |
#include <bldvariant.hrh>
|
|
24 |
#include <gsopticaljoystickpluginrsc.rsg>
|
|
25 |
#include <centralrepository.h>
|
|
26 |
#include <aknlists.h>
|
|
27 |
#include <StringLoader.h>
|
|
28 |
#include <AknUtils.h>
|
|
29 |
#include <csxhelp/cp.hlp.hrh>
|
|
30 |
#include <gsfwviewuids.h>
|
|
31 |
#include <gslistbox.h>
|
|
32 |
#include <settingsinternalcrkeys.h>
|
|
33 |
|
|
34 |
// These enumations could be found in ofn_hal_groups.h
|
|
35 |
/**
|
|
36 |
* The OFN HAL group
|
|
37 |
*/
|
|
38 |
enum
|
|
39 |
{
|
|
40 |
EHalGroupOFN = 28
|
|
41 |
};
|
|
42 |
|
|
43 |
/**
|
|
44 |
* Supported HAL functions
|
|
45 |
*
|
|
46 |
*/
|
|
47 |
enum TOFNHalFunction
|
|
48 |
{
|
|
49 |
EOFNSetPowerON, // OFN Powering (ON/OFF)
|
|
50 |
EOFNGetPowerState // For reading power state
|
|
51 |
};
|
|
52 |
|
|
53 |
// ========================= MEMBER FUNCTIONS ================================
|
|
54 |
|
|
55 |
// ---------------------------------------------------------------------------
|
|
56 |
// CGSOpticalJoystickPluginContainer::ConstructL()
|
|
57 |
//
|
|
58 |
// Symbian OS two phased constructor
|
|
59 |
// ---------------------------------------------------------------------------
|
|
60 |
//
|
|
61 |
void CGSOpticalJoystickPluginContainer::ConstructL( const TRect& aRect )
|
|
62 |
{
|
|
63 |
iPersonalizationRepository = CRepository::NewL( KCRUidPersonalizationSettings );
|
|
64 |
|
|
65 |
iListBox = new( ELeave ) CAknSettingStyleListBox;
|
|
66 |
|
|
67 |
BaseConstructL( aRect, R_GS_OPTICALJOYSTICK_VIEW_TITLE, R_OPTICALJOYSTICK_LBX );
|
|
68 |
}
|
|
69 |
|
|
70 |
// ---------------------------------------------------------------------------
|
|
71 |
// CGSOpticalJoystickPluginContainer::~CGSOpticalJoystickPluginContainer()
|
|
72 |
//
|
|
73 |
// Destructor
|
|
74 |
// ---------------------------------------------------------------------------
|
|
75 |
//
|
|
76 |
CGSOpticalJoystickPluginContainer::~CGSOpticalJoystickPluginContainer()
|
|
77 |
{
|
|
78 |
delete iAutodisconValue;
|
|
79 |
delete iListboxItemArray;
|
|
80 |
if ( iPersonalizationRepository )
|
|
81 |
{
|
|
82 |
delete iPersonalizationRepository;
|
|
83 |
iPersonalizationRepository = NULL;
|
|
84 |
}
|
|
85 |
}
|
|
86 |
|
|
87 |
|
|
88 |
// ---------------------------------------------------------------------------
|
|
89 |
// CGSOpticalJoystickPluginContainer::ConstructListBoxL()
|
|
90 |
//
|
|
91 |
// Construct the listbox from resource array.
|
|
92 |
// ---------------------------------------------------------------------------
|
|
93 |
//
|
|
94 |
void CGSOpticalJoystickPluginContainer::ConstructListBoxL( TInt aResLbxId )
|
|
95 |
{
|
|
96 |
iListBox->ConstructL( this, EAknListBoxSelectionList );
|
|
97 |
|
|
98 |
iListboxItemArray = CGSListBoxItemTextArray::NewL( aResLbxId,
|
|
99 |
*iListBox, *iCoeEnv );
|
|
100 |
iListBox->Model()->SetItemTextArray( iListboxItemArray );
|
|
101 |
iListBox->Model()->SetOwnershipType( ELbmDoesNotOwnItemArray );
|
|
102 |
|
|
103 |
CreateListBoxItemsL();
|
|
104 |
}
|
|
105 |
|
|
106 |
|
|
107 |
// ---------------------------------------------------------------------------
|
|
108 |
// CGSOpticalJoystickPluginContainer::CreateListBoxItemsL()
|
|
109 |
//
|
|
110 |
// Create listbox items.
|
|
111 |
// ---------------------------------------------------------------------------
|
|
112 |
//
|
|
113 |
void CGSOpticalJoystickPluginContainer::CreateListBoxItemsL()
|
|
114 |
{
|
|
115 |
MakeFocusedItemContentL();
|
|
116 |
}
|
|
117 |
|
|
118 |
|
|
119 |
// ---------------------------------------------------------------------------
|
|
120 |
// CGSOpticalJoystickPluginContainer::UpdateListBoxL()
|
|
121 |
//
|
|
122 |
// Update listbox item.
|
|
123 |
// ---------------------------------------------------------------------------
|
|
124 |
//
|
|
125 |
void CGSOpticalJoystickPluginContainer::UpdateListBoxL( TInt aFeatureId )
|
|
126 |
{
|
|
127 |
switch( aFeatureId )
|
|
128 |
{
|
|
129 |
case KGSSettIdOptJoyst:
|
|
130 |
MakeFocusedItemContentL();
|
|
131 |
break;
|
|
132 |
default:
|
|
133 |
break;
|
|
134 |
}
|
|
135 |
|
|
136 |
iListBox->HandleItemAdditionL();
|
|
137 |
}
|
|
138 |
|
|
139 |
|
|
140 |
// ---------------------------------------------------------------------------
|
|
141 |
// CGSOpticalJoystickPluginContainer::MakeAutodisconItemL()
|
|
142 |
//
|
|
143 |
// Create auto disconnect list item
|
|
144 |
// ---------------------------------------------------------------------------
|
|
145 |
//
|
|
146 |
void CGSOpticalJoystickPluginContainer::MakeFocusedItemContentL()
|
|
147 |
{
|
|
148 |
TInt currentStatus = 0;
|
|
149 |
GetOpticalJoystickStatus( currentStatus);
|
|
150 |
__GSLOGSTRING1("[CGSOpticalJoystickPluginContainer]--> MakeFocusedItemContentL(), value: %d", currentStatus);
|
|
151 |
|
|
152 |
HBufC* buf = NULL;
|
|
153 |
switch( currentStatus )
|
|
154 |
{
|
|
155 |
case 1:
|
|
156 |
buf = iEikonEnv->AllocReadResourceL( R_OPTICAL_JOYSTICK_ON );
|
|
157 |
break;
|
|
158 |
case 0:
|
|
159 |
buf = iEikonEnv->AllocReadResourceL( R_OPTICAL_JOYSTICK_OFF );
|
|
160 |
break;
|
|
161 |
default:
|
|
162 |
buf = iEikonEnv->AllocReadResourceL( R_OPTICAL_JOYSTICK_OFF );
|
|
163 |
break;
|
|
164 |
}
|
|
165 |
|
|
166 |
TPtr bufPtr( buf->Des() );
|
|
167 |
iListboxItemArray->SetDynamicTextL( KGSSettIdOptJoyst, bufPtr );
|
|
168 |
|
|
169 |
// And add to listbox
|
|
170 |
iListboxItemArray->SetItemVisibilityL( KGSSettIdOptJoyst, CGSListBoxItemTextArray::EVisible );
|
|
171 |
|
|
172 |
delete buf;
|
|
173 |
}
|
|
174 |
|
|
175 |
// ---------------------------------------------------------------------------
|
|
176 |
// CGSOpticalJoystickPluginContainer::GetHelpContext() const
|
|
177 |
//
|
|
178 |
// Gets Help
|
|
179 |
// ---------------------------------------------------------------------------
|
|
180 |
//
|
|
181 |
void CGSOpticalJoystickPluginContainer::GetHelpContext( TCoeHelpContext& aContext ) const
|
|
182 |
{
|
|
183 |
aContext.iMajor = KUidGS;
|
|
184 |
aContext.iContext = KCP_HLP_DEVICE_MANAGEMENT;
|
|
185 |
}
|
|
186 |
|
|
187 |
// ---------------------------------------------------------------------------
|
|
188 |
// CGSOpticalJoystickPluginContainer::CurrentFeatureId()
|
|
189 |
//
|
|
190 |
// Return the feature id of selected listitem
|
|
191 |
// ---------------------------------------------------------------------------
|
|
192 |
//
|
|
193 |
TInt CGSOpticalJoystickPluginContainer::CurrentFeatureId( ) const
|
|
194 |
{
|
|
195 |
return iListboxItemArray->CurrentFeature( );
|
|
196 |
}
|
|
197 |
|
|
198 |
// ---------------------------------------------------------------------------
|
|
199 |
// CGSOpticalJoystickPluginContainer::GetOpticalJoystickStatus()
|
|
200 |
//
|
|
201 |
// Get the status of optical joystick
|
|
202 |
// ---------------------------------------------------------------------------
|
|
203 |
//
|
|
204 |
void CGSOpticalJoystickPluginContainer::GetOpticalJoystickStatus(TInt& aStatus)
|
|
205 |
{
|
|
206 |
TInt err = UserSvr::HalFunction( EHalGroupOFN, EOFNGetPowerState,
|
|
207 |
&aStatus, reinterpret_cast<TAny*>( ETrue ) );
|
|
208 |
__GSLOGSTRING2( "[CGSOpticalJoystickPluginContainer::GetOpticalJoystickStatusL] err: %d, status: %d", err, aStatus );
|
|
209 |
}
|
|
210 |
|
|
211 |
// ---------------------------------------------------------------------------
|
|
212 |
// CGSOpticalJoystickPluginContainer::SetOpticalJoystickStatus()
|
|
213 |
//
|
|
214 |
// Set the status of optical joystick
|
|
215 |
// ---------------------------------------------------------------------------
|
|
216 |
//
|
|
217 |
void CGSOpticalJoystickPluginContainer::SetOpticalJoystickStatusL(TInt aStatus)
|
|
218 |
{
|
|
219 |
TInt err = UserSvr::HalFunction( EHalGroupOFN, EOFNSetPowerON,
|
|
220 |
reinterpret_cast<TAny*>( aStatus ),
|
|
221 |
reinterpret_cast<TAny*>( aStatus ) );
|
|
222 |
__GSLOGSTRING2( "[CGSOpticalJoystickPluginContainer::SetOpticalJoystickStatusL] err: %d, status: %d", err, aStatus );
|
|
223 |
User::LeaveIfError( iPersonalizationRepository->Set( KSettingsOpticalJoystickStatus, aStatus ) );
|
|
224 |
}
|
|
225 |
|
|
226 |
// End of File
|