Commit 13dcd018 authored by Albert Vaca Cintora's avatar Albert Vaca Cintora

Added some comments and todos

parent 2625150b
...@@ -30,12 +30,11 @@ LoopbackDeviceLink::LoopbackDeviceLink(const QString& deviceId, LoopbackLinkProv ...@@ -30,12 +30,11 @@ LoopbackDeviceLink::LoopbackDeviceLink(const QString& deviceId, LoopbackLinkProv
bool LoopbackDeviceLink::sendPackage(const NetworkPackage& input) bool LoopbackDeviceLink::sendPackage(const NetworkPackage& input)
{ {
qDebug() << "loopbacksendpackage";
NetworkPackage output(""); NetworkPackage output("");
NetworkPackage::unserialize(input.serialize(), &output); NetworkPackage::unserialize(input.serialize(), &output);
//LoopbackDeviceLink does not need deviceTransferInfo
if (input.hasPayload()) { if (input.hasPayload()) {
//Loopback does not need payloadTransferInfo
QIODevice* device = input.payload(); QIODevice* device = input.payload();
device->open(QIODevice::ReadOnly); device->open(QIODevice::ReadOnly);
output.setPayload(device); output.setPayload(device);
......
...@@ -44,7 +44,6 @@ NetworkPackage::NetworkPackage(const QString& type) ...@@ -44,7 +44,6 @@ NetworkPackage::NetworkPackage(const QString& type)
mPayload = 0; mPayload = 0;
} }
void NetworkPackage::createIdentityPackage(NetworkPackage* np) void NetworkPackage::createIdentityPackage(NetworkPackage* np)
{ {
KSharedConfigPtr config = KSharedConfig::openConfig("kdeconnectrc"); KSharedConfigPtr config = KSharedConfig::openConfig("kdeconnectrc");
...@@ -69,6 +68,7 @@ QByteArray NetworkPackage::serialize() const ...@@ -69,6 +68,7 @@ QByteArray NetworkPackage::serialize() const
QVariantMap variant = QJson::QObjectHelper::qobject2qvariant(this); QVariantMap variant = QJson::QObjectHelper::qobject2qvariant(this);
if (hasPayload()) { if (hasPayload()) {
//qDebug() << "Serializing payloadTransferInfo";
variant["payloadTransferInfo"] = mPayloadTransferInfo; variant["payloadTransferInfo"] = mPayloadTransferInfo;
} }
...@@ -103,6 +103,7 @@ bool NetworkPackage::unserialize(const QByteArray& a, NetworkPackage* np) ...@@ -103,6 +103,7 @@ bool NetworkPackage::unserialize(const QByteArray& a, NetworkPackage* np)
QJson::QObjectHelper::qvariant2qobject(variant,np); QJson::QObjectHelper::qvariant2qobject(variant,np);
if (variant.contains("payloadTransferInfo")) { if (variant.contains("payloadTransferInfo")) {
//qDebug() << "Unserializing payloadTransferInfo";
np->mPayloadTransferInfo = variant["payloadTransferInfo"].toMap(); np->mPayloadTransferInfo = variant["payloadTransferInfo"].toMap();
} }
...@@ -110,9 +111,10 @@ bool NetworkPackage::unserialize(const QByteArray& a, NetworkPackage* np) ...@@ -110,9 +111,10 @@ bool NetworkPackage::unserialize(const QByteArray& a, NetworkPackage* np)
} }
void NetworkPackage::encrypt (QCA::PublicKey& key) void NetworkPackage::encrypt(QCA::PublicKey& key)
{ {
//TODO: Implement payload encryption somehow (create an intermediate iodevice to encrypt the payload here?)
QByteArray serialized = serialize(); QByteArray serialized = serialize();
int chunkSize = key.maximumEncryptSize(NetworkPackage::EncryptionAlgorithm); int chunkSize = key.maximumEncryptSize(NetworkPackage::EncryptionAlgorithm);
...@@ -134,8 +136,9 @@ void NetworkPackage::encrypt (QCA::PublicKey& key) ...@@ -134,8 +136,9 @@ void NetworkPackage::encrypt (QCA::PublicKey& key)
} }
bool NetworkPackage::decrypt (QCA::PrivateKey& key, NetworkPackage* out) const bool NetworkPackage::decrypt(QCA::PrivateKey& key, NetworkPackage* out) const
{ {
const QStringList& chunks = mBody["data"].toStringList(); const QStringList& chunks = mBody["data"].toStringList();
QByteArray decryptedJson; QByteArray decryptedJson;
...@@ -147,7 +150,11 @@ bool NetworkPackage::decrypt (QCA::PrivateKey& key, NetworkPackage* out) const ...@@ -147,7 +150,11 @@ bool NetworkPackage::decrypt (QCA::PrivateKey& key, NetworkPackage* out) const
return false; return false;
} }
decryptedJson.append(decryptedChunk.toByteArray()); decryptedJson.append(decryptedChunk.toByteArray());
}
//TODO: Implement payload encryption somehow (create an intermediate iodevice to decrypt the payload here?)
if (hasPayload()) {
out->setPayload(mPayload);
} }
return unserialize(decryptedJson, out); return unserialize(decryptedJson, out);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment