mirror of
https://github.com/hyperion-project/hyperion.ng.git
synced 2025-03-01 10:33:28 +00:00
Logging migration continues ... (#97)
* migrate logging for blackborder and bonjour. fix logging bug in hyperion * fix kodichecker when kodi is not there
This commit is contained in:
@@ -31,6 +31,8 @@ ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
#include <QtCore/QSocketNotifier>
|
||||
|
||||
#include <utils/Logger.h>
|
||||
|
||||
BonjourServiceRegister::BonjourServiceRegister(QObject *parent)
|
||||
: QObject(parent), dnssref(0), bonjourSocket(0)
|
||||
{
|
||||
@@ -39,49 +41,56 @@ BonjourServiceRegister::BonjourServiceRegister(QObject *parent)
|
||||
|
||||
BonjourServiceRegister::~BonjourServiceRegister()
|
||||
{
|
||||
if (dnssref) {
|
||||
DNSServiceRefDeallocate(dnssref);
|
||||
dnssref = 0;
|
||||
}
|
||||
if (dnssref)
|
||||
{
|
||||
DNSServiceRefDeallocate(dnssref);
|
||||
dnssref = 0;
|
||||
}
|
||||
}
|
||||
|
||||
void BonjourServiceRegister::registerService(const BonjourRecord &record, quint16 servicePort)
|
||||
{
|
||||
if (dnssref) {
|
||||
qWarning("Warning: Already registered a service for this object, aborting new register");
|
||||
return;
|
||||
}
|
||||
quint16 bigEndianPort = servicePort;
|
||||
if (dnssref)
|
||||
{
|
||||
Warning(Logger::getInstance("BonJour"), "Already registered a service for this object, aborting new register");
|
||||
return;
|
||||
}
|
||||
quint16 bigEndianPort = servicePort;
|
||||
#if Q_BYTE_ORDER == Q_LITTLE_ENDIAN
|
||||
{
|
||||
bigEndianPort = 0 | ((servicePort & 0x00ff) << 8) | ((servicePort & 0xff00) >> 8);
|
||||
}
|
||||
{
|
||||
bigEndianPort = 0 | ((servicePort & 0x00ff) << 8) | ((servicePort & 0xff00) >> 8);
|
||||
}
|
||||
#endif
|
||||
|
||||
DNSServiceErrorType err = DNSServiceRegister(&dnssref, 0, 0, record.serviceName.toUtf8().constData(),
|
||||
record.registeredType.toUtf8().constData(),
|
||||
record.replyDomain.isEmpty() ? 0
|
||||
: record.replyDomain.toUtf8().constData(), 0,
|
||||
bigEndianPort, 0, 0, bonjourRegisterService, this);
|
||||
if (err != kDNSServiceErr_NoError) {
|
||||
emit error(err);
|
||||
} else {
|
||||
int sockfd = DNSServiceRefSockFD(dnssref);
|
||||
if (sockfd == -1) {
|
||||
emit error(kDNSServiceErr_Invalid);
|
||||
} else {
|
||||
bonjourSocket = new QSocketNotifier(sockfd, QSocketNotifier::Read, this);
|
||||
connect(bonjourSocket, SIGNAL(activated(int)), this, SLOT(bonjourSocketReadyRead()));
|
||||
}
|
||||
}
|
||||
DNSServiceErrorType err = DNSServiceRegister(&dnssref, 0, 0, record.serviceName.toUtf8().constData(),
|
||||
record.registeredType.toUtf8().constData(),
|
||||
(record.replyDomain.isEmpty() ? 0 : record.replyDomain.toUtf8().constData()),
|
||||
0, bigEndianPort, 0, 0, bonjourRegisterService, this);
|
||||
if (err != kDNSServiceErr_NoError)
|
||||
{
|
||||
emit error(err);
|
||||
}
|
||||
else
|
||||
{
|
||||
int sockfd = DNSServiceRefSockFD(dnssref);
|
||||
if (sockfd == -1)
|
||||
{
|
||||
emit error(kDNSServiceErr_Invalid);
|
||||
}
|
||||
else
|
||||
{
|
||||
bonjourSocket = new QSocketNotifier(sockfd, QSocketNotifier::Read, this);
|
||||
connect(bonjourSocket, SIGNAL(activated(int)), this, SLOT(bonjourSocketReadyRead()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void BonjourServiceRegister::bonjourSocketReadyRead()
|
||||
{
|
||||
DNSServiceErrorType err = DNSServiceProcessResult(dnssref);
|
||||
if (err != kDNSServiceErr_NoError)
|
||||
emit error(err);
|
||||
DNSServiceErrorType err = DNSServiceProcessResult(dnssref);
|
||||
if (err != kDNSServiceErr_NoError)
|
||||
emit error(err);
|
||||
}
|
||||
|
||||
|
||||
@@ -90,13 +99,16 @@ void BonjourServiceRegister::bonjourRegisterService(DNSServiceRef, DNSServiceFla
|
||||
const char *regtype, const char *domain,
|
||||
void *data)
|
||||
{
|
||||
BonjourServiceRegister *serviceRegister = static_cast<BonjourServiceRegister *>(data);
|
||||
if (errorCode != kDNSServiceErr_NoError) {
|
||||
emit serviceRegister->error(errorCode);
|
||||
} else {
|
||||
serviceRegister->finalRecord = BonjourRecord(QString::fromUtf8(name),
|
||||
QString::fromUtf8(regtype),
|
||||
QString::fromUtf8(domain));
|
||||
emit serviceRegister->serviceRegistered(serviceRegister->finalRecord);
|
||||
}
|
||||
BonjourServiceRegister *serviceRegister = static_cast<BonjourServiceRegister *>(data);
|
||||
if (errorCode != kDNSServiceErr_NoError)
|
||||
{
|
||||
emit serviceRegister->error(errorCode);
|
||||
}
|
||||
else
|
||||
{
|
||||
serviceRegister->finalRecord = BonjourRecord(QString::fromUtf8(name),
|
||||
QString::fromUtf8(regtype),
|
||||
QString::fromUtf8(domain));
|
||||
emit serviceRegister->serviceRegistered(serviceRegister->finalRecord);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user