Commit 60331ccb authored by Albert Vaca Cintora's avatar Albert Vaca Cintora

Clazy says all this QStringLiteral and QLatin1String were missing/wrong

parent a1340c80
......@@ -26,8 +26,8 @@
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
KAboutData aboutData("kdeconnect.app", i18n("Awesome App"), "1.0", i18n("KDE Connect App"), KAboutLicense::GPL, i18n("(c) 2015, Aleix Pol Gonzalez"));
aboutData.addAuthor(i18n("Aleix Pol Gonzalez"), i18n("Maintainer"), "aleixpol@kde.org");
KAboutData aboutData(QStringLiteral("kdeconnect.app"), i18n("Awesome App"), QStringLiteral("1.0"), i18n("KDE Connect App"), KAboutLicense::GPL, i18n("(c) 2015, Aleix Pol Gonzalez"));
aboutData.addAuthor(i18n("Aleix Pol Gonzalez"), i18n("Maintainer"), QStringLiteral("aleixpol@kde.org"));
KAboutData::setApplicationData(aboutData);
{
......@@ -45,7 +45,7 @@ int main(int argc, char *argv[])
kdeclarative.setDeclarativeEngine(&engine);
kdeclarative.setupBindings();
engine.load(QUrl("qrc:/qml/main.qml"));
engine.load(QUrl(QStringLiteral("qrc:/qml/main.qml")));
return app.exec();
}
This diff is collapsed.
......@@ -34,11 +34,11 @@
DownloadJob::DownloadJob(const QHostAddress &address, const QVariantMap &transferInfo)
: KJob()
, mAddress(address)
, mPort(transferInfo["port"].toInt())
, mPort(transferInfo[QStringLiteral("port")].toInt())
, mSocket(new QSslSocket)
, mBuffer(new QBuffer)
{
LanLinkProvider::configureSslSocket(mSocket.data(), transferInfo.value("deviceId").toString(), true);
LanLinkProvider::configureSslSocket(mSocket.data(), transferInfo.value(QStringLiteral("deviceId")).toString(), true);
connect(mSocket.data(), SIGNAL(error(QAbstractSocket::SocketError)), this, SLOT(socketFailed(QAbstractSocket::SocketError)));
// connect(mSocket.data(), &QAbstractSocket::stateChanged, [](QAbstractSocket::SocketState state){ qDebug() << "statechange" << state; });
......
......@@ -56,13 +56,13 @@ void LanDeviceLink::reset(QSslSocket* socket, ConnectionStarted connectionSource
mConnectionSource = connectionSource;
QString certString = KdeConnectConfig::instance()->getDeviceProperty(deviceId(), "certificate");
QString certString = KdeConnectConfig::instance()->getDeviceProperty(deviceId(), QStringLiteral("certificate"));
DeviceLink::setPairStatus(certString.isEmpty()? PairStatus::NotPaired : PairStatus::Paired);
}
QString LanDeviceLink::name()
{
return "LanLink"; // Should be same in both android and kde version
return QStringLiteral("LanLink"); // Should be same in both android and kde version
}
bool LanDeviceLink::sendPackage(NetworkPackage& np)
......@@ -106,8 +106,8 @@ void LanDeviceLink::dataReceived()
//qCDebug(KDECONNECT_CORE) << "HasPayloadTransferInfo";
QVariantMap transferInfo = package.payloadTransferInfo();
//FIXME: The next two lines shouldn't be needed! Why are they here?
transferInfo.insert("useSsl", true);
transferInfo.insert("deviceId", deviceId());
transferInfo.insert(QStringLiteral("useSsl"), true);
transferInfo.insert(QStringLiteral("deviceId"), deviceId());
DownloadJob* job = new DownloadJob(mSocketLineReader->peerAddress(), transferInfo);
job->start();
package.setPayload(job->getPayload(), package.payloadSize());
......@@ -146,7 +146,7 @@ void LanDeviceLink::setPairStatus(PairStatus status)
if (status == Paired) {
Q_ASSERT(KdeConnectConfig::instance()->trustedDevices().contains(deviceId()));
Q_ASSERT(!mSocketLineReader->peerCertificate().isNull());
KdeConnectConfig::instance()->setDeviceProperty(deviceId(), "certificate", mSocketLineReader->peerCertificate().toPem());
KdeConnectConfig::instance()->setDeviceProperty(deviceId(), QStringLiteral("certificate"), mSocketLineReader->peerCertificate().toPem());
}
}
......
......@@ -126,11 +126,11 @@ void LanLinkProvider::broadcastToNetwork()
qCDebug(KDECONNECT_CORE()) << "Broadcasting identity packet";
QHostAddress destAddress = mTestMode? QHostAddress::LocalHost : QHostAddress("255.255.255.255");
QHostAddress destAddress = mTestMode? QHostAddress::LocalHost : QHostAddress(QStringLiteral("255.255.255.255"));
NetworkPackage np("");
NetworkPackage np(QLatin1String(""));
NetworkPackage::createIdentityPackage(&np);
np.set("tcpPort", mTcpPort);
np.set(QStringLiteral("tcpPort"), mTcpPort);
#ifdef Q_OS_WIN
//On Windows we need to broadcast from every local IP address to reach all networks
......@@ -171,7 +171,7 @@ void LanLinkProvider::newUdpConnection() //udpBroadcastReceived
if (sender.isLoopback() && !mTestMode)
continue;
NetworkPackage* receivedPackage = new NetworkPackage("");
NetworkPackage* receivedPackage = new NetworkPackage(QLatin1String(""));
bool success = NetworkPackage::unserialize(datagram, receivedPackage);
//qCDebug(KDECONNECT_CORE) << "udp connection from " << receivedPackage->;
......@@ -183,13 +183,13 @@ void LanLinkProvider::newUdpConnection() //udpBroadcastReceived
continue;
}
if (receivedPackage->get<QString>("deviceId") == KdeConnectConfig::instance()->deviceId()) {
if (receivedPackage->get<QString>(QStringLiteral("deviceId")) == KdeConnectConfig::instance()->deviceId()) {
//qCDebug(KDECONNECT_CORE) << "Ignoring my own broadcast";
delete receivedPackage;
continue;
}
int tcpPort = receivedPackage->get<int>("tcpPort", PORT);
int tcpPort = receivedPackage->get<int>(QStringLiteral("tcpPort"), PORT);
//qCDebug(KDECONNECT_CORE) << "Received Udp identity package from" << sender << " asking for a tcp connection on port " << tcpPort;
......@@ -210,9 +210,9 @@ void LanLinkProvider::connectError()
disconnect(socket, SIGNAL(error(QAbstractSocket::SocketError)), this, SLOT(connectError()));
qCDebug(KDECONNECT_CORE) << "Fallback (1), try reverse connection (send udp packet)" << socket->errorString();
NetworkPackage np("");
NetworkPackage np(QLatin1String(""));
NetworkPackage::createIdentityPackage(&np);
np.set("tcpPort", mTcpPort);
np.set(QStringLiteral("tcpPort"), mTcpPort);
mUdpSocket.writeDatagram(np.serialize(), receivedIdentityPackages[socket].sender, PORT);
//The socket we created didn't work, and we didn't manage
......@@ -237,11 +237,11 @@ void LanLinkProvider::connected()
connect(socket, &QAbstractSocket::disconnected, socket, &QObject::deleteLater);
NetworkPackage* receivedPackage = receivedIdentityPackages[socket].np;
const QString& deviceId = receivedPackage->get<QString>("deviceId");
const QString& deviceId = receivedPackage->get<QString>(QStringLiteral("deviceId"));
//qCDebug(KDECONNECT_CORE) << "Connected" << socket->isWritable();
// If network is on ssl, do not believe when they are connected, believe when handshake is completed
NetworkPackage np2("");
NetworkPackage np2(QLatin1String(""));
NetworkPackage::createIdentityPackage(&np2);
socket->write(np2.serialize());
bool success = socket->waitForBytesWritten();
......@@ -251,7 +251,7 @@ void LanLinkProvider::connected()
qCDebug(KDECONNECT_CORE) << "TCP connection done (i'm the existing device)";
// if ssl supported
if (receivedPackage->get<int>("protocolVersion") >= MIN_VERSION_WITH_SSL_SUPPORT) {
if (receivedPackage->get<int>(QStringLiteral("protocolVersion")) >= MIN_VERSION_WITH_SSL_SUPPORT) {
bool isDeviceTrusted = KdeConnectConfig::instance()->trustedDevices().contains(deviceId);
configureSslSocket(socket, deviceId, isDeviceTrusted);
......@@ -268,7 +268,7 @@ void LanLinkProvider::connected()
return; // Return statement prevents from deleting received package, needed in slot "encrypted"
} else {
qWarning() << receivedPackage->get<QString>("deviceName") << "uses an old protocol version, this won't work";
qWarning() << receivedPackage->get<QString>(QStringLiteral("deviceName")) << "uses an old protocol version, this won't work";
//addLink(deviceId, socket, receivedPackage, LanDeviceLink::Remotely);
}
......@@ -296,7 +296,7 @@ void LanLinkProvider::encrypted()
LanDeviceLink::ConnectionStarted connectionOrigin = (socket->mode() == QSslSocket::SslClientMode)? LanDeviceLink::Locally : LanDeviceLink::Remotely;
NetworkPackage* receivedPackage = receivedIdentityPackages[socket].np;
const QString& deviceId = receivedPackage->get<QString>("deviceId");
const QString& deviceId = receivedPackage->get<QString>(QStringLiteral("deviceId"));
addLink(deviceId, socket, receivedPackage, connectionOrigin);
......@@ -364,7 +364,7 @@ void LanLinkProvider::dataReceived()
//qCDebug(KDECONNECT_CORE) << "LanLinkProvider received reply:" << data;
NetworkPackage* np = new NetworkPackage("");
NetworkPackage* np = new NetworkPackage(QLatin1String(""));
bool success = NetworkPackage::unserialize(data, np);
if (!success) {
......@@ -381,13 +381,13 @@ void LanLinkProvider::dataReceived()
// Needed in "encrypted" if ssl is used, similar to "connected"
receivedIdentityPackages[socket].np = np;
const QString& deviceId = np->get<QString>("deviceId");
const QString& deviceId = np->get<QString>(QStringLiteral("deviceId"));
//qCDebug(KDECONNECT_CORE) << "Handshaking done (i'm the new device)";
//This socket will now be owned by the LanDeviceLink or we don't want more data to be received, forget about it
disconnect(socket, &QIODevice::readyRead, this, &LanLinkProvider::dataReceived);
if (np->get<int>("protocolVersion") >= MIN_VERSION_WITH_SSL_SUPPORT) {
if (np->get<int>(QStringLiteral("protocolVersion")) >= MIN_VERSION_WITH_SSL_SUPPORT) {
bool isDeviceTrusted = KdeConnectConfig::instance()->trustedDevices().contains(deviceId);
configureSslSocket(socket, deviceId, isDeviceTrusted);
......@@ -403,7 +403,7 @@ void LanLinkProvider::dataReceived()
socket->startClientEncryption();
} else {
qWarning() << np->get<QString>("deviceName") << "uses an old protocol version, this won't work";
qWarning() << np->get<QString>(QStringLiteral("deviceName")) << "uses an old protocol version, this won't work";
//addLink(deviceId, socket, np, LanDeviceLink::Locally);
delete receivedIdentityPackages.take(socket).np;
}
......@@ -429,11 +429,11 @@ void LanLinkProvider::configureSslSocket(QSslSocket* socket, const QString& devi
// Top 3 ciphers are for new Android devices, botton two are for old Android devices
// FIXME : These cipher suites should be checked whether they are supported or not on device
QList<QSslCipher> socketCiphers;
socketCiphers.append(QSslCipher("ECDHE-ECDSA-AES256-GCM-SHA384"));
socketCiphers.append(QSslCipher("ECDHE-ECDSA-AES128-GCM-SHA256"));
socketCiphers.append(QSslCipher("ECDHE-RSA-AES128-SHA"));
socketCiphers.append(QSslCipher("RC4-SHA"));
socketCiphers.append(QSslCipher("RC4-MD5"));
socketCiphers.append(QSslCipher(QStringLiteral("ECDHE-ECDSA-AES256-GCM-SHA384")));
socketCiphers.append(QSslCipher(QStringLiteral("ECDHE-ECDSA-AES128-GCM-SHA256")));
socketCiphers.append(QSslCipher(QStringLiteral("ECDHE-RSA-AES128-SHA")));
socketCiphers.append(QSslCipher(QStringLiteral("RC4-SHA")));
socketCiphers.append(QSslCipher(QStringLiteral("RC4-MD5")));
// Configure for ssl
QSslConfiguration sslConfig;
......@@ -446,7 +446,7 @@ void LanLinkProvider::configureSslSocket(QSslSocket* socket, const QString& devi
socket->setPeerVerifyName(deviceId);
if (isDeviceTrusted) {
QString certString = KdeConnectConfig::instance()->getDeviceProperty(deviceId, "certificate", QString());
QString certString = KdeConnectConfig::instance()->getDeviceProperty(deviceId, QStringLiteral("certificate"), QString());
socket->addCaCertificate(QSslCertificate(certString.toLatin1()));
socket->setPeerVerifyMode(QSslSocket::VerifyPeer);
} else {
......
......@@ -44,7 +44,7 @@ public:
LanLinkProvider(bool testMode = false);
~LanLinkProvider() override;
QString name() override { return "LanLinkProvider"; }
QString name() override { return QStringLiteral("LanLinkProvider"); }
int priority() override { return PRIORITY_HIGH; }
void userRequestsPair(const QString &deviceId);
......
......@@ -40,7 +40,7 @@ void LanPairingHandler::packageReceived(const NetworkPackage& np)
{
m_pairingTimeout.stop();
bool wantsPair = np.get<bool>("pair");
bool wantsPair = np.get<bool>(QStringLiteral("pair"));
if (wantsPair) {
......
......@@ -30,7 +30,7 @@ LoopbackDeviceLink::LoopbackDeviceLink(const QString& deviceId, LoopbackLinkProv
QString LoopbackDeviceLink::name()
{
return "LoopbackLink";
return QStringLiteral("LoopbackLink");
}
bool LoopbackDeviceLink::sendPackage(NetworkPackage& input)
......
......@@ -35,7 +35,7 @@ LoopbackLinkProvider::~LoopbackLinkProvider()
void LoopbackLinkProvider::onNetworkChange()
{
LoopbackDeviceLink* newLoopbackDeviceLink = new LoopbackDeviceLink("loopback", this);
LoopbackDeviceLink* newLoopbackDeviceLink = new LoopbackDeviceLink(QStringLiteral("loopback"), this);
Q_EMIT onConnectionReceived(identityPackage, newLoopbackDeviceLink);
if (loopbackDeviceLink) {
......
......@@ -33,7 +33,7 @@ public:
LoopbackLinkProvider();
~LoopbackLinkProvider() override;
QString name() override { return "LoopbackLinkProvider"; }
QString name() override { return QStringLiteral("LoopbackLinkProvider"); }
int priority() override { return PRIORITY_LOW; }
void onStart() override;
......
......@@ -85,8 +85,8 @@ Daemon::Daemon(QObject *parent, bool testMode)
}
//Register on DBus
QDBusConnection::sessionBus().registerService("org.kde.kdeconnect");
QDBusConnection::sessionBus().registerObject("/modules/kdeconnect", this, QDBusConnection::ExportScriptableContents);
QDBusConnection::sessionBus().registerService(QStringLiteral("org.kde.kdeconnect"));
QDBusConnection::sessionBus().registerObject(QStringLiteral("/modules/kdeconnect"), this, QDBusConnection::ExportScriptableContents);
qCDebug(KDECONNECT_CORE) << "KdeConnect daemon started";
}
......@@ -165,12 +165,12 @@ QStringList Daemon::devices(bool onlyReachable, bool onlyTrusted) const
void Daemon::onNewDeviceLink(const NetworkPackage& identityPackage, DeviceLink* dl)
{
const QString& id = identityPackage.get<QString>("deviceId");
const QString& id = identityPackage.get<QString>(QStringLiteral("deviceId"));
//qCDebug(KDECONNECT_CORE) << "Device discovered" << id << "via" << dl->provider()->name();
if (d->mDevices.contains(id)) {
qCDebug(KDECONNECT_CORE) << "It is a known device" << identityPackage.get<QString>("deviceName");
qCDebug(KDECONNECT_CORE) << "It is a known device" << identityPackage.get<QString>(QStringLiteral("deviceName"));
Device* device = d->mDevices[id];
bool wasReachable = device->isReachable();
device->addLink(identityPackage, dl);
......@@ -178,7 +178,7 @@ void Daemon::onNewDeviceLink(const NetworkPackage& identityPackage, DeviceLink*
Q_EMIT deviceVisibilityChanged(id, true);
}
} else {
qCDebug(KDECONNECT_CORE) << "It is a new device" << identityPackage.get<QString>("deviceName");
qCDebug(KDECONNECT_CORE) << "It is a new device" << identityPackage.get<QString>(QStringLiteral("deviceName"));
Device* device = new Device(this, identityPackage, dl);
//we discard the connections that we created but it's not paired.
......
......@@ -27,7 +27,7 @@ namespace DbusHelper {
void filterNonExportableCharacters(QString& s)
{
static QRegExp regexp("[^A-Za-z0-9_]", Qt::CaseSensitive, QRegExp::Wildcard);
s.replace(regexp,"_");
s.replace(regexp,QLatin1String("_"));
}
}
......@@ -68,8 +68,8 @@ Device::Device(QObject* parent, const QString& id)
Device::Device(QObject* parent, const NetworkPackage& identityPackage, DeviceLink* dl)
: QObject(parent)
, m_deviceId(identityPackage.get<QString>("deviceId"))
, m_deviceName(identityPackage.get<QString>("deviceName"))
, m_deviceId(identityPackage.get<QString>(QStringLiteral("deviceId")))
, m_deviceName(identityPackage.get<QString>(QStringLiteral("deviceName")))
{
addLink(identityPackage, dl);
......@@ -108,7 +108,7 @@ void Device::reloadPlugins()
const KPluginMetaData service = loader->getPluginInfo(pluginName);
const bool pluginEnabled = isPluginEnabled(pluginName);
const QSet<QString> incomingCapabilities = KPluginMetaData::readStringList(service.rawData(), "X-KdeConnect-SupportedPackageType").toSet();
const QSet<QString> incomingCapabilities = KPluginMetaData::readStringList(service.rawData(), QStringLiteral("X-KdeConnect-SupportedPackageType")).toSet();
if (pluginEnabled) {
KdeConnectPlugin* plugin = m_plugins.take(pluginName);
......@@ -146,7 +146,7 @@ void Device::reloadPlugins()
QString Device::pluginsConfigFile() const
{
return KdeConnectConfig::instance()->deviceConfigDir(id()).absoluteFilePath("config");
return KdeConnectConfig::instance()->deviceConfigDir(id()).absoluteFilePath(QStringLiteral("config"));
}
void Device::requestPair()
......@@ -206,7 +206,7 @@ void Device::addLink(const NetworkPackage& identityPackage, DeviceLink* link)
Q_ASSERT(!m_deviceLinks.contains(link));
m_protocolVersion = identityPackage.get<int>("protocolVersion", -1);
m_protocolVersion = identityPackage.get<int>(QStringLiteral("protocolVersion"), -1);
if (m_protocolVersion != NetworkPackage::ProtocolVersion) {
qCWarning(KDECONNECT_CORE) << m_deviceName << "- warning, device uses a different protocol version" << m_protocolVersion << "expected" << NetworkPackage::ProtocolVersion;
}
......@@ -217,8 +217,8 @@ void Device::addLink(const NetworkPackage& identityPackage, DeviceLink* link)
m_deviceLinks.append(link);
//re-read the device name from the identityPackage because it could have changed
setName(identityPackage.get<QString>("deviceName"));
m_deviceType = str2type(identityPackage.get<QString>("deviceType"));
setName(identityPackage.get<QString>(QStringLiteral("deviceName")));
m_deviceType = str2type(identityPackage.get<QString>(QStringLiteral("deviceType")));
//Theoretically we will never add two links from the same provider (the provider should destroy
//the old one before this is called), so we do not have to worry about destroying old links.
......@@ -229,10 +229,10 @@ void Device::addLink(const NetworkPackage& identityPackage, DeviceLink* link)
qSort(m_deviceLinks.begin(), m_deviceLinks.end(), lessThan);
const bool capabilitiesSupported = identityPackage.has("incomingCapabilities") || identityPackage.has("outgoingCapabilities");
const bool capabilitiesSupported = identityPackage.has(QStringLiteral("incomingCapabilities")) || identityPackage.has(QStringLiteral("outgoingCapabilities"));
if (capabilitiesSupported) {
const QSet<QString> outgoingCapabilities = identityPackage.get<QStringList>("outgoingCapabilities").toSet()
, incomingCapabilities = identityPackage.get<QStringList>("incomingCapabilities").toSet();
const QSet<QString> outgoingCapabilities = identityPackage.get<QStringList>(QStringLiteral("outgoingCapabilities")).toSet()
, incomingCapabilities = identityPackage.get<QStringList>(QStringLiteral("incomingCapabilities")).toSet();
m_supportedPlugins = PluginLoader::instance()->pluginsForCapabilities(incomingCapabilities, outgoingCapabilities);
//qDebug() << "new plugins for" << m_deviceName << m_supportedPlugins << incomingCapabilities << outgoingCapabilities;
......@@ -328,19 +328,19 @@ void Device::cleanUnneededLinks() {
}
Device::DeviceType Device::str2type(const QString &deviceType) {
if (deviceType == "desktop") return Desktop;
if (deviceType == "laptop") return Laptop;
if (deviceType == "smartphone" || deviceType == "phone") return Phone;
if (deviceType == "tablet") return Tablet;
if (deviceType == QLatin1String("desktop")) return Desktop;
if (deviceType == QLatin1String("laptop")) return Laptop;
if (deviceType == QLatin1String("smartphone") || deviceType == QLatin1String("phone")) return Phone;
if (deviceType == QLatin1String("tablet")) return Tablet;
return Unknown;
}
QString Device::type2str(Device::DeviceType deviceType) {
if (deviceType == Desktop) return "desktop";
if (deviceType == Laptop) return "laptop";
if (deviceType == Phone) return "smartphone";
if (deviceType == Tablet) return "tablet";
return "unknown";
if (deviceType == Desktop) return QStringLiteral("desktop");
if (deviceType == Laptop) return QStringLiteral("laptop");
if (deviceType == Phone) return QStringLiteral("smartphone");
if (deviceType == Tablet) return QStringLiteral("tablet");
return QStringLiteral("unknown");
}
QString Device::statusIconName() const
......@@ -411,7 +411,7 @@ QString Device::encryptionInfo() const
}
result += i18n("SHA1 fingerprint of your device certificate is: %1\n", localSha1);
std::string remotePem = KdeConnectConfig::instance()->getDeviceProperty(id(), "certificate").toStdString();
std::string remotePem = KdeConnectConfig::instance()->getDeviceProperty(id(), QStringLiteral("certificate")).toStdString();
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) {
......
......@@ -33,7 +33,7 @@ FileTransferJob::FileTransferJob(const QSharedPointer<QIODevice>& origin, qint64
: KJob()
, mOrigin(origin)
, mReply(Q_NULLPTR)
, mFrom("KDE Connect")
, mFrom(QStringLiteral("KDE Connect"))
, mDestination(destination)
, mSpeedBytes(0)
, mWritten(0)
......@@ -42,7 +42,7 @@ FileTransferJob::FileTransferJob(const QSharedPointer<QIODevice>& origin, qint64
Q_ASSERT(mOrigin->isReadable());
if (mDestination.scheme().isEmpty()) {
qCWarning(KDECONNECT_CORE) << "Destination QUrl" << mDestination << "lacks a scheme. Setting its scheme to 'file'.";
mDestination.setScheme("file");
mDestination.setScheme(QStringLiteral("file"));
}
if (size >= 0) {
......
......@@ -77,14 +77,14 @@ KdeConnectConfig::KdeConnectConfig()
QDir().mkpath(baseConfigDir().path());
//.config/kdeconnect/config
d->config = new QSettings(baseConfigDir().absoluteFilePath("config"), QSettings::IniFormat);
d->trusted_devices = new QSettings(baseConfigDir().absoluteFilePath("trusted_devices"), QSettings::IniFormat);
d->config = new QSettings(baseConfigDir().absoluteFilePath(QStringLiteral("config")), QSettings::IniFormat);
d->trusted_devices = new QSettings(baseConfigDir().absoluteFilePath(QStringLiteral("trusted_devices")), QSettings::IniFormat);
//Register my own id if not there yet
if (!d->config->contains("id")) {
if (!d->config->contains(QStringLiteral("id"))) {
QString uuid = QUuid::createUuid().toString();
DbusHelper::filterNonExportableCharacters(uuid);
d->config->setValue("id", uuid);
d->config->setValue(QStringLiteral("id"), uuid);
d->config->sync();
qCDebug(KDECONNECT_CORE) << "My id:" << uuid;
}
......@@ -102,7 +102,7 @@ KdeConnectConfig::KdeConnectConfig()
d->privateKey = QCA::KeyGenerator().createRSA(2048);
if (!privKey.open(QIODevice::ReadWrite | QIODevice::Truncate)) {
Daemon::instance()->reportError(QLatin1String("KDE Connect"), i18n("Could not store private key file: %1", keyPath));
Daemon::instance()->reportError(QStringLiteral("KDE Connect"), i18n("Could not store private key file: %1", keyPath));
} else {
privKey.setPermissions(strict);
privKey.write(d->privateKey.toPEM().toLatin1());
......@@ -126,8 +126,8 @@ KdeConnectConfig::KdeConnectConfig()
QDateTime endTime = startTime.addYears(10);
QCA::CertificateInfo certificateInfo;
certificateInfo.insert(QCA::CommonName,deviceId());
certificateInfo.insert(QCA::Organization,"KDE");
certificateInfo.insert(QCA::OrganizationalUnit,"Kde connect");
certificateInfo.insert(QCA::Organization,QStringLiteral("KDE"));
certificateInfo.insert(QCA::OrganizationalUnit,QStringLiteral("Kde connect"));
certificateOptions.setInfo(certificateInfo);
certificateOptions.setFormat(QCA::PKCS10);
certificateOptions.setSerialNumber(QCA::BigInteger(10));
......@@ -136,7 +136,7 @@ KdeConnectConfig::KdeConnectConfig()
d->certificate = QSslCertificate(QCA::Certificate(certificateOptions, d->privateKey).toPEM().toLatin1());
if (!cert.open(QIODevice::ReadWrite | QIODevice::Truncate)) {
Daemon::instance()->reportError(QLatin1String("KDE Connect"), i18n("Could not store certificate file: %1", certPath));
Daemon::instance()->reportError(QStringLiteral("KDE Connect"), i18n("Could not store certificate file: %1", certPath));
} else {
cert.setPermissions(strict);
cert.write(d->certificate.toPem());
......@@ -152,30 +152,30 @@ KdeConnectConfig::KdeConnectConfig()
QString KdeConnectConfig::name()
{
QString defaultName = qgetenv("USER") + '@' + QHostInfo::localHostName();
QString name = d->config->value("name", defaultName).toString();
QString name = d->config->value(QStringLiteral("name"), defaultName).toString();
return name;
}
void KdeConnectConfig::setName(QString name)
{
d->config->setValue("name", name);
d->config->setValue(QStringLiteral("name"), name);
d->config->sync();
}
QString KdeConnectConfig::deviceType()
{
return "desktop"; // TODO
return QStringLiteral("desktop"); // TODO
}
QString KdeConnectConfig::deviceId()
{
QString id = d->config->value("id", "").toString();
QString id = d->config->value(QStringLiteral("id"), "").toString();
return id;
}
QString KdeConnectConfig::privateKeyPath()
{
return baseConfigDir().absoluteFilePath("privateKey.pem");
return baseConfigDir().absoluteFilePath(QStringLiteral("privateKey.pem"));
}
QCA::PrivateKey KdeConnectConfig::privateKey()
......@@ -190,7 +190,7 @@ QCA::PublicKey KdeConnectConfig::publicKey()
QString KdeConnectConfig::certificatePath()
{
return baseConfigDir().absoluteFilePath("certificate.pem");
return baseConfigDir().absoluteFilePath(QStringLiteral("certificate.pem"));
}
QSslCertificate KdeConnectConfig::certificate()
......@@ -201,7 +201,7 @@ QSslCertificate KdeConnectConfig::certificate()
QDir KdeConnectConfig::baseConfigDir()
{
QString configPath = QStandardPaths::writableLocation(QStandardPaths::ConfigLocation);
QString kdeconnectConfigPath = QDir(configPath).absoluteFilePath("kdeconnect");
QString kdeconnectConfigPath = QDir(configPath).absoluteFilePath(QStringLiteral("kdeconnect"));
return QDir(kdeconnectConfigPath);
}
......@@ -215,8 +215,8 @@ QStringList KdeConnectConfig::trustedDevices()
void KdeConnectConfig::addTrustedDevice(const QString &id, const QString &name, const QString &type)
{
d->trusted_devices->beginGroup(id);
d->trusted_devices->setValue("name", name);
d->trusted_devices->setValue("type", type);
d->trusted_devices->setValue(QStringLiteral("name"), name);
d->trusted_devices->setValue(QStringLiteral("type"), type);
d->trusted_devices->endGroup();
d->trusted_devices->sync();
......@@ -228,8 +228,8 @@ KdeConnectConfig::DeviceInfo KdeConnectConfig::getTrustedDevice(const QString &i
d->trusted_devices->beginGroup(id);
KdeConnectConfig::DeviceInfo info;
info.deviceName = d->trusted_devices->value("name", QLatin1String("unnamed")).toString();
info.deviceType = d->trusted_devices->value("type", QLatin1String("unknown")).toString();
info.deviceName = d->trusted_devices->value(QStringLiteral("name"), QLatin1String("unnamed")).toString();
info.deviceType = d->trusted_devices->value(QStringLiteral("type"), QLatin1String("unknown")).toString();
d->trusted_devices->endGroup();
return info;
......
......@@ -40,10 +40,10 @@ KdeConnectPluginConfig::KdeConnectPluginConfig(const QString& deviceId, const QS
d->mConfigDir = KdeConnectConfig::instance()->pluginConfigDir(deviceId, pluginName);
QDir().mkpath(d->mConfigDir.path());
d->mConfig = new QSettings(d->mConfigDir.absoluteFilePath("config"), QSettings::IniFormat);
d->mConfig = new QSettings(d->mConfigDir.absoluteFilePath(QStringLiteral("config")), QSettings::IniFormat);
d->signal = QDBusMessage::createSignal("/kdeconnect/"+deviceId+"/"+pluginName, "org.kde.kdeconnect.config", "configChanged");
QDBusConnection::sessionBus().connect("", "/kdeconnect/"+deviceId+"/"+pluginName, "org.kde.kdeconnect.config", "configChanged", this, SLOT(slotConfigChanged()));
d->signal = QDBusMessage::createSignal("/kdeconnect/"+deviceId+"/"+pluginName, QStringLiteral("org.kde.kdeconnect.config"), QStringLiteral("configChanged"));
QDBusConnection::sessionBus().connect(QLatin1String(""), "/kdeconnect/"+deviceId+"/"+pluginName, QStringLiteral("org.kde.kdeconnect.config"), QStringLiteral("configChanged"), this, SLOT(slotConfigChanged()));
}
KdeConnectPluginConfig::~KdeConnectPluginConfig()
......@@ -74,7 +74,7 @@ QVariantList KdeConnectPluginConfig::getList(const QString& key,
}
for (int i = 0; i < size; ++i) {
d->mConfig->setArrayIndex(i);
list << d->mConfig->value("value");
list << d->mConfig->value(QStringLiteral("value"));
}
d->mConfig->endArray();
return list;
......@@ -92,7 +92,7 @@ void KdeConnectPluginConfig::setList(const QString& key, const QVariantList& lis
d->mConfig->beginWriteArray(key);
for (int i = 0; i < list.size(); ++i) {
d->mConfig->setArrayIndex(i);
d->mConfig->setValue("value", list.at(i));
d->mConfig->setValue(QStringLiteral("value"), list.at(i));
}
d->mConfig->endArray();
d->mConfig->sync();
......
......@@ -63,12 +63,12 @@ void NetworkPackage::createIdentityPackage(NetworkPackage* np)
np->mType = PACKAGE_TYPE_IDENTITY;
np->mPayload = QSharedPointer<QIODevice>();
np->mPayloadSize = 0;
np->set("deviceId", id);
np->set("deviceName", config->name());
np->set("deviceType", config->deviceType());
np->set("protocolVersion", NetworkPackage::ProtocolVersion);
np->set("incomingCapabilities", PluginLoader::instance()->incomingCapabilities());
np->set("outgoingCapabilities", PluginLoader::instance()->outgoingCapabilities());
np->set(QStringLiteral("deviceId"), id);
np->set(QStringLiteral("deviceName"), config->name());
np->set(QStringLiteral("deviceType"), config->deviceType());
np->set(QStringLiteral("protocolVersion"), NetworkPackage::ProtocolVersion);
np->set(QStringLiteral("incomingCapabilities"), PluginLoader::instance()->incomingCapabilities());
np->set(QStringLiteral("outgoingCapabilities"), PluginLoader::instance()->outgoingCapabilities());
//qCDebug(KDECONNECT_CORE) << "createIdentityPackage" << np->serialize();
}
......@@ -97,8 +97,8 @@ QByteArray NetworkPackage::serialize() const
if (hasPayload()) {
//qCDebug(KDECONNECT_CORE) << "Serializing payloadTransferInfo";
variant["payloadSize"] = payloadSize();
variant["payloadTransferInfo"] = mPayloadTransferInfo;
variant[QStringLiteral("payloadSize")] = payloadSize();
variant[QStringLiteral("payloadTransferInfo")] = mPayloadTransferInfo;
}
//QVariant -> json
......@@ -148,18 +148,18 @@ bool NetworkPackage::unserialize(const QByteArray& a, NetworkPackage* np)
auto variant = parser.toVariant().toMap();
qvariant2qobject(variant, np);
np->mPayloadSize = variant["payloadSize"].toInt(); //Will return 0 if was not present, which is ok
np->mPayloadSize = variant[QStringLiteral("payloadSize")].toInt(); //Will return 0 if was not present, which is ok
if (np->mPayloadSize == -1) {
np->mPayloadSize = np->get<int>("size", -1);
np->mPayloadSize = np->get<int>(QStringLiteral("size"), -1);
}
np->mPayloadTransferInfo = variant["payloadTransferInfo"].toMap(); //Will return an empty qvariantmap if was not present, which is ok
np->mPayloadTransferInfo = variant[QStringLiteral("payloadTransferInfo")].toMap(); //Will return an empty qvariantmap if was not present, which is ok
//Ids containing characters that are not allowed as dbus paths would make app crash
if (np->mBody.contains("deviceId"))
if (np->mBody.contains(QStringLiteral("deviceId")))
{
QString deviceId = np->get<QString>("deviceId");
QString deviceId = np->get<QString>(QStringLiteral("deviceId"));
DbusHelper::filterNonExportableCharacters(deviceId);
np->set("deviceId", deviceId);
np->set(QStringLiteral("deviceId"), deviceId);
}
return true;
......
......@@ -21,7 +21,7 @@
#ifndef NETWORKPACKAGETYPES_H
#define NETWORKPACKAGETYPES_H
#define PACKAGE_TYPE_IDENTITY QLatin1String("kdeconnect.identity")
#define PACKAGE_TYPE_PAIR QLatin1String("kdeconnect.pair")
#define PACKAGE_TYPE_IDENTITY QStringLiteral("kdeconnect.identity")
#define PACKAGE_TYPE_PAIR QStringLiteral("kdeconnect.pair")
#endif // NETWORKPACKAGETYPES_H
......@@ -36,7 +36,7 @@ PluginLoader* PluginLoader::instance()
PluginLoader::PluginLoader()
{
QVector<KPluginMetaData> data = KPluginLoader::findPlugins("kdeconnect/");
QVector<KPluginMetaData> data = KPluginLoader::findPlugins(QStringLiteral("kdeconnect/"));
Q_FOREACH (const KPluginMetaData& metadata, data) {
plugins[metadata.pluginId()] = metadata;
}
......@@ -69,7 +69,7 @@ KdeConnectPlugin* PluginLoader::instantiatePluginForDevice(const QString& plugin
return ret;
}
const QStringList outgoingInterfaces = KPluginMetaData::readStringList(service.rawData(), "X-KdeConnect-OutgoingPackageType");
const QStringList outgoingInterfaces = KPluginMetaData::readStringList(service.rawData(), QStringLiteral("X-KdeConnect-OutgoingPackageType"));
QVariant deviceVariant = QVariant::fromValue<Device*>(device);