33 #include "private/ArnDiscoverRemote_p.hpp"    39 #include <QMetaObject>    41 #include <QNetworkInterface>    47 ArnDiscoverRemotePrivate::ArnDiscoverRemotePrivate()
    49     _servTimer             = 
new QTimer;
    50     _arnInternalServer     = arnNullptr;
    51     _arnDResolver          = arnNullptr;
    52     _defaultService        = 
"Arn Default Service";
    53     _initialServiceTimeout = 0;
    57 ArnDiscoverRemotePrivate::~ArnDiscoverRemotePrivate()
    83     QString  listenAddr = ((addr == QHostAddress::Any) || (addr == QHostAddress::AnyIPv6))
    84                           ? QString(
"Any") : addr.toString();
    85     int  hostPort = arnServer->
port();
    92     QStringList  hostIpList;
    94     foreach (QNetworkInterface  interface, QNetworkInterface::allInterfaces()) {
    95         QNetworkInterface::InterfaceFlags  flags = interface.flags();
    96         if (!flags.testFlag( QNetworkInterface::IsUp)
    97         || flags.testFlag( QNetworkInterface::IsPointToPoint)
    98         || flags.testFlag( QNetworkInterface::IsLoopBack))
   101         foreach (QNetworkAddressEntry  entry, interface.addressEntries()) {
   102             QAbstractSocket::NetworkLayerProtocol  prot = entry.ip().protocol();
   103             if ((prot != QAbstractSocket::IPv4Protocol) && (prot != QAbstractSocket::IPv6Protocol))
   107             QString  addr    = entry.ip().toString();
   108             QString  mask    = entry.netmask().toString();
   109             QString  sysName = interface.humanReadableName();
   115             if (prot == QAbstractSocket::IPv4Protocol) {
   123     ArnDiscoverAdvertise::setHostIpList( hostIpList);
   132     if (!d->_arnInternalServer)
   133         delete d->_arnInternalServer;
   135     d->_arnInternalServer->start( port);
   151 void  ArnDiscoverRemote::postSetupThis()
   155     d->_servTimer->start( d->_initialServiceTimeout * 1000);  
   156     connect( d->_servTimer, SIGNAL(timeout()), 
this, SLOT(serviceTimeout()));
   158     connect( &d->_arnService,   SIGNAL(changed(QString)), 
this, SLOT(firstServiceSetup(QString)));
   159     connect( &d->_arnServicePv, SIGNAL(changed(QString)), 
this, SLOT(firstServiceSetup(QString)));
   163     d->_arnService.open( servicePath);
   166     ArnDiscoverAdvertise::postSetupThis();
   170 void  ArnDiscoverRemote::serviceTimeout()
   176     firstServiceSetup( d->_defaultService, 
true);
   180 void  ArnDiscoverRemote::firstServiceSetup( 
const QString& serviceName, 
bool forceSetup)
   184     QString  useService = 
service();  
   185     if (useService.isEmpty())
   186         useService = serviceName;
   188                                       << 
" useService=" << useService << 
" forceSetup=" << forceSetup;
   190     if (!forceSetup && useService.isEmpty())  
return;  
   192     d->_servTimer->stop();
   193     disconnect( &d->_arnService,   SIGNAL(changed(QString)), 
this, SLOT(firstServiceSetup(QString)));
   194     disconnect( &d->_arnServicePv, SIGNAL(changed(QString)), 
this, SLOT(firstServiceSetup(QString)));
   195     connect( &d->_arnServicePv, SIGNAL(changed(QString)), 
this, SLOT(doServiceChanged(QString)));
   201 void  ArnDiscoverRemote::doServiceChanged( 
const QString& val)
   205     if (
Arn::debugDiscover)  qDebug() << 
"DiscoverRemote Service changed: servname=" << val;
   206     d->_arnServicePv = val;
   211 void  ArnDiscoverRemote::serviceRegistered( 
const QString& serviceName)
   213     if (
Arn::debugDiscover)  qDebug() << 
"DiscoverRemote Service registered: serviceName=" << serviceName;
   217     ArnDiscoverAdvertise::serviceRegistered( serviceName);
   227     if (hasSetupAdvertise()) {
   242     return d->_defaultService;
   259     return d->_initialServiceTimeout;
 const QString pathDiscover
 
static void setValue(const QString &path, int value)
Assign an integer to an Arn Data Object at path 
 
QString defaultService() const
Return the default service name. 
 
void advertiseService(ArnDiscover::Type discoverType, const QString &serviceName, int port=-1, const QString &hostName=QString())
Start advertising the service. 
 
void clientReadyToConnect(ArnClient *arnClient, const QString &id)
Central signal for external client connection. 
 
const QString resourceArnRoot
 
Class for making an Arn Server. 
 
void setInitialServiceTimeout(int initialServiceTimeout)
Set the time for initial timeout processing. 
 
Advertise an Arn service. 
 
Assigning same value generates an update of the Arn Data Object 
 
static bool loadFromDirRoot(const QString &path, const QDir &dirRoot, Arn::Coding coding)
Load relative a directory root to an Arn Data Object at path 
 
int initialServiceTimeout() const
Return the time for initial timeout processing. 
 
QString service() const
Returns the requested service name for this Advertise. 
 
void startUseNewServer(ArnDiscover::Type discoverType, int port=-1)
Start a new ArnServer and advertise as a service. 
 
Text coding, can be any character set. 
 
Types of Arn discover advertise. 
 
ArnDiscoverRemote(QObject *parent=arnNullptr)
 
Class for connecting to an Arn Server. 
 
An automatic client discover connector. 
 
void startUseServer(ArnServer *arnServer, ArnDiscover::Type discoverType=ArnDiscover::Type::Server)
Start advertising the ArnServer as a service. 
 
QString twinPath(const QString &path)
Get the bidirectional twin to a given path 
 
QHostAddress listenAddress()
Address of the interface used to listening for connections to the Arn server 
 
virtual void setService(const QString &service)
Set the service name. 
 
const QString pathDiscoverThis
 
ArnDiscoverConnector * newConnector(ArnClient &client, const QString &id)
Create and return an ArnDiscoverConnector for handling remote client. 
 
int port()
Port number of the Arn server 
 
Discover with remote setting. 
 
State state() const
Returns the state for this Advertise. 
 
Assigning same value is ignored. 
 
isAny(): Startup advertising in progress or has finished sucessfully. 
 
Data is persistent and will be saved. 
 
void setDefaultService(const QString &defaultService)
Set the default service name. 
 
virtual void setService(const QString &service)
Set the service name.