bluetooth/btstack/linkmgr/pairingscache.h
changeset 0 29b1cd4cb562
equal deleted inserted replaced
-1:000000000000 0:29b1cd4cb562
       
     1 // Copyright (c) 2007-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:
       
    14 //
       
    15 
       
    16 #ifndef PAIRINGSCACHE_H
       
    17 #define PAIRINGSCACHE_H
       
    18 
       
    19 #include <e32base.h>
       
    20 #include "RegistryHelpers.h"
       
    21 
       
    22 class CBTPairedBDAddrGetter;
       
    23 
       
    24 class MBTPairingsCacheObserver
       
    25 	{
       
    26 public:
       
    27 	virtual void MbpcoDeferredDecisionResolved(TInt aError) = 0;
       
    28 	};
       
    29 
       
    30 NONSHARABLE_CLASS(CBTPairingsCache) : public CBase, public MBTPairedDeviceNotifier
       
    31 	{
       
    32 public:
       
    33 	enum TPairingState
       
    34 		{
       
    35 		ENotPaired,
       
    36 		EPaired,
       
    37 		EDeferred, // Issued when we are waiting for a registry update.
       
    38 		};
       
    39 public:
       
    40 	static CBTPairingsCache* NewL(MBTPairingsCacheObserver& aObserver, RBTRegServ& aRegServ);
       
    41 	~CBTPairingsCache();
       
    42 
       
    43    	void UpdateCache();
       
    44 	TPairingState IsPaired(const TBTDevAddr& aBDAddr);
       
    45 
       
    46 private:
       
    47 	CBTPairingsCache(MBTPairingsCacheObserver& aObserver);
       
    48 	void ConstructL(RBTRegServ& aRegServ);
       
    49 
       
    50 	static TBool AreBDAddrsEqual(const TBTDevAddr& aA, const TBTDevAddr& aB);
       
    51     TInt PairedDeviceIndex(const TBTDevAddr& aBDAddr);
       
    52 	TBool InPairingCache(const TBTDevAddr& aBDAddr);
       
    53 	void DoUpdateCache();
       
    54 	void RemoveAllPairedDevices();
       
    55 	void InformObserver(TInt aError);
       
    56 	TInt AddPairedDevice(const TBTDevAddr& aAddr);
       
    57 
       
    58 private: // MBTPairedDeviceNotifier
       
    59 	virtual void MbpdnAddPairedDevices(const RBTDeviceArray& aAddrs);
       
    60 	virtual void MbpdnErrorInGettingPairedDevices(TInt aError);
       
    61 
       
    62 private:
       
    63 	enum TCacheState
       
    64 		{
       
    65 		EValid,
       
    66 		EUpdateOutstanding,
       
    67 		EUpdateFailed,
       
    68 		};
       
    69 
       
    70 private:
       
    71 	MBTPairingsCacheObserver& iObserver;
       
    72 	CBTPairedBDAddrGetter* iBTPairedBDAddrGetter;
       
    73 	RArray<TBTDevAddr> iPairedBDAddrs;
       
    74 	TCacheState iCacheState;
       
    75 	TBool iDeferredDecision;
       
    76 	};
       
    77 
       
    78 
       
    79 #endif // PAIRINGSCACHE_H