1 /* |
|
2 * Copyright (c) 2009 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: Part of SyncML Data Synchronization Plug In Adapter |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include <f32file.h> |
|
20 #include <bautils.h> |
|
21 #include <barsc.h> |
|
22 #include <stringpool.h> |
|
23 #include <data_caging_path_literals.hrh> |
|
24 |
|
25 #include <smldataformat.h> |
|
26 #include <ecom/implementationproxy.h> |
|
27 #include "mediadsprovider.h" |
|
28 #include "mediadsproviderdefs.h" |
|
29 #include "mediadsstore.h" |
|
30 #include <mediadsstore.rsg> |
|
31 #include "logger.h" |
|
32 |
|
33 |
|
34 |
|
35 // ----------------------------------------------------------------------------- |
|
36 // CMediaDataProvider::CMediaDataProvider |
|
37 // C++ default constructor can NOT contain any code, that might leave |
|
38 // ----------------------------------------------------------------------------- |
|
39 CMediaDataProvider::CMediaDataProvider() : |
|
40 iOwnStoreFormat(NULL), |
|
41 iFilters(1) |
|
42 { |
|
43 } |
|
44 |
|
45 // ----------------------------------------------------------------------------- |
|
46 // CMediaDataProvider::ConstructL |
|
47 // Symbian 2nd phase constructor can leave. |
|
48 // ----------------------------------------------------------------------------- |
|
49 void CMediaDataProvider::ConstructL() |
|
50 { |
|
51 TRACE_FUNC_ENTRY; |
|
52 |
|
53 iStringPool.OpenL(); |
|
54 User::LeaveIfError( iFs.Connect() ); |
|
55 |
|
56 TRACE_FUNC_EXIT; |
|
57 } |
|
58 |
|
59 // ----------------------------------------------------------------------------- |
|
60 // CMediaDataProvider::NewL |
|
61 // Two-phased constructor. |
|
62 // ----------------------------------------------------------------------------- |
|
63 CMediaDataProvider* CMediaDataProvider::NewL() |
|
64 { |
|
65 TRACE_FUNC_ENTRY; |
|
66 |
|
67 CMediaDataProvider* self = new (ELeave) CMediaDataProvider; |
|
68 |
|
69 CleanupStack::PushL( self ); |
|
70 self->ConstructL(); |
|
71 CleanupStack::Pop( self ); |
|
72 |
|
73 TRACE_FUNC_EXIT; |
|
74 return self; |
|
75 } |
|
76 |
|
77 |
|
78 // ----------------------------------------------------------------------------- |
|
79 // CMediaDataProvider::~CMediaDataProvider |
|
80 // Destructor. |
|
81 // ----------------------------------------------------------------------------- |
|
82 CMediaDataProvider::~CMediaDataProvider() |
|
83 { |
|
84 TRACE_FUNC_ENTRY; |
|
85 |
|
86 delete iOwnStoreFormat; |
|
87 iStringPool.Close(); |
|
88 |
|
89 iFilters.ResetAndDestroy(); |
|
90 iFilters.Close(); |
|
91 |
|
92 iFs.Close(); |
|
93 |
|
94 TRACE_FUNC_EXIT; |
|
95 } |
|
96 |
|
97 // ----------------------------------------------------------------------------- |
|
98 // CMediaDataProvider::DoOnFrameworkEvent |
|
99 // Not used |
|
100 // ----------------------------------------------------------------------------- |
|
101 void CMediaDataProvider::DoOnFrameworkEvent(TSmlFrameworkEvent, TInt /*aParam1*/, TInt /*aParam2*/) |
|
102 { |
|
103 TRACE_FUNC; |
|
104 } |
|
105 |
|
106 // ----------------------------------------------------------------------------- |
|
107 // CMediaDataProvider::DoSupportsOperation |
|
108 // Checks whether data provider supports specific operation |
|
109 // ----------------------------------------------------------------------------- |
|
110 TBool CMediaDataProvider::DoSupportsOperation(TUid /*aOpId*/) const |
|
111 { |
|
112 TRACE_FUNC; |
|
113 |
|
114 // Optional operations are not supported |
|
115 return EFalse; |
|
116 } |
|
117 |
|
118 // ----------------------------------------------------------------------------- |
|
119 // CMediaDataProvider::DoStoreFormatL |
|
120 // Creates data store format |
|
121 // ----------------------------------------------------------------------------- |
|
122 const CSmlDataStoreFormat& CMediaDataProvider::DoStoreFormatL() |
|
123 { |
|
124 TRACE_FUNC_ENTRY; |
|
125 |
|
126 if ( !iOwnStoreFormat ) |
|
127 { |
|
128 iOwnStoreFormat = DoOwnStoreFormatL(); |
|
129 } |
|
130 |
|
131 TRACE_FUNC_EXIT; |
|
132 |
|
133 return *iOwnStoreFormat; |
|
134 } |
|
135 |
|
136 // ----------------------------------------------------------------------------- |
|
137 // CMediaDataProvider::DoListStoresLC |
|
138 // Returns array fo data stores, not implemented because only single data store |
|
139 // is supported |
|
140 // ----------------------------------------------------------------------------- |
|
141 CDesCArray* CMediaDataProvider::DoListStoresLC() |
|
142 { |
|
143 TRACE_FUNC_ENTRY; |
|
144 |
|
145 CDesCArrayFlat* stores = new (ELeave) CDesCArrayFlat(1); |
|
146 CleanupStack::PushL( stores ); |
|
147 stores->AppendL( KMediaDsDbName ); |
|
148 stores->AppendL( KMediaDsRefreshDbName ); |
|
149 |
|
150 TRACE_FUNC_EXIT; |
|
151 |
|
152 return stores; |
|
153 } |
|
154 |
|
155 // ----------------------------------------------------------------------------- |
|
156 // CMediaDataProvider::DoDefaultStoreL |
|
157 // Returns the name of the default data store |
|
158 // ----------------------------------------------------------------------------- |
|
159 const TDesC& CMediaDataProvider::DoDefaultStoreL() |
|
160 { |
|
161 TRACE_FUNC; |
|
162 return KMediaDsDbName; |
|
163 } |
|
164 |
|
165 // ----------------------------------------------------------------------------- |
|
166 // CMediaDataProvider::DoNewStoreInstanceLC |
|
167 // Creates a new data store object, which can be used for synchronization |
|
168 // ----------------------------------------------------------------------------- |
|
169 CSmlDataStore* CMediaDataProvider::DoNewStoreInstanceLC() |
|
170 { |
|
171 TRACE_FUNC_ENTRY; |
|
172 CMediaDsDataStore* newStore = CMediaDsDataStore::NewLC( iFs ); |
|
173 TRACE_FUNC_EXIT; |
|
174 return newStore; |
|
175 } |
|
176 |
|
177 // ----------------------------------------------------------------------------- |
|
178 // CMediaDataProvider::DoCheckSupportedServerFiltersL |
|
179 // Filters are not supported |
|
180 // ----------------------------------------------------------------------------- |
|
181 void CMediaDataProvider::DoCheckSupportedServerFiltersL( |
|
182 const CSmlDataStoreFormat& /*aServerDataStoreFormat*/, |
|
183 RPointerArray<CSyncMLFilter>& /*aFilters*/, |
|
184 TSyncMLFilterChangeInfo& /*aChangeInfo*/ ) |
|
185 { |
|
186 TRACE_FUNC; |
|
187 User::Leave( KErrNotSupported ); |
|
188 } |
|
189 |
|
190 // ----------------------------------------------------------------------------- |
|
191 // CMediaDataProvider::DoCheckServerFiltersL |
|
192 // Filters are not supported |
|
193 // ----------------------------------------------------------------------------- |
|
194 void CMediaDataProvider::DoCheckServerFiltersL( |
|
195 RPointerArray<CSyncMLFilter>& /*aFilters*/, |
|
196 TSyncMLFilterChangeInfo& /*aChangeInfo*/) |
|
197 { |
|
198 TRACE_FUNC; |
|
199 User::Leave( KErrNotSupported ); |
|
200 } |
|
201 |
|
202 // ----------------------------------------------------------------------------- |
|
203 // CMediaDataProvider::DoSupportedServerFiltersL |
|
204 // Filters are not supported |
|
205 // ----------------------------------------------------------------------------- |
|
206 const RPointerArray<CSyncMLFilter>& CMediaDataProvider::DoSupportedServerFiltersL() |
|
207 { |
|
208 TRACE_FUNC; |
|
209 return iFilters; // empty array |
|
210 } |
|
211 |
|
212 // ----------------------------------------------------------------------------- |
|
213 // CMediaDataProvider::DoSupportsUserSelectableMatchType |
|
214 // Not supported |
|
215 // ----------------------------------------------------------------------------- |
|
216 TBool CMediaDataProvider::DoSupportsUserSelectableMatchType() const |
|
217 { |
|
218 TRACE_FUNC; |
|
219 return EFalse; |
|
220 } |
|
221 |
|
222 // ----------------------------------------------------------------------------- |
|
223 // CMediaDataProvider::DoGenerateRecordFilterQueryLC |
|
224 // Filters are not supported |
|
225 // ----------------------------------------------------------------------------- |
|
226 HBufC* CMediaDataProvider::DoGenerateRecordFilterQueryLC( |
|
227 const RPointerArray<CSyncMLFilter>& /*aFilters*/, |
|
228 TSyncMLFilterMatchType /*aMatch*/, TDes& /*aFilterMimeType*/, |
|
229 TSyncMLFilterType& /*aFilterType*/, TDesC& /*aStoreName*/ ) |
|
230 { |
|
231 TRACE_FUNC; |
|
232 User::Leave( KErrNotSupported ); |
|
233 return NULL; |
|
234 } |
|
235 |
|
236 // ----------------------------------------------------------------------------- |
|
237 // CMediaDataProvider::DoGenerateFieldFilterQueryL |
|
238 // Filters are not supported |
|
239 // ----------------------------------------------------------------------------- |
|
240 void CMediaDataProvider::DoGenerateFieldFilterQueryL( |
|
241 const RPointerArray<CSyncMLFilter>& /*aFilters*/, TDes& /*aFilterMimeType*/, |
|
242 RPointerArray<CSmlDataProperty>& /*aProperties*/, TDesC& /*aStoreName*/) |
|
243 { |
|
244 TRACE_FUNC; |
|
245 User::Leave( KErrNotSupported ); |
|
246 } |
|
247 |
|
248 // ----------------------------------------------------------------------------- |
|
249 // CMediaDataProvider::DoOwnStoreFormatL |
|
250 // Creates data store format |
|
251 // ----------------------------------------------------------------------------- |
|
252 CSmlDataStoreFormat* CMediaDataProvider::DoOwnStoreFormatL() |
|
253 { |
|
254 TRACE_FUNC_ENTRY; |
|
255 |
|
256 TParse* parse = new ( ELeave ) TParse(); |
|
257 CleanupStack::PushL(parse); |
|
258 TFileName fileName; |
|
259 RResourceFile resourceFile; |
|
260 |
|
261 parse->Set( KMediaDsStoreFormatRsc, &KDC_RESOURCE_FILES_DIR, NULL ); |
|
262 fileName = parse->FullName(); |
|
263 LOGGER_WRITE_1("filename: %S", &fileName); |
|
264 BaflUtils::NearestLanguageFile( iFs, fileName ); |
|
265 |
|
266 resourceFile.OpenL( iFs, fileName ); |
|
267 CleanupClosePushL( resourceFile ); |
|
268 |
|
269 HBufC8* buffer = resourceFile.AllocReadLC( MEDIADS_DATA_STORE ); |
|
270 |
|
271 TResourceReader reader; |
|
272 reader.SetBuffer( buffer ); |
|
273 |
|
274 CSmlDataStoreFormat* dsFormat = NULL; |
|
275 dsFormat = CSmlDataStoreFormat::NewLC( iStringPool, reader ); |
|
276 |
|
277 CleanupStack::Pop( dsFormat ); |
|
278 CleanupStack::PopAndDestroy( buffer ); |
|
279 CleanupStack::PopAndDestroy( &resourceFile ); |
|
280 CleanupStack::PopAndDestroy( parse ); |
|
281 |
|
282 TRACE_FUNC_EXIT; |
|
283 |
|
284 return dsFormat; |
|
285 } |
|
286 |
|
287 |
|
288 // ----------------------------------------------------------------------------- |
|
289 // ImplementationTable |
|
290 // Required by ECom plugin interface, tells the entry point of the library |
|
291 // ----------------------------------------------------------------------------- |
|
292 const TImplementationProxy ImplementationTable[] = |
|
293 { |
|
294 IMPLEMENTATION_PROXY_ENTRY(KMediaDataProviderImplUid, CMediaDataProvider::NewL) |
|
295 }; |
|
296 |
|
297 // ----------------------------------------------------------------------------- |
|
298 // ImplementationGroupProxy |
|
299 // Returns the implementation table, required by the ECom plugin interface |
|
300 // ----------------------------------------------------------------------------- |
|
301 EXPORT_C const TImplementationProxy* ImplementationGroupProxy(TInt& aTableCount) |
|
302 { |
|
303 aTableCount = sizeof(ImplementationTable) / sizeof(TImplementationProxy); |
|
304 return ImplementationTable; |
|
305 } |
|