mirror of
https://github.com/mudita/MuditaOS.git
synced 2026-01-02 19:08:54 -05:00
Fix of the issue that unlocked phone would automatically lock after user tried to reject incoming call via SMS and stayed on the templates window.
135 lines
3.2 KiB
C++
135 lines
3.2 KiB
C++
// Copyright (c) 2017-2023, Mudita Sp. z.o.o. All rights reserved.
|
|
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md
|
|
|
|
#pragma once
|
|
|
|
#include <SwitchData.hpp>
|
|
#include <SMSTemplateRecord.hpp>
|
|
#include <ContactRecord.hpp>
|
|
#include <ThreadRecord.hpp>
|
|
#include <SMSRecord.hpp>
|
|
#include <Database/Database.hpp>
|
|
#include <ApplicationCommon.hpp>
|
|
#include <memory>
|
|
#include <string>
|
|
#include <utility>
|
|
|
|
class SMSThreadData : public gui::SwitchData
|
|
{
|
|
public:
|
|
std::shared_ptr<ThreadRecord> thread;
|
|
std::optional<UTF8> threadName;
|
|
|
|
SMSThreadData(std::shared_ptr<ThreadRecord> _thread, std::optional<UTF8> _threadName = std::nullopt)
|
|
: thread(std::move(_thread)), threadName{std::move(_threadName)}
|
|
{}
|
|
};
|
|
|
|
class SMSSwitchData : public gui::SwitchData
|
|
{
|
|
protected:
|
|
SMSRecord record;
|
|
|
|
public:
|
|
SMSSwitchData() = delete;
|
|
explicit SMSSwitchData(SMSRecord record) : record(std::move(record))
|
|
{}
|
|
~SMSSwitchData() override = default;
|
|
|
|
[[nodiscard]] auto getRecord() const noexcept -> const SMSRecord &
|
|
{
|
|
return record;
|
|
};
|
|
};
|
|
|
|
class SMSRequest : public gui::SwitchData
|
|
{
|
|
protected:
|
|
utils::PhoneNumber::View phoneNumber;
|
|
|
|
public:
|
|
SMSRequest() = delete;
|
|
SMSRequest(const utils::PhoneNumber::View &phoneNumber) : phoneNumber(phoneNumber)
|
|
{}
|
|
~SMSRequest() override = default;
|
|
|
|
[[nodiscard]] auto getPhoneNumber() const -> const utils::PhoneNumber::View &
|
|
{
|
|
return phoneNumber;
|
|
};
|
|
};
|
|
|
|
class SMSSendRequest : public SMSRequest
|
|
{
|
|
public:
|
|
SMSSendRequest(const utils::PhoneNumber::View &phoneNumber, UTF8 textData)
|
|
: SMSRequest(phoneNumber), textData(std::move(textData))
|
|
{}
|
|
~SMSSendRequest() override = default;
|
|
UTF8 textData;
|
|
};
|
|
|
|
class SMSSendTemplateRequest : public SMSRequest
|
|
{
|
|
public:
|
|
enum class AutolockBehavior
|
|
{
|
|
Allow,
|
|
Prevent
|
|
};
|
|
|
|
explicit SMSSendTemplateRequest(const utils::PhoneNumber::View &phoneNumber,
|
|
AutolockBehavior autolockBehavior = AutolockBehavior::Allow)
|
|
: SMSRequest(phoneNumber), autolockBehavior(autolockBehavior)
|
|
{}
|
|
~SMSSendTemplateRequest() override = default;
|
|
|
|
[[nodiscard]] AutolockBehavior getAutolockBehavior() const noexcept
|
|
{
|
|
return autolockBehavior;
|
|
}
|
|
|
|
private:
|
|
AutolockBehavior autolockBehavior;
|
|
};
|
|
|
|
class SMSTemplateSent : public gui::SwitchData
|
|
{
|
|
public:
|
|
explicit SMSTemplateSent(const UTF8 &text) : smsText(text){};
|
|
auto getText() -> UTF8
|
|
{
|
|
return smsText;
|
|
}
|
|
|
|
private:
|
|
UTF8 smsText;
|
|
};
|
|
|
|
class SMSTextData : public gui::SwitchData
|
|
{
|
|
public:
|
|
enum class Concatenate : bool
|
|
{
|
|
True,
|
|
False
|
|
};
|
|
|
|
SMSTextData(UTF8 text, Concatenate concatenate = Concatenate::False)
|
|
: text(std::move(text)), concatenate(concatenate)
|
|
{}
|
|
~SMSTextData() override = default;
|
|
UTF8 text;
|
|
Concatenate concatenate = Concatenate::False;
|
|
};
|
|
|
|
class SMSTemplateRequest : public gui::SwitchData
|
|
{
|
|
public:
|
|
SMSTemplateRequest(std::string requestingWindow) : requestingWindow(std::move(requestingWindow))
|
|
{}
|
|
~SMSTemplateRequest() override = default;
|
|
|
|
std::string requestingWindow;
|
|
};
|