mirror of
https://github.com/mudita/MuditaOS.git
synced 2026-07-24 06:55:37 -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).
64 lines
2.4 KiB
C++
64 lines
2.4 KiB
C++
#pragma once
|
|
|
|
#include "Application.hpp"
|
|
#include "Service/Message.hpp"
|
|
#include "SystemManager/SystemManager.hpp"
|
|
#include <service-cellular/api/CellularServiceAPI.hpp>
|
|
#include <time/time_conversion.hpp>
|
|
|
|
namespace app
|
|
{
|
|
inline const std::string name_call = "ApplicationCall";
|
|
constexpr std::uint16_t call_stack_size = 8192;
|
|
|
|
namespace window
|
|
{
|
|
inline const std::string name_call = "CallWindow";
|
|
inline const std::string name_enterNumber = "EnterNumberWindow";
|
|
inline const std::string name_emergencyCall = "EmergencyCallWindow";
|
|
inline const std::string name_duplicatedContact = "DuplicatedContactWindow";
|
|
} // namespace window
|
|
|
|
inline const std::string ringtone_path = "sys/assets/audio/ringtone.wav"; // Should bo moved to database
|
|
|
|
class ApplicationCall : public Application
|
|
{
|
|
private:
|
|
void CallAbortHandler();
|
|
void CallActiveHandler();
|
|
void IncomingCallHandler(const CellularCallMessage *const msg);
|
|
void RingingHandler(const CellularCallMessage *const msg);
|
|
|
|
protected:
|
|
AppTimer timerCall;
|
|
utils::time::Timestamp callStartTime = 0;
|
|
utils::time::Duration callDuration;
|
|
utils::time::Timestamp callDelayedStopTime = 0;
|
|
void timerCallCallback();
|
|
|
|
public:
|
|
ApplicationCall(std::string name = name_call, std::string parent = "", bool startBackgound = false);
|
|
~ApplicationCall() override = default;
|
|
sys::Message_t DataReceivedHandler(sys::DataMessage *msgl, sys::ResponseMessage *resp) override;
|
|
sys::ReturnCodes InitHandler() override;
|
|
sys::ReturnCodes DeinitHandler() override;
|
|
|
|
sys::ReturnCodes SwitchPowerModeHandler(const sys::ServicePowerMode mode) override final
|
|
{
|
|
return sys::ReturnCodes::Success;
|
|
}
|
|
|
|
void createUserInterface() override;
|
|
void destroyUserInterface() override;
|
|
void setDisplayedNumber(std::string num);
|
|
const std::string &getDisplayedNumber();
|
|
// starts timer that upon triggering, if no user action was performed, will hide application to background and
|
|
// move to previous application
|
|
void runCallTimer();
|
|
void stopCallTimer();
|
|
|
|
void handleCallEvent(const std::string &number);
|
|
void handleAddContactEvent(const std::string &number);
|
|
};
|
|
} /* namespace app */
|