|
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: |
|
15 * Obsererver for Set System Locked event |
|
16 * |
|
17 * |
|
18 */ |
|
19 |
|
20 #include <bldvariant.hrh> |
|
21 #include <e32property.h> |
|
22 #include <PSVariables.h> |
|
23 #include <coreapplicationuisdomainpskeys.h> |
|
24 #include <SCPClient.h> // EMKK-7N3G7R |
|
25 #include <startupdomainpskeys.h> // EMKK-7N3G7R |
|
26 #include <mmtsy_names.h> // EMKK-7N3G7R |
|
27 #include "AutoLockLockObserverPS.h" |
|
28 #include "AutolockAppUiPS.h" |
|
29 #include "AutoLockModelPS.h" |
|
30 |
|
31 |
|
32 // ================= MEMBER FUNCTIONS ======================= |
|
33 // |
|
34 // ---------------------------------------------------------- |
|
35 // CLockObserver::NewL() |
|
36 // Constructs a new entry with given values. |
|
37 // ---------------------------------------------------------- |
|
38 // |
|
39 CLockObserver* CLockObserver::NewL(CAutolockAppUi* aAppUi) |
|
40 { |
|
41 CLockObserver* self = new (ELeave) CLockObserver(aAppUi); |
|
42 CleanupStack::PushL(self); |
|
43 self->ConstructL(); |
|
44 CleanupStack::Pop(); |
|
45 return self; |
|
46 } |
|
47 // |
|
48 // ---------------------------------------------------------- |
|
49 // CLockObserver::CLockObserver() |
|
50 // Destructor |
|
51 // ---------------------------------------------------------- |
|
52 // |
|
53 CLockObserver::~CLockObserver() |
|
54 { |
|
55 Cancel(); |
|
56 iProperty.Close(); |
|
57 #ifdef FF_STARTUP_OMA_DM_SUPPORT // New booting order Start EMKK-7N3G7R |
|
58 delete wait; |
|
59 if (iServer.Handle()) |
|
60 { |
|
61 iServer.UnloadPhoneModule(KMmTsyModuleName); |
|
62 iServer.Close(); |
|
63 } |
|
64 #endif // End EMKK-7N3G7R |
|
65 } |
|
66 // |
|
67 // ---------------------------------------------------------- |
|
68 // CNoSimCard::Start() |
|
69 // Starts listening KUidAutolockStatus event |
|
70 // ---------------------------------------------------------- |
|
71 // |
|
72 TInt CLockObserver::Start() |
|
73 { |
|
74 if (IsActive()) |
|
75 return KErrInUse; |
|
76 iStatus = KRequestPending; |
|
77 iProperty.Attach(KPSUidCoreApplicationUIs, KCoreAppUIsAutolockStatus); |
|
78 iProperty.Subscribe(iStatus); |
|
79 SetActive(); |
|
80 return KErrNone; |
|
81 } |
|
82 // |
|
83 // ---------------------------------------------------------- |
|
84 // CLockObserver::CLockObserver() |
|
85 // C++ constructor |
|
86 // ---------------------------------------------------------- |
|
87 // |
|
88 CLockObserver::CLockObserver(CAutolockAppUi* aAppUi) : CActive(0), iAppUi(aAppUi) |
|
89 { |
|
90 } |
|
91 // |
|
92 // ---------------------------------------------------------- |
|
93 // CLockObserver::ConstructL() |
|
94 // Symbian OS default constructor |
|
95 // ---------------------------------------------------------- |
|
96 // |
|
97 void CLockObserver::ConstructL() |
|
98 { |
|
99 |
|
100 #if defined(_DEBUG) |
|
101 RDebug::Print(_L("(AUTOLOCK)CLockObserver::ConstructL()")); |
|
102 #endif |
|
103 |
|
104 // Add this active object to the scheduler. |
|
105 CActiveScheduler::Add(this); |
|
106 TInt ret; |
|
107 _LIT_SECURITY_POLICY_PASS(KReadPolicy); |
|
108 _LIT_SECURITY_POLICY_C1(KWritePolicy, ECapabilityWriteDeviceData); |
|
109 |
|
110 ret = RProperty::Define(KPSUidCoreApplicationUIs, KCoreAppUIsAutolockStatus, RProperty::EInt, KReadPolicy, KWritePolicy); |
|
111 if(ret != KErrAlreadyExists) |
|
112 User::LeaveIfError(ret); |
|
113 |
|
114 // Begin obsering PubSub event |
|
115 Start(); |
|
116 } |
|
117 // |
|
118 // ---------------------------------------------------------- |
|
119 // CLockObserver::RunL() |
|
120 // Called when device (autolock) is activated from menu. |
|
121 // ---------------------------------------------------------- |
|
122 // |
|
123 void CLockObserver::RunL() |
|
124 { |
|
125 // set ui locked. |
|
126 TInt autolockState; |
|
127 iProperty.Get( autolockState ); |
|
128 if (autolockState > EAutolockOff) |
|
129 { |
|
130 iAppUi->Model()->LockSystemL(autolockState); |
|
131 } |
|
132 // Continue observing PubSub event |
|
133 Start(); |
|
134 } |
|
135 // |
|
136 // ---------------------------------------------------------- |
|
137 // CLockObserver::DoCancel() |
|
138 // Cancels event listening |
|
139 // ---------------------------------------------------------- |
|
140 // |
|
141 void CLockObserver::DoCancel() |
|
142 { |
|
143 iProperty.Cancel(); |
|
144 } |
|
145 // End of file |