|
1 /* |
|
2 * Copyright (c) 2007-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: Contact handling wrapper |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef C_CCAPPCOMMLAUNCHERCONTACTHANDLER_H |
|
20 #define C_CCAPPCOMMLAUNCHERCONTACTHANDLER_H |
|
21 |
|
22 // INCLUDES |
|
23 #include "ccappcommlauncherheaders.h" |
|
24 #include <mccacontactobserver.h> |
|
25 |
|
26 class CCCAppCommLauncherPlugin; |
|
27 class CCCAParameter; |
|
28 class CCmsContactFieldInfo; |
|
29 class CCCAppCommLauncherView; |
|
30 class MCCAppContactFieldDataObserver; |
|
31 |
|
32 /* |
|
33 * Small macro to ease up counting of array sizes below |
|
34 */ |
|
35 #define CCACOMMLAUNCHER_ROMARRAY_SIZE( aRomArray ) \ |
|
36 ( sizeof( aRomArray ) / sizeof(( aRomArray )[0] )) |
|
37 |
|
38 /* |
|
39 * Defines the addresses used for voice calls. |
|
40 * (todo; should be dynamically loaded from pbk selector resources to CMS |
|
41 * and handled by CMS CCmsContactField::GroupType() -functionality ) |
|
42 * */ |
|
43 const TInt KCCAppCommLauncherVoiceCallGroup[] = { |
|
44 CCmsContactFieldItem::ECmsMobilePhoneGeneric, |
|
45 CCmsContactFieldItem::ECmsMobilePhoneHome, |
|
46 CCmsContactFieldItem::ECmsMobilePhoneWork, |
|
47 CCmsContactFieldItem::ECmsLandPhoneGeneric, |
|
48 CCmsContactFieldItem::ECmsLandPhoneHome, |
|
49 CCmsContactFieldItem::ECmsLandPhoneWork, |
|
50 CCmsContactFieldItem::ECmsPagerNumber, |
|
51 CCmsContactFieldItem::ECmsAssistantNumber, |
|
52 CCmsContactFieldItem::ECmsCarPhone }; |
|
53 |
|
54 /* |
|
55 * Defines the addresses used for messaging. |
|
56 * (todo; should be dynamically loaded from pbk selector resources to CMS |
|
57 * and handled by CMS CCmsContactField::GroupType() -functionality ) |
|
58 * */ |
|
59 const TInt KCCAppCommLauncherMessageEmailGroup[] = { |
|
60 CCmsContactFieldItem::ECmsMobilePhoneGeneric, |
|
61 CCmsContactFieldItem::ECmsMobilePhoneHome, |
|
62 CCmsContactFieldItem::ECmsMobilePhoneWork, |
|
63 CCmsContactFieldItem::ECmsLandPhoneGeneric, |
|
64 CCmsContactFieldItem::ECmsLandPhoneHome, |
|
65 CCmsContactFieldItem::ECmsLandPhoneWork, |
|
66 //CCmsContactFieldItem::ECmsAssistantNumber, |
|
67 //CCmsContactFieldItem::ECmsCarPhone, |
|
68 CCmsContactFieldItem::ECmsEmailGeneric, |
|
69 CCmsContactFieldItem::ECmsEmailHome, |
|
70 CCmsContactFieldItem::ECmsEmailWork }; |
|
71 |
|
72 const TInt KCCAppCommLauncherMessageGroup[] = { |
|
73 CCmsContactFieldItem::ECmsMobilePhoneGeneric, |
|
74 CCmsContactFieldItem::ECmsMobilePhoneHome, |
|
75 CCmsContactFieldItem::ECmsMobilePhoneWork, |
|
76 CCmsContactFieldItem::ECmsLandPhoneGeneric, |
|
77 CCmsContactFieldItem::ECmsLandPhoneHome, |
|
78 CCmsContactFieldItem::ECmsLandPhoneWork}; |
|
79 |
|
80 /* |
|
81 * Defines the addresses used for emailing. |
|
82 * (todo; should be dynamically loaded from pbk selector resources to CMS |
|
83 * and handled by CMS CCmsContactField::GroupType() -functionality ) |
|
84 * */ |
|
85 const TInt KCCAppCommLauncherEmailGroup[] = { |
|
86 CCmsContactFieldItem::ECmsEmailGeneric, |
|
87 CCmsContactFieldItem::ECmsEmailHome, |
|
88 CCmsContactFieldItem::ECmsEmailWork }; |
|
89 |
|
90 /* |
|
91 * Defines the addresses used for chatting. |
|
92 * (todo; should be dynamically loaded from pbk selector resources to CMS |
|
93 * and handled by CMS CCmsContactField::GroupType() -functionality ) |
|
94 * */ |
|
95 const TInt KCCAppCommLauncherChatGroup[] = { |
|
96 CCmsContactFieldItem::ECmsImpp }; |
|
97 |
|
98 /* |
|
99 * Defines the addresses used for browsing. |
|
100 * (todo; should be dynamically loaded from pbk selector resources to CMS |
|
101 * and handled by CMS CCmsContactField::GroupType() -functionality ) |
|
102 * */ |
|
103 const TInt KCCAppCommLauncherUrlGroup[] = { |
|
104 CCmsContactFieldItem::ECmsUrlGeneric, |
|
105 CCmsContactFieldItem::ECmsUrlHome, |
|
106 CCmsContactFieldItem::ECmsUrlWork }; |
|
107 |
|
108 /* |
|
109 * Defines the addresses used for video calls. |
|
110 * (todo; should be dynamically loaded from pbk selector resources to CMS |
|
111 * and handled by CMS CCmsContactField::GroupType() -functionality ) |
|
112 * */ |
|
113 const TInt KCCAppCommLauncherVideoCallGroup[] = { |
|
114 CCmsContactFieldItem::ECmsMobilePhoneGeneric, |
|
115 CCmsContactFieldItem::ECmsMobilePhoneHome, |
|
116 CCmsContactFieldItem::ECmsMobilePhoneWork, |
|
117 CCmsContactFieldItem::ECmsVideoNumberGeneric, |
|
118 CCmsContactFieldItem::ECmsVideoNumberHome, |
|
119 CCmsContactFieldItem::ECmsVideoNumberWork }; |
|
120 |
|
121 /* |
|
122 * Defines the addresses used for find/show on map. |
|
123 * (todo; should be dynamically loaded from pbk selector resources to CMS |
|
124 * and handled by CMS CCmsContactField::GroupType() -functionality ) |
|
125 * */ |
|
126 const TInt KCCAppCommLauncherAddressGroup[] = { |
|
127 CCmsContactFieldItem::ECmsAddrStreetGeneric, |
|
128 CCmsContactFieldItem::ECmsAddrLocalGeneric, |
|
129 CCmsContactFieldItem::ECmsAddrCountryGeneric, |
|
130 CCmsContactFieldItem::ECmsAddrPostcodeGeneric, |
|
131 CCmsContactFieldItem::ECmsAddrPOGeneric, |
|
132 CCmsContactFieldItem::ECmsAddrExtGeneric, |
|
133 CCmsContactFieldItem::ECmsAddrRegionGeneric, |
|
134 CCmsContactFieldItem::ECmsAddrStreetHome, |
|
135 CCmsContactFieldItem::ECmsAddrLocalHome, |
|
136 CCmsContactFieldItem::ECmsAddrCountryHome, |
|
137 CCmsContactFieldItem::ECmsAddrPostcodeHome, |
|
138 CCmsContactFieldItem::ECmsAddrPOHome, |
|
139 CCmsContactFieldItem::ECmsAddrExtHome, |
|
140 CCmsContactFieldItem::ECmsAddrRegionHome, |
|
141 CCmsContactFieldItem::ECmsAddrStreetWork, |
|
142 CCmsContactFieldItem::ECmsAddrLocalWork, |
|
143 CCmsContactFieldItem::ECmsAddrCountryWork, |
|
144 CCmsContactFieldItem::ECmsAddrPostcodeWork, |
|
145 CCmsContactFieldItem::ECmsAddrPOWork, |
|
146 CCmsContactFieldItem::ECmsAddrExtWork, |
|
147 CCmsContactFieldItem::ECmsAddrRegionWork }; |
|
148 |
|
149 |
|
150 /** |
|
151 * Interface-class for contact data notifications |
|
152 * |
|
153 * @code |
|
154 * ?good_class_usage_example(s) |
|
155 * @endcode |
|
156 * |
|
157 * @lib ccappcommlauncherplugin.dll |
|
158 * @since S60 v5.0 |
|
159 */ |
|
160 class MCCAppContactHandlerNotifier |
|
161 { |
|
162 public: |
|
163 |
|
164 /** |
|
165 * Notifies observer when CCmsContactFieldInfo is available. |
|
166 * Ownership not transferred. |
|
167 * |
|
168 * @param CCmsContactFieldInfo |
|
169 */ |
|
170 virtual void ContactInfoFetchedNotifyL( |
|
171 const CCmsContactFieldInfo& aContactFieldInfo ) = 0; |
|
172 |
|
173 /** |
|
174 * Notifies observer when new CCmsContactField is available. |
|
175 * Ownership not transferred. |
|
176 * |
|
177 * @param CCmsContactField |
|
178 */ |
|
179 virtual void ContactFieldFetchedNotifyL( |
|
180 const CCmsContactField& aContactField ) = 0; |
|
181 |
|
182 /** |
|
183 * Notifies observer when all the contact fields have been fetched |
|
184 * |
|
185 * @param CCmsContactField |
|
186 */ |
|
187 virtual void ContactFieldFetchingCompletedL() = 0; |
|
188 |
|
189 /** |
|
190 * Notifies observer that contact data has been changed and will be reloaded |
|
191 */ |
|
192 virtual void ContactsChangedL() = 0; |
|
193 |
|
194 /** |
|
195 * Notifies observer that contact presence has changed |
|
196 * |
|
197 * @param CCmsContactField |
|
198 */ |
|
199 virtual void ContactPresenceChangedL( const CCmsContactField& aContactField) = 0; |
|
200 }; |
|
201 |
|
202 /** |
|
203 * This class encapsulates the contact handling functionality through CCAPP/CMS. |
|
204 * |
|
205 * @code |
|
206 * ?good_class_usage_example(s) |
|
207 * @endcode |
|
208 * |
|
209 * @lib ccappcommlauncherplugin.dll |
|
210 * @since S60 v5.0 |
|
211 */ |
|
212 class CCCAppCommLauncherContactHandler : |
|
213 public CBase, |
|
214 public MCCAppContactFieldDataObserver |
|
215 { |
|
216 #ifdef __COMMLAUNCHERPLUGINUNITTESTMODE |
|
217 friend class T_CCCAppCommLauncherContactHandler; |
|
218 #endif// __COMMLAUNCHERPLUGINUNITTESTMODE |
|
219 |
|
220 public: // Construction and destruction |
|
221 |
|
222 /** |
|
223 * Creates a new instance of this class. |
|
224 * |
|
225 * @return pointer to a new instance of this clas. |
|
226 * @param pointer to target the contact data |
|
227 * @param aPlugin reference |
|
228 */ |
|
229 static CCCAppCommLauncherContactHandler* NewL( |
|
230 MCCAppContactHandlerNotifier& aObserver, |
|
231 CCCAppCommLauncherPlugin& aPlugin ); |
|
232 |
|
233 /** |
|
234 * Destructor. |
|
235 */ |
|
236 ~CCCAppCommLauncherContactHandler(); |
|
237 |
|
238 public: //new |
|
239 |
|
240 /** |
|
241 * Request current and coming data from CMS wrapper |
|
242 * |
|
243 * @since S60 v5.0 |
|
244 */ |
|
245 void RequestContactDataL(); |
|
246 |
|
247 /** |
|
248 * Returns amount of address fields in a contact |
|
249 * |
|
250 * @since S60 v5.0 |
|
251 * @param aContactAction defining the address type |
|
252 * @return amount of suitable addresses |
|
253 */ |
|
254 TInt AddressAmount( |
|
255 VPbkFieldTypeSelectorFactory::TVPbkContactActionTypeSelector aContactAction ); |
|
256 |
|
257 /** |
|
258 * Checks if there is a service available for the contact method |
|
259 * |
|
260 * @since S60 v5.0 |
|
261 * @param aContactAction defining the address type |
|
262 * @return TInt 1 if there is a service available, 0 otherwise. Voip is |
|
263 * a special case having more levels than just on/off. |
|
264 */ |
|
265 TInt IsServiceAvailable( |
|
266 VPbkFieldTypeSelectorFactory::TVPbkContactActionTypeSelector aContactAction ); |
|
267 |
|
268 /** |
|
269 * Check from which store this contact is from |
|
270 * |
|
271 * @return store type containing this contact |
|
272 */ |
|
273 TCmsContactStore ContactStore() const; |
|
274 |
|
275 /** |
|
276 * Returns contact field array. |
|
277 * |
|
278 * @since S60 v5.0 |
|
279 */ |
|
280 RPointerArray<CCmsContactField>& ContactFieldDataArray(); |
|
281 |
|
282 /** |
|
283 * Returns packed contact identifiers |
|
284 * |
|
285 * @since S60 v5.0 |
|
286 */ |
|
287 HBufC8* ContactIdentifierLC(); |
|
288 |
|
289 /** |
|
290 * Find out is there default attributes set to this communication method. |
|
291 * Maps communication methods with default already fetched default |
|
292 * attributes. |
|
293 * |
|
294 * @since S60 v5.0 |
|
295 * @param aContactAction communication method |
|
296 * @return TBool |
|
297 */ |
|
298 TBool HasDefaultAttribute( |
|
299 VPbkFieldTypeSelectorFactory::TVPbkContactActionTypeSelector aContactAction ); |
|
300 |
|
301 /** |
|
302 * Maps between different communication methods and CMS default fields |
|
303 * |
|
304 * @since S60 v5.0 |
|
305 * @param aContactAction communication method |
|
306 * @return CMS default type |
|
307 */ |
|
308 CCmsContactFieldItem::TCmsDefaultAttributeTypes MapContactorTypeToCMSDefaultType( |
|
309 VPbkFieldTypeSelectorFactory::TVPbkContactActionTypeSelector aContactAction ); |
|
310 |
|
311 /** |
|
312 * Returns data of 1st index as descriptor if found, otherwise KNullDesC. |
|
313 * |
|
314 * @since S60 v5.0 |
|
315 * @param aFieldType type of the field |
|
316 * @param aData of field as descriptor |
|
317 */ |
|
318 void ContactFieldItemDataL( |
|
319 const CCmsContactFieldItem::TCmsContactField aFieldType, |
|
320 TPtrC& aData ); |
|
321 |
|
322 /** |
|
323 * Checks if the contact field is among the fields of certain selector |
|
324 * |
|
325 * @since S60 v5.0 |
|
326 * @param aContactField contact field to be matched |
|
327 * @param aContactAction defines set of selector fields |
|
328 * @return ETrue if contact field is among the fields of certain selector |
|
329 */ |
|
330 TBool ContactFieldTypeAndContactActionMatch( |
|
331 CCmsContactFieldItem::TCmsContactField aContactField, |
|
332 VPbkFieldTypeSelectorFactory::TVPbkContactActionTypeSelector aContactAction ); |
|
333 |
|
334 /** |
|
335 * Checks if the address is thought as number or address |
|
336 * |
|
337 * @since S60 v5.0 |
|
338 * @param aContactAction to be checked |
|
339 * @return ETrue if address is thought to be number address |
|
340 */ |
|
341 TBool IsItNumberAddress( |
|
342 VPbkFieldTypeSelectorFactory::TVPbkContactActionTypeSelector aContactAction ); |
|
343 |
|
344 /** |
|
345 * Refetches a new contact from a store |
|
346 * |
|
347 * @since S60 v5.0 |
|
348 */ |
|
349 void RefetchContactL(); |
|
350 |
|
351 /** |
|
352 * Checks whether the Current contact is top contact. |
|
353 * |
|
354 * @return ETrue if Contact is a top contact, otherwise EFalse |
|
355 */ |
|
356 TBool IsTopContact(); |
|
357 |
|
358 private: // from MCCAppContactFieldDataObserver |
|
359 |
|
360 /** |
|
361 * from MCCAppContactFieldDataObserver |
|
362 */ |
|
363 void ContactFieldDataObserverNotifyL( |
|
364 MCCAppContactFieldDataObserver::TParameter& aParameter ); |
|
365 |
|
366 /** |
|
367 * from MCCAppContactFieldDataObserver |
|
368 */ |
|
369 void ContactFieldDataObserverHandleErrorL( |
|
370 TInt aState, TInt aError ); |
|
371 |
|
372 private:// new |
|
373 |
|
374 /** |
|
375 * ContactInfo -notifies are handled through this. |
|
376 * See ContactFieldDataObserverNotifyL. |
|
377 * |
|
378 * @since S60 v5.0 |
|
379 */ |
|
380 void ContactInfoFetchedNotifyL( |
|
381 const CCmsContactFieldInfo& aContactFieldInfo ); |
|
382 |
|
383 /** |
|
384 * ContactField -notifies are handled through this. |
|
385 * See ContactFieldDataObserverNotifyL. |
|
386 * |
|
387 * @since S60 v5.0 |
|
388 */ |
|
389 void ContactFieldFetchedNotifyL( |
|
390 CCmsContactField& aContactField ); |
|
391 |
|
392 /** |
|
393 * Helper function to fetch attribute of given contact field. |
|
394 * |
|
395 * @since S60 v5.0 |
|
396 * @param aContactField: contact field. |
|
397 */ |
|
398 void UpdateDefaultAttributes( const CCmsContactField& aContactField ); |
|
399 |
|
400 /** |
|
401 * Checks if the contact field is among the fields of certain selector |
|
402 * |
|
403 * @since S60 v5.0 |
|
404 * @param aContactField contact field to be matched |
|
405 * @param aFieldArray array of fields |
|
406 * @param aCount amount of the array fields |
|
407 * @return ETrue if contact field is among the fields of certain selector |
|
408 */ |
|
409 TBool FieldArrayAndContactActionMatch( |
|
410 CCmsContactFieldItem::TCmsContactField aContactField, |
|
411 const TInt aFieldArray[], const TInt aCount ); |
|
412 |
|
413 /** |
|
414 * Checks if dynamic field array is needed and creates one if it is |
|
415 * |
|
416 * @since S60 v5.0 |
|
417 * @param aContactAction to be a array |
|
418 */ |
|
419 void ConstructDynamicFieldArrayIfNeeded( |
|
420 VPbkFieldTypeSelectorFactory::TVPbkContactActionTypeSelector aContactAction ); |
|
421 |
|
422 /** |
|
423 * Creates VoIP address group |
|
424 * |
|
425 * @since S60 v5.0 |
|
426 * @param aVoipSupportFlag defines the details of voip support |
|
427 */ |
|
428 void CreateDynamicVoipAddressGroup( const TInt aVoipSupportFlag ); |
|
429 |
|
430 private: // construction |
|
431 |
|
432 CCCAppCommLauncherContactHandler( |
|
433 MCCAppContactHandlerNotifier& aObserver, |
|
434 CCCAppCommLauncherPlugin& aPlugin ); |
|
435 |
|
436 void ConstructL(); |
|
437 |
|
438 private: // data |
|
439 |
|
440 /** |
|
441 * Observer to be updated of contact fields |
|
442 * Own. |
|
443 */ |
|
444 MCCAppContactHandlerNotifier& iObserver; |
|
445 /** |
|
446 * Notify if dynamic address fields are set or not |
|
447 * Own. |
|
448 */ |
|
449 TBool iDynamicAddressGroupSet; |
|
450 /** |
|
451 * Dynamic address fields |
|
452 * Own. |
|
453 * */ |
|
454 RArray<TInt> iDynamicVoipAddressGroup; |
|
455 /** |
|
456 * Default attributes as bitmasks |
|
457 * Own. |
|
458 */ |
|
459 TInt iDefaultAttributesBitMask; |
|
460 /** |
|
461 * CMS is used through CmsHandler to fetch contact data fields |
|
462 * Not own. |
|
463 */ |
|
464 CCCAppCmsContactFetcherWrapper* iCmsWrapper; |
|
465 |
|
466 /** |
|
467 * Ref to plugin. |
|
468 * Not own. |
|
469 */ |
|
470 CCCAppCommLauncherPlugin& iPlugin; |
|
471 |
|
472 /** |
|
473 * Address amount cache |
|
474 * Own |
|
475 */ |
|
476 RHashMap<TInt, TInt> iAddressCache; |
|
477 }; |
|
478 |
|
479 #endif // C_CCAPPCOMMLAUNCHERCONTACTHANDLER_H |
|
480 |
|
481 // End of File |