// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved. // For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md #pragma once #include #include #include "Common.hpp" namespace sys { class Service; // Forward declaration } // namespace sys namespace sys::phone_modes { class Observer { public: using OnChangeCallback = std::function; using OnCompleteCallback = std::function; using OnErrorCallback = std::function; void connect(Service *owner); void subscribe(OnChangeCallback &&onChange, OnCompleteCallback &&onComplete = {}, OnErrorCallback &&onError = {}) noexcept; bool isInMode(PhoneMode mode) const noexcept; bool isTetheringOn() const noexcept; private: sys::MessagePointer handlePhoneModeChange(PhoneModeChanged *message); void onPhoneModeChanged(); OnChangeCallback onChangeCallback; OnCompleteCallback onCompleteCallback; OnErrorCallback onErrorCallback; PhoneMode phoneMode = PhoneMode::Connected; Tethering tetheringMode = Tethering::Off; }; } // namespace sys::phone_modes