|
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 Sim Locking events. |
|
15 * Shows "Sim restriction on" note if necessary. |
|
16 * |
|
17 * |
|
18 */ |
|
19 |
|
20 |
|
21 #include "SecSimLockObserver.h" |
|
22 |
|
23 #ifndef RD_STARTUP_CHANGE |
|
24 #include <PSVariables.h> // Property values |
|
25 #else //RD_STARTUP_CHANGE |
|
26 #include <StartupDomainPSKeys.h> |
|
27 #endif //RD_STARTUP_CHANGE |
|
28 |
|
29 #include "SecObsNotify.h" |
|
30 #include "SecurityObserver.hrh" |
|
31 |
|
32 // ================= MEMBER FUNCTIONS ======================= |
|
33 // |
|
34 // ---------------------------------------------------------- |
|
35 // CSimLockObserver::NewL() |
|
36 // Constructs a new entry with given values. |
|
37 // ---------------------------------------------------------- |
|
38 // |
|
39 CSimLockObserver* CSimLockObserver::NewL(CSecObsNotify* aNotifierController) |
|
40 { |
|
41 CSimLockObserver* self = new (ELeave) CSimLockObserver(aNotifierController); |
|
42 CleanupStack::PushL(self); |
|
43 self->ConstructL(); |
|
44 CleanupStack::Pop(); |
|
45 return self; |
|
46 } |
|
47 // |
|
48 // ---------------------------------------------------------- |
|
49 // CSimLockObserver::CSimLockObserver() |
|
50 // Destructor |
|
51 // ---------------------------------------------------------- |
|
52 // |
|
53 CSimLockObserver::~CSimLockObserver() |
|
54 { |
|
55 Cancel(); |
|
56 } |
|
57 // |
|
58 // ---------------------------------------------------------- |
|
59 // CSimLockObserver::Start() |
|
60 // Starts listening event |
|
61 // ---------------------------------------------------------- |
|
62 // |
|
63 TInt CSimLockObserver::Start() |
|
64 { |
|
65 if (IsActive()) |
|
66 return KErrInUse; |
|
67 iStatus = KRequestPending; |
|
68 #ifndef RD_STARTUP_CHANGE |
|
69 iProperty.Attach(KUidSystemCategory, KPSUidSimLockStatusValue); |
|
70 #else //RD_STARTUP_CHANGE |
|
71 iProperty.Attach(KPSUidStartup, KStartupSimLockStatus); |
|
72 #endif //RD_STARTUP_CHANGE |
|
73 iProperty.Subscribe(iStatus); |
|
74 SetActive(); |
|
75 return KErrNone; |
|
76 } |
|
77 |
|
78 // |
|
79 // ---------------------------------------------------------- |
|
80 // CSimLockObserver::Stopt() |
|
81 // Stops listening event |
|
82 // ---------------------------------------------------------- |
|
83 // |
|
84 void CSimLockObserver::Stop() |
|
85 { |
|
86 Cancel(); |
|
87 } |
|
88 // |
|
89 // ---------------------------------------------------------- |
|
90 // CCSimLockObserver::CSimLockObserver() |
|
91 // C++ constructor |
|
92 // ---------------------------------------------------------- |
|
93 // |
|
94 CSimLockObserver::CSimLockObserver(CSecObsNotify* aNotifierController) : |
|
95 CActive(0) |
|
96 ,iNotifierController(aNotifierController) |
|
97 { |
|
98 |
|
99 } |
|
100 // |
|
101 // ---------------------------------------------------------- |
|
102 // CSimLockObserver::ConstructL() |
|
103 // Symbian OS default constructor |
|
104 // ---------------------------------------------------------- |
|
105 // |
|
106 void CSimLockObserver::ConstructL() |
|
107 { |
|
108 // Add this active object to the scheduler. |
|
109 CActiveScheduler::Add(this); |
|
110 } |
|
111 // |
|
112 // ---------------------------------------------------------- |
|
113 // CPhoneObserver::RunL() |
|
114 // |
|
115 // ---------------------------------------------------------- |
|
116 // |
|
117 void CSimLockObserver::RunL() |
|
118 { |
|
119 // Show "Sim restriction on" note |
|
120 TInt simLockStatus; |
|
121 #ifndef RD_STARTUP_CHANGE |
|
122 iProperty.Get(KUidSystemCategory, KPSUidSimLockStatusValue, simLockStatus); |
|
123 if (simLockStatus == EPSSimLockRestrictionOn) |
|
124 #else //RD_STARTUP_CHANGE |
|
125 iProperty.Get(KPSUidStartup, KStartupSimLockStatus, simLockStatus); |
|
126 if (simLockStatus == ESimLockRestrictionOn) |
|
127 #endif //RD_STARTUP_CHANGE |
|
128 { |
|
129 iNotifierController->StartNotifier(ESecuritySimLockRestrictionOn); |
|
130 } |
|
131 else |
|
132 { |
|
133 // Continue observing system agent event |
|
134 Start(); |
|
135 } |
|
136 } |
|
137 // |
|
138 // ---------------------------------------------------------- |
|
139 // CSimLockObserver::DoCancel() |
|
140 // Cancels event listening |
|
141 // ---------------------------------------------------------- |
|
142 // |
|
143 void CSimLockObserver::DoCancel() |
|
144 { |
|
145 iProperty.Cancel(); |
|
146 } |
|
147 |
|
148 // End of file |