|
1 /* |
|
2 * Copyright (c) 2002 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: Observer for phone events. Used to re-active |
|
15 * code query after emergency call |
|
16 * |
|
17 * |
|
18 */ |
|
19 |
|
20 |
|
21 #include "SecPhoneObserver.h" |
|
22 |
|
23 #ifndef RD_STARTUP_CHANGE |
|
24 #include <SysStartup.h> |
|
25 #endif //RD_STARTUP_CHANGE |
|
26 |
|
27 #include <PSVariables.h> // Property values |
|
28 #include <TelephonyInternalPSKeys.h> |
|
29 #include "SecObsNotify.h" |
|
30 #include "SecurityObserver.h" |
|
31 #include "SecurityObserver.hrh" |
|
32 |
|
33 // ================= MEMBER FUNCTIONS ======================= |
|
34 // |
|
35 // ---------------------------------------------------------- |
|
36 // CPhoneObserver::NewL() |
|
37 // Constructs a new entry with given values. |
|
38 // ---------------------------------------------------------- |
|
39 // |
|
40 CPhoneObserver* CPhoneObserver::NewL(CSecObsNotify* aNotifierController,CSecurityObserver* aObserver) |
|
41 { |
|
42 CPhoneObserver* self = new (ELeave) CPhoneObserver(aNotifierController,aObserver); |
|
43 CleanupStack::PushL(self); |
|
44 self->ConstructL(); |
|
45 CleanupStack::Pop(); |
|
46 return self; |
|
47 } |
|
48 // |
|
49 // ---------------------------------------------------------- |
|
50 // CPhoneObserver::CPhoneObserver() |
|
51 // Destructor |
|
52 // ---------------------------------------------------------- |
|
53 // |
|
54 CPhoneObserver::~CPhoneObserver() |
|
55 { |
|
56 Cancel(); |
|
57 } |
|
58 // |
|
59 // ---------------------------------------------------------- |
|
60 // CPhoneObserver::Start() |
|
61 // Starts listening KUidCurrentCall event |
|
62 // ---------------------------------------------------------- |
|
63 // |
|
64 TInt CPhoneObserver::Start(TSecurityNotifier aNotifier) |
|
65 { |
|
66 if (IsActive()) |
|
67 return KErrInUse; |
|
68 #if defined(_DEBUG) |
|
69 RDebug::Print(_L("(SECURITYOBSERVER) CPhoneObserver::Start")); |
|
70 #endif |
|
71 iNotifier = aNotifier; |
|
72 iStatus = KRequestPending; |
|
73 iProperty.Attach(KPSUidTelephonyCallHandling, KTelephonyCallState); |
|
74 iProperty.Subscribe(iStatus); |
|
75 SetActive(); |
|
76 #if defined(_DEBUG) |
|
77 RDebug::Print(_L("(SECURITYOBSERVER) CPhoneObserver::Start Observer active")); |
|
78 #endif |
|
79 return KErrNone; |
|
80 } |
|
81 |
|
82 // |
|
83 // ---------------------------------------------------------- |
|
84 // CPhoneObserver::Start() |
|
85 // Stops listening KUidCurrentCall event |
|
86 // ---------------------------------------------------------- |
|
87 // |
|
88 void CPhoneObserver::Stop() |
|
89 { |
|
90 Cancel(); |
|
91 } |
|
92 // |
|
93 // ---------------------------------------------------------- |
|
94 // CPhoneObserver::CPhoneObserver() |
|
95 // C++ constructor |
|
96 // ---------------------------------------------------------- |
|
97 // |
|
98 CPhoneObserver::CPhoneObserver(CSecObsNotify* aNotifierController,CSecurityObserver* aObserver) : |
|
99 CActive(0) |
|
100 ,iNotifierController(aNotifierController) |
|
101 ,iObserver(aObserver) |
|
102 { |
|
103 } |
|
104 // |
|
105 // ---------------------------------------------------------- |
|
106 // CPhoneObserver::ConstructL() |
|
107 // Symbian OS default constructor |
|
108 // ---------------------------------------------------------- |
|
109 // |
|
110 void CPhoneObserver::ConstructL() |
|
111 { |
|
112 // Add this active object to the scheduler. |
|
113 CActiveScheduler::Add(this); |
|
114 } |
|
115 // |
|
116 // ---------------------------------------------------------- |
|
117 // CPhoneObserver::RunL() |
|
118 // |
|
119 // ---------------------------------------------------------- |
|
120 // |
|
121 void CPhoneObserver::RunL() |
|
122 { |
|
123 TInt callState; |
|
124 iProperty.Get(KPSUidTelephonyCallHandling, KTelephonyCallState, callState); |
|
125 if (callState == EPSTelephonyCallStateNone) |
|
126 { |
|
127 |
|
128 switch (iNotifier) |
|
129 { |
|
130 #if defined(__PROTOCOL_WCDMA) || defined(__UPIN) |
|
131 #ifndef RD_STARTUP_CHANGE |
|
132 case ESecurityNotifierUPin: |
|
133 #if defined(_DEBUG) |
|
134 RDebug::Print(_L("(SECURITYOBSERVER) CPhoneObserver::RunL() UPIN")); |
|
135 #endif |
|
136 if (iObserver->IsUPinRequired() && !iObserver->IsUPukRequired()) |
|
137 iNotifierController->StartNotifier(iNotifier); |
|
138 break; |
|
139 #endif //RD_STARTUP_CHANGE |
|
140 case ESecurityNotifierUPuk: |
|
141 #if defined(_DEBUG) |
|
142 RDebug::Print(_L("(SECURITYOBSERVER) CPhoneObserver::RunL() UPUK")); |
|
143 #endif |
|
144 if (iObserver->IsUPukRequired()) |
|
145 iNotifierController->StartNotifier(iNotifier); |
|
146 break; |
|
147 #endif //__PROTOCOL_WCDMA |
|
148 |
|
149 #ifndef RD_STARTUP_CHANGE |
|
150 case ESecurityNotifierPin1: |
|
151 #if defined(_DEBUG) |
|
152 RDebug::Print(_L("(SECURITYOBSERVER) CPhoneObserver::RunL() PIN1")); |
|
153 #endif |
|
154 if (iObserver->IsPin1Required() && !iObserver->IsPuk1Required()) |
|
155 iNotifierController->StartNotifier(iNotifier); |
|
156 break; |
|
157 #endif //RD_STARTUP_CHANGE |
|
158 case ESecurityNotifierPuk1: |
|
159 #if defined(_DEBUG) |
|
160 RDebug::Print(_L("(SECURITYOBSERVER) CPhoneObserver::RunL() PUK1")); |
|
161 #endif |
|
162 if (iObserver->IsPuk1Required()) |
|
163 iNotifierController->StartNotifier(iNotifier); |
|
164 break; |
|
165 #ifndef RD_STARTUP_CHANGE |
|
166 case ESecurityNotifierSecurityCode: |
|
167 #if defined(_DEBUG) |
|
168 RDebug::Print(_L("(SECURITYOBSERVER) CPhoneObserver::RunL() Sec Code")); |
|
169 #endif |
|
170 if (iObserver->IsPassPhraseRequired() && SysStartup::State() != ESWStateNormal) |
|
171 iNotifierController->StartNotifier(iNotifier); |
|
172 break; |
|
173 #endif //RD_STARTUP_CHANGE |
|
174 default: |
|
175 break; |
|
176 } |
|
177 } |
|
178 else |
|
179 { |
|
180 #if defined(_DEBUG) |
|
181 RDebug::Print(_L("(SECURITYOBSERVER) CPhoneObserver::RunL() Call Active")); |
|
182 #endif |
|
183 // Continue observing system agent event |
|
184 Start(iNotifier); |
|
185 } |
|
186 } |
|
187 // |
|
188 // ---------------------------------------------------------- |
|
189 // CValueObserver::DoCancel() |
|
190 // Cancels event listening |
|
191 // ---------------------------------------------------------- |
|
192 // |
|
193 void CPhoneObserver::DoCancel() |
|
194 { |
|
195 iProperty.Cancel(); |
|
196 } |
|
197 |
|
198 // End of file |