|
1 /* |
|
2 * Copyright (c) 2006-2007 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: Virtual Phonebook VCard engine |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 // INCLUDES |
|
21 #include "CVPbkVCardEng.h" |
|
22 #include "CVPbkVCardOperationFactory.h" |
|
23 #include "CVPbkVCardData.h" |
|
24 |
|
25 #include <MVPbkContactOperation.h> |
|
26 #include <CVPbkContactManager.h> |
|
27 #include <MVPbkFieldType.h> |
|
28 |
|
29 #include <vcard.h> |
|
30 |
|
31 CVPbkVCardEng::CVPbkVCardEng(CVPbkContactManager& aContactManager) |
|
32 : iContactManager( aContactManager ) |
|
33 { |
|
34 } |
|
35 |
|
36 void CVPbkVCardEng::ConstructL() |
|
37 { |
|
38 iData = CVPbkVCardData::NewL(iContactManager); |
|
39 } |
|
40 |
|
41 CVPbkVCardEng::~CVPbkVCardEng() |
|
42 { |
|
43 delete iData; |
|
44 } |
|
45 |
|
46 EXPORT_C |
|
47 CVPbkVCardEng* CVPbkVCardEng::NewL(CVPbkContactManager& aContactManager) |
|
48 { |
|
49 CVPbkVCardEng* self = new (ELeave) CVPbkVCardEng( aContactManager ); |
|
50 CleanupStack::PushL( self ); |
|
51 self->ConstructL(); |
|
52 CleanupStack::Pop( self ); |
|
53 return self; |
|
54 } |
|
55 |
|
56 EXPORT_C MVPbkContactOperationBase* CVPbkVCardEng::ImportVCardL( |
|
57 MVPbkContactStore& aTargetStore, |
|
58 RReadStream& aSourceStream, |
|
59 MVPbkContactCopyObserver& aObserver) |
|
60 { |
|
61 MVPbkContactOperation* operation = |
|
62 VPbkVCardOperationFactory::CreateImportOperationL( *iData, |
|
63 aSourceStream, aTargetStore, aObserver, EFalse ); |
|
64 |
|
65 if( operation ) |
|
66 { |
|
67 CleanupDeletePushL( operation ); |
|
68 operation->StartL(); |
|
69 CleanupStack::Pop(); // operation |
|
70 } |
|
71 |
|
72 return operation; |
|
73 } |
|
74 |
|
75 EXPORT_C MVPbkContactOperationBase* CVPbkVCardEng::ImportVCardL( |
|
76 RPointerArray<MVPbkStoreContact>& aImportedContacts, |
|
77 MVPbkContactStore& aTargetStore, |
|
78 RReadStream &aSourceStream, |
|
79 MVPbkSingleContactOperationObserver& aObserver ) |
|
80 { |
|
81 MVPbkContactOperation* operation = |
|
82 VPbkVCardOperationFactory::CreateImportOperationL( *iData, |
|
83 aImportedContacts, aSourceStream, aTargetStore, aObserver ); |
|
84 |
|
85 if( operation ) |
|
86 { |
|
87 CleanupDeletePushL( operation ); |
|
88 operation->StartL(); |
|
89 CleanupStack::Pop(); // operation |
|
90 } |
|
91 |
|
92 return operation; |
|
93 } |
|
94 |
|
95 EXPORT_C MVPbkContactOperationBase* CVPbkVCardEng::ImportCompactBusinessCardL( |
|
96 MVPbkContactStore& aTargetStore, |
|
97 RReadStream &aSourceStream, |
|
98 MVPbkContactCopyObserver& aObserver ) |
|
99 { |
|
100 MVPbkContactOperation* operation = |
|
101 VPbkVCardOperationFactory::CreateImportCompactBCardOperationL( |
|
102 *iData, aTargetStore, aSourceStream, aObserver ); |
|
103 |
|
104 if( operation ) |
|
105 { |
|
106 CleanupDeletePushL( operation ); |
|
107 operation->StartL(); |
|
108 CleanupStack::Pop(); // operation |
|
109 } |
|
110 |
|
111 return operation; |
|
112 } |
|
113 |
|
114 EXPORT_C MVPbkContactOperationBase* CVPbkVCardEng::ImportCompactBusinessCardL( |
|
115 RPointerArray<MVPbkStoreContact>& aImportedContacts, |
|
116 MVPbkContactStore& aTargetStore, |
|
117 RReadStream &aSourceStream, |
|
118 MVPbkSingleContactOperationObserver& aObserver ) |
|
119 { |
|
120 MVPbkContactOperation* operation = |
|
121 VPbkVCardOperationFactory::CreateImportCompactBCardOperationL( |
|
122 *iData, aImportedContacts, aTargetStore, aSourceStream, |
|
123 aObserver ); |
|
124 |
|
125 if( operation ) |
|
126 { |
|
127 CleanupDeletePushL( operation ); |
|
128 operation->StartL(); |
|
129 CleanupStack::Pop(); // operation |
|
130 } |
|
131 |
|
132 return operation; |
|
133 } |
|
134 |
|
135 EXPORT_C MVPbkContactOperationBase* CVPbkVCardEng::ExportVCardL( |
|
136 RWriteStream& aDestStream, |
|
137 const MVPbkContactLink& aContactLink, |
|
138 MVPbkSingleContactOperationObserver& aObserver) |
|
139 { |
|
140 MVPbkContactOperation* operation = |
|
141 VPbkVCardOperationFactory::CreateExportOperationL( |
|
142 *iData, |
|
143 aDestStream, |
|
144 aContactLink, |
|
145 aObserver, |
|
146 iContactManager, |
|
147 ETrue ); |
|
148 |
|
149 if( operation ) |
|
150 { |
|
151 CleanupDeletePushL( operation ); |
|
152 operation->StartL(); |
|
153 CleanupStack::Pop(); // operation |
|
154 } |
|
155 |
|
156 return operation; |
|
157 } |
|
158 |
|
159 EXPORT_C MVPbkContactOperationBase* CVPbkVCardEng::ExportVCardL( |
|
160 RWriteStream& aDestStream, |
|
161 const MVPbkStoreContact& aSourceItem, |
|
162 MVPbkSingleContactOperationObserver& aObserver) |
|
163 { |
|
164 MVPbkContactOperation* operation = |
|
165 VPbkVCardOperationFactory::CreateExportOperationL( *iData, |
|
166 aDestStream, |
|
167 aSourceItem, |
|
168 aObserver, |
|
169 ETrue ); |
|
170 if( operation ) |
|
171 { |
|
172 CleanupDeletePushL( operation ); |
|
173 operation->StartL(); |
|
174 CleanupStack::Pop(); // operation |
|
175 } |
|
176 |
|
177 return operation; |
|
178 } |
|
179 |
|
180 EXPORT_C MVPbkContactOperationBase* CVPbkVCardEng::ExportVCardForSyncL( |
|
181 RWriteStream& aDestStream, |
|
182 const MVPbkContactLink& aContactLink, |
|
183 MVPbkSingleContactOperationObserver& aObserver) |
|
184 { |
|
185 MVPbkContactOperation* operation = |
|
186 VPbkVCardOperationFactory::CreateExportOperationL( |
|
187 *iData, |
|
188 aDestStream, |
|
189 aContactLink, |
|
190 aObserver, |
|
191 iContactManager, |
|
192 EFalse ); |
|
193 |
|
194 if( operation ) |
|
195 { |
|
196 CleanupDeletePushL( operation ); |
|
197 operation->StartL(); |
|
198 CleanupStack::Pop(); // operation |
|
199 } |
|
200 |
|
201 return operation; |
|
202 } |
|
203 |
|
204 EXPORT_C MVPbkContactOperationBase* CVPbkVCardEng::ExportVCardForSyncL( |
|
205 RWriteStream& aDestStream, |
|
206 const MVPbkStoreContact& aSourceItem, |
|
207 MVPbkSingleContactOperationObserver& aObserver) |
|
208 { |
|
209 MVPbkContactOperation* operation = |
|
210 VPbkVCardOperationFactory::CreateExportOperationL( *iData, |
|
211 aDestStream, |
|
212 aSourceItem, |
|
213 aObserver, |
|
214 EFalse ); |
|
215 if( operation ) |
|
216 { |
|
217 CleanupDeletePushL( operation ); |
|
218 operation->StartL(); |
|
219 CleanupStack::Pop(); // operation |
|
220 } |
|
221 |
|
222 return operation; |
|
223 } |
|
224 |
|
225 EXPORT_C TBool CVPbkVCardEng::SupportsFieldType(const MVPbkFieldType& aFieldType) |
|
226 { |
|
227 return iData->SupportedFieldTypes().ContainsSame( aFieldType ); |
|
228 } |
|
229 |
|
230 EXPORT_C const MVPbkFieldTypeList& CVPbkVCardEng::SupportedFieldTypes() |
|
231 { |
|
232 return iData->SupportedFieldTypes(); |
|
233 } |
|
234 |
|
235 EXPORT_C MVPbkContactOperationBase* CVPbkVCardEng::ImportVCardForSyncL( |
|
236 MVPbkContactStore& aTargetStore, |
|
237 RReadStream& aSourceStream, |
|
238 MVPbkContactCopyObserver& aObserver) |
|
239 { |
|
240 MVPbkContactOperation* operation = |
|
241 VPbkVCardOperationFactory::CreateImportOperationL( *iData, |
|
242 aSourceStream, aTargetStore, aObserver, ETrue ); |
|
243 |
|
244 if( operation ) |
|
245 { |
|
246 CleanupDeletePushL( operation ); |
|
247 operation->StartL(); |
|
248 CleanupStack::Pop(); // operation |
|
249 } |
|
250 |
|
251 return operation; |
|
252 } |
|
253 |
|
254 // ---------------------------------------------------------------------------- |
|
255 // CVPbkVCardEng::ImportVCardMergeL |
|
256 // ---------------------------------------------------------------------------- |
|
257 EXPORT_C MVPbkContactOperationBase* CVPbkVCardEng::ImportVCardMergeL( |
|
258 const MVPbkContactLink& aReplaceContact, |
|
259 MVPbkContactStore& aTargetStore, |
|
260 RReadStream& aSourceStream, |
|
261 MVPbkSingleContactOperationObserver& aObserver ) |
|
262 { |
|
263 MVPbkContactOperation* operation = |
|
264 VPbkVCardOperationFactory::CreateImportOperationL( |
|
265 *iData, |
|
266 aReplaceContact, |
|
267 aTargetStore, |
|
268 aSourceStream, |
|
269 aObserver ); |
|
270 |
|
271 if( operation ) |
|
272 { |
|
273 CleanupDeletePushL( operation ); |
|
274 operation->StartL(); |
|
275 CleanupStack::Pop(); // operation |
|
276 } |
|
277 |
|
278 return operation; |
|
279 } |
|
280 |
|
281 |
|
282 // End of file |