|
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: DS contacts dataprovider |
|
15 * |
|
16 */ |
|
17 |
|
18 // INCLUDE FILES |
|
19 #include <utf.h> |
|
20 #include <e32base.h> |
|
21 #include <s32strm.h> |
|
22 #include <e32cmn.h> |
|
23 #include <sysutil.h> |
|
24 #include <barsc.h> |
|
25 #include <bautils.h> |
|
26 #include <SmlDataProvider.h> |
|
27 #include <NSmlContactsDataStoreFormat_1_1_2.rsg> |
|
28 #include <NSmlContactsDataStoreFormat_1_2.rsg> |
|
29 #include <data_caging_path_literals.hrh> |
|
30 #include <vtoken.h> |
|
31 #include <e32property.h> |
|
32 #include <DataSyncInternalPSKeys.h> |
|
33 #include <implementationproxy.h> |
|
34 #include <NSmlDataModBase.h> |
|
35 #include "NSmlContactsDataProvider.h" |
|
36 #include "nsmldebug.h" |
|
37 #include "nsmlconstants.h" |
|
38 #include "nsmldsimpluids.h" |
|
39 #include "nsmlchangefinder.h" |
|
40 |
|
41 // ============================ MEMBER FUNCTIONS =============================== |
|
42 |
|
43 // ----------------------------------------------------------------------------- |
|
44 // CNSmlContactsDataProvider::NewL |
|
45 // ----------------------------------------------------------------------------- |
|
46 // |
|
47 EXPORT_C CNSmlContactsDataProvider* CNSmlContactsDataProvider::NewL() |
|
48 { |
|
49 _DBG_FILE("CNSmlContactsDataProvider::NewL(): begin"); |
|
50 CNSmlContactsDataProvider* self = NewLC(); |
|
51 CleanupStack::Pop(); |
|
52 _DBG_FILE("CNSmlContactsDataProvider::NewL(): end"); |
|
53 return self; |
|
54 } |
|
55 |
|
56 // ----------------------------------------------------------------------------- |
|
57 // CNSmlContactsDataProvider::NewLC |
|
58 // ----------------------------------------------------------------------------- |
|
59 // |
|
60 EXPORT_C CNSmlContactsDataProvider* CNSmlContactsDataProvider::NewLC() |
|
61 { |
|
62 _DBG_FILE("CNSmlContactsDataProvider::NewLC(): begin"); |
|
63 |
|
64 CNSmlContactsDataProvider* self = new (ELeave) CNSmlContactsDataProvider(); |
|
65 CleanupStack::PushL( self ); |
|
66 self->ConstructL(); |
|
67 _DBG_FILE("CNSmlContactsDataProvider::NewLC(): end"); |
|
68 return self; |
|
69 } |
|
70 |
|
71 // ----------------------------------------------------------------------------- |
|
72 // CNSmlContactsDataProvider::CNSmlContactsDataProvider |
|
73 // ----------------------------------------------------------------------------- |
|
74 // |
|
75 EXPORT_C CNSmlContactsDataProvider::CNSmlContactsDataProvider() |
|
76 { |
|
77 _DBG_FILE("CNSmlContactsDataProvider::CNSmlContactsDataProvider(): begin"); |
|
78 _DBG_FILE("CNSmlContactsDataProvider::CNSmlContactsDataProvider(): end"); |
|
79 } |
|
80 |
|
81 // ----------------------------------------------------------------------------- |
|
82 // CNSmlContactsDataProvider::ConstructL |
|
83 // ----------------------------------------------------------------------------- |
|
84 // |
|
85 EXPORT_C void CNSmlContactsDataProvider::ConstructL() |
|
86 { |
|
87 _DBG_FILE("CNSmlContactsDataProvider::ConstructL(): begin"); |
|
88 |
|
89 User::LeaveIfError( iRfs.Connect() ); |
|
90 |
|
91 iContactsDataStore = CreateDataStoreLC(); |
|
92 CleanupStack::Pop( iContactsDataStore ); |
|
93 iStringPool.OpenL(); |
|
94 |
|
95 _DBG_FILE("CNSmlContactsDataProvider::ConstructL(): end"); |
|
96 } |
|
97 |
|
98 // ----------------------------------------------------------------------------- |
|
99 // CNSmlContactsDataProvider::~CNSmlContactsDataProvider |
|
100 // ----------------------------------------------------------------------------- |
|
101 // |
|
102 EXPORT_C CNSmlContactsDataProvider::~CNSmlContactsDataProvider() |
|
103 { |
|
104 _DBG_FILE("CNSmlContactsDataProvider::~CNSmlContactsDataProvider(): begin"); |
|
105 |
|
106 iRfs.Close(); |
|
107 |
|
108 delete iContactsDataStore; |
|
109 delete iStoreFormat; |
|
110 iFilterArray.ResetAndDestroy(); |
|
111 iFilterArray.Close(); |
|
112 |
|
113 iStringPool.Close(); |
|
114 |
|
115 _DBG_FILE("CNSmlContactsDataProvider::~CNSmlContactsDataProvider(): end"); |
|
116 } |
|
117 |
|
118 // ----------------------------------------------------------------------------- |
|
119 // CNSmlContactsDataProvider::DoOnFrameworkEvent |
|
120 // ----------------------------------------------------------------------------- |
|
121 // |
|
122 EXPORT_C void CNSmlContactsDataProvider::DoOnFrameworkEvent( TSmlFrameworkEvent /*aFrameworkEvent*/, TInt /*aParam1*/, TInt /*aParam2*/ ) |
|
123 { |
|
124 _DBG_FILE("CNSmlContactsDataProvider::DoOnFrameworkEvent(): begin"); |
|
125 _DBG_FILE("CNSmlContactsDataProvider::DoOnFrameworkEvent(): end"); |
|
126 } |
|
127 |
|
128 // ----------------------------------------------------------------------------- |
|
129 // CNSmlContactsDataProvider::DoSupportsOperation |
|
130 // ----------------------------------------------------------------------------- |
|
131 // |
|
132 EXPORT_C TBool CNSmlContactsDataProvider::DoSupportsOperation( TUid aOpId ) const |
|
133 { |
|
134 _DBG_FILE("CNSmlContactsDataProvider::DoSupportsOperation(): begin"); |
|
135 |
|
136 if ( aOpId == KUidSmlSupportBatch || |
|
137 aOpId == KUidSmlSupportMultipleStores ) |
|
138 { |
|
139 return ETrue; |
|
140 } |
|
141 |
|
142 _DBG_FILE("CNSmlContactsDataProvider::DoSupportsOperation(): end"); |
|
143 |
|
144 return EFalse; // KUidSmlSupportTransaction ,KUidSmlSupportSuspendResume, KUidSmlSupportUserSelectableMatchType |
|
145 } |
|
146 |
|
147 // ----------------------------------------------------------------------------- |
|
148 // CNSmlContactsDataProvider::DoStoreFormatL |
|
149 // ----------------------------------------------------------------------------- |
|
150 // |
|
151 EXPORT_C const CSmlDataStoreFormat& CNSmlContactsDataProvider::DoStoreFormatL() |
|
152 { |
|
153 _DBG_FILE("CNSmlContactsDataProvider::DoStoreFormatL(): begin"); |
|
154 |
|
155 delete iStoreFormat; |
|
156 iStoreFormat = NULL; |
|
157 |
|
158 TFileName fileName; |
|
159 TParse parse; |
|
160 |
|
161 // Locate the resource file |
|
162 TFileName dllFileName; |
|
163 Dll::FileName( dllFileName ); |
|
164 |
|
165 TFileName resourceFileName; |
|
166 resourceFileName.Copy( TParsePtrC( dllFileName ).Drive() ); |
|
167 |
|
168 parse.Set( GetStoreFormatResourceFileL(), &KDC_RESOURCE_FILES_DIR, NULL ); |
|
169 |
|
170 fileName = parse.FullName(); |
|
171 |
|
172 RResourceFile resourceFile; |
|
173 BaflUtils::NearestLanguageFile( iRfs, fileName ); |
|
174 |
|
175 resourceFile.OpenL( iRfs,fileName ); |
|
176 CleanupClosePushL( resourceFile ); |
|
177 |
|
178 HBufC8* contactsDataFormat = resourceFile.AllocReadLC( NSML_CONTACTS_DATA_STORE_FORMAT ); |
|
179 |
|
180 TResourceReader reader; |
|
181 reader.SetBuffer( contactsDataFormat ); |
|
182 |
|
183 iStoreFormat = CSmlDataStoreFormat::NewLC( iStringPool, reader ); |
|
184 CleanupStack::Pop(); // iStoreFormat |
|
185 |
|
186 CleanupStack::PopAndDestroy( 2 ); // contactsDataFormat,resourceFile |
|
187 |
|
188 _DBG_FILE("CNSmlContactsDataProvider::DoStoreFormatL(): end"); |
|
189 |
|
190 return *iStoreFormat; |
|
191 } |
|
192 |
|
193 // ----------------------------------------------------------------------------- |
|
194 // CNSmlContactsDataProvider::DoListStoresLC |
|
195 // ----------------------------------------------------------------------------- |
|
196 // |
|
197 EXPORT_C CDesCArray* CNSmlContactsDataProvider::DoListStoresLC() |
|
198 { |
|
199 _DBG_FILE("CNSmlContactsDataProvider::DoListStoresLC(): begin"); |
|
200 _DBG_FILE("CNSmlContactsDataProvider::DoListStoresLC(): end"); |
|
201 |
|
202 return iContactsDataStore->DoListStoresLC(); |
|
203 } |
|
204 |
|
205 // ----------------------------------------------------------------------------- |
|
206 // CNSmlContactsDataProvider::DoDefaultStoreL |
|
207 // ----------------------------------------------------------------------------- |
|
208 // |
|
209 EXPORT_C const TDesC& CNSmlContactsDataProvider::DoDefaultStoreL() |
|
210 { |
|
211 _DBG_FILE("CNSmlContactsDataProvider::DoIdentifier(): begin"); |
|
212 _DBG_FILE("CNSmlContactsDataProvider::DoIdentifier(): end"); |
|
213 |
|
214 return iContactsDataStore->DefaultStoreNameL(); |
|
215 } |
|
216 |
|
217 // ----------------------------------------------------------------------------- |
|
218 // CNSmlContactsDataProvider::DoNewStoreInstanceLC |
|
219 // ----------------------------------------------------------------------------- |
|
220 // |
|
221 EXPORT_C CSmlDataStore* CNSmlContactsDataProvider::DoNewStoreInstanceLC() |
|
222 { |
|
223 _DBG_FILE("CNSmlContactsDataProvider::DoNewStoreInstanceLC(): begin"); |
|
224 |
|
225 CNSmlContactsDataStore* newDataStore = CreateDataStoreLC(); |
|
226 |
|
227 _DBG_FILE("CNSmlContactsDataProvider::DoNewStoreInstanceLC(): end"); |
|
228 |
|
229 return newDataStore; |
|
230 } |
|
231 |
|
232 // ------------------------------------------------------------------------------------------------ |
|
233 // CNSmlContactsDataProvider::DoSupportedServerFiltersL |
|
234 // |
|
235 // ------------------------------------------------------------------------------------------------ |
|
236 EXPORT_C const RPointerArray<CSyncMLFilter>& CNSmlContactsDataProvider::DoSupportedServerFiltersL() |
|
237 { |
|
238 // This method returns empty array. It means that this Data Provider does not support filtering |
|
239 _DBG_FILE("CNSmlContactsDataProvider::DoSupportedServerFiltersL(): BEGIN"); |
|
240 _DBG_FILE("CNSmlContactsDataProvider::DoSupportedServerFiltersL(): END"); |
|
241 return iFilterArray; |
|
242 } |
|
243 |
|
244 // ------------------------------------------------------------------------------------------------ |
|
245 // CNSmlContactsDataProvider::DoCheckSupportedServerFiltersL |
|
246 // |
|
247 // ------------------------------------------------------------------------------------------------ |
|
248 EXPORT_C void CNSmlContactsDataProvider::DoCheckSupportedServerFiltersL( const CSmlDataStoreFormat& /*aServerDataStoreFormat*/, RPointerArray<CSyncMLFilter>& /*aFilters*/, TSyncMLFilterChangeInfo& /*aChangeInfo*/ ) |
|
249 { |
|
250 _DBG_FILE("CNSmlContactsDataProvider::DoCheckSupportedServerFiltersL(): BEGIN"); |
|
251 User::Leave( KErrNotSupported ); |
|
252 _DBG_FILE("CNSmlContactsDataProvider::DoCheckSupportedServerFiltersL(): END"); |
|
253 } |
|
254 |
|
255 // ------------------------------------------------------------------------------------------------ |
|
256 // CNSmlContactsDataProvider::CheckServerFiltersL |
|
257 // |
|
258 // ------------------------------------------------------------------------------------------------ |
|
259 EXPORT_C void CNSmlContactsDataProvider::DoCheckServerFiltersL( RPointerArray<CSyncMLFilter>& /*aFilters*/, TSyncMLFilterChangeInfo& /*aChangeInfo*/ ) |
|
260 { |
|
261 _DBG_FILE("CNSmlContactsDataProvider::DoCheckServerFiltersL(): BEGIN"); |
|
262 User::Leave( KErrNotSupported ); |
|
263 _DBG_FILE("CNSmlContactsDataProvider::DoCheckServerFiltersL(): END"); |
|
264 } |
|
265 |
|
266 // ------------------------------------------------------------------------------------------------ |
|
267 // CNSmlContactsDataProvider::DoGenerateRecordFilterQueryLC |
|
268 // |
|
269 // ------------------------------------------------------------------------------------------------ |
|
270 EXPORT_C HBufC* CNSmlContactsDataProvider::DoGenerateRecordFilterQueryLC( const RPointerArray<CSyncMLFilter>& /*aFilters*/, TSyncMLFilterMatchType /*aMatch*/, TDes& /*aFilterMimeType*/, TSyncMLFilterType& /*aFilterType*/, TDesC& /*aStoreName*/ ) |
|
271 { |
|
272 _DBG_FILE("CNSmlContactsDataProvider::DoGenerateRecordFilterQueryLC(): BEGIN"); |
|
273 User::Leave( KErrNotSupported ); |
|
274 _DBG_FILE("CNSmlContactsDataProvider::DoGenerateRecordFilterQueryLC(): END"); |
|
275 return NULL; |
|
276 } |
|
277 |
|
278 // ------------------------------------------------------------------------------------------------ |
|
279 // CNSmlContactsDataProvider::DoGenerateFieldFilterQueryL |
|
280 // |
|
281 // ------------------------------------------------------------------------------------------------ |
|
282 EXPORT_C void CNSmlContactsDataProvider::DoGenerateFieldFilterQueryL( const RPointerArray<CSyncMLFilter>& /*aFilters*/, TDes& /*aFilterMimeType*/, RPointerArray<CSmlDataProperty>& /*aProperties*/, TDesC& /*aStoreName*/ ) |
|
283 { |
|
284 _DBG_FILE("CNSmlContactsDataProvider::DoGenerateFieldFilterQueryL(): BEGIN"); |
|
285 User::Leave( KErrNotSupported ); |
|
286 _DBG_FILE("CNSmlContactsDataProvider::DoGenerateFieldFilterQueryL(): END"); |
|
287 } |
|
288 |
|
289 // ------------------------------------------------------------------------------------------------ |
|
290 // CNSmlContactsDataProvider::GetStoreFormatResourceFileL |
|
291 // |
|
292 // ------------------------------------------------------------------------------------------------ |
|
293 EXPORT_C const TDesC& CNSmlContactsDataProvider::GetStoreFormatResourceFileL() const |
|
294 { |
|
295 _DBG_FILE("CNSmlContactsDataProvider::GetStoreFormatResourceFileL(): BEGIN"); |
|
296 |
|
297 // Check correct Data Sync protocol |
|
298 TInt value( EDataSyncNotRunning ); |
|
299 TInt error = RProperty::Get( KPSUidDataSynchronizationInternalKeys, |
|
300 KDataSyncStatus, |
|
301 value ); |
|
302 if ( error == KErrNone && value == EDataSyncRunning ) |
|
303 { |
|
304 _DBG_FILE("CNSmlContactsDataProvider::GetStoreFormatResourceFileL(): END"); |
|
305 return KNSmlContactsStoreFormatRsc_1_1_2; |
|
306 } |
|
307 else // error or protocol version 1.2 |
|
308 { |
|
309 _DBG_FILE("CNSmlContactsDataProvider::GetStoreFormatResourceFileL(): END"); |
|
310 return KNSmlContactsStoreFormatRsc_1_2; |
|
311 } |
|
312 } |
|
313 |
|
314 // ------------------------------------------------------------------------------------------------ |
|
315 // CNSmlContactsDataProvider::CreateDataStoreLC |
|
316 // |
|
317 // ------------------------------------------------------------------------------------------------ |
|
318 EXPORT_C CNSmlContactsDataStore* CNSmlContactsDataProvider::CreateDataStoreLC() const |
|
319 { |
|
320 _DBG_FILE("CNSmlContactsDataProvider::CreateDataStoreLC(): BEGIN"); |
|
321 CNSmlContactsDataStore* dataStore = CNSmlContactsDataStore::NewL(); |
|
322 CleanupStack::PushL( dataStore ); |
|
323 _DBG_FILE("CNSmlContactsDataProvider::CreateDataStoreLC(): END"); |
|
324 return dataStore; |
|
325 } |
|
326 |
|
327 // ----------------------------------------------------------------------------- |
|
328 // ImplementationGroupProxy array |
|
329 // ----------------------------------------------------------------------------- |
|
330 // |
|
331 #ifndef IMPLEMENTATION_PROXY_ENTRY |
|
332 #define IMPLEMENTATION_PROXY_ENTRY( aUid, aFuncPtr ) {{aUid},(aFuncPtr)} |
|
333 #endif |
|
334 |
|
335 const TImplementationProxy ImplementationTable[] = |
|
336 { |
|
337 IMPLEMENTATION_PROXY_ENTRY( KNSmlContactsAdapterImplUid, CNSmlContactsDataProvider::NewL ) |
|
338 }; |
|
339 |
|
340 // ----------------------------------------------------------------------------- |
|
341 // ImplementationGroupProxy |
|
342 // ----------------------------------------------------------------------------- |
|
343 // |
|
344 EXPORT_C const TImplementationProxy* ImplementationGroupProxy( TInt& aTableCount ) |
|
345 { |
|
346 _DBG_FILE("ImplementationGroupProxy() for CNSmlContactsDataProvider: begin"); |
|
347 aTableCount = sizeof( ImplementationTable ) / sizeof( TImplementationProxy ); |
|
348 _DBG_FILE("ImplementationGroupProxy() for CNSmlContactsDataProvider: end"); |
|
349 return ImplementationTable; |
|
350 } |
|
351 // End of File |