2021-06-02 18:16:05 +03:00
|
|
|
#pragma once
|
2021-07-16 19:43:54 +03:00
|
|
|
#include <irda_worker.h>
|
2021-06-02 18:16:05 +03:00
|
|
|
#include <stdint.h>
|
|
|
|
#include <string>
|
|
|
|
#include <vector>
|
2021-06-09 16:04:49 +03:00
|
|
|
#include <memory>
|
2021-06-02 18:16:05 +03:00
|
|
|
#include <irda.h>
|
2021-06-09 16:04:49 +03:00
|
|
|
#include <sd-card-api.h>
|
|
|
|
#include <filesystem-api.h>
|
2021-07-16 19:43:54 +03:00
|
|
|
#include "irda-app-signal.h"
|
|
|
|
|
2021-06-02 18:16:05 +03:00
|
|
|
|
|
|
|
class IrdaAppRemoteButton {
|
|
|
|
friend class IrdaAppRemoteManager;
|
|
|
|
std::string name;
|
2021-07-16 19:43:54 +03:00
|
|
|
IrdaAppSignal signal;
|
2021-06-02 18:16:05 +03:00
|
|
|
public:
|
2021-07-16 19:43:54 +03:00
|
|
|
IrdaAppRemoteButton(const char* name, const IrdaAppSignal& signal)
|
|
|
|
: name(name), signal (signal) {}
|
2021-06-02 18:16:05 +03:00
|
|
|
~IrdaAppRemoteButton() {}
|
|
|
|
};
|
|
|
|
|
|
|
|
class IrdaAppRemote {
|
|
|
|
friend class IrdaAppRemoteManager;
|
|
|
|
std::vector<IrdaAppRemoteButton> buttons;
|
|
|
|
std::string name;
|
|
|
|
public:
|
2021-06-09 16:04:49 +03:00
|
|
|
IrdaAppRemote(const std::string& name);
|
|
|
|
IrdaAppRemote& operator=(std::string& new_name) noexcept
|
|
|
|
{
|
|
|
|
name = new_name;
|
|
|
|
buttons.clear();
|
|
|
|
return *this;
|
|
|
|
}
|
2021-06-02 18:16:05 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
class IrdaAppRemoteManager {
|
2021-06-09 16:04:49 +03:00
|
|
|
static const char* irda_directory;
|
|
|
|
static const char* irda_extension;
|
|
|
|
std::unique_ptr<IrdaAppRemote> remote;
|
|
|
|
std::string make_filename(const std::string& name) const;
|
|
|
|
|
2021-06-02 18:16:05 +03:00
|
|
|
public:
|
2021-07-16 19:43:54 +03:00
|
|
|
bool add_remote_with_button(const char* button_name, const IrdaAppSignal& signal);
|
|
|
|
bool add_button(const char* button_name, const IrdaAppSignal& signal);
|
2021-06-09 16:04:49 +03:00
|
|
|
|
|
|
|
int find_remote_name(const std::vector<std::string>& strings);
|
|
|
|
bool rename_button(uint32_t index, const char* str);
|
|
|
|
bool rename_remote(const char* str);
|
2021-06-02 18:16:05 +03:00
|
|
|
|
2021-06-09 16:04:49 +03:00
|
|
|
bool get_remote_list(std::vector<std::string>& remote_names) const;
|
|
|
|
std::vector<std::string> get_button_list() const;
|
|
|
|
std::string get_button_name(uint32_t index);
|
|
|
|
std::string get_remote_name();
|
|
|
|
size_t get_number_of_buttons();
|
2021-07-16 19:43:54 +03:00
|
|
|
const IrdaAppSignal& get_button_data(size_t index) const;
|
2021-06-09 16:04:49 +03:00
|
|
|
bool delete_button(uint32_t index);
|
|
|
|
bool delete_remote();
|
|
|
|
|
|
|
|
bool store();
|
|
|
|
bool load(const std::string& name);
|
|
|
|
bool check_fs() const;
|
2021-06-02 18:16:05 +03:00
|
|
|
};
|
|
|
|
|