examples/ForumNokia/S60_3rd_Edition_TextMTM_Example/modules/UI/src/txtmtmeditop.cpp

00001 //
00002 // � 2004 Nokia Corporation.  All rights reserved.
00003 //
00004 
00005 // class include
00006 #include "txtmtmeditop.h"
00007 
00008 // system include
00009 #include <msvids.h>
00010 
00011 // ----------------------------------------------------------------------------
00012 //
00013 //      CTxtMtmEditRemoteOperation: remote edit operation
00014 //
00015 // ----------------------------------------------------------------------------
00016 CTxtMtmEditRemoteOperation::CTxtMtmEditRemoteOperation(CTextMtmUi& aMtmUi, CMsvSession& aMsvSession, 
00017                                                                                    TInt aPriority, TRequestStatus& aObserverRequestStatus)
00018         : CMsvOperation(aMsvSession, aPriority, aObserverRequestStatus), iMtmUi(aMtmUi)
00019         {
00020     CActiveScheduler::Add(this);
00021         }
00022 
00023 // ----------------------------------------------------------------------------
00024 CTxtMtmEditRemoteOperation::~CTxtMtmEditRemoteOperation()
00025         {
00026         Cancel();
00027         delete iCopyOperation;
00028         delete iEditOperation;
00029         }
00030 
00031 
00032 // ----------------------------------------------------------------------------
00033 const TDesC8& CTxtMtmEditRemoteOperation::ProgressL() 
00034         {
00035         return iProgress;
00036         }
00037 
00038 
00039 // ----------------------------------------------------------------------------
00040 //
00041 // cancel any outstanding operations
00042 //
00043 void CTxtMtmEditRemoteOperation::DoCancel()
00044         {
00045         switch (iState)
00046                 {
00047                 case EStateCopying:
00048             {
00049             if(iCopyOperation)
00050                             iCopyOperation->Cancel();
00051             }
00052                         break;
00053                 case EStateEditing:
00054             {
00055             if(iEditOperation)
00056                             iEditOperation->Cancel();
00057             }
00058                         break;
00059                 default:
00060                         break;
00061                 }
00062         }
00063 
00064 
00065 // ----------------------------------------------------------------------------
00066 //
00067 // asynchronously copy the entry from the remote service to the inbox
00068 //
00069 void CTxtMtmEditRemoteOperation::StartL(TMsvEntry& aSourceEntry)
00070         {
00071         CMsvEntry* cEntry=iMsvSession.GetEntryL(aSourceEntry.Parent());
00072         CleanupStack::PushL(cEntry);
00073         iObserverRequestStatus = KRequestPending;
00074         SetActive();
00075         iCopyOperation=cEntry->CopyL(aSourceEntry.Id(), KMsvDraftEntryId/*KMsvGlobalInBoxIndexEntryId*/, iStatus);
00076         CleanupStack::PopAndDestroy(cEntry);// cEntry
00077         iState = EStateCopying;
00078         }
00079 
00080 
00081 // ----------------------------------------------------------------------------
00082 void CTxtMtmEditRemoteOperation::RunL()
00083         {
00084         switch (iState)
00085                 {
00086                 case EStateCopying:
00087                         {
00088             // launch the viewer application if the entry copy operation
00089             // was successful
00090                         TTxtProgressBuf package;
00091                         package.Copy(iCopyOperation->ProgressL());
00092             
00093             User::LeaveIfError(package().iErrorCode);
00094                         TMsvId newid = package().iNewId;
00095 
00096                         iStatus = KRequestPending;
00097                         SetActive();
00098                         iEditOperation = iMtmUi.LaunchViewerApplicationL(iStatus, newid);
00099                         iState = EStateEditing;
00100                         }
00101                         break;
00102                 case EStateEditing:
00103                         {
00104             // the user has finished editing, so complete the requesting
00105             // active object
00106                         iState = EStateFinished;
00107                         TRequestStatus *sP = &iObserverRequestStatus;
00108                         User::RequestComplete(sP,iStatus.Int());
00109                         }
00110                         break;
00111                 default:
00112                         break;
00113                 }
00114         }
00115 
00116 
00117 // ----------------------------------------------------------------------------
00118 //
00119 // This method gets called if there's a leave in RunL
00120 //
00121 TInt CTxtMtmEditRemoteOperation::RunError(TInt aError)
00122     {
00123         TRequestStatus *sP = &iObserverRequestStatus;
00124         User::RequestComplete(sP, aError);
00125     return KErrNone;
00126     }

Generated by  doxygen 1.6.2