ArnLib  4.0.x
Active Registry Network
ArnZeroConfRegister Class Reference

Registering a ZeroConfig service. More...

#include <ArnZeroConf.hpp>

Inheritance diagram for ArnZeroConfRegister:
Collaboration diagram for ArnZeroConfRegister:

Signals

void registered (const QString &serviceName)
 Indicate successfull registration of service. More...
 
void registrationError (int code)
 Indicate unsuccessfull registration of service. More...
 

Public Member Functions

 ArnZeroConfRegister (QObject *parent=arnNullptr)
 Standard constructor of an ArnZeroConfRegister object. More...
 
 ArnZeroConfRegister (const QString &serviceName, QObject *parent=arnNullptr)
 Constructor of an ArnZeroConfRegister object. More...
 
 ArnZeroConfRegister (const QString &serviceName, const QString &serviceType, quint16 port, QObject *parent=arnNullptr)
 Constructor of an ArnZeroConfRegister object. More...
 
virtual ~ArnZeroConfRegister ()
 Destructor of an ArnZeroConfRegister object. More...
 
QStringList subTypes () const
 Returns the list of current subtypes. More...
 
void setSubTypes (const QStringList &subtypes)
 Sets the list of current subtypes. More...
 
void addSubType (const QString &subtype)
 Add a subtype to the list of current subtypes. More...
 
quint16 port () const
 Returns the port number for connecting to the service. More...
 
void setPort (quint16 port)
 Sets the port number for connecting to the service. More...
 
QString serviceName () const
 Returns the service name for this Zero Config. More...
 
QString currentServiceName () const
 Returns the current service name for this Zero Config. More...
 
void setServiceName (const QString &name)
 Set the service name for this Zero Config. More...
 
QString host () const
 Returns the host name for this Zero Config. More...
 
void setHost (const QString &host)
 Set the host name for this Zero Config. More...
 
bool getTxtRecordMap (Arn::XStringMap &xsm)
 Load a XStringMap with parameters from the Txt Record. More...
 
void setTxtRecordMap (const Arn::XStringMap &xsm)
 Save a XStringMap with parameters to the Txt Record. More...
 
QByteArray txtRecord () const
 Return the Txt Record for this Zero Config. More...
 
void setTxtRecord (const QByteArray &txt)
 Set the Txt Record for this Zero Config. More...
 
void registerService (bool noAutoRename=false)
 Register the service. More...
 
void releaseService ()
 Release the service. 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...
 

Friends

class ArnZeroConfIntern
 

Detailed Description

Registering a ZeroConfig service.

About Zero Config

This class handles registration of a ZeroConfig service. The service name can be any string, giving a clear human readable naming of the service. If the given service name is already in use, it will have a number added to make it unique. A given TXT record can be registered together with the service.

Example usage

// In class declare
ArnZeroConfRegister* _advertService;
// In class code
_advertService = new ArnZeroConfRegister("My TestService. In the attic", this);
_advertService->addSubType("server");
xsmPar.add("ver", "1.0").add("server", "1");
_advertService->setTxtRecordMap( xsmPar);
connect(_advertService, SIGNAL(registered()), this, SLOT(onRegistered()));
connect(_advertService, SIGNAL(registrationError(int)),
this, SLOT(onRegisterError(int)));
_advertService->registerService();

Definition at line 366 of file ArnZeroConf.hpp.

Constructor & Destructor Documentation

◆ ArnZeroConfRegister() [1/3]

ArnZeroConfRegister::ArnZeroConfRegister ( QObject *  parent = arnNullptr)

Standard constructor of an ArnZeroConfRegister object.

The service name can be automatically generated based on the system's hostname.

Parameters
[in]parent

Definition at line 375 of file ArnZeroConf.cpp.

◆ ArnZeroConfRegister() [2/3]

ArnZeroConfRegister::ArnZeroConfRegister ( const QString &  serviceName,
QObject *  parent = arnNullptr 
)

Constructor of an ArnZeroConfRegister object.

All needed parameters for an "arn" service type, using standard arn-port at this computer.

Parameters
[in]serviceNamethe human readable naming of the service, e.g. "My fantastic service".
[in]parent

Definition at line 382 of file ArnZeroConf.cpp.

◆ ArnZeroConfRegister() [3/3]

ArnZeroConfRegister::ArnZeroConfRegister ( const QString &  serviceName,
const QString &  serviceType,
quint16  port,
QObject *  parent = arnNullptr 
)

Constructor of an ArnZeroConfRegister object.

All needed parameters for a service at this computer.

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

Parameters
[in]serviceNamethe human readable naming of the service, e.g. "My fantastic service".
[in]serviceTypethe service type, e.g. "arn" or "_arn._tcp".
[in]portthe service port num
[in]parent

Definition at line 391 of file ArnZeroConf.cpp.

◆ ~ArnZeroConfRegister()

ArnZeroConfRegister::~ArnZeroConfRegister ( )
virtual

Destructor of an ArnZeroConfRegister object.

If the service is registered, it will be unregistered.

Definition at line 403 of file ArnZeroConf.cpp.

Member Function Documentation

◆ addSubType()

void ArnZeroConfRegister::addSubType ( const QString &  subtype)
inline

Add a subtype to the list of current subtypes.

Parameters
[in]subtypethe subtype to add, e.g. "myGroup1"
See also
subTypes()
setSubTypes()

Definition at line 427 of file ArnZeroConf.hpp.

◆ currentServiceName()

QString ArnZeroConfRegister::currentServiceName ( ) const

Returns the current service name for this Zero Config.

At first, the requested service name is returned. Later the service name is internally updated with real name when registered() signal is emitted.

Returns
current service name, e.g. "My House Registry (2)"
See also
setServiceName()
serviceName()
registered()

Definition at line 414 of file ArnZeroConf.cpp.

◆ getTxtRecordMap()

bool ArnZeroConfRegister::getTxtRecordMap ( Arn::XStringMap xsm)
inline

Load a XStringMap with parameters from the Txt Record.

It is assumed that the Txt Record has already been received.

After loading XStringMap is successfull it contains the parameters from the Txt Record, e.g. Arn::XStringMap::toXString() can return "protovers=1.0 MyParam=xyz".

Parameters
[out]xsmis the loaded XStringMap if successfull, otherwise undefined.
Return values
trueif successfull.
See also
setTxtRecordMap()
Arn::XStringMap

Definition at line 509 of file ArnZeroConf.hpp.

◆ host()

QString ArnZeroConfRegister::host ( ) const
inline

Returns the host name for this Zero Config.

Usually hostname is empty, automatically using the computers name, but it can also be like "myserver".

Returns
current host name (se above)
See also
setHost()

Definition at line 487 of file ArnZeroConf.hpp.

◆ port()

quint16 ArnZeroConfRegister::port ( ) const
inline

Returns the port number for connecting to the service.

Return values
theport number
See also
setPort()

Definition at line 434 of file ArnZeroConf.hpp.

◆ registered

void ArnZeroConfRegister::registered ( const QString &  serviceName)
signal

Indicate successfull registration of service.

The service name will also be internally updated, it can be accesed via currentServiceName().

Parameters
[in]serviceNameis the realy registered name e.g. "My House Registry (2)"
See also
registerService()
setServiceName()
serviceName()

◆ registerService()

void ArnZeroConfRegister::registerService ( bool  noAutoRename = false)

Register the service.

Tries to register the service on the local network.

Result is indicated by registered() and registrationError() signals.

Parameters
[in]noAutoRenamewhen true, registration will fail if another service with the same service type already is registered with the same service name.
See also
registered()
registrationError()

Definition at line 427 of file ArnZeroConf.cpp.

◆ registrationError

void ArnZeroConfRegister::registrationError ( int  code)
signal

Indicate unsuccessfull registration of service.

Parameters
[in]codeerror code.
See also
registerService()

◆ releaseService()

void ArnZeroConfRegister::releaseService ( )

Release the service.

If the service is registered, it will be unregistered. Any registration attempts in progress will be aborted.

Definition at line 472 of file ArnZeroConf.cpp.

◆ serviceName()

QString ArnZeroConfRegister::serviceName ( ) const
inline

Returns the service name for this Zero Config.

The returned service name is always the requested name. For real name use currentServiceName().

Returns
current service name, e.g. "My House Registry"
See also
setServiceName()
currentServiceName()
registered()

Definition at line 454 of file ArnZeroConf.hpp.

◆ setHost()

void ArnZeroConfRegister::setHost ( const QString &  host)
inline

Set the host name for this Zero Config.

Usually hostname is empty, automatically using the computers name, but it can also be like "myserver".

Parameters
[in]hostis the current host name (se above)
See also
host()

Definition at line 496 of file ArnZeroConf.hpp.

◆ setPort()

void ArnZeroConfRegister::setPort ( quint16  port)
inline

Sets the port number for connecting to the service.

When registering a service with a port number of 0, the service will not be found when browsing, but the service name will be marked as reserved.

Parameters
[in]portthe port number
See also
port()

Definition at line 443 of file ArnZeroConf.hpp.

◆ setServiceName()

void ArnZeroConfRegister::setServiceName ( const QString &  name)

Set the service name for this Zero Config.

Service names can be any human readable id. It should be easy to understand, without any cryptic coding, and can usually be modified by the end user.

The requested service name is not guaranted to be registered, as it has to be unique within the local network. The realy used name comes with the registered() signal and can be accessed via currentServiceName().

Parameters
[in]nameis service name, e.g. "My House Registry"
See also
serviceName()
currentServiceName()
registered()

Definition at line 420 of file ArnZeroConf.cpp.

◆ setSubTypes()

void ArnZeroConfRegister::setSubTypes ( const QStringList &  subtypes)
inline

Sets the list of current subtypes.

Parameters
[in]subtypesThe new list of subtypes, e.g. ("myGroup1", "myGroup2")
See also
subTypes()
addSubType()
ArnZeroConfBrowser::setSubType()

Definition at line 419 of file ArnZeroConf.hpp.

◆ setTxtRecord()

void ArnZeroConfRegister::setTxtRecord ( const QByteArray &  txt)
inline

Set the Txt Record for this Zero Config.

The binary format should be the standardized from the Zeroconfig specification. This Txt Record will typically be used later for publishing in zero config.

Parameters
[in]txtis The Txt Record (in binary format)
See also
txtRecord()
setTxtRecordMap()

Definition at line 540 of file ArnZeroConf.hpp.

◆ setTxtRecordMap()

void ArnZeroConfRegister::setTxtRecordMap ( const Arn::XStringMap xsm)
inline

Save a XStringMap with parameters to the Txt Record.

The XStringMap contains the parameters to be saved into the Txt Record. This Txt Record will typically be used later for publishing in zero config.

Parameters
[in]xsmis the XStringMap to be saved into the Txt Record.
See also
getTxtRecordMap()
Arn::XStringMap

Definition at line 519 of file ArnZeroConf.hpp.

◆ subTypes()

QStringList ArnZeroConfRegister::subTypes ( ) const
inline

Returns the list of current subtypes.

Return values
thesubtype list, e.g. ("myGroup1", "myGroup2")
See also
setSubTypes()
addSubType()

Definition at line 410 of file ArnZeroConf.hpp.

◆ txtRecord()

QByteArray ArnZeroConfRegister::txtRecord ( ) const
inline

Return the Txt Record for this Zero Config.

It is assumed that the Txt Record has already been received.

The binary format should be the standardized from the Zeroconfig specification.

Returns
The Txt Record (in binary format)
See also
setTxtRecord()
getTxtRecordMap()

Definition at line 530 of file ArnZeroConf.hpp.

Friends And Related Function Documentation

◆ ArnZeroConfIntern

friend class ArnZeroConfIntern
friend

Definition at line 368 of file ArnZeroConf.hpp.


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