author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Tue, 14 Sep 2010 20:54:53 +0300 | |
branch | RCL_3 |
changeset 21 | 9da50d567e3c |
parent 20 | f4a778e096c2 |
permissions | -rw-r--r-- |
20 | 1 |
/* |
2 |
* Copyright (c) 2002-2007 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: Implements the sim store domain |
|
15 |
* |
|
16 |
*/ |
|
17 |
||
18 |
||
19 |
||
20 |
// INCLUDE FILES |
|
21 |
#include "CContactStoreDomain.h" |
|
22 |
||
23 |
#include "CFieldTypeMappings.h" |
|
24 |
#include "CContactStore.h" |
|
25 |
||
26 |
#include <CVPbkContactStoreList.h> |
|
27 |
#include <cvpbkcontactoperationfactory.h> |
|
28 |
#include <CVPbkContactStoreUriArray.h> |
|
29 |
#include <MVPbkContactStore.h> |
|
30 |
#include <RLocalizedResourceFile.h> |
|
31 |
#include <TVPbkContactStoreUriPtr.h> |
|
32 |
#include <VPbkDataCaging.hrh> |
|
21
9da50d567e3c
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
33 |
#include <vpbksimstoreres.rsg> |
20 | 34 |
#include <VPbkStoreUriLiterals.h> |
35 |
#include <VPbkUtil.h> |
|
36 |
||
37 |
#include <barsc.h> |
|
38 |
#include <barsread.h> |
|
39 |
#include <featmgr.h> |
|
40 |
||
41 |
namespace VPbkSimStore { |
|
42 |
||
43 |
// CONSTANTS |
|
44 |
_LIT(KResFile, "VPbkSimStoreRes.rsc"); |
|
45 |
||
46 |
||
47 |
// ============================ MEMBER FUNCTIONS =============================== |
|
48 |
||
49 |
// ----------------------------------------------------------------------------- |
|
50 |
// CContactStoreDomain::CContactStoreDomain |
|
51 |
// C++ default constructor can NOT contain any code, that |
|
52 |
// might leave. |
|
53 |
// ----------------------------------------------------------------------------- |
|
54 |
// |
|
55 |
CContactStoreDomain::CContactStoreDomain( |
|
56 |
const MVPbkFieldTypeList& aMasterFieldTypeList, |
|
57 |
const TSecurityInfo& aSecurityInfo ) |
|
58 |
: iMasterFieldTypeList( aMasterFieldTypeList ), |
|
59 |
iSecurityInfo( aSecurityInfo ) |
|
60 |
{ |
|
61 |
} |
|
62 |
||
63 |
// ----------------------------------------------------------------------------- |
|
64 |
// CContactStoreDomain::ConstructL |
|
65 |
// Symbian 2nd phase constructor can leave. |
|
66 |
// ----------------------------------------------------------------------------- |
|
67 |
// |
|
68 |
void CContactStoreDomain::ConstructL( |
|
69 |
const CVPbkContactStoreUriArray& aURIList, const TDesC& aURIDomain ) |
|
70 |
{ |
|
71 |
iDomainDescriptor = aURIDomain.AllocL(); |
|
72 |
||
73 |
// Load Versit field type mappings |
|
74 |
User::LeaveIfError( iFs.Connect() ); |
|
75 |
||
76 |
// Create text store for versit property extension names |
|
77 |
iTextStore = new(ELeave) VPbkEngUtils::CTextStore; |
|
78 |
// Create the field type mapper |
|
79 |
iFieldTypeMappings = CFieldTypeMappings::NewL( iMasterFieldTypeList, * |
|
80 |
iTextStore ); |
|
81 |
||
82 |
VPbkEngUtils::RLocalizedResourceFile resFile; |
|
83 |
resFile.OpenLC( iFs, KVPbkRomFileDrive, KDC_RESOURCE_FILES_DIR, KResFile ); |
|
84 |
FeatureManager::InitializeLibL(); |
|
85 |
TResourceReader resReader; |
|
86 |
||
87 |
if ( !FeatureManager::FeatureSupported( |
|
88 |
KFeatureIdFfTdClmcontactreplicationfromphonebooktousimcard ) ) |
|
89 |
{ |
|
90 |
resReader.SetBuffer( resFile.AllocReadLC( |
|
91 |
R_VPBK_VERSIT_FIELD_TYPE_MAPPINGS ) ); |
|
92 |
} |
|
93 |
else |
|
94 |
{ |
|
95 |
resReader.SetBuffer( resFile.AllocReadLC( |
|
96 |
R_VPBK_USIM_VERSIT_FIELD_TYPE_MAPPINGS ) ); |
|
97 |
} |
|
98 |
// Read versit types |
|
99 |
iFieldTypeMappings->InitVersitMappingsL( resReader ); |
|
100 |
resReader.SetBuffer( resFile.AllocReadLC( |
|
101 |
R_VPBK_NONVERSIT_FIELD_TYPE_MAPPINGS ) ); |
|
102 |
// Read non versit types |
|
103 |
iFieldTypeMappings->InitNonVersitMappingsL( resReader ); |
|
104 |
//R_VPBK_NONVERSIT_FIELD_TYPE_MAPPINGS, resFile, iFs |
|
105 |
CleanupStack::PopAndDestroy( 3 ); |
|
106 |
||
107 |
// Create the store list |
|
108 |
iContactStoreList = CVPbkContactStoreList::NewL(); |
|
109 |
// Load all SIM stores |
|
110 |
TVPbkContactStoreUriPtr defaultDb( KVPbkSimGlobalAdnURI ); |
|
111 |
const TPtrC domain = defaultDb.Component( |
|
112 |
TVPbkContactStoreUriPtr::EContactStoreUriStoreType ); |
|
113 |
const TInt uriCount = aURIList.Count(); |
|
114 |
for ( TInt i = 0; i < uriCount; ++i ) |
|
115 |
{ |
|
116 |
if ( aURIList[i].Compare( domain, |
|
117 |
TVPbkContactStoreUriPtr::EContactStoreUriStoreType ) == 0 ) |
|
118 |
{ |
|
119 |
LoadContactStoreL( aURIList[i] ); |
|
120 |
} |
|
121 |
} |
|
122 |
// Create multioperation factory |
|
123 |
iOperationFactory = CVPbkContactOperationFactory::NewL( |
|
124 |
*iContactStoreList ); |
|
125 |
} |
|
126 |
||
127 |
// ----------------------------------------------------------------------------- |
|
128 |
// CContactStoreDomain::NewL |
|
129 |
// Two-phased constructor. |
|
130 |
// ----------------------------------------------------------------------------- |
|
131 |
// |
|
132 |
CContactStoreDomain* CContactStoreDomain::NewL |
|
133 |
( const CVPbkContactStoreUriArray& aURIList, |
|
134 |
const TDesC& aURIDomain, |
|
135 |
const MVPbkFieldTypeList& aMasterFieldTypeList, |
|
136 |
const TSecurityInfo& aSecurityInfo ) |
|
137 |
{ |
|
138 |
CContactStoreDomain* self = |
|
139 |
new( ELeave ) CContactStoreDomain( aMasterFieldTypeList, aSecurityInfo ); |
|
140 |
CleanupStack::PushL( self ); |
|
141 |
self->ConstructL( aURIList, aURIDomain ); |
|
142 |
CleanupStack::Pop( self ); |
|
143 |
return self; |
|
144 |
} |
|
145 |
||
146 |
// ----------------------------------------------------------------------------- |
|
147 |
// CContactStoreDomain::NewL |
|
148 |
// Two-phased constructor. |
|
149 |
// ----------------------------------------------------------------------------- |
|
150 |
// |
|
151 |
CContactStoreDomain* CContactStoreDomain::NewL( TAny* aParam ) |
|
152 |
{ |
|
153 |
TStoreDomainParam* param = static_cast<TStoreDomainParam*>( aParam ); |
|
154 |
return NewL( param->iURIList, *param->iURIDomain, |
|
155 |
*param->iFieldTypeList, param->iSecurityInfo ); |
|
156 |
} |
|
157 |
||
158 |
// Destructor |
|
159 |
CContactStoreDomain::~CContactStoreDomain() |
|
160 |
{ |
|
161 |
delete iDomainDescriptor; |
|
162 |
delete iFieldTypeMappings; |
|
163 |
delete iOperationFactory; |
|
164 |
delete iContactStoreList; |
|
165 |
delete iTextStore; |
|
166 |
iFs.Close(); |
|
167 |
FeatureManager::UnInitializeLib(); |
|
168 |
} |
|
169 |
||
170 |
// ----------------------------------------------------------------------------- |
|
171 |
// CContactStoreDomain::UriDomain |
|
172 |
// ----------------------------------------------------------------------------- |
|
173 |
// |
|
174 |
const TDesC& CContactStoreDomain::UriDomain() const |
|
175 |
{ |
|
176 |
return *iDomainDescriptor; |
|
177 |
} |
|
178 |
||
179 |
// ----------------------------------------------------------------------------- |
|
180 |
// CContactStoreDomain::Count |
|
181 |
// ----------------------------------------------------------------------------- |
|
182 |
// |
|
183 |
void CContactStoreDomain::LoadContactStoreL( |
|
184 |
const TVPbkContactStoreUriPtr& aUri ) |
|
185 |
{ |
|
186 |
if ( !iContactStoreList->Find(aUri) ) |
|
187 |
{ |
|
188 |
CContactStore* store = CContactStore::NewL( aUri, *this ); |
|
189 |
CleanupStack::PushL( store ); |
|
190 |
iContactStoreList->AppendL( store ); |
|
191 |
CleanupStack::Pop( store ); |
|
192 |
} |
|
193 |
} |
|
194 |
||
195 |
// ----------------------------------------------------------------------------- |
|
196 |
// CContactStoreDomain::Count |
|
197 |
// ----------------------------------------------------------------------------- |
|
198 |
// |
|
199 |
TInt CContactStoreDomain::Count() const |
|
200 |
{ |
|
201 |
return iContactStoreList->Count(); |
|
202 |
} |
|
203 |
||
204 |
// ----------------------------------------------------------------------------- |
|
205 |
// CContactStoreDomain::At |
|
206 |
// ----------------------------------------------------------------------------- |
|
207 |
// |
|
208 |
MVPbkContactStore& CContactStoreDomain::At( TInt aIndex ) const |
|
209 |
{ |
|
210 |
return iContactStoreList->At( aIndex ); |
|
211 |
} |
|
212 |
||
213 |
// ----------------------------------------------------------------------------- |
|
214 |
// CContactStoreDomain::Find |
|
215 |
// ----------------------------------------------------------------------------- |
|
216 |
// |
|
217 |
MVPbkContactStore* CContactStoreDomain::Find( |
|
218 |
const TVPbkContactStoreUriPtr& aUri ) const |
|
219 |
{ |
|
220 |
return iContactStoreList->Find( aUri ); |
|
221 |
} |
|
222 |
||
223 |
// ----------------------------------------------------------------------------- |
|
224 |
// CContactStoreDomain::OpenAllL |
|
225 |
// ----------------------------------------------------------------------------- |
|
226 |
// |
|
227 |
void CContactStoreDomain::OpenAllL( MVPbkContactStoreListObserver& aObserver ) |
|
228 |
{ |
|
229 |
iContactStoreList->OpenAllL( aObserver ); |
|
230 |
} |
|
231 |
||
232 |
// ----------------------------------------------------------------------------- |
|
233 |
// CContactStoreDomain::CloseAll |
|
234 |
// ----------------------------------------------------------------------------- |
|
235 |
// |
|
236 |
void CContactStoreDomain::CloseAll( MVPbkContactStoreListObserver& aObserver ) |
|
237 |
{ |
|
238 |
iContactStoreList->CloseAll( aObserver ); |
|
239 |
} |
|
240 |
||
241 |
// ----------------------------------------------------------------------------- |
|
242 |
// CContactStoreDomain::CreateContactRetrieverL |
|
243 |
// ----------------------------------------------------------------------------- |
|
244 |
// |
|
245 |
MVPbkContactOperation* CContactStoreDomain::CreateContactRetrieverL( |
|
246 |
const MVPbkContactLink& aLink, |
|
247 |
MVPbkSingleContactOperationObserver& aObserver ) |
|
248 |
{ |
|
249 |
return iOperationFactory->CreateContactRetrieverL( aLink, aObserver ); |
|
250 |
} |
|
251 |
||
252 |
// ----------------------------------------------------------------------------- |
|
253 |
// CContactStoreDomain::CreateDeleteContactsOperationL |
|
254 |
// ----------------------------------------------------------------------------- |
|
255 |
// |
|
256 |
MVPbkContactOperation* CContactStoreDomain::CreateDeleteContactsOperationL( |
|
257 |
const MVPbkContactLinkArray& aContactLinks, |
|
258 |
MVPbkBatchOperationObserver& aObserver ) |
|
259 |
{ |
|
260 |
return iOperationFactory->CreateDeleteContactsOperationL( aContactLinks, |
|
261 |
aObserver ); |
|
262 |
} |
|
263 |
||
264 |
// ----------------------------------------------------------------------------- |
|
265 |
// CContactStoreDomain::CreateCommitContactsOperationL |
|
266 |
// ----------------------------------------------------------------------------- |
|
267 |
// |
|
268 |
MVPbkContactOperation* CContactStoreDomain::CreateCommitContactsOperationL( |
|
269 |
const TArray<MVPbkStoreContact*>& aContacts, |
|
270 |
MVPbkBatchOperationObserver& aObserver ) |
|
271 |
{ |
|
272 |
return iOperationFactory->CreateCommitContactsOperationL( |
|
273 |
aContacts, aObserver ); |
|
274 |
} |
|
275 |
||
276 |
// ----------------------------------------------------------------------------- |
|
277 |
// CContactStoreDomain::CreateMatchPhoneNumberOperationL |
|
278 |
// ----------------------------------------------------------------------------- |
|
279 |
// |
|
280 |
MVPbkContactOperation* CContactStoreDomain::CreateMatchPhoneNumberOperationL( |
|
281 |
const TDesC& aPhoneNumber, |
|
282 |
TInt aMaxMatchDigits, |
|
283 |
MVPbkContactFindObserver& aObserver ) |
|
284 |
{ |
|
285 |
return iOperationFactory->CreateMatchPhoneNumberOperationL( aPhoneNumber, |
|
286 |
aMaxMatchDigits, aObserver ); |
|
287 |
} |
|
288 |
||
289 |
// ----------------------------------------------------------------------------- |
|
290 |
// CContactStoreDomain::CreateMatchPhoneNumberOperationL |
|
291 |
// ----------------------------------------------------------------------------- |
|
292 |
// |
|
293 |
MVPbkContactOperation* CContactStoreDomain::CreateFindOperationL( |
|
294 |
const TDesC& aSearchString, |
|
295 |
const MVPbkFieldTypeList& aFieldTypes, |
|
296 |
MVPbkContactFindObserver& aObserver) |
|
297 |
{ |
|
298 |
return iOperationFactory->CreateFindOperationL( aSearchString, aFieldTypes, |
|
299 |
aObserver ); |
|
300 |
} |
|
301 |
||
302 |
// ----------------------------------------------------------------------------- |
|
303 |
// CContactStoreDomain::CreateFindOperationL |
|
304 |
// ----------------------------------------------------------------------------- |
|
305 |
// |
|
306 |
MVPbkContactOperation* CContactStoreDomain::CreateFindOperationL( |
|
307 |
const MDesC16Array& aSearchStrings, |
|
308 |
const MVPbkFieldTypeList& aFieldTypes, |
|
309 |
MVPbkContactFindFromStoresObserver& aObserver, |
|
310 |
const TCallBack& aWordParserCallBack ) |
|
311 |
{ |
|
312 |
return iOperationFactory->CreateFindOperationL( aSearchStrings, aFieldTypes, |
|
313 |
aObserver, aWordParserCallBack ); |
|
314 |
} |
|
315 |
||
316 |
// ----------------------------------------------------------------------------- |
|
317 |
// CContactStoreDomain::CreateFindOperationL |
|
318 |
// ----------------------------------------------------------------------------- |
|
319 |
// |
|
320 |
MVPbkContactOperation* CContactStoreDomain::CreateFindOperationL( |
|
321 |
const MDesC16Array& aSearchStrings, |
|
322 |
const MVPbkFieldTypeList& aFieldTypes, |
|
323 |
MVPbkContactFindFromStoresObserver& aObserver, |
|
324 |
const TCallBack& aWordParserCallBack, |
|
325 |
const CDesC16ArrayFlat& aStoreEntriesArray ) |
|
326 |
{ |
|
327 |
return (reinterpret_cast<MVPbkContactOperationFactory2*> |
|
328 |
(iOperationFactory->ContactOperationFactoryExtension(KMVPbkContactOperationFactory2Uid)))-> |
|
329 |
CreateFindOperationL( aSearchStrings, aFieldTypes, |
|
330 |
aObserver, aWordParserCallBack, aStoreEntriesArray ); |
|
331 |
} |
|
332 |
||
333 |
// CContactStoreDomain::CreateCompressStoresOperationL |
|
334 |
// ----------------------------------------------------------------------------- |
|
335 |
// |
|
336 |
MVPbkContactOperation* CContactStoreDomain::CreateCompressStoresOperationL( |
|
337 |
MVPbkBatchOperationObserver& /*aObserver*/) |
|
338 |
{ |
|
339 |
// Compress not supported in SIM store |
|
340 |
return NULL; |
|
341 |
} |
|
342 |
TAny* CContactStoreDomain::ContactOperationFactoryExtension( TUid aExtensionUid ) |
|
343 |
{ |
|
344 |
if ( aExtensionUid == KMVPbkContactOperationFactory2Uid ) |
|
345 |
{ |
|
346 |
return static_cast<MVPbkContactOperationFactory2*>( this ); |
|
347 |
} |
|
348 |
return NULL; |
|
349 |
} |
|
350 |
||
351 |
} // namespace VPbkSimStore |
|
352 |
||
353 |
// End of File |