273 // Handle events |
288 // Handle events |
274 // --------------------------------------------------------------------- |
289 // --------------------------------------------------------------------- |
275 // |
290 // |
276 void CCsPreviewPluginHandler::HandleEventL(CMsvEntrySelection* aSelection) |
291 void CCsPreviewPluginHandler::HandleEventL(CMsvEntrySelection* aSelection) |
277 { |
292 { |
278 PRINT ( _L("Enter CCsPreviewPluginHandler::HandleEvent") ); |
293 PRINT ( _L("Enter CCsPreviewPluginHandler::HandleEvent start.") ); |
279 |
294 |
280 TMsvEntry entry; |
295 TMsvEntry entry; |
281 TMsvId service; |
296 TMsvId service; |
282 TInt error = KErrNone; |
297 TInt error = KErrNone; |
283 |
298 |
284 for (TInt i = 0; i < aSelection->Count(); i++) |
299 for (TInt i = 0; i < aSelection->Count(); i++) |
285 { |
300 { |
286 error = iSession->GetEntry(aSelection->At(i), service, entry); |
301 error = iSession->GetEntry(aSelection->At(i), service, entry); |
287 |
302 |
288 if ( (KErrNone == error) && !entry.InPreparation() && entry.Visible() |
303 if ((KErrNone == error) && !entry.InPreparation() && entry.Visible()) |
289 && (KSenduiMtmMmsUidValue == entry.iMtm.iUid)) |
|
290 { |
304 { |
291 PRINT ( _L("Enter CCsPreviewPluginHandler::HandleEvent for loop started.") ); |
305 PRINT ( _L("Enter CCsPreviewPluginHandler::HandleEvent for loop started.") ); |
292 |
306 if ((KSenduiMtmMmsUidValue == entry.iMtm.iUid)) |
293 TInt msgId = entry.Id(); |
|
294 |
|
295 // check if the msg is already under processing Or processed |
|
296 if( EPreviewMsgNotProcessed != msgProcessingState(msgId) ) |
|
297 { |
|
298 // skip processing this event for the given message |
|
299 continue; |
|
300 } |
|
301 else |
|
302 { |
|
303 // start processing message, set flag |
|
304 setMsgProcessingState(msgId, EPreviewMsgProcessing); |
|
305 } |
|
306 |
|
307 // update db with message preview data |
|
308 RSqlStatement sqlInsertStmt; |
|
309 CleanupClosePushL(sqlInsertStmt); |
|
310 sqlInsertStmt.PrepareL(iSqlDb, KSqlInsertStmt); |
|
311 |
|
312 // parse message |
|
313 iMmsMtm->SwitchCurrentEntryL(msgId); |
|
314 iMmsMtm->LoadMessageL(); |
|
315 |
|
316 CUniDataModel* iUniDataModel = CUniDataModel::NewL(ifsSession, |
|
317 *iMmsMtm); |
|
318 CleanupStack::PushL(iUniDataModel); |
|
319 iUniDataModel->RestoreL(*this, ETrue); |
|
320 |
|
321 //msg property |
|
322 TInt msgProperty = 0; |
|
323 if (iUniDataModel->AttachmentList().Count() > 0) |
|
324 { |
|
325 msgProperty |= EPreviewAttachment; |
|
326 } |
|
327 |
|
328 //check for msg forward |
|
329 //Validate if the mms msg can be forwarded or not |
|
330 if (ValidateMsgForForward(iUniDataModel)) |
|
331 { |
|
332 msgProperty |= EPreviewForward; |
|
333 } |
|
334 |
|
335 TPtrC videoPath; |
|
336 TPtrC imagePath; |
|
337 |
|
338 // preview parsing |
|
339 TInt slideCount = iUniDataModel->SmilModel().SlideCount(); |
|
340 TBool isBodyTextSet = EFalse; |
|
341 TBool isImageSet = EFalse; |
|
342 TBool isAudioSet = EFalse; |
|
343 TBool isVideoSet = EFalse; |
|
344 |
|
345 for (int i = 0; i < slideCount; i++) |
|
346 { |
|
347 int slideobjcount = |
|
348 iUniDataModel->SmilModel().SlideObjectCount(i); |
|
349 for (int j = 0; j < slideobjcount; j++) |
|
350 { |
307 { |
351 CUniObject *obj = |
308 HandleMMSEntryL(entry); |
352 iUniDataModel->SmilModel(). GetObjectByIndex(i, j); |
309 } |
353 CMsgMediaInfo *mediaInfo = obj->MediaInfo(); |
310 else if ((KSenduiMtmSmsUidValue == entry.iMtm.iUid) || (KSenduiMtmBioUidValue == entry.iMtm.iUid)) |
354 |
311 { |
355 TPtrC8 mimetype = obj->MimeType(); |
312 if ((KMsgBioUidVCard.iUid == entry.iBioType)) |
356 TMsvAttachmentId attachId = obj->AttachmentId(); |
313 { |
357 |
314 HandleVCardEntryL(entry); |
358 //bodytext |
|
359 if (!isBodyTextSet && (mimetype.Find(_L8("text")) |
|
360 != KErrNotFound)) |
|
361 { |
|
362 //bind bodytext into statement |
|
363 BindBodyText(sqlInsertStmt, attachId); |
|
364 isBodyTextSet = ETrue; |
|
365 } |
|
366 |
|
367 //image parsing |
|
368 if (!isVideoSet && !isImageSet && (mimetype.Find(_L8("image")) |
|
369 != KErrNotFound)) |
|
370 { |
|
371 //get thumbnail for this image |
|
372 isImageSet = ETrue; |
|
373 imagePath.Set(mediaInfo->FullFilePath()); |
|
374 msgProperty |= EPreviewImage; |
|
375 |
|
376 if (EFileProtNoProtection != mediaInfo->Protection()) |
|
377 { |
|
378 msgProperty |= EPreviewProtectedImage; |
|
379 } |
|
380 if (mediaInfo->Corrupt()) |
|
381 { |
|
382 msgProperty |= EPreviewCorruptedImage; |
|
383 } |
|
384 |
|
385 if (!(EPreviewProtectedImage & msgProperty) && |
|
386 !(EPreviewCorruptedImage & msgProperty)) |
|
387 { |
|
388 //Generate thumbnail for non protected, |
|
389 //non corrupted image. |
|
390 GetThumbNailL(attachId, mimetype, msgId); |
|
391 } |
|
392 } |
|
393 |
|
394 //audio content |
|
395 if (!isVideoSet && !isAudioSet && (mimetype.Find(_L8("audio")) |
|
396 != KErrNotFound)) |
|
397 { |
|
398 isAudioSet = ETrue; |
|
399 msgProperty |= EPreviewAudio; |
|
400 if (EFileProtNoProtection != mediaInfo->Protection()) |
|
401 { |
|
402 msgProperty |= EPreviewProtectedAudio; |
|
403 } |
|
404 if (mediaInfo->Corrupt()) |
|
405 { |
|
406 msgProperty |= EPreviewCorruptedAudio; |
|
407 } |
|
408 } |
|
409 |
|
410 //video content |
|
411 if (!( isImageSet || isAudioSet) && !isVideoSet && (mimetype.Find(_L8("video")) |
|
412 != KErrNotFound)) |
|
413 { |
|
414 videoPath.Set(mediaInfo->FullFilePath()); |
|
415 isVideoSet = ETrue; |
|
416 msgProperty |= EPreviewVideo; |
|
417 if (EFileProtNoProtection != mediaInfo->Protection()) |
|
418 { |
|
419 msgProperty |= EPreviewProtectedVideo; |
|
420 } |
|
421 if (mediaInfo->Corrupt()) |
|
422 { |
|
423 msgProperty |= EPreviewCorruptedVideo; |
|
424 } |
|
425 } |
315 } |
426 } |
316 } |
427 } |
317 } |
428 |
318 }//end for loop |
429 //set preview path |
319 |
430 TInt previewPathIndex = sqlInsertStmt.ParameterIndex(_L( |
320 PRINT ( _L("Exit CCsPreviewPluginHandler::HandleEvent end.") ); |
|
321 } |
|
322 // ----------------------------------------------------------------------------- |
|
323 // CCsPreviewPluginHandler::HandleMMSEntryL() |
|
324 // |
|
325 // ----------------------------------------------------------------------------- |
|
326 // |
|
327 void CCsPreviewPluginHandler::HandleMMSEntryL(const TMsvEntry& aEntry) |
|
328 { |
|
329 PRINT ( _L("Enter CCsPreviewPluginHandler::HandleMMSEntry start.") ); |
|
330 |
|
331 TInt msgId = aEntry.Id(); |
|
332 |
|
333 // check if the msg is already under processing Or processed |
|
334 if (EPreviewMsgNotProcessed != msgProcessingState(msgId)) |
|
335 { |
|
336 // skip processing this event for the given message |
|
337 return; |
|
338 } |
|
339 |
|
340 // start processing message, set flag |
|
341 setMsgProcessingState(msgId, EPreviewMsgProcessing); |
|
342 |
|
343 // update db with message preview data |
|
344 RSqlStatement sqlInsertStmt; |
|
345 CleanupClosePushL(sqlInsertStmt); |
|
346 sqlInsertStmt.PrepareL(iSqlDb, KSqlInsertStmt); |
|
347 |
|
348 // parse message |
|
349 iMmsMtm->SwitchCurrentEntryL(msgId); |
|
350 iMmsMtm->LoadMessageL(); |
|
351 |
|
352 CUniDataModel* iUniDataModel = CUniDataModel::NewL(ifsSession, *iMmsMtm); |
|
353 CleanupStack::PushL(iUniDataModel); |
|
354 iUniDataModel->RestoreL(*this, ETrue); |
|
355 |
|
356 //msg property |
|
357 TInt msgProperty = 0; |
|
358 if (iUniDataModel->AttachmentList().Count() > 0) |
|
359 { |
|
360 msgProperty |= EPreviewAttachment; |
|
361 } |
|
362 |
|
363 //check for msg forward |
|
364 //Validate if the mms msg can be forwarded or not |
|
365 if (ValidateMsgForForward(iUniDataModel)) |
|
366 { |
|
367 msgProperty |= EPreviewForward; |
|
368 } |
|
369 |
|
370 TPtrC videoPath; |
|
371 TPtrC imagePath; |
|
372 |
|
373 // preview parsing |
|
374 TInt slideCount = iUniDataModel->SmilModel().SlideCount(); |
|
375 TBool isBodyTextSet = EFalse; |
|
376 TBool isImageSet = EFalse; |
|
377 TBool isAudioSet = EFalse; |
|
378 TBool isVideoSet = EFalse; |
|
379 |
|
380 for (int i = 0; i < slideCount; i++) |
|
381 { |
|
382 int slideobjcount = iUniDataModel->SmilModel().SlideObjectCount(i); |
|
383 for (int j = 0; j < slideobjcount; j++) |
|
384 { |
|
385 CUniObject *obj = iUniDataModel->SmilModel(). GetObjectByIndex(i, |
|
386 j); |
|
387 CMsgMediaInfo *mediaInfo = obj->MediaInfo(); |
|
388 |
|
389 TPtrC8 mimetype = obj->MimeType(); |
|
390 TMsvAttachmentId attachId = obj->AttachmentId(); |
|
391 |
|
392 //bodytext |
|
393 if (!isBodyTextSet |
|
394 && (mimetype.Find(_L8("text")) != KErrNotFound)) |
|
395 { |
|
396 //bind bodytext into statement |
|
397 BindBodyText(sqlInsertStmt, attachId); |
|
398 isBodyTextSet = ETrue; |
|
399 } |
|
400 |
|
401 //image parsing |
|
402 if (!isVideoSet && !isImageSet && (mimetype.Find(_L8("image")) |
|
403 != KErrNotFound)) |
|
404 { |
|
405 //get thumbnail for this image |
|
406 isImageSet = ETrue; |
|
407 imagePath.Set(mediaInfo->FullFilePath()); |
|
408 msgProperty |= EPreviewImage; |
|
409 |
|
410 if (EFileProtNoProtection != mediaInfo->Protection()) |
|
411 { |
|
412 msgProperty |= EPreviewProtectedImage; |
|
413 } |
|
414 if (mediaInfo->Corrupt()) |
|
415 { |
|
416 msgProperty |= EPreviewCorruptedImage; |
|
417 } |
|
418 |
|
419 if (!(EPreviewProtectedImage & msgProperty) |
|
420 && !(EPreviewCorruptedImage & msgProperty)) |
|
421 { |
|
422 //Generate thumbnail for non protected, |
|
423 //non corrupted image. |
|
424 GetThumbNailL(attachId, mimetype, msgId); |
|
425 } |
|
426 } |
|
427 |
|
428 //audio content |
|
429 if (!isVideoSet && !isAudioSet && (mimetype.Find(_L8("audio")) |
|
430 != KErrNotFound)) |
|
431 { |
|
432 isAudioSet = ETrue; |
|
433 msgProperty |= EPreviewAudio; |
|
434 if (EFileProtNoProtection != mediaInfo->Protection()) |
|
435 { |
|
436 msgProperty |= EPreviewProtectedAudio; |
|
437 } |
|
438 if (mediaInfo->Corrupt()) |
|
439 { |
|
440 msgProperty |= EPreviewCorruptedAudio; |
|
441 } |
|
442 } |
|
443 |
|
444 //video content |
|
445 if (!(isImageSet || isAudioSet) && !isVideoSet && (mimetype.Find( |
|
446 _L8("video")) != KErrNotFound)) |
|
447 { |
|
448 videoPath.Set(mediaInfo->FullFilePath()); |
|
449 isVideoSet = ETrue; |
|
450 msgProperty |= EPreviewVideo; |
|
451 if (EFileProtNoProtection != mediaInfo->Protection()) |
|
452 { |
|
453 msgProperty |= EPreviewProtectedVideo; |
|
454 } |
|
455 if (mediaInfo->Corrupt()) |
|
456 { |
|
457 msgProperty |= EPreviewCorruptedVideo; |
|
458 } |
|
459 } |
|
460 } |
|
461 } |
|
462 |
|
463 //set preview path |
|
464 TInt previewPathIndex = sqlInsertStmt.ParameterIndex(_L( |
|
465 ":preview_path")); |
|
466 if (isVideoSet) |
|
467 { |
|
468 User::LeaveIfError( |
|
469 sqlInsertStmt.BindText(previewPathIndex, videoPath)); |
|
470 } |
|
471 else if (isImageSet) |
|
472 { |
|
473 User::LeaveIfError( |
|
474 sqlInsertStmt.BindText(previewPathIndex, imagePath)); |
|
475 } |
|
476 |
|
477 //msg_id |
|
478 TInt msgIdIndex = sqlInsertStmt.ParameterIndex(_L(":message_id")); |
|
479 User::LeaveIfError(sqlInsertStmt.BindInt(msgIdIndex, msgId)); |
|
480 |
|
481 //subjext |
|
482 TInt subjectIndex = sqlInsertStmt.ParameterIndex(_L(":subject")); |
|
483 User::LeaveIfError(sqlInsertStmt.BindText(subjectIndex, |
|
484 iMmsMtm->SubjectL())); |
|
485 |
|
486 //msg_property |
|
487 TInt msgPropertyIndex = sqlInsertStmt.ParameterIndex(_L( |
|
488 ":msg_property")); |
|
489 User::LeaveIfError(sqlInsertStmt.BindInt(msgPropertyIndex, msgProperty)); |
|
490 |
|
491 //msg_processingstate |
|
492 TInt msgProcessingStateIndex = sqlInsertStmt.ParameterIndex( |
|
493 _L(":msg_processingstate")); |
|
494 User::LeaveIfError(sqlInsertStmt.BindInt(msgProcessingStateIndex, |
|
495 EPreviewMsgProcessed)); |
|
496 |
|
497 //execute sql stament |
|
498 User::LeaveIfError(sqlInsertStmt.Exec()); |
|
499 |
|
500 //cleanup |
|
501 CleanupStack::PopAndDestroy(2, &sqlInsertStmt); |
|
502 |
|
503 PRINT ( _L("Enter CCsPreviewPluginHandler::HandleMMSEntry end.") ); |
|
504 } |
|
505 |
|
506 // ----------------------------------------------------------------------------- |
|
507 // CCsPreviewPluginHandler::HandleVCardEntryL() |
|
508 // |
|
509 // ----------------------------------------------------------------------------- |
|
510 // |
|
511 void CCsPreviewPluginHandler::HandleVCardEntryL(const TMsvEntry& aEntry) |
|
512 { |
|
513 PRINT ( _L("Enter CCsPreviewPluginHandler::HandleBioMsgEntry start.") ); |
|
514 |
|
515 TMsvId msgId = aEntry.Id(); |
|
516 |
|
517 // check if the msg is already under processing Or processed |
|
518 TInt msgProcessState = EPreviewMsgNotProcessed; |
|
519 msgProcessState = msgProcessingState(msgId); |
|
520 if (EPreviewMsgProcessed == msgProcessState) |
|
521 { |
|
522 return; |
|
523 } |
|
524 //get attachments |
|
525 CMsvEntry* cMsvEntry = CMsvEntry::NewL(iBioClientMtm->Session(), msgId, |
|
526 TMsvSelectionOrdering()); |
|
527 |
|
528 CleanupStack::PushL(cMsvEntry); |
|
529 CMsvStore* store = cMsvEntry->ReadStoreL(); |
|
530 CleanupStack::PushL(store); |
|
531 MMsvAttachmentManager& attachMan = store->AttachmentManagerL(); |
|
532 |
|
533 TInt attachmentCount = attachMan.AttachmentCount(); |
|
534 if (attachmentCount) |
|
535 { |
|
536 // get attachment file path |
|
537 RFile file = attachMan.GetAttachmentFileL(0); |
|
538 CleanupClosePushL(file); |
|
539 TFileName fullName; |
|
540 User::LeaveIfError(file.FullName(fullName)); |
|
541 |
|
542 // update db with meta-data |
|
543 RSqlStatement sqlInsertStmt; |
|
544 CleanupClosePushL(sqlInsertStmt); |
|
545 sqlInsertStmt.PrepareL(iSqlDb, KSqlInsertBioMsgStmt); |
|
546 |
|
547 //msg_id |
|
548 TInt msgIdIndex = sqlInsertStmt.ParameterIndex(_L(":message_id")); |
|
549 User::LeaveIfError(sqlInsertStmt.BindInt(msgIdIndex, msgId)); |
|
550 |
|
551 //set attachment path |
|
552 TInt previewPathIndex = sqlInsertStmt.ParameterIndex(_L( |
431 ":preview_path")); |
553 ":preview_path")); |
432 if (isVideoSet) |
554 User::LeaveIfError(sqlInsertStmt.BindText(previewPathIndex, fullName)); |
433 { |
555 |
434 User::LeaveIfError(sqlInsertStmt.BindText(previewPathIndex, |
556 //msg_processingstate |
435 videoPath)); |
557 TInt msgProcessingStateIndex = sqlInsertStmt.ParameterIndex( |
436 } |
558 _L(":msg_processingstate")); |
437 else if (isImageSet) |
559 User::LeaveIfError(sqlInsertStmt.BindInt(msgProcessingStateIndex, |
438 { |
560 EPreviewMsgProcessed)); |
439 User::LeaveIfError(sqlInsertStmt.BindText(previewPathIndex, |
561 |
440 imagePath)); |
562 //execute sql stament |
441 } |
563 User::LeaveIfError(sqlInsertStmt.Exec()); |
442 |
564 |
443 //msg_id |
565 //cleanup |
444 TInt msgIdIndex = sqlInsertStmt.ParameterIndex(_L(":message_id")); |
566 CleanupStack::PopAndDestroy(&sqlInsertStmt); |
445 User::LeaveIfError(sqlInsertStmt.BindInt(msgIdIndex, msgId)); |
567 CleanupStack::PopAndDestroy(&file); |
446 |
568 } |
447 //subjext |
569 |
448 TInt subjectIndex = sqlInsertStmt.ParameterIndex(_L(":subject")); |
570 CleanupStack::PopAndDestroy(2, cMsvEntry);//cMsvEntry,store |
449 User::LeaveIfError(sqlInsertStmt.BindText(subjectIndex, |
571 |
450 iMmsMtm->SubjectL())); |
572 PRINT ( _L("Enter CCsPreviewPluginHandler::HandleBioMsgEntry End.") ); |
451 |
573 } |
452 //msg_property |
|
453 TInt msgPropertyIndex = sqlInsertStmt.ParameterIndex(_L( |
|
454 ":msg_property")); |
|
455 User::LeaveIfError(sqlInsertStmt.BindInt(msgPropertyIndex, |
|
456 msgProperty)); |
|
457 |
|
458 //msg_processingstate |
|
459 TInt msgProcessingStateIndex = sqlInsertStmt.ParameterIndex(_L(":msg_processingstate")); |
|
460 User::LeaveIfError(sqlInsertStmt.BindInt(msgProcessingStateIndex, EPreviewMsgProcessed)); |
|
461 |
|
462 //execute sql stament |
|
463 User::LeaveIfError(sqlInsertStmt.Exec()); |
|
464 |
|
465 //cleanup |
|
466 CleanupStack::PopAndDestroy(2, &sqlInsertStmt); |
|
467 } |
|
468 }//end for loop |
|
469 |
|
470 PRINT ( _L("Exit CCsPreviewPluginHandler::HandleEvent") ); |
|
471 } |
|
472 |
574 |
473 // ----------------------------------------------------------------------------- |
575 // ----------------------------------------------------------------------------- |
474 // CCsPreviewPluginHandler::RestoreReady() |
576 // CCsPreviewPluginHandler::RestoreReady() |
475 // |
577 // |
476 // ----------------------------------------------------------------------------- |
578 // ----------------------------------------------------------------------------- |