messagingappbase/msgeditor/modelsrc/MsgEditorDocument.cpp
changeset 0 72b543305e3a
equal deleted inserted replaced
-1:000000000000 0:72b543305e3a
       
     1 /*
       
     2 * Copyright (c) 2002 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:  MsgEditorDocument implementation
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 // ========== INCLUDE FILES ================================
       
    21 
       
    22 #include <mtclbase.h>
       
    23 #include <mtmuibas.h>                   // MTM UI base
       
    24 #include <mtmdef.h>
       
    25 
       
    26 #include <MuiuMsgEditorLauncher.h>      // for TEditorParameters
       
    27 #include <MuiuOperationWait.h>          // for CMuiuOperationWait
       
    28 
       
    29 #include "MsgEditorDocument.h"          // module header
       
    30 #include "MsgEditorModelPanic.h"        // Panics
       
    31 #include "MsgEditorLauncher.h"
       
    32 #include "MsgEditorModel.h"             // Model
       
    33 #include "MsgEditorModelObserver.h"     // MMsgEditorModelObserver
       
    34 #include "MsgAttachmentModel.h"
       
    35 #include "MsgEditorAppUi.h"             // MsgEditorAppUi
       
    36 
       
    37 // ========== EXTERNAL DATA STRUCTURES =====================
       
    38 
       
    39 // ========== EXTERNAL FUNCTION PROTOTYPES =================
       
    40 
       
    41 // ========== CONSTANTS ====================================
       
    42 
       
    43 const TInt KOperationGranularity = 4;
       
    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 // CMsgEditorDocument::CMsgEditorDocument
       
    59 //
       
    60 // Constructor.
       
    61 // ---------------------------------------------------------
       
    62 //
       
    63 EXPORT_C CMsgEditorDocument::CMsgEditorDocument( CEikApplication& aApp ) :
       
    64     CEikDocument( aApp )
       
    65     {
       
    66     }
       
    67 
       
    68 // ---------------------------------------------------------
       
    69 // CMsgEditorDocument::~CMsgEditorDocument
       
    70 //
       
    71 // Destructor.
       
    72 // ---------------------------------------------------------
       
    73 //
       
    74 EXPORT_C CMsgEditorDocument::~CMsgEditorDocument()
       
    75     {
       
    76     if ( iOpWatchers )
       
    77         {
       
    78         iOpWatchers->ResetAndDestroy();
       
    79         }
       
    80     delete iOpWatchers;
       
    81     delete iModel;
       
    82     delete iAttachmentModel;
       
    83     iAttachmentModel = NULL;
       
    84     }
       
    85 
       
    86 // ---------------------------------------------------------
       
    87 // CMsgEditorDocument::SetEntryWithoutNotificationL
       
    88 //
       
    89 // Set given entry to be current context.
       
    90 // ---------------------------------------------------------
       
    91 //
       
    92 EXPORT_C void CMsgEditorDocument::SetEntryWithoutNotificationL( TMsvId aId )
       
    93     {
       
    94     __ASSERT_DEBUG( ( &( iModel->Session() ) != NULL ), Panic( ENoSession ) );
       
    95 
       
    96     iModel->SetEntryL( aId );
       
    97     }
       
    98 
       
    99 // ---------------------------------------------------------
       
   100 // CMsgEditorDocument::SetEntryL
       
   101 //
       
   102 // Set given entry to be current context and notifies after change.
       
   103 // ---------------------------------------------------------
       
   104 //
       
   105 EXPORT_C void CMsgEditorDocument::SetEntryL( TMsvId aId )
       
   106     {
       
   107     SetEntryWithoutNotificationL( aId );
       
   108 #ifdef RD_MSG_FAST_PREV_NEXT
       
   109     SetMsgAsReadL();
       
   110 #endif
       
   111     EntryChangedL();
       
   112     }
       
   113 
       
   114 // ---------------------------------------------------------
       
   115 // CMsgEditorDocument::Entry
       
   116 //
       
   117 // Return context.
       
   118 // ---------------------------------------------------------
       
   119 //
       
   120 EXPORT_C const TMsvEntry& CMsgEditorDocument::Entry() const
       
   121     {
       
   122     __ASSERT_DEBUG( HasModel(), Panic( ENoMessageEntry ) );
       
   123 
       
   124     return iModel->Entry();
       
   125     }
       
   126 
       
   127 // ---------------------------------------------------------
       
   128 // CMsgEditorDocument::Session
       
   129 //
       
   130 // Return session.
       
   131 // ---------------------------------------------------------
       
   132 //
       
   133 EXPORT_C CMsvSession& CMsgEditorDocument::Session() const
       
   134     {
       
   135     __ASSERT_DEBUG( iModel, Panic( ENoSession ) );
       
   136 
       
   137     return iModel->Session();
       
   138     }
       
   139 
       
   140 // ---------------------------------------------------------
       
   141 // CMsgEditorDocument::CurrentEntry
       
   142 //
       
   143 // Returns CMsvEntry of the current context.
       
   144 // ---------------------------------------------------------
       
   145 //
       
   146 EXPORT_C CMsvEntry& CMsgEditorDocument::CurrentEntry() const
       
   147     {
       
   148     __ASSERT_DEBUG( HasModel(), Panic( ENoMessageEntry ) );
       
   149 
       
   150     return iModel->Mtm().Entry();
       
   151     }
       
   152 
       
   153 // ---------------------------------------------------------
       
   154 // CMsgEditorDocument::Mtm
       
   155 //
       
   156 // Returns the current Mtm.
       
   157 // ---------------------------------------------------------
       
   158 //
       
   159 EXPORT_C CBaseMtm& CMsgEditorDocument::Mtm() const
       
   160     {
       
   161     __ASSERT_DEBUG( HasModel(), Panic( ENoMessageEntry ) );
       
   162 
       
   163     return iModel->Mtm();
       
   164     }
       
   165 
       
   166 // ---------------------------------------------------------
       
   167 // CMsgEditorDocument::MtmUi
       
   168 //
       
   169 // to be deprecated
       
   170 // ---------------------------------------------------------
       
   171 //
       
   172 EXPORT_C CBaseMtmUi& CMsgEditorDocument::MtmUi() const
       
   173     {
       
   174     __ASSERT_DEBUG( HasModel(), Panic( ENoMessageEntry ) );
       
   175     CBaseMtmUi* retVal = NULL;
       
   176     TRAP_IGNORE( retVal = &(iModel->MtmUiL() ) );
       
   177     return *retVal;
       
   178     }
       
   179 
       
   180 // ---------------------------------------------------------
       
   181 // CMsgEditorDocument::MtmUiData
       
   182 //
       
   183 // to be deprecated
       
   184 // ---------------------------------------------------------
       
   185 //
       
   186 EXPORT_C CBaseMtmUiData& CMsgEditorDocument::MtmUiData() const
       
   187     {
       
   188     __ASSERT_DEBUG( HasModel(), Panic( ENoMessageEntry ) );
       
   189     CBaseMtmUiData* retVal = NULL;
       
   190     TRAP_IGNORE( retVal = &(iModel->MtmUiDataL() ) );
       
   191     return *retVal;
       
   192     }
       
   193 
       
   194 // ---------------------------------------------------------
       
   195 // CMsgEditorDocument::MtmUiL
       
   196 //
       
   197 // Returns the current MtmUi.
       
   198 // ---------------------------------------------------------
       
   199 //
       
   200 EXPORT_C CBaseMtmUi& CMsgEditorDocument::MtmUiL() const
       
   201     {
       
   202     __ASSERT_DEBUG( HasModel(), Panic( ENoMessageEntry ) );
       
   203 
       
   204     return iModel->MtmUiL();
       
   205     }
       
   206 
       
   207 // ---------------------------------------------------------
       
   208 // CMsgEditorDocument::MtmUiDataL
       
   209 //
       
   210 // Returns the current MtmUiData.
       
   211 // ---------------------------------------------------------
       
   212 //
       
   213 EXPORT_C CBaseMtmUiData& CMsgEditorDocument::MtmUiDataL() const
       
   214     {
       
   215     __ASSERT_DEBUG( HasModel(), Panic( ENoMessageEntry ) );
       
   216 
       
   217     return iModel->MtmUiDataL();
       
   218     }
       
   219     
       
   220 // ---------------------------------------------------------
       
   221 // CMsgEditorDocument::PrepareMtmL
       
   222 //
       
   223 // Loads client and ui mtm's. Set clietn mtm
       
   224 // to have some context
       
   225 // ---------------------------------------------------------
       
   226 //
       
   227 EXPORT_C void CMsgEditorDocument::PrepareMtmL( const TUid aMtmType )
       
   228     {
       
   229     iModel->PrepareMtmL( aMtmType );
       
   230     }
       
   231 
       
   232 // ---------------------------------------------------------
       
   233 // CMsgEditorDocument::RestoreL
       
   234 //
       
   235 // Called (by the environment) when editor or viewer is opened embedded.
       
   236 // ---------------------------------------------------------
       
   237 //
       
   238 EXPORT_C void CMsgEditorDocument::RestoreL(
       
   239         const CStreamStore& aStore,
       
   240         const CStreamDictionary& aStreamDic )
       
   241     {
       
   242     TEditorParameters params;
       
   243     RStoreReadStream stream;
       
   244 
       
   245     stream.OpenLC( aStore, aStreamDic.At( KUidMsvEditorParameterValue ) );
       
   246     params.InternalizeL( stream );
       
   247     CleanupStack::PopAndDestroy();  // stream
       
   248 
       
   249     LaunchParametersL( params );
       
   250     EntryChangedL();
       
   251     PrepareToLaunchL( static_cast<CMsgEditorAppUi*>( iAppUi ) );
       
   252     }
       
   253 
       
   254 // ---------------------------------------------------------
       
   255 // CMsgEditorDocument::HasModel
       
   256 //
       
   257 // Check if model is already created.
       
   258 // ---------------------------------------------------------
       
   259 //
       
   260 EXPORT_C TBool CMsgEditorDocument::HasModel() const
       
   261     {
       
   262     return ( iModel && NULL != &( iModel->Mtm() ) );
       
   263     }
       
   264 
       
   265 // ---------------------------------------------------------
       
   266 // CMsgEditorDocument::ConstructL
       
   267 //
       
   268 // 2nd phase constructor.
       
   269 // ---------------------------------------------------------
       
   270 //
       
   271 EXPORT_C void CMsgEditorDocument::ConstructL()
       
   272     {
       
   273     iModel = new ( ELeave ) CMsgEditorModel();
       
   274     iModel->ConstructL();
       
   275     iOpWatchers = new ( ELeave ) CSingleOpWatchers( KOperationGranularity );
       
   276 
       
   277     iAttachmentModel = CreateNewAttachmentModelL( EFalse );
       
   278     iAttachmentModel->SetObserver( this );
       
   279     }
       
   280 
       
   281 // ---------------------------------------------------------
       
   282 // CMsgEditorDocument::PrepareToLaunchL
       
   283 //
       
   284 // Calls LaunchView() function after all pre-launch steps are completed.
       
   285 // ---------------------------------------------------------
       
   286 //
       
   287 EXPORT_C void CMsgEditorDocument::PrepareToLaunchL(
       
   288     MMsgEditorLauncher* aLauncher )
       
   289     {
       
   290     __ASSERT_DEBUG( iModel, Panic( ENoMessageEntry ) );
       
   291 
       
   292     iModel->iLaunchWait--;
       
   293 
       
   294     if ( iModel->iLaunchWait <= 0 )
       
   295         {
       
   296         __ASSERT_DEBUG( aLauncher, Panic( EViewNotReady ) );
       
   297 
       
   298         aLauncher->LaunchViewL();
       
   299         iLaunched = ETrue;
       
   300         }
       
   301     }
       
   302 
       
   303 // ---------------------------------------------------------
       
   304 // CMsgEditorDocument::LaunchParametersL
       
   305 //
       
   306 // Handle command line parameters.
       
   307 // ---------------------------------------------------------
       
   308 //
       
   309 EXPORT_C void CMsgEditorDocument::LaunchParametersL(
       
   310     const TEditorParameters& aParameters )
       
   311     {
       
   312     iLaunchFlags = aParameters.iFlags;
       
   313 
       
   314     iModel->Wait();
       
   315 
       
   316     if ( aParameters.iFlags & EMsgCreateMessageToService )
       
   317         {
       
   318         // Create new message in given folder/service.
       
   319         const TMsvId id = CreateNewL( aParameters.iId, DefaultMsgFolder() );
       
   320         SetEntryWithoutNotificationL( id );
       
   321         }
       
   322     else if ( aParameters.iFlags & EMsgCreateNewMessage )
       
   323         {
       
   324         // create new in folder.
       
   325         const TMsvId id = CreateNewL(DefaultMsgService(), aParameters.iId);
       
   326         SetEntryWithoutNotificationL(id);
       
   327         }
       
   328     else if ( aParameters.iFlags & EMsgForwardMessage       ||
       
   329              aParameters.iFlags & EMsgReplyToMessageSender ||
       
   330              aParameters.iFlags & EMsgReplyToMessageAll )
       
   331         {
       
   332         
       
   333         const TMsvId id = ChangeContextL( aParameters );
       
   334         
       
   335          // Save priority of forwarded message from original entry as
       
   336          // entry is changed on SetEntryWithoutNotificationL
       
   337         TMsvPriority priority( EMsvMediumPriority );
       
   338         if( aParameters.iFlags & EMsgForwardMessage )
       
   339             {
       
   340             priority = Entry().Priority();
       
   341             }
       
   342         
       
   343         SetEntryWithoutNotificationL( id );
       
   344 
       
   345         TBool changeEntry = EFalse;
       
   346         TMsvEntry tEntry = Entry();
       
   347         
       
   348         // Set saved priority for new entry.
       
   349         tEntry.SetPriority( priority ); 
       
   350         
       
   351         if ( tEntry.Visible() )
       
   352             {
       
   353             tEntry.SetVisible( EFalse );
       
   354             changeEntry = ETrue;
       
   355             }
       
   356 
       
   357         if ( !tEntry.InPreparation() )
       
   358             {
       
   359             tEntry.SetInPreparation( ETrue );
       
   360             changeEntry = ETrue;
       
   361             }
       
   362 
       
   363         if ( changeEntry )
       
   364             {
       
   365             CurrentEntry().ChangeL( tEntry );
       
   366             }
       
   367         }
       
   368     else
       
   369         {
       
   370         // Open editor using the given message id.
       
   371         const TMsvId preparedId = PrepareContextL( aParameters.iId );
       
   372         SetEntryWithoutNotificationL( preparedId );
       
   373         }
       
   374 
       
   375     __ASSERT_DEBUG( HasModel(), Panic( ENoMessage ) );
       
   376 
       
   377     SetMsgAsReadL();
       
   378     }
       
   379 
       
   380 // ---------------------------------------------------------
       
   381 // CMsgEditorDocument::ChangeContextL
       
   382 //
       
   383 // Handles existing messages (typically opened from Drafts).
       
   384 // This function can be overriden by inherited class if some
       
   385 // preprocessing is needed for the message.
       
   386 //
       
   387 // Default implementation just returns the given context.
       
   388 // ---------------------------------------------------------
       
   389 //
       
   390 EXPORT_C TMsvId CMsgEditorDocument::PrepareContextL( const TMsvId aContext )
       
   391     {
       
   392     return aContext;
       
   393     }
       
   394     
       
   395 // ---------------------------------------------------------
       
   396 // CMsgEditorDocument::ChangeContextL
       
   397 //
       
   398 // Handles reply and forward messages, change current message context to
       
   399 // be context of replied or forwarded message.
       
   400 // ---------------------------------------------------------
       
   401 //
       
   402 EXPORT_C TMsvId CMsgEditorDocument::ChangeContextL(
       
   403     const TEditorParameters& aParameters )
       
   404     {
       
   405     SetEntryWithoutNotificationL( aParameters.iId );
       
   406 
       
   407     CMuiuOperationWait* wait = CMuiuOperationWait::NewLC();
       
   408 
       
   409     CMsvOperation* oper = NULL;
       
   410 
       
   411     const TMsvPartList parts = aParameters.iPartList;
       
   412     const TMsvId dest = aParameters.iDestinationFolderId;
       
   413 
       
   414     if ( aParameters.iFlags & EMsgReplyToMessageSender ||
       
   415         aParameters.iFlags & EMsgReplyToMessageAll )
       
   416         {
       
   417         oper = CreateReplyL( dest, parts, wait->iStatus );
       
   418         }
       
   419     else if (aParameters.iFlags & EMsgForwardMessage)
       
   420         {
       
   421         oper = CreateForwardL( dest, parts, wait->iStatus );
       
   422         }
       
   423 
       
   424     __ASSERT_ALWAYS( oper != NULL, Panic( ENoMessage ) );
       
   425 
       
   426     CleanupStack::PushL( oper );
       
   427 
       
   428     wait->Start();
       
   429 
       
   430     const TMsvId id = GetOperId( *oper );
       
   431 
       
   432     if ( id < 0 )
       
   433         {
       
   434         User::Leave( id );
       
   435         }
       
   436 
       
   437     CleanupStack::PopAndDestroy( 2 );      // oper, wait
       
   438 
       
   439     return id;
       
   440     }
       
   441 
       
   442 // ---------------------------------------------------------
       
   443 // CMsgEditorDocument::CreateReplyL
       
   444 //
       
   445 //
       
   446 // ---------------------------------------------------------
       
   447 //
       
   448 EXPORT_C CMsvOperation* CMsgEditorDocument::CreateReplyL(
       
   449     TMsvId aDest, TMsvPartList aParts, TRequestStatus& aStatus )
       
   450     {
       
   451     return Mtm().ReplyL( aDest, aParts, aStatus );
       
   452     }
       
   453 
       
   454 // ---------------------------------------------------------
       
   455 // CMsgEditorDocument::CreateForwardL
       
   456 //
       
   457 //
       
   458 // ---------------------------------------------------------
       
   459 //
       
   460 EXPORT_C CMsvOperation* CMsgEditorDocument::CreateForwardL(
       
   461     TMsvId aDest, TMsvPartList aParts, TRequestStatus& aStatus )
       
   462     {
       
   463     return Mtm().ForwardL( aDest, aParts, aStatus );
       
   464     }
       
   465 
       
   466 // ---------------------------------------------------------
       
   467 // CMsgEditorDocument::AddSingleOperationL
       
   468 //
       
   469 // Adds operation into operation queque.
       
   470 // ---------------------------------------------------------
       
   471 //
       
   472 EXPORT_C void CMsgEditorDocument::AddSingleOperationL(
       
   473     CMsvOperation* aOperation, CMsvSingleOpWatcher* aSopWatch )
       
   474     {
       
   475     __ASSERT_DEBUG( aSopWatch != NULL, Panic( ENullPointer ) );
       
   476     __ASSERT_DEBUG( aOperation != NULL, Panic( ENullPointer ) );
       
   477 
       
   478     aSopWatch->SetOperation( aOperation );
       
   479     iOpWatchers->AppendL( aSopWatch );
       
   480     }
       
   481 
       
   482 // ---------------------------------------------------------
       
   483 // CMsgEditorDocument::OpCompleted
       
   484 //
       
   485 // Is called when operation is completed. If operation is found, handler is called.
       
   486 // ---------------------------------------------------------
       
   487 //
       
   488 EXPORT_C void CMsgEditorDocument::OpCompleted(
       
   489     CMsvSingleOpWatcher& aOpWatcher, TInt aCompletionCode )
       
   490     {
       
   491     __ASSERT_DEBUG( iOpWatchers != NULL, Panic( ENullPointer ) );
       
   492 
       
   493     const TInt count = iOpWatchers->Count();
       
   494     TInt i = 0;
       
   495 
       
   496     for ( ; i < count; i++ )
       
   497         {
       
   498         // looking for right operation in array.
       
   499         if ( ( (*iOpWatchers)[i] ) == &aOpWatcher )
       
   500             {
       
   501             break;
       
   502             }
       
   503         }
       
   504 
       
   505     if ( i >= count )
       
   506         {
       
   507         // Although invalid operation is an error, we do not
       
   508         // want to panic for that in product - since it not supposed
       
   509         // to seem anyhow to user (Is this true?)
       
   510 
       
   511         __ASSERT_DEBUG( EFalse, Panic( EInvalidOperation ) );
       
   512         return ;
       
   513         }
       
   514 
       
   515     if ( aCompletionCode != KErrNone )
       
   516         {
       
   517         __ASSERT_DEBUG( HasModel(), Panic( ENullPointer ) );
       
   518 
       
   519         TRAP_IGNORE( MtmUi().DisplayProgressSummary( (*iOpWatchers)[i]->Operation().ProgressL() ) );
       
   520         }
       
   521 
       
   522     // Operation has completed, remove watcher and operation (watcher owns operation)
       
   523     // NOTE: Have to delete the watcher first, as the array does not call delete.
       
   524     delete (*iOpWatchers)[i];
       
   525 
       
   526     iOpWatchers->Delete( i );
       
   527     iOpWatchers->Compress();
       
   528     }
       
   529 
       
   530 // ---------------------------------------------------------
       
   531 // CMsgEditorDocument::MediaAvailable
       
   532 //
       
   533 // Return the current (or latest known) state of the message storage.
       
   534 // If this function returns EFalse, then it's likely that operations
       
   535 // saving or restoring message entries will fail.
       
   536 // ---------------------------------------------------------
       
   537 //
       
   538 EXPORT_C TBool CMsgEditorDocument::MediaAvailable() const
       
   539     {
       
   540     return iModel->MediaAvailable();
       
   541     }
       
   542 
       
   543 // ---------------------------------------------------------
       
   544 // CMsgEditorDocument::SetEditorModelObserver
       
   545 //
       
   546 // Define editor model observer. There can be only one editor model
       
   547 // observer defined at any time, so this function just changes the
       
   548 // current observer.
       
   549 // ---------------------------------------------------------
       
   550 //
       
   551 EXPORT_C void CMsgEditorDocument::SetEditorModelObserver(
       
   552     MMsgEditorModelObserver* aObs )
       
   553     {
       
   554     iModel->SetModelObserver( aObs );
       
   555     }
       
   556 
       
   557 // ---------------------------------------------------------
       
   558 // CMsgEditorDocument::GetOperId
       
   559 //
       
   560 // Returns TMsvId (new message id) of given CMsvOperation.
       
   561 //
       
   562 // Given operation class must return the id of the new
       
   563 // message entry with FinalProgress().
       
   564 // ---------------------------------------------------------
       
   565 //
       
   566 EXPORT_C TMsvId CMsgEditorDocument::GetOperId( CMsvOperation& aOperation )
       
   567     {
       
   568     TMsvId temp;
       
   569     TPckgC < TMsvId > paramPack( temp );
       
   570     const TDesC8& progress = aOperation.FinalProgress();
       
   571     paramPack.Set( progress );
       
   572     return paramPack();
       
   573     }
       
   574 
       
   575 // ---------------------------------------------------------
       
   576 // CMsgEditorDocument::AttachmentModel
       
   577 //
       
   578 // Returns reference to attachment model.
       
   579 // ---------------------------------------------------------
       
   580 //
       
   581 EXPORT_C CMsgAttachmentModel& CMsgEditorDocument::AttachmentModel() const
       
   582     {
       
   583     return *iAttachmentModel;
       
   584     }
       
   585 
       
   586 // ---------------------------------------------------------
       
   587 // CMsgEditorDocument::NotifyChanges
       
   588 //
       
   589 // Default implementation panics with EMsgInheritedFunctionMissing.
       
   590 // ---------------------------------------------------------
       
   591 //
       
   592 EXPORT_C void CMsgEditorDocument::NotifyChanges(
       
   593     TMsgAttachmentCommand /*aCommand*/, CMsgAttachmentInfo* /*aAttachmentInfo*/ )
       
   594     {
       
   595     __ASSERT_DEBUG( EFalse, Panic( EMsgInheritedFunctionMissing ) );
       
   596     }
       
   597 
       
   598 
       
   599 // ---------------------------------------------------------
       
   600 // CMsgEditorDocument::GetAttachmentFileL
       
   601 //
       
   602 // Default implementation leaves with KErrNotSupported
       
   603 // ---------------------------------------------------------
       
   604 //
       
   605 EXPORT_C RFile CMsgEditorDocument::GetAttachmentFileL( TMsvAttachmentId /*aId*/ )
       
   606     {
       
   607     User::Leave( KErrNotSupported );
       
   608     RFile dummy;
       
   609     return dummy;
       
   610     }
       
   611 
       
   612 // ---------------------------------------------------------
       
   613 // CMsgEditorDocument::CreateNewAttachmentModelL
       
   614 //
       
   615 //
       
   616 // ---------------------------------------------------------
       
   617 //
       
   618 EXPORT_C CMsgAttachmentModel* CMsgEditorDocument::CreateNewAttachmentModelL(
       
   619     TBool aReadOnly )
       
   620     {
       
   621     return CMsgAttachmentModel::NewL( aReadOnly );
       
   622     }
       
   623 
       
   624 // ---------------------------------------------------------
       
   625 // CMsgEditorDocument::SetMsgAsReadL
       
   626 //
       
   627 // ---------------------------------------------------------
       
   628 //
       
   629 void CMsgEditorDocument::SetMsgAsReadL()
       
   630     {
       
   631     iLaunchFlags &= ~EMsgUnreadMessage;
       
   632     
       
   633     // Unset unread flag
       
   634     // Can be done since viewers should not lock entries
       
   635     if ( Entry().Unread() || Entry().New() )
       
   636         {
       
   637         if ( Entry().Unread() )
       
   638             {
       
   639             iLaunchFlags |= EMsgUnreadMessage;
       
   640             }
       
   641         TMsvEntry entry = Entry();  // create a copy
       
   642 
       
   643         entry.SetUnread( EFalse );
       
   644         entry.SetNew( EFalse );
       
   645 
       
   646         // Asynchronous version used because entry may be remote.
       
   647         CMsvSingleOpWatcher* watch = CMsvSingleOpWatcher::NewLC( *this );
       
   648         CMsvOperation* op = CurrentEntry().ChangeL( entry, watch->iStatus );
       
   649         CleanupStack::Pop();  // watch;
       
   650         AddSingleOperationL( op, watch );
       
   651         }
       
   652     }
       
   653 
       
   654 //  End of File