| Absolute File Name: | /home/qt/qt5_coco/qt5/qtbase/src/network/kernel/qdnslookup.cpp |
| Switch to Source code | Preprocessed file |
| Line | Source | Count | ||||||
|---|---|---|---|---|---|---|---|---|
| 1 | - | |||||||
| 2 | - | |||||||
| 3 | - | |||||||
| 4 | - | |||||||
| 5 | - | |||||||
| 6 | - | |||||||
| 7 | namespace { namespace Q_QGS_theDnsLookupThreadPool { typedef QDnsLookupThreadPool Type; QBasicAtomicInt guard = { QtGlobalStatic::Uninitialized }; __attribute__((visibility("hidden"))) inline Type *innerFunction() { struct HolderBase { ~HolderBase() noexcept { if (guard.load() == QtGlobalStatic::Initialized) guard.store(QtGlobalStatic::Destroyed); } }; static struct Holder : public HolderBase { Type value; Holder() noexcept(noexcept(Type ())) : value () { guard.store(QtGlobalStatic::Initialized); } } holder; return &holder.value; } } } static QGlobalStatic<QDnsLookupThreadPool, Q_QGS_theDnsLookupThreadPool::innerFunction, Q_QGS_theDnsLookupThreadPool::guard> theDnsLookupThreadPool;; | - | ||||||
| 8 | namespace { namespace Q_QGS_theDnsLookupSeedStorage { typedef QThreadStorage<bool *> Type; QBasicAtomicInt guard = { QtGlobalStatic::Uninitialized }; __attribute__((visibility("hidden"))) inline Type *innerFunction() { struct HolderBase { ~HolderBase() noexcept { if (guard.load() == QtGlobalStatic::Initialized) guard.store(QtGlobalStatic::Destroyed); } }; static struct Holder : public HolderBase { Type value; Holder() noexcept(noexcept(Type ())) : value () { guard.store(QtGlobalStatic::Initialized); } } holder; return &holder.value; } } } static QGlobalStatic<QThreadStorage<bool *>, Q_QGS_theDnsLookupSeedStorage::innerFunction, Q_QGS_theDnsLookupSeedStorage::guard> theDnsLookupSeedStorage;; | - | ||||||
| 9 | - | |||||||
| 10 | static bool qt_qdnsmailexchangerecord_less_than(const QDnsMailExchangeRecord &r1, const QDnsMailExchangeRecord &r2) | - | ||||||
| 11 | { | - | ||||||
| 12 | - | |||||||
| 13 | return r1.preference() < r2.preference(); | - | ||||||
| 14 | } | - | ||||||
| 15 | - | |||||||
| 16 | - | |||||||
| 17 | - | |||||||
| 18 | - | |||||||
| 19 | - | |||||||
| 20 | static void qt_qdnsmailexchangerecord_sort(QList<QDnsMailExchangeRecord> &records) | - | ||||||
| 21 | { | - | ||||||
| 22 | - | |||||||
| 23 | if (records.size() <= 1
| 4-80 | ||||||
| 24 | return; executed 80 times by 2 tests: return;Executed by:
| 80 | ||||||
| 25 | - | |||||||
| 26 | - | |||||||
| 27 | std::sort(records.begin(), records.end(), qt_qdnsmailexchangerecord_less_than); | - | ||||||
| 28 | - | |||||||
| 29 | int i = 0; | - | ||||||
| 30 | while (i < records.size()
| 4-6 | ||||||
| 31 | - | |||||||
| 32 | - | |||||||
| 33 | QList<QDnsMailExchangeRecord> slice; | - | ||||||
| 34 | const quint16 slicePreference = records[.at(i].).preference(); | - | ||||||
| 35 | for (int j = i; j < records.size()
| 4-10 | ||||||
| 36 | if (records[.at(j].).preference() != slicePreference
| 2-8 | ||||||
| 37 | break; executed 2 times by 1 test: break;Executed by:
| 2 | ||||||
| 38 | slice << records[.at(j];); | - | ||||||
| 39 | } executed 8 times by 1 test: end of blockExecuted by:
| 8 | ||||||
| 40 | - | |||||||
| 41 | - | |||||||
| 42 | while (!slice.isEmpty()
| 6-8 | ||||||
| 43 | const unsigned int pos = qrand() % slice.size(); | - | ||||||
| 44 | records[i++] = slice.takeAt(pos); | - | ||||||
| 45 | } executed 8 times by 1 test: end of blockExecuted by:
| 8 | ||||||
| 46 | } executed 6 times by 1 test: end of blockExecuted by:
| 6 | ||||||
| 47 | } executed 4 times by 1 test: end of blockExecuted by:
| 4 | ||||||
| 48 | - | |||||||
| 49 | static bool qt_qdnsservicerecord_less_than(const QDnsServiceRecord &r1, const QDnsServiceRecord &r2) | - | ||||||
| 50 | { | - | ||||||
| 51 | - | |||||||
| 52 | - | |||||||
| 53 | return r1.priority() < r2.priority() | - | ||||||
| 54 | || (r1.priority() == r2.priority() | - | ||||||
| 55 | && r1.weight() == 0 && r2.weight() > 0); | - | ||||||
| 56 | } | - | ||||||
| 57 | - | |||||||
| 58 | - | |||||||
| 59 | - | |||||||
| 60 | - | |||||||
| 61 | - | |||||||
| 62 | static void qt_qdnsservicerecord_sort(QList<QDnsServiceRecord> &records) | - | ||||||
| 63 | { | - | ||||||
| 64 | - | |||||||
| 65 | if (records.size() <= 1
| 6-78 | ||||||
| 66 | return; executed 78 times by 2 tests: return;Executed by:
| 78 | ||||||
| 67 | - | |||||||
| 68 | - | |||||||
| 69 | - | |||||||
| 70 | std::sort(records.begin(), records.end(), qt_qdnsservicerecord_less_than); | - | ||||||
| 71 | - | |||||||
| 72 | int i = 0; | - | ||||||
| 73 | while (i < records.size()
| 6-12 | ||||||
| 74 | - | |||||||
| 75 | - | |||||||
| 76 | QList<QDnsServiceRecord> slice; | - | ||||||
| 77 | const quint16 slicePriority = records[.at(i].).priority(); | - | ||||||
| 78 | unsigned int sliceWeight = 0; | - | ||||||
| 79 | for (int j = i; j < records.size()
| 6-22 | ||||||
| 80 | if (records[.at(j].).priority() != slicePriority
| 6-16 | ||||||
| 81 | break; executed 6 times by 1 test: break;Executed by:
| 6 | ||||||
| 82 | sliceWeight += records[.at(j].).weight(); | - | ||||||
| 83 | slice << records[.at(j];); | - | ||||||
| 84 | } executed 16 times by 1 test: end of blockExecuted by:
| 16 | ||||||
| 85 | - | |||||||
| 86 | - | |||||||
| 87 | - | |||||||
| 88 | - | |||||||
| 89 | - | |||||||
| 90 | - | |||||||
| 91 | while (!slice.isEmpty()
| 12-16 | ||||||
| 92 | const unsigned int weightThreshold = qrand() % (sliceWeight + 1); | - | ||||||
| 93 | unsigned int summedWeight = 0; | - | ||||||
| 94 | for (int j = 0; j < slice.size()
| 0-19 | ||||||
| 95 | summedWeight += slice[.at(j].).weight(); | - | ||||||
| 96 | if (summedWeight >= weightThreshold
| 3-16 | ||||||
| 97 | - | |||||||
| 98 | - | |||||||
| 99 | - | |||||||
| 100 | - | |||||||
| 101 | - | |||||||
| 102 | - | |||||||
| 103 | sliceWeight -= slice[.at(j].).weight(); | - | ||||||
| 104 | records[i++] = slice.takeAt(j); | - | ||||||
| 105 | break; executed 16 times by 1 test: break;Executed by:
| 16 | ||||||
| 106 | } | - | ||||||
| 107 | } executed 3 times by 1 test: end of blockExecuted by:
| 3 | ||||||
| 108 | } executed 16 times by 1 test: end of blockExecuted by:
| 16 | ||||||
| 109 | } executed 12 times by 1 test: end of blockExecuted by:
| 12 | ||||||
| 110 | } executed 6 times by 1 test: end of blockExecuted by:
| 6 | ||||||
| 111 | - | |||||||
| 112 | const char *QDnsLookupPrivate::msgNoIpV6NameServerAdresses = | - | ||||||
| 113 | "IPv6 addresses for nameservers are currently not supported"; | - | ||||||
| 114 | QDnsLookup::QDnsLookup(QObject *parent) | - | ||||||
| 115 | : QObject(*new QDnsLookupPrivate, parent) | - | ||||||
| 116 | { | - | ||||||
| 117 | qRegisterMetaType<QDnsLookupReply>(); | - | ||||||
| 118 | } | - | ||||||
| 119 | - | |||||||
| 120 | - | |||||||
| 121 | - | |||||||
| 122 | - | |||||||
| 123 | - | |||||||
| 124 | QDnsLookup::QDnsLookup(Type type, const QString &name, QObject *parent) | - | ||||||
| 125 | : QObject(*new QDnsLookupPrivate, parent) | - | ||||||
| 126 | { | - | ||||||
| 127 | QDnsLookupPrivate * const d = d_func(); | - | ||||||
| 128 | qRegisterMetaType<QDnsLookupReply>(); | - | ||||||
| 129 | d->name = name; | - | ||||||
| 130 | d->type = type; | - | ||||||
| 131 | } | - | ||||||
| 132 | QDnsLookup::QDnsLookup(Type type, const QString &name, const QHostAddress &nameserver, QObject *parent) | - | ||||||
| 133 | : QObject(*new QDnsLookupPrivate, parent) | - | ||||||
| 134 | { | - | ||||||
| 135 | QDnsLookupPrivate * const d = d_func(); | - | ||||||
| 136 | qRegisterMetaType<QDnsLookupReply>(); | - | ||||||
| 137 | d->name = name; | - | ||||||
| 138 | d->type = type; | - | ||||||
| 139 | d->nameserver = nameserver; | - | ||||||
| 140 | } | - | ||||||
| 141 | QDnsLookup::~QDnsLookup() | - | ||||||
| 142 | { | - | ||||||
| 143 | } | - | ||||||
| 144 | - | |||||||
| 145 | - | |||||||
| 146 | - | |||||||
| 147 | - | |||||||
| 148 | - | |||||||
| 149 | - | |||||||
| 150 | QDnsLookup::Error QDnsLookup::error() const | - | ||||||
| 151 | { | - | ||||||
| 152 | return d_func()->reply.error; | - | ||||||
| 153 | } | - | ||||||
| 154 | - | |||||||
| 155 | - | |||||||
| 156 | - | |||||||
| 157 | - | |||||||
| 158 | - | |||||||
| 159 | - | |||||||
| 160 | QString QDnsLookup::errorString() const | - | ||||||
| 161 | { | - | ||||||
| 162 | return d_func()->reply.errorString; | - | ||||||
| 163 | } | - | ||||||
| 164 | - | |||||||
| 165 | - | |||||||
| 166 | - | |||||||
| 167 | - | |||||||
| 168 | - | |||||||
| 169 | bool QDnsLookup::isFinished() const | - | ||||||
| 170 | { | - | ||||||
| 171 | return d_func()->isFinished; | - | ||||||
| 172 | } | - | ||||||
| 173 | QString QDnsLookup::name() const | - | ||||||
| 174 | { | - | ||||||
| 175 | return d_func()->name; | - | ||||||
| 176 | } | - | ||||||
| 177 | - | |||||||
| 178 | void QDnsLookup::setName(const QString &name) | - | ||||||
| 179 | { | - | ||||||
| 180 | QDnsLookupPrivate * const d = d_func(); | - | ||||||
| 181 | if (name != d->name) { | - | ||||||
| 182 | d->name = name; | - | ||||||
| 183 | nameChanged(name); | - | ||||||
| 184 | } | - | ||||||
| 185 | } | - | ||||||
| 186 | - | |||||||
| 187 | - | |||||||
| 188 | - | |||||||
| 189 | - | |||||||
| 190 | - | |||||||
| 191 | - | |||||||
| 192 | QDnsLookup::Type QDnsLookup::type() const | - | ||||||
| 193 | { | - | ||||||
| 194 | return d_func()->type; | - | ||||||
| 195 | } | - | ||||||
| 196 | - | |||||||
| 197 | void QDnsLookup::setType(Type type) | - | ||||||
| 198 | { | - | ||||||
| 199 | QDnsLookupPrivate * const d = d_func(); | - | ||||||
| 200 | if (type != d->type) { | - | ||||||
| 201 | d->type = type; | - | ||||||
| 202 | typeChanged(type); | - | ||||||
| 203 | } | - | ||||||
| 204 | } | - | ||||||
| 205 | - | |||||||
| 206 | - | |||||||
| 207 | - | |||||||
| 208 | - | |||||||
| 209 | - | |||||||
| 210 | - | |||||||
| 211 | QHostAddress QDnsLookup::nameserver() const | - | ||||||
| 212 | { | - | ||||||
| 213 | return d_func()->nameserver; | - | ||||||
| 214 | } | - | ||||||
| 215 | - | |||||||
| 216 | void QDnsLookup::setNameserver(const QHostAddress &nameserver) | - | ||||||
| 217 | { | - | ||||||
| 218 | QDnsLookupPrivate * const d = d_func(); | - | ||||||
| 219 | if (nameserver != d->nameserver) { | - | ||||||
| 220 | d->nameserver = nameserver; | - | ||||||
| 221 | nameserverChanged(nameserver); | - | ||||||
| 222 | } | - | ||||||
| 223 | } | - | ||||||
| 224 | - | |||||||
| 225 | - | |||||||
| 226 | - | |||||||
| 227 | - | |||||||
| 228 | - | |||||||
| 229 | QList<QDnsDomainNameRecord> QDnsLookup::canonicalNameRecords() const | - | ||||||
| 230 | { | - | ||||||
| 231 | return d_func()->reply.canonicalNameRecords; | - | ||||||
| 232 | } | - | ||||||
| 233 | - | |||||||
| 234 | - | |||||||
| 235 | - | |||||||
| 236 | - | |||||||
| 237 | - | |||||||
| 238 | QList<QDnsHostAddressRecord> QDnsLookup::hostAddressRecords() const | - | ||||||
| 239 | { | - | ||||||
| 240 | return d_func()->reply.hostAddressRecords; | - | ||||||
| 241 | } | - | ||||||
| 242 | QList<QDnsMailExchangeRecord> QDnsLookup::mailExchangeRecords() const | - | ||||||
| 243 | { | - | ||||||
| 244 | return d_func()->reply.mailExchangeRecords; | - | ||||||
| 245 | } | - | ||||||
| 246 | - | |||||||
| 247 | - | |||||||
| 248 | - | |||||||
| 249 | - | |||||||
| 250 | - | |||||||
| 251 | QList<QDnsDomainNameRecord> QDnsLookup::nameServerRecords() const | - | ||||||
| 252 | { | - | ||||||
| 253 | return d_func()->reply.nameServerRecords; | - | ||||||
| 254 | } | - | ||||||
| 255 | - | |||||||
| 256 | - | |||||||
| 257 | - | |||||||
| 258 | - | |||||||
| 259 | - | |||||||
| 260 | QList<QDnsDomainNameRecord> QDnsLookup::pointerRecords() const | - | ||||||
| 261 | { | - | ||||||
| 262 | return d_func()->reply.pointerRecords; | - | ||||||
| 263 | } | - | ||||||
| 264 | QList<QDnsServiceRecord> QDnsLookup::serviceRecords() const | - | ||||||
| 265 | { | - | ||||||
| 266 | return d_func()->reply.serviceRecords; | - | ||||||
| 267 | } | - | ||||||
| 268 | - | |||||||
| 269 | - | |||||||
| 270 | - | |||||||
| 271 | - | |||||||
| 272 | - | |||||||
| 273 | QList<QDnsTextRecord> QDnsLookup::textRecords() const | - | ||||||
| 274 | { | - | ||||||
| 275 | return d_func()->reply.textRecords; | - | ||||||
| 276 | } | - | ||||||
| 277 | - | |||||||
| 278 | - | |||||||
| 279 | - | |||||||
| 280 | - | |||||||
| 281 | - | |||||||
| 282 | - | |||||||
| 283 | - | |||||||
| 284 | void QDnsLookup::abort() | - | ||||||
| 285 | { | - | ||||||
| 286 | QDnsLookupPrivate * const d = d_func(); | - | ||||||
| 287 | if (d->runnable) { | - | ||||||
| 288 | d->runnable = 0; | - | ||||||
| 289 | d->reply = QDnsLookupReply(); | - | ||||||
| 290 | d->reply.error = QDnsLookup::OperationCancelledError; | - | ||||||
| 291 | d->reply.errorString = tr("Operation cancelled"); | - | ||||||
| 292 | d->isFinished = true; | - | ||||||
| 293 | finished(); | - | ||||||
| 294 | } | - | ||||||
| 295 | } | - | ||||||
| 296 | - | |||||||
| 297 | - | |||||||
| 298 | - | |||||||
| 299 | - | |||||||
| 300 | - | |||||||
| 301 | - | |||||||
| 302 | - | |||||||
| 303 | void QDnsLookup::lookup() | - | ||||||
| 304 | { | - | ||||||
| 305 | QDnsLookupPrivate * const d = d_func(); | - | ||||||
| 306 | d->isFinished = false; | - | ||||||
| 307 | d->reply = QDnsLookupReply(); | - | ||||||
| 308 | d->runnable = new QDnsLookupRunnable(d->type, QUrl::toAce(d->name), d->nameserver); | - | ||||||
| 309 | connect(d->runnable, qFlagLocation("2""finished(QDnsLookupReply)" "\0" __FILE__ ":" "498""504"), | - | ||||||
| 310 | this, qFlagLocation("1""_q_lookupFinished(QDnsLookupReply)" "\0" __FILE__ ":" "499""505"), | - | ||||||
| 311 | Qt::BlockingQueuedConnection); | - | ||||||
| 312 | theDnsLookupThreadPool()->start(d->runnable); | - | ||||||
| 313 | } | - | ||||||
| 314 | QDnsDomainNameRecord::QDnsDomainNameRecord() | - | ||||||
| 315 | : d(new QDnsDomainNameRecordPrivate) | - | ||||||
| 316 | { | - | ||||||
| 317 | } | - | ||||||
| 318 | - | |||||||
| 319 | - | |||||||
| 320 | - | |||||||
| 321 | - | |||||||
| 322 | - | |||||||
| 323 | QDnsDomainNameRecord::QDnsDomainNameRecord(const QDnsDomainNameRecord &other) | - | ||||||
| 324 | : d(other.d) | - | ||||||
| 325 | { | - | ||||||
| 326 | } | - | ||||||
| 327 | - | |||||||
| 328 | - | |||||||
| 329 | - | |||||||
| 330 | - | |||||||
| 331 | - | |||||||
| 332 | QDnsDomainNameRecord::~QDnsDomainNameRecord() | - | ||||||
| 333 | { | - | ||||||
| 334 | } | - | ||||||
| 335 | - | |||||||
| 336 | - | |||||||
| 337 | - | |||||||
| 338 | - | |||||||
| 339 | - | |||||||
| 340 | QString QDnsDomainNameRecord::name() const | - | ||||||
| 341 | { | - | ||||||
| 342 | return d->name; | - | ||||||
| 343 | } | - | ||||||
| 344 | - | |||||||
| 345 | - | |||||||
| 346 | - | |||||||
| 347 | - | |||||||
| 348 | - | |||||||
| 349 | quint32 QDnsDomainNameRecord::timeToLive() const | - | ||||||
| 350 | { | - | ||||||
| 351 | return d->timeToLive; | - | ||||||
| 352 | } | - | ||||||
| 353 | - | |||||||
| 354 | - | |||||||
| 355 | - | |||||||
| 356 | - | |||||||
| 357 | - | |||||||
| 358 | QString QDnsDomainNameRecord::value() const | - | ||||||
| 359 | { | - | ||||||
| 360 | return d->value; | - | ||||||
| 361 | } | - | ||||||
| 362 | - | |||||||
| 363 | - | |||||||
| 364 | - | |||||||
| 365 | - | |||||||
| 366 | - | |||||||
| 367 | - | |||||||
| 368 | QDnsDomainNameRecord &QDnsDomainNameRecord::operator=(const QDnsDomainNameRecord &other) | - | ||||||
| 369 | { | - | ||||||
| 370 | d = other.d; | - | ||||||
| 371 | return *this; | - | ||||||
| 372 | } | - | ||||||
| 373 | QDnsHostAddressRecord::QDnsHostAddressRecord() | - | ||||||
| 374 | : d(new QDnsHostAddressRecordPrivate) | - | ||||||
| 375 | { | - | ||||||
| 376 | } | - | ||||||
| 377 | - | |||||||
| 378 | - | |||||||
| 379 | - | |||||||
| 380 | - | |||||||
| 381 | - | |||||||
| 382 | QDnsHostAddressRecord::QDnsHostAddressRecord(const QDnsHostAddressRecord &other) | - | ||||||
| 383 | : d(other.d) | - | ||||||
| 384 | { | - | ||||||
| 385 | } | - | ||||||
| 386 | - | |||||||
| 387 | - | |||||||
| 388 | - | |||||||
| 389 | - | |||||||
| 390 | - | |||||||
| 391 | QDnsHostAddressRecord::~QDnsHostAddressRecord() | - | ||||||
| 392 | { | - | ||||||
| 393 | } | - | ||||||
| 394 | - | |||||||
| 395 | - | |||||||
| 396 | - | |||||||
| 397 | - | |||||||
| 398 | - | |||||||
| 399 | QString QDnsHostAddressRecord::name() const | - | ||||||
| 400 | { | - | ||||||
| 401 | return d->name; | - | ||||||
| 402 | } | - | ||||||
| 403 | - | |||||||
| 404 | - | |||||||
| 405 | - | |||||||
| 406 | - | |||||||
| 407 | - | |||||||
| 408 | quint32 QDnsHostAddressRecord::timeToLive() const | - | ||||||
| 409 | { | - | ||||||
| 410 | return d->timeToLive; | - | ||||||
| 411 | } | - | ||||||
| 412 | - | |||||||
| 413 | - | |||||||
| 414 | - | |||||||
| 415 | - | |||||||
| 416 | - | |||||||
| 417 | QHostAddress QDnsHostAddressRecord::value() const | - | ||||||
| 418 | { | - | ||||||
| 419 | return d->value; | - | ||||||
| 420 | } | - | ||||||
| 421 | - | |||||||
| 422 | - | |||||||
| 423 | - | |||||||
| 424 | - | |||||||
| 425 | - | |||||||
| 426 | - | |||||||
| 427 | QDnsHostAddressRecord &QDnsHostAddressRecord::operator=(const QDnsHostAddressRecord &other) | - | ||||||
| 428 | { | - | ||||||
| 429 | d = other.d; | - | ||||||
| 430 | return *this; | - | ||||||
| 431 | } | - | ||||||
| 432 | QDnsMailExchangeRecord::QDnsMailExchangeRecord() | - | ||||||
| 433 | : d(new QDnsMailExchangeRecordPrivate) | - | ||||||
| 434 | { | - | ||||||
| 435 | } | - | ||||||
| 436 | - | |||||||
| 437 | - | |||||||
| 438 | - | |||||||
| 439 | - | |||||||
| 440 | - | |||||||
| 441 | QDnsMailExchangeRecord::QDnsMailExchangeRecord(const QDnsMailExchangeRecord &other) | - | ||||||
| 442 | : d(other.d) | - | ||||||
| 443 | { | - | ||||||
| 444 | } | - | ||||||
| 445 | - | |||||||
| 446 | - | |||||||
| 447 | - | |||||||
| 448 | - | |||||||
| 449 | - | |||||||
| 450 | QDnsMailExchangeRecord::~QDnsMailExchangeRecord() | - | ||||||
| 451 | { | - | ||||||
| 452 | } | - | ||||||
| 453 | - | |||||||
| 454 | - | |||||||
| 455 | - | |||||||
| 456 | - | |||||||
| 457 | - | |||||||
| 458 | QString QDnsMailExchangeRecord::exchange() const | - | ||||||
| 459 | { | - | ||||||
| 460 | return d->exchange; | - | ||||||
| 461 | } | - | ||||||
| 462 | - | |||||||
| 463 | - | |||||||
| 464 | - | |||||||
| 465 | - | |||||||
| 466 | - | |||||||
| 467 | QString QDnsMailExchangeRecord::name() const | - | ||||||
| 468 | { | - | ||||||
| 469 | return d->name; | - | ||||||
| 470 | } | - | ||||||
| 471 | - | |||||||
| 472 | - | |||||||
| 473 | - | |||||||
| 474 | - | |||||||
| 475 | - | |||||||
| 476 | quint16 QDnsMailExchangeRecord::preference() const | - | ||||||
| 477 | { | - | ||||||
| 478 | return d->preference; | - | ||||||
| 479 | } | - | ||||||
| 480 | - | |||||||
| 481 | - | |||||||
| 482 | - | |||||||
| 483 | - | |||||||
| 484 | - | |||||||
| 485 | quint32 QDnsMailExchangeRecord::timeToLive() const | - | ||||||
| 486 | { | - | ||||||
| 487 | return d->timeToLive; | - | ||||||
| 488 | } | - | ||||||
| 489 | - | |||||||
| 490 | - | |||||||
| 491 | - | |||||||
| 492 | - | |||||||
| 493 | - | |||||||
| 494 | - | |||||||
| 495 | QDnsMailExchangeRecord &QDnsMailExchangeRecord::operator=(const QDnsMailExchangeRecord &other) | - | ||||||
| 496 | { | - | ||||||
| 497 | d = other.d; | - | ||||||
| 498 | return *this; | - | ||||||
| 499 | } | - | ||||||
| 500 | QDnsServiceRecord::QDnsServiceRecord() | - | ||||||
| 501 | : d(new QDnsServiceRecordPrivate) | - | ||||||
| 502 | { | - | ||||||
| 503 | } | - | ||||||
| 504 | - | |||||||
| 505 | - | |||||||
| 506 | - | |||||||
| 507 | - | |||||||
| 508 | - | |||||||
| 509 | QDnsServiceRecord::QDnsServiceRecord(const QDnsServiceRecord &other) | - | ||||||
| 510 | : d(other.d) | - | ||||||
| 511 | { | - | ||||||
| 512 | } | - | ||||||
| 513 | - | |||||||
| 514 | - | |||||||
| 515 | - | |||||||
| 516 | - | |||||||
| 517 | - | |||||||
| 518 | QDnsServiceRecord::~QDnsServiceRecord() | - | ||||||
| 519 | { | - | ||||||
| 520 | } | - | ||||||
| 521 | - | |||||||
| 522 | - | |||||||
| 523 | - | |||||||
| 524 | - | |||||||
| 525 | - | |||||||
| 526 | QString QDnsServiceRecord::name() const | - | ||||||
| 527 | { | - | ||||||
| 528 | return d->name; | - | ||||||
| 529 | } | - | ||||||
| 530 | - | |||||||
| 531 | - | |||||||
| 532 | - | |||||||
| 533 | - | |||||||
| 534 | - | |||||||
| 535 | quint16 QDnsServiceRecord::port() const | - | ||||||
| 536 | { | - | ||||||
| 537 | return d->port; | - | ||||||
| 538 | } | - | ||||||
| 539 | quint16 QDnsServiceRecord::priority() const | - | ||||||
| 540 | { | - | ||||||
| 541 | return d->priority; | - | ||||||
| 542 | } | - | ||||||
| 543 | - | |||||||
| 544 | - | |||||||
| 545 | - | |||||||
| 546 | - | |||||||
| 547 | - | |||||||
| 548 | QString QDnsServiceRecord::target() const | - | ||||||
| 549 | { | - | ||||||
| 550 | return d->target; | - | ||||||
| 551 | } | - | ||||||
| 552 | - | |||||||
| 553 | - | |||||||
| 554 | - | |||||||
| 555 | - | |||||||
| 556 | - | |||||||
| 557 | quint32 QDnsServiceRecord::timeToLive() const | - | ||||||
| 558 | { | - | ||||||
| 559 | return d->timeToLive; | - | ||||||
| 560 | } | - | ||||||
| 561 | quint16 QDnsServiceRecord::weight() const | - | ||||||
| 562 | { | - | ||||||
| 563 | return d->weight; | - | ||||||
| 564 | } | - | ||||||
| 565 | - | |||||||
| 566 | - | |||||||
| 567 | - | |||||||
| 568 | - | |||||||
| 569 | - | |||||||
| 570 | - | |||||||
| 571 | QDnsServiceRecord &QDnsServiceRecord::operator=(const QDnsServiceRecord &other) | - | ||||||
| 572 | { | - | ||||||
| 573 | d = other.d; | - | ||||||
| 574 | return *this; | - | ||||||
| 575 | } | - | ||||||
| 576 | QDnsTextRecord::QDnsTextRecord() | - | ||||||
| 577 | : d(new QDnsTextRecordPrivate) | - | ||||||
| 578 | { | - | ||||||
| 579 | } | - | ||||||
| 580 | - | |||||||
| 581 | - | |||||||
| 582 | - | |||||||
| 583 | - | |||||||
| 584 | - | |||||||
| 585 | QDnsTextRecord::QDnsTextRecord(const QDnsTextRecord &other) | - | ||||||
| 586 | : d(other.d) | - | ||||||
| 587 | { | - | ||||||
| 588 | } | - | ||||||
| 589 | - | |||||||
| 590 | - | |||||||
| 591 | - | |||||||
| 592 | - | |||||||
| 593 | - | |||||||
| 594 | QDnsTextRecord::~QDnsTextRecord() | - | ||||||
| 595 | { | - | ||||||
| 596 | } | - | ||||||
| 597 | - | |||||||
| 598 | - | |||||||
| 599 | - | |||||||
| 600 | - | |||||||
| 601 | - | |||||||
| 602 | QString QDnsTextRecord::name() const | - | ||||||
| 603 | { | - | ||||||
| 604 | return d->name; | - | ||||||
| 605 | } | - | ||||||
| 606 | - | |||||||
| 607 | - | |||||||
| 608 | - | |||||||
| 609 | - | |||||||
| 610 | - | |||||||
| 611 | quint32 QDnsTextRecord::timeToLive() const | - | ||||||
| 612 | { | - | ||||||
| 613 | return d->timeToLive; | - | ||||||
| 614 | } | - | ||||||
| 615 | - | |||||||
| 616 | - | |||||||
| 617 | - | |||||||
| 618 | - | |||||||
| 619 | - | |||||||
| 620 | QList<QByteArray> QDnsTextRecord::values() const | - | ||||||
| 621 | { | - | ||||||
| 622 | return d->values; | - | ||||||
| 623 | } | - | ||||||
| 624 | - | |||||||
| 625 | - | |||||||
| 626 | - | |||||||
| 627 | - | |||||||
| 628 | - | |||||||
| 629 | - | |||||||
| 630 | QDnsTextRecord &QDnsTextRecord::operator=(const QDnsTextRecord &other) | - | ||||||
| 631 | { | - | ||||||
| 632 | d = other.d; | - | ||||||
| 633 | return *this; | - | ||||||
| 634 | } | - | ||||||
| 635 | - | |||||||
| 636 | - | |||||||
| 637 | - | |||||||
| 638 | - | |||||||
| 639 | - | |||||||
| 640 | - | |||||||
| 641 | - | |||||||
| 642 | void QDnsLookupPrivate::_q_lookupFinished(const QDnsLookupReply &_reply) | - | ||||||
| 643 | { | - | ||||||
| 644 | QDnsLookup * const q = q_func(); | - | ||||||
| 645 | if (runnable == q->sender()) { | - | ||||||
| 646 | - | |||||||
| 647 | - | |||||||
| 648 | - | |||||||
| 649 | reply = _reply; | - | ||||||
| 650 | runnable = 0; | - | ||||||
| 651 | isFinished = true; | - | ||||||
| 652 | q->finished(); | - | ||||||
| 653 | } | - | ||||||
| 654 | } | - | ||||||
| 655 | - | |||||||
| 656 | void QDnsLookupRunnable::run() | - | ||||||
| 657 | { | - | ||||||
| 658 | QDnsLookupReply reply; | - | ||||||
| 659 | - | |||||||
| 660 | - | |||||||
| 661 | if (requestName.isEmpty()) { | - | ||||||
| 662 | reply.error = QDnsLookup::InvalidRequestError; | - | ||||||
| 663 | reply.errorString = tr("Invalid domain name"); | - | ||||||
| 664 | finished(reply); | - | ||||||
| 665 | return; | - | ||||||
| 666 | } | - | ||||||
| 667 | - | |||||||
| 668 | - | |||||||
| 669 | query(requestType, requestName, nameserver, &reply); | - | ||||||
| 670 | - | |||||||
| 671 | - | |||||||
| 672 | if (!theDnsLookupSeedStorage()->hasLocalData()) { | - | ||||||
| 673 | qsrand(QTime(0,0,0).msecsTo(QTime::currentTime()) ^ reinterpret_cast<quintptr>(this)); | - | ||||||
| 674 | theDnsLookupSeedStorage()->setLocalData(new bool(true)); | - | ||||||
| 675 | } | - | ||||||
| 676 | qt_qdnsmailexchangerecord_sort(reply.mailExchangeRecords); | - | ||||||
| 677 | qt_qdnsservicerecord_sort(reply.serviceRecords); | - | ||||||
| 678 | - | |||||||
| 679 | finished(reply); | - | ||||||
| 680 | } | - | ||||||
| 681 | - | |||||||
| 682 | QDnsLookupThreadPool::QDnsLookupThreadPool() | - | ||||||
| 683 | : signalsConnected(false) | - | ||||||
| 684 | { | - | ||||||
| 685 | - | |||||||
| 686 | setMaxThreadCount(5); | - | ||||||
| 687 | } | - | ||||||
| 688 | - | |||||||
| 689 | void QDnsLookupThreadPool::start(QRunnable *runnable) | - | ||||||
| 690 | { | - | ||||||
| 691 | - | |||||||
| 692 | if (!signalsConnected) { | - | ||||||
| 693 | QMutexLocker signalsLocker(&signalsMutex); | - | ||||||
| 694 | if (!signalsConnected) { | - | ||||||
| 695 | QCoreApplication *app = QCoreApplication::instance(); | - | ||||||
| 696 | if (!app) { | - | ||||||
| 697 | QMessageLogger(__FILE__, 10331039, __PRETTY_FUNCTION__).warning("QDnsLookup requires a QCoreApplication"); | - | ||||||
| 698 | delete runnable; | - | ||||||
| 699 | return; | - | ||||||
| 700 | } | - | ||||||
| 701 | - | |||||||
| 702 | moveToThread(app->thread()); | - | ||||||
| 703 | connect(app, qFlagLocation("2""destroyed()" "\0" __FILE__ ":" "1039""1045"), | - | ||||||
| 704 | qFlagLocation("1""_q_applicationDestroyed()" "\0" __FILE__ ":" "1040""1046"), Qt::DirectConnection); | - | ||||||
| 705 | signalsConnected = true; | - | ||||||
| 706 | } | - | ||||||
| 707 | } | - | ||||||
| 708 | - | |||||||
| 709 | QThreadPool::start(runnable); | - | ||||||
| 710 | } | - | ||||||
| 711 | - | |||||||
| 712 | void QDnsLookupThreadPool::_q_applicationDestroyed() | - | ||||||
| 713 | { | - | ||||||
| 714 | waitForDone(); | - | ||||||
| 715 | signalsConnected = false; | - | ||||||
| 716 | } | - | ||||||
| 717 | - | |||||||
| 718 | - | |||||||
| 719 | - | |||||||
| Switch to Source code | Preprocessed file |