QtNetwork: use _L1 for for creating Latin-1 string literals

Task-number: QTBUG-98434
Change-Id: Ic235b92377203f7a1429ae7fd784c4a1fa893e9f
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
This commit is contained in:
Sona Kurazyan 2022-04-12 15:03:54 +02:00
parent f2637e1a77
commit 46d6cc47cf
53 changed files with 514 additions and 441 deletions

View File

@ -50,6 +50,8 @@
QT_BEGIN_NAMESPACE
using namespace Qt::StringLiterals;
QT_IMPL_METATYPE_EXTERN_TAGGED(Http2::Settings, Http2__Settings)
Q_LOGGING_CATEGORY(QT_HTTP2, "qt.network.http2")
@ -130,7 +132,7 @@ void qt_error(quint32 errorCode, QNetworkReply::NetworkError &error,
{
if (errorCode > quint32(HTTP_1_1_REQUIRED)) {
error = QNetworkReply::ProtocolFailure;
errorMessage = QLatin1String("RST_STREAM with unknown error code (%1)");
errorMessage = "RST_STREAM with unknown error code (%1)"_L1;
errorMessage = errorMessage.arg(errorCode);
return;
}
@ -144,61 +146,61 @@ void qt_error(quint32 errorCode, QNetworkReply::NetworkError &error,
break;
case PROTOCOL_ERROR:
error = QNetworkReply::ProtocolFailure;
errorMessage = QLatin1String("HTTP/2 protocol error");
errorMessage = "HTTP/2 protocol error"_L1;
break;
case INTERNAL_ERROR:
error = QNetworkReply::InternalServerError;
errorMessage = QLatin1String("Internal server error");
errorMessage = "Internal server error"_L1;
break;
case FLOW_CONTROL_ERROR:
error = QNetworkReply::ProtocolFailure;
errorMessage = QLatin1String("Flow control error");
errorMessage = "Flow control error"_L1;
break;
case SETTINGS_TIMEOUT:
error = QNetworkReply::TimeoutError;
errorMessage = QLatin1String("SETTINGS ACK timeout error");
errorMessage = "SETTINGS ACK timeout error"_L1;
break;
case STREAM_CLOSED:
error = QNetworkReply::ProtocolFailure;
errorMessage = QLatin1String("Server received frame(s) on a half-closed stream");
errorMessage = "Server received frame(s) on a half-closed stream"_L1;
break;
case FRAME_SIZE_ERROR:
error = QNetworkReply::ProtocolFailure;
errorMessage = QLatin1String("Server received a frame with an invalid size");
errorMessage = "Server received a frame with an invalid size"_L1;
break;
case REFUSE_STREAM:
error = QNetworkReply::ProtocolFailure;
errorMessage = QLatin1String("Server refused a stream");
errorMessage = "Server refused a stream"_L1;
break;
case CANCEL:
error = QNetworkReply::ProtocolFailure;
errorMessage = QLatin1String("Stream is no longer needed");
errorMessage = "Stream is no longer needed"_L1;
break;
case COMPRESSION_ERROR:
error = QNetworkReply::ProtocolFailure;
errorMessage = QLatin1String("Server is unable to maintain the "
"header compression context for the connection");
errorMessage = "Server is unable to maintain the "
"header compression context for the connection"_L1;
break;
case CONNECT_ERROR:
// TODO: in Qt6 we'll have to add more error codes in QNetworkReply.
error = QNetworkReply::UnknownNetworkError;
errorMessage = QLatin1String("The connection established in response "
"to a CONNECT request was reset or abnormally closed");
errorMessage = "The connection established in response "
"to a CONNECT request was reset or abnormally closed"_L1;
break;
case ENHANCE_YOUR_CALM:
error = QNetworkReply::UnknownServerError;
errorMessage = QLatin1String("Server dislikes our behavior, excessive load detected.");
errorMessage = "Server dislikes our behavior, excessive load detected."_L1;
break;
case INADEQUATE_SECURITY:
error = QNetworkReply::ContentAccessDenied;
errorMessage = QLatin1String("The underlying transport has properties "
"that do not meet minimum security "
"requirements");
errorMessage = "The underlying transport has properties "
"that do not meet minimum security "
"requirements"_L1;
break;
case HTTP_1_1_REQUIRED:
error = QNetworkReply::ProtocolFailure;
errorMessage = QLatin1String("Server requires that HTTP/1.1 "
"be used instead of HTTP/2.");
errorMessage = "Server requires that HTTP/1.1 "
"be used instead of HTTP/2."_L1;
}
}

View File

@ -52,6 +52,8 @@
QT_BEGIN_NAMESPACE
using namespace Qt::StringLiterals;
static QString host_name_to_settings_key(const QString &hostName)
{
const QByteArray hostNameAsHex(hostName.toUtf8().toHex());
@ -136,13 +138,13 @@ QString QHstsStore::absoluteFilePath(const QString &dirName)
{
const QDir dir(dirName.isEmpty() ? QStandardPaths::writableLocation(QStandardPaths::CacheLocation)
: dirName);
return dir.absoluteFilePath(QLatin1String("hstsstore"));
return dir.absoluteFilePath("hstsstore"_L1);
}
void QHstsStore::beginHstsGroups()
{
store.beginGroup(QLatin1String("StrictTransportSecurity"));
store.beginGroup(QLatin1String("Policies"));
store.beginGroup("StrictTransportSecurity"_L1);
store.beginGroup("Policies"_L1);
}
void QHstsStore::endHstsGroups()

View File

@ -65,6 +65,8 @@
QT_BEGIN_NAMESPACE
using namespace Qt::StringLiterals;
namespace
{
@ -239,8 +241,7 @@ void QHttp2ProtocolHandler::_q_uploadDataReadyRead()
auto &stream = activeStreams[streamID];
if (!sendDATA(stream)) {
finishStreamWithError(stream, QNetworkReply::UnknownNetworkError,
QLatin1String("failed to send DATA"));
finishStreamWithError(stream, QNetworkReply::UnknownNetworkError, "failed to send DATA"_L1);
sendRST_STREAM(streamID, INTERNAL_ERROR);
markAsReset(streamID);
deleteActiveStream(streamID);
@ -354,8 +355,7 @@ bool QHttp2ProtocolHandler::sendRequest()
for (auto it = requests.begin(), endIt = requests.end(); it != endIt;) {
const auto &pair = *it;
const QString scheme(pair.first.url().scheme());
if (scheme == QLatin1String("preconnect-http")
|| scheme == QLatin1String("preconnect-https")) {
if (scheme == "preconnect-http"_L1 || scheme == "preconnect-https"_L1) {
m_connection->preConnectFinished();
emit pair.second->finished();
it = requests.erase(it);
@ -410,14 +410,14 @@ bool QHttp2ProtocolHandler::sendRequest()
Stream &newStream = activeStreams[newStreamID];
if (!sendHEADERS(newStream)) {
finishStreamWithError(newStream, QNetworkReply::UnknownNetworkError,
QLatin1String("failed to send HEADERS frame(s)"));
"failed to send HEADERS frame(s)"_L1);
deleteActiveStream(newStreamID);
continue;
}
if (newStream.data() && !sendDATA(newStream)) {
finishStreamWithError(newStream, QNetworkReply::UnknownNetworkError,
QLatin1String("failed to send DATA frame(s)"));
"failed to send DATA frame(s)"_L1);
sendRST_STREAM(newStreamID, INTERNAL_ERROR);
markAsReset(newStreamID);
deleteActiveStream(newStreamID);
@ -616,8 +616,7 @@ void QHttp2ProtocolHandler::handleDATA()
auto &stream = activeStreams[streamID];
if (qint32(inboundFrame.payloadSize()) > stream.recvWindow) {
finishStreamWithError(stream, QNetworkReply::ProtocolFailure,
QLatin1String("flow control error"));
finishStreamWithError(stream, QNetworkReply::ProtocolFailure, "flow control error"_L1);
sendRST_STREAM(streamID, FLOW_CONTROL_ERROR);
markAsReset(streamID);
deleteActiveStream(streamID);
@ -891,7 +890,7 @@ void QHttp2ProtocolHandler::handleGOAWAY()
// successful completion.
if (errorCode == HTTP2_NO_ERROR) {
error = QNetworkReply::ContentReSendError;
message = QLatin1String("Server stopped accepting new streams before this stream was established");
message = "Server stopped accepting new streams before this stream was established"_L1;
}
for (quint32 id = lastStreamID; id < nextID; id += 2) {
@ -931,7 +930,7 @@ void QHttp2ProtocolHandler::handleWINDOW_UPDATE()
auto &stream = activeStreams[streamID];
if (!valid || sum_will_overflow(stream.sendWindow, delta)) {
finishStreamWithError(stream, QNetworkReply::ProtocolFailure,
QLatin1String("invalid WINDOW_UPDATE delta"));
"invalid WINDOW_UPDATE delta"_L1);
sendRST_STREAM(streamID, PROTOCOL_ERROR);
markAsReset(streamID);
deleteActiveStream(streamID);
@ -986,7 +985,7 @@ void QHttp2ProtocolHandler::handleContinuedHEADERS()
// (these streams are in halfClosedLocal or open state) or
// remote-reserved streams from a server's PUSH_PROMISE.
finishStreamWithError(stream, QNetworkReply::ProtocolFailure,
QLatin1String("HEADERS on invalid stream"));
"HEADERS on invalid stream"_L1);
sendRST_STREAM(streamID, CANCEL);
markAsReset(streamID);
deleteActiveStream(streamID);
@ -1077,7 +1076,7 @@ bool QHttp2ProtocolHandler::acceptSetting(Http2::Settings identifier, quint32 ne
for (auto id : brokenStreams) {
auto &stream = activeStreams[id];
finishStreamWithError(stream, QNetworkReply::ProtocolFailure,
QLatin1String("SETTINGS window overflow"));
"SETTINGS window overflow"_L1);
sendRST_STREAM(id, PROTOCOL_ERROR);
markAsReset(id);
deleteActiveStream(id);
@ -1491,7 +1490,7 @@ void QHttp2ProtocolHandler::resumeSuspendedStreams()
Stream &stream = activeStreams[streamID];
if (!sendDATA(stream)) {
finishStreamWithError(stream, QNetworkReply::UnknownNetworkError,
QLatin1String("failed to send DATA"));
"failed to send DATA"_L1);
sendRST_STREAM(streamID, INTERNAL_ERROR);
markAsReset(streamID);
deleteActiveStream(streamID);

View File

@ -66,6 +66,8 @@
QT_BEGIN_NAMESPACE
using namespace Qt::StringLiterals;
const int QHttpNetworkConnectionPrivate::defaultHttpChannelCount = 6;
// The pipeline length. So there will be 4 requests in flight.
@ -318,12 +320,12 @@ void QHttpNetworkConnectionPrivate::prepareRequest(HttpMessagePair &messagePair)
if (value.isEmpty()) {
QString systemLocale = QLocale::system().name().replace(QChar::fromLatin1('_'),QChar::fromLatin1('-'));
QString acceptLanguage;
if (systemLocale == QLatin1String("C"))
if (systemLocale == "C"_L1)
acceptLanguage = QString::fromLatin1("en,*");
else if (systemLocale.startsWith(QLatin1String("en-")))
acceptLanguage = systemLocale + QLatin1String(",*");
else if (systemLocale.startsWith("en-"_L1))
acceptLanguage = systemLocale + ",*"_L1;
else
acceptLanguage = systemLocale + QLatin1String(",en,*");
acceptLanguage = systemLocale + ",en,*"_L1;
request.setHeaderField("Accept-Language", std::move(acceptLanguage).toLatin1());
}
@ -567,7 +569,7 @@ QHttpNetworkConnectionPrivate::parseRedirectResponse(QHttpNetworkReply *reply)
// Check redirect url protocol
const QUrl priorUrl(reply->request().url());
if (redirectUrl.scheme() == QLatin1String("http") || redirectUrl.scheme() == QLatin1String("https")) {
if (redirectUrl.scheme() == "http"_L1 || redirectUrl.scheme() == "https"_L1) {
switch (reply->request().redirectPolicy()) {
case QNetworkRequest::NoLessSafeRedirectPolicy:
// Here we could handle https->http redirects as InsecureProtocolError.

View File

@ -50,6 +50,8 @@
QT_BEGIN_NAMESPACE
using namespace Qt::StringLiterals;
QHttpNetworkReply::QHttpNetworkReply(const QUrl &url, QObject *parent)
: QObject(*new QHttpNetworkReplyPrivate(url), parent)
{
@ -352,8 +354,7 @@ QHttpNetworkReplyPrivate::QHttpNetworkReplyPrivate(const QUrl &newUrl)
{
QString scheme = newUrl.scheme();
if (scheme == QLatin1String("preconnect-http")
|| scheme == QLatin1String("preconnect-https"))
if (scheme == "preconnect-http"_L1 || scheme == "preconnect-https"_L1)
// make sure we do not close the socket after preconnecting
connectionCloseEnabled = false;
}

View File

@ -44,6 +44,8 @@
QT_BEGIN_NAMESPACE
using namespace Qt::StringLiterals;
QHttpProtocolHandler::QHttpProtocolHandler(QHttpNetworkConnectionChannel *channel)
: QAbstractProtocolHandler(channel)
{
@ -273,8 +275,7 @@ bool QHttpProtocolHandler::sendRequest()
return false;
}
QString scheme = m_channel->request.url().scheme();
if (scheme == QLatin1String("preconnect-http")
|| scheme == QLatin1String("preconnect-https")) {
if (scheme == "preconnect-http"_L1 || scheme == "preconnect-https"_L1) {
m_channel->state = QHttpNetworkConnectionChannel::IdleState;
m_reply->d_func()->state = QHttpNetworkReplyPrivate::AllDoneState;
m_channel->allDone();

View File

@ -52,6 +52,8 @@
QT_BEGIN_NAMESPACE
using namespace Qt::StringLiterals;
static QNetworkReply::NetworkError statusCodeFromHttp(int httpStatusCode, const QUrl &url)
{
QNetworkReply::NetworkError code;
@ -128,14 +130,12 @@ static QByteArray makeCacheKey(QUrl &url, QNetworkProxy *proxy, const QString &p
QString result;
QUrl copy = url;
QString scheme = copy.scheme();
bool isEncrypted = scheme == QLatin1String("https")
|| scheme == QLatin1String("preconnect-https");
bool isEncrypted = scheme == "https"_L1 || scheme == "preconnect-https"_L1;
copy.setPort(copy.port(isEncrypted ? 443 : 80));
if (scheme == QLatin1String("preconnect-http")) {
copy.setScheme(QLatin1String("http"));
} else if (scheme == QLatin1String("preconnect-https")) {
copy.setScheme(QLatin1String("https"));
}
if (scheme == "preconnect-http"_L1)
copy.setScheme("http"_L1);
else if (scheme == "preconnect-https"_L1)
copy.setScheme("https"_L1);
result = copy.toString(QUrl::RemoveUserInfo | QUrl::RemovePath |
QUrl::RemoveQuery | QUrl::RemoveFragment | QUrl::FullyEncoded);
@ -145,12 +145,12 @@ static QByteArray makeCacheKey(QUrl &url, QNetworkProxy *proxy, const QString &p
switch (proxy->type()) {
case QNetworkProxy::Socks5Proxy:
key.setScheme(QLatin1String("proxy-socks5"));
key.setScheme("proxy-socks5"_L1);
break;
case QNetworkProxy::HttpProxy:
case QNetworkProxy::HttpCachingProxy:
key.setScheme(QLatin1String("proxy-http"));
key.setScheme("proxy-http"_L1);
break;
default:

View File

@ -51,6 +51,8 @@
QT_BEGIN_NAMESPACE
using namespace Qt::StringLiterals;
class QNetworkAuthenticationCache : private QList<QNetworkAuthenticationCredential>,
public QNetworkAccessCache::CacheableObject
{
@ -105,16 +107,16 @@ static QByteArray proxyAuthenticationKey(const QNetworkProxy &proxy, const QStri
switch (proxy.type()) {
case QNetworkProxy::Socks5Proxy:
key.setScheme(QLatin1String("proxy-socks5"));
key.setScheme("proxy-socks5"_L1);
break;
case QNetworkProxy::HttpProxy:
case QNetworkProxy::HttpCachingProxy:
key.setScheme(QLatin1String("proxy-http"));
key.setScheme("proxy-http"_L1);
break;
case QNetworkProxy::FtpCachingProxy:
key.setScheme(QLatin1String("proxy-ftp"));
key.setScheme("proxy-ftp"_L1);
break;
case QNetworkProxy::DefaultProxy:

View File

@ -46,6 +46,8 @@
QT_BEGIN_NAMESPACE
using namespace Qt::StringLiterals;
#ifdef QT_BUILD_INTERNAL
enum {
@ -74,7 +76,7 @@ QNetworkAccessDebugPipeBackendFactory::create(QNetworkAccessManager::Operation o
}
QUrl url = request.url();
if (url.scheme() == QLatin1String("debugpipe"))
if (url.scheme() == "debugpipe"_L1)
return new QNetworkAccessDebugPipeBackend;
return nullptr;
}
@ -109,7 +111,7 @@ void QNetworkAccessDebugPipeBackend::open()
// socket bytes written -> we can push more from upstream to socket
connect(&socket, SIGNAL(bytesWritten(qint64)), SLOT(socketBytesWritten(qint64)));
bareProtocol = QUrlQuery(url()).queryItemValue(QLatin1String("bare")) == QLatin1String("1");
bareProtocol = QUrlQuery(url()).queryItemValue("bare"_L1) == "1"_L1;
if (operation() == QNetworkAccessManager::PutOperation) {
createUploadByteDevice();

View File

@ -47,6 +47,8 @@
QT_BEGIN_NAMESPACE
using namespace Qt::StringLiterals;
QStringList QNetworkAccessFileBackendFactory::supportedSchemes() const
{
QStringList schemes;
@ -74,9 +76,9 @@ QNetworkAccessFileBackendFactory::create(QNetworkAccessManager::Operation op,
}
QUrl url = request.url();
if (url.scheme().compare(QLatin1String("qrc"), Qt::CaseInsensitive) == 0
if (url.scheme().compare("qrc"_L1, Qt::CaseInsensitive) == 0
#if defined(Q_OS_ANDROID)
|| url.scheme().compare(QLatin1String("assets"), Qt::CaseInsensitive) == 0
|| url.scheme().compare("assets"_L1, Qt::CaseInsensitive) == 0
#endif
|| url.isLocalFile()) {
return new QNetworkAccessFileBackend;
@ -112,7 +114,7 @@ void QNetworkAccessFileBackend::open()
{
QUrl url = this->url();
if (url.host() == QLatin1String("localhost"))
if (url.host() == "localhost"_L1)
url.setHost(QString());
#if !defined(Q_OS_WIN)
// do not allow UNC paths on Unix
@ -125,17 +127,17 @@ void QNetworkAccessFileBackend::open()
}
#endif // !defined(Q_OS_WIN)
if (url.path().isEmpty())
url.setPath(QLatin1String("/"));
url.setPath("/"_L1);
setUrl(url);
QString fileName = url.toLocalFile();
if (fileName.isEmpty()) {
if (url.scheme() == QLatin1String("qrc")) {
if (url.scheme() == "qrc"_L1) {
fileName = u':' + url.path();
} else {
#if defined(Q_OS_ANDROID)
if (url.scheme() == QLatin1String("assets"))
fileName = QLatin1String("assets:") + url.path();
if (url.scheme() == "assets"_L1)
fileName = "assets:"_L1 + url.path();
else
#endif
fileName = url.toString(QUrl::RemoveAuthority | QUrl::RemoveFragment | QUrl::RemoveQuery);

View File

@ -100,14 +100,15 @@
QT_BEGIN_NAMESPACE
using namespace Qt::StringLiterals;
Q_APPLICATION_STATIC(QNetworkAccessFileBackendFactory, fileBackend)
#ifdef QT_BUILD_INTERNAL
Q_GLOBAL_STATIC(QNetworkAccessDebugPipeBackendFactory, debugpipeBackend)
#endif
Q_APPLICATION_STATIC(QFactoryLoader, loader, QNetworkAccessBackendFactory_iid,
QLatin1String("/networkaccess"))
Q_APPLICATION_STATIC(QFactoryLoader, loader, QNetworkAccessBackendFactory_iid, "/networkaccess"_L1)
#if defined(Q_OS_MACOS)
bool getProxyAuth(const QString& proxyHostname, const QString &scheme, QString& username, QString& password)
@ -116,13 +117,13 @@ bool getProxyAuth(const QString& proxyHostname, const QString &scheme, QString&
SecKeychainItemRef itemRef;
bool retValue = false;
SecProtocolType protocolType = kSecProtocolTypeAny;
if (scheme.compare(QLatin1String("ftp"),Qt::CaseInsensitive)==0) {
if (scheme.compare("ftp"_L1, Qt::CaseInsensitive) == 0) {
protocolType = kSecProtocolTypeFTPProxy;
} else if (scheme.compare(QLatin1String("http"),Qt::CaseInsensitive)==0
|| scheme.compare(QLatin1String("preconnect-http"),Qt::CaseInsensitive)==0) {
} else if (scheme.compare("http"_L1, Qt::CaseInsensitive) == 0
|| scheme.compare("preconnect-http"_L1, Qt::CaseInsensitive) == 0) {
protocolType = kSecProtocolTypeHTTPProxy;
} else if (scheme.compare(QLatin1String("https"),Qt::CaseInsensitive)==0
|| scheme.compare(QLatin1String("preconnect-https"),Qt::CaseInsensitive)==0) {
} else if (scheme.compare("https"_L1,Qt::CaseInsensitive)==0
|| scheme.compare("preconnect-https"_L1, Qt::CaseInsensitive) == 0) {
protocolType = kSecProtocolTypeHTTPSProxy;
}
QByteArray proxyHostnameUtf8(proxyHostname.toUtf8());
@ -978,7 +979,7 @@ void QNetworkAccessManager::connectToHostEncrypted(const QString &hostName, quin
QUrl url;
url.setHost(hostName);
url.setPort(port);
url.setScheme(QLatin1String("preconnect-https"));
url.setScheme("preconnect-https"_L1);
QNetworkRequest request(url);
if (sslConfiguration != QSslConfiguration::defaultConfiguration())
request.setSslConfiguration(sslConfiguration);
@ -1009,7 +1010,7 @@ void QNetworkAccessManager::connectToHost(const QString &hostName, quint16 port)
QUrl url;
url.setHost(hostName);
url.setPort(port);
url.setScheme(QLatin1String("preconnect-http"));
url.setScheme("preconnect-http"_L1);
QNetworkRequest request(url);
get(request);
}
@ -1164,13 +1165,13 @@ QNetworkReply *QNetworkAccessManager::createRequest(QNetworkAccessManager::Opera
|| op == QNetworkAccessManager::HeadOperation) {
if (isLocalFile
#ifdef Q_OS_ANDROID
|| scheme == QLatin1String("assets")
|| scheme == "assets"_L1
#endif
|| scheme == QLatin1String("qrc")) {
|| scheme == "qrc"_L1) {
return new QNetworkReplyFileImpl(this, req, op);
}
if (scheme == QLatin1String("data"))
if (scheme == "data"_L1)
return new QNetworkReplyDataImpl(this, req, op);
// A request with QNetworkRequest::AlwaysCache does not need any bearer management
@ -1212,7 +1213,7 @@ QNetworkReply *QNetworkAccessManager::createRequest(QNetworkAccessManager::Opera
#ifdef Q_OS_WASM
Q_UNUSED(isLocalFile);
// Support http, https, and relative urls
if (scheme == QLatin1String("http") || scheme == QLatin1String("https") || scheme.isEmpty()) {
if (scheme == "http"_L1 || scheme == "https"_L1 || scheme.isEmpty()) {
QNetworkReplyWasmImpl *reply = new QNetworkReplyWasmImpl(this);
QNetworkReplyWasmImplPrivate *priv = reply->d_func();
priv->manager = this;
@ -1246,7 +1247,7 @@ QNetworkReply *QNetworkAccessManager::createRequest(QNetworkAccessManager::Opera
// MUST NOT add one.
if (stsUrl.port() == 80)
stsUrl.setPort(443);
stsUrl.setScheme(QLatin1String("https"));
stsUrl.setScheme("https"_L1);
request.setUrl(stsUrl);
}
#endif

View File

@ -537,7 +537,7 @@ QByteArray QNetworkCookie::toRawForm(RawForm form) const
if (!isSessionCookie()) {
result += "; expires=";
result += QLocale::c().toString(d->expirationDate.toUTC(),
QLatin1String("ddd, dd-MMM-yyyy hh:mm:ss 'GMT")).toLatin1();
"ddd, dd-MMM-yyyy hh:mm:ss 'GMT"_L1).toLatin1();
}
if (!d->domain.isEmpty()) {
result += "; domain=";
@ -759,7 +759,7 @@ static QDateTime parseDateString(const QByteArray &dateString)
int ms = match.capturedView(4).toInt();
QStringView ampm = match.capturedView(5);
if (h < 12 && !ampm.isEmpty())
if (ampm == QLatin1String("pm"))
if (ampm == "pm"_L1)
h += 12;
time = QTime(h, m, s, ms);
#ifdef PARSEDATESTRINGDEBUG

View File

@ -57,6 +57,8 @@ QT_END_NAMESPACE
QT_BEGIN_NAMESPACE
using namespace Qt::StringLiterals;
/*!
\class QNetworkCookieJar
\since 4.4
@ -148,7 +150,7 @@ void QNetworkCookieJar::setAllCookies(const QList<QNetworkCookie> &cookieList)
static inline bool isParentPath(const QString &path, const QString &reference)
{
if ((path.isEmpty() && reference == QLatin1String("/")) || path.startsWith(reference)) {
if ((path.isEmpty() && reference == "/"_L1) || path.startsWith(reference)) {
//The cookie-path and the request-path are identical.
if (path.length() == reference.length())
return true;
@ -234,7 +236,7 @@ QList<QNetworkCookie> QNetworkCookieJar::cookiesForUrl(const QUrl &url) const
Q_D(const QNetworkCookieJar);
const QDateTime now = QDateTime::currentDateTimeUtc();
QList<QNetworkCookie> result;
bool isEncrypted = url.scheme() == QLatin1String("https");
bool isEncrypted = url.scheme() == "https"_L1;
// scan our cookies for something that matches
QList<QNetworkCookie>::ConstIterator it = d->allCookies.constBegin(),

View File

@ -56,15 +56,17 @@
#include <memory>
#define CACHE_POSTFIX QLatin1String(".d")
#define PREPARED_SLASH QLatin1String("prepared/")
#define CACHE_POSTFIX ".d"_L1
#define PREPARED_SLASH "prepared/"_L1
#define CACHE_VERSION 8
#define DATA_DIR QLatin1String("data")
#define DATA_DIR "data"_L1
#define MAX_COMPRESSION_SIZE (1024 * 1024 * 3)
QT_BEGIN_NAMESPACE
using namespace Qt::StringLiterals;
/*!
\class QNetworkDiskCache
\since 4.5
@ -606,7 +608,7 @@ QString QNetworkDiskCachePrivate::uniqueFileName(const QUrl &url)
QString QNetworkDiskCachePrivate::tmpCacheFileName() const
{
//The subdirectory is presumed to be already read for use.
return cacheDirectory + PREPARED_SLASH + QLatin1String("XXXXXX") + CACHE_POSTFIX;
return cacheDirectory + PREPARED_SLASH + "XXXXXX"_L1 + CACHE_POSTFIX;
}
/*!

View File

@ -49,6 +49,8 @@
QT_BEGIN_NAMESPACE
using namespace Qt::StringLiterals;
QT_IMPL_METATYPE_EXTERN_TAGGED(QNetworkRequest::KnownHeaders, QNetworkRequest__KnownHeaders)
QNetworkReplyFileImplPrivate::QNetworkReplyFileImplPrivate()
@ -82,7 +84,7 @@ QNetworkReplyFileImpl::QNetworkReplyFileImpl(QNetworkAccessManager *manager, con
d->managerPrivate = manager->d_func();
QUrl url = req.url();
if (url.host() == QLatin1String("localhost"))
if (url.host() == "localhost"_L1)
url.setHost(QString());
#if !defined(Q_OS_WIN)
@ -98,18 +100,18 @@ QNetworkReplyFileImpl::QNetworkReplyFileImpl(QNetworkAccessManager *manager, con
}
#endif
if (url.path().isEmpty())
url.setPath(QLatin1String("/"));
url.setPath("/"_L1);
setUrl(url);
QString fileName = url.toLocalFile();
if (fileName.isEmpty()) {
const QString scheme = url.scheme();
if (scheme == QLatin1String("qrc")) {
if (scheme == "qrc"_L1) {
fileName = u':' + url.path();
} else {
#if defined(Q_OS_ANDROID)
if (scheme == QLatin1String("assets"))
fileName = QLatin1String("assets:") + url.path();
if (scheme == "assets"_L1)
fileName = "assets:"_L1 + url.path();
else
#endif
fileName = url.toString(QUrl::RemoveAuthority | QUrl::RemoveFragment | QUrl::RemoveQuery);
@ -224,7 +226,7 @@ qint64 QNetworkReplyFileImpl::readData(char *data, qint64 maxlen)
return -1;
else {
setAttribute(QNetworkRequest::HttpStatusCodeAttribute, 200);
setAttribute(QNetworkRequest::HttpReasonPhraseAttribute, QLatin1String("OK"));
setAttribute(QNetworkRequest::HttpReasonPhraseAttribute, "OK"_L1);
return ret;
}
}

View File

@ -67,6 +67,8 @@
QT_BEGIN_NAMESPACE
using namespace Qt::StringLiterals;
class QNetworkProxy;
static inline bool isSeparator(char c)
@ -182,7 +184,7 @@ QNetworkReplyHttpImpl::QNetworkReplyHttpImpl(QNetworkAccessManager* const manage
d->outgoingData = outgoingData;
d->url = request.url();
#ifndef QT_NO_SSL
if (request.url().scheme() == QLatin1String("https"))
if (request.url().scheme() == "https"_L1)
d->sslConfiguration.reset(new QSslConfiguration(request.sslConfiguration()));
#endif
@ -658,13 +660,11 @@ void QNetworkReplyHttpImplPrivate::postRequest(const QNetworkRequest &newHttpReq
httpRequest.setRedirectCount(newHttpRequest.maximumRedirectsAllowed());
QString scheme = url.scheme();
bool ssl = (scheme == QLatin1String("https")
|| scheme == QLatin1String("preconnect-https"));
bool ssl = (scheme == "https"_L1 || scheme == "preconnect-https"_L1);
q->setAttribute(QNetworkRequest::ConnectionEncryptedAttribute, ssl);
httpRequest.setSsl(ssl);
bool preConnect = (scheme == QLatin1String("preconnect-http")
|| scheme == QLatin1String("preconnect-https"));
bool preConnect = (scheme == "preconnect-http"_L1 || scheme == "preconnect-https"_L1);
httpRequest.setPreConnect(preConnect);
#ifndef QT_NO_NETWORKPROXY
@ -1235,13 +1235,12 @@ void QNetworkReplyHttpImplPrivate::onRedirected(const QUrl &redirectUrl, int htt
// equal to "80", the port component value MUST be preserved;
// otherwise, if the URI does not contain an explicit port
// component, the UA MUST NOT add one.
url.setScheme(QLatin1String("https"));
url.setScheme("https"_L1);
if (url.port() == 80)
url.setPort(443);
}
const bool isLessSafe = schemeBefore == QLatin1String("https")
&& url.scheme() == QLatin1String("http");
const bool isLessSafe = schemeBefore == "https"_L1 && url.scheme() == "http"_L1;
if (httpRequest.redirectPolicy() == QNetworkRequest::NoLessSafeRedirectPolicy
&& isLessSafe) {
error(QNetworkReply::InsecureRedirectError,
@ -1341,7 +1340,7 @@ void QNetworkReplyHttpImplPrivate::replyDownloadMetaData(const QList<QPair<QByte
// RFC6797, 8.1
// If an HTTP response is received over insecure transport, the UA MUST
// ignore any present STS header field(s).
if (url.scheme() == QLatin1String("https") && managerPrivate->stsEnabled)
if (url.scheme() == "https"_L1 && managerPrivate->stsEnabled)
managerPrivate->stsCache.updateFromHeaders(hm, url);
#endif
// Download buffer

View File

@ -59,6 +59,8 @@
QT_BEGIN_NAMESPACE
using namespace Qt::StringLiterals;
QT_IMPL_METATYPE_EXTERN(QNetworkRequest)
QT_IMPL_METATYPE_EXTERN_TAGGED(QNetworkRequest::RedirectPolicy, QNetworkRequest__RedirectPolicy)
@ -1512,7 +1514,7 @@ QDateTime QNetworkHeadersPrivate::fromHttpDate(const QByteArray &value)
// eat the weekday, the comma and the space following it
QString sansWeekday = QString::fromLatin1(value.constData() + pos + 2);
// must be RFC 850 date
dt = c.toDateTime(sansWeekday, QLatin1String("dd-MMM-yy hh:mm:ss 'GMT'"));
dt = c.toDateTime(sansWeekday, "dd-MMM-yy hh:mm:ss 'GMT'"_L1);
}
}
#endif // datestring

View File

@ -48,8 +48,10 @@
**
****************************************************************************/
using namespace Qt::StringLiterals;
//! [0]
QList<QSslCertificate> cert = QSslCertificate::fromPath(QLatin1String("server-certificate.pem"));
QList<QSslCertificate> cert = QSslCertificate::fromPath("server-certificate.pem"_L1);
QSslError error(QSslError::SelfSignedCertificate, cert.at(0));
QList<QSslError> expectedSslErrors;
expectedSslErrors.append(error);

View File

@ -48,6 +48,7 @@
**
****************************************************************************/
using namespace Qt::StringLiterals;
//! [0]
// A client initiates a handshake:
QUdpSocket clientSocket;
@ -126,7 +127,7 @@ if (!dtls.doHandshake(&socket, dgram)) {
//! [5]
//! [6]
QList<QSslCertificate> cert = QSslCertificate::fromPath(QLatin1String("server-certificate.pem"));
QList<QSslCertificate> cert = QSslCertificate::fromPath("server-certificate.pem"_L1);
QSslError error(QSslError::SelfSignedCertificate, cert.at(0));
QList<QSslError> expectedSslErrors;
expectedSslErrors.append(error);

View File

@ -48,6 +48,8 @@
**
****************************************************************************/
using namespace Qt::StringLiterals;
//! [0]
QSslSocket *socket = new QSslSocket(this);
connect(socket, SIGNAL(encrypted()), this, SLOT(ready()));
@ -107,7 +109,7 @@ if (socket->waitForEncrypted(1000))
//! [5]
//! [6]
QList<QSslCertificate> cert = QSslCertificate::fromPath(QLatin1String("server-certificate.pem"));
QList<QSslCertificate> cert = QSslCertificate::fromPath("server-certificate.pem"_L1);
QSslError error(QSslError::SelfSignedCertificate, cert.at(0));
QList<QSslError> expectedSslErrors;
expectedSslErrors.append(error);

View File

@ -69,6 +69,8 @@
QT_BEGIN_NAMESPACE
using namespace Qt::StringLiterals;
Q_DECLARE_LOGGING_CATEGORY(lcAuthenticator);
Q_LOGGING_CATEGORY(lcAuthenticator, "qt.network.authenticator");
@ -405,7 +407,7 @@ void QAuthenticatorPrivate::updateCredentials()
switch (method) {
case QAuthenticatorPrivate::Ntlm:
if ((separatorPosn = user.indexOf(QLatin1String("\\"))) != -1) {
if ((separatorPosn = user.indexOf("\\"_L1)) != -1) {
//domain name is present
realm.clear();
userDomain = user.left(separatorPosn);
@ -522,7 +524,7 @@ void QAuthenticatorPrivate::parseHttpResponse(const QList<QPair<QByteArray, QByt
if (phase == Done)
phase = Start;
realm = newRealm;
this->options[QLatin1String("realm")] = realm;
this->options["realm"_L1] = realm;
}
};
@ -1658,7 +1660,7 @@ static QByteArray qSspiContinue(QAuthenticatorPrivate *ctx, QAuthenticatorPrivat
// Calculate target (SPN for Negotiate, empty for NTLM)
std::wstring targetNameW = (method == QAuthenticatorPrivate::Negotiate
? QLatin1String("HTTP/") + host : QString()).toStdWString();
? "HTTP/"_L1 + host : QString()).toStdWString();
// Generate our challenge-response message
SECURITY_STATUS secStatus = pSecurityFunctionTable->InitializeSecurityContext(

View File

@ -67,6 +67,8 @@
QT_BEGIN_NAMESPACE
using namespace Qt::StringLiterals;
#if QT_CONFIG(library)
#if defined(Q_OS_OPENBSD)
@ -111,7 +113,7 @@ static bool resolveLibraryInternal()
if (!lib.load())
#endif
{
lib.setFileName(QLatin1String("resolv"));
lib.setFileName("resolv"_L1);
lib.load();
}

View File

@ -70,6 +70,8 @@
QT_BEGIN_NAMESPACE
using namespace Qt::StringLiterals;
//#define QHOSTINFO_DEBUG
QT_IMPL_METATYPE_EXTERN(QHostInfo)
@ -536,7 +538,7 @@ QHostInfo QHostInfoAgent::lookup(const QString &hostName)
QString tmp;
QList<QHostAddress> addresses = results.addresses();
for (int i = 0; i < addresses.count(); ++i) {
if (i != 0) tmp += QLatin1String(", ");
if (i != 0) tmp += ", "_L1;
tmp += addresses.at(i).toString();
}
qDebug("QHostInfoAgent::fromName(): found %i entries for \"%s\": {%s}",

View File

@ -74,6 +74,8 @@
QT_BEGIN_NAMESPACE
using namespace Qt::StringLiterals;
enum LibResolvFeature {
NeedResInit,
NeedResNInit
@ -129,7 +131,7 @@ LibResolv::LibResolv()
if (!lib.load())
#endif
{
lib.setFileName(QLatin1String("resolv"));
lib.setFileName("resolv"_L1);
lib.load();
}
@ -228,7 +230,7 @@ QString QHostInfo::localDomainName()
#if defined(_PATH_RESCONF)
resolvconf.setFileName(QFile::decodeName(_PATH_RESCONF));
#else
resolvconf.setFileName(QLatin1String("/etc/resolv.conf"));
resolvconf.setFileName("/etc/resolv.conf"_L1);
#endif
if (!resolvconf.open(QIODevice::ReadOnly))
return QString(); // failure

View File

@ -243,6 +243,8 @@
QT_BEGIN_NAMESPACE
using namespace Qt::StringLiterals;
QT_IMPL_METATYPE_EXTERN(QNetworkProxy)
class QSocks5SocketEngineHandler;
@ -356,10 +358,8 @@ QList<QNetworkProxy> QGlobalNetworkProxy::proxyForQuery(const QNetworkProxyQuery
// don't look for proxies for a local connection
QHostAddress parsed;
QString hostname = query.url().host();
if (hostname == QLatin1String("localhost")
|| hostname.startsWith(QLatin1String("localhost."))
|| (parsed.setAddress(hostname)
&& (parsed.isLoopback()))) {
if (hostname == "localhost"_L1 || hostname.startsWith("localhost."_L1)
|| (parsed.setAddress(hostname) && (parsed.isLoopback()))) {
result << QNetworkProxy(QNetworkProxy::NoProxy);
return result;
}

View File

@ -51,6 +51,8 @@
QT_BEGIN_NAMESPACE
using namespace Qt::StringLiterals;
static bool ignoreProxyFor(const QNetworkProxyQuery &query)
{
const QByteArray noProxy = qgetenv("no_proxy").trimmed();
@ -101,11 +103,11 @@ QList<QNetworkProxy> QNetworkProxyFactory::systemProxyForQuery(const QNetworkPro
const QString queryProtocol = query.protocolTag();
QByteArray proxy_env;
if (queryProtocol == QLatin1String("http"))
if (queryProtocol == "http"_L1)
proxy_env = qgetenv("http_proxy");
else if (queryProtocol == QLatin1String("https"))
else if (queryProtocol == "https"_L1)
proxy_env = qgetenv("https_proxy");
else if (queryProtocol == QLatin1String("ftp"))
else if (queryProtocol == "ftp"_L1)
proxy_env = qgetenv("ftp_proxy");
else
proxy_env = qgetenv("all_proxy");
@ -117,16 +119,16 @@ QList<QNetworkProxy> QNetworkProxyFactory::systemProxyForQuery(const QNetworkPro
if (!proxy_env.isEmpty()) {
QUrl url = QUrl(QString::fromLocal8Bit(proxy_env));
const QString scheme = url.scheme();
if (scheme == QLatin1String("socks5")) {
if (scheme == "socks5"_L1) {
QNetworkProxy proxy(QNetworkProxy::Socks5Proxy, url.host(),
url.port() ? url.port() : 1080, url.userName(), url.password());
proxyList << proxy;
} else if (scheme == QLatin1String("socks5h")) {
} else if (scheme == "socks5h"_L1) {
QNetworkProxy proxy(QNetworkProxy::Socks5Proxy, url.host(),
url.port() ? url.port() : 1080, url.userName(), url.password());
proxy.setCapabilities(QNetworkProxy::HostNameLookupCapability);
proxyList << proxy;
} else if ((scheme.isEmpty() || scheme == QLatin1String("http"))
} else if ((scheme.isEmpty() || scheme == "http"_L1)
&& query.queryType() != QNetworkProxyQuery::UdpSocket
&& query.queryType() != QNetworkProxyQuery::TcpServer) {
QNetworkProxy proxy(QNetworkProxy::HttpProxy, url.host(),

View File

@ -54,6 +54,8 @@
QT_BEGIN_NAMESPACE
using namespace Qt::StringLiterals;
static bool isThreadingNeeded()
{
// Try to guess if the libproxy we linked to is from the libproxy project
@ -221,14 +223,13 @@ QList<QNetworkProxy> QNetworkProxyFactory::systemProxyForQuery(const QNetworkPro
for (const QUrl& url : rawProxies) {
QNetworkProxy::ProxyType type;
const QString scheme = url.scheme();
if (scheme == QLatin1String("http")) {
if (scheme == "http"_L1) {
type = QNetworkProxy::HttpProxy;
} else if (scheme == QLatin1String("socks")
|| scheme == QLatin1String("socks5")) {
} else if (scheme == "socks"_L1 || scheme == "socks5"_L1) {
type = QNetworkProxy::Socks5Proxy;
} else if (scheme == QLatin1String("ftp")) {
} else if (scheme == "ftp"_L1) {
type = QNetworkProxy::FtpCachingProxy;
} else if (scheme == QLatin1String("direct")) {
} else if (scheme == "direct"_L1) {
type = QNetworkProxy::NoProxy;
haveDirectConnection = true;
} else {

View File

@ -78,6 +78,8 @@
QT_BEGIN_NAMESPACE
using namespace Qt::StringLiterals;
static bool isHostExcluded(CFDictionaryRef dict, const QString &host)
{
if (host.isEmpty())
@ -292,19 +294,19 @@ QList<QNetworkProxy> macQueryInternal(const QNetworkProxyQuery &query)
// try the protocol-specific proxy
QNetworkProxy protocolSpecificProxy;
if (protocol == QLatin1String("ftp")) {
if (protocol == "ftp"_L1) {
protocolSpecificProxy =
proxyFromDictionary(dict, QNetworkProxy::FtpCachingProxy,
kSCPropNetProxiesFTPEnable,
kSCPropNetProxiesFTPProxy,
kSCPropNetProxiesFTPPort);
} else if (protocol == QLatin1String("http")) {
} else if (protocol == "http"_L1) {
protocolSpecificProxy =
proxyFromDictionary(dict, QNetworkProxy::HttpProxy,
kSCPropNetProxiesHTTPEnable,
kSCPropNetProxiesHTTPProxy,
kSCPropNetProxiesHTTPPort);
} else if (protocol == QLatin1String("https")) {
} else if (protocol == "https"_L1) {
isHttps = true;
protocolSpecificProxy =
proxyFromDictionary(dict, QNetworkProxy::HttpProxy,

View File

@ -57,6 +57,8 @@
QT_BEGIN_NAMESPACE
using namespace Qt::StringLiterals;
static bool currentProcessIsService()
{
wchar_t userName[UNLEN + 1] = L"";
@ -119,7 +121,7 @@ static bool isBypassed(const QString &host, const QStringList &bypassList)
// does it match the list of exclusions?
for (const QString &entry : bypassList) {
if (entry == QLatin1String("<local>")) {
if (entry == "<local>"_L1) {
if (isSimple)
return true;
if (isIpAddress) {
@ -231,20 +233,20 @@ static QList<QNetworkProxy> parseServerList(const QNetworkProxyQuery &query, con
scheme = protocolTag = QStringView{entry}.left(pos);
server = pos + 1;
}
pos = entry.indexOf(QLatin1String("://"), server);
pos = entry.indexOf("://"_L1, server);
if (pos != -1) {
scheme = QStringView{entry}.mid(server, pos - server);
server = pos + 3;
}
if (!scheme.isEmpty()) {
if (scheme == QLatin1String("http") || scheme == QLatin1String("https")) {
if (scheme == "http"_L1 || scheme == "https"_L1) {
// no-op
// defaults are above
} else if (scheme == QLatin1String("socks") || scheme == QLatin1String("socks5")) {
} else if (scheme == "socks"_L1 || scheme == "socks5"_L1) {
proxyType = QNetworkProxy::Socks5Proxy;
port = 1080;
} else if (scheme == QLatin1String("ftp")) {
} else if (scheme == "ftp"_L1) {
proxyType = QNetworkProxy::FtpCachingProxy;
port = 2121;
} else {
@ -279,10 +281,10 @@ static QList<QNetworkProxy> parseServerList(const QNetworkProxyQuery &query, con
result.prepend(taggedProxies.value(requiredTag));
}
}
if (!checkTags || requiredTag != QLatin1String("http")) {
if (!checkTags || requiredTag != "http"_L1) {
// if there are different http proxies for http and https, prefer the https one (more likely to be capable of CONNECT)
QNetworkProxy httpProxy = taggedProxies.value(QLatin1String("http"));
QNetworkProxy httpsProxy = taggedProxies.value(QLatin1String("http"));
QNetworkProxy httpProxy = taggedProxies.value("http"_L1);
QNetworkProxy httpsProxy = taggedProxies.value("http"_L1);
if (httpProxy != httpsProxy && httpProxy.type() == QNetworkProxy::HttpProxy && httpsProxy.type() == QNetworkProxy::HttpProxy) {
for (int i = 0; i < result.count(); i++) {
if (httpProxy == result.at(i))
@ -504,11 +506,11 @@ QList<QNetworkProxy> QNetworkProxyFactory::systemProxyForQuery(const QNetworkPro
// url could be empty, e.g. from QNetworkProxy::applicationProxy(), that's fine,
// we'll still ask for the proxy.
// But for a file url, we know we don't need one.
if (url.scheme() == QLatin1String("file") || url.scheme() == QLatin1String("qrc"))
if (url.scheme() == "file"_L1 || url.scheme() == "qrc"_L1)
return sp->defaultResult;
if (query.queryType() != QNetworkProxyQuery::UrlRequest) {
// change the scheme to https, maybe it'll work
url.setScheme(QLatin1String("https"));
url.setScheme("https"_L1);
}
QString urlQueryString = url.toString();

View File

@ -500,6 +500,8 @@
QT_BEGIN_NAMESPACE
using namespace Qt::StringLiterals;
QT_IMPL_METATYPE_EXTERN_TAGGED(QAbstractSocket::SocketState, QAbstractSocket__SocketState)
QT_IMPL_METATYPE_EXTERN_TAGGED(QAbstractSocket::SocketError, QAbstractSocket__SocketError)
@ -576,14 +578,14 @@ bool QAbstractSocketPrivate::initSocketLayer(QAbstractSocket::NetworkLayerProtoc
Q_Q(QAbstractSocket);
#if defined (QABSTRACTSOCKET_DEBUG)
QString typeStr;
if (q->socketType() == QAbstractSocket::TcpSocket) typeStr = QLatin1String("TcpSocket");
else if (q->socketType() == QAbstractSocket::UdpSocket) typeStr = QLatin1String("UdpSocket");
else if (q->socketType() == QAbstractSocket::SctpSocket) typeStr = QLatin1String("SctpSocket");
else typeStr = QLatin1String("UnknownSocketType");
if (q->socketType() == QAbstractSocket::TcpSocket) typeStr = "TcpSocket"_L1;
else if (q->socketType() == QAbstractSocket::UdpSocket) typeStr = "UdpSocket"_L1;
else if (q->socketType() == QAbstractSocket::SctpSocket) typeStr = "SctpSocket"_L1;
else typeStr = "UnknownSocketType"_L1;
QString protocolStr;
if (protocol == QAbstractSocket::IPv4Protocol) protocolStr = QLatin1String("IPv4Protocol");
else if (protocol == QAbstractSocket::IPv6Protocol) protocolStr = QLatin1String("IPv6Protocol");
else protocolStr = QLatin1String("UnknownNetworkLayerProtocol");
if (protocol == QAbstractSocket::IPv4Protocol) protocolStr = "IPv4Protocol"_L1;
else if (protocol == QAbstractSocket::IPv6Protocol) protocolStr = "IPv6Protocol"_L1;
else protocolStr = "UnknownNetworkLayerProtocol"_L1;
#endif
resetSocketLayer();
@ -969,9 +971,9 @@ void QAbstractSocketPrivate::_q_startConnecting(const QHostInfo &hostInfo)
#if defined(QABSTRACTSOCKET_DEBUG)
QString s = QLatin1String("{");
QString s = "{"_L1;
for (int i = 0; i < addresses.count(); ++i) {
if (i != 0) s += QLatin1String(", ");
if (i != 0) s += ", "_L1;
s += addresses.at(i).toString();
}
s += u'}';

View File

@ -51,6 +51,8 @@
QT_BEGIN_NAMESPACE
using namespace Qt::StringLiterals;
#define DEBUG
QHttpSocketEngine::QHttpSocketEngine(QObject *parent)
@ -186,8 +188,7 @@ bool QHttpSocketEngine::connectToHostByName(const QString &hostname, quint16 por
bool QHttpSocketEngine::bind(const QHostAddress &, quint16)
{
qWarning("Operation is not supported");
setError(QAbstractSocket::UnsupportedSocketOperationError,
QLatin1String("Unsupported socket operation"));
setError(QAbstractSocket::UnsupportedSocketOperationError, "Unsupported socket operation"_L1);
return false;
}
@ -195,16 +196,14 @@ bool QHttpSocketEngine::listen(int backlog)
{
Q_UNUSED(backlog);
qWarning("Operation is not supported");
setError(QAbstractSocket::UnsupportedSocketOperationError,
QLatin1String("Unsupported socket operation"));
setError(QAbstractSocket::UnsupportedSocketOperationError, "Unsupported socket operation"_L1);
return false;
}
int QHttpSocketEngine::accept()
{
qWarning("Operation is not supported");
setError(QAbstractSocket::UnsupportedSocketOperationError,
QLatin1String("Unsupported socket operation"));
setError(QAbstractSocket::UnsupportedSocketOperationError, "Unsupported socket operation"_L1);
return -1;
}
@ -239,8 +238,7 @@ qint64 QHttpSocketEngine::read(char *data, qint64 maxlen)
// failed, return the socket's error. Otherwise, fall through and
// return as much as we read so far.
close();
setError(QAbstractSocket::RemoteHostClosedError,
QLatin1String("Remote host closed"));
setError(QAbstractSocket::RemoteHostClosedError, "Remote host closed"_L1);
setState(QAbstractSocket::UnconnectedState);
return -1;
}
@ -259,8 +257,7 @@ bool QHttpSocketEngine::joinMulticastGroup(const QHostAddress &,
const QNetworkInterface &)
{
qWarning("Operation is not supported");
setError(QAbstractSocket::UnsupportedSocketOperationError,
QLatin1String("Unsupported socket operation"));
setError(QAbstractSocket::UnsupportedSocketOperationError, "Unsupported socket operation"_L1);
return false;
}
@ -268,8 +265,7 @@ bool QHttpSocketEngine::leaveMulticastGroup(const QHostAddress &,
const QNetworkInterface &)
{
qWarning("Operation is not supported");
setError(QAbstractSocket::UnsupportedSocketOperationError,
QLatin1String("Unsupported socket operation"));
setError(QAbstractSocket::UnsupportedSocketOperationError, "Unsupported socket operation"_L1);
return false;
}
@ -281,8 +277,7 @@ QNetworkInterface QHttpSocketEngine::multicastInterface() const
bool QHttpSocketEngine::setMulticastInterface(const QNetworkInterface &)
{
qWarning("Operation is not supported");
setError(QAbstractSocket::UnsupportedSocketOperationError,
QLatin1String("Unsupported socket operation"));
setError(QAbstractSocket::UnsupportedSocketOperationError, "Unsupported socket operation"_L1);
return false;
}
#endif // QT_NO_NETWORKINTERFACE
@ -303,16 +298,14 @@ qint64 QHttpSocketEngine::pendingDatagramSize() const
qint64 QHttpSocketEngine::readDatagram(char *, qint64, QIpPacketHeader *, PacketHeaderOptions)
{
qWarning("Operation is not supported");
setError(QAbstractSocket::UnsupportedSocketOperationError,
QLatin1String("Unsupported socket operation"));
setError(QAbstractSocket::UnsupportedSocketOperationError, "Unsupported socket operation"_L1);
return -1;
}
qint64 QHttpSocketEngine::writeDatagram(const char *, qint64, const QIpPacketHeader &)
{
qWarning("Operation is not supported");
setError(QAbstractSocket::UnsupportedSocketOperationError,
QLatin1String("Unsupported socket operation"));
setError(QAbstractSocket::UnsupportedSocketOperationError, "Unsupported socket operation"_L1);
return -1;
}

View File

@ -47,6 +47,8 @@
QT_BEGIN_NAMESPACE
using namespace Qt::StringLiterals;
/*!
\class QLocalServer
\since 4.4
@ -348,7 +350,7 @@ bool QLocalServer::listen(const QString &name)
if (name.isEmpty()) {
d->error = QAbstractSocket::HostNotFoundError;
QString function = QLatin1String("QLocalServer::listen");
QString function = "QLocalServer::listen"_L1;
d->errorString = tr("%1: Name error").arg(function);
return false;
}

View File

@ -48,6 +48,8 @@
QT_BEGIN_NAMESPACE
using namespace Qt::StringLiterals;
void QLocalServerPrivate::init()
{
Q_Q(QLocalServer);
@ -61,13 +63,13 @@ bool QLocalServerPrivate::listen(const QString &requestedServerName)
if (!tcpServer.listen(QHostAddress::LocalHost))
return false;
const QLatin1String prefix("QLocalServer/");
const auto prefix = "QLocalServer/"_L1;
if (requestedServerName.startsWith(prefix))
fullServerName = requestedServerName;
else
fullServerName = prefix + requestedServerName;
QSettings settings(QLatin1String("QtProject"), QLatin1String("Qt"));
QSettings settings("QtProject"_L1, "Qt"_L1);
if (settings.contains(fullServerName)) {
qWarning("QLocalServer::listen: server name is already in use.");
tcpServer.close();
@ -85,8 +87,8 @@ bool QLocalServerPrivate::listen(qintptr socketDescriptor)
void QLocalServerPrivate::closeServer()
{
QSettings settings(QLatin1String("QtProject"), QLatin1String("Qt"));
if (fullServerName == QLatin1String("QLocalServer"))
QSettings settings("QtProject"_L1, "Qt"_L1);
if (fullServerName == "QLocalServer"_L1)
settings.setValue(fullServerName, QVariant());
else
settings.remove(fullServerName);
@ -117,14 +119,14 @@ void QLocalServerPrivate::_q_onNewConnection()
bool QLocalServerPrivate::removeServer(const QString &name)
{
const QLatin1String prefix("QLocalServer/");
const auto prefix = "QLocalServer/"_L1;
QString serverName;
if (name.startsWith(prefix))
serverName = name;
else
serverName = prefix + name;
QSettings settings(QLatin1String("QtProject"), QLatin1String("Qt"));
QSettings settings("QtProject"_L1, "Qt"_L1);
if (settings.contains(serverName))
settings.remove(serverName);

View File

@ -60,6 +60,8 @@
QT_BEGIN_NAMESPACE
using namespace Qt::StringLiterals;
namespace {
QLocalServer::SocketOptions optionsForPlatform(QLocalServer::SocketOptions srcOptions)
{
@ -121,16 +123,16 @@ bool QLocalServerPrivate::listen(const QString &requestedServerName)
QFileInfo serverNameFileInfo(fullServerName);
tempDir.emplace(serverNameFileInfo.absolutePath() + u'/');
if (!tempDir->isValid()) {
setError(QLatin1String("QLocalServer::listen"));
setError("QLocalServer::listen"_L1);
return false;
}
encodedTempPath = QFile::encodeName(tempDir->path() + QLatin1String("/s"));
encodedTempPath = QFile::encodeName(tempDir->path() + "/s"_L1);
}
// create the unix socket
listenSocket = qt_safe_socket(PF_UNIX, SOCK_STREAM, 0);
if (-1 == listenSocket) {
setError(QLatin1String("QLocalServer::listen"));
setError("QLocalServer::listen"_L1);
closeServer();
return false;
}
@ -145,7 +147,7 @@ bool QLocalServerPrivate::listen(const QString &requestedServerName)
constexpr unsigned int extraCharacters = PlatformSupportsAbstractNamespace ? 2 : 1;
if (sizeof(addr.sun_path) < static_cast<size_t>(encodedFullServerName.size() + extraCharacters)) {
setError(QLatin1String("QLocalServer::listen"));
setError("QLocalServer::listen"_L1);
closeServer();
return false;
}
@ -159,7 +161,7 @@ bool QLocalServerPrivate::listen(const QString &requestedServerName)
addrSize = offsetof(::sockaddr_un, sun_path) + encodedFullServerName.size() + 1;
} else if (options & QLocalServer::WorldAccessOption) {
if (sizeof(addr.sun_path) < static_cast<size_t>(encodedTempPath.size() + 1)) {
setError(QLatin1String("QLocalServer::listen"));
setError("QLocalServer::listen"_L1);
closeServer();
return false;
}
@ -172,7 +174,7 @@ bool QLocalServerPrivate::listen(const QString &requestedServerName)
// bind
if (-1 == QT_SOCKET_BIND(listenSocket, (sockaddr *)&addr, addrSize)) {
setError(QLatin1String("QLocalServer::listen"));
setError("QLocalServer::listen"_L1);
// if address is in use already, just close the socket, but do not delete the file
if (errno == EADDRINUSE)
QT_CLOSE(listenSocket);
@ -185,7 +187,7 @@ bool QLocalServerPrivate::listen(const QString &requestedServerName)
// listen for connections
if (-1 == qt_safe_listen(listenSocket, listenBacklog)) {
setError(QLatin1String("QLocalServer::listen"));
setError("QLocalServer::listen"_L1);
closeServer();
return false;
}
@ -203,13 +205,13 @@ bool QLocalServerPrivate::listen(const QString &requestedServerName)
mode |= S_IRWXO;
if (::chmod(encodedTempPath.constData(), mode) == -1) {
setError(QLatin1String("QLocalServer::listen"));
setError("QLocalServer::listen"_L1);
closeServer();
return false;
}
if (::rename(encodedTempPath.constData(), encodedFullServerName.constData()) == -1) {
setError(QLatin1String("QLocalServer::listen"));
setError("QLocalServer::listen"_L1);
closeServer();
return false;
}
@ -301,7 +303,7 @@ void QLocalServerPrivate::_q_onNewConnection()
QT_SOCKLEN_T length = sizeof(sockaddr_un);
int connectedSocket = qt_safe_accept(listenSocket, (sockaddr *)&addr, &length);
if (-1 == connectedSocket) {
setError(QLatin1String("QLocalSocket::activated"));
setError("QLocalSocket::activated"_L1);
closeServer();
} else {
socketNotifier->setEnabled(pendingConnections.size()
@ -330,7 +332,7 @@ void QLocalServerPrivate::waitForNewConnection(int msec, bool *timedOut)
errno = EBADF;
Q_FALLTHROUGH();
case -1:
setError(QLatin1String("QLocalServer::waitForNewConnection"));
setError("QLocalServer::waitForNewConnection"_L1);
closeServer();
break;
}

View File

@ -55,6 +55,8 @@
QT_BEGIN_NAMESPACE
using namespace Qt::StringLiterals;
bool QLocalServerPrivate::addListener()
{
// The object must not change its address once the
@ -77,7 +79,7 @@ bool QLocalServerPrivate::addListener()
if ((socketOptions.value() & QLocalServer::WorldAccessOption)) {
pSD.reset(new SECURITY_DESCRIPTOR);
if (!InitializeSecurityDescriptor(pSD.data(), SECURITY_DESCRIPTOR_REVISION)) {
setError(QLatin1String("QLocalServerPrivate::addListener"));
setError("QLocalServerPrivate::addListener"_L1);
return false;
}
HANDLE hToken = NULL;
@ -88,7 +90,7 @@ bool QLocalServerPrivate::addListener()
tokenUserBuffer.fill(0, dwBufferSize);
auto pTokenUser = reinterpret_cast<PTOKEN_USER>(tokenUserBuffer.data());
if (!GetTokenInformation(hToken, TokenUser, pTokenUser, dwBufferSize, &dwBufferSize)) {
setError(QLatin1String("QLocalServerPrivate::addListener"));
setError("QLocalServerPrivate::addListener"_L1);
CloseHandle(hToken);
return false;
}
@ -98,7 +100,7 @@ bool QLocalServerPrivate::addListener()
tokenGroupBuffer.fill(0, dwBufferSize);
auto pTokenGroup = reinterpret_cast<PTOKEN_PRIMARY_GROUP>(tokenGroupBuffer.data());
if (!GetTokenInformation(hToken, TokenPrimaryGroup, pTokenGroup, dwBufferSize, &dwBufferSize)) {
setError(QLatin1String("QLocalServerPrivate::addListener"));
setError("QLocalServerPrivate::addListener"_L1);
CloseHandle(hToken);
return false;
}
@ -125,7 +127,7 @@ bool QLocalServerPrivate::addListener()
if (!AllocateAndInitializeSid(&WorldAuth, 1, SECURITY_WORLD_RID,
0, 0, 0, 0, 0, 0, 0,
&worldSID)) {
setError(QLatin1String("QLocalServerPrivate::addListener"));
setError("QLocalServerPrivate::addListener"_L1);
return false;
}
@ -142,21 +144,21 @@ bool QLocalServerPrivate::addListener()
if (socketOptions.value() & QLocalServer::UserAccessOption) {
if (!AddAccessAllowedAce(acl, ACL_REVISION, FILE_ALL_ACCESS, pTokenUser->User.Sid)) {
setError(QLatin1String("QLocalServerPrivate::addListener"));
setError("QLocalServerPrivate::addListener"_L1);
FreeSid(worldSID);
return false;
}
}
if (socketOptions.value() & QLocalServer::GroupAccessOption) {
if (!AddAccessAllowedAce(acl, ACL_REVISION, FILE_ALL_ACCESS, pTokenGroup->PrimaryGroup)) {
setError(QLatin1String("QLocalServerPrivate::addListener"));
setError("QLocalServerPrivate::addListener"_L1);
FreeSid(worldSID);
return false;
}
}
if (socketOptions.value() & QLocalServer::OtherAccessOption) {
if (!AddAccessAllowedAce(acl, ACL_REVISION, FILE_ALL_ACCESS, worldSID)) {
setError(QLatin1String("QLocalServerPrivate::addListener"));
setError("QLocalServerPrivate::addListener"_L1);
FreeSid(worldSID);
return false;
}
@ -164,7 +166,7 @@ bool QLocalServerPrivate::addListener()
SetSecurityDescriptorOwner(pSD.data(), pTokenUser->User.Sid, FALSE);
SetSecurityDescriptorGroup(pSD.data(), pTokenGroup->PrimaryGroup, FALSE);
if (!SetSecurityDescriptorDacl(pSD.data(), TRUE, acl, FALSE)) {
setError(QLatin1String("QLocalServerPrivate::addListener"));
setError("QLocalServerPrivate::addListener"_L1);
FreeSid(worldSID);
return false;
}
@ -185,7 +187,7 @@ bool QLocalServerPrivate::addListener()
&sa);
if (listener->handle == INVALID_HANDLE_VALUE) {
setError(QLatin1String("QLocalServerPrivate::addListener"));
setError("QLocalServerPrivate::addListener"_L1);
listeners.pop_back();
return false;
}
@ -208,7 +210,7 @@ bool QLocalServerPrivate::addListener()
break;
default:
CloseHandle(listener->handle);
setError(QLatin1String("QLocalServerPrivate::addListener"));
setError("QLocalServerPrivate::addListener"_L1);
listeners.pop_back();
return false;
}
@ -240,7 +242,7 @@ bool QLocalServerPrivate::listen(const QString &name)
{
Q_Q(QLocalServer);
const QLatin1String pipePath("\\\\.\\pipe\\");
const auto pipePath = "\\\\.\\pipe\\"_L1;
if (name.startsWith(pipePath))
fullServerName = name;
else
@ -300,7 +302,7 @@ void QLocalServerPrivate::_q_onNewConnection()
} else {
if (GetLastError() != ERROR_IO_INCOMPLETE) {
q->close();
setError(QLatin1String("QLocalServerPrivate::_q_onNewConnection"));
setError("QLocalServerPrivate::_q_onNewConnection"_L1);
return;
}

View File

@ -47,6 +47,8 @@
QT_BEGIN_NAMESPACE
using namespace Qt::StringLiterals;
QLocalSocketPrivate::QLocalSocketPrivate() : QIODevicePrivate(),
tcpSocket(0),
ownsTcpSocket(true),
@ -85,7 +87,7 @@ void QLocalSocketPrivate::setSocket(QLocalUnixSocket* socket)
void QLocalSocketPrivate::_q_errorOccurred(QAbstractSocket::SocketError socketError)
{
Q_Q(QLocalSocket);
QString function = QLatin1String("QLocalSocket");
QString function = "QLocalSocket"_L1;
QLocalSocket::LocalSocketError error = (QLocalSocket::LocalSocketError)socketError;
QString errorString = generateErrorString(error, function);
q->setErrorString(errorString);
@ -225,23 +227,21 @@ void QLocalSocket::connectToServer(OpenMode openMode)
emit stateChanged(d->state);
if (d->serverName.isEmpty()) {
d->setErrorAndEmit(ServerNotFoundError,
QLatin1String("QLocalSocket::connectToServer"));
d->setErrorAndEmit(ServerNotFoundError, "QLocalSocket::connectToServer"_L1);
return;
}
const QLatin1String prefix("QLocalServer/");
const auto prefix = "QLocalServer/"_L1;
if (d->serverName.startsWith(prefix))
d->fullServerName = d->serverName;
else
d->fullServerName = prefix + d->serverName;
QSettings settings(QLatin1String("QtProject"), QLatin1String("Qt"));
QSettings settings("QtProject"_L1, "Qt"_L1);
bool ok;
const quint16 port = settings.value(d->fullServerName).toUInt(&ok);
if (!ok) {
d->setErrorAndEmit(ServerNotFoundError,
QLatin1String("QLocalSocket::connectToServer"));
d->setErrorAndEmit(ServerNotFoundError, "QLocalSocket::connectToServer"_L1);
return;
}
QIODevice::open(openMode);

View File

@ -62,6 +62,8 @@
QT_BEGIN_NAMESPACE
using namespace Qt::StringLiterals;
namespace {
// determine the full server path
static QString pathNameForConnection(const QString &connectingName,
@ -115,7 +117,7 @@ void QLocalSocketPrivate::init()
void QLocalSocketPrivate::_q_errorOccurred(QAbstractSocket::SocketError socketError)
{
Q_Q(QLocalSocket);
QString function = QLatin1String("QLocalSocket");
QString function = "QLocalSocket"_L1;
QLocalSocket::LocalSocketError error = (QLocalSocket::LocalSocketError)socketError;
QString errorString = generateErrorString(error, function);
q->setErrorString(errorString);
@ -245,7 +247,7 @@ void QLocalSocket::connectToServer(OpenMode openMode)
{
Q_D(QLocalSocket);
if (state() == ConnectedState || state() == ConnectingState) {
QString errorString = d->generateErrorString(QLocalSocket::OperationError, QLatin1String("QLocalSocket::connectToserver"));
QString errorString = d->generateErrorString(QLocalSocket::OperationError, "QLocalSocket::connectToserver"_L1);
setErrorString(errorString);
emit errorOccurred(QLocalSocket::OperationError);
return;
@ -257,15 +259,13 @@ void QLocalSocket::connectToServer(OpenMode openMode)
emit stateChanged(d->state);
if (d->serverName.isEmpty()) {
d->setErrorAndEmit(ServerNotFoundError,
QLatin1String("QLocalSocket::connectToServer"));
d->setErrorAndEmit(ServerNotFoundError, "QLocalSocket::connectToServer"_L1);
return;
}
// create the socket
if (-1 == (d->connectingSocket = qt_safe_socket(PF_UNIX, SOCK_STREAM, 0, O_NONBLOCK))) {
d->setErrorAndEmit(UnsupportedSocketOperationError,
QLatin1String("QLocalSocket::connectToServer"));
d->setErrorAndEmit(UnsupportedSocketOperationError, "QLocalSocket::connectToServer"_L1);
return;
}
@ -298,7 +298,7 @@ void QLocalSocketPrivate::_q_connectToSocket()
constexpr unsigned int extraCharacters = PlatformSupportsAbstractNamespace ? 2 : 1;
if (sizeof(addr.sun_path) < static_cast<size_t>(encodedConnectingPathName.size() + extraCharacters)) {
QString function = QLatin1String("QLocalSocket::connectToServer");
QString function = "QLocalSocket::connectToServer"_L1;
setErrorAndEmit(QLocalSocket::ServerNotFoundError, function);
return;
}
@ -313,7 +313,7 @@ void QLocalSocketPrivate::_q_connectToSocket()
encodedConnectingPathName.size() + 1);
}
if (-1 == qt_safe_connect(connectingSocket, (struct sockaddr *)&addr, addrSize)) {
QString function = QLatin1String("QLocalSocket::connectToServer");
QString function = "QLocalSocket::connectToServer"_L1;
switch (errno)
{
case EINVAL:
@ -361,7 +361,7 @@ void QLocalSocketPrivate::_q_connectToSocket()
q->QIODevice::open(connectingOpenMode);
q->emit connected();
} else {
QString function = QLatin1String("QLocalSocket::connectToServer");
QString function = "QLocalSocket::connectToServer"_L1;
setErrorAndEmit(QLocalSocket::UnknownSocketError, function);
}
connectingSocket = -1;
@ -632,7 +632,7 @@ bool QLocalSocket::waitForConnected(int msec)
if (result == -1)
d->setErrorAndEmit(QLocalSocket::UnknownSocketError,
QLatin1String("QLocalSocket::waitForConnected"));
"QLocalSocket::waitForConnected"_L1);
else if (result > 0)
d->_q_connectToSocket();
} while (state() == ConnectingState && !timer.hasExpired(msec));

View File

@ -43,6 +43,8 @@
QT_BEGIN_NAMESPACE
using namespace Qt::StringLiterals;
namespace {
struct QSocketPoller
{
@ -197,14 +199,14 @@ void QLocalSocket::connectToServer(OpenMode openMode)
emit stateChanged(d->state);
if (d->serverName.isEmpty()) {
d->error = ServerNotFoundError;
d->errorString = tr("%1: Invalid name").arg(QLatin1String("QLocalSocket::connectToServer"));
d->errorString = tr("%1: Invalid name").arg("QLocalSocket::connectToServer"_L1);
d->state = UnconnectedState;
emit errorOccurred(d->error);
emit stateChanged(d->state);
return;
}
const QLatin1String pipePath("\\\\.\\pipe\\");
const auto pipePath = "\\\\.\\pipe\\"_L1;
if (d->serverName.startsWith(pipePath))
d->fullServerName = d->serverName;
else
@ -237,7 +239,7 @@ void QLocalSocket::connectToServer(OpenMode openMode)
if (localSocket == INVALID_HANDLE_VALUE) {
const DWORD winError = GetLastError();
d->_q_winError(winError, QLatin1String("QLocalSocket::connectToServer"));
d->_q_winError(winError, "QLocalSocket::connectToServer"_L1);
d->fullServerName = QString();
return;
}

View File

@ -135,6 +135,8 @@
QT_BEGIN_NAMESPACE
using namespace Qt::StringLiterals;
//#define QNATIVESOCKETENGINE_DEBUG
#define Q_VOID
@ -448,13 +450,13 @@ bool QNativeSocketEngine::initialize(QAbstractSocket::SocketType socketType, QAb
// Create the socket
if (!d->createNewSocket(socketType, protocol)) {
#if defined (QNATIVESOCKETENGINE_DEBUG)
QString typeStr = QLatin1String("UnknownSocketType");
if (socketType == QAbstractSocket::TcpSocket) typeStr = QLatin1String("TcpSocket");
else if (socketType == QAbstractSocket::UdpSocket) typeStr = QLatin1String("UdpSocket");
else if (socketType == QAbstractSocket::SctpSocket) typeStr = QLatin1String("SctpSocket");
QString protocolStr = QLatin1String("UnknownProtocol");
if (protocol == QAbstractSocket::IPv4Protocol) protocolStr = QLatin1String("IPv4Protocol");
else if (protocol == QAbstractSocket::IPv6Protocol) protocolStr = QLatin1String("IPv6Protocol");
QString typeStr = "UnknownSocketType"_L1;
if (socketType == QAbstractSocket::TcpSocket) typeStr = "TcpSocket"_L1;
else if (socketType == QAbstractSocket::UdpSocket) typeStr = "UdpSocket"_L1;
else if (socketType == QAbstractSocket::SctpSocket) typeStr = "SctpSocket"_L1;
QString protocolStr = "UnknownProtocol"_L1;
if (protocol == QAbstractSocket::IPv4Protocol) protocolStr = "IPv4Protocol"_L1;
else if (protocol == QAbstractSocket::IPv6Protocol) protocolStr = "IPv6Protocol"_L1;
qDebug("QNativeSocketEngine::initialize(type == %s, protocol == %s) failed: %s",
typeStr.toLatin1().constData(), protocolStr.toLatin1().constData(), d->socketErrorString.toLatin1().constData());
#endif

View File

@ -60,6 +60,8 @@
QT_BEGIN_NAMESPACE
using namespace Qt::StringLiterals;
static const int MaxWriteBufferSize = 128*1024;
//#define QSOCKS5SOCKETLAYER_DEBUG
@ -102,22 +104,22 @@ static const int MaxWriteBufferSize = 128*1024;
static QString s5StateToString(QSocks5SocketEnginePrivate::Socks5State s)
{
switch (s) {
case QSocks5SocketEnginePrivate::Uninitialized: return QLatin1String("Uninitialized");
case QSocks5SocketEnginePrivate::ConnectError: return QLatin1String("ConnectError");
case QSocks5SocketEnginePrivate::AuthenticationMethodsSent: return QLatin1String("AuthenticationMethodsSent");
case QSocks5SocketEnginePrivate::Authenticating: return QLatin1String("Authenticating");
case QSocks5SocketEnginePrivate::AuthenticatingError: return QLatin1String("AuthenticatingError");
case QSocks5SocketEnginePrivate::RequestMethodSent: return QLatin1String("RequestMethodSent");
case QSocks5SocketEnginePrivate::RequestError: return QLatin1String("RequestError");
case QSocks5SocketEnginePrivate::Connected: return QLatin1String("Connected");
case QSocks5SocketEnginePrivate::UdpAssociateSuccess: return QLatin1String("UdpAssociateSuccess");
case QSocks5SocketEnginePrivate::BindSuccess: return QLatin1String("BindSuccess");
case QSocks5SocketEnginePrivate::ControlSocketError: return QLatin1String("ControlSocketError");
case QSocks5SocketEnginePrivate::SocksError: return QLatin1String("SocksError");
case QSocks5SocketEnginePrivate::HostNameLookupError: return QLatin1String("HostNameLookupError");
case QSocks5SocketEnginePrivate::Uninitialized: return "Uninitialized"_L1;
case QSocks5SocketEnginePrivate::ConnectError: return "ConnectError"_L1;
case QSocks5SocketEnginePrivate::AuthenticationMethodsSent: return "AuthenticationMethodsSent"_L1;
case QSocks5SocketEnginePrivate::Authenticating: return "Authenticating"_L1;
case QSocks5SocketEnginePrivate::AuthenticatingError: return "AuthenticatingError"_L1;
case QSocks5SocketEnginePrivate::RequestMethodSent: return "RequestMethodSent"_L1;
case QSocks5SocketEnginePrivate::RequestError: return "RequestError"_L1;
case QSocks5SocketEnginePrivate::Connected: return "Connected"_L1;
case QSocks5SocketEnginePrivate::UdpAssociateSuccess: return "UdpAssociateSuccess"_L1;
case QSocks5SocketEnginePrivate::BindSuccess: return "BindSuccess"_L1;
case QSocks5SocketEnginePrivate::ControlSocketError: return "ControlSocketError"_L1;
case QSocks5SocketEnginePrivate::SocksError: return "SocksError"_L1;
case QSocks5SocketEnginePrivate::HostNameLookupError: return "HostNameLookupError"_L1;
default: break;
}
return QLatin1String("unknown state");
return "unknown state"_L1;
}
static QString dump(const QByteArray &buf)
@ -130,7 +132,7 @@ static QString dump(const QByteArray &buf)
data += QString::number(val);
}
if (buf.size() > MAX_DATA_DUMP)
data += QLatin1String(" ...");
data += " ..."_L1;
return QString::fromLatin1("size: %1 data: { %2 }").arg(buf.size()).arg(data);
}
@ -494,7 +496,7 @@ bool QSocks5PasswordAuthenticator::continueAuthenticate(QTcpSocket *socket, bool
QString QSocks5PasswordAuthenticator::errorString()
{
return QLatin1String("Socks5 user name or password incorrect");
return "Socks5 user name or password incorrect"_L1;
}
@ -749,7 +751,7 @@ void QSocks5SocketEnginePrivate::parseAuthenticationMethodReply()
return;
} else if (buf.at(1) != data->authenticator->methodId()
|| !data->authenticator->beginAuthenticate(data->controlSocket, &authComplete)) {
setErrorState(AuthenticatingError, QLatin1String("Socks5 host did not support authentication method."));
setErrorState(AuthenticatingError, "Socks5 host did not support authentication method."_L1);
socketError = QAbstractSocket::SocketAccessError; // change the socket error
emitConnectionNotification();
return;
@ -1102,7 +1104,7 @@ bool QSocks5SocketEngine::connectInternal()
} else if (socketType() == QAbstractSocket::UdpSocket) {
d->initialize(QSocks5SocketEnginePrivate::UdpAssociateMode);
// all udp needs to be bound
if (!bind(QHostAddress(QLatin1String("0.0.0.0")), 0))
if (!bind(QHostAddress("0.0.0.0"_L1), 0))
return false;
setState(QAbstractSocket::ConnectedState);
@ -1439,10 +1441,10 @@ int QSocks5SocketEngine::accept()
d->socketState = QAbstractSocket::UnconnectedState;
break;
case QSocks5SocketEnginePrivate::ControlSocketError:
setError(QAbstractSocket::ProxyProtocolError, QLatin1String("Control socket error"));
setError(QAbstractSocket::ProxyProtocolError, "Control socket error"_L1);
break;
default:
setError(QAbstractSocket::ProxyProtocolError, QLatin1String("SOCKS5 proxy error"));
setError(QAbstractSocket::ProxyProtocolError, "SOCKS5 proxy error"_L1);
break;
}
return sd;
@ -1494,7 +1496,7 @@ qint64 QSocks5SocketEngine::read(char *data, qint64 maxlen)
//imitate remote closed
close();
setError(QAbstractSocket::RemoteHostClosedError,
QLatin1String("Remote host closed connection###"));
"Remote host closed connection###"_L1);
setState(QAbstractSocket::UnconnectedState);
return -1;
} else {
@ -1557,7 +1559,7 @@ bool QSocks5SocketEngine::joinMulticastGroup(const QHostAddress &,
const QNetworkInterface &)
{
setError(QAbstractSocket::UnsupportedSocketOperationError,
QLatin1String("Operation on socket is not supported"));
"Operation on socket is not supported"_L1);
return false;
}
@ -1565,7 +1567,7 @@ bool QSocks5SocketEngine::leaveMulticastGroup(const QHostAddress &,
const QNetworkInterface &)
{
setError(QAbstractSocket::UnsupportedSocketOperationError,
QLatin1String("Operation on socket is not supported"));
"Operation on socket is not supported"_L1);
return false;
}
@ -1578,7 +1580,7 @@ QNetworkInterface QSocks5SocketEngine::multicastInterface() const
bool QSocks5SocketEngine::setMulticastInterface(const QNetworkInterface &)
{
setError(QAbstractSocket::UnsupportedSocketOperationError,
QLatin1String("Operation on socket is not supported"));
"Operation on socket is not supported"_L1);
return false;
}
#endif // QT_NO_NETWORKINTERFACE
@ -1634,7 +1636,7 @@ qint64 QSocks5SocketEngine::writeDatagram(const char *data, qint64 len, const QI
if (!d->data) {
d->initialize(QSocks5SocketEnginePrivate::UdpAssociateMode);
// all udp needs to be bound
if (!bind(QHostAddress(QLatin1String("0.0.0.0")), 0)) {
if (!bind(QHostAddress("0.0.0.0"_L1), 0)) {
//### set error
return -1;
}

View File

@ -151,6 +151,8 @@
QT_BEGIN_NAMESPACE
using namespace Qt::StringLiterals;
QT_IMPL_METATYPE_EXTERN(QSslCertificate)
QSslCertificatePrivate::QSslCertificatePrivate()
@ -665,9 +667,9 @@ QList<QSslCertificate> QSslCertificate::fromPath(const QString &path,
#if QT_CONFIG(regularexpression)
if (syntax == PatternSyntax::Wildcard)
pos = pathPrefix.indexOf(QRegularExpression(QLatin1String("[*?[]")));
pos = pathPrefix.indexOf(QRegularExpression("[*?[]"_L1));
else if (syntax == PatternSyntax::RegularExpression)
pos = sourcePath.indexOf(QRegularExpression(QLatin1String("[\\$\\(\\)\\*\\+\\.\\?\\[\\]\\^\\{\\}\\|]")));
pos = sourcePath.indexOf(QRegularExpression("[\\$\\(\\)\\*\\+\\.\\?\\[\\]\\^\\{\\}\\|]"_L1));
#else
if (syntax == PatternSyntax::Wildcard || syntax == PatternSyntax::RegExp)
qWarning("Regular expression support is disabled in this build. Only fixed string can be searched");
@ -698,7 +700,7 @@ QList<QSslCertificate> QSslCertificate::fromPath(const QString &path,
// Special case - if the prefix ends up being nothing, use "." instead.
int startIndex = 0;
if (pathPrefix.isEmpty()) {
pathPrefix = QLatin1String(".");
pathPrefix = "."_L1;
startIndex = 2;
}

View File

@ -399,6 +399,8 @@
QT_BEGIN_NAMESPACE
using namespace Qt::StringLiterals;
class QSslSocketGlobalData
{
public:
@ -2085,12 +2087,12 @@ void QSslSocketPrivate::init()
*/
bool QSslSocketPrivate::verifyProtocolSupported(const char *where)
{
QLatin1String protocolName("DTLS");
auto protocolName = "DTLS"_L1;
switch (configuration.protocol) {
case QSsl::UnknownProtocol:
// UnknownProtocol, according to our docs, is for cipher whose protocol is unknown.
// Should not be used when configuring QSslSocket.
protocolName = QLatin1String("UnknownProtocol");
protocolName = "UnknownProtocol"_L1;
Q_FALLTHROUGH();
QT_WARNING_PUSH
QT_WARNING_DISABLE_DEPRECATED
@ -3078,7 +3080,7 @@ bool QSslSocketPrivate::isMatchingHostname(const QString &cn, const QString &hos
// Reject wildcard character embedded within the A-labels or U-labels of an internationalized
// domain name (RFC6125 section 7.2)
if (cn.startsWith(QLatin1String("xn--"), Qt::CaseInsensitive))
if (cn.startsWith("xn--"_L1, Qt::CaseInsensitive))
return false;
// Check characters preceding * (if any) match

View File

@ -61,6 +61,8 @@
QT_BEGIN_NAMESPACE
using namespace Qt::StringLiterals;
Q_APPLICATION_STATIC(QFactoryLoader, loader, QTlsBackend_iid,
QStringLiteral("/tls"))
@ -832,13 +834,13 @@ QT_WARNING_DISABLE_DEPRECATED
}
QT_WARNING_POP
if (descriptionList.at(2).startsWith(QLatin1String("Kx=")))
if (descriptionList.at(2).startsWith("Kx="_L1))
ciph.d->keyExchangeMethod = descriptionList.at(2).mid(3).toString();
if (descriptionList.at(3).startsWith(QLatin1String("Au=")))
if (descriptionList.at(3).startsWith("Au="_L1))
ciph.d->authenticationMethod = descriptionList.at(3).mid(3).toString();
if (descriptionList.at(4).startsWith(QLatin1String("Enc=")))
if (descriptionList.at(4).startsWith("Enc="_L1))
ciph.d->encryptionMethod = descriptionList.at(4).mid(4).toString();
ciph.d->exportable = (descriptionList.size() > 6 && descriptionList.at(6) == QLatin1String("export"));
ciph.d->exportable = (descriptionList.size() > 6 && descriptionList.at(6) == "export"_L1);
ciph.d->bits = bits;
ciph.d->supportedBits = supportedBits;
@ -852,7 +854,7 @@ QT_WARNING_POP
Auxiliary function. Creates a new QSslCipher from \a suiteName, \a protocol version and
\a protocolString. For example:
\code
createCiphersuite(QLatin1String("ECDHE-RSA-AES256-GCM-SHA256"), QSsl::TlsV1_2, QLatin1String("TLSv1.2"));
createCiphersuite("ECDHE-RSA-AES256-GCM-SHA256"_L1, QSsl::TlsV1_2, "TLSv1.2"_L1);
\endcode
*/
QSslCipher QTlsBackend::createCiphersuite(const QString &suiteName, QSsl::SslProtocol protocol,
@ -871,49 +873,49 @@ QSslCipher QTlsBackend::createCiphersuite(const QString &suiteName, QSsl::SslPro
const auto bits = QStringView{ciph.d->name}.split(u'-');
if (bits.size() >= 2) {
if (bits.size() == 2 || bits.size() == 3)
ciph.d->keyExchangeMethod = QLatin1String("RSA");
else if (bits.front() == QLatin1String("DH") || bits.front() == QLatin1String("DHE"))
ciph.d->keyExchangeMethod = QLatin1String("DH");
else if (bits.front() == QLatin1String("ECDH") || bits.front() == QLatin1String("ECDHE"))
ciph.d->keyExchangeMethod = QLatin1String("ECDH");
ciph.d->keyExchangeMethod = "RSA"_L1;
else if (bits.front() == "DH"_L1 || bits.front() == "DHE"_L1)
ciph.d->keyExchangeMethod = "DH"_L1;
else if (bits.front() == "ECDH"_L1 || bits.front() == "ECDHE"_L1)
ciph.d->keyExchangeMethod = "ECDH"_L1;
else
qCWarning(lcSsl) << "Unknown Kx" << ciph.d->name;
if (bits.size() == 2 || bits.size() == 3)
ciph.d->authenticationMethod = QLatin1String("RSA");
else if (ciph.d->name.contains(QLatin1String("-ECDSA-")))
ciph.d->authenticationMethod = QLatin1String("ECDSA");
else if (ciph.d->name.contains(QLatin1String("-RSA-")))
ciph.d->authenticationMethod = QLatin1String("RSA");
ciph.d->authenticationMethod = "RSA"_L1;
else if (ciph.d->name.contains("-ECDSA-"_L1))
ciph.d->authenticationMethod = "ECDSA"_L1;
else if (ciph.d->name.contains("-RSA-"_L1))
ciph.d->authenticationMethod = "RSA"_L1;
else
qCWarning(lcSsl) << "Unknown Au" << ciph.d->name;
if (ciph.d->name.contains(QLatin1String("RC4-"))) {
ciph.d->encryptionMethod = QLatin1String("RC4(128)");
if (ciph.d->name.contains("RC4-"_L1)) {
ciph.d->encryptionMethod = "RC4(128)"_L1;
ciph.d->bits = 128;
ciph.d->supportedBits = 128;
} else if (ciph.d->name.contains(QLatin1String("DES-CBC3-"))) {
ciph.d->encryptionMethod = QLatin1String("3DES(168)");
} else if (ciph.d->name.contains("DES-CBC3-"_L1)) {
ciph.d->encryptionMethod = "3DES(168)"_L1;
ciph.d->bits = 168;
ciph.d->supportedBits = 168;
} else if (ciph.d->name.contains(QLatin1String("AES128-"))) {
ciph.d->encryptionMethod = QLatin1String("AES(128)");
} else if (ciph.d->name.contains("AES128-"_L1)) {
ciph.d->encryptionMethod = "AES(128)"_L1;
ciph.d->bits = 128;
ciph.d->supportedBits = 128;
} else if (ciph.d->name.contains(QLatin1String("AES256-GCM"))) {
ciph.d->encryptionMethod = QLatin1String("AESGCM(256)");
} else if (ciph.d->name.contains("AES256-GCM"_L1)) {
ciph.d->encryptionMethod = "AESGCM(256)"_L1;
ciph.d->bits = 256;
ciph.d->supportedBits = 256;
} else if (ciph.d->name.contains(QLatin1String("AES256-"))) {
ciph.d->encryptionMethod = QLatin1String("AES(256)");
} else if (ciph.d->name.contains("AES256-"_L1)) {
ciph.d->encryptionMethod = "AES(256)"_L1;
ciph.d->bits = 256;
ciph.d->supportedBits = 256;
} else if (ciph.d->name.contains(QLatin1String("CHACHA20-"))) {
ciph.d->encryptionMethod = QLatin1String("CHACHA20");
} else if (ciph.d->name.contains("CHACHA20-"_L1)) {
ciph.d->encryptionMethod = "CHACHA20"_L1;
ciph.d->bits = 256;
ciph.d->supportedBits = 256;
} else if (ciph.d->name.contains(QLatin1String("NULL-"))) {
ciph.d->encryptionMethod = QLatin1String("NULL");
} else if (ciph.d->name.contains("NULL-"_L1)) {
ciph.d->encryptionMethod = "NULL"_L1;
} else {
qCWarning(lcSsl) << "Unknown Enc" << ciph.d->name;
}
@ -926,7 +928,7 @@ QSslCipher QTlsBackend::createCiphersuite(const QString &suiteName, QSsl::SslPro
Auxiliary function. Creates a new QSslCipher from \a name (which is an implementation-specific
string), \a protocol and \a protocolString, e.g.:
\code
createCipher(QStringLiteral("schannel"), QSsl::TlsV1_2, QLatin1String("TLSv1.2"));
createCipher(QStringLiteral("schannel"), QSsl::TlsV1_2, "TLSv1.2"_L1);
\endcode
*/
QSslCipher QTlsBackend::createCipher(const QString &name, QSsl::SslProtocol protocol,

View File

@ -45,6 +45,9 @@
#include <gio/gio.h>
QT_BEGIN_NAMESPACE
using namespace Qt::StringLiterals;
Q_DECLARE_LOGGING_CATEGORY(lcNetInfoGlib)
Q_LOGGING_CATEGORY(lcNetInfoGlib, "qt.network.info.glib");
@ -141,7 +144,7 @@ QGlibNetworkInformationBackend::~QGlibNetworkInformationBackend()
bool QGlibNetworkInformationBackend::isValid() const
{
return G_OBJECT_TYPE_NAME(networkMonitor) != QLatin1String("GNetworkMonitorBase");
return G_OBJECT_TYPE_NAME(networkMonitor) != "GNetworkMonitorBase"_L1;
}
void QGlibNetworkInformationBackend::updateInformation(QGlibNetworkInformationBackend *backend)

View File

@ -64,7 +64,7 @@ QT_BEGIN_NAMESPACE
using namespace Qt::StringLiterals;
QNetworkManagerInterfaceBase::QNetworkManagerInterfaceBase(QObject *parent)
: QDBusAbstractInterface(QLatin1String(NM_DBUS_SERVICE), QLatin1String(NM_DBUS_PATH),
: QDBusAbstractInterface(NM_DBUS_SERVICE ""_L1, NM_DBUS_PATH ""_L1,
NM_DBUS_INTERFACE, QDBusConnection::systemBus(), parent)
{
}
@ -81,29 +81,27 @@ QNetworkManagerInterface::QNetworkManagerInterface(QObject *parent)
return;
PropertiesDBusInterface managerPropertiesInterface(
QLatin1String(NM_DBUS_SERVICE), QLatin1String(NM_DBUS_PATH), DBUS_PROPERTIES_INTERFACE,
NM_DBUS_SERVICE ""_L1, NM_DBUS_PATH ""_L1, DBUS_PROPERTIES_INTERFACE,
QDBusConnection::systemBus());
QList<QVariant> argumentList;
argumentList << QLatin1String(NM_DBUS_INTERFACE);
argumentList << NM_DBUS_INTERFACE ""_L1;
QDBusPendingReply<QVariantMap> propsReply = managerPropertiesInterface.callWithArgumentList(
QDBus::Block, QLatin1String("GetAll"), argumentList);
QDBus::Block, "GetAll"_L1, argumentList);
if (!propsReply.isError()) {
propertyMap = propsReply.value();
} else {
qWarning() << "propsReply" << propsReply.error().message();
}
QDBusConnection::systemBus().connect(
QLatin1String(NM_DBUS_SERVICE), QLatin1String(NM_DBUS_PATH),
QLatin1String(DBUS_PROPERTIES_INTERFACE), QLatin1String("PropertiesChanged"), this,
QDBusConnection::systemBus().connect(NM_DBUS_SERVICE ""_L1, NM_DBUS_PATH ""_L1,
DBUS_PROPERTIES_INTERFACE""_L1, "PropertiesChanged"_L1, this,
SLOT(setProperties(QString, QMap<QString, QVariant>, QList<QString>)));
}
QNetworkManagerInterface::~QNetworkManagerInterface()
{
QDBusConnection::systemBus().disconnect(
QLatin1String(NM_DBUS_SERVICE), QLatin1String(NM_DBUS_PATH),
QLatin1String(DBUS_PROPERTIES_INTERFACE), QLatin1String("PropertiesChanged"), this,
QDBusConnection::systemBus().disconnect(NM_DBUS_SERVICE ""_L1, NM_DBUS_PATH ""_L1,
DBUS_PROPERTIES_INTERFACE ""_L1, "PropertiesChanged"_L1, this,
SLOT(setProperties(QString, QMap<QString, QVariant>, QList<QString>)));
}
@ -202,17 +200,17 @@ void QNetworkManagerInterface::setProperties(const QString &interfaceName,
}
if (valueChanged) {
if (i.key() == QLatin1String("State")) {
if (i.key() == "State"_L1) {
quint32 state = i.value().toUInt();
Q_EMIT stateChanged(static_cast<NMState>(state));
} else if (i.key() == QLatin1String("Connectivity")) {
} else if (i.key() == "Connectivity"_L1) {
quint32 state = i.value().toUInt();
Q_EMIT connectivityChanged(static_cast<NMConnectivityState>(state));
} else if (i.key() == QLatin1String("PrimaryConnection")) {
} else if (i.key() == "PrimaryConnection"_L1) {
const QDBusObjectPath devicePath = i->value<QDBusObjectPath>();
Q_EMIT deviceTypeChanged(extractDeviceType(devicePath));
Q_EMIT meteredChanged(extractDeviceMetered(devicePath));
} else if (i.key() == QLatin1String("Metered")) {
} else if (i.key() == "Metered"_L1) {
Q_EMIT meteredChanged(static_cast<NMMetered>(i->toUInt()));
}
}

View File

@ -81,6 +81,8 @@
QT_BEGIN_NAMESPACE
using namespace Qt::StringLiterals;
/*
Note to maintainer:
-------------------
@ -628,12 +630,12 @@ static QStringList libraryPathList()
# else
paths = QString::fromLatin1(qgetenv("LD_LIBRARY_PATH")).split(u':', Qt::SkipEmptyParts);
# endif
paths << QLatin1String("/lib") << QLatin1String("/usr/lib") << QLatin1String("/usr/local/lib");
paths << QLatin1String("/lib64") << QLatin1String("/usr/lib64") << QLatin1String("/usr/local/lib64");
paths << QLatin1String("/lib32") << QLatin1String("/usr/lib32") << QLatin1String("/usr/local/lib32");
paths << "/lib"_L1 << "/usr/lib"_L1 << "/usr/local/lib"_L1;
paths << "/lib64"_L1 << "/usr/lib64"_L1 << "/usr/local/lib64"_L1;
paths << "/lib32"_L1 << "/usr/lib32"_L1 << "/usr/local/lib32"_L1;
#if defined(Q_OS_ANDROID)
paths << QLatin1String("/system/lib");
paths << "/system/lib"_L1;
#elif defined(Q_OS_LINUX)
// discover paths of already loaded libraries
QDuplicateTracker<QString> loadedPaths;
@ -665,12 +667,12 @@ static QStringList findAllLibs(QLatin1String filter)
static QStringList findAllLibSsl()
{
return findAllLibs(QLatin1String("libssl.*"));
return findAllLibs("libssl.*"_L1);
}
static QStringList findAllLibCrypto()
{
return findAllLibs(QLatin1String("libcrypto.*"));
return findAllLibs("libcrypto.*"_L1);
}
# endif
@ -721,8 +723,8 @@ static LoadedOpenSsl loadOpenSsl()
#define QT_SSL_SUFFIX
#endif
tryToLoadOpenSslWin32Library(QLatin1String("libssl-" QT_OPENSSL_VERSION QT_SSL_SUFFIX),
QLatin1String("libcrypto-" QT_OPENSSL_VERSION QT_SSL_SUFFIX), result);
tryToLoadOpenSslWin32Library("libssl-" QT_OPENSSL_VERSION QT_SSL_SUFFIX ""_L1,
"libcrypto-" QT_OPENSSL_VERSION QT_SSL_SUFFIX ""_L1, result);
#undef QT_SSL_SUFFIX
return result;
@ -779,8 +781,8 @@ static LoadedOpenSsl loadOpenSsl()
#endif
#if defined(SHLIB_VERSION_NUMBER) && !defined(Q_OS_QNX) // on QNX, the libs are always libssl.so and libcrypto.so
// first attempt: the canonical name is libssl.so.<SHLIB_VERSION_NUMBER>
libssl->setFileNameAndVersion(QLatin1String("ssl"), QLatin1String(SHLIB_VERSION_NUMBER));
libcrypto->setFileNameAndVersion(QLatin1String("crypto"), QLatin1String(SHLIB_VERSION_NUMBER));
libssl->setFileNameAndVersion("ssl"_L1, SHLIB_VERSION_NUMBER ""_L1);
libcrypto->setFileNameAndVersion("crypto"_L1, SHLIB_VERSION_NUMBER ""_L1);
if (libcrypto->load() && libssl->load()) {
// libssl.so.<SHLIB_VERSION_NUMBER> and libcrypto.so.<SHLIB_VERSION_NUMBER> found
return result;
@ -808,11 +810,11 @@ static LoadedOpenSsl loadOpenSsl()
static QString suffix = QString::fromLatin1(openSSLSuffix("_1_1"));
libssl->setFileNameAndVersion(QLatin1String("ssl") + suffix, -1);
libcrypto->setFileNameAndVersion(QLatin1String("crypto") + suffix, -1);
libssl->setFileNameAndVersion("ssl"_L1 + suffix, -1);
libcrypto->setFileNameAndVersion("crypto"_L1 + suffix, -1);
# else
libssl->setFileNameAndVersion(QLatin1String("ssl"), -1);
libcrypto->setFileNameAndVersion(QLatin1String("crypto"), -1);
libssl->setFileNameAndVersion("ssl"_L1, -1);
libcrypto->setFileNameAndVersion("crypto"_L1, -1);
# endif
if (libcrypto->load() && libssl->load()) {
// libssl.so.0 and libcrypto.so.0 found

View File

@ -60,6 +60,8 @@
QT_BEGIN_NAMESPACE
using namespace Qt::StringLiterals;
namespace {
QSsl::AlertLevel tlsAlertLevel(int value)
@ -85,7 +87,7 @@ QString tlsAlertDescription(int value)
{
QString description = QLatin1String(q_SSL_alert_desc_string_long(value));
if (!description.size())
description = QLatin1String("no description provided");
description = "no description provided"_L1;
return description;
}
@ -822,7 +824,7 @@ void TlsCryptographOpenSSL::continueHandshake()
debugLineClientRandom.append(masterKey.toHex().toUpper());
debugLineClientRandom.append("\n");
QString sslKeyFile = QDir::tempPath() + QLatin1String("/qt-ssl-keys");
QString sslKeyFile = QDir::tempPath() + "/qt-ssl-keys"_L1;
QFile file(sslKeyFile);
if (!file.open(QIODevice::Append))
qCWarning(lcTlsBackend) << "could not open file" << sslKeyFile << "for appending";

View File

@ -65,6 +65,8 @@
QT_BEGIN_NAMESPACE
using namespace Qt::StringLiterals;
Q_LOGGING_CATEGORY(lcTlsBackend, "qt.tlsbackend.ossl");
Q_GLOBAL_STATIC(QRecursiveMutex, qt_opensslInitMutex)
@ -80,9 +82,9 @@ static void q_loadCiphersForConnection(SSL *connection, QList<QSslCipher> &ciphe
const auto ciph = QTlsBackendOpenSSL::qt_OpenSSL_cipher_to_QSslCipher(cipher);
if (!ciph.isNull()) {
// Unconditionally exclude ADH and AECDH ciphers since they offer no MITM protection
if (!ciph.name().toLower().startsWith(QLatin1String("adh")) &&
!ciph.name().toLower().startsWith(QLatin1String("exp-adh")) &&
!ciph.name().toLower().startsWith(QLatin1String("aecdh"))) {
if (!ciph.name().toLower().startsWith("adh"_L1) &&
!ciph.name().toLower().startsWith("exp-adh"_L1) &&
!ciph.name().toLower().startsWith("aecdh"_L1)) {
ciphers << ciph;
if (ciph.usedBits() >= 128)
@ -104,7 +106,7 @@ QString QTlsBackendOpenSSL::getErrorsFromOpenSsl()
unsigned long errNum;
while ((errNum = q_ERR_get_error())) {
if (!errorString.isEmpty())
errorString.append(QLatin1String(", "));
errorString.append(", "_L1);
q_ERR_error_string_n(errNum, buf, sizeof buf);
errorString.append(QString::fromLatin1(buf)); // error is ascii according to man ERR_error_string
}
@ -226,7 +228,7 @@ void QTlsBackendOpenSSL::ensureCiphersAndCertsLoaded() const
// check whether we can enable on-demand root-cert loading (i.e. check whether the sym links are there)
const QList<QByteArray> dirs = QSslSocketPrivate::unixRootCertDirectories();
QStringList symLinkFilter;
symLinkFilter << QLatin1String("[0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f].[0-9]");
symLinkFilter << "[0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f].[0-9]"_L1;
for (const auto &dir : dirs) {
QDirIterator iterator(QLatin1String(dir), symLinkFilter, QDir::Files);
if (iterator.hasNext()) {

View File

@ -57,6 +57,8 @@
QT_BEGIN_NAMESPACE
using namespace Qt::StringLiterals;
namespace QTlsPrivate {
namespace {
@ -305,9 +307,9 @@ QVariant x509ExtensionToValue(X509_EXTENSION *ext)
if (!basic)
return {};
QVariantMap result;
result[QLatin1String("ca")] = basic->ca ? true : false;
result["ca"_L1] = basic->ca ? true : false;
if (basic->pathlen)
result[QLatin1String("pathLenConstraint")] = (qlonglong)q_ASN1_INTEGER_get(basic->pathlen);
result["pathLenConstraint"_L1] = (qlonglong)q_ASN1_INTEGER_get(basic->pathlen);
q_BASIC_CONSTRAINTS_free(basic);
return result;
@ -364,7 +366,7 @@ QVariant x509ExtensionToValue(X509_EXTENSION *ext)
if (auth_key->keyid) {
QByteArray keyid(reinterpret_cast<const char *>(auth_key->keyid->data),
auth_key->keyid->length);
result[QLatin1String("keyid")] = keyid.toHex();
result["keyid"_L1] = keyid.toHex();
}
// issuer
@ -372,7 +374,7 @@ QVariant x509ExtensionToValue(X509_EXTENSION *ext)
// serial
if (auth_key->serial)
result[QLatin1String("serial")] = (qlonglong)q_ASN1_INTEGER_get(auth_key->serial);
result["serial"_L1] = (qlonglong)q_ASN1_INTEGER_get(auth_key->serial);
q_AUTHORITY_KEYID_free(auth_key);
return result;

View File

@ -161,6 +161,8 @@
QT_BEGIN_NAMESPACE
using namespace Qt::StringLiterals;
Q_LOGGING_CATEGORY(lcTlsBackendSchannel, "qt.tlsbackend.schannel");
// Defined in qsslsocket_qt.cpp.
@ -213,7 +215,7 @@ long QSchannelBackend::tlsLibraryVersionNumber() const
QString QSchannelBackend::tlsLibraryVersionString() const
{
const auto os = QOperatingSystemVersion::current();
return QLatin1String("Secure Channel, %1 %2.%3.%4")
return "Secure Channel, %1 %2.%3.%4"_L1
.arg(os.name(),
QString::number(os.majorVersion()),
QString::number(os.minorVersion()),
@ -227,7 +229,7 @@ long QSchannelBackend::tlsLibraryBuildVersionNumber() const
QString QSchannelBackend::tlsLibraryBuildVersionString() const
{
return QLatin1String("Secure Channel (NTDDI: 0x%1)")
return "Secure Channel (NTDDI: 0x%1)"_L1
.arg(QString::number(NTDDI_VERSION, 16).toUpper());
}
@ -571,11 +573,11 @@ bool isCertificateAuthority(const QList<QSslCertificateExtension> &extensions)
{
auto it = std::find_if(extensions.cbegin(), extensions.cend(),
[](const QSslCertificateExtension &extension) {
return extension.name() == QLatin1String("basicConstraints");
return extension.name() == "basicConstraints"_L1;
});
if (it != extensions.cend()) {
QVariantMap basicConstraints = it->value().toMap();
return basicConstraints.value(QLatin1String("ca"), false).toBool();
return basicConstraints.value("ca"_L1, false).toBool();
}
return false;
}
@ -2245,7 +2247,7 @@ bool TlsCryptographSchannel::verifyCertContext(CERT_CONTEXT *certContext)
if (element->TrustStatus.dwErrorStatus & CERT_TRUST_INVALID_BASIC_CONSTRAINTS) {
auto it = std::find_if(extensions.cbegin(), extensions.cend(),
[](const QSslCertificateExtension &extension) {
return extension.name() == QLatin1String("basicConstraints");
return extension.name() == "basicConstraints"_L1;
});
if (it != extensions.cend()) {
// @Note: This is actually one of two errors:
@ -2253,7 +2255,7 @@ bool TlsCryptographSchannel::verifyCertContext(CERT_CONTEXT *certContext)
// or the chain path length has been exceeded."
QVariantMap basicConstraints = it->value().toMap();
QSslError error;
if (i > 0 && !basicConstraints.value(QLatin1String("ca"), false).toBool())
if (i > 0 && !basicConstraints.value("ca"_L1, false).toBool())
error = QSslError(QSslError::InvalidPurpose, certificate);
else
error = QSslError(QSslError::PathLengthExceeded, certificate);

View File

@ -76,6 +76,8 @@
QT_BEGIN_NAMESPACE
using namespace Qt::StringLiterals;
// Defined in qsslsocket_qt.cpp.
QByteArray _q_makePkcs12(const QList<QSslCertificate> &certs, const QSslKey &key,
const QString &passPhrase);
@ -120,7 +122,7 @@ EphemeralSecKeychain::EphemeralSecKeychain()
const auto uuidAsString = QLatin1String(uuidAsByteArray.data(), uuidAsByteArray.size()).mid(1, uuidAsByteArray.size() - 2);
const QString keychainName
= QDir::tempPath() + QDir::separator() + uuidAsString + QLatin1String(".keychain");
= QDir::tempPath() + QDir::separator() + uuidAsString + ".keychain"_L1;
// SecKeychainCreate, pathName parameter:
//
// "A constant character string representing the POSIX path indicating where
@ -575,107 +577,107 @@ void TlsCryptographSecureTransport::transmit()
SSLCipherSuite TlsCryptographSecureTransport::SSLCipherSuite_from_QSslCipher(const QSslCipher &ciph)
{
if (ciph.name() == QLatin1String("AES128-SHA"))
if (ciph.name() == "AES128-SHA"_L1)
return TLS_RSA_WITH_AES_128_CBC_SHA;
if (ciph.name() == QLatin1String("DHE-RSA-AES128-SHA"))
if (ciph.name() == "DHE-RSA-AES128-SHA"_L1)
return TLS_DHE_RSA_WITH_AES_128_CBC_SHA;
if (ciph.name() == QLatin1String("AES256-SHA"))
if (ciph.name() == "AES256-SHA"_L1)
return TLS_RSA_WITH_AES_256_CBC_SHA;
if (ciph.name() == QLatin1String("DHE-RSA-AES256-SHA"))
if (ciph.name() == "DHE-RSA-AES256-SHA"_L1)
return TLS_DHE_RSA_WITH_AES_256_CBC_SHA;
if (ciph.name() == QLatin1String("ECDH-ECDSA-NULL-SHA"))
if (ciph.name() == "ECDH-ECDSA-NULL-SHA"_L1)
return TLS_ECDH_ECDSA_WITH_NULL_SHA;
if (ciph.name() == QLatin1String("ECDH-ECDSA-RC4-SHA"))
if (ciph.name() == "ECDH-ECDSA-RC4-SHA"_L1)
return TLS_ECDH_ECDSA_WITH_RC4_128_SHA;
if (ciph.name() == QLatin1String("ECDH-ECDSA-DES-CBC3-SHA"))
if (ciph.name() == "ECDH-ECDSA-DES-CBC3-SHA"_L1)
return TLS_ECDH_ECDSA_WITH_3DES_EDE_CBC_SHA;
if (ciph.name() == QLatin1String("ECDH-ECDSA-AES128-SHA"))
if (ciph.name() == "ECDH-ECDSA-AES128-SHA"_L1)
return TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA;
if (ciph.name() == QLatin1String("ECDH-ECDSA-AES256-SHA"))
if (ciph.name() == "ECDH-ECDSA-AES256-SHA"_L1)
return TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA;
if (ciph.name() == QLatin1String("ECDH-ECDSA-RC4-SHA"))
if (ciph.name() == "ECDH-ECDSA-RC4-SHA"_L1)
return TLS_ECDHE_ECDSA_WITH_RC4_128_SHA;
if (ciph.name() == QLatin1String("ECDH-ECDSA-DES-CBC3-SHA"))
if (ciph.name() == "ECDH-ECDSA-DES-CBC3-SHA"_L1)
return TLS_ECDHE_ECDSA_WITH_3DES_EDE_CBC_SHA;
if (ciph.name() == QLatin1String("ECDH-ECDSA-AES128-SHA"))
if (ciph.name() == "ECDH-ECDSA-AES128-SHA"_L1)
return TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA;
if (ciph.name() == QLatin1String("ECDH-ECDSA-AES256-SHA"))
if (ciph.name() == "ECDH-ECDSA-AES256-SHA"_L1)
return TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA;
if (ciph.name() == QLatin1String("ECDH-RSA-NULL-SHA"))
if (ciph.name() == "ECDH-RSA-NULL-SHA"_L1)
return TLS_ECDH_RSA_WITH_NULL_SHA;
if (ciph.name() == QLatin1String("ECDH-RSA-RC4-SHA"))
if (ciph.name() == "ECDH-RSA-RC4-SHA"_L1)
return TLS_ECDH_RSA_WITH_RC4_128_SHA;
if (ciph.name() == QLatin1String("ECDH-RSA-DES-CBC3-SHA"))
if (ciph.name() == "ECDH-RSA-DES-CBC3-SHA"_L1)
return TLS_ECDH_RSA_WITH_3DES_EDE_CBC_SHA;
if (ciph.name() == QLatin1String("ECDH-RSA-AES128-SHA"))
if (ciph.name() == "ECDH-RSA-AES128-SHA"_L1)
return TLS_ECDH_RSA_WITH_AES_128_CBC_SHA;
if (ciph.name() == QLatin1String("ECDH-RSA-AES256-SHA"))
if (ciph.name() == "ECDH-RSA-AES256-SHA"_L1)
return TLS_ECDH_RSA_WITH_AES_256_CBC_SHA;
if (ciph.name() == QLatin1String("ECDH-RSA-RC4-SHA"))
if (ciph.name() == "ECDH-RSA-RC4-SHA"_L1)
return TLS_ECDHE_RSA_WITH_RC4_128_SHA;
if (ciph.name() == QLatin1String("ECDH-RSA-DES-CBC3-SHA"))
if (ciph.name() == "ECDH-RSA-DES-CBC3-SHA"_L1)
return TLS_ECDHE_RSA_WITH_3DES_EDE_CBC_SHA;
if (ciph.name() == QLatin1String("ECDH-RSA-AES128-SHA"))
if (ciph.name() == "ECDH-RSA-AES128-SHA"_L1)
return TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA;
if (ciph.name() == QLatin1String("ECDH-RSA-AES256-SHA"))
if (ciph.name() == "ECDH-RSA-AES256-SHA"_L1)
return TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA;
if (ciph.name() == QLatin1String("DES-CBC3-SHA"))
if (ciph.name() == "DES-CBC3-SHA"_L1)
return TLS_RSA_WITH_3DES_EDE_CBC_SHA;
if (ciph.name() == QLatin1String("AES128-SHA256"))
if (ciph.name() == "AES128-SHA256"_L1)
return TLS_RSA_WITH_AES_128_CBC_SHA256;
if (ciph.name() == QLatin1String("AES256-SHA256"))
if (ciph.name() == "AES256-SHA256"_L1)
return TLS_RSA_WITH_AES_256_CBC_SHA256;
if (ciph.name() == QLatin1String("DHE-RSA-DES-CBC3-SHA"))
if (ciph.name() == "DHE-RSA-DES-CBC3-SHA"_L1)
return TLS_DHE_RSA_WITH_3DES_EDE_CBC_SHA;
if (ciph.name() == QLatin1String("DHE-RSA-AES128-SHA256"))
if (ciph.name() == "DHE-RSA-AES128-SHA256"_L1)
return TLS_DHE_RSA_WITH_AES_128_CBC_SHA256;
if (ciph.name() == QLatin1String("DHE-RSA-AES256-SHA256"))
if (ciph.name() == "DHE-RSA-AES256-SHA256"_L1)
return TLS_DHE_RSA_WITH_AES_256_CBC_SHA256;
if (ciph.name() == QLatin1String("AES256-GCM-SHA384"))
if (ciph.name() == "AES256-GCM-SHA384"_L1)
return TLS_RSA_WITH_AES_256_GCM_SHA384;
if (ciph.name() == QLatin1String("ECDHE-ECDSA-AES128-SHA256"))
if (ciph.name() == "ECDHE-ECDSA-AES128-SHA256"_L1)
return TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256;
if (ciph.name() == QLatin1String("ECDHE-ECDSA-AES256-SHA384"))
if (ciph.name() == "ECDHE-ECDSA-AES256-SHA384"_L1)
return TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384;
if (ciph.name() == QLatin1String("ECDH-ECDSA-AES128-SHA256"))
if (ciph.name() == "ECDH-ECDSA-AES128-SHA256"_L1)
return TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA256;
if (ciph.name() == QLatin1String("ECDH-ECDSA-AES256-SHA384"))
if (ciph.name() == "ECDH-ECDSA-AES256-SHA384"_L1)
return TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA384;
if (ciph.name() == QLatin1String("ECDHE-RSA-AES128-SHA256"))
if (ciph.name() == "ECDHE-RSA-AES128-SHA256"_L1)
return TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256;
if (ciph.name() == QLatin1String("ECDHE-RSA-AES256-SHA384"))
if (ciph.name() == "ECDHE-RSA-AES256-SHA384"_L1)
return TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384;
if (ciph.name() == QLatin1String("ECDHE-RSA-AES256-SHA384"))
if (ciph.name() == "ECDHE-RSA-AES256-SHA384"_L1)
return TLS_ECDH_RSA_WITH_AES_128_CBC_SHA256;
if (ciph.name() == QLatin1String("ECDHE-RSA-AES256-GCM-SHA384"))
if (ciph.name() == "ECDHE-RSA-AES256-GCM-SHA384"_L1)
return TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384;
if (ciph.name() == QLatin1String("AES128-GCM-SHA256"))
if (ciph.name() == "AES128-GCM-SHA256"_L1)
return TLS_AES_128_GCM_SHA256;
if (ciph.name() == QLatin1String("AES256-GCM-SHA384"))
if (ciph.name() == "AES256-GCM-SHA384"_L1)
return TLS_AES_256_GCM_SHA384;
if (ciph.name() == QLatin1String("CHACHA20-POLY1305-SHA256"))
if (ciph.name() == "CHACHA20-POLY1305-SHA256"_L1)
return TLS_CHACHA20_POLY1305_SHA256;
if (ciph.name() == QLatin1String("AES128-CCM-SHA256"))
if (ciph.name() == "AES128-CCM-SHA256"_L1)
return TLS_AES_128_CCM_SHA256;
if (ciph.name() == QLatin1String("AES128-CCM8-SHA256"))
if (ciph.name() == "AES128-CCM8-SHA256"_L1)
return TLS_AES_128_CCM_8_SHA256;
if (ciph.name() == QLatin1String("ECDHE-ECDSA-AES128-GCM-SHA256"))
if (ciph.name() == "ECDHE-ECDSA-AES128-GCM-SHA256"_L1)
return TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256;
if (ciph.name() == QLatin1String("ECDHE-ECDSA-AES256-GCM-SHA384"))
if (ciph.name() == "ECDHE-ECDSA-AES256-GCM-SHA384"_L1)
return TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384;
if (ciph.name() == QLatin1String("ECDH-ECDSA-AES128-GCM-SHA256"))
if (ciph.name() == "ECDH-ECDSA-AES128-GCM-SHA256"_L1)
return TLS_ECDH_ECDSA_WITH_AES_128_GCM_SHA256;
if (ciph.name() == QLatin1String("ECDH-ECDSA-AES256-GCM-SHA384"))
if (ciph.name() == "ECDH-ECDSA-AES256-GCM-SHA384"_L1)
return TLS_ECDH_ECDSA_WITH_AES_256_GCM_SHA384;
if (ciph.name() == QLatin1String("ECDHE-RSA-AES128-GCM-SHA256"))
if (ciph.name() == "ECDHE-RSA-AES128-GCM-SHA256"_L1)
return TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256;
if (ciph.name() == QLatin1String("ECDH-RSA-AES128-GCM-SHA256"))
if (ciph.name() == "ECDH-RSA-AES128-GCM-SHA256"_L1)
return TLS_ECDH_RSA_WITH_AES_128_GCM_SHA256;
if (ciph.name() == QLatin1String("ECDH-RSA-AES256-GCM-SHA384"))
if (ciph.name() == "ECDH-RSA-AES256-GCM-SHA384"_L1)
return TLS_ECDH_RSA_WITH_AES_256_GCM_SHA384;
if (ciph.name() == QLatin1String("ECDHE-RSA-CHACHA20-POLY1305-SHA256"))
if (ciph.name() == "ECDHE-RSA-CHACHA20-POLY1305-SHA256"_L1)
return TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256;
if (ciph.name() == QLatin1String("ECDHE-ECDSA-CHACHA20-POLY1305-SHA256"))
if (ciph.name() == "ECDHE-ECDSA-CHACHA20-POLY1305-SHA256"_L1)
return TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256;
return 0;

View File

@ -47,6 +47,8 @@
QT_BEGIN_NAMESPACE
using namespace Qt::StringLiterals;
Q_GLOBAL_STATIC(QRecursiveMutex, qt_securetransport_mutex)
Q_LOGGING_CATEGORY(lcSecureTransport, "qt.tlsbackend.securetransport");
@ -64,98 +66,98 @@ QSslCipher QSslCipher_from_SSLCipherSuite(SSLCipherSuite cipher)
// Sorted as in CipherSuite.h (and groupped by their RFC)
// TLS addenda using AES, per RFC 3268
case TLS_RSA_WITH_AES_128_CBC_SHA:
name = QLatin1String("AES128-SHA");
name = "AES128-SHA"_L1;
break;
case TLS_DHE_RSA_WITH_AES_128_CBC_SHA:
name = QLatin1String("DHE-RSA-AES128-SHA");
name = "DHE-RSA-AES128-SHA"_L1;
break;
case TLS_RSA_WITH_AES_256_CBC_SHA:
name = QLatin1String("AES256-SHA");
name = "AES256-SHA"_L1;
break;
case TLS_DHE_RSA_WITH_AES_256_CBC_SHA:
name = QLatin1String("DHE-RSA-AES256-SHA");
name = "DHE-RSA-AES256-SHA"_L1;
break;
// ECDSA addenda, RFC 4492
case TLS_ECDH_ECDSA_WITH_NULL_SHA:
name = QLatin1String("ECDH-ECDSA-NULL-SHA");
name = "ECDH-ECDSA-NULL-SHA"_L1;
break;
case TLS_ECDH_ECDSA_WITH_RC4_128_SHA:
name = QLatin1String("ECDH-ECDSA-RC4-SHA");
name = "ECDH-ECDSA-RC4-SHA"_L1;
break;
case TLS_ECDH_ECDSA_WITH_3DES_EDE_CBC_SHA:
name = QLatin1String("ECDH-ECDSA-DES-CBC3-SHA");
name = "ECDH-ECDSA-DES-CBC3-SHA"_L1;
break;
case TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA:
name = QLatin1String("ECDH-ECDSA-AES128-SHA");
name = "ECDH-ECDSA-AES128-SHA"_L1;
break;
case TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA:
name = QLatin1String("ECDH-ECDSA-AES256-SHA");
name = "ECDH-ECDSA-AES256-SHA"_L1;
break;
case TLS_ECDHE_ECDSA_WITH_NULL_SHA:
name = QLatin1String("ECDHE-ECDSA-NULL-SHA");
name = "ECDHE-ECDSA-NULL-SHA"_L1;
break;
case TLS_ECDHE_ECDSA_WITH_RC4_128_SHA:
name = QLatin1String("ECDHE-ECDSA-RC4-SHA");
name = "ECDHE-ECDSA-RC4-SHA"_L1;
break;
case TLS_ECDHE_ECDSA_WITH_3DES_EDE_CBC_SHA:
name = QLatin1String("ECDHE-ECDSA-DES-CBC3-SHA");
name = "ECDHE-ECDSA-DES-CBC3-SHA"_L1;
break;
case TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA:
name = QLatin1String("ECDHE-ECDSA-AES128-SHA");
name = "ECDHE-ECDSA-AES128-SHA"_L1;
break;
case TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA:
name = QLatin1String("ECDHE-ECDSA-AES256-SHA");
name = "ECDHE-ECDSA-AES256-SHA"_L1;
break;
case TLS_ECDH_RSA_WITH_NULL_SHA:
name = QLatin1String("ECDH-RSA-NULL-SHA");
name = "ECDH-RSA-NULL-SHA"_L1;
break;
case TLS_ECDH_RSA_WITH_RC4_128_SHA:
name = QLatin1String("ECDH-RSA-RC4-SHA");
name = "ECDH-RSA-RC4-SHA"_L1;
break;
case TLS_ECDH_RSA_WITH_3DES_EDE_CBC_SHA:
name = QLatin1String("ECDH-RSA-DES-CBC3-SHA");
name = "ECDH-RSA-DES-CBC3-SHA"_L1;
break;
case TLS_ECDH_RSA_WITH_AES_128_CBC_SHA:
name = QLatin1String("ECDH-RSA-AES128-SHA");
name = "ECDH-RSA-AES128-SHA"_L1;
break;
case TLS_ECDH_RSA_WITH_AES_256_CBC_SHA:
name = QLatin1String("ECDH-RSA-AES256-SHA");
name = "ECDH-RSA-AES256-SHA"_L1;
break;
case TLS_ECDHE_RSA_WITH_NULL_SHA:
name = QLatin1String("ECDHE-RSA-NULL-SHA");
name = "ECDHE-RSA-NULL-SHA"_L1;
break;
case TLS_ECDHE_RSA_WITH_RC4_128_SHA:
name = QLatin1String("ECDHE-RSA-RC4-SHA");
name = "ECDHE-RSA-RC4-SHA"_L1;
break;
case TLS_ECDHE_RSA_WITH_3DES_EDE_CBC_SHA:
name = QLatin1String("ECDHE-RSA-DES-CBC3-SHA");
name = "ECDHE-RSA-DES-CBC3-SHA"_L1;
break;
case TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA:
name = QLatin1String("ECDHE-RSA-AES128-SHA");
name = "ECDHE-RSA-AES128-SHA"_L1;
break;
case TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA:
name = QLatin1String("ECDHE-RSA-AES256-SHA");
name = "ECDHE-RSA-AES256-SHA"_L1;
break;
// TLS 1.2 addenda, RFC 5246
case TLS_RSA_WITH_3DES_EDE_CBC_SHA:
name = QLatin1String("DES-CBC3-SHA");
name = "DES-CBC3-SHA"_L1;
break;
case TLS_RSA_WITH_AES_128_CBC_SHA256:
name = QLatin1String("AES128-SHA256");
name = "AES128-SHA256"_L1;
break;
case TLS_RSA_WITH_AES_256_CBC_SHA256:
name = QLatin1String("AES256-SHA256");
name = "AES256-SHA256"_L1;
break;
case TLS_DHE_RSA_WITH_3DES_EDE_CBC_SHA:
name = QLatin1String("DHE-RSA-DES-CBC3-SHA");
name = "DHE-RSA-DES-CBC3-SHA"_L1;
break;
case TLS_DHE_RSA_WITH_AES_128_CBC_SHA256:
name = QLatin1String("DHE-RSA-AES128-SHA256");
name = "DHE-RSA-AES128-SHA256"_L1;
break;
case TLS_DHE_RSA_WITH_AES_256_CBC_SHA256:
name = QLatin1String("DHE-RSA-AES256-SHA256");
name = "DHE-RSA-AES256-SHA256"_L1;
break;
// Addendum from RFC 4279, TLS PSK
@ -166,7 +168,7 @@ QSslCipher QSslCipher_from_SSLCipherSuite(SSLCipherSuite cipher)
// Addenda from rfc 5288 AES Galois Counter Mode (CGM) Cipher Suites for TLS
case TLS_RSA_WITH_AES_256_GCM_SHA384:
name = QLatin1String("AES256-GCM-SHA384");
name = "AES256-GCM-SHA384"_L1;
break;
// RFC 5487 - PSK with SHA-256/384 and AES GCM
@ -174,90 +176,90 @@ QSslCipher QSslCipher_from_SSLCipherSuite(SSLCipherSuite cipher)
// Addenda from rfc 5289 Elliptic Curve Cipher Suites with HMAC SHA-256/384
case TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256:
name = QLatin1String("ECDHE-ECDSA-AES128-SHA256");
name = "ECDHE-ECDSA-AES128-SHA256"_L1;
break;
case TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384:
name = QLatin1String("ECDHE-ECDSA-AES256-SHA384");
name = "ECDHE-ECDSA-AES256-SHA384"_L1;
break;
case TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA256:
name = QLatin1String("ECDH-ECDSA-AES128-SHA256");
name = "ECDH-ECDSA-AES128-SHA256"_L1;
break;
case TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA384:
name = QLatin1String("ECDH-ECDSA-AES256-SHA384");
name = "ECDH-ECDSA-AES256-SHA384"_L1;
break;
case TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256:
name = QLatin1String("ECDHE-RSA-AES128-SHA256");
name = "ECDHE-RSA-AES128-SHA256"_L1;
break;
case TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384:
name = QLatin1String("ECDHE-RSA-AES256-SHA384");
name = "ECDHE-RSA-AES256-SHA384"_L1;
break;
case TLS_ECDH_RSA_WITH_AES_128_CBC_SHA256:
name = QLatin1String("ECDH-RSA-AES128-SHA256");
name = "ECDH-RSA-AES128-SHA256"_L1;
break;
case TLS_ECDH_RSA_WITH_AES_256_CBC_SHA384:
name = QLatin1String("ECDH-RSA-AES256-SHA384");
name = "ECDH-RSA-AES256-SHA384"_L1;
break;
// Addenda from rfc 5289 Elliptic Curve Cipher Suites
// with SHA-256/384 and AES Galois Counter Mode (GCM)
case TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384:
name = QLatin1String("ECDHE-RSA-AES256-GCM-SHA384");
name = "ECDHE-RSA-AES256-GCM-SHA384"_L1;
break;
// TLS 1.3 standard cipher suites for ChaCha20+Poly1305.
// Note: TLS 1.3 ciphersuites do not specify the key exchange
// algorithm -- they only specify the symmetric ciphers.
case TLS_AES_128_GCM_SHA256:
name = QLatin1String("AES128-GCM-SHA256");
name = "AES128-GCM-SHA256"_L1;
break;
case TLS_AES_256_GCM_SHA384:
name = QLatin1String("AES256-GCM-SHA384");
name = "AES256-GCM-SHA384"_L1;
break;
case TLS_CHACHA20_POLY1305_SHA256:
name = QLatin1String("CHACHA20-POLY1305-SHA256");
name = "CHACHA20-POLY1305-SHA256"_L1;
break;
case TLS_AES_128_CCM_SHA256:
name = QLatin1String("AES128-CCM-SHA256");
name = "AES128-CCM-SHA256"_L1;
break;
case TLS_AES_128_CCM_8_SHA256:
name = QLatin1String("AES128-CCM8-SHA256");
name = "AES128-CCM8-SHA256"_L1;
break;
// Addenda from rfc 5289 Elliptic Curve Cipher Suites with
// SHA-256/384 and AES Galois Counter Mode (GCM).
case TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256:
name = QLatin1String("ECDHE-ECDSA-AES128-GCM-SHA256");
name = "ECDHE-ECDSA-AES128-GCM-SHA256"_L1;
break;
case TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384:
name = QLatin1String("ECDHE-ECDSA-AES256-GCM-SHA384");
name = "ECDHE-ECDSA-AES256-GCM-SHA384"_L1;
break;
case TLS_ECDH_ECDSA_WITH_AES_128_GCM_SHA256:
name = QLatin1String("ECDH-ECDSA-AES128-GCM-SHA256");
name = "ECDH-ECDSA-AES128-GCM-SHA256"_L1;
break;
case TLS_ECDH_ECDSA_WITH_AES_256_GCM_SHA384:
name = QLatin1String("ECDH-ECDSA-AES256-GCM-SHA384");
name = "ECDH-ECDSA-AES256-GCM-SHA384"_L1;
break;
case TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256:
name = QLatin1String("ECDHE-RSA-AES128-GCM-SHA256");
name = "ECDHE-RSA-AES128-GCM-SHA256"_L1;
break;
case TLS_ECDH_RSA_WITH_AES_128_GCM_SHA256:
name = QLatin1String("ECDH-RSA-AES128-GCM-SHA256");
name = "ECDH-RSA-AES128-GCM-SHA256"_L1;
break;
case TLS_ECDH_RSA_WITH_AES_256_GCM_SHA384:
name = QLatin1String("ECDH-RSA-AES256-GCM-SHA384");
name = "ECDH-RSA-AES256-GCM-SHA384"_L1;
break;
// Addenda from rfc 7905 ChaCha20-Poly1305 Cipher Suites for
// Transport Layer Security (TLS).
case TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256:
name = QLatin1String("ECDHE-RSA-CHACHA20-POLY1305-SHA256");
name = "ECDHE-RSA-CHACHA20-POLY1305-SHA256"_L1;
break;
case TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256:
name = QLatin1String("ECDHE-ECDSA-CHACHA20-POLY1305-SHA256");
name = "ECDHE-ECDSA-CHACHA20-POLY1305-SHA256"_L1;
break;
default:
return {};
}
return QTlsBackend::createCiphersuite(name, QSsl::TlsV1_2, QLatin1String("TLSv1.2"));
return QTlsBackend::createCiphersuite(name, QSsl::TlsV1_2, "TLSv1.2"_L1);
}
} // namespace QTlsPrivate
@ -266,7 +268,7 @@ bool QSecureTransportBackend::s_loadedCiphersAndCerts = false;
QString QSecureTransportBackend::tlsLibraryVersionString() const
{
return QLatin1String("Secure Transport, ") + QSysInfo::prettyProductName();
return "Secure Transport, "_L1 + QSysInfo::prettyProductName();
}
QString QSecureTransportBackend::tlsLibraryBuildVersionString() const

View File

@ -52,6 +52,8 @@
QT_BEGIN_NAMESPACE
using namespace Qt::StringLiterals;
namespace QTlsPrivate {
namespace {
@ -291,7 +293,7 @@ bool X509CertificateGeneric::parse(const QByteArray &data)
if (!parseExtension(elem.value(), extension))
return false;
if (extension.oid == QLatin1String("2.5.29.17")) {
if (extension.oid == "2.5.29.17"_L1) {
// subjectAltName
// Note, parseExtension() returns true for this extensions,