58 lines
1.0 KiB
C++
58 lines
1.0 KiB
C++
#pragma once
|
|
|
|
#include "event.hpp"
|
|
|
|
#include <memory>
|
|
#include <string_view>
|
|
#include <vector>
|
|
|
|
class Connection;
|
|
struct hs_database;
|
|
struct hs_scratch;
|
|
|
|
enum class SnoteTag
|
|
{
|
|
ClientConnecting,
|
|
ClientExiting,
|
|
RejectingKlined,
|
|
NickChange,
|
|
CreateChannel,
|
|
TemporaryKlineExpired,
|
|
PropagatedBanExpired,
|
|
DisconnectingKlined,
|
|
NewPropagatedKline,
|
|
NewTemporaryKline,
|
|
LoginAttempts,
|
|
PossibleFlooder,
|
|
Killed,
|
|
};
|
|
|
|
struct SnoteEvent : Event
|
|
{
|
|
SnoteEvent(SnoteTag tag, std::vector<std::string_view> parts)
|
|
: tag{tag}
|
|
, parts{std::move(parts)}
|
|
{}
|
|
|
|
SnoteTag tag;
|
|
std::vector<std::string_view> parts;
|
|
};
|
|
|
|
struct SnoteThread
|
|
{
|
|
struct DbDeleter
|
|
{
|
|
auto operator()(hs_database * db) const -> void;
|
|
};
|
|
|
|
struct ScratchDeleter
|
|
{
|
|
auto operator()(hs_scratch * scratch) const -> void;
|
|
};
|
|
|
|
std::unique_ptr<hs_database, DbDeleter> db_;
|
|
std::unique_ptr<hs_scratch, ScratchDeleter> scratch_;
|
|
|
|
static auto start(Connection& connection) -> std::shared_ptr<SnoteThread>;
|
|
};
|