|
1 /* |
|
2 * Copyright (c) 2008 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: Class for handlind the launchpad related data |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef __CCAPPCOMMLAUNCHERLPADMODEL_H__ |
|
20 #define __CCAPPCOMMLAUNCHERLPADMODEL_H__ |
|
21 |
|
22 #include <e32base.h> |
|
23 #include "ccalogger.h" |
|
24 #include <e32hashtab.h> |
|
25 #include <spdefinitions.h> |
|
26 #include <mspnotifychangeobserver.h> |
|
27 #include <vpbkfieldtype.hrh> |
|
28 |
|
29 |
|
30 _LIT( KPbk2ECEIconFileName, "\\resource\\apps\\phonebook2ece.mif"); |
|
31 |
|
32 class CCCAppCommLauncherContainer; |
|
33 class CAknIconArray; |
|
34 class CCoeEnv; |
|
35 class CFbsBitmap; |
|
36 class CCCAppCommLauncherPlugin; |
|
37 class CCCAppCommLauncherPbkCmd; |
|
38 class CSPSettings; |
|
39 class CSPNotifyChange; |
|
40 |
|
41 const TInt KCCAppCommLauncherMaxButtonDataTextLength = 150; |
|
42 |
|
43 enum TCCAppCommLauncherAddressFields |
|
44 { |
|
45 EAddressPO, |
|
46 EAddressExt, |
|
47 EAddressStreet, |
|
48 EAddressLocal, |
|
49 EAddressRegion, |
|
50 EAddressPostcode, |
|
51 EAddressCountry |
|
52 }; |
|
53 |
|
54 /** |
|
55 * Small utility class for launchpad data storage |
|
56 * |
|
57 * @code |
|
58 * ?good_class_usage_example(s) |
|
59 * @endcode |
|
60 * |
|
61 * @lib ccaappcommlauncher.dll |
|
62 * @since S60 v5.0 |
|
63 */ |
|
64 class TCommLauncherButtonData |
|
65 { |
|
66 public: |
|
67 TCommLauncherButtonData( VPbkFieldTypeSelectorFactory::TVPbkContactActionTypeSelector aContactAction ): |
|
68 iContactAction( aContactAction ), |
|
69 iNumberOfAddresses(0), |
|
70 iFlags(0), |
|
71 iClipFromBegining(EFalse){}; |
|
72 |
|
73 enum TFlags |
|
74 { |
|
75 EDefaultSet = 1 |
|
76 }; |
|
77 |
|
78 VPbkFieldTypeSelectorFactory::TVPbkContactActionTypeSelector iContactAction; |
|
79 TBuf<KCCAppCommLauncherMaxButtonDataTextLength> iText; |
|
80 TInt iNumberOfAddresses; |
|
81 TInt iFlags; |
|
82 TBuf<KCCAppCommLauncherMaxButtonDataTextLength> iPopupText; |
|
83 TBool iClipFromBegining; |
|
84 }; |
|
85 |
|
86 /** |
|
87 * Class for handlind the launchpad related data |
|
88 * |
|
89 * @code |
|
90 * ?good_class_usage_example(s) |
|
91 * @endcode |
|
92 * |
|
93 * @lib ccaappcommlauncher.dll |
|
94 * @since S60 v5.0 |
|
95 */ |
|
96 class CCCAppCommLauncherLPadModel : |
|
97 public CBase, |
|
98 public MDesCArray, |
|
99 public MSPNotifyChangeObserver |
|
100 { |
|
101 public: |
|
102 |
|
103 /** |
|
104 * Two phased constructor. |
|
105 */ |
|
106 static CCCAppCommLauncherLPadModel* NewL( |
|
107 CCCAppCommLauncherContainer& aContainer, CEikListBox& aListBox, CCCAppCommLauncherPlugin& aPlugin ); |
|
108 |
|
109 /** |
|
110 * Destructor. |
|
111 */ |
|
112 ~CCCAppCommLauncherLPadModel(); |
|
113 |
|
114 /** |
|
115 * See more details from MDesCArray. |
|
116 * |
|
117 * @since S60 v5.0 |
|
118 */ |
|
119 TInt MdcaCount() const; |
|
120 |
|
121 protected: |
|
122 |
|
123 /** |
|
124 * See more details from MDesCArray. |
|
125 * |
|
126 * @since S60 v5.0 |
|
127 */ |
|
128 TPtrC MdcaPoint(TInt aIndex) const; |
|
129 |
|
130 public: // New |
|
131 |
|
132 /** |
|
133 * Fills the communication button related data based on |
|
134 * CCmsContactFieldInfo. Initial layout is created based |
|
135 * on this. |
|
136 * |
|
137 * @since S60 v5.0 |
|
138 */ |
|
139 void FillButtonArrayL(); |
|
140 |
|
141 /** |
|
142 * Loads all the icons needed for listbox. |
|
143 * |
|
144 * @since S60 v5.0 |
|
145 */ |
|
146 void LoadIconArrayL(); |
|
147 |
|
148 /** |
|
149 * Loads one particular icon. |
|
150 * |
|
151 * @since S60 v5.0 |
|
152 * @param aBmpId for the icon |
|
153 * @param aBmpId for the icon mask |
|
154 */ |
|
155 CGulIcon* LoadIconLC( TInt aBmpId, TInt aMaskId ); |
|
156 |
|
157 /** |
|
158 * Mapping of icons in iButtonIconArray. |
|
159 * |
|
160 * @since S60 v5.0 |
|
161 */ |
|
162 enum TIconIndex |
|
163 { |
|
164 ECallIconIndex, |
|
165 EMsgIconIndex, |
|
166 EEmailIconIndex, |
|
167 EVoipIconIndex, |
|
168 EInstMsgIconIndex, |
|
169 EUrlIconIndex, |
|
170 EVideocallIconIndex, |
|
171 EAddressValIconIndex, |
|
172 EAddressNotValIconIndex, |
|
173 EMultiIconIndex |
|
174 }; |
|
175 |
|
176 /** |
|
177 * Getter for icon array. |
|
178 * |
|
179 * @since S60 v5.0 |
|
180 * @return CAknIconArray containing the icons |
|
181 */ |
|
182 CAknIconArray* IconArray(); |
|
183 |
|
184 /** |
|
185 * Getter for TCommLauncherButtonData |
|
186 * |
|
187 * @since S60 v5.0 |
|
188 * @param Index of wanted buttondata |
|
189 * @return TCommLauncherButtonData |
|
190 */ |
|
191 TCommLauncherButtonData& ButtonData( TInt aIndex ); |
|
192 |
|
193 /** |
|
194 * Similar as in MCCAppContactHandlerNotifier, but this is |
|
195 * forwarded by container-class. |
|
196 * |
|
197 * @since S60 v5.0 |
|
198 * @param aContactField |
|
199 */ |
|
200 void ContactFieldFetchedNotifyL( |
|
201 const CCmsContactField& aContactField ); |
|
202 |
|
203 /** |
|
204 * Getter for popup-texts |
|
205 * |
|
206 * @since S60 v5.0 |
|
207 * @param aButtonIndex |
|
208 * @return descriptor containing text to be shown |
|
209 */ |
|
210 TPtrC TextForPopUpL( TInt aButtonIndex ); |
|
211 |
|
212 /** |
|
213 * Returns address information for popup-texts |
|
214 * |
|
215 * @param aButtonIndex |
|
216 * @return descriptor containing text to be shown |
|
217 */ |
|
218 TPtrC AddressTextForPopUpL(); |
|
219 |
|
220 /** |
|
221 * Resets the model, does not unload icons |
|
222 * |
|
223 * @since S60 v5.0 |
|
224 */ |
|
225 void Reset(); |
|
226 |
|
227 /** |
|
228 * Notifies of presence change |
|
229 * |
|
230 * @param aContactField |
|
231 */ |
|
232 void ContactPresenceChangedL( const CCmsContactField& aContactField ); |
|
233 |
|
234 /** |
|
235 * Updates information if addresses are validated |
|
236 * |
|
237 * @param aContactFieldInfo |
|
238 */ |
|
239 void UpdateAddressesValidationL( const CCmsContactFieldInfo& aContactFieldInfo ); |
|
240 |
|
241 |
|
242 private: // New |
|
243 |
|
244 /** |
|
245 * Maps communication methods to icons in launchpad-listbox. |
|
246 * |
|
247 * @since S60 v5.0 |
|
248 * @param aContactAction communication method |
|
249 * @return icon array index of the icon |
|
250 */ |
|
251 TInt MapCommMethodToIcon( |
|
252 VPbkFieldTypeSelectorFactory::TVPbkContactActionTypeSelector aContactAction ) const; |
|
253 |
|
254 /** |
|
255 * Updates button's popup text |
|
256 * |
|
257 * @since S60 v5.0 |
|
258 * @param aButtonIndex |
|
259 * @param aContactAction communication method |
|
260 * @param aContactField method |
|
261 */ |
|
262 void CheckPopupTextL( |
|
263 const TInt aButtonIndex, |
|
264 const VPbkFieldTypeSelectorFactory::TVPbkContactActionTypeSelector aContactAction, |
|
265 const CCmsContactField& aContactField ); |
|
266 |
|
267 /** |
|
268 * Getter for button label text |
|
269 * |
|
270 * @since S60 v5.0 |
|
271 * @param aContactAction communication method |
|
272 * @param aText descriptor the text will be copied to, needs size of at least KCCAppCommLauncherMaxButtonDataTextLength |
|
273 */ |
|
274 void ButtonTextL( |
|
275 VPbkFieldTypeSelectorFactory::TVPbkContactActionTypeSelector aContactAction, |
|
276 TDes& aText ); |
|
277 |
|
278 /** |
|
279 * Replace the bitmap with original default bitmap. Supports only |
|
280 * ECmsPresenceVoIPNotification and ECmsPresenceChatNotification. |
|
281 * Will leave with KErrArgument if tried with other type. |
|
282 * |
|
283 * @since S60 v5.0 |
|
284 * @param aBitmap, aMask bitmaps to be replaced |
|
285 * @param aServiceType service type identifying the bitmap |
|
286 */ |
|
287 void ReplaceWithDefaultIconL( |
|
288 CFbsBitmap*& aBitmap, |
|
289 CFbsBitmap*& aMask, |
|
290 const TUint32 aServiceType ); |
|
291 |
|
292 /** |
|
293 * Draws find/show on map button |
|
294 * |
|
295 * @param aNumberOfAddresses number of addresses |
|
296 * @param aIndex communication method index |
|
297 */ |
|
298 void AddressButtonL( const TInt aNumberOfAddresses, const TInt aIndex ); |
|
299 |
|
300 /** |
|
301 * Updates addresses button popup text |
|
302 * |
|
303 * @since S60 v5.0 |
|
304 * @param aButtonIndex |
|
305 * @param aContactAction communication method |
|
306 * @param aContactField method |
|
307 */ |
|
308 void CheckAddressesPopupTextL( |
|
309 const TInt aButtonIndex, |
|
310 const VPbkFieldTypeSelectorFactory::TVPbkContactActionTypeSelector aContactAction, |
|
311 const CCmsContactField& aContactField ); |
|
312 |
|
313 private: |
|
314 |
|
315 /** |
|
316 * Private constructor |
|
317 */ |
|
318 CCCAppCommLauncherLPadModel( CCCAppCommLauncherContainer& aContainer, |
|
319 CEikListBox& aListBox, |
|
320 CCCAppCommLauncherPlugin& aPlugin ); |
|
321 |
|
322 /** |
|
323 * ConstructL |
|
324 */ |
|
325 void ConstructL(); |
|
326 |
|
327 /** |
|
328 * Loads the VOIP Button Icon & Label |
|
329 * Usecase : If we have only one voip service, the voip(Internet Call) |
|
330 * button should have the Branded Icon of that Service and the label |
|
331 * must be "ServiceName" appended with "Call". |
|
332 * eg : If we have a service named SKYPE installed in the Phone |
|
333 * and if SKYPE supports VOIP, then the VOIP Button Icon should be |
|
334 * the Branded Icon of SKYPE and the Button Label should be |
|
335 * "SKYPE CALL". |
|
336 * @return TInt - Stores the Info regd whether Image/Text was set for the |
|
337 * VOIP Buttton or not. We use KVOIPButtonImageSet && with the returnval |
|
338 * to know whether Image has been set or not |
|
339 * Will be used in HandleNotifyChange |
|
340 */ |
|
341 TInt LoadVoipButtonInfoL(); |
|
342 |
|
343 /** |
|
344 * Finds the number of services that support internet call |
|
345 * by scanning all the services in the SPSettings Table. |
|
346 * @param aServiceId - Stores the last matched service id |
|
347 * @return - Total Number of services on which Internet call is possible |
|
348 */ |
|
349 TInt GetSupportedVOIPServicesL( TServiceId& aServiceId ); |
|
350 |
|
351 /** |
|
352 * Loads the Branded VOIP icon & Localised ServiceName |
|
353 * from PBK2 service manager interface |
|
354 * @param aServiceId - Service Id of the Service that supports InternetCall |
|
355 * @param aBitmap - Contains the Retreived BrandIcon Bitmap. Ownership |
|
356 * is passed to the caller |
|
357 * @param aMask - Contains the Retreived BrandIcon Bitmap MAsk. Ownership |
|
358 * is passed to the caller |
|
359 * @param aLocalisedServiceName - Contains the localised service name |
|
360 * @return None |
|
361 */ |
|
362 void LoadVoipButtonInfoFromPbkL( |
|
363 TServiceId aServiceId, |
|
364 CFbsBitmap*& aBitmap, CFbsBitmap*& aMask, HBufC*& aLocalisedServiceName ); |
|
365 |
|
366 /** |
|
367 * Handles SPSettings Changes |
|
368 */ |
|
369 void DoHandleNotifyChangeL() ; |
|
370 |
|
371 private: |
|
372 //From MSPNotifyChangeObserver |
|
373 void HandleNotifyChange( TServiceId aServiceId ); |
|
374 void HandleError( TInt aError ); |
|
375 |
|
376 private: |
|
377 |
|
378 /* Check if multi icon should be show |
|
379 * @param aButtonIndex - The button index |
|
380 * @return - EFalse for not show, ETrue for show the icon |
|
381 */ |
|
382 TBool IfShowMultiIcon(TInt aButtonIndex) const; |
|
383 |
|
384 |
|
385 /* Set clip direction for label text |
|
386 * @param aContactAction: The action type |
|
387 * @param aCmsFieldType: Cms field type |
|
388 * @return - none |
|
389 */ |
|
390 void SetTextClipDirection( |
|
391 VPbkFieldTypeSelectorFactory::TVPbkContactActionTypeSelector aContactAction, |
|
392 TInt aButtonIndex |
|
393 /*CCmsContactFieldItem::TCmsContactField aCmsFieldType*/ ); |
|
394 |
|
395 /* Clip the text from begining |
|
396 * @param aBuffer |
|
397 * @param aItemIndex |
|
398 * @param aSubCellNumber |
|
399 * @return - the result of clipping |
|
400 */ |
|
401 TBool ClipFromBeginning( |
|
402 TDes& aBuffer, |
|
403 TInt aItemIndex, |
|
404 TInt aSubCellNumber) const; |
|
405 |
|
406 private: // Data |
|
407 |
|
408 /** |
|
409 * Array of button data |
|
410 * Own. |
|
411 */ |
|
412 RArray<TCommLauncherButtonData> iButtonDataArray; |
|
413 /** |
|
414 * Array of icons used in listbox |
|
415 * Own. |
|
416 */ |
|
417 CAknIconArray* iButtonIconArray; |
|
418 /** |
|
419 * For storing the texts |
|
420 * Own. |
|
421 */ |
|
422 HBufC* iTempText; |
|
423 /** |
|
424 * Ref to container class |
|
425 * Not own. |
|
426 */ |
|
427 CCCAppCommLauncherContainer& iContainer; |
|
428 /** |
|
429 * Addresses validation status |
|
430 * Own. |
|
431 */ |
|
432 TBool iAddressesValidated; |
|
433 /** |
|
434 * For storing the address text |
|
435 * Own. |
|
436 */ |
|
437 RHashMap<TInt, TPtrC> iAddressFields; |
|
438 |
|
439 /** |
|
440 * Launching performance logger |
|
441 * Will be removed (hopefully) when launching performance is sufficient. |
|
442 */ |
|
443 TBool iPerfLauncherCalled; |
|
444 |
|
445 /** |
|
446 * Environment. |
|
447 * Not Own. |
|
448 */ |
|
449 CCoeEnv& iCoeEnv; |
|
450 |
|
451 /* |
|
452 * Reference to list box control |
|
453 */ |
|
454 CEikListBox& iListBox; |
|
455 |
|
456 /** |
|
457 * Ref to plugin. |
|
458 * Not own. |
|
459 */ |
|
460 CCCAppCommLauncherPlugin& iPlugin; |
|
461 |
|
462 /// Own: CCCAppCommLauncherPbkCmd |
|
463 // used to get the instance of the Phonebook 2 application services. |
|
464 CCCAppCommLauncherPbkCmd* iPbkCmd; |
|
465 |
|
466 //Owns - Instance to spSettings |
|
467 CSPSettings* iSettings; |
|
468 |
|
469 //Owns - Service provider settings change notifer |
|
470 CSPNotifyChange* iSPNotifyChange; |
|
471 |
|
472 HBufC* iTextBuf; |
|
473 |
|
474 inline void RunLaunchLogger() |
|
475 { |
|
476 #ifdef PERF_LAUNCH |
|
477 if(!iPerfLauncherCalled) |
|
478 { |
|
479 WriteToPerfLaunchLog(_L(" Ready")); |
|
480 iPerfLauncherCalled = ETrue; |
|
481 } |
|
482 #endif // PERF_LAUNCH |
|
483 } |
|
484 }; |
|
485 |
|
486 |
|
487 |
|
488 #endif // __CCAPPCOMMLAUNCHERLPADMODEL_H__ |
|
489 //End of file |