|
1 // Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // |
|
15 |
|
16 #include "CGetLockInfo.h" |
|
17 |
|
18 /** |
|
19 Factory constructor. |
|
20 |
|
21 @param aController Pointer to MExecAsync object passed to constructor of |
|
22 CISVAPIBase |
|
23 @return Instance of CGetLockInfo class |
|
24 */ |
|
25 CGetLockInfo* CGetLockInfo::NewL(MExecAsync* aController) |
|
26 { |
|
27 CGetLockInfo* self = new(ELeave) CGetLockInfo(aController); |
|
28 CleanupStack::PushL(self); |
|
29 self->ConstructL(); |
|
30 CleanupStack::Pop(self); |
|
31 return self; |
|
32 } |
|
33 |
|
34 /** |
|
35 Destructor. |
|
36 Cancels outstanding requests. |
|
37 */ |
|
38 CGetLockInfo::~CGetLockInfo() |
|
39 { |
|
40 Cancel(); |
|
41 } |
|
42 |
|
43 /** |
|
44 Gets ICC Lock information and stores it in the iIccLockInfoV1Pckg package. |
|
45 */ |
|
46 void CGetLockInfo::DoStartRequestL() |
|
47 { |
|
48 _LIT(KDummyAnswerPanic, "CGetLockInfo Get Method"); |
|
49 __ASSERT_ALWAYS(!IsActive(), User::Panic(KDummyAnswerPanic, 1)); |
|
50 iRequestNotify = EFalse; |
|
51 CTelephony::TIccLock lockSelect = CTelephony::ELockPin2; |
|
52 |
|
53 // Retrieves the state and status of ICC locks |
|
54 iTelephony->GetLockInfo(iStatus, lockSelect, iIccLockInfoV1Pckg); |
|
55 SetActive(); |
|
56 } |
|
57 |
|
58 /** |
|
59 Default constructor. |
|
60 |
|
61 @param aController Pointer to an MExecAsync object passed to constructor of |
|
62 CISVAPIBase |
|
63 */ |
|
64 CGetLockInfo::CGetLockInfo(MExecAsync* aController) |
|
65 : CISVAPIAsync(aController, KLockInfo), |
|
66 iIccLockInfoV1Pckg(iIccLockInfoV1) |
|
67 { |
|
68 // Empty method |
|
69 } |
|
70 |
|
71 /** |
|
72 Second phase constructor. |
|
73 */ |
|
74 void CGetLockInfo::ConstructL() |
|
75 { |
|
76 // Empty method |
|
77 } |
|
78 |
|
79 /** |
|
80 Checks status of the active object and displays the ICC lock information if |
|
81 there is no error. |
|
82 */ |
|
83 void CGetLockInfo::RunL() |
|
84 { |
|
85 if(iStatus != KErrNone) |
|
86 { |
|
87 iConsole->Printf(KError); |
|
88 |
|
89 // Print the error status code |
|
90 iConsole->Printf(_L("%d\n"), iStatus.Int()); |
|
91 } |
|
92 else |
|
93 { |
|
94 if( iIccLockInfoV1.iSetting == CTelephony::ELockSetEnabled) |
|
95 { |
|
96 iConsole->Printf(_L("Lock 2 is available for the phone to use\n")); |
|
97 switch (iIccLockInfoV1.iStatus) |
|
98 { |
|
99 case CTelephony::EStatusUnlocked: |
|
100 iConsole->Printf(_L("Its current status is Unlocked\n")); |
|
101 break; |
|
102 case CTelephony::EStatusBlocked: |
|
103 iConsole->Printf(_L("Its current status is blocked\n")); |
|
104 break; |
|
105 case CTelephony::EStatusLocked: |
|
106 iConsole->Printf(_L("Its current status is locked\n")); |
|
107 break; |
|
108 case CTelephony::EStatusUnknown: |
|
109 iConsole->Printf(_L("Its current status is unknown\n")); |
|
110 break; |
|
111 } |
|
112 if (iIccLockInfoV1.iStatus == CTelephony::EStatusUnlocked) |
|
113 { |
|
114 // Lock is enabled but unlocked so can continue. |
|
115 ExampleComplete(); |
|
116 } |
|
117 else |
|
118 { |
|
119 DoRequestNotificationL(); |
|
120 // Alert user that they may not be able to call number if it's |
|
121 // not in their FDN phone book. |
|
122 } |
|
123 } |
|
124 else |
|
125 { |
|
126 // Lock isn't enabled so can continue |
|
127 ExampleComplete(); |
|
128 } |
|
129 } |
|
130 } |
|
131 |
|
132 /** |
|
133 Requests to receive notifications of change in the ICC lock information. |
|
134 */ |
|
135 void CGetLockInfo::DoRequestNotificationL() |
|
136 { |
|
137 // Panic if this object is already performing an asynchronous operation. |
|
138 // Application will panic if you call SetActive() on an already active object. |
|
139 _LIT( KNotifyPanic, "CGetLockInfo Notify Method" ); |
|
140 __ASSERT_ALWAYS( !IsActive(), User::Panic( KNotifyPanic, 1 )); |
|
141 iRequestNotify = ETrue; |
|
142 |
|
143 // Registers interest in receiving change notifications for events. |
|
144 iTelephony->NotifyChange( iStatus, |
|
145 CTelephony::EPin2LockInfoChange, |
|
146 iIccLockInfoV1Pckg ); |
|
147 SetActive(); |
|
148 } |
|
149 |
|
150 /** |
|
151 Cancels asynchronous request to CTelephony::GetLockInfo(). |
|
152 */ |
|
153 void CGetLockInfo::DoCancel() |
|
154 { |
|
155 // Cancels an outstanding asynchronous request. |
|
156 iTelephony->CancelAsync(CTelephony::EPin2LockInfoChangeCancel); |
|
157 } |
|
158 |