williamr@4
|
1 |
/*
|
williamr@4
|
2 |
* Copyright (c) 2005-2007 Nokia Corporation and/or its subsidiary(-ies).
|
williamr@4
|
3 |
* All rights reserved.
|
williamr@4
|
4 |
* This component and the accompanying materials are made available
|
williamr@4
|
5 |
* under the terms of "Eclipse Public License v1.0"
|
williamr@4
|
6 |
* which accompanies this distribution, and is available
|
williamr@4
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
williamr@4
|
8 |
*
|
williamr@4
|
9 |
* Initial Contributors:
|
williamr@4
|
10 |
* Nokia Corporation - initial contribution.
|
williamr@4
|
11 |
*
|
williamr@4
|
12 |
* Contributors:
|
williamr@4
|
13 |
*
|
williamr@4
|
14 |
* Description: The vcard engine for importing/exporting vcards and compact
|
williamr@4
|
15 |
* business cards.
|
williamr@4
|
16 |
*
|
williamr@4
|
17 |
*/
|
williamr@4
|
18 |
|
williamr@4
|
19 |
|
williamr@4
|
20 |
#ifndef CVPBKVCARDENG_H
|
williamr@4
|
21 |
#define CVPBKVCARDENG_H
|
williamr@4
|
22 |
|
williamr@4
|
23 |
|
williamr@4
|
24 |
// INCLUDES
|
williamr@4
|
25 |
#include <e32base.h>
|
williamr@4
|
26 |
#include <f32file.h>
|
williamr@4
|
27 |
#include <s32file.h>
|
williamr@4
|
28 |
|
williamr@4
|
29 |
// FORWARD DECLARATIONS
|
williamr@4
|
30 |
class MVPbkFieldTypeList;
|
williamr@4
|
31 |
class CVPbkContactManager;
|
williamr@4
|
32 |
class MVPbkStoreContact;
|
williamr@4
|
33 |
class MVPbkFieldType;
|
williamr@4
|
34 |
class MVPbkContactOperationBase;
|
williamr@4
|
35 |
class MVPbkSingleContactOperationObserver;
|
williamr@4
|
36 |
class MVPbkContactCopyObserver;
|
williamr@4
|
37 |
class MVPbkContactLink;
|
williamr@4
|
38 |
class MVPbkContactStore;
|
williamr@4
|
39 |
class CVPbkVCardData;
|
williamr@4
|
40 |
|
williamr@4
|
41 |
// CLASS DECLARATIONS
|
williamr@4
|
42 |
|
williamr@4
|
43 |
/**
|
williamr@4
|
44 |
* The vcard engine for importing/exporting vcards and compact business cards.
|
williamr@4
|
45 |
*
|
williamr@4
|
46 |
* @lib VPbkVCardEng.lib
|
williamr@4
|
47 |
*/
|
williamr@4
|
48 |
class CVPbkVCardEng : public CBase
|
williamr@4
|
49 |
{
|
williamr@4
|
50 |
public: // Constructors and destructor
|
williamr@4
|
51 |
/**
|
williamr@4
|
52 |
* Creates VCard engine instance.
|
williamr@4
|
53 |
* @param aContactManager The Contact manager.
|
williamr@4
|
54 |
* @return A new instance of the CVPbkVCardEng.
|
williamr@4
|
55 |
*/
|
williamr@4
|
56 |
IMPORT_C static CVPbkVCardEng* NewL(
|
williamr@4
|
57 |
CVPbkContactManager& aContactManager);
|
williamr@4
|
58 |
|
williamr@4
|
59 |
/**
|
williamr@4
|
60 |
* Destructor.
|
williamr@4
|
61 |
*/
|
williamr@4
|
62 |
~CVPbkVCardEng();
|
williamr@4
|
63 |
|
williamr@4
|
64 |
public: // New methods
|
williamr@4
|
65 |
|
williamr@4
|
66 |
/**
|
williamr@4
|
67 |
* Reads vCard records from a stream and saves contacts to the store
|
williamr@4
|
68 |
* asynchronously.
|
williamr@4
|
69 |
*
|
williamr@4
|
70 |
* A client receives links to the created contacts in a call back.
|
williamr@4
|
71 |
*
|
williamr@4
|
72 |
* @param aTargetStore The Virtual Phonebook store in which the
|
williamr@4
|
73 |
* information is copied to. The store must be
|
williamr@4
|
74 |
* writable.
|
williamr@4
|
75 |
* @param aSourceStream A stream where the vCard data is read from
|
williamr@4
|
76 |
* @param aObserver The observer who is notified when the import
|
williamr@4
|
77 |
* completes. Failed cases:
|
williamr@4
|
78 |
* -KErrNotFound if the card contained fields that
|
williamr@4
|
79 |
* cannot be saved to the target store i.e.
|
williamr@4
|
80 |
* the operation didn't find any fields to copy.
|
williamr@4
|
81 |
* @return A new operation handle owned by the client.
|
williamr@4
|
82 |
* @exception KErrNotFound if the engine didn't find a copy policy
|
williamr@4
|
83 |
* for the target store.
|
williamr@4
|
84 |
* @asynchronous
|
williamr@4
|
85 |
*/
|
williamr@4
|
86 |
IMPORT_C MVPbkContactOperationBase* ImportVCardL(
|
williamr@4
|
87 |
MVPbkContactStore& aTargetStore,
|
williamr@4
|
88 |
RReadStream &aSourceStream,
|
williamr@4
|
89 |
MVPbkContactCopyObserver& aObserver);
|
williamr@4
|
90 |
|
williamr@4
|
91 |
/**
|
williamr@4
|
92 |
* Reads vCard records from a stream and saves contacts to the store
|
williamr@4
|
93 |
* asynchronously.
|
williamr@4
|
94 |
*
|
williamr@4
|
95 |
* A client receives links to the created contacts in a call back.
|
williamr@4
|
96 |
* NOTE: This API is introduced for performance improvements in sync.
|
williamr@4
|
97 |
* When imported for Sync the duplicate policy checks are ignored.
|
williamr@4
|
98 |
*
|
williamr@4
|
99 |
* @param aTargetStore The Virtual Phonebook store in which the
|
williamr@4
|
100 |
* information is copied to. The store must be
|
williamr@4
|
101 |
* writable.
|
williamr@4
|
102 |
* @param aSourceStream A stream where the vCard data is read from
|
williamr@4
|
103 |
* @param aObserver The observer who is notified when the import
|
williamr@4
|
104 |
* completes. Failed cases:
|
williamr@4
|
105 |
* -KErrNotFound if the card contained fields that
|
williamr@4
|
106 |
* cannot be saved to the target store i.e.
|
williamr@4
|
107 |
* the operation didn't find any fields to copy.
|
williamr@4
|
108 |
* @return A new operation handle owned by the client.
|
williamr@4
|
109 |
* @exception KErrNotFound if the engine didn't find a copy policy
|
williamr@4
|
110 |
* for the target store.
|
williamr@4
|
111 |
* @asynchronous
|
williamr@4
|
112 |
*/
|
williamr@4
|
113 |
IMPORT_C MVPbkContactOperationBase* ImportVCardForSyncL(
|
williamr@4
|
114 |
MVPbkContactStore& aTargetStore,
|
williamr@4
|
115 |
RReadStream &aSourceStream,
|
williamr@4
|
116 |
MVPbkContactCopyObserver& aObserver);
|
williamr@4
|
117 |
|
williamr@4
|
118 |
/**
|
williamr@4
|
119 |
* Reads vCard records from a stream and creates contacts
|
williamr@4
|
120 |
* asynchronously.
|
williamr@4
|
121 |
*
|
williamr@4
|
122 |
* A client handles commiting the contact(s). Otherwise contacts
|
williamr@4
|
123 |
* are not saved to the store.
|
williamr@4
|
124 |
*
|
williamr@4
|
125 |
* @param aImportedContact An array for imported contacts from
|
williamr@4
|
126 |
* the client. Contains results after
|
williamr@4
|
127 |
* asynchronous import operation has completed.
|
williamr@4
|
128 |
* @param aTargetStore The Virtual Phonebook Store in which the
|
williamr@4
|
129 |
* information is copied to. The store must be
|
williamr@4
|
130 |
* writable.
|
williamr@4
|
131 |
* @param aSourceStream A stream where the vCard data is read from.
|
williamr@4
|
132 |
* @param aObserver An observer for asynchronous import.
|
williamr@4
|
133 |
* The aContact in the call back is always NULL.
|
williamr@4
|
134 |
* @return A new operation handle owned by the client.
|
williamr@4
|
135 |
* @asynchronous
|
williamr@4
|
136 |
*/
|
williamr@4
|
137 |
IMPORT_C MVPbkContactOperationBase* ImportVCardL(
|
williamr@4
|
138 |
RPointerArray<MVPbkStoreContact>& aImportedContacts,
|
williamr@4
|
139 |
MVPbkContactStore& aTargetStore,
|
williamr@4
|
140 |
RReadStream &aSourceStream,
|
williamr@4
|
141 |
MVPbkSingleContactOperationObserver& aObserver );
|
williamr@4
|
142 |
|
williamr@4
|
143 |
|
williamr@4
|
144 |
/**
|
williamr@4
|
145 |
* Reads Compact Business Card records from a stream and saves
|
williamr@4
|
146 |
* contacts to the store asynchronously.
|
williamr@4
|
147 |
*
|
williamr@4
|
148 |
* A client receives links to the created contacts in a call back.
|
williamr@4
|
149 |
*
|
williamr@4
|
150 |
* @param aTargetStore The Virtual Phonebook Store in which the
|
williamr@4
|
151 |
* information is copied to. The store must be
|
williamr@4
|
152 |
* writable.
|
williamr@4
|
153 |
* @param aSourceStream A stream where the card data is read from.
|
williamr@4
|
154 |
* @param aObserver An observer for asynchronous import.
|
williamr@4
|
155 |
* If successful there is one or more contact
|
williamr@4
|
156 |
* links in the array. Failed cases:
|
williamr@4
|
157 |
* -KErrNotSupported if the card is not compact
|
williamr@4
|
158 |
* business card
|
williamr@4
|
159 |
* -KErrCorrupted if the data is corrupted
|
williamr@4
|
160 |
* -KErrNotFound if there were no supported fields
|
williamr@4
|
161 |
* in the card.
|
williamr@4
|
162 |
* @return A new operation handle owned by the client.
|
williamr@4
|
163 |
* @exception KErrNotFound if the engine didn't find a copy policy
|
williamr@4
|
164 |
* for the target store.
|
williamr@4
|
165 |
* @asynchronous
|
williamr@4
|
166 |
*/
|
williamr@4
|
167 |
IMPORT_C MVPbkContactOperationBase* ImportCompactBusinessCardL(
|
williamr@4
|
168 |
MVPbkContactStore& aTargetStore,
|
williamr@4
|
169 |
RReadStream &aSourceStream,
|
williamr@4
|
170 |
MVPbkContactCopyObserver& aObserver );
|
williamr@4
|
171 |
|
williamr@4
|
172 |
/**
|
williamr@4
|
173 |
* Reads Compact Business Card records from a stream and creates
|
williamr@4
|
174 |
* contacts asynchronously.
|
williamr@4
|
175 |
*
|
williamr@4
|
176 |
* A client handles commiting the contact(s). Otherwise contacts
|
williamr@4
|
177 |
* are not saved to the store.
|
williamr@4
|
178 |
*
|
williamr@4
|
179 |
* @param aImportedContact An array for imported contacts from
|
williamr@4
|
180 |
* the client. Contains results after
|
williamr@4
|
181 |
* asynchronous import operation has completed.
|
williamr@4
|
182 |
* @param aTargetStore The Virtual Phonebook Store in which the
|
williamr@4
|
183 |
* contacts are created from. The store must be
|
williamr@4
|
184 |
* writable.
|
williamr@4
|
185 |
* @param aSourceStream A stream where the card data is read from.
|
williamr@4
|
186 |
* @param aObserver An observer for asynchronous import.
|
williamr@4
|
187 |
* aContact is always NULL in call back.
|
williamr@4
|
188 |
* If successful there is one or more contact
|
williamr@4
|
189 |
* links in the array. Failed cases:
|
williamr@4
|
190 |
* -KErrNotSupported if the card is not compact
|
williamr@4
|
191 |
* business card
|
williamr@4
|
192 |
* -KErrCorrupted if the data is corrupted
|
williamr@4
|
193 |
* -KErrNotFound if there were no supported fields
|
williamr@4
|
194 |
* in the card.
|
williamr@4
|
195 |
* @return A new operation handle owned by the client.
|
williamr@4
|
196 |
* @exception KErrNotFound if the engine didn't find a copy policy
|
williamr@4
|
197 |
* for the target store.
|
williamr@4
|
198 |
* @asynchronous
|
williamr@4
|
199 |
*/
|
williamr@4
|
200 |
IMPORT_C MVPbkContactOperationBase* ImportCompactBusinessCardL(
|
williamr@4
|
201 |
RPointerArray<MVPbkStoreContact>& aImportedContacts,
|
williamr@4
|
202 |
MVPbkContactStore& aTargetStore,
|
williamr@4
|
203 |
RReadStream &aSourceStream,
|
williamr@4
|
204 |
MVPbkSingleContactOperationObserver& aObserver );
|
williamr@4
|
205 |
|
williamr@4
|
206 |
/**
|
williamr@4
|
207 |
* Exports contact information asynchronously to a vCard record.
|
williamr@4
|
208 |
*
|
williamr@4
|
209 |
* The client gives the contact whose information is exported.
|
williamr@4
|
210 |
*
|
williamr@4
|
211 |
* @param aDestStream A stream where the vCard data is written to.
|
williamr@4
|
212 |
* The data written to the stream is not Committed by this method.
|
williamr@4
|
213 |
* @param aSourceItem A contact whose information is exported.
|
williamr@4
|
214 |
* @param aObserver An observer that is notified when the export completes.
|
williamr@4
|
215 |
* A store contact returned when operation has completed is
|
williamr@4
|
216 |
* always NULL.
|
williamr@4
|
217 |
* @param aBeamed If ETrue, then select fields are masked while exporting VCard
|
williamr@4
|
218 |
* @return A new operation handle owned by the client.
|
williamr@4
|
219 |
* @asynchronous
|
williamr@4
|
220 |
*/
|
williamr@4
|
221 |
IMPORT_C MVPbkContactOperationBase* ExportVCardL(
|
williamr@4
|
222 |
RWriteStream& aDestStream,
|
williamr@4
|
223 |
const MVPbkStoreContact& aSourceItem,
|
williamr@4
|
224 |
MVPbkSingleContactOperationObserver& aObserver);
|
williamr@4
|
225 |
|
williamr@4
|
226 |
/**
|
williamr@4
|
227 |
* Exports contact information asynchronously to a vCard record.
|
williamr@4
|
228 |
*
|
williamr@4
|
229 |
* The client gives the identifier of the contact that is first loaded
|
williamr@4
|
230 |
* and then exported.
|
williamr@4
|
231 |
*
|
williamr@4
|
232 |
* @param aDestStream A stream where the vCard data is written to.
|
williamr@4
|
233 |
* The data written to the stream is not Commited by this method.
|
williamr@4
|
234 |
* @param aContactLink An identifier of the contact that is exported.
|
williamr@4
|
235 |
* @param aObserver An observer that is notified when the export completes.
|
williamr@4
|
236 |
* A store contact returned when operation has completed is
|
williamr@4
|
237 |
* always NULL.
|
williamr@4
|
238 |
* @param aBeamed If ETrue, then select fields are masked while exporting VCard
|
williamr@4
|
239 |
* @return A new operation handle owned by the client.
|
williamr@4
|
240 |
* @asynchronous
|
williamr@4
|
241 |
*/
|
williamr@4
|
242 |
IMPORT_C MVPbkContactOperationBase* ExportVCardL(
|
williamr@4
|
243 |
RWriteStream& aDestStream,
|
williamr@4
|
244 |
const MVPbkContactLink& aContactLink,
|
williamr@4
|
245 |
MVPbkSingleContactOperationObserver& aObserver);
|
williamr@4
|
246 |
|
williamr@4
|
247 |
/**
|
williamr@4
|
248 |
* Exports contact information asynchronously to a vCard record.
|
williamr@4
|
249 |
* Note: Includes the fields, X-FAVORITE and X-SELF, during export
|
williamr@4
|
250 |
*
|
williamr@4
|
251 |
* The client gives the contact whose information is exported.
|
williamr@4
|
252 |
*
|
williamr@4
|
253 |
* @param aDestStream A stream where the vCard data is written to.
|
williamr@4
|
254 |
* The data written to the stream is not Committed by this method.
|
williamr@4
|
255 |
* @param aSourceItem A contact whose information is exported.
|
williamr@4
|
256 |
* @param aObserver An observer that is notified when the export completes.
|
williamr@4
|
257 |
* A store contact returned when operation has completed is
|
williamr@4
|
258 |
* always NULL.
|
williamr@4
|
259 |
* @return A new operation handle owned by the client.
|
williamr@4
|
260 |
* @asynchronous
|
williamr@4
|
261 |
*/
|
williamr@4
|
262 |
IMPORT_C MVPbkContactOperationBase* ExportVCardForSyncL(
|
williamr@4
|
263 |
RWriteStream& aDestStream,
|
williamr@4
|
264 |
const MVPbkStoreContact& aSourceItem,
|
williamr@4
|
265 |
MVPbkSingleContactOperationObserver& aObserver);
|
williamr@4
|
266 |
|
williamr@4
|
267 |
/**
|
williamr@4
|
268 |
* Exports contact information asynchronously to a vCard record.
|
williamr@4
|
269 |
* Note: Includes the fields, X-FAVORITE and X-SELF, during export
|
williamr@4
|
270 |
*
|
williamr@4
|
271 |
* The client gives the identifier of the contact that is first loaded
|
williamr@4
|
272 |
* and then exported.
|
williamr@4
|
273 |
*
|
williamr@4
|
274 |
* @param aDestStream A stream where the vCard data is written to.
|
williamr@4
|
275 |
* The data written to the stream is not Commited by this method.
|
williamr@4
|
276 |
* @param aContactLink An identifier of the contact that is exported.
|
williamr@4
|
277 |
* @param aObserver An observer that is notified when the export completes.
|
williamr@4
|
278 |
* A store contact returned when operation has completed is
|
williamr@4
|
279 |
* always NULL.
|
williamr@4
|
280 |
* @return A new operation handle owned by the client.
|
williamr@4
|
281 |
* @asynchronous
|
williamr@4
|
282 |
*/
|
williamr@4
|
283 |
IMPORT_C MVPbkContactOperationBase* ExportVCardForSyncL(
|
williamr@4
|
284 |
RWriteStream& aDestStream,
|
williamr@4
|
285 |
const MVPbkContactLink& aContactLink,
|
williamr@4
|
286 |
MVPbkSingleContactOperationObserver& aObserver);
|
williamr@4
|
287 |
|
williamr@4
|
288 |
|
williamr@4
|
289 |
/**
|
williamr@4
|
290 |
* Returns true for those field types that are supported by the vCard
|
williamr@4
|
291 |
* format and this engine.
|
williamr@4
|
292 |
*
|
williamr@4
|
293 |
* @param aFieldType A field type that is looked for.
|
williamr@4
|
294 |
* @return ETrue if given field is supported, EFalse otherwise
|
williamr@4
|
295 |
*/
|
williamr@4
|
296 |
IMPORT_C TBool SupportsFieldType(const MVPbkFieldType& aFieldType);
|
williamr@4
|
297 |
|
williamr@4
|
298 |
|
williamr@4
|
299 |
/**
|
williamr@4
|
300 |
* Returns field types that are supported by vCard engine.
|
williamr@4
|
301 |
*
|
williamr@4
|
302 |
* @return Field types that are supported by vCard engine.
|
williamr@4
|
303 |
*/
|
williamr@4
|
304 |
IMPORT_C const MVPbkFieldTypeList& SupportedFieldTypes();
|
williamr@4
|
305 |
|
williamr@4
|
306 |
/**
|
williamr@4
|
307 |
* Reads vCard records from a stream and replaces contacts
|
williamr@4
|
308 |
* asynchronously.
|
williamr@4
|
309 |
*
|
williamr@4
|
310 |
* A client handles commiting the contact(s). Otherwise contacts
|
williamr@4
|
311 |
* are not saved to the store.
|
williamr@4
|
312 |
*
|
williamr@4
|
313 |
* @param aReplaceContact Current contact which needs to replaced with
|
williamr@4
|
314 |
* the contact recevied from server as VcardBuffer. Contains results after
|
williamr@4
|
315 |
* asynchronous import operation has completed.
|
williamr@4
|
316 |
* @param aTargetStore The Virtual Phonebook Store in which the
|
williamr@4
|
317 |
* information is copied to. The store must be
|
williamr@4
|
318 |
* writable.
|
williamr@4
|
319 |
* @param aSourceStream A stream where the vCard data is read from.
|
williamr@4
|
320 |
* @param aObserver An observer for asynchronous import.
|
williamr@4
|
321 |
* The aContact in the call back is always NULL.
|
williamr@4
|
322 |
* @return A new operation handle owned by the client.
|
williamr@4
|
323 |
* @asynchronous
|
williamr@4
|
324 |
*/
|
williamr@4
|
325 |
IMPORT_C MVPbkContactOperationBase* CVPbkVCardEng::ImportVCardMergeL(
|
williamr@4
|
326 |
const MVPbkContactLink& aReplaceContact,
|
williamr@4
|
327 |
MVPbkContactStore& aTargetStore,
|
williamr@4
|
328 |
RReadStream& aSourceStream,
|
williamr@4
|
329 |
MVPbkSingleContactOperationObserver& aObserver );
|
williamr@4
|
330 |
|
williamr@4
|
331 |
private: // Implementation
|
williamr@4
|
332 |
CVPbkVCardEng(CVPbkContactManager& aContactManager);
|
williamr@4
|
333 |
void ConstructL();
|
williamr@4
|
334 |
|
williamr@4
|
335 |
private: // Data
|
williamr@4
|
336 |
/// Ref: Contact manager reference
|
williamr@4
|
337 |
CVPbkContactManager& iContactManager;
|
williamr@4
|
338 |
/// Own: Data for vCard handling
|
williamr@4
|
339 |
CVPbkVCardData* iData;
|
williamr@4
|
340 |
};
|
williamr@4
|
341 |
|
williamr@4
|
342 |
|
williamr@4
|
343 |
#endif // CVPBKVCARDENG_H
|
williamr@4
|
344 |
|
williamr@4
|
345 |
// End of file
|