|
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 "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // |
|
15 |
|
16 #if !defined(__OFFOP_H__) |
|
17 #define __OFFOP_H__ |
|
18 |
|
19 #if !defined (__MSVIDS_H__) |
|
20 #include <msvids.h> |
|
21 #endif |
|
22 |
|
23 #if !defined (__MSVUIDS_H__) |
|
24 #include <msvuids.h> |
|
25 #endif |
|
26 |
|
27 #if !defined(__MSVSTORE_H__) |
|
28 #include <msvstore.h> |
|
29 #endif |
|
30 |
|
31 #include <miut_err.h> |
|
32 |
|
33 const TInt KCurrentOfflineOperationArrayVersion = 2; |
|
34 _LIT(KImcmPanic, "IMCM"); |
|
35 |
|
36 class CMsvEntry; |
|
37 |
|
38 // |
|
39 // CImOffLineOperation container for cached off line operation, to be performed |
|
40 // on next connection to remote server. |
|
41 class CImOffLineOperation : public CBase |
|
42 /** |
|
43 @internalTechnology |
|
44 @released |
|
45 */ |
|
46 { |
|
47 public: |
|
48 enum TOffLineOpType |
|
49 { |
|
50 EOffLineOpNone = 0x0000, |
|
51 // |
|
52 EOffLineOpCopyToLocal = 0x0001, |
|
53 EOffLineOpCopyFromLocal, |
|
54 EOffLineOpCopyWithinService, |
|
55 // |
|
56 EOffLineOpMoveToLocal = 0x0010, |
|
57 EOffLineOpMoveFromLocal, |
|
58 EOffLineOpMoveWithinService, |
|
59 // |
|
60 EOffLineOpDelete = 0x0020, |
|
61 // |
|
62 EOffLineOpChange = 0x0030, |
|
63 EOffLineOpCreate, |
|
64 // |
|
65 EOffLineOpMtmSpecific = 0x0100, |
|
66 }; |
|
67 |
|
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); |
|
75 // |
|
76 inline void SetMoveToLocal(TMsvId aMessageId, TMsvId aTargetFolderId); |
|
77 inline void SetMoveFromLocal(TMsvId aMessageId, TMsvId aTargetFolderId); |
|
78 inline void SetMoveWithinService(TMsvId aMessageId, TMsvId aTargetFolderId); |
|
79 |
|
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 ; |
|
90 |
|
91 public: |
|
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 |
|
96 public: |
|
97 IMPORT_C TBool Equals(const CImOffLineOperation& aOperation) const; |
|
98 IMPORT_C void CopyL(const CImOffLineOperation& aOperation); |
|
99 // Copy-constructor that can leave |
|
100 public: |
|
101 IMPORT_C void ExternalizeL( RMsvWriteStream& aWriteStream ) const; |
|
102 IMPORT_C void InternalizeL( RMsvReadStream& aReadStream ); |
|
103 public: |
|
104 IMPORT_C int operator ==(const CImOffLineOperation& otherOperation) const; |
|
105 private: |
|
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); |
|
108 private: |
|
109 TOffLineOpType iOpType; |
|
110 TMsvId iMessageId; |
|
111 TMsvId iTargetMessageId; |
|
112 TInt iMtmFunctionId; |
|
113 HBufC8* iMtmParameters; // Mtm-specifics |
|
114 }; |
|
115 |
|
116 // |
|
117 // MOffLineOperationArray : generic mixin for accessing arrays of Off line operations. |
|
118 class MImOffLineOperationArray |
|
119 /** |
|
120 @internalTechnology |
|
121 @released |
|
122 */ |
|
123 { |
|
124 public: |
|
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; |
|
129 }; |
|
130 |
|
131 // |
|
132 // CImOffLineArrayStore : storing and restoring MImOffLineOperationArray |
|
133 // derived classes |
|
134 class CImOffLineArrayStore : public CBase |
|
135 /** |
|
136 @internalTechnology |
|
137 @released |
|
138 */ |
|
139 { |
|
140 public: |
|
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); |
|
148 private: |
|
149 TUint16 iVersion; |
|
150 MImOffLineOperationArray* iArray; |
|
151 }; |
|
152 |
|
153 // |
|
154 // CImOffLineOperationArray : implementation of MImOffLineOperationArray |
|
155 class CImOffLineOperationArray : public CBase, public MImOffLineOperationArray |
|
156 /** |
|
157 @internalTechnology |
|
158 @released |
|
159 */ |
|
160 { |
|
161 public: |
|
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); |
|
171 protected: |
|
172 CImOffLineOperationArray(); |
|
173 IMPORT_C void ConstructL(); |
|
174 protected: |
|
175 CArrayFixFlat<CImOffLineOperation> *iArray; |
|
176 }; |
|
177 |
|
178 |
|
179 class TQueuedOperation |
|
180 /** |
|
181 @internalComponent |
|
182 @released |
|
183 */ |
|
184 { |
|
185 public: |
|
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); |
|
193 private: |
|
194 TQueuedOperation(TMsvId aFolderId,TInt aOperationIndex); |
|
195 private: |
|
196 TMsvId iFolderId; |
|
197 TInt iOperationIndex; |
|
198 CImOffLineOperation iStoredOperation; |
|
199 }; |
|
200 |
|
201 class CImQueuedList : public CBase, public MImOffLineOperationArray |
|
202 /** |
|
203 @internalComponent |
|
204 @released |
|
205 */ |
|
206 { |
|
207 public: |
|
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); |
|
220 private: |
|
221 CImQueuedList() ; |
|
222 private: |
|
223 TMsvId iFolderId; |
|
224 TInt iLine; |
|
225 CArrayFixFlat<TQueuedOperation> *iArray; |
|
226 }; |
|
227 |
|
228 class MImUndoOffLineOperation |
|
229 /** |
|
230 @internalTechnology |
|
231 @released |
|
232 */ |
|
233 { |
|
234 public: |
|
235 virtual void UndoOffLineChangesL(const CImOffLineOperation& aDeleted, TMsvId aFolderId) = 0; |
|
236 }; |
|
237 |
|
238 class CImOperationQueueList : public CBase |
|
239 /** |
|
240 @internalComponent |
|
241 @released |
|
242 */ |
|
243 { |
|
244 public: |
|
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. |
|
256 protected: |
|
257 void ConstructL(); |
|
258 CImOperationQueueList(CMsvEntry& aServiceEntry,MImUndoOffLineOperation *aImUndoOffLineOperation); |
|
259 void RestoreQueuedListL(CImQueuedList &/*aList*/); |
|
260 void StoreQueuedListL(CImQueuedList &/*aList*/); |
|
261 void ProcessFoldersL(); |
|
262 private: |
|
263 CImQueuedList *iQueuedList; |
|
264 CImQueuedList *iDeletedList; |
|
265 CMsvEntry* iServiceEntry; |
|
266 TMsvId iServiceId; |
|
267 MImUndoOffLineOperation *iUndoOffline; |
|
268 }; |
|
269 |
|
270 #include <offop.inl> |
|
271 |
|
272 #endif |