33 lines
836 B
C++
33 lines
836 B
C++
#pragma once
|
|
|
|
#include "FileAddressList.hpp"
|
|
|
|
namespace tw::app {
|
|
|
|
/**
|
|
* Manages a list of recently used server addresses.
|
|
*
|
|
* Persists addresses to a text file, one "ip:port" per line.
|
|
* Most recent first, capped at 8 entries. File path is
|
|
* $XDG_CONFIG_HOME/towards/recent_servers.txt, falling back to
|
|
* $HOME/.config/towards/recent_servers.txt. If both variables are
|
|
* unset, keeps the list in memory only.
|
|
*/
|
|
class RecentServers : public FileAddressList {
|
|
static constexpr size_t MAX_ENTRIES = 8;
|
|
|
|
public:
|
|
RecentServers();
|
|
|
|
const char* name() const override;
|
|
|
|
/**
|
|
* Add an address to the recents list.
|
|
* Most recent first, de-duplicated, capped at 8.
|
|
* Does not persist to disk; call save() after connecting.
|
|
*/
|
|
void add(const std::string& entry) override;
|
|
};
|
|
|
|
} // namespace tw::app
|