bluetooth/btexample/example/eir/teir.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 #ifndef TEIR_H
       
    17 #define TEIR_H
       
    18 
       
    19 // forward declarations
       
    20 #include <e32test.h>
       
    21 #include <es_sock.h>
       
    22 #include <f32file.h>
       
    23 #include <bt_sock.h>
       
    24 #include <btsdp.h>
       
    25 #include <c32comm.h>
       
    26 //#include "debug.h"
       
    27 #include <btmanclient.h>
       
    28 //#include <hcierrors.h>
       
    29 #include <btextnotifiers.h>
       
    30 #include <bluetooth/eirpublisher.h>
       
    31 #include <bluetooth/eirpublishermanufacturerspecificdata.h>
       
    32 #include <bttypes.h>
       
    33 #include <bluetooth/eirdatacodec.h>
       
    34 
       
    35 class CActiveNameRequester;
       
    36 //class CActiveInquirer;
       
    37 class CActiveHostResolver;
       
    38 class CActiveConnector;
       
    39 class CActiveConsole;
       
    40 class CActiveBasebandDisconnector;
       
    41 class CEirPublisherTestName;
       
    42 class CEirPublisherTestUuid16;
       
    43 class CEirPublisherTestUuid128;
       
    44 class CEirPublisherTestManuSpecific;
       
    45 class CEirPublisherTestTxPowerLevel;
       
    46 
       
    47 class CEirPublisherManufacturerSpecificData;
       
    48 class CEirApp;
       
    49 	
       
    50 enum TTestEirTag
       
    51 	{
       
    52 	ETestDeviceName = 0,
       
    53 	ETestUuid16,
       
    54 	ETestUuid128,
       
    55 	ETestSetMSD,
       
    56 	ETestRemoveMSD,
       
    57 	};
       
    58 
       
    59 class CManufacturerDataNotifier : public CBase, public MManufacturerSpecificDataPublisherNotifier
       
    60 	{
       
    61 public:
       
    62 	static CManufacturerDataNotifier* NewL(CEirApp& aEirApp);
       
    63 	CManufacturerDataNotifier(CEirApp& aEirApp);
       
    64 	~CManufacturerDataNotifier();
       
    65 	void ConstructL();
       
    66 	
       
    67 	// From MManufacturerSpecificDataPublisherNotifier
       
    68 	virtual void MmsdpnNotifyAvailableDataSize(TUint aAvailableDataSize);
       
    69 	virtual void MmsdpnNotifyError(TInt aResult);
       
    70 private:
       
    71 	CEirApp& iEirApp;
       
    72 	};
       
    73 
       
    74 class CEirApp : public CBase
       
    75 	{
       
    76 	public:
       
    77 
       
    78 		static CEirApp* NewL(CConsoleBase& aConsole);
       
    79 		void NewNameRequesterL(TBool aEirInstead, TBool aIgnoreCache);
       
    80 		//void CancelNameRequester();
       
    81 		//void DeleteNameRequester();
       
    82 		void NewInquirerL(TUint aIAC, TBool aDoNames, TBool aIgnoreCache, TBool aDoEir, TBool forever=EFalse);
       
    83 		void CancelInquirer();
       
    84 		void DeviceFound(TBTDevAddr aAddress);
       
    85 		void InquiryComplete();
       
    86 		void NewNameArrayRequesterL();
       
    87 
       
    88 		void NewEirPublisherTestL(TTestEirTag aTag);
       
    89 
       
    90 		void InitialiseL();
       
    91 		void StopProtocols();
       
    92 		void ShowAddress();
       
    93 
       
    94 		void StartL();
       
    95 		void Stop();
       
    96 		~CEirApp();
       
    97 
       
    98 		RSocketServ& SocketServ(); 
       
    99 		void SetPublishManuData(TUint aAvailableDataSize);
       
   100 		void Register16BitSDPRecordL();
       
   101 		void Register128BitSDPRecordL();
       
   102 
       
   103 	private:
       
   104 		CEirApp(CConsoleBase& aConsole);
       
   105 		void ConstructL(CConsoleBase& aConsole);
       
   106 		void CreateSdpRecordL(const TUUID& aUUID, TBool aIsPublicBrowseGroup = ETrue, TBool aIsL2cap = ETrue);
       
   107 	private:
       
   108 		RSocketServ		iSocketServer;
       
   109 		CActiveNameRequester* iNameRequester;
       
   110 		//CActiveInquirer* iInquirer;
       
   111 		CActiveConsole*	iActiveConsole;
       
   112 		CConsoleBase& iConsole;
       
   113 
       
   114 		RPointerArray<CActiveHostResolver> iResolvers;
       
   115 		RArray<TBTDevAddr>	iDevicesFound;
       
   116 
       
   117 		CEirPublisherManufacturerSpecificData* iEirPublisherTestManuSpecific;
       
   118 
       
   119 		CManufacturerDataNotifier* iManuNotifier;
       
   120 		RSdpDatabase iSdpDB;
       
   121 		RSdp iSdp;
       
   122 
       
   123 	};
       
   124 
       
   125 
       
   126 class CActiveConsole : public CActive
       
   127 	{
       
   128 	public:
       
   129 		static CActiveConsole* NewL(CConsoleBase& aConsole, CEirApp& aApp);
       
   130 
       
   131 		void RunL();
       
   132 		void DoCancel();
       
   133 		void TestMenu();
       
   134 		void DrawCursor();
       
   135 		~CActiveConsole();
       
   136 
       
   137 	private:
       
   138 		CActiveConsole(CConsoleBase& aConsole, CEirApp& aApp);
       
   139 		void ConstructL();
       
   140 		void RequestKey();
       
   141 		TInt SetHostName();
       
   142 	TBool ProcessKey(TChar aCh);
       
   143 
       
   144 	private:
       
   145 		CConsoleBase&		iConsole;
       
   146 		CEirApp&	iApp;
       
   147 	};
       
   148 
       
   149 class CActiveHostResolver : public CActive
       
   150 	{
       
   151 	// abstract class for derivation - deriveees implement RunL and Start
       
   152 	public:
       
   153 		void DoCancel();
       
   154 		~CActiveHostResolver();
       
   155 		void SetLocalNameL();
       
   156 
       
   157 	protected:
       
   158 		CActiveHostResolver(CConsoleBase& aConsole, CEirApp& aApp);
       
   159 		void StartServerL();
       
   160 		void StartHostResolverL();
       
   161 		void SetIAC(TUint aIAC);
       
   162 		void ConstructL();
       
   163 		virtual void Start() = 0;
       
   164 
       
   165 	protected:
       
   166 		RHostResolver		iHostResolver;
       
   167 		RSocketServ			iSocketServer;
       
   168 		TProtocolDesc		iProtocolInfo;
       
   169 		CConsoleBase&		iConsole; //root console
       
   170 		CEirApp&	iApp;
       
   171 		CConsoleBase*		iHROutputConsole;
       
   172 		TInquirySockAddr	iInquiryRequest;
       
   173 
       
   174 	private:
       
   175 		TInt RunError(TInt aError);
       
   176 
       
   177 	private:
       
   178 		static TInt			iHRNumber;
       
   179 	};
       
   180 
       
   181 
       
   182 class CActiveNameRequester : public CActiveHostResolver
       
   183 	{
       
   184 	public:
       
   185 		static CActiveNameRequester* NewL(CConsoleBase& aConsole, CEirApp& aApp, TBool aEirInstead, TBool aIgnoreCache);
       
   186 		void RunL();
       
   187 	protected:
       
   188 		virtual void PrintResults();
       
   189 
       
   190 		CActiveNameRequester(CConsoleBase& aConsole, CEirApp& aApp, TBool aEirInstead, TBool aIgnoreCache);
       
   191 		void ConstructL();
       
   192 	private:
       
   193 		void Start();
       
   194 	private:
       
   195 		TNameEntry			iResult;
       
   196 		TBool				iEirInstead;
       
   197 		TBool				iIgnoreCache;
       
   198 	};
       
   199 
       
   200 class CActiveInquirer : public CActiveHostResolver
       
   201 	{
       
   202 	public:
       
   203 		static CActiveInquirer* NewL(CConsoleBase& aConsole, CEirApp& aApp, TUint aIAC, TBool aDoNames, TBool aIgnoreCache, TBool aDoEir, TBool forever);
       
   204 		void RunL();
       
   205 	private:
       
   206 		void ConstructL(TUint aIAC);
       
   207 		void Start();
       
   208 		CActiveInquirer(CConsoleBase& aConsole, CEirApp& aApp, TBool aDoNames, TBool aIgnoreCache, TBool aDoEir, TBool forever);
       
   209 	private:
       
   210 		TNameEntry			iResult;
       
   211 		TBool				iDoNames;
       
   212 		TBool				iIgnoreCache;
       
   213 		TBool				iDoEir;
       
   214 		TBool				iForever;
       
   215 	};
       
   216 
       
   217 
       
   218 class CActiveNameArrayRequester : public CActiveNameRequester
       
   219 // A 'high-level' name request iterator
       
   220 	{
       
   221 public:
       
   222 	static CActiveNameArrayRequester* NewL(CConsoleBase& aConsole, CEirApp& aApp, RArray<TBTDevAddr>& aNameArray);
       
   223 
       
   224 private: // from CActive
       
   225 	void RunL();
       
   226 
       
   227 private:
       
   228 	virtual void PrintResults();
       
   229 	void DoSingleNameRequest();
       
   230 	void ConstructL();
       
   231 	void Start();
       
   232 	CActiveNameArrayRequester(CConsoleBase& aConsole, CEirApp& aApp, RArray<TBTDevAddr>& aNameArray);
       
   233 
       
   234 private: // owned
       
   235 	TNameEntry			iResult;
       
   236 	TInt				iCurrentNameIndex;
       
   237 
       
   238 private: // unowned
       
   239 	RArray<TBTDevAddr>&	iNameArray;
       
   240 	};
       
   241 
       
   242 #endif // TEIR_H