|
1 /* |
|
2 * Copyright (c) 2005 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: Rsfw GS plugin, Setting List class implementation |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // INCLUDE FILES |
|
20 #include <akntitle.h> |
|
21 #include <ApSettingsHandlerUI.h> |
|
22 #include <ApUtils.h> |
|
23 #include <commdb.h> |
|
24 #include <eikspane.h> |
|
25 #include <akntextsettingpage.h> |
|
26 #include <ConnectionUiUtilities.h> |
|
27 |
|
28 #include "rsfwgspluginsettinglist.h" |
|
29 #include "rsfwgssettingsdata.h" |
|
30 #include "mdebug.h" |
|
31 |
|
32 // ----------------------------------------------------------------------------- |
|
33 // CRsfwGsPluginSettingsList::NewL(CRsfwGsSettingsData &aData) |
|
34 // ----------------------------------------------------------------------------- |
|
35 // |
|
36 CRsfwGsPluginSettingsList *CRsfwGsPluginSettingsList::NewL(CRsfwGsSettingsData &aData) |
|
37 { |
|
38 CRsfwGsPluginSettingsList* self = CRsfwGsPluginSettingsList::NewLC(aData); |
|
39 CleanupStack::Pop(self); |
|
40 return self; |
|
41 } |
|
42 |
|
43 // ----------------------------------------------------------------------------- |
|
44 // CRsfwGsPluginSettingsList::NewLC(CRsfwGsSettingsData &aData) |
|
45 // ----------------------------------------------------------------------------- |
|
46 // |
|
47 CRsfwGsPluginSettingsList *CRsfwGsPluginSettingsList::NewLC(CRsfwGsSettingsData &aData) |
|
48 { |
|
49 CRsfwGsPluginSettingsList* self = new (ELeave) CRsfwGsPluginSettingsList(aData); |
|
50 CleanupStack::PushL(self); |
|
51 return self; |
|
52 } |
|
53 |
|
54 // ----------------------------------------------------------------------------- |
|
55 // CRsfwGsPluginSettingsList::CRsfwGsPluginSettingsList(CRsfwGsSettingsData &aData) |
|
56 // ----------------------------------------------------------------------------- |
|
57 // |
|
58 CRsfwGsPluginSettingsList::CRsfwGsPluginSettingsList(CRsfwGsSettingsData &aData) : |
|
59 CAknSettingItemList(), |
|
60 iSettingsData(aData) |
|
61 { |
|
62 } |
|
63 |
|
64 // ----------------------------------------------------------------------------- |
|
65 // CRsfwGsPluginSettingsList::~CRsfwGsPluginSettingsList() |
|
66 // ----------------------------------------------------------------------------- |
|
67 // |
|
68 CRsfwGsPluginSettingsList::~CRsfwGsPluginSettingsList() |
|
69 { |
|
70 #if defined __WINS__ |
|
71 iDlgSrv.Close(); |
|
72 #endif |
|
73 } |
|
74 |
|
75 // ----------------------------------------------------------------------------- |
|
76 // CRsfwGsPluginSettingsList::SizeChanged() |
|
77 // ----------------------------------------------------------------------------- |
|
78 // |
|
79 void CRsfwGsPluginSettingsList::SizeChanged() |
|
80 { |
|
81 // if size changes, make sure component takes whole available space |
|
82 if (ListBox()) |
|
83 { |
|
84 ListBox()->SetRect(Rect()); |
|
85 } |
|
86 } |
|
87 |
|
88 // ----------------------------------------------------------------------------- |
|
89 // CRsfwGsPluginSettingsList::EditCurrentItemL() |
|
90 // ----------------------------------------------------------------------------- |
|
91 // |
|
92 void CRsfwGsPluginSettingsList::EditCurrentItemL() |
|
93 { |
|
94 // invoke EditItemL on the current item |
|
95 |
|
96 TInt index = ListBox()->CurrentItemIndex(); |
|
97 EditItemL(index,ETrue); // invoked from menu |
|
98 } |
|
99 |
|
100 // ----------------------------------------------------------------------------- |
|
101 // CRsfwGsPluginSettingsList::EditItemL (TInt aIndex, TBool aCalledFromMenu) |
|
102 // ----------------------------------------------------------------------------- |
|
103 // |
|
104 void CRsfwGsPluginSettingsList::EditItemL (TInt aIndex, TBool aCalledFromMenu) |
|
105 { |
|
106 if (aIndex == EAccessPointIndex) |
|
107 { |
|
108 EditAccessPointL(); |
|
109 } |
|
110 else |
|
111 { |
|
112 TInt cflags = (*SettingItemArray())[aIndex]->SettingPageFlags(); |
|
113 // allow user to exit address field without typing anything, |
|
114 // if he e.g. realizes that he does not remember the address |
|
115 if ((aIndex == EUserIDIndex) || (aIndex == EServerAddressIndex)) |
|
116 { |
|
117 cflags |= CAknTextSettingPage::EZeroLengthAllowed; |
|
118 } |
|
119 else |
|
120 { |
|
121 cflags &= (!CAknTextSettingPage::EZeroLengthAllowed); |
|
122 } |
|
123 (*SettingItemArray())[aIndex]->SetSettingPageFlags(cflags); |
|
124 CAknSettingItemList::EditItemL(aIndex, aCalledFromMenu); |
|
125 (*SettingItemArray())[aIndex]->StoreL(); |
|
126 } |
|
127 SaveSettingL(aIndex); |
|
128 } |
|
129 |
|
130 // ----------------------------------------------------------------------------- |
|
131 // CRsfwGsPluginSettingsList::SaveSettingL(TInt aIndex) |
|
132 // ----------------------------------------------------------------------------- |
|
133 // |
|
134 void CRsfwGsPluginSettingsList::SaveSettingL(TInt aIndex) |
|
135 { |
|
136 |
|
137 switch (aIndex) |
|
138 { |
|
139 case ESettingNameIndex: |
|
140 SetTitlePaneTextL(iSettingsData.iSettingName); |
|
141 break; |
|
142 case EServerAddressIndex: |
|
143 break; |
|
144 |
|
145 case EAccessPointIndex: |
|
146 if (iSettingsData.iAccessPoint > -1) // if Valid AP number |
|
147 { |
|
148 (iSettingsData.iAccessPointDes).Num(iSettingsData.iAccessPoint); |
|
149 GetAccessPointNameL(iSettingsData.iAccessPoint, |
|
150 iSettingsData.iAccessPointName); |
|
151 } |
|
152 break; |
|
153 case EUserIDIndex: |
|
154 break; |
|
155 |
|
156 case EPasswordIndex: |
|
157 break; |
|
158 |
|
159 default: |
|
160 break; |
|
161 } |
|
162 LoadSettingsL(); |
|
163 DrawNow(); |
|
164 } |
|
165 |
|
166 // ----------------------------------------------------------------------------- |
|
167 // CRsfwGsPluginSettingsList::CreateSettingItemL (TInt aIdentifier) |
|
168 // ----------------------------------------------------------------------------- |
|
169 // |
|
170 CAknSettingItem * CRsfwGsPluginSettingsList::CreateSettingItemL (TInt aIdentifier) |
|
171 { |
|
172 // method is used to create specific setting item as required at run-time. |
|
173 // aIdentifier is used to determine what kind of setting item should be |
|
174 // created |
|
175 |
|
176 CAknSettingItem* settingItem = NULL; |
|
177 |
|
178 switch (aIdentifier) |
|
179 { |
|
180 case ESettingItemDriveName: |
|
181 settingItem = new (ELeave) CAknTextSettingItem ( aIdentifier, |
|
182 iSettingsData.iSettingName); |
|
183 break; |
|
184 case ESettingItemURL: |
|
185 settingItem = new (ELeave) CAknTextSettingItem ( |
|
186 aIdentifier, |
|
187 iSettingsData.iURL); |
|
188 break; |
|
189 |
|
190 case ESettingItemAccessPoint: |
|
191 GetAccessPointNameL(iSettingsData.iAccessPoint, iSettingsData.iAccessPointName); |
|
192 settingItem = new (ELeave) CAknTextSettingItem ( |
|
193 aIdentifier, iSettingsData.iAccessPointName); |
|
194 break; |
|
195 |
|
196 |
|
197 |
|
198 case ESettingItemUserID: |
|
199 settingItem = new (ELeave) CAknTextSettingItem ( |
|
200 aIdentifier, |
|
201 iSettingsData.iUserID); |
|
202 settingItem->SetEmptyItemTextL(KNullDesC); |
|
203 settingItem->LoadL(); |
|
204 break; |
|
205 case ESettingItemPassword: |
|
206 settingItem = new (ELeave) CAknPasswordSettingItem ( |
|
207 aIdentifier, |
|
208 CAknPasswordSettingItem::EAlpha, |
|
209 iSettingsData.iPassword); |
|
210 break; |
|
211 default: |
|
212 break; |
|
213 } |
|
214 return settingItem; |
|
215 } |
|
216 |
|
217 // ----------------------------------------------------------------------------- |
|
218 // CRsfwGsPluginSettingsList::EditAccessPoint() |
|
219 // ----------------------------------------------------------------------------- |
|
220 // |
|
221 void CRsfwGsPluginSettingsList::EditAccessPointL() |
|
222 { |
|
223 |
|
224 CCommsDatabase* commsDb = CCommsDatabase::NewL( EDatabaseTypeIAP ); |
|
225 CleanupStack::PushL(commsDb); |
|
226 CApUtils* aPUtils = CApUtils::NewLC( *commsDb ); |
|
227 |
|
228 TUint32 id = 0; |
|
229 TRAP_IGNORE(id = aPUtils->WapIdFromIapIdL(iSettingsData.iAccessPoint)); |
|
230 |
|
231 CConnectionUiUtilities* connUiUtils = |
|
232 CConnectionUiUtilities::NewL(); |
|
233 CleanupStack::PushL( connUiUtils ); |
|
234 |
|
235 TCuuAlwaysAskResults result; |
|
236 // determine how radio button will be initially displayed to the user |
|
237 // (depending on what is the current IAP choice) |
|
238 iSettingsData.iAccessPoint < 0 ? result = ECuuAlwaysAsk : result = ECuuUserDefined; |
|
239 |
|
240 if (connUiUtils->AlwaysAskPageL(result)) |
|
241 { |
|
242 if (result == ECuuUserDefined) |
|
243 { |
|
244 |
|
245 #if defined __WINS__ |
|
246 // In wins emulator mode we need to show emulator-lan access point so we |
|
247 // different technique |
|
248 TConnectionPrefs prefs; |
|
249 |
|
250 User::LeaveIfError(iDlgSrv.Connect()); |
|
251 |
|
252 prefs.iRank = 1; |
|
253 prefs.iDirection = ECommDbConnectionDirectionOutgoing; |
|
254 prefs.iBearerSet = ECommDbBearerCSD | ECommDbBearerWcdma | ECommDbBearerVirtual; |
|
255 |
|
256 TUint32 id = iSettingsData.iAccessPoint; |
|
257 |
|
258 TRAPD( err, iDlgSrv.IapConnection( id, prefs, iStatus ) ); |
|
259 User::LeaveIfError( err ); |
|
260 |
|
261 User::WaitForRequest( iStatus ); |
|
262 iSettingsData.iAccessPoint = id; |
|
263 iDlgSrv.Close(); |
|
264 |
|
265 #else |
|
266 CApSettingsHandler *ApUi = CApSettingsHandler::NewLC( |
|
267 ETrue, |
|
268 EApSettingsSelListIsPopUp, |
|
269 EApSettingsSelMenuSelectNormal, |
|
270 KEApIspTypeAll, |
|
271 EApBearerTypeAllBearers, |
|
272 KEApSortNameAscending, |
|
273 EIPv4 | EIPv6 |
|
274 ); |
|
275 ApUi->RunSettingsL( id, id ); |
|
276 CleanupStack::PopAndDestroy(ApUi); |
|
277 iSettingsData.iAccessPoint = aPUtils->IapIdFromWapIdL(id); |
|
278 #endif |
|
279 } |
|
280 else if (result == ECuuAlwaysAsk) |
|
281 { |
|
282 iSettingsData.iAccessPoint = -1; |
|
283 iSettingsData.iAccessPointDes = KNullDesC; |
|
284 iSettingsData.iAccessPointName = KNullDesC; |
|
285 } |
|
286 } |
|
287 |
|
288 |
|
289 CleanupStack::PopAndDestroy(3); //commsDb, aPUtils, CConnectionUtilities |
|
290 |
|
291 } |
|
292 |
|
293 // ----------------------------------------------------------------------------- |
|
294 // CRsfwGsPluginSettingsList::GetAccessPointNameL(TInt32 aAP, TDes& aAccessPoint) |
|
295 // ----------------------------------------------------------------------------- |
|
296 // |
|
297 void CRsfwGsPluginSettingsList::GetAccessPointNameL(TInt32 aAP, TDes& aAccessPoint) |
|
298 { |
|
299 // Fetch CommDB data for a matching IAP Id or IAP Name |
|
300 CCommsDatabase* commsDb = CCommsDatabase::NewL(); |
|
301 CleanupStack::PushL(commsDb); |
|
302 CCommsDbTableView* table; |
|
303 table = commsDb->OpenViewMatchingUintLC(TPtrC(IAP), |
|
304 TPtrC(COMMDB_ID), |
|
305 aAP); |
|
306 |
|
307 TInt err = table->GotoFirstRecord(); |
|
308 if (err != KErrNone) |
|
309 { |
|
310 CleanupStack::PopAndDestroy(2, commsDb); // table, commsDb |
|
311 return; |
|
312 } |
|
313 |
|
314 // Read name for IAP information |
|
315 table->ReadTextL(TPtrC(COMMDB_NAME), aAccessPoint); |
|
316 CleanupStack::PopAndDestroy(2, commsDb); // table, commsDb |
|
317 } |
|
318 |
|
319 // ----------------------------------------------------------------------------- |
|
320 // CRsfwGsPluginSettingsList::SetTitlePaneTextL( const TDesC& aTitleText ) const |
|
321 // ----------------------------------------------------------------------------- |
|
322 // |
|
323 void CRsfwGsPluginSettingsList::SetTitlePaneTextL( const TDesC& aTitleText ) const |
|
324 { |
|
325 DEBUGSTRING(("CRsfwGsPluginSettingsList::SetTitlePaneTextL")); |
|
326 CAknTitlePane* title = static_cast< CAknTitlePane* > |
|
327 ( iEikonEnv->AppUiFactory()->StatusPane()->ControlL( |
|
328 TUid::Uid( EEikStatusPaneUidTitle ) ) ); |
|
329 if ( !title ) |
|
330 { |
|
331 User::Leave( KErrNotSupported ); |
|
332 } |
|
333 |
|
334 title->SetTextL( aTitleText ); |
|
335 } |
|
336 |
|
337 // ----------------------------------------------------------------------------- |
|
338 // CRsfwGsPluginSettingsList::ResetItemIndex() |
|
339 // ----------------------------------------------------------------------------- |
|
340 // |
|
341 void CRsfwGsPluginSettingsList::ResetItemIndex() |
|
342 { |
|
343 ListBox()->SetCurrentItemIndex(NULL); |
|
344 } |
|
345 |
|
346 // End of File |