mobilemessaging/unieditor/application/src/UniEditorSendUiOperation.cpp
changeset 0 72b543305e3a
child 24 696bfeff199e
equal deleted inserted replaced
-1:000000000000 0:72b543305e3a
       
     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:   CUniEditorSendUiOperation, operation for opening messages created by SendUI
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 // ========== INCLUDE FILES ================================
       
    21 
       
    22 #include <mmsconst.h>
       
    23 
       
    24 #include <unidatautils.h>
       
    25 #include <MsgMimeTypes.h>
       
    26 #include <unismilmodel.h>
       
    27 #include <MsgMediaInfo.h>
       
    28 #include <MsgTextInfo.h>
       
    29 #include <MsgImageInfo.h>
       
    30 #include <MsgVideoInfo.h>
       
    31 
       
    32 #include <MmsConformance.h>
       
    33 
       
    34 #include "UniEditorSendUiOperation.h"
       
    35 #include "UniEditorProcessTextOperation.h"
       
    36 
       
    37 // ========== EXTERNAL DATA STRUCTURES =====================
       
    38 
       
    39 // ========== EXTERNAL FUNCTION PROTOTYPES =================
       
    40 
       
    41 // ========== CONSTANTS ====================================
       
    42 
       
    43 const TUint KSendAsDeleteAllPercentage      = 80;   
       
    44 
       
    45 // ========== MACROS =======================================
       
    46 
       
    47 // ========== LOCAL CONSTANTS AND MACROS ===================
       
    48 
       
    49 // ========== MODULE DATA STRUCTURES =======================
       
    50 
       
    51 // ========== LOCAL FUNCTION PROTOTYPES ====================
       
    52 
       
    53 // ========== LOCAL FUNCTIONS ==============================
       
    54 
       
    55 // ========== MEMBER FUNCTIONS =============================
       
    56 
       
    57 // ---------------------------------------------------------
       
    58 // CUniEditorSendUiOperation::NewL
       
    59 //
       
    60 // Factory method.
       
    61 // ---------------------------------------------------------
       
    62 //
       
    63 CUniEditorSendUiOperation* CUniEditorSendUiOperation::NewL(
       
    64         MUniEditorOperationObserver& aObserver,
       
    65         CUniEditorDocument& aDocument,
       
    66         RFs& aFs )
       
    67     {
       
    68     CUniEditorSendUiOperation* self = 
       
    69         new ( ELeave ) CUniEditorSendUiOperation( aObserver, aDocument, aFs );
       
    70         
       
    71     CleanupStack::PushL( self );
       
    72     self->ConstructL();
       
    73     CleanupStack::Pop( self );
       
    74     
       
    75     return self;
       
    76     }
       
    77 
       
    78 // ---------------------------------------------------------
       
    79 // CUniEditorSendUiOperation::CUniEditorSendUiOperation
       
    80 //
       
    81 // Constructor.
       
    82 // ---------------------------------------------------------
       
    83 //
       
    84 CUniEditorSendUiOperation::CUniEditorSendUiOperation(
       
    85         MUniEditorOperationObserver& aObserver,
       
    86         CUniEditorDocument& aDocument,
       
    87         RFs& aFs ) :
       
    88     CUniEditorOperation( aObserver, aDocument, aFs, EUniEditorOperationSendUi )
       
    89     {
       
    90     }
       
    91 
       
    92 
       
    93 // ---------------------------------------------------------
       
    94 // CUniEditorSendUiOperation::CUniEditorSendUiOperation
       
    95 //
       
    96 // Destructor.
       
    97 // ---------------------------------------------------------
       
    98 //
       
    99 CUniEditorSendUiOperation::~CUniEditorSendUiOperation()
       
   100     {
       
   101     Cancel();
       
   102     delete iImageOperation;
       
   103     delete iVideoOperation;
       
   104 #ifdef RD_MSG_XHTML_SUPPORT 
       
   105     delete iTextOperation;
       
   106 #endif        
       
   107     }
       
   108 
       
   109 // ---------------------------------------------------------
       
   110 // CUniEditorSendUiOperation::Start
       
   111 // ---------------------------------------------------------
       
   112 //
       
   113 void CUniEditorSendUiOperation::Start()
       
   114     {
       
   115     ResetErrors();
       
   116     
       
   117     iOperationState = EUniEditorSendUiCheck;
       
   118     iObjectsSize = 0;
       
   119     iObjectNum = 0;
       
   120     iSlideNum = 0;
       
   121     iDeleteAll = EFalse;
       
   122     
       
   123     CompleteSelf( KErrNone );
       
   124     }
       
   125 
       
   126 // ---------------------------------------------------------
       
   127 // CUniEditorSendUiOperation::ConstructL
       
   128 //
       
   129 // 2nd phase constructor.
       
   130 // ---------------------------------------------------------
       
   131 //
       
   132 void CUniEditorSendUiOperation::ConstructL()
       
   133     {
       
   134     BaseConstructL();
       
   135     
       
   136     iDeleteAllLimit = ( iDocument.MaxMessageSize() * KSendAsDeleteAllPercentage ) / 100;
       
   137     }
       
   138 
       
   139 // ---------------------------------------------------------
       
   140 // CUniEditorSendUiOperation::DoCancelCleanup
       
   141 //
       
   142 // ---------------------------------------------------------
       
   143 //
       
   144 void CUniEditorSendUiOperation::DoCancelCleanup()
       
   145     {
       
   146     if ( iImageOperation )
       
   147         {
       
   148         iImageOperation->Cancel();
       
   149         }
       
   150         
       
   151     if ( iVideoOperation )
       
   152         {
       
   153         iVideoOperation->Cancel();
       
   154         }  
       
   155 #ifdef RD_MSG_XHTML_SUPPORT 
       
   156     if ( iTextOperation )
       
   157         {
       
   158         iTextOperation->Cancel();
       
   159         }
       
   160 #endif      
       
   161     }
       
   162 
       
   163 // ---------------------------------------------------------
       
   164 // CUniEditorSendUiOperation::RunL
       
   165 //
       
   166 // ---------------------------------------------------------
       
   167 //
       
   168 void CUniEditorSendUiOperation::RunL()
       
   169     { 
       
   170     PrintOperationAndState();
       
   171     
       
   172     if ( !SetErrorAndReport( iStatus.Int() ) )
       
   173         {
       
   174         DoSendUiStepL();
       
   175         }
       
   176     }
       
   177 
       
   178 // ---------------------------------------------------------
       
   179 // CUniEditorSendUiOperation::DoSendUiStepL
       
   180 //
       
   181 // ---------------------------------------------------------
       
   182 //
       
   183 void CUniEditorSendUiOperation::DoSendUiStepL()
       
   184     {
       
   185     switch ( iOperationState )
       
   186         {
       
   187         case EUniEditorSendUiCheck:
       
   188             {
       
   189             DoSendUiCheckL();
       
   190             break;
       
   191             }
       
   192         case EUniEditorSendUiPrepareObject:
       
   193             {
       
   194             DoSendUiPrepareObjectL();
       
   195             break;
       
   196             }
       
   197         case EUniEditorSendUiPrepareAttachments:
       
   198             {
       
   199             DoSendUiPrepareAttachmentsL();
       
   200             break;
       
   201             }
       
   202         case EUniEditorSendUiEnd:
       
   203             {
       
   204             iObserver.EditorOperationEvent( EUniEditorOperationSendUi,
       
   205                                             EUniEditorOperationComplete );
       
   206             break;
       
   207             }
       
   208         default:
       
   209             {
       
   210             iObserver.EditorOperationEvent( EUniEditorOperationSendUi,
       
   211                                             EUniEditorOperationError );
       
   212             break;
       
   213             }
       
   214         }
       
   215     }
       
   216 
       
   217 // ---------------------------------------------------------
       
   218 // CUniEditorSendUiOperation::DoSendUiCheckL
       
   219 // 
       
   220 // Check message content when message created by SendAs
       
   221 // ---------------------------------------------------------
       
   222 //
       
   223 void CUniEditorSendUiOperation::DoSendUiCheckL()
       
   224     {
       
   225     if ( iDocument.DataModel()->ObjectList().Count() ||
       
   226          iDocument.DataModel()->AttachmentList().Count() )
       
   227         {
       
   228         DoCheckFilesL();
       
   229         }
       
   230         
       
   231     if ( iDocument.DataModel()->ObjectList().Count() )
       
   232         {
       
   233         iDocument.DataModel()->SmilModel().SortSlidesL();
       
   234         }
       
   235         
       
   236     iOperationState = EUniEditorSendUiPrepareObject;
       
   237     CompleteSelf( KErrNone );
       
   238     }
       
   239 
       
   240 // ---------------------------------------------------------
       
   241 // CUniEditorSendUiOperation::DoCheckFilesL
       
   242 // ---------------------------------------------------------
       
   243 //
       
   244 void CUniEditorSendUiOperation::DoCheckFilesL()
       
   245     {
       
   246     TInt slideCount = iDocument.DataModel()->SmilModel().SlideCount();
       
   247 
       
   248     //It's important to go from end to beginning
       
   249     //because slides may be removed
       
   250     for ( TInt i = slideCount; --i >= 0 ; )
       
   251         {
       
   252         //It's important to go from end to beginning
       
   253         //because objects may be removed
       
   254         for ( TInt ii = iDocument.DataModel()->SmilModel().SlideObjectCount(i); --ii >= 0 ;)
       
   255             {
       
   256             CUniObject* obj = iDocument.DataModel()->SmilModel().GetObjectByIndex( i, ii );
       
   257 
       
   258             TMmsConformance conformance = 
       
   259                 iDocument.DataModel()->MmsConformance().MediaConformance( *obj->MediaInfo() );
       
   260 
       
   261             TUint32 confStatus = conformance.iConfStatus;
       
   262 
       
   263             TBool remove = EFalse;
       
   264             if ( confStatus & EMmsConfNokDRM )
       
   265                 {
       
   266                 remove = ETrue;
       
   267                 SetError( EUniSendUiForbidden );
       
   268                 }
       
   269             else if ( confStatus & EMmsConfNokCorrupt )
       
   270                 {
       
   271                 SetError( EUniSendUiCorrupted );
       
   272                 }
       
   273             else if ( confStatus & ( EMmsConfNokNotEnoughInfo | EMmsConfNokNotSupported ) ||
       
   274                       ( iDocument.CreationMode() == EMmsCreationModeRestricted &&
       
   275                         confStatus & EMmsConfNokFreeModeOnly ) )
       
   276                 {
       
   277                 remove = ETrue;
       
   278                 SetError( EUniSendUiUnsupported );
       
   279                 }
       
   280             else if ( !conformance.iCanAdapt && 
       
   281                       confStatus & EMmsConfNokTooBig ) 
       
   282                 {
       
   283                 remove = ETrue;
       
   284                 SetError( EUniSendUiTooBig );
       
   285                 }
       
   286                 
       
   287             if ( remove )
       
   288                 {
       
   289                 iDocument.DataModel()->SmilModel().RemoveObjectByIndexL( i, ii );
       
   290                 remove = EFalse;
       
   291                 }
       
   292             }
       
   293               
       
   294         if ( !iDocument.DataModel()->SmilModel().SlideObjectCount( i ) )
       
   295             {
       
   296             iDocument.DataModel()->SmilModel().RemoveSlide( i );
       
   297             }
       
   298         }  
       
   299 
       
   300     CUniObjectList& attachments = iDocument.DataModel()->AttachmentList();
       
   301     //It's important to go from end to beginning
       
   302     //because attachments may be removed
       
   303     for ( TInt j = attachments.Count(); --j >= 0 ; )
       
   304         {
       
   305         CUniObject* obj = attachments.GetByIndex( j );
       
   306         
       
   307         TMmsConformance conformance = 
       
   308             iDocument.DataModel()->MmsConformance().MediaConformance( *obj->MediaInfo() );
       
   309 
       
   310         TUint32 confStatus = conformance.iConfStatus;
       
   311         
       
   312         if ( iDocument.CreationMode() != EMmsCreationModeRestricted )
       
   313             {
       
   314             // Mask "FreeModeOnly" away in free mode
       
   315             confStatus &= ~EMmsConfNokFreeModeOnly;
       
   316             // Mask "Scaling needed" away in free mode
       
   317             confStatus &= ~EMmsConfNokScalingNeeded;
       
   318             }
       
   319         
       
   320         if ( confStatus & EMmsConfNokDRM )
       
   321             {
       
   322             attachments.RemoveObjectL( obj );
       
   323             SetError( EUniSendUiForbidden );
       
   324             delete obj;
       
   325             }
       
   326         else if ( confStatus & EMmsConfNokCorrupt )
       
   327             {
       
   328             SetError( EUniSendUiCorrupted );
       
   329             }
       
   330         else if ( confStatus != EMmsConfOk )
       
   331             {
       
   332             attachments.RemoveObjectL( obj );
       
   333             SetError( EUniSendUiUnsupported );
       
   334             delete obj;
       
   335             }
       
   336         }
       
   337     }
       
   338 
       
   339 // ---------------------------------------------------------
       
   340 // CUniEditorSendUiOperation::DoSendUiPrepareObjectL
       
   341 // 
       
   342 // Processes images and checks whether message size is below
       
   343 // max size. If not removes as many objects as needed.
       
   344 // ---------------------------------------------------------
       
   345 //
       
   346 void CUniEditorSendUiOperation::DoSendUiPrepareObjectL()
       
   347     {
       
   348     VerifyPreparedObjectL();
       
   349         
       
   350     CUniObject* obj = iDocument.DataModel()->SmilModel().GetObjectByIndex( iSlideNum, iObjectNum );
       
   351     
       
   352     if ( obj )
       
   353         {
       
   354         DoPrepareObjectL( obj );
       
   355         }
       
   356     else
       
   357         {
       
   358         iOperationState = EUniEditorSendUiPrepareAttachments;
       
   359         CompleteSelf( KErrNone );
       
   360         }
       
   361     }
       
   362 
       
   363 // ---------------------------------------------------------
       
   364 // CUniEditorSendUiOperation::VerifyPreparedObjectL
       
   365 // ---------------------------------------------------------
       
   366 //
       
   367 void CUniEditorSendUiOperation::VerifyPreparedObjectL()
       
   368     {
       
   369     if ( iPreparedObject )
       
   370         {
       
   371         TBool remove = EFalse;
       
   372         
       
   373         // Conformance status check!
       
   374         TMmsConformance conformance = 
       
   375             iDocument.DataModel()->MmsConformance().MediaConformance( *iPreparedObject->MediaInfo() );
       
   376 
       
   377         TUint32 confStatus = conformance.iConfStatus;
       
   378         if ( iPreparedObject->MediaType() == EMsgMediaText )
       
   379             {
       
   380             // Mask "ConversionNeeded" away for text objects
       
   381             // -> Will be always converted to UTF-8 anyway
       
   382             confStatus &= ~EMmsConfNokConversionNeeded;
       
   383             }
       
   384             
       
   385         if ( iDocument.CreationMode() != EMmsCreationModeRestricted )
       
   386             {
       
   387             // Mask "FreeModeOnly" away in free mode
       
   388             confStatus &= ~EMmsConfNokFreeModeOnly;
       
   389             // Mask "Scaling needed" away in free mode
       
   390             confStatus &= ~EMmsConfNokScalingNeeded;
       
   391             //Mask "Corrupted" away in free mode
       
   392             confStatus &= ~EMmsConfNokCorrupt;
       
   393             }
       
   394             
       
   395         // Mask "Too big" away as there is a separate check for that
       
   396         confStatus &= ~EMmsConfNokTooBig;
       
   397         
       
   398         if ( confStatus != EMmsConfOk )
       
   399             {
       
   400             SetError( EUniSendUiUnsupported );
       
   401             remove = ETrue;
       
   402             }
       
   403 
       
   404         TInt currentSize = iObjectsSize + 
       
   405                            iPreparedObject->Size() + 
       
   406                            iDocument.DataModel()->SmilModel().SmilComposeSize( iSlideNum + 1, iObjectNum + 1 );
       
   407 
       
   408         if ( !remove && 
       
   409              TUint( currentSize ) > iDocument.MaxMessageSize() )
       
   410             {
       
   411             // Remove if above max size
       
   412             if ( TUint( iPreviousSize ) > iDeleteAllLimit )
       
   413                 {
       
   414                 //Once above "delete all limit" delete all the rest.
       
   415                 iDeleteAll = ETrue;
       
   416                 }
       
   417             remove = ETrue;
       
   418             SetError( EUniSendUiTooBig );
       
   419             }
       
   420         else
       
   421             {
       
   422             // Don't remove. Update previous size.
       
   423             iPreviousSize = currentSize;
       
   424             }
       
   425 
       
   426         if ( remove )
       
   427             {
       
   428             iDocument.DataModel()->SmilModel().RemoveObjectByIndexL( iSlideNum, iObjectNum );
       
   429             
       
   430             if ( !iDocument.DataModel()->SmilModel().SlideObjectCount( iSlideNum ) )
       
   431                 {
       
   432                 iDocument.DataModel()->SmilModel().RemoveSlide( iSlideNum );
       
   433                 }
       
   434             }
       
   435         else
       
   436             {
       
   437             iObjectsSize += iPreparedObject->Size();
       
   438             iObjectNum++;
       
   439             
       
   440             if ( iObjectNum >= iDocument.DataModel()->SmilModel().SlideObjectCount( iSlideNum ) )
       
   441                 {
       
   442                 iSlideNum++;
       
   443                 iObjectNum = 0;
       
   444                 }
       
   445             }
       
   446         }
       
   447     }
       
   448 
       
   449 // ---------------------------------------------------------
       
   450 // CUniEditorSendUiOperation::DoPrepareObjectL
       
   451 // ---------------------------------------------------------
       
   452 //
       
   453 void CUniEditorSendUiOperation::DoPrepareObjectL( CUniObject* aObject )
       
   454     {
       
   455     switch ( aObject->MediaType() )
       
   456         {
       
   457         case EMsgMediaImage:
       
   458             {
       
   459             if ( !iImageOperation )
       
   460                 {
       
   461                 iImageOperation = CUniEditorProcessImageOperation::NewL( *this, iDocument, iFs );
       
   462                 }
       
   463                 
       
   464             // Processes if needed:
       
   465             iImageOperation->Process( static_cast<CMsgImageInfo*>( aObject->MediaInfo() ),
       
   466                                       aObject->AttachmentId(),
       
   467                                       iPreviousSize );
       
   468             iPreparedObject = aObject;
       
   469             
       
   470             SetPending();
       
   471             return;
       
   472             }
       
   473         case EMsgMediaVideo:
       
   474             {
       
   475             //We need video conversion only for mp4 videos
       
   476             if ( aObject->MimeType().Compare( KMsgMimeVideoMp4 ) == 0   )
       
   477                 {
       
   478                 if ( CUniEditorConvertVideoOperation::IsImplementedL() )
       
   479                     {
       
   480                     if ( !iVideoOperation )
       
   481                         { 
       
   482                         iVideoOperation = CUniEditorConvertVideoOperation::NewL( *this, iDocument, iFs );
       
   483                         }
       
   484                     
       
   485                     // Processes if needed:
       
   486                     iVideoOperation->Process( static_cast<CMsgVideoInfo*>( aObject->MediaInfo() ),
       
   487                                               aObject->AttachmentId(),
       
   488                                               iDocument.MaxMessageSize() );
       
   489                     iPreparedObject = aObject;
       
   490                     
       
   491                     SetPending();
       
   492                     return;
       
   493                     }
       
   494                 }
       
   495             break;
       
   496             }
       
   497         case EMsgMediaXhtml:
       
   498             {
       
   499 #ifdef RD_MSG_XHTML_SUPPORT 
       
   500             // Processes all XHTML objects and converts them into plain text.
       
   501             iTextOperation = CUniEditorProcessTextOperation::NewL( *this, iDocument, iFs );
       
   502             iTextOperation->Start();
       
   503             
       
   504             SetPending();
       
   505             return;
       
   506 #else
       
   507             break;
       
   508 #endif
       
   509             }
       
   510         case EMsgMediaText:
       
   511         case EMsgMediaAudio:
       
   512         default:
       
   513             {
       
   514             // nothing
       
   515             break;
       
   516             }
       
   517         }
       
   518         
       
   519     iPreparedObject = aObject;
       
   520     CompleteSelf( KErrNone );
       
   521     }
       
   522 
       
   523 // ---------------------------------------------------------
       
   524 // CUniEditorSendUiOperation::DoSendUiPrepareAttachmentsL
       
   525 // ---------------------------------------------------------
       
   526 //
       
   527 void CUniEditorSendUiOperation::DoSendUiPrepareAttachmentsL()
       
   528     {
       
   529     TInt smilSize = iObjectsSize + iDocument.DataModel()->SmilModel().SmilComposeSize();
       
   530     
       
   531     TInt attaSize = 0;
       
   532     TInt j = 0;
       
   533     
       
   534     CUniObjectList& attachments = iDocument.DataModel()->AttachmentList();
       
   535     
       
   536     if ( attachments.Count() )
       
   537         {
       
   538         while ( TUint( smilSize + attaSize ) < iDocument.MaxMessageSize() )
       
   539             {
       
   540             attaSize += attachments.GetByIndex( j )->Size();
       
   541             j++;
       
   542             if ( j >= attachments.Count()  && 
       
   543                  TUint( smilSize + attaSize ) < iDocument.MaxMessageSize() )
       
   544                 {
       
   545                 j++;
       
   546                 break;
       
   547                 }
       
   548             }
       
   549         j--;
       
   550         while ( j < attachments.Count() )
       
   551             {
       
   552             CUniObject* obj = attachments.GetByIndex( j );
       
   553             attachments.RemoveObjectL( obj );
       
   554             SetError( EUniSendUiTooBig );
       
   555             delete obj;
       
   556             }
       
   557         }
       
   558     iOperationState = EUniEditorSendUiEnd;
       
   559     CompleteSelf( KErrNone );
       
   560     }
       
   561 
       
   562 // ---------------------------------------------------------
       
   563 // CUniEditorSendUiOperation::HandleOperationEvent
       
   564 // ---------------------------------------------------------
       
   565 //
       
   566 void CUniEditorSendUiOperation::HandleOperationEvent( TUniEditorOperationType aOperation,
       
   567                                                       TUniEditorOperationEvent /*aEvent*/ )
       
   568     {
       
   569     TBool remove( EFalse );
       
   570     
       
   571     TMsvAttachmentId attaId( KMsvNullIndexEntryId );
       
   572     CMsgMediaInfo* info = NULL;
       
   573     
       
   574     if ( aOperation == EUniEditorOperationProcessImage )
       
   575         {
       
   576         // Process image error handling
       
   577         CArrayFixFlat<TInt>* errors = iImageOperation->GetErrors();
       
   578         for ( TInt i = 0; i < errors->Count(); i++ )
       
   579             {
       
   580             if ( errors->At( i ) == EUniProcessImgUserAbort )
       
   581                 {
       
   582                 iOperationState = EUniEditorSendUiEnd;
       
   583                 }
       
   584             else if ( ( errors->At( i ) == EUniProcessImgCouldNotScale &&
       
   585                         iDocument.CreationMode() == EMmsCreationModeRestricted ) ||
       
   586                       errors->At( i ) == EUniProcessImgNotFound )
       
   587                 {
       
   588                 remove = ETrue;
       
   589                 }
       
   590             
       
   591             SetError( errors->At( i ) );
       
   592             }
       
   593         
       
   594         info = iImageOperation->DetachImageInfo();
       
   595         iImageOperation->DetachAttachmentId( attaId );
       
   596         }
       
   597     else if ( aOperation == EUniEditorOperationConvertVideo )
       
   598         {
       
   599         // Convert video error handling
       
   600         CArrayFixFlat<TInt>* errors = iVideoOperation->GetErrors();
       
   601         for ( TInt i = 0; i < errors->Count(); i++ )
       
   602             {
       
   603             if ( errors->At( i ) == EUniConvertVidUserAbort )
       
   604                 {
       
   605                 iOperationState = EUniEditorSendUiEnd;
       
   606                 }
       
   607             else if ( ( errors->At( i ) == EUniConvertVidFailed &&
       
   608                         iDocument.CreationMode() == EMmsCreationModeRestricted ) ||
       
   609                       errors->At( i ) == EUniConvertVidNotFound )
       
   610                 {
       
   611                 remove = ETrue;
       
   612                 }
       
   613             
       
   614             SetError( errors->At( i ) );
       
   615             }
       
   616         
       
   617         info = iVideoOperation->DetachVideoInfo();
       
   618         iVideoOperation->DetachAttachmentId( attaId );
       
   619         }
       
   620 #ifdef RD_MSG_XHTML_SUPPORT 
       
   621     else if ( aOperation == EUniEditorOperationProcessText )
       
   622         {
       
   623         CArrayFixFlat<TInt>* errors = iTextOperation->GetErrors();
       
   624         for ( TInt i = 0; i < errors->Count(); i++ )
       
   625             {
       
   626             SetError( errors->At( i ) );
       
   627             }
       
   628         }
       
   629 #endif
       
   630     
       
   631     if ( info )
       
   632         {
       
   633         TRAPD( error,
       
   634                iDocument.DataModel()->SmilModel().RemoveObjectL( iSlideNum, iPreparedObject ) );
       
   635                
       
   636         if ( !error )
       
   637             {
       
   638             iPreparedObject = NULL;
       
   639             TRAP_IGNORE( iPreparedObject = iDocument.DataModel()->SmilModel().AddStoredObjectL( iSlideNum, attaId, info ) );
       
   640             }
       
   641         else // --> original object remains...
       
   642             {
       
   643             delete info;
       
   644             }
       
   645         }
       
   646 
       
   647     if ( remove && iPreparedObject )
       
   648         {
       
   649         TRAPD( err, iDocument.DataModel()->SmilModel().RemoveObjectByIndexL( iSlideNum, iObjectNum ) );
       
   650         
       
   651         if ( !err && 
       
   652              !iDocument.DataModel()->SmilModel().SlideObjectCount( iSlideNum ) )
       
   653             {
       
   654             iDocument.DataModel()->SmilModel().RemoveSlide( iSlideNum );
       
   655             }
       
   656             
       
   657         iPreparedObject = NULL;
       
   658         }
       
   659         
       
   660     //else --> original object remains...
       
   661     CompleteOperation( KErrNone );
       
   662     }
       
   663 
       
   664 // EOF