remade text type switch as tabview
This commit is contained in:
18
ofd/module.h
18
ofd/module.h
@@ -1,18 +0,0 @@
|
||||
#ifndef OFD_MODULE_H
|
||||
#define OFD_MODULE_H
|
||||
|
||||
#include <string>
|
||||
|
||||
class OFDModule {
|
||||
std::string path;
|
||||
std::wstring name;
|
||||
std::wstring url;
|
||||
public:
|
||||
OFDModule(std::string);
|
||||
OFDModule();
|
||||
|
||||
std::wstring get_name();
|
||||
std::wstring get_url();
|
||||
};
|
||||
|
||||
#endif // OFDMODULE_H
|
||||
64
ofd/ofd.cpp
64
ofd/ofd.cpp
@@ -1,67 +1,3 @@
|
||||
#include "ofd.h"
|
||||
#include "../utils/utils.h"
|
||||
#include <filesystem>
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include "../net/net.h"
|
||||
#include "../settings/settings.h"
|
||||
|
||||
OFD::OFD() {}
|
||||
|
||||
OFD::OFD(std::string path) { this->module = OFDModule(path); };
|
||||
|
||||
std::vector<std::string> OFD::search_ofds() {
|
||||
Settings s(get_path_relative_to_home(".local/share/checks_parser/settings.json"));
|
||||
std::vector<std::string> result{};
|
||||
|
||||
std::string path = get_path_relative_to_home(s.get_setting("ods_modules_dir"));
|
||||
std::filesystem::directory_entry modules_dir(path);
|
||||
|
||||
if (!modules_dir.exists()) {
|
||||
std::filesystem::create_directories(path);
|
||||
std::cout << "No modules directory found. Created one at " << path
|
||||
<< std::endl;
|
||||
std::cout << "Please, download modules to that directory from my git."
|
||||
<< std::endl;
|
||||
}
|
||||
|
||||
for (auto file : std::filesystem::directory_iterator(path)) {
|
||||
result.push_back(file.path());
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
void OFD::set_module(std::string path) { this->module = OFDModule(path); }
|
||||
|
||||
std::string OFD::get_check_data(std::string fn, std::string fd,
|
||||
std::string fp) {
|
||||
//TODO
|
||||
return "";
|
||||
}
|
||||
|
||||
std::vector<std::string> OFD::check_updates() {
|
||||
Settings s(get_path_relative_to_home(".local/share/checks_parser/settings.json"));
|
||||
|
||||
std::string path = get_path_relative_to_home(s.get_setting("ofds_modules_dir"));
|
||||
std::vector<std::string> to_download;
|
||||
std::vector<std::string> stored_modules;
|
||||
|
||||
for (const auto& file : std::filesystem::directory_iterator(path)) {
|
||||
if (!file.is_regular_file()) continue;
|
||||
stored_modules.push_back(file.path().filename());
|
||||
std::cout << "Detected OFD module" << file.path().filename() << std::endl;
|
||||
}
|
||||
Net n;
|
||||
std::vector<std::string> remote_modules = n.get_all_modules(s.get_setting("ofds_modules_url"));
|
||||
|
||||
for (const std::string& module : remote_modules) {
|
||||
if (!vector_contains_element(stored_modules, module)) {
|
||||
to_download.push_back(module);
|
||||
std::cout << "I need to download OFD module " << module << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
return to_download;
|
||||
}
|
||||
|
||||
14
ofd/ofd.h
14
ofd/ofd.h
@@ -2,22 +2,12 @@
|
||||
#define OFD_H
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include "module.h"
|
||||
|
||||
class OFD {
|
||||
|
||||
OFDModule module;
|
||||
|
||||
public:
|
||||
OFD();
|
||||
OFD(std::string);
|
||||
|
||||
std::vector<std::string> search_ofds();
|
||||
|
||||
void set_module(std::string);
|
||||
|
||||
std::string get_check_data(std::string fn, std::string fd, std::string fp);
|
||||
std::vector<std::string> check_updates();
|
||||
void ask_captcha();
|
||||
std::string request_and_parse_check(long fiscal_number, long fiscal_document, long fiscal_sign, std::string datetime, double total, std::string captcha);
|
||||
};
|
||||
#endif // OFD_H
|
||||
|
||||
Reference in New Issue
Block a user