From 1068c00b5672fea34235af1939a3d69f0b0ff30a Mon Sep 17 00:00:00 2001 From: "Edson W. R. Pereira" Date: Wed, 4 Sep 2013 18:55:38 +0000 Subject: [PATCH] Change DNS loopup to slot in PSK Reporter class. git-svn-id: svn+ssh://svn.code.sf.net/p/wsjt/wsjt/branches/wsjtx@3567 ab8295b8-cf94-4d9e-aec4-7959e3be5d79 --- psk_reporter.cpp | 15 +++++++++++---- psk_reporter.h | 5 +++++ 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/psk_reporter.cpp b/psk_reporter.cpp index 540d6a058..91d7bb6ae 100644 --- a/psk_reporter.cpp +++ b/psk_reporter.cpp @@ -33,6 +33,7 @@ PSK_Reporter::PSK_Reporter(QObject *parent) : m_randomId_h = QString("%1").arg(qrand(),8,16,QChar('0')); m_udpSocket = new QUdpSocket(this); + QHostInfo::lookupHost("report.pskreporter.info", this, SLOT(dnsLookupResult(QHostInfo))); reportTimer = new QTimer(this); connect(reportTimer, SIGNAL(timeout()), this, SLOT(sendReport())); @@ -45,7 +46,6 @@ void PSK_Reporter::setLocalStation(QString call, QString gridSquare, QString ant m_rxGrid = gridSquare; m_rxAnt = antenna; m_progId = programInfo; - //qDebug() << "PSK_Reporter::setLocalStation. Antenna:" << antenna; } void PSK_Reporter::addRemoteStation(QString call, QString grid, QString freq, QString mode, QString snr, QString time ) @@ -104,10 +104,17 @@ void PSK_Reporter::sendReport() report_h.replace("000Allll", "000A" + QString("%1").arg(report_h.length()/2,4,16,QChar('0'))); QByteArray report = QByteArray::fromHex(report_h.toUtf8()); - // Get IP address for pskreporter.info and send report via UDP - QHostInfo info = QHostInfo::fromName("report.pskreporter.info"); + // Send data to PSK Reporter site + if (!m_pskReporterAddress.isNull()) { + m_udpSocket->writeDatagram(report, m_pskReporterAddress, 4739); + } +} + +void PSK_Reporter::dnsLookupResult(QHostInfo info) +{ if (!info.addresses().isEmpty()) { - m_udpSocket->writeDatagram(report,info.addresses().at(0),4739); + m_pskReporterAddress = info.addresses().at(0); + qDebug() << "PSK Reporter IP: " << m_pskReporterAddress; } } diff --git a/psk_reporter.h b/psk_reporter.h index ce1b01969..46bc72756 100644 --- a/psk_reporter.h +++ b/psk_reporter.h @@ -18,6 +18,9 @@ signals: public slots: void sendReport(); +private slots: + void dnsLookupResult(QHostInfo info); + private: QString m_header_h; QString m_rxInfoDescriptor_h; @@ -30,6 +33,8 @@ private: QString m_rxAnt; QString m_progId; + QHostAddress m_pskReporterAddress; + QQueue< QHash > m_spotQueue; QUdpSocket *m_udpSocket;