|
1 /* |
|
2 * Copyright (c) 2002-2005 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: Holds data for one match result. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef CPHCNTMATCHITEM_H |
|
20 #define CPHCNTMATCHITEM_H |
|
21 |
|
22 // INCLUDES |
|
23 #include <e32base.h> |
|
24 #include <CNTDEF.H> // TContactItemId |
|
25 |
|
26 #include "CPhCntMatcher.h" // TFieldId |
|
27 #include "MPhCntMatch.h" // TPhCCliType |
|
28 |
|
29 // CONSTANTS |
|
30 |
|
31 // Panic literal for maching related panics. |
|
32 _LIT( KPhCntMatchPanic, "PhCntMatch" ); |
|
33 |
|
34 /** |
|
35 * Enumerates panic reasons. |
|
36 * |
|
37 * EPhCntMatchReferenceCountPanic |
|
38 * - reference count is invalid |
|
39 * EPhCntMatchNeededObjectNotPresentPanic |
|
40 * - instance is not present even if it is required to be. |
|
41 * EPhCntMatchPhonebookNotReleasedPanic |
|
42 * - phonebook has been released but still request of |
|
43 * phonebook to be released is given. |
|
44 */ |
|
45 enum TPhCntMatchPanicReason |
|
46 { |
|
47 EPhCntMatchReferenceCountPanic, |
|
48 EPhCntMatchNeededObjectNotPresentPanic, |
|
49 EPhCntMatchPhonebookNotReleasedPanic |
|
50 }; |
|
51 |
|
52 // FORWARD DECLARATIONS |
|
53 class CPbkContactItem; |
|
54 class MPhCntMatchItemOwner; |
|
55 class CContactIdArray; |
|
56 class CPhCntPbkContactId; |
|
57 |
|
58 // CLASS DECLARATION |
|
59 |
|
60 /** |
|
61 * Holds data for one match result. |
|
62 * Many CPhCntMatch objects may use this. |
|
63 * |
|
64 * @lib PhoneCntFinder |
|
65 * @since 1.0 |
|
66 */ |
|
67 NONSHARABLE_CLASS( CPhCntMatchItem ) :public CBase |
|
68 { |
|
69 public: // Constructors and destructor |
|
70 |
|
71 /** |
|
72 * Two-phased constructor. |
|
73 * @param aTelNumber Original phone number |
|
74 * @param aContact Matched contact item |
|
75 * @param aFieldId Matched field from the contact item |
|
76 * @param aOwner Own this i.e. handles delete |
|
77 * @return New instance |
|
78 */ |
|
79 static CPhCntMatchItem* NewL( |
|
80 const TDesC& aTelNumber, |
|
81 CPbkContactItem& aContact, |
|
82 const TFieldId aFieldId, |
|
83 MPhCntMatchItemOwner& aOwner ); |
|
84 |
|
85 /** |
|
86 * Destructor. |
|
87 */ |
|
88 virtual ~CPhCntMatchItem(); |
|
89 |
|
90 public: // New functions |
|
91 |
|
92 /** |
|
93 * Get the compared phone number |
|
94 * @return The original phonenumber |
|
95 */ |
|
96 inline const TDesC& OriginalNumber() const; |
|
97 |
|
98 /** |
|
99 * Add reference to this match item. |
|
100 */ |
|
101 inline void AddReference(); |
|
102 |
|
103 /** |
|
104 * Removes reference to this match item. If reference count |
|
105 * gets to zero the object is deleted. |
|
106 */ |
|
107 void RemoveReference(); |
|
108 |
|
109 /** |
|
110 * Returns reference count. |
|
111 * @return The count. |
|
112 */ |
|
113 inline TInt ReferenceCount() const; |
|
114 |
|
115 /** |
|
116 * Get contact ID. |
|
117 * @return The ID. |
|
118 */ |
|
119 inline CPhCntPbkContactId* ContactId() const; |
|
120 |
|
121 /** |
|
122 * Get number type |
|
123 * @return Phonebook number type |
|
124 */ |
|
125 inline TInt NumberType() const; |
|
126 |
|
127 /** |
|
128 * Get contact's CLI |
|
129 * @param aCliText CLI is saved here. User deletes the object. |
|
130 * @return CLI type |
|
131 */ |
|
132 MPhCntMatch::TCliType Cli( HBufC*& aCliText ) const; |
|
133 |
|
134 /** |
|
135 * First name field content. |
|
136 * @return The field. Empty if not specified. |
|
137 */ |
|
138 TPtrC FirstName() const; |
|
139 |
|
140 /** |
|
141 * Last name field content. |
|
142 * @return The field. Empty if not specified. |
|
143 */ |
|
144 TPtrC LastName() const; |
|
145 |
|
146 /** |
|
147 * Company name field content. |
|
148 * @return The field. Empty if not specified. |
|
149 */ |
|
150 TPtrC CompanyName() const; |
|
151 |
|
152 /** |
|
153 * Number field content (matched field). |
|
154 * @return The field. Empty if not specified. |
|
155 */ |
|
156 TPtrC Number() const; |
|
157 |
|
158 /** |
|
159 * Ringing tone field content. |
|
160 * @return The field. Empty if not specified. |
|
161 */ |
|
162 TPtrC PersonalRingingTone() const; |
|
163 |
|
164 /** |
|
165 * Find if contact belongs to any contact groups given. |
|
166 * @param aGroupArray Compared contact groups. |
|
167 * @return ETrue is belongs at least one group from parameter. |
|
168 */ |
|
169 TBool BelongsToGroups( const CArrayFix<TContactItemId>& aGroupArray ) const; |
|
170 |
|
171 /** |
|
172 * Returns text to speech text for this contact. Used in |
|
173 * text to speech ringing tone. |
|
174 * @since Series 60 3.0 |
|
175 * @return descriptor, ownership passed. |
|
176 */ |
|
177 HBufC* TextToSpeechTextL() const; |
|
178 |
|
179 /** |
|
180 * Call text field content. |
|
181 * @since Series 60 3.1 |
|
182 * @return The field. Empty if not specified. |
|
183 */ |
|
184 TPtrC CallText() const; |
|
185 |
|
186 /** |
|
187 * Call image field content. |
|
188 * @since Series 60 3.1 |
|
189 * @return The field. Empty if not specified. |
|
190 */ |
|
191 TPtrC CallImage() const; |
|
192 |
|
193 /** |
|
194 * Check if contact has a thumbnail image. |
|
195 * @since Series 60 3.1 |
|
196 * @return ETrue if thumbnail exists, otherwise EFalse. |
|
197 */ |
|
198 TBool HasThumbnailImage() const; |
|
199 |
|
200 private: |
|
201 |
|
202 /** |
|
203 * C++ constructor. |
|
204 */ |
|
205 CPhCntMatchItem( const TFieldId aFieldId, MPhCntMatchItemOwner& aOwner); |
|
206 |
|
207 /** |
|
208 * By default Symbian OS constructor is private. |
|
209 */ |
|
210 void ConstructL( const TDesC& aTelNumber, CPbkContactItem& aContact ); |
|
211 |
|
212 |
|
213 /** |
|
214 * Read all needed info from the contact. |
|
215 * @param aContact Contact item from Phonebook |
|
216 */ |
|
217 void GetContactInfoL( CPbkContactItem& aContact ); |
|
218 void ReadFirstNameL( CPbkContactItem& aContact ); |
|
219 void ReadLastNameL( CPbkContactItem& aContact ); |
|
220 void ReadCompanyNameL( CPbkContactItem& aContact ); |
|
221 void ReadNumberL( CPbkContactItem& aContact ); |
|
222 void ReadNumberType( CPbkContactItem& aContact ); |
|
223 void ReadCliAndTypeL( CPbkContactItem& aContact ); |
|
224 void ReadGroupsL( CPbkContactItem& aContact ); |
|
225 void ReadRingingToneL( CPbkContactItem& aContact ); |
|
226 void ReadTextToSpeechL( CPbkContactItem& aContact ); |
|
227 void ReadCallObjectL( CPbkContactItem& aContact ); |
|
228 |
|
229 /** |
|
230 * Allocate string and trim the result. |
|
231 * @since Series 60 3.0 |
|
232 * @param aText text to be allocated. |
|
233 * @return trimmed version. |
|
234 */ |
|
235 static HBufC* AllocAndTrimL( const TDesC* aText ); |
|
236 |
|
237 /** |
|
238 * Returns ETrue if order of the names needs to be swapped. |
|
239 * Default order is first name followed by last name. |
|
240 * |
|
241 * @since Series 60 3.0 |
|
242 * @return ETrue if order of the names needs to be swapped. |
|
243 */ |
|
244 static TBool SwapNameOrder(); |
|
245 |
|
246 private: // Data |
|
247 // Original phone number buffer |
|
248 HBufC* iOriginalTelNumber; |
|
249 // Contact item id |
|
250 CPhCntPbkContactId* iContactId; |
|
251 // Field id of the contact |
|
252 TFieldId iFieldId; |
|
253 // Reference count to this match data |
|
254 TInt iReferenceCount; |
|
255 // Who can delete this (when reference count comes to 0) |
|
256 MPhCntMatchItemOwner& iOwner; |
|
257 |
|
258 // First name buffer |
|
259 HBufC* iFirstName; |
|
260 // Last name buffer |
|
261 HBufC* iLastName; |
|
262 // Company name buffer |
|
263 HBufC* iCompanyName; |
|
264 // Matched phone numer buffer |
|
265 HBufC* iNumber; |
|
266 // Number type |
|
267 TInt iNumberType; |
|
268 // CLI |
|
269 HBufC* iCli; |
|
270 // CLI type (name, number, company, ...) |
|
271 MPhCntMatch::TCliType iCliType; |
|
272 // Contact groups |
|
273 CContactIdArray* iGroups; |
|
274 // Path to ringing tone |
|
275 HBufC* iRingingTone; |
|
276 |
|
277 // Text to speech related variables: |
|
278 |
|
279 // First name reading |
|
280 HBufC* iFirstNameReading; |
|
281 // Last name reading |
|
282 HBufC* iLastNameReading; |
|
283 // Nick name |
|
284 HBufC* iSecondName; |
|
285 // Call text |
|
286 HBufC* iCallText; |
|
287 // Call image |
|
288 HBufC* iCallImage; |
|
289 // Has thumbnail image |
|
290 TBool iHasThumbnailImage; |
|
291 |
|
292 }; |
|
293 |
|
294 #include "CPhCntMatchItem.inl" |
|
295 |
|
296 #endif // CPHCNTMATCHITEM_H |
|
297 |
|
298 // End of File |