1 // Copyright (c) 1998-2009 Nokia Corporation and/or its subsidiary(-ies).
2 // All rights reserved.
3 // This component and the accompanying materials are made available
4 // under the terms of the License "Symbian Foundation License v1.0" to Symbian Foundation members and "Symbian Foundation End User License Agreement v1.0" to non-members
5 // which accompanies this distribution, and is available
6 // at the URL "http://www.symbianfoundation.org/legal/licencesv10.html".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
16 #if !defined(__OFFOP_H__)
19 #if !defined (__MSVIDS_H__)
23 #if !defined (__MSVUIDS_H__)
27 #if !defined(__MSVSTORE_H__)
33 const TInt KCurrentOfflineOperationArrayVersion = 2;
34 _LIT(KImcmPanic, "IMCM");
38 ///////////////////////////////////////////////////////////////////////////////
39 // CImOffLineOperation container for cached off line operation, to be performed
40 // on next connection to remote server.
41 class CImOffLineOperation : public CBase
50 EOffLineOpNone = 0x0000,
52 EOffLineOpCopyToLocal = 0x0001,
53 EOffLineOpCopyFromLocal,
54 EOffLineOpCopyWithinService,
56 EOffLineOpMoveToLocal = 0x0010,
57 EOffLineOpMoveFromLocal,
58 EOffLineOpMoveWithinService,
60 EOffLineOpDelete = 0x0020,
62 EOffLineOpChange = 0x0030,
65 EOffLineOpMtmSpecific = 0x0100,
68 public: // Constructor of a null operation
69 IMPORT_C CImOffLineOperation();
70 IMPORT_C ~CImOffLineOperation();
71 public: // Set this operation to a specific type.
72 inline void SetCopyToLocal(TMsvId aMessageId, TMsvId aTargetFolderId);
73 inline void SetCopyFromLocal(TMsvId aMessageId, TMsvId aTargetFolderId);
74 inline void SetCopyWithinService(TMsvId aMessageId, TMsvId aTargetFolderId);
76 inline void SetMoveToLocal(TMsvId aMessageId, TMsvId aTargetFolderId);
77 inline void SetMoveFromLocal(TMsvId aMessageId, TMsvId aTargetFolderId);
78 inline void SetMoveWithinService(TMsvId aMessageId, TMsvId aTargetFolderId);
80 inline void SetDelete(TMsvId aMessageId);
81 inline void SetChange(TMsvId aMessageId);
82 inline void SetCreate(TMsvId aMessageId);
83 IMPORT_C void SetMtmSpecificCommandL(TMsvId aMessageId, TMsvId aTargetFolderId, TInt aMtmFunctionId, const TDesC8& aParameters);
84 public: // Access to parameters of operation
85 inline TOffLineOpType OpType()const ;
86 inline TMsvId MessageId()const ;
87 inline TMsvId TargetMessageId()const ;
88 inline TInt MtmFunctionId() const ;
89 inline TPtrC8 MtmParameters() const ;
92 IMPORT_C void DetachMtmParameters() ;
93 // Need this detach because the copy constructor will not be called when appending this class to an array!
94 IMPORT_C void DeleteBuffer();
95 // Need this because destructor will not be called when item is removed from an array
97 IMPORT_C TBool Equals(const CImOffLineOperation& aOperation) const;
98 IMPORT_C void CopyL(const CImOffLineOperation& aOperation);
99 // Copy-constructor that can leave
101 IMPORT_C void ExternalizeL( RMsvWriteStream& aWriteStream ) const;
102 IMPORT_C void InternalizeL( RMsvReadStream& aReadStream );
104 IMPORT_C int operator ==(const CImOffLineOperation& otherOperation) const;
106 IMPORT_C void SetOperation(TOffLineOpType aOpType, TMsvId aMessageId, TMsvId aTargetFolderId, TInt aMtmFunctionId, HBufC8* aParameters);
107 IMPORT_C void SetOperation(TOffLineOpType aOpType, TMsvId aMessageId, TMsvId aTargetFolderId);
109 TOffLineOpType iOpType;
111 TMsvId iTargetMessageId;
113 HBufC8* iMtmParameters; // Mtm-specifics
116 ///////////////////////////////////////////////////////////////////////////////
117 // MOffLineOperationArray : generic mixin for accessing arrays of Off line operations.
118 class MImOffLineOperationArray
125 virtual TInt CountOperations() const = 0;
126 virtual const CImOffLineOperation& Operation(TInt aIndex) const = 0;
127 virtual void AppendOperationL(const CImOffLineOperation& aOperation) = 0;
128 virtual void Delete(TInt aIndex) = 0;
131 ///////////////////////////////////////////////////////////////////////////////
132 // CImOffLineArrayStore : storing and restoring MImOffLineOperationArray
134 class CImOffLineArrayStore : public CBase
141 inline CImOffLineArrayStore(MImOffLineOperationArray& aArray);
142 inline void SetVersion(TUint16 aVersion);
143 inline TUint16 Version();
144 IMPORT_C void StoreL(CMsvStore& aMsvStore) const;
145 IMPORT_C void RestoreL(const CMsvStore& aMessageStore );
146 IMPORT_C void ExternalizeL(RMsvWriteStream& aWriteStream) const;
147 IMPORT_C void InternalizeL(RMsvReadStream& aReadStream);
150 MImOffLineOperationArray* iArray;
153 ///////////////////////////////////////////////////////////////////////////////
154 // CImOffLineOperationArray : implementation of MImOffLineOperationArray
155 class CImOffLineOperationArray : public CBase, public MImOffLineOperationArray
162 IMPORT_C static CImOffLineOperationArray* NewL();
163 IMPORT_C virtual ~CImOffLineOperationArray();
164 public: // derived from MImOffLineOperationArray
165 TInt CountOperations() const;
166 const CImOffLineOperation& Operation(TInt aIndex) const;
167 void AppendOperationL(const CImOffLineOperation& aOperation);
168 void Delete(TInt aIndex);
169 public: // Not derived from MImOffLineOperationArray
170 IMPORT_C void InsertOperationL(CImOffLineOperation& aOperation, TInt aPosition);
172 CImOffLineOperationArray();
173 IMPORT_C void ConstructL();
175 CArrayFixFlat<CImOffLineOperation> *iArray;
179 class TQueuedOperation
186 IMPORT_C static TQueuedOperation* NewL(TMsvId aFolderId,TInt aOperationIndex, const CImOffLineOperation& aStoredOperation);
187 IMPORT_C TQueuedOperation();
188 IMPORT_C TBool operator!=(const TQueuedOperation& aOp);
189 inline TMsvId FolderId() const;
190 inline TInt OperationIndex() const;
191 inline CImOffLineOperation& Operation() ;
192 IMPORT_C void CopyL(const TQueuedOperation& aOperation);
194 TQueuedOperation(TMsvId aFolderId,TInt aOperationIndex);
197 TInt iOperationIndex;
198 CImOffLineOperation iStoredOperation;
201 class CImQueuedList : public CBase, public MImOffLineOperationArray
208 IMPORT_C static CImQueuedList* NewL();
209 IMPORT_C virtual ~CImQueuedList() ;
210 IMPORT_C void SetFolder(TMsvId aFolderId);
211 IMPORT_C void ResetLineCounter();
212 IMPORT_C TQueuedOperation& operator[](TInt anIndex);
213 IMPORT_C void Delete(TInt aIndex);
214 IMPORT_C void Reset();
215 IMPORT_C void AppendL(TQueuedOperation& aOperation);
216 public: // From MOffLineOperationArrayStore
217 IMPORT_C virtual TInt CountOperations() const;
218 IMPORT_C virtual const CImOffLineOperation& Operation(TInt aIndex) const;
219 IMPORT_C virtual void AppendOperationL(const CImOffLineOperation& aOperation);
225 CArrayFixFlat<TQueuedOperation> *iArray;
228 class MImUndoOffLineOperation
235 virtual void UndoOffLineChangesL(const CImOffLineOperation& aDeleted, TMsvId aFolderId) = 0;
238 class CImOperationQueueList : public CBase
245 IMPORT_C static CImOperationQueueList* NewL(CMsvEntry& aServiceEntry, MImUndoOffLineOperation *aImUndoOffLineOperation);
246 // Create new list of queued operations for service entry aServiceEntry is set to.
247 IMPORT_C ~CImOperationQueueList();
248 inline const TInt Count() const;
249 // Current number of queued operations in list
250 inline TQueuedOperation& operator[](TInt anIndex);
251 // Access to array of queued operations.
252 IMPORT_C void DeleteL(TInt aLine);
253 // Remove operation from list of queued operations locally.
254 IMPORT_C void ExpungeDeletedOperationsL();
255 // Enforce removal of queued operations from the stores of the folders.
258 CImOperationQueueList(CMsvEntry& aServiceEntry,MImUndoOffLineOperation *aImUndoOffLineOperation);
259 void RestoreQueuedListL(CImQueuedList &/*aList*/);
260 void StoreQueuedListL(CImQueuedList &/*aList*/);
261 void ProcessFoldersL();
263 CImQueuedList *iQueuedList;
264 CImQueuedList *iDeletedList;
265 CMsvEntry* iServiceEntry;
267 MImUndoOffLineOperation *iUndoOffline;