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