Fixed landevice link not setting the payload to the proper package

Wrong variable name
This commit is contained in:
Albert Vaca 2013-09-18 18:35:50 +02:00
parent ddbbafab63
commit 79a55d8ec0

View file

@ -89,29 +89,31 @@ void LanDeviceLink::dataReceived()
if (package.length() < 3) continue; if (package.length() < 3) continue;
NetworkPackage np(QString::null); NetworkPackage unserialized(QString::null);
NetworkPackage::unserialize(package, &np); NetworkPackage::unserialize(package, &unserialized);
if (np.type() == PACKAGE_TYPE_ENCRYPTED) { if (unserialized.isEncrypted()) {
if (mPrivateKey.isNull()) {
//TODO: Emit the problem?
return;
}
//mPrivateKey should always be set when device link is added to device, no null-checking done here
NetworkPackage decrypted(QString::null); NetworkPackage decrypted(QString::null);
np.decrypt(mPrivateKey, &decrypted); unserialized.decrypt(mPrivateKey, &decrypted);
if (np.hasPayloadTransferInfo()) { if (decrypted.hasPayloadTransferInfo()) {
DownloadJob* job = new DownloadJob(mSocket->peerAddress(), np.payloadTransferInfo()); qDebug() << "HasPayloadTransferInfo";
DownloadJob* job = new DownloadJob(mSocket->peerAddress(), decrypted.payloadTransferInfo());
job->start(); job->start();
np.setPayload(job->getPayload()); decrypted.setPayload(job->getPayload());
} }
Q_EMIT receivedPackage(decrypted); Q_EMIT receivedPackage(decrypted);
} else { } else {
Q_EMIT receivedPackage(np); if (unserialized.hasPayloadTransferInfo()) {
//Lets ignore unencrypted payloads
}
Q_EMIT receivedPackage(unserialized);
} }