~aleteoryx/muditaos

d558e60a4d5bc26a982f0ba85f20631d7efac5df — Lefucjusz 2 years ago 85a6dba
[CP-2013] Add time sync endpoint

Added endpoint that can be used
to synchronize time via MC
protocol.
40 files changed, 312 insertions(+), 226 deletions(-)

M doc/os_api/protocol_description/common_parameters_explanation.md
M harmony_changelog.md
M module-apps/application-desktop/windows/DesktopMainWindow.cpp
M module-apps/application-desktop/windows/DesktopMainWindow.hpp
M module-apps/apps-common/ApplicationCommon.cpp
M module-services/service-desktop/DesktopMessages.cpp
M module-services/service-desktop/endpoints/BaseHelper.cpp
M module-services/service-desktop/endpoints/CMakeLists.txt
M module-services/service-desktop/endpoints/HttpEnums.cpp
M module-services/service-desktop/endpoints/bluetooth/BluetoothEndpoint.cpp
M module-services/service-desktop/endpoints/bluetooth/BluetoothEventMessages.cpp
M module-services/service-desktop/endpoints/deviceInfo/DeviceInfoEndpointCommon.cpp
M module-services/service-desktop/endpoints/factoryReset/FactoryResetEndpoint.cpp
M module-services/service-desktop/endpoints/include/endpoints/Context.hpp
M module-services/service-desktop/endpoints/include/endpoints/EndpointFactory.hpp
M module-services/service-desktop/endpoints/include/endpoints/EndpointType.hpp
M module-services/service-desktop/endpoints/include/endpoints/HttpEnums.hpp
M module-services/service-desktop/endpoints/include/endpoints/JsonKeyNames.hpp
M module-services/service-desktop/endpoints/include/endpoints/reboot/RebootHelper.hpp
A module-services/service-desktop/endpoints/include/endpoints/timeSync/TimeSyncEndpoint.hpp
A module-services/service-desktop/endpoints/include/endpoints/timeSync/TimeSyncHelper.hpp
M module-services/service-desktop/endpoints/reboot/RebootEndpoint.cpp
M module-services/service-desktop/endpoints/reboot/RebootHelper.cpp
A module-services/service-desktop/endpoints/timeSync/TimeSyncEndpoint.cpp
A module-services/service-desktop/endpoints/timeSync/TimeSyncHelper.cpp
M module-services/service-desktop/endpoints/update/UpdateEndpoint.cpp
M module-services/service-desktop/message-common/include/endpoints/message/Common.hpp
M module-services/service-desktop/parser/ParserFSM.cpp
M module-services/service-desktop/parser/ParserFSM.hpp
M module-services/service-time/AlarmMessageHandler.cpp
M module-services/service-time/ServiceTime.cpp
M module-services/service-time/ServiceTimeName.hpp
M module-services/service-time/service-time/TimeMessage.hpp
M products/BellHybrid/services/desktop/endpoints/EndpointFactoryBell.cpp
M products/BellHybrid/services/desktop/endpoints/EndpointFactoryBell.hpp
M products/PurePhone/services/desktop/endpoints/EndpointFactoryPure.cpp
M products/PurePhone/services/desktop/endpoints/calllog/CalllogEndpoint.cpp
M products/PurePhone/services/desktop/endpoints/contacts/ContactsEndpoint.cpp
M products/PurePhone/services/desktop/endpoints/messages/MessagesEndpoint.cpp
M products/PurePhone/services/desktop/endpoints/outbox/OutboxEndpoint.cpp
M doc/os_api/protocol_description/common_parameters_explanation.md => doc/os_api/protocol_description/common_parameters_explanation.md +17 -14
@@ 2,20 2,23 @@

- *endpoint* - the target endpoint
```
    invalid = 0,
    deviceInfo = 1,
    update = 2, 
    filesystemUpload = 3,
    backup = 4,
    restore = 5,
    factory = 6,
    contacts = 7,
    messages = 8,
    calllog = 9,
    calendarEvents= 10,
    developerMode = 11,
    bluetooth = 12,
    usbSecurity = 13
    Invalid = 0,
    DeviceInfo = 1,
    Update = 2, 
    FilesystemUpload = 3,
    Backup = 4,
    Restore = 5,
    Factory = 6,
    Contacts = 7,
    Messages = 8,
    Calllog = 9,
    CalendarEvents = 10,
    DeveloperMode = 11,
    Bluetooth = 12,
    UsbSecurity = 13,
    Outbox = 14,
    Reboot = 15,
    TimeSync = 16
```

- *method* - the request methods that indicate the desired action to be performed for a given resource.

M harmony_changelog.md => harmony_changelog.md +1 -0
@@ 10,6 10,7 @@
* Added versioning for private assets
* Added greetings in all languages
* Added fade in and fade out to relaxation songs
* Added time sync endpoint to be used by Mudita Center

### Changed / Improved


M module-apps/application-desktop/windows/DesktopMainWindow.cpp => module-apps/application-desktop/windows/DesktopMainWindow.cpp +2 -10
@@ 1,4 1,4 @@
// Copyright (c) 2017-2023, Mudita Sp. z.o.o. All rights reserved.
// Copyright (c) 2017-2024, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md

#include "ApplicationDesktop.hpp"


@@ 9,7 9,6 @@
#include <messages/DialogMetadataMessage.hpp>
#include <notifications/NotificationsModel.hpp>
#include <service-appmgr/Controller.hpp>
#include <service-time/TimeMessage.hpp>
#include <time/time_conversion_factory.hpp>
#include <windows/Dialog.hpp>
#include <windows/DialogMetadata.hpp>


@@ 198,13 197,6 @@ namespace gui
        };
    }

    app::ApplicationDesktop *DesktopMainWindow::getAppDesktop() const
    {
        const auto app = dynamic_cast<app::ApplicationDesktop *>(application);
        assert(app);
        return app;
    }

    RefreshModes DesktopMainWindow::updateTime()
    {
        AppWindow::updateTime();


@@ 220,4 212,4 @@ namespace gui
        return app::manager::Controller::sendAction(
            application, app::manager::actions::Dial, std::make_unique<app::EnterNumberData>(number));
    }
} /* namespace gui */
} // namespace gui

M module-apps/application-desktop/windows/DesktopMainWindow.hpp => module-apps/application-desktop/windows/DesktopMainWindow.hpp +0 -1
@@ 32,7 32,6 @@ namespace gui
        void setActiveState();
        bool processLongReleaseEvent(const InputEvent &inputEvent);
        bool processShortReleaseEvent(const InputEvent &inputEvent);
        app::ApplicationDesktop *getAppDesktop() const;

      public:
        explicit DesktopMainWindow(app::ApplicationCommon *app);

M module-apps/apps-common/ApplicationCommon.cpp => module-apps/apps-common/ApplicationCommon.cpp +3 -2
@@ 95,8 95,8 @@ namespace app
                                            gui::status_bar::Indicator::PhoneMode});

        bus.channels.push_back(sys::BusChannel::ServiceCellularNotifications);

        bus.channels.push_back(sys::BusChannel::USBNotifications);
        bus.channels.push_back(sys::BusChannel::ServiceEvtmgrNotifications);

        longPressTimer = sys::TimerFactory::createPeriodicTimer(this,
                                                                "LongPress",


@@ 360,6 360,7 @@ namespace app
        case MessageType::KBDKeyEvent:
            return handleKBDKeyEvent(msgl);
        case MessageType::EVMMinuteUpdated:
        case MessageType::EVMTimeUpdated:
            return handleMinuteUpdated(msgl);
        case MessageType::AppAction:
            return handleAction(msgl);


@@ 905,7 906,7 @@ namespace app
        /// request handle actually switches window to popup window
        auto retval = request->handle();
        if (!retval) {
            LOG_ERROR("Popup %s handling failure, please check registered blueprint!", popup);
            LOG_ERROR("Popup '%s' handling failure, please check registered blueprint!", popup);
        }

        return retval;

M module-services/service-desktop/DesktopMessages.cpp => module-services/service-desktop/DesktopMessages.cpp +5 -5
@@ 1,4 1,4 @@
// Copyright (c) 2017-2023, Mudita Sp. z.o.o. All rights reserved.
// Copyright (c) 2017-2024, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md

#include "service-desktop/DesktopMessages.hpp"


@@ 16,28 16,28 @@ namespace sdesktop
        AppFocusChangeEvent::AppFocusChangeEvent(std::string appName)
        {
            context.setResponseStatus(http::Code::OK);
            context.setEndpoint(EndpointType::developerMode);
            context.setEndpoint(EndpointType::DeveloperMode);
            context.setResponseBody(json11::Json::object{{json::developerMode::focus, appName}});
        }

        ScreenlockCheckEvent::ScreenlockCheckEvent(bool isLocked)
        {
            context.setResponseStatus(http::Code::OK);
            context.setEndpoint(EndpointType::developerMode);
            context.setEndpoint(EndpointType::DeveloperMode);
            context.setResponseBody(json11::Json::object{{json::developerMode::phoneLocked, isLocked}});
        }

        CellularStateInfoRequestEvent::CellularStateInfoRequestEvent(std::string stateStr)
        {
            context.setResponseStatus(http::Code::OK);
            context.setEndpoint(EndpointType::developerMode);
            context.setEndpoint(EndpointType::DeveloperMode);
            context.setResponseBody(json11::Json::object{{json::developerMode::cellularStateInfo, stateStr}});
        }

        CellularSleepModeInfoRequestEvent::CellularSleepModeInfoRequestEvent(bool isInSleepMode)
        {
            context.setResponseStatus(http::Code::OK);
            context.setEndpoint(EndpointType::developerMode);
            context.setEndpoint(EndpointType::DeveloperMode);
            context.setResponseBody(json11::Json::object{{json::developerMode::cellularSleepModeInfo, isInSleepMode}});
        }
    } // namespace developerMode

M module-services/service-desktop/endpoints/BaseHelper.cpp => module-services/service-desktop/endpoints/BaseHelper.cpp +5 -7
@@ 1,11 1,10 @@
// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved.
// Copyright (c) 2017-2024, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md

#include <endpoints/BaseHelper.hpp>

namespace sdesktop::endpoints
{

    auto ret() -> BaseHelper::ProcessResult
    {
        return {sent::no, std::nullopt};


@@ 35,17 34,16 @@ namespace sdesktop::endpoints
    {
        preProcess(method, context);
        switch (method) {
        case http::Method::del:
        case http::Method::Del:
            return processDelete(context);
        case http::Method::get:
        case http::Method::Get:
            return processGet(context);
        case http::Method::post:
        case http::Method::Post:
            return processPost(context);
        case http::Method::put:
        case http::Method::Put:
            return processPut(context);
        }
        postProcess(method, context);
        return {sent::no, std::nullopt};
    }

} // namespace sdesktop::endpoints

M module-services/service-desktop/endpoints/CMakeLists.txt => module-services/service-desktop/endpoints/CMakeLists.txt +4 -0
@@ 65,6 65,8 @@ target_sources(
        update/UpdateHelper.cpp
        reboot/RebootEndpoint.cpp
        reboot/RebootHelper.cpp
        timeSync/TimeSyncEndpoint.cpp
        timeSync/TimeSyncHelper.cpp
    PUBLIC
        include/endpoints/backup/BackupEndpoint.hpp
        include/endpoints/backup/BackupHelper.hpp


@@ 92,6 94,8 @@ target_sources(
        include/endpoints/update/UpdateHelper.hpp
        include/endpoints/reboot/RebootEndpoint.hpp
        include/endpoints/reboot/RebootHelper.hpp
        include/endpoints/timeSync/TimeSyncEndpoint.hpp
        include/endpoints/timeSync/TimeSyncHelper.hpp
)

target_include_directories(

M module-services/service-desktop/endpoints/HttpEnums.cpp => module-services/service-desktop/endpoints/HttpEnums.cpp +9 -10
@@ 1,4 1,4 @@
// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved.
// Copyright (c) 2017-2024, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md

#include <endpoints/HttpEnums.hpp>


@@ 7,17 7,16 @@

namespace sdesktop::endpoints::http
{

    auto isMethodValid(uint8_t method) -> bool
    auto isMethodValid(std::uint8_t method) -> bool
    {
        if (method == static_cast<uint8_t>(http::Method::get) || method == static_cast<uint8_t>(http::Method::post) ||
            method == static_cast<uint8_t>(http::Method::put) || method == static_cast<uint8_t>(http::Method::del)) {
        if (method == static_cast<std::uint8_t>(http::Method::Get) ||
            method == static_cast<std::uint8_t>(http::Method::Post) ||
            method == static_cast<std::uint8_t>(http::Method::Put) ||
            method == static_cast<std::uint8_t>(http::Method::Del)) {
            return true;
        }
        else {
            LOG_ERROR("Invalid method!");
            return false;
        }
    }

        LOG_ERROR("Invalid method!");
        return false;
    }
} // namespace sdesktop::endpoints::http

M module-services/service-desktop/endpoints/bluetooth/BluetoothEndpoint.cpp => module-services/service-desktop/endpoints/bluetooth/BluetoothEndpoint.cpp +5 -7
@@ 1,27 1,25 @@
// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved.
// Copyright (c) 2017-2024, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md

#include <endpoints/bluetooth/BluetoothEndpoint.hpp>

namespace sdesktop::endpoints
{

    auto BluetoothEndpoint::handle(Context &context) -> void
    {
        switch (context.getMethod()) {
        case http::Method::get:
        case http::Method::Get:
            helper->processGetRequest(context);
            break;
        case http::Method::post:
        case http::Method::Post:
            helper->processPostRequest(context);
            break;
        case http::Method::put:
        case http::Method::Put:
            helper->processPutRequest(context);
            break;
        case http::Method::del:
        case http::Method::Del:
            helper->processDeleteRequest(context);
            break;
        }
    }

} // namespace sdesktop::endpoints

M module-services/service-desktop/endpoints/bluetooth/BluetoothEventMessages.cpp => module-services/service-desktop/endpoints/bluetooth/BluetoothEventMessages.cpp +2 -3
@@ 1,4 1,4 @@
// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved.
// Copyright (c) 2017-2024, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md

#include <endpoints/bluetooth/BluetoothEventMessages.hpp>


@@ 8,7 8,6 @@ namespace sdesktop::bluetooth
    BluetoothEvent::BluetoothEvent()
    {
        context.setResponseStatus(endpoints::http::Code::OK);
        context.setEndpoint(endpoints::EndpointType::bluetooth);
        context.setEndpoint(endpoints::EndpointType::Bluetooth);
    }

} // namespace sdesktop::bluetooth

M module-services/service-desktop/endpoints/deviceInfo/DeviceInfoEndpointCommon.cpp => module-services/service-desktop/endpoints/deviceInfo/DeviceInfoEndpointCommon.cpp +2 -2
@@ 1,4 1,4 @@
// Copyright (c) 2017-2023, Mudita Sp. z.o.o. All rights reserved.
// Copyright (c) 2017-2024, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md

#include <endpoints/deviceInfo/DeviceInfoEndpointCommon.hpp>


@@ 12,7 12,7 @@ namespace sdesktop::endpoints
    {
        http::Code status;
        switch (context.getMethod()) {
        case http::Method::get:
        case http::Method::Get:
            status = handleGet(context);
            break;
        default:

M module-services/service-desktop/endpoints/factoryReset/FactoryResetEndpoint.cpp => module-services/service-desktop/endpoints/factoryReset/FactoryResetEndpoint.cpp +5 -14
@@ 1,4 1,4 @@
// Copyright (c) 2017-2023, Mudita Sp. z.o.o. All rights reserved.
// Copyright (c) 2017-2024, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md

#include <endpoints/factoryReset/FactoryResetEndpoint.hpp>


@@ 14,32 14,23 @@

namespace sdesktop::endpoints
{

    auto FactoryResetEndpoint::handle(Context &context) -> void
    {
        if (context.getMethod() == http::Method::post) {

        if (context.getMethod() == http::Method::Post) {
            if (context.getBody()[json::factoryReset::factoryRequest] == true) {
                auto msg = std::make_shared<sdesktop::FactoryMessage>();
                ownerServicePtr->bus.sendUnicast(msg, service::name::service_desktop);
                ownerServicePtr->bus.sendUnicast(std::move(msg), service::name::service_desktop);

                context.setResponseBody(json11::Json::object({{json::factoryReset::factoryRequest, true}}));
            }
            else {
                context.setResponseBody(json11::Json::object({{json::factoryReset::factoryRequest, false}}));
            }

            sender::putToSendQueue(context.createSimpleResponse());

            return;
        }
        else {
            context.setResponseBody(json11::Json::object({{json::factoryReset::factoryRequest, false}}));

            sender::putToSendQueue(context.createSimpleResponse());

            return;
        }
    }

        sender::putToSendQueue(context.createSimpleResponse());
    }
} // namespace sdesktop::endpoints

M module-services/service-desktop/endpoints/include/endpoints/Context.hpp => module-services/service-desktop/endpoints/include/endpoints/Context.hpp +9 -9
@@ 1,4 1,4 @@
// Copyright (c) 2017-2023, Mudita Sp. z.o.o. All rights reserved.
// Copyright (c) 2017-2024, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md

#pragma once


@@ 48,10 48,10 @@ namespace sdesktop::endpoints
                body = json11::Json();
            }
            if (static_cast<unsigned>(endpoint) > lastEndpoint) {
                endpoint = EndpointType::invalid;
                endpoint = EndpointType::Invalid;
            }
            if (method > http::Method::del) {
                method = http::Method::get;
            if (method > http::Method::Del) {
                method = http::Method::Get;
            }
        }



@@ 67,9 67,9 @@ namespace sdesktop::endpoints
        Context()
        {
            body     = json11::Json();
            endpoint = EndpointType::invalid;
            endpoint = EndpointType::Invalid;
            uuid     = invalidUuid;
            method   = http::Method::get;
            method   = http::Method::Get;
        }
        virtual ~Context() noexcept = default;



@@ 186,10 186,10 @@ namespace sdesktop::endpoints
        {
            switch (static_cast<EndpointType>(js[json::endpoint].int_value())) {
            // enable for pagination in other endpoints
            // case EndpointType::calllog:
            case EndpointType::contacts:
            // case EndpointType::Calllog:
            case EndpointType::Contacts:
                return std::make_unique<PagedContext>(js, endpoint_pageing::contactsPageSize);
            case EndpointType::messages:
            case EndpointType::Messages:
                return std::make_unique<PagedContext>(js, endpoint_pageing::messagesPageSize);
            default:
                return std::make_unique<Context>(js);

M module-services/service-desktop/endpoints/include/endpoints/EndpointFactory.hpp => module-services/service-desktop/endpoints/include/endpoints/EndpointFactory.hpp +2 -4
@@ 1,4 1,4 @@
// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved.
// Copyright (c) 2017-2024, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md

#pragma once


@@ 7,11 7,10 @@

namespace sdesktop::endpoints
{

    class EndpointFactory
    {
      protected:
        static constexpr auto Whitelist = {EndpointType::developerMode, EndpointType::usbSecurity};
        static constexpr auto whitelist = {EndpointType::DeveloperMode, EndpointType::UsbSecurity};

        EndpointFactory() = default;



@@ 22,5 21,4 @@ namespace sdesktop::endpoints

        virtual auto create(Context &context, sys::Service *ownerServicePtr) -> std::unique_ptr<Endpoint> = 0;
    };

} // namespace sdesktop::endpoints

M module-services/service-desktop/endpoints/include/endpoints/EndpointType.hpp => module-services/service-desktop/endpoints/include/endpoints/EndpointType.hpp +18 -18
@@ 1,4 1,4 @@
// Copyright (c) 2017-2023, Mudita Sp. z.o.o. All rights reserved.
// Copyright (c) 2017-2024, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md

#pragma once


@@ 7,25 7,25 @@

namespace sdesktop::endpoints
{

    enum class EndpointType
    {
        invalid = 0,
        deviceInfo,
        update,
        filesystemUpload,
        backup,
        restore,
        factory,
        contacts,
        messages,
        calllog,
        calendarEventsPlaceholder,
        developerMode,
        bluetooth,
        usbSecurity,
        outbox,
        reboot
        Invalid = 0,
        DeviceInfo,
        Update,
        FilesystemUpload,
        Backup,
        Restore,
        Factory,
        Contacts,
        Messages,
        Calllog,
        CalendarEventsPlaceholder,
        DeveloperMode,
        Bluetooth,
        UsbSecurity,
        Outbox,
        Reboot,
        TimeSync
    };

    inline constexpr auto lastEndpoint = magic_enum::enum_count<EndpointType>() - 1;

M module-services/service-desktop/endpoints/include/endpoints/HttpEnums.hpp => module-services/service-desktop/endpoints/include/endpoints/HttpEnums.hpp +7 -7
@@ 1,4 1,4 @@
// Copyright (c) 2017-2022, Mudita Sp. z.o.o. All rights reserved.
// Copyright (c) 2017-2024, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md

#pragma once


@@ 30,13 30,13 @@ namespace sdesktop::endpoints::http

    /*! Enum class for the HTTP methods.
     */
    enum class Method
    enum class Method : std::uint8_t
    {
        get = 1,
        post,
        put,
        del
        Get = 1,
        Post,
        Put,
        Del
    };

    [[nodiscard]] auto isMethodValid(uint8_t) -> bool;
    [[nodiscard]] auto isMethodValid(std::uint8_t method) -> bool;
}; // namespace sdesktop::endpoints::http

M module-services/service-desktop/endpoints/include/endpoints/JsonKeyNames.hpp => module-services/service-desktop/endpoints/include/endpoints/JsonKeyNames.hpp +4 -4
@@ 70,8 70,6 @@ namespace sdesktop::endpoints::json
        inline constexpr auto limit              = "limit";
        inline constexpr auto offset             = "offset";
        inline constexpr auto order              = "order";
        inline constexpr auto totalCount         = "totalCount";
        inline constexpr auto nextPage           = "nextPage";
        inline constexpr auto entries            = "entries";
        inline constexpr auto messageBody        = "messageBody";
        inline constexpr auto messageCount       = "messageCount";


@@ 87,8 85,6 @@ namespace sdesktop::endpoints::json
        inline constexpr auto numberID           = "numberID";
        inline constexpr auto threadID           = "threadID";
        inline constexpr auto messageSnippet     = "messageSnippet";
        inline constexpr auto unreadMessageCount = "unreadMessageCount";
        inline constexpr auto messageTemplate    = "messageTemplate";
        inline constexpr auto templateBody       = "templateBody";
        inline constexpr auto templateID         = "templateID";
    } // namespace messages


@@ 122,4 118,8 @@ namespace sdesktop::endpoints::json
        inline constexpr auto shutdown   = "shutdown";
    } // namespace reboot

    namespace timeSync
    {
        inline constexpr auto timestamp = "timestamp";
    }
} // namespace sdesktop::endpoints::json

M module-services/service-desktop/endpoints/include/endpoints/reboot/RebootHelper.hpp => module-services/service-desktop/endpoints/include/endpoints/reboot/RebootHelper.hpp +0 -2
@@ 14,7 14,5 @@ namespace sdesktop::endpoints
        {}

        auto processPost(Context &context) -> ProcessResult final;

      private:
    };
} // namespace sdesktop::endpoints

A module-services/service-desktop/endpoints/include/endpoints/timeSync/TimeSyncEndpoint.hpp => module-services/service-desktop/endpoints/include/endpoints/timeSync/TimeSyncEndpoint.hpp +25 -0
@@ 0,0 1,25 @@
// Copyright (c) 2017-2024, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md

#pragma once

#include "TimeSyncHelper.hpp"
#include <endpoints/Endpoint.hpp>

namespace sdesktop::endpoints
{
    class TimeSyncEndpoint : public Endpoint
    {
      public:
        explicit TimeSyncEndpoint(sys::Service *ownerServicePtr)
            : Endpoint(ownerServicePtr), helper(std::make_unique<TimeSyncHelper>(ownerServicePtr))
        {
            debugName = "TimeSyncEndpoint";
        }

        auto handle(Context &context) -> void override;

      private:
        const std::unique_ptr<TimeSyncHelper> helper;
    };
} // namespace sdesktop::endpoints

A module-services/service-desktop/endpoints/include/endpoints/timeSync/TimeSyncHelper.hpp => module-services/service-desktop/endpoints/include/endpoints/timeSync/TimeSyncHelper.hpp +23 -0
@@ 0,0 1,23 @@
// Copyright (c) 2017-2024, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md

#pragma once

#include <endpoints/BaseHelper.hpp>
#include <ctime>

namespace sdesktop::endpoints
{
    class TimeSyncHelper : public BaseHelper
    {
      public:
        explicit TimeSyncHelper(sys::Service *p) : BaseHelper(p)
        {}

        auto processPost(Context &context) -> ProcessResult final;

      private:
        [[nodiscard]] auto sendTimeUpdateMessage(std::time_t timestamp) const -> bool;
        auto logReceivedDateTime(std::time_t timestamp) const noexcept -> void;
    };
} // namespace sdesktop::endpoints

M module-services/service-desktop/endpoints/reboot/RebootEndpoint.cpp => module-services/service-desktop/endpoints/reboot/RebootEndpoint.cpp +0 -1
@@ 30,5 30,4 @@ namespace sdesktop::endpoints
            LOG_ERROR("Response set when we already handled response in handler");
        }
    }

} // namespace sdesktop::endpoints

M module-services/service-desktop/endpoints/reboot/RebootHelper.cpp => module-services/service-desktop/endpoints/reboot/RebootHelper.cpp +0 -4
@@ 4,15 4,12 @@
#include <endpoints/Context.hpp>
#include <endpoints/reboot/RebootHelper.hpp>
#include <endpoints/JsonKeyNames.hpp>
#include <endpoints/message/Sender.hpp>
#include <service-desktop/DesktopMessages.hpp>
#include <service-desktop/ServiceDesktop.hpp>

#include <json11.hpp>

namespace sdesktop::endpoints
{
    using sender::putToSendQueue;
    auto RebootHelper::processPost(Context &context) -> ProcessResult
    {
        const auto rebootType = context.getBody()[json::reboot::rebootType].string_value();


@@ 32,5 29,4 @@ namespace sdesktop::endpoints
        LOG_ERROR("Invalid request: %s", rebootType.c_str());
        return {sent::no, ResponseContext{.status = http::Code::BadRequest}};
    }

} // namespace sdesktop::endpoints

A module-services/service-desktop/endpoints/timeSync/TimeSyncEndpoint.cpp => module-services/service-desktop/endpoints/timeSync/TimeSyncEndpoint.cpp +32 -0
@@ 0,0 1,32 @@
// Copyright (c) 2017-2023, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md

#include <endpoints/timeSync/TimeSyncEndpoint.hpp>
#include <endpoints/message/Sender.hpp>
#include <log/log.hpp>

namespace sdesktop::endpoints
{
    auto TimeSyncEndpoint::handle(Context &context) -> void
    {
        const auto &[sent, response] = helper->process(context.getMethod(), context);

        if (sent == sent::delayed) {
            LOG_DEBUG("There is no proper delayed serving mechanism - depend on invisible context caching");
        }
        if (sent == sent::no) {
            if (not response.has_value()) {
                LOG_ERROR("Response not sent & response not created : respond with error");
                context.setResponseStatus(http::Code::NotAcceptable);
            }
            else {
                context.setResponse(response.value());
            }

            sender::putToSendQueue(context.createSimpleResponse());
        }
        if (sent == sent::yes and response.has_value()) {
            LOG_ERROR("Response set when we already handled response in handler");
        }
    }
} // namespace sdesktop::endpoints

A module-services/service-desktop/endpoints/timeSync/TimeSyncHelper.cpp => module-services/service-desktop/endpoints/timeSync/TimeSyncHelper.cpp +51 -0
@@ 0,0 1,51 @@
// Copyright (c) 2017-2024, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md

#include <endpoints/timeSync/TimeSyncHelper.hpp>
#include <endpoints/Context.hpp>
#include <endpoints/JsonKeyNames.hpp>
#include <service-time/ServiceTimeName.hpp>
#include <service-time/service-time/TimeMessage.hpp>
#include <Service/Service.hpp>
#include <log/log.hpp>

namespace sdesktop::endpoints
{
    auto TimeSyncHelper::processPost(Context &context) -> ProcessResult
    {
        const auto &jsonTimestamp = context.getBody()[json::timeSync::timestamp];

        /* Validate */
        if (!jsonTimestamp.is_number()) {
            LOG_ERROR("Timestamp data type not a number!");
            return {sent::no, ResponseContext{.status = http::Code::UnprocessableEntity}};
        }

        const auto timestamp = static_cast<std::time_t>(jsonTimestamp.number_value());
        logReceivedDateTime(timestamp);
        if (const auto success = sendTimeUpdateMessage(timestamp); !success) {
            LOG_ERROR("Failed to send time update message!");
            return {sent::no, ResponseContext{.status = http::Code::InternalServerError}};
        }

        return {sent::no, ResponseContext{.status = http::Code::OK}};
    }

    auto TimeSyncHelper::logReceivedDateTime(std::time_t timestamp) const noexcept -> void
    {
        const auto t = localtime(&timestamp);
        LOG_INFO("Received time set request: %d-%02d-%02d %02d:%02d:%02d",
                 t->tm_year + 1900,
                 t->tm_mon + 1,
                 t->tm_mday,
                 t->tm_hour,
                 t->tm_min,
                 t->tm_sec);
    }

    auto TimeSyncHelper::sendTimeUpdateMessage(std::time_t timestamp) const -> bool
    {
        auto msg = std::make_shared<stm::message::TimeChangeRequestMessage>(timestamp);
        return owner->bus.sendUnicast(std::move(msg), service::name::service_time);
    }
} // namespace sdesktop::endpoints

M module-services/service-desktop/endpoints/update/UpdateEndpoint.cpp => module-services/service-desktop/endpoints/update/UpdateEndpoint.cpp +1 -6
@@ 1,16 1,11 @@
// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved.
// Copyright (c) 2017-2023, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md

#include <endpoints/update/UpdateEndpoint.hpp>

#include <service-desktop/DesktopMessages.hpp>
#include <service-desktop/ServiceDesktop.hpp>
#include <endpoints/message/Sender.hpp>

#include <json11.hpp>

#include <memory>

namespace sdesktop::endpoints
{


M module-services/service-desktop/message-common/include/endpoints/message/Common.hpp => module-services/service-desktop/message-common/include/endpoints/message/Common.hpp +1 -2
@@ 1,4 1,4 @@
// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved.
// Copyright (c) 2017-2023, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md

#pragma once


@@ 14,7 14,6 @@ namespace sdesktop::endpoints::message
    inline constexpr auto size_header = size_length + 1;

    inline constexpr auto endpointChar = '#';
    inline constexpr auto rawDataChar  = '$';

    inline void removeHeader(std::string &msg)
    {

M module-services/service-desktop/parser/ParserFSM.cpp => module-services/service-desktop/parser/ParserFSM.cpp +6 -7
@@ 1,4 1,4 @@
// Copyright (c) 2017-2023, Mudita Sp. z.o.o. All rights reserved.
// Copyright (c) 2017-2024, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md

#include "ParserFSM.hpp"


@@ 16,16 16,15 @@ namespace
{
    constexpr auto receiveMsgTimerDelayMs = std::chrono::milliseconds{1000 * 5};
    constexpr auto parserTimerName        = "parserTimer";

} // namespace

namespace sdesktop::endpoints
{

    StateMachine::StateMachine(sys::Service *OwnerService)
        : OwnerServicePtr(OwnerService),
          parserTimer{sys::TimerFactory::createSingleShotTimer(
              OwnerService, parserTimerName, receiveMsgTimerDelayMs, [this](sys::Timer & /*timer*/) { resetParser(); })}
    StateMachine::StateMachine(sys::Service *ownerServicePtr)
        : parserTimer{sys::TimerFactory::createSingleShotTimer(
              ownerServicePtr, parserTimerName, receiveMsgTimerDelayMs, [this]([[maybe_unused]] sys::Timer &t) {
                  resetParser();
              })}
    {}

    void StateMachine::processMessage(std::string &&msg)

M module-services/service-desktop/parser/ParserFSM.hpp => module-services/service-desktop/parser/ParserFSM.hpp +3 -6
@@ 1,4 1,4 @@
// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved.
// Copyright (c) 2017-2023, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md

#pragma once


@@ 13,7 13,6 @@

namespace sdesktop::endpoints
{

    enum class State
    {
        NoMsg,


@@ 24,7 23,7 @@ namespace sdesktop::endpoints
    class StateMachine
    {
      public:
        explicit StateMachine(sys::Service *OwnerService);
        explicit StateMachine(sys::Service *ownerServicePtr);
        void processMessage(std::string &&msg);
        [[nodiscard]] auto getCurrentState() const noexcept -> State
        {


@@ 43,8 42,7 @@ namespace sdesktop::endpoints
        State state = State::NoMsg;
        std::string payload;
        std::string header;
        unsigned long payloadLength   = 0;
        sys::Service *OwnerServicePtr = nullptr;
        unsigned long payloadLength = 0;
        std::unique_ptr<MessageHandler> messageHandler;
        sys::TimerHandle parserTimer;



@@ 56,5 54,4 @@ namespace sdesktop::endpoints
        void parsePartialMessage();
        void parsePayload();
    };

} // namespace sdesktop::endpoints

M module-services/service-time/AlarmMessageHandler.cpp => module-services/service-time/AlarmMessageHandler.cpp +14 -14
@@ 26,7 26,7 @@ namespace alarms
    {
        return handleWithCallback<AlarmGetRequestMessage, AlarmGetResponseMessage, AlarmEventRecord>(
            request, [&](AlarmGetRequestMessage *request, IAlarmOperations::OnGetAlarmProcessed callback) {
                alarmOperations->getAlarm(request->id, callback);
                alarmOperations->getAlarm(request->id, std::move(callback));
            });
    }



@@ 38,7 38,7 @@ namespace alarms
                                  std::pair<AlarmEventRecord, AlarmStatus>>(
            request,
            [&](AlarmGetWithStatusRequestMessage *request, IAlarmOperations::OnGetAlarmWithStatusProcessed callback) {
                alarmOperations->getAlarmWithStatus(request->id, callback);
                alarmOperations->getAlarmWithStatus(request->id, std::move(callback));
            });
    }



@@ 47,7 47,7 @@ namespace alarms
    {
        return handleWithCallback<AlarmAddRequestMessage, AlarmAddResponseMessage, bool>(
            request, [&](AlarmAddRequestMessage *request, IAlarmOperations::OnAddAlarmProcessed callback) {
                alarmOperations->addAlarm(request->alarmEvent, callback);
                alarmOperations->addAlarm(request->alarmEvent, std::move(callback));
            });
    }



@@ 56,7 56,7 @@ namespace alarms
    {
        return handleWithCallback<AlarmUpdateRequestMessage, AlarmUpdateResponseMessage, bool>(
            request, [&](AlarmUpdateRequestMessage *request, IAlarmOperations::OnUpdateAlarmProcessed callback) {
                alarmOperations->updateAlarm(request->alarmEvent, callback);
                alarmOperations->updateAlarm(request->alarmEvent, std::move(callback));
            });
    }



@@ 65,7 65,7 @@ namespace alarms
    {
        return handleWithCallback<AlarmRemoveRequestMessage, AlarmRemoveResponseMessage, bool>(
            request, [&](AlarmRemoveRequestMessage *request, IAlarmOperations::OnRemoveAlarmProcessed callback) {
                alarmOperations->removeAlarm(request->id, callback);
                alarmOperations->removeAlarm(request->id, std::move(callback));
            });
    }



@@ 74,7 74,7 @@ namespace alarms
    {
        return handleWithCallback<AlarmToggleAllRequestMessage, AlarmToggleAllResponseMessage, bool>(
            request, [&](AlarmToggleAllRequestMessage *request, IAlarmOperations::OnToggleAllProcessed callback) {
                alarmOperations->toggleAll(request->toggle, callback);
                alarmOperations->toggleAll(request->toggle, std::move(callback));
            });
    }



@@ 98,7 98,7 @@ namespace alarms
                                  std::vector<SingleEventRecord>>(
            request,
            [&](AlarmGetNextSingleEventsRequestMessage *request, IAlarmOperations::OnGetAlarmsProcessed callback) {
                alarmOperations->getNextSingleEvents(TimePointNow(), callback);
                alarmOperations->getNextSingleEvents(TimePointNow(), std::move(callback));
            });
    }



@@ 107,7 107,7 @@ namespace alarms
    {
        return handleWithCallback<RingingAlarmTurnOffRequestMessage, RingingAlarmTurnOffResponseMessage, bool>(
            request, [&](RingingAlarmTurnOffRequestMessage *request, IAlarmOperations::OnTurnOffRingingAlarm callback) {
                alarmOperations->turnOffRingingAlarm(request->id, callback);
                alarmOperations->turnOffRingingAlarm(request->id, std::move(callback));
            });
    }



@@ 116,7 116,7 @@ namespace alarms
    {
        return handleWithCallback<TurnOffSnoozeRequestMessage, TurnOffSnoozeResponseMessage, bool>(
            request, [&](TurnOffSnoozeRequestMessage *request, IAlarmOperations::OnTurnOffRingingAlarm callback) {
                alarmOperations->turnOffSnoozedAlarm(request->id, callback);
                alarmOperations->turnOffSnoozedAlarm(request->id, std::move(callback));
            });
    }



@@ 125,7 125,7 @@ namespace alarms
    {
        return handleWithCallback<RingingAlarmSnoozeRequestMessage, RingingAlarmSnoozeResponseMessage, bool>(
            request, [&](RingingAlarmSnoozeRequestMessage *request, IAlarmOperations::OnSnoozeRingingAlarm callback) {
                alarmOperations->snoozeRingingAlarm(request->id, request->nextAlarmTime, callback);
                alarmOperations->snoozeRingingAlarm(request->id, request->nextAlarmTime, std::move(callback));
            });
    }



@@ 134,7 134,7 @@ namespace alarms
    {
        return handleWithCallback<PostponeSnoozeRequestMessage, PostponeSnoozeResponseMessage, bool>(
            request, [&](PostponeSnoozeRequestMessage *request, IAlarmOperations::OnSnoozeRingingAlarm callback) {
                alarmOperations->postponeSnooze(request->id, request->nextAlarmTime, callback);
                alarmOperations->postponeSnooze(request->id, request->nextAlarmTime, std::move(callback));
            });
    }



@@ 151,13 151,13 @@ namespace alarms
    auto AlarmMessageHandler::handleAddSnoozedAlarmCountChangeCallback(
        AlarmOperationsCommon::OnSnoozedAlarmsCountChange callback) -> void
    {
        alarmOperations->addSnoozedAlarmsCountChangeCallback(callback);
        alarmOperations->addSnoozedAlarmsCountChangeCallback(std::move(callback));
    }

    auto AlarmMessageHandler::handleAddActiveAlarmCountChangeCallback(
        AlarmOperationsCommon::OnActiveAlarmCountChange callback) -> void
    {
        alarmOperations->addActiveAlarmCountChangeCallback(callback);
        alarmOperations->addActiveAlarmCountChangeCallback(std::move(callback));
        alarmOperations->updateEventsCache(TimePointNow());
    }



@@ 168,7 168,7 @@ namespace alarms
                                  GetSnoozedAlarmsResponseMessage,
                                  std::vector<SingleEventRecord>>(
            request, [&](GetSnoozedAlarmsRequestMessage *request, IAlarmOperations::OnGetSnoozedAlarms callback) {
                alarmOperations->getSnoozedAlarms(callback);
                alarmOperations->getSnoozedAlarms(std::move(callback));
            });
    }


M module-services/service-time/ServiceTime.cpp => module-services/service-time/ServiceTime.cpp +3 -5
@@ 106,9 106,7 @@ namespace stm
            alarmMessageHandler->handleTimeUpdate(TimePointNow());
            return std::make_shared<sys::ResponseMessage>();
        }
        else {
            return std::make_shared<sys::ResponseMessage>(sys::ReturnCodes::Unresolved);
        }
        return std::make_shared<sys::ResponseMessage>(sys::ReturnCodes::Unresolved);
    }

    void ServiceTime::registerMessageHandlers()


@@ 311,12 309,12 @@ namespace stm
        stm::internal::StaticData::get().setAutomaticDateAndTime(
            utils::getNumericValue<bool>(settings->getValue(::settings::SystemProperties::automaticDateAndTimeIsOn)));
        auto dateFormat = magic_enum::enum_cast<utils::time::Locale::DateFormat>(
            utils::getNumericValue<unsigned int>(settings->getValue(::settings::SystemProperties::dateFormat)));
            utils::getNumericValue<int>(settings->getValue(::settings::SystemProperties::dateFormat)));
        if (dateFormat != std::nullopt) {
            stm::internal::StaticData::get().setDateFormat(dateFormat.value());
        }
        auto timeFormat = magic_enum::enum_cast<utils::time::Locale::TimeFormat>(
            utils::getNumericValue<unsigned int>(settings->getValue(::settings::SystemProperties::timeFormat)));
            utils::getNumericValue<int>(settings->getValue(::settings::SystemProperties::timeFormat)));
        if (timeFormat != std::nullopt) {
            stm::internal::StaticData::get().setTimeFormat(timeFormat.value());
        }

M module-services/service-time/ServiceTimeName.hpp => module-services/service-time/ServiceTimeName.hpp +1 -0
@@ 2,6 2,7 @@
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md

#pragma once

#include <string>

namespace service::name

M module-services/service-time/service-time/TimeMessage.hpp => module-services/service-time/service-time/TimeMessage.hpp +4 -4
@@ 1,4 1,4 @@
// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved.
// Copyright (c) 2017-2023, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md

#pragma once


@@ 80,16 80,16 @@ namespace stm::message
    class TimeChangeRequestMessage : public sys::DataMessage
    {
      public:
        explicit TimeChangeRequestMessage(const time_t &time)
        explicit TimeChangeRequestMessage(std::time_t time)
            : sys::DataMessage(MessageType::MessageTypeUninitialized), time(time){};

        auto getTime() -> time_t
        auto getTime() -> std::time_t
        {
            return time;
        }

      private:
        time_t time;
        const std::time_t time;
    };

    class SetAutomaticDateAndTimeRequest : public sys::DataMessage

M products/BellHybrid/services/desktop/endpoints/EndpointFactoryBell.cpp => products/BellHybrid/services/desktop/endpoints/EndpointFactoryBell.cpp +11 -12
@@ 11,36 11,35 @@
#include <endpoints/restore/RestoreEndpoint.hpp>
#include <endpoints/update/UpdateEndpoint.hpp>
#include <endpoints/reboot/RebootEndpoint.hpp>
#include <endpoints/timeSync/TimeSyncEndpoint.hpp>

namespace sdesktop::endpoints
{

    EndpointFactoryBell::EndpointFactoryBell() : EndpointFactory{}
    {}

    std::unique_ptr<Endpoint> EndpointFactoryBell::create(Context &context, sys::Service *ownerServicePtr)
    {
        switch (context.getEndpoint()) {
        case EndpointType::update:
        case EndpointType::Update:
            return std::make_unique<UpdateEndpoint>(ownerServicePtr);
        case EndpointType::filesystemUpload:
        case EndpointType::FilesystemUpload:
            return FilesystemEndpoint::createInstance(ownerServicePtr);
        case EndpointType::backup:
        case EndpointType::Backup:
            return std::make_unique<BackupEndpoint>(ownerServicePtr);
        case EndpointType::deviceInfo:
        case EndpointType::DeviceInfo:
            return std::make_unique<DeviceInfoEndpoint>(ownerServicePtr);
        case EndpointType::restore:
        case EndpointType::Restore:
            return std::make_unique<RestoreEndpoint>(ownerServicePtr);
        case EndpointType::factory:
        case EndpointType::Factory:
            return std::make_unique<FactoryResetEndpoint>(ownerServicePtr);
        case EndpointType::reboot:
        case EndpointType::Reboot:
            return std::make_unique<RebootEndpoint>(ownerServicePtr);
        case EndpointType::TimeSync:
            return std::make_unique<TimeSyncEndpoint>(ownerServicePtr);
        default:
            return std::make_unique<NullEndpoint>(ownerServicePtr);
        }
    }

    auto EndpointFactory::create(EndpointSecurity /*unused*/) -> std::unique_ptr<EndpointFactory>
    auto EndpointFactory::create([[maybe_unused]] EndpointSecurity endpointSecurity) -> std::unique_ptr<EndpointFactory>
    {
        return std::make_unique<EndpointFactoryBell>();
    }

M products/BellHybrid/services/desktop/endpoints/EndpointFactoryBell.hpp => products/BellHybrid/services/desktop/endpoints/EndpointFactoryBell.hpp +1 -1
@@ 10,7 10,7 @@ namespace sdesktop::endpoints
    class EndpointFactoryBell : public EndpointFactory
    {
      public:
        explicit EndpointFactoryBell();
        EndpointFactoryBell() = default;

        auto create(Context &context, sys::Service *ownerServicePtr) -> std::unique_ptr<Endpoint> override;
    };

M products/PurePhone/services/desktop/endpoints/EndpointFactoryPure.cpp => products/PurePhone/services/desktop/endpoints/EndpointFactoryPure.cpp +18 -17
@@ 1,4 1,4 @@
// Copyright (c) 2017-2023, Mudita Sp. z.o.o. All rights reserved.
// Copyright (c) 2017-2024, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md

#include "EndpointFactoryPure.hpp"


@@ 17,53 17,55 @@
#include <endpoints/restore/RestoreEndpoint.hpp>
#include <endpoints/security/SecurityEndpoint.hpp>
#include <endpoints/update/UpdateEndpoint.hpp>
#include <endpoints/timeSync/TimeSyncEndpoint.hpp>

namespace sdesktop::endpoints
{

    std::unique_ptr<Endpoint> EndpointFactoryPure::constructEndpoint(Context &context, sys::Service *ownerServicePtr)
    {
        switch (context.getEndpoint()) {
        case EndpointType::update:
        case EndpointType::Update:
            return std::make_unique<UpdateEndpoint>(ownerServicePtr);
        case EndpointType::filesystemUpload:
        case EndpointType::FilesystemUpload:
            return FilesystemEndpoint::createInstance(ownerServicePtr);
        case EndpointType::backup:
        case EndpointType::Backup:
            return std::make_unique<BackupEndpoint>(ownerServicePtr);
        case EndpointType::deviceInfo:
        case EndpointType::DeviceInfo:
            return std::make_unique<DeviceInfoEndpoint>(ownerServicePtr);
        case EndpointType::restore:
        case EndpointType::Restore:
            return std::make_unique<RestoreEndpoint>(ownerServicePtr);
        case EndpointType::contacts:
        case EndpointType::Contacts:
            return std::make_unique<ContactsEndpoint>(ownerServicePtr);
        case EndpointType::messages:
        case EndpointType::Messages:
            return std::make_unique<MessagesEndpoint>(ownerServicePtr);
        case EndpointType::factory:
        case EndpointType::Factory:
            return std::make_unique<FactoryResetEndpoint>(ownerServicePtr);
        case EndpointType::calllog:
        case EndpointType::Calllog:
            return std::make_unique<CalllogEndpoint>(ownerServicePtr);
#if ENABLE_DEVELOPER_MODE_ENDPOINT
        case EndpointType::developerMode:
            return std::make_unique<DeveloperModeEndpoint>(ownerServicePtr);
#endif
        case EndpointType::bluetooth:
        case EndpointType::Bluetooth:
            return std::make_unique<BluetoothEndpoint>(ownerServicePtr);
        case EndpointType::usbSecurity:
        case EndpointType::UsbSecurity:
            return std::make_unique<SecurityEndpoint>(ownerServicePtr);
        case EndpointType::outbox:
        case EndpointType::Outbox:
            return std::make_unique<OutboxEndpoint>(ownerServicePtr);
        case EndpointType::TimeSync:
            return std::make_unique<TimeSyncEndpoint>(ownerServicePtr);
        default:
            return std::make_unique<NullEndpoint>(ownerServicePtr);
        }
    }

    EndpointFactoryPure::EndpointFactoryPure(EndpointSecurity security) : EndpointFactory{}, endpointSecurity{security}
    EndpointFactoryPure::EndpointFactoryPure(EndpointSecurity security) : endpointSecurity{security}
    {}

    std::unique_ptr<Endpoint> EndpointFactoryPure::create(Context &context, sys::Service *ownerServicePtr)
    {
        auto security = endpointSecurity;
        if (std::find(Whitelist.begin(), Whitelist.end(), context.getEndpoint()) != Whitelist.end()) {
        if (std::find(whitelist.begin(), whitelist.end(), context.getEndpoint()) != whitelist.end()) {
            security = EndpointSecurity::Allow;
        }



@@ 79,5 81,4 @@ namespace sdesktop::endpoints
    {
        return std::make_unique<EndpointFactoryPure>(security);
    }

} // namespace sdesktop::endpoints

M products/PurePhone/services/desktop/endpoints/calllog/CalllogEndpoint.cpp => products/PurePhone/services/desktop/endpoints/calllog/CalllogEndpoint.cpp +5 -7
@@ 1,27 1,25 @@
// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved.
// Copyright (c) 2017-2024, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md

#include <endpoints/calllog/CalllogEndpoint.hpp>

namespace sdesktop::endpoints
{

    auto CalllogEndpoint::handle(Context &context) -> void
    {
        switch (context.getMethod()) {
        case http::Method::get:
        case http::Method::Get:
            helper->requestDataFromDB(context);
            break;
        case http::Method::post: // update entry
        case http::Method::Post: // update entry
            helper->updateDBEntry(context);
            break;
        case http::Method::put:
        case http::Method::Put:
            helper->createDBEntry(context);
            break;
        case http::Method::del:
        case http::Method::Del:
            helper->deleteDBEntry(context);
            break;
        }
    }

} // namespace sdesktop::endpoints

M products/PurePhone/services/desktop/endpoints/contacts/ContactsEndpoint.cpp => products/PurePhone/services/desktop/endpoints/contacts/ContactsEndpoint.cpp +5 -7
@@ 1,27 1,25 @@
// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved.
// Copyright (c) 2017-2024, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md

#include <endpoints/contacts/ContactsEndpoint.hpp>

namespace sdesktop::endpoints
{

    auto ContactsEndpoint::handle(Context &context) -> void
    {
        switch (context.getMethod()) {
        case http::Method::get:
        case http::Method::Get:
            helper->requestDataFromDB(context);
            break;
        case http::Method::post:
        case http::Method::Post:
            helper->createDBEntry(context);
            break;
        case http::Method::put:
        case http::Method::Put:
            helper->updateDBEntry(context);
            break;
        case http::Method::del:
        case http::Method::Del:
            helper->deleteDBEntry(context);
            break;
        }
    }

} // namespace sdesktop::endpoints

M products/PurePhone/services/desktop/endpoints/messages/MessagesEndpoint.cpp => products/PurePhone/services/desktop/endpoints/messages/MessagesEndpoint.cpp +5 -8
@@ 1,28 1,25 @@
// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved.
// Copyright (c) 2017-2024, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md

#include <endpoints/messages/MessagesEndpoint.hpp>

namespace sdesktop::endpoints
{

    auto MessagesEndpoint::handle(Context &context) -> void
    {

        switch (context.getMethod()) {
        case http::Method::get:
        case http::Method::Get:
            helper->requestDataFromDB(context);
            break;
        case http::Method::post:
        case http::Method::Post:
            helper->createDBEntry(context);
            break;
        case http::Method::put:
        case http::Method::Put:
            helper->updateDBEntry(context);
            break;
        case http::Method::del:
        case http::Method::Del:
            helper->deleteDBEntry(context);
            break;
        }
    }

} // namespace sdesktop::endpoints

M products/PurePhone/services/desktop/endpoints/outbox/OutboxEndpoint.cpp => products/PurePhone/services/desktop/endpoints/outbox/OutboxEndpoint.cpp +3 -6
@@ 1,19 1,17 @@
// Copyright (c) 2017-2022, Mudita Sp. z.o.o. All rights reserved.
// Copyright (c) 2017-2024, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md

#include <endpoints/outbox/OutboxEndpoint.hpp>

namespace sdesktop::endpoints
{

    auto OutboxEndpoint::handle(Context &context) -> void
    {

        switch (context.getMethod()) {
        case http::Method::get:
        case http::Method::Get:
            helper->processGetRequest(context);
            break;
        case http::Method::del:
        case http::Method::Del:
            helper->processDeleteRequest(context);
            break;
        default:


@@ 21,5 19,4 @@ namespace sdesktop::endpoints
            break;
        }
    }

} // namespace sdesktop::endpoints