messagingapp/msgappfw/plugins/previewplugin/src/ccspreviewpluginhandler.cpp
branchGCC_SURGE
changeset 47 5b14749788d7
parent 44 36f374c67aa8
child 52 12db4185673b
equal deleted inserted replaced
35:a32b19fb291e 47:5b14749788d7
    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;
       
    58 //Preview thumbnail size
       
    59 const TInt KWidth = 9.5 * 6.7;
       
    60 const TInt KHeight = 9.5 * 6.7;
    45 
    61 
    46 // NOTE:- DRAFTS ENTRIES ARE NOT HANDLED IN THE PLUGIN
    62 // NOTE:- DRAFTS ENTRIES ARE NOT HANDLED IN THE PLUGIN
    47 
    63 
    48 // ============================== MEMBER FUNCTIONS ============================
    64 // ============================== MEMBER FUNCTIONS ============================
    49 // ----------------------------------------------------------------------------
    65 // ----------------------------------------------------------------------------
   160     else
   176     else
   161     {
   177     {
   162         User::LeaveIfError(error);
   178         User::LeaveIfError(error);
   163     }
   179     }
   164 
   180 
       
   181     //get the max size of mms from the repository
       
   182     TRAP_IGNORE(
       
   183             CRepository* repository = CRepository::NewL(KCRUidMmsEngine);
       
   184             CleanupStack::PushL(repository);
       
   185 
       
   186             //Fetch and set max mms composition size
       
   187             TInt maxSize = KDefaultMaxSize;
       
   188             repository->Get( KMmsEngineMaximumSendSize, maxSize );
       
   189             iMaxMmsSize = maxSize;
       
   190 
       
   191             //Fetch and set creation mode
       
   192             TInt creationMode = EMmsCreationModeRestricted;
       
   193             repository->Get(KMmsEngineCreationMode, creationMode);
       
   194             iCreationMode = creationMode;
       
   195 
       
   196             CleanupStack::PopAndDestroy(repository);
       
   197     );
   165     PRINT ( _L("End CCsPreviewPluginHandler::ConstructL") );
   198     PRINT ( _L("End CCsPreviewPluginHandler::ConstructL") );
   166 }
   199 }
   167 
   200 
   168 // ----------------------------------------------------------------------------
   201 // ----------------------------------------------------------------------------
   169 // CCsPreviewPluginHandler::CCsPreviewPluginHandler
   202 // CCsPreviewPluginHandler::CCsPreviewPluginHandler
   257         {
   290         {
   258             PRINT ( _L("Enter CCsPreviewPluginHandler::HandleEvent for loop started.") );
   291             PRINT ( _L("Enter CCsPreviewPluginHandler::HandleEvent for loop started.") );
   259 
   292 
   260             TInt msgId = entry.Id();
   293             TInt msgId = entry.Id();
   261 
   294 
   262             //check if the message is already parsed
   295             // check if the msg is already under processing Or processed
   263             RSqlStatement sqlSelectStmt;
   296             if( EPreviewMsgNotProcessed != msgProcessingState(msgId) )
   264             CleanupClosePushL(sqlSelectStmt);
   297             {
   265             sqlSelectStmt.PrepareL(iSqlDb,KSelectMsgParsedStmt);
   298                 // skip processing this event for the given message
   266             TInt messageIdIndex = sqlSelectStmt.ParameterIndex(
   299                 continue;
   267                 _L(":message_id"));
   300             }
   268 
   301             else
   269             User::LeaveIfError(sqlSelectStmt.BindInt(messageIdIndex, msgId));
   302             {
   270 
   303                 // start processing message, set flag
   271             if (sqlSelectStmt.Next() == KSqlAtRow)
   304                 setMsgProcessingState(msgId, EPreviewMsgProcessing);
   272             {
   305             }
   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 
   306 
   285             // update db with message preview data
   307             // update db with message preview data
   286             RSqlStatement sqlInsertStmt;
   308             RSqlStatement sqlInsertStmt;
   287             CleanupClosePushL(sqlInsertStmt);
   309             CleanupClosePushL(sqlInsertStmt);
   288             sqlInsertStmt.PrepareL(iSqlDb, KSqlInsertStmt);
   310             sqlInsertStmt.PrepareL(iSqlDb, KSqlInsertStmt);
   299             //msg property
   321             //msg property
   300             TInt msgProperty = 0;
   322             TInt msgProperty = 0;
   301             if (iUniDataModel->AttachmentList().Count() > 0)
   323             if (iUniDataModel->AttachmentList().Count() > 0)
   302             {
   324             {
   303                 msgProperty |= EPreviewAttachment;
   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;
   304             }
   333             }
   305 
   334 
   306             TPtrC videoPath;
   335             TPtrC videoPath;
   307             TPtrC imagePath;
   336             TPtrC imagePath;
   308            
   337            
   319                         iUniDataModel->SmilModel().SlideObjectCount(i);
   348                         iUniDataModel->SmilModel().SlideObjectCount(i);
   320                 for (int j = 0; j < slideobjcount; j++)
   349                 for (int j = 0; j < slideobjcount; j++)
   321                 {
   350                 {
   322                     CUniObject *obj =
   351                     CUniObject *obj =
   323                             iUniDataModel->SmilModel(). GetObjectByIndex(i, j);
   352                             iUniDataModel->SmilModel(). GetObjectByIndex(i, j);
       
   353                     CMsgMediaInfo *mediaInfo = obj->MediaInfo();
   324 
   354 
   325                     TPtrC8 mimetype = obj->MimeType();
   355                     TPtrC8 mimetype = obj->MimeType();
   326                     TMsvAttachmentId attachId = obj->AttachmentId();
   356                     TMsvAttachmentId attachId = obj->AttachmentId();
   327 
   357 
   328                     //bodytext
   358                     //bodytext
   333                         BindBodyText(sqlInsertStmt, attachId);
   363                         BindBodyText(sqlInsertStmt, attachId);
   334                         isBodyTextSet = ETrue;
   364                         isBodyTextSet = ETrue;
   335                     }
   365                     }
   336 
   366 
   337                     //image parsing
   367                     //image parsing
   338                     if (!isImageSet && (mimetype.Find(_L8("image"))
   368                     if (!isVideoSet && !isImageSet && (mimetype.Find(_L8("image"))
   339                             != KErrNotFound))
   369                             != KErrNotFound))
   340                     {
   370                     {
   341                         //get thumbnail for this image
   371                         //get thumbnail for this image
   342                         GetThumbNailL(attachId, mimetype, msgId);
       
   343                         isImageSet = ETrue;
   372                         isImageSet = ETrue;
   344                         imagePath.Set(obj->MediaInfo()->FullFilePath());
   373                         imagePath.Set(mediaInfo->FullFilePath());
   345                         msgProperty |= EPreviewImage;
   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                         }
   346                     }
   392                     }
   347 
   393 
   348                     //audio content
   394                     //audio content
   349                     if (!isAudioSet && (mimetype.Find(_L8("audio"))
   395                     if (!isVideoSet && !isAudioSet && (mimetype.Find(_L8("audio"))
   350                             != KErrNotFound))
   396                             != KErrNotFound))
   351                     {
   397                     {
   352                         isAudioSet = ETrue;
   398                         isAudioSet = ETrue;
   353                         msgProperty |= EPreviewAudio;
   399                         msgProperty |= EPreviewAudio;
       
   400                         if (EFileProtNoProtection != mediaInfo->Protection())
       
   401                         {
       
   402                             msgProperty |= EPreviewProtectedAudio;
       
   403                         }
       
   404                         if (mediaInfo->Corrupt())
       
   405                         {
       
   406                             msgProperty |= EPreviewCorruptedAudio;
       
   407                         }
   354                     }
   408                     }
   355 
   409 
   356                     //video content
   410                     //video content
   357                     if (!isVideoSet && (mimetype.Find(_L8("video"))
   411                     if (!( isImageSet || isAudioSet) && !isVideoSet && (mimetype.Find(_L8("video"))
   358                             != KErrNotFound))
   412                             != KErrNotFound))
   359                     {
   413                     {
   360                         videoPath.Set(obj->MediaInfo()->FullFilePath());
   414                         videoPath.Set(mediaInfo->FullFilePath());
   361                         isVideoSet = ETrue;
   415                         isVideoSet = ETrue;
   362                         msgProperty |= EPreviewVideo;
   416                         msgProperty |= EPreviewVideo;
       
   417                         if (EFileProtNoProtection != mediaInfo->Protection())
       
   418                         {
       
   419                             msgProperty |= EPreviewProtectedVideo;
       
   420                         }
       
   421                         if (mediaInfo->Corrupt())
       
   422                         {
       
   423                             msgProperty |= EPreviewCorruptedVideo;
       
   424                         }
   363                     }
   425                     }
   364                 }
   426                 }
   365             }
   427             }
   366 
   428 
   367             //set preview path
   429             //set preview path
   391             TInt msgPropertyIndex = sqlInsertStmt.ParameterIndex(_L(
   453             TInt msgPropertyIndex = sqlInsertStmt.ParameterIndex(_L(
   392                 ":msg_property"));
   454                 ":msg_property"));
   393             User::LeaveIfError(sqlInsertStmt.BindInt(msgPropertyIndex,
   455             User::LeaveIfError(sqlInsertStmt.BindInt(msgPropertyIndex,
   394                 msgProperty));
   456                 msgProperty));
   395 
   457 
   396             //msg-parsed
   458             //msg_processingstate
   397             TInt msgParsedIndex = sqlInsertStmt.ParameterIndex(
   459             TInt msgProcessingStateIndex = sqlInsertStmt.ParameterIndex(_L(":msg_processingstate"));
   398                 _L(":msg_parsed"));
   460             User::LeaveIfError(sqlInsertStmt.BindInt(msgProcessingStateIndex, EPreviewMsgProcessed));
   399             User::LeaveIfError(sqlInsertStmt.BindInt(msgParsedIndex, 1)); // 1 as true
       
   400 
   461 
   401             //execute sql stament
   462             //execute sql stament
   402             User::LeaveIfError(sqlInsertStmt.Exec());
   463             User::LeaveIfError(sqlInsertStmt.Exec());
   403 
   464 
   404             //cleanup
   465             //cleanup
   501 
   562 
   502     //execute the statent
   563     //execute the statent
   503     User::LeaveIfError(sqlInsertStmt.Exec());
   564     User::LeaveIfError(sqlInsertStmt.Exec());
   504 
   565 
   505     CleanupStack::PopAndDestroy(2,&sqlInsertStmt);//sqlInsertStmt,previewIconStream
   566     CleanupStack::PopAndDestroy(2,&sqlInsertStmt);//sqlInsertStmt,previewIconStream
       
   567 }
       
   568 
       
   569 TBool CCsPreviewPluginHandler::ValidateMsgForForward(CUniDataModel* aUniDataModel)
       
   570 {
       
   571     TBool retValue = ETrue;
       
   572 
       
   573     //1. Check the slide count more than 1
       
   574     if (aUniDataModel->SmilModel().SlideCount() > 1)
       
   575     {
       
   576         retValue = EFalse;
       
   577         return retValue;
       
   578     }
       
   579 
       
   580     //2. message sixe check
       
   581     //Fetch and set max mms composition size
       
   582     if (iMmsMtm->MessageSize() > iMaxMmsSize)
       
   583     {
       
   584         retValue = EFalse;
       
   585         return retValue;
       
   586     }
       
   587 
       
   588     //3. If there is restricted content then return false
       
   589     RArray<TMsvAttachmentId>* pathList = GetSlideAttachmentIds(
       
   590             0, 
       
   591             aUniDataModel);
       
   592     
       
   593     CleanupStack::PushL(pathList);
       
   594 
       
   595     for (int i = 0; i < pathList->Count(); i++)
       
   596     {
       
   597         TMsvAttachmentId aId = (*pathList)[i];
       
   598         CMsvStore * store = iMmsMtm->Entry().ReadStoreL();
       
   599         CleanupStack::PushL(store);
       
   600         MMsvAttachmentManager& attachMan = store->AttachmentManagerL();
       
   601         RFile fileHandle = attachMan.GetAttachmentFileL(aId);
       
   602         //close the store
       
   603         CleanupStack::PopAndDestroy(store);
       
   604 
       
   605         if (CheckModeForInsertL(fileHandle) != EInsertSuccess)
       
   606         {
       
   607             retValue = EFalse;
       
   608             break;
       
   609         }
       
   610     }
       
   611 
       
   612     if (retValue == EFalse)
       
   613     {
       
   614         CleanupStack::PopAndDestroy(pathList);
       
   615         return retValue;
       
   616     }
       
   617 
       
   618     CleanupStack::Pop(pathList);
       
   619     delete pathList;
       
   620     pathList = NULL;
       
   621 
       
   622     //4. check the same case for all attachments
       
   623     pathList = GetAttachmentIdList(aUniDataModel);
       
   624     CleanupStack::PushL(pathList);
       
   625 
       
   626     for (int i = 0; i < pathList->Count(); i++)
       
   627     {
       
   628         TMsvAttachmentId aId = (*pathList)[i];
       
   629         CMsvStore * store = iMmsMtm->Entry().ReadStoreL();
       
   630         CleanupStack::PushL(store);
       
   631         MMsvAttachmentManager& attachMan = store->AttachmentManagerL();
       
   632         RFile fileHandle = attachMan.GetAttachmentFileL(aId);
       
   633         //close the store
       
   634         CleanupStack::PopAndDestroy(store);
       
   635         
       
   636         if (CheckModeForInsertL(fileHandle) != EInsertSuccess)
       
   637         {
       
   638             retValue = EFalse;
       
   639             break;
       
   640         }
       
   641     }
       
   642 
       
   643     CleanupStack::PopAndDestroy(pathList);
       
   644     return retValue;
       
   645 }
       
   646 
       
   647 RArray<TMsvAttachmentId>*
       
   648 CCsPreviewPluginHandler::GetSlideAttachmentIds(TInt aSlideNum,
       
   649                                         CUniDataModel* aUniDataModel)
       
   650 {
       
   651     TInt slideObjectCount =
       
   652             aUniDataModel->SmilModel().SlideObjectCount(aSlideNum);
       
   653 
       
   654     RArray<TMsvAttachmentId> *attachmentIdList = new (ELeave) RArray<
       
   655             TMsvAttachmentId> ();
       
   656     for (TInt i = 0; i < slideObjectCount; i++)
       
   657     {
       
   658         CUniObject *obj =
       
   659                 aUniDataModel->SmilModel().GetObjectByIndex(aSlideNum, i);
       
   660         attachmentIdList->Append(obj->AttachmentId());
       
   661     }
       
   662     return attachmentIdList;
       
   663 }
       
   664 
       
   665 RArray<TMsvAttachmentId>*
       
   666 CCsPreviewPluginHandler::GetAttachmentIdList(CUniDataModel* aUniDataModel)
       
   667 {
       
   668     TInt attcount = aUniDataModel->AttachmentList().Count();
       
   669     RArray<TMsvAttachmentId> *attachmentIdList = new (ELeave) RArray<
       
   670             TMsvAttachmentId> ();
       
   671 
       
   672     for (TInt i = 0; i < attcount; i++)
       
   673     {
       
   674         CUniObject *obj = aUniDataModel->AttachmentList().GetByIndex(i);
       
   675 
       
   676         attachmentIdList->AppendL(obj->AttachmentId());
       
   677     }
       
   678     return attachmentIdList;
       
   679 }
       
   680 
       
   681 TInt CCsPreviewPluginHandler::CheckModeForInsertL(RFile aFileHandle)
       
   682 {
       
   683     CleanupClosePushL(aFileHandle);
       
   684 
       
   685     CMmsConformance* mmsConformance = CMmsConformance::NewL();
       
   686     mmsConformance->CheckCharacterSet(EFalse);
       
   687 
       
   688     CleanupStack::PushL(mmsConformance);
       
   689 
       
   690     CMsgMediaResolver* mediaResolver = CMsgMediaResolver::NewL();
       
   691     mediaResolver->SetCharacterSetRecognition(EFalse);
       
   692 
       
   693     CleanupStack::PushL(mediaResolver);
       
   694 
       
   695     CMsgMediaInfo* info = mediaResolver->CreateMediaInfoL(aFileHandle);
       
   696     mediaResolver->ParseInfoDetailsL(info, aFileHandle);
       
   697 
       
   698     TMmsConformance conformance = mmsConformance->MediaConformance(*info);
       
   699     iConfStatus = conformance.iConfStatus;
       
   700 
       
   701     CleanupStack::PopAndDestroy(3);
       
   702 
       
   703     // In "free" mode user can insert images that are larger by dimensions than allowed by conformance
       
   704     if (iCreationMode != EMmsCreationModeRestricted)
       
   705     {
       
   706         TInt i = EMmsConfNokFreeModeOnly | EMmsConfNokScalingNeeded
       
   707                 | EMmsConfNokTooBig;
       
   708         TInt j = ~ (EMmsConfNokFreeModeOnly | EMmsConfNokScalingNeeded
       
   709                 | EMmsConfNokTooBig);
       
   710 
       
   711         // If user answers yes to Guided mode confirmation query he/she moves to free mode
       
   712         if ( (iConfStatus & i) && ! (iConfStatus & j))
       
   713         {
       
   714             if (iCreationMode == EMmsCreationModeFree || info->Protection()
       
   715                     & EFileProtSuperDistributable)
       
   716             {
       
   717                 // SuperDistribution not checked here
       
   718                 // Mask "FreeModeOnly" and "ScalingNeeded" away in free mode
       
   719                 iConfStatus &= ~EMmsConfNokFreeModeOnly;
       
   720                 iConfStatus &= ~EMmsConfNokScalingNeeded;
       
   721             }
       
   722             else
       
   723             {
       
   724                 delete info;
       
   725                 //query not accepted. Stop insertion.
       
   726                 return EInsertQueryAbort;
       
   727             }
       
   728         }
       
   729     }
       
   730     else if (iConfStatus & EMmsConfNokDRM || iConfStatus
       
   731             & EMmsConfNokNotEnoughInfo || iConfStatus & EMmsConfNokNotSupported
       
   732             || iConfStatus & EMmsConfNokFreeModeOnly || iConfStatus
       
   733             & EMmsConfNokCorrupt)
       
   734     {
       
   735         delete info;
       
   736         return EInsertNotSupported;
       
   737     }
       
   738 
       
   739     delete info;
       
   740     return EInsertSuccess;
   506 }
   741 }
   507 
   742 
   508 //-----------------------------------------------------------------------------
   743 //-----------------------------------------------------------------------------
   509 // CCsPreviewPluginHandler::CompareByRequestId
   744 // CCsPreviewPluginHandler::CompareByRequestId
   510 // Compare to conversation entry object based on Entry Ids
   745 // Compare to conversation entry object based on Entry Ids
   560 void CCsPreviewPluginHandler::GetThumbNailL(TMsvAttachmentId attachmentId,
   795 void CCsPreviewPluginHandler::GetThumbNailL(TMsvAttachmentId attachmentId,
   561     TDesC8& mimeType, TMsvId msgId)
   796     TDesC8& mimeType, TMsvId msgId)
   562 {
   797 {
   563     //Scale the image
   798     //Scale the image
   564     iThumbnailManager->SetFlagsL(CThumbnailManager::ECropToAspectRatio);
   799     iThumbnailManager->SetFlagsL(CThumbnailManager::ECropToAspectRatio);
   565     // Preferred size is 100x100 (or less)
   800 
   566     iThumbnailManager->SetThumbnailSizeL(TSize(100, 100));
   801     //TODO replace with hb-param-graphic-size-image-portrait * value of un in pixcels
       
   802     iThumbnailManager->SetThumbnailSizeL(TSize(KWidth, KHeight)); 
       
   803     
   567     //optimize for performace
   804     //optimize for performace
   568     iThumbnailManager->SetQualityPreferenceL(
   805     iThumbnailManager->SetQualityPreferenceL(
   569         CThumbnailManager::EOptimizeForPerformance);
   806         CThumbnailManager::EOptimizeForPerformance);
   570 
   807 
   571     // Create Thumbnail object source representing a path to a file
   808     // Create Thumbnail object source representing a path to a file
   590     iThumbnailRequestArray.Append(reqObject);
   827     iThumbnailRequestArray.Append(reqObject);
   591 
   828 
   592     CleanupStack::PopAndDestroy(4, mimeInfo);//mimeInfo,store,file,source
   829     CleanupStack::PopAndDestroy(4, mimeInfo);//mimeInfo,store,file,source
   593 }
   830 }
   594 
   831 
       
   832 // -----------------------------------------------------------------------------
       
   833 // CCsPreviewPluginHandler::msgProcessingState
       
   834 // 
       
   835 // -----------------------------------------------------------------------------
       
   836 //
       
   837 TInt CCsPreviewPluginHandler::msgProcessingState(TMsvId aMsgId)
       
   838 {
       
   839     TInt retState = EPreviewMsgNotProcessed;
       
   840 
       
   841     // sql-statement to check if msg's under processing flag is set or not
       
   842     RSqlStatement sqlSelectStmt;
       
   843     CleanupClosePushL(sqlSelectStmt);
       
   844     sqlSelectStmt.PrepareL(iSqlDb,KSelectProcessingStateStmt);
       
   845 
       
   846     TInt msgIdIndex = sqlSelectStmt.ParameterIndex(_L(":message_id"));
       
   847     User::LeaveIfError(sqlSelectStmt.BindInt(msgIdIndex, aMsgId));
       
   848 
       
   849     // read the flag
       
   850     TInt msgProcessingStateIndex = sqlSelectStmt.ColumnIndex(_L("msg_processingstate"));
       
   851     if (sqlSelectStmt.Next() == KSqlAtRow)
       
   852     {
       
   853          retState = static_cast<TInt>(sqlSelectStmt.ColumnInt(msgProcessingStateIndex));
       
   854     }
       
   855     else
       
   856     {
       
   857         // this is first event for this msgid, hence record doesn't exist
       
   858         // create an empty record, so that we can set & use flags
       
   859         RSqlStatement sqlBasicInsertStmt;
       
   860         CleanupClosePushL(sqlBasicInsertStmt);
       
   861         sqlBasicInsertStmt.PrepareL(iSqlDb, KSqlBasicInsertStmt);
       
   862         TInt index_msgid = sqlBasicInsertStmt.ParameterIndex(_L(":message_id"));
       
   863         User::LeaveIfError(sqlBasicInsertStmt.BindInt(index_msgid, aMsgId));
       
   864         User::LeaveIfError(sqlBasicInsertStmt.Exec());
       
   865         CleanupStack::PopAndDestroy(&sqlBasicInsertStmt);
       
   866     }
       
   867     // cleanup
       
   868     CleanupStack::PopAndDestroy(&sqlSelectStmt);
       
   869     return retState;
       
   870 }
       
   871 
       
   872 // -----------------------------------------------------------------------------
       
   873 // CCsPreviewPluginHandler::setMsgProcessingState
       
   874 // 
       
   875 // -----------------------------------------------------------------------------
       
   876 //
       
   877 void CCsPreviewPluginHandler::setMsgProcessingState(TMsvId aMsgId, TInt aState)
       
   878 {
       
   879     // sql-statment to set/reset msg's under processing flag
       
   880     RSqlStatement sqlUpdateStmt;
       
   881     CleanupClosePushL(sqlUpdateStmt);
       
   882     sqlUpdateStmt.PrepareL(iSqlDb, KSqlUpdateProcessingStateStmt);
       
   883 
       
   884     TInt msgIdIndex = sqlUpdateStmt.ParameterIndex(_L(":message_id"));
       
   885     User::LeaveIfError(sqlUpdateStmt.BindInt(msgIdIndex, aMsgId));
       
   886 
       
   887     // bind data
       
   888     TInt msgProcessingStateIndex = sqlUpdateStmt.ParameterIndex(_L(":msg_processingstate"));
       
   889     User::LeaveIfError(sqlUpdateStmt.BindInt(msgProcessingStateIndex, aState));
       
   890 
       
   891     // execute the statement
       
   892     User::LeaveIfError(sqlUpdateStmt.Exec());
       
   893     // cleanup
       
   894     CleanupStack::PopAndDestroy(&sqlUpdateStmt);
       
   895 }
       
   896 
   595 // End of file
   897 // End of file
   596 
   898