Changeset 846 for trunk/src/network/kernel
- Timestamp:
- May 5, 2011, 5:36:53 AM (14 years ago)
- Location:
- trunk
- Files:
-
- 27 edited
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk
- Property svn:mergeinfo changed
/branches/vendor/nokia/qt/4.7.2 (added) merged: 845 /branches/vendor/nokia/qt/current merged: 844 /branches/vendor/nokia/qt/4.6.3 removed
- Property svn:mergeinfo changed
-
trunk/src/network/kernel/kernel.pri
r561 r846 29 29 mac:SOURCES += kernel/qnetworkproxy_mac.cpp 30 30 else:win32:SOURCES += kernel/qnetworkproxy_win.cpp 31 else:symbian:SOURCES += kernel/qnetworkproxy_symbian.cpp 31 32 else:SOURCES += kernel/qnetworkproxy_generic.cpp 32 33 34 symbian: LIBS += -lcommsdat -
trunk/src/network/kernel/qauthenticator.cpp
r769 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) … … 51 51 #include <qendian.h> 52 52 #include <qstring.h> 53 #include <qdatetime.h> 54 55 //#define NTLMV1_CLIENT 53 56 54 57 QT_BEGIN_NAMESPACE 55 58 59 #ifdef NTLMV1_CLIENT 56 60 #include "../../3rdparty/des/des.cpp" 61 #endif 57 62 58 63 static QByteArray qNtlmPhase1(); … … 84 89 Note that, in particular, NTLM version 2 is not supported. 85 90 91 \section1 Options 92 93 In addition to the username and password required for authentication, a 94 QAuthenticator object can also contain additional options. The 95 options() function can be used to query incoming options sent by 96 the server; the setOption() function can 97 be used to set outgoing options, to be processed by the authenticator 98 calculation. The options accepted and provided depend on the authentication 99 type (see method()). 100 101 The following tables list known incoming options as well as accepted 102 outgoing options. The list of incoming options is not exhaustive, since 103 servers may include additional information at any time. The list of 104 outgoing options is exhaustive, however, and no unknown options will be 105 treated or sent back to the server. 106 107 \section2 Basic 108 109 \table 110 \header \o Option \o Direction \o Description 111 \row \o \tt{realm} \o Incoming \o Contains the realm of the authentication, the same as realm() 112 \endtable 113 114 The Basic authentication mechanism supports no outgoing options. 115 116 \section2 NTLM version 1 117 118 The NTLM authentication mechanism currently supports no incoming or outgoing options. 119 120 \section2 Digest-MD5 121 122 \table 123 \header \o Option \o Direction \o Description 124 \row \o \tt{realm} \o Incoming \o Contains the realm of the authentication, the same as realm() 125 \endtable 126 127 The Digest-MD5 authentication mechanism supports no outgoing options. 128 86 129 \sa QSslSocket 87 130 */ … … 122 165 if (d == other.d) 123 166 return *this; 124 detach(); 125 d->user = other.d->user; 126 d->password = other.d->password; 167 168 if (d && !d->ref.deref()) 169 delete d; 170 171 d = other.d; 172 if (d) 173 d->ref.ref(); 127 174 return *this; 128 175 } … … 139 186 && d->password == other.d->password 140 187 && d->realm == other.d->realm 141 && d->method == other.d->method; 188 && d->method == other.d->method 189 && d->options == other.d->options; 142 190 } 143 191 … … 163 211 { 164 212 detach(); 165 d->user = user; 213 int separatorPosn = 0; 214 215 switch(d->method) { 216 case QAuthenticatorPrivate::Ntlm: 217 if((separatorPosn = user.indexOf(QLatin1String("\\"))) != -1) { 218 //domain name is present 219 d->realm.clear(); 220 d->userDomain = user.left(separatorPosn); 221 d->extractedUser = user.mid(separatorPosn + 1); 222 d->user = user; 223 } else if((separatorPosn = user.indexOf(QLatin1String("@"))) != -1) { 224 //domain name is present 225 d->realm.clear(); 226 d->userDomain = user.left(separatorPosn); 227 d->extractedUser = user.left(separatorPosn); 228 d->user = user; 229 } else { 230 d->extractedUser = user; 231 d->user = user; 232 d->realm.clear(); 233 d->userDomain.clear(); 234 } 235 break; 236 default: 237 d->user = user; 238 d->userDomain.clear(); 239 break; 240 } 166 241 } 167 242 … … 206 281 } 207 282 208 209 /*! 210 returns true if the authenticator is null. 283 /*! 284 \since 4.7 285 Returns the value related to option \a opt if it was set by the server. 286 See \l{QAuthenticator#Options} for more information on incoming options. 287 If option \a opt isn't found, an invalid QVariant will be returned. 288 289 \sa options(), QAuthenticator#Options 290 */ 291 QVariant QAuthenticator::option(const QString &opt) const 292 { 293 return d ? d->options.value(opt) : QVariant(); 294 } 295 296 /*! 297 \since 4.7 298 Returns all incoming options set in this QAuthenticator object by parsing 299 the server reply. See \l{QAuthenticator#Options} for more information 300 on incoming options. 301 302 \sa option(), QAuthenticator#Options 303 */ 304 QVariantHash QAuthenticator::options() const 305 { 306 return d ? d->options : QVariantHash(); 307 } 308 309 /*! 310 \since 4.7 311 312 Sets the outgoing option \a opt to value \a value. 313 See \l{QAuthenticator#Options} for more information on outgoing options. 314 315 \sa options(), option(), QAuthenticator#Options 316 */ 317 void QAuthenticator::setOption(const QString &opt, const QVariant &value) 318 { 319 detach(); 320 d->options.insert(opt, value); 321 } 322 323 324 /*! 325 Returns true if the authenticator is null. 211 326 */ 212 327 bool QAuthenticator::isNull() const … … 229 344 void QAuthenticatorPrivate::parseHttpResponse(const QHttpResponseHeader &header, bool isProxy) 230 345 { 231 QList<QPair<QString, QString> > values = header.values(); 346 const QList<QPair<QString, QString> > values = header.values(); 347 QList<QPair<QByteArray, QByteArray> > rawValues; 348 349 QList<QPair<QString, QString> >::const_iterator it, end; 350 for (it = values.constBegin(), end = values.constEnd(); it != end; ++it) 351 rawValues.append(qMakePair(it->first.toLatin1(), it->second.toUtf8())); 352 353 // continue in byte array form 354 parseHttpResponse(rawValues, isProxy); 355 } 356 #endif 357 358 void QAuthenticatorPrivate::parseHttpResponse(const QList<QPair<QByteArray, QByteArray> > &values, bool isProxy) 359 { 232 360 const char *search = isProxy ? "proxy-authenticate" : "www-authenticate"; 233 361 … … 243 371 */ 244 372 245 Q StringheaderVal;373 QByteArray headerVal; 246 374 for (int i = 0; i < values.size(); ++i) { 247 const QPair<Q String, QString> ¤t = values.at(i);248 if (current.first.toLower() != QLatin1String(search))375 const QPair<QByteArray, QByteArray> ¤t = values.at(i); 376 if (current.first.toLower() != search) 249 377 continue; 250 QString str = current.second; 251 if (method < Basic && str.startsWith(QLatin1String("Basic"), Qt::CaseInsensitive)) { 252 method = Basic; headerVal = str.mid(6); 253 } else if (method < Ntlm && str.startsWith(QLatin1String("NTLM"), Qt::CaseInsensitive)) { 378 QByteArray str = current.second.toLower(); 379 if (method < Basic && str.startsWith("basic")) { 380 method = Basic; 381 headerVal = current.second.mid(6); 382 } else if (method < Ntlm && str.startsWith("ntlm")) { 254 383 method = Ntlm; 255 headerVal = str.mid(5);256 } else if (method < DigestMd5 && str.startsWith( QLatin1String("Digest"), Qt::CaseInsensitive)) {384 headerVal = current.second.mid(5); 385 } else if (method < DigestMd5 && str.startsWith("digest")) { 257 386 method = DigestMd5; 258 headerVal = str.mid(7);387 headerVal = current.second.mid(7); 259 388 } 260 389 } 261 390 262 challenge = headerVal.trimmed() .toLatin1();391 challenge = headerVal.trimmed(); 263 392 QHash<QByteArray, QByteArray> options = parseDigestAuthenticationChallenge(challenge); 264 393 265 394 switch(method) { 266 395 case Basic: 267 realm = QString::fromLatin1(options.value("realm")); 396 if(realm.isEmpty()) 397 this->options[QLatin1String("realm")] = realm = QString::fromLatin1(options.value("realm")); 268 398 if (user.isEmpty()) 269 399 phase = Done; … … 271 401 case Ntlm: 272 402 // #### extract from header 273 realm.clear();274 403 break; 275 404 case DigestMd5: { 276 realm = QString::fromLatin1(options.value("realm")); 405 if(realm.isEmpty()) 406 this->options[QLatin1String("realm")] = realm = QString::fromLatin1(options.value("realm")); 277 407 if (options.value("stale").toLower() == "true") 278 408 phase = Start; … … 287 417 } 288 418 } 289 #endif290 419 291 420 QByteArray QAuthenticatorPrivate::calculateResponse(const QByteArray &requestMethod, const QByteArray &path) … … 662 791 #define NTLMSSP_NEGOTIATE_56 0x80000000 663 792 793 /* 794 * AvId values 795 */ 796 #define AVTIMESTAMP 7 797 798 //#define NTLMV1_CLIENT 799 800 801 //************************Global variables*************************** 802 803 const int blockSize = 64; //As per RFC2104 Block-size is 512 bits 804 const int nDigestLen = 16; //Trunctaion Length of the Hmac-Md5 digest 805 const quint8 respversion = 1; 806 const quint8 hirespversion = 1; 664 807 665 808 /* usage: … … 804 947 // extracted 805 948 QString targetNameStr, targetInfoStr; 949 QByteArray targetInfoBuff; 806 950 }; 807 951 … … 819 963 QByteArray lmResponseBuf, ntlmResponseBuf; 820 964 QString domainStr, userStr, workstationStr, sessionKeyStr; 965 QByteArray v2Hash; 821 966 }; 822 967 … … 900 1045 } 901 1046 902 1047 #ifdef NTLMV1_CLIENT 903 1048 static QByteArray qEncodeNtlmResponse(const QAuthenticatorPrivate *ctx, const QNtlmPhase2Block& ch) 904 1049 { … … 942 1087 return rc; 943 1088 } 944 1089 #endif 1090 1091 /********************************************************************* 1092 * Function Name: qEncodeHmacMd5 1093 * Params: 1094 * key: Type - QByteArray 1095 * - It is the Authentication key 1096 * message: Type - QByteArray 1097 * - This is the actual message which will be encoded 1098 * using HMacMd5 hash algorithm 1099 * 1100 * Return Value: 1101 * hmacDigest: Type - QByteArray 1102 * 1103 * Description: 1104 * This function will be used to encode the input message using 1105 * HMacMd5 hash algorithm. 1106 * 1107 * As per the RFC2104 the HMacMd5 algorithm can be specified 1108 * --------------------------------------- 1109 * MD5(K XOR opad, MD5(K XOR ipad, text)) 1110 * --------------------------------------- 1111 * 1112 *********************************************************************/ 1113 QByteArray qEncodeHmacMd5(QByteArray &key, const QByteArray &message) 1114 { 1115 Q_ASSERT_X(!(message.isEmpty()),"qEncodeHmacMd5", "Empty message check"); 1116 Q_ASSERT_X(!(key.isEmpty()),"qEncodeHmacMd5", "Empty key check"); 1117 1118 QCryptographicHash hash(QCryptographicHash::Md5); 1119 QByteArray hMsg; 1120 1121 QByteArray iKeyPad(blockSize, 0x36); 1122 QByteArray oKeyPad(blockSize, 0x5c); 1123 1124 hash.reset(); 1125 // Adjust the key length to blockSize 1126 1127 if(blockSize < key.length()) { 1128 hash.addData(key); 1129 key = hash.result(); //MD5 will always return 16 bytes length output 1130 } 1131 1132 //Key will be <= 16 or 20 bytes as hash function (MD5 or SHA hash algorithms) 1133 //key size can be max of Block size only 1134 key = key.leftJustified(blockSize,0,true); 1135 1136 //iKeyPad, oKeyPad and key are all of same size "blockSize" 1137 1138 //xor of iKeyPad with Key and store the result into iKeyPad 1139 for(int i = 0; i<key.size();i++) { 1140 iKeyPad[i] = key[i]^iKeyPad[i]; 1141 } 1142 1143 //xor of oKeyPad with Key and store the result into oKeyPad 1144 for(int i = 0; i<key.size();i++) { 1145 oKeyPad[i] = key[i]^oKeyPad[i]; 1146 } 1147 1148 iKeyPad.append(message); // (K0 xor ipad) || text 1149 1150 hash.reset(); 1151 hash.addData(iKeyPad); 1152 hMsg = hash.result(); 1153 //Digest gen after pass-1: H((K0 xor ipad)||text) 1154 1155 QByteArray hmacDigest; 1156 oKeyPad.append(hMsg); 1157 hash.reset(); 1158 hash.addData(oKeyPad); 1159 hmacDigest = hash.result(); 1160 // H((K0 xor opad )|| H((K0 xor ipad) || text)) 1161 1162 /*hmacDigest should not be less than half the length of the HMAC output 1163 (to match the birthday attack bound) and not less than 80 bits 1164 (a suitable lower bound on the number of bits that need to be 1165 predicted by an attacker). 1166 Refer RFC 2104 for more details on truncation part */ 1167 1168 /*MD5 hash always returns 16 byte digest only and HMAC-MD5 spec 1169 (RFC 2104) also says digest length should be 16 bytes*/ 1170 return hmacDigest; 1171 } 1172 1173 static QByteArray qCreatev2Hash(const QAuthenticatorPrivate *ctx, 1174 QNtlmPhase3Block *phase3) 1175 { 1176 Q_ASSERT(phase3 != 0); 1177 // since v2 Hash is need for both NTLMv2 and LMv2 it is calculated 1178 // only once and stored and reused 1179 if(phase3->v2Hash.size() == 0) { 1180 QCryptographicHash md4(QCryptographicHash::Md4); 1181 QByteArray passUnicode = qStringAsUcs2Le(ctx->password); 1182 md4.addData(passUnicode.data(), passUnicode.size()); 1183 1184 QByteArray hashKey = md4.result(); 1185 Q_ASSERT(hashKey.size() == 16); 1186 // Assuming the user and domain is always unicode in challenge 1187 QByteArray message = 1188 qStringAsUcs2Le(ctx->extractedUser.toUpper()) + 1189 qStringAsUcs2Le(phase3->domainStr); 1190 1191 phase3->v2Hash = qEncodeHmacMd5(hashKey, message); 1192 } 1193 return phase3->v2Hash; 1194 } 1195 1196 static QByteArray clientChallenge(const QAuthenticatorPrivate *ctx) 1197 { 1198 Q_ASSERT(ctx->cnonce.size() >= 8); 1199 QByteArray clientCh = ctx->cnonce.right(8); 1200 return clientCh; 1201 } 1202 1203 // caller has to ensure a valid targetInfoBuff 1204 static QByteArray qExtractServerTime(const QByteArray& targetInfoBuff) 1205 { 1206 QByteArray timeArray; 1207 QDataStream ds(targetInfoBuff); 1208 ds.setByteOrder(QDataStream::LittleEndian); 1209 1210 quint16 avId; 1211 quint16 avLen; 1212 1213 ds >> avId; 1214 ds >> avLen; 1215 while(avId != 0) { 1216 if(avId == AVTIMESTAMP) { 1217 timeArray.resize(avLen); 1218 //avLen size of QByteArray is allocated 1219 ds.readRawData(timeArray.data(), avLen); 1220 break; 1221 } 1222 ds.skipRawData(avLen); 1223 ds >> avId; 1224 ds >> avLen; 1225 } 1226 return timeArray; 1227 } 1228 1229 static QByteArray qEncodeNtlmv2Response(const QAuthenticatorPrivate *ctx, 1230 const QNtlmPhase2Block& ch, 1231 QNtlmPhase3Block *phase3) 1232 { 1233 Q_ASSERT(phase3 != 0); 1234 // return value stored in phase3 1235 qCreatev2Hash(ctx, phase3); 1236 1237 QByteArray temp; 1238 QDataStream ds(&temp, QIODevice::WriteOnly); 1239 ds.setByteOrder(QDataStream::LittleEndian); 1240 1241 ds << respversion; 1242 ds << hirespversion; 1243 1244 //Reserved 1245 QByteArray reserved1(6, 0); 1246 ds.writeRawData(reserved1.constData(), reserved1.size()); 1247 1248 quint64 time = 0; 1249 QByteArray timeArray; 1250 1251 if(ch.targetInfo.len) 1252 { 1253 timeArray = qExtractServerTime(ch.targetInfoBuff); 1254 } 1255 1256 //if server sends time, use it instead of current time 1257 if(timeArray.size()) { 1258 ds.writeRawData(timeArray.constData(), timeArray.size()); 1259 } else { 1260 QDateTime currentTime(QDate::currentDate(), 1261 QTime::currentTime(), Qt::UTC); 1262 1263 // number of seconds between 1601 and epoc(1970) 1264 // 369 years, 89 leap years 1265 // ((369 * 365) + 89) * 24 * 3600 = 11644473600 1266 1267 time = Q_UINT64_C(currentTime.toTime_t() + 11644473600); 1268 1269 // represented as 100 nano seconds 1270 time = Q_UINT64_C(time * 10000000); 1271 ds << time; 1272 } 1273 1274 //8 byte client challenge 1275 QByteArray clientCh = clientChallenge(ctx); 1276 ds.writeRawData(clientCh.constData(), clientCh.size()); 1277 1278 //Reserved 1279 QByteArray reserved2(4, 0); 1280 ds.writeRawData(reserved2.constData(), reserved2.size()); 1281 1282 if (ch.targetInfo.len > 0) { 1283 ds.writeRawData(ch.targetInfoBuff.constData(), 1284 ch.targetInfoBuff.size()); 1285 } 1286 1287 //Reserved 1288 QByteArray reserved3(4, 0); 1289 ds.writeRawData(reserved3.constData(), reserved3.size()); 1290 1291 QByteArray message((const char*)ch.challenge, sizeof(ch.challenge)); 1292 message.append(temp); 1293 1294 QByteArray ntChallengeResp = qEncodeHmacMd5(phase3->v2Hash, message); 1295 ntChallengeResp.append(temp); 1296 1297 return ntChallengeResp; 1298 } 1299 1300 static QByteArray qEncodeLmv2Response(const QAuthenticatorPrivate *ctx, 1301 const QNtlmPhase2Block& ch, 1302 QNtlmPhase3Block *phase3) 1303 { 1304 Q_ASSERT(phase3 != 0); 1305 // return value stored in phase3 1306 qCreatev2Hash(ctx, phase3); 1307 1308 QByteArray message((const char*)ch.challenge, sizeof(ch.challenge)); 1309 QByteArray clientCh = clientChallenge(ctx); 1310 1311 message.append(clientCh); 1312 1313 QByteArray lmChallengeResp = qEncodeHmacMd5(phase3->v2Hash, message); 1314 lmChallengeResp.append(clientCh); 1315 1316 return lmChallengeResp; 1317 } 945 1318 946 1319 static bool qNtlmDecodePhase2(const QByteArray& data, QNtlmPhase2Block& ch) … … 977 1350 978 1351 if (ch.targetInfo.len > 0) { 979 // UNUSED right now 1352 if (ch.targetInfo.len + ch.targetInfo.offset > (unsigned)data.size()) 1353 return false; 1354 1355 ch.targetInfoBuff = data.mid(ch.targetInfo.offset, ch.targetInfo.len); 980 1356 } 981 1357 … … 996 1372 997 1373 bool unicode = ch.flags & NTLMSSP_NEGOTIATE_UNICODE; 998 999 ctx->realm = ch.targetNameStr;1000 1374 1001 1375 pb.flags = NTLMSSP_NEGOTIATE_NTLM; … … 1009 1383 Q_ASSERT(QNtlmPhase3BlockBase::Size == sizeof(QNtlmPhase3BlockBase)); 1010 1384 1011 offset = qEncodeNtlmString(pb.domain, offset, ctx->realm, unicode); 1012 pb.domainStr = ctx->realm; 1013 offset = qEncodeNtlmString(pb.user, offset, ctx->user, unicode); 1014 pb.userStr = ctx->user; 1385 if(ctx->userDomain.isEmpty()) { 1386 offset = qEncodeNtlmString(pb.domain, offset, ch.targetNameStr, unicode); 1387 pb.domainStr = ch.targetNameStr; 1388 } else { 1389 offset = qEncodeNtlmString(pb.domain, offset, ctx->userDomain, unicode); 1390 pb.domainStr = ctx->userDomain; 1391 } 1392 1393 offset = qEncodeNtlmString(pb.user, offset, ctx->extractedUser, unicode); 1394 pb.userStr = ctx->extractedUser; 1015 1395 1016 1396 offset = qEncodeNtlmString(pb.workstation, offset, ctx->workstation, unicode); … … 1018 1398 1019 1399 // Get LM response 1400 #ifdef NTLMV1_CLIENT 1020 1401 pb.lmResponseBuf = qEncodeLmResponse(ctx, ch); 1402 #else 1403 if (ch.targetInfo.len > 0) { 1404 pb.lmResponseBuf = QByteArray(); 1405 } else { 1406 pb.lmResponseBuf = qEncodeLmv2Response(ctx, ch, &pb); 1407 } 1408 #endif 1021 1409 offset = qEncodeNtlmBuffer(pb.lmResponse, offset, pb.lmResponseBuf); 1022 1410 1023 1411 // Get NTLM response 1412 #ifdef NTLMV1_CLIENT 1024 1413 pb.ntlmResponseBuf = qEncodeNtlmResponse(ctx, ch); 1414 #else 1415 pb.ntlmResponseBuf = qEncodeNtlmv2Response(ctx, ch, &pb); 1416 #endif 1025 1417 offset = qEncodeNtlmBuffer(pb.ntlmResponse, offset, pb.ntlmResponseBuf); 1026 1418 -
trunk/src/network/kernel/qauthenticator.h
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) … … 44 44 45 45 #include <QtCore/qstring.h> 46 #include <QtCore/qvariant.h> 46 47 47 48 QT_BEGIN_HEADER … … 74 75 QString realm() const; 75 76 77 QVariant option(const QString &opt) const; 78 QVariantHash options() const; 79 void setOption(const QString &opt, const QVariant &value); 80 76 81 bool isNull() const; 77 82 void detach(); -
trunk/src/network/kernel/qauthenticator_p.h
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) … … 58 58 #include <qstring.h> 59 59 #include <qauthenticator.h> 60 #include <qvariant.h> 60 61 61 62 QT_BEGIN_NAMESPACE … … 63 64 class QHttpResponseHeader; 64 65 65 class Q AuthenticatorPrivate66 class Q_AUTOTEST_EXPORT QAuthenticatorPrivate 66 67 { 67 68 public: … … 71 72 QAtomicInt ref; 72 73 QString user; 74 QString extractedUser; 73 75 QString password; 74 Q Hash<QByteArray, QByteArray>options;76 QVariantHash options; 75 77 Method method; 76 78 QString realm; … … 91 93 // ntlm specific 92 94 QString workstation; 95 QString userDomain; 93 96 94 97 QByteArray calculateResponse(const QByteArray &method, const QByteArray &path); … … 103 106 void parseHttpResponse(const QHttpResponseHeader &, bool isProxy); 104 107 #endif 108 void parseHttpResponse(const QList<QPair<QByteArray, QByteArray> >&, bool isProxy); 105 109 106 110 }; -
trunk/src/network/kernel/qhostaddress.cpp
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) … … 429 429 and QUdpSocket to connect to a host or to set up a server. 430 430 431 A host address is set with setAddress(), checked for its type432 using isIPv4Address() or isIPv6Address(), and retrieved with433 t oIPv4Address(), toIPv6Address(), or toString().431 A host address is set with setAddress(), and retrieved with 432 toIPv4Address(), toIPv6Address(), or toString(). You can check the 433 type with protocol(). 434 434 435 435 \note Please note that QHostAddress does not do DNS lookups. … … 680 680 2130706433 (i.e. 0x7f000001). 681 681 682 This value is only valid if isIp4Addr() returns true. 682 This value is only valid if the Protocol() is 683 \l{QAbstractSocket::}{IPv4Protocol}. 683 684 684 685 \sa toString() … … 705 706 \snippet doc/src/snippets/code/src_network_kernel_qhostaddress.cpp 0 706 707 707 This value is only valid if isIPv6Address() returns true. 708 This value is only valid if the protocol() is 709 \l{QAbstractSocket::}{IPv6Protocol}. 708 710 709 711 \sa toString() … … 1098 1100 to the stream. 1099 1101 1100 \sa { Format of the QDataStream operators}1102 \sa {Serializing Qt Data Types} 1101 1103 */ 1102 1104 QDataStream &operator<<(QDataStream &out, const QHostAddress &address) … … 1128 1130 reference to the stream. 1129 1131 1130 \sa { Format of the QDataStream operators}1132 \sa {Serializing Qt Data Types} 1131 1133 */ 1132 1134 QDataStream &operator>>(QDataStream &in, QHostAddress &address) -
trunk/src/network/kernel/qhostaddress.h
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) -
trunk/src/network/kernel/qhostaddress_p.h
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) -
trunk/src/network/kernel/qhostinfo.cpp
r769 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) … … 169 169 QHostInfo hostInfo(id); 170 170 hostInfo.setError(QHostInfo::HostNotFound); 171 hostInfo.setErrorString(Q Object::tr("No host name given"));171 hostInfo.setErrorString(QCoreApplication::translate("QHostInfo", "No host name given")); 172 172 QScopedPointer<QHostInfoResult> result(new QHostInfoResult); 173 173 QObject::connect(result.data(), SIGNAL(resultsReady(QHostInfo)), … … 244 244 #endif 245 245 246 return QHostInfoAgent::fromName(name); 246 QHostInfo hostInfo = QHostInfoAgent::fromName(name); 247 QHostInfoLookupManager *manager = theHostInfoLookupManager(); 248 manager->cache.put(name, hostInfo); 249 return hostInfo; 247 250 } 248 251 … … 468 471 resultEmitter.emitResultsReady(hostInfo); 469 472 473 // now also iterate through the postponed ones 474 { 475 QMutexLocker locker(&manager->mutex); 476 QMutableListIterator<QHostInfoRunnable*> iterator(manager->postponedLookups); 477 while (iterator.hasNext()) { 478 QHostInfoRunnable* postponed = iterator.next(); 479 if (toBeLookedUp == postponed->toBeLookedUp) { 480 // we can now emit 481 iterator.remove(); 482 hostInfo.setLookupId(postponed->id); 483 postponed->resultEmitter.emitResultsReady(hostInfo); 484 } 485 } 486 } 487 470 488 manager->lookupFinished(this); 471 489 … … 485 503 486 504 // don't qDeleteAll currentLookups, the QThreadPool has ownership 487 qDeleteAll(postponedLookups); 488 qDeleteAll(scheduledLookups); 489 qDeleteAll(finishedLookups); 505 clear(); 506 } 507 508 void QHostInfoLookupManager::clear() 509 { 510 { 511 QMutexLocker locker(&mutex); 512 qDeleteAll(postponedLookups); 513 qDeleteAll(scheduledLookups); 514 qDeleteAll(finishedLookups); 515 postponedLookups.clear(); 516 scheduledLookups.clear(); 517 finishedLookups.clear(); 518 } 519 520 threadPool.waitForDone(); 521 cache.clear(); 490 522 } 491 523 … … 579 611 580 612 QMutexLocker locker(&this->mutex); 613 614 // is postponed? delete and return 615 for (int i = 0; i < postponedLookups.length(); i++) { 616 if (postponedLookups.at(i)->id == id) { 617 delete postponedLookups.takeAt(i); 618 return; 619 } 620 } 621 622 // is scheduled? delete and return 623 for (int i = 0; i < scheduledLookups.length(); i++) { 624 if (scheduledLookups.at(i)->id == id) { 625 delete scheduledLookups.takeAt(i); 626 return; 627 } 628 } 629 581 630 if (!abortedLookups.contains(id)) 582 631 abortedLookups.append(id); … … 605 654 } 606 655 607 // This function returns immediat ly when we had a result in the cache, else it will later emit a signal656 // This function returns immediately when we had a result in the cache, else it will later emit a signal 608 657 QHostInfo qt_qhostinfo_lookup(const QString &name, QObject *receiver, const char *member, bool *valid, int *id) 609 658 { … … 631 680 QHostInfoLookupManager* manager = theHostInfoLookupManager(); 632 681 if (manager) { 633 manager->c ache.clear();682 manager->clear(); 634 683 } 635 684 } -
trunk/src/network/kernel/qhostinfo.h
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) -
trunk/src/network/kernel/qhostinfo_p.h
r769 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) … … 85 85 86 86 Q_SIGNALS: 87 void resultsReady(const QHostInfo info);87 void resultsReady(const QHostInfo &info); 88 88 }; 89 89 … … 117 117 // Do NOT use them outside of QAbstractSocket. 118 118 QHostInfo Q_NETWORK_EXPORT qt_qhostinfo_lookup(const QString &name, QObject *receiver, const char *member, bool *valid, int *id); 119 void Q_ NETWORK_EXPORT qt_qhostinfo_clear_cache();119 void Q_AUTOTEST_EXPORT qt_qhostinfo_clear_cache(); 120 120 void Q_AUTOTEST_EXPORT qt_qhostinfo_enable_cache(bool e); 121 121 … … 162 162 ~QHostInfoLookupManager(); 163 163 164 void clear(); 164 165 void work(); 165 166 … … 173 174 174 175 QHostInfoCache cache; 176 177 friend class QHostInfoRunnable; 175 178 protected: 176 179 QList<QHostInfoRunnable*> currentLookups; // in progress -
trunk/src/network/kernel/qhostinfo_unix.cpp
r769 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) … … 195 195 if (aceHostname.isEmpty()) { 196 196 results.setError(QHostInfo::HostNotFound); 197 results.setErrorString(hostName.isEmpty() ? QObject::tr("No host name given") : QObject::tr("Invalid hostname")); 197 results.setErrorString(hostName.isEmpty() ? 198 QCoreApplication::translate("QHostInfoAgent", "No host name given") : 199 QCoreApplication::translate("QHostInfoAgent", "Invalid hostname")); 198 200 return results; 199 201 } … … 209 211 hints.ai_flags = Q_ADDRCONFIG; 210 212 #endif 213 #ifdef Q_OS_SYMBIAN 214 # ifdef QHOSTINFO_DEBUG 215 qDebug() << "Setting flags: 'hints.ai_flags &= AI_V4MAPPED | AI_ALL'"; 216 # endif 217 #endif 211 218 212 219 int result = getaddrinfo(aceHostname.constData(), 0, &hints, &res); … … 215 222 // if the lookup failed with AI_ADDRCONFIG set, try again without it 216 223 hints.ai_flags = 0; 224 #ifdef Q_OS_SYMBIAN 225 # ifdef QHOSTINFO_DEBUG 226 qDebug() << "Setting flags: 'hints.ai_flags &= AI_V4MAPPED | AI_ALL'"; 227 # endif 228 hints.ai_flags &= AI_V4MAPPED | AI_ALL; 229 #endif 217 230 result = getaddrinfo(aceHostname.constData(), 0, &hints, &res); 218 231 } … … 223 236 QList<QHostAddress> addresses; 224 237 while (node) { 238 #ifdef QHOSTINFO_DEBUG 239 qDebug() << "getaddrinfo node: flags:" << node->ai_flags << "family:" << node->ai_family << "ai_socktype:" << node->ai_socktype << "ai_protocol:" << node->ai_protocol << "ai_addrlen:" << node->ai_addrlen; 240 #endif 225 241 if (node->ai_family == AF_INET) { 226 242 QHostAddress addr; … … 232 248 else if (node->ai_family == AF_INET6) { 233 249 QHostAddress addr; 234 addr.setAddress(((sockaddr_in6 *) node->ai_addr)->sin6_addr.s6_addr); 250 sockaddr_in6 *sa6 = (sockaddr_in6 *) node->ai_addr; 251 addr.setAddress(sa6->sin6_addr.s6_addr); 252 if (sa6->sin6_scope_id) 253 addr.setScopeId(QString::number(sa6->sin6_scope_id)); 235 254 if (!addresses.contains(addr)) 236 255 addresses.append(addr); -
trunk/src/network/kernel/qhostinfo_win.cpp
r769 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) … … 50 50 #include "private/qnativesocketengine_p.h" 51 51 #include <ws2tcpip.h> 52 #include < qlibrary.h>52 #include <private/qsystemlibrary_p.h> 53 53 #include <qmutex.h> 54 54 #include <qurl.h> … … 91 91 // back to gethostbyname(), which has no IPv6 support. 92 92 #if !defined(Q_OS_WINCE) 93 local_getaddrinfo = (getaddrinfoProto) Q Library::resolve(QLatin1String("ws2_32.dll"), "getaddrinfo");94 local_freeaddrinfo = (freeaddrinfoProto) Q Library::resolve(QLatin1String("ws2_32.dll"), "freeaddrinfo");95 local_getnameinfo = (getnameinfoProto) Q Library::resolve(QLatin1String("ws2_32.dll"), "getnameinfo");93 local_getaddrinfo = (getaddrinfoProto) QSystemLibrary::resolve(QLatin1String("ws2_32"), "getaddrinfo"); 94 local_freeaddrinfo = (freeaddrinfoProto) QSystemLibrary::resolve(QLatin1String("ws2_32"), "freeaddrinfo"); 95 local_getnameinfo = (getnameinfoProto) QSystemLibrary::resolve(QLatin1String("ws2_32"), "getnameinfo"); 96 96 #else 97 local_getaddrinfo = (getaddrinfoProto) Q Library::resolve(QLatin1String("ws2.dll"), "getaddrinfo");98 local_freeaddrinfo = (freeaddrinfoProto) Q Library::resolve(QLatin1String("ws2.dll"), "freeaddrinfo");99 local_getnameinfo = (getnameinfoProto) Q Library::resolve(QLatin1String("ws2.dll"), "getnameinfo");97 local_getaddrinfo = (getaddrinfoProto) QSystemLibrary::resolve(QLatin1String("ws2"), "getaddrinfo"); 98 local_freeaddrinfo = (freeaddrinfoProto) QSystemLibrary::resolve(QLatin1String("ws2"), "freeaddrinfo"); 99 local_getnameinfo = (getnameinfoProto) QSystemLibrary::resolve(QLatin1String("ws2"), "getnameinfo"); 100 100 #endif 101 101 } -
trunk/src/network/kernel/qnetworkinterface.cpp
r769 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) -
trunk/src/network/kernel/qnetworkinterface.h
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) -
trunk/src/network/kernel/qnetworkinterface_p.h
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) -
trunk/src/network/kernel/qnetworkinterface_symbian.cpp
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) -
trunk/src/network/kernel/qnetworkinterface_unix.cpp
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) -
trunk/src/network/kernel/qnetworkinterface_win.cpp
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) … … 49 49 #include <qhash.h> 50 50 #include <qurl.h> 51 #include <private/qsystemlibrary_p.h> 51 52 52 53 QT_BEGIN_NAMESPACE … … 67 68 done = true; 68 69 69 HINSTANCE iphlpapiHnd = LoadLibrary(L"iphlpapi");70 HINSTANCE iphlpapiHnd = QSystemLibrary::load(L"iphlpapi"); 70 71 if (iphlpapiHnd == NULL) 71 72 return; -
trunk/src/network/kernel/qnetworkinterface_win_p.h
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) -
trunk/src/network/kernel/qnetworkproxy.cpp
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) … … 427 427 : d(0) 428 428 { 429 globalNetworkProxy()->init(); 429 if (QGlobalNetworkProxy *globalProxy = globalNetworkProxy()) 430 globalProxy->init(); 430 431 } 431 432 … … 442 443 : d(new QNetworkProxyPrivate(type, hostName, port, user, password)) 443 444 { 444 globalNetworkProxy()->init(); 445 if (QGlobalNetworkProxy *globalProxy = globalNetworkProxy()) 446 globalProxy->init(); 445 447 } 446 448 … … 1139 1141 such object, the factory will be queried for sockets created by 1140 1142 that framework only. 1143 1144 \section1 System Proxies 1145 1146 You can configure a factory to use the system proxy's settings. 1147 Call the setUseSystemConfiguration() function with true to enable 1148 this behavior, or false to disable it. 1149 1150 Similarly, you can use a factory to make queries directly to the 1151 system proxy by calling its systemProxyForQuery() function. 1152 1153 \warning Depending on the configuration of the user's system, the 1154 use of system proxy features on certain platforms may be subject 1155 to limitations. The systemProxyForQuery() documentation contains a 1156 list of these limitations for those platforms that are affected. 1141 1157 */ 1142 1158 … … 1160 1176 1161 1177 /*! 1178 \since 4.6 1179 1162 1180 Enables the use of the platform-specific proxy settings, and only those. 1163 1181 See systemProxyForQuery() for more information. … … 1165 1183 Internally, this method (when called with \a enable set to true) 1166 1184 sets an application-wide proxy factory. For this reason, this method 1167 is mutually exclusive with setApplicationProxyFactory : calling1168 setApplicationProxyFactory overrides the use of the system-wide proxy,1169 and calling setUseSystemConfiguration overrides any1185 is mutually exclusive with setApplicationProxyFactory(): calling 1186 setApplicationProxyFactory() overrides the use of the system-wide proxy, 1187 and calling setUseSystemConfiguration() overrides any 1170 1188 application proxy or proxy factory that was previously set. 1171 1189 1172 \since 4.6 1190 \note See the systemProxyForQuery() documentation for a list of 1191 limitations related to the use of system proxies. 1173 1192 */ 1174 1193 void QNetworkProxyFactory::setUseSystemConfiguration(bool enable) … … 1265 1284 listed here. 1266 1285 1267 On MacOS X, this function will ignore the Proxy Auto Configuration 1286 \list 1287 \o On MacOS X, this function will ignore the Proxy Auto Configuration 1268 1288 settings, since it cannot execute the associated ECMAScript code. 1289 1290 \o On Windows platforms, this function may take several seconds to 1291 execute depending on the configuration of the user's system. 1292 \endlist 1269 1293 */ 1270 1294 -
trunk/src/network/kernel/qnetworkproxy.h
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) -
trunk/src/network/kernel/qnetworkproxy_generic.cpp
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) -
trunk/src/network/kernel/qnetworkproxy_mac.cpp
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) … … 158 158 } 159 159 160 if (isHostExcluded(dict, query.peerHostName())) 160 if (isHostExcluded(dict, query.peerHostName())) { 161 CFRelease(dict); 161 162 return result; // no proxy for this host 163 } 162 164 163 165 // is there a PAC enabled? If so, use it first. … … 223 225 } 224 226 227 CFRelease(dict); 225 228 return result; 226 229 } -
trunk/src/network/kernel/qnetworkproxy_win.cpp
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) … … 52 52 #include <qt_windows.h> 53 53 #include <wininet.h> 54 #include <private/qsystemlibrary_p.h> 54 55 55 56 /* … … 100 101 #define WINHTTP_NO_PROXY_NAME NULL 101 102 #define WINHTTP_NO_PROXY_BYPASS NULL 103 104 #define WINHTTP_ERROR_BASE 12000 105 #define ERROR_WINHTTP_LOGIN_FAILURE (WINHTTP_ERROR_BASE + 15) 106 #define ERROR_WINHTTP_AUTODETECTION_FAILED (WINHTTP_ERROR_BASE + 180) 102 107 103 108 QT_BEGIN_NAMESPACE … … 274 279 #else 275 280 // load the winhttp.dll library 276 HINSTANCE winhttpHnd = LoadLibrary(L"winhttp");277 if (! winhttpHnd)281 QSystemLibrary lib(L"winhttp"); 282 if (!lib.load()) 278 283 return; // failed to load 279 284 280 ptrWinHttpOpen = (PtrWinHttpOpen) GetProcAddress(winhttpHnd,"WinHttpOpen");281 ptrWinHttpCloseHandle = (PtrWinHttpCloseHandle) GetProcAddress(winhttpHnd,"WinHttpCloseHandle");282 ptrWinHttpGetProxyForUrl = (PtrWinHttpGetProxyForUrl) GetProcAddress(winhttpHnd,"WinHttpGetProxyForUrl");283 ptrWinHttpGetDefaultProxyConfiguration = (PtrWinHttpGetDefaultProxyConfiguration) GetProcAddress(winhttpHnd,"WinHttpGetDefaultProxyConfiguration");284 ptrWinHttpGetIEProxyConfigForCurrentUser = (PtrWinHttpGetIEProxyConfigForCurrentUser) GetProcAddress(winhttpHnd,"WinHttpGetIEProxyConfigForCurrentUser");285 ptrWinHttpOpen = (PtrWinHttpOpen)lib.resolve("WinHttpOpen"); 286 ptrWinHttpCloseHandle = (PtrWinHttpCloseHandle)lib.resolve("WinHttpCloseHandle"); 287 ptrWinHttpGetProxyForUrl = (PtrWinHttpGetProxyForUrl)lib.resolve("WinHttpGetProxyForUrl"); 288 ptrWinHttpGetDefaultProxyConfiguration = (PtrWinHttpGetDefaultProxyConfiguration)lib.resolve("WinHttpGetDefaultProxyConfiguration"); 289 ptrWinHttpGetIEProxyConfigForCurrentUser = (PtrWinHttpGetIEProxyConfigForCurrentUser)lib.resolve("WinHttpGetIEProxyConfigForCurrentUser"); 285 290 286 291 // Try to obtain the Internet Explorer configuration. … … 321 326 isAutoConfig = true; 322 327 memset(&autoProxyOptions, 0, sizeof autoProxyOptions); 323 autoProxyOptions.fAutoLogonIfChallenged = true;328 autoProxyOptions.fAutoLogonIfChallenged = false; 324 329 if (ieProxyConfig.fAutoDetect) { 325 330 autoProxyOptions.dwFlags = WINHTTP_AUTOPROXY_AUTO_DETECT; … … 378 383 url.setScheme(QLatin1String("https")); 379 384 } 380 if (ptrWinHttpGetProxyForUrl(sp->hHttpSession, 381 (LPCWSTR)url.toString().utf16(), 382 &sp->autoProxyOptions, 383 &proxyInfo)) { 385 386 bool getProxySucceeded = ptrWinHttpGetProxyForUrl(sp->hHttpSession, 387 (LPCWSTR)url.toString().utf16(), 388 &sp->autoProxyOptions, 389 &proxyInfo); 390 DWORD getProxyError = GetLastError(); 391 392 if (!getProxySucceeded 393 && (ERROR_WINHTTP_LOGIN_FAILURE == getProxyError)) { 394 // We first tried without AutoLogon, because this might prevent caching the result. 395 // But now we've to enable it (http://msdn.microsoft.com/en-us/library/aa383153%28v=VS.85%29.aspx) 396 sp->autoProxyOptions.fAutoLogonIfChallenged = TRUE; 397 getProxySucceeded = ptrWinHttpGetProxyForUrl(sp->hHttpSession, 398 (LPCWSTR)url.toString().utf16(), 399 &sp->autoProxyOptions, 400 &proxyInfo); 401 getProxyError = GetLastError(); 402 } 403 404 if (getProxySucceeded) { 384 405 // yes, we got a config for this URL 385 406 QString proxyBypass = QString::fromWCharArray(proxyInfo.lpszProxyBypass); … … 396 417 397 418 // GetProxyForUrl failed 419 420 if (ERROR_WINHTTP_AUTODETECTION_FAILED == getProxyError) { 421 //No config file could be retrieved on the network. 422 //Don't search for it next time again. 423 sp->isAutoConfig = false; 424 } 425 398 426 return sp->defaultResult; 399 427 } -
trunk/src/network/kernel/qurlinfo.cpp
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) -
trunk/src/network/kernel/qurlinfo.h
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com)
Note:
See TracChangeset
for help on using the changeset viewer.