|
S60 3rd Edition SDK for Symbian OS Example Applications Guide |
#include <ChatBtServiceAdvertiser.h>
Inheritance diagram for CChatBtServiceAdvertiser:

Public Member Functions | |
| virtual | ~CChatBtServiceAdvertiser () |
| void | StartAdvertisingL (TInt aPort) |
| void | StopAdvertisingL () |
| TBool | IsAdvertising () |
| void | UpdateAvailabilityL (TBool aIsAvailable) |
Protected Member Functions | |
| CChatBtServiceAdvertiser () | |
| virtual void | BuildProtocolDescriptionL (CSdpAttrValueDES *aProtocolDescriptor, TInt aPort)=0 |
| virtual TInt | ServiceClass ()=0 |
| virtual const TDesC & | ServiceName ()=0 |
| virtual const TDesC & | ServiceDescription ()=0 |
Private Member Functions | |
| void | ConnectL () |
Private Attributes | |
| RSdp | iSdpSession |
| RSdpDatabase | iSdpDatabase |
| TSdpServRecordHandle | iRecord |
| TInt | iRecordState |
| TBool | iIsConnected |
Definition at line 32 of file ChatBtServiceAdvertiser.h.
|
|
~CChatBtServiceAdvertiser Destroy the object, close all open handles and remove the advertised service. Definition at line 40 of file ChatBtServiceAdvertiser.cpp. References IsAdvertising(), iSdpDatabase, iSdpSession, and StopAdvertisingL(). 00041 { 00042 if ( IsAdvertising() ) 00043 { 00044 TRAPD( err,StopAdvertisingL() ); 00045 if ( err != KErrNone ) 00046 { 00047 User::Panic( KPanicBTServiceAdvertiser, err ); 00048 } 00049 } 00050 00051 iSdpDatabase.Close(); 00052 iSdpSession.Close(); 00053 }
|
|
|
CChatBtServiceAdvertiser Construct this object Definition at line 28 of file ChatBtServiceAdvertiser.cpp. 00028 : 00029 iRecord( 0 ), 00030 iIsConnected( EFalse ) 00031 { 00032 // no implementation required 00033 }
|
|
|
StartAdvertisingL Start the advertising of this service
Definition at line 75 of file ChatBtServiceAdvertiser.cpp. References BuildProtocolDescriptionL(), ConnectL(), iIsConnected, iRecord, IsAdvertising(), iSdpDatabase, ServiceClass(), ServiceDescription(), ServiceName(), and StopAdvertisingL(). 00076 { 00077 if ( IsAdvertising() ) 00078 { 00079 // could be advertising on a different port 00080 StopAdvertisingL(); 00081 } 00082 if ( ! iIsConnected ) 00083 { 00084 ConnectL(); 00085 } 00086 iSdpDatabase.CreateServiceRecordL( ServiceClass(), iRecord ); 00087 00088 // add a Protocol to the record 00089 CSdpAttrValueDES* vProtocolDescriptor = CSdpAttrValueDES::NewDESL( NULL ); 00090 CleanupStack::PushL( vProtocolDescriptor ); 00091 00092 BuildProtocolDescriptionL( vProtocolDescriptor,aPort ); 00093 00094 iSdpDatabase.UpdateAttributeL( iRecord, KSdpAttrIdProtocolDescriptorList, 00095 *vProtocolDescriptor ); 00096 00097 CleanupStack::PopAndDestroy( vProtocolDescriptor ); 00098 00099 // Add a name to the record 00100 iSdpDatabase.UpdateAttributeL( iRecord, 00101 KSdpAttrIdBasePrimaryLanguage + 00102 KSdpAttrIdOffsetServiceName, 00103 ServiceName() ); 00104 00105 // Add a description to the record 00106 iSdpDatabase.UpdateAttributeL( iRecord, 00107 KSdpAttrIdBasePrimaryLanguage + 00108 KSdpAttrIdOffsetServiceDescription, 00109 ServiceDescription() ); 00110 00111 }
|
|
|
StopAdvertisingL Stop advertising this service. Remove the record from the sdp database Definition at line 146 of file ChatBtServiceAdvertiser.cpp. References iRecord, IsAdvertising(), and iSdpDatabase. 00147 { 00148 if ( IsAdvertising() ) 00149 { 00150 iSdpDatabase.DeleteRecordL( iRecord ); 00151 iRecord = 0; 00152 } 00153 }
|
|
|
IsAdvertising Does the SDP database contain a record for this service
Definition at line 160 of file ChatBtServiceAdvertiser.cpp. References iRecord. 00161 { 00162 return iRecord != 0; 00163 }
|
|
|
UpdateAvailabilityL Update the service availability field of the service record
Definition at line 118 of file ChatBtServiceAdvertiser.cpp. References iRecord, iRecordState, and iSdpDatabase. 00119 { 00120 TUint state; 00121 if ( aIsAvailable ) 00122 { 00123 state = 0xFF; // Fully unused 00124 } 00125 else 00126 { 00127 state = 0x00; // Fully used -> can't connect 00128 } 00129 00130 // Update the availibility attribute field 00131 iSdpDatabase.UpdateAttributeL( iRecord, 00132 KSdpAttrIdServiceAvailability, 00133 state ); 00134 00135 // Mark the record as changed - by increasing its state number (version) 00136 iSdpDatabase.UpdateAttributeL( iRecord, 00137 KSdpAttrIdServiceRecordState, 00138 ++iRecordState ); 00139 }
|
|
||||||||||||
|
BuildProtocolDescriptionL Builds the protocol description
Implemented in CChatServiceAdvertiser. |
|
|
ServiceClass
Implemented in CChatServiceAdvertiser. |
|
|
ServiceName
Implemented in CChatServiceAdvertiser. |
|
|
ServiceDescription
Implemented in CChatServiceAdvertiser. |
|
|
ConnectL Connect to the SDP database Definition at line 60 of file ChatBtServiceAdvertiser.cpp. References iIsConnected, iSdpDatabase, and iSdpSession. 00061 { 00062 if ( !iIsConnected ) 00063 { 00064 User::LeaveIfError( iSdpSession.Connect() ); 00065 User::LeaveIfError( iSdpDatabase.Open( iSdpSession ) ); 00066 iIsConnected = ETrue; 00067 } 00068 }
|
|
|
iSdpSession a handle to the SDP session Definition at line 121 of file ChatBtServiceAdvertiser.h. |
|
|
iSdpDatabase a connection to the SDP database Definition at line 127 of file ChatBtServiceAdvertiser.h. |
|
|
iRecord the record handle of the service record for this server Definition at line 133 of file ChatBtServiceAdvertiser.h. |
|
|
iRecordState the current record state - change number Definition at line 139 of file ChatBtServiceAdvertiser.h. |
|
|
iIsConnected has a connection been made to the SDP Database Definition at line 145 of file ChatBtServiceAdvertiser.h. |
|
© Nokia 2006 |