Files
MuditaOS/module-services/service-cellular/CellularCall.hpp
Alek-Mudita 1446a4bff8 Egd 2539 duration class (#258)
* [GED-2539] Timestamp : changed buffer to heap one

[EGD-2539] implemented 1st version of Duration class

[EGD-2539] added autoformating of the output

[EGD-2539] clean up

[EGD-2539] used duration in call and calllog
added Duration operators

[EGD-2539] add better duartions to calllog.db

[EGD-2539] format file

* [EGD-2539] fixes after rebase

* [EGD-2539] displayed format follows design guidline

* [EGD-2539] added UT for duration class and necessary FW fixes

* [EGD-2539] fixed tim_conversion UT

* [EGD-2539] PR fixes

* [EGD-2539] added move constructor to UTF8 class

* [EGD-2539] added checking for nullptr in fillContactData

* [EGD-2539] PR fixes
2020-03-25 17:14:00 +01:00

135 lines
3.8 KiB
C++

#pragma once
#include "Interface/CalllogRecord.hpp"
#include "time/time_conversion.hpp"
#include <functional>
#include <string>
namespace ModemCall
{
enum class CallState : uint8_t
{
Active = 0, // 0 active: call in progress (setup was successful)
Held, // 1 held: call on hold
Dialing, // 2 dialing (MO call): number dialed
Alerting, // 3 alerting (MO call): number dialed and the called party is alerted
Incoming, // 4 incoming (MT call): incoming call, ringtone played (AT RING notification)
Waiting // 5 waiting (MT call): call waiting notification while another call is active (if call waiting feature
// enabled)
};
enum class CallDir : uint8_t
{
MO = 0, // Mobile originated (MO) call
MT = 1, // Mobile terminated (MT) call
};
enum class CallMode : uint8_t
{
Voice = 0,
Data = 1,
FAX = 2,
};
// TODO: alek: check specification
enum class CallType : uint8_t
{
UknownType = 129,
InternationType = 145, // contains the "+" character
NationalType = 161,
};
struct ModemCall
{
int8_t idx;
CallDir dir;
CallState state;
CallMode mode;
bool isConferenceCall;
std::string phoneNumber;
CallType type;
std::string phoneBookName; // TODO: alek: This field is defined in the AT+CLCC command resposne but our modem is
// not returning it. Need to verify in modem specification
ModemCall() = delete;
~ModemCall() = default;
ModemCall(const std::string str);
friend std::ostream &operator<<(std::ostream &out, const ModemCall &call);
};
} // namespace ModemCall
namespace CellularCall
{
enum class Forced : bool
{
False,
True
};
class CellularCall
{
CalllogRecord call;
bool isActiveCall = false;
std::function<CalllogRecord(const CalllogRecord &rec)> startCallAction;
std::function<bool(const CalllogRecord &rec)> endCallAction;
utils::time::Timestamp startActiveTime = 0;
void setType(const CallType type)
{
call.type = type;
}
void clear()
{
call.ID = 0; // 0 - Invalid
call.number = "";
call.presentation = PresentationType::PR_ALLOWED;
call.date = 0;
call.duration = 0;
call.type = CallType::CT_NONE;
call.name = "";
call.contactId = "";
isActiveCall = false;
startActiveTime = 0;
}
public:
CellularCall(const UTF8 &number = "",
const CallType type = CallType::CT_NONE,
const time_t date = 0,
const time_t duration = 0)
{
clear();
this->call.number = number;
this->call.date = date;
this->call.duration = duration;
this->call.type = type;
this->call.name = number; // temporary set number as name
this->call.contactId = "1";
}
~CellularCall() = default;
void setStartCallAction(const std::function<CalllogRecord(const CalllogRecord &rec)> callAction)
{
startCallAction = callAction;
}
void setEndCallAction(const std::function<bool(const CalllogRecord &rec)> callAction)
{
endCallAction = callAction;
}
bool startCall(const UTF8 &number, const CallType type);
bool setActive();
bool endCall(Forced forced = Forced::False);
bool isValid() const
{
return call.ID != 0;
}
};
} // namespace CellularCall