|
1 /* |
|
2 * Copyright (c) 2006,2007 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: Provides CUniEditorProcessImageOperation methods. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 // ========== INCLUDE FILES ================================ |
|
21 |
|
22 #include <BASCHED.H> |
|
23 #include <icl/imagedata.h> |
|
24 |
|
25 #include <centralrepository.h> |
|
26 |
|
27 #include <messagingvariant.hrh> |
|
28 #include <messaginginternalcrkeys.h> // for Central Repository keys |
|
29 |
|
30 #include <MsgMediaResolver.h> |
|
31 #include <MsgImageInfo.h> |
|
32 #include <MmsConformance.h> |
|
33 #include <MsgMimeTypes.h> |
|
34 |
|
35 #include <msgunieditorimageprocessor.h> |
|
36 |
|
37 |
|
38 #include <mmsvattachmentmanager.h> |
|
39 #include <mmsvattachmentmanagersync.h> |
|
40 #include <cmsvattachment.h> |
|
41 |
|
42 #include <msgtextutils.h> |
|
43 |
|
44 #include <msvids.h> |
|
45 #include <MmsEngineDomainCRKeys.h> |
|
46 #include <mmssettingsdefs.h> |
|
47 #include <HbMessageBox> |
|
48 #include <HbAction> |
|
49 #include <mmsconst.h> |
|
50 |
|
51 #include "msgmonitor.h" |
|
52 #include "msgunieditorprocessimageoperation.h" |
|
53 |
|
54 // ========== CONSTANTS ==================================== |
|
55 |
|
56 // Leave some space after compression so that text can be inserted to the |
|
57 // message. |
|
58 const TInt KUniCompressionMargin = 10 * 1024; // 10 kB |
|
59 |
|
60 //const TInt KUniMmsUploadImageWidth = 1600; |
|
61 //const TInt KUniMmsUploadImageHeight = 1200; |
|
62 |
|
63 |
|
64 _LIT8( KUniExtImageJpeg_8, ".jpg" ); |
|
65 _LIT8( KUniExtImageGif_8, ".gif" ); |
|
66 |
|
67 _LIT(KTempFilePath,"c:\\temp\\unieditor\\"); |
|
68 |
|
69 #define LOC_LARGE_IMAGE_NOTE QString("The receiver may not support image this large. Continue?") |
|
70 |
|
71 |
|
72 // ========== MEMBER FUNCTIONS ============================= |
|
73 |
|
74 // --------------------------------------------------------- |
|
75 // CUniEditorProcessImageOperation::NewL |
|
76 // |
|
77 // Factory method. |
|
78 // --------------------------------------------------------- |
|
79 // |
|
80 CUniEditorProcessImageOperation* CUniEditorProcessImageOperation::NewL( |
|
81 MUniEditorProcessImageOperationObserver &aObserver) |
|
82 { |
|
83 CUniEditorProcessImageOperation* self = new ( ELeave ) |
|
84 CUniEditorProcessImageOperation(aObserver); |
|
85 |
|
86 CleanupStack::PushL( self ); |
|
87 self->ConstructL(); |
|
88 CleanupStack::Pop( self ); |
|
89 |
|
90 return self; |
|
91 } |
|
92 |
|
93 // --------------------------------------------------------- |
|
94 // CUniEditorProcessImageOperation::CUniEditorProcessImageOperation. |
|
95 // --------------------------------------------------------- |
|
96 // |
|
97 CUniEditorProcessImageOperation::CUniEditorProcessImageOperation( |
|
98 MUniEditorProcessImageOperationObserver &aObserver) |
|
99 : CActive( EPriorityStandard ), |
|
100 iObserver(aObserver) |
|
101 { |
|
102 CActiveScheduler::Add( this ); |
|
103 } |
|
104 |
|
105 // --------------------------------------------------------- |
|
106 // CUniEditorProcessImageOperation::ConstructL |
|
107 // |
|
108 // 2nd phase constructor. |
|
109 // --------------------------------------------------------- |
|
110 // |
|
111 void CUniEditorProcessImageOperation::ConstructL() |
|
112 { |
|
113 User::LeaveIfError(iFs.Connect()); |
|
114 iFs.ShareProtected(); |
|
115 |
|
116 TInt featureBitmask( 0 ); |
|
117 |
|
118 CRepository* repository = CRepository::NewL( KCRUidMuiuVariation ); |
|
119 repository->Get( KMuiuMmsFeatures, featureBitmask ); |
|
120 |
|
121 iExactImageScaling = ( featureBitmask & KMmsFeatureIdExactImageScaling ); |
|
122 |
|
123 delete repository; |
|
124 |
|
125 // MMS Engine CR |
|
126 repository = CRepository::NewL( KCRUidMmsEngine ); |
|
127 |
|
128 |
|
129 TInt temp = 0; |
|
130 if ( repository->Get( KMmsEngineImageWidth, temp ) == KErrNone ) |
|
131 { |
|
132 iMaxImageWidth = temp; |
|
133 } |
|
134 temp = 0; |
|
135 if ( repository->Get( KMmsEngineImageHeight, temp ) == KErrNone ) |
|
136 { |
|
137 iMaxImageHeight = temp; |
|
138 } |
|
139 |
|
140 // Just to make sure the size is at least "small" |
|
141 iMaxImageWidth = Max( KMmsUniImageSmallWidth, iMaxImageWidth ); |
|
142 iMaxImageHeight = Max( KMmsUniImageSmallHeight, iMaxImageHeight ); |
|
143 |
|
144 temp = 0; |
|
145 if ( repository->Get( KMmsEngineCreationMode, temp ) == KErrNone ) |
|
146 { |
|
147 iMmsCreationMode = temp; |
|
148 } |
|
149 |
|
150 delete repository; |
|
151 |
|
152 iMaxMmsSize = MsgMonitor::maxMmsSize(); |
|
153 } |
|
154 |
|
155 // --------------------------------------------------------- |
|
156 // CUniEditorProcessImageOperation::~CUniEditorProcessImageOperation |
|
157 // --------------------------------------------------------- |
|
158 // |
|
159 CUniEditorProcessImageOperation::~CUniEditorProcessImageOperation() |
|
160 { |
|
161 Cancel(); |
|
162 delete iNewImageInfo; |
|
163 iNewImageInfo = NULL; |
|
164 iNewImageFile.Close(); |
|
165 delete iImageProcessor; |
|
166 |
|
167 //Since iFs doesnot have recursive dir deletion use file manager |
|
168 TRAP_IGNORE( |
|
169 CFileMan *fm = CFileMan::NewL(iFs); |
|
170 fm->RmDir(KTempFilePath); |
|
171 delete fm; |
|
172 ); |
|
173 |
|
174 iFs.Close(); |
|
175 } |
|
176 |
|
177 // --------------------------------------------------------- |
|
178 // CUniEditorProcessImageOperation::Process |
|
179 // --------------------------------------------------------- |
|
180 // |
|
181 void CUniEditorProcessImageOperation::Process( CMsgImageInfo* aImageInfo ) |
|
182 { |
|
183 iImageInfo = aImageInfo; |
|
184 iOperationState = EUniProcessImgCheck; |
|
185 |
|
186 CompleteSelf( KErrNone ); |
|
187 } |
|
188 |
|
189 |
|
190 |
|
191 // --------------------------------------------------------- |
|
192 // CUniEditorProcessImageOperation::RunL |
|
193 // --------------------------------------------------------- |
|
194 // |
|
195 void CUniEditorProcessImageOperation::RunL() |
|
196 { |
|
197 if ( iStatus.Int() != KErrNone ) |
|
198 { |
|
199 iOperationState = EUniProcessImgError; |
|
200 } |
|
201 TFileName newFileName; |
|
202 |
|
203 switch ( iOperationState ) |
|
204 { |
|
205 case EUniProcessImgCheck: |
|
206 { |
|
207 DoStartCheck(); |
|
208 break; |
|
209 } |
|
210 case EUniProcessImgProcess: |
|
211 { |
|
212 DoStartProcessL(); |
|
213 break; |
|
214 } |
|
215 case EUniProcessImgResolve: |
|
216 { |
|
217 DoStartResolveL(); |
|
218 break; |
|
219 } |
|
220 case EUniProcessImgReady: |
|
221 { |
|
222 if(iNewImageInfo) |
|
223 { |
|
224 newFileName.Append(iNewImageInfo->FullFilePath()); |
|
225 } |
|
226 iObserver.EditorOperationEvent( EUniEditorProcessImageOperationComplete,newFileName ); |
|
227 break; |
|
228 } |
|
229 case EUniProcessImgError: |
|
230 { |
|
231 DoErrorWithoutStateChange(); |
|
232 iObserver.EditorOperationEvent( EUniEditorProcessImageOperationError,newFileName ); |
|
233 break; |
|
234 } |
|
235 default: |
|
236 { |
|
237 iObserver.EditorOperationEvent( EUniEditorProcessImageOperationError,newFileName ); |
|
238 break; |
|
239 } |
|
240 } |
|
241 } |
|
242 |
|
243 // --------------------------------------------------------- |
|
244 // CUniEditorProcessImageOperation::DoCancelCleanup |
|
245 // --------------------------------------------------------- |
|
246 // |
|
247 void CUniEditorProcessImageOperation::DoCancelCleanup() |
|
248 { |
|
249 if ( iImageProcessor ) |
|
250 { |
|
251 iImageProcessor->Cancel(); |
|
252 } |
|
253 |
|
254 DoErrorWithoutStateChange(); |
|
255 } |
|
256 |
|
257 // --------------------------------------------------------- |
|
258 // CUniEditorProcessImageOperation::DoStartCheck |
|
259 // --------------------------------------------------------- |
|
260 // |
|
261 void CUniEditorProcessImageOperation::DoStartCheck() |
|
262 { |
|
263 if ( !CheckNeedToProcess() ) |
|
264 { |
|
265 iOperationState = EUniProcessImgError; |
|
266 } |
|
267 else if ( iProcessMethod == EUniProcessImgMethodNone ) |
|
268 { |
|
269 //Since resizing is not started |
|
270 //we should ensure that original file is picked for insertion |
|
271 iOperationState = EUniProcessImgError; |
|
272 } |
|
273 else |
|
274 { |
|
275 iOperationState = EUniProcessImgProcess; |
|
276 } |
|
277 checkLargeImage(); |
|
278 } |
|
279 |
|
280 // --------------------------------------------------------- |
|
281 // CUniEditorProcessImageOperation::DoStartProcessL |
|
282 // --------------------------------------------------------- |
|
283 // |
|
284 void CUniEditorProcessImageOperation::DoStartProcessL() |
|
285 { |
|
286 CreateEmptyAttachmentL(); |
|
287 |
|
288 if ( !iImageProcessor ) |
|
289 { |
|
290 iImageProcessor = new( ELeave )CUniImageProcessor( this ); |
|
291 } |
|
292 |
|
293 RFile sourceFile = OpenFileForReadingL(); |
|
294 |
|
295 CleanupClosePushL( sourceFile ); |
|
296 |
|
297 iImageProcessor->ProcessImageL( sourceFile, |
|
298 iNewImageFile, |
|
299 iScaleSize, |
|
300 iTargetType.Des8(), |
|
301 ETrue, // Always maintain aspect ratio |
|
302 iMaxMmsSize - KUniCompressionMargin ); |
|
303 SetPending(); |
|
304 |
|
305 CleanupStack::PopAndDestroy(); // sourceFile; |
|
306 } |
|
307 |
|
308 // --------------------------------------------------------- |
|
309 // CUniEditorProcessImageOperation::DoStartResolveL |
|
310 // --------------------------------------------------------- |
|
311 // |
|
312 void CUniEditorProcessImageOperation::DoStartResolveL() |
|
313 { |
|
314 CMsgMediaResolver* mediaResolver = CMsgMediaResolver::NewL(); |
|
315 mediaResolver->SetCharacterSetRecognition( EFalse ); |
|
316 CleanupStack::PushL(mediaResolver); |
|
317 |
|
318 //Delete the previous object if present |
|
319 delete iNewImageInfo; |
|
320 iNewImageInfo = NULL; |
|
321 iNewImageInfo = static_cast<CMsgImageInfo*>(mediaResolver->CreateMediaInfoL( iNewImageFile ) ); |
|
322 |
|
323 mediaResolver->ParseInfoDetailsL( iNewImageInfo, iNewImageFile ); |
|
324 |
|
325 iOperationState = EUniProcessImgReady; |
|
326 |
|
327 iNewImageFile.Close(); |
|
328 |
|
329 CleanupStack::PopAndDestroy(mediaResolver); |
|
330 CompleteSelf( KErrNone ); |
|
331 } |
|
332 |
|
333 // --------------------------------------------------------- |
|
334 // CUniEditorProcessImageOperation::DoErrorWithoutStateChange |
|
335 // --------------------------------------------------------- |
|
336 // |
|
337 void CUniEditorProcessImageOperation::DoErrorWithoutStateChange() |
|
338 { |
|
339 iNewImageFile.Close(); |
|
340 delete iNewImageInfo; |
|
341 iNewImageInfo = NULL; |
|
342 } |
|
343 |
|
344 // --------------------------------------------------------- |
|
345 // CUniEditorProcessImageOperation::ImageProcessingReady |
|
346 // |
|
347 // Image Compressor callback implementation. |
|
348 // --------------------------------------------------------- |
|
349 // |
|
350 void CUniEditorProcessImageOperation::ImageProcessingReady( TSize aBitmapSize, |
|
351 TInt aFileSize, |
|
352 TBool aCompressed ) |
|
353 { |
|
354 TInt err = iImageProcessor->Error(); |
|
355 |
|
356 if ( err == KErrNone && |
|
357 ( aBitmapSize.iWidth == 0 || aBitmapSize.iHeight == 0 || |
|
358 ( aCompressed && |
|
359 ( aFileSize == 0 || |
|
360 aFileSize > ( iMaxMmsSize - KUniCompressionMargin ) ) ) ) ) |
|
361 { |
|
362 err = KErrGeneral; |
|
363 } |
|
364 |
|
365 switch ( err ) |
|
366 { |
|
367 case KErrNone: |
|
368 { |
|
369 iOperationState = EUniProcessImgResolve; |
|
370 break; |
|
371 } |
|
372 case KErrNoMemory: |
|
373 { |
|
374 iOperationState = EUniProcessImgError; |
|
375 |
|
376 break; |
|
377 } |
|
378 case KErrDiskFull: |
|
379 { |
|
380 iOperationState = EUniProcessImgError; |
|
381 |
|
382 break; |
|
383 } |
|
384 case KErrNotFound: |
|
385 { |
|
386 iOperationState = EUniProcessImgError; |
|
387 |
|
388 break; |
|
389 } |
|
390 default: |
|
391 { |
|
392 iOperationState = EUniProcessImgError; |
|
393 break; |
|
394 } |
|
395 } |
|
396 |
|
397 if ( err == KErrCancel ) |
|
398 { |
|
399 CompleteOperation( KErrCancel ); |
|
400 } |
|
401 else |
|
402 { |
|
403 CompleteOperation( KErrNone ); |
|
404 } |
|
405 } |
|
406 |
|
407 // --------------------------------------------------------- |
|
408 // CUniEditorProcessImageOperation::CheckNeedToProcess |
|
409 // |
|
410 // Checks if scaling/converting/compression is needed. |
|
411 // --------------------------------------------------------- |
|
412 // |
|
413 TBool CUniEditorProcessImageOperation::CheckNeedToProcess() |
|
414 { |
|
415 iProcessMethod = EUniProcessImgMethodNone; |
|
416 |
|
417 CMmsConformance* mmsConformance = NULL; |
|
418 TRAP_IGNORE(mmsConformance = CMmsConformance::NewL()); |
|
419 TMmsConformance conformance; |
|
420 if(mmsConformance) |
|
421 { |
|
422 mmsConformance->CheckCharacterSet( EFalse ); |
|
423 conformance = mmsConformance->MediaConformance( *iImageInfo ); |
|
424 } |
|
425 |
|
426 if ( conformance.iCanAdapt == EFalse ) |
|
427 { |
|
428 return EFalse; |
|
429 } |
|
430 |
|
431 TSize origSize = iImageInfo->Dimensions(); |
|
432 |
|
433 if ( origSize.iWidth == 0 || origSize.iHeight == 0 ) |
|
434 { |
|
435 // Cannot get size -> corrupted |
|
436 return EFalse; // Abort |
|
437 } |
|
438 |
|
439 TSize scaleSize = ImageSendSize(); |
|
440 TSize optimizedSize = origSize; |
|
441 |
|
442 while ( optimizedSize.iWidth > scaleSize.iWidth || |
|
443 optimizedSize.iHeight > scaleSize.iHeight ) |
|
444 { |
|
445 // Largest possible (1/2)^n size |
|
446 optimizedSize.iWidth >>= 1; |
|
447 optimizedSize.iHeight >>= 1; |
|
448 } |
|
449 |
|
450 if ( scaleSize.iWidth < origSize.iWidth || |
|
451 scaleSize.iHeight < origSize.iHeight ) |
|
452 { |
|
453 if ( !iExactImageScaling && |
|
454 ( scaleSize.iWidth > KMmsUniImageSmallWidth || |
|
455 scaleSize.iHeight > KMmsUniImageSmallHeight ) ) |
|
456 { |
|
457 // Use optimized (1/2^n) size when scaling |
|
458 // to larger than "Small" |
|
459 scaleSize = optimizedSize; |
|
460 } |
|
461 // else -> scale to exact (non-optimized) size |
|
462 |
|
463 iProcessMethod |= EUniProcessImgMethodScale; |
|
464 } |
|
465 else |
|
466 { |
|
467 // Scaling not needed. Check possible conversion need. |
|
468 scaleSize = origSize; |
|
469 |
|
470 if ( conformance.iConfStatus & EMmsConfNokConversionNeeded ) |
|
471 { |
|
472 // Conversion needed. |
|
473 iProcessMethod |= EUniProcessImgMethodConvert; |
|
474 } |
|
475 } |
|
476 |
|
477 if ( !( iProcessMethod & EUniProcessImgMethodScale ) && |
|
478 ( iImageInfo->FileSize() + |
|
479 MsgMonitor::messageSize() ) > iMaxMmsSize && |
|
480 iImageInfo->MimeType().CompareF( KMsgMimeImageJpeg ) == 0 && |
|
481 (MsgMonitor::messageSize()) < KUniCompressionMargin ) |
|
482 { |
|
483 // Only compression needed as image is JPEG that is larger than can be fitted |
|
484 // into the message and scaling is not performed. Also current message size |
|
485 // is under comression margin. |
|
486 iProcessMethod |= EUniProcessImgMethodCompress; |
|
487 } |
|
488 |
|
489 largeImageQuery = EFalse; |
|
490 |
|
491 if ( iProcessMethod == EUniProcessImgMethodNone ) |
|
492 { |
|
493 // Image won't be processed |
|
494 if ( ( origSize.iWidth > KImageRichWidth || |
|
495 origSize.iHeight > KImageRichHeight ) && |
|
496 ( iImageInfo->FileSize() + MsgMonitor::messageSize() ) < iMaxMmsSize ) |
|
497 { |
|
498 // Original image width or height is "non-conformant" and original image would |
|
499 // fit to into the message without any processing. |
|
500 largeImageQuery = ETrue; |
|
501 } |
|
502 } |
|
503 else |
|
504 { |
|
505 // Image will be processed |
|
506 if ( scaleSize.iWidth > KImageRichWidth || |
|
507 scaleSize.iHeight > KImageRichHeight ) |
|
508 { |
|
509 // Processed image is "non-conformant" after processing. |
|
510 largeImageQuery = ETrue; |
|
511 } |
|
512 } |
|
513 |
|
514 iScaleSize = scaleSize; |
|
515 return ETrue; |
|
516 } |
|
517 |
|
518 // --------------------------------------------------------- |
|
519 // CUniEditorProcessImageOperation::checkLargeImage |
|
520 // --------------------------------------------------------- |
|
521 // |
|
522 void CUniEditorProcessImageOperation::checkLargeImage() |
|
523 { |
|
524 //Large image query |
|
525 if( largeImageQuery && iMmsCreationMode == EMmsCreationModeWarning) |
|
526 { |
|
527 HbMessageBox::question(LOC_LARGE_IMAGE_NOTE, this, |
|
528 SLOT(onDialogLargeImage(HbAction*))); |
|
529 } |
|
530 else |
|
531 { |
|
532 CompleteSelf(KErrNone); |
|
533 } |
|
534 |
|
535 } |
|
536 |
|
537 |
|
538 // --------------------------------------------------------- |
|
539 // CUniEditorProcessImageOperation::CreateEmptyAttachmentL |
|
540 // --------------------------------------------------------- |
|
541 // |
|
542 void CUniEditorProcessImageOperation::CreateEmptyAttachmentL() |
|
543 { |
|
544 |
|
545 // Get the file name from original full path name. |
|
546 TParsePtrC parser( iImageInfo->FullFilePath() ); |
|
547 |
|
548 TFileName ext( parser.Ext() ); |
|
549 iTargetType = iImageInfo->MimeType(); |
|
550 |
|
551 if ( iTargetType.Des8().CompareF( KMsgMimeImagePng ) == 0 ) |
|
552 { |
|
553 //png is non-conformant image type |
|
554 //->convert to jpeg |
|
555 iTargetType = TDataType( KMsgMimeImageJpeg ); |
|
556 ext.Zero(); |
|
557 ext.Copy( KUniExtImageJpeg_8 ); |
|
558 } |
|
559 else if ( iTargetType.Des8().CompareF( KMsgMimeImageWbmp ) == 0 ) |
|
560 { |
|
561 //no wbmp encoder |
|
562 //->convert to gif if scaling is needed |
|
563 iTargetType = TDataType( KMsgMimeImageGif ); |
|
564 ext.Zero(); |
|
565 ext.Copy( KUniExtImageGif_8 ); |
|
566 } |
|
567 |
|
568 //Create dir if doesnot exist, if dir already exits error is returned |
|
569 //which can be ignored |
|
570 iFs.MkDirAll(KTempFilePath); |
|
571 |
|
572 TFileName newFileName( KTempFilePath ); |
|
573 newFileName.Append(parser.Name()); |
|
574 newFileName.Append( ext ); |
|
575 |
|
576 |
|
577 iNewImageFile.Replace(iFs,newFileName,EFileWrite | EFileShareAny); |
|
578 |
|
579 } |
|
580 |
|
581 // --------------------------------------------------------- |
|
582 // CUniEditorProcessImageOperation::ImageSendSize |
|
583 // --------------------------------------------------------- |
|
584 // |
|
585 TSize CUniEditorProcessImageOperation::ImageSendSize() const |
|
586 { |
|
587 TSize size; |
|
588 size.iWidth = iMaxImageWidth; |
|
589 size.iHeight = iMaxImageHeight; |
|
590 return size; |
|
591 } |
|
592 |
|
593 // --------------------------------------------------------- |
|
594 // CUniEditorProcessImageOperation::OpenFileForReadingL |
|
595 // --------------------------------------------------------- |
|
596 // |
|
597 RFile CUniEditorProcessImageOperation::OpenFileForReadingL() |
|
598 { |
|
599 RFile sourceFile; |
|
600 TInt err = sourceFile.Open( |
|
601 iFs, iImageInfo->FullFilePath(), EFileRead | EFileShareAny ); |
|
602 if ( err ) |
|
603 { |
|
604 err = sourceFile.Open( |
|
605 iFs, iImageInfo->FullFilePath(), EFileRead | EFileShareReadersOnly ); |
|
606 |
|
607 User::LeaveIfError( err ); |
|
608 } |
|
609 return sourceFile; |
|
610 } |
|
611 |
|
612 // --------------------------------------------------------- |
|
613 // CUniEditorProcessImageOperation::RunError |
|
614 // --------------------------------------------------------- |
|
615 // |
|
616 TInt CUniEditorProcessImageOperation::RunError( TInt aError ) |
|
617 { |
|
618 delete iImageProcessor; |
|
619 iImageProcessor = NULL; |
|
620 |
|
621 if ( aError == KLeaveExit ) |
|
622 { |
|
623 return KLeaveExit; |
|
624 } |
|
625 else |
|
626 { |
|
627 CompleteSelf( aError ); |
|
628 return KErrNone; |
|
629 } |
|
630 } |
|
631 |
|
632 // --------------------------------------------------------- |
|
633 // CUniEditorProcessImageOperation::DetachImageInfo |
|
634 // --------------------------------------------------------- |
|
635 // |
|
636 CMsgImageInfo* CUniEditorProcessImageOperation::DetachImageInfo() |
|
637 { |
|
638 // ownership transferred |
|
639 CMsgImageInfo* tempInfo = iNewImageInfo; |
|
640 iNewImageInfo = NULL; |
|
641 return tempInfo; |
|
642 } |
|
643 |
|
644 // --------------------------------------------------------- |
|
645 // CUniEditorProcessImageOperation::CompleteSelf |
|
646 // |
|
647 // Completes current step of state machine |
|
648 // --------------------------------------------------------- |
|
649 // |
|
650 void CUniEditorProcessImageOperation::CompleteSelf( TInt aError ) |
|
651 { |
|
652 iStatus = KRequestPending; |
|
653 TRequestStatus* pStatus = &iStatus; |
|
654 SetActive(); |
|
655 User::RequestComplete( pStatus, aError ); |
|
656 } |
|
657 |
|
658 // --------------------------------------------------------- |
|
659 // CUniEditorProcessImageOperation::SetPending |
|
660 // --------------------------------------------------------- |
|
661 // |
|
662 void CUniEditorProcessImageOperation::SetPending() |
|
663 { |
|
664 if ( !IsActive() ) |
|
665 { |
|
666 iStatus = KRequestPending; |
|
667 SetActive(); |
|
668 } |
|
669 } |
|
670 |
|
671 // --------------------------------------------------------- |
|
672 // CUniEditorProcessImageOperation::CompleteOperation |
|
673 // --------------------------------------------------------- |
|
674 // |
|
675 void CUniEditorProcessImageOperation::CompleteOperation( TInt aError ) |
|
676 { |
|
677 SetPending(); |
|
678 |
|
679 TRequestStatus* pStatus = &iStatus; |
|
680 User::RequestComplete( pStatus, aError ); |
|
681 } |
|
682 |
|
683 // --------------------------------------------------------- |
|
684 // CUniEditorProcessImageOperation::DoCancel |
|
685 // --------------------------------------------------------- |
|
686 // |
|
687 void CUniEditorProcessImageOperation::DoCancel() |
|
688 { |
|
689 DoCancelCleanup(); |
|
690 |
|
691 |
|
692 if ( iStatus == KRequestPending ) |
|
693 { |
|
694 CompleteOperation( KErrCancel ); |
|
695 } |
|
696 } |
|
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 } |
|
710 |
|
711 // End of file |