|
1 /* |
|
2 * Copyright (c) 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: Implementation of TPhCntContactField class. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include <VPbkFieldType.hrh> |
|
20 #include <TVPbkFieldTypeParameters.h> |
|
21 #include <VPbkEng.rsg> |
|
22 #include <MVPbkStoreContactField.h> |
|
23 |
|
24 #include "MPhCntContactManager.h" |
|
25 #include "tphcntcontactfield.h" |
|
26 #include "PhCntTrace.h" |
|
27 |
|
28 // Speed dial related constants |
|
29 const TInt KPhCntPositionNotSet = 0; |
|
30 const TInt KPhCntPositionMin = 1; |
|
31 const TInt KPhCntPositionMax = 9; |
|
32 |
|
33 |
|
34 // ======== MEMBER FUNCTIONS ======== |
|
35 |
|
36 // --------------------------------------------------------------------------- |
|
37 // Constructor |
|
38 // --------------------------------------------------------------------------- |
|
39 // |
|
40 TPhCntContactField::TPhCntContactField() : |
|
41 iDataPointedByContactLink( EFalse ), |
|
42 iContactFieldId( 0 ) |
|
43 { |
|
44 } |
|
45 |
|
46 // --------------------------------------------------------------------------- |
|
47 // Constructor |
|
48 // --------------------------------------------------------------------------- |
|
49 // |
|
50 TPhCntContactField::TPhCntContactField( |
|
51 TInt aContactFieldId ) : |
|
52 iDataPointedByContactLink( EFalse ), |
|
53 iContactFieldId( aContactFieldId ) |
|
54 { |
|
55 } |
|
56 |
|
57 // --------------------------------------------------------------------------- |
|
58 // Destructor. |
|
59 // --------------------------------------------------------------------------- |
|
60 // |
|
61 TPhCntContactField::~TPhCntContactField() |
|
62 { |
|
63 } |
|
64 |
|
65 |
|
66 // --------------------------------------------------------------------------- |
|
67 // Gives the contact field data. |
|
68 // --------------------------------------------------------------------------- |
|
69 // |
|
70 const TDesC& TPhCntContactField::Data() const |
|
71 { |
|
72 return iContactFieldData; |
|
73 } |
|
74 |
|
75 // --------------------------------------------------------------------------- |
|
76 // Checks if this resolver is received datas resolver. If so then sets |
|
77 // the contact field data. |
|
78 // --------------------------------------------------------------------------- |
|
79 // |
|
80 void TPhCntContactField::Resolve( |
|
81 TInt aContactFieldId, |
|
82 const TDesC& aFieldData, |
|
83 TBool aPointedData ) |
|
84 { |
|
85 if( iContactFieldId == aContactFieldId ) |
|
86 { |
|
87 SetData( aFieldData, aPointedData ); |
|
88 } |
|
89 } |
|
90 |
|
91 // --------------------------------------------------------------------------- |
|
92 // Sets the contact field data if the possible earlier data is not |
|
93 // data which has been pointed by contact link. |
|
94 // --------------------------------------------------------------------------- |
|
95 // |
|
96 void TPhCntContactField::SetData( |
|
97 const TDesC& aData, |
|
98 TBool aPointedData ) |
|
99 { |
|
100 if( !iDataPointedByContactLink ) |
|
101 { |
|
102 iDataPointedByContactLink = aPointedData; |
|
103 PRINTF( "PhCnt: ContactField.SetData: %S", &aData ); |
|
104 iContactFieldData.Set( aData ); |
|
105 } |
|
106 } |
|
107 |
|
108 |
|
109 // --------------------------------------------------------------------------- |
|
110 // Constructor |
|
111 // --------------------------------------------------------------------------- |
|
112 // |
|
113 TPhCntPhoneNumber::TPhCntPhoneNumber() : |
|
114 TPhCntContactField( EVPbkVersitNameTEL ) |
|
115 { |
|
116 } |
|
117 |
|
118 // --------------------------------------------------------------------------- |
|
119 // Destructor. |
|
120 // --------------------------------------------------------------------------- |
|
121 // |
|
122 TPhCntPhoneNumber::~TPhCntPhoneNumber() |
|
123 { |
|
124 iAllNumbers.Close(); |
|
125 } |
|
126 |
|
127 // --------------------------------------------------------------------------- |
|
128 // Gives the phone number pointed by contact link |
|
129 // --------------------------------------------------------------------------- |
|
130 // |
|
131 const TPhCntNumber& TPhCntPhoneNumber::Number() const |
|
132 { |
|
133 return iPointedNumber; |
|
134 } |
|
135 |
|
136 // --------------------------------------------------------------------------- |
|
137 // Gives all numbers resolved. |
|
138 // --------------------------------------------------------------------------- |
|
139 // |
|
140 const RArray<TPhCntNumber>& TPhCntPhoneNumber::AllNumbers() const |
|
141 { |
|
142 return iAllNumbers; |
|
143 } |
|
144 |
|
145 // --------------------------------------------------------------------------- |
|
146 // Resolves phone number and its type. |
|
147 // --------------------------------------------------------------------------- |
|
148 // |
|
149 void TPhCntPhoneNumber::ResolveL( |
|
150 TInt aContactFieldId, |
|
151 const TDesC& aFieldData, |
|
152 TBool aPointedData, |
|
153 MPhCntContactManager& aContactManager, |
|
154 MVPbkStoreContactField& aContactField ) |
|
155 { |
|
156 |
|
157 // Evaluate fields type information |
|
158 const MPhCntMatch::TNumberType numberType = PhoneNumberType( aContactFieldId ); |
|
159 if ( numberType != MPhCntMatch::ENone ) |
|
160 { |
|
161 TBool speedDial = EFalse; |
|
162 // Test all speed dial positions |
|
163 for( TInt positionIndex = KPhCntPositionMin; positionIndex <= KPhCntPositionMax; positionIndex++ ) |
|
164 { |
|
165 if ( aContactManager.HasSpeedDialL( positionIndex, aContactField ) ) |
|
166 { |
|
167 speedDial = ETrue; |
|
168 // Add phone number & position specific entry |
|
169 SetNumber( aFieldData, numberType, aPointedData, positionIndex ); |
|
170 } |
|
171 } |
|
172 if ( !speedDial ) |
|
173 { |
|
174 // Add at least one phone number entry without any positions |
|
175 SetNumber( aFieldData, numberType, aPointedData, KPhCntPositionNotSet ); |
|
176 } |
|
177 } |
|
178 } |
|
179 |
|
180 // --------------------------------------------------------------------------- |
|
181 // Evaluates the type of a phone number field. |
|
182 // --------------------------------------------------------------------------- |
|
183 // |
|
184 MPhCntMatch::TNumberType TPhCntPhoneNumber::PhoneNumberType( |
|
185 TInt aContactFieldId ) |
|
186 { |
|
187 MPhCntMatch::TNumberType numberType = MPhCntMatch::ENone; |
|
188 |
|
189 switch( aContactFieldId ) |
|
190 { |
|
191 case R_VPBK_FIELD_TYPE_MOBILEPHONEGEN: |
|
192 case R_VPBK_FIELD_TYPE_MOBILEPHONEWORK: |
|
193 case R_VPBK_FIELD_TYPE_MOBILEPHONEHOME: |
|
194 numberType = MPhCntMatch::EMobileNumber; |
|
195 break; |
|
196 |
|
197 case R_VPBK_FIELD_TYPE_VOIPHOME: |
|
198 case R_VPBK_FIELD_TYPE_VOIPWORK: |
|
199 case R_VPBK_FIELD_TYPE_VOIPGEN: |
|
200 case R_VPBK_FIELD_TYPE_IMPP: |
|
201 case R_VPBK_FIELD_TYPE_SIP: |
|
202 numberType = MPhCntMatch::EVoipNumber; |
|
203 break; |
|
204 |
|
205 case R_VPBK_FIELD_TYPE_LANDPHONEHOME: |
|
206 case R_VPBK_FIELD_TYPE_LANDPHONEWORK: |
|
207 case R_VPBK_FIELD_TYPE_LANDPHONEGEN: |
|
208 |
|
209 numberType = MPhCntMatch::EStandardNumber; |
|
210 break; |
|
211 |
|
212 case R_VPBK_FIELD_TYPE_PAGERNUMBER: |
|
213 numberType = MPhCntMatch::EPagerNumber; |
|
214 break; |
|
215 |
|
216 case R_VPBK_FIELD_TYPE_FAXNUMBERGEN: |
|
217 case R_VPBK_FIELD_TYPE_FAXNUMBERHOME: |
|
218 case R_VPBK_FIELD_TYPE_FAXNUMBERWORK: |
|
219 numberType = MPhCntMatch::EFaxNumber; |
|
220 break; |
|
221 |
|
222 case R_VPBK_FIELD_TYPE_VIDEONUMBERHOME: |
|
223 case R_VPBK_FIELD_TYPE_VIDEONUMBERWORK: |
|
224 case R_VPBK_FIELD_TYPE_VIDEONUMBERGEN: |
|
225 numberType = MPhCntMatch::EVideoNumber; |
|
226 break; |
|
227 |
|
228 case R_VPBK_FIELD_TYPE_ASSTPHONE: |
|
229 numberType = MPhCntMatch::EAssistantNumber; |
|
230 break; |
|
231 |
|
232 case R_VPBK_FIELD_TYPE_CARPHONE: |
|
233 numberType = MPhCntMatch::ECarNumber; |
|
234 break; |
|
235 |
|
236 default: |
|
237 // Not a phone number. |
|
238 break; |
|
239 } |
|
240 return numberType; |
|
241 } |
|
242 |
|
243 // --------------------------------------------------------------------------- |
|
244 // Sets number |
|
245 // --------------------------------------------------------------------------- |
|
246 // |
|
247 void TPhCntPhoneNumber::SetNumber( |
|
248 const TDesC& aNumber, |
|
249 MPhCntMatch::TNumberType aNumberType, |
|
250 TBool aPointedField, |
|
251 TInt aSpeedDialPosition ) |
|
252 { |
|
253 if( aPointedField && !iDataPointedByContactLink ) |
|
254 { |
|
255 iDataPointedByContactLink = ETrue; |
|
256 iPointedNumber.Set( aNumber, aNumberType, aSpeedDialPosition ); |
|
257 } |
|
258 iAllNumbers.Append( TPhCntNumber( aNumber, aNumberType, aSpeedDialPosition ) ); |
|
259 } |
|
260 |
|
261 |