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 //coverity[logical_vs_bitwise] |
|
122 cflags &= (!CAknTextSettingPage::EZeroLengthAllowed); |
|
123 } |
|
124 (*SettingItemArray())[aIndex]->SetSettingPageFlags(cflags); |
|
125 CAknSettingItemList::EditItemL(aIndex, aCalledFromMenu); |
|
126 (*SettingItemArray())[aIndex]->StoreL(); |
|
127 } |
|
128 SaveSettingL(aIndex); |
|
129 } |
|
130 |
|
131 // ----------------------------------------------------------------------------- |
|
132 // CRsfwGsPluginSettingsList::SaveSettingL(TInt aIndex) |
|
133 // ----------------------------------------------------------------------------- |
|
134 // |
|
135 void CRsfwGsPluginSettingsList::SaveSettingL(TInt aIndex) |
|
136 { |
|
137 |
|
138 switch (aIndex) |
|
139 { |
|
140 case ESettingNameIndex: |
|
141 SetTitlePaneTextL(iSettingsData.iSettingName); |
|
142 break; |
|
143 case EServerAddressIndex: |
|
144 break; |
|
145 |
|
146 case EAccessPointIndex: |
|
147 if (iSettingsData.iAccessPoint > -1) // if Valid AP number |
|
148 { |
|
149 (iSettingsData.iAccessPointDes).Num(iSettingsData.iAccessPoint); |
|
150 GetAccessPointNameL(iSettingsData.iAccessPoint, |
|
151 iSettingsData.iAccessPointName); |
|
152 } |
|
153 break; |
|
154 case EUserIDIndex: |
|
155 break; |
|
156 |
|
157 case EPasswordIndex: |
|
158 break; |
|
159 |
|
160 default: |
|
161 break; |
|
162 } |
|
163 LoadSettingsL(); |
|
164 DrawNow(); |
|
165 } |
|
166 |
|
167 // ----------------------------------------------------------------------------- |
|
168 // CRsfwGsPluginSettingsList::CreateSettingItemL (TInt aIdentifier) |
|
169 // ----------------------------------------------------------------------------- |
|
170 // |
|
171 CAknSettingItem * CRsfwGsPluginSettingsList::CreateSettingItemL (TInt aIdentifier) |
|
172 { |
|
173 // method is used to create specific setting item as required at run-time. |
|
174 // aIdentifier is used to determine what kind of setting item should be |
|
175 // created |
|
176 |
|
177 CAknSettingItem* settingItem = NULL; |
|
178 |
|
179 switch (aIdentifier) |
|
180 { |
|
181 case ESettingItemDriveName: |
|
182 settingItem = new (ELeave) CAknTextSettingItem ( aIdentifier, |
|
183 iSettingsData.iSettingName); |
|
184 break; |
|
185 case ESettingItemURL: |
|
186 settingItem = new (ELeave) CAknTextSettingItem ( |
|
187 aIdentifier, |
|
188 iSettingsData.iURL); |
|
189 break; |
|
190 |
|
191 case ESettingItemAccessPoint: |
|
192 GetAccessPointNameL(iSettingsData.iAccessPoint, iSettingsData.iAccessPointName); |
|
193 settingItem = new (ELeave) CAknTextSettingItem ( |
|
194 aIdentifier, iSettingsData.iAccessPointName); |
|
195 break; |
|
196 |
|
197 |
|
198 |
|
199 case ESettingItemUserID: |
|
200 settingItem = new (ELeave) CAknTextSettingItem ( |
|
201 aIdentifier, |
|
202 iSettingsData.iUserID); |
|
203 settingItem->SetEmptyItemTextL(KNullDesC); |
|
204 settingItem->LoadL(); |
|
205 break; |
|
206 case ESettingItemPassword: |
|
207 settingItem = new (ELeave) CAknPasswordSettingItem ( |
|
208 aIdentifier, |
|
209 CAknPasswordSettingItem::EAlpha, |
|
210 iSettingsData.iPassword); |
|
211 break; |
|
212 default: |
|
213 break; |
|
214 } |
|
215 return settingItem; |
|
216 } |
|
217 |
|
218 // ----------------------------------------------------------------------------- |
|
219 // CRsfwGsPluginSettingsList::EditAccessPoint() |
|
220 // ----------------------------------------------------------------------------- |
|
221 // |
|
222 void CRsfwGsPluginSettingsList::EditAccessPointL() |
|
223 { |
|
224 |
|
225 CCommsDatabase* commsDb = CCommsDatabase::NewL( EDatabaseTypeIAP ); |
|
226 CleanupStack::PushL(commsDb); |
|
227 CApUtils* aPUtils = CApUtils::NewLC( *commsDb ); |
|
228 |
|
229 TUint32 id = 0; |
|
230 TRAP_IGNORE(id = aPUtils->WapIdFromIapIdL(iSettingsData.iAccessPoint)); |
|
231 |
|
232 CConnectionUiUtilities* connUiUtils = |
|
233 CConnectionUiUtilities::NewL(); |
|
234 CleanupStack::PushL( connUiUtils ); |
|
235 |
|
236 TCuuAlwaysAskResults result; |
|
237 // determine how radio button will be initially displayed to the user |
|
238 // (depending on what is the current IAP choice) |
|
239 iSettingsData.iAccessPoint < 0 ? result = ECuuAlwaysAsk : result = ECuuUserDefined; |
|
240 |
|
241 if (connUiUtils->AlwaysAskPageL(result)) |
|
242 { |
|
243 if (result == ECuuUserDefined) |
|
244 { |
|
245 |
|
246 #if defined __WINS__ |
|
247 // In wins emulator mode we need to show emulator-lan access point so we |
|
248 // different technique |
|
249 TConnectionPrefs prefs; |
|
250 |
|
251 User::LeaveIfError(iDlgSrv.Connect()); |
|
252 |
|
253 prefs.iRank = 1; |
|
254 prefs.iDirection = ECommDbConnectionDirectionOutgoing; |
|
255 prefs.iBearerSet = ECommDbBearerCSD | ECommDbBearerWcdma | ECommDbBearerVirtual; |
|
256 |
|
257 TUint32 id = iSettingsData.iAccessPoint; |
|
258 |
|
259 TRAPD( err, iDlgSrv.IapConnection( id, prefs, iStatus ) ); |
|
260 User::LeaveIfError( err ); |
|
261 |
|
262 User::WaitForRequest( iStatus ); |
|
263 iSettingsData.iAccessPoint = id; |
|
264 iDlgSrv.Close(); |
|
265 |
|
266 #else |
|
267 CApSettingsHandler *ApUi = CApSettingsHandler::NewLC( |
|
268 ETrue, |
|
269 EApSettingsSelListIsPopUp, |
|
270 EApSettingsSelMenuSelectNormal, |
|
271 KEApIspTypeAll, |
|
272 EApBearerTypeAllBearers, |
|
273 KEApSortNameAscending, |
|
274 EIPv4 | EIPv6 |
|
275 ); |
|
276 ApUi->RunSettingsL( id, id ); |
|
277 CleanupStack::PopAndDestroy(ApUi); |
|
278 iSettingsData.iAccessPoint = aPUtils->IapIdFromWapIdL(id); |
|
279 #endif |
|
280 } |
|
281 else if (result == ECuuAlwaysAsk) |
|
282 { |
|
283 iSettingsData.iAccessPoint = -1; |
|
284 iSettingsData.iAccessPointDes = KNullDesC; |
|
285 iSettingsData.iAccessPointName = KNullDesC; |
|
286 } |
|
287 } |
|
288 |
|
289 |
|
290 CleanupStack::PopAndDestroy(3); //commsDb, aPUtils, CConnectionUtilities |
|
291 |
|
292 } |
|
293 |
|
294 // ----------------------------------------------------------------------------- |
|
295 // CRsfwGsPluginSettingsList::GetAccessPointNameL(TInt32 aAP, TDes& aAccessPoint) |
|
296 // ----------------------------------------------------------------------------- |
|
297 // |
|
298 void CRsfwGsPluginSettingsList::GetAccessPointNameL(TInt32 aAP, TDes& aAccessPoint) |
|
299 { |
|
300 // Fetch CommDB data for a matching IAP Id or IAP Name |
|
301 CCommsDatabase* commsDb = CCommsDatabase::NewL(); |
|
302 CleanupStack::PushL(commsDb); |
|
303 CCommsDbTableView* table; |
|
304 table = commsDb->OpenViewMatchingUintLC(TPtrC(IAP), |
|
305 TPtrC(COMMDB_ID), |
|
306 aAP); |
|
307 |
|
308 TInt err = table->GotoFirstRecord(); |
|
309 if (err != KErrNone) |
|
310 { |
|
311 CleanupStack::PopAndDestroy(2, commsDb); // table, commsDb |
|
312 return; |
|
313 } |
|
314 |
|
315 // Read name for IAP information |
|
316 table->ReadTextL(TPtrC(COMMDB_NAME), aAccessPoint); |
|
317 CleanupStack::PopAndDestroy(2, commsDb); // table, commsDb |
|
318 } |
|
319 |
|
320 // ----------------------------------------------------------------------------- |
|
321 // CRsfwGsPluginSettingsList::SetTitlePaneTextL( const TDesC& aTitleText ) const |
|
322 // ----------------------------------------------------------------------------- |
|
323 // |
|
324 void CRsfwGsPluginSettingsList::SetTitlePaneTextL( const TDesC& aTitleText ) const |
|
325 { |
|
326 DEBUGSTRING(("CRsfwGsPluginSettingsList::SetTitlePaneTextL")); |
|
327 CAknTitlePane* title = static_cast< CAknTitlePane* > |
|
328 ( iEikonEnv->AppUiFactory()->StatusPane()->ControlL( |
|
329 TUid::Uid( EEikStatusPaneUidTitle ) ) ); |
|
330 if ( !title ) |
|
331 { |
|
332 User::Leave( KErrNotSupported ); |
|
333 } |
|
334 |
|
335 title->SetTextL( aTitleText ); |
|
336 } |
|
337 |
|
338 // ----------------------------------------------------------------------------- |
|
339 // CRsfwGsPluginSettingsList::ResetItemIndex() |
|
340 // ----------------------------------------------------------------------------- |
|
341 // |
|
342 void CRsfwGsPluginSettingsList::ResetItemIndex() |
|
343 { |
|
344 ListBox()->SetCurrentItemIndex(NULL); |
|
345 } |
|
346 |
|
347 // End of File |
|