|
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: CUniEditorInsertOperation. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 // ========== INCLUDE FILES ================================ |
|
21 |
|
22 #include <apmstd.h> |
|
23 #include <mmsconst.h> |
|
24 |
|
25 #include <MmsConformance.h> |
|
26 |
|
27 #include <MsgMediaInfo.h> |
|
28 #include <MsgImageInfo.h> |
|
29 #include <MsgVideoInfo.h> |
|
30 #include <MsgMimeTypes.h> |
|
31 #include <msgimagecontrol.h> |
|
32 #include <msgvideocontrol.h> |
|
33 |
|
34 // DRM |
|
35 #include <fileprotectionresolver.h> |
|
36 |
|
37 #include "unislideloader.h" |
|
38 #include "UniClientMtm.h" |
|
39 #include "UniEditorEnum.h" |
|
40 #include "UniEditorDocument.h" |
|
41 #include "UniEditorProcessImageOperation.h" |
|
42 #include "UniEditorChangeSlideOperation.h" |
|
43 #include "UniEditorConvertVideoOperation.h" |
|
44 #include "UniEditorInsertOperation.h" |
|
45 |
|
46 // ========== CONSTANTS ==================================== |
|
47 |
|
48 // ========== MEMBER FUNCTIONS ============================= |
|
49 |
|
50 // --------------------------------------------------------- |
|
51 // CUniEditorInsertOperation::NewL |
|
52 // |
|
53 // Two-phased constructor. |
|
54 // --------------------------------------------------------- |
|
55 // |
|
56 CUniEditorInsertOperation* CUniEditorInsertOperation::NewL( |
|
57 MUniEditorOperationObserver& aOperationObserver, |
|
58 CUniEditorDocument& aDocument, |
|
59 CUniEditorHeader& aHeader, |
|
60 CUniSlideLoader& aSlideLoader, |
|
61 CMsgEditorView& aView, |
|
62 RFs& aFs ) |
|
63 { |
|
64 CUniEditorInsertOperation* self = new ( ELeave ) CUniEditorInsertOperation( |
|
65 aOperationObserver, |
|
66 aDocument, |
|
67 aHeader, |
|
68 aSlideLoader, |
|
69 aView, |
|
70 aFs ); |
|
71 |
|
72 CleanupStack::PushL( self ); |
|
73 self->ConstructL(); |
|
74 CleanupStack::Pop( self ); |
|
75 |
|
76 return self; |
|
77 } |
|
78 |
|
79 // --------------------------------------------------------- |
|
80 // CUniEditorInsertOperation::CUniEditorInsertOperation |
|
81 // --------------------------------------------------------- |
|
82 // |
|
83 CUniEditorInsertOperation::CUniEditorInsertOperation( |
|
84 MUniEditorOperationObserver& aOperationObserver, |
|
85 CUniEditorDocument& aDocument, |
|
86 CUniEditorHeader& aHeader, |
|
87 CUniSlideLoader& aSlideLoader, |
|
88 CMsgEditorView& aView, |
|
89 RFs& aFs ) : |
|
90 CUniEditorOperation( aOperationObserver, aDocument, aFs, EUniEditorOperationInsert ), |
|
91 iHeader( aHeader ), |
|
92 iSlideLoader( aSlideLoader ), |
|
93 iView( aView ), |
|
94 iInsertedSlide( -1 ), |
|
95 iPreviousSlide( -1 ) |
|
96 { |
|
97 } |
|
98 |
|
99 // --------------------------------------------------------- |
|
100 // CUniEditorInsertOperation::ConstructL |
|
101 // 2nd phase constructor |
|
102 // --------------------------------------------------------- |
|
103 // |
|
104 void CUniEditorInsertOperation::ConstructL() |
|
105 { |
|
106 BaseConstructL(); |
|
107 } |
|
108 |
|
109 // --------------------------------------------------------- |
|
110 // CUniEditorInsertOperation::~CUniEditorInsertOperation |
|
111 // --------------------------------------------------------- |
|
112 // |
|
113 CUniEditorInsertOperation::~CUniEditorInsertOperation() |
|
114 { |
|
115 Cancel(); |
|
116 delete iOldInfo; |
|
117 delete iNewInfo; |
|
118 |
|
119 delete iImageOperation; |
|
120 delete iVideoOperation; |
|
121 delete iChangeSlideOperation; |
|
122 } |
|
123 |
|
124 // --------------------------------------------------------- |
|
125 // CUniEditorInsertOperation::Insert |
|
126 // --------------------------------------------------------- |
|
127 // |
|
128 void CUniEditorInsertOperation::Insert( CMsgMediaInfo* aInfo, |
|
129 TBool aAddSlide, |
|
130 TBool aAddAsAttachment ) |
|
131 { |
|
132 ResetErrors(); |
|
133 |
|
134 iInsertedSlide = -1; |
|
135 iInsertedObject = NULL; |
|
136 iOldInfo = aInfo; |
|
137 iAddSlide = aAddSlide; |
|
138 |
|
139 if ( aInfo && |
|
140 aInfo->Protection() & EFileProtDrm2 ) |
|
141 { |
|
142 // DRM 2 content is always added as an attachment. |
|
143 iAddAsAttachment = ETrue; |
|
144 } |
|
145 else |
|
146 { |
|
147 iAddAsAttachment = aAddAsAttachment; |
|
148 } |
|
149 |
|
150 //Coverty fix : Forward Null http://ousrv057/cov.cgi?cid=35696 |
|
151 if ( aInfo && aInfo->MediaType() == EMsgMediaImage ) |
|
152 { |
|
153 iOperationState = EUniInsertCheckMode; |
|
154 } |
|
155 else if ( aInfo && aInfo->MimeType() == KMsgMimeVideoMp4 ) |
|
156 { |
|
157 iOperationState = EUniInsertConvertVideo; |
|
158 } |
|
159 else |
|
160 { |
|
161 iOperationState = EUniInsertCopyAttachment; |
|
162 } |
|
163 |
|
164 CompleteSelf( KErrNone ); |
|
165 } |
|
166 |
|
167 // --------------------------------------------------------- |
|
168 // CUniEditorInsertOperation::RunL |
|
169 // --------------------------------------------------------- |
|
170 // |
|
171 void CUniEditorInsertOperation::RunL() |
|
172 { |
|
173 PrintOperationAndState(); |
|
174 |
|
175 if ( iStatus.Int() != KErrNone ) |
|
176 { |
|
177 SetError( iStatus.Int() ); |
|
178 iOperationState = EUniInsertError; |
|
179 } |
|
180 |
|
181 switch ( iOperationState ) |
|
182 { |
|
183 case EUniInsertCheckMode: |
|
184 { |
|
185 DoCheckModeL(); |
|
186 break; |
|
187 } |
|
188 case EUniInsertProcessImage: |
|
189 { |
|
190 DoStartProcessImageL(); |
|
191 break; |
|
192 } |
|
193 case EUniInsertConvertVideo: |
|
194 { |
|
195 DoStartConvertVideoL(); |
|
196 break; |
|
197 } |
|
198 case EUniInsertCheckSize: |
|
199 { |
|
200 DoCheckSizeL(); |
|
201 break; |
|
202 } |
|
203 case EUniInsertCopyAttachment: |
|
204 { |
|
205 iObserver.EditorOperationEvent( EUniEditorOperationInsert, |
|
206 EUniEditorOperationProcessing ); |
|
207 DoStartCopyAttachmentL(); |
|
208 break; |
|
209 } |
|
210 case EUniInsertLoad: |
|
211 { |
|
212 DoStartLoadL(); |
|
213 break; |
|
214 } |
|
215 case EUniInsertReady: |
|
216 { |
|
217 iObserver.EditorOperationEvent( EUniEditorOperationInsert, |
|
218 EUniEditorOperationComplete ); |
|
219 break; |
|
220 } |
|
221 case EUniInsertError: |
|
222 { |
|
223 DoErrorWithoutStateChangeL(); |
|
224 break; |
|
225 } |
|
226 case EUniInsertErrorReload: |
|
227 { |
|
228 DoStartReloadL(); |
|
229 break; |
|
230 } |
|
231 case EUniInsertErrorReport: |
|
232 { |
|
233 iObserver.EditorOperationEvent( EUniEditorOperationInsert, |
|
234 EUniEditorOperationError ); |
|
235 break; |
|
236 } |
|
237 default: |
|
238 { |
|
239 SetError( KErrUnknown ); |
|
240 iObserver.EditorOperationEvent( EUniEditorOperationInsert, |
|
241 EUniEditorOperationError ); |
|
242 break; |
|
243 } |
|
244 } |
|
245 } |
|
246 |
|
247 // --------------------------------------------------------- |
|
248 // CUniEditorInsertOperation::DoCancelCleanup |
|
249 // --------------------------------------------------------- |
|
250 // |
|
251 void CUniEditorInsertOperation::DoCancelCleanup() |
|
252 { |
|
253 if ( iImageOperation ) |
|
254 { |
|
255 iImageOperation->Cancel(); |
|
256 } |
|
257 |
|
258 if ( iVideoOperation ) |
|
259 { |
|
260 iVideoOperation->Cancel(); |
|
261 } |
|
262 |
|
263 if ( iInsertedObject ) |
|
264 { |
|
265 iInsertedObject->Cancel(); |
|
266 } |
|
267 |
|
268 if ( iChangeSlideOperation ) |
|
269 { |
|
270 iChangeSlideOperation->Cancel(); |
|
271 } |
|
272 |
|
273 iSlideLoader.Cancel(); |
|
274 } |
|
275 |
|
276 // --------------------------------------------------------- |
|
277 // CUniEditorInsertOperation::DoStartProcessImageL |
|
278 // --------------------------------------------------------- |
|
279 // |
|
280 void CUniEditorInsertOperation::DoStartProcessImageL() |
|
281 { |
|
282 if ( iAddSlide ) |
|
283 { |
|
284 // If there is an image with same name added on the current slide, it must be closed that |
|
285 // inserting would succeed. Insert attachment fails in Symbian messaging otherwise. |
|
286 // If error occurs after this, current slide must be realoded again |
|
287 CMsgImageControl* imageControl= static_cast<CMsgImageControl*> ( iView.ControlById( EMsgComponentIdImage ) ); |
|
288 if ( imageControl ) |
|
289 { |
|
290 imageControl->SetImageFileClosed(); |
|
291 } |
|
292 } |
|
293 |
|
294 if ( !iImageOperation ) |
|
295 { |
|
296 iImageOperation = CUniEditorProcessImageOperation::NewL( *this, iDocument, iFs ); |
|
297 } |
|
298 |
|
299 iImageOperation->Process( static_cast<CMsgImageInfo*>( iOldInfo ), KMsvNullIndexEntryId, iDocument.MessageSize( ETrue ) ); |
|
300 SetPending(); |
|
301 } |
|
302 |
|
303 |
|
304 // --------------------------------------------------------- |
|
305 // CUniEditorInsertOperation::DoStartConvertVideoL |
|
306 // --------------------------------------------------------- |
|
307 // |
|
308 void CUniEditorInsertOperation::DoStartConvertVideoL() |
|
309 { |
|
310 if ( CUniEditorConvertVideoOperation::IsImplementedL() ) |
|
311 { |
|
312 if ( !iVideoOperation ) |
|
313 { |
|
314 iVideoOperation = CUniEditorConvertVideoOperation::NewL( *this, iDocument, iFs ); |
|
315 } |
|
316 |
|
317 iVideoOperation->Process( static_cast<CMsgVideoInfo*>( iOldInfo ), KMsvNullIndexEntryId, iDocument.MaxMessageSize() ); |
|
318 SetPending(); |
|
319 } |
|
320 else |
|
321 { |
|
322 iOperationState = EUniInsertCopyAttachment; |
|
323 CompleteSelf( KErrNone ); |
|
324 } |
|
325 } |
|
326 |
|
327 // --------------------------------------------------------- |
|
328 // CUniEditorInsertOperation::DoStartCopyAttachmentL |
|
329 // --------------------------------------------------------- |
|
330 // |
|
331 void CUniEditorInsertOperation::DoStartCopyAttachmentL() |
|
332 { |
|
333 TInt slide = iDocument.CurrentSlide(); |
|
334 |
|
335 if ( iAddSlide ) |
|
336 { |
|
337 iPreviousSlide = slide; |
|
338 |
|
339 slide++; |
|
340 iDocument.DataModel()->SmilModel().AddSlideL( slide ); |
|
341 |
|
342 iInsertedSlide = slide; |
|
343 } |
|
344 |
|
345 if ( iNewInfo ) |
|
346 { |
|
347 TMsvAttachmentId attaId; |
|
348 |
|
349 if ( iImageOperation ) |
|
350 { |
|
351 iImageOperation->DetachAttachmentId( attaId ); |
|
352 } |
|
353 else |
|
354 { |
|
355 iVideoOperation->DetachAttachmentId( attaId ); |
|
356 } |
|
357 |
|
358 if ( iAddAsAttachment ) |
|
359 { |
|
360 iInsertedObject = iDocument.DataModel()->AddStoredAttachmentL( attaId, iNewInfo ); |
|
361 } |
|
362 else |
|
363 { |
|
364 iInsertedObject = iDocument.DataModel()->SmilModel().AddStoredObjectL( slide, attaId, iNewInfo ); |
|
365 } |
|
366 |
|
367 iNewInfo = NULL; |
|
368 CompleteSelf( KErrNone ); |
|
369 } |
|
370 else |
|
371 { |
|
372 if ( iAddAsAttachment ) |
|
373 { |
|
374 iInsertedObject = iDocument.DataModel()->AddAttachmentL( *this, iOldInfo ); |
|
375 } |
|
376 else |
|
377 { |
|
378 iInsertedObject = iDocument.DataModel()->SmilModel().AddObjectL( *this, slide, iOldInfo ); |
|
379 } |
|
380 |
|
381 iOldInfo = NULL; // Ownership transferred |
|
382 SetPending(); |
|
383 } |
|
384 |
|
385 if ( iAddAsAttachment ) |
|
386 { |
|
387 iOperationState = EUniInsertReady; |
|
388 } |
|
389 else |
|
390 { |
|
391 iDocument.SetBodyModified( ETrue ); |
|
392 iOperationState = EUniInsertLoad; |
|
393 } |
|
394 } |
|
395 |
|
396 // --------------------------------------------------------- |
|
397 // CUniEditorInsertOperation::DoStartLoadL |
|
398 // --------------------------------------------------------- |
|
399 // |
|
400 void CUniEditorInsertOperation::DoStartLoadL() |
|
401 { |
|
402 if ( iAddSlide ) |
|
403 { |
|
404 if ( !iChangeSlideOperation ) |
|
405 { |
|
406 iChangeSlideOperation = CUniEditorChangeSlideOperation::NewL( *this, |
|
407 iDocument, |
|
408 iHeader, |
|
409 iSlideLoader, |
|
410 iView, |
|
411 iFs ); |
|
412 } |
|
413 |
|
414 iChangeSlideOperation->ChangeSlide( iInsertedSlide ); |
|
415 } |
|
416 else |
|
417 { |
|
418 iSlideLoader.LoadObject( *this, iInsertedObject ); |
|
419 } |
|
420 |
|
421 SetPending(); |
|
422 iOperationState = EUniInsertReady; |
|
423 } |
|
424 |
|
425 // --------------------------------------------------------- |
|
426 // CUniEditorInsertOperation::DoStartReloadL |
|
427 // --------------------------------------------------------- |
|
428 // |
|
429 void CUniEditorInsertOperation::DoStartReloadL() |
|
430 { |
|
431 TInt CurrSlide = iDocument.CurrentSlide(); |
|
432 TInt slide = (iPreviousSlide!= -1)?iPreviousSlide:CurrSlide; |
|
433 if ( iPreviousSlide != ( -1 ) || CurrSlide == 0 ) |
|
434 { |
|
435 if ( !iChangeSlideOperation ) |
|
436 { |
|
437 iChangeSlideOperation = CUniEditorChangeSlideOperation::NewL( *this, |
|
438 iDocument, |
|
439 iHeader, |
|
440 iSlideLoader, |
|
441 iView, |
|
442 iFs ); |
|
443 } |
|
444 |
|
445 iChangeSlideOperation->ChangeSlide( slide ); |
|
446 SetPending(); |
|
447 } |
|
448 |
|
449 iOperationState = EUniInsertErrorReport; |
|
450 } |
|
451 |
|
452 // --------------------------------------------------------- |
|
453 // CUniEditorInsertOperation::DoCheckSizeL |
|
454 // --------------------------------------------------------- |
|
455 // |
|
456 void CUniEditorInsertOperation::DoCheckSizeL() |
|
457 { |
|
458 if ( CheckSizeForInsertL() ) |
|
459 { |
|
460 iOperationState = EUniInsertCopyAttachment; |
|
461 } |
|
462 else |
|
463 { |
|
464 iOperationState = EUniInsertError; |
|
465 } |
|
466 |
|
467 CompleteSelf( KErrNone ); |
|
468 } |
|
469 |
|
470 // --------------------------------------------------------- |
|
471 // CUniEditorInsertOperation::DoCheckModeL |
|
472 // --------------------------------------------------------- |
|
473 // |
|
474 void CUniEditorInsertOperation::DoCheckModeL() |
|
475 { |
|
476 if ( CheckModeForInsert( ETrue ) ) |
|
477 { |
|
478 iOperationState = EUniInsertProcessImage; |
|
479 } |
|
480 else |
|
481 { |
|
482 iOperationState = EUniInsertError; |
|
483 } |
|
484 |
|
485 CompleteSelf( KErrNone ); |
|
486 } |
|
487 |
|
488 // --------------------------------------------------------- |
|
489 // CUniEditorInsertOperation::CheckModeForInsertL |
|
490 // --------------------------------------------------------- |
|
491 // |
|
492 TBool CUniEditorInsertOperation::CheckModeForInsert( TBool aBeforeProcessing ) |
|
493 { |
|
494 CMsgMediaInfo* info; |
|
495 if ( iNewInfo ) |
|
496 { |
|
497 info = iNewInfo; |
|
498 } |
|
499 else |
|
500 { |
|
501 info = iOldInfo; |
|
502 } |
|
503 |
|
504 TMmsConformance conformance = |
|
505 iDocument.DataModel()->MmsConformance().MediaConformance( *info ); |
|
506 |
|
507 TUint32 confStatus = conformance.iConfStatus; |
|
508 |
|
509 if ( aBeforeProcessing && |
|
510 iDocument.CreationMode() != EMmsCreationModeRestricted ) |
|
511 { |
|
512 return ETrue; |
|
513 } |
|
514 |
|
515 // In "free" mode user can insert images that are larger by dimensions than allowed by conformance |
|
516 if ( iDocument.CreationMode() != EMmsCreationModeRestricted ) |
|
517 { |
|
518 TInt i = EMmsConfNokFreeModeOnly | EMmsConfNokScalingNeeded | EMmsConfNokTooBig; |
|
519 TInt j = ~( EMmsConfNokFreeModeOnly | EMmsConfNokScalingNeeded | EMmsConfNokTooBig ); |
|
520 |
|
521 // If user answers yes to Guided mode confirmation query he/she moves to free mode |
|
522 if ( ( confStatus & i ) && |
|
523 !( confStatus & j ) ) |
|
524 { |
|
525 if ( info->Protection() & EFileProtSuperDistributable ) |
|
526 { |
|
527 // SuperDistribution not checked here |
|
528 // Mask "FreeModeOnly" and "ScalingNeeded" away in free mode |
|
529 confStatus &= ~EMmsConfNokFreeModeOnly; |
|
530 confStatus &= ~EMmsConfNokScalingNeeded; |
|
531 } |
|
532 else if ( iObserver.EditorOperationQuery( EUniEditorOperationInsert, EMEOQueryGuidedObject ) ) |
|
533 { |
|
534 // Guided query accepted. |
|
535 // Mask "FreeModeOnly" and "ScalingNeeded" away in free mode |
|
536 confStatus &= ~EMmsConfNokFreeModeOnly; |
|
537 confStatus &= ~EMmsConfNokScalingNeeded; |
|
538 } |
|
539 else |
|
540 { |
|
541 // Guided query not accepted. Stop insertion. |
|
542 SetError( EUniInsertUserGuidedAbort ); |
|
543 return EFalse; |
|
544 } |
|
545 } |
|
546 } |
|
547 else if ( confStatus & EMmsConfNokDRM || |
|
548 confStatus & EMmsConfNokNotEnoughInfo || |
|
549 confStatus & EMmsConfNokNotSupported || |
|
550 confStatus & EMmsConfNokFreeModeOnly || |
|
551 confStatus & EMmsConfNokCorrupt ) |
|
552 { |
|
553 // Sanity check |
|
554 // "Not conformant" assumed if check fails. |
|
555 SetError( EUniInsertNotSupported ); |
|
556 return EFalse; |
|
557 } |
|
558 |
|
559 return ETrue; |
|
560 } |
|
561 |
|
562 // --------------------------------------------------------- |
|
563 // CUniEditorInsertOperation::CheckSizeForInsertL |
|
564 // --------------------------------------------------------- |
|
565 // |
|
566 TBool CUniEditorInsertOperation::CheckSizeForInsertL() |
|
567 { |
|
568 CMsgMediaInfo* info; |
|
569 if ( iNewInfo ) |
|
570 { |
|
571 info = iNewInfo; |
|
572 } |
|
573 else |
|
574 { |
|
575 info = iOldInfo; |
|
576 } |
|
577 |
|
578 TMmsConformance conformance = |
|
579 iDocument.DataModel()->MmsConformance().MediaConformance( *info ); |
|
580 |
|
581 TUint32 confStatus = conformance.iConfStatus; |
|
582 |
|
583 if ( confStatus & EMmsConfNokTooBig || |
|
584 TUint( iDocument.MessageSize( ETrue ) + info->FileSize() ) > iDocument.MaxMessageSize() ) |
|
585 { |
|
586 SetError( EUniInsertTooBig ); |
|
587 return EFalse; |
|
588 } |
|
589 |
|
590 return ETrue; |
|
591 } |
|
592 |
|
593 // --------------------------------------------------------- |
|
594 // CUniEditorInsertOperation::DoErrorWithoutStateChange |
|
595 // --------------------------------------------------------- |
|
596 // |
|
597 void CUniEditorInsertOperation::DoErrorWithoutStateChangeL() |
|
598 { |
|
599 /* |
|
600 Object need to be removed before possible new slide. |
|
601 RemoveObjectL removes also attachment. |
|
602 |
|
603 Only possible reason for leave in RemoveObjectL is failure of attachment deletion. |
|
604 Object will be left in Objectlist and in SmilModel. |
|
605 -> Remove only from model |
|
606 */ |
|
607 if ( iInsertedObject ) |
|
608 { |
|
609 if ( iInsertedSlide != -1 ) |
|
610 { |
|
611 iDocument.DataModel()->SmilModel().RemoveObjectL( iInsertedSlide, iInsertedObject, ETrue ); |
|
612 |
|
613 iDocument.DataModel()->SmilModel().RemoveSlide( iInsertedSlide ); |
|
614 iInsertedSlide = -1; |
|
615 } |
|
616 else |
|
617 { |
|
618 iDocument.DataModel()->SmilModel().RemoveObjectL( iDocument.CurrentSlide(), iInsertedObject, ETrue ); |
|
619 } |
|
620 |
|
621 iInsertedObject = NULL; |
|
622 } |
|
623 else |
|
624 { |
|
625 // attachment may still be there after compress or scaling operation, if it didn't fit |
|
626 // into message |
|
627 TMsvAttachmentId attaId( KMsvNullIndexEntryId ); |
|
628 if ( iNewInfo ) |
|
629 { |
|
630 if ( iImageOperation ) |
|
631 { |
|
632 iImageOperation->DetachAttachmentId( attaId ); |
|
633 } |
|
634 else |
|
635 { |
|
636 iVideoOperation->DetachAttachmentId( attaId ); |
|
637 } |
|
638 } |
|
639 |
|
640 if ( attaId != KMsvNullIndexEntryId ) |
|
641 { |
|
642 CMsvStore* store = iDocument.Mtm().Entry().EditStoreL(); |
|
643 CleanupStack::PushL( store ); |
|
644 MMsvAttachmentManager& manager = store->AttachmentManagerL(); |
|
645 MMsvAttachmentManagerSync& managerSync = store->AttachmentManagerExtensionsL(); |
|
646 managerSync.RemoveAttachmentL( CUniDataUtils::IndexPositionOfAttachmentL( manager, attaId ) ); |
|
647 store->CommitL(); |
|
648 CleanupStack::PopAndDestroy( store ); |
|
649 attaId = KMsvNullIndexEntryId; |
|
650 } |
|
651 } |
|
652 |
|
653 delete iNewInfo; |
|
654 iNewInfo = NULL; |
|
655 //If previous slide is -1 then reload first slide |
|
656 if ( iPreviousSlide != -1 || (iDocument.CurrentSlide()) == 0) |
|
657 { |
|
658 iOperationState = EUniInsertErrorReload; |
|
659 } |
|
660 else |
|
661 { |
|
662 iOperationState = EUniInsertErrorReport; |
|
663 } |
|
664 |
|
665 CompleteSelf( KErrNone ); |
|
666 } |
|
667 |
|
668 // --------------------------------------------------------- |
|
669 // CUniEditorInsertOperation::InsertedType |
|
670 // --------------------------------------------------------- |
|
671 // |
|
672 TMsgMediaType CUniEditorInsertOperation::InsertedType() |
|
673 { |
|
674 TMsgMediaType type = EMsgMediaUnknown; |
|
675 if ( iInsertedObject ) |
|
676 { |
|
677 type = iInsertedObject->MediaType(); |
|
678 } |
|
679 return type; |
|
680 } |
|
681 |
|
682 // --------------------------------------------------------- |
|
683 // CUniEditorInsertOperation::InsertedObject |
|
684 // --------------------------------------------------------- |
|
685 // |
|
686 CUniObject* CUniEditorInsertOperation::InsertedObject() |
|
687 { |
|
688 return iInsertedObject; |
|
689 } |
|
690 |
|
691 // --------------------------------------------------------- |
|
692 // CUniEditorInsertOperation::IsAddedAsAttachment |
|
693 // --------------------------------------------------------- |
|
694 // |
|
695 TBool CUniEditorInsertOperation::IsAddedAsAttachment() const |
|
696 { |
|
697 return iAddAsAttachment; |
|
698 } |
|
699 |
|
700 // --------------------------------------------------------- |
|
701 // CUniEditorInsertOperation::ObjectSaveReady |
|
702 // --------------------------------------------------------- |
|
703 // |
|
704 void CUniEditorInsertOperation::ObjectSaveReady( TInt aError ) |
|
705 { |
|
706 CompleteOperation( aError ); |
|
707 } |
|
708 |
|
709 // --------------------------------------------------------- |
|
710 // CUniEditorInsertOperation::SlideLoadReady |
|
711 // --------------------------------------------------------- |
|
712 // |
|
713 void CUniEditorInsertOperation::SlideLoadReady( TInt aError ) |
|
714 { |
|
715 CompleteOperation( aError ); |
|
716 } |
|
717 |
|
718 |
|
719 // --------------------------------------------------------- |
|
720 // CUniEditorInsertOperation::HandleOperationEvent |
|
721 // --------------------------------------------------------- |
|
722 // |
|
723 void CUniEditorInsertOperation::HandleOperationEvent( TUniEditorOperationType aOperation, |
|
724 TUniEditorOperationEvent /*aEvent*/ ) |
|
725 { |
|
726 if ( aOperation == EUniEditorOperationChangeSlide ) |
|
727 { |
|
728 if ( iChangeSlideOperation->GetErrors()->Count() ) |
|
729 { |
|
730 SetError( EUniInsertSlideChangeFailed ); |
|
731 iOperationState = EUniInsertErrorReport; |
|
732 } |
|
733 } |
|
734 else |
|
735 { |
|
736 TBool toErrorState = EFalse; |
|
737 |
|
738 if ( aOperation == EUniEditorOperationProcessImage ) |
|
739 { |
|
740 CArrayFixFlat<TInt>* errors = iImageOperation->GetErrors(); |
|
741 |
|
742 for ( TInt i = 0; i < errors->Count(); i++ ) |
|
743 { |
|
744 if ( errors->At( i ) != EUniProcessImgCompressSuccessful && |
|
745 !( errors->At( i ) == EUniProcessImgCouldNotScale && |
|
746 iDocument.CreationMode() != EMmsCreationModeRestricted ) && |
|
747 errors->At( i ) != EUniProcessImgCorrupted ) |
|
748 { |
|
749 toErrorState = ETrue; |
|
750 } |
|
751 SetError( errors->At( i ) ); |
|
752 } |
|
753 |
|
754 // Take ownership (even in case of possible errors) |
|
755 iNewInfo = iImageOperation->DetachImageInfo(); |
|
756 } |
|
757 else // EUniEditorOperationConvertVideo |
|
758 { |
|
759 CArrayFixFlat<TInt>* errors = iVideoOperation->GetErrors(); |
|
760 |
|
761 for ( TInt i = 0; i < errors->Count(); i++ ) |
|
762 { |
|
763 if ( errors->At( i ) != EUniConvertVidSuccessful ) |
|
764 { |
|
765 toErrorState = ETrue; |
|
766 } |
|
767 SetError( errors->At( i ) ); |
|
768 } |
|
769 |
|
770 // Take ownership (even in case of possible errors) |
|
771 iNewInfo = iVideoOperation->DetachVideoInfo(); |
|
772 } |
|
773 |
|
774 if ( iNewInfo ) |
|
775 { |
|
776 delete iOldInfo; |
|
777 iOldInfo = NULL; |
|
778 } |
|
779 |
|
780 if ( toErrorState ) |
|
781 { |
|
782 // Process image / video error |
|
783 iOperationState = EUniInsertError; |
|
784 |
|
785 delete iOldInfo; |
|
786 iOldInfo = NULL; |
|
787 } |
|
788 else |
|
789 { |
|
790 if ( !CheckModeForInsert( EFalse ) ) |
|
791 { |
|
792 iOperationState = EUniInsertError; |
|
793 |
|
794 delete iOldInfo; |
|
795 iOldInfo = NULL; |
|
796 } |
|
797 else |
|
798 { |
|
799 iOperationState = EUniInsertCheckSize; |
|
800 } |
|
801 } |
|
802 } |
|
803 |
|
804 CompleteOperation( KErrNone ); |
|
805 } |
|
806 |
|
807 |