www.pudn.com > S60_Platform_Bluetooth_OBEX_Example.rar > btserviceadvertiser.h


/* Copyright (c) 2004, Nokia. All rights reserved */ 
 
 
#ifndef __CBTSERVICE_ADVERTISER__ 
#define __CBTSERVICE_ADVERTISER__ 
 
// INCLUDES 
#include  
#include  
#include  
 
#include "BTServiceAdvertiser.h" 
 
 
/** 
* CBTServiceAdvertiser 
* Advertises a service in the SDP database. 
*/ 
class CBTServiceAdvertiser : public CBase 
    { 
    public: // Constructors and destructor 
 
        /** 
        * ~CBTServiceAdvertiser() 
        * Destroy the object, close all open handles 
        * and remove the advertised service. 
        */ 
        virtual ~CBTServiceAdvertiser(); 
 
        /** 
        * StartAdvertisingL() 
        * Start the advertising of this service 
        * @param aPort the port being used by the service 
        */ 
        void StartAdvertisingL( TInt aPort ); 
 
        /** 
        * StopAdvertisingL() 
        * Stop advertising this service. Remove the record 
        * from the sdp database 
        */ 
        void StopAdvertisingL(); 
 
        /** 
        * IsAdvertising() 
        * Does the SDP database contain a record for this service 
        * @return ETrue whether the service is being advertised 
        */ 
        TBool IsAdvertising(); 
 
        /** 
        * UpdateAvailabilityL() 
        * Update the service availability field of the service record 
        * @param aIsAvailable ETrue is the service is not busy. 
        */ 
        void UpdateAvailabilityL( TBool aIsAvailable ); 
 
    protected:  // Constructor 
 
        /** 
        * CBTServiceAdvertiser() 
        * Construct this object 
        */ 
        CBTServiceAdvertiser(); 
 
        /** 
        * BuildProtocolDescriptionL() 
        * Builds the protocol description 
        * @param aProtocolDescriptor the protocol descriptor 
        * @param aPort the service port 
        */ 
        virtual void BuildProtocolDescriptionL( 
            CSdpAttrValueDES* aProtocolDescriptor, TInt aPort ) = 0; 
 
        /** 
        * ServiceClass() 
        * @return the service class 
        */ 
        virtual const TInt ServiceClass() = 0; 
 
        /** 
        * ServiceName() 
        * @return the service name 
        */ 
        virtual const TDesC& ServiceName() = 0; 
 
        /** 
        * ServiceDescription() 
        * @return the service description 
        */ 
        virtual const TDesC& ServiceDescription() = 0; 
 
    private: 
 
        /** 
        * ConnectL 
        * Connect to the SDP database 
        */ 
        void ConnectL(); 
 
    private:    //data 
 
        /** iSdpSession a handle to the SDP session */ 
        RSdp iSdpSession; 
 
        /** iSdpDatabase a connection to the SDP database */ 
        RSdpDatabase iSdpDatabase; 
 
        /**iRecord the record handle of the service 
        record for this server 
        */ 
        TSdpServRecordHandle iRecord; 
 
        /**iRecordState the current record state - change number */ 
        TInt iRecordState; 
 
        /** iIsConnected has a connection been made to the SDP Database */ 
        TBool iIsConnected; 
    }; 
 
#endif // __CBTSERVICE_ADVERTISER__ 
 
// End of File