examples/Messaging/TextMTM/txts/TXTSCPMV.H

00001 // Copyright (c) 1999-2009 Nokia Corporation and/or its subsidiary(-ies).
00002 // All rights reserved.
00003 // This component and the accompanying materials are made available
00004 // under the terms of "Eclipse Public License v1.0"
00005 // which accompanies this distribution, and is available
00006 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
00007 //
00008 // Initial Contributors:
00009 // Nokia Corporation - initial contribution.
00010 //
00011 // Contributors:
00012 //
00013 // Description:
00014 //
00015 
00016 #ifndef _TXTSCPMV_H_
00017 #define _TXTSCPMV_H_
00018 
00019 #if !defined(__MSVSTD_H__)
00020 #include <msvstd.h> 
00021 #endif
00022 #if !defined(__MSVENTRY_H__)
00023 #include <msventry.h>
00024 #endif
00025 
00026 #if !defined(__TXUT_H__)
00027 #include "txut.h" //for TTxtProgress
00028 #endif
00029 
00030 #define ETxtRetrievingMessage  1
00031 #define ETxtFinished               0
00032 
00033 
00034 const TInt KMsgTxtRefreshMailboxPriority = 1;
00035 
00036 class CParaFormatLayer;
00037 class CCharFormatLayer;
00038 class CMsvServerEntry;
00039 class CTxtCopyMoveBase;
00040 
00041 // 
00042 // CTxtActiveOper: performs an operation on exactly one Msv Entry.
00043 // Derive from this for the several move/copy/delete operations
00044 //
00045 // The methods have a RFs at their disposal, for access to the current
00046 // folder for the operation in the file system.
00047 //
00048 
00049 class CTxtActiveOper : public CActive
00050         {
00051 public:
00052         CTxtActiveOper(RFs& aFs, CMsvServerEntry& aServerEntry);
00053         virtual ~CTxtActiveOper();
00054         void Start(TMsvId& aSourceId, TMsvId& aDestId, TRequestStatus& aStatus);
00055         void SetCurrentCaller(CTxtCopyMoveBase* aCurrentCaller);
00056 public:
00057         virtual CTxtActiveOper* CopyConstructL()=0;
00058         // CopiedHeader reports whether messages are copied and entries need to be created.
00059         // the destination entry id will then be passed on in the Start method
00060         virtual TBool CopiedHeader() const = 0;
00061         // DeleteSourceAfterwards specifies whether the source entry needs to be deleted
00062         // afterwards. This will then be done automatically also.
00063         virtual TBool DeleteSourceAfterwards() const = 0;
00064         // MoveIsToService specifies whether the messages that are moved are moved to the service.
00065         // Some additional operations need to be done to make the entry a valid entry, 
00066         // the flag iServiceId has to be set, and the correctness of the iDetails has
00067         // to be assured. Also the file name has to be altered if it already exists.
00068         virtual TBool MoveIsToService() const = 0;
00069 protected:
00070         // RunL will then do the actual transfer. It should call ReportFinished when the operation
00071         // has completed.
00072         void RunL();
00073         virtual void DoRunL()=0;
00074         virtual void DoCancel();
00075 protected:
00076         TRequestStatus*         iReportStatus;
00077         CMsvServerEntry&        iServerEntry;
00078         RFs                                     &iFs;
00079         TMsvId                          iSourceId;
00080         TMsvId                          iDestId;
00081         CTxtCopyMoveBase*       iCurrentCaller;   // Currently being called from. 
00082         TFileName iFileName;                              // Current source entry info
00083         };
00084 
00085 //
00086 // CTxtCopyMoveBase: defines some base functionality for transferring
00087 // between the server and the local file system. It needs a CTxtActiveOper
00088 // class at construction, that will actually copy the body text over asynchronously.
00089 //
00090 
00091 class CTxtCopyMoveBase : public  CActive
00092         {
00093 public:
00094         static CTxtCopyMoveBase* NewL(CTxtActiveOper* aActiveOperation, const CMsvEntrySelection& aSource, 
00095                 CMsvServerEntry& aDestination, TMsvId& aServiceEntryId, TParse& aParse);
00096         CTxtCopyMoveBase* CopyConstructL(const CMsvEntrySelection& aSource);
00097         ~CTxtCopyMoveBase();
00098         void Start(TRequestStatus& aStatus);
00099         TTxtProgress& Progress();
00100 protected:
00101         CTxtCopyMoveBase(CTxtActiveOper* aActiveOperation, const CMsvEntrySelection& aSource, 
00102                 CMsvServerEntry& aDestination, TMsvId& aServiceEntryId, TParse& aParse);
00103         void ConstructL();
00104         void DoCancel();
00105         void RunL();
00106         void DoRunL();
00107 private:
00108         void CheckDeleteSource();
00109         void SetupNewEntryL(TMsvId& SourceMsgId, TMsvId& newDestMsvId);
00110 private: 
00111         TInt iTxtCopyMoveState;
00112         CTxtActiveOper*                         iActiveOperation;
00113         const CMsvEntrySelection&       iSource;
00114         CMsvServerEntry&                        iDestination;
00115         TMsvId                                          iServiceEntryId;
00116         TMsvId                                          iDestId;
00117         TInt                                            iMsgCounter;
00118         TTxtProgress                            iProgress;
00119         TRequestStatus*                         iReportStatus;
00120 public: 
00121         // iServiceDestinationpath is used as a current folder, when transferring to the RFs
00122         TParse& iServiceDestinationpath;
00123         };
00124 
00125 //
00126 // CTxtActiveOper-derived classes, defining the actual moving around of 
00127 // body texts.
00128 //
00129 
00130 //
00131 // CTxtCopyToLocalOp, CTxtCopyFromLocalOp, CTxtCopyWithinServiceOp:
00132 // The copy operations
00133 //
00134 
00135 class CTxtCopyToLocalOp : public CTxtActiveOper
00136         {
00137 public:
00138         CTxtActiveOper* CopyConstructL();
00139         CTxtCopyToLocalOp(RFs& aFs, CMsvServerEntry& aServerEntry) 
00140                 : CTxtActiveOper(aFs, aServerEntry) {};
00141         TBool CopiedHeader() const;
00142         virtual TBool DeleteSourceAfterwards() const;
00143         TBool MoveIsToService() const;
00144 protected:
00145         void DoRunL();
00146 private:
00147         void DoMessageCopyToLocalL();
00148         };
00149 
00150 class CTxtCopyFromLocalOp : public CTxtActiveOper
00151         {
00152 public:
00153         CTxtActiveOper* CopyConstructL();
00154         CTxtCopyFromLocalOp(RFs& aFs, CMsvServerEntry& aServerEntry) 
00155                 : CTxtActiveOper(aFs, aServerEntry) {};
00156         TBool CopiedHeader() const;
00157         virtual TBool DeleteSourceAfterwards() const;
00158         TBool MoveIsToService() const;
00159 protected:
00160         void DoRunL();
00161 private:
00162         void DoMessageCopyFromLocalL(const TMsvEntry& aEntry);
00163         };
00164 
00165 class CTxtCopyWithinServiceOp : public CTxtActiveOper
00166         {
00167 public:
00168         CTxtActiveOper* CopyConstructL();
00169         CTxtCopyWithinServiceOp(RFs& aFs, CMsvServerEntry& aServerEntry) 
00170                 : CTxtActiveOper(aFs, aServerEntry) {};
00171         TBool CopiedHeader() const;
00172         virtual TBool DeleteSourceAfterwards() const;
00173         TBool MoveIsToService() const ;
00174 protected:
00175         void DoRunL();
00176 private:
00177         void DoMessageCopyWithinServiceL();
00178         };
00179 
00180 //
00181 // CTxtMoveToLocalOp, CTxtMoveFromLocalOp, CTxtMoveWithinServiceOp:
00182 // The move operations: these are only a special case of copying, 
00183 // where the original needs to be deleted.
00184 //
00185 
00186 class CTxtMoveToLocalOp : public CTxtCopyToLocalOp
00187         {
00188 public:
00189         CTxtActiveOper* CopyConstructL();
00190         CTxtMoveToLocalOp(RFs& aFs, CMsvServerEntry& aServerEntry) 
00191                 : CTxtCopyToLocalOp(aFs, aServerEntry) {};
00192         TBool DeleteSourceAfterwards() const;
00193         };
00194 
00195 class CTxtMoveFromLocalOp : public CTxtCopyFromLocalOp
00196         {
00197 public:
00198         CTxtActiveOper* CopyConstructL();
00199         CTxtMoveFromLocalOp(RFs& aFs, CMsvServerEntry& aServerEntry) 
00200                 : CTxtCopyFromLocalOp(aFs, aServerEntry) {};
00201         TBool DeleteSourceAfterwards() const;
00202         };
00203 
00204 class CTxtMoveWithinServiceOp : public CTxtCopyWithinServiceOp
00205         {
00206 public:
00207         CTxtActiveOper* CopyConstructL();
00208         CTxtMoveWithinServiceOp(RFs& aFs, CMsvServerEntry& aServerEntry) 
00209                 : CTxtCopyWithinServiceOp(aFs, aServerEntry) {};
00210         TBool DeleteSourceAfterwards() const;
00211         };
00212 
00213 //
00214 // CTxtDeleteOp: Delete operation
00215 //
00216 
00217 class CTxtDeleteOp : public CTxtActiveOper
00218         {
00219 public:
00220         CTxtActiveOper* CopyConstructL();
00221         CTxtDeleteOp(RFs& aFs, CMsvServerEntry& aServerEntry) 
00222                 : CTxtActiveOper(aFs, aServerEntry) {};
00223         TBool CopiedHeader() const;
00224         TBool DeleteSourceAfterwards() const;
00225         TBool MoveIsToService() const;
00226 protected:
00227         void DoRunL();
00228         };
00229 
00230 
00231 inline void CTxtActiveOper::SetCurrentCaller(CTxtCopyMoveBase* aCurrentCaller)
00232         {
00233         iCurrentCaller = aCurrentCaller;
00234         }
00235 
00236 
00237 #endif
00238 

Generated on Thu Jan 21 10:32:59 2010 for TB10.1 Example Applications by  doxygen 1.5.3