|
1 /* |
|
2 * Copyright (c) 2006 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: The main header file of RemoteLock Engine |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 #ifndef REMOTELOCK_H |
|
21 #define REMOTELOCK_H |
|
22 |
|
23 // INCLUDE FILES |
|
24 #include <msvapi.h> |
|
25 #include <RemoteLockSettings.h> |
|
26 #include <cenrepnotifyhandler.h> |
|
27 #include <centralrepository.h> |
|
28 #include "RLLockObserver.h" |
|
29 |
|
30 // CONSTANTS |
|
31 |
|
32 // MACROS |
|
33 |
|
34 // FORWARD DECLARATIONS |
|
35 class CClientMtmRegistry; |
|
36 |
|
37 // LOCAL FUNCTION PROTOTYPES |
|
38 LOCAL_C TInt ThreadStartL(); |
|
39 |
|
40 // MEMBER FUNCTIONS |
|
41 |
|
42 // CLASS DECLARATION |
|
43 /** |
|
44 * Main class for remote lock program |
|
45 * |
|
46 * @lib |
|
47 * @since S60 3.2 |
|
48 */ |
|
49 class CRemoteLock : public CTimer, |
|
50 public MMsvSessionObserver, |
|
51 public MRemoteLockSettingsHandler, |
|
52 public MRLLockObserverHandler, |
|
53 public MCenRepNotifyHandlerCallback |
|
54 { |
|
55 public: |
|
56 /** |
|
57 * Two-Phased constructor |
|
58 */ |
|
59 static CRemoteLock* NewL(); |
|
60 |
|
61 /** |
|
62 * Destructor. |
|
63 */ |
|
64 virtual ~CRemoteLock(); |
|
65 |
|
66 // from base class MMsvSessionObserver |
|
67 |
|
68 /** |
|
69 * From MMsvSessionObserver |
|
70 * Session observer |
|
71 * |
|
72 * @param aEvent EMsvEntriesCreated when new sms arrives, |
|
73 * EMsvServerReady while MSV server is ready, |
|
74 * EMsvServerFailedToStart while server is failed to start |
|
75 * EMsvCloseSession while session is closed |
|
76 * EMsvServerTerminated while server is terminated. |
|
77 * @param aArg1 A CMsvEntrySelection of the new entries. |
|
78 * @param aArg2 The TMsvId of the parent entry |
|
79 * @param aArg3 Event type-specific argument value |
|
80 * @return |
|
81 */ |
|
82 void HandleSessionEventL( |
|
83 TMsvSessionEvent aEvent, |
|
84 TAny* aArg1, |
|
85 TAny* aArg2, |
|
86 TAny* aArg3 ); |
|
87 |
|
88 /** |
|
89 * Remote Lock Settings notify handler called |
|
90 * when remote lock settings are changed by client. |
|
91 * |
|
92 * @param |
|
93 * @return |
|
94 */ |
|
95 void HandleRemoteLockNotifyL(); |
|
96 |
|
97 |
|
98 public: // from MRLLockObserverHandler |
|
99 |
|
100 void HandleUnlockEvent(); |
|
101 |
|
102 private: |
|
103 |
|
104 CRemoteLock(); |
|
105 |
|
106 void ConstructL(); |
|
107 |
|
108 /** |
|
109 * Handles remote lock message. |
|
110 * |
|
111 * @param aEntry Message entry to be handled. |
|
112 * @return |
|
113 */ |
|
114 void HandleMessageL( CMsvEntry* aEntry ); |
|
115 |
|
116 /** |
|
117 * Compares lock code from SMS against correct lock code. |
|
118 * If the lock code is correct, lock the phone. |
|
119 * |
|
120 * @param |
|
121 * @return ETrue when remotelock is correct. |
|
122 * EFalse remotelock is not correct. |
|
123 */ |
|
124 TBool VerifyAndLockL(); |
|
125 |
|
126 /** |
|
127 * Check the remote lock settings. |
|
128 * |
|
129 * @param |
|
130 * @return |
|
131 */ |
|
132 void CheckSettingsL(); |
|
133 |
|
134 /** |
|
135 * Check whether memory card is locked or not. |
|
136 * |
|
137 * @param aDriveInfo Drive information |
|
138 * @return ETrue if memory card is locked, |
|
139 * EFalse if memory card isn't locked. |
|
140 */ |
|
141 TBool IsMemoryCardLocked( const TDriveInfo& aDriveInfo ) const; |
|
142 |
|
143 /** |
|
144 * Check whether memory card has password or not. |
|
145 * |
|
146 * @param aDriveInfo Drive information |
|
147 * @return ETrue if memory card has password, |
|
148 * EFalse if memory card doesn't have password. |
|
149 */ |
|
150 TBool HasMemoryCardPassword( const TDriveInfo& aDriveInfo ) const; |
|
151 |
|
152 /** |
|
153 * Check whether memory card is present or not. |
|
154 * |
|
155 * @param aDriveInfo Drive information |
|
156 * @return ETrue memory card is in the phone, |
|
157 * EFalse memory card is not in the phone. |
|
158 */ |
|
159 TBool IsMemoryCardPresent( const TDriveInfo& aDriveInfo ) const; |
|
160 |
|
161 /** |
|
162 * Sets the password to memory card, if the memory card is mounted into the phone |
|
163 * and memory card doesn't have password or not locked |
|
164 * |
|
165 * @param aClear if ETrue, then remove the password |
|
166 * @return ETrue if memory card is locked or password removed, |
|
167 * EFalse memory card is not locked. |
|
168 */ |
|
169 TBool SetMemoryCardPasswdL( const TBool aClear ); |
|
170 |
|
171 /** |
|
172 * Converts memory card password format |
|
173 * |
|
174 * @param aPassword Password that needs to be converted |
|
175 * aClear if ETrue, then remove the password |
|
176 * @return |
|
177 */ |
|
178 void ConvertMemoryCardPassword( TMediaPassword& aPassword, const TBool aClear ); |
|
179 |
|
180 /** |
|
181 * Initialize a new reply message when phone is on lock status. |
|
182 * |
|
183 * @param |
|
184 * @return ETrue if initialize is succeed, |
|
185 * EFalse inistialize is failed. |
|
186 */ |
|
187 TBool InitialSendMessageL(); |
|
188 |
|
189 /** |
|
190 * Creates a new message server entry and set up default values. |
|
191 * |
|
192 * @param |
|
193 * @return TMsvId a Id of operational progress entry. |
|
194 */ |
|
195 TMsvId CreateNewMessageL(); |
|
196 |
|
197 /** |
|
198 * Set up current message entry. |
|
199 * |
|
200 * @param aEntryId Entry Id of message. |
|
201 * @return |
|
202 */ |
|
203 void SetEntryL( TMsvId aEntryId ); |
|
204 |
|
205 /** |
|
206 * Moves an entry to another parent entry. |
|
207 * |
|
208 * @param aEntryId Entry Id of target. |
|
209 * @return TMsvId a message entry |
|
210 */ |
|
211 TMsvId MoveMessageEntryL( TMsvId aTarget ); |
|
212 |
|
213 /** |
|
214 * Reply SMS when the terminal or memory card is successfully locked. |
|
215 * |
|
216 * @param aRecipientAddress the phone number which is used to send Lock |
|
217 * sms |
|
218 * @return ETrue if message is successfully sent, |
|
219 * EFalse message is not sent. |
|
220 */ |
|
221 TBool SendMessageL( const TDesC& aRecipientAddress ); |
|
222 |
|
223 /** |
|
224 * Schedules the message to be immediately sent through the message server. |
|
225 * |
|
226 * @param aSelection A point contains TMsvId |
|
227 * @return |
|
228 */ |
|
229 void SetScheduledSendingStateL( CMsvEntrySelection* aSelection ); |
|
230 |
|
231 /** |
|
232 * Try to re-connect message server every 10 seconds after |
|
233 * it is shut down or terminated. |
|
234 * |
|
235 * @param |
|
236 * @return |
|
237 */ |
|
238 void RunL(); |
|
239 |
|
240 /** |
|
241 * Checks if there are any unicode characters in the message |
|
242 * |
|
243 * @param TDesC& a reference to a string to be checked |
|
244 * @return TBool indicates whether we have unicode chars or not |
|
245 */ |
|
246 TBool NeedsToBeSentAsUnicodeL( const TDesC& aInputString ) const; |
|
247 |
|
248 /** |
|
249 * Active the device lock to lock the phone |
|
250 */ |
|
251 TBool ActivateDeviceLock(); |
|
252 |
|
253 |
|
254 /** |
|
255 * Get the current profile |
|
256 * |
|
257 * @param aProfile profile id |
|
258 * @return ETrue if succeeded |
|
259 * EFalse otherwise |
|
260 */ |
|
261 TBool GetProfile( TInt& aProfile ); |
|
262 |
|
263 /** |
|
264 * Setup Profile notifier |
|
265 * |
|
266 * @param aNotifyEnable enable or disable notifier |
|
267 * @return ETrue |
|
268 * EFalse |
|
269 */ |
|
270 TBool ProfileNotifyL( const TBool aNotifyEnable ); |
|
271 |
|
272 |
|
273 /** |
|
274 * Call back function of Central Repository |
|
275 * from MCenRepNotifyHandlerCallback |
|
276 */ |
|
277 void HandleNotifyGeneric( TUint32 aId ); |
|
278 |
|
279 |
|
280 /** |
|
281 * Do Sets the password to memory card, if the memory card is mounted into the phone |
|
282 * and memory card doesn't have password or not locked |
|
283 * |
|
284 * @param aClear if ETrue, then remove the password |
|
285 * @return ETrue if memory card is locked or password removed, |
|
286 * EFalse memory card is not locked. |
|
287 */ |
|
288 TBool DoSetMemoryCardPasswdL( TBool aClear ); |
|
289 |
|
290 private: // Data |
|
291 // Remote lock code from SMS. |
|
292 HBufC* iRemoteLockCode; |
|
293 |
|
294 // memory card password buffer having the same |
|
295 // content with iRemoteLockCode buffer |
|
296 HBufC* iMemoryCardPasswd; |
|
297 |
|
298 // Correct remote lock code digest. |
|
299 HBufC* iStoredCode; |
|
300 |
|
301 // Correct remote lock code digest (spaces trimmed). |
|
302 HBufC* iStoredTrimmedCode; |
|
303 |
|
304 // If remote lock is enabled or not. |
|
305 TBool iIsEnabled; |
|
306 |
|
307 // The lock state of memory card |
|
308 TBool iStateMemoryCard; |
|
309 |
|
310 CRemoteLockSettings* iRemoteLockSetting; |
|
311 |
|
312 CMsvSession* iMsvSession; |
|
313 |
|
314 CBaseMtm* iClientMtmForSending; |
|
315 |
|
316 CClientMtmRegistry* iMtmReg; |
|
317 |
|
318 //Indicate if the phone is locked by remote lock |
|
319 TBool iLockedByRL; |
|
320 |
|
321 //Indicate if the memory card is locked by remote lock |
|
322 TBool iMemoryCardLockedByRL; |
|
323 |
|
324 //Device lock observer |
|
325 CRLLockObserver* iObserver; |
|
326 |
|
327 CRepository* iProfileSession; |
|
328 |
|
329 CCenRepNotifyHandler* iProfileNotifyHandler; |
|
330 |
|
331 //Boolean used to indicate whether we have subscribed profile |
|
332 //changes in CenRep or not, default value is EFalse; |
|
333 TBool iSubscribeProfile; |
|
334 |
|
335 //Current profile |
|
336 TInt iCurrentProfile; |
|
337 |
|
338 }; |
|
339 |
|
340 #endif |