Files
MuditaOS/module-db/Interface/CalllogRecord.hpp
Marcin Smoczyński c47923d70a [EGD-3107] Call number validation
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).
2020-05-05 00:51:53 +02:00

76 lines
2.4 KiB
C++

/*
* @file CalllogRecord.hpp
* @author Aleksander Rudnik (aleksander.rudnik@mudita.com)
* @date 23.09.2019
* @brief Call Log DB Record
* @copyright Copyright (C) 2019 mudita.com
* @details
*/
#pragma once
#include <Common/Common.hpp>
#include <ContactRecord.hpp>
#include <Databases/CalllogDB.hpp>
#include <Record.hpp>
#include <PhoneNumber.hpp>
#include <utf8/UTF8.hpp>
#include <cstdint>
#include <vector>
#include <utility>
struct CalllogRecord : public Record
{
PresentationType presentation = PresentationType::PR_UNKNOWN;
time_t date = 0;
time_t duration = 0;
CallType type = CallType::CT_NONE;
UTF8 name = "";
UTF8 contactId = "";
utils::PhoneNumber::View phoneNumber = utils::PhoneNumber::View();
friend std::ostream &operator<<(std::ostream &out, const CalllogRecord &point);
CalllogRecord() = default;
~CalllogRecord() = default;
CalllogRecord(const CalllogTableRow &tableRow);
uint32_t getContactId() const;
};
enum class CalllogRecordField
{
DATE,
TYPE,
};
class CalllogRecordInterface : public RecordInterface<CalllogRecord, CalllogRecordField>
{
public:
CalllogRecordInterface(CalllogDB *CalllogDb, ContactsDB *contactsDb);
virtual ~CalllogRecordInterface();
bool Add(const CalllogRecord &rec) override final;
bool RemoveByID(uint32_t id) override final;
bool RemoveByField(CalllogRecordField field, const char *str) override final;
bool Update(const CalllogRecord &rec) override final;
CalllogRecord GetByID(uint32_t id) override final;
uint32_t GetCount() override final;
uint32_t GetCount(EntryState state);
std::unique_ptr<std::vector<CalllogRecord>> GetLimitOffset(uint32_t offset, uint32_t limit) override final;
std::unique_ptr<std::vector<CalllogRecord>> GetLimitOffsetByField(uint32_t offset,
uint32_t limit,
CalllogRecordField field,
const char *str) override final;
uint32_t GetLastID();
private:
CalllogDB *calllogDB = nullptr;
ContactsDB *contactsDB = nullptr;
ContactRecord GetContactRecordByID(const UTF8 &contactId);
};