mirror of
https://github.com/mudita/MuditaOS.git
synced 2026-07-04 13:17:08 -04:00
* [EGD-2420] tokenizer refactoring new class CellularCall * [EDG-2420] new file added * [EGD-2420] fixed include * [EGD-2420] added new ModemCall type and its usage in Sevice Cellular. missing dep in module-cellular. Fix in tokenizer. * [EGD-2420] get calllogrecordID one adding new entry to DB number as contact name * [EGD-2420] fixes at DB level api for update and delete Outgoing call seems to add proper calllog entries now * [EGD-2420][fix] fix for HF during call before full modem init * [EGD-2420] incoming and missed calls are handled code clean-up * [EGD-2420] ModemCall::to_string * [EGD-2420] added proper exceptions * [EGD-2420] minor clean up * [EGD-2420] split string with multichar delimiter * [EGD-2420] done some TODOs * [EGD-2420] PR fixes * [EGD-2420] separation between cellularcall and cellularservice PR fixes * [EGD-2420] duration based on timestamp instead of timer * [EGD-2420] new to_strings * [EGD-2420] fixes after rebase * [EGD-2420] operator<< * [EGD-2420] changed split params * [EGD-2420] changed returned db id * [EGD-2420] comment with explantaion
137 lines
4.5 KiB
C++
137 lines
4.5 KiB
C++
/*
|
|
* @file CalllogRecord.cpp
|
|
* @author Aleksander Rudnik (aleksander.rudnik@mudita.com)
|
|
* @date 23.09.2019
|
|
* @brief Call Log DB Record
|
|
* @copyright Copyright (C) 2019 mudita.com
|
|
* @details
|
|
*/
|
|
#include "CalllogRecord.hpp"
|
|
#include "../Tables/CalllogTable.hpp"
|
|
#include <log/log.hpp>
|
|
#include <sstream>
|
|
|
|
std::ostream &operator<<(std::ostream &out, const CalllogRecord &rec)
|
|
{
|
|
out << " <id> " << rec.id << " <number> " << rec.number << " <presentation> " << static_cast<uint32_t>(rec.presentation) << " <date> " << rec.date
|
|
<< " <duration> " << rec.duration << " <type> " << static_cast<uint32_t>(rec.type) << " <name> " << rec.name << " <contactID> " << rec.contactId;
|
|
|
|
return out;
|
|
}
|
|
|
|
CalllogRecordInterface::CalllogRecordInterface(CalllogDB* calllogDb): calllogDB(calllogDb) {
|
|
}
|
|
|
|
CalllogRecordInterface::~CalllogRecordInterface() {
|
|
}
|
|
|
|
bool CalllogRecordInterface::Add(const CalllogRecord &rec)
|
|
{
|
|
return calllogDB->calls.Add(CalllogTableRow{.id = rec.id, // this is only to remove warning
|
|
.number = rec.number,
|
|
.presentation = rec.presentation,
|
|
.date = rec.date,
|
|
.duration = rec.duration,
|
|
.type = rec.type,
|
|
.name = rec.name,
|
|
.contactId = rec.contactId});
|
|
}
|
|
|
|
uint32_t CalllogRecordInterface::GetLastID()
|
|
{
|
|
return calllogDB->GetLastInsertRowID();
|
|
}
|
|
|
|
std::unique_ptr<std::vector<CalllogRecord>> CalllogRecordInterface::GetLimitOffsetByField(uint32_t offset, uint32_t limit,
|
|
CalllogRecordField field,
|
|
const char *str) {
|
|
// TODO: alek: need proper implementation
|
|
return GetLimitOffset(offset,limit);
|
|
}
|
|
|
|
|
|
std::unique_ptr<std::vector<CalllogRecord>> CalllogRecordInterface::GetLimitOffset(uint32_t offset, uint32_t limit) {
|
|
auto calls = calllogDB->calls.GetLimitOffset(offset,limit);
|
|
|
|
auto records = std::make_unique<std::vector<CalllogRecord>>();
|
|
|
|
CalllogRecordInterface callsInterface(calllogDB);
|
|
for(const auto &rec : calls){
|
|
|
|
records->push_back({
|
|
.id=rec.id,
|
|
.number=rec.number,
|
|
.presentation=rec.presentation,
|
|
.date=rec.date,
|
|
.duration=rec.duration,
|
|
.type=rec.type,
|
|
.name=rec.name,
|
|
.contactId=rec.contactId
|
|
});
|
|
}
|
|
|
|
return records;
|
|
}
|
|
|
|
bool CalllogRecordInterface::Update(const CalllogRecord &rec) {
|
|
|
|
auto call = calllogDB->calls.GetByID(rec.id);
|
|
if(call.id == 0){
|
|
return false;
|
|
}
|
|
|
|
return calllogDB->calls.Update(CalllogTableRow{.id = rec.id,
|
|
.number = rec.number,
|
|
.presentation = rec.presentation,
|
|
.date = rec.date,
|
|
.duration = rec.duration,
|
|
.type = rec.type,
|
|
.name = rec.name,
|
|
.contactId = rec.contactId});
|
|
}
|
|
|
|
bool CalllogRecordInterface::RemoveByID(uint32_t id) {
|
|
|
|
auto call = calllogDB->calls.GetByID(id);
|
|
if(call.id == 0){
|
|
return false;
|
|
}
|
|
|
|
return calllogDB->calls.RemoveByID(id);
|
|
}
|
|
|
|
bool CalllogRecordInterface::RemoveByField(CalllogRecordField field, const char *str) {
|
|
|
|
switch(field){
|
|
case CalllogRecordField::DATE:
|
|
return calllogDB->calls.RemoveByField(CalllogTableFields::DATE,str);
|
|
case CalllogRecordField::TYPE:
|
|
return calllogDB->calls.RemoveByField(CalllogTableFields::TYPE,str);
|
|
default:
|
|
return false;
|
|
|
|
}
|
|
}
|
|
|
|
CalllogRecord CalllogRecordInterface::GetByID(uint32_t id) {
|
|
auto rec = calllogDB->calls.GetByID(id);
|
|
|
|
return CalllogRecord{
|
|
.id=rec.id, // this is only to remove warning
|
|
.number=rec.number,
|
|
.presentation=rec.presentation,
|
|
.date=rec.date,
|
|
.duration=rec.duration,
|
|
.type=rec.type,
|
|
.name=rec.name,
|
|
.contactId=rec.contactId
|
|
};
|
|
}
|
|
|
|
uint32_t CalllogRecordInterface::GetCount() {
|
|
return calllogDB->calls.GetCount();
|
|
}
|
|
|
|
|
|
|