51 CSysApDriveList& aSysApDriveList, |
51 CSysApDriveList& aSysApDriveList, |
52 CSysApAppUi& aSysApAppUi, |
52 CSysApAppUi& aSysApAppUi, |
53 const TBool aMemoryCardLockSupported ) : |
53 const TBool aMemoryCardLockSupported ) : |
54 iSysApDriveList( aSysApDriveList ), |
54 iSysApDriveList( aSysApDriveList ), |
55 iSysApAppUi( aSysApAppUi ), |
55 iSysApAppUi( aSysApAppUi ), |
56 iMemoryCardLockSupported( aMemoryCardLockSupported ) |
56 iMemoryCardLockSupported( aMemoryCardLockSupported ), |
|
57 iMemCardPwdDialog(NULL) |
57 { |
58 { |
58 } |
59 } |
59 |
60 |
60 // --------------------------------------------------------------------------- |
61 // --------------------------------------------------------------------------- |
61 // CSysApDriveUnlockHandler::~CSysApDriveUnlockHandler |
62 // CSysApDriveUnlockHandler::~CSysApDriveUnlockHandler |
65 { |
66 { |
66 TRACES( RDebug::Print( |
67 TRACES( RDebug::Print( |
67 _L( "CSysApDriveUnlockHandler::~CSysApDriveUnlockHandler" ) ) ); |
68 _L( "CSysApDriveUnlockHandler::~CSysApDriveUnlockHandler" ) ) ); |
68 |
69 |
69 iIgnoreQueryResult = ETrue; |
70 iIgnoreQueryResult = ETrue; |
70 delete iQueryShowCB; |
71 if (iMemCardPwdDialog!=NULL) |
71 delete iMemoryCardDialog; |
72 { |
|
73 //MemoryCardDialog already exist |
|
74 delete iMemCardPwdDialog; |
|
75 iMemCardPwdDialog = NULL; |
|
76 } |
72 } |
77 } |
73 |
78 |
74 // --------------------------------------------------------------------------- |
79 // --------------------------------------------------------------------------- |
75 // CSysApDriveUnlockHandler::StartUnlock |
80 // CSysApDriveUnlockHandler::StartUnlock |
76 // --------------------------------------------------------------------------- |
81 // --------------------------------------------------------------------------- |
77 // |
82 // |
78 void CSysApDriveUnlockHandler::StartUnlock() |
83 void CSysApDriveUnlockHandler::StartUnlock() |
79 { |
84 { |
80 TBool isOngoing( IsQueryOngoing() ); |
|
81 |
|
82 TRACES( RDebug::Print( |
|
83 _L( "CSysApMCSysApMMCUnlockObserver::StartUnlock: ongoing: %d" ), |
|
84 isOngoing ) ); |
|
85 |
|
86 if ( isOngoing ) |
|
87 { |
|
88 return; |
|
89 } |
|
90 TRAPD( err, DoStartQueryIfNeededL() ); |
85 TRAPD( err, DoStartQueryIfNeededL() ); |
91 if ( err != KErrNone ) |
86 if ( err != KErrNone ) |
92 { |
87 { |
93 DoStopUnlock( err ); |
88 DoStopUnlock( err ); |
94 } |
89 } |
173 // CSysApDriveUnlockHandler::ShowUnlockQueryL |
167 // CSysApDriveUnlockHandler::ShowUnlockQueryL |
174 // --------------------------------------------------------------------------- |
168 // --------------------------------------------------------------------------- |
175 // |
169 // |
176 void CSysApDriveUnlockHandler::ShowUnlockQueryL() |
170 void CSysApDriveUnlockHandler::ShowUnlockQueryL() |
177 { |
171 { |
|
172 iDriveToUnlock = iSysApDriveList.DriveToUnlock(); |
178 TRACES( RDebug::Print( |
173 TRACES( RDebug::Print( |
179 _L( "CSysApMCSysApMMCUnlockObserver::ShowUnlockQueryL: drive: %d" ), |
174 _L( "CSysApMCSysApMMCUnlockObserver::ShowUnlockQueryL: drive: %d" ), |
180 iDriveToUnlock ) ); |
175 iDriveToUnlock ) ); |
181 |
176 |
182 if ( !iMemoryCardDialog ) |
177 if (iMemCardPwdDialog!=NULL) |
183 { |
178 { |
184 CAknMemoryCardDialog* mmcDialog = CAknMemoryCardDialog::NewLC( this ); |
179 //PowerMenu already exist |
185 iMemoryCardDialog = mmcDialog; // temporary variable used for hiding codescanner error |
180 delete iMemCardPwdDialog; |
186 iMemoryCardDialog->SetSelfPointer( &iMemoryCardDialog ); |
181 iMemCardPwdDialog = NULL; |
187 TDriveNumber drive( static_cast< TDriveNumber >( iDriveToUnlock ) ); |
182 } |
188 iMemoryCardDialog->UnlockCardLD( drive, ETrue ); |
183 TRACES( RDebug::Print(_L("CSysApAppUi::HandleKeyEventL, JEELani 01") ) ); |
189 } |
184 iMemCardPwdDialog = CHbDeviceInputDialogSymbian::NewL(); |
190 } |
185 TRACES( RDebug::Print(_L("CSysApAppUi::HandleKeyEventL, JEELani 02") ) ); |
|
186 iMemCardPwdDialog->ShowL(); |
|
187 TRACES( RDebug::Print(_L("CSysApAppUi::HandleKeyEventL, JEELani 03") ) ); |
|
188 } |
191 |
189 |
192 // --------------------------------------------------------------------------- |
190 // --------------------------------------------------------------------------- |
193 // CSysApDriveUnlockHandler::IsQueryOngoing |
191 // CSysApDriveUnlockHandler::IsQueryOngoing |
194 // --------------------------------------------------------------------------- |
192 // --------------------------------------------------------------------------- |
195 // |
193 // |
196 TBool CSysApDriveUnlockHandler::IsQueryOngoing() const |
194 TBool CSysApDriveUnlockHandler::IsQueryOngoing() const |
197 { |
195 { |
198 return ( iMemoryCardDialog || iQueryShowCB ); |
196 return 0; |
199 } |
197 } |
200 |
198 |
201 // --------------------------------------------------------------------------- |
199 // --------------------------------------------------------------------------- |
202 // CSysApDriveUnlockHandler::DoStartQueryIfNeededL |
200 // CSysApDriveUnlockHandler::DoStartQueryIfNeededL |
203 // --------------------------------------------------------------------------- |
201 // --------------------------------------------------------------------------- |
204 // |
202 // |
205 void CSysApDriveUnlockHandler::DoStartQueryIfNeededL() |
203 void CSysApDriveUnlockHandler::DoStartQueryIfNeededL() |
|
204 { |
|
205 iDriveToUnlock = iSysApDriveList.DriveToUnlock(); |
|
206 |
|
207 if ( iDriveToUnlock == KErrNotFound ) |
|
208 { |
|
209 _LIT(KChargingNote,"Phone does not found drive to unlock"); |
|
210 HBufC* aString = HBufC16::NewLC(150); |
|
211 TPtrC aStringPointer = aString->Des(); |
|
212 aStringPointer.Set(KChargingNote); |
|
213 TRACES( RDebug::Print( _L("CSysApWsClient::RunL(): Key EEventKeyUp 01") ) ); |
|
214 iSysApAppUi.ShowExampleUiNoteL( aStringPointer ); |
|
215 CleanupStack::PopAndDestroy(); // aString |
|
216 return; |
|
217 } |
|
218 |
|
219 if ( iMemoryCardLockSupported ) |
|
220 { |
|
221 ShowUnlockQueryL(); |
|
222 } |
|
223 else |
|
224 { |
|
225 iSysApAppUi.ShowQueryL( ESysApMemoryCardLockedNote ); |
|
226 _LIT(KChargingNote,"Phone does not support locked memory cards"); |
|
227 HBufC* aString = HBufC16::NewLC(150); |
|
228 TPtrC aStringPointer = aString->Des(); |
|
229 aStringPointer.Set(KChargingNote); |
|
230 TRACES( RDebug::Print( _L("CSysApWsClient::RunL(): Key EEventKeyUp 01") ) ); |
|
231 iSysApAppUi.ShowExampleUiNoteL( aStringPointer ); |
|
232 CleanupStack::PopAndDestroy(); // aString |
|
233 iSysApDriveList.MarkDriveUnlockQueryShown( iDriveToUnlock ); |
|
234 } |
|
235 } |
|
236 |
|
237 // --------------------------------------------------------------------------- |
|
238 // CSysApDriveUnlockHandler::DoStartQueryAsyncIfNeeded |
|
239 // --------------------------------------------------------------------------- |
|
240 // |
|
241 void CSysApDriveUnlockHandler::DoStartQueryAsyncIfNeeded() |
206 { |
242 { |
207 iDriveToUnlock = iSysApDriveList.DriveToUnlock(); |
243 iDriveToUnlock = iSysApDriveList.DriveToUnlock(); |
208 if ( iDriveToUnlock == KErrNotFound ) |
244 if ( iDriveToUnlock == KErrNotFound ) |
209 { |
245 { |
210 return; |
|
211 } |
|
212 if ( iMemoryCardLockSupported ) |
|
213 { |
|
214 ShowUnlockQueryL(); |
|
215 } |
|
216 else |
|
217 { |
|
218 iSysApAppUi.ShowQueryL( ESysApMemoryCardLockedNote ); |
|
219 iSysApDriveList.MarkDriveUnlockQueryShown( iDriveToUnlock ); |
|
220 } |
|
221 } |
|
222 |
|
223 // --------------------------------------------------------------------------- |
|
224 // CSysApDriveUnlockHandler::DoStartQueryAsyncIfNeeded |
|
225 // --------------------------------------------------------------------------- |
|
226 // |
|
227 void CSysApDriveUnlockHandler::DoStartQueryAsyncIfNeeded() |
|
228 { |
|
229 iDriveToUnlock = iSysApDriveList.DriveToUnlock(); |
|
230 if ( iDriveToUnlock == KErrNotFound ) |
|
231 { |
|
232 DoStopUnlock( KErrNone ); |
246 DoStopUnlock( KErrNone ); |
233 return; |
247 return; |
234 } |
|
235 delete iQueryShowCB; |
|
236 iQueryShowCB = NULL; |
|
237 iQueryShowCB = new CAsyncCallBack( |
|
238 TCallBack( QueryShowCB, this ), CActive::EPriorityStandard ); |
|
239 if ( iQueryShowCB ) |
|
240 { |
|
241 iQueryShowCB->CallBack(); |
|
242 } |
|
243 else |
|
244 { |
|
245 DoStopUnlock( KErrNoMemory ); |
|
246 } |
248 } |
247 } |
249 } |
248 |
250 |
249 // --------------------------------------------------------------------------- |
251 // --------------------------------------------------------------------------- |
250 // CSysApDriveUnlockHandler::DoStopUnlock |
252 // CSysApDriveUnlockHandler::DoStopUnlock |
256 { |
258 { |
257 TRACES( RDebug::Print( |
259 TRACES( RDebug::Print( |
258 _L( "CSysApMCSysApMMCUnlockObserver::DoStopUnlock: error: %d" ), |
260 _L( "CSysApMCSysApMMCUnlockObserver::DoStopUnlock: error: %d" ), |
259 aError ) ); |
261 aError ) ); |
260 } |
262 } |
|
263 ReleaseMemoryForInputCardDialog(); |
261 iIgnoreQueryResult = ETrue; |
264 iIgnoreQueryResult = ETrue; |
262 delete iMemoryCardDialog; |
|
263 iMemoryCardDialog = NULL; |
|
264 delete iQueryShowCB; |
|
265 iQueryShowCB = NULL; |
|
266 iIgnoreQueryResult = EFalse; |
265 iIgnoreQueryResult = EFalse; |
267 } |
266 } |
268 |
267 |
|
268 void CSysApDriveUnlockHandler::ReleaseMemoryForInputCardDialog() |
|
269 { |
|
270 if (iMemCardPwdDialog!=NULL) |
|
271 { |
|
272 //MemoryCardDialog already exist |
|
273 delete iMemCardPwdDialog; |
|
274 iMemCardPwdDialog = NULL; |
|
275 } |
|
276 } |
|
277 |
|
278 TInt CSysApDriveUnlockHandler::CheckMemoryDialogIfNeeded() |
|
279 { |
|
280 TRACES( RDebug::Print(_L( "CSysApDriveUnlockHandler::CheckMemoryDialogIfNeeded(): Begin" ))); |
|
281 TDriveNumber drive( static_cast< TDriveNumber >( iDriveToUnlock ) ); |
|
282 TRACES( RDebug::Print(_L( "CSysApDriveUnlockHandler::CheckMemoryDialogIfNeeded()" ))); |
|
283 TPtrC aStringPointer11 = iMemCardPwdDialog->getTextL(); |
|
284 ConvertCharactersToPwd(aStringPointer11,iPassword); |
|
285 |
|
286 if(!aStringPointer11.Length()) |
|
287 { |
|
288 return EFalse; // It meant user has pressed OK without password |
|
289 } |
|
290 |
|
291 TRACES( RDebug::Print(_L( "CSysApMCSysApMMCUnlockObserver::RunL; iPassword %S" ),&iPassword)); |
|
292 CEikonEnv* eikEnv = CEikonEnv:: Static(); |
|
293 TInt err = eikEnv->FsSession().UnlockDrive(drive,iPassword,ETrue); |
|
294 ReleaseMemoryForInputCardDialog(); |
|
295 |
|
296 if ( err == KErrNone) |
|
297 { |
|
298 TRACES( RDebug::Print(_L( "CSysApAppUi::ReleaseMemoryCardCustomDialogMemory(), Drive Unlocked Succesfully" ))); |
|
299 _LIT(KUnlockNote,"The memory is unlocked!"); |
|
300 HBufC* aString = HBufC16::NewLC(150); |
|
301 TPtrC aStringPointer = aString->Des(); |
|
302 aStringPointer.Set(KUnlockNote); |
|
303 iSysApAppUi.ShowExampleUiNoteL( aStringPointer ); |
|
304 CleanupStack::PopAndDestroy(); // aString |
|
305 return ETrue; |
|
306 } |
|
307 else if( err == KErrAccessDenied ) |
|
308 { |
|
309 TRACES( RDebug::Print(_L( "CSysApAppUi::ReleaseMemoryCardCustomDialogMemory(), Password InCorrect" ))); |
|
310 _LIT(KUnlockDeniedNote,"The password is incorrect, try again!"); |
|
311 HBufC* aString = HBufC16::NewLC(150); |
|
312 TPtrC aStringPointer = aString->Des(); |
|
313 aStringPointer.Set(KUnlockDeniedNote); |
|
314 iSysApAppUi.ShowExampleUiNoteL( aStringPointer ); |
|
315 CleanupStack::PopAndDestroy(); // aString |
|
316 return EFalse; |
|
317 } |
|
318 else if( err == KErrAlreadyExists ) |
|
319 { |
|
320 TRACES( RDebug::Print(_L( "CSysApAppUi::ReleaseMemoryCardCustomDialogMemory(), Already been Drive Unlocked" ))); |
|
321 _LIT(KUnlockAlreadyExistNote,"The disk has already been unlocked!"); |
|
322 HBufC* aString = HBufC16::NewLC(150); |
|
323 TPtrC aStringPointer = aString->Des(); |
|
324 aStringPointer.Set(KUnlockAlreadyExistNote); |
|
325 iSysApAppUi.ShowExampleUiNoteL( aStringPointer ); |
|
326 CleanupStack::PopAndDestroy(); // aString |
|
327 return ETrue; |
|
328 } |
|
329 else if( err == KErrNotSupported ) |
|
330 { |
|
331 TRACES( RDebug::Print(_L( "CSysApAppUi::ReleaseMemoryCardCustomDialogMemory(), Media does not support password locking." ))); |
|
332 _LIT(KUnlockNotSupporrtedNote,"The media does not support password locking!"); |
|
333 HBufC* aString = HBufC16::NewLC(150); |
|
334 TPtrC aStringPointer = aString->Des(); |
|
335 aStringPointer.Set(KUnlockNotSupporrtedNote); |
|
336 TRACES( RDebug::Print( _L("CSysApWsClient::RunL(): Key EEventKeyUp 01") ) ); |
|
337 iSysApAppUi.ShowExampleUiNoteL( aStringPointer ); |
|
338 CleanupStack::PopAndDestroy(); // aString |
|
339 return ETrue; |
|
340 } |
|
341 else |
|
342 { |
|
343 // check for error -18 what it is . |
|
344 _LIT(KUnlockOperationCancelNote,"Error occurred, operation cancelled!"); |
|
345 HBufC* aString = HBufC16::NewLC(150); |
|
346 TPtrC aStringPointer = aString->Des(); |
|
347 aStringPointer.Set(KUnlockOperationCancelNote); |
|
348 TRACES( RDebug::Print( _L("CSysApWsClient::RunL(): Key EEventKeyUp 01") ) ); |
|
349 iSysApAppUi.ShowExampleUiNoteL( aStringPointer ); |
|
350 CleanupStack::PopAndDestroy(); // aString |
|
351 return ETrue; |
|
352 } |
|
353 } |
|
354 |
|
355 HBufC8* CSysApDriveUnlockHandler::Convert16to8L(TDesC16& aStr)//const |
|
356 { |
|
357 |
|
358 HBufC8* newFrom1 = HBufC8::NewL(aStr.Length()); |
|
359 |
|
360 newFrom1->Des().Copy(aStr); |
|
361 |
|
362 return newFrom1; |
|
363 } |
|
364 |
|
365 void CSysApDriveUnlockHandler::ConvertCharactersToPwd(TDesC& aWord, TDes8& aConverted) |
|
366 { |
|
367 aConverted.FillZ(aConverted.MaxLength()); |
|
368 aConverted.Zero(); |
|
369 |
|
370 if (aWord.Length()) |
|
371 { |
|
372 aConverted.Copy( (TUint8*)(&aWord[0]), aWord.Size() ); |
|
373 } |
|
374 } |
|
375 |
269 // End of File |
376 // End of File |