コード例 #1
0
bool PublicService::publish()
{
    publishAsync();
    while(d->isRunning() && !d->m_published)
        d->process();
    return d->m_published;
}
コード例 #2
0
void PublicService::setType(const QString &type)
{
    m_type = type;
    if(d->isRunning())
    {
        stop();
        publishAsync();
    }
}
コード例 #3
0
void PublicService::setDomain(const QString &domain)
{
    m_domain = domain;
    if(d->isRunning())
    {
        stop();
        publishAsync();
    }
}
コード例 #4
0
void PublicService::setServiceName(const QString &serviceName)
{
    m_serviceName = serviceName;
    if(d->isRunning())
    {
        stop();
        publishAsync();
    }
}
コード例 #5
0
void PublicService::setTextData(const QMap< QString, QString > &textData)
{
    m_textData = textData;
    if(d->isRunning())
    {
        stop();
        publishAsync();
    }
}
コード例 #6
0
void PublicService::setPort(unsigned short port)
{
    m_port = port;
    if(d->isRunning())
    {
        stop();
        publishAsync();
    }
}
コード例 #7
0
void PublicService::setSubTypes(const QStringList& subtypes)
{
	K_D;
	d->m_subtypes = subtypes;
	if (d->isRunning()) {
		stop();
		publishAsync();
	}
}
コード例 #8
0
ファイル: serverthread.cpp プロジェクト: Rambo2015/Drawpile
int ServerThread::startServer(const QString &title)
{
	_startmutex.lock();

	start();

	_starter.wait(&_startmutex);
	_startmutex.unlock();

#ifdef HAVE_DNSSD
	// Publish this server via DNS-SD.
	// Note: this code runs in the main thread
	if(_port>0) {
		QSettings cfg;
		if(cfg.value("settings/server/dnssd", true).toBool()) {
			qDebug("Announcing server (port %d) via DNSSD", _port);
			auto dnssd = new KDNSSD::PublicService(
				QString(),
				"_drawpile._tcp",
				_port,
				"local"
			);
			dnssd->setParent(this);

			QMap<QString,QByteArray> txt;
			txt["protocol"] = QStringLiteral(DRAWPILE_PROTO_STR).toUtf8();
			txt["started"] = QDateTime::currentDateTimeUtc().toString(Qt::ISODate).toUtf8();
			txt["title"] = title.toUtf8();

			dnssd->setTextData(txt);
			dnssd->publishAsync();
		}
	}
#endif

#ifdef HAVE_UPNP
	if(_port>0) {
		QSettings cfg;
		if(cfg.value("settings/server/upnp", true).toBool()) {
			QString myIp = WhatIsMyIp::localAddress();
			if(WhatIsMyIp::isMyPrivateAddress(myIp)) {
				qDebug() << "UPnP enabled: trying to forward" << _port << "to" << myIp;
				UPnPClient::instance()->activateForward(_port);
				_portForwarded = true;
			}
		}
	}
#endif
	return _port;
}