|
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 agenda data provider |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // INCLUDE FILES |
|
20 #include "nsmlagendadataprovider.h" |
|
21 #include "nsmlagendadatastore.h" |
|
22 #include "nsmldebug.h" |
|
23 #include "nsmldsimpluids.h" |
|
24 #include <SmlDataProvider.h> |
|
25 #include <ecom.h> |
|
26 #include <barsc.h> |
|
27 #include <bautils.h> |
|
28 #include <NSmlAgendaDataStore_1_1_2.rsg> |
|
29 #include <NSmlAgendaDataStore_1_2.rsg> |
|
30 #include <SmlDataFormat.h> |
|
31 #include <implementationproxy.h> |
|
32 #include <data_caging_path_literals.hrh> |
|
33 #include <e32property.h> |
|
34 #include <DataSyncInternalPSKeys.h> |
|
35 |
|
36 // ====================================== MEMBER FUNCTIONS ======================================== |
|
37 |
|
38 // ------------------------------------------------------------------------------------------------ |
|
39 // CNSmlAgendaDataProvider::CNSmlAgendaDataProvider |
|
40 // C++ default constructor can NOT contain any code, that |
|
41 // might leave. |
|
42 // ------------------------------------------------------------------------------------------------ |
|
43 // |
|
44 CNSmlAgendaDataProvider::CNSmlAgendaDataProvider() |
|
45 { |
|
46 _DBG_FILE("CNSmlAgendaDataProvider::CNSmlAgendaDataProvider(): BEGIN"); |
|
47 _DBG_FILE("CNSmlAgendaDataProvider::CNSmlAgendaDataProvider(): END"); |
|
48 } |
|
49 |
|
50 // ------------------------------------------------------------------------------------------------ |
|
51 // CNSmlAgendaDataProvider::ConstructL |
|
52 // Symbian 2nd phase constructor can leave. |
|
53 // ------------------------------------------------------------------------------------------------ |
|
54 // |
|
55 void CNSmlAgendaDataProvider::ConstructL( ) |
|
56 { |
|
57 _DBG_FILE("CNSmlAgendaDataProvider::NewL: BEGIN"); |
|
58 iAgnDataStore = CNSmlAgendaDataStore::NewL(); |
|
59 iStringPool.OpenL(); |
|
60 User::LeaveIfError( iSession.Connect() ); |
|
61 _DBG_FILE("CNSmlAgendaDataProvider::NewL: BEGIN"); |
|
62 } |
|
63 |
|
64 // ------------------------------------------------------------------------------------------------ |
|
65 // CNSmlAgendaDataProvider::NewL |
|
66 // Two-phased constructor. |
|
67 // ------------------------------------------------------------------------------------------------ |
|
68 // |
|
69 CNSmlAgendaDataProvider* CNSmlAgendaDataProvider::NewL() |
|
70 { |
|
71 _DBG_FILE("CNSmlAgendaDataProvider::NewL: BEGIN"); |
|
72 CNSmlAgendaDataProvider* self = new ( ELeave ) CNSmlAgendaDataProvider(); |
|
73 CleanupStack::PushL( self ); |
|
74 self->ConstructL(); |
|
75 CleanupStack::Pop( self ); |
|
76 _DBG_FILE("CNSmlAgendaDataProvider::NewL: BEGIN"); |
|
77 return self; |
|
78 } |
|
79 |
|
80 // ------------------------------------------------------------------------------------------------ |
|
81 // CNSmlAgendaDataProvider::~CNSmlAgendaDataProvider |
|
82 // Destructor. |
|
83 // ------------------------------------------------------------------------------------------------ |
|
84 // |
|
85 CNSmlAgendaDataProvider::~CNSmlAgendaDataProvider() |
|
86 { |
|
87 _DBG_FILE("CNSmlAgendaDataProvider::~CNSmlAgendaDataProvider(): BEGIN"); |
|
88 delete iAgnDataStore; |
|
89 iSession.Close(); |
|
90 delete iDSFormat; |
|
91 iStringPool.Close(); |
|
92 iFilterArray.ResetAndDestroy(); |
|
93 iFilterArray.Close(); |
|
94 _DBG_FILE("CNSmlAgendaDataProvider::~CNSmlAgendaDataProvider(): END"); |
|
95 } |
|
96 |
|
97 // ------------------------------------------------------------------------------------------------ |
|
98 // CNSmlAgendaDataProvider::DoOnFrameworkEvent |
|
99 // Not supported. |
|
100 // ------------------------------------------------------------------------------------------------ |
|
101 // |
|
102 void CNSmlAgendaDataProvider::DoOnFrameworkEvent( TSmlFrameworkEvent /*aEvent*/, TInt /*aParam1*/, TInt /*aParam2*/ ) |
|
103 { |
|
104 _DBG_FILE("CNSmlAgendaDataProvider::DoOnFrameworkEvent: BEGIN"); |
|
105 _DBG_FILE("CNSmlAgendaDataProvider::DoOnFrameworkEvent: END"); |
|
106 } |
|
107 |
|
108 // ------------------------------------------------------------------------------------------------ |
|
109 // CNSmlAgendaDataProvider::DoSupportsOperation |
|
110 // Return supported operation uid. |
|
111 // ------------------------------------------------------------------------------------------------ |
|
112 // |
|
113 TBool CNSmlAgendaDataProvider::DoSupportsOperation( TUid aOpId ) const |
|
114 { |
|
115 _DBG_FILE("CNSmlAgendaDataProvider::DoSupportsOperation: BEGIN"); |
|
116 if ( aOpId == KUidSmlSupportMultipleStores ) |
|
117 { |
|
118 _DBG_FILE("CNSmlAgendaDataProvider::DoSupportsOperation: END"); |
|
119 return ETrue; |
|
120 } |
|
121 _DBG_FILE("CNSmlAgendaDataProvider::DoSupportsOperation: END"); |
|
122 return EFalse; |
|
123 } |
|
124 |
|
125 // ------------------------------------------------------------------------------------------------ |
|
126 // CNSmlAgendaDataProvider::DoStoreFormatL |
|
127 // Return the current data store format. |
|
128 // ------------------------------------------------------------------------------------------------ |
|
129 // |
|
130 const CSmlDataStoreFormat& CNSmlAgendaDataProvider::DoStoreFormatL() |
|
131 { |
|
132 _DBG_FILE("CNSmlAgendaDataProvider::DoStoreFormatL(): BEGIN"); |
|
133 |
|
134 if ( iDSFormat ) |
|
135 { |
|
136 delete iDSFormat; |
|
137 iDSFormat = NULL; |
|
138 } |
|
139 iDSFormat = DoOwnStoreFormatL(); |
|
140 |
|
141 return *iDSFormat; |
|
142 } |
|
143 |
|
144 // ------------------------------------------------------------------------------------------------ |
|
145 // CNSmlAgendaDataProvider::DoListStoresLC |
|
146 // Return the list of datastore names. |
|
147 // ------------------------------------------------------------------------------------------------ |
|
148 // |
|
149 CDesCArray* CNSmlAgendaDataProvider::DoListStoresLC() |
|
150 { |
|
151 _DBG_FILE("CNSmlAgendaDataProvider::DoListStoresLC(): BEGIN"); |
|
152 _DBG_FILE("CNSmlAgendaDataProvider::DoListStoresLC(): END"); |
|
153 return iAgnDataStore->DoListAgendaFilesLC(); |
|
154 } |
|
155 |
|
156 // ------------------------------------------------------------------------------------------------ |
|
157 // CNSmlAgendaDataProvider::DoDefaultStoreL |
|
158 // Return the name of default store name. |
|
159 // ------------------------------------------------------------------------------------------------ |
|
160 // |
|
161 const TDesC& CNSmlAgendaDataProvider::DoDefaultStoreL() |
|
162 { |
|
163 _DBG_FILE("CNSmlAgendaDataProvider::DoDefaultStoreL(): BEGIN"); |
|
164 _DBG_FILE("CNSmlAgendaDataProvider::DoDefaultStoreL(): END"); |
|
165 return iAgnDataStore->DoGetDefaultFileNameL(); |
|
166 } |
|
167 |
|
168 // ------------------------------------------------------------------------------------------------ |
|
169 // CNSmlAgendaDataProvider::DoNewStoreInstanceLC |
|
170 // Return instance of data store |
|
171 // ------------------------------------------------------------------------------------------------ |
|
172 // |
|
173 CSmlDataStore* CNSmlAgendaDataProvider::DoNewStoreInstanceLC() |
|
174 { |
|
175 _DBG_FILE("CNSmlAgendaDataProvider::DoNewStoreInstanceLC(): BEGIN"); |
|
176 CNSmlAgendaDataStore* newStore = CNSmlAgendaDataStore::NewL(); |
|
177 CleanupStack::PushL( newStore ); |
|
178 _DBG_FILE("CNSmlAgendaDataProvider::DoNewStoreInstanceLC(): END"); |
|
179 return newStore; |
|
180 } |
|
181 |
|
182 // ------------------------------------------------------------------------------------------------ |
|
183 // CNSmlAgendaDataProvider::DoSupportedServerFiltersL |
|
184 // |
|
185 // ------------------------------------------------------------------------------------------------ |
|
186 const RPointerArray<CSyncMLFilter>& CNSmlAgendaDataProvider::DoSupportedServerFiltersL() |
|
187 { |
|
188 // This method returns empty array. It means that this Data Provider does not support filtering |
|
189 _DBG_FILE("CNSmlAgendaDataProvider::DoSupportedServerFiltersL(): BEGIN"); |
|
190 _DBG_FILE("CNSmlAgendaDataProvider::DoSupportedServerFiltersL(): END"); |
|
191 return iFilterArray; |
|
192 } |
|
193 |
|
194 // ------------------------------------------------------------------------------------------------ |
|
195 // CNSmlAgendaDataProvider::DoCheckSupportedServerFiltersL |
|
196 // |
|
197 // ------------------------------------------------------------------------------------------------ |
|
198 void CNSmlAgendaDataProvider::DoCheckSupportedServerFiltersL( const CSmlDataStoreFormat& /*aServerDataStoreFormat*/, RPointerArray<CSyncMLFilter>& /*aFilters*/, TSyncMLFilterChangeInfo& /*aChangeInfo*/ ) |
|
199 { |
|
200 _DBG_FILE("CNSmlAgendaDataProvider::DoCheckSupportedServerFiltersL(): BEGIN"); |
|
201 User::Leave( KErrNotSupported ); |
|
202 _DBG_FILE("CNSmlAgendaDataProvider::DoCheckSupportedServerFiltersL(): END"); |
|
203 } |
|
204 |
|
205 // ------------------------------------------------------------------------------------------------ |
|
206 // CNSmlAgendaDataProvider::CheckServerFiltersL |
|
207 // |
|
208 // ------------------------------------------------------------------------------------------------ |
|
209 void CNSmlAgendaDataProvider::DoCheckServerFiltersL( RPointerArray<CSyncMLFilter>& /*aFilters*/, TSyncMLFilterChangeInfo& /*aChangeInfo*/ ) |
|
210 { |
|
211 _DBG_FILE("CNSmlAgendaDataProvider::DoCheckServerFiltersL(): BEGIN"); |
|
212 User::Leave( KErrNotSupported ); |
|
213 _DBG_FILE("CNSmlAgendaDataProvider::DoCheckServerFiltersL(): END"); |
|
214 } |
|
215 |
|
216 // ------------------------------------------------------------------------------------------------ |
|
217 // CNSmlAgendaDataProvider::DoGenerateRecordFilterQueryLC |
|
218 // |
|
219 // ------------------------------------------------------------------------------------------------ |
|
220 HBufC* CNSmlAgendaDataProvider::DoGenerateRecordFilterQueryLC( const RPointerArray<CSyncMLFilter>& /*aFilters*/, TSyncMLFilterMatchType /*aMatch*/, TDes& /*aFilterMimeType*/, TSyncMLFilterType& /*aFilterType*/, TDesC& /*aStoreName*/ ) |
|
221 { |
|
222 _DBG_FILE("CNSmlAgendaDataProvider::DoGenerateRecordFilterQueryLC(): BEGIN"); |
|
223 User::Leave( KErrNotSupported ); |
|
224 _DBG_FILE("CNSmlAgendaDataProvider::DoGenerateRecordFilterQueryLC(): END"); |
|
225 return NULL; |
|
226 } |
|
227 |
|
228 // ------------------------------------------------------------------------------------------------ |
|
229 // CNSmlAgendaDataProvider::DoGenerateFieldFilterQueryL |
|
230 // |
|
231 // ------------------------------------------------------------------------------------------------ |
|
232 void CNSmlAgendaDataProvider::DoGenerateFieldFilterQueryL( const RPointerArray<CSyncMLFilter>& /*aFilters*/, TDes& /*aFilterMimeType*/, RPointerArray<CSmlDataProperty>& /*aProperties*/, TDesC& /*aStoreName*/ ) |
|
233 { |
|
234 _DBG_FILE("CNSmlAgendaDataProvider::DoGenerateFieldFilterQueryL(): BEGIN"); |
|
235 User::Leave( KErrNotSupported ); |
|
236 _DBG_FILE("CNSmlAgendaDataProvider::DoGenerateFieldFilterQueryL(): END"); |
|
237 } |
|
238 |
|
239 // ------------------------------------------------------------------------------------------------ |
|
240 // CNSmlAgendaDataProvider::DoOwnStoreFormatL |
|
241 // Read own store format from own resource file. |
|
242 // ------------------------------------------------------------------------------------------------ |
|
243 // |
|
244 CSmlDataStoreFormat* CNSmlAgendaDataProvider::DoOwnStoreFormatL() |
|
245 { |
|
246 _DBG_FILE("CNSmlAgendaDataProvider::DoOwnStoreFormatL(): BEGIN"); |
|
247 TFileName fileName; |
|
248 TParse parse; |
|
249 |
|
250 // Check correct Data Sync protocol |
|
251 TInt value( EDataSyncNotRunning ); |
|
252 TInt error = RProperty::Get( KPSUidDataSynchronizationInternalKeys, |
|
253 KDataSyncStatus, |
|
254 value ); |
|
255 if ( error == KErrNone && |
|
256 value == EDataSyncRunning ) |
|
257 { |
|
258 parse.Set( KNSmlDSAgendaDataStoreRsc_1_1_2, &KDC_RESOURCE_FILES_DIR, NULL ); |
|
259 } |
|
260 else // error or protocol version 1.2 |
|
261 { |
|
262 parse.Set( KNSmlDSAgendaDataStoreRsc_1_2, &KDC_RESOURCE_FILES_DIR, NULL ); |
|
263 } |
|
264 |
|
265 fileName = parse.FullName(); |
|
266 RResourceFile resourceFile; |
|
267 BaflUtils::NearestLanguageFile( iSession, fileName ); |
|
268 |
|
269 resourceFile.OpenL( iSession, fileName ); |
|
270 CleanupClosePushL( resourceFile ); |
|
271 |
|
272 HBufC8* profileRes = resourceFile.AllocReadLC( NSML_AGENDA_DATA_STORE ); |
|
273 TResourceReader reader; |
|
274 reader.SetBuffer( profileRes ); |
|
275 |
|
276 CSmlDataStoreFormat* dsFormat = CSmlDataStoreFormat::NewLC( iStringPool, reader ); |
|
277 CleanupStack::Pop(); // dsFormat |
|
278 CleanupStack::PopAndDestroy( 2 ); // profileRes, resourceFile |
|
279 _DBG_FILE("CNSmlAgendaDataProvider::DoOwnStoreFormatL(): END"); |
|
280 return dsFormat; |
|
281 } |
|
282 |
|
283 // =================================== OTHER EXPORTED FUNCTIONS =================================== |
|
284 #ifndef IMPLEMENTATION_PROXY_ENTRY |
|
285 #define IMPLEMENTATION_PROXY_ENTRY( aUid, aFuncPtr ) { { aUid }, ( aFuncPtr ) } |
|
286 #endif |
|
287 |
|
288 const TImplementationProxy ImplementationTable[] = |
|
289 { |
|
290 IMPLEMENTATION_PROXY_ENTRY( KNSmlAgendaAdapterImplUid, CNSmlAgendaDataProvider::NewL ) |
|
291 }; |
|
292 |
|
293 // ------------------------------------------------------------------------------------------------ |
|
294 // ImplementationGroupProxy |
|
295 // Framework needs this. |
|
296 // ------------------------------------------------------------------------------------------------ |
|
297 // |
|
298 EXPORT_C const TImplementationProxy* ImplementationGroupProxy( TInt& aTableCount ) |
|
299 { |
|
300 _DBG_FILE("ImplementationGroupProxy() for CNSmlAgendaDataProvider: begin"); |
|
301 aTableCount = sizeof( ImplementationTable ) / sizeof( TImplementationProxy ); |
|
302 _DBG_FILE("ImplementationGroupProxy() for CNSmlAgendaDataProvider: end"); |
|
303 return ImplementationTable; |
|
304 } |
|
305 |
|
306 |
|
307 // End of File |