mirror of
https://github.com/mudita/MuditaOS.git
synced 2026-06-28 02:07:08 -04:00
Use specialized class to to pass phone number between apps and services instead of ambigious std::string. Introduced class (utils::PhoneNumber) wraps calls to libphonenumber providing more convienient interface. However using libphonenumber directly may be resource hungry in terms of stack, heap and cpu usage, so helper class has been introduced to pass information about phone numbers (utils::PhoneNumber::View). It is designed to maintain integrity thus can be created from an instance of utils::PhoneNumber only or moved/copied to. Add new field to the calllog db holding e164 formatted number. Both entered and e164 numbers will be needed to be able to match with contacts correctly. Add constexpr information about country codes (utils::country).
77 lines
1.9 KiB
C++
77 lines
1.9 KiB
C++
#pragma once
|
|
|
|
#include "SwitchData.hpp"
|
|
|
|
#include <PhoneNumber.hpp>
|
|
|
|
#include <string>
|
|
|
|
namespace app
|
|
{
|
|
|
|
class CallSwitchData : public gui::SwitchData
|
|
{
|
|
public:
|
|
enum class Type
|
|
{
|
|
UNDEFINED,
|
|
INCOMMING_CALL,
|
|
EXECUTE_CALL
|
|
};
|
|
static const inline std::string descriptionStr = "CallSwitchData";
|
|
|
|
protected:
|
|
Type type = Type::UNDEFINED;
|
|
utils::PhoneNumber::View phoneNumber;
|
|
|
|
public:
|
|
CallSwitchData(const utils::PhoneNumber::View &phoneNumber, Type type = Type::UNDEFINED)
|
|
: SwitchData(descriptionStr), type(type), phoneNumber(phoneNumber){};
|
|
virtual ~CallSwitchData(){};
|
|
|
|
const Type &getType() const
|
|
{
|
|
return type;
|
|
};
|
|
const utils::PhoneNumber::View &getPhoneNumber() const
|
|
{
|
|
return phoneNumber;
|
|
};
|
|
};
|
|
|
|
class EnterNumberData : public gui::SwitchData
|
|
{
|
|
std::string phoneNumber;
|
|
|
|
public:
|
|
static const inline std::string descriptionStr = "EnterNumberSwitchData";
|
|
|
|
EnterNumberData(const std::string &phoneNumber) : SwitchData(descriptionStr), phoneNumber(phoneNumber)
|
|
{}
|
|
virtual ~EnterNumberData(){};
|
|
|
|
const std::string &getPhoneNumber() const
|
|
{
|
|
return phoneNumber;
|
|
}
|
|
};
|
|
|
|
class IncommingCallData : public CallSwitchData
|
|
{
|
|
public:
|
|
IncommingCallData(const utils::PhoneNumber::View &phoneNumber)
|
|
: CallSwitchData(phoneNumber, CallSwitchData::Type::INCOMMING_CALL){};
|
|
virtual ~IncommingCallData(){};
|
|
};
|
|
|
|
class ExecuteCallData : public CallSwitchData
|
|
{
|
|
public:
|
|
ExecuteCallData(const utils::PhoneNumber::View &phoneNumber)
|
|
: CallSwitchData(phoneNumber, app::CallSwitchData::Type::EXECUTE_CALL){};
|
|
|
|
virtual ~ExecuteCallData(){};
|
|
};
|
|
|
|
} /* namespace app */
|