M module-apps/application-desktop/data/LockPhoneData.hpp => module-apps/application-desktop/data/LockPhoneData.hpp +7 -6
@@ 48,7 48,7 @@ namespace gui
};
};
- class UpdateSwitchData : public gui::SwitchData
+ class UpdateSwitchData : public gui::SwitchData
{
public:
UpdateSwitchData(sdesktop::UpdateOsMessage *messageToCopyFrom) : updateOsMessage(*messageToCopyFrom)
@@ 58,12 58,13 @@ namespace gui
return updateOsMessage;
}
- const sdesktop::UpdateOsMessage &getUpdateOsMessage()
- {
- return updateOsMessage;
- }
+ const sdesktop::UpdateOsMessage &getUpdateOsMessage()
+ {
+ return updateOsMessage;
+ }
+
private:
- sdesktop::UpdateOsMessage updateOsMessage;
+ sdesktop::UpdateOsMessage updateOsMessage;
};
} // namespace gui
M module-apps/application-desktop/windows/Update.cpp => module-apps/application-desktop/windows/Update.cpp +18 -15
@@ 50,7 50,7 @@ namespace gui
titleLabel->setFilled(false);
titleLabel->setBorderColor(gui::ColorFullBlack);
titleLabel->setFont(style::header::font::title);
- titleLabel->setEdges(RectangleEdgeFlags::GUI_RECT_EDGE_NO_EDGES);
+ titleLabel->setEdges(RectangleEdge::None);
titleLabel->setAlignment(gui::Alignment(gui::Alignment::Horizontal::Center, gui::Alignment::Vertical::Top));
titleLabel->setText(utils::localize.get("app_desktop_update"));
@@ 59,7 59,7 @@ namespace gui
updateVersionInfo->setFilled(false);
updateVersionInfo->setBorderColor(gui::ColorFullBlack);
updateVersionInfo->setFont(style::window::font::smallbold);
- updateVersionInfo->setEdges(RectangleEdgeFlags::GUI_RECT_EDGE_NO_EDGES);
+ updateVersionInfo->setEdges(RectangleEdge::None);
updateVersionInfo->setAlignment(
gui::Alignment(gui::Alignment::Horizontal::Left, gui::Alignment::Vertical::Top));
updateVersionInfo->setText(utils::localize.get("app_desktop_update"));
@@ 69,7 69,7 @@ namespace gui
updateDetails->setFilled(false);
updateDetails->setBorderColor(gui::ColorFullBlack);
updateDetails->setFont(style::window::font::verysmall);
- updateDetails->setEdges(RectangleEdgeFlags::GUI_RECT_EDGE_NO_EDGES);
+ updateDetails->setEdges(RectangleEdge::None);
updateDetails->setAlignment(gui::Alignment(gui::Alignment::Horizontal::Left, gui::Alignment::Vertical::Top));
updateDetails->setText(utils::localize.get("app_desktop_update"));
@@ 78,7 78,7 @@ namespace gui
currentVersionInfo->setFilled(false);
currentVersionInfo->setBorderColor(gui::ColorFullBlack);
currentVersionInfo->setFont(style::window::font::small);
- currentVersionInfo->setEdges(RectangleEdgeFlags::GUI_RECT_EDGE_NO_EDGES);
+ currentVersionInfo->setEdges(RectangleEdge::None);
currentVersionInfo->setAlignment(
gui::Alignment(gui::Alignment::Horizontal::Left, gui::Alignment::Vertical::Top));
currentVersionInfo->setText(utils::localize.get("app_desktop_update_current"));
@@ 103,7 103,8 @@ namespace gui
percentLabel->setFilled(false);
percentLabel->setBorderColor(gui::ColorNoColor);
percentLabel->setFont(style::window::font::largelight);
- percentLabel->setAlignment(gui::Alignment(gui::Alignment::Horizontal::Center, gui::Alignment::Vertical::Bottom));
+ percentLabel->setAlignment(
+ gui::Alignment(gui::Alignment::Horizontal::Center, gui::Alignment::Vertical::Bottom));
percentLabel->setVisible(false);
uint32_t pinLabelX = 46;
@@ 116,7 117,7 @@ namespace gui
label->setPenFocusWidth(2);
label->setRadius(5);
label->setFont(style::window::font::medium);
- label->setEdges(RectangleEdgeFlags::GUI_RECT_ALL_EDGES);
+ label->setEdges(RectangleEdge::All);
label->setAlignment(gui::Alignment(gui::Alignment::Horizontal::Center, gui::Alignment::Vertical::Center));
selectionLabels.push_back(label);
pinLabelX += 193;
@@ 133,15 134,15 @@ namespace gui
// callbacks for getting focus
selectionLabels[0]->focusChangedCallback = [=](gui::Item &item) {
- if (item.focus)
- this->state = State::Return;
- return true;
+ if (item.focus)
+ this->state = State::Return;
+ return true;
};
selectionLabels[1]->focusChangedCallback = [=](gui::Item &item) {
- if (item.focus)
- this->state = State::UpdateNow;
- return true;
+ if (item.focus)
+ this->state = State::UpdateNow;
+ return true;
};
}
void UpdateWindow::destroyInterface()
@@ 153,7 154,8 @@ namespace gui
{
if (data == nullptr) {
LOG_ERROR("Received null pointer");
- } else {
+ }
+ else {
gui::UpdateSwitchData *item = dynamic_cast<gui::UpdateSwitchData *>(data);
if (item != nullptr) {
std::stringstream currentVersion;
@@ 223,7 225,7 @@ namespace gui
percentLabel->setVisible(true);
percentLabel->setText(utils::localize.get("app_desktop_update_start"));
auto msgToSend = std::make_shared<sdesktop::UpdateOsMessage>(updateFile.c_str(), 0);
- sys::Bus::SendUnicast (msgToSend, service::name::service_desktop, application);
+ sys::Bus::SendUnicast(msgToSend, service::name::service_desktop, application);
return true;
}
@@ 253,7 255,8 @@ namespace gui
ssi << " %";
percentLabel->setText(ssi.str());
infoLabel->setText(item->getUpdateOsMessage().updateStats.messageText);
- } else if (item->getUpdateOsMessage().updateStats.messageText != "") {
+ }
+ else if (item->getUpdateOsMessage().updateStats.messageText != "") {
percentLabel->setText(item->getUpdateOsMessage().updateStats.messageText);
}
M module-apps/application-desktop/windows/Update.hpp => module-apps/application-desktop/windows/Update.hpp +9 -8
@@ 18,18 18,19 @@ namespace gui
Return,
};
- gui::Label *titleLabel = nullptr;
- gui::Label *infoLabel = nullptr;
- gui::Label *detailLabel = nullptr;
- gui::Label *percentLabel = nullptr;
+ gui::Label *titleLabel = nullptr;
+ gui::Label *infoLabel = nullptr;
+ gui::Label *detailLabel = nullptr;
+ gui::Label *percentLabel = nullptr;
- gui::Label *currentVersionInfo = nullptr;
- gui::Label *updateVersionInfo = nullptr;
- gui::Label *updateDetails = nullptr;
+ gui::Label *currentVersionInfo = nullptr;
+ gui::Label *updateVersionInfo = nullptr;
+ gui::Label *updateDetails = nullptr;
std::vector<gui::Label *> selectionLabels;
- State state = State::Return;
+ State state = State::Return;
int progressPercent = 0;
+
public:
UpdateWindow(app::Application *app);
void onBeforeShow(ShowMode mode, SwitchData *data) override;
M module-services/service-desktop/ServiceDesktop.cpp => module-services/service-desktop/ServiceDesktop.cpp +7 -8
@@ 54,15 54,14 @@ sys::ReturnCodes ServiceDesktop::InitHandler()
});
connect(sdesktop::UpdateOsMessage(), [&](sys::DataMessage *msg, sys::ResponseMessage *resp) {
- sdesktop::UpdateOsMessage *updateOsMsg = dynamic_cast<sdesktop::UpdateOsMessage *>(msg);
+ sdesktop::UpdateOsMessage *updateOsMsg = dynamic_cast<sdesktop::UpdateOsMessage *>(msg);
if (updateOsMsg != nullptr &&
updateOsMsg->messageType == updateos::UpdateMessageType::UpdateCheckForUpdateOnce) {
fs::path file = UpdatePureOS::checkForUpdate();
- if (file.has_filename()) {
- /* send info to applicationDesktop that there is an update waiting */
-
+ if (file.has_filename()) {
+ /* send info to applicationDesktop that there is an update waiting */
auto msgToSend =
std::make_shared<sdesktop::UpdateOsMessage>(updateos::UpdateMessageType::UpdateFoundOnBoot, file);
msgToSend->updateStats.versioInformation = UpdatePureOS::getVersionInfoFromFile(file);
@@ 75,10 74,10 @@ sys::ReturnCodes ServiceDesktop::InitHandler()
updateOsMsg->updateStats.updateFile.c_str(),
updateOsMsg->updateStats.uuid);
- if (updateOS->setUpdateFile(updateOsMsg->updateStats.updateFile) == updateos::UpdateError::NoError)
- updateOS->runUpdate(updateOsMsg->rebootDelay);
- }
- return std::make_shared<sys::ResponseMessage>();
+ if (updateOS->setUpdateFile(updateOsMsg->updateStats.updateFile) == updateos::UpdateError::NoError)
+ updateOS->runUpdate();
+ }
+ return std::make_shared<sys::ResponseMessage>();
});
vfs.updateTimestamp();
M module-services/service-desktop/endpoints/update/UpdatePureOS.cpp => module-services/service-desktop/endpoints/update/UpdatePureOS.cpp +31 -31
@@ 51,7 51,7 @@ updateos::UpdateError UpdatePureOS::setUpdateFile(fs::path updateFileToUse)
return updateos::UpdateError::NoError;
}
-updateos::UpdateError UpdatePureOS::runUpdate(const int resetDelay)
+updateos::UpdateError UpdatePureOS::runUpdate()
{
informDebug("Prepraring temp dir");
@@ 101,15 101,13 @@ updateos::UpdateError UpdatePureOS::runUpdate(const int resetDelay)
informError("Can't prepare root dir for reset");
}
- if ( (err = cleanupAfterUpdate()) == updateos::UpdateError::NoError) {
- if (resetDelay == -1)
- return err;
-
- if (resetDelay >= 0) { // no resetDelay implementation for now
- sys::SystemManager::Reboot(owner);
- }
+ if ((err = cleanupAfterUpdate()) != updateos::UpdateError::NoError) {
+ informError("runUpdate cleanupAfterUpdate failed, resetting anyway");
}
+ // reboot always
+ sys::SystemManager::Reboot(owner);
+
return err;
}
@@ 223,10 221,10 @@ void UpdatePureOS::getChecksumInfo(const std::string &infoLine, std::string &fil
if (fileCRC32Long != nullptr) {
*fileCRC32Long = strtoull(fileCRC32Str.c_str(), nullptr, purefs::buffer::crc_radix);
informDebug("getChecksumInfo filePath: %s fileCRC32Str: %s fileCRC32Long: %lu fileCRC32Hex: %lX",
- filePath.c_str(),
- fileCRC32Str.c_str(),
- *fileCRC32Long,
- *fileCRC32Long);
+ filePath.c_str(),
+ fileCRC32Str.c_str(),
+ *fileCRC32Long,
+ *fileCRC32Long);
}
}
}
@@ 250,8 248,8 @@ updateos::UpdateError UpdatePureOS::prepareRoot()
if (ret != 0) {
informError("prepareRoot ff_deltree on %s caused an error %s",
- purefs::dir::os_previous.c_str(),
- vfs.lastErrnoToStr().c_str());
+ purefs::dir::os_previous.c_str(),
+ vfs.lastErrnoToStr().c_str());
}
if (vfs.isDir(purefs::dir::os_previous.c_str())) {
@@ 264,9 262,9 @@ updateos::UpdateError UpdatePureOS::prepareRoot()
if (ret != 0) {
informError("prepareRoot can't rename %s -> %s error %s",
- purefs::dir::os_current.c_str(),
- purefs::dir::os_previous.c_str(),
- vfs.lastErrnoToStr().c_str());
+ purefs::dir::os_current.c_str(),
+ purefs::dir::os_previous.c_str(),
+ vfs.lastErrnoToStr().c_str());
return updateos::UpdateError::CantRenameCurrentToPrevious;
}
@@ 276,9 274,9 @@ updateos::UpdateError UpdatePureOS::prepareRoot()
if (ret != 0) {
informError("prepareRoot can't rename %s -> %s error %s",
- updateTempDirectory.c_str(),
- purefs::dir::os_current.c_str(),
- vfs.lastErrnoToStr().c_str());
+ updateTempDirectory.c_str(),
+ purefs::dir::os_current.c_str(),
+ vfs.lastErrnoToStr().c_str());
return updateos::UpdateError::CantRenameTempToCurrent;
}
@@ 326,10 324,10 @@ bool UpdatePureOS::unpackFileToTemp(mtar_header_t &h, unsigned long *crc32)
std::unique_ptr<unsigned char[]> readBuf(new unsigned char[purefs::buffer::tar_buf]);
const fs::path fullPath = getUpdateTmpChild(h.name);
- uint32_t blocksToRead = (h.size / purefs::buffer::tar_buf) + 1;
- uint32_t sizeToRead = purefs::buffer::tar_buf;
- fileExtracted = h.name;
- fileExtractedSize = h.size;
+ uint32_t blocksToRead = (h.size / purefs::buffer::tar_buf) + 1;
+ uint32_t sizeToRead = purefs::buffer::tar_buf;
+ fileExtracted = h.name;
+ fileExtractedSize = h.size;
informUpdate("Unpack %s", fullPath.filename().c_str());
@@ 448,8 446,8 @@ updateos::UpdateError UpdatePureOS::prepareTempDirForUpdate()
informDebug("prepareTempDirForUpdate trying to create %s as tempDir", updateTempDirectory.c_str());
if (vfs.mkdir(updateTempDirectory.c_str()) != 0) {
informError("prepareTempDirForUpdate failed to create: %s error: %s",
- updateTempDirectory.c_str(),
- vfs.lastErrnoToStr().c_str());
+ updateTempDirectory.c_str(),
+ vfs.lastErrnoToStr().c_str());
return updateos::UpdateError::CantCreateUniqueTmpDir;
}
@@ 563,7 561,8 @@ bool UpdatePureOS::isUpgradeToCurrent(const std::string &versionToCompare)
const fs::path UpdatePureOS::checkForUpdate()
{
- std::vector<vfs::DirectoryEntry> fileList = vfs.listdir(purefs::dir::os_updates.c_str(), updateos::extension::update, true);
+ std::vector<vfs::DirectoryEntry> fileList =
+ vfs.listdir(purefs::dir::os_updates.c_str(), updateos::extension::update, true);
for (auto &file : fileList) {
json11::Json versionInfo = UpdatePureOS::getVersionInfoFromFile(purefs::dir::os_updates / file.fileName);
@@ 571,7 570,8 @@ const fs::path UpdatePureOS::checkForUpdate()
continue;
if (versionInfo[purefs::json::os_version][purefs::json::version_string].is_string()) {
- if (UpdatePureOS::isUpgradeToCurrent(versionInfo[purefs::json::os_version][purefs::json::version_string].string_value())) {
+ if (UpdatePureOS::isUpgradeToCurrent(
+ versionInfo[purefs::json::os_version][purefs::json::version_string].string_value())) {
return purefs::dir::os_updates / file.fileName;
}
}
@@ 590,7 590,7 @@ void UpdatePureOS::informError(const char *format, ...)
va_list argptr;
std::unique_ptr<char[]> readBuf(new char[purefs::buffer::tar_buf]);
va_start(argptr, format);
- vsnprintf (readBuf.get(), purefs::buffer::tar_buf, format, argptr);
+ vsnprintf(readBuf.get(), purefs::buffer::tar_buf, format, argptr);
va_end(argptr);
LOG_ERROR("UPDATE_ERRROR %s", readBuf.get());
@@ 606,7 606,7 @@ void UpdatePureOS::informDebug(const char *format, ...)
va_list argptr;
std::unique_ptr<char[]> readBuf(new char[purefs::buffer::tar_buf]);
va_start(argptr, format);
- vsnprintf (readBuf.get(), purefs::buffer::tar_buf, format, argptr);
+ vsnprintf(readBuf.get(), purefs::buffer::tar_buf, format, argptr);
va_end(argptr);
LOG_DEBUG("UPDATE_DEBUG %s", readBuf.get());
@@ 617,7 617,7 @@ void UpdatePureOS::informUpdate(const char *format, ...)
va_list argptr;
std::unique_ptr<char[]> readBuf(new char[purefs::buffer::tar_buf]);
va_start(argptr, format);
- vsnprintf (readBuf.get(), purefs::buffer::tar_buf, format, argptr);
+ vsnprintf(readBuf.get(), purefs::buffer::tar_buf, format, argptr);
va_end(argptr);
LOG_INFO("UPDATE_INFO %s", readBuf.get());
M module-services/service-desktop/endpoints/update/UpdatePureOS.hpp => module-services/service-desktop/endpoints/update/UpdatePureOS.hpp +1 -1
@@ 106,7 106,7 @@ class UpdatePureOS : public updateos::UpdateStats
public:
UpdatePureOS(ServiceDesktop *ownerService);
- updateos::UpdateError runUpdate(const int resetDelay);
+ updateos::UpdateError runUpdate();
updateos::UpdateError prepareTempDirForUpdate();
updateos::UpdateError unpackUpdate();
updateos::UpdateError verifyChecksums();
M module-services/service-desktop/messages/DesktopMessages.hpp => module-services/service-desktop/messages/DesktopMessages.hpp +8 -8
@@ 9,15 9,16 @@ namespace sdesktop
{
class UpdateOsMessage : public sys::DataMessage
{
- public:
+ public:
UpdateOsMessage(const std::string updateFilePath, const uint32_t requestUUID)
- : sys::DataMessage(MessageType::UpdateOS)
- {
- updateStats.updateFile = updateFilePath;
- updateStats.uuid = requestUUID;
- };
+ : sys::DataMessage(MessageType::UpdateOS)
+ {
+ updateStats.updateFile = updateFilePath;
+ updateStats.uuid = requestUUID;
+ };
- UpdateOsMessage() : sys::DataMessage(MessageType::UpdateOS) {}
+ UpdateOsMessage() : sys::DataMessage(MessageType::UpdateOS)
+ {}
UpdateOsMessage(const updateos::UpdateMessageType updateMessageType)
: sys::DataMessage(MessageType::UpdateOS), messageType(updateMessageType)
@@ 33,7 34,6 @@ namespace sdesktop
updateos::UpdateStats updateStats = {};
updateos::UpdateMessageType messageType = updateos::UpdateMessageType::UpdateNow;
- int rebootDelay = 0;
};
class BackupMessage : public sys::DataMessage