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();
}
......@@ -36,36 +36,36 @@
int main(int argc, char** argv)
{
QCoreApplication app(argc, argv);
KAboutData about("kdeconnect-cli",
"kdeconnect-cli",
QLatin1String(KDECONNECT_VERSION_STRING),
KAboutData about(QStringLiteral("kdeconnect-cli"),
QStringLiteral("kdeconnect-cli"),
QStringLiteral(KDECONNECT_VERSION_STRING),
i18n("KDE Connect CLI tool"),
KAboutLicense::GPL,
i18n("(C) 2015 Aleix Pol Gonzalez"));
KAboutData::setApplicationData(about);
about.addAuthor( i18n("Aleix Pol Gonzalez"), QString(), "aleixpol@kde.org" );
about.addAuthor( i18n("Albert Vaca Cintora"), QString(), "albertvaka@gmail.com" );
about.addAuthor( i18n("Aleix Pol Gonzalez"), QString(), QStringLiteral("aleixpol@kde.org") );
about.addAuthor( i18n("Albert Vaca Cintora"), QString(), QStringLiteral("albertvaka@gmail.com") );
QCommandLineParser parser;
parser.addOption(QCommandLineOption(QStringList("l") << "list-devices", i18n("List all devices")));
parser.addOption(QCommandLineOption(QStringList("a") << "list-available", i18n("List available (paired and reachable) devices")));
parser.addOption(QCommandLineOption("id-only", i18n("Make --list-devices or --list-available print only the devices id, to ease scripting")));
parser.addOption(QCommandLineOption("refresh", i18n("Search for devices in the network and re-establish connections")));
parser.addOption(QCommandLineOption("pair", i18n("Request pairing to a said device")));
parser.addOption(QCommandLineOption("ring", i18n("Find the said device by ringing it.")));
parser.addOption(QCommandLineOption("unpair", i18n("Stop pairing to a said device")));
parser.addOption(QCommandLineOption("ping", i18n("Sends a ping to said device")));
parser.addOption(QCommandLineOption("ping-msg", i18n("Same as ping but you can set the message to display"), i18n("message")));
parser.addOption(QCommandLineOption("share", i18n("Share a file to a said device"), "path"));
parser.addOption(QCommandLineOption("list-notifications", i18n("Display the notifications on a said device")));
parser.addOption(QCommandLineOption("lock", i18n("Lock the specified device")));
parser.addOption(QCommandLineOption("send-sms", i18n("Sends an SMS. Requires destination"), i18n("message")));
parser.addOption(QCommandLineOption("destination", i18n("Phone number to send the message"), i18n("phone number")));
parser.addOption(QCommandLineOption(QStringList("device") << "d", i18n("Device ID"), "dev"));
parser.addOption(QCommandLineOption(QStringList("name") << "n", i18n("Device Name"), "name"));
parser.addOption(QCommandLineOption("encryption-info", i18n("Get encryption info about said device")));
parser.addOption(QCommandLineOption("list-commands", i18n("Lists remote commands and their ids")));
parser.addOption(QCommandLineOption("execute-command", i18n("Executes a remote command by id"), "id"));
parser.addOption(QCommandLineOption(QStringList(QStringLiteral("l")) << QStringLiteral("list-devices"), i18n("List all devices")));
parser.addOption(QCommandLineOption(QStringList(QStringLiteral("a")) << QStringLiteral("list-available"), i18n("List available (paired and reachable) devices")));
parser.addOption(QCommandLineOption(QStringLiteral("id-only"), i18n("Make --list-devices or --list-available print only the devices id, to ease scripting")));
parser.addOption(QCommandLineOption(QStringLiteral("refresh"), i18n("Search for devices in the network and re-establish connections")));
parser.addOption(QCommandLineOption(QStringLiteral("pair"), i18n("Request pairing to a said device")));
parser.addOption(QCommandLineOption(QStringLiteral("ring"), i18n("Find the said device by ringing it.")));
parser.addOption(QCommandLineOption(QStringLiteral("unpair"), i18n("Stop pairing to a said device")));
parser.addOption(QCommandLineOption(QStringLiteral("ping"), i18n("Sends a ping to said device")));
parser.addOption(QCommandLineOption(QStringLiteral("ping-msg"), i18n("Same as ping but you can set the message to display"), i18n("message")));
parser.addOption(QCommandLineOption(QStringLiteral("share"), i18n("Share a file to a said device"), QStringLiteral("path")));
parser.addOption(QCommandLineOption(QStringLiteral("list-notifications"), i18n("Display the notifications on a said device")));
parser.addOption(QCommandLineOption(QStringLiteral("lock"), i18n("Lock the specified device")));
parser.addOption(QCommandLineOption(QStringLiteral("send-sms"), i18n("Sends an SMS. Requires destination"), i18n("message")));
parser.addOption(QCommandLineOption(QStringLiteral("destination"), i18n("Phone number to send the message"), i18n("phone number")));
parser.addOption(QCommandLineOption(QStringList(QStringLiteral("device")) << QStringLiteral("d"), i18n("Device ID"), QStringLiteral("dev")));
parser.addOption(QCommandLineOption(QStringList(QStringLiteral("name")) << QStringLiteral("n"), i18n("Device Name"), QStringLiteral("name")));
parser.addOption(QCommandLineOption(QStringLiteral("encryption-info"), i18n("Get encryption info about said device")));
parser.addOption(QCommandLineOption(QStringLiteral("list-commands"), i18n("Lists remote commands and their ids")));
parser.addOption(QCommandLineOption(QStringLiteral("execute-command"), i18n("Executes a remote command by id"), QStringLiteral("id")));
about.setupCommandLine(&parser);
parser.addHelpOption();
......@@ -75,9 +75,9 @@ int main(int argc, char** argv)
const QString id = "kdeconnect-cli-"+QString::number(QCoreApplication::applicationPid());
DaemonDbusInterface iface;
if(parser.isSet("l") || parser.isSet("a")) {
if(parser.isSet(QStringLiteral("l")) || parser.isSet(QStringLiteral("a"))) {
bool paired = true, reachable = false;
if (parser.isSet("a")) {
if (parser.isSet(QStringLiteral("a"))) {
reachable = true;
} else {
iface.acquireDiscoveryMode(id);
......@@ -88,7 +88,7 @@ int main(int argc, char** argv)
const QStringList devices = reply.value();
Q_FOREACH (const QString& id, devices) {
if (parser.isSet("id-only")) {
if (parser.isSet(QStringLiteral("id-only"))) {
QTextStream(stdout) << id << endl;
} else {
DeviceDbusInterface deviceIface(id);
......@@ -106,23 +106,23 @@ int main(int argc, char** argv)
<< ": " << deviceIface.id() << ' ' << statusInfo << endl;
}
}
if (!parser.isSet("id-only")) {
if (!parser.isSet(QStringLiteral("id-only"))) {
QTextStream(stdout) << i18np("1 device found", "%1 devices found", devices.size()) << endl;
} else if (devices.isEmpty()) {
QTextStream(stderr) << i18n("No devices found") << endl;
}
iface.releaseDiscoveryMode(id);
} else if(parser.isSet("refresh")) {
QDBusMessage msg = QDBusMessage::createMethodCall("org.kde.kdeconnect", "/modules/kdeconnect", "org.kde.kdeconnect.daemon", "forceOnNetworkChange");
} else if(parser.isSet(QStringLiteral("refresh"))) {
QDBusMessage msg = QDBusMessage::createMethodCall(QStringLiteral("org.kde.kdeconnect"), QStringLiteral("/modules/kdeconnect"), QStringLiteral("org.kde.kdeconnect.daemon"), QStringLiteral("forceOnNetworkChange"));
QDBusConnection::sessionBus().call(msg);
} else {
QString device = parser.value("device");
if (device.isEmpty() && parser.isSet("name")) {
device = iface.deviceIdByName(parser.value("name"));
QString device = parser.value(QStringLiteral("device"));
if (device.isEmpty() && parser.isSet(QStringLiteral("name"))) {
device = iface.deviceIdByName(parser.value(QStringLiteral("name")));
if (device.isEmpty()) {
QTextStream(stderr) << "Couldn't find device: " << parser.value("name") << endl;
QTextStream(stderr) << "Couldn't find device: " << parser.value(QStringLiteral("name")) << endl;
return 1;
}
}
......@@ -131,17 +131,17 @@ int main(int argc, char** argv)
return 1;
}
if(parser.isSet("share")) {
QUrl url = QUrl::fromUserInput(parser.value("share"), QDir::currentPath());
if(parser.isSet(QStringLiteral("share"))) {
QUrl url = QUrl::fromUserInput(parser.value(QStringLiteral("share")), QDir::currentPath());
parser.clearPositionalArguments();
if(!url.isEmpty() && !device.isEmpty()) {
QDBusMessage msg = QDBusMessage::createMethodCall("org.kde.kdeconnect", "/modules/kdeconnect/devices/"+device+"/share", "org.kde.kdeconnect.device.share", "shareUrl");
QDBusMessage msg = QDBusMessage::createMethodCall(QStringLiteral("org.kde.kdeconnect"), "/modules/kdeconnect/devices/"+device+"/share", QStringLiteral("org.kde.kdeconnect.device.share"), QStringLiteral("shareUrl"));
msg.setArguments(QVariantList() << url.toString());
QDBusConnection::sessionBus().call(msg);
} else {
QTextStream(stderr) << (i18n("Couldn't share %1", url.toString())) << endl;
}
} else if(parser.isSet("pair")) {
} else if(parser.isSet(QStringLiteral("pair"))) {
DeviceDbusInterface dev(device);
if (!dev.isReachable()) {
//Device doesn't exist, go into discovery mode and wait up to 30 seconds for the device to appear
......@@ -169,7 +169,7 @@ int main(int argc, char** argv)
req.waitForFinished();
}
iface.releaseDiscoveryMode(id);
} else if(parser.isSet("unpair")) {
} else if(parser.isSet(QStringLiteral("unpair"))) {
DeviceDbusInterface dev(device);
if (!dev.isReachable()) {
QTextStream(stderr) << i18n("Device does not exist") << endl;
......@@ -180,26 +180,26 @@ int main(int argc, char** argv)
QDBusPendingReply<void> req = dev.unpair();
req.waitForFinished();
}
} else if(parser.isSet("ping") || parser.isSet("ping-msg")) {
QDBusMessage msg = QDBusMessage::createMethodCall("org.kde.kdeconnect", "/modules/kdeconnect/devices/"+device+"/ping", "org.kde.kdeconnect.device.ping", "sendPing");
if (parser.isSet("ping-msg")) {
QString message = parser.value("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"));
if (parser.isSet(QStringLiteral("ping-msg"))) {
QString message = parser.value(QStringLiteral("ping-msg"));
msg.setArguments(QVariantList() << message);
}
QDBusConnection::sessionBus().call(msg);
} else if(parser.isSet("send-sms")) {
if (parser.isSet("destination")) {
QDBusMessage msg = QDBusMessage::createMethodCall("org.kde.kdeconnect", "/modules/kdeconnect/devices/"+device+"/telephony", "org.kde.kdeconnect.device.telephony", "sendSms");
} else if(parser.isSet(QStringLiteral("send-sms"))) {
if (parser.isSet(QStringLiteral("destination"))) {
QDBusMessage msg = QDBusMessage::createMethodCall(QStringLiteral("org.kde.kdeconnect"), "/modules/kdeconnect/devices/"+device+"/telephony", QStringLiteral("org.kde.kdeconnect.device.telephony"), QStringLiteral("sendSms"));
msg.setArguments({ parser.value("destination"), parser.value("send-sms") });
QDBusConnection::sessionBus().call(msg);
} else {
QTextStream(stderr) << i18n("error: should specify the SMS's recipient by passing --destination <phone number>");
return 1;
}
} else if(parser.isSet("ring")) {
QDBusMessage msg = QDBusMessage::createMethodCall("org.kde.kdeconnect", "/modules/kdeconnect/devices/"+device+"/findmyphone", "org.kde.kdeconnect.device.findmyphone", "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"));
QDBusConnection::sessionBus().call(msg);
} else if(parser.isSet("list-notifications")) {
} else if(parser.isSet(QStringLiteral("list-notifications"))) {
NotificationsModel notifications;
notifications.setDeviceId(device);
for(int i=0, rows=notifications.rowCount(); i<rows; ++i) {
......@@ -207,21 +207,21 @@ int main(int argc, char** argv)
QTextStream(stdout) << "- " << idx.data(NotificationsModel::AppNameModelRole).toString()
<< ": " << idx.data(NotificationsModel::NameModelRole).toString() << endl;
}
} else if(parser.isSet("list-commands")) {
} else if(parser.isSet(QStringLiteral("list-commands"))) {
RemoteCommandsDbusInterface iface(device);
const auto cmds = QJsonDocument::fromJson(iface.commands()).object();
for (auto it = cmds.constBegin(), itEnd = cmds.constEnd(); it!=itEnd; ++it) {
const QJsonObject cont = it->toObject();
QTextStream(stdout) << it.key() << ": " << cont.value("name").toString() << ": " << cont.value("command").toString() << endl;
QTextStream(stdout) << it.key() << ": " << cont.value(QStringLiteral("name")).toString() << ": " << cont.value(QStringLiteral("command")).toString() << endl;
}
const auto err = iface.lastError();
if (err.isValid()) {
QTextStream(stderr) << err.message() << endl;
}
} else if(parser.isSet("execute-command")) {
} else if(parser.isSet(QStringLiteral("execute-command"))) {
RemoteCommandsDbusInterface iface(device);
iface.triggerCommand(parser.value("execute-command"));
} else if(parser.isSet("encryption-info")) {
iface.triggerCommand(parser.value(QStringLiteral("execute-command")));
} else if(parser.isSet(QStringLiteral("encryption-info"))) {
DeviceDbusInterface dev(device);
QDBusPendingReply<QString> devReply = dev.encryptionInfo(); // QSsl::Der = 1
devReply.waitForFinished();
......
......@@ -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);