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