Torc
0.1
|
Advertises and searches for services via Bonjour (aka Zero Configuration Networking/Avahi) More...
#include <torcbonjour.h>
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 TorcBonjour * | Instance (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 () | |
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).
Definition at line 65 of file torcbonjour.h.
|
protected |
Definition at line 63 of file torcbonjourwindows.cpp.
|
protected |
Definition at line 72 of file torcbonjourwindows.cpp.
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.
Type | A string describing the Bonjour service type (e.g. _http._tcp). |
Reference | Used to re-create a Browse following a Resume. |
Definition at line 82 of file torcbonjourwindows.cpp.
void TorcBonjour::Deregister | ( | quint32 | Reference | ) |
Cancel a Bonjour service registration or browse request.
Reference | A TorcBonjour reference previously obtained via a call to Register |
Definition at line 87 of file torcbonjourwindows.cpp.
|
static |
Returns the global TorcBonjour singleton.
If it does not exist, it will be created.
Definition at line 30 of file torcbonjourwindows.cpp.
|
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.
Definition at line 889 of file torcbonjour.cpp.
|
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.
|
static |
Suspends all Bonjour activities.
Definition at line 40 of file torcbonjourwindows.cpp.
|
static |
Destroys the global TorcBonjour singleton.
Definition at line 44 of file torcbonjourwindows.cpp.
|
static |
Extracts a QMap from a properly formatted Bonjour Txt record.
Definition at line 57 of file torcbonjourwindows.cpp.