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

Added some comments and todos

parent 2625150b
......@@ -7,4 +7,4 @@ set(kded_kdeconnect_SRCS
#landevicelinktransfer.cpp
PARENT_SCOPE
)
\ No newline at end of file
)
......@@ -6,4 +6,4 @@ set(kded_kdeconnect_SRCS
backends/loopback/loopbackdevicelink.cpp
PARENT_SCOPE
)
\ No newline at end of file
)
......@@ -30,12 +30,11 @@ LoopbackDeviceLink::LoopbackDeviceLink(const QString& deviceId, LoopbackLinkProv
bool LoopbackDeviceLink::sendPackage(const NetworkPackage& input)
{
qDebug() << "loopbacksendpackage";
NetworkPackage output("");
NetworkPackage::unserialize(input.serialize(), &output);
//LoopbackDeviceLink does not need deviceTransferInfo
if (input.hasPayload()) {
//Loopback does not need payloadTransferInfo
QIODevice* device = input.payload();
device->open(QIODevice::ReadOnly);
output.setPayload(device);
......
......@@ -44,7 +44,6 @@ NetworkPackage::NetworkPackage(const QString& type)
mPayload = 0;
}
void NetworkPackage::createIdentityPackage(NetworkPackage* np)
{
KSharedConfigPtr config = KSharedConfig::openConfig("kdeconnectrc");
......@@ -69,6 +68,7 @@ QByteArray NetworkPackage::serialize() const
QVariantMap variant = QJson::QObjectHelper::qobject2qvariant(this);
if (hasPayload()) {
//qDebug() << "Serializing payloadTransferInfo";
variant["payloadTransferInfo"] = mPayloadTransferInfo;
}
......@@ -103,6 +103,7 @@ bool NetworkPackage::unserialize(const QByteArray& a, NetworkPackage* np)
QJson::QObjectHelper::qvariant2qobject(variant,np);
if (variant.contains("payloadTransferInfo")) {
//qDebug() << "Unserializing payloadTransferInfo";
np->mPayloadTransferInfo = variant["payloadTransferInfo"].toMap();
}
......@@ -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();
int chunkSize = key.maximumEncryptSize(NetworkPackage::EncryptionAlgorithm);
......@@ -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();
QByteArray decryptedJson;
......@@ -147,7 +150,11 @@ bool NetworkPackage::decrypt (QCA::PrivateKey& key, NetworkPackage* out) const
return false;
}
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);
......
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