Torc  0.1
Public Slots | Public Member Functions | Static Public Member Functions | Protected Member Functions | List of all members
TorcBonjour Class Reference

Advertises and searches for services via Bonjour (aka Zero Configuration Networking/Avahi) More...

#include <torcbonjour.h>

Inheritance diagram for TorcBonjour:
[legend]

Public Slots

void socketReadyRead (int Socket)
 Read from a socket. More...
 

Public Member Functions

quint32 Register (quint16 Port, const QByteArray &Type, const QByteArray &Name, const QMap< QByteArray, QByteArray > &TxtRecords, quint32 Reference=0)
 
quint32 Register (quint16 Port, const QByteArray &Type, const QByteArray &Name, const QByteArray &Txt, quint32 Reference=0)
 
quint32 Browse (const QByteArray &Type, quint32 Reference=0)
 Search for a service advertised via Bonjour. More...
 
void Deregister (quint32 Reference)
 Cancel a Bonjour service registration or browse request. More...
 
void AddBrowseResult (DNSServiceRef Reference, const TorcBonjourService &Service)
 Handle newly discovered service. More...
 
void RemoveBrowseResult (DNSServiceRef Reference, const TorcBonjourService &Service)
 Handle removed services. More...
 
void Resolve (DNSServiceRef Reference, DNSServiceErrorType ErrorType, const char *Fullname, const char *HostTarget, uint16_t Port, uint16_t TxtLen, const unsigned char *TxtRecord)
 Handle name resolution respones from Bonjour. More...
 

Static Public Member Functions

static TorcBonjourInstance (void)
 Returns the global TorcBonjour singleton. More...
 
static void Suspend (bool Suspend)
 Suspends all Bonjour activities. More...
 
static void TearDown (void)
 Destroys the global TorcBonjour singleton. More...
 
static QByteArray MapToTxtRecord (const QMap< QByteArray, QByteArray > &Map)
 Serialises a QMap into a Bonjour Txt record format. More...
 
static QMap< QByteArray, QByteArray > TxtRecordToMap (const QByteArray &TxtRecord)
 Extracts a QMap from a properly formatted Bonjour Txt record. More...
 

Protected Member Functions

 TorcBonjour ()
 
 ~TorcBonjour ()
 

Detailed Description

Advertises and searches for services via Bonjour (aka Zero Configuration Networking/Avahi)

TorcBonjour returns opaque references for use by client objects. These are guaranteed to remain unchanged across network outages and other suspension events. Hence clients do not need to explicitly monitor network status and cancel advertisements and/or browse requests.

A ServiceDiscovered event is sent (via TorcLocalContext) when a device is discovered and a ServiceWentAway event when it is no longer available. Clients must listen for such events via TorcLocalContext::AddObserver(this).

See also
gBonjour
gBonjourLock
TorcBonjourService

Definition at line 65 of file torcbonjour.h.

Constructor & Destructor Documentation

TorcBonjour::TorcBonjour ( )
protected

Definition at line 63 of file torcbonjourwindows.cpp.

TorcBonjour::~TorcBonjour ( )
protected

Definition at line 72 of file torcbonjourwindows.cpp.

Member Function Documentation

void TorcBonjour::AddBrowseResult ( DNSServiceRef  Reference,
const TorcBonjourService Service 
)

Handle newly discovered service.

Services that have not been seen before are added to the list of known services and a name resolution is kicked off.

Definition at line 755 of file torcbonjour.cpp.

quint32 TorcBonjour::Browse ( const QByteArray &  Type,
quint32  Reference = 0 
)

Search for a service advertised via Bonjour.

Initiates a browse request for the service named by Type. The requestor must listen for the Torc::ServiceDiscovered and Torc::ServiceWentAway events.

Parameters
TypeA string describing the Bonjour service type (e.g. _http._tcp).
ReferenceUsed to re-create a Browse following a Resume.
Returns
An opaque reference to be used via Deregister on success, 0 on failure.
See also
Deregister

Definition at line 82 of file torcbonjourwindows.cpp.

void TorcBonjour::Deregister ( quint32  Reference)

Cancel a Bonjour service registration or browse request.

Parameters
ReferenceA TorcBonjour reference previously obtained via a call to Register
See also
Register
Browse

Definition at line 87 of file torcbonjourwindows.cpp.

TorcBonjour * TorcBonjour::Instance ( void  )
static

Returns the global TorcBonjour singleton.

If it does not exist, it will be created.

Definition at line 30 of file torcbonjourwindows.cpp.

QByteArray TorcBonjour::MapToTxtRecord ( const QMap< QByteArray, QByteArray > &  Map)
static

Serialises a QMap into a Bonjour Txt record format.

Definition at line 51 of file torcbonjourwindows.cpp.

quint32 TorcBonjour::Register ( quint16  Port,
const QByteArray &  Type,
const QByteArray &  Name,
const QMap< QByteArray, QByteArray > &  TxtRecords,
quint32  Reference = 0 
)

Definition at line 76 of file torcbonjourwindows.cpp.

quint32 TorcBonjour::Register ( quint16  Port,
const QByteArray &  Type,
const QByteArray &  Name,
const QByteArray &  Txt,
quint32  Reference = 0 
)

Definition at line 470 of file torcbonjour.cpp.

void TorcBonjour::RemoveBrowseResult ( DNSServiceRef  Reference,
const TorcBonjourService Service 
)

Handle removed services.

Definition at line 826 of file torcbonjour.cpp.

void TorcBonjour::Resolve ( DNSServiceRef  Reference,
DNSServiceErrorType  ErrorType,
const char *  Fullname,
const char *  HostTarget,
uint16_t  Port,
uint16_t  TxtLen,
const unsigned char *  TxtRecord 
)

Handle name resolution respones from Bonjour.

This function is called from the Bonjour library when a discovered service is resolved to a target and port. Before we can use this target, we attempt to discover its IP addresses via QHostInfo.

See also
HostLookup

Definition at line 889 of file torcbonjour.cpp.

void TorcBonjour::socketReadyRead ( int  Socket)
slot

Read from a socket.

TorcBonjourPriv does not inherit QObject hence needs TorcBonjour to handle slots and events.

Definition at line 91 of file torcbonjourwindows.cpp.

void TorcBonjour::Suspend ( bool  Suspend)
static

Suspends all Bonjour activities.

Definition at line 40 of file torcbonjourwindows.cpp.

void TorcBonjour::TearDown ( void  )
static

Destroys the global TorcBonjour singleton.

Definition at line 44 of file torcbonjourwindows.cpp.

QMap< QByteArray, QByteArray > TorcBonjour::TxtRecordToMap ( const QByteArray &  TxtRecord)
static

Extracts a QMap from a properly formatted Bonjour Txt record.

Definition at line 57 of file torcbonjourwindows.cpp.


The documentation for this class was generated from the following files: