|
1 /* |
|
2 * Copyright (c) 2010 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: Easy dialing plugin implementation. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef __CEASYDIALINGPLUGIN_H__ |
|
20 #define __CEASYDIALINGPLUGIN_H__ |
|
21 |
|
22 // INCLUDES |
|
23 |
|
24 #include "dialingextensioninterface.h" |
|
25 #include <MPsResultsObserver.h> |
|
26 #include <mccaconnection.h> |
|
27 #include <mccaconnectionext.h> |
|
28 #include "measydialingcenreplistenerobserver.h" |
|
29 #include "mcontactdatamanagerobserver.h" |
|
30 #include "medcontactorobserver.h" |
|
31 #include "easydialingcontactdatamanager.h" // for TNameOrder |
|
32 |
|
33 // ListBox Observer API |
|
34 #include <eiklbo.h> |
|
35 |
|
36 // MAknInputBlockCancelHandler |
|
37 #include <akninputblock.h> |
|
38 |
|
39 |
|
40 // CONSTANTS |
|
41 |
|
42 /** Maximum constact search string length. */ |
|
43 const TInt KEDMaxSearchStringLength = 200; |
|
44 |
|
45 /** Maximum string length for listbox model string. */ |
|
46 const TInt KEDMaxContactStringLength = 600; |
|
47 |
|
48 /** Maximum phone number length. */ |
|
49 const TInt KEDMaxPhoneNumberLength = 64; |
|
50 |
|
51 // MACROS |
|
52 |
|
53 // DATA TYPES |
|
54 |
|
55 // FUNCTION PROTOTYPES |
|
56 |
|
57 // FORWARD DECLARATIONS |
|
58 |
|
59 class CPSRequestHandler; |
|
60 class CPsQuery; |
|
61 class CEasyDialingListBox; |
|
62 class MVPbkContactLink; |
|
63 class CEasyDialingCenrepListener; |
|
64 class CEasyDialingContactDataManager; |
|
65 class CEDContactorService; |
|
66 class CEikMenuPane; |
|
67 class CAsyncCallBack; |
|
68 class CEikLabel; |
|
69 |
|
70 // CLASS DECLARATION |
|
71 |
|
72 /** |
|
73 * Easy dialing plugin. |
|
74 */ |
|
75 class CEasyDialingPlugin : public CDialingExtensionInterface, |
|
76 public MPsResultsObserver, |
|
77 public MCCAObserver, |
|
78 public MEasyDialingCenrepListenerObserver, |
|
79 public MContactDataManagerObserver, |
|
80 public MEDContactorObserver, |
|
81 public MEikListBoxObserver, |
|
82 public MAknInputBlockCancelHandler, |
|
83 public MCoeForegroundObserver |
|
84 { |
|
85 public: |
|
86 |
|
87 /** |
|
88 * Static constructor. |
|
89 * @return: Created object. |
|
90 */ |
|
91 static CEasyDialingPlugin* NewL(); |
|
92 |
|
93 /** |
|
94 * Destructor. |
|
95 */ |
|
96 virtual ~CEasyDialingPlugin(); |
|
97 |
|
98 public: // from CCoeControl |
|
99 |
|
100 /** |
|
101 * From CCoeControl. |
|
102 */ |
|
103 TKeyResponse OfferKeyEventL( const TKeyEvent& aKeyEvent, TEventCode aType ); |
|
104 |
|
105 /** |
|
106 * From CCoeControl |
|
107 */ |
|
108 TInt CountComponentControls() const; |
|
109 |
|
110 /** |
|
111 * From CCoeControl |
|
112 */ |
|
113 CCoeControl* ComponentControl( TInt aIndex ) const; |
|
114 |
|
115 /** |
|
116 * From CCoeControl |
|
117 */ |
|
118 void MakeVisible( TBool aVisible ); |
|
119 |
|
120 /** |
|
121 * From CCoeControl |
|
122 */ |
|
123 void HandleResourceChange( TInt aType ); |
|
124 |
|
125 protected: |
|
126 |
|
127 /** |
|
128 * See CCoeControl |
|
129 */ |
|
130 void SizeChanged(); |
|
131 |
|
132 /** |
|
133 * See CCoeControl |
|
134 */ |
|
135 void FocusChanged( TDrawNow aDrawNow ); |
|
136 |
|
137 public: // from CDialingExtensionInterface |
|
138 |
|
139 /** |
|
140 * Does further initialization to component. |
|
141 * @param: parent container of this control. |
|
142 */ |
|
143 virtual void InitializeL( CCoeControl& aParent ); |
|
144 |
|
145 /** |
|
146 * Reset the previour easy dialing search. |
|
147 */ |
|
148 void Reset(); |
|
149 |
|
150 /** |
|
151 * Adds an observer to dialing extension. |
|
152 * @param: aObserver: observer to be added. |
|
153 */ |
|
154 void AddObserverL( MDialingExtensionObserver* aObserver ); |
|
155 |
|
156 /** |
|
157 * Removes an observer from dialing extension. |
|
158 * @param: aObserver: observer to be removed. |
|
159 */ |
|
160 void RemoveObserver( MDialingExtensionObserver* aObserver ); |
|
161 |
|
162 /** |
|
163 * Sets input string (search string) to easy dialing. |
|
164 * @param: aDesC: input string descriptor. |
|
165 */ |
|
166 void SetInputL( const TDesC& aDesC ); |
|
167 |
|
168 /** |
|
169 * Returns the number of matching contacts in previous search. |
|
170 * @return: number of matches. |
|
171 */ |
|
172 TInt MatchingContactCount(); |
|
173 |
|
174 /** |
|
175 * Gets the resource id of plugin's control button area resource. |
|
176 * |
|
177 * @return Resource id. |
|
178 */ |
|
179 TInt CbaResourceId(); |
|
180 |
|
181 /** |
|
182 * From CDialingExtensionInterface. |
|
183 * Gets the resource id of plugin's menu bar resource. |
|
184 * |
|
185 * @return Resource id. |
|
186 */ |
|
187 TInt MenuResourceId(); |
|
188 |
|
189 /** |
|
190 * From CDialingExtensionInterface. |
|
191 * Gets the resource id of plugin's menu bar resource. |
|
192 * |
|
193 * @param aMenuPane Menu pane |
|
194 * @param aMenuResourceId Menu bar resource id. |
|
195 * @return Resource id. |
|
196 */ |
|
197 TBool InitializeMenuPaneL( CEikMenuPane& aMenuPane, TInt aMenuResourceId ); |
|
198 |
|
199 /** |
|
200 * From CDialingExtensionInterface. |
|
201 * Gets the resource id of plugin's menu bar resource. |
|
202 * |
|
203 * @param aCommand Command id. |
|
204 * @return ETrue if command was handled, EFalse otherwise. |
|
205 */ |
|
206 TBool HandleCommandL( TInt aCommand ); |
|
207 |
|
208 /** |
|
209 * Tells if extension is currently enabled from settings. |
|
210 * @return ETrue if extension is enabled, EFalse otherwise. |
|
211 */ |
|
212 TBool IsEnabled() const; |
|
213 |
|
214 /** |
|
215 * Tells if extension is currently enabled from settings. |
|
216 * @return ETrue if extension is enabled, EFalse otherwise. |
|
217 */ |
|
218 void SetKeyboardMode( TKeyboardMode aMode ); |
|
219 |
|
220 public: |
|
221 |
|
222 /** |
|
223 * From MEasyDialingCenrepListenerObserver. |
|
224 */ |
|
225 void EasyDialingSettingsChanged( TInt aValue ); |
|
226 |
|
227 /** |
|
228 * From MEasyDialingCenrepListenerObserver. |
|
229 */ |
|
230 void EasyDialingContactThumbnailsSettingsChanged( TInt aThumbnailSettingValue ); |
|
231 |
|
232 /** |
|
233 * From MContactDataManagerObserver. |
|
234 */ |
|
235 void AllContactDataLoaded(); |
|
236 |
|
237 /** |
|
238 * From MContactDataManagerObserver. |
|
239 */ |
|
240 void NameOrderChanged(); |
|
241 |
|
242 /** |
|
243 * From MContactDataManagerObserver. |
|
244 */ |
|
245 void FavouritesChanged(); |
|
246 |
|
247 /** |
|
248 * From MContactDataManagerObserver. |
|
249 */ |
|
250 void StoreConfigurationChanged(); |
|
251 |
|
252 /** |
|
253 * From MEDContactorObserver. |
|
254 */ |
|
255 void InformContactorEvent( MEDContactorObserver::TEvent aEvent ); |
|
256 |
|
257 /** |
|
258 * From MEikListBoxObserver. |
|
259 */ |
|
260 void HandleListBoxEventL( CEikListBox* aListBox, TListBoxEvent aEventType ); |
|
261 |
|
262 /** |
|
263 * From MAknInputBlockCancelHandler. |
|
264 */ |
|
265 void AknInputBlockCancel(); |
|
266 |
|
267 /** |
|
268 * From MCoeForegroundObserver. |
|
269 */ |
|
270 void HandleGainingForeground(); |
|
271 |
|
272 /** |
|
273 * From MCoeForegroundObserver. |
|
274 */ |
|
275 void HandleLosingForeground(); |
|
276 |
|
277 private: |
|
278 |
|
279 /** |
|
280 * Constructor. |
|
281 */ |
|
282 CEasyDialingPlugin (); |
|
283 |
|
284 /** |
|
285 * Second phase constructor. |
|
286 */ |
|
287 void ConstructL (); |
|
288 |
|
289 void InitPredictiveContactSearchL(); |
|
290 |
|
291 void SetupPcsSettingsL(); |
|
292 |
|
293 void SetSortOrderL( CEasyDialingContactDataManager::TNameOrder aNameOrder ); |
|
294 |
|
295 /** |
|
296 * From MPsResultsObserver. |
|
297 */ |
|
298 virtual void HandlePsResultsUpdate( RPointerArray<CPsClientData>& aResults, RPointerArray<CPsPattern>& aSeqs ); |
|
299 virtual void HandlePsError( TInt aErrorCode ); |
|
300 virtual void CachingStatus( TCachingStatus& aStatus, TInt& aError ); |
|
301 |
|
302 /** |
|
303 * FindContactFieldPCSIndex |
|
304 * Searches the index that stores the given contact field. |
|
305 * To see possible contact field numbering, see file "vpbkeng.rsg". |
|
306 * @param: contact field to search for. See file "vpbkeng.rsg" |
|
307 * for contact field numbering. |
|
308 * @return: index of the contact field. KErrNotFound if field was not found. |
|
309 * Non-negative return values are for indexing CPsClientData array. |
|
310 */ |
|
311 TInt FindContactFieldPCSIndexL( TInt aIndex ); |
|
312 |
|
313 /** |
|
314 * HandlePsResultsUpdateL |
|
315 * A leaving function to be trapped in HandlePsResultsUpdate. |
|
316 */ |
|
317 void HandlePsResultsUpdateL( RPointerArray<CPsClientData>& aResults, RPointerArray<CPsPattern>& aSeqs ); |
|
318 |
|
319 public: |
|
320 |
|
321 /** |
|
322 * MCCAObserver function handling exit of CCA launcher. |
|
323 */ |
|
324 void CCASimpleNotifyL( TNotifyType aType, TInt aReason ); |
|
325 |
|
326 private: |
|
327 |
|
328 /* |
|
329 * Informs all observers registered with AddObserverL. |
|
330 * @param: aEvent: event id to be informed. |
|
331 */ |
|
332 void InformObservers( MDialingExtensionObserver::TEvent aEvent ); |
|
333 |
|
334 |
|
335 private: |
|
336 |
|
337 /** |
|
338 * This method perform the drawing functionality of the component. |
|
339 * @param: aRect: The rect to be rendered |
|
340 * @return None |
|
341 */ |
|
342 void Draw( const TRect& aRect ) const; |
|
343 |
|
344 /** |
|
345 * Initiates predictive contact search. |
|
346 */ |
|
347 void LaunchSearchL(); |
|
348 |
|
349 /** |
|
350 * Opens ca launcher for currently selected contact. |
|
351 */ |
|
352 void LaunchCurrentContactL(); |
|
353 |
|
354 /** |
|
355 * Creates listbox model string. |
|
356 */ |
|
357 void CreateListBoxContactStringL( |
|
358 const TDesC& aContactString, |
|
359 MVPbkContactLink *aLink, |
|
360 TBool aMatchThumbnails, |
|
361 TBool aFav ); |
|
362 |
|
363 /** |
|
364 * Creates string with first name, last name and company name. |
|
365 */ |
|
366 HBufC* CreateContactStringLC( CPsClientData* aResult, |
|
367 CEasyDialingContactDataManager::TNameOrder aNameOrder ); |
|
368 |
|
369 /** Possible actions launched by this plugin. */ |
|
370 enum TEasyDialingAction |
|
371 { |
|
372 ENoActionDefined, |
|
373 ECallCurrentContact, |
|
374 EVideoCallCurrentContact, |
|
375 ESendMessageCurrentContact, |
|
376 ELaunchCurrentContact, |
|
377 ELaunchSearch, |
|
378 EInitializePcs, |
|
379 ESimulateKeyEvent |
|
380 }; |
|
381 |
|
382 /** |
|
383 * Simulates a key event asynchronously |
|
384 */ |
|
385 void AsyncSimulateKeyEvent( const TKeyEvent& aKeyEvent ); |
|
386 |
|
387 /** |
|
388 * Initiates asynchronous callback to launch action and sets |
|
389 * input blocker active. |
|
390 */ |
|
391 void AsyncActionLaunchL( TEasyDialingAction aAction ); |
|
392 |
|
393 /** |
|
394 * Callback for CAsyncCallBack. Launches action set in iActionToBeLaunched |
|
395 * and stops input block when launch is done. |
|
396 */ |
|
397 static TInt AsyncCallBackToLaunchAction( TAny* aPtr ); |
|
398 |
|
399 /** |
|
400 * Launches action defined in iActionToBeLaunched. |
|
401 */ |
|
402 void DoLaunchActionL(); |
|
403 |
|
404 /** |
|
405 * Cancels async action launch and input block. |
|
406 */ |
|
407 void CancelActionLaunchAndInputBlock(); |
|
408 |
|
409 /** |
|
410 * Handles change events from contact database and favourites view. |
|
411 */ |
|
412 void DoHandleContactsChangedL(); |
|
413 |
|
414 /** |
|
415 * Makes contact listbox visible. Effect is used if feasible. |
|
416 */ |
|
417 void ShowContactListBoxWithEffect(); |
|
418 |
|
419 /** |
|
420 * Makes contact listbox invisible. Effect is used if feasible. |
|
421 */ |
|
422 void HideContactListBoxWithEffect(); |
|
423 |
|
424 /** |
|
425 * Checks if listbox effect can be triggered. Eg checks if |
|
426 * app is in the foreground. |
|
427 */ |
|
428 TBool CanListBoxEffectBeUsed() const; |
|
429 |
|
430 /** |
|
431 * Sets correct info label text color from theme. |
|
432 */ |
|
433 void SetInfoLabelColourL(); |
|
434 |
|
435 /** |
|
436 * Sets info label visibility. |
|
437 */ |
|
438 void SetInfoLabelVisibleL( TBool aVisible ); |
|
439 |
|
440 private: |
|
441 |
|
442 /** Textual version of current search string. */ |
|
443 TBuf<KEDMaxSearchStringLength> iSearchString; |
|
444 |
|
445 /** Handle to predictive search engine. Owned. */ |
|
446 CPSRequestHandler* iPredictiveContactSearchHandler; |
|
447 |
|
448 /** PCS type of presentation of the current search string. Owned. */ |
|
449 CPsQuery* iPredictiveSearchQuery; |
|
450 |
|
451 /** If ETrue, completing PCS searches are not displayed but just discarded. */ |
|
452 TBool iDiscardCompletingSearches; |
|
453 |
|
454 /** ETrue if contact database has been changed and a new search is needed. */ |
|
455 TBool iNewSearchNeeded; |
|
456 |
|
457 /** Array of used data stores. Owned. */ |
|
458 RPointerArray<TDesC> iContactDataStores; |
|
459 |
|
460 /** Search result field index for first name field. */ |
|
461 TInt iFirstNamePCSIndex; |
|
462 |
|
463 /** Search result field index for last name field. */ |
|
464 TInt iLastNamePCSIndex; |
|
465 |
|
466 /** Search result field index for first name field. */ |
|
467 TInt iCompanyNamePCSIndex; |
|
468 |
|
469 /** Array containing observers to this class. Owned. */ |
|
470 RPointerArray<MDialingExtensionObserver> iObservers; |
|
471 |
|
472 /** Contact listbox. Owned. */ |
|
473 CEasyDialingListBox* iContactListBox; |
|
474 |
|
475 /** Listbox model from search results. Owned. */ |
|
476 CDesCArrayFlat* iListBoxModel; |
|
477 |
|
478 /** Number of found matching contacts from most recent search. */ |
|
479 TInt iNumberOfNames; |
|
480 |
|
481 /** Handle to contact launcher. */ |
|
482 MCCAConnectionExt* iContactLauncher; |
|
483 |
|
484 /** ETrue if contact launcher (a.k.a. communication launcher) is open. */ |
|
485 TBool iContactLauncherActive; |
|
486 |
|
487 /** If true, contact listbox must not reset focus when contact launcher exits. */ |
|
488 TBool iRememberFocus; |
|
489 |
|
490 /** Working buffer for creating contact string to listbox. */ |
|
491 TBuf<KEDMaxContactStringLength> iContactStringCreationBuffer; |
|
492 |
|
493 /** Central repository listener. Owned. */ |
|
494 CEasyDialingCenrepListener* iCenrepListener; |
|
495 |
|
496 /** Contact data manager. Owned. */ |
|
497 CEasyDialingContactDataManager* iContactDataManager; |
|
498 |
|
499 /** Easy dialing contactor service. Owned. */ |
|
500 CEDContactorService* iContactorService; |
|
501 |
|
502 /** Easy dialing resource file offset in current application. */ |
|
503 TInt iResourceFileOffset; |
|
504 |
|
505 /** Blocks user input when action is being launched. NULL if not active. Owned. */ |
|
506 CAknInputBlock* iInputBlocker; |
|
507 |
|
508 /** Used to launch action asynchronously. Owned.*/ |
|
509 CAsyncCallBack* iAsyncCallBack; |
|
510 |
|
511 /** Action to be launched next asynchronously. */ |
|
512 TEasyDialingAction iActionToBeLaunched; |
|
513 |
|
514 /** Contact link related to the asynchronous action. */ |
|
515 HBufC8* iContactToBeLaunched; |
|
516 |
|
517 /** Contact name related to the asynchronous action. */ |
|
518 HBufC* iContactToBeLaunchedName; |
|
519 |
|
520 /** Key event to be simulated asynchronously. */ |
|
521 TKeyEvent iKeyEventToSimulate; |
|
522 |
|
523 /** Is virtual keyboard currently open or not.*/ |
|
524 TBool iVirtualKeyboardOpen; |
|
525 |
|
526 /** First line of info text shown when number entry is empty. Owned. */ |
|
527 HBufC* iInfoLabelTextLine1; |
|
528 |
|
529 /** Second line of info text shown when number entry is empty. Owned. */ |
|
530 HBufC* iInfoLabelTextLine2; |
|
531 |
|
532 /** Label for showing first line of info text when number entry is empty. Owned. */ |
|
533 CEikLabel* iInfoLabelLine1; |
|
534 |
|
535 /** Label for showing second line of info text when number entry is empty. Owned. */ |
|
536 CEikLabel* iInfoLabelLine2; |
|
537 |
|
538 /** Keyboard mode to be used in matching. */ |
|
539 TKeyboardMode iKeyboardMode; |
|
540 |
|
541 /** 'Flag' if contact have been long tapped, so ECE launcher opens. Long tap contact = True, default = False */ |
|
542 TBool iLongTapped; |
|
543 }; |
|
544 |
|
545 |
|
546 #endif //__CEASYDIALINGPLUGIN_H__ |
|
547 |
|
548 // End of File |