1 /* |
|
2 * Copyright (c) 2006 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: Class for asyncron calls. |
|
15 * |
|
16 */ |
|
17 |
|
18 // INCLUDE FILES |
|
19 #include <AknQueryDialog.h> |
|
20 #include <rmmcustomapi.h> |
|
21 #include <etelmm.h> |
|
22 #include <apcontrollistpluginrsc.rsg> |
|
23 #include <errorres.rsg> |
|
24 #include <StringLoader.h> |
|
25 #include <aknnotewrappers.h> |
|
26 |
|
27 #include "apcontrollistapiwrapper.h" |
|
28 #include "apcontrollistpluginlogger.h" |
|
29 #include "apcontrollistplugincontainer.h" |
|
30 #include "apcontrollistplugin.h" |
|
31 #include "apcontrollistbox.h" |
|
32 #include "centralrepository.h" |
|
33 #include "CoreApplicationUIsSDKCRKeys.h" |
|
34 |
|
35 // ============================ MEMBER FUNCTIONS =============================== |
|
36 |
|
37 // ----------------------------------------------------------------------------- |
|
38 // CAPControlListAPIWrapper::CAPControlListAPIWrapper |
|
39 // Description: CAPControlListAPIWrapper constructer |
|
40 // ----------------------------------------------------------------------------- |
|
41 // |
|
42 CAPControlListAPIWrapper::CAPControlListAPIWrapper( |
|
43 CAPControlListPlugin& aPlugin, TInt aPriority ) : |
|
44 CActive( aPriority ), |
|
45 iPlugin(aPlugin), |
|
46 iApnPKG(iApn) |
|
47 { |
|
48 CActiveScheduler::Add( this ); |
|
49 } |
|
50 |
|
51 // |
|
52 //----------------------------------------------------------------------------- |
|
53 // CAPControlListAPIWrapper:: CAPControlListAPIWrapper |
|
54 // Description: CAPControlListAPIWrapper Destructer |
|
55 // ----------------------------------------------------------------------------- |
|
56 // |
|
57 CAPControlListAPIWrapper::~CAPControlListAPIWrapper() |
|
58 { |
|
59 CLOG( ( ESelector, 0, _L( |
|
60 "-> CAPControlListAPIWrapper::~CAPControlListAPIWrapper" ) ) ); |
|
61 Cancel(); |
|
62 iCustomAPI.Close(); |
|
63 iPhone.Close(); |
|
64 iServer.Close(); |
|
65 delete iAPN; |
|
66 CLOG( ( ESelector, 0, _L( |
|
67 "<- CAPControlListAPIWrapper::~CAPControlListAPIWrapper" ) ) ); |
|
68 } |
|
69 |
|
70 // |
|
71 //----------------------------------------------------------------------------- |
|
72 // CAPControlListAPIWrapper::RequestFunction |
|
73 // Description: Request Function for CAPControlListAPIWrapper |
|
74 // ---------------------------------------------------------------------------- |
|
75 // |
|
76 void CAPControlListAPIWrapper::SecurityCheck(TRequestType aRequest) |
|
77 { |
|
78 CLOG( ( ESelector, 0, _L( |
|
79 "-> CAPControlListAPIWrapper::SecurityCheck" ) ) ); |
|
80 if( !IsActive() ) |
|
81 { |
|
82 iCustomAPI.CheckSecurityCode (iStatus, |
|
83 RMmCustomAPI::ESecurityCodePin2 ); |
|
84 iRequest = aRequest; |
|
85 SetActive(); |
|
86 } |
|
87 CLOG( ( ESelector, 0, _L( |
|
88 "<- CAPControlListAPIWrapper::SecurityCheck" ) ) ); |
|
89 } |
|
90 |
|
91 |
|
92 // |
|
93 //----------------------------------------------------------------------------- |
|
94 // CAPControlListAPIWrapper::DoCancel |
|
95 // Description: This is called from CActive's Cancel |
|
96 //----------------------------------------------------------------------------- |
|
97 // |
|
98 void CAPControlListAPIWrapper::DoCancel() |
|
99 { |
|
100 CLOG( ( ESelector, 0, _L( |
|
101 "-> CAPControlListAPIWrapper::DoCancel" ) ) ); |
|
102 CLOG( ( ESelector, 0, _L( "Current request: %d" ), iRequest ) ); |
|
103 switch(iRequest) |
|
104 { |
|
105 case EEnumerateAPN: |
|
106 iPhone.CancelAsyncRequest(EMobilePhoneEnumerateAPNEntries); |
|
107 break; |
|
108 case EReadData: |
|
109 iPhone.CancelAsyncRequest(EMobilePhoneGetAPNname); |
|
110 break; |
|
111 |
|
112 // Since there are no enums for these, can't cancel |
|
113 case EAddAPNSecurity: |
|
114 case EAddAPN: |
|
115 case ERemoveAPNSecurity: |
|
116 case ERemoveAPN: |
|
117 case EActivateACLSecurity: |
|
118 case EActivateACL: |
|
119 case EDeactivateACLSecurity: |
|
120 case EDeactivateACL: |
|
121 break; |
|
122 |
|
123 case ENoRequest: // no active request |
|
124 break; |
|
125 default: |
|
126 // This could be only in case of programming error |
|
127 CLOG( ( ESelector, 0, _L( "State Error: %d" ), iRequest ) ); |
|
128 break; |
|
129 } |
|
130 CLOG( ( ESelector, 0, _L( |
|
131 "<- CAPControlListAPIWrapper::DoCancel" ) ) ); |
|
132 } |
|
133 |
|
134 // |
|
135 //----------------------------------------------------------------------------- |
|
136 // CAPControlListAPIWrapper::FinishReadDataL |
|
137 // Description: Case EReadData in RunL |
|
138 //----------------------------------------------------------------------------- |
|
139 // |
|
140 void CAPControlListAPIWrapper::FinishReadDataL() |
|
141 { |
|
142 CLOG( ( ESelector, 0, _L( |
|
143 "-> CAPControlListAPIWrapper::FinishReadDataL" ) ) ); |
|
144 if (iIndex > 0) |
|
145 { |
|
146 iApn = iApnPKG(); |
|
147 // lablel lengthes must be replaced with dots and |
|
148 // removed from the beginnig |
|
149 if ( iApn.iApn.Length() ) |
|
150 { |
|
151 TUint8 lablelLength = (TUint8)(iApn.iApn[0]); |
|
152 TUint8 wholeLength = lablelLength; |
|
153 iApn.iApn.Delete(0,1); |
|
154 while (iApn.iApn.Length() > wholeLength) |
|
155 { |
|
156 wholeLength = wholeLength + |
|
157 (TUint8)(iApn.iApn[lablelLength]) + 1; |
|
158 iApn.iApn[lablelLength] = '.'; |
|
159 lablelLength = wholeLength;//place of next dot |
|
160 } |
|
161 HBufC* buf = HBufC::NewLC( RMobilePhone::KMaxApnName ); |
|
162 buf->Des().Copy( iApn.iApn ); |
|
163 TPtrC itemPtr(buf->Des()); |
|
164 iPlugin.Container()->AddToListBoxL(itemPtr); |
|
165 CleanupStack::PopAndDestroy( buf ); |
|
166 } |
|
167 else |
|
168 { |
|
169 // Empty APN means network provided APN |
|
170 HBufC* buf = StringLoader::LoadLC ( |
|
171 R_QTN_ACL_NETWORK_PROVIDED_APN ); |
|
172 TPtrC nPtr(buf->Des()); |
|
173 iPlugin.Container()->AddToListBoxL(nPtr); |
|
174 CleanupStack::PopAndDestroy( buf ); |
|
175 } |
|
176 } |
|
177 if (iIndex < iSize) |
|
178 { |
|
179 DoReadData(); |
|
180 iIndex++; |
|
181 } |
|
182 else |
|
183 { |
|
184 iRequest = ENoRequest; |
|
185 if ( iSize > 0 ) |
|
186 { |
|
187 iPlugin.Container()->SetCurrentItemIndex(0); |
|
188 } |
|
189 } |
|
190 CLOG( ( ESelector, 0, _L( |
|
191 "<- CAPControlListAPIWrapper::FinishReadDataL" ) ) ); |
|
192 } |
|
193 |
|
194 // |
|
195 //----------------------------------------------------------------------------- |
|
196 // CAPControlListAPIWrapper::RunL |
|
197 // Description: CActive::RunL implementation which will either stop the |
|
198 // Scheduler or increment the count |
|
199 //----------------------------------------------------------------------------- |
|
200 // |
|
201 void CAPControlListAPIWrapper::RunL() |
|
202 { |
|
203 if ( iStatus != KErrNone ) |
|
204 { |
|
205 CLOG( ( ESelector, 0, _L( "Bad RequestStatus: %d for request: %d" ), |
|
206 iStatus.Int(), iRequest) ); |
|
207 |
|
208 // KErrOverflow can occur during APN adding process, if the APN list is full |
|
209 // or there is no space for an additional entry in SIM card. |
|
210 if( iStatus.Int() == KErrOverflow && iRequest == EAddAPN) |
|
211 { |
|
212 HBufC* text = StringLoader::LoadLC ( |
|
213 R_QTN_ACL_ERR_SIM_CARD ); |
|
214 CAknErrorNote* note = new ( ELeave ) CAknErrorNote( |
|
215 ETrue ); |
|
216 note->ExecuteLD( *text ); |
|
217 |
|
218 CleanupStack::PopAndDestroy( text ); |
|
219 } |
|
220 |
|
221 iRequest = ENoRequest; |
|
222 |
|
223 return; |
|
224 } |
|
225 switch(iRequest) |
|
226 { |
|
227 case EGetACLStatus: |
|
228 { |
|
229 CLOG( ( ESelector, 0, _L( "EGetACLStatus OK" ) ) ); |
|
230 #ifdef _DEBUG |
|
231 if (iAclStatus == RMobilePhone::EAPNControlListServiceEnabled) |
|
232 { |
|
233 CLOG( ( ESelector, 0, _L( "iAclStatus == EAclStatusEnabled" ) ) ); |
|
234 } |
|
235 else if (iAclStatus == RMobilePhone::EAPNControlListServiceDisabled) |
|
236 { |
|
237 CLOG( ( ESelector, 0, _L( "iAclStatus == EAclStatusDisabled" ) ) ); |
|
238 } |
|
239 else |
|
240 { |
|
241 CLOG( ( ESelector, 0, _L( "iAclStatus is bad!!!" ) ) ); |
|
242 } |
|
243 #endif |
|
244 if ( Enabled() ) |
|
245 { |
|
246 iPlugin.ShowInfoNoteL(R_QTN_ACL_INFO_ACTIVE); |
|
247 iPlugin.Container()->WriteToNaviPaneL(R_QTN_ACL_NAVI_ACTIVE); |
|
248 } |
|
249 else |
|
250 { |
|
251 iPlugin.ShowInfoNoteL(R_QTN_ACL_INFO_NOT_ACTIVE); |
|
252 iPlugin.Container()->WriteToNaviPaneL(R_QTN_ACL_NAVI_NOT_ACTIVE); |
|
253 } |
|
254 EnumerateAPN(); |
|
255 break; |
|
256 } |
|
257 case EAddAPNSecurity: |
|
258 CLOG( ( ESelector, 0, _L( "EAddAPNSecurity OK" ) ) ); |
|
259 iSecurityChecked = ETrue; |
|
260 DoAddAPNL(); |
|
261 break; |
|
262 case EAddAPN: |
|
263 { |
|
264 iRequest = ENoRequest; |
|
265 CLOG( ( ESelector, 0, _L( "EAddAPN OK" ) ) ); |
|
266 TPtrC tptrc(iAPN->Des()); |
|
267 if (tptrc.Length()) |
|
268 { |
|
269 iPlugin.Container()->AddToListBoxL(tptrc); |
|
270 iPlugin.ShowConfirmNoteAPNL(R_QTN_ACL_CONF_APN_ADDED, tptrc); |
|
271 } |
|
272 else |
|
273 { |
|
274 HBufC* buf = StringLoader::LoadLC ( |
|
275 R_QTN_ACL_NETWORK_PROVIDED_APN ); |
|
276 TPtrC itemPtr(buf->Des()); |
|
277 iPlugin.Container()->AddToListBoxL(itemPtr); |
|
278 CleanupStack::PopAndDestroy( buf ); |
|
279 iPlugin.ShowConfirmNoteL(R_QTN_ACL_CONF_NWP_APN_ADDED); |
|
280 } |
|
281 break; |
|
282 } |
|
283 case ERemoveAPNSecurity: |
|
284 CLOG( ( ESelector, 0, _L( "ERemoveAPNSecurity OK" ) ) ); |
|
285 iSecurityChecked = ETrue; |
|
286 DoRemoveAPN(); |
|
287 break; |
|
288 case ERemoveAPN: |
|
289 iRequest = ENoRequest; |
|
290 CLOG( ( ESelector, 0, _L( "ERemoveAPN OK" ) ) ); |
|
291 iPlugin.ShowConfirmNoteL(R_QTN_ACL_CONF_APN_REMOVED); |
|
292 iPlugin.Container()->RemoveFromListBoxL(); |
|
293 break; |
|
294 case EActivateACLSecurity: |
|
295 CLOG( ( ESelector, 0, _L( "EActivateACLSecurity OK" ) ) ); |
|
296 iSecurityChecked = ETrue; |
|
297 SetACLStatus( RMobilePhone::EAPNControlListServiceEnabled ); |
|
298 break; |
|
299 case EActivateACL: |
|
300 iRequest = ENoRequest; |
|
301 CLOG( ( ESelector, 0, _L( "EActivateACL OK" ) ) ); |
|
302 iAclStatus = RMobilePhone::EAPNControlListServiceEnabled; |
|
303 iPlugin.ShowConfirmNoteL(R_QTN_ACL_CONF_CONTROL_ACTIVATED); |
|
304 iPlugin.Container()->WriteToNaviPaneL(R_QTN_ACL_NAVI_ACTIVE); |
|
305 break; |
|
306 case EDeactivateACLSecurity: |
|
307 CLOG( ( ESelector, 0, _L( "EDeactivateACLSecurity OK" ) ) ); |
|
308 iSecurityChecked = ETrue; |
|
309 SetACLStatus( RMobilePhone::EAPNControlListServiceDisabled ); |
|
310 break; |
|
311 case EDeactivateACL: |
|
312 iRequest = ENoRequest; |
|
313 CLOG( ( ESelector, 0, _L( "EDeactivateACL OK" ) ) ); |
|
314 iAclStatus = RMobilePhone::EAPNControlListServiceDisabled; |
|
315 iPlugin.ShowConfirmNoteL(R_QTN_ACL_CONF_CONTROL_DEACTIVATED); |
|
316 iPlugin.Container()->WriteToNaviPaneL(R_QTN_ACL_NAVI_NOT_ACTIVE); |
|
317 break; |
|
318 case EEnumerateAPN: |
|
319 CLOG( ( ESelector, 0, _L( "EEnumerateAPN OK" ) ) ); |
|
320 iRequest = EReadData; |
|
321 FinishReadDataL(); |
|
322 break; |
|
323 case EReadData: |
|
324 CLOG( ( ESelector, 0, _L( "EReadData OK" ) ) ); |
|
325 FinishReadDataL(); |
|
326 break; |
|
327 default: |
|
328 { |
|
329 // This could be only in case of programming error |
|
330 CLOG( ( ESelector, 0, _L( "State Error: %d" ), iRequest ) ); |
|
331 User::Leave(KErrGeneral); |
|
332 } |
|
333 break; |
|
334 } |
|
335 } |
|
336 |
|
337 |
|
338 // --------------------------------------------------------- |
|
339 // CAPControlListAPIWrapper::DoReadData |
|
340 // --------------------------------------------------------- |
|
341 void CAPControlListAPIWrapper::DoReadData() |
|
342 { |
|
343 CLOG( ( ESelector, 0, _L( "-> CAPControlListAPIWrapper::ReadData2" ) ) ); |
|
344 if( !IsActive() ) |
|
345 { |
|
346 iRequest = EReadData; |
|
347 iApn.iApn.Zero(); |
|
348 iApn.iApn.SetMax(); |
|
349 iPhone.GetAPNname(iStatus, iIndex, iApnPKG); |
|
350 SetActive(); |
|
351 } |
|
352 CLOG( ( ESelector, 0, _L( "<- CAPControlListAPIWrapper::ReadData2" ) ) ); |
|
353 } |
|
354 // --------------------------------------------------------- |
|
355 // CAPControlListAPIWrapper::ReadData |
|
356 // --------------------------------------------------------- |
|
357 void CAPControlListAPIWrapper::ReadData() |
|
358 { |
|
359 CLOG( ( ESelector, 0, _L( "-> CAPControlListAPIWrapper::ReadData" ) ) ); |
|
360 if( !IsActive() ) |
|
361 { |
|
362 iRequest = EGetACLStatus; |
|
363 iPhone.GetAPNControlListServiceStatus( iStatus, iAclStatus ); |
|
364 SetActive(); |
|
365 } |
|
366 CLOG( ( ESelector, 0, _L( "<- CAPControlListAPIWrapper::ReadData" ) ) ); |
|
367 } |
|
368 // --------------------------------------------------------- |
|
369 // CAPControlListAPIWrapper::ReadData |
|
370 // --------------------------------------------------------- |
|
371 void CAPControlListAPIWrapper::EnumerateAPN() |
|
372 { |
|
373 CLOG( ( ESelector, 0, _L( "-> CAPControlListAPIWrapper::ReadData" ) ) ); |
|
374 if( !IsActive() ) |
|
375 { |
|
376 iRequest = EEnumerateAPN; |
|
377 iIndex = 0; |
|
378 iPhone.EnumerateAPNEntries(iStatus, iSize); |
|
379 SetActive(); |
|
380 } |
|
381 CLOG( ( ESelector, 0, _L( "<- CAPControlListAPIWrapper::ReadData" ) ) ); |
|
382 } |
|
383 |
|
384 // --------------------------------------------------------- |
|
385 // CAPControlListAPIWrapper::DeActivateACLL() |
|
386 // --------------------------------------------------------- |
|
387 // |
|
388 void CAPControlListAPIWrapper::DeActivateACL() |
|
389 { |
|
390 CLOG( ( ESelector, 0, _L( |
|
391 "-> CAPControlListAPIWrapper::DeActivateACLL" ) ) ); |
|
392 if (iSecurityChecked) |
|
393 { |
|
394 SetACLStatus( RMobilePhone::EAPNControlListServiceDisabled ); |
|
395 } |
|
396 else |
|
397 { |
|
398 SecurityCheck(EDeactivateACLSecurity); |
|
399 } |
|
400 |
|
401 CLOG( ( ESelector, 0, _L( |
|
402 "<- CAPControlListAPIWrapper::DeActivateACLL" ) ) ); |
|
403 } |
|
404 |
|
405 // --------------------------------------------------------- |
|
406 // CAPControlListAPIWrapper::ActivateACLL() |
|
407 // --------------------------------------------------------- |
|
408 // |
|
409 void CAPControlListAPIWrapper::ActivateACL() |
|
410 { |
|
411 CLOG( ( ESelector, 0, _L( |
|
412 "-> CAPControlListAPIWrapper::ActivateACLL" ) ) ); |
|
413 if (iSecurityChecked) |
|
414 { |
|
415 SetACLStatus( RMobilePhone::EAPNControlListServiceEnabled ); |
|
416 } |
|
417 else |
|
418 { |
|
419 SecurityCheck(EActivateACLSecurity); |
|
420 } |
|
421 |
|
422 CLOG( ( ESelector, 0, _L( |
|
423 "<- CAPControlListAPIWrapper::ActivateACLL" ) ) ); |
|
424 } |
|
425 |
|
426 // --------------------------------------------------------- |
|
427 // CAPControlListAPIWrapper::SetACLStatus() |
|
428 // --------------------------------------------------------- |
|
429 // |
|
430 void CAPControlListAPIWrapper::SetACLStatus( const |
|
431 RMobilePhone::TAPNControlListServiceStatus aAPNControlListServiceStatus ) |
|
432 { |
|
433 CLOG( ( ESelector, 0, |
|
434 _L( "-> CAPControlListAPIWrapper::SetACLStatus" ) ) ); |
|
435 if( !IsActive() ) |
|
436 { |
|
437 iPhone.SetAPNControlListServiceStatus( iStatus, |
|
438 aAPNControlListServiceStatus ); |
|
439 if ( aAPNControlListServiceStatus == |
|
440 RMobilePhone::EAPNControlListServiceEnabled ) |
|
441 { |
|
442 iRequest = EActivateACL; |
|
443 } |
|
444 else |
|
445 { |
|
446 iRequest = EDeactivateACL; |
|
447 } |
|
448 SetActive(); |
|
449 } |
|
450 CLOG( ( ESelector, 0, _L( |
|
451 "<- CAPControlListAPIWrapper::SetACLStatus" ) ) ); |
|
452 } |
|
453 |
|
454 |
|
455 // --------------------------------------------------------- |
|
456 // CAPControlListAPIWrapper::RemoveAPN() |
|
457 // --------------------------------------------------------- |
|
458 // |
|
459 void CAPControlListAPIWrapper::RemoveAPN() |
|
460 { |
|
461 CLOG( ( ESelector, 0, _L( "-> CAPControlListAPIWrapper::RemoveAPNL" ) ) ); |
|
462 if( iPlugin.Container()->NumberOfItems() > 0) |
|
463 { |
|
464 if (iSecurityChecked) |
|
465 { |
|
466 DoRemoveAPN(); |
|
467 } |
|
468 else |
|
469 { |
|
470 SecurityCheck(ERemoveAPNSecurity); |
|
471 } |
|
472 } |
|
473 CLOG( ( ESelector, 0, _L( "<- CAPControlListAPIWrapper::RemoveAPNL" ) ) ); |
|
474 } |
|
475 |
|
476 // --------------------------------------------------------- |
|
477 // CAPControlListAPIWrapper::DoRemoveAPN() |
|
478 // --------------------------------------------------------- |
|
479 // |
|
480 void CAPControlListAPIWrapper::DoRemoveAPN() |
|
481 { |
|
482 CLOG( ( ESelector, 0, _L( "-> CAPControlListAPIWrapper::RemoveAPN2L" ) ) ); |
|
483 if( !IsActive() ) |
|
484 { |
|
485 TInt index = iPlugin.Container()->CurrentItemIndex(); |
|
486 iPhone.DeleteAPNName( iStatus, index ); |
|
487 iRequest = ERemoveAPN; |
|
488 SetActive(); |
|
489 } |
|
490 CLOG( ( ESelector, 0, _L( "<- CAPControlListAPIWrapper::RemoveAPN2L" ) ) ); |
|
491 } |
|
492 |
|
493 // --------------------------------------------------------- |
|
494 // CAPControlListAPIWrapper::AddAPNL() |
|
495 // --------------------------------------------------------- |
|
496 // |
|
497 void CAPControlListAPIWrapper::AddAPNL() |
|
498 { |
|
499 CLOG( ( ESelector, 0, _L( "-> CAPControlListAPIWrapper::AddAPNL" ) ) ); |
|
500 if (iSecurityChecked) |
|
501 { |
|
502 DoAddAPNL(); |
|
503 } |
|
504 else |
|
505 { |
|
506 SecurityCheck(EAddAPNSecurity); |
|
507 } |
|
508 |
|
509 CLOG( ( ESelector, 0, _L( "<- CAPControlListAPIWrapper::AddAPNL" ) ) ); |
|
510 } |
|
511 |
|
512 // --------------------------------------------------------- |
|
513 // CAPControlListAPIWrapper::DoAddAPNL() |
|
514 // --------------------------------------------------------- |
|
515 // |
|
516 void CAPControlListAPIWrapper::DoAddAPNL() |
|
517 { |
|
518 CLOG( ( ESelector, 0, _L( "-> CAPControlListAPIWrapper::DoAddAPNL" ) ) ); |
|
519 if( !IsActive() ) |
|
520 { |
|
521 delete iAPN; |
|
522 iAPN = NULL; |
|
523 iAPN = HBufC::NewL( RMobilePhone::KMaxApnName ); |
|
524 TPtr16 ptr( iAPN->Des() ); |
|
525 CAknQueryDialog* dlg = |
|
526 CAknQueryDialog::NewL( ptr, CAknQueryDialog::ENoTone ); |
|
527 |
|
528 TBool notCanceled = EFalse; |
|
529 |
|
530 // Ask the user until either the input is valid or canceled |
|
531 while ( dlg->ExecuteLD( R_APN_NAME_QUERY ) ) |
|
532 { |
|
533 |
|
534 TBool validInput = ETrue; |
|
535 |
|
536 for (TInt index = 0; index < ptr.Length(); index++) |
|
537 { |
|
538 TChar inputchar = ptr[index]; |
|
539 // For ACL only 0-9, A-Z, a-z, '-' and '.' are valid |
|
540 if (! ( ('0' <= inputchar && inputchar <= '9') || |
|
541 ('A' <= inputchar && inputchar <= 'Z') || |
|
542 ('a' <= inputchar && inputchar <= 'z') || |
|
543 inputchar == '-' || inputchar == '.' ) ) |
|
544 { |
|
545 validInput = EFalse; |
|
546 break; |
|
547 } |
|
548 } |
|
549 |
|
550 if ( validInput ) |
|
551 { |
|
552 notCanceled = ETrue; |
|
553 break; |
|
554 } |
|
555 else |
|
556 { |
|
557 HBufC* text = StringLoader::LoadLC ( |
|
558 R_QTN_ACL_ERR_INVALID_INPUT ); |
|
559 CAknErrorNote* note = new ( ELeave ) CAknErrorNote( |
|
560 ETrue ); |
|
561 note->ExecuteLD( *text ); |
|
562 |
|
563 CleanupStack::PopAndDestroy( text ); |
|
564 |
|
565 dlg = |
|
566 CAknQueryDialog::NewL( ptr, CAknQueryDialog::ENoTone ); |
|
567 |
|
568 } |
|
569 } |
|
570 |
|
571 if ( notCanceled ) |
|
572 { |
|
573 |
|
574 // lablel lengthes must be added in place of dots and at the |
|
575 // beginnig |
|
576 _LIT8(KFormat,"%c%S"); |
|
577 iApn.iApn.SetMax(); |
|
578 iApn.iApn.Zero(); |
|
579 if ( iAPN->Length() ) |
|
580 { |
|
581 TBufC8<RMobilePhone::KMaxApnName> buffer; |
|
582 TBufC8<RMobilePhone::KMaxApnName> buffer2; |
|
583 buffer.Des().Copy( iAPN->Des() ); |
|
584 TInt index = buffer.Des().Find(_L8(".")); |
|
585 |
|
586 while (index != KErrNotFound) |
|
587 { |
|
588 buffer2.Des().Copy( buffer.Des().Left( index ) ); |
|
589 TPtr8 tmp = buffer2.Des(); |
|
590 iApn.iApn.AppendFormat(KFormat, index, &tmp); |
|
591 buffer.Des().Delete(0,index+1); |
|
592 index = buffer.Des().Find(_L8(".")); |
|
593 } |
|
594 TPtr8 tmp = buffer.Des(); |
|
595 iApn.iApn.AppendFormat(KFormat, buffer.Length(), &tmp); |
|
596 } |
|
597 else |
|
598 { |
|
599 _LIT8(KEmpty8,""); |
|
600 iApn.iApn.Copy(KEmpty8); |
|
601 } |
|
602 |
|
603 CLOG( ( ESelector, 0, _L( "Size: %d" ), iApn.iApn.Size() ) ); |
|
604 iPhone.AppendAPNName( iStatus, iApnPKG ); |
|
605 |
|
606 iRequest = EAddAPN; |
|
607 SetActive(); |
|
608 } |
|
609 } |
|
610 CLOG( ( ESelector, 0, _L( "<- CAPControlListAPIWrapper::DoAddAPNL" ) ) ); |
|
611 } |
|
612 |
|
613 // --------------------------------------------------------- |
|
614 // CAPControlListAPIWrapper::Visible |
|
615 // --------------------------------------------------------- |
|
616 TBool CAPControlListAPIWrapper::Visible() const |
|
617 { |
|
618 CLOG( ( ESelector, 0, _L( "-> CAPControlListAPIWrapper::Visible" ) ) ); |
|
619 if (!iConnAllowed) |
|
620 { |
|
621 return EFalse; // phone is in off-line mode |
|
622 } |
|
623 TUint32 aCaps; |
|
624 iPhone.GetIccAccessCaps(aCaps); |
|
625 CLOG( ( ESelector, 0, _L( "%d" ), aCaps) ); |
|
626 if (aCaps & RMobilePhone::KCapsUSimAccessSupported) |
|
627 { |
|
628 CLOG( ( ESelector, 0, _L( |
|
629 "<- CAPControlListAPIWrapper::Visible 2" ) ) ); |
|
630 return ETrue; |
|
631 } |
|
632 else |
|
633 { |
|
634 CLOG( ( ESelector, 0, _L( |
|
635 "<- CAPControlListAPIWrapper::Visible 3" ) ) ); |
|
636 return EFalse; |
|
637 } |
|
638 } |
|
639 // --------------------------------------------------------- |
|
640 // CAPControlListAPIWrapper::Enabled |
|
641 // --------------------------------------------------------- |
|
642 TBool CAPControlListAPIWrapper::Enabled() const |
|
643 { |
|
644 CLOG( ( ESelector, 0, _L( "-> CAPControlListAPIWrapper::Enabled" ) ) ); |
|
645 CLOG( ( ESelector, 0, _L( "<- CAPControlListAPIWrapper::Enabled" ) ) ); |
|
646 if ( iAclStatus == RMobilePhone::EAPNControlListServiceEnabled ) |
|
647 { |
|
648 return ETrue; |
|
649 } |
|
650 else |
|
651 { |
|
652 return EFalse; |
|
653 } |
|
654 } |
|
655 |
|
656 // --------------------------------------------------------- |
|
657 // CAPControlListAPIWrapper::ConstructL() |
|
658 // --------------------------------------------------------- |
|
659 // |
|
660 void CAPControlListAPIWrapper::ConstructL() |
|
661 { |
|
662 CLOG( ( ESelector, 0, _L( "-> CAPControlListAPIWrapper::ConstructL" ) ) ); |
|
663 // init RMobilePhone and RMmCustomAPI |
|
664 _LIT (KTsyName,"phonetsy.tsy"); |
|
665 RTelServer::TPhoneInfo info; |
|
666 RPhone::TLineInfo lineInfo; |
|
667 User::LeaveIfError( iServer.Connect() ); |
|
668 User::LeaveIfError( iServer.LoadPhoneModule( KTsyName ) ); |
|
669 User::LeaveIfError( iServer.GetPhoneInfo( 0, info ) ); |
|
670 User::LeaveIfError( iPhone.Open(iServer, info.iName) ); |
|
671 User::LeaveIfError( iPhone.Initialise() ); |
|
672 User::LeaveIfError( iCustomAPI.Open(iPhone) ); |
|
673 |
|
674 CRepository* aRepository = CRepository::NewL( KCRUidCoreApplicationUIs ); |
|
675 aRepository->Get( KCoreAppUIsNetworkConnectionAllowed, iConnAllowed); |
|
676 delete aRepository; |
|
677 |
|
678 if (!iAPN) |
|
679 { |
|
680 iAPN = HBufC::NewL( RMobilePhone::KMaxApnName ); |
|
681 } |
|
682 CLOG( ( ESelector, 0, _L( "<- CAPControlListAPIWrapper::ConstructL" ) ) ); |
|
683 } |
|
684 |
|
685 // ---------------------------------------------------------- |
|
686 // CAPControlListPlugin::NotifyIccAccessCapsChange() |
|
687 // ---------------------------------------------------------- |
|
688 // |
|
689 void CAPControlListAPIWrapper::NotifyIccAccessCapsChange( |
|
690 TRequestStatus& aReqStatus, TUint32& aCaps) |
|
691 { |
|
692 CLOG( ( ESelector, 0, |
|
693 _L( "-> CAPControlListAPIWrapper::NotifyIccAccessCapsChange" ) ) ); |
|
694 iPhone.NotifyIccAccessCapsChange( aReqStatus, aCaps ); |
|
695 CLOG( ( ESelector, 0, |
|
696 _L( "<- CAPControlListAPIWrapper::NotifyIccAccessCapsChange" ) ) ); |
|
697 } |
|
698 // ---------------------------------------------------------- |
|
699 // CAPControlListPlugin::CancelNotify() |
|
700 // ---------------------------------------------------------- |
|
701 // |
|
702 void CAPControlListAPIWrapper::CancelNotify() |
|
703 { |
|
704 CLOG( ( ESelector, 0, |
|
705 _L( "-> CAPControlListAPIWrapper::CancelNotify" ) ) ); |
|
706 iPhone.CancelAsyncRequest(EMobilePhoneNotifyIccAccessCapsChange); |
|
707 CLOG( ( ESelector, 0, |
|
708 _L( "<- CAPControlListAPIWrapper::CancelNotify" ) ) ); |
|
709 } |
|