phonebookengines/contactsmodel/inc/CNTPHBKSYNCWATCHER.H
changeset 0 e686773b3f54
child 24 0ba2181d7c28
equal deleted inserted replaced
-1:000000000000 0:e686773b3f54
       
     1 /**
       
     2 * Copyright (c) 2005-2009 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:
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 /**
       
    21  @file
       
    22  @internalComponent
       
    23  @released
       
    24 */
       
    25 
       
    26 
       
    27 #ifndef __CNTPHBKSYNCWATCHER_H__
       
    28 #define __CNTPHBKSYNCWATCHER_H__
       
    29 
       
    30 
       
    31 #include <cntsync.h>
       
    32 
       
    33 
       
    34 class CSinglePhbkWatcher;
       
    35 
       
    36 
       
    37 /**
       
    38 Types of ICC Phonebook synchronisation tht Contact Views care about events.
       
    39 */
       
    40 enum TPhonebookState 
       
    41 	{
       
    42 	/**
       
    43 	Initial state, or ICC card has 'gone away' (e.g. ICC is resetting).
       
    44 	*/
       
    45 	EIccPhbkNotSynchronised,
       
    46 	/**
       
    47 	ICC Phonebook has completed synchronisation.
       
    48 	*/
       
    49 	EIccPhbkSynchronised,
       
    50 	/**
       
    51 	Sync failed due to ICC either being locked or not ready.
       
    52 	*/
       
    53 	EIccWaitForPhbkToBeReady,
       
    54 	/**
       
    55 	ICC Sync with Phonebook Server failed.
       
    56 	*/
       
    57 	EIccPhbkSyncError,
       
    58 	};
       
    59 	
       
    60 
       
    61 /**	
       
    62 An observer class for Contacts Views to track the status of ICC Phonebook
       
    63 Synchronisation.
       
    64 */
       
    65 class MContactPhbkSyncObserver
       
    66 	{
       
    67 public:
       
    68 	virtual void ContactPhbkSyncEventHandler(TPhonebookState aPhbkState) = 0;
       
    69 	};
       
    70 
       
    71 
       
    72 /**
       
    73 A watcher class for Contacts Views to track the status of ICC Phonebook
       
    74 Synchronisation.
       
    75 	
       
    76 If created with a NULL pointer to the Phonebook Sync plugin implements default
       
    77 behaviour of notifications (e.g. no Phonebook Synchroniser plugin present or
       
    78 non-default database).
       
    79 */
       
    80 NONSHARABLE_CLASS(CContactPhbkSyncWatcher) : public CBase
       
    81 	{
       
    82 public:
       
    83 	static CContactPhbkSyncWatcher* NewL(MContactSynchroniser& aSyncPlugin);
       
    84 	~CContactPhbkSyncWatcher();
       
    85 
       
    86 	/**
       
    87 	Add the object that sorts a contact view to the PhbkSync observer list.
       
    88 	*/
       
    89 	void AddPhbkObserverL(MContactPhbkSyncObserver& aPhbkObserver);
       
    90 
       
    91 	/**
       
    92 	Add the object that sorts a contact view to the PhbkSync observer list.
       
    93 	*/
       
    94 	void RemovePhbkObserver(MContactPhbkSyncObserver& aPhbkObserver);
       
    95 
       
    96 	TInt PhonebooksReady();
       
    97 	TInt PhonebooksWaiting();
       
    98 	TInt PhonebookSyncError();
       
    99 	
       
   100 	TInt ObserverCount();
       
   101 
       
   102 private:
       
   103 	CContactPhbkSyncWatcher(MContactSynchroniser& aSyncPlugin);
       
   104 	void ConstructL();
       
   105 
       
   106 	friend class CSinglePhbkWatcher;
       
   107 	MContactSynchroniser& SyncPlugin();
       
   108 	void SendWatcherEvent(TPhonebookState aNewState, TPhonebookState aOldState, TInt aError=KErrNone);
       
   109 
       
   110 private:
       
   111 	MContactSynchroniser&				iSyncPlugin;
       
   112 	RArray<MContactPhbkSyncObserver*>	iObservers;
       
   113 	RPointerArray<CSinglePhbkWatcher>	iWatchers;
       
   114 	TInt								iPhonebooksReady;
       
   115 	TInt								iPhonebooksWaiting;
       
   116 	TInt								iPhonebookErrors;
       
   117 	TInt								iSyncError;
       
   118 	};
       
   119 	
       
   120 
       
   121 NONSHARABLE_CLASS(CSinglePhbkWatcher) : public CActive
       
   122 	{
       
   123 public:
       
   124 	static CSinglePhbkWatcher* NewLC(CContactPhbkSyncWatcher& aSyncWatcher, TUid& aPhonebookUid);
       
   125 	~CSinglePhbkWatcher();
       
   126 	TBool IsAcceptableError(TInt aSyncError);
       
   127 
       
   128 private:
       
   129 	CSinglePhbkWatcher(CContactPhbkSyncWatcher& aSyncWatcher, TUid& aPhonebookUid);
       
   130 
       
   131 	void ConstructL();
       
   132 	void Start();
       
   133 
       
   134 	// From CActive.
       
   135 	void DoCancel();
       
   136 	void RunL();
       
   137 	TInt RunError(TInt aError);
       
   138 
       
   139 private:
       
   140 	CContactPhbkSyncWatcher& 	iSyncWatcher;
       
   141 	TUid						iPhonebookUid;
       
   142 	TPhonebookState				iPhbkState;
       
   143 	};
       
   144 
       
   145 
       
   146 #endif // __CNTPHBKSYNCWATCHER_H__