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: A class that reads an array of PSU2_COPY_TO_SIM_FIELDTYPE_INFO
|
|
15 |
* items
|
|
16 |
*
|
|
17 |
*/
|
|
18 |
|
|
19 |
|
|
20 |
|
|
21 |
// INCLUDE FILES
|
|
22 |
#include "CPsu2CopyToSimFieldInfoArray.h"
|
|
23 |
|
|
24 |
#include <RPbk2LocalizedResourceFile.h>
|
|
25 |
#include <Pbk2DataCaging.hrh>
|
|
26 |
#include <Pbk2USimUIRes.rsg>
|
|
27 |
#include <Pbk2CommonUi.rsg>
|
|
28 |
|
|
29 |
#include <TVPbkFieldTypeMapping.h>
|
|
30 |
#include <CVPbkFieldTypeSelector.h>
|
|
31 |
#include <MVPbkFieldType.h>
|
|
32 |
|
|
33 |
#include <coemain.h>
|
|
34 |
#include <barsread.h>
|
|
35 |
#include <gsmerror.h>
|
|
36 |
#include <featmgr.h>
|
|
37 |
#include <VPbkEng.rsg>
|
|
38 |
|
|
39 |
namespace
|
|
40 |
{
|
|
41 |
|
|
42 |
_LIT(KPsu2USimExtensionResFile, "Pbk2USimUIRes.rsc");
|
|
43 |
|
|
44 |
// ============================= LOCAL FUNCTIONS ===============================
|
|
45 |
|
|
46 |
#ifdef _DEBUG
|
|
47 |
enum TPanicCode
|
|
48 |
{
|
|
49 |
EPostCond_ConstructL,
|
|
50 |
EPostCond_CreateMappingsL
|
|
51 |
};
|
|
52 |
|
|
53 |
void Panic(TInt aReason)
|
|
54 |
{
|
|
55 |
_LIT(KPanicText, "SimFieldInfoArray");
|
|
56 |
User::Panic(KPanicText, aReason);
|
|
57 |
}
|
|
58 |
#endif // _DEBUG
|
|
59 |
}
|
|
60 |
|
|
61 |
/**
|
|
62 |
* A class that can read PSU2_COPY_TO_SIM_FIELDTYPE_MAPPING resource
|
|
63 |
* structure from Pbk2USimUi.rh
|
|
64 |
*/
|
|
65 |
class CPsu2CopyToSimFieldtypeMapping : public CBase
|
|
66 |
{
|
|
67 |
public:
|
|
68 |
|
|
69 |
/**
|
|
70 |
* @param aReader a resource reader to
|
|
71 |
* PSU2_COPY_TO_SIM_FIELDTYPE_MAPPING.
|
|
72 |
* @param aMasterFieldTypeList all field types from CVPbkContactManager
|
|
73 |
*/
|
|
74 |
static CPsu2CopyToSimFieldtypeMapping* NewLC(
|
|
75 |
TResourceReader& aReader,
|
|
76 |
const MVPbkFieldTypeList& aMasterFieldTypeList );
|
|
77 |
|
|
78 |
// Destructor
|
|
79 |
~CPsu2CopyToSimFieldtypeMapping();
|
|
80 |
|
|
81 |
/**
|
|
82 |
* The selector for the source field types.
|
|
83 |
*
|
|
84 |
* @return The selector for the source field types.
|
|
85 |
*/
|
|
86 |
MVPbkFieldTypeSelector& SourceTypeSelector() const;
|
|
87 |
|
|
88 |
/**
|
|
89 |
* Returns the resource id (VPbkEng.rsg) of the target field type.
|
|
90 |
*
|
|
91 |
* @return the resource id (VPbkEng.rsg) of the target field type.
|
|
92 |
*/
|
|
93 |
TInt TargetFieldtypeResId() const;
|
|
94 |
|
|
95 |
/**
|
|
96 |
* Returns flags defined Pbk2UsimUi.hrh
|
|
97 |
*
|
|
98 |
* @return flags defined Pbk2UsimUi.hrh
|
|
99 |
*/
|
|
100 |
TUint8 Flags() const;
|
|
101 |
|
|
102 |
/**
|
|
103 |
* @return TPsu2ErrorCode that causes this sim field type
|
|
104 |
* to be blocked.
|
|
105 |
*/
|
|
106 |
TUint8 BlockingError() const;
|
|
107 |
|
|
108 |
private:
|
|
109 |
void ConstructL( TResourceReader& aReader,
|
|
110 |
const MVPbkFieldTypeList& aMasterFieldTypeList );
|
|
111 |
|
|
112 |
private: // Data
|
|
113 |
/// Own: source field type selector
|
|
114 |
CVPbkFieldTypeSelector* iSourceTypeSelector;
|
|
115 |
/// Own: target field type resource id (VPbkEng.rsg)
|
|
116 |
TInt iTargetFieldTypeResId;
|
|
117 |
/// Flags from Pbk2UsimUi.hrh
|
|
118 |
TUint8 iFlags;
|
|
119 |
/// See TPsu2ErrorCode
|
|
120 |
TUint8 iBlockingError;
|
|
121 |
};
|
|
122 |
|
|
123 |
// ============================ MEMBER FUNCTIONS ===============================
|
|
124 |
|
|
125 |
// -----------------------------------------------------------------------------
|
|
126 |
// TPsu2CopyToSimFieldInfo::TPsu2CopyToSimFieldInfo
|
|
127 |
// C++ default constructor can NOT contain any code, that
|
|
128 |
// might leave.
|
|
129 |
// -----------------------------------------------------------------------------
|
|
130 |
//
|
|
131 |
TPsu2CopyToSimFieldInfo::TPsu2CopyToSimFieldInfo(
|
|
132 |
const MVPbkFieldType& aSourceType,
|
|
133 |
const MVPbkFieldType& aSimType,
|
|
134 |
TUint8 aFlags,
|
|
135 |
TUint8 aBlockingError )
|
|
136 |
: iSourceType( aSourceType ),
|
|
137 |
iSimType( aSimType ),
|
|
138 |
iFlags( aFlags ),
|
|
139 |
iBlockingError( aBlockingError )
|
|
140 |
{
|
|
141 |
}
|
|
142 |
|
|
143 |
// -----------------------------------------------------------------------------
|
|
144 |
// CPsu2CopyToSimFieldtypeMapping::NewLC
|
|
145 |
// -----------------------------------------------------------------------------
|
|
146 |
//
|
|
147 |
CPsu2CopyToSimFieldtypeMapping* CPsu2CopyToSimFieldtypeMapping::NewLC(
|
|
148 |
TResourceReader& aReader,
|
|
149 |
const MVPbkFieldTypeList& aMasterFieldTypeList )
|
|
150 |
{
|
|
151 |
CPsu2CopyToSimFieldtypeMapping* self =
|
|
152 |
new( ELeave ) CPsu2CopyToSimFieldtypeMapping;
|
|
153 |
CleanupStack::PushL( self );
|
|
154 |
self->ConstructL( aReader, aMasterFieldTypeList );
|
|
155 |
return self;
|
|
156 |
}
|
|
157 |
|
|
158 |
// -----------------------------------------------------------------------------
|
|
159 |
// CPsu2CopyToSimFieldtypeMapping::ConstructL
|
|
160 |
// -----------------------------------------------------------------------------
|
|
161 |
//
|
|
162 |
void CPsu2CopyToSimFieldtypeMapping::ConstructL( TResourceReader& aReader,
|
|
163 |
const MVPbkFieldTypeList& aMasterFieldTypeList )
|
|
164 |
{
|
|
165 |
iSourceTypeSelector = CVPbkFieldTypeSelector::NewL( aReader,
|
|
166 |
aMasterFieldTypeList );
|
|
167 |
iTargetFieldTypeResId = aReader.ReadInt32();
|
|
168 |
iFlags = aReader.ReadUint8();
|
|
169 |
iBlockingError = aReader.ReadUint8();
|
|
170 |
}
|
|
171 |
|
|
172 |
// -----------------------------------------------------------------------------
|
|
173 |
// CPsu2CopyToSimFieldtypeMapping::~CPsu2CopyToSimFieldtypeMapping
|
|
174 |
// -----------------------------------------------------------------------------
|
|
175 |
//
|
|
176 |
CPsu2CopyToSimFieldtypeMapping::~CPsu2CopyToSimFieldtypeMapping()
|
|
177 |
{
|
|
178 |
delete iSourceTypeSelector;
|
|
179 |
}
|
|
180 |
|
|
181 |
// -----------------------------------------------------------------------------
|
|
182 |
// CPsu2CopyToSimFieldtypeMapping::SourceTypeSelector
|
|
183 |
// -----------------------------------------------------------------------------
|
|
184 |
//
|
|
185 |
MVPbkFieldTypeSelector& CPsu2CopyToSimFieldtypeMapping::SourceTypeSelector() const
|
|
186 |
{
|
|
187 |
return *iSourceTypeSelector;
|
|
188 |
}
|
|
189 |
|
|
190 |
// -----------------------------------------------------------------------------
|
|
191 |
// CPsu2CopyToSimFieldtypeMapping::TargetFieldtypeResId
|
|
192 |
// -----------------------------------------------------------------------------
|
|
193 |
//
|
|
194 |
TInt CPsu2CopyToSimFieldtypeMapping::TargetFieldtypeResId() const
|
|
195 |
{
|
|
196 |
return iTargetFieldTypeResId;
|
|
197 |
}
|
|
198 |
|
|
199 |
// -----------------------------------------------------------------------------
|
|
200 |
// CPsu2CopyToSimFieldtypeMapping::Flags
|
|
201 |
// -----------------------------------------------------------------------------
|
|
202 |
//
|
|
203 |
TUint8 CPsu2CopyToSimFieldtypeMapping::Flags() const
|
|
204 |
{
|
|
205 |
return iFlags;
|
|
206 |
}
|
|
207 |
|
|
208 |
// -----------------------------------------------------------------------------
|
|
209 |
// CPsu2CopyToSimFieldtypeMapping::BlockingError
|
|
210 |
// -----------------------------------------------------------------------------
|
|
211 |
//
|
|
212 |
TUint8 CPsu2CopyToSimFieldtypeMapping::BlockingError() const
|
|
213 |
{
|
|
214 |
return iBlockingError;
|
|
215 |
}
|
|
216 |
|
|
217 |
// -----------------------------------------------------------------------------
|
|
218 |
// CPsu2CopyToSimFieldInfoArray::CPsu2CopyToSimFieldInfoArray
|
|
219 |
// C++ default constructor can NOT contain any code, that
|
|
220 |
// might leave.
|
|
221 |
// -----------------------------------------------------------------------------
|
|
222 |
//
|
|
223 |
CPsu2CopyToSimFieldInfoArray::CPsu2CopyToSimFieldInfoArray(
|
|
224 |
const MVPbkFieldTypeList& aMasterFieldTypeList)
|
|
225 |
: iMasterFieldTypeList(aMasterFieldTypeList)
|
|
226 |
{
|
|
227 |
}
|
|
228 |
|
|
229 |
// -----------------------------------------------------------------------------
|
|
230 |
// CPsu2CopyToSimFieldInfoArray::ConstructL
|
|
231 |
// Symbian 2nd phase constructor can leave.
|
|
232 |
// -----------------------------------------------------------------------------
|
|
233 |
//
|
|
234 |
void CPsu2CopyToSimFieldInfoArray::ConstructL( RFs& aFs )
|
|
235 |
{
|
|
236 |
// Open USIM extension resource file for reading field mappings.
|
|
237 |
// This class can be used from SIM copy policy so it must not
|
|
238 |
// depend on CCoeEnv in anyway.
|
|
239 |
RPbk2LocalizedResourceFile resFile( &aFs );
|
|
240 |
resFile.OpenLC(KPbk2RomFileDrive,
|
|
241 |
KDC_RESOURCE_FILES_DIR, KPsu2USimExtensionResFile);
|
|
242 |
FeatureManager::InitializeLibL();
|
|
243 |
TResourceReader reader;
|
|
244 |
if( !FeatureManager::FeatureSupported(
|
|
245 |
KFeatureIdFfTdClmcontactreplicationfromphonebooktousimcard ) )
|
|
246 |
{
|
|
247 |
reader.SetBuffer(
|
|
248 |
resFile.AllocReadLC( R_PSU2_COPY_TO_SIM_FIELDTYPE_MAPPINGS ) );
|
|
249 |
}
|
|
250 |
else
|
|
251 |
{
|
|
252 |
reader.SetBuffer(
|
|
253 |
resFile.AllocReadLC( R_PSU2_COPY_TO_USIM_FIELDTYPE_MAPPINGS ) );
|
|
254 |
}
|
|
255 |
|
|
256 |
// Go through all mappings in resource and create a mapping array
|
|
257 |
const TInt count = reader.ReadInt16();
|
|
258 |
for ( TInt i = 0; i < count; ++i )
|
|
259 |
{
|
|
260 |
CPsu2CopyToSimFieldtypeMapping* cmapping =
|
|
261 |
CPsu2CopyToSimFieldtypeMapping::NewLC( reader,
|
|
262 |
iMasterFieldTypeList );
|
|
263 |
CreateMappingsL( *cmapping );
|
|
264 |
CleanupStack::PopAndDestroy( cmapping );
|
|
265 |
}
|
|
266 |
CleanupStack::PopAndDestroy(); // R_PSU2_COPY_TO_SIM_FIELDTYPE_MAPPINGS
|
|
267 |
|
|
268 |
// Valid characters for number fields.
|
|
269 |
// Note: StringLoader can not be used in this class because it depends
|
|
270 |
// on CCoeEnv. This class can be run in non-UI context because
|
|
271 |
// CPsu2ContactCopyPolicy uses this class.
|
|
272 |
reader.SetBuffer(
|
|
273 |
resFile.AllocReadLC( R_PSU2_STANDARD_NUMBER_CHARACTER_MAP ) );
|
|
274 |
iNumberKeyMap = reader.ReadHBufCL();
|
|
275 |
// R_PSU2_STANDARD_NUMBER_CHARACTER_MAP, resFile
|
|
276 |
CleanupStack::PopAndDestroy(2);
|
|
277 |
|
|
278 |
// Get SIM name field type. This must be the same type as the type
|
|
279 |
// defined in VPbkSimStore
|
|
280 |
iSimNameType = iMasterFieldTypeList.Find( R_VPBK_FIELD_TYPE_LASTNAME );
|
|
281 |
iSimReadingType =
|
|
282 |
iMasterFieldTypeList.Find( R_VPBK_FIELD_TYPE_LASTNAMEREADING );
|
|
283 |
|
|
284 |
__ASSERT_DEBUG( iSimNameType && iSimReadingType,
|
|
285 |
Panic( EPostCond_ConstructL ) );
|
|
286 |
}
|
|
287 |
|
|
288 |
// -----------------------------------------------------------------------------
|
|
289 |
// CPsu2CopyToSimFieldInfoArray::NewL
|
|
290 |
// Two-phased constructor.
|
|
291 |
// -----------------------------------------------------------------------------
|
|
292 |
//
|
|
293 |
CPsu2CopyToSimFieldInfoArray* CPsu2CopyToSimFieldInfoArray::NewL(
|
|
294 |
const MVPbkFieldTypeList& aMasterFieldTypeList, RFs& aFs )
|
|
295 |
{
|
|
296 |
CPsu2CopyToSimFieldInfoArray* self =
|
|
297 |
new( ELeave ) CPsu2CopyToSimFieldInfoArray(aMasterFieldTypeList);
|
|
298 |
CleanupStack::PushL( self );
|
|
299 |
self->ConstructL( aFs );
|
|
300 |
CleanupStack::Pop();
|
|
301 |
return self;
|
|
302 |
}
|
|
303 |
|
|
304 |
|
|
305 |
// Destructor
|
|
306 |
CPsu2CopyToSimFieldInfoArray::~CPsu2CopyToSimFieldInfoArray()
|
|
307 |
{
|
|
308 |
iInfoArray.Close();
|
|
309 |
iMatchedTypes.Close();
|
|
310 |
delete iNumberKeyMap;
|
|
311 |
FeatureManager::UnInitializeLib();
|
|
312 |
}
|
|
313 |
|
|
314 |
// -----------------------------------------------------------------------------
|
|
315 |
// CPsu2CopyToSimFieldInfoArray::FindInfoForSourceType
|
|
316 |
// -----------------------------------------------------------------------------
|
|
317 |
//
|
|
318 |
const TPsu2CopyToSimFieldInfo*
|
|
319 |
CPsu2CopyToSimFieldInfoArray::FindInfoForSourceType(
|
|
320 |
const MVPbkFieldType& aSourceType )
|
|
321 |
{
|
|
322 |
const TPsu2CopyToSimFieldInfo* result = NULL;
|
|
323 |
const TInt count = iInfoArray.Count();
|
|
324 |
for (TInt i = 0; i < count && !result; ++i)
|
|
325 |
{
|
|
326 |
if (iInfoArray[i].SourceType().IsSame( aSourceType ) )
|
|
327 |
{
|
|
328 |
result = &iInfoArray[i];
|
|
329 |
}
|
|
330 |
}
|
|
331 |
return result;
|
|
332 |
}
|
|
333 |
|
|
334 |
// -----------------------------------------------------------------------------
|
|
335 |
// CPsu2CopyToSimFieldInfoArray::RemoveUnSupportedTargetTypeFieldInfo
|
|
336 |
// -----------------------------------------------------------------------------
|
|
337 |
//
|
|
338 |
void CPsu2CopyToSimFieldInfoArray::RemoveUnSupportedFieldInfo( const MVPbkFieldTypeList& aSupportedTypes )
|
|
339 |
{
|
|
340 |
// Check all the field info in the iInfoArray, if the target of the fieldinfo
|
|
341 |
// is not contained in the supportedTypes, Remove it from iInfoArray.
|
|
342 |
TInt i = iInfoArray.Count() - 1;
|
|
343 |
while( i >= 0 )
|
|
344 |
{
|
|
345 |
if( !aSupportedTypes.ContainsSame( iInfoArray[i].SimType()))
|
|
346 |
{
|
|
347 |
iInfoArray.Remove( i );
|
|
348 |
}
|
|
349 |
i --;
|
|
350 |
}
|
|
351 |
}
|
|
352 |
|
|
353 |
// -----------------------------------------------------------------------------
|
|
354 |
// CPsu2CopyToSimFieldInfoArray::SimNameType
|
|
355 |
// -----------------------------------------------------------------------------
|
|
356 |
//
|
|
357 |
const MVPbkFieldType& CPsu2CopyToSimFieldInfoArray::SimNameType() const
|
|
358 |
{
|
|
359 |
return *iSimNameType;
|
|
360 |
}
|
|
361 |
|
|
362 |
// -----------------------------------------------------------------------------
|
|
363 |
// CPsu2CopyToSimFieldInfoArray::LastNameReadingType
|
|
364 |
// -----------------------------------------------------------------------------
|
|
365 |
//
|
|
366 |
const MVPbkFieldType& CPsu2CopyToSimFieldInfoArray::LastNameReadingType() const
|
|
367 |
{
|
|
368 |
return *iSimReadingType;
|
|
369 |
}
|
|
370 |
|
|
371 |
// -----------------------------------------------------------------------------
|
|
372 |
// CPsu2CopyToSimFieldInfoArray::ConvertToSimType
|
|
373 |
// -----------------------------------------------------------------------------
|
|
374 |
//
|
|
375 |
const MVPbkFieldType* CPsu2CopyToSimFieldInfoArray::ConvertToSimType(
|
|
376 |
const MVPbkFieldType& aSourceType)
|
|
377 |
{
|
|
378 |
const TInt count = iInfoArray.Count();
|
|
379 |
for (TInt i = 0; i < count; ++i)
|
|
380 |
{
|
|
381 |
if (iInfoArray[i].SourceType().IsSame(aSourceType))
|
|
382 |
{
|
|
383 |
return &iInfoArray[i].SimType();
|
|
384 |
}
|
|
385 |
}
|
|
386 |
return NULL;
|
|
387 |
}
|
|
388 |
|
|
389 |
// -----------------------------------------------------------------------------
|
|
390 |
// CPsu2CopyToSimFieldInfoArray::TruncationAllowed
|
|
391 |
// -----------------------------------------------------------------------------
|
|
392 |
//
|
|
393 |
TBool CPsu2CopyToSimFieldInfoArray::TruncationAllowed(
|
|
394 |
const MVPbkFieldType& aSimType )
|
|
395 |
{
|
|
396 |
const TInt count = iInfoArray.Count();
|
|
397 |
for ( TInt i = 0; i < count; ++i )
|
|
398 |
{
|
|
399 |
if ( iInfoArray[i].SimType().IsSame( aSimType ) )
|
|
400 |
{
|
|
401 |
return iInfoArray[i].TruncationAllowed();
|
|
402 |
}
|
|
403 |
}
|
|
404 |
return EFalse;
|
|
405 |
}
|
|
406 |
|
|
407 |
// -----------------------------------------------------------------------------
|
|
408 |
// CPsu2CopyToSimFieldInfoArray::NumberKeyMap
|
|
409 |
// -----------------------------------------------------------------------------
|
|
410 |
//
|
|
411 |
const TDesC& CPsu2CopyToSimFieldInfoArray::NumberKeyMap() const
|
|
412 |
{
|
|
413 |
return *iNumberKeyMap;
|
|
414 |
}
|
|
415 |
|
|
416 |
// -----------------------------------------------------------------------------
|
|
417 |
// CPsu2CopyToSimFieldInfoArray::CreateMappingsL
|
|
418 |
// -----------------------------------------------------------------------------
|
|
419 |
//
|
|
420 |
void CPsu2CopyToSimFieldInfoArray::CreateMappingsL(
|
|
421 |
CPsu2CopyToSimFieldtypeMapping& aCMapping )
|
|
422 |
{
|
|
423 |
const TInt typeCount = iMasterFieldTypeList.FieldTypeCount();
|
|
424 |
// First find the target type
|
|
425 |
const MVPbkFieldType* targetType = iMasterFieldTypeList.Find(
|
|
426 |
aCMapping.TargetFieldtypeResId() );
|
|
427 |
|
|
428 |
// Then find all source types and create mappings
|
|
429 |
MVPbkFieldTypeSelector& selector = aCMapping.SourceTypeSelector();
|
|
430 |
for ( TInt i = 0; i < typeCount; ++i )
|
|
431 |
{
|
|
432 |
if ( selector.IsFieldTypeIncluded(
|
|
433 |
iMasterFieldTypeList.FieldTypeAt( i ) ) )
|
|
434 |
{
|
|
435 |
TPsu2CopyToSimFieldInfo info(
|
|
436 |
iMasterFieldTypeList.FieldTypeAt( i ),
|
|
437 |
*targetType, aCMapping.Flags(), aCMapping.BlockingError() );
|
|
438 |
iInfoArray.AppendL( info );
|
|
439 |
}
|
|
440 |
}
|
|
441 |
|
|
442 |
// Target type must be found from master field type list.
|
|
443 |
// If it doesn't, then either the field type list is not the
|
|
444 |
// master field types list or the field type resource id is corrupted.
|
|
445 |
__ASSERT_DEBUG( targetType, Panic( EPostCond_CreateMappingsL) );
|
|
446 |
}
|
|
447 |
// End of File
|