messagingfw/biomsgfw/BDBINC/bifchangeobserver.h
changeset 62 db3f5fa34ec7
parent 0 8e480a14352b
equal deleted inserted replaced
60:9f5ae1728557 62:db3f5fa34ec7
       
     1 // Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description: bifchangeobserver.h
       
    14 // 
       
    15 // Author	
       
    16 // Date		 
       
    17 //
       
    18 /**
       
    19  * @file 
       
    20  * Callback interface implementation for BIF files changes.
       
    21  *
       
    22  * @publishedPartner
       
    23  * @released
       
    24  */
       
    25 
       
    26 #ifndef __BIFCHANGEOBSERVER_H__
       
    27 #define __BIFCHANGEOBSERVER_H__
       
    28 
       
    29 class CBIODatabase;
       
    30 
       
    31 /** Callback interface implemented by classes to receive notifications of BIF files 
       
    32 changes from CBifChangeObserver. 
       
    33 
       
    34 @publishedPartner
       
    35 @released
       
    36 */
       
    37 class MBifChangeObserver 
       
    38 	{
       
    39 public:
       
    40 	/** BIF change events. */
       
    41 	enum TBifChangeEvent
       
    42 		{
       
    43 		/** Unknown change. */
       
    44 		EBifChangeUnknown = 0,
       
    45 		/** BIF added. */
       
    46 		EBifAdded,
       
    47 		/** BIF deleted. */
       
    48 		EBifDeleted,
       
    49 		/** BIF changed. */
       
    50 		EBifChanged
       
    51 		};
       
    52 
       
    53 public: 
       
    54 	/** Called when a BIF change occurs.
       
    55 	
       
    56 	@param aEvent Change event type
       
    57 	@param aBioID BIO message type of changed BIF */
       
    58 	virtual void HandleBifChangeL(TBifChangeEvent aEvent, TUid aBioID)=0;
       
    59 	};
       
    60 
       
    61 /** Active object that watches for changes made to the installed BIF files. 
       
    62 
       
    63 @publishedPartner
       
    64 @released
       
    65 */
       
    66 class CBifChangeObserver : public CActive
       
    67 	{
       
    68 public: 
       
    69 	IMPORT_C static CBifChangeObserver* NewL(MBifChangeObserver& aObserver, RFs& aFs);
       
    70 	IMPORT_C void Start();
       
    71 	~CBifChangeObserver();
       
    72 	
       
    73 	static void CleanupBifArray(TAny* aBifArray);
       
    74 
       
    75 private:
       
    76 	// from CActive
       
    77 	virtual void RunL();
       
    78 	virtual void DoCancel();
       
    79 
       
    80 private:
       
    81 	CBifChangeObserver(MBifChangeObserver& aObserver, RFs& aFs);
       
    82 	void ConstructL();
       
    83 	
       
    84 	void NotifyObserverL();
       
    85 	void WaitForFileNotification();
       
    86 	void DoRunL();
       
    87 	void CopyEntriesL(const CDir& aDir, CArrayFixFlat<TEntry>& aEntries);
       
    88 	TBool CompareReaders(const CBioInfoFileReader& aReader1, const CBioInfoFileReader& aReader2) const;
       
    89 	
       
    90 	TInt FindEntry(const CBifEntry& aBifEntry, const RPointerArray<CBifEntry>& aEntries, TInt& aIndex) const;
       
    91 	
       
    92 private:
       
    93 	MBifChangeObserver&	iChangeObserver;
       
    94 	RFs&			iFs;
       
    95 
       
    96 	RPointerArray<CBifEntry> iEntries;
       
    97 
       
    98 	CBIODatabase*	iBioDB;
       
    99 	RTimer	iTimer;
       
   100 	TInt iRetryCount;
       
   101 	};
       
   102 
       
   103 #endif // __BIFCHANGEOBSERVER_H__