bluetooth/btstack/secman/oobdata.h
changeset 0 29b1cd4cb562
equal deleted inserted replaced
-1:000000000000 0:29b1cd4cb562
       
     1 // Copyright (c) 2008-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 /**
       
    17  @file
       
    18  @internalComponent
       
    19 */
       
    20 
       
    21 #ifndef OOBDATA_H
       
    22 #define OOBDATA_H
       
    23 
       
    24 #include <e32base.h>
       
    25 #include <bttypes.h>
       
    26 #include <bluetooth/hcicommandqueueclient.h>
       
    27 #include "internaltypes.h"
       
    28 
       
    29 class CPairingServer;
       
    30 class MHCICommandQueue;
       
    31 
       
    32 class COobDataManager;
       
    33 class CBTSecMan;
       
    34 
       
    35 
       
    36 NONSHARABLE_CLASS(TOobData)
       
    37 	{
       
    38 public:
       
    39 	TOobData(const TBTDevAddr& aAddr, const TBluetoothSimplePairingHash& aHashC, const TBluetoothSimplePairingRandomizer& aRandomizerR);
       
    40 	
       
    41 	const TBTDevAddr& Addr() const;
       
    42 	const TBluetoothSimplePairingHash& HashC() const;
       
    43 	const TBluetoothSimplePairingRandomizer& RandomizerR() const;
       
    44 	
       
    45 	static TBool IsForAddress(const TBTDevAddr* aAddr, const TOobData& aOobData);
       
    46 	
       
    47 private:
       
    48 	TBTDevAddr iAddr;
       
    49 	TBluetoothSimplePairingHash iHashC;
       
    50 	TBluetoothSimplePairingRandomizer iRandomizerR;
       
    51 	};
       
    52 
       
    53 
       
    54 
       
    55 NONSHARABLE_CLASS(XOobLocalDataObserver)
       
    56 	{
       
    57 friend class COobDataManager;
       
    58 private:
       
    59 	virtual void XoldoLocalOobDataRetrieved(TInt aResult, const TBluetoothSimplePairingHash& aHash, const TBluetoothSimplePairingRandomizer& aRandomizer) = 0;
       
    60 	
       
    61 private:
       
    62 	TBTDblQueLink	iLink;
       
    63 	};
       
    64 
       
    65 
       
    66 NONSHARABLE_CLASS(COobDataManager)
       
    67 	: public CBase
       
    68 	, public MHCICommandQueueClient
       
    69 	{
       
    70 public:
       
    71 	static COobDataManager* NewL(CBTSecMan& aSecMan);
       
    72 	~COobDataManager();
       
    73 	
       
    74 	void SetHCICommandQueue(MHCICommandQueue& aCommandQueue);
       
    75 	void ClearHCICommandQueue();
       
    76 	
       
    77 public:
       
    78 	void RefreshLocalOobData();
       
    79 	void ReadLocalOobData(XOobLocalDataObserver& aObserver);
       
    80 	void CancelReadLocalOobData(XOobLocalDataObserver& aObserver);
       
    81 	void ProvideRemoteOobDataL(const TOobData& aData);
       
    82 	void ClearRemoteOobData(const TBTDevAddr& aAddr);
       
    83 
       
    84 	TBool GetRemoteOobData(const TBTDevAddr& aAddr, TBluetoothSimplePairingHash& aHashC, TBluetoothSimplePairingRandomizer& aRandomizerR);
       
    85 	TBool HasRemoteOobData(const TBTDevAddr& aAddr);
       
    86 	
       
    87 	MHCICommandQueue& CommandQueueL() const;
       
    88 
       
    89 private:
       
    90 	COobDataManager(CBTSecMan& aSecMan);
       
    91 	void ConstructL();
       
    92 	void MakeLocalOobRequestToController();
       
    93 	void MakeLocalOobRequestToControllerL();
       
    94 	void CompleteQueuedLocalOobObservers(TInt aResult);
       
    95 	
       
    96 private: // from MHCICommandQueueClient
       
    97 	void MhcqcCommandEventReceived(const THCIEventBase& aEvent, const CHCICommandBase* aRelatedCommand);
       
    98 	void MhcqcCommandErrored(TInt aErrorCode, const CHCICommandBase* aCommand);
       
    99 	
       
   100 private:
       
   101 	enum TLocalOobState
       
   102 		{
       
   103 		ELocalOobInvalid,
       
   104 		ELocalOobUpdating,
       
   105 		ELocalOobValid,
       
   106 		};
       
   107 	
       
   108 	
       
   109 private: // owned
       
   110 	// Remote OOB Data
       
   111 	RArray<TOobData>					iOobDataFromPeers;
       
   112 	
       
   113 	// Local OOB Data
       
   114 	TLocalOobState						iLocalOobState;
       
   115 	TBluetoothSimplePairingHash			iOobHashC;
       
   116 	TBluetoothSimplePairingRandomizer	iOobRandomizerR;
       
   117 	
       
   118 private: // unowned
       
   119 	TDblQue<XOobLocalDataObserver>		iLocalOobObservers;
       
   120 	MHCICommandQueue*					iCommandQueue;
       
   121 	CBTSecMan&							iSecMan;
       
   122 	};
       
   123 
       
   124 
       
   125 _LIT(KOobDataPanicCat, "OobDataManager");
       
   126 enum TOobDataPanicCode
       
   127 	{
       
   128 	EOobDataPanicCommandQueueAlreadyProvided,
       
   129 	EOobDataPanicMultipleOobEntriesForDevice,
       
   130 	EOobDataPanicLocalOobObserverIsAlreadyQueuedDuringUpdate,
       
   131 	EOobDataPanicLocalOobObserverIsAlreadyQueuedWhileInvalid,
       
   132 	EOobDataPanicUnknownState,
       
   133 	EOobDataPanicUnexpectedHciCommandAssociated,
       
   134 	EOobDataPanicUnexpectedHciCommandAssociatedWithError,
       
   135 	EOobDataPanicUnexpectedHciEventReceived,
       
   136 	EOobDataPanicUnexpectedHciCommandCompleteEventReceived,
       
   137 	EOobDataPanicErrorWhenFindingOobDataForProvision,
       
   138 	EOobDataPanicErrorWhenFindingOobDataForClear,
       
   139 	EOobDataPanicErrorWhenFindingOobDataForGet,
       
   140 	EOobDataPanicErrorWhenFindingOobDataForHas,
       
   141 	};
       
   142 
       
   143 #endif // OOBDATA_H
       
   144