multimediacommsengine/tsrc/testdriver/testclient/net/src/CTcBtManager.h
changeset 0 1bce908db942
equal deleted inserted replaced
-1:000000000000 0:1bce908db942
       
     1 /*
       
     2 * Copyright (c) 2004 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:  See class definition below.
       
    15 *
       
    16 */
       
    17 
       
    18 #ifndef __CTCBTMANAGER_H__
       
    19 #define __CTCBTMANAGER_H__
       
    20 
       
    21 // INCLUDES
       
    22 #include <e32base.h>
       
    23 #include <btsdp.h>
       
    24 #include "MTcBearerManager.h"
       
    25 #include "MTcBearerObserver.h"
       
    26 #include "CTcBtConnection.h"
       
    27 
       
    28 // FORWARD DECLARATIONS
       
    29 class TTcBtFactory;
       
    30 
       
    31 // CLASS DEFINITION
       
    32 /**
       
    33  * CTcBtManager implements Bluetooth specific connection management,
       
    34  * like security settings and service advertisement.
       
    35  * It also owns and controls the CTcBtConnection instance
       
    36  */
       
    37 class CTcBtManager
       
    38 	: public CBase,
       
    39 	  public MTcBearerManager,
       
    40 	  public MTcBearerObserver
       
    41 	{
       
    42 	public:	// Constructors and destructor
       
    43 
       
    44 		/**
       
    45 		 * Static constructor.
       
    46 		 *
       
    47 		 * @param aFactory Specifies the used bearer type
       
    48 		 * @return An initialized instance of this class
       
    49 		 */
       
    50 		static CTcBtManager* NewL( const TTcBtFactory& aFactory );
       
    51 
       
    52 		/// Destructor
       
    53 		~CTcBtManager();
       
    54 
       
    55 	private: // Constructors
       
    56 
       
    57 		/**
       
    58 		 * Constructor
       
    59 		 *
       
    60 		 * @param aFactory Specifies the used bearer type
       
    61 		 */
       
    62 		CTcBtManager( const TTcBtFactory& aFactory );
       
    63 
       
    64 		/// Default constructor. Not implemented.
       
    65 		CTcBtManager();
       
    66 
       
    67 		/// 2nd phase constructor.
       
    68 		void ConstructL();
       
    69 
       
    70 	public: // From MTcBearerManager
       
    71 
       
    72 		void ConnectL( TInetAddr* aRemoteAddr );
       
    73 		void Close();
       
    74 		void Send( const TDesC8& aDes );
       
    75 		void Receive( TDes8& aDes );
       
    76 		void ReceiveOneOrMore( TDes8& aDes );
       
    77 		void SetObserver( MTcBearerObserver* aObserver );
       
    78 		void GetLocalAddressL( TDes& aDes );
       
    79 
       
    80 	public: // From MTcBearerObserver
       
    81 
       
    82 		void BearerCompletion( MTcBearerObserver::TOperation aOp,
       
    83 							   TInt aStatus );
       
    84 
       
    85 	private: // New methods
       
    86 
       
    87 		/**
       
    88 		 * Add our service to the Service Discovery Database (SDP)
       
    89 		 *
       
    90 		 * @param aChannel Bluetooth channel/port number of the service
       
    91 		 */
       
    92 		void StartAdvertiserL( TInt aChannel );
       
    93 
       
    94 		/// Remove our service from the SDP
       
    95 		void StopAdvertiser();
       
    96 
       
    97 		/**
       
    98 		 * Mark our service as available or unavailable in the SDP.
       
    99 		 *
       
   100 		 * @param aIsAvailable ETrue for available,
       
   101 		 *					   EFalse for unavailable
       
   102 		 */
       
   103 		void MakeAvailableL( TBool aIsAvailable );
       
   104 
       
   105 		/**
       
   106 		 * Define security requirements for incoming connections.
       
   107 		 *
       
   108 		 * @param aChannel Bluetooth channel/port number
       
   109 		 * @param aAuthentication ETrue = required, EFalse = not required
       
   110 		 * @param aEncryption ETrue = required, EFalse = not required
       
   111 		 * @param aAuthorisation ETrue = required, EFalse = not required
       
   112 		 */
       
   113 #ifndef __BLUETOOTH_API_V2__
       
   114 		void SetSecurityL( TInt aChannel,
       
   115 						   TBool aAuthentication,
       
   116 						   TBool aEncryption,
       
   117 						   TBool aAuthorisation );
       
   118 #endif
       
   119 		/// Turn on BT if it's not already on. May result in a dialog
       
   120 		/// shown to the user.
       
   121 		void TurnOnBtL();
       
   122 
       
   123 	private: // Data
       
   124 
       
   125 		/// Connection implementation. Owned.
       
   126 		CTcBtConnection iConn;
       
   127 
       
   128 		/// Connection observer. Not owned.
       
   129 		MTcBearerObserver* iObserver;
       
   130 
       
   131 		/// SDP session. Owned.
       
   132 		RSdp iSdpServ;
       
   133 
       
   134 		/// SDP database handle. Owned.
       
   135 		RSdpDatabase iSdpDb;
       
   136 
       
   137 		/// SDP record for our service
       
   138 		TSdpServRecordHandle iSdpRecord;
       
   139 
       
   140 		/// State (bit like a version number) of SDP records
       
   141 		TInt iSdpRecordState;
       
   142 		
       
   143 		/// Socket server session. Owned.
       
   144 		RSocketServ iSockServ;
       
   145 
       
   146 	};
       
   147 
       
   148 #endif // __CTCBTMANAGER_H__