|
1 /* |
|
2 * Copyright (c) 2009 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: |
|
15 * |
|
16 */ |
|
17 #include <qcontact.h> |
|
18 #include <qcontactdetail.h> |
|
19 #include <qcontactname.h> |
|
20 #include <qcontactavatar.h> |
|
21 #include <qcontactphonenumber.h> |
|
22 #include <qtcontactsglobal.h> |
|
23 #include "cphcntmatch2.h" |
|
24 #include "cphcntcontactidimpl2.h" |
|
25 #include "qtphonelog.h" |
|
26 |
|
27 // ======== MEMBER FUNCTIONS ======== |
|
28 |
|
29 // --------------------------------------------------------------------------- |
|
30 // Constructor |
|
31 // --------------------------------------------------------------------------- |
|
32 // |
|
33 CPhCntMatch2::CPhCntMatch2(const QContact aContact): |
|
34 iContact(aContact), iNumber(NULL), iContactId(NULL), iDummyArray(NULL) |
|
35 { |
|
36 } |
|
37 |
|
38 // --------------------------------------------------------------------------- |
|
39 // Destructor. |
|
40 // --------------------------------------------------------------------------- |
|
41 // |
|
42 CPhCntMatch2::~CPhCntMatch2() |
|
43 { |
|
44 delete iNumber; |
|
45 delete iDummyArray; |
|
46 delete iContactId; |
|
47 } |
|
48 |
|
49 // ----------------------------------------------------------------------------- |
|
50 // CPhCntMatch2::NewL |
|
51 // Two-phased constructor. |
|
52 // ----------------------------------------------------------------------------- |
|
53 // |
|
54 CPhCntMatch2* CPhCntMatch2::NewL(const QContact aContact) |
|
55 { |
|
56 CPhCntMatch2* self = new( ELeave ) CPhCntMatch2(aContact); |
|
57 CleanupStack::PushL( self ); |
|
58 self->ConstructL(); |
|
59 CleanupStack::Pop(); |
|
60 return self; |
|
61 } |
|
62 |
|
63 // ----------------------------------------------------------------------------- |
|
64 // Release |
|
65 // ----------------------------------------------------------------------------- |
|
66 // |
|
67 void CPhCntMatch2::Release() |
|
68 { |
|
69 delete iNumber; |
|
70 iNumber = NULL; |
|
71 } |
|
72 |
|
73 // ----------------------------------------------------------------------------- |
|
74 // NewL |
|
75 // ----------------------------------------------------------------------------- |
|
76 // |
|
77 CPhCntContactId* CPhCntMatch2::ContactId() const |
|
78 { |
|
79 return iContactId; |
|
80 } |
|
81 |
|
82 // ----------------------------------------------------------------------------- |
|
83 // NumberType |
|
84 // ----------------------------------------------------------------------------- |
|
85 // |
|
86 MPhCntMatch::TNumberType CPhCntMatch2::NumberType() const |
|
87 { |
|
88 |
|
89 MPhCntMatch::TNumberType valueToReturn = MPhCntMatch::EMobileNumber; |
|
90 /* -> TODO not yet supported |
|
91 switch (iContact->field(fieldNumber).property()) |
|
92 { |
|
93 case propertyMobile: |
|
94 { |
|
95 valueToReturn = MPhCntMatch::EMobileNumber; |
|
96 break; |
|
97 } |
|
98 default: |
|
99 { |
|
100 valueToReturn = MPhCntMatch::ENone; |
|
101 } |
|
102 |
|
103 }//switch |
|
104 */ |
|
105 |
|
106 return valueToReturn; |
|
107 } |
|
108 |
|
109 // ----------------------------------------------------------------------------- |
|
110 // Cli |
|
111 // ----------------------------------------------------------------------------- |
|
112 // |
|
113 |
|
114 MPhCntMatch::TCliType CPhCntMatch2::Cli( HBufC*& /*aCliText*/ ) const |
|
115 { |
|
116 return ECliNumber; |
|
117 } |
|
118 |
|
119 // ----------------------------------------------------------------------------- |
|
120 // FirstName |
|
121 // ----------------------------------------------------------------------------- |
|
122 // |
|
123 TPtrC CPhCntMatch2::FirstName() const |
|
124 { |
|
125 return FieldValue(QContactName::DefinitionName, QContactName::FieldFirst); |
|
126 |
|
127 } |
|
128 // ----------------------------------------------------------------------------- |
|
129 // LastName |
|
130 // ----------------------------------------------------------------------------- |
|
131 // |
|
132 TPtrC CPhCntMatch2::LastName() const |
|
133 { |
|
134 return FieldValue(QContactName::DefinitionName, QContactName::FieldLast); |
|
135 |
|
136 } |
|
137 // ----------------------------------------------------------------------------- |
|
138 // CompanyName |
|
139 // ----------------------------------------------------------------------------- |
|
140 // |
|
141 TPtrC CPhCntMatch2::CompanyName() const |
|
142 { |
|
143 return KNullDesC(); |
|
144 } |
|
145 // ----------------------------------------------------------------------------- |
|
146 // Number |
|
147 // ----------------------------------------------------------------------------- |
|
148 // |
|
149 TPtrC CPhCntMatch2::Number() const |
|
150 { |
|
151 //how many numbers are returned here? should be only one that matched |
|
152 return iNumber? iNumber->Des() : |
|
153 FieldValue(QContactPhoneNumber::DefinitionName, |
|
154 QContactPhoneNumber::FieldNumber); |
|
155 } |
|
156 // ----------------------------------------------------------------------------- |
|
157 // PersonalRingingTone |
|
158 // ----------------------------------------------------------------------------- |
|
159 // |
|
160 TPtrC CPhCntMatch2::PersonalRingingTone() const |
|
161 { |
|
162 /* |
|
163 //TODO |
|
164 QString returnValue; |
|
165 QList<QContactAvatar> details = iContact.details<QContactAvatar>(); |
|
166 |
|
167 for (int i=0;i<details.count();++i) { |
|
168 if (details.at(i).subType() == QContactAvatar::SubTypeAudioRingtone) { |
|
169 returnValue = details.at(i).avatar(); |
|
170 break; |
|
171 } |
|
172 } |
|
173 |
|
174 return returnValue.utf16();*/ |
|
175 return KNullDesC(); |
|
176 } |
|
177 // ----------------------------------------------------------------------------- |
|
178 // BelongsToGroups |
|
179 // ----------------------------------------------------------------------------- |
|
180 // |
|
181 TBool CPhCntMatch2::BelongsToGroups( |
|
182 const CArrayFix<TContactItemId>& /*aGroupArray*/ ) const |
|
183 { |
|
184 return EFalse; |
|
185 } |
|
186 // ----------------------------------------------------------------------------- |
|
187 // TextToSpeechTextL |
|
188 // ----------------------------------------------------------------------------- |
|
189 // |
|
190 HBufC* CPhCntMatch2::TextToSpeechTextL() const |
|
191 { |
|
192 return NULL; |
|
193 } |
|
194 // ----------------------------------------------------------------------------- |
|
195 // CallText |
|
196 // ----------------------------------------------------------------------------- |
|
197 // |
|
198 TPtrC CPhCntMatch2::CallText() const |
|
199 { |
|
200 return KNullDesC(); |
|
201 } |
|
202 // ----------------------------------------------------------------------------- |
|
203 // CallImage |
|
204 // ----------------------------------------------------------------------------- |
|
205 // |
|
206 TPtrC CPhCntMatch2::CallImage() const |
|
207 { |
|
208 QString returnValue; |
|
209 QList<QContactAvatar> details = iContact.details<QContactAvatar>(); |
|
210 |
|
211 for (int i=0;i<details.count();++i) { |
|
212 if (details.at(i).subType() == QContactAvatar::SubTypeImage) { |
|
213 returnValue = details.at(i).avatar(); |
|
214 break; |
|
215 } |
|
216 } |
|
217 |
|
218 return returnValue.utf16(); |
|
219 } |
|
220 // ----------------------------------------------------------------------------- |
|
221 // HasThumbnailImage |
|
222 // ----------------------------------------------------------------------------- |
|
223 // |
|
224 TBool CPhCntMatch2::HasThumbnailImage() const |
|
225 { |
|
226 return EFalse; |
|
227 } |
|
228 // ----------------------------------------------------------------------------- |
|
229 // AllDtmfNumbers |
|
230 // ----------------------------------------------------------------------------- |
|
231 // |
|
232 CDesCArray& CPhCntMatch2::AllDtmfNumbers() const |
|
233 { |
|
234 return *iDummyArray; |
|
235 } |
|
236 // ----------------------------------------------------------------------------- |
|
237 // SetNumberL |
|
238 // ----------------------------------------------------------------------------- |
|
239 // |
|
240 |
|
241 void CPhCntMatch2::SetNumberL(const TDesC& aNumber) |
|
242 { |
|
243 delete iNumber; |
|
244 iNumber = NULL; |
|
245 iNumber = aNumber.AllocL(); |
|
246 } |
|
247 |
|
248 // ----------------------------------------------------------------------------- |
|
249 // ConstructL |
|
250 // ----------------------------------------------------------------------------- |
|
251 // |
|
252 void CPhCntMatch2::ConstructL() |
|
253 { |
|
254 iContactId = CPhCntContactIdImpl2::NewL(iContact); |
|
255 iDummyArray = new CDesCArrayFlat(1); |
|
256 } |
|
257 |
|
258 // ----------------------------------------------------------------------------- |
|
259 // FieldValue |
|
260 // ----------------------------------------------------------------------------- |
|
261 // |
|
262 TPtrC CPhCntMatch2::FieldValue(const QString& name, const QString& key) const |
|
263 { |
|
264 QString returnValue; |
|
265 QList<QContactDetail> details = iContact.details(name); |
|
266 if (details.count() == 1) |
|
267 { |
|
268 returnValue = details.first().value(key); |
|
269 } |
|
270 PHONE_DEBUG4("CPhCntMatch2::FieldValue:: key is :", key, "..value is :", returnValue); |
|
271 return returnValue.utf16(); |
|
272 } |
|
273 |
|
274 |