messagingapp/msgui/unifiededitor/src/msgunieditorprocessimageoperation.cpp
changeset 27 e4592d119491
parent 25 84d9eb65b26f
child 47 5b14749788d7
equal deleted inserted replaced
25:84d9eb65b26f 27:e4592d119491
    43 
    43 
    44 #include <msvids.h>
    44 #include <msvids.h>
    45 #include <MmsEngineDomainCRKeys.h>
    45 #include <MmsEngineDomainCRKeys.h>
    46 #include <mmssettingsdefs.h>
    46 #include <mmssettingsdefs.h>
    47 #include <HbMessageBox>
    47 #include <HbMessageBox>
       
    48 #include <HbAction>
    48 #include <mmsconst.h>
    49 #include <mmsconst.h>
    49 
    50 
    50 #include "msgmonitor.h"
    51 #include "msgmonitor.h"
    51 #include "msgunieditorprocessimageoperation.h"
    52 #include "msgunieditorprocessimageoperation.h"
    52 
    53 
    75 //
    76 //
    76 // Factory method.
    77 // Factory method.
    77 // ---------------------------------------------------------
    78 // ---------------------------------------------------------
    78 //
    79 //
    79 CUniEditorProcessImageOperation* CUniEditorProcessImageOperation::NewL(
    80 CUniEditorProcessImageOperation* CUniEditorProcessImageOperation::NewL(
    80     MUniEditorProcessImageOperationObserver &aObserver,
    81     MUniEditorProcessImageOperationObserver &aObserver)
    81     RFs& aFs )
       
    82     {
    82     {
    83     CUniEditorProcessImageOperation* self = new ( ELeave ) 
    83     CUniEditorProcessImageOperation* self = new ( ELeave ) 
    84     CUniEditorProcessImageOperation(aObserver,aFs );
    84                     CUniEditorProcessImageOperation(aObserver);
    85             
    85             
    86     CleanupStack::PushL( self );
    86     CleanupStack::PushL( self );
    87     self->ConstructL();
    87     self->ConstructL();
    88     CleanupStack::Pop( self );
    88     CleanupStack::Pop( self );
    89     
    89     
    93 // ---------------------------------------------------------
    93 // ---------------------------------------------------------
    94 // CUniEditorProcessImageOperation::CUniEditorProcessImageOperation.
    94 // CUniEditorProcessImageOperation::CUniEditorProcessImageOperation.
    95 // ---------------------------------------------------------
    95 // ---------------------------------------------------------
    96 //
    96 //
    97 CUniEditorProcessImageOperation::CUniEditorProcessImageOperation(
    97 CUniEditorProcessImageOperation::CUniEditorProcessImageOperation(
    98     MUniEditorProcessImageOperationObserver &aObserver,
    98     MUniEditorProcessImageOperationObserver &aObserver) 
    99     RFs& aFs ) :    CActive( EPriorityStandard ),
    99     :    CActive( EPriorityStandard ),
   100     iObserver(aObserver),
   100          iObserver(aObserver)
   101     iFs( aFs )
       
   102     {
   101     {
   103             CActiveScheduler::Add( this );
   102             CActiveScheduler::Add( this );
   104     }
   103     }
   105 
   104 
   106 // ---------------------------------------------------------
   105 // ---------------------------------------------------------
   109 // 2nd phase constructor.
   108 // 2nd phase constructor.
   110 // ---------------------------------------------------------
   109 // ---------------------------------------------------------
   111 //
   110 //
   112 void CUniEditorProcessImageOperation::ConstructL()
   111 void CUniEditorProcessImageOperation::ConstructL()
   113     {
   112     {
       
   113     User::LeaveIfError(iFs.Connect());
       
   114     iFs.ShareProtected();            
   114 
   115 
   115     TInt featureBitmask( 0 );
   116     TInt featureBitmask( 0 );
   116     
   117     
   117     CRepository* repository = CRepository::NewL( KCRUidMuiuVariation );
   118     CRepository* repository = CRepository::NewL( KCRUidMuiuVariation );
   118     repository->Get( KMuiuMmsFeatures, featureBitmask );
   119     repository->Get( KMuiuMmsFeatures, featureBitmask );
   162     iNewImageInfo = NULL;
   163     iNewImageInfo = NULL;
   163     iNewImageFile.Close();
   164     iNewImageFile.Close();
   164     delete iImageProcessor;
   165     delete iImageProcessor;
   165 
   166 
   166     //Since iFs doesnot have recursive dir deletion use file manager
   167     //Since iFs doesnot have recursive dir deletion use file manager
   167     CFileMan *fm = CFileMan::NewL(iFs);
   168     TRAP_IGNORE(
   168     fm->RmDir(KTempFilePath);
   169         CFileMan *fm = CFileMan::NewL(iFs);
   169     delete fm;
   170         fm->RmDir(KTempFilePath);
       
   171         delete fm;
       
   172         );
       
   173 
       
   174     iFs.Close();
   170     }
   175     }
   171 
   176 
   172 // ---------------------------------------------------------
   177 // ---------------------------------------------------------
   173 // CUniEditorProcessImageOperation::Process
   178 // CUniEditorProcessImageOperation::Process
   174 // ---------------------------------------------------------
   179 // ---------------------------------------------------------
   267         }
   272         }
   268     else
   273     else
   269         {
   274         {
   270         iOperationState = EUniProcessImgProcess;
   275         iOperationState = EUniProcessImgProcess;
   271         }
   276         }
   272     CompleteSelf( KErrNone );
   277     checkLargeImage();
   273     }
   278     }
   274   
   279   
   275 // ---------------------------------------------------------
   280 // ---------------------------------------------------------
   276 // CUniEditorProcessImageOperation::DoStartProcessL
   281 // CUniEditorProcessImageOperation::DoStartProcessL
   277 // ---------------------------------------------------------
   282 // ---------------------------------------------------------
   310     mediaResolver->SetCharacterSetRecognition( EFalse );    
   315     mediaResolver->SetCharacterSetRecognition( EFalse );    
   311     CleanupStack::PushL(mediaResolver);
   316     CleanupStack::PushL(mediaResolver);
   312     
   317     
   313     //Delete the previous object if present
   318     //Delete the previous object if present
   314     delete iNewImageInfo;
   319     delete iNewImageInfo;
       
   320     iNewImageInfo = NULL;
   315     iNewImageInfo = static_cast<CMsgImageInfo*>(mediaResolver->CreateMediaInfoL( iNewImageFile ) );
   321     iNewImageInfo = static_cast<CMsgImageInfo*>(mediaResolver->CreateMediaInfoL( iNewImageFile ) );
   316     
   322     
   317     mediaResolver->ParseInfoDetailsL( iNewImageInfo, iNewImageFile );
   323     mediaResolver->ParseInfoDetailsL( iNewImageInfo, iNewImageFile );
   318 
   324 
   319     iOperationState = EUniProcessImgReady;
   325     iOperationState = EUniProcessImgReady;
   406 //
   412 //
   407 TBool CUniEditorProcessImageOperation::CheckNeedToProcess()
   413 TBool CUniEditorProcessImageOperation::CheckNeedToProcess()
   408     {
   414     {
   409     iProcessMethod = EUniProcessImgMethodNone;
   415     iProcessMethod = EUniProcessImgMethodNone;
   410     
   416     
   411     CMmsConformance* mmsConformance = CMmsConformance::NewL();
   417     CMmsConformance* mmsConformance = NULL;
   412     mmsConformance->CheckCharacterSet( EFalse );
   418     TRAP_IGNORE(mmsConformance = CMmsConformance::NewL());
   413 
   419     TMmsConformance conformance;
   414     TMmsConformance conformance = 
   420     if(mmsConformance)
   415         mmsConformance->MediaConformance( *iImageInfo );
   421     {
       
   422         mmsConformance->CheckCharacterSet( EFalse );
       
   423         conformance = mmsConformance->MediaConformance( *iImageInfo );
       
   424     }
   416     
   425     
   417     if ( conformance.iCanAdapt == EFalse )
   426     if ( conformance.iCanAdapt == EFalse )
   418         {
   427         {
   419         return EFalse;
   428         return EFalse;
   420         }
   429         }
   475         // into the message and scaling is not performed. Also current message size
   484         // into the message and scaling is not performed. Also current message size
   476         // is under comression margin.
   485         // is under comression margin.
   477         iProcessMethod |= EUniProcessImgMethodCompress;
   486         iProcessMethod |= EUniProcessImgMethodCompress;
   478         }
   487         }
   479     
   488     
   480     TBool largeImageQuery = EFalse;
   489     largeImageQuery = EFalse;
   481     
   490     
   482     if ( iProcessMethod == EUniProcessImgMethodNone )
   491     if ( iProcessMethod == EUniProcessImgMethodNone )
   483         {
   492         {
   484         // Image won't be processed
   493         // Image won't be processed
   485         if ( ( origSize.iWidth > KImageRichWidth ||
   494         if ( ( origSize.iWidth > KImageRichWidth ||
   499             {
   508             {
   500             // Processed image is "non-conformant" after processing.
   509             // Processed image is "non-conformant" after processing.
   501             largeImageQuery = ETrue;
   510             largeImageQuery = ETrue;
   502             }
   511             }
   503         }
   512         }
   504 
   513  
       
   514     iScaleSize = scaleSize;
       
   515     return ETrue;
       
   516     }
       
   517 
       
   518 // ---------------------------------------------------------
       
   519 // CUniEditorProcessImageOperation::checkLargeImage
       
   520 // ---------------------------------------------------------
       
   521 //
       
   522 void CUniEditorProcessImageOperation::checkLargeImage()
       
   523 {
   505     //Large image query     
   524     //Large image query     
   506     if( largeImageQuery && iMmsCreationMode == EMmsCreationModeWarning)
   525     if( largeImageQuery && iMmsCreationMode == EMmsCreationModeWarning)
   507     {
   526     {
   508         if(!HbMessageBox::question(LOC_LARGE_IMAGE_NOTE))
   527         HbMessageBox::question(LOC_LARGE_IMAGE_NOTE, this,
   509         {
   528             SLOT(onDialogLargeImage(HbAction*))); 
   510             return EFalse; // Abort
   529     }
   511         }
   530     else
   512         
   531     {
   513     }
   532         CompleteSelf(KErrNone);
   514         
   533     }
   515     iScaleSize = scaleSize;
   534         
   516     return ETrue;
   535 }
   517     }
   536        
   518 
   537 
   519 // ---------------------------------------------------------
   538 // ---------------------------------------------------------
   520 // CUniEditorProcessImageOperation::CreateEmptyAttachmentL
   539 // CUniEditorProcessImageOperation::CreateEmptyAttachmentL
   521 // ---------------------------------------------------------
   540 // ---------------------------------------------------------
   522 //
   541 //
   674         {
   693         {
   675         CompleteOperation( KErrCancel );
   694         CompleteOperation( KErrCancel );
   676         }
   695         }
   677     }
   696     }
   678 
   697 
       
   698 // ---------------------------------------------------------
       
   699 // CUniEditorProcessImageOperation::onDialogLargeImage
       
   700 // ---------------------------------------------------------
       
   701 //
       
   702 void CUniEditorProcessImageOperation::onDialogLargeImage(HbAction* action)
       
   703     {
       
   704     HbMessageBox *dlg = qobject_cast<HbMessageBox*> (sender());
       
   705     if (action == dlg->actions().at(1)) {
       
   706         iOperationState = EUniProcessImgError;
       
   707         }
       
   708     CompleteSelf(KErrNone);
       
   709     }
   679 
   710 
   680 // End of file
   711 // End of file