|
1 /* |
|
2 * Copyright (c) 2003-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: Management UI Container |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 // INCLUDE FILES |
|
21 #include <akntitle.h> //for CAknTitlePane |
|
22 #include <barsread.h> //for TResourceReader |
|
23 #include <StringLoader.h> |
|
24 #include <eiktxlbx.h> //for listbox control |
|
25 #include <aknlists.h> |
|
26 #include <eikclbd.h> |
|
27 #include <vpnmanagementuirsc.rsg> |
|
28 #include "vpnuiloader.h" |
|
29 #include "vpnmanagementuicontainer.h" |
|
30 |
|
31 #ifdef __SERIES60_HELP |
|
32 #include <csxhelp/vpn.hlp.hrh> // for help context of VPN Management UI |
|
33 #endif //__SERIES60_HELP |
|
34 |
|
35 |
|
36 // ================= MEMBER FUNCTIONS ======================= |
|
37 |
|
38 // --------------------------------------------------------- |
|
39 // CVpnManagementUiContainer::CVpnManagementUiContainer( |
|
40 // CVpnManagementUiView& aParent, CVpnUiLoader& aLoader) |
|
41 // Constructor with parent |
|
42 // --------------------------------------------------------- |
|
43 // |
|
44 CVpnManagementUiContainer::CVpnManagementUiContainer( |
|
45 CVpnManagementUiView& aParent, CVpnUiLoader& aLoader ) : |
|
46 iParent ( aParent ), iLoader ( aLoader ) |
|
47 { |
|
48 } |
|
49 |
|
50 // --------------------------------------------------------- |
|
51 // CVpnManagementUiContainer::~CVpnManagementUiContainer() |
|
52 // Destructor |
|
53 // --------------------------------------------------------- |
|
54 // |
|
55 CVpnManagementUiContainer::~CVpnManagementUiContainer() |
|
56 { |
|
57 delete iListBox; |
|
58 } |
|
59 |
|
60 // --------------------------------------------------------- |
|
61 // CVpnManagementUiContainer::ConstructL(const TRect& aRect) |
|
62 // EPOC two phased constructor |
|
63 // --------------------------------------------------------- |
|
64 // |
|
65 void CVpnManagementUiContainer::ConstructL(const TRect& aRect) |
|
66 { |
|
67 CreateWindowL(); |
|
68 |
|
69 TitlePaneTextsL(); |
|
70 |
|
71 CreateListBoxL(); |
|
72 ShowItemsL(); |
|
73 |
|
74 SetRect(aRect); |
|
75 ActivateL(); |
|
76 } |
|
77 |
|
78 |
|
79 // --------------------------------------------------------- |
|
80 // CVpnManagementUiContainer::SizeChanged() |
|
81 // Called by framework when the view size is changed |
|
82 // --------------------------------------------------------- |
|
83 // |
|
84 void CVpnManagementUiContainer::SizeChanged() |
|
85 { |
|
86 if (iListBox) |
|
87 { |
|
88 iListBox->SetRect(Rect()); |
|
89 } |
|
90 } |
|
91 |
|
92 // --------------------------------------------------------- |
|
93 // CVpnManagementUiContainer::CountComponentControls |
|
94 // --------------------------------------------------------- |
|
95 // |
|
96 TInt CVpnManagementUiContainer::CountComponentControls() const |
|
97 { |
|
98 return 1; // return nbr of controls inside this container |
|
99 } |
|
100 |
|
101 // --------------------------------------------------------- |
|
102 // CVpnManagementUiContainer::ComponentControl |
|
103 // --------------------------------------------------------- |
|
104 // |
|
105 CCoeControl* CVpnManagementUiContainer::ComponentControl(TInt aIndex) const |
|
106 { |
|
107 switch ( aIndex ) |
|
108 { |
|
109 case 0: |
|
110 return iListBox; |
|
111 default: |
|
112 return NULL; |
|
113 } |
|
114 } |
|
115 |
|
116 // --------------------------------------------------------- |
|
117 // CVpnManagementUiContainer::HandleResourceChange |
|
118 // --------------------------------------------------------- |
|
119 // |
|
120 void CVpnManagementUiContainer::HandleResourceChange( TInt aType ) |
|
121 { |
|
122 CCoeControl::HandleResourceChange(aType); |
|
123 |
|
124 //Handle change in layout orientation |
|
125 if (aType == KEikDynamicLayoutVariantSwitch || |
|
126 aType == KAknsMessageSkinChange ) |
|
127 { |
|
128 TRect mainPaneRect; |
|
129 AknLayoutUtils::LayoutMetricsRect( |
|
130 AknLayoutUtils::EMainPane, mainPaneRect); |
|
131 SetRect(mainPaneRect); |
|
132 DrawNow(); |
|
133 } |
|
134 } |
|
135 |
|
136 // --------------------------------------------------------- |
|
137 // CVpnManagementUiContainer::DrawListBoxL() |
|
138 // Draws listbox |
|
139 // --------------------------------------------------------- |
|
140 // |
|
141 void CVpnManagementUiContainer::DrawListBoxL( |
|
142 TInt aCurrentPosition, TInt aTopItem) |
|
143 { |
|
144 if (aCurrentPosition >= 0) |
|
145 { |
|
146 iListBox->SetTopItemIndex( aTopItem ); |
|
147 iListBox->SetCurrentItemIndex( aCurrentPosition ); |
|
148 } |
|
149 ActivateL(); |
|
150 DrawNow(); |
|
151 } |
|
152 |
|
153 // --------------------------------------------------------- |
|
154 // CVpnManagementUiContainer::HandleControlEventL( |
|
155 // CCoeControl* aControl,TCoeEvent aEventType) |
|
156 // --------------------------------------------------------- |
|
157 // |
|
158 void CVpnManagementUiContainer::HandleControlEventL( |
|
159 CCoeControl* /*aControl*/,TCoeEvent /*aEventType*/) |
|
160 { |
|
161 } |
|
162 |
|
163 TKeyResponse CVpnManagementUiContainer::OfferKeyEventL( |
|
164 const TKeyEvent& aKeyEvent, TEventCode aType) |
|
165 { |
|
166 if (aType!=EEventKey) |
|
167 { |
|
168 return EKeyWasNotConsumed; |
|
169 } |
|
170 switch (aKeyEvent.iCode) |
|
171 { |
|
172 case EKeyUpArrow: |
|
173 if (iListBox) |
|
174 { |
|
175 return iListBox->OfferKeyEventL(aKeyEvent, aType); |
|
176 } |
|
177 break; |
|
178 case EKeyDownArrow: |
|
179 if (iListBox) |
|
180 { |
|
181 return iListBox->OfferKeyEventL(aKeyEvent, aType); |
|
182 } |
|
183 break; |
|
184 case EKeyEnter: |
|
185 case EKeyDevice3: |
|
186 // Select button or enter key pressed, do default action |
|
187 if (iListBox) |
|
188 { |
|
189 return iListBox->OfferKeyEventL(aKeyEvent, aType); |
|
190 } |
|
191 break; |
|
192 |
|
193 default: |
|
194 break; |
|
195 } |
|
196 return EKeyWasNotConsumed; |
|
197 } |
|
198 |
|
199 // --------------------------------------------------------- |
|
200 // CVpnManagementUiContainer::TitlePaneTextsL |
|
201 // Initialized Title pane text |
|
202 // --------------------------------------------------------- |
|
203 // |
|
204 void CVpnManagementUiContainer::TitlePaneTextsL() |
|
205 { |
|
206 // first get StatusPane. Not owned |
|
207 CEikStatusPane* statusPane = iEikonEnv->AppUiFactory()->StatusPane(); |
|
208 if (statusPane) |
|
209 { |
|
210 // then get TitlePane. Not owned |
|
211 CAknTitlePane* titlePane = ( CAknTitlePane* ) statusPane->ControlL( |
|
212 TUid::Uid( EEikStatusPaneUidTitle ) ); |
|
213 |
|
214 // set new titlepane text |
|
215 TResourceReader reader; |
|
216 iEikonEnv->CreateResourceReaderLC(reader, R_VPN_MANAGEMENT_TITLE); |
|
217 titlePane->SetFromResourceL( reader ); |
|
218 CleanupStack::PopAndDestroy(); // reader |
|
219 } |
|
220 } |
|
221 |
|
222 void CVpnManagementUiContainer::CreateListBoxL() |
|
223 { |
|
224 iListBox = new(ELeave) CAknSettingStyleListBox; |
|
225 iListBox->SetContainerWindowL( *this); |
|
226 |
|
227 iListBox->ConstructL( this, EAknListBoxSelectionList); |
|
228 iListBox->CreateScrollBarFrameL(ETrue); |
|
229 iListBox->ScrollBarFrame()->SetScrollBarVisibilityL( |
|
230 CEikScrollBarFrame::EOff,CEikScrollBarFrame::EAuto); |
|
231 } |
|
232 |
|
233 |
|
234 void CVpnManagementUiContainer::ShowItemsL() |
|
235 { |
|
236 CDesCArrayFlat* itemTextArray = |
|
237 static_cast<CDesCArrayFlat*>(iListBox->Model()->ItemTextArray()); |
|
238 |
|
239 itemTextArray->Reset(); |
|
240 iListBox->Reset(); |
|
241 |
|
242 HBufC* resourceText = NULL; |
|
243 |
|
244 //Create VPN policies setting listbox item |
|
245 resourceText = StringLoader::LoadLC( R_VPN_POLICIES ); |
|
246 itemTextArray->AppendL(*resourceText); |
|
247 CleanupStack::PopAndDestroy(); // resourceText |
|
248 |
|
249 //Create Policy servers setting listbox item |
|
250 |
|
251 resourceText = StringLoader::LoadLC( R_VPN_POLICY_SERVERS ); |
|
252 itemTextArray->AppendL(*resourceText); |
|
253 CleanupStack::PopAndDestroy(); // resourceText |
|
254 |
|
255 //Create Log setting listbox item |
|
256 resourceText = StringLoader::LoadLC( R_VPN_LOG ); |
|
257 itemTextArray->AppendL(*resourceText); |
|
258 CleanupStack::PopAndDestroy(); // resourceText |
|
259 |
|
260 iListBox->HandleItemAdditionL(); |
|
261 } |
|
262 |
|
263 // --------------------------------------------------------- |
|
264 // CVpnManagementUiContainer::GetHelpContext |
|
265 // This function is called when Help application is launched. |
|
266 // --------------------------------------------------------- |
|
267 // |
|
268 #ifdef __SERIES60_HELP |
|
269 void CVpnManagementUiContainer::GetHelpContext( |
|
270 TCoeHelpContext& aContext ) const |
|
271 { |
|
272 aContext.iMajor = KUidVpnManagementUi; |
|
273 aContext.iContext = KSET_HLP_VPN_CONFIG_MAIN; |
|
274 } |
|
275 #endif //__SERIES60_HELP |
|
276 |
|
277 // End of File |