23 #include <mtclreg.h> |
23 #include <mtclreg.h> |
24 #include <msvids.h> |
24 #include <msvids.h> |
25 #include <e32const.h> |
25 #include <e32const.h> |
26 #include <SendUiConsts.h> |
26 #include <SendUiConsts.h> |
27 #include <utf.h> |
27 #include <utf.h> |
|
28 #include <centralrepository.h> |
|
29 #include <MmsConformance.h> |
|
30 #include <mmsconst.h> |
|
31 #include <msgmediainfo.h> |
|
32 #include <MsgMediaResolver.h> |
|
33 #include <fileprotectionresolver.h> |
|
34 #include <MmsEngineInternalCRKeys.h> |
28 //CONSTANTS |
35 //CONSTANTS |
29 //DB-file |
36 //DB-file |
30 _LIT(KDbFileName, "c:[2002A542]conversations.db"); |
37 _LIT(KDbFileName, "c:[2002A542]conversations.db"); |
31 //Encoding |
38 //Encoding |
32 _LIT(KEncodingStmnt,"PRAGMA encoding=\"UTF-8\""); |
39 _LIT(KEncodingStmnt,"PRAGMA encoding=\"UTF-8\""); |
33 //Size |
40 //Size |
34 _LIT(KCacheSizeStmnt,"PRAGMA default_cache_size = 1024"); |
41 _LIT(KCacheSizeStmnt,"PRAGMA default_cache_size = 1024"); |
35 // Create table query statement |
42 // Create table query statement |
36 _LIT(KSqlCreateStmt, "CREATE TABLE IF NOT EXISTS conversation_messages ( message_id INTEGER PRIMARY KEY, msg_parsed INTEGER DEFAULT 0, subject TEXT(100), body_text TEXT(160), preview_path TEXT, msg_property INTEGER, preview_icon BLOB DEFAULT NULL ) " ); |
43 _LIT(KSqlCreateStmt, "CREATE TABLE IF NOT EXISTS conversation_messages ( message_id INTEGER PRIMARY KEY, msg_processingstate INTEGER DEFAULT 0, subject TEXT(100), body_text TEXT(160), preview_path TEXT, msg_property INTEGER, preview_icon BLOB DEFAULT NULL ) " ); |
|
44 //Create an empty record for the given message id |
|
45 _LIT(KSqlBasicInsertStmt, "INSERT OR REPLACE INTO conversation_messages ( message_id ) VALUES( :message_id )"); |
37 //Insert without bitmap query |
46 //Insert without bitmap query |
38 _LIT(KSqlInsertStmt, "INSERT OR REPLACE INTO conversation_messages (message_id, msg_parsed, subject, body_text, preview_path, msg_property ) VALUES( :message_id, :msg_parsed, :subject, :body_text, :preview_path, :msg_property )"); |
47 _LIT(KSqlInsertStmt, "INSERT OR REPLACE INTO conversation_messages ( message_id, msg_processingstate, subject, body_text, preview_path, msg_property ) VALUES( :message_id, :msg_processingstate, :subject, :body_text, :preview_path, :msg_property )"); |
|
48 //update processing-state flag of a message |
|
49 _LIT(KSqlUpdateProcessingStateStmt, "UPDATE conversation_messages SET msg_processingstate=:msg_processingstate WHERE message_id=:message_id " ); |
39 //update with bitmap query |
50 //update with bitmap query |
40 _LIT(KSqlUpdateBitmapStmt, "UPDATE conversation_messages SET preview_icon=:preview_icon WHERE message_id=:message_id " ); |
51 _LIT(KSqlUpdateBitmapStmt, "UPDATE conversation_messages SET preview_icon=:preview_icon WHERE message_id=:message_id " ); |
41 // query to see if msg_parsed is set |
52 // query to see if msg is under process at the moment |
42 _LIT(KSelectMsgParsedStmt, " SELECT message_id, msg_parsed FROM conversation_messages WHERE message_id=:message_id "); |
53 _LIT(KSelectProcessingStateStmt, " SELECT message_id, msg_processingstate FROM conversation_messages WHERE message_id=:message_id "); |
43 // Remove record from conversation_messages table. |
54 // Remove record from conversation_messages table. |
44 _LIT(KRemoveMsgStmnt,"DELETE FROM conversation_messages WHERE message_id=:message_id"); |
55 _LIT(KRemoveMsgStmnt,"DELETE FROM conversation_messages WHERE message_id=:message_id"); |
|
56 |
|
57 const TInt KDefaultMaxSize = 300 * 1024; |
45 |
58 |
46 // NOTE:- DRAFTS ENTRIES ARE NOT HANDLED IN THE PLUGIN |
59 // NOTE:- DRAFTS ENTRIES ARE NOT HANDLED IN THE PLUGIN |
47 |
60 |
48 // ============================== MEMBER FUNCTIONS ============================ |
61 // ============================== MEMBER FUNCTIONS ============================ |
49 // ---------------------------------------------------------------------------- |
62 // ---------------------------------------------------------------------------- |
160 else |
173 else |
161 { |
174 { |
162 User::LeaveIfError(error); |
175 User::LeaveIfError(error); |
163 } |
176 } |
164 |
177 |
|
178 //get the max size of mms from the repository |
|
179 TRAP_IGNORE( |
|
180 CRepository* repository = CRepository::NewL(KCRUidMmsEngine); |
|
181 CleanupStack::PushL(repository); |
|
182 |
|
183 //Fetch and set max mms composition size |
|
184 TInt maxSize = KDefaultMaxSize; |
|
185 repository->Get( KMmsEngineMaximumSendSize, maxSize ); |
|
186 iMaxMmsSize = maxSize; |
|
187 |
|
188 //Fetch and set creation mode |
|
189 TInt creationMode = EMmsCreationModeRestricted; |
|
190 repository->Get(KMmsEngineCreationMode, creationMode); |
|
191 iCreationMode = creationMode; |
|
192 |
|
193 CleanupStack::PopAndDestroy(repository); |
|
194 ); |
165 PRINT ( _L("End CCsPreviewPluginHandler::ConstructL") ); |
195 PRINT ( _L("End CCsPreviewPluginHandler::ConstructL") ); |
166 } |
196 } |
167 |
197 |
168 // ---------------------------------------------------------------------------- |
198 // ---------------------------------------------------------------------------- |
169 // CCsPreviewPluginHandler::CCsPreviewPluginHandler |
199 // CCsPreviewPluginHandler::CCsPreviewPluginHandler |
257 { |
287 { |
258 PRINT ( _L("Enter CCsPreviewPluginHandler::HandleEvent for loop started.") ); |
288 PRINT ( _L("Enter CCsPreviewPluginHandler::HandleEvent for loop started.") ); |
259 |
289 |
260 TInt msgId = entry.Id(); |
290 TInt msgId = entry.Id(); |
261 |
291 |
262 //check if the message is already parsed |
292 // check if the msg is already under processing Or processed |
263 RSqlStatement sqlSelectStmt; |
293 if( EPreviewMsgNotProcessed != msgProcessingState(msgId) ) |
264 CleanupClosePushL(sqlSelectStmt); |
294 { |
265 sqlSelectStmt.PrepareL(iSqlDb,KSelectMsgParsedStmt); |
295 // skip processing this event for the given message |
266 TInt messageIdIndex = sqlSelectStmt.ParameterIndex( |
296 continue; |
267 _L(":message_id")); |
297 } |
268 |
298 else |
269 User::LeaveIfError(sqlSelectStmt.BindInt(messageIdIndex, msgId)); |
299 { |
270 |
300 // start processing message, set flag |
271 if (sqlSelectStmt.Next() == KSqlAtRow) |
301 setMsgProcessingState(msgId, EPreviewMsgProcessing); |
272 { |
302 } |
273 TInt parsedColIndex = sqlSelectStmt.ColumnIndex( |
|
274 _L("msg_parsed")); |
|
275 TInt msgParsed = sqlSelectStmt.ColumnInt(parsedColIndex); |
|
276 //if message alresdy parsed, move to next message. |
|
277 if (msgParsed) |
|
278 { |
|
279 CleanupStack::PopAndDestroy(&sqlSelectStmt); |
|
280 continue; |
|
281 } |
|
282 } |
|
283 CleanupStack::PopAndDestroy(&sqlSelectStmt); |
|
284 |
303 |
285 // update db with message preview data |
304 // update db with message preview data |
286 RSqlStatement sqlInsertStmt; |
305 RSqlStatement sqlInsertStmt; |
287 CleanupClosePushL(sqlInsertStmt); |
306 CleanupClosePushL(sqlInsertStmt); |
288 sqlInsertStmt.PrepareL(iSqlDb, KSqlInsertStmt); |
307 sqlInsertStmt.PrepareL(iSqlDb, KSqlInsertStmt); |
501 |
526 |
502 //execute the statent |
527 //execute the statent |
503 User::LeaveIfError(sqlInsertStmt.Exec()); |
528 User::LeaveIfError(sqlInsertStmt.Exec()); |
504 |
529 |
505 CleanupStack::PopAndDestroy(2,&sqlInsertStmt);//sqlInsertStmt,previewIconStream |
530 CleanupStack::PopAndDestroy(2,&sqlInsertStmt);//sqlInsertStmt,previewIconStream |
|
531 } |
|
532 |
|
533 TBool CCsPreviewPluginHandler::ValidateMsgForForward(CUniDataModel* aUniDataModel) |
|
534 { |
|
535 TBool retValue = ETrue; |
|
536 |
|
537 //1. Check the slide count more than 1 |
|
538 if (aUniDataModel->SmilModel().SlideCount() > 1) |
|
539 { |
|
540 retValue = EFalse; |
|
541 return retValue; |
|
542 } |
|
543 |
|
544 //2. message sixe check |
|
545 //Fetch and set max mms composition size |
|
546 if (iMmsMtm->MessageSize() > iMaxMmsSize) |
|
547 { |
|
548 retValue = EFalse; |
|
549 return retValue; |
|
550 } |
|
551 |
|
552 //3. If there is restricted content then return false |
|
553 RArray<TMsvAttachmentId>* pathList = GetSlideAttachmentIds( |
|
554 0, |
|
555 aUniDataModel); |
|
556 |
|
557 CleanupStack::PushL(pathList); |
|
558 |
|
559 for (int i = 0; i < pathList->Count(); i++) |
|
560 { |
|
561 TMsvAttachmentId aId = (*pathList)[i]; |
|
562 CMsvStore * store = iMmsMtm->Entry().ReadStoreL(); |
|
563 CleanupStack::PushL(store); |
|
564 MMsvAttachmentManager& attachMan = store->AttachmentManagerL(); |
|
565 RFile fileHandle = attachMan.GetAttachmentFileL(aId); |
|
566 //close the store |
|
567 CleanupStack::PopAndDestroy(store); |
|
568 |
|
569 if (CheckModeForInsertL(fileHandle) != EInsertSuccess) |
|
570 { |
|
571 retValue = EFalse; |
|
572 break; |
|
573 } |
|
574 } |
|
575 |
|
576 if (retValue == EFalse) |
|
577 { |
|
578 CleanupStack::PopAndDestroy(pathList); |
|
579 return retValue; |
|
580 } |
|
581 |
|
582 CleanupStack::Pop(pathList); |
|
583 delete pathList; |
|
584 pathList = NULL; |
|
585 |
|
586 //4. check the same case for all attachments |
|
587 pathList = GetAttachmentIdList(aUniDataModel); |
|
588 CleanupStack::PushL(pathList); |
|
589 |
|
590 for (int i = 0; i < pathList->Count(); i++) |
|
591 { |
|
592 TMsvAttachmentId aId = (*pathList)[i]; |
|
593 CMsvStore * store = iMmsMtm->Entry().ReadStoreL(); |
|
594 CleanupStack::PushL(store); |
|
595 MMsvAttachmentManager& attachMan = store->AttachmentManagerL(); |
|
596 RFile fileHandle = attachMan.GetAttachmentFileL(aId); |
|
597 //close the store |
|
598 CleanupStack::PopAndDestroy(store); |
|
599 |
|
600 if (CheckModeForInsertL(fileHandle) != EInsertSuccess) |
|
601 { |
|
602 retValue = EFalse; |
|
603 break; |
|
604 } |
|
605 } |
|
606 |
|
607 CleanupStack::PopAndDestroy(pathList); |
|
608 return retValue; |
|
609 } |
|
610 |
|
611 RArray<TMsvAttachmentId>* |
|
612 CCsPreviewPluginHandler::GetSlideAttachmentIds(TInt aSlideNum, |
|
613 CUniDataModel* aUniDataModel) |
|
614 { |
|
615 TInt slideObjectCount = |
|
616 aUniDataModel->SmilModel().SlideObjectCount(aSlideNum); |
|
617 |
|
618 RArray<TMsvAttachmentId> *attachmentIdList = new (ELeave) RArray< |
|
619 TMsvAttachmentId> (); |
|
620 for (TInt i = 0; i < slideObjectCount; i++) |
|
621 { |
|
622 CUniObject *obj = |
|
623 aUniDataModel->SmilModel().GetObjectByIndex(aSlideNum, i); |
|
624 attachmentIdList->Append(obj->AttachmentId()); |
|
625 } |
|
626 return attachmentIdList; |
|
627 } |
|
628 |
|
629 RArray<TMsvAttachmentId>* |
|
630 CCsPreviewPluginHandler::GetAttachmentIdList(CUniDataModel* aUniDataModel) |
|
631 { |
|
632 TInt attcount = aUniDataModel->AttachmentList().Count(); |
|
633 RArray<TMsvAttachmentId> *attachmentIdList = new (ELeave) RArray< |
|
634 TMsvAttachmentId> (); |
|
635 |
|
636 for (TInt i = 0; i < attcount; i++) |
|
637 { |
|
638 CUniObject *obj = aUniDataModel->AttachmentList().GetByIndex(i); |
|
639 |
|
640 attachmentIdList->AppendL(obj->AttachmentId()); |
|
641 } |
|
642 return attachmentIdList; |
|
643 } |
|
644 |
|
645 TInt CCsPreviewPluginHandler::CheckModeForInsertL(RFile aFileHandle) |
|
646 { |
|
647 CleanupClosePushL(aFileHandle); |
|
648 |
|
649 CMmsConformance* mmsConformance = CMmsConformance::NewL(); |
|
650 mmsConformance->CheckCharacterSet(EFalse); |
|
651 |
|
652 CleanupStack::PushL(mmsConformance); |
|
653 |
|
654 CMsgMediaResolver* mediaResolver = CMsgMediaResolver::NewL(); |
|
655 mediaResolver->SetCharacterSetRecognition(EFalse); |
|
656 |
|
657 CleanupStack::PushL(mediaResolver); |
|
658 |
|
659 CMsgMediaInfo* info = mediaResolver->CreateMediaInfoL(aFileHandle); |
|
660 mediaResolver->ParseInfoDetailsL(info, aFileHandle); |
|
661 |
|
662 TMmsConformance conformance = mmsConformance->MediaConformance(*info); |
|
663 iConfStatus = conformance.iConfStatus; |
|
664 |
|
665 CleanupStack::PopAndDestroy(3); |
|
666 |
|
667 // In "free" mode user can insert images that are larger by dimensions than allowed by conformance |
|
668 if (iCreationMode != EMmsCreationModeRestricted) |
|
669 { |
|
670 TInt i = EMmsConfNokFreeModeOnly | EMmsConfNokScalingNeeded |
|
671 | EMmsConfNokTooBig; |
|
672 TInt j = ~ (EMmsConfNokFreeModeOnly | EMmsConfNokScalingNeeded |
|
673 | EMmsConfNokTooBig); |
|
674 |
|
675 // If user answers yes to Guided mode confirmation query he/she moves to free mode |
|
676 if ( (iConfStatus & i) && ! (iConfStatus & j)) |
|
677 { |
|
678 if (iCreationMode == EMmsCreationModeFree || info->Protection() |
|
679 & EFileProtSuperDistributable) |
|
680 { |
|
681 // SuperDistribution not checked here |
|
682 // Mask "FreeModeOnly" and "ScalingNeeded" away in free mode |
|
683 iConfStatus &= ~EMmsConfNokFreeModeOnly; |
|
684 iConfStatus &= ~EMmsConfNokScalingNeeded; |
|
685 } |
|
686 else |
|
687 { |
|
688 delete info; |
|
689 //query not accepted. Stop insertion. |
|
690 return EInsertQueryAbort; |
|
691 } |
|
692 } |
|
693 } |
|
694 else if (iConfStatus & EMmsConfNokDRM || iConfStatus |
|
695 & EMmsConfNokNotEnoughInfo || iConfStatus & EMmsConfNokNotSupported |
|
696 || iConfStatus & EMmsConfNokFreeModeOnly || iConfStatus |
|
697 & EMmsConfNokCorrupt) |
|
698 { |
|
699 delete info; |
|
700 return EInsertNotSupported; |
|
701 } |
|
702 |
|
703 delete info; |
|
704 return EInsertSuccess; |
506 } |
705 } |
507 |
706 |
508 //----------------------------------------------------------------------------- |
707 //----------------------------------------------------------------------------- |
509 // CCsPreviewPluginHandler::CompareByRequestId |
708 // CCsPreviewPluginHandler::CompareByRequestId |
510 // Compare to conversation entry object based on Entry Ids |
709 // Compare to conversation entry object based on Entry Ids |
560 void CCsPreviewPluginHandler::GetThumbNailL(TMsvAttachmentId attachmentId, |
759 void CCsPreviewPluginHandler::GetThumbNailL(TMsvAttachmentId attachmentId, |
561 TDesC8& mimeType, TMsvId msgId) |
760 TDesC8& mimeType, TMsvId msgId) |
562 { |
761 { |
563 //Scale the image |
762 //Scale the image |
564 iThumbnailManager->SetFlagsL(CThumbnailManager::ECropToAspectRatio); |
763 iThumbnailManager->SetFlagsL(CThumbnailManager::ECropToAspectRatio); |
565 // Preferred size is 100x100 (or less) |
764 |
566 iThumbnailManager->SetThumbnailSizeL(TSize(100, 100)); |
765 //TODO replace with hb-param-graphic-size-image-portrait * value of un in pixcels |
|
766 iThumbnailManager->SetThumbnailSizeL(TSize(63.65, 63.65)); |
|
767 |
567 //optimize for performace |
768 //optimize for performace |
568 iThumbnailManager->SetQualityPreferenceL( |
769 iThumbnailManager->SetQualityPreferenceL( |
569 CThumbnailManager::EOptimizeForPerformance); |
770 CThumbnailManager::EOptimizeForPerformance); |
570 |
771 |
571 // Create Thumbnail object source representing a path to a file |
772 // Create Thumbnail object source representing a path to a file |
590 iThumbnailRequestArray.Append(reqObject); |
791 iThumbnailRequestArray.Append(reqObject); |
591 |
792 |
592 CleanupStack::PopAndDestroy(4, mimeInfo);//mimeInfo,store,file,source |
793 CleanupStack::PopAndDestroy(4, mimeInfo);//mimeInfo,store,file,source |
593 } |
794 } |
594 |
795 |
|
796 // ----------------------------------------------------------------------------- |
|
797 // CCsPreviewPluginHandler::msgProcessingState |
|
798 // |
|
799 // ----------------------------------------------------------------------------- |
|
800 // |
|
801 TInt CCsPreviewPluginHandler::msgProcessingState(TMsvId aMsgId) |
|
802 { |
|
803 TInt retState = EPreviewMsgNotProcessed; |
|
804 |
|
805 // sql-statement to check if msg's under processing flag is set or not |
|
806 RSqlStatement sqlSelectStmt; |
|
807 CleanupClosePushL(sqlSelectStmt); |
|
808 sqlSelectStmt.PrepareL(iSqlDb,KSelectProcessingStateStmt); |
|
809 |
|
810 TInt msgIdIndex = sqlSelectStmt.ParameterIndex(_L(":message_id")); |
|
811 User::LeaveIfError(sqlSelectStmt.BindInt(msgIdIndex, aMsgId)); |
|
812 |
|
813 // read the flag |
|
814 TInt msgProcessingStateIndex = sqlSelectStmt.ColumnIndex(_L("msg_processingstate")); |
|
815 if (sqlSelectStmt.Next() == KSqlAtRow) |
|
816 { |
|
817 retState = static_cast<TInt>(sqlSelectStmt.ColumnInt(msgProcessingStateIndex)); |
|
818 } |
|
819 else |
|
820 { |
|
821 // this is first event for this msgid, hence record doesn't exist |
|
822 // create an empty record, so that we can set & use flags |
|
823 RSqlStatement sqlBasicInsertStmt; |
|
824 CleanupClosePushL(sqlBasicInsertStmt); |
|
825 sqlBasicInsertStmt.PrepareL(iSqlDb, KSqlBasicInsertStmt); |
|
826 TInt index_msgid = sqlBasicInsertStmt.ParameterIndex(_L(":message_id")); |
|
827 User::LeaveIfError(sqlBasicInsertStmt.BindInt(index_msgid, aMsgId)); |
|
828 User::LeaveIfError(sqlBasicInsertStmt.Exec()); |
|
829 CleanupStack::PopAndDestroy(&sqlBasicInsertStmt); |
|
830 } |
|
831 // cleanup |
|
832 CleanupStack::PopAndDestroy(&sqlSelectStmt); |
|
833 return retState; |
|
834 } |
|
835 |
|
836 // ----------------------------------------------------------------------------- |
|
837 // CCsPreviewPluginHandler::setMsgProcessingState |
|
838 // |
|
839 // ----------------------------------------------------------------------------- |
|
840 // |
|
841 void CCsPreviewPluginHandler::setMsgProcessingState(TMsvId aMsgId, TInt aState) |
|
842 { |
|
843 // sql-statment to set/reset msg's under processing flag |
|
844 RSqlStatement sqlUpdateStmt; |
|
845 CleanupClosePushL(sqlUpdateStmt); |
|
846 sqlUpdateStmt.PrepareL(iSqlDb, KSqlUpdateProcessingStateStmt); |
|
847 |
|
848 TInt msgIdIndex = sqlUpdateStmt.ParameterIndex(_L(":message_id")); |
|
849 User::LeaveIfError(sqlUpdateStmt.BindInt(msgIdIndex, aMsgId)); |
|
850 |
|
851 // bind data |
|
852 TInt msgProcessingStateIndex = sqlUpdateStmt.ParameterIndex(_L(":msg_processingstate")); |
|
853 User::LeaveIfError(sqlUpdateStmt.BindInt(msgProcessingStateIndex, aState)); |
|
854 |
|
855 // execute the statement |
|
856 User::LeaveIfError(sqlUpdateStmt.Exec()); |
|
857 // cleanup |
|
858 CleanupStack::PopAndDestroy(&sqlUpdateStmt); |
|
859 } |
|
860 |
595 // End of file |
861 // End of file |
596 |
862 |