QDnsLookup: make the query() function non-static
Simplifies arguments and will allow me to add stateful helper methods. Change-Id: I3e3bfef633af4130a03afffd175d6044829a96f2 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
This commit is contained in:
parent
365af87f94
commit
e1c3083dad
@ -470,7 +470,7 @@ void QDnsLookup::lookup()
|
||||
Q_D(QDnsLookup);
|
||||
d->isFinished = false;
|
||||
d->reply = QDnsLookupReply();
|
||||
d->runnable = new QDnsLookupRunnable(d->type, QUrl::toAce(d->name), d->nameserver);
|
||||
d->runnable = new QDnsLookupRunnable(d);
|
||||
connect(d->runnable, &QDnsLookupRunnable::finished,
|
||||
this, [this](const QDnsLookupReply &reply) { d_func()->_q_lookupFinished(reply); },
|
||||
Qt::BlockingQueuedConnection);
|
||||
@ -965,6 +965,13 @@ void QDnsLookupPrivate::_q_lookupFinished(const QDnsLookupReply &_reply)
|
||||
}
|
||||
}
|
||||
|
||||
inline QDnsLookupRunnable::QDnsLookupRunnable(const QDnsLookupPrivate *d)
|
||||
: requestName(QUrl::toAce(d->name)),
|
||||
nameserver(d->nameserver),
|
||||
requestType(d->type)
|
||||
{
|
||||
}
|
||||
|
||||
void QDnsLookupRunnable::run()
|
||||
{
|
||||
QDnsLookupReply reply;
|
||||
@ -978,7 +985,7 @@ void QDnsLookupRunnable::run()
|
||||
}
|
||||
|
||||
// Perform request.
|
||||
query(requestType, requestName, nameserver, &reply);
|
||||
query(&reply);
|
||||
|
||||
// Sort results.
|
||||
qt_qdnsmailexchangerecord_sort(reply.mailExchangeRecords);
|
||||
|
@ -5,13 +5,9 @@
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
void QDnsLookupRunnable::query(const int requestType, const QByteArray &requestName, const QHostAddress &nameserver, QDnsLookupReply *reply)
|
||||
void QDnsLookupRunnable::query(QDnsLookupReply *reply)
|
||||
{
|
||||
Q_UNUSED(requestType);
|
||||
Q_UNUSED(requestName);
|
||||
Q_UNUSED(nameserver);
|
||||
Q_UNUSED(reply);
|
||||
qWarning("Not yet supported on Android");
|
||||
qWarning("Not yet supported on this OS");
|
||||
reply->error = QDnsLookup::ResolverError;
|
||||
reply->errorString = tr("Not yet supported on this OS");
|
||||
return;
|
||||
|
@ -102,21 +102,17 @@ class QDnsLookupRunnable : public QObject, public QRunnable
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
QDnsLookupRunnable(QDnsLookup::Type type, const QByteArray &name, const QHostAddress &nameserver)
|
||||
: requestType(type)
|
||||
, requestName(name)
|
||||
, nameserver(nameserver)
|
||||
{ }
|
||||
QDnsLookupRunnable(const QDnsLookupPrivate *d);
|
||||
void run() override;
|
||||
|
||||
signals:
|
||||
void finished(const QDnsLookupReply &reply);
|
||||
|
||||
private:
|
||||
static void query(const int requestType, const QByteArray &requestName, const QHostAddress &nameserver, QDnsLookupReply *reply);
|
||||
QDnsLookup::Type requestType;
|
||||
void query(QDnsLookupReply *reply);
|
||||
QByteArray requestName;
|
||||
QHostAddress nameserver;
|
||||
QDnsLookup::Type requestType;
|
||||
};
|
||||
|
||||
class QDnsLookupThreadPool : public QThreadPool
|
||||
|
@ -100,7 +100,7 @@ static const char *applyNameServer(res_state state, const QHostAddress &nameserv
|
||||
}
|
||||
#endif // !QT_CONFIG(res_setservers)
|
||||
|
||||
void QDnsLookupRunnable::query(const int requestType, const QByteArray &requestName, const QHostAddress &nameserver, QDnsLookupReply *reply)
|
||||
void QDnsLookupRunnable::query(QDnsLookupReply *reply)
|
||||
{
|
||||
// Initialize state.
|
||||
std::remove_pointer_t<res_state> state = {};
|
||||
|
@ -51,7 +51,7 @@ DNS_STATUS WINAPI DnsQueryEx(PDNS_QUERY_REQUEST pQueryRequest,
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
void QDnsLookupRunnable::query(const int requestType, const QByteArray &requestName, const QHostAddress &nameserver, QDnsLookupReply *reply)
|
||||
void QDnsLookupRunnable::query(QDnsLookupReply *reply)
|
||||
{
|
||||
// Perform DNS query.
|
||||
const QString requestNameUtf16 = QString::fromUtf8(requestName.data(), requestName.size());
|
||||
|
Loading…
Reference in New Issue
Block a user