|
1 /* |
|
2 * Copyright (c) 2005 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: Provides item buffering during synchronisation. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef __NSMLDSBATCHBUFFER_H__ |
|
20 #define __NSMLDSBATCHBUFFER_H__ |
|
21 |
|
22 // INCLUDES |
|
23 #include <e32base.h> |
|
24 #include <SmlDataSyncDefs.h> |
|
25 #include "nsmlcliagconstants.h" |
|
26 |
|
27 // FORWARD DECLARATIONS |
|
28 class CNSmlDbMetaHandler; |
|
29 |
|
30 // CLASS DECLARATION |
|
31 |
|
32 /** |
|
33 * Class used to buffer batched items during synchronisation. |
|
34 * |
|
35 * @lib nsmldsagent.lib |
|
36 */ |
|
37 class CNSmlDSBatchBuffer : public CBase |
|
38 { |
|
39 public: // constructors and destructor |
|
40 /** |
|
41 * C++ constructor. |
|
42 */ |
|
43 CNSmlDSBatchBuffer(); |
|
44 |
|
45 /** |
|
46 * Destructor. |
|
47 */ |
|
48 ~CNSmlDSBatchBuffer(); |
|
49 |
|
50 public: // new functions |
|
51 /** |
|
52 * Creates a new item to the buffer. |
|
53 * @param aCommand New item's associated command. |
|
54 */ |
|
55 void CreateNewItemL( const TDesC8& aCommand ); |
|
56 |
|
57 /** |
|
58 * Sets the status of the given item. |
|
59 * @param aIndex Index to the item in the buffer. |
|
60 * @param aStatus Item's status. |
|
61 */ |
|
62 void SetStatus( const TInt aIndex, const TInt aStatus ); |
|
63 |
|
64 /** |
|
65 * Sets the item's id in the status container. |
|
66 * @param aEntry Item's status id. |
|
67 */ |
|
68 void SetStatusEntryId( const TInt aEntry ); |
|
69 |
|
70 /** |
|
71 * Resets the buffer and frees all associated resources. |
|
72 */ |
|
73 void Reset(); |
|
74 |
|
75 /** |
|
76 * Increases the operation counter of the current item by one. |
|
77 */ |
|
78 void Increase(); |
|
79 |
|
80 /** |
|
81 * Sets the current item's GUID. |
|
82 * @param aGUid New GUID value. |
|
83 */ |
|
84 void SetGUidL( const TDesC8& aGUid ); |
|
85 |
|
86 /** |
|
87 * Returns the number of items in the buffer. |
|
88 * @return The number of items in the buffer. |
|
89 */ |
|
90 TInt Count() const; |
|
91 |
|
92 /** |
|
93 * Returns the given item's status code. |
|
94 * @param aIndex Index to an item. |
|
95 * @return Given item's status. |
|
96 */ |
|
97 TInt Status( const TInt aIndex ) const; |
|
98 |
|
99 /** |
|
100 * Returns the given item's status container id. |
|
101 * @param aIndex Index to an item. |
|
102 * @return Given item's status container id. |
|
103 */ |
|
104 TInt StatusEntryId( const TInt aIndex ) const; |
|
105 |
|
106 /** |
|
107 * Returns the number of operations associated with the given item. |
|
108 * @param aIndex Index to an item. |
|
109 * @return Number of operations. |
|
110 */ |
|
111 TInt NumberOfResults( const TInt aIndex ) const; |
|
112 |
|
113 /** |
|
114 * Returns the command associated with the given item. |
|
115 * @param aIndex Index to an item. |
|
116 * @return Item's associated command. |
|
117 */ |
|
118 const TDesC8& Command( const TInt aIndex ) const; |
|
119 |
|
120 /** |
|
121 * Returns a reference to the current item's UID. |
|
122 * @return Reference to the UID. |
|
123 */ |
|
124 TSmlDbItemUid& Uid() const; |
|
125 |
|
126 /** |
|
127 * Returns the UID of the given item. |
|
128 * @param aIndex Index to an item. |
|
129 * @return Given item's UID. |
|
130 */ |
|
131 TSmlDbItemUid Uid( const TInt aIndex ) const; |
|
132 |
|
133 /** |
|
134 * Returns the GUID of the given item. |
|
135 * @param aIndex Index to an item. |
|
136 * @return Given item's GUID. |
|
137 */ |
|
138 const TDesC8& GUid( const TInt aIndex ) const; |
|
139 |
|
140 /** |
|
141 * Sets current item's parent UID. |
|
142 * @param aParent Item's parent. |
|
143 */ |
|
144 void SetParent( const TSmlDbItemUid aParent ); |
|
145 |
|
146 /** |
|
147 * Returns the given item's parent. |
|
148 * @param aIndex Index to an item. |
|
149 * @return Given item's parent. |
|
150 */ |
|
151 TSmlDbItemUid Parent( const TInt aIndex ) const; |
|
152 |
|
153 /** |
|
154 * Sets current item's meta information. |
|
155 * @param aMetaHandler Item's meta information. |
|
156 */ |
|
157 void SetMetaInformationL( const CNSmlDbMetaHandler* aMetaHandler ); |
|
158 |
|
159 /** |
|
160 * Returns the given item's meta version. |
|
161 * @param aIndex Index to an item. |
|
162 * @return Given item's meta version. |
|
163 */ |
|
164 TPtrC8 MimeVersion( const TInt aIndex ) const; |
|
165 |
|
166 /** |
|
167 * Returns the given item's meta type. |
|
168 * @param aIndex Index to an item. |
|
169 * @return Given item's meta version. |
|
170 */ |
|
171 TPtrC8 MimeType( const TInt aIndex ) const; |
|
172 |
|
173 /** |
|
174 * Copies the given data under the current item. |
|
175 * @param aData Data to be stored. |
|
176 */ |
|
177 void StoreItemDataL( TPtrC8 aData ); |
|
178 |
|
179 /** |
|
180 * Returns a pointer to the given item's data. |
|
181 * @param aIndex Index to an item. |
|
182 * @return Pointer to the item's data. |
|
183 */ |
|
184 TPtrC8 ItemData( const TInt aIndex ) const; |
|
185 |
|
186 private: // constructor & operators |
|
187 /** |
|
188 * Prohibit copy constructor |
|
189 */ |
|
190 CNSmlDSBatchBuffer( const CNSmlDSBatchBuffer& aOther ); |
|
191 |
|
192 /** |
|
193 * Prohibit assignment operator. |
|
194 */ |
|
195 CNSmlDSBatchBuffer& operator=( const CNSmlDSBatchBuffer aOther ); |
|
196 |
|
197 private: // data |
|
198 // buffered item |
|
199 class CNSmlDSBatchItem : public CBase |
|
200 { |
|
201 public: |
|
202 CNSmlDSBatchItem(); |
|
203 ~CNSmlDSBatchItem(); |
|
204 TInt iStatus; |
|
205 TInt iNumberOfResults; |
|
206 TBuf8<KNSmlMaxCmdNameLength> iCommand; |
|
207 TSmlDbItemUid iUid; |
|
208 HBufC8* iGUid; |
|
209 TSmlDbItemUid iParent; |
|
210 TInt iStatusEntryId; |
|
211 HBufC8* iItemData; |
|
212 HBufC8* iMimeType; |
|
213 HBufC8* iMimeVersion; |
|
214 }; |
|
215 |
|
216 // array of buffered items |
|
217 RPointerArray<CNSmlDSBatchItem> iBuffer; |
|
218 }; |
|
219 |
|
220 #endif // __NSMLDSBATCHBUFFER_H__ |
|
221 |
|
222 // End of File |