author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Tue, 14 Sep 2010 20:54:53 +0300 | |
branch | RCL_3 |
changeset 68 | 9da50d567e3c |
parent 63 | f4a778e096c2 |
child 85 | 38bb213f60ba |
permissions | -rw-r--r-- |
63 | 1 |
/* |
2 |
* Copyright (c) 2006-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: Virtual Phonebook vCard data class. |
|
15 |
* |
|
16 |
*/ |
|
17 |
||
18 |
||
19 |
#include "CVPbkVCardData.h" |
|
20 |
#include "CVPbkVCardIdNameMapping.h" |
|
21 |
#include "CVPbkVCardFieldTypeProperty.h" |
|
22 |
#include "CVPbkVCardFieldTypeList.h" |
|
23 |
#include "CVPbkVCardOperationFactory.h" |
|
24 |
||
25 |
#include <CVPbkContactManager.h> |
|
26 |
#include <VPbkDataCaging.hrh> |
|
68
9da50d567e3c
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
63
diff
changeset
|
27 |
#include <vpbkvcardeng.rsg> |
63 | 28 |
#include <RLocalizedResourceFile.h> |
29 |
#include <CVPbkContactCopyPolicyManager.h> |
|
30 |
#include <VPbkStoreUriLiterals.h> |
|
31 |
#include <MVPbkContactStoreList.h> |
|
32 |
#include <TVPbkContactStoreUriPtr.h> |
|
33 |
#include <CVPbkContactStoreUriArray.h> |
|
34 |
#include <CVPbkContactDuplicatePolicy.h> |
|
35 |
#include <VPbkUtil.h> |
|
36 |
||
37 |
#include <barsread.h> |
|
38 |
#include <vcard.h> |
|
39 |
#include <versittls.h> |
|
40 |
||
41 |
namespace |
|
42 |
{ |
|
43 |
/// VCard engine default resource file |
|
44 |
_LIT(KVCardEngDefResFileName, "VPbkVCardEng.rsc"); |
|
45 |
} |
|
46 |
||
47 |
CVPbkVCardData::CVPbkVCardData(CVPbkContactManager& aContactManager) : |
|
48 |
iContactManager(aContactManager), |
|
49 |
iMaskedFieldsArray(NULL) |
|
50 |
{ |
|
51 |
} |
|
52 |
||
53 |
inline void CVPbkVCardData::ConstructL() |
|
54 |
{ |
|
55 |
// Open a file server session |
|
56 |
RFs fs; |
|
57 |
User::LeaveIfError(fs.Connect()); |
|
58 |
CleanupClosePushL(fs); |
|
59 |
||
60 |
// Create text store for extension names |
|
61 |
iTextStore = new(ELeave) VPbkEngUtils::CTextStore; |
|
62 |
||
63 |
VPbkEngUtils::RLocalizedResourceFile resFile; |
|
64 |
resFile.OpenLC( fs, |
|
65 |
KVPbkRomFileDrive, |
|
66 |
KDC_RESOURCE_FILES_DIR, |
|
67 |
KVCardEngDefResFileName ); |
|
68 |
HBufC8* fieldTypesBuf = resFile.AllocReadLC( R_VPBK_TYPE_MAPPINGS ); |
|
69 |
TResourceReader resReader; |
|
70 |
resReader.SetBuffer( fieldTypesBuf ); |
|
71 |
||
72 |
TInt propertyCount( resReader.ReadInt16() ); |
|
73 |
while (propertyCount-- > 0) |
|
74 |
{ |
|
75 |
CVPbkVCardFieldTypeProperty* prop = |
|
76 |
CVPbkVCardFieldTypeProperty::NewLC( resReader, *iTextStore ); |
|
77 |
User::LeaveIfError( iProperties.Append( prop ) ); |
|
78 |
CleanupStack::Pop( prop ); |
|
79 |
} |
|
80 |
||
81 |
resReader.SetBuffer( |
|
82 |
resFile.AllocReadLC( R_VPBK_VCARD_PARAM_ID_NAME_MAPPINGS ) ); |
|
83 |
TInt mappingsCount( resReader.ReadInt16() ); |
|
84 |
while ( mappingsCount-- > 0 ) |
|
85 |
{ |
|
86 |
CVPbkVCardIdNameMapping* mapping = |
|
87 |
CVPbkVCardIdNameMapping::NewLC( resReader ); |
|
88 |
User::LeaveIfError( iParamIdNameMappings.Append( mapping ) ); |
|
89 |
CleanupStack::Pop( mapping ); |
|
90 |
} |
|
91 |
||
92 |
resReader.SetBuffer( |
|
93 |
resFile.AllocReadLC( R_VPBK_VCARD_VNAME_ID_NAME_MAPPINGS ) ); |
|
94 |
TInt vNameMappingsCount( resReader.ReadInt16() ); |
|
95 |
while ( vNameMappingsCount-- > 0 ) |
|
96 |
{ |
|
97 |
CVPbkVCardIdNameMapping* mapping = |
|
98 |
CVPbkVCardIdNameMapping::NewLC( resReader ); |
|
99 |
User::LeaveIfError( iVNameIdNameMappings.Append( mapping ) ); |
|
100 |
CleanupStack::Pop( mapping ); |
|
101 |
} |
|
102 |
||
103 |
HBufC8* dataMaskedFields = resFile.AllocReadLC(R_VPBK_VCARD_MASKED_FIELDS); |
|
104 |
resReader.SetBuffer(dataMaskedFields); |
|
105 |
iMaskedFieldsArray = resReader.ReadDesC8ArrayL(); |
|
106 |
CleanupStack::PopAndDestroy(dataMaskedFields); |
|
107 |
||
108 |
CleanupStack::PopAndDestroy(4, &resFile); |
|
109 |
// R_VPBK_VCARD_VNAME_ID_NAME_MAPPINGS |
|
110 |
// R_VPBK_VCARD_PARAMETER_ID_NAME_MAPPINGS, fieldTypesBuf, resFile |
|
111 |
||
112 |
CleanupStack::PopAndDestroy(); // fs |
|
113 |
||
114 |
iSupportedFieldTypes = |
|
115 |
CVPbkVCardFieldTypeList::NewLC( |
|
116 |
iProperties.Array(), iContactManager.FieldTypes() ); |
|
117 |
CleanupStack::Pop(); // iSupportedFieldTypes |
|
118 |
||
119 |
CVPbkContactDuplicatePolicy::TParam param( iContactManager ); |
|
120 |
||
121 |
iCopyPolicyManager = CVPbkContactCopyPolicyManager::NewL(); |
|
122 |
||
123 |
// Don leave if implementation is not found -> duplicate checking |
|
124 |
// is not used if there is no policy |
|
125 |
TRAPD( res, iDuplicatePolicy = CVPbkContactDuplicatePolicy::NewL( param )); |
|
126 |
if ( res != KErrNone && res != KErrNotFound ) |
|
127 |
{ |
|
128 |
User::LeaveIfError( res ); |
|
129 |
} |
|
130 |
iVersitTlsData = &CVersitTlsData::VersitTlsDataL(); |
|
131 |
} |
|
132 |
||
133 |
CVPbkVCardData* CVPbkVCardData::NewL(CVPbkContactManager& aContactManager) |
|
134 |
{ |
|
135 |
CVPbkVCardData* self = new(ELeave) CVPbkVCardData(aContactManager); |
|
136 |
CleanupStack::PushL(self); |
|
137 |
self->ConstructL(); |
|
138 |
CleanupStack::Pop(self); |
|
139 |
return self; |
|
140 |
} |
|
141 |
||
142 |
CVPbkVCardData::~CVPbkVCardData() |
|
143 |
{ |
|
144 |
if (iVersitTlsData) |
|
145 |
{ |
|
146 |
iVersitTlsData->VersitTlsDataClose(); |
|
147 |
} |
|
148 |
delete iCopyPolicyManager; |
|
149 |
iParamIdNameMappings.ResetAndDestroy(); |
|
150 |
iVNameIdNameMappings.ResetAndDestroy(); |
|
151 |
iProperties.ResetAndDestroy(); |
|
152 |
delete iSupportedFieldTypes; |
|
153 |
delete iDuplicatePolicy; |
|
154 |
delete iTextStore; |
|
155 |
delete iMaskedFieldsArray; |
|
156 |
} |
|
157 |
||
158 |
const MVPbkFieldTypeList& CVPbkVCardData::SupportedFieldTypes() const |
|
159 |
{ |
|
160 |
return *iSupportedFieldTypes; |
|
161 |
} |
|
162 |
||
163 |
TArray<CVPbkVCardFieldTypeProperty*> CVPbkVCardData::Properties() const |
|
164 |
{ |
|
165 |
return iProperties.Array(); |
|
166 |
} |
|
167 |
||
168 |
TArray<CVPbkVCardIdNameMapping*> CVPbkVCardData::VNameIdNameMappings() const |
|
169 |
{ |
|
170 |
return iVNameIdNameMappings.Array(); |
|
171 |
} |
|
172 |
||
173 |
TArray<CVPbkVCardIdNameMapping*> CVPbkVCardData::ParamIdNameMappings() const |
|
174 |
{ |
|
175 |
return iParamIdNameMappings.Array(); |
|
176 |
} |
|
177 |
||
178 |
MVPbkContactAttributeManager& CVPbkVCardData::AttributeManagerL() const |
|
179 |
{ |
|
180 |
return iContactManager.ContactAttributeManagerL(); |
|
181 |
} |
|
182 |
||
183 |
MVPbkContactDuplicatePolicy* CVPbkVCardData::DuplicatePolicy() |
|
184 |
{ |
|
185 |
return iDuplicatePolicy; |
|
186 |
} |
|
187 |
||
188 |
MVPbkContactCopyPolicy& CVPbkVCardData::CopyPolicyL( |
|
189 |
const TVPbkContactStoreUriPtr& aUri) const |
|
190 |
{ |
|
191 |
MVPbkContactCopyPolicy* policy = |
|
192 |
iCopyPolicyManager->GetPolicyL(iContactManager,aUri); |
|
193 |
if (!policy) |
|
194 |
{ |
|
195 |
User::Leave(KErrNotFound); |
|
196 |
} |
|
197 |
return *policy; |
|
198 |
} |
|
199 |
||
200 |
MVPbkContactStore& CVPbkVCardData::GetCntModelStoreL() |
|
201 |
{ |
|
202 |
TVPbkContactStoreUriPtr uriPtr(KVPbkDefaultCntDbURI); |
|
203 |
MVPbkContactStore* store = iContactManager.ContactStoresL().Find(uriPtr); |
|
204 |
if (!store) |
|
205 |
{ |
|
206 |
iContactManager.LoadContactStoreL(uriPtr); |
|
207 |
store = iContactManager.ContactStoresL().Find(uriPtr); |
|
208 |
} |
|
209 |
return *store; |
|
210 |
} |
|
211 |
||
212 |
const CDesC8ArrayFlat* CVPbkVCardData::GetMaskedFields() |
|
213 |
{ |
|
214 |
return (const CDesC8ArrayFlat*) iMaskedFieldsArray; |
|
215 |
} |
|
216 |
CVPbkContactManager& CVPbkVCardData::GetContactManager() |
|
217 |
{ |
|
218 |
return iContactManager; |
|
219 |
} |