|
1 /* |
|
2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * |
|
5 * This program is free software: you can redistribute it and/or modify |
|
6 * it under the terms of the GNU Lesser General Public License as published by |
|
7 * the Free Software Foundation, version 2.1 of the License. |
|
8 * |
|
9 * This program is distributed in the hope that it will be useful, |
|
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
12 * GNU Lesser General Public License for more details. |
|
13 * |
|
14 * You should have received a copy of the GNU Lesser General Public License |
|
15 * along with this program. If not, |
|
16 * see "http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html/". |
|
17 * |
|
18 * Description: |
|
19 * |
|
20 */ |
|
21 |
|
22 #ifndef AUTOLOCK_H |
|
23 #define AUTOLOCK_H |
|
24 |
|
25 #ifdef _DEBUG |
|
26 #define RDEBUG( x, y ) RDebug::Printf( "%s %s (%u) %s=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, x, y ); |
|
27 #else |
|
28 #define RDEBUG( x, y ) |
|
29 #endif |
|
30 |
|
31 #include <QWidget> |
|
32 #include <QEvent> |
|
33 #include <QModelIndex> |
|
34 #include <QMap> |
|
35 #include <QStringList> |
|
36 #include <xqserviceprovider.h> |
|
37 #include <QToolButton> |
|
38 #include <qmobilityglobal.h> |
|
39 |
|
40 #include "autolockuseractivityservice.h" |
|
41 #include "../../SecUi/Inc/SecQueryUi.h" |
|
42 |
|
43 QTM_BEGIN_NAMESPACE |
|
44 class QValueSpacePublisher; |
|
45 class QValueSpaceSubscriber; |
|
46 QTM_END_NAMESPACE |
|
47 QTM_USE_NAMESPACE |
|
48 |
|
49 #include <hbwidget.h> |
|
50 #include <qapplication.h> |
|
51 #include <hbdevicedialog.h> |
|
52 |
|
53 enum TLockStatus |
|
54 { |
|
55 ELockNotActive = 0, |
|
56 EKeyguardActive, |
|
57 EDevicelockActive |
|
58 }; |
|
59 |
|
60 enum TDevicelockReason |
|
61 { |
|
62 EDevicelockManual = 1, |
|
63 EDevicelockRemote, |
|
64 EDevicelockTimer |
|
65 }; |
|
66 |
|
67 enum TDeviceDialogCreated |
|
68 { |
|
69 EDeviceDialogUninitialized = -1, |
|
70 EDeviceDialogDestroyed = 0, |
|
71 EDeviceDialogCreated = 1, |
|
72 EDeviceDialogRaised = 2, |
|
73 EDeviceDialogScreenSaver = 0x10, |
|
74 EDeviceDialogLockIcon= 0x11, |
|
75 EDeviceDialogLastValue |
|
76 }; |
|
77 |
|
78 class QTimer; |
|
79 |
|
80 class AutolockService; |
|
81 class CPowerSaveDisplayMode; |
|
82 |
|
83 class Autolock : public QWidget |
|
84 { |
|
85 Q_OBJECT |
|
86 |
|
87 public: |
|
88 Autolock( QWidget *parent = 0, Qt::WFlags f = 0 ); |
|
89 ~Autolock(); |
|
90 |
|
91 void setLabelNumber(QString label,QString number); |
|
92 void setLabelIcon(int value); |
|
93 int CheckIfLegal(int value); |
|
94 void DebugRequest(int value); |
|
95 void DebugError(int value); |
|
96 void DebugStatus(int value); |
|
97 void adjustInactivityTimers(int aReason); |
|
98 int updateIndicator(int aReason); |
|
99 int AskValidSecCode(int aReason); |
|
100 int publishStatus(int aReason); |
|
101 int TryChangeStatus(int aReason); |
|
102 int setLockDialog(int aReason, int status); |
|
103 int showNoteIfRequested(int aReason); |
|
104 |
|
105 bool event(QEvent *event); |
|
106 bool eventFilter(QObject *, QEvent *); |
|
107 |
|
108 int callerHasECapabilityWriteDeviceData; |
|
109 int iShowKeyguardNote; |
|
110 int mParam1; |
|
111 int mParam2; |
|
112 |
|
113 public slots: |
|
114 void quit(); |
|
115 void handleAnswerDelivered(); |
|
116 void subscriberKSettingsAutolockStatusChanged(); |
|
117 void subscriberKSettingsAutoLockTimeChanged(); |
|
118 void subscriberKSettingsAutomaticKeyguardTimeChanged(); |
|
119 void subscriberKDisplayLightsTimeoutChanged(); |
|
120 void subscriberKProEngActiveProfileChanged(); |
|
121 void subscriberKAknKeyguardStatusChanged(); |
|
122 void subscriberKCoreAppUIsAutolockStatusChanged(); |
|
123 void subscriberKHWRMGripStatusChanged(); |
|
124 void subscriberKCTsyCallStateChanged(); |
|
125 void subscriberKSecurityUIsDismissDialogChanged(); |
|
126 |
|
127 private slots: |
|
128 void activeKeyguard(); |
|
129 void notActiveKeyguard(); |
|
130 void activeDevicelock(); |
|
131 void notActiveDevicelock(); |
|
132 void switchScreensaverMode( int mode ); |
|
133 void switchScreensaverToPowerSaveMode(); |
|
134 void handleMessageFromScreensaver( const QVariantMap &data ); |
|
135 void handleScreensaverClosed(); |
|
136 private: |
|
137 int handleLockSwitch(); |
|
138 |
|
139 private: |
|
140 AutolockService* mService; |
|
141 // int mKeyCode; |
|
142 // int mKeyCaptureHandle; |
|
143 QValueSpaceSubscriber *subscriberKSettingsAutolockStatus; |
|
144 QValueSpaceSubscriber *subscriberKSettingsAutoLockTime; |
|
145 QValueSpaceSubscriber *subscriberKSettingsAutomaticKeyguardTime; |
|
146 QValueSpaceSubscriber *subscriberKDisplayLightsTimeout; |
|
147 QValueSpaceSubscriber *subscriberKProEngActiveProfile; |
|
148 QValueSpaceSubscriber *subscriberKAknKeyguardStatus; |
|
149 QValueSpaceSubscriber *subscriberKCoreAppUIsAutolockStatus; |
|
150 QValueSpaceSubscriber *subscriberKHWRMGripStatus; |
|
151 QValueSpaceSubscriber *subscriberKCTsyCallState; |
|
152 QValueSpaceSubscriber *subscriberKSecurityUIsDismissDialog; |
|
153 |
|
154 AutolockUserActivityService* serviceKeyguard; |
|
155 AutolockUserActivityService* serviceDevicelock; |
|
156 |
|
157 int iLockStatus; |
|
158 int iLockStatusPrev; |
|
159 CSecQueryUi *iSecQueryUi; |
|
160 int iSecQueryUiCreated; |
|
161 HbDeviceDialog *iDeviceDialog; |
|
162 int iDeviceDialogCreated; |
|
163 TInt32 mPowerKeyCaptureHandle; |
|
164 TInt32 mApplicationKeyCaptureHandle; |
|
165 TInt32 mApplicationLongKeyCaptureHandle; |
|
166 TInt32 mEKeyDeviceFCaptureHandle; |
|
167 TInt32 mEKeyBellCaptureHandle; |
|
168 TInt32 mEKeyYesCaptureHandle; |
|
169 TInt32 mEKeyNoCaptureHandle; |
|
170 TBool iLockCodeQueryInDisplay; |
|
171 QTimer *mScreensaverModeTimer; |
|
172 CPowerSaveDisplayMode *mScreensaverPowerSave; |
|
173 HBufC16 *mScreensaverPowerSavePixelBuffer; |
|
174 TInt32 iProcessingEvent; |
|
175 }; |
|
176 |
|
177 class AutolockService : public XQServiceProvider |
|
178 { |
|
179 Q_OBJECT |
|
180 public: |
|
181 AutolockService( Autolock *parent = 0 ); |
|
182 ~AutolockService(); |
|
183 |
|
184 void complete(QString number); |
|
185 bool asyncAnswer() {return mAsyncAnswer;} |
|
186 public slots: |
|
187 int service(const QString& number, const QString& aParam1, const QString& aParam2 ); |
|
188 |
|
189 private slots: |
|
190 void handleClientDisconnect(); |
|
191 |
|
192 private: |
|
193 Autolock* mAutolock; |
|
194 QString mNumber; |
|
195 bool mAsyncAnswer; |
|
196 int mAsyncReqId; |
|
197 }; |
|
198 |
|
199 class CWait : public CActive |
|
200 { |
|
201 public: |
|
202 /** |
|
203 * Creates instance of the CWait class. |
|
204 * |
|
205 * @return Returns the instance just created. |
|
206 */ |
|
207 static CWait* NewL(); |
|
208 /** |
|
209 * Destructor. |
|
210 */ |
|
211 ~CWait(); |
|
212 public: |
|
213 /** |
|
214 * Starts waiting for aReqStatus. |
|
215 */ |
|
216 TInt WaitForRequestL(); |
|
217 public: |
|
218 /** |
|
219 * Sets active request type. |
|
220 */ |
|
221 void SetRequestType(TInt aRequestType); |
|
222 /** |
|
223 * Gets active request type. |
|
224 */ |
|
225 TInt GetRequestType(); |
|
226 private: |
|
227 /** |
|
228 * C++ default constructor. |
|
229 */ |
|
230 CWait(); |
|
231 /** |
|
232 * Symbian OS constructor. |
|
233 */ |
|
234 void ConstructL(); |
|
235 private: // from CActive |
|
236 /** @see CActive::RunL() */ |
|
237 void RunL(); |
|
238 /** @see CActive::DoCancel() */ |
|
239 void DoCancel(); |
|
240 RTimer iTimer; |
|
241 CActiveSchedulerWait iWait; |
|
242 // Used if there is a need to cancel an active request; |
|
243 // namely in situations where destructor is called when Wait |
|
244 // is active. |
|
245 TInt iRequestType; |
|
246 }; |
|
247 |
|
248 |
|
249 #endif // AUTOLOCK_H |