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