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: An API for sim contacts
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
// INCLUDE FILES
|
|
21 |
#include "CVPbkSimContactBase.h"
|
|
22 |
|
|
23 |
#include "MVPbkSimCntStore.h"
|
|
24 |
#include "CVPbkSimCntField.h"
|
|
25 |
#include <RVPbkStreamedIntArray.h>
|
|
26 |
|
|
27 |
// ============================ MEMBER FUNCTIONS ===============================
|
|
28 |
|
|
29 |
// -----------------------------------------------------------------------------
|
|
30 |
// CVPbkSimContactBase::CVPbkSimContactBase
|
|
31 |
// C++ default constructor can NOT contain any code, that
|
|
32 |
// might leave.
|
|
33 |
// -----------------------------------------------------------------------------
|
|
34 |
//
|
|
35 |
CVPbkSimContactBase::CVPbkSimContactBase( MVPbkSimCntStore& aStore )
|
|
36 |
: iStore( aStore )
|
|
37 |
{
|
|
38 |
}
|
|
39 |
|
|
40 |
// -----------------------------------------------------------------------------
|
|
41 |
// CVPbkSimContactBase::ParentStore
|
|
42 |
// -----------------------------------------------------------------------------
|
|
43 |
//
|
|
44 |
MVPbkSimCntStore& CVPbkSimContactBase::ParentStore() const
|
|
45 |
{
|
|
46 |
return iStore;
|
|
47 |
}
|
|
48 |
|
|
49 |
// -----------------------------------------------------------------------------
|
|
50 |
// CVPbkSimContactBase::DeleteL
|
|
51 |
// -----------------------------------------------------------------------------
|
|
52 |
//
|
|
53 |
MVPbkSimStoreOperation* CVPbkSimContactBase::DeleteL(
|
|
54 |
MVPbkSimContactObserver& aObserver )
|
|
55 |
{
|
|
56 |
RVPbkStreamedIntArray indexArray;
|
|
57 |
CleanupClosePushL( indexArray );
|
|
58 |
indexArray.AppendIntL( SimIndex() );
|
|
59 |
MVPbkSimStoreOperation* op = iStore.DeleteL( indexArray, aObserver );
|
|
60 |
CleanupStack::PopAndDestroy(); // indexArray
|
|
61 |
return op;
|
|
62 |
}
|
|
63 |
|
|
64 |
// -----------------------------------------------------------------------------
|
|
65 |
// CVPbkSimContactBase::FindField
|
|
66 |
// -----------------------------------------------------------------------------
|
|
67 |
//
|
|
68 |
MVPbkSimContact::TFieldLookup CVPbkSimContactBase::FindField(
|
|
69 |
TVPbkSimCntFieldType aType ) const
|
|
70 |
{
|
|
71 |
MVPbkSimContact::TFieldLookup lookup;
|
|
72 |
lookup.SetType( aType );
|
|
73 |
const TInt firstPosition = 0;
|
|
74 |
lookup.SetPos( firstPosition );
|
|
75 |
FindNextField( lookup );
|
|
76 |
return lookup;
|
|
77 |
}
|
|
78 |
|
|
79 |
// -----------------------------------------------------------------------------
|
|
80 |
// CVPbkSimContactBase::FindNextField
|
|
81 |
// -----------------------------------------------------------------------------
|
|
82 |
//
|
|
83 |
void CVPbkSimContactBase::FindNextField(
|
|
84 |
MVPbkSimContact::TFieldLookup& aLookup ) const
|
|
85 |
{
|
|
86 |
const TInt count = FieldCount();
|
|
87 |
TInt i = aLookup.Pos();
|
|
88 |
aLookup.SetPos( KErrNotFound );
|
|
89 |
for ( ; i < count; ++i )
|
|
90 |
{
|
|
91 |
if( aLookup.Type() == EVPbkSimAdditionalNumber )
|
|
92 |
{
|
|
93 |
const CVPbkSimCntField& field = ConstFieldAt( i );
|
|
94 |
if ( field.Type() == EVPbkSimAdditionalNumber1
|
|
95 |
|| field.Type() == EVPbkSimAdditionalNumber2
|
|
96 |
|| field.Type() == EVPbkSimAdditionalNumber3
|
|
97 |
|| field.Type() == EVPbkSimAdditionalNumberLast ) // the same as EVPbkSimAdditionalNumber
|
|
98 |
{
|
|
99 |
aLookup.SetIndex( i );
|
|
100 |
aLookup.SetPos( i + 1 );
|
|
101 |
break;
|
|
102 |
}
|
|
103 |
}
|
|
104 |
else
|
|
105 |
{
|
|
106 |
if ( ConstFieldAt( i ).Type() == aLookup.Type() )
|
|
107 |
{
|
|
108 |
aLookup.SetIndex( i );
|
|
109 |
aLookup.SetPos( i + 1 );
|
|
110 |
break;
|
|
111 |
}
|
|
112 |
}
|
|
113 |
}
|
|
114 |
}
|
|
115 |
// End of File
|