Files
WoW-Hybrid-gateway/native/remember_credentials.hpp

44 lines
1.3 KiB
C++

#pragma once
#include <cstdint>
#include <filesystem>
#include <string>
#include <vector>
namespace gw::remember {
struct Credential {
std::string account, password;
bool automatic = false;
};
void wipe(Credential &value);
bool save(const std::filesystem::path &file, const Credential &value);
bool load(const std::filesystem::path &file, Credential &value);
bool clear(const std::filesystem::path &file);
struct Account {
std::string account, password, label, character;
uint16_t character_index=0;
};
struct Vault {
std::vector<Account> accounts;
bool locked=false, streamer=false;
};
void wipe(Vault &value);
bool encode(const Vault &value, std::string &plain);
bool decode(const std::string &plain, Vault &value);
bool save(const std::filesystem::path &file, const Vault &value);
bool load(const std::filesystem::path &file, Vault &value);
// Small scalar transport for the existing glue bridge, never a credential
// log/mailbox.
class Exchange {
public:
explicit Exchange(std::filesystem::path file) : file_(std::move(file)) {}
~Exchange();
int64_t query(uint32_t operation, uint32_t row, uint32_t chunk);
private:
std::filesystem::path file_;
std::string staging_;
uint32_t expected_ = 0, offset_ = 0;
bool writing_ = false, reading_ = false;
void reset();
};
} // namespace gw::remember