mirror of
https://github.com/mudita/MuditaOS.git
synced 2026-10-25 16:08:30 -04:00
Extended cmd mechanism to provide class defined responses and implemented SMS center verification to check if SIM card is properly cofigured and is able to send SMS messagess at all. This check is needed because if SMS Center is lost we are not able to send SMS messages with no verbose error codes. Added milliseconds and noexcept specifiers for at commands Fixed Chanel name to Channel
60 lines
1.8 KiB
C++
60 lines
1.8 KiB
C++
// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved.
|
|
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md
|
|
|
|
// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved.
|
|
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md
|
|
|
|
#pragma once
|
|
|
|
#include <json/json11.hpp>
|
|
|
|
#include <list>
|
|
#include <functional>
|
|
#include <module-apps/Application.hpp>
|
|
#include <vfs.hpp>
|
|
|
|
namespace app
|
|
{
|
|
struct QuoteRecord
|
|
{
|
|
int id = 0;
|
|
std::string quote;
|
|
std::string author;
|
|
|
|
[[nodiscard]] auto to_json() const -> json11::Json
|
|
{
|
|
return json11::Json::object{{"quote", quote}, {"author", author}};
|
|
}
|
|
};
|
|
|
|
class QuotesRepository
|
|
{
|
|
public:
|
|
using OnGetCallback = std::function<bool(const std::list<QuoteRecord> &, unsigned int)>;
|
|
|
|
virtual ~QuotesRepository() noexcept = default;
|
|
|
|
virtual void get(std::uint32_t offset, std::uint32_t limit, const OnGetCallback &callback) = 0;
|
|
virtual void save(const QuoteRecord "e) = 0;
|
|
virtual void remove(const QuoteRecord "e) = 0;
|
|
};
|
|
|
|
class QuotesJsonRepository : public QuotesRepository
|
|
{
|
|
public:
|
|
QuotesJsonRepository(const std::string &path);
|
|
|
|
void get(std::uint32_t offset, std::uint32_t limit, const OnGetCallback &callback) override;
|
|
void save(const QuoteRecord "e) override;
|
|
void remove(const QuoteRecord "e) override;
|
|
|
|
private:
|
|
void writeQuotes(const fs::path &path);
|
|
void readQuotes(const fs::path &fn);
|
|
std::string readFileToString(const fs::path &fn);
|
|
|
|
std::list<QuoteRecord> quotes;
|
|
std::string repositoryPath;
|
|
};
|
|
} // namespace app
|