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