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()
if(NOT WIN32 AND NOT APPLE)
find_package(KF5PulseAudioQt REQUIRED)
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()
find_package(ECM ${KF5_MIN_VERSION} REQUIRED NO_MODULE)
......
......@@ -78,8 +78,8 @@ int main(int argc, char** argv)
//Hidden because it's an implementation detail
QCommandLineOption deviceAutocomplete(QStringLiteral("shell-device-autocompletion"));
deviceAutocomplete.setHidden(true);
deviceAutocomplete.setDescription("Outputs all available devices id's with their name and paired status"); //Not visible, so no translation needed
deviceAutocomplete.setValueName("shell");
deviceAutocomplete.setDescription(QStringLiteral("Outputs all available devices id's with their name and paired status")); //Not visible, so no translation needed
deviceAutocomplete.setValueName(QStringLiteral("shell"));
parser.addOption(deviceAutocomplete);
about.setupCommandLine(&parser);
......@@ -87,7 +87,7 @@ int main(int argc, char** argv)
parser.process(app);
about.processCommandLine(&parser);
const QString id = "kdeconnect-cli-"+QString::number(QCoreApplication::applicationPid());
const QString id = QStringLiteral("kdeconnect-cli-") + QString::number(QCoreApplication::applicationPid());
DaemonDbusInterface iface;
if (parser.isSet(QStringLiteral("my-id"))) {
......@@ -152,15 +152,15 @@ int main(int argc, char** argv)
}
//Description: "device name (paired/unpaired)"
QString description = deviceIface.name() + " " + statusInfo;
QString description = deviceIface.name() + QLatin1Char(' ') + statusInfo;
//Replace characters
description.replace(QChar('\\'), QStringLiteral("\\\\"));
description.replace(QChar('['), QStringLiteral("\\["));
description.replace(QChar(']'), QStringLiteral("\\]"));
description.replace(QChar('\''), QStringLiteral("\\'"));
description.replace(QChar('\"'), QStringLiteral("\\\""));
description.replace(QChar('\n'), QChar(' '));
description.remove(QChar('\0'));
description.replace(QLatin1Char('\\'), QStringLiteral("\\\\"));
description.replace(QLatin1Char('['), QStringLiteral("\\["));
description.replace(QLatin1Char(']'), QStringLiteral("\\]"));
description.replace(QLatin1Char('\''), QStringLiteral("\\'"));
description.replace(QLatin1Char('\"'), QStringLiteral("\\\""));
description.replace(QLatin1Char('\n'), QLatin1Char(' '));
description.remove(QLatin1Char('\0'));
//Output id and description
QTextStream(stdout) << id << '[' << description << ']' << endl;
......@@ -196,7 +196,7 @@ int main(int argc, char** argv)
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"));
msg.setArguments(QVariantList() << QVariant(urls));
......@@ -206,7 +206,7 @@ int main(int argc, char** argv)
QTextStream(stdout) << i18n("Shared %1", url) << endl;
}
} 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")));
blockOnReply(DbusHelper::sessionBus().asyncCall(msg));
QTextStream(stdout) << i18n("Shared text: %1", parser.value(QStringLiteral("share-text"))) << endl;
......@@ -246,7 +246,7 @@ int main(int argc, char** argv)
blockOnReply(dev.unpair());
}
} 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"))) {
QString message = parser.value(QStringLiteral("ping-msg"));
msg.setArguments(QVariantList() << message);
......@@ -254,29 +254,29 @@ int main(int argc, char** argv)
blockOnReply(DbusHelper::sessionBus().asyncCall(msg));
} else if(parser.isSet(QStringLiteral("send-sms"))) {
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"));
msg.setArguments({ parser.value("destination"), parser.value("send-sms") });
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(QStringLiteral("destination")), parser.value(QStringLiteral("send-sms"))});
blockOnReply(DbusHelper::sessionBus().asyncCall(msg));
} else {
QTextStream(stderr) << i18n("error: should specify the SMS's recipient by passing --destination <phone number>");
return 1;
}
} 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));
} 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));
} else if(parser.isSet("send-keys")) {
QString seq = parser.value("send-keys");
QDBusMessage msg = QDBusMessage::createMethodCall("org.kde.kdeconnect", "/modules/kdeconnect/devices/"+device+"/remotekeyboard", "org.kde.kdeconnect.device.remotekeyboard", "sendKeyPress");
} else if(parser.isSet(QStringLiteral("send-keys"))) {
QString seq = parser.value(QStringLiteral("send-keys"));
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("-")) {
// from stdin
QFile in;
if(in.open(stdin,QIODevice::ReadOnly | QIODevice::Unbuffered)) {
while (!in.atEnd()) {
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));
}
in.close();
......
......@@ -45,7 +45,7 @@ BluetoothDeviceLink::BluetoothDeviceLink(const QString& deviceId, LinkProvider*
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)
......
......@@ -23,7 +23,7 @@
BluetoothDownloadJob::BluetoothDownloadJob(const QBluetoothAddress& remoteAddress, const QVariantMap& transferInfo, QObject* parent)
: QObject(parent)
, mRemoteAddress(remoteAddress)
, mTransferUuid(QBluetoothUuid(transferInfo.value("uuid").toString()))
, mTransferUuid(QBluetoothUuid(transferInfo.value(QStringLiteral("uuid")).toString()))
, mSocket(new QBluetoothSocket(QBluetoothServiceInfo::RfcommProtocol))
{
}
......
......@@ -34,7 +34,7 @@
BluetoothLinkProvider::BluetoothLinkProvider()
{
mServiceUuid = QBluetoothUuid(QString("185f3df4-3268-4e3f-9fca-d4d5059915bd"));
mServiceUuid = QBluetoothUuid(QStringLiteral("185f3df4-3268-4e3f-9fca-d4d5059915bd"));
connectTimer = new QTimer(this);
connectTimer->setInterval(30000);
......@@ -61,7 +61,7 @@ void BluetoothLinkProvider::onStart()
mServiceDiscoveryAgent->start();
connectTimer->start();
mKdeconnectService = mBluetoothServer->listen(mServiceUuid, "KDE Connect");
mKdeconnectService = mBluetoothServer->listen(mServiceUuid, QStringLiteral("KDE Connect"));
}
void BluetoothLinkProvider::onStop()
......@@ -183,7 +183,7 @@ void BluetoothLinkProvider::clientIdentityReceived()
disconnect(socket, SIGNAL(readyRead()), this, SLOT(clientIdentityReceived()));
NetworkPacket receivedPacket("");
NetworkPacket receivedPacket;
bool success = NetworkPacket::unserialize(identityArray, &receivedPacket);
if (!success || receivedPacket.type() != PACKET_TYPE_IDENTITY) {
......@@ -198,10 +198,10 @@ void BluetoothLinkProvider::clientIdentityReceived()
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);
NetworkPacket np2("");
NetworkPacket np2;
NetworkPacket::createIdentityPacket(&np2);
success = deviceLink->sendPacket(np2);
......@@ -243,7 +243,7 @@ void BluetoothLinkProvider::serverNewConnection()
connect(socket, SIGNAL(error(QBluetoothSocket::SocketError)), this, SLOT(connectError()));
connect(socket, SIGNAL(disconnected()), this, SLOT(socketDisconnected()));
NetworkPacket np2("");
NetworkPacket np2;
NetworkPacket::createIdentityPacket(&np2);
socket->write(np2.serialize());
......@@ -276,7 +276,7 @@ void BluetoothLinkProvider::serverDataReceived()
disconnect(socket, SIGNAL(readyRead()), this, SLOT(serverDataReceived()));
disconnect(socket, SIGNAL(error(QBluetoothSocket::SocketError)), this, SLOT(connectError()));
NetworkPacket receivedPacket("");
NetworkPacket receivedPacket;
bool success = NetworkPacket::unserialize(identityArray, &receivedPacket);
if (!success || receivedPacket.type() != PACKET_TYPE_IDENTITY) {
......@@ -289,7 +289,7 @@ void BluetoothLinkProvider::serverDataReceived()
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);
connect(deviceLink, SIGNAL(destroyed(QObject*)),
......
......@@ -45,7 +45,7 @@ public:
BluetoothLinkProvider();
virtual ~BluetoothLinkProvider();
QString name() override { return "BluetoothLinkProvider"; }
QString name() override { return QStringLiteral("BluetoothLinkProvider"); }
int priority() override { return PRIORITY_MEDIUM; }
public Q_SLOTS:
......
......@@ -42,7 +42,7 @@ void BluetoothPairingHandler::packetReceived(const NetworkPacket& np)
m_pairingTimeout.stop();
bool wantsPair = np.get<bool>("pair");
bool wantsPair = np.get<bool>(QStringLiteral("pair"));
if (wantsPair) {
......@@ -91,7 +91,7 @@ bool BluetoothPairingHandler::requestPairing()
}
NetworkPacket np(PACKET_TYPE_PAIR);
np.set("pair", true);
np.set(QStringLiteral("pair"), true);
bool success;
success = deviceLink()->sendPacket(np);
if (success) {
......@@ -106,7 +106,7 @@ bool BluetoothPairingHandler::acceptPairing()
qCDebug(KDECONNECT_CORE) << "User accepts pairing";
m_pairingTimeout.stop(); // Just in case it is started
NetworkPacket np(PACKET_TYPE_PAIR);
np.set("pair", true);
np.set(QStringLiteral("pair"), true);
bool success = deviceLink()->sendPacket(np);
if (success) {
setInternalPairStatus(Paired);
......@@ -118,14 +118,14 @@ void BluetoothPairingHandler::rejectPairing()
{
qCDebug(KDECONNECT_CORE) << "User rejects pairing";
NetworkPacket np(PACKET_TYPE_PAIR);
np.set("pair", false);
np.set(QStringLiteral("pair"), false);
deviceLink()->sendPacket(np);
setInternalPairStatus(NotPaired);
}
void BluetoothPairingHandler::unpair() {
NetworkPacket np(PACKET_TYPE_PAIR);
np.set("pair", false);
np.set(QStringLiteral("pair"), false);
deviceLink()->sendPacket(np);
setInternalPairStatus(NotPaired);
}
......@@ -133,7 +133,7 @@ void BluetoothPairingHandler::unpair() {
void BluetoothPairingHandler::pairingTimeout()
{
NetworkPacket np(PACKET_TYPE_PAIR);
np.set("pair", false);
np.set(QStringLiteral("pair"), false);
deviceLink()->sendPacket(np);
setInternalPairStatus(NotPaired); //Will emit the change as well
Q_EMIT pairingError(i18n("Timed out"));
......
......@@ -38,14 +38,14 @@ BluetoothUploadJob::BluetoothUploadJob(const QSharedPointer<QIODevice>& data, co
QVariantMap BluetoothUploadJob::transferInfo() const
{
QVariantMap ret;
ret["uuid"] = mTransferUuid.toString().mid(1, 36);
ret[QStringLiteral("uuid")] = mTransferUuid.toString().mid(1, 36);
return ret;
}
void BluetoothUploadJob::start()
{
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());
}
......
......@@ -111,7 +111,7 @@ void CompositeUploadJob::startNextSubJob()
//TODO: Create a copy of the networkpacket that can be re-injected if sending via lan fails?
NetworkPacket np = m_currentJob->getNetworkPacket();
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<quint64>(QStringLiteral("totalPayloadSize"), m_totalPayloadSize);
......@@ -272,7 +272,7 @@ void CompositeUploadJob::slotResult(KJob *job) {
startNextSubJob();
} else {
QPair<QString, QString> field2;
field2.first = QString("Files");
field2.first = QStringLiteral("Files");
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()),
{ QString(), QString() }, field2
......
......@@ -179,7 +179,7 @@ void LanDeviceLink::setPairStatus(PairStatus status)
if (status == Paired) {
Q_ASSERT(KdeConnectConfig::instance()->trustedDevices().contains(deviceId()));
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()
if (!success) {
QAbstractSocket::SocketError sockErr = m_udpSocket.error();
// 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)
<< QLatin1String("Failed to bind UDP socket on port")
<< m_udpListenPort
......
......@@ -81,7 +81,7 @@ bool LanPairingHandler::requestPairing()
return acceptPairing();
}
NetworkPacket np(PACKET_TYPE_PAIR, {{"pair", true}});
NetworkPacket np(PACKET_TYPE_PAIR, {{QStringLiteral("pair"), true}});
const bool success = deviceLink()->sendPacket(np);
if (success) {
setInternalPairStatus(Requested);
......@@ -91,7 +91,7 @@ bool LanPairingHandler::requestPairing()
bool LanPairingHandler::acceptPairing()
{
NetworkPacket np(PACKET_TYPE_PAIR, {{"pair", true}});
NetworkPacket np(PACKET_TYPE_PAIR, {{QStringLiteral("pair"), true}});
bool success = deviceLink()->sendPacket(np);
if (success) {
setInternalPairStatus(Paired);
......@@ -101,20 +101,20 @@ bool LanPairingHandler::acceptPairing()
void LanPairingHandler::rejectPairing()
{
NetworkPacket np(PACKET_TYPE_PAIR, {{"pair", false}});
NetworkPacket np(PACKET_TYPE_PAIR, {{QStringLiteral("pair"), false}});
deviceLink()->sendPacket(np);
setInternalPairStatus(NotPaired);
}
void LanPairingHandler::unpair() {
NetworkPacket np(PACKET_TYPE_PAIR, {{"pair", false}});
NetworkPacket np(PACKET_TYPE_PAIR, {{QStringLiteral("pair"), false}});
deviceLink()->sendPacket(np);
setInternalPairStatus(NotPaired);
}
void LanPairingHandler::pairingTimeout()
{
NetworkPacket np(PACKET_TYPE_PAIR, {{"pair", false}});
NetworkPacket np(PACKET_TYPE_PAIR, {{QStringLiteral("pair"), false}});
deviceLink()->sendPacket(np);
setInternalPairStatus(NotPaired); //Will emit the change as well
Q_EMIT pairingError(i18n("Timed out"));
......
......@@ -38,7 +38,7 @@ void Server::incomingConnection(qintptr socketDescriptor) {
if (serverSocket->setSocketDescriptor(socketDescriptor)) {
addPendingConnection(serverSocket);
} else {
qWarning() << "setSocketDescriptor failed " + serverSocket->errorString();
qWarning() << "setSocketDescriptor failed" << serverSocket->errorString();
delete serverSocket;
}
}
......
......@@ -24,7 +24,7 @@ namespace DbusHelper {
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("_"));
}
......
......@@ -540,7 +540,7 @@ QString Device::encryptionInfo() const
QString localSha1 = QString::fromLatin1(KdeConnectConfig::instance()->certificate().digest(digestAlgorithm).toHex());
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);
......@@ -548,7 +548,7 @@ QString Device::encryptionInfo() const
QSslCertificate remoteCertificate = QSslCertificate(QByteArray(remotePem.c_str(), (int)remotePem.size()));
QString remoteSha1 = QString::fromLatin1(remoteCertificate.digest(digestAlgorithm).toHex());
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);
......
......@@ -74,7 +74,7 @@ public:
QString id() 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 iconName() const;
QString statusIconName() const;
......
......@@ -88,11 +88,11 @@ QString KdeConnectConfig::name()
{
QString username;
#ifdef Q_OS_WIN
username = qgetenv("USERNAME");
username = QString::fromLatin1(qgetenv("USERNAME"));
#else
username = qgetenv("USER");
username = QString::fromLatin1(qgetenv("USER"));
#endif
QString defaultName = username + '@' + QHostInfo::localHostName();
QString defaultName = username + QStringLiteral("@") + QHostInfo::localHostName();
QString name = d->m_config->value(QStringLiteral("name"), defaultName).toString();
return name;
}
......@@ -212,7 +212,7 @@ void KdeConnectConfig::loadPrivateKey()
bool needsToGenerateKey = false;
if (privKey.exists() && privKey.open(QIODevice::ReadOnly)) {
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) {
qCWarning(KDECONNECT_CORE) << "Private key from" << keyPath << "is not valid";
needsToGenerateKey = true;
......
......@@ -42,8 +42,8 @@ KdeConnectPluginConfig::KdeConnectPluginConfig(const QString& deviceId, const QS
d->m_config = new QSettings(d->m_configDir.absoluteFilePath(QStringLiteral("config")), QSettings::IniFormat);
d->m_signal = QDBusMessage::createSignal("/kdeconnect/"+deviceId+"/"+pluginName, QStringLiteral("org.kde.kdeconnect.config"), QStringLiteral("configChanged"));
DbusHelper::sessionBus().connect(QLatin1String(""), "/kdeconnect/"+deviceId+"/"+pluginName, QStringLiteral("org.kde.kdeconnect.config"), QStringLiteral("configChanged"), this, SLOT(slotConfigChanged()));
d->m_signal = QDBusMessage::createSignal(QStringLiteral("/kdeconnect/") + deviceId + QStringLiteral("/") + pluginName, QStringLiteral("org.kde.kdeconnect.config"), QStringLiteral("configChanged"));
DbusHelper::sessionBus().connect(QLatin1String(""), QStringLiteral("/kdeconnect/") + deviceId + QStringLiteral("/") + pluginName, QStringLiteral("org.kde.kdeconnect.config"), QStringLiteral("configChanged"), this, SLOT(slotConfigChanged()));
}
KdeConnectPluginConfig::~KdeConnectPluginConfig()
......
......@@ -46,7 +46,7 @@ QVariant DBusResponseWaiter::waitForReply(QVariant variant) const
if (call->isError())
{
qWarning() << "error:" << call->error();
return QVariant("error");
return QVariant(QStringLiteral("error"));
}
QDBusMessage reply = call->reply();
......
......@@ -92,7 +92,7 @@ void SendFileItemAction::sendFile()
const QList<QUrl> urls = sender()->property("urls").value<QList<QUrl>>();
QString id = sender()->property("id").toString();
for (const QUrl& url : urls) {
QDBusMessage msg = QDBusMessage::createMethodCall(QStringLiteral("org.kde.kdeconnect"), "/modules/kdeconnect/devices/"+id+"/share", QStringLiteral("org.kde.kdeconnect.device.share"), QStringLiteral("shareUrl"));
QDBusMessage msg = QDBusMessage::createMethodCall(QStringLiteral("org.kde.kdeconnect"), QStringLiteral("/modules/kdeconnect/devices/") + id + QStringLiteral("/share"), QStringLiteral("org.kde.kdeconnect.device.share"), QStringLiteral("shareUrl"));
msg.setArguments(QVariantList() << url.toString());
DbusHelper::sessionBus().call(msg);
}
......
......@@ -70,7 +70,7 @@ DeviceIndicator::DeviceIndicator(DeviceDbusInterface* device)
, m_device(device)
{
#ifdef Q_OS_WIN
setIcon(QIcon(QStandardPaths::locate(QStandardPaths::AppDataLocation, "icons/hicolor/scalable/status/"+device->iconName()+".svg")));
setIcon(QIcon(QStandardPaths::locate(QStandardPaths::AppDataLocation, QStringLiteral("icons/hicolor/scalable/status/") + device->iconName() + QStringLiteral(".svg"))));
#else
setIcon(QIcon::fromTheme(device->iconName()));
#endif
......@@ -79,7 +79,7 @@ DeviceIndicator::DeviceIndicator(DeviceDbusInterface* device)
auto battery = new BatteryAction(device);
addAction(battery);
setWhenAvailable(device->hasPlugin("kdeconnect_battery"),
setWhenAvailable(device->hasPlugin(QStringLiteral("kdeconnect_battery")),
[battery](bool available) { battery->setVisible(available); }
, this);
......@@ -89,7 +89,7 @@ DeviceIndicator::DeviceIndicator(DeviceDbusInterface* device)
sftpIface->startBrowsing();
sftpIface->deleteLater();
});
setWhenAvailable(device->hasPlugin("kdeconnect_sftp"), [browse](bool available) { browse->setVisible(available); }, this);
setWhenAvailable(device->hasPlugin(QStringLiteral("kdeconnect_sftp")), [browse](bool available) { browse->setVisible(available); }, this);
auto findDevice = addAction(QIcon::fromTheme(QStringLiteral("irc-voice")), i18n("Ring device"));
connect(findDevice, &QAction::triggered, device, [device](){
......@@ -97,7 +97,7 @@ DeviceIndicator::DeviceIndicator(DeviceDbusInterface* device)
iface->ring();
iface->deleteLater();
});
setWhenAvailable(device->hasPlugin("kdeconnect_findmyphone"), [findDevice](bool available) { findDevice->setVisible(available); }, this);
setWhenAvailable(device->hasPlugin(QStringLiteral("kdeconnect_findmyphone")), [findDevice](bool available) { findDevice->setVisible(available); }, this);
auto sendFile = addAction(QIcon::fromTheme(QStringLiteral("document-share")), i18n("Send file"));
connect(sendFile, &QAction::triggered, device, [device, this](){
......@@ -105,11 +105,11 @@ DeviceIndicator::DeviceIndicator(DeviceDbusInterface* device)
if (url.isEmpty())
return;
QDBusMessage msg = QDBusMessage::createMethodCall(QStringLiteral("org.kde.kdeconnect"), "/modules/kdeconnect/devices/"+device->id()+"/share", QStringLiteral("org.kde.kdeconnect.device.share"), QStringLiteral("shareUrl"));
QDBusMessage msg = QDBusMessage::createMethodCall(QStringLiteral("org.kde.kdeconnect"), QStringLiteral("/modules/kdeconnect/devices/") + device->id() + QStringLiteral("/share"), QStringLiteral("org.kde.kdeconnect.device.share"), QStringLiteral("shareUrl"));
msg.setArguments(QVariantList() << url.toString());
DbusHelper::sessionBus().call(msg);
});
setWhenAvailable(device->hasPlugin("kdeconnect_share"), [sendFile](bool available) { sendFile->setVisible(available); }, this);
setWhenAvailable(device->hasPlugin(QStringLiteral("kdeconnect_share")), [sendFile](bool available) { sendFile->setVisible(available); }, this);
}
#include "deviceindicator.moc"
......@@ -46,7 +46,7 @@
int main(int argc, char** argv)
{
QApplication app(argc, argv);
KAboutData about("kdeconnect-indicator",
KAboutData about(QStringLiteral("kdeconnect-indicator"),
i18n("KDE Connect Indicator"),
QStringLiteral(KDECONNECT_VERSION_STRING),
i18n("KDE Connect Indicator tool"),
......@@ -55,7 +55,7 @@ int main(int argc, char** argv)
KAboutData::setApplicationData(about);
#ifdef Q_OS_WIN
QProcess::startDetached("kdeconnectd.exe");
QProcess::startDetached(QStringLiteral("kdeconnectd.exe"));
#endif
#ifdef Q_OS_MAC
......@@ -81,7 +81,7 @@ int main(int argc, char** argv)
auto configure = menu->addAction(QIcon::fromTheme(QStringLiteral("configure")), i18n("Configure..."));
QObject::connect(configure, &QAction::triggered, configure, [](){
KCMultiDialog* dialog = new KCMultiDialog;
dialog->addModule("kcm_kdeconnect");
dialog->addModule(QStringLiteral("kcm_kdeconnect"));
dialog->setAttribute(Qt::WA_DeleteOnClose);
dialog->show();
});
......@@ -129,7 +129,7 @@ int main(int argc, char** argv)
#else
KStatusNotifierItem systray;
systray.setIconByName(QStringLiteral("kdeconnectindicatordark"));
systray.setToolTip(QStringLiteral("kdeconnect"), "KDE Connect", "KDE Connect");
systray.setToolTip(QStringLiteral("kdeconnect"), QStringLiteral("KDE Connect"), QStringLiteral("KDE Connect"));
systray.setCategory(KStatusNotifierItem::Communications);
systray.setStatus(KStatusNotifierItem::Passive);
systray.setStandardActionsEnabled(false);
......
......@@ -24,14 +24,14 @@
ConversationMessage::ConversationMessage(const QVariantMap& args)
: m_eventField(args["event"].toInt()),
m_body(args["body"].toString()),
m_address(args["address"].toString()),
m_date(args["date"].toLongLong()),
m_type(args["type"].toInt()),
m_read(args["read"].toInt()),
m_threadID(args["thread_id"].toLongLong()),
m_uID(args["_id"].toInt())
: m_eventField(args[QStringLiteral("event")].toInt()),
m_body(args[QStringLiteral("body")].toString()),
m_address(args[QStringLiteral("address")].toString()),
m_date(args[QStringLiteral("date")].toLongLong()),
m_type(args[QStringLiteral("type")].toInt()),
m_read(args[QStringLiteral("read")].toInt()),
m_threadID(args[QStringLiteral("thread_id")].toLongLong()),
m_uID(args[QStringLiteral("_id")].toInt())
{
}
......@@ -81,14 +81,14 @@ ConversationMessage& ConversationMessage::operator=(const ConversationMessage& o
QVariantMap ConversationMessage::toVariant() const
{
return {
{"event", m_eventField},
{"body", m_body},
{"address", m_address},
{"date", m_date},
{"type", m_type},
{"read", m_read},
{"thread_id", m_threadID},
{"_id", m_uID},
{QStringLiteral("event"), m_eventField},
{QStringLiteral("body"), m_body},
{QStringLiteral("address"), m_address},
{QStringLiteral("date"), m_date},
{QStringLiteral("type"), m_type},
{QStringLiteral("read"), m_read},
{QStringLiteral("thread_id"), m_threadID},
{QStringLiteral("_id"), m_uID},
};
}
......
......@@ -42,7 +42,7 @@ DaemonDbusInterface::~DaemonDbusInterface()
}
DeviceDbusInterface::DeviceDbusInterface(const QString& id, QObject* parent)
: OrgKdeKdeconnectDeviceInterface(DaemonDbusInterface::activatedService(), "/modules/kdeconnect/devices/"+id, DbusHelper::sessionBus(), parent)
: OrgKdeKdeconnectDeviceInterface(DaemonDbusInterface::activatedService(), QStringLiteral("/modules/kdeconnect/devices/") +id, DbusHelper::sessionBus(), parent)
, m_id(id)
{
connect(this, &OrgKdeKdeconnectDeviceInterface::trustedChanged, this, &DeviceDbusInterface::trustedChangedProxy);
......@@ -63,12 +63,12 @@ QString DeviceDbusInterface::id() const
void DeviceDbusInterface::pluginCall(const QString& plugin, const QString& method)
{
QDBusMessage msg = QDBusMessage::createMethodCall(QStringLiteral("org.kde.kdeconnect"), "/modules/kdeconnect/devices/"+id()+'/'+plugin, "org.kde.kdeconnect.device."+plugin, method);
QDBusMessage msg = QDBusMessage::createMethodCall(QStringLiteral("org.kde.kdeconnect"), QStringLiteral("/modules/kdeconnect/devices/") +id() + QStringLiteral("/") + plugin, QStringLiteral("org.kde.kdeconnect.device.") + plugin, method);
DbusHelper::sessionBus().asyncCall(msg);
}
DeviceBatteryDbusInterface::DeviceBatteryDbusInterface(const QString& id, QObject* parent)
: OrgKdeKdeconnectDeviceBatteryInterface(DaemonDbusInterface::activatedService(), "/modules/kdeconnect/devices/"+id, DbusHelper::sessionBus(), parent)
: OrgKdeKdeconnectDeviceBatteryInterface(DaemonDbusInterface::activatedService(), QStringLiteral("/modules/kdeconnect/devices/") +id, DbusHelper::sessionBus(), parent)
{
}
......@@ -79,7 +79,7 @@ DeviceBatteryDbusInterface::~DeviceBatteryDbusInterface()
}
DeviceNotificationsDbusInterface::DeviceNotificationsDbusInterface(const QString& id, QObject* parent)
: OrgKdeKdeconnectDeviceNotificationsInterface(DaemonDbusInterface::activatedService(), "/modules/kdeconnect/devices/"+id, DbusHelper::sessionBus(), parent)
: OrgKdeKdeconnectDeviceNotificationsInterface(DaemonDbusInterface::activatedService(), QStringLiteral("/modules/kdeconnect/devices/") +id, DbusHelper::sessionBus(), parent)
{
}
......@@ -90,7 +90,7 @@ DeviceNotificationsDbusInterface::~DeviceNotificationsDbusInterface()
}
NotificationDbusInterface::NotificationDbusInterface(const QString& deviceId, const QString& notificationId, QObject* parent)
: OrgKdeKdeconnectDeviceNotificationsNotificationInterface(DaemonDbusInterface::activatedService(), "/modules/kdeconnect/devices/"+deviceId+"/notifications/"+notificationId, DbusHelper::sessionBus(), parent)
: OrgKdeKdeconnectDeviceNotificationsNotificationInterface(DaemonDbusInterface::activatedService(), QStringLiteral("/modules/kdeconnect/devices/") + deviceId + QStringLiteral("/notifications/") + notificationId, DbusHelper::sessionBus(), parent)
, id(notificationId)
{
......@@ -102,7 +102,7 @@ NotificationDbusInterface::~NotificationDbusInterface()
}
DeviceConversationsDbusInterface::DeviceConversationsDbusInterface(const QString& deviceId, QObject* parent)
: OrgKdeKdeconnectDeviceConversationsInterface(DaemonDbusInterface::activatedService(), "/modules/kdeconnect/devices/"+deviceId, DbusHelper::sessionBus(), parent)
: OrgKdeKdeconnectDeviceConversationsInterface(DaemonDbusInterface::activatedService(), QStringLiteral("/modules/kdeconnect/devices/") + deviceId, DbusHelper::sessionBus(), parent)
{
}
......@@ -113,7 +113,7 @@ DeviceConversationsDbusInterface::~DeviceConversationsDbusInterface()
}
SftpDbusInterface::SftpDbusInterface(const QString& id, QObject* parent)
: OrgKdeKdeconnectDeviceSftpInterface(DaemonDbusInterface::activatedService(), "/modules/kdeconnect/devices/" + id + "/sftp", DbusHelper::sessionBus(), parent)
: OrgKdeKdeconnectDeviceSftpInterface(DaemonDbusInterface::activatedService(), QStringLiteral("/modules/kdeconnect/devices/") + id + QStringLiteral("/sftp"), DbusHelper::sessionBus(), parent)
{
}
......@@ -124,7 +124,7 @@ SftpDbusInterface::~SftpDbusI