1#ifndef ENGINE_FAVORITES_H
2#define ENGINE_FAVORITES_H
3
4#include <memory>
5
6#include <base/types.h>
7#include <engine/shared/protocol.h>
8
9#include "kernel.h"
10
11class IConfigManager;
12
13class IFavorites : public IInterface
14{
15 MACRO_INTERFACE("favorites")
16
17protected:
18 virtual void OnConfigSave(IConfigManager *pConfigManager) = 0;
19
20public:
21 class CEntry
22 {
23 public:
24 int m_NumAddrs;
25 NETADDR m_aAddrs[MAX_SERVER_ADDRESSES];
26 bool m_AllowPing;
27 };
28
29 virtual ~IFavorites() {}
30
31 virtual TRISTATE IsFavorite(const NETADDR *pAddrs, int NumAddrs) const = 0;
32 // Only considers the addresses that are actually favorites.
33 virtual TRISTATE IsPingAllowed(const NETADDR *pAddrs, int NumAddrs) const = 0;
34 virtual void Add(const NETADDR *pAddrs, int NumAddrs) = 0;
35 // Only considers the addresses that are actually favorites.
36 virtual void AllowPing(const NETADDR *pAddrs, int NumAddrs, bool AllowPing) = 0;
37 virtual void Remove(const NETADDR *pAddrs, int NumAddrs) = 0;
38 virtual void AllEntries(const CEntry **ppEntries, int *pNumEntries) = 0;
39
40 // Pass the `IFavorites` instance as callback.
41 static void ConfigSaveCallback(IConfigManager *pConfigManager, void *pUserData);
42};
43
44std::unique_ptr<IFavorites> CreateFavorites();
45#endif // ENGINE_FAVORITES_H
46