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