|
1 /* |
|
2 * Copyright (c) 2004-2006 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: VAS contact handler implementation |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef NSSCONTACTHANDLERIMPL_H |
|
20 #define NSSCONTACTHANDLERIMPL_H |
|
21 |
|
22 // INCLUDES |
|
23 #include <cenrepnotifyhandler.h> |
|
24 |
|
25 #include <vasmcontactobserver.h> |
|
26 |
|
27 #include <nssvasmgetcontextclient.h> |
|
28 #include <nssvasmgettagclient.h> |
|
29 #include <nssvasmtraintexteventhandler.h> |
|
30 #include <nssvasmdeletecontextclient.h> |
|
31 #include <nssvasmdeletetagclient.h> |
|
32 #include <nssvasmsavetagclient.h> |
|
33 #include <nssvasmsavecontextclient.h> |
|
34 #include "nssvasdatasyncwatcher.h" |
|
35 #include <nssvascoreconstant.h> |
|
36 #include "srsfbldvariant.hrh" |
|
37 |
|
38 // Publish & Subscribe of the contact handler activity |
|
39 #include <e32property.h> |
|
40 |
|
41 #include <PbkFields.hrh> |
|
42 |
|
43 // CONSTANTS |
|
44 |
|
45 // Number of restart timer calls checked during periodic calls check |
|
46 const TInt KEventMomentsSize = 3; |
|
47 |
|
48 // MACROS |
|
49 // Deprecated |
|
50 #ifdef TEST_MANUAL_SYNC |
|
51 #define CNssContactHandler CManualContactHandler |
|
52 #endif // TEST_MANUAL_SYNC |
|
53 |
|
54 // FORWARD DECLARATIONS |
|
55 class CNssTrainingParameters; |
|
56 class MVasBasePbkHandler; |
|
57 class CNssVASDBMgr; |
|
58 class MNssTagMgr; |
|
59 class MNssContextMgr; |
|
60 class CSuccessfulDeletionSimulator; |
|
61 class CRepository; |
|
62 class CNssChBackupObserver; |
|
63 |
|
64 // CLASS DECLARATION |
|
65 |
|
66 /** |
|
67 * TNssContextClientData contains last last sync time and UI language |
|
68 * which was used when training voice tags. |
|
69 * |
|
70 * @lib NssVASContactHdlr.dll |
|
71 * @since 2.8 |
|
72 */ |
|
73 struct TNssContextClientData |
|
74 { |
|
75 TTime iLastSyncTime; |
|
76 TLanguage iLanguage; |
|
77 TContactSyncId iContactSyncId; |
|
78 |
|
79 void InternalizeL(const TDesC8& aBuffer) |
|
80 { |
|
81 iLastSyncTime = 0; |
|
82 iLanguage = ELangOther; |
|
83 iContactSyncId = KErrNotFound; |
|
84 |
|
85 if ( (TUint)aBuffer.Size() > sizeof( TNssContextClientData ) ) |
|
86 { |
|
87 User::Leave( KErrCorrupt ); |
|
88 } |
|
89 |
|
90 Mem::Copy( this, aBuffer.Ptr(), sizeof( TNssContextClientData ) ); |
|
91 } |
|
92 |
|
93 void ExternalizeL(TDes8& aBuffer) |
|
94 { |
|
95 if ( (TUint)aBuffer.MaxSize() < sizeof( TNssContextClientData ) ) |
|
96 { |
|
97 User::Leave( KErrTooBig ); |
|
98 } |
|
99 |
|
100 aBuffer.SetLength( 0 ); |
|
101 aBuffer.Copy( (TUint8*)this, sizeof( TNssContextClientData ) ); |
|
102 } |
|
103 }; |
|
104 |
|
105 /** |
|
106 * Contact handler creates voice tags out of phonebook contacts and keeps |
|
107 * SIND data in sync with the phonebook |
|
108 * |
|
109 * @lib NssVASContactHdlr.dll |
|
110 * @since 2.8 |
|
111 */ |
|
112 NONSHARABLE_CLASS( CNssContactHandlerImplementation ): public CBase, |
|
113 public MVasContactObserver, |
|
114 public MNssGetTagClient, |
|
115 public MNssDeleteTagClient, |
|
116 public MNssGetContextClient, |
|
117 public MNssSaveTagClient, |
|
118 public MNssSaveContextClient, |
|
119 public MNssTrainTextEventHandler, |
|
120 public MNssDeleteContextClient, |
|
121 public MNssDataSyncStateObserver, |
|
122 public MCenRepNotifyHandlerCallback |
|
123 { |
|
124 // DATA TYPES |
|
125 enum TContactHandlerState |
|
126 { |
|
127 ECHIdle, |
|
128 ECHInitializing, |
|
129 // contact addition, removal or change |
|
130 ECHHandlingNormalChanges, |
|
131 ECHFullResync |
|
132 }; |
|
133 |
|
134 |
|
135 struct TExtension |
|
136 { |
|
137 TPbkFieldId iId; |
|
138 HBufC* iText; |
|
139 TVasExtensionAction iAction; |
|
140 TVasExtensionCommand iCommand; |
|
141 }; |
|
142 |
|
143 struct TContactData |
|
144 { |
|
145 // Can be 1.Nickname, 2.firstname-lastname or vise versa, 3.Company name |
|
146 HBufC* iTitle; |
|
147 TContactItemId iID; |
|
148 TTime iSyncTime; |
|
149 TVasTagType iType; |
|
150 }; |
|
151 |
|
152 public: // Constructors and destructor |
|
153 |
|
154 /** |
|
155 * Two-phased constructor. |
|
156 */ |
|
157 static CNssContactHandlerImplementation* NewL( ); |
|
158 |
|
159 /** |
|
160 * Destructor. |
|
161 */ |
|
162 virtual ~CNssContactHandlerImplementation(); |
|
163 public: // New functions |
|
164 |
|
165 /** |
|
166 * Disables the contact handler until EnableEventHandling is called |
|
167 * Typically this means 'until reboot' |
|
168 * Is used in case of unrecoverable error. |
|
169 * |
|
170 * @todo Move to private? |
|
171 * @return void |
|
172 */ |
|
173 void DisableEventHandling(); |
|
174 |
|
175 /** |
|
176 * Enables the contact handler. |
|
177 * |
|
178 * @deprecated Move to private? |
|
179 * @return void |
|
180 */ |
|
181 void EnableEventHandling(); |
|
182 |
|
183 public: // Functions from base classes |
|
184 |
|
185 /** |
|
186 * Is called by phonebook handler when contact change has occurred |
|
187 * |
|
188 * @param aEvent Event to be handled |
|
189 */ |
|
190 void HandleEventL( const TPhonebookEvent& aEvent ); |
|
191 |
|
192 /** |
|
193 * Is called by tag manager when getting of a tag list is completed |
|
194 * successfully |
|
195 * From MNssGetTagClient Interface |
|
196 * |
|
197 * @param aTagList list of tags returned |
|
198 * @param aErrorCode KErrNone if getting of tags has been successfull |
|
199 * @return void |
|
200 */ |
|
201 void GetTagListCompleted( MNssTagListArray* aTagList, TInt aErrorCode ); |
|
202 |
|
203 /** |
|
204 * Called when the deletion of a tag requested from tag manager |
|
205 * is completed successfully |
|
206 * From MNssDeleteTagClient Interface |
|
207 * @param aErrorCode KErrNone if tag deletion has been successfull |
|
208 * @return void |
|
209 */ |
|
210 void DeleteTagCompleted( TInt aErrorCode ); |
|
211 |
|
212 /** |
|
213 * Called by tag manager, when GetContext() completes successfully |
|
214 * |
|
215 * Depending on the contact handler state, continues full resync sequence or |
|
216 * sets the idle state |
|
217 * @param aContext |
|
218 * @param aErrorCode KErrNone if getting of context list was successfull |
|
219 * @return void |
|
220 */ |
|
221 void GetContextCompleted(MNssContext* aContext, TInt aErrorCode); |
|
222 |
|
223 /** |
|
224 * Callback to indicate GetContext successed. |
|
225 * @param aContextList - A list of contexts. |
|
226 * user has to ResetAndDestroy() after using the list. |
|
227 * @param aErrorCode KErrNone if getting of context list was successfull |
|
228 * @return None |
|
229 */ |
|
230 void GetContextListCompleted( MNssContextListArray *aContextList, |
|
231 TInt aErrorCode ); |
|
232 |
|
233 /** |
|
234 * Is called when SaveContext() completes |
|
235 * @param aErrorCode KErrNone if saving of context was successfull |
|
236 */ |
|
237 void SaveContextCompleted( TInt aErrorCode ); |
|
238 |
|
239 /** |
|
240 * Callback to indicate taht SaveTag completed successfully |
|
241 * @param aErrorCode KErrNone if saving of tag has was successfull |
|
242 * @return None |
|
243 */ |
|
244 void SaveTagCompleted( TInt aErrorCode ); |
|
245 |
|
246 /** |
|
247 * Is called when data sync status is changed and when data sync state |
|
248 * observation was just started |
|
249 * @param aRunning ETrue if from now on data sync process is running |
|
250 * EFalse otherwise |
|
251 * @see MNssDataSyncStateObserver |
|
252 */ |
|
253 void DataSyncStateChanged( TBool aRunning ); |
|
254 |
|
255 /** |
|
256 * Is called when backup/restore status is changed and when backup/restore |
|
257 * state observation was just started |
|
258 * @param aRunning ETrue if some backup/restore action is in progress |
|
259 * EFalse otherwise |
|
260 * @param aRestoreType ETrue if the event is restore related |
|
261 * EFalse if the event is backup related |
|
262 * @see CNssChBackupObserver |
|
263 */ |
|
264 void BackupRestoreStateChanged( TBool aRestoreType, TBool aRunning ); |
|
265 |
|
266 /** |
|
267 * From MCenRepNotifyHandlerCallback |
|
268 * @see MCenRepNotifyHandlerCallback for more information |
|
269 */ |
|
270 void HandleNotifyInt( TUint32 aId, TInt aNewValue ); |
|
271 |
|
272 private: |
|
273 |
|
274 /** |
|
275 * C++ default constructor. |
|
276 */ |
|
277 CNssContactHandlerImplementation( ); |
|
278 |
|
279 /** |
|
280 * Second-phase constructor |
|
281 */ |
|
282 void ConstructL(); |
|
283 |
|
284 // Prohibit copy constructor |
|
285 CNssContactHandlerImplementation( const CNssContactHandlerImplementation& ); |
|
286 |
|
287 // Prohibit assigment operator |
|
288 CNssContactHandlerImplementation& operator= ( const CNssContactHandlerImplementation& ); |
|
289 |
|
290 /** |
|
291 * Register itself for phonebook database events |
|
292 */ |
|
293 void RegisterForDatabaseEventsL( ); |
|
294 |
|
295 /** |
|
296 * Check if the event was caused by voice tag field adding |
|
297 * @param aEvent event from contact db |
|
298 * @return ETrue if voice tag field was added |
|
299 */ |
|
300 TBool CausedByVoiceTagAddition( const TPhonebookEvent& aEvent ); |
|
301 |
|
302 /** |
|
303 * Get the current contact's title in a buffer |
|
304 * @param aContactId Id of the contact to return title for |
|
305 * @param aUseDefaultOrder If ETrue created title uses preferred |
|
306 * lastname-firstname order of the current UI language. If |
|
307 * EFalse, uses reverse order |
|
308 * @param aBothFirstAndLastFound Is set to ETrue if returned title |
|
309 * contains both first name and last name. To EFalse otherwise |
|
310 * @param aTagType Set based on found tag type (name or company name) |
|
311 * @return 'Title' of the contact, i.e. value that is pronounced when |
|
312 * this contact tag is recognized by SIND |
|
313 */ |
|
314 HBufC* GetContactTitleL( TContactItemId aContactId, TBool aUseDefaultOrder, |
|
315 TBool& aBothFirstAndLastFound, TVasTagType& aTagType ); |
|
316 |
|
317 /** |
|
318 * Return the nickname for a given contact |
|
319 * |
|
320 * @exception KErrNotFound if nickname field is not present |
|
321 * @param aContactId Phonebook id of the contact in question |
|
322 * @return NULL if nickname is present, but empty. |
|
323 * Otherwise newly allocated descriptor to the nickname |
|
324 */ |
|
325 HBufC* GetContactNicknameL( TContactItemId aContactId ); |
|
326 |
|
327 /* |
|
328 * Returns a flag which tells if name order should be changed. |
|
329 * @return ETrue if preferred order of the current UI language is |
|
330 * lastname-firstname. EFalse otherwise |
|
331 */ |
|
332 TBool SwapNameOrder(); |
|
333 |
|
334 // Process the Contact Database Events |
|
335 void DoHandleEventsL(); |
|
336 |
|
337 /** |
|
338 * Routine to handle failure during processing the event at the lower |
|
339 * layers |
|
340 */ |
|
341 void DoHandleEventFailedL(); |
|
342 |
|
343 /** |
|
344 * Single tag training completed successfully |
|
345 */ |
|
346 void HandleTrainComplete( TInt aErrorCode ); |
|
347 |
|
348 /**************** The functions to handle miscellanious changes ***************/ |
|
349 |
|
350 // Handling miscellaneous changes has 3 phases: |
|
351 // 1. Fuse add & remove & change events into a list |
|
352 // of tags to be added and tags to be removed. |
|
353 // 2. Remove tags to be removed. |
|
354 // 3. Add tags to be added |
|
355 |
|
356 |
|
357 /** |
|
358 * Fuse add & remove & change events into a list of tags to be added |
|
359 * and tags to be removed. |
|
360 */ |
|
361 void CollectAddRemoveListsL(); |
|
362 |
|
363 |
|
364 /** |
|
365 * Starts adding names: Creates the tags and sends TrainTextL calls. |
|
366 */ |
|
367 void DoAddNamesL(); |
|
368 |
|
369 /** |
|
370 * Is called after all the tags scheduled for addition have been |
|
371 * trained successfully |
|
372 */ |
|
373 void DoAddNamesTrainingFinished(); |
|
374 |
|
375 /** |
|
376 * Initiates saving tags after they have been trained. |
|
377 * After saving tags started is recursively called for every next |
|
378 * tag to be saved |
|
379 */ |
|
380 void DoAddNamesSaveTag(); |
|
381 |
|
382 /** |
|
383 * Is called when single tag saving has been completed |
|
384 * @param aError KErrNone if saving was successful, |
|
385 * KErrGeneral otherwise |
|
386 */ |
|
387 void DoAddNamesSaveTagCompleted( TInt aError ); |
|
388 |
|
389 /** |
|
390 * Cleanup addition-related buffers after new tags have been created, |
|
391 * trained and saved. |
|
392 * Add voice tag icons to the phonebook |
|
393 */ |
|
394 void DoAddNamesCompletedL(); |
|
395 |
|
396 |
|
397 /** |
|
398 * Start removing names by requesting list of tags for the first |
|
399 * contact scheduled for deletion |
|
400 */ |
|
401 void DoRemoveNamesL(); |
|
402 |
|
403 /** |
|
404 * Callback for handling list of tags, that should be deleted |
|
405 * The first list is requested from DoRemoveNamesL, other - recursively |
|
406 * from DoRemoveNamesAfterGetTagList |
|
407 * @param aTagListArray List of tags to be deleted. Can be empty |
|
408 */ |
|
409 void DoRemoveNamesAfterGetTagList( MNssTagListArray* aTagListArray ); |
|
410 |
|
411 /** |
|
412 * Send single DeleteTag call to remove the first tag of those that |
|
413 * are in the to-be-deleted list from VAS |
|
414 * Expects callbacks to DeleteTagCompleted or to DeleteTagFailed |
|
415 */ |
|
416 void DoRemoveNamesCallDeleteTag(); |
|
417 |
|
418 /** |
|
419 * DeleteTag() callbacks call this funciton. It counts |
|
420 * the number of callbacks, and when all callbacks have arrived |
|
421 * goes to the next phase: RemovingNamesCompletedL or |
|
422 * DoHandleEventFailedL |
|
423 */ |
|
424 void DoRemoveNamesAfterDeleteTagCompleted(); |
|
425 |
|
426 /** |
|
427 * Tag removal for a pack on names completed successfully. Clean the |
|
428 * deletion tag buffers |
|
429 */ |
|
430 void RemovingNamesCompletedL(); |
|
431 |
|
432 /** |
|
433 * TLinearOrder comparison function for sorting phonebook events |
|
434 */ |
|
435 static TInt PhonebookOrder( const TPhonebookEvent& a1, const TPhonebookEvent& a2 ); |
|
436 |
|
437 /*************** The functions to handle miscellanious changes end ************/ |
|
438 /** |
|
439 * Compares client data from VAS context to the state of the phonebook |
|
440 * to find out if full synchronization is needed. |
|
441 * Compares client data (saved in VAS context) |
|
442 * to state of the phonebook to find out if |
|
443 * full synchronization is needed. |
|
444 * |
|
445 * If full resync is needed initiates it by saving into the event queue |
|
446 * special 'full resync event' |
|
447 * @since 2.0 |
|
448 */ |
|
449 void CheckErrorSigns(); |
|
450 |
|
451 /** |
|
452 * Handle errors which happend when updating normal changes |
|
453 */ |
|
454 void NormalChangesHandleError(); |
|
455 |
|
456 /** |
|
457 * Start full resynchronisation |
|
458 */ |
|
459 void FullResyncStart(); |
|
460 |
|
461 /** |
|
462 * Delete existing context if any, create a new one. |
|
463 * Is a part of full resynchronization sequence |
|
464 */ |
|
465 void FullResyncCreateContextL(); |
|
466 |
|
467 /** |
|
468 * Simulate phonebook addition events for all the phonebook contacts. |
|
469 * Is a part of full resynchronization sequence |
|
470 */ |
|
471 void FullResyncCreateChangesL(); |
|
472 |
|
473 /** |
|
474 * Checks if the event queue contains an event, which |
|
475 * launches full resynchronization |
|
476 * @return ETrue if full resync request is present in the queue |
|
477 * EFalse otherwise |
|
478 */ |
|
479 TBool IsFullResyncNeeded(); |
|
480 |
|
481 /** |
|
482 * Is called when conext deletion has completed successfully. |
|
483 * Is a part of the full synchronization sequence |
|
484 * @param aErrorCode KErrNone if deletion of context was successfull |
|
485 */ |
|
486 void DeleteContextCompleted( TInt aErrorCode ); |
|
487 |
|
488 /** |
|
489 * Is called when conext deletion fails. |
|
490 * Is a part of the full synchronization sequence |
|
491 */ |
|
492 //void DeleteContextFailed( enum MNssDeleteContextClient::TNssDeleteContextClientFailCode ); |
|
493 |
|
494 /** |
|
495 * Static callback required by Symbian Timer services. |
|
496 * Real action happens in the DoPeriodicCallback |
|
497 * @param pX Pointer to the active instance of CNssContactHandlerImplementation |
|
498 * @return KErrNone. Has no meaning in this case |
|
499 * @see CNssContactHandlerImplementation::DoPeriodicCallback() |
|
500 */ |
|
501 static TInt PeriodicCallback( TAny* pX ); |
|
502 |
|
503 /** |
|
504 * Timer callback used to check if periodic action completed, |
|
505 * there are events to process and contact handler can do it now |
|
506 * (is idle). If this is true, initiates event processing |
|
507 */ |
|
508 void DoPeriodicCallback(); |
|
509 |
|
510 /** |
|
511 * Checks if it events look like they are periodically sent |
|
512 * from some lengthy operation |
|
513 * @return ETrue if periodic behavior detected, EFalse otherwise |
|
514 */ |
|
515 TBool PeriodicAction(); |
|
516 |
|
517 /** |
|
518 * Updates variables used for periodic action checks. |
|
519 * Adds current time to the array of phonebook event moments |
|
520 */ |
|
521 void UpdatePeriodicActionVars(); |
|
522 |
|
523 |
|
524 /** |
|
525 * Returns maximal interval between time moments recorded in the array. |
|
526 * Moments are stored in a cyclic way, i.e. moment 0 is stored at index 0, |
|
527 * moment1 at index 2,... moment n at index 0 again |
|
528 * @param aMoments Array of time moments |
|
529 * @param aMomensLength Length of the aMoments array. Must be > 1 |
|
530 * @param aLastMomentIndex Index of the last recorded moment within aMoments |
|
531 * @return Maximal interval. If Maximal interval is too big to fit into |
|
532 * TTimeIntervalMicroSeconds32, TTimeIntervalMicroSeconds32(KMaxTInt) |
|
533 * is returned |
|
534 */ |
|
535 TTimeIntervalMicroSeconds32 MaximalInterval( const TTime aMoments[], const TInt aMomentsLength, const TInt aLastMomentIndex ); |
|
536 |
|
537 /** |
|
538 * Set the contact handler state. It is the place, where state-related |
|
539 * invariants are checked in debug builds. In debug builds panics if |
|
540 * intended change is illegal |
|
541 */ |
|
542 void SetState( TContactHandlerState aState ); |
|
543 |
|
544 /** |
|
545 * Returns immediately if neither data sync nor backup is in progress |
|
546 * Otherwise waits indefinetely until data sync run is over |
|
547 */ |
|
548 void WaitUntilNoSyncBackupIsRunning(); |
|
549 |
|
550 /** |
|
551 * Sets the central repository full resync flag |
|
552 * @leave CRepository error codes |
|
553 */ |
|
554 void SetFullResyncCrFlagL( TBool aResyncNeeded ); |
|
555 |
|
556 #ifdef __SIND_EXTENSIONS |
|
557 /** |
|
558 * Read name dialling extension from resource file |
|
559 */ |
|
560 void ReadExtensionsL(); |
|
561 |
|
562 /** |
|
563 * Finds extension field based on priority lists |
|
564 * |
|
565 * @param aAction Extension action |
|
566 * @return KErrNotFound if contact item field was not found |
|
567 */ |
|
568 TInt FindExtensionField( TVasExtensionAction aAction, |
|
569 TPbkFieldId aDefaultFieldId ); |
|
570 |
|
571 |
|
572 /** |
|
573 * Loops through list of fields |
|
574 * |
|
575 * @param aArray Array field IDs |
|
576 * @param aCount Number of elements in aArray |
|
577 * @param aItem Contact item |
|
578 * |
|
579 * @return KErrNotFound if contact item field was not found |
|
580 */ |
|
581 TInt ExtensionFieldFindLoop( const TPbkFieldId* const aArray, |
|
582 TInt aCount ); |
|
583 #endif // __SIND_EXTENSIONS |
|
584 |
|
585 /** |
|
586 * Reads a contact and returns a phonebook contact item. If contact is |
|
587 * already locked by something, function keeps trying for a long time. |
|
588 * If still fails, contact handler is disabled and full resync will |
|
589 * be attempted after the reboot |
|
590 * |
|
591 * @param aContactId Contact item id to be read. |
|
592 */ |
|
593 void ReadContactL( TContactItemId aContactId ); |
|
594 |
|
595 /** |
|
596 * Opens a contact. If contact is already locked by something, |
|
597 * function keeps trying for a long time. |
|
598 * If still fails, contact handler is disabled and full resync will |
|
599 * be attempted after the reboot |
|
600 * |
|
601 * @param aContactId Contact item id to be opened. |
|
602 */ |
|
603 void OpenContactL( TContactItemId aContactId ); |
|
604 |
|
605 /** |
|
606 * Reads contact from phonebook |
|
607 * |
|
608 * If contact is already locked by something, function keeps trying for a long time. |
|
609 * If still fails, contact handler is disabled and full resync will |
|
610 * be attempted after the reboot |
|
611 * |
|
612 * @param aContactId Contact of interest |
|
613 * @param aReadContact ETrue for ReadContactL and EFalse for OpenContactL |
|
614 */ |
|
615 void GetContactL( TContactItemId aContactId, TBool aReadContact ); |
|
616 |
|
617 /** |
|
618 * Static callback required by Symbian Timer services. |
|
619 * Real action happens in the DoContactWaitCallback |
|
620 * @param pX Pointer to the active instance of CNssContactHandlerImplementation |
|
621 * @return KErrNone. Has no meaning in this case |
|
622 * @see CNssContactHandlerImplementation::DoPeriodicCallback() |
|
623 */ |
|
624 static TInt ContactWaitCallback( TAny* pX ); |
|
625 |
|
626 /** |
|
627 * Timer callback used to check if phonebook contact is unlocked |
|
628 * Unlocks the waiter |
|
629 */ |
|
630 void DoContactWaitCallback(); |
|
631 |
|
632 /** |
|
633 * Utility function to check if there isn't enough disk space to perform |
|
634 * the operation. |
|
635 * |
|
636 * @return ETrue if there is not enough disk space, EFalse otherwise |
|
637 */ |
|
638 TBool NoDiskSpace(); |
|
639 |
|
640 /** |
|
641 * Utility function to substitute all separator characters as white spaces. |
|
642 * |
|
643 * @param aBuf Descriptor which is manipulated |
|
644 */ |
|
645 void TrimName( HBufC* aBuf ); |
|
646 |
|
647 /** |
|
648 * Utility function to append name to a buffer. |
|
649 * |
|
650 * @param aBuf Descriptor which is appended |
|
651 * @param aName Name |
|
652 */ |
|
653 void AppendName( HBufC* aBuf, HBufC* aName ); |
|
654 |
|
655 /** |
|
656 * Utility function to append extension marker ("_2") to buffer. |
|
657 * |
|
658 * @param aDes Buffer where to do the modification |
|
659 */ |
|
660 void AppendExtensionMarker( TDes& aDes ); |
|
661 |
|
662 /** |
|
663 * Establishes the connection to the contact engine and |
|
664 * starts listening to it |
|
665 */ |
|
666 void ConnectToPhonebookL(); |
|
667 |
|
668 /** |
|
669 * Clears the connection to the contact engine |
|
670 */ |
|
671 void DisconnectFromPhonebook(); |
|
672 |
|
673 private: // Data |
|
674 // Phonebook engine |
|
675 MVasBasePbkHandler* iPbkHandler; |
|
676 CNssVASDBMgr* iVasDbManager; |
|
677 MNssTagMgr* iTagManager; |
|
678 MNssContextMgr* iContextManager; |
|
679 TContactHandlerState iState; |
|
680 |
|
681 // Id of the contact that is currently deleted |
|
682 /** @todo Why is it not used for additions? Or why it is used at all? */ |
|
683 TContactItemId iContactId; |
|
684 |
|
685 // Notifier object for the default contact database. |
|
686 // iContactChangeNotifier attaches contact handler to the phonebook |
|
687 // engine as long as the object exists. |
|
688 // CPbkContactChangeNotifier* iContactChangeNotifier; |
|
689 |
|
690 // Tells if ocntact handler is active |
|
691 TBool iHandlerEnabled; |
|
692 |
|
693 // Context used for name dialing |
|
694 MNssContext* iContext; |
|
695 |
|
696 // List of raw database events. Also can store special 'full resync' event |
|
697 RArray<TPhonebookEvent> iEventArray; |
|
698 |
|
699 // Number of retrials to save tags |
|
700 TInt iRetry; |
|
701 |
|
702 // Delimeter between first an last name in the contact title |
|
703 TChar iSeparator; |
|
704 |
|
705 // Array of relevant data from contacts to add |
|
706 // Just id and title |
|
707 RArray<TContactData> iContactQueue; |
|
708 |
|
709 // Language specific settings |
|
710 CNssTrainingParameters* iTrainingParams; |
|
711 |
|
712 // List of contacts to add to VAS |
|
713 RArray<TPhonebookEvent> iAddList; |
|
714 |
|
715 // List of contacts to remove tags for |
|
716 RArray<TPhonebookEvent> iDelList; |
|
717 |
|
718 // List of contacts, for which voice tag icon has been added OR REMOVED |
|
719 // Is used to ignore events related to the change of voice dial icon |
|
720 RArray<TContactItemId> iVoiceTagAddedList; |
|
721 |
|
722 // List of contacts for which voice tag icon should be removed if present |
|
723 // The need for it occurs if training voice tag fails and before training |
|
724 // icon was present |
|
725 RArray<TContactItemId> iRemoveIconList; |
|
726 |
|
727 // List of tags that are to be trained and saved |
|
728 RPointerArray<MNssTag> iTagArray; |
|
729 |
|
730 // Counts the number of callbacks after TrainText() calls |
|
731 TInt iTrainCallbackCounter; |
|
732 |
|
733 // Counts the number of callbacks after SaveTag() calls |
|
734 TInt iSaveCallbackCounter; |
|
735 |
|
736 // Counts the number of callbacks after DeleteTag() calls |
|
737 TInt iDeleteCallbackCounter; |
|
738 |
|
739 // General information about the context used for name dialing: |
|
740 // language and last sync timestamp |
|
741 TNssContextClientData iClientData; |
|
742 |
|
743 // Tells if full resync happened at least once |
|
744 // I.e. if name dialing context exists |
|
745 TBool iHaveWeEverSynced; |
|
746 |
|
747 // Indicates if error happened during normal event handling |
|
748 // Can be only KErrNone of KErrGeneral |
|
749 TInt iNormalChangesError; |
|
750 |
|
751 // List of tags to be deleted for one contact |
|
752 // (main name + possible nickname ) |
|
753 MNssTagListArray* iDeleteTagListArray; |
|
754 |
|
755 // Languages which use lastname-firstname order in names |
|
756 RArray<TLanguage> iSwappedLanguages; |
|
757 |
|
758 // Timer used to ensure, that events queue is checked at least every 30 secs |
|
759 CPeriodic* iPeriodicHandleEventTimer; |
|
760 |
|
761 // Array of event receivement times |
|
762 TTime iEventMoments[KEventMomentsSize]; |
|
763 |
|
764 // Index of the last value in iRestartTimerCalls |
|
765 TInt iEventMomentIndex; |
|
766 |
|
767 |
|
768 // Time interval used to detect END of periodic action. In microseconds |
|
769 // Note, that it is NOT the value used to command |
|
770 // iPeriodicHandleEventTimer |
|
771 TTimeIntervalMicroSeconds iEndOfPeriodicActionInterval; |
|
772 |
|
773 // Counter for consecutive full resyncs forced by error during |
|
774 // handling normal changes (or also resync changes) |
|
775 // Is used to prevent endless resyncing in case of some unexpected |
|
776 // consistent lower level failure |
|
777 TInt iConsecutiveErrorFullResync; |
|
778 |
|
779 // Publish & Subscribe property, that tells external entities if contact |
|
780 // handler training is ongoing. Note, that it is different from |
|
781 // the contact handler state |
|
782 RProperty iBusyProperty; |
|
783 |
|
784 // Publish & Subscribe property that watches for the PC-Suite Sync activity |
|
785 RProperty iSyncProperty; |
|
786 |
|
787 // Temporary container for a tag that is created and used in the |
|
788 // DoAddNamesL. Member variable is used only because we cannot use |
|
789 // CleanupStack with MNssTag |
|
790 MNssTag* iNewTag; |
|
791 // Informs that VoIP feature is supported. |
|
792 TBool iVoIPFeatureSupported; |
|
793 |
|
794 // Informs that video telephony feature is supported |
|
795 TBool iVideoCallFeatureSupported; |
|
796 |
|
797 #ifdef __SIND_EXTENSIONS |
|
798 // extensions |
|
799 RArray<TExtension> iExtensionList; |
|
800 #endif //__SIND_EXTENSIONS |
|
801 |
|
802 // ETrue if PC-suite data sync is in progress. I.e. contact hanlder should |
|
803 // delay its actions until iDataSyncRunning is EFalse |
|
804 TBool iDataSyncRunning; |
|
805 |
|
806 // Waits until iDataSyncRunning is EFalse |
|
807 CActiveSchedulerWait* iSyncBackupWaiter; |
|
808 |
|
809 // Waits until contact of interest is unlocked |
|
810 CActiveSchedulerWait* iContactWaiter; |
|
811 |
|
812 // Periodic timer that ticks ones per socond if we are waiting for the |
|
813 // contact unlock |
|
814 CPeriodic* iContactWaitTimer; |
|
815 |
|
816 // Watches for the data sync state changes |
|
817 MNssDataSyncWatcher* iDataSyncWatcher; |
|
818 |
|
819 // Watches the backup/restore state |
|
820 CNssChBackupObserver* iBackupObserver; |
|
821 |
|
822 // Watches central repository changes |
|
823 CCenRepNotifyHandler* iRepositoryObserver; |
|
824 |
|
825 // Is used to *asynchronously* simulate successful tag deletion |
|
826 CSuccessfulDeletionSimulator* iDeletionSimulator; |
|
827 |
|
828 // To simplify access for the pure utility class |
|
829 friend class CSuccessfulDeletionSimulator; |
|
830 |
|
831 // File server session to find out the available disk space |
|
832 RFs iFSession; |
|
833 |
|
834 // central repository for setting resync needed flag |
|
835 CRepository* iRepository; |
|
836 |
|
837 // flag for phonebook restore |
|
838 TBool iRestoreRunning; |
|
839 |
|
840 // Current resync flag state |
|
841 TBool iResyncAtBoot; |
|
842 }; |
|
843 |
|
844 #endif // CONTACTHANDLERIMPL_H |
|
845 |
|
846 // End of File |