diff options
| author | Remko Tronçon <git@el-tramo.be> | 2009-12-03 20:42:48 (GMT) |
|---|---|---|
| committer | Remko Tronçon <git@el-tramo.be> | 2009-12-03 20:42:48 (GMT) |
| commit | 09308b9a81ddb960c45fc38e3bdf9d45cd1713f7 (patch) | |
| tree | c984551890b4db8a90d384bda3794de25143bd15 | |
| parent | a70afd502466e229e3f0d5dec08b5458ad52cbac (diff) | |
| download | swift-09308b9a81ddb960c45fc38e3bdf9d45cd1713f7.zip swift-09308b9a81ddb960c45fc38e3bdf9d45cd1713f7.tar.bz2 | |
Fixed windows compilation of PlatformDomainNameServiceQuery.
| -rw-r--r-- | Swiften/Network/PlatformDomainNameServiceQuery.cpp | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/Swiften/Network/PlatformDomainNameServiceQuery.cpp b/Swiften/Network/PlatformDomainNameServiceQuery.cpp index bc2138d..13f5fc8 100644 --- a/Swiften/Network/PlatformDomainNameServiceQuery.cpp +++ b/Swiften/Network/PlatformDomainNameServiceQuery.cpp @@ -19,106 +19,106 @@ #include "Swiften/Base/ByteArray.h" #include "Swiften/EventLoop/MainEventLoop.h" #include "Swiften/Base/foreach.h" using namespace Swift; namespace { struct SRVRecordPriorityComparator { bool operator()(const DomainNameServiceQuery::Result& a, const DomainNameServiceQuery::Result& b) const { return a.priority < b.priority; } }; } namespace Swift { PlatformDomainNameServiceQuery::PlatformDomainNameServiceQuery(const String& service) : thread(NULL), service(service), safeToJoin(true) { } PlatformDomainNameServiceQuery::~PlatformDomainNameServiceQuery() { if (safeToJoin) { thread->join(); } else { // FIXME: UGLYYYYY } delete thread; } void PlatformDomainNameServiceQuery::run() { safeToJoin = false; thread = new boost::thread(boost::bind(&PlatformDomainNameServiceQuery::doRun, shared_from_this())); } void PlatformDomainNameServiceQuery::doRun() { std::vector<DomainNameServiceQuery::Result> records; #if defined(SWIFTEN_PLATFORM_WINDOWS) DNS_RECORD* responses; // FIXME: This conversion doesn't work if unicode is deffed above if (DnsQuery(service.getUTF8Data(), DNS_TYPE_SRV, DNS_QUERY_STANDARD, NULL, &responses, NULL) != ERROR_SUCCESS) { emitError(); return; } DNS_RECORD* currentEntry = responses; while (currentEntry) { if (currentEntry->wType == DNS_TYPE_SRV) { - SRVRecord record; + DomainNameServiceQuery::Result record; record.priority = currentEntry->Data.SRV.wPriority; record.weight = currentEntry->Data.SRV.wWeight; record.port = currentEntry->Data.SRV.wPort; // The pNameTarget is actually a PCWSTR, so I would have expected this // conversion to not work at all, but it does. // Actually, it doesn't. Fix this and remove explicit cast // Remove unicode undef above as well - record.hostname = std::string((const char*) currentEntry->Data.SRV.pNameTarget); + record.hostname = String((const char*) currentEntry->Data.SRV.pNameTarget); records.push_back(record); } currentEntry = currentEntry->pNext; } DnsRecordListFree(responses, DnsFreeRecordList); #else std::cout << "SRV: Querying " << service << std::endl; ByteArray response; response.resize(NS_PACKETSZ); int responseLength = res_query(const_cast<char*>(service.getUTF8Data()), ns_c_in, ns_t_srv, reinterpret_cast<u_char*>(response.getData()), response.getSize()); std::cout << "res_query done " << (responseLength != -1) << std::endl; if (responseLength == -1) { emitError(); return; } // Parse header HEADER* header = reinterpret_cast<HEADER*>(response.getData()); unsigned char* messageStart = reinterpret_cast<unsigned char*>(response.getData()); unsigned char* messageEnd = messageStart + responseLength; unsigned char* currentEntry = messageStart + NS_HFIXEDSZ; // Skip over the queries int queriesCount = ntohs(header->qdcount); while (queriesCount > 0) { int entryLength = dn_skipname(currentEntry, messageEnd); if (entryLength < 0) { emitError(); return; } currentEntry += entryLength + NS_QFIXEDSZ; queriesCount--; } // Process the SRV answers int answersCount = ntohs(header->ancount); while (answersCount > 0) { DomainNameServiceQuery::Result record; int entryLength = dn_skipname(currentEntry, messageEnd); currentEntry += entryLength; currentEntry += NS_RRFIXEDSZ; // Priority if (currentEntry + 2 >= messageEnd) { emitError(); |
Swift