17 |
17 |
18 |
18 |
19 |
19 |
20 // ========== INCLUDE FILES ================================ |
20 // ========== INCLUDE FILES ================================ |
21 |
21 |
22 #include <BASCHED.H> |
22 #include <basched.h> |
23 #include <icl/imagedata.h> |
23 #include <icl/imagedata.h> |
24 |
24 |
25 #include <centralrepository.h> |
25 #include <centralrepository.h> |
26 |
26 |
27 #include <messagingvariant.hrh> |
27 #include <MessagingVariant.hrh> |
28 #include <messaginginternalcrkeys.h> // for Central Repository keys |
28 #include <MessagingInternalCRKeys.h> // for Central Repository keys |
29 |
29 |
30 #include <MsgMediaResolver.h> |
30 #include <MsgMediaResolver.h> |
31 #include <MsgImageInfo.h> |
31 #include <MsgImageInfo.h> |
32 #include <MmsConformance.h> |
32 #include <MmsConformance.h> |
33 #include <MsgMimeTypes.h> |
33 #include <MsgMimeTypes.h> |
41 |
41 |
42 #include <msgtextutils.h> |
42 #include <msgtextutils.h> |
43 |
43 |
44 #include <msvids.h> |
44 #include <msvids.h> |
45 #include <MmsEngineDomainCRKeys.h> |
45 #include <MmsEngineDomainCRKeys.h> |
46 #include <mmssettingsdefs.h> |
46 #include <msgunieditormmssettingsdefs.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 "msgunieditormonitor.h" |
51 #include "msgunieditorprocessimageoperation.h" |
52 #include "msgunieditorprocessimageoperation.h" |
52 |
53 |
53 // ========== CONSTANTS ==================================== |
54 // ========== CONSTANTS ==================================== |
54 |
55 |
55 // Leave some space after compression so that text can be inserted to the |
56 // Leave some space after compression so that text can be inserted to the |
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(); |
89 |
89 |
90 return self; |
90 return self; |
91 } |
91 } |
92 |
92 |
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 ); |
146 iMmsCreationMode = temp; |
147 iMmsCreationMode = temp; |
147 } |
148 } |
148 |
149 |
149 delete repository; |
150 delete repository; |
150 |
151 |
151 iMaxMmsSize = MsgMonitor::maxMmsSize(); |
152 iMaxMmsSize = MsgUnifiedEditorMonitor::maxMmsSize(); |
152 } |
153 } |
153 |
154 |
154 // --------------------------------------------------------- |
155 // --------------------------------------------------------- |
155 // CUniEditorProcessImageOperation::~CUniEditorProcessImageOperation |
156 // CUniEditorProcessImageOperation::~CUniEditorProcessImageOperation |
156 // --------------------------------------------------------- |
157 // --------------------------------------------------------- |
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 } |
465 } |
474 } |
466 } |
475 } |
467 |
476 |
468 if ( !( iProcessMethod & EUniProcessImgMethodScale ) && |
477 if ( !( iProcessMethod & EUniProcessImgMethodScale ) && |
469 ( iImageInfo->FileSize() + |
478 ( iImageInfo->FileSize() + |
470 MsgMonitor::messageSize() ) > iMaxMmsSize && |
479 MsgUnifiedEditorMonitor::messageSize() ) > iMaxMmsSize && |
471 iImageInfo->MimeType().CompareF( KMsgMimeImageJpeg ) == 0 && |
480 iImageInfo->MimeType().CompareF( KMsgMimeImageJpeg ) == 0 && |
472 (MsgMonitor::messageSize()) < KUniCompressionMargin ) |
481 (MsgUnifiedEditorMonitor::messageSize()) < KUniCompressionMargin ) |
473 { |
482 { |
474 // Only compression needed as image is JPEG that is larger than can be fitted |
483 // Only compression needed as image is JPEG that is larger than can be fitted |
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 || |
486 origSize.iHeight > KImageRichHeight ) && |
495 origSize.iHeight > KImageRichHeight ) && |
487 ( iImageInfo->FileSize() + MsgMonitor::messageSize() ) < iMaxMmsSize ) |
496 ( iImageInfo->FileSize() + MsgUnifiedEditorMonitor::messageSize() ) < iMaxMmsSize ) |
488 { |
497 { |
489 // Original image width or height is "non-conformant" and original image would |
498 // Original image width or height is "non-conformant" and original image would |
490 // fit to into the message without any processing. |
499 // fit to into the message without any processing. |
491 largeImageQuery = ETrue; |
500 largeImageQuery = ETrue; |
492 } |
501 } |
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 HbMessageBox::Yes | HbMessageBox::No); |
511 } |
530 } |
512 |
531 else |
513 } |
532 { |
514 |
533 CompleteSelf(KErrNone); |
515 iScaleSize = scaleSize; |
534 } |
516 return ETrue; |
535 |
517 } |
536 } |
|
537 |
518 |
538 |
519 // --------------------------------------------------------- |
539 // --------------------------------------------------------- |
520 // CUniEditorProcessImageOperation::CreateEmptyAttachmentL |
540 // CUniEditorProcessImageOperation::CreateEmptyAttachmentL |
521 // --------------------------------------------------------- |
541 // --------------------------------------------------------- |
522 // |
542 // |
674 { |
694 { |
675 CompleteOperation( KErrCancel ); |
695 CompleteOperation( KErrCancel ); |
676 } |
696 } |
677 } |
697 } |
678 |
698 |
|
699 // --------------------------------------------------------- |
|
700 // CUniEditorProcessImageOperation::onDialogLargeImage |
|
701 // --------------------------------------------------------- |
|
702 // |
|
703 void CUniEditorProcessImageOperation::onDialogLargeImage(HbAction* action) |
|
704 { |
|
705 HbMessageBox *dlg = qobject_cast<HbMessageBox*> (sender()); |
|
706 if (action == dlg->actions().at(1)) { |
|
707 iOperationState = EUniProcessImgError; |
|
708 } |
|
709 CompleteSelf(KErrNone); |
|
710 } |
679 |
711 |
680 // End of file |
712 // End of file |