33 #include <mmsconst.h> |
33 #include <mmsconst.h> |
34 #include <msgmediainfo.h> |
34 #include <msgmediainfo.h> |
35 #include <MsgMediaResolver.h> |
35 #include <MsgMediaResolver.h> |
36 #include <fileprotectionresolver.h> |
36 #include <fileprotectionresolver.h> |
37 #include <MmsEngineInternalCRKeys.h> |
37 #include <MmsEngineInternalCRKeys.h> |
|
38 #include <imageconversion.h> |
38 //CONSTANTS |
39 //CONSTANTS |
39 //DB-file |
40 //DB-file |
40 _LIT(KDbFileName, "c:[2002A542]conversations.db"); |
41 _LIT(KDbFileName, "c:[2002A542]conversations.db"); |
41 //Encoding |
42 //Encoding |
42 _LIT(KEncodingStmnt,"PRAGMA encoding=\"UTF-8\""); |
43 _LIT(KEncodingStmnt,"PRAGMA encoding=\"UTF-8\""); |
59 //Insert vcard meta-daa query |
60 //Insert vcard meta-daa query |
60 _LIT(KSqlInsertBioMsgStmt, "INSERT OR REPLACE INTO conversation_messages ( message_id, msg_processingstate, preview_path ) VALUES( :message_id, :msg_processingstate, :preview_path )"); |
61 _LIT(KSqlInsertBioMsgStmt, "INSERT OR REPLACE INTO conversation_messages ( message_id, msg_processingstate, preview_path ) VALUES( :message_id, :msg_processingstate, :preview_path )"); |
61 |
62 |
62 const TInt KDefaultMaxSize = 300 * 1024; |
63 const TInt KDefaultMaxSize = 300 * 1024; |
63 //Preview thumbnail size |
64 //Preview thumbnail size |
64 const TInt KWidth = 9.5 * 6.7; |
65 const TInt KWidth = 24 * 6.7; |
65 const TInt KHeight = 9.5 * 6.7; |
66 const TInt KHeight = 24 * 6.7; |
66 |
67 |
67 // NOTE:- DRAFTS ENTRIES ARE NOT HANDLED IN THE PLUGIN |
68 // NOTE:- DRAFTS ENTRIES ARE NOT HANDLED IN THE PLUGIN |
68 |
69 |
69 // ============================== MEMBER FUNCTIONS ============================ |
70 // ============================== MEMBER FUNCTIONS ============================ |
70 // ---------------------------------------------------------------------------- |
71 // ---------------------------------------------------------------------------- |
334 if (EPreviewMsgNotProcessed != msgProcessingState(msgId)) |
335 if (EPreviewMsgNotProcessed != msgProcessingState(msgId)) |
335 { |
336 { |
336 // skip processing this event for the given message |
337 // skip processing this event for the given message |
337 return; |
338 return; |
338 } |
339 } |
339 |
340 |
340 // start processing message, set flag |
341 // start processing message, set flag |
341 setMsgProcessingState(msgId, EPreviewMsgProcessing); |
342 setMsgProcessingState(msgId, EPreviewMsgProcessing); |
342 |
343 |
|
344 |
|
345 TRAPD( err, |
|
346 { |
343 // update db with message preview data |
347 // update db with message preview data |
344 RSqlStatement sqlInsertStmt; |
348 RSqlStatement sqlInsertStmt; |
345 CleanupClosePushL(sqlInsertStmt); |
349 CleanupClosePushL(sqlInsertStmt); |
346 sqlInsertStmt.PrepareL(iSqlDb, KSqlInsertStmt); |
350 sqlInsertStmt.PrepareL(iSqlDb, KSqlInsertStmt); |
347 |
351 |
348 // parse message |
352 // parse message |
349 iMmsMtm->SwitchCurrentEntryL(msgId); |
353 iMmsMtm->SwitchCurrentEntryL(msgId); |
350 iMmsMtm->LoadMessageL(); |
354 iMmsMtm->LoadMessageL(); |
351 |
355 |
352 CUniDataModel* iUniDataModel = CUniDataModel::NewL(ifsSession, *iMmsMtm); |
356 CUniDataModel* iUniDataModel = CUniDataModel::NewL(ifsSession, *iMmsMtm); |
353 CleanupStack::PushL(iUniDataModel); |
357 CleanupStack::PushL(iUniDataModel); |
354 iUniDataModel->RestoreL(*this, ETrue); |
358 iUniDataModel->RestoreL(*this, ETrue); |
355 |
359 |
356 //msg property |
360 //msg property |
357 TInt msgProperty = 0; |
361 TInt msgProperty = 0; |
358 if (iUniDataModel->AttachmentList().Count() > 0) |
362 if (iUniDataModel->AttachmentList().Count() > 0) |
359 { |
363 { |
360 msgProperty |= EPreviewAttachment; |
364 msgProperty |= EPreviewAttachment; |
497 //execute sql stament |
501 //execute sql stament |
498 User::LeaveIfError(sqlInsertStmt.Exec()); |
502 User::LeaveIfError(sqlInsertStmt.Exec()); |
499 |
503 |
500 //cleanup |
504 //cleanup |
501 CleanupStack::PopAndDestroy(2, &sqlInsertStmt); |
505 CleanupStack::PopAndDestroy(2, &sqlInsertStmt); |
|
506 }); //TRAP |
|
507 |
|
508 if( err != KErrNone ) |
|
509 { |
|
510 setMsgProcessingState(msgId, EPreviewMsgNotProcessed); |
|
511 } |
502 |
512 |
503 PRINT ( _L("Enter CCsPreviewPluginHandler::HandleMMSEntry end.") ); |
513 PRINT ( _L("Enter CCsPreviewPluginHandler::HandleMMSEntry end.") ); |
504 } |
514 } |
505 |
515 |
506 // ----------------------------------------------------------------------------- |
516 // ----------------------------------------------------------------------------- |
895 // ----------------------------------------------------------------------------- |
905 // ----------------------------------------------------------------------------- |
896 // |
906 // |
897 void CCsPreviewPluginHandler::GetThumbNailL(TMsvAttachmentId attachmentId, |
907 void CCsPreviewPluginHandler::GetThumbNailL(TMsvAttachmentId attachmentId, |
898 TDesC8& mimeType, TMsvId msgId) |
908 TDesC8& mimeType, TMsvId msgId) |
899 { |
909 { |
900 //Scale the image |
|
901 iThumbnailManager->SetFlagsL(CThumbnailManager::ECropToAspectRatio); |
|
902 |
|
903 //TODO replace with hb-param-graphic-size-image-portrait * value of un in pixcels |
|
904 iThumbnailManager->SetThumbnailSizeL(TSize(KWidth, KHeight)); |
|
905 |
|
906 //optimize for performace |
|
907 iThumbnailManager->SetQualityPreferenceL( |
|
908 CThumbnailManager::EOptimizeForPerformance); |
|
909 |
910 |
910 // Create Thumbnail object source representing a path to a file |
911 // Create Thumbnail object source representing a path to a file |
911 HBufC* mimeInfo = HBufC::NewLC(mimeType.Length()); |
912 HBufC* mimeInfo = HBufC::NewLC(mimeType.Length()); |
912 mimeInfo->Des().Copy(mimeType); |
913 mimeInfo->Des().Copy(mimeType); |
913 |
914 |
916 |
917 |
917 //get file handle from attachment manager. |
918 //get file handle from attachment manager. |
918 MMsvAttachmentManager& attachMan = store->AttachmentManagerL(); |
919 MMsvAttachmentManager& attachMan = store->AttachmentManagerL(); |
919 RFile file = attachMan.GetAttachmentFileL(attachmentId); |
920 RFile file = attachMan.GetAttachmentFileL(attachmentId); |
920 CleanupClosePushL(file); |
921 CleanupClosePushL(file); |
|
922 |
|
923 //Find if the image is portrait image (or) landscape image |
|
924 CImageDecoder *decoder = CImageDecoder::FileNewL(file,mimeType,ContentAccess::EUnknown); |
|
925 CleanupStack::PushL(decoder); |
|
926 TSize size(0,0); |
|
927 |
|
928 TFrameInfo info = decoder->FrameInfo(); |
|
929 |
|
930 size = info.iOverallSizeInPixels; |
|
931 |
|
932 CleanupStack::PopAndDestroy(decoder); |
|
933 |
|
934 TReal32 newLength = 0; |
|
935 |
|
936 if(size.iWidth >= size.iHeight) |
|
937 { |
|
938 //TODO replace with hb-param-graphic-size-image-portrait * value of un in pixcels |
|
939 if(size.iWidth < KWidth) |
|
940 { |
|
941 iThumbnailManager->SetThumbnailSizeL(size); |
|
942 } |
|
943 else |
|
944 { |
|
945 newLength = (KWidth * size.iHeight) /size.iWidth; |
|
946 iThumbnailManager->SetThumbnailSizeL(TSize(KWidth, newLength)); |
|
947 } |
|
948 } |
|
949 else |
|
950 { |
|
951 //TODO replace with hb-param-graphic-size-image-portrait * value of un in pixcels |
|
952 if(size.iHeight < KHeight) |
|
953 { |
|
954 iThumbnailManager->SetThumbnailSizeL(size); |
|
955 } |
|
956 else |
|
957 { |
|
958 newLength = (KHeight * size.iWidth) / size.iHeight; |
|
959 iThumbnailManager->SetThumbnailSizeL(TSize(newLength, KHeight)); |
|
960 } |
|
961 } |
|
962 |
|
963 //Scale the image |
|
964 iThumbnailManager->SetFlagsL(CThumbnailManager::ECropToAspectRatio); |
|
965 |
|
966 //optimize for performace |
|
967 iThumbnailManager->SetQualityPreferenceL( |
|
968 CThumbnailManager::EOptimizeForQuality); |
921 |
969 |
922 CThumbnailObjectSource* source = CThumbnailObjectSource::NewLC( |
970 CThumbnailObjectSource* source = CThumbnailObjectSource::NewLC( |
923 (RFile64&) file, mimeInfo->Des()); |
971 (RFile64&) file, mimeInfo->Des()); |
924 |
972 |
925 // Issue the request for thumbnail creation |
973 // Issue the request for thumbnail creation |