Commit e6017556 authored by Nicolas Fella's avatar Nicolas Fella

Force usage of QStringLiteral and port remaining offenders

parent 86b82677
Pipeline #4186 passed with stage
in 9 minutes and 41 seconds
...@@ -34,7 +34,7 @@ else() ...@@ -34,7 +34,7 @@ else()
if(NOT WIN32 AND NOT APPLE) if(NOT WIN32 AND NOT APPLE)
find_package(KF5PulseAudioQt REQUIRED) find_package(KF5PulseAudioQt REQUIRED)
endif() endif()
add_definitions(-DQT_NO_URL_CAST_FROM_STRING -DQT_NO_KEYWORDS) add_definitions(-DQT_NO_URL_CAST_FROM_STRING -DQT_NO_KEYWORDS -DQT_NO_CAST_FROM_ASCII)
endif() endif()
find_package(ECM ${KF5_MIN_VERSION} REQUIRED NO_MODULE) find_package(ECM ${KF5_MIN_VERSION} REQUIRED NO_MODULE)
......
...@@ -78,8 +78,8 @@ int main(int argc, char** argv) ...@@ -78,8 +78,8 @@ int main(int argc, char** argv)
//Hidden because it's an implementation detail //Hidden because it's an implementation detail
QCommandLineOption deviceAutocomplete(QStringLiteral("shell-device-autocompletion")); QCommandLineOption deviceAutocomplete(QStringLiteral("shell-device-autocompletion"));
deviceAutocomplete.setHidden(true); deviceAutocomplete.setHidden(true);
deviceAutocomplete.setDescription("Outputs all available devices id's with their name and paired status"); //Not visible, so no translation needed deviceAutocomplete.setDescription(QStringLiteral("Outputs all available devices id's with their name and paired status")); //Not visible, so no translation needed
deviceAutocomplete.setValueName("shell"); deviceAutocomplete.setValueName(QStringLiteral("shell"));
parser.addOption(deviceAutocomplete); parser.addOption(deviceAutocomplete);
about.setupCommandLine(&parser); about.setupCommandLine(&parser);
...@@ -87,7 +87,7 @@ int main(int argc, char** argv) ...@@ -87,7 +87,7 @@ int main(int argc, char** argv)
parser.process(app); parser.process(app);
about.processCommandLine(&parser); about.processCommandLine(&parser);
const QString id = "kdeconnect-cli-"+QString::number(QCoreApplication::applicationPid()); const QString id = QStringLiteral("kdeconnect-cli-") + QString::number(QCoreApplication::applicationPid());
DaemonDbusInterface iface; DaemonDbusInterface iface;
if (parser.isSet(QStringLiteral("my-id"))) { if (parser.isSet(QStringLiteral("my-id"))) {
...@@ -152,15 +152,15 @@ int main(int argc, char** argv) ...@@ -152,15 +152,15 @@ int main(int argc, char** argv)
} }
//Description: "device name (paired/unpaired)" //Description: "device name (paired/unpaired)"
QString description = deviceIface.name() + " " + statusInfo; QString description = deviceIface.name() + QLatin1Char(' ') + statusInfo;
//Replace characters //Replace characters
description.replace(QChar('\\'), QStringLiteral("\\\\")); description.replace(QLatin1Char('\\'), QStringLiteral("\\\\"));
description.replace(QChar('['), QStringLiteral("\\[")); description.replace(QLatin1Char('['), QStringLiteral("\\["));
description.replace(QChar(']'), QStringLiteral("\\]")); description.replace(QLatin1Char(']'), QStringLiteral("\\]"));
description.replace(QChar('\''), QStringLiteral("\\'")); description.replace(QLatin1Char('\''), QStringLiteral("\\'"));
description.replace(QChar('\"'), QStringLiteral("\\\"")); description.replace(QLatin1Char('\"'), QStringLiteral("\\\""));
description.replace(QChar('\n'), QChar(' ')); description.replace(QLatin1Char('\n'), QLatin1Char(' '));
description.remove(QChar('\0')); description.remove(QLatin1Char('\0'));
//Output id and description //Output id and description
QTextStream(stdout) << id << '[' << description << ']' << endl; QTextStream(stdout) << id << '[' << description << ']' << endl;
...@@ -196,7 +196,7 @@ int main(int argc, char** argv) ...@@ -196,7 +196,7 @@ int main(int argc, char** argv)
urls.append(url.toString()); urls.append(url.toString());
} }
QDBusMessage msg = QDBusMessage::createMethodCall(QStringLiteral("org.kde.kdeconnect"), "/modules/kdeconnect/devices/"+device+"/share", QDBusMessage msg = QDBusMessage::createMethodCall(QStringLiteral("org.kde.kdeconnect"), QStringLiteral("/modules/kdeconnect/devices/") + device + QStringLiteral("/share"),
QStringLiteral("org.kde.kdeconnect.device.share"), QStringLiteral("shareUrls")); QStringLiteral("org.kde.kdeconnect.device.share"), QStringLiteral("shareUrls"));
msg.setArguments(QVariantList() << QVariant(urls)); msg.setArguments(QVariantList() << QVariant(urls));
...@@ -206,7 +206,7 @@ int main(int argc, char** argv) ...@@ -206,7 +206,7 @@ int main(int argc, char** argv)
QTextStream(stdout) << i18n("Shared %1", url) << endl; QTextStream(stdout) << i18n("Shared %1", url) << endl;
} }
} else if (parser.isSet(QStringLiteral("share-text"))) { } else if (parser.isSet(QStringLiteral("share-text"))) {
QDBusMessage msg = QDBusMessage::createMethodCall(QStringLiteral("org.kde.kdeconnect"), "/modules/kdeconnect/devices/"+device+"/share", QStringLiteral("org.kde.kdeconnect.device.share"), QStringLiteral("shareText")); QDBusMessage msg = QDBusMessage::createMethodCall(QStringLiteral("org.kde.kdeconnect"), QStringLiteral("/modules/kdeconnect/devices/") + device + QStringLiteral("/share"), QStringLiteral("org.kde.kdeconnect.device.share"), QStringLiteral("shareText"));
msg.setArguments(QVariantList() << parser.value(QStringLiteral("share-text"))); msg.setArguments(QVariantList() << parser.value(QStringLiteral("share-text")));
blockOnReply(DbusHelper::sessionBus().asyncCall(msg)); blockOnReply(DbusHelper::sessionBus().asyncCall(msg));
QTextStream(stdout) << i18n("Shared text: %1", parser.value(QStringLiteral("share-text"))) << endl; QTextStream(stdout) << i18n("Shared text: %1", parser.value(QStringLiteral("share-text"))) << endl;
...@@ -246,7 +246,7 @@ int main(int argc, char** argv) ...@@ -246,7 +246,7 @@ int main(int argc, char** argv)
blockOnReply(dev.unpair()); blockOnReply(dev.unpair());
} }
} else if(parser.isSet(QStringLiteral("ping")) || parser.isSet(QStringLiteral("ping-msg"))) { } else if(parser.isSet(QStringLiteral("ping")) || parser.isSet(QStringLiteral("ping-msg"))) {
QDBusMessage msg = QDBusMessage::createMethodCall(QStringLiteral("org.kde.kdeconnect"), "/modules/kdeconnect/devices/"+device+"/ping", QStringLiteral("org.kde.kdeconnect.device.ping"), QStringLiteral("sendPing")); QDBusMessage msg = QDBusMessage::createMethodCall(QStringLiteral("org.kde.kdeconnect"), QStringLiteral("/modules/kdeconnect/devices/") + device + QStringLiteral("/ping"), QStringLiteral("org.kde.kdeconnect.device.ping"), QStringLiteral("sendPing"));
if (parser.isSet(QStringLiteral("ping-msg"))) { if (parser.isSet(QStringLiteral("ping-msg"))) {
QString message = parser.value(QStringLiteral("ping-msg")); QString message = parser.value(QStringLiteral("ping-msg"));
msg.setArguments(QVariantList() << message); msg.setArguments(QVariantList() << message);
...@@ -254,29 +254,29 @@ int main(int argc, char** argv) ...@@ -254,29 +254,29 @@ int main(int argc, char** argv)
blockOnReply(DbusHelper::sessionBus().asyncCall(msg)); blockOnReply(DbusHelper::sessionBus().asyncCall(msg));
} else if(parser.isSet(QStringLiteral("send-sms"))) { } else if(parser.isSet(QStringLiteral("send-sms"))) {
if (parser.isSet(QStringLiteral("destination"))) { if (parser.isSet(QStringLiteral("destination"))) {
QDBusMessage msg = QDBusMessage::createMethodCall(QStringLiteral("org.kde.kdeconnect"), "/modules/kdeconnect/devices/"+device+"/sms", QStringLiteral("org.kde.kdeconnect.device.sms"), QStringLiteral("sendSms")); QDBusMessage msg = QDBusMessage::createMethodCall(QStringLiteral("org.kde.kdeconnect"), QStringLiteral("/modules/kdeconnect/devices/") + device + QStringLiteral("/sms"), QStringLiteral("org.kde.kdeconnect.device.sms"), QStringLiteral("sendSms"));
msg.setArguments({ parser.value("destination"), parser.value("send-sms") }); msg.setArguments({ parser.value(QStringLiteral("destination")), parser.value(QStringLiteral("send-sms"))});
blockOnReply(DbusHelper::sessionBus().asyncCall(msg)); blockOnReply(DbusHelper::sessionBus().asyncCall(msg));
} else { } else {
QTextStream(stderr) << i18n("error: should specify the SMS's recipient by passing --destination <phone number>"); QTextStream(stderr) << i18n("error: should specify the SMS's recipient by passing --destination <phone number>");
return 1; return 1;
} }
} else if(parser.isSet(QStringLiteral("ring"))) { } else if(parser.isSet(QStringLiteral("ring"))) {
QDBusMessage msg = QDBusMessage::createMethodCall(QStringLiteral("org.kde.kdeconnect"), "/modules/kdeconnect/devices/"+device+"/findmyphone", QStringLiteral("org.kde.kdeconnect.device.findmyphone"), QStringLiteral("ring")); QDBusMessage msg = QDBusMessage::createMethodCall(QStringLiteral("org.kde.kdeconnect"), QStringLiteral("/modules/kdeconnect/devices/") + device + QStringLiteral("/findmyphone"), QStringLiteral("org.kde.kdeconnect.device.findmyphone"), QStringLiteral("ring"));
blockOnReply(DbusHelper::sessionBus().asyncCall(msg)); blockOnReply(DbusHelper::sessionBus().asyncCall(msg));
} else if(parser.isSet(QStringLiteral("photo"))) { } else if(parser.isSet(QStringLiteral("photo"))) {
QDBusMessage msg = QDBusMessage::createMethodCall(QStringLiteral("org.kde.kdeconnect"), "/modules/kdeconnect/devices/"+device+"/photo", QStringLiteral("org.kde.kdeconnect.device.photo"), QStringLiteral("requestPhoto")); QDBusMessage msg = QDBusMessage::createMethodCall(QStringLiteral("org.kde.kdeconnect"), QStringLiteral("/modules/kdeconnect/devices/") + device + QStringLiteral("/photo"), QStringLiteral("org.kde.kdeconnect.device.photo"), QStringLiteral("requestPhoto"));
blockOnReply(DbusHelper::sessionBus().asyncCall(msg)); blockOnReply(DbusHelper::sessionBus().asyncCall(msg));
} else if(parser.isSet("send-keys")) { } else if(parser.isSet(QStringLiteral("send-keys"))) {
QString seq = parser.value("send-keys"); QString seq = parser.value(QStringLiteral("send-keys"));
QDBusMessage msg = QDBusMessage::createMethodCall("org.kde.kdeconnect", "/modules/kdeconnect/devices/"+device+"/remotekeyboard", "org.kde.kdeconnect.device.remotekeyboard", "sendKeyPress"); QDBusMessage msg = QDBusMessage::createMethodCall(QStringLiteral("org.kde.kdeconnect"), QStringLiteral("/modules/kdeconnect/devices/") + device + QStringLiteral("/remotekeyboard"), QStringLiteral("org.kde.kdeconnect.device.remotekeyboard"), QStringLiteral("sendKeyPress"));
if (seq.trimmed() == QLatin1String("-")) { if (seq.trimmed() == QLatin1String("-")) {
// from stdin // from stdin
QFile in; QFile in;
if(in.open(stdin,QIODevice::ReadOnly | QIODevice::Unbuffered)) { if(in.open(stdin,QIODevice::ReadOnly | QIODevice::Unbuffered)) {
while (!in.atEnd()) { while (!in.atEnd()) {
QByteArray line = in.readLine(); // sanitize to ASCII-codes > 31? QByteArray line = in.readLine(); // sanitize to ASCII-codes > 31?
msg.setArguments({QString(line), -1, false, false, false}); msg.setArguments({QString::fromLatin1(line), -1, false, false, false});
blockOnReply(DbusHelper::sessionBus().asyncCall(msg)); blockOnReply(DbusHelper::sessionBus().asyncCall(msg));
} }
in.close(); in.close();
......
...@@ -45,7 +45,7 @@ BluetoothDeviceLink::BluetoothDeviceLink(const QString& deviceId, LinkProvider* ...@@ -45,7 +45,7 @@ BluetoothDeviceLink::BluetoothDeviceLink(const QString& deviceId, LinkProvider*
QString BluetoothDeviceLink::name() QString BluetoothDeviceLink::name()
{ {
return "BluetoothLink"; // Should be same in both android and kde version return QStringLiteral("BluetoothLink"); // Should be same in both android and kde version
} }
bool BluetoothDeviceLink::sendPacket(NetworkPacket& np) bool BluetoothDeviceLink::sendPacket(NetworkPacket& np)
......
...@@ -23,7 +23,7 @@ ...@@ -23,7 +23,7 @@
BluetoothDownloadJob::BluetoothDownloadJob(const QBluetoothAddress& remoteAddress, const QVariantMap& transferInfo, QObject* parent) BluetoothDownloadJob::BluetoothDownloadJob(const QBluetoothAddress& remoteAddress, const QVariantMap& transferInfo, QObject* parent)
: QObject(parent) : QObject(parent)
, mRemoteAddress(remoteAddress) , mRemoteAddress(remoteAddress)
, mTransferUuid(QBluetoothUuid(transferInfo.value("uuid").toString())) , mTransferUuid(QBluetoothUuid(transferInfo.value(QStringLiteral("uuid")).toString()))
, mSocket(new QBluetoothSocket(QBluetoothServiceInfo::RfcommProtocol)) , mSocket(new QBluetoothSocket(QBluetoothServiceInfo::RfcommProtocol))
{ {
} }
......
...@@ -34,7 +34,7 @@ ...@@ -34,7 +34,7 @@
BluetoothLinkProvider::BluetoothLinkProvider() BluetoothLinkProvider::BluetoothLinkProvider()
{ {
mServiceUuid = QBluetoothUuid(QString("185f3df4-3268-4e3f-9fca-d4d5059915bd")); mServiceUuid = QBluetoothUuid(QStringLiteral("185f3df4-3268-4e3f-9fca-d4d5059915bd"));
connectTimer = new QTimer(this); connectTimer = new QTimer(this);
connectTimer->setInterval(30000); connectTimer->setInterval(30000);
...@@ -61,7 +61,7 @@ void BluetoothLinkProvider::onStart() ...@@ -61,7 +61,7 @@ void BluetoothLinkProvider::onStart()
mServiceDiscoveryAgent->start(); mServiceDiscoveryAgent->start();
connectTimer->start(); connectTimer->start();
mKdeconnectService = mBluetoothServer->listen(mServiceUuid, "KDE Connect"); mKdeconnectService = mBluetoothServer->listen(mServiceUuid, QStringLiteral("KDE Connect"));
} }
void BluetoothLinkProvider::onStop() void BluetoothLinkProvider::onStop()
...@@ -183,7 +183,7 @@ void BluetoothLinkProvider::clientIdentityReceived() ...@@ -183,7 +183,7 @@ void BluetoothLinkProvider::clientIdentityReceived()
disconnect(socket, SIGNAL(readyRead()), this, SLOT(clientIdentityReceived())); disconnect(socket, SIGNAL(readyRead()), this, SLOT(clientIdentityReceived()));
NetworkPacket receivedPacket(""); NetworkPacket receivedPacket;
bool success = NetworkPacket::unserialize(identityArray, &receivedPacket); bool success = NetworkPacket::unserialize(identityArray, &receivedPacket);
if (!success || receivedPacket.type() != PACKET_TYPE_IDENTITY) { if (!success || receivedPacket.type() != PACKET_TYPE_IDENTITY) {
...@@ -198,10 +198,10 @@ void BluetoothLinkProvider::clientIdentityReceived() ...@@ -198,10 +198,10 @@ void BluetoothLinkProvider::clientIdentityReceived()
disconnect(socket, SIGNAL(error(QBluetoothSocket::SocketError)), this, SLOT(connectError())); disconnect(socket, SIGNAL(error(QBluetoothSocket::SocketError)), this, SLOT(connectError()));
const QString& deviceId = receivedPacket.get<QString>("deviceId"); const QString& deviceId = receivedPacket.get<QString>(QStringLiteral("deviceId"));
BluetoothDeviceLink* deviceLink = new BluetoothDeviceLink(deviceId, this, socket); BluetoothDeviceLink* deviceLink = new BluetoothDeviceLink(deviceId, this, socket);
NetworkPacket np2(""); NetworkPacket np2;
NetworkPacket::createIdentityPacket(&np2); NetworkPacket::createIdentityPacket(&np2);
success = deviceLink->sendPacket(np2); success = deviceLink->sendPacket(np2);
...@@ -243,7 +243,7 @@ void BluetoothLinkProvider::serverNewConnection() ...@@ -243,7 +243,7 @@ void BluetoothLinkProvider::serverNewConnection()
connect(socket, SIGNAL(error(QBluetoothSocket::SocketError)), this, SLOT(connectError())); connect(socket, SIGNAL(error(QBluetoothSocket::SocketError)), this, SLOT(connectError()));
connect(socket, SIGNAL(disconnected()), this, SLOT(socketDisconnected())); connect(socket, SIGNAL(disconnected()), this, SLOT(socketDisconnected()));
NetworkPacket np2(""); NetworkPacket np2;
NetworkPacket::createIdentityPacket(&np2); NetworkPacket::createIdentityPacket(&np2);
socket->write(np2.serialize()); socket->write(np2.serialize());
...@@ -276,7 +276,7 @@ void BluetoothLinkProvider::serverDataReceived() ...@@ -276,7 +276,7 @@ void BluetoothLinkProvider::serverDataReceived()
disconnect(socket, SIGNAL(readyRead()), this, SLOT(serverDataReceived())); disconnect(socket, SIGNAL(readyRead()), this, SLOT(serverDataReceived()));
disconnect(socket, SIGNAL(error(QBluetoothSocket::SocketError)), this, SLOT(connectError())); disconnect(socket, SIGNAL(error(QBluetoothSocket::SocketError)), this, SLOT(connectError()));
NetworkPacket receivedPacket(""); NetworkPacket receivedPacket;
bool success = NetworkPacket::unserialize(identityArray, &receivedPacket); bool success = NetworkPacket::unserialize(identityArray, &receivedPacket);
if (!success || receivedPacket.type() != PACKET_TYPE_IDENTITY) { if (!success || receivedPacket.type() != PACKET_TYPE_IDENTITY) {
...@@ -289,7 +289,7 @@ void BluetoothLinkProvider::serverDataReceived() ...@@ -289,7 +289,7 @@ void BluetoothLinkProvider::serverDataReceived()
qCDebug(KDECONNECT_CORE()) << "Received identity packet from" << socket->peerAddress(); qCDebug(KDECONNECT_CORE()) << "Received identity packet from" << socket->peerAddress();
const QString& deviceId = receivedPacket.get<QString>("deviceId"); const QString& deviceId = receivedPacket.get<QString>(QStringLiteral("deviceId"));
BluetoothDeviceLink* deviceLink = new BluetoothDeviceLink(deviceId, this, socket); BluetoothDeviceLink* deviceLink = new BluetoothDeviceLink(deviceId, this, socket);
connect(deviceLink, SIGNAL(destroyed(QObject*)), connect(deviceLink, SIGNAL(destroyed(QObject*)),
......
...@@ -45,7 +45,7 @@ public: ...@@ -45,7 +45,7 @@ public:
BluetoothLinkProvider(); BluetoothLinkProvider();
virtual ~BluetoothLinkProvider(); virtual ~BluetoothLinkProvider();
QString name() override { return "BluetoothLinkProvider"; } QString name() override { return QStringLiteral("BluetoothLinkProvider"); }
int priority() override { return PRIORITY_MEDIUM; } int priority() override { return PRIORITY_MEDIUM; }
public Q_SLOTS: public Q_SLOTS:
......
...@@ -42,7 +42,7 @@ void BluetoothPairingHandler::packetReceived(const NetworkPacket& np) ...@@ -42,7 +42,7 @@ void BluetoothPairingHandler::packetReceived(const NetworkPacket& np)
m_pairingTimeout.stop(); m_pairingTimeout.stop();
bool wantsPair = np.get<bool>("pair"); bool wantsPair = np.get<bool>(QStringLiteral("pair"));
if (wantsPair) { if (wantsPair) {
...@@ -91,7 +91,7 @@ bool BluetoothPairingHandler::requestPairing() ...@@ -91,7 +91,7 @@ bool BluetoothPairingHandler::requestPairing()
} }
NetworkPacket np(PACKET_TYPE_PAIR); NetworkPacket np(PACKET_TYPE_PAIR);
np.set("pair", true); np.set(QStringLiteral("pair"), true);
bool success; bool success;
success = deviceLink()->sendPacket(np); success = deviceLink()->sendPacket(np);
if (success) { if (success) {
...@@ -106,7 +106,7 @@ bool BluetoothPairingHandler::acceptPairing() ...@@ -106,7 +106,7 @@ bool BluetoothPairingHandler::acceptPairing()
qCDebug(KDECONNECT_CORE) << "User accepts pairing"; qCDebug(KDECONNECT_CORE) << "User accepts pairing";
m_pairingTimeout.stop(); // Just in case it is started m_pairingTimeout.stop(); // Just in case it is started
NetworkPacket np(PACKET_TYPE_PAIR); NetworkPacket np(PACKET_TYPE_PAIR);
np.set("pair", true); np.set(QStringLiteral("pair"), true);
bool success = deviceLink()->sendPacket(np); bool success = deviceLink()->sendPacket(np);
if (success) { if (success) {
setInternalPairStatus(Paired); setInternalPairStatus(Paired);
...@@ -118,14 +118,14 @@ void BluetoothPairingHandler::rejectPairing() ...@@ -118,14 +118,14 @@ void BluetoothPairingHandler::rejectPairing()
{ {
qCDebug(KDECONNECT_CORE) << "User rejects pairing"; qCDebug(KDECONNECT_CORE) << "User rejects pairing";
NetworkPacket np(PACKET_TYPE_PAIR); NetworkPacket np(PACKET_TYPE_PAIR);
np.set("pair", false); np.set(QStringLiteral("pair"), false);
deviceLink()->sendPacket(np); deviceLink()->sendPacket(np);
setInternalPairStatus(NotPaired); setInternalPairStatus(NotPaired);
} }
void BluetoothPairingHandler::unpair() { void BluetoothPairingHandler::unpair() {
NetworkPacket np(PACKET_TYPE_PAIR); NetworkPacket np(PACKET_TYPE_PAIR);
np.set("pair", false); np.set(QStringLiteral("pair"), false);
deviceLink()->sendPacket(np); deviceLink()->sendPacket(np);
setInternalPairStatus(NotPaired); setInternalPairStatus(NotPaired);
} }
...@@ -133,7 +133,7 @@ void BluetoothPairingHandler::unpair() { ...@@ -133,7 +133,7 @@ void BluetoothPairingHandler::unpair() {
void BluetoothPairingHandler::pairingTimeout() void BluetoothPairingHandler::pairingTimeout()
{ {
NetworkPacket np(PACKET_TYPE_PAIR); NetworkPacket np(PACKET_TYPE_PAIR);
np.set("pair", false); np.set(QStringLiteral("pair"), false);
deviceLink()->sendPacket(np); deviceLink()->sendPacket(np);
setInternalPairStatus(NotPaired); //Will emit the change as well setInternalPairStatus(NotPaired); //Will emit the change as well
Q_EMIT pairingError(i18n("Timed out")); Q_EMIT pairingError(i18n("Timed out"));
......
...@@ -38,14 +38,14 @@ BluetoothUploadJob::BluetoothUploadJob(const QSharedPointer<QIODevice>& data, co ...@@ -38,14 +38,14 @@ BluetoothUploadJob::BluetoothUploadJob(const QSharedPointer<QIODevice>& data, co
QVariantMap BluetoothUploadJob::transferInfo() const QVariantMap BluetoothUploadJob::transferInfo() const
{ {
QVariantMap ret; QVariantMap ret;
ret["uuid"] = mTransferUuid.toString().mid(1, 36); ret[QStringLiteral("uuid")] = mTransferUuid.toString().mid(1, 36);
return ret; return ret;
} }
void BluetoothUploadJob::start() void BluetoothUploadJob::start()
{ {
connect(mServer, &QBluetoothServer::newConnection, this, &BluetoothUploadJob::newConnection); connect(mServer, &QBluetoothServer::newConnection, this, &BluetoothUploadJob::newConnection);
mServiceInfo = mServer->listen(mTransferUuid, "KDE Connect Transfer Job"); mServiceInfo = mServer->listen(mTransferUuid, QStringLiteral("KDE Connect Transfer Job"));
Q_ASSERT(mServiceInfo.isValid()); Q_ASSERT(mServiceInfo.isValid());
} }
......
...@@ -111,7 +111,7 @@ void CompositeUploadJob::startNextSubJob() ...@@ -111,7 +111,7 @@ void CompositeUploadJob::startNextSubJob()
//TODO: Create a copy of the networkpacket that can be re-injected if sending via lan fails? //TODO: Create a copy of the networkpacket that can be re-injected if sending via lan fails?
NetworkPacket np = m_currentJob->getNetworkPacket(); NetworkPacket np = m_currentJob->getNetworkPacket();
np.setPayload(nullptr, np.payloadSize()); np.setPayload(nullptr, np.payloadSize());
np.setPayloadTransferInfo({{"port", m_port}}); np.setPayloadTransferInfo({{QStringLiteral("port"), m_port}});
np.set<int>(QStringLiteral("numberOfFiles"), m_totalJobs); np.set<int>(QStringLiteral("numberOfFiles"), m_totalJobs);
np.set<quint64>(QStringLiteral("totalPayloadSize"), m_totalPayloadSize); np.set<quint64>(QStringLiteral("totalPayloadSize"), m_totalPayloadSize);
...@@ -272,7 +272,7 @@ void CompositeUploadJob::slotResult(KJob *job) { ...@@ -272,7 +272,7 @@ void CompositeUploadJob::slotResult(KJob *job) {
startNextSubJob(); startNextSubJob();
} else { } else {
QPair<QString, QString> field2; QPair<QString, QString> field2;
field2.first = QString("Files"); field2.first = QStringLiteral("Files");
field2.second = i18np("Sent 1 file", "Sent %1 files", m_totalJobs); field2.second = i18np("Sent 1 file", "Sent %1 files", m_totalJobs);
Q_EMIT description(this, i18n("Sending to %1", Daemon::instance()->getDevice(this->m_deviceId)->name()), Q_EMIT description(this, i18n("Sending to %1", Daemon::instance()->getDevice(this->m_deviceId)->name()),
{ QString(), QString() }, field2 { QString(), QString() }, field2
......
...@@ -179,7 +179,7 @@ void LanDeviceLink::setPairStatus(PairStatus status) ...@@ -179,7 +179,7 @@ void LanDeviceLink::setPairStatus(PairStatus status)
if (status == Paired) { if (status == Paired) {
Q_ASSERT(KdeConnectConfig::instance()->trustedDevices().contains(deviceId())); Q_ASSERT(KdeConnectConfig::instance()->trustedDevices().contains(deviceId()));
Q_ASSERT(!m_socketLineReader->peerCertificate().isNull()); Q_ASSERT(!m_socketLineReader->peerCertificate().isNull());
KdeConnectConfig::instance()->setDeviceProperty(deviceId(), QStringLiteral("certificate"), m_socketLineReader->peerCertificate().toPem()); KdeConnectConfig::instance()->setDeviceProperty(deviceId(), QStringLiteral("certificate"), QString::fromLatin1(m_socketLineReader->peerCertificate().toPem().data()));
} }
} }
......
...@@ -96,7 +96,7 @@ void LanLinkProvider::onStart() ...@@ -96,7 +96,7 @@ void LanLinkProvider::onStart()
if (!success) { if (!success) {
QAbstractSocket::SocketError sockErr = m_udpSocket.error(); QAbstractSocket::SocketError sockErr = m_udpSocket.error();
// Refer to https://doc.qt.io/qt-5/qabstractsocket.html#SocketError-enum to decode socket error number // Refer to https://doc.qt.io/qt-5/qabstractsocket.html#SocketError-enum to decode socket error number
QString errorMessage = QMetaEnum::fromType<QAbstractSocket::SocketError>().valueToKey(sockErr); QString errorMessage = QString::fromLatin1(QMetaEnum::fromType<QAbstractSocket::SocketError>().valueToKey(sockErr));
qCritical(KDECONNECT_CORE) qCritical(KDECONNECT_CORE)
<< QLatin1String("Failed to bind UDP socket on port") << QLatin1String("Failed to bind UDP socket on port")
<< m_udpListenPort << m_udpListenPort
......
...@@ -81,7 +81,7 @@ bool LanPairingHandler::requestPairing() ...@@ -81,7 +81,7 @@ bool LanPairingHandler::requestPairing()
return acceptPairing(); return acceptPairing();
} }
NetworkPacket np(PACKET_TYPE_PAIR, {{"pair", true}}); NetworkPacket np(PACKET_TYPE_PAIR, {{QStringLiteral("pair"), true}});
const bool success = deviceLink()->sendPacket(np); const bool success = deviceLink()->sendPacket(np);
if (success) { if (success) {
setInternalPairStatus(Requested); setInternalPairStatus(Requested);
...@@ -91,7 +91,7 @@ bool LanPairingHandler::requestPairing() ...@@ -91,7 +91,7 @@ bool LanPairingHandler::requestPairing()
bool LanPairingHandler::acceptPairing() bool LanPairingHandler::acceptPairing()
{ {
NetworkPacket np(PACKET_TYPE_PAIR, {{"pair", true}}); NetworkPacket np(PACKET_TYPE_PAIR, {{QStringLiteral("pair"), true}});
bool success = deviceLink()->sendPacket(np); bool success = deviceLink()->sendPacket(np);
if (success) { if (success) {
setInternalPairStatus(Paired); setInternalPairStatus(Paired);
...@@ -101,20 +101,20 @@ bool LanPairingHandler::acceptPairing() ...@@ -101,20 +101,20 @@ bool LanPairingHandler::acceptPairing()
void LanPairingHandler::rejectPairing() void LanPairingHandler::rejectPairing()
{ {
NetworkPacket np(PACKET_TYPE_PAIR, {{"pair", false}}); NetworkPacket np(PACKET_TYPE_PAIR, {{QStringLiteral("pair"), false}});
deviceLink()->sendPacket(np); deviceLink()->sendPacket(np);
setInternalPairStatus(NotPaired); setInternalPairStatus(NotPaired);
} }
void LanPairingHandler::unpair() { void LanPairingHandler::unpair() {
NetworkPacket np(PACKET_TYPE_PAIR, {{"pair", false}}); NetworkPacket np(PACKET_TYPE_PAIR, {{QStringLiteral("pair"), false}});
deviceLink()->sendPacket(np); deviceLink()->sendPacket(np);
setInternalPairStatus(NotPaired); setInternalPairStatus(NotPaired);
} }
void LanPairingHandler::pairingTimeout() void LanPairingHandler::pairingTimeout()
{ {
NetworkPacket np(PACKET_TYPE_PAIR, {{"pair", false}}); NetworkPacket np(PACKET_TYPE_PAIR, {{QStringLiteral("pair"), false}});
deviceLink()->sendPacket(np); deviceLink()->sendPacket(np);
setInternalPairStatus(NotPaired); //Will emit the change as well setInternalPairStatus(NotPaired); //Will emit the change as well
Q_EMIT pairingError(i18n("Timed out")); Q_EMIT pairingError(i18n("Timed out"));
......
...@@ -38,7 +38,7 @@ void Server::incomingConnection(qintptr socketDescriptor) { ...@@ -38,7 +38,7 @@ void Server::incomingConnection(qintptr socketDescriptor) {
if (serverSocket->setSocketDescriptor(socketDescriptor)) { if (serverSocket->setSocketDescriptor(socketDescriptor)) {
addPendingConnection(serverSocket); addPendingConnection(serverSocket);
} else { } else {
qWarning() << "setSocketDescriptor failed " + serverSocket->errorString(); qWarning() << "setSocketDescriptor failed" << serverSocket->errorString();
delete serverSocket; delete serverSocket;
} }
} }
......
...@@ -24,7 +24,7 @@ namespace DbusHelper { ...@@ -24,7 +24,7 @@ namespace DbusHelper {
void filterNonExportableCharacters(QString& s) void filterNonExportableCharacters(QString& s)
{ {
static QRegExp regexp("[^A-Za-z0-9_]", Qt::CaseSensitive, QRegExp::Wildcard); static QRegExp regexp(QStringLiteral("[^A-Za-z0-9_]"), Qt::CaseSensitive, QRegExp::Wildcard);
s.replace(regexp,QLatin1String("_")); s.replace(regexp,QLatin1String("_"));
} }
......
...@@ -540,7 +540,7 @@ QString Device::encryptionInfo() const ...@@ -540,7 +540,7 @@ QString Device::encryptionInfo() const
QString localSha1 = QString::fromLatin1(KdeConnectConfig::instance()->certificate().digest(digestAlgorithm).toHex()); QString localSha1 = QString::fromLatin1(KdeConnectConfig::instance()->certificate().digest(digestAlgorithm).toHex());
for (int i = 2; i<localSha1.size(); i += 3) { for (int i = 2; i<localSha1.size(); i += 3) {
localSha1.insert(i, ':'); // Improve readability localSha1.insert(i, QStringLiteral(":")); // Improve readability
} }
result += i18n("SHA1 fingerprint of your device certificate is: %1\n", localSha1); result += i18n("SHA1 fingerprint of your device certificate is: %1\n", localSha1);
...@@ -548,7 +548,7 @@ QString Device::encryptionInfo() const ...@@ -548,7 +548,7 @@ QString Device::encryptionInfo() const
QSslCertificate remoteCertificate = QSslCertificate(QByteArray(remotePem.c_str(), (int)remotePem.size())); QSslCertificate remoteCertificate = QSslCertificate(QByteArray(remotePem.c_str(), (int)remotePem.size()));
QString remoteSha1 = QString::fromLatin1(remoteCertificate.digest(digestAlgorithm).toHex()); QString remoteSha1 = QString::fromLatin1(remoteCertificate.digest(digestAlgorithm).toHex());
for (int i = 2; i < remoteSha1.size(); i += 3) { for (int i = 2; i < remoteSha1.size(); i += 3) {
remoteSha1.insert(i, ':'); // Improve readability remoteSha1.insert(i, QStringLiteral(":")); // Improve readability
} }
result += i18n("SHA1 fingerprint of remote device certificate is: %1\n", remoteSha1); result += i18n("SHA1 fingerprint of remote device certificate is: %1\n", remoteSha1);
......
...@@ -74,7 +74,7 @@ public: ...@@ -74,7 +74,7 @@ public:
QString id() const; QString id() const;
QString name() const; QString name() const;
QString dbusPath() const { return "/modules/kdeconnect/devices/"+id(); } QString dbusPath() const { return QStringLiteral("/modules/kdeconnect/devices/") + id(); }
QString type() const; QString type() const;
QString iconName() const; QString iconName() const;
QString statusIconName() const; QString statusIconName() const;
......
...@@ -88,11 +88,11 @@ QString KdeConnectConfig::name() ...@@ -88,11 +88,11 @@ QString KdeConnectConfig::name()
{ {
QString username; QString username;
#ifdef Q_OS_WIN #ifdef Q_OS_WIN
username = qgetenv("USERNAME"); username = QString::fromLatin1(qgetenv("USERNAME"));
#else #else
username = qgetenv("USER"); username = QString::fromLatin1(qgetenv("USER"));
#endif #endif
QString defaultName = username + '@' + QHostInfo::localHostName(); QString defaultName = username + QStringLiteral("@") + QHostInfo::localHostName();
QString name = d->m_config->value(QStringLiteral("name"), defaultName).toString(); QString name = d->m_config->value(QStringLiteral("name"), defaultName).toString();
return name; return name;
} }
...@@ -212,7 +212,7 @@ void KdeConnectConfig::loadPrivateKey() ...@@ -212,7 +212,7 @@ void KdeConnectConfig::loadPrivateKey()
bool needsToGenerateKey = false; bool needsToGenerateKey = false;
if (privKey.exists() && privKey.open(QIODevice::ReadOnly)) { if (privKey.exists() && privKey.open(QIODevice::ReadOnly)) {
QCA::ConvertResult result; QCA::ConvertResult result;
d->m_privateKey = QCA::PrivateKey::fromPEM(privKey.readAll(), QCA::SecureArray(), &result); d->m_privateKey = QCA::PrivateKey::fromPEM(QString::fromLatin1(privKey.readAll()), QCA::SecureArray(), &result);
if (result != QCA::ConvertResult::ConvertGood) { if (result != QCA::ConvertResult::ConvertGood) {
qCWarning(KDECONNECT_CORE) << "Private key from" << keyPath << "is not valid"; qCWarning(KDECONNECT_CORE) << "Private key from" << keyPath << "is not valid";
needsToGenerateKey = true; needsToGenerateKey = true;
......
...@@ -42,8 +42,8 @@ KdeConnectPluginConfig::KdeConnectPluginConfig(const QString& deviceId, const QS ...@@ -42,8 +42,8 @@ KdeConnectPluginConfig::KdeConnectPluginConfig(const QString& deviceId, const QS