[SCM] kdeconnect packaging branch, master, updated. debian/0.9g-1-1183-g9d69498
Maximiliano Curia
maxy at moszumanska.debian.org
Fri Oct 14 14:29:23 UTC 2016
Gitweb-URL: http://git.debian.org/?p=pkg-kde/kde-extras/kdeconnect.git;a=commitdiff;h=82bc73d
The following commit has been merged in the master branch:
commit 82bc73dd9b811465c526364336f14fbf29bb1fde
Author: Albert Vaca <albertvaka at gmail.com>
Date: Tue Dec 1 07:25:34 2015 -0800
WIPx2
---
cli/kdeconnect-cli.cpp | 2 +-
core/backends/devicelink.h | 2 +-
core/backends/lan/landevicelink.cpp | 26 +++++++------------------
core/backends/lan/landevicelink.h | 5 ++---
core/backends/lan/lanlinkprovider.cpp | 4 ----
core/backends/loopback/loopbackdevicelink.cpp | 28 ++-------------------------
core/backends/loopback/loopbackdevicelink.h | 2 +-
core/backends/pairinghandler.cpp | 17 +++++++++++++---
core/backends/pairinghandler.h | 2 +-
core/device.cpp | 20 +++++++++----------
core/device.h | 2 +-
kcm/kcm.cpp | 2 +-
tests/devicetest.cpp | 15 +++-----------
tests/kdeconnectconfigtest.cpp | 13 ++++---------
tests/lanlinkprovidertest.cpp | 6 +++---
15 files changed, 51 insertions(+), 95 deletions(-)
diff --git a/cli/kdeconnect-cli.cpp b/cli/kdeconnect-cli.cpp
index 69856cb..9c9447f 100644
--- a/cli/kdeconnect-cli.cpp
+++ b/cli/kdeconnect-cli.cpp
@@ -184,7 +184,7 @@ int main(int argc, char** argv)
}
} else if(parser.isSet("encryption-info")) {
DeviceDbusInterface dev(device);
- QDBusPendingReply<QByteArray> devReply = dev.encryptionInfo(); // QSsl::Der = 1
+ QDBusPendingReply<QString> devReply = dev.encryptionInfo(); // QSsl::Der = 1
devReply.waitForFinished();
QTextStream(stderr) << devReply.value() << endl;
} else {
diff --git a/core/backends/devicelink.h b/core/backends/devicelink.h
index 2697873..9c9b419 100644
--- a/core/backends/devicelink.h
+++ b/core/backends/devicelink.h
@@ -49,7 +49,7 @@ public:
virtual PairingHandler* createPairingHandler(Device* device) = 0;
virtual bool sendPackage(NetworkPackage& np) = 0;
- virtual bool sendPackageEncrypted(QCA::PublicKey& publicKey, NetworkPackage& np) = 0;
+ virtual bool sendPackageEncrypted(NetworkPackage& np) = 0;
ConnectionStarted connectionSource() const {
return mConnectionSource;
diff --git a/core/backends/lan/landevicelink.cpp b/core/backends/lan/landevicelink.cpp
index f2f6dc5..169ff8d 100644
--- a/core/backends/lan/landevicelink.cpp
+++ b/core/backends/lan/landevicelink.cpp
@@ -30,7 +30,6 @@
LanDeviceLink::LanDeviceLink(const QString& deviceId, LinkProvider* parent, QSslSocket* socket, ConnectionStarted connectionSource)
: DeviceLink(deviceId, parent, connectionSource)
, mSocketLineReader(new SocketLineReader(socket))
- , onSsl(false)
{
connect(mSocketLineReader, SIGNAL(readyRead()),
this, SLOT(dataReceived()));
@@ -50,26 +49,17 @@ QString LanDeviceLink::name()
return "LanLink"; // Should be same in both android and kde version
}
-void LanDeviceLink::setOnSsl(bool value)
-{
- onSsl = value;
-}
-
PairingHandler* LanDeviceLink::createPairingHandler(Device* device)
{
return new LanPairingHandler(device->id());
}
-bool LanDeviceLink::sendPackageEncrypted(QCA::PublicKey& key, NetworkPackage& np)
+bool LanDeviceLink::sendPackageEncrypted(NetworkPackage& np)
{
if (np.hasPayload()) {
np.setPayloadTransferInfo(sendPayload(np)->transferInfo());
}
- if (!onSsl) {
- np.encrypt(key);
- }
-
int written = mSocketLineReader->write(np.serialize());
//TODO: Actually detect if a package is received or not, now we keep TCP
@@ -91,10 +81,9 @@ bool LanDeviceLink::sendPackage(NetworkPackage& np)
UploadJob* LanDeviceLink::sendPayload(NetworkPackage& np)
{
QVariantMap transferInfo;
- if (onSsl) {
- transferInfo.insert("useSsl", true);
- transferInfo.insert("deviceId", deviceId());
- }
+ //FIXME: The next two lines shouldn't be needed! Why are they here?
+ transferInfo.insert("useSsl", true);
+ transferInfo.insert("deviceId", deviceId());
UploadJob* job = new UploadJob(np.payload(), deviceId());
job->start();
return job;
@@ -120,10 +109,9 @@ void LanDeviceLink::dataReceived()
if (unserialized.hasPayloadTransferInfo()) {
//qCDebug(KDECONNECT_CORE) << "HasPayloadTransferInfo";
QVariantMap transferInfo = unserialized.payloadTransferInfo();
- if (onSsl) {
- transferInfo.insert("useSsl", true);
- transferInfo.insert("deviceId", deviceId());
- }
+ //FIXME: The next two lines shouldn't be needed! Why are they here?
+ transferInfo.insert("useSsl", true);
+ transferInfo.insert("deviceId", deviceId());
DownloadJob* job = new DownloadJob(mSocketLineReader->peerAddress(), transferInfo);
job->start();
unserialized.setPayload(job->getPayload(), unserialized.payloadSize());
diff --git a/core/backends/lan/landevicelink.h b/core/backends/lan/landevicelink.h
index 271e12a..6c72fe6 100644
--- a/core/backends/lan/landevicelink.h
+++ b/core/backends/lan/landevicelink.h
@@ -39,11 +39,10 @@ public:
LanDeviceLink(const QString& deviceId, LinkProvider* parent, QSslSocket* socket, ConnectionStarted connectionSource);
virtual QString name() Q_DECL_OVERRIDE;
- void setOnSsl(bool value);
virtual PairingHandler* createPairingHandler(Device* device) Q_DECL_OVERRIDE;
bool sendPackage(NetworkPackage& np) override;
- bool sendPackageEncrypted(QCA::PublicKey& key, NetworkPackage& np) override;
- UploadJob* sendPayload(NetworkPackage&);
+ bool sendPackageEncrypted(NetworkPackage& np) override;
+ UploadJob* sendPayload(NetworkPackage& np);
private Q_SLOTS:
void dataReceived();
diff --git a/core/backends/lan/lanlinkprovider.cpp b/core/backends/lan/lanlinkprovider.cpp
index 417250c..5ff16d7 100644
--- a/core/backends/lan/lanlinkprovider.cpp
+++ b/core/backends/lan/lanlinkprovider.cpp
@@ -427,10 +427,6 @@ void LanLinkProvider::addLink(const QString& deviceId, QSslSocket* socket, Netwo
// Socket disconnection will now be handled by LanDeviceLink
disconnect(socket, SIGNAL(disconnected()), socket, SLOT(deleteLater()));
- if (socket->isEncrypted()) {
- deviceLink->setOnSsl(true);
- }
-
//We kill any possible link from this same device
QMap< QString, DeviceLink* >::iterator oldLinkIterator = mLinks.find(deviceLink->deviceId());
if (oldLinkIterator != mLinks.end()) {
diff --git a/core/backends/loopback/loopbackdevicelink.cpp b/core/backends/loopback/loopbackdevicelink.cpp
index 3cb53b5..fefaa5d 100644
--- a/core/backends/loopback/loopbackdevicelink.cpp
+++ b/core/backends/loopback/loopbackdevicelink.cpp
@@ -38,33 +38,9 @@ PairingHandler* LoopbackDeviceLink::createPairingHandler(Device *device)
{
return new LoopbackPairingHandler(device->id());
}
-bool LoopbackDeviceLink::sendPackageEncrypted(QCA::PublicKey& key, NetworkPackage& input)
+bool LoopbackDeviceLink::sendPackageEncrypted(NetworkPackage& input)
{
- if (mPrivateKey.isNull() || key.isNull()) {
- return false;
- }
-
- input.encrypt(key);
-
- QByteArray serialized = input.serialize();
-
- NetworkPackage unserialized(QString::null);
- NetworkPackage::unserialize(serialized, &unserialized);
-
- NetworkPackage output(QString::null);
- unserialized.decrypt(mPrivateKey, &output);
-
- bool b = true;
- //LoopbackDeviceLink does not need deviceTransferInfo
- if (input.hasPayload()) {
- b = input.payload()->open(QIODevice::ReadOnly);
- Q_ASSERT(b);
- output.setPayload(input.payload(), input.payloadSize());
- }
-
- Q_EMIT receivedPackage(output);
-
- return b;
+ return sendPackage(input);
}
bool LoopbackDeviceLink::sendPackage(NetworkPackage& input)
diff --git a/core/backends/loopback/loopbackdevicelink.h b/core/backends/loopback/loopbackdevicelink.h
index 3550b8f..97864e7 100644
--- a/core/backends/loopback/loopbackdevicelink.h
+++ b/core/backends/loopback/loopbackdevicelink.h
@@ -35,7 +35,7 @@ public:
virtual QString name() override;
virtual PairingHandler* createPairingHandler(Device* device) override;
virtual bool sendPackage(NetworkPackage& np) override;
- virtual bool sendPackageEncrypted(QCA::PublicKey& publicKey, NetworkPackage& np) override;
+ virtual bool sendPackageEncrypted(NetworkPackage& np) override;
};
diff --git a/core/backends/pairinghandler.cpp b/core/backends/pairinghandler.cpp
index 0d77263..2633f53 100644
--- a/core/backends/pairinghandler.cpp
+++ b/core/backends/pairinghandler.cpp
@@ -21,17 +21,22 @@
#include "pairinghandler.h"
PairingHandler::PairingHandler()
- : m_pairStatus(NotPaired)
- , m_deviceLink(nullptr)
+ : m_deviceLink(nullptr)
+ , m_pairStatus(NotPaired)
{
}
-void PairingHandler::setLink(DeviceLink *dl)
+void PairingHandler::setDeviceLink(DeviceLink *dl)
{
m_deviceLink = dl;
}
+DeviceLink* PairingHandler::deviceLink() const
+{
+ return m_deviceLink;
+}
+
void PairingHandler::linkDestroyed(QObject* o)
{
DeviceLink* dl = static_cast<DeviceLink*>(o);
@@ -49,3 +54,9 @@ void PairingHandler::setPairStatus(PairingHandler::PairStatus status)
Q_EMIT pairStatusChanged(status, oldStatus);
}
}
+
+PairingHandler::PairStatus PairingHandler::pairStatus() const
+{
+ return m_pairStatus;
+}
+
diff --git a/core/backends/pairinghandler.h b/core/backends/pairinghandler.h
index 4edc6c5..0caf5c8 100644
--- a/core/backends/pairinghandler.h
+++ b/core/backends/pairinghandler.h
@@ -54,7 +54,7 @@ public:
PairingHandler();
virtual ~PairingHandler() { }
- void setLink(DeviceLink* dl);
+ void setDeviceLink(DeviceLink* dl);
bool isPaired() const { return m_pairStatus == PairStatus::Paired; }
bool isPairRequested() const { return m_pairStatus == PairStatus::Requested; }
diff --git a/core/device.cpp b/core/device.cpp
index bf42d4a..a37e8eb 100644
--- a/core/device.cpp
+++ b/core/device.cpp
@@ -34,6 +34,7 @@
#include <QIcon>
#include <QDir>
#include <QJsonArray>
+#include <qstringbuilder.h>
#include "core_debug.h"
#include "kdeconnectplugin.h"
@@ -288,7 +289,7 @@ void Device::addLink(const NetworkPackage& identityPackage, DeviceLink* link)
connect(m_pairingHandlers[link->name()], SIGNAL(pairStatusChanged(PairStatus, PairStatus)), this, SLOT(pairStatusChanged(PairStatus, PairStatus)));
connect(m_pairingHandlers[link->name()], SIGNAL(pairingFailed(const QString&)), this, SIGNAL(pairingFailed(const QString&)));
}
- m_pairingHandlers[link->name()]->setLink(link);
+ m_pairingHandlers[link->name()]->setDeviceLink(link);
connect(link, SIGNAL(destroyed(QObject*)), m_pairingHandlers[link->name()], SLOT(linkDestroyed(QObject*)));
}
@@ -320,7 +321,7 @@ bool Device::sendPackage(NetworkPackage& np)
{
if (np.type() != PACKAGE_TYPE_PAIR && isPaired()) {
Q_FOREACH(DeviceLink* dl, m_deviceLinks) {
- if (dl->sendPackageEncrypted(m_publicKey, np)) return true;
+ if (dl->sendPackageEncrypted(np)) return true;
}
} else {
//Maybe we could block here any package that is not an identity or a pairing package to prevent sending non encrypted data
@@ -366,8 +367,6 @@ void Device::rejectPairing()
{
qCDebug(KDECONNECT_CORE) << "Rejected pairing";
- m_pairStatus = PairingHandler::NotPaired;
-
Q_FOREACH(PairingHandler* ph, m_pairingHandlers.values()) {
ph->rejectPairing();
}
@@ -387,7 +386,8 @@ void Device::acceptPairing()
}
-void Device::isPaired() {
+bool Device::isPaired() const
+{
Q_FOREACH(PairingHandler* ph, m_pairingHandlers) {
if (ph->isPaired()) return true;
}
@@ -466,9 +466,9 @@ void Device::setName(const QString &name)
}
}
-Device::PairStatus Device::pairStatus() const
+PairingHandler::PairStatus Device::pairStatus() const
{
- return m_pairStatus;
+ return isPaired()? PairingHandler::Paired : PairingHandler::NotPaired;
}
KdeConnectPlugin* Device::plugin(const QString& pluginName) const
@@ -499,17 +499,17 @@ QString Device::encryptionInfo() const
{
QString result;
- QByteArray myCertificate = KdeConnectConfig::instance()->certificate().toDer();
+ QString myCertificate = QString::fromLatin1(KdeConnectConfig::instance()->certificate().toDer());
for (int i=2 ; i<myCertificate.size() ; i+=3) {
myCertificate.insert(i, ':'); // Improve readability
}
- result += i18n("SHA1 fingerprint of your device certificate is : ") + myCertificate + endl;
+ result += i18n("SHA1 fingerprint of your device certificate is: ") + myCertificate + "
";
QString remoteCertificate = KdeConnectConfig::instance()->getDeviceProperty(id(), "certificate");
for (int i=2 ; i<remoteCertificate.size() ; i+=3) {
remoteCertificate.insert(i, ':'); // Improve readability
}
- result += i18n("SHA1 fingerprint of remote device certificate is : ") << remoteCertificate << endl;
+ result += i18n("SHA1 fingerprint of remote device certificate is: ") + remoteCertificate + "
";
return result;
}
diff --git a/core/device.h b/core/device.h
index 80100a9..26fc97d 100644
--- a/core/device.h
+++ b/core/device.h
@@ -83,7 +83,7 @@ public:
QString iconName() const;
QString statusIconName() const;
QStringList unsupportedPlugins() const { return m_unsupportedPlugins; }
- QString encryptionInfo() const;
+ Q_SCRIPTABLE QString encryptionInfo() const;
//Add and remove links
void addLink(const NetworkPackage& identityPackage, DeviceLink*);
diff --git a/kcm/kcm.cpp b/kcm/kcm.cpp
index 444477c..cae6cdc 100644
--- a/kcm/kcm.cpp
+++ b/kcm/kcm.cpp
@@ -286,7 +286,7 @@ void KdeConnectKcm::pairingChanged(bool paired)
kcmUi->pair_button->setVisible(!paired);
kcmUi->unpair_button->setVisible(paired);
- kcmUi->progressBar->setVisible(senderDevice->pairRequested());
+ kcmUi->progressBar->setVisible(senderDevice->isPairRequested());
kcmUi->ping_button->setVisible(paired);
kcmUi->status_label->setText(paired ? i18n("(paired)") : i18n("(unpaired)"));
}
diff --git a/tests/devicetest.cpp b/tests/devicetest.cpp
index 82bccd6..f7b9d27 100644
--- a/tests/devicetest.cpp
+++ b/tests/devicetest.cpp
@@ -18,6 +18,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
+#include "../core/device.h"
#include "../core/backends/lan/lanlinkprovider.h"
#include "../core/kdeconnectconfig.h"
@@ -68,15 +69,8 @@ void DeviceTest::testPairedDevice()
QCOMPARE(device.name(), deviceName);
QCOMPARE(device.type(), deviceType);
- QVERIFY2(!device.publicKey().isNull(), "Public key for device is null");
- QCOMPARE(device.publicKey(), kcc->publicKey());
-
- QVERIFY2(device.certificate().isNull(), "Certificate should be null before initialisation");
-
- // TODO : Set certificate via identity package
-
QCOMPARE(device.isPaired(), true);
- QCOMPARE(device.pairRequested(), false);
+ QCOMPARE(device.isPairRequested(), false);
QCOMPARE(device.isReachable(), false);
@@ -112,11 +106,8 @@ void DeviceTest::testUnpairedDevice()
QCOMPARE(device.name(), deviceName);
QCOMPARE(device.type(), deviceType);
- QVERIFY2(device.publicKey().isNull(), "Public key for unpaired device should be null");
- QVERIFY2(device.certificate().isNull(), "Certificate for unpaired device should be null");
-
QCOMPARE(device.isPaired(), false);
- QCOMPARE(device.pairRequested(), false);
+ QCOMPARE(device.isPairRequested(), false);
QCOMPARE(device.isReachable(), true);
QCOMPARE(device.availableLinks().contains(linkProvider.name()), true);
diff --git a/tests/kdeconnectconfigtest.cpp b/tests/kdeconnectconfigtest.cpp
index b928f1a..6ed8a1d 100644
--- a/tests/kdeconnectconfigtest.cpp
+++ b/tests/kdeconnectconfigtest.cpp
@@ -34,9 +34,9 @@ Q_OBJECT
private Q_SLOTS:
void initTestCase();
void addTrustedDevice();
-
+/*
void remoteCertificateTest();
-
+*/
void removeTrustedDevice();
private:
@@ -46,13 +46,6 @@ private:
void KdeConnectConfigTest::initTestCase()
{
kcc = KdeConnectConfig::instance();
-
- QVERIFY2(!kcc->publicKey().isNull(), "Public key not generated, is null");
- QVERIFY2(!kcc->privateKey().isNull(), "Private key not generated, is null");
- QVERIFY2(!kcc->certificate().isNull(), "Certificate not generated, is null");
- QVERIFY2(QFile::exists(kcc->privateKeyPath()), "Private key file does not exists, private key not saved properly");
- QVERIFY2(QFile::exists(kcc->certificatePath()), "Certificate file does not exists, certificate not saved properly");
-
}
void KdeConnectConfigTest::addTrustedDevice()
@@ -63,6 +56,7 @@ void KdeConnectConfigTest::addTrustedDevice()
QCOMPARE(devInfo.deviceType, QString("phone"));
}
+/*
// This checks whether certificate is generated correctly and stored correctly or not
void KdeConnectConfigTest::remoteCertificateTest()
{
@@ -84,6 +78,7 @@ void KdeConnectConfigTest::remoteCertificateTest()
QCOMPARE(devCertificate.subjectInfo(QSslCertificate::OrganizationalUnitName).first(), QString("Kde connect"));
}
+*/
void KdeConnectConfigTest::removeTrustedDevice()
diff --git a/tests/lanlinkprovidertest.cpp b/tests/lanlinkprovidertest.cpp
index 10fba97..965adc1 100644
--- a/tests/lanlinkprovidertest.cpp
+++ b/tests/lanlinkprovidertest.cpp
@@ -29,6 +29,7 @@
#include <QAbstractSocket>
#include <QSslSocket>
#include <QtTest>
+#include <QSslKey>
#include <QUdpSocket>
/*
@@ -322,11 +323,10 @@ QSslCertificate LanLinkProviderTest::generateCertificate(QString& commonName, QC
return certificate;
}
-void LanLinkProviderTest::setSocketAttributes(QSslSocket *socket) {
-
+void LanLinkProviderTest::setSocketAttributes(QSslSocket *socket)
+{
socket->setPrivateKey(QSslKey(privateKey.toPEM().toLatin1(), QSsl::Rsa));
socket->setLocalCertificate(certificate);
-
}
void LanLinkProviderTest::addTrustedDevice()
--
kdeconnect packaging
More information about the pkg-kde-commits
mailing list