diff options
author | Lars Knoll <lars.knoll@nokia.com> | 2012-03-05 10:44:04 +0100 |
---|---|---|
committer | Lars Knoll <lars.knoll@nokia.com> | 2012-03-05 10:44:48 +0100 |
commit | d51abed57a8f677a0d4eac57fd3f16bd4662190a (patch) | |
tree | b3e173db4b72edbff6cb8dcc203c3d4526a1b51b /src/network/kernel/qdnslookup_win.cpp | |
parent | 07ae18f96e87a2db40ae014f28893f1080efa7ae (diff) | |
parent | 0862d7f78af978cf513097b3bdc33cd8096dee75 (diff) |
Merge remote-tracking branch 'origin/master' into api_changes
Change-Id: Ibcb1f7070f50968b77b66112750ce5c70fc0b6d0
Diffstat (limited to 'src/network/kernel/qdnslookup_win.cpp')
-rw-r--r-- | src/network/kernel/qdnslookup_win.cpp | 38 |
1 files changed, 5 insertions, 33 deletions
diff --git a/src/network/kernel/qdnslookup_win.cpp b/src/network/kernel/qdnslookup_win.cpp index 9b2c088ee2..63f4377dfc 100644 --- a/src/network/kernel/qdnslookup_win.cpp +++ b/src/network/kernel/qdnslookup_win.cpp @@ -44,46 +44,18 @@ #include <qurl.h> #include <private/qmutexpool_p.h> -#include <private/qsystemlibrary_p.h> +#include <private/qsystemerror_p.h> #include <qt_windows.h> #include <windns.h> QT_BEGIN_NAMESPACE -typedef DNS_STATUS (*dns_query_utf8_proto)(PCSTR,WORD,DWORD,PIP4_ARRAY,PDNS_RECORD*,PVOID*); -static dns_query_utf8_proto local_dns_query_utf8 = 0; -typedef void (*dns_record_list_free_proto)(PDNS_RECORD,DNS_FREE_TYPE); -static dns_record_list_free_proto local_dns_record_list_free = 0; - -static void resolveLibrary() -{ - local_dns_query_utf8 = (dns_query_utf8_proto) QSystemLibrary::resolve(QLatin1String("dnsapi"), "DnsQuery_UTF8"); - local_dns_record_list_free = (dns_record_list_free_proto) QSystemLibrary::resolve(QLatin1String("dnsapi"), "DnsRecordListFree"); -} - void QDnsLookupRunnable::query(const int requestType, const QByteArray &requestName, QDnsLookupReply *reply) { - // Load DnsQuery_UTF8 and DnsRecordListFree on demand. - static volatile bool triedResolve = false; - if (!triedResolve) { - QMutexLocker locker(QMutexPool::globalInstanceGet(&local_dns_query_utf8)); - if (!triedResolve) { - resolveLibrary(); - triedResolve = true; - } - } - - // If DnsQuery_UTF8 or DnsRecordListFree is missing, fail. - if (!local_dns_query_utf8 || !local_dns_record_list_free) { - reply->error = QDnsLookup::ResolverError, - reply->errorString = tr("Resolver functions not found"); - return; - } - // Perform DNS query. - PDNS_RECORD dns_records; - const DNS_STATUS status = local_dns_query_utf8(requestName, requestType, DNS_QUERY_STANDARD, NULL, &dns_records, NULL); + PDNS_RECORD dns_records = 0; + const DNS_STATUS status = DnsQuery_UTF8(requestName, requestType, DNS_QUERY_STANDARD, NULL, &dns_records, NULL); switch (status) { case ERROR_SUCCESS: break; @@ -105,7 +77,7 @@ void QDnsLookupRunnable::query(const int requestType, const QByteArray &requestN return; default: reply->error = QDnsLookup::InvalidReplyError; - reply->errorString = tr("Invalid reply received"); + reply->errorString = QSystemError(status, QSystemError::NativeError).toString(); return; } @@ -172,7 +144,7 @@ void QDnsLookupRunnable::query(const int requestType, const QByteArray &requestN } } - local_dns_record_list_free(dns_records, DnsFreeRecordList); + DnsRecordListFree(dns_records, DnsFreeRecordList); } QT_END_NAMESPACE |