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