From 05011ecce5da659f36a0abea79f1a96d24703801 Mon Sep 17 00:00:00 2001 From: Andrew Branson Date: Sat, 28 Nov 2015 23:49:17 +0100 Subject: Support Pebble apps with workers Separate upload for 'worker' binaries. Split binary upload type into firmware, application and worker, as the 'type' field states 'worker' for applications with worker binaries. Fixes #34 --- daemon/bankmanager.cpp | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) (limited to 'daemon/bankmanager.cpp') diff --git a/daemon/bankmanager.cpp b/daemon/bankmanager.cpp index ef74ef6..797d7e3 100644 --- a/daemon/bankmanager.cpp +++ b/daemon/bankmanager.cpp @@ -80,7 +80,7 @@ bool BankManager::uploadApp(const QUuid &uuid, int slot) qCDebug(l) << "about to install app" << info.shortName() << "into slot" << slot; - QSharedPointer binaryFile(info.openFile(AppInfo::BINARY)); + QSharedPointer binaryFile(info.openFile(AppInfo::APPLICATION)); if (!binaryFile) { qCWarning(l) << "failed to open" << info.shortName() << "AppInfo::BINARY"; return false; @@ -93,11 +93,26 @@ bool BankManager::uploadApp(const QUuid &uuid, int slot) _slots[slot].name.clear(); _slots[slot].uuid = QUuid(); - upload->uploadAppBinary(slot, binaryFile.data(), info.crcFile(AppInfo::BINARY), + upload->uploadAppBinary(slot, binaryFile.data(), info.crcFile(AppInfo::APPLICATION), [this, info, binaryFile, slot]() { qCDebug(l) << "app binary upload succesful"; binaryFile->close(); + // Upload worker if present + if (info.type() == "worker") { + QSharedPointer workerFile(info.openFile(AppInfo::WORKER)); + if (workerFile) { + upload->uploadAppWorker(slot, workerFile.data(), info.crcFile(AppInfo::WORKER), + [this, workerFile, slot]() { + qCDebug(l) << "app worker upload succesful"; + workerFile->close(); + }, [this, workerFile](int code) { + workerFile->close(); + qCWarning(l) << "app worker upload failed" << code; + }); + } + } + // Proceed to upload the resource file QSharedPointer resourceFile(info.openFile(AppInfo::RESOURCES)); if (resourceFile) { -- cgit v1.2.3