mirror of
https://github.com/mudita/MuditaOS.git
synced 2026-04-20 23:17:35 -04:00
* [EGD-3169] added sms templates model and item fixed common class name convention * [EGD-3169] added templates window Passing template to new sms window is already working * [EGD-3169] PR fixes from DB PR * [EGD-3169] add universal callback for templates items * [EGD-3169] requesting templates from more 2 windows * [EGD-3169] missign change - display template in threads window * [EGD-3169] minor fixes * [EGD-3169] minimal clean up * [EGD-3169] fixed some layout constatnt * [EGD-3169] rem minor comments and logs * [EGD-3089] rem redundant vector include * [EGD-3169] PR fixes * [EGD-3169] fixes afeter rebase * [EGD-3169] workaround for list view issue - added 2 dump entries * [EGD-3169] PR fixes * [EGD-3169] style fixes * [EGD-3169] fix for 0x0D char on enter in text widget * [EGD-3169] PR fixes * [EGD-3169] compilation issue
76 lines
2.1 KiB
C++
76 lines
2.1 KiB
C++
#include "SMSTemplateRecord.hpp"
|
|
|
|
#include <log/log.hpp>
|
|
|
|
#include <cassert>
|
|
|
|
SMSTemplateRecord::SMSTemplateRecord(const SMSTemplateTableRow &w)
|
|
{
|
|
ID = w.ID;
|
|
text = w.text;
|
|
lastUsageTimestamp = w.lastUsageTimestamp;
|
|
}
|
|
|
|
SMSTemplateRecordInterface::SMSTemplateRecordInterface(SmsDB *smsDb) : smsDB(smsDb)
|
|
{}
|
|
|
|
bool SMSTemplateRecordInterface::Add(const SMSTemplateRecord &rec)
|
|
{
|
|
return smsDB->templates.Add(
|
|
SMSTemplateTableRow{{.ID = rec.ID}, .text = rec.text, .lastUsageTimestamp = rec.lastUsageTimestamp});
|
|
}
|
|
uint32_t SMSTemplateRecordInterface::GetCount()
|
|
{
|
|
return smsDB->templates.GetCount();
|
|
}
|
|
|
|
std::unique_ptr<std::vector<SMSTemplateRecord>> SMSTemplateRecordInterface::GetLimitOffsetByField(
|
|
uint32_t offset, uint32_t limit, SMSTemplateRecordField field, const char *str)
|
|
{
|
|
assert(0 && "need proper implementation");
|
|
return GetLimitOffset(offset, limit);
|
|
}
|
|
|
|
std::unique_ptr<std::vector<SMSTemplateRecord>> SMSTemplateRecordInterface::GetLimitOffset(uint32_t offset,
|
|
uint32_t limit)
|
|
{
|
|
auto templates = smsDB->templates.GetLimitOffset(offset, limit);
|
|
|
|
return std::make_unique<std::vector<SMSTemplateRecord>>(templates.begin(), templates.end());
|
|
}
|
|
|
|
bool SMSTemplateRecordInterface::Update(const SMSTemplateRecord &rec)
|
|
{
|
|
auto templ = smsDB->templates.GetByID(rec.ID);
|
|
if (templ.ID == DB_ID_NONE) {
|
|
return false;
|
|
}
|
|
|
|
return smsDB->templates.Update(
|
|
SMSTemplateTableRow{{.ID = rec.ID}, .text = rec.text, .lastUsageTimestamp = rec.lastUsageTimestamp});
|
|
}
|
|
|
|
bool SMSTemplateRecordInterface::RemoveByID(uint32_t id)
|
|
{
|
|
|
|
auto templ = smsDB->templates.GetByID(id);
|
|
if (templ.ID == 0) {
|
|
return false;
|
|
}
|
|
|
|
return smsDB->templates.RemoveByID(id);
|
|
}
|
|
|
|
bool SMSTemplateRecordInterface::RemoveByField(SMSTemplateRecordField field, const char *str)
|
|
{
|
|
assert(0 && "need implementation");
|
|
return false;
|
|
}
|
|
|
|
SMSTemplateRecord SMSTemplateRecordInterface::GetByID(uint32_t id)
|
|
{
|
|
auto templ = smsDB->templates.GetByID(id);
|
|
|
|
return SMSTemplateRecord{templ};
|
|
}
|