|
1 /* |
|
2 * Copyright (c) 2007 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: This file implements classes CIpsSetUiItemAccessPoint, AccessPoint, AccessPoint. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include "emailtrace.h" |
|
20 #include <featmgr.h> |
|
21 #include <badesca.h> // CDesCArrayFlat |
|
22 #include <StringLoader.h> |
|
23 #include <cmdestination.h> |
|
24 #include <cmconnectionmethoddef.h> |
|
25 #include <ipssossettings.rsg> |
|
26 |
|
27 #include "ipssetuiitemaccesspoint.h" |
|
28 |
|
29 |
|
30 // ============================ MEMBER FUNCTIONS =============================== |
|
31 |
|
32 // ---------------------------------------------------------------------------- |
|
33 // CIpsSetUiItemAccessPoint::CIpsSetUiItemAccessPoint() |
|
34 // ---------------------------------------------------------------------------- |
|
35 // |
|
36 CIpsSetUiItemAccessPoint::CIpsSetUiItemAccessPoint() |
|
37 : |
|
38 iIapType( ECuuUserDefined ), |
|
39 iIapPref( ECommDbDialogPrefUnknown ), |
|
40 iIapId( 0 ) |
|
41 { |
|
42 FUNC_LOG; |
|
43 } |
|
44 |
|
45 // ---------------------------------------------------------------------------- |
|
46 // CIpsSetUiItemAccessPoint::~CIpsSetUiItemAccessPoint() |
|
47 // ---------------------------------------------------------------------------- |
|
48 // |
|
49 CIpsSetUiItemAccessPoint::~CIpsSetUiItemAccessPoint() |
|
50 { |
|
51 FUNC_LOG; |
|
52 iIapList.Close(); |
|
53 iCommMethodManager.Close(); |
|
54 } |
|
55 |
|
56 // ---------------------------------------------------------------------------- |
|
57 // CIpsSetUiItemAccessPoint::ConstructL() |
|
58 // ---------------------------------------------------------------------------- |
|
59 // |
|
60 void CIpsSetUiItemAccessPoint::ConstructL() |
|
61 { |
|
62 FUNC_LOG; |
|
63 CIpsSetUiItemLink::ConstructL(); |
|
64 iCommMethodManager.OpenL(); |
|
65 } |
|
66 |
|
67 // ---------------------------------------------------------------------------- |
|
68 // CIpsSetUiItemAccessPoint::NewL() |
|
69 // ---------------------------------------------------------------------------- |
|
70 // |
|
71 CIpsSetUiItemAccessPoint* CIpsSetUiItemAccessPoint::NewL() |
|
72 { |
|
73 FUNC_LOG; |
|
74 CIpsSetUiItemAccessPoint* self = NewLC(); |
|
75 CleanupStack::Pop( self ); |
|
76 |
|
77 return self; |
|
78 } |
|
79 |
|
80 // ---------------------------------------------------------------------------- |
|
81 // CIpsSetUiItemAccessPoint::NewLC() |
|
82 // ---------------------------------------------------------------------------- |
|
83 // |
|
84 CIpsSetUiItemAccessPoint* CIpsSetUiItemAccessPoint::NewLC() |
|
85 { |
|
86 FUNC_LOG; |
|
87 CIpsSetUiItemAccessPoint* self = |
|
88 new ( ELeave ) CIpsSetUiItemAccessPoint(); |
|
89 CleanupStack::PushL( self ); |
|
90 self->ConstructL(); |
|
91 |
|
92 return self; |
|
93 } |
|
94 |
|
95 // ---------------------------------------------------------------------------- |
|
96 // CIpsSetUiItemAccessPoint::operator=() |
|
97 // ---------------------------------------------------------------------------- |
|
98 // |
|
99 CIpsSetUiItemAccessPoint& CIpsSetUiItemAccessPoint::operator=( |
|
100 const CIpsSetUiItemAccessPoint& aIapItem ) |
|
101 { |
|
102 FUNC_LOG; |
|
103 iItemFlags = aIapItem.iItemFlags; |
|
104 iItemType = aIapItem.iItemType; |
|
105 iItemLabel->Copy( *aIapItem.iItemLabel ); |
|
106 iItemId = aIapItem.iItemId; |
|
107 iItemResourceId = aIapItem.iItemResourceId; |
|
108 iItemLinkArray = aIapItem.iItemLinkArray; |
|
109 iItemSettingText->Copy( *aIapItem.iItemSettingText ); |
|
110 iItemAppereance = aIapItem.iItemAppereance; |
|
111 iIapType = aIapItem.iIapType; |
|
112 //iIapRadioButton = aIapItem.iIapRadioButton; |
|
113 iIapPref = aIapItem.iIapPref; |
|
114 iIapId = aIapItem.iIapId; |
|
115 |
|
116 return *this; |
|
117 } |
|
118 |
|
119 // ---------------------------------------------------------------------------- |
|
120 // CIpsSetUiItemAccessPoint::LaunchIapPageL() |
|
121 // ---------------------------------------------------------------------------- |
|
122 // |
|
123 TInt CIpsSetUiItemAccessPoint::LaunchL() |
|
124 { |
|
125 FUNC_LOG; |
|
126 // You have been warned... |
|
127 TInt result = KErrNone; |
|
128 TCuuAlwaysAskResults iapType = iIapType; |
|
129 TUint32 iapId = iIapId; |
|
130 |
|
131 InitializeSelectionL(); |
|
132 |
|
133 // Always ask page is launched, no matter what. |
|
134 result = LaunchAlwaysAskPageL( iapType ); |
|
135 |
|
136 if( result == KErrNone ) |
|
137 { |
|
138 // Launch the iap page |
|
139 if( iapType == ECuuUserDefined ) |
|
140 { |
|
141 result = LaunchIapPageL( iapId ); |
|
142 } |
|
143 } |
|
144 |
|
145 // Everything is fine, finally update the setting item |
|
146 if ( result == KErrNone ) |
|
147 { |
|
148 iIapPref = ECommDbDialogPrefUnknown; |
|
149 iIapType = iapType; |
|
150 iIapId = iapId; |
|
151 } |
|
152 |
|
153 // Access point has been changed, update the setting text. |
|
154 UpdateL(); |
|
155 |
|
156 // Return the quit method |
|
157 return result; |
|
158 } |
|
159 |
|
160 // ---------------------------------------------------------------------------- |
|
161 // CIpsSetUiItemAccessPoint::UpdateL() |
|
162 // ---------------------------------------------------------------------------- |
|
163 // |
|
164 void CIpsSetUiItemAccessPoint::UpdateL() |
|
165 { |
|
166 FUNC_LOG; |
|
167 if( iIapPref == ECommDbDialogPrefPrompt || iIapType == ECuuAlwaysAsk ) |
|
168 { |
|
169 iIapType = ECuuAlwaysAsk; |
|
170 iIapPref = ECommDbDialogPrefPrompt; |
|
171 iIapId = 0; |
|
172 } |
|
173 else |
|
174 { |
|
175 iIapType = ECuuUserDefined; |
|
176 iIapPref = ECommDbDialogPrefDoNotPrompt; |
|
177 } |
|
178 |
|
179 // If a static access point is set, the name of the accesspoint can |
|
180 // be fetched from the list. |
|
181 if( iIapType == ECuuUserDefined ) |
|
182 { |
|
183 iItemSettingText->Copy( AccessPointNameLC()->Des() ); |
|
184 CleanupStack::PopAndDestroy(); //AccessPointNameLC() |
|
185 } |
|
186 else |
|
187 { |
|
188 // Access point set to always ask, display the correct text |
|
189 HBufC* text = StringLoader::LoadL( R_FSE_SETTINGS_IAP_ALWAYS_ASK ); |
|
190 iItemSettingText->Copy( text->Left( KIpsSetUiMaxSettingsLongTextLength ) ); |
|
191 delete text; |
|
192 text = NULL; |
|
193 } |
|
194 } |
|
195 |
|
196 // ---------------------------------------------------------------------------- |
|
197 // CIpsSetUiItemAccessPoint::AccessPointNameLC() |
|
198 // ---------------------------------------------------------------------------- |
|
199 // |
|
200 HBufC* CIpsSetUiItemAccessPoint::AccessPointNameLC() |
|
201 { |
|
202 FUNC_LOG; |
|
203 HBufC* bearerName( NULL ); |
|
204 RCmConnectionMethod method = iCommMethodManager.ConnectionMethodL( iIapId ); |
|
205 CleanupClosePushL( method ); |
|
206 bearerName = method.GetStringAttributeL( CMManager::ECmName ); |
|
207 CleanupStack::PopAndDestroy(); //method |
|
208 CleanupStack::PushL( bearerName ); |
|
209 return bearerName; |
|
210 } |
|
211 |
|
212 // ---------------------------------------------------------------------------- |
|
213 // CIpsSetUiItemAccessPoint::AccessPointNameLC() |
|
214 // ---------------------------------------------------------------------------- |
|
215 // |
|
216 HBufC* CIpsSetUiItemAccessPoint::AccessPointNameLC( TInt aIndex ) |
|
217 { |
|
218 FUNC_LOG; |
|
219 HBufC* bearerName( NULL ); |
|
220 if( aIndex >= 0 && aIndex < iIapList.Count() ) |
|
221 { |
|
222 RCmConnectionMethod method = iCommMethodManager.ConnectionMethodL( iIapList[aIndex] ); |
|
223 CleanupClosePushL( method ); |
|
224 bearerName = method.GetStringAttributeL( CMManager::ECmName ); |
|
225 CleanupStack::PopAndDestroy(); //method |
|
226 CleanupStack::PushL( bearerName ); |
|
227 } |
|
228 return bearerName; |
|
229 } |
|
230 |
|
231 // ---------------------------------------------------------------------------- |
|
232 // CIpsSetUiItemAccessPoint::LaunchIapPageL() |
|
233 // ---------------------------------------------------------------------------- |
|
234 // |
|
235 TInt CIpsSetUiItemAccessPoint::LaunchIapPageL( TUint32& aIapId ) |
|
236 { |
|
237 FUNC_LOG; |
|
238 //This function handles the launching of the IAP setting page. |
|
239 //using the Connection Method Manager |
|
240 TInt result = KErrNotFound; |
|
241 //Show the access point list using Connection Method Manager |
|
242 TCmSettingSelection selection; |
|
243 TBearerFilterArray filterArray; |
|
244 //Set focus to the currently selected access point |
|
245 selection.iId = iIapId; |
|
246 selection.iResult = CMManager::EConnectionMethod; |
|
247 CCmApplicationSettingsUi* settingsUi = CCmApplicationSettingsUi::NewLC(); |
|
248 TUint apFilter = CMManager::EShowConnectionMethods; |
|
249 result = settingsUi->RunApplicationSettingsL( selection, apFilter, filterArray ); |
|
250 aIapId = result ? selection.iId : ( TUint32 )KErrNotFound; |
|
251 CleanupStack::PopAndDestroy( settingsUi ); |
|
252 // Return the quit method |
|
253 return result ? KErrNone : KErrCancel; |
|
254 } |
|
255 |
|
256 // ---------------------------------------------------------------------------- |
|
257 // CIpsSetUiItemAccessPoint::LaunchAlwaysAskPageL() |
|
258 // ---------------------------------------------------------------------------- |
|
259 // |
|
260 TInt CIpsSetUiItemAccessPoint::LaunchAlwaysAskPageL(TCuuAlwaysAskResults& aAlwaysAsk ) |
|
261 { |
|
262 FUNC_LOG; |
|
263 // Create utilities object for always ask page |
|
264 CConnectionUiUtilities* dialog = CConnectionUiUtilities::NewL(); |
|
265 CleanupStack::PushL( dialog ); |
|
266 |
|
267 // Open the always ask -page |
|
268 TBool ok = dialog->AlwaysAskPageL( aAlwaysAsk ); |
|
269 |
|
270 CleanupStack::PopAndDestroy( dialog ); |
|
271 dialog = NULL; |
|
272 |
|
273 // Ok or cancel pressed |
|
274 return ok ? KErrNone : KErrCancel; |
|
275 } |
|
276 |
|
277 // --------------------------------------------------------------------------- |
|
278 // CIpsSetUiItemAccessPoint::InitL() |
|
279 // --------------------------------------------------------------------------- |
|
280 // |
|
281 void CIpsSetUiItemAccessPoint::InitL( const TImIAPChoice& aIapChoice ) |
|
282 { |
|
283 FUNC_LOG; |
|
284 iIapPref = aIapChoice.iDialogPref; |
|
285 if( iIapPref == ECommDbDialogPrefPrompt ) |
|
286 { |
|
287 iIapId = 0; |
|
288 iIapType = ECuuAlwaysAsk; |
|
289 } |
|
290 else |
|
291 { |
|
292 InitializeSelectionL(); |
|
293 iIapId = aIapChoice.iIAP; |
|
294 iIapType = ECuuUserDefined; |
|
295 } |
|
296 UpdateL(); |
|
297 } |
|
298 |
|
299 // ---------------------------------------------------------------------------- |
|
300 // CIpsSetUiItemAccessPoint::InitializeSelection() |
|
301 // ---------------------------------------------------------------------------- |
|
302 // |
|
303 void CIpsSetUiItemAccessPoint::InitializeSelectionL() |
|
304 { |
|
305 FUNC_LOG; |
|
306 TBool wlanSupported( FeatureManager::FeatureSupported( KFeatureIdProtocolWlan ) ); |
|
307 //fill the array of connection method id's |
|
308 iCommMethodManager.ConnectionMethodL( iIapList, ETrue, EFalse, wlanSupported ); |
|
309 } |
|
310 |
|
311 // ---------------------------------------------------------------------------- |
|
312 // CIpsSetUiItemAccessPoint::GetIapIdL() |
|
313 // ---------------------------------------------------------------------------- |
|
314 // |
|
315 TUint32 CIpsSetUiItemAccessPoint::GetIapIdL() |
|
316 { |
|
317 FUNC_LOG; |
|
318 return iIapId; |
|
319 } |
|
320 |
|
321 // End of File |
|
322 |
|
323 |