bluetooth/btstack/inc/RegistryHelpers.h
changeset 0 29b1cd4cb562
equal deleted inserted replaced
-1:000000000000 0:29b1cd4cb562
       
     1 // Copyright (c) 2005-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 #include <btmanclient.h>
       
    17 #include <btdevice.h>
       
    18 
       
    19 
       
    20 #ifndef _REGISTRY_HELPERS_H
       
    21 #define _REGISTRY_HELPERS_H
       
    22 
       
    23 //
       
    24 // Classes apertaining to MBTRegistryTaskNotifier //
       
    25 //
       
    26 
       
    27 class CBTInquiryMgr;
       
    28 class CRegistrySession;
       
    29 class CBTRegistryHelperBase;
       
    30 
       
    31 enum TRegistryUpdateStatus
       
    32 	{
       
    33 	ENoChange,
       
    34 	EModification,
       
    35 	EAddition
       
    36 	};
       
    37 
       
    38 class MBTRegistryTaskNotifier
       
    39 	{
       
    40 public:
       
    41 	virtual void RegistryTaskComplete(CBTRegistryHelperBase* /*aHelper*/,
       
    42 									  TInt /*aResult*/) {};
       
    43 	virtual void RegistryTaskComplete(CBTRegistryHelperBase* /*aHelper*/,
       
    44 									  const TBTNamelessDevice& /*aDevice*/,
       
    45 									  TInt /*aResult*/)=0;
       
    46   	virtual void RegistryTaskComplete(CBTRegistryHelperBase* /*aHelper*/,
       
    47   									  TRegistryUpdateStatus /*aModified*/,
       
    48   									  TInt /*aResult*/)=0;
       
    49 	};
       
    50 
       
    51 NONSHARABLE_CLASS(CBTRegistryHelperBase) : public CActive
       
    52 	{
       
    53 public:
       
    54 	~CBTRegistryHelperBase();
       
    55 	void DetachParent();
       
    56 	
       
    57 protected:
       
    58 	virtual void DoCancel();
       
    59 	virtual void RunL();
       
    60 	virtual TInt RunError(TInt aError);
       
    61 	CBTRegistryHelperBase(MBTRegistryTaskNotifier& aParent, CRegistrySession& aRegSess);
       
    62 	virtual void ConstructL();
       
    63 
       
    64 	virtual TBool IsRegistryTaskCompleteL();
       
    65 	virtual void Notify(TInt aError);
       
    66 	
       
    67 public:
       
    68 	TSglQueLink 				iLink;
       
    69 protected:
       
    70 	CRegistrySession&			iRegSess;
       
    71 	TBTNamelessDevice			iDevice;
       
    72 	MBTRegistryTaskNotifier*	iParent;
       
    73 	RBTRegistry					iRegistry;
       
    74 	};
       
    75 
       
    76 
       
    77 
       
    78 NONSHARABLE_CLASS(CBTDeviceGetter): public CBTRegistryHelperBase
       
    79 	{
       
    80 public:
       
    81 	static CBTDeviceGetter* NewL(CRegistrySession& aRegSess,
       
    82 								  MBTRegistryTaskNotifier& aParent);
       
    83 	void Start(const TBTDevAddr& aAddress);
       
    84 private:
       
    85 	CBTDeviceGetter(MBTRegistryTaskNotifier& aParent, CRegistrySession& aRegSess);
       
    86 
       
    87 	void Notify(TInt aError);
       
    88 	};
       
    89 
       
    90 NONSHARABLE_CLASS(CBTLinkKeyDeleter): public CBTRegistryHelperBase
       
    91 	{
       
    92 public:
       
    93 	static CBTLinkKeyDeleter* NewL(CRegistrySession& aRegSess,
       
    94 										  MBTRegistryTaskNotifier& aParent);
       
    95 	void Start(const TBTDevAddr& aAddr);
       
    96 private:
       
    97 	CBTLinkKeyDeleter(MBTRegistryTaskNotifier& aParent, CRegistrySession& aRegSess);
       
    98 	};
       
    99 
       
   100 NONSHARABLE_CLASS(CBTDeviceModifier): public CBTRegistryHelperBase
       
   101 	{
       
   102 public:
       
   103 	static CBTDeviceModifier* NewL(CRegistrySession& aRegSess, MBTRegistryTaskNotifier& aParent, CBTInquiryMgr& aInquiryMgr);
       
   104 	void Start(const TBTNamelessDevice& aDevice, TBool aCanAddDevice);
       
   105 	~CBTDeviceModifier();
       
   106 	
       
   107 private:
       
   108 	CBTDeviceModifier(MBTRegistryTaskNotifier& aParent, CBTInquiryMgr& aInquiryMgr, CRegistrySession& aRegSess);
       
   109 	void Notify(TInt aError);
       
   110 	
       
   111 private: // from CBTRegistryHelperBase
       
   112 	TBool IsRegistryTaskCompleteL();
       
   113 	
       
   114 private:
       
   115 	enum TModifierState
       
   116 		{
       
   117 		EFindingDevice,
       
   118 		EAddingDevice,
       
   119 		EModifyingDevice,
       
   120 		EModifyingName,
       
   121 		};
       
   122 	
       
   123 private:
       
   124 	CBTInquiryMgr&			iInquiryMgr; // for updating of device name
       
   125 	TModifierState			iState;
       
   126 	CBTDevice* 				iDeviceWithName;
       
   127 	TBool					iCanAddDevice;
       
   128 	TBTRegistrySearch		iRegistrySearch; // Used for checking if an entry exists for a specified address. 
       
   129 	TRegistryUpdateStatus	iRegistryUpdateStatus;	//indicate the registry modification
       
   130 	};
       
   131 
       
   132 NONSHARABLE_CLASS(CBTDeviceNameChanger): public CBTRegistryHelperBase
       
   133 	{
       
   134 public:
       
   135 	static CBTDeviceNameChanger* NewL(CRegistrySession& aRegSess,
       
   136 								  MBTRegistryTaskNotifier& aParent);
       
   137 	void Start(const TBTDevAddr& aAddress, const TBTDeviceName8& aName);
       
   138 private:
       
   139 	CBTDeviceNameChanger(MBTRegistryTaskNotifier& aParent, CRegistrySession& aRegSess);
       
   140 	TBTDevAddr		iAddr;
       
   141 	TBTDeviceName8	iName;
       
   142 	};
       
   143 	
       
   144 	
       
   145 //
       
   146 // Classes apertaining to MBtPairedDeviceNotifier //
       
   147 //
       
   148 
       
   149 class MBTPairedDeviceNotifier
       
   150 	{
       
   151 public:
       
   152 	virtual void MbpdnAddPairedDevices(const RBTDeviceArray& aAddrs) = 0;
       
   153 	virtual void MbpdnErrorInGettingPairedDevices(TInt aError) = 0;
       
   154 	};
       
   155 
       
   156 
       
   157 NONSHARABLE_CLASS(CBTPairedBDAddrGetter): public CActive
       
   158 	{
       
   159 public:
       
   160 	~CBTPairedBDAddrGetter();
       
   161 	static CBTPairedBDAddrGetter* NewL(MBTPairedDeviceNotifier& aNotifier, RBTRegServ& aRegServ);
       
   162 
       
   163 	void Retrieve();
       
   164 
       
   165 private:
       
   166 	CBTPairedBDAddrGetter(MBTPairedDeviceNotifier& aNotifier, RBTRegServ& aRegServ);
       
   167 	void DoCancel();
       
   168 	void RunL();
       
   169 	TInt RunError(TInt aError);
       
   170 	void ConstructL();
       
   171 
       
   172 private:
       
   173 	enum TBTPairedBDAddrGetterState
       
   174 		{
       
   175 		EReady,
       
   176 		ECreatingView,
       
   177 		EUsingResponse,
       
   178 		};
       
   179 private:
       
   180 	MBTPairedDeviceNotifier&	iNotifier;
       
   181 	RBTRegistry					iView;
       
   182 	RBTRegServ&					iRegistryServer;
       
   183 	CBTRegistryResponse*		iResponseHandler;
       
   184 	TBTRegistrySearch			iRegistrySearch;
       
   185 	TBTPairedBDAddrGetterState	iState;
       
   186 	};
       
   187 
       
   188 
       
   189 #endif // _REGISTRY_HELPERS_H