129 MPbk2ImageOperation& aOperation); |
131 MPbk2ImageOperation& aOperation); |
130 void Pbk2ImageSetFailed( |
132 void Pbk2ImageSetFailed( |
131 MPbk2ImageOperation& aOperation, |
133 MPbk2ImageOperation& aOperation, |
132 TInt aError); |
134 TInt aError); |
133 |
135 |
|
136 private: // from MProgressDialogCallback |
|
137 void DialogDismissedL( TInt aButtonId ); |
|
138 |
134 private: // from MMGFetchVerifier |
139 private: // from MMGFetchVerifier |
135 TBool VerifySelectionL( |
140 TBool VerifySelectionL( |
136 const MDesCArray* aSelectedFiles); |
141 const MDesCArray* aSelectedFiles); |
137 private: |
142 private: |
138 CSetImageCmd(); |
143 CSetImageCmd(); |
139 void ConstructL(); |
144 void ConstructL(); |
140 void Cancel(); |
145 void Cancel(); |
141 void DismissWaitNote(); |
146 void DismissWaitNote(); |
142 void SetImageRefL( MVPbkStoreContact* aContact, |
147 void SetImageRefL( MVPbkStoreContact* aContact, |
143 const TDesC& aFileName); |
148 const TDesC& aFileName); |
|
149 TBool DoVerifySelectionL( |
|
150 const MDesCArray* aSelectedFiles); |
|
151 void ShowErrorNoteL(); |
144 |
152 |
145 private: |
153 private: |
146 /// Own: image set operation |
154 /// Own: image set operation |
147 MPbk2ImageOperation* iImageOperation; |
155 MPbk2ImageOperation* iImageOperation; |
148 /// Own: wait note dialog |
156 /// Own: wait note dialog |
181 Release( iServices ); |
192 Release( iServices ); |
182 } |
193 } |
183 |
194 |
184 void CSetImageCmd::ExecuteL( MVPbkStoreContact* aContact,MPbk2ImageFieldObserver* aObserver ) |
195 void CSetImageCmd::ExecuteL( MVPbkStoreContact* aContact,MPbk2ImageFieldObserver* aObserver ) |
185 { |
196 { |
|
197 iImageSetFailed = EFalse; |
186 iObserver=aObserver; |
198 iObserver=aObserver; |
187 CDesCArray* selectedFile = new(ELeave) CDesCArrayFlat( |
199 CDesCArray* selectedFile = new(ELeave) CDesCArrayFlat( |
188 KSelectedFilesDefaultGranularity ); |
200 KSelectedFilesDefaultGranularity ); |
189 CleanupStack::PushL( selectedFile ); |
201 CleanupStack::PushL( selectedFile ); |
190 TBool res( EFalse ); |
202 TBool res( EFalse ); |
191 |
203 |
192 // run image fetch dialog |
204 // run image fetch dialog |
193 res = MGFetch::RunL( *selectedFile, |
205 res = MGFetch::RunL( *selectedFile, |
194 EImageFile, |
206 EImageFile, |
195 EFalse, /* multiselection */ |
207 EFalse, /* multiselection */ |
196 this /* provide MMGFetchVerifier interface to check DRM */); |
208 this /* provide MMGFetchVerifier interface to check DRM */); |
197 |
209 |
198 if ( res && selectedFile->Count() > 0 ) |
210 if ( !iVerificationFailed && res && selectedFile->Count() > 0 ) |
199 { |
211 { |
200 if (iWaitNote==NULL) |
212 if (iWaitNote==NULL) |
201 { |
213 { |
202 iWaitNote =new(ELeave) CAknWaitDialog(reinterpret_cast<CEikDialog**>( &iWaitNote ),ETrue ); |
214 iWaitNote =new(ELeave) CAknWaitDialog(reinterpret_cast<CEikDialog**>( &iWaitNote ),ETrue ); |
203 } |
215 } |
|
216 iWaitNote->SetCallback( this ); |
|
217 |
204 // doesn't delete waitNote |
218 // doesn't delete waitNote |
205 iWaitNote->ExecuteLD( R_QTN_GEN_NOTE_FETCHING ); |
219 iWaitNote->ExecuteLD( R_QTN_GEN_NOTE_FETCHING ); |
206 |
220 |
207 TPtrC fileName = (*selectedFile)[0]; |
221 TPtrC fileName = (*selectedFile)[0]; |
208 |
222 |
209 // delete old filename |
223 // delete old filename |
210 delete iImageFilename; |
224 delete iImageFilename; |
211 iImageFilename=NULL; |
225 iImageFilename=NULL; |
212 // store these for later use |
226 // store these for later use |
213 iImageFilename=fileName.AllocL(); |
227 iImageFilename=fileName.AllocL(); |
214 iContact=aContact; |
228 iContact=aContact; |
215 |
229 |
216 |
230 // write data to thumbnail field |
217 // write data to thumbnail field |
|
218 iImageOperation = |
231 iImageOperation = |
219 iImageManager->SetImageAsyncL( |
232 iImageManager->SetImageAsyncL( |
220 *aContact, *iThumbnailFieldType, *this, fileName ); |
233 *aContact, *iThumbnailFieldType, *this, fileName ); |
221 |
234 } |
222 } |
235 |
223 |
236 CleanupStack::PopAndDestroy( selectedFile ); |
224 CleanupStack::PopAndDestroy( selectedFile ); |
|
225 } |
237 } |
226 |
238 |
227 CSetImageCmd::CSetImageCmd() |
239 CSetImageCmd::CSetImageCmd() |
228 { |
240 { |
229 } |
241 } |
277 iImageOperation = NULL; |
294 iImageOperation = NULL; |
278 DismissWaitNote(); |
295 DismissWaitNote(); |
279 if (iObserver) |
296 if (iObserver) |
280 { |
297 { |
281 iObserver->ImageLoadingComplete(); |
298 iObserver->ImageLoadingComplete(); |
282 } |
299 } |
283 |
|
284 } |
300 } |
285 |
301 |
286 // -------------------------------------------------------------------------- |
302 // -------------------------------------------------------------------------- |
287 // CPbk2SetImageCmd::Pbk2ImageSetFailed |
303 // CPbk2SetImageCmd::Pbk2ImageSetFailed |
288 // -------------------------------------------------------------------------- |
304 // -------------------------------------------------------------------------- |
289 // |
305 // |
290 void CSetImageCmd::Pbk2ImageSetFailed |
306 void CSetImageCmd::Pbk2ImageSetFailed |
291 ( MPbk2ImageOperation& /*aOperation*/, TInt aError ) |
307 ( MPbk2ImageOperation& /*aOperation*/, TInt aError ) |
292 { |
308 { |
293 delete iImageOperation; |
309 delete iImageOperation; |
294 iImageOperation = NULL; |
310 iImageOperation = NULL; |
295 DismissWaitNote(); |
311 |
296 if (iObserver) |
312 iImageSetFailed = ETrue; |
297 { |
313 iImageSetError = aError; |
298 iObserver->ImageLoadingFailed(); |
314 |
299 } |
315 DismissWaitNote(); |
300 |
|
301 if ( aError != KErrNone ) |
|
302 { |
|
303 CCoeEnv::Static()->HandleError( aError ); |
|
304 } |
|
305 } |
316 } |
306 |
317 |
307 void CSetImageCmd::SetImageRefL( MVPbkStoreContact* aContact, |
318 void CSetImageCmd::SetImageRefL( MVPbkStoreContact* aContact, |
308 const TDesC& aFileName) |
319 const TDesC& aFileName) |
309 { |
320 { |
335 CleanupStack::Pop(); // field |
346 CleanupStack::Pop(); // field |
336 } |
347 } |
337 } |
348 } |
338 |
349 |
339 // -------------------------------------------------------------------------- |
350 // -------------------------------------------------------------------------- |
340 // DRM check for image fetch dialog |
351 // CSetImageCmd::DialogDismissedL |
|
352 // -------------------------------------------------------------------------- |
|
353 // |
|
354 void CSetImageCmd::DialogDismissedL( TInt /*aButtonId*/ ) |
|
355 { |
|
356 if( iImageSetFailed ) |
|
357 { |
|
358 ShowErrorNoteL(); |
|
359 } |
|
360 } |
|
361 |
|
362 // -------------------------------------------------------------------------- |
|
363 // CSetImageCmd::VerifySelectionL |
341 // -------------------------------------------------------------------------- |
364 // -------------------------------------------------------------------------- |
342 // |
365 // |
343 TBool CSetImageCmd::VerifySelectionL |
366 TBool CSetImageCmd::VerifySelectionL |
344 (const MDesCArray* aSelectedFiles) |
367 (const MDesCArray* aSelectedFiles) |
345 { |
368 { |
346 TBool result = EFalse; |
369 iVerificationFailed = EFalse; |
|
370 TBool ret = ETrue; |
|
371 |
|
372 TRAPD( err, ret = DoVerifySelectionL( aSelectedFiles ) ); |
|
373 |
|
374 if( err != KErrNone ) |
|
375 { |
|
376 iVerificationFailed = ETrue; |
|
377 ShowErrorNoteL(); |
|
378 } |
|
379 |
|
380 // Selection is always accepted if the image is not drm protected. |
|
381 // Image fetch dialog functionality is always same in spite of error |
|
382 // type (DRM check, ImageDecoder, etc. errors) Dialog is always closed. |
|
383 return ret; |
|
384 } |
|
385 |
|
386 // -------------------------------------------------------------------------- |
|
387 // CSetImageCmd::DoVerifySelectionL |
|
388 // -------------------------------------------------------------------------- |
|
389 // |
|
390 TBool CSetImageCmd::DoVerifySelectionL |
|
391 (const MDesCArray* aSelectedFiles) |
|
392 { |
|
393 TBool ret = ETrue; |
|
394 |
347 if ( aSelectedFiles && aSelectedFiles->MdcaCount() > 0 ) |
395 if ( aSelectedFiles && aSelectedFiles->MdcaCount() > 0 ) |
348 { |
396 { |
349 // DRM for phonebook image fetch |
397 // DRM for phonebook image fetch |
350 TPtrC fileName = aSelectedFiles->MdcaPoint( 0 ); |
398 TPtrC fileName = aSelectedFiles->MdcaPoint( 0 ); |
|
399 |
351 TBool isProtected( ETrue ); |
400 TBool isProtected( ETrue ); |
352 User::LeaveIfError( |
401 User::LeaveIfError( |
353 iDrmManager->IsProtectedFile( fileName, isProtected ) ); |
402 iDrmManager->IsProtectedFile( fileName, isProtected ) ); |
|
403 |
354 if ( isProtected ) |
404 if ( isProtected ) |
355 { |
405 { |
|
406 ret = EFalse; |
|
407 |
356 RPbk2LocalizedResourceFile resFile( *CCoeEnv::Static() ); |
408 RPbk2LocalizedResourceFile resFile( *CCoeEnv::Static() ); |
357 resFile.OpenLC( |
409 resFile.OpenLC( |
358 KPbk2RomFileDrive, |
410 KPbk2RomFileDrive, |
359 KDC_RESOURCE_FILES_DIR, |
411 KDC_RESOURCE_FILES_DIR, |
360 Pbk2PresentationUtils::PresentationResourceFile() ); |
412 Pbk2PresentationUtils::PresentationResourceFile() ); |
361 // show user copyright note |
413 // show user copyright note |
|
414 |
362 HBufC* prompt = |
415 HBufC* prompt = |
363 CCoeEnv::Static()->AllocReadResourceLC( R_PBK2_QTN_DRM_NOT_ALLOWED ); |
416 CCoeEnv::Static()->AllocReadResourceLC( R_PBK2_QTN_DRM_NOT_ALLOWED ); |
364 CAknInformationNote* dlg = new(ELeave) CAknInformationNote( ETrue ); |
417 CAknInformationNote* dlg = new(ELeave) CAknInformationNote( ETrue ); |
365 dlg->ExecuteLD( *prompt ); |
418 dlg->ExecuteLD( *prompt ); |
366 CleanupStack::PopAndDestroy( 2 ); // resFile, prompt |
419 CleanupStack::PopAndDestroy( 2 ); // resFile, prompt |
367 } |
420 } |
368 else |
421 } |
369 { |
422 |
370 result = ETrue; |
423 return ret; |
371 } |
|
372 } |
|
373 |
|
374 return result; |
|
375 } |
424 } |
|
425 |
|
426 // -------------------------------------------------------------------------- |
|
427 // CSetImageCmd::ShowErrorNoteL |
|
428 // -------------------------------------------------------------------------- |
|
429 // |
|
430 void CSetImageCmd::ShowErrorNoteL() |
|
431 { |
|
432 HBufC* prompt = StringLoader::LoadLC( R_QTN_ALBUM_ERR_FORMAT_UNKNOWN ); |
|
433 CAknInformationNote* dlg = new ( ELeave ) CAknInformationNote( ETrue ); |
|
434 dlg->ExecuteLD( *prompt ); |
|
435 CleanupStack::PopAndDestroy( prompt ); |
|
436 |
|
437 if( iImageSetFailed ) |
|
438 { |
|
439 iImageSetFailed = EFalse; |
|
440 |
|
441 if (iObserver) |
|
442 { |
|
443 iObserver->ImageLoadingFailed(); |
|
444 } |
|
445 |
|
446 if ( iImageSetError != KErrNone ) |
|
447 { |
|
448 CCoeEnv::Static()->HandleError( iImageSetError ); |
|
449 iImageSetError = KErrNone; |
|
450 } |
|
451 } |
|
452 } |
376 |
453 |
377 // -------------------------------------------------------------------------- |
454 // -------------------------------------------------------------------------- |
378 // Starts external image viewer via doc.handler and waits for its exit |
455 // Starts external image viewer via doc.handler and waits for its exit |
379 // -------------------------------------------------------------------------- |
456 // -------------------------------------------------------------------------- |
380 // |
457 // |