ArnLib  4.0.x
Active Registry Network
ArnZeroConfBrowser Class Reference

Browsing for ZeroConfig services. More...

#include <ArnZeroConf.hpp>

Inheritance diagram for ArnZeroConfBrowser:
Collaboration diagram for ArnZeroConfBrowser:

Public Slots

void browse (bool enable=true)
 Change state of browsing. More...
 
void stopBrowse ()
 Stop browsing. More...
 

Signals

void serviceChanged (bool isAdded, int id, const QString &serviceName, const QString &domain)
 Indicate service has been added / removed. More...
 
void serviceAdded (int id, const QString &serviceName, const QString &domain)
 Indicate service has been added (discovered) More...
 
void serviceRemoved (int id, const QString &serviceName, const QString &domain)
 Indicate service has been removed. More...
 
void browseError (int errorCode)
 Indicate unsuccessfull browsing. More...
 

Public Member Functions

 ArnZeroConfBrowser (QObject *parent=arnNullptr)
 Standard constructor of an ArnZeroConfBrowser object. More...
 
 ArnZeroConfBrowser (const QString &serviceType, QObject *parent=arnNullptr)
 Constructor of an ArnZeroConfBrowser object. More...
 
virtual ~ArnZeroConfBrowser ()
 Destructor of an ArnZeroConfBrowser object. More...
 
void setSubType (const QString &subtype)
 Set subtype (filter) More...
 
QString subType ()
 Return current subtype (filter) More...
 
QStringList activeServiceNames () const
 Return current list of active service names. More...
 
int serviceNameToId (const QString &name)
 Return the id for a service by its service name. More...
 
bool isBrowsing () const
 Return the status of the browsing. More...
 
- Public Member Functions inherited from ArnZeroConfB
 ArnZeroConfB (QObject *parent=arnNullptr)
 
virtual ~ArnZeroConfB ()
 
QAbstractSocket::SocketType socketType () const
 Returns the socket type for this Zero Config. More...
 
void setSocketType (QAbstractSocket::SocketType type)
 Sets the socket type for this Zero Config. More...
 
QString serviceType () const
 Returns the service type for this Zero Config. More...
 
void setServiceType (const QString &type)
 Returns the service type for this Zero Config. More...
 
QString domain () const
 Returns the domain for this Zero Config. More...
 
void setDomain (const QString &domain)
 Sets the domain for this Zero Config. More...
 
ArnZeroConf::State state () const
 Returns the current state of the service. More...
 
QString fullServiceType () const
 Returns the full service type for this Zero Config. More...
 

Static Public Member Functions

static int getNextId ()
 Return the next id number for zero config objects. More...
 

Friends

class ArnZeroConfIntern
 

Detailed Description

Browsing for ZeroConfig services.

About Zero Config

This class handles browsing of ZeroConfig services.

Example usage

// In class declare
ArnZeroConfBrowser* _serviceBrowser;
// In class code
_serviceBrowser = new ArnZeroConfBrowser( this);
connect(_serviceBrowser, SIGNAL(browseError(int)),
this, SLOT(onBrowseError(int)));
connect(_serviceBrowser, SIGNAL(serviceAdded(int,QString,QString)),
this, SLOT(onServiceAdded(int,QString,QString)));
connect(_serviceBrowser, SIGNAL(serviceRemoved(int,QString,QString)),
this, SLOT(onServiceRemoved(int,QString,QString)));
void XXX::onServiceAdded( int id, QString name, QString domain)
{
ArnZeroConfResolve* ds = new ArnZeroConfResolve( name, this);
ds->setId( id);
connect( ds, SIGNAL(resolveError(int,int)), this, SLOT(onResolveError(int,int)));
connect( ds, SIGNAL(resolved(int,QByteArray)), this, SLOT(onResolved(int,QByteArray)));
ds->resolve();
}
void XXX::onServiceRemoved( int id, QString name, QString domain)
{
}

Definition at line 936 of file ArnZeroConf.hpp.

Constructor & Destructor Documentation

◆ ArnZeroConfBrowser() [1/2]

ArnZeroConfBrowser::ArnZeroConfBrowser ( QObject *  parent = arnNullptr)

Standard constructor of an ArnZeroConfBrowser object.

All needed for browsing an "arn" service type.

Parameters
[in]parent

Definition at line 897 of file ArnZeroConf.cpp.

◆ ArnZeroConfBrowser() [2/2]

ArnZeroConfBrowser::ArnZeroConfBrowser ( const QString &  serviceType,
QObject *  parent = arnNullptr 
)

Constructor of an ArnZeroConfBrowser object.

All needed parameters for browsing a service.

The service type can be a name or the standard format used by the Zeroconf specification, e.g. "_arn._tcp".

Parameters
[in]serviceTypethe service type, e.g. "arn" or "_arn._tcp".
[in]parent

Definition at line 904 of file ArnZeroConf.cpp.

◆ ~ArnZeroConfBrowser()

ArnZeroConfBrowser::~ArnZeroConfBrowser ( )
virtual

Destructor of an ArnZeroConfBrowser object.

If browsing is active, it will be stopped.

Definition at line 912 of file ArnZeroConf.cpp.

Member Function Documentation

◆ activeServiceNames()

QStringList ArnZeroConfBrowser::activeServiceNames ( ) const

Return current list of active service names.

Return values
theactive service names
See also
serviceAdded()

Definition at line 922 of file ArnZeroConf.cpp.

◆ browse

void ArnZeroConfBrowser::browse ( bool  enable = true)
slot

Change state of browsing.

When browsing is started, services will be discovered.

Parameters
[in]enableif true browsing is started, otherwise it is stopped
See also
stopBrowse()

Definition at line 954 of file ArnZeroConf.cpp.

◆ browseError

void ArnZeroConfBrowser::browseError ( int  errorCode)
signal

Indicate unsuccessfull browsing.

Parameters
[in]errorCode
See also
browse()

◆ getNextId()

static int ArnZeroConfBrowser::getNextId ( )
inlinestatic

Return the next id number for zero config objects.

Returns
id number

Definition at line 1002 of file ArnZeroConf.hpp.

◆ isBrowsing()

bool ArnZeroConfBrowser::isBrowsing ( ) const

Return the status of the browsing.

Return values
trueif browsing is started
See also
browse()

Definition at line 934 of file ArnZeroConf.cpp.

◆ serviceAdded

void ArnZeroConfBrowser::serviceAdded ( int  id,
const QString &  serviceName,
const QString &  domain 
)
signal

Indicate service has been added (discovered)

id will not be reused for any other service, it is unique within this program.

Parameters
[in]idis the id number for the service
[in]serviceNamee.g. "My House Registry"
[in]domaine.g. "local."
See also
serviceRemoved()
serviceChanged()

◆ serviceChanged

void ArnZeroConfBrowser::serviceChanged ( bool  isAdded,
int  id,
const QString &  serviceName,
const QString &  domain 
)
signal

Indicate service has been added / removed.

id will not be reused for any other service, it is unique within this program.

Parameters
[in]isAddedis true when service has been added, otherwise false
[in]idis the id number for the service
[in]serviceNamee.g. "My House Registry"
[in]domaine.g. "local."
See also
serviceAdded()
serviceRemoved()
browse()

◆ serviceNameToId()

int ArnZeroConfBrowser::serviceNameToId ( const QString &  name)

Return the id for a service by its service name.

Parameters
[in]namethe service name, e.g. "My House Registry"
Returns
the id for the service
See also
serviceAdded()

Definition at line 928 of file ArnZeroConf.cpp.

◆ serviceRemoved

void ArnZeroConfBrowser::serviceRemoved ( int  id,
const QString &  serviceName,
const QString &  domain 
)
signal

Indicate service has been removed.

Parameters
[in]idis the id number for the service
[in]serviceNamee.g. "My House Registry"
[in]domaine.g. "local."
See also
serviceAdded()
serviceChanged()

◆ setSubType()

void ArnZeroConfBrowser::setSubType ( const QString &  subtype)

Set subtype (filter)

If passing empy subtype, this is taken as subtype (filter) disabled. When subtype (filter) is enabled, only services that have the same subtype is discovered.

Parameters
[in]subtypethe filter, e.g. "myGroup1"
See also
subType()
browse()
ArnZeroConfRegister::setSubTypes()

Definition at line 940 of file ArnZeroConf.cpp.

◆ stopBrowse

void ArnZeroConfBrowser::stopBrowse ( )
slot

Stop browsing.

See also
browse()

Definition at line 988 of file ArnZeroConf.cpp.

◆ subType()

QString ArnZeroConfBrowser::subType ( )

Return current subtype (filter)

Empy subtype, is taken as subtype (filter) disabled.

Returns
subtype, e.g. "myGroup1"
See also
setSubType()

Definition at line 946 of file ArnZeroConf.cpp.

Friends And Related Function Documentation

◆ ArnZeroConfIntern

friend class ArnZeroConfIntern
friend

Definition at line 938 of file ArnZeroConf.hpp.


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