2018-04-08 21:36:08 +02:00
|
|
|
#ifndef LIBSYNCTHING_INTERFACE_H
|
|
|
|
#define LIBSYNCTHING_INTERFACE_H
|
|
|
|
|
|
|
|
#include "./global.h"
|
|
|
|
|
2019-07-18 16:38:19 +02:00
|
|
|
#include <cstdint>
|
2018-04-14 23:03:04 +02:00
|
|
|
#include <functional>
|
2018-04-08 21:36:08 +02:00
|
|
|
#include <string>
|
2020-05-05 19:01:05 +02:00
|
|
|
#include <type_traits>
|
2018-04-17 23:54:43 +02:00
|
|
|
#include <vector>
|
2018-04-08 21:36:08 +02:00
|
|
|
|
|
|
|
namespace LibSyncthing {
|
|
|
|
|
2020-05-05 19:01:05 +02:00
|
|
|
enum class RuntimeFlags : std::uint64_t {
|
|
|
|
None = 0,
|
|
|
|
Verbose = (1 << 0),
|
|
|
|
AllowNewerConfig = (1 << 1),
|
|
|
|
NoDefaultConfig = (1 << 2),
|
|
|
|
EnsureConfigDirExists = (1 << 3),
|
|
|
|
EnsureDataDirExists = (1 << 4),
|
2022-02-01 13:21:01 +01:00
|
|
|
SkipPortProbing = (1 << 5),
|
2020-05-05 19:01:05 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
constexpr bool operator&(RuntimeFlags lhs, RuntimeFlags rhs)
|
|
|
|
{
|
|
|
|
return static_cast<std::underlying_type_t<RuntimeFlags>>(lhs) & static_cast<std::underlying_type_t<RuntimeFlags>>(rhs);
|
|
|
|
}
|
|
|
|
|
|
|
|
constexpr RuntimeFlags operator|(RuntimeFlags lhs, RuntimeFlags rhs)
|
|
|
|
{
|
|
|
|
return static_cast<RuntimeFlags>(static_cast<std::underlying_type_t<RuntimeFlags>>(lhs) | static_cast<std::underlying_type_t<RuntimeFlags>>(rhs));
|
|
|
|
}
|
|
|
|
|
2018-04-08 21:36:08 +02:00
|
|
|
struct RuntimeOptions {
|
|
|
|
std::string configDir;
|
2020-05-05 19:01:05 +02:00
|
|
|
std::string dataDir;
|
2018-04-08 21:36:08 +02:00
|
|
|
std::string guiAddress;
|
|
|
|
std::string guiApiKey;
|
2020-05-05 19:01:05 +02:00
|
|
|
RuntimeFlags flags = RuntimeFlags::AllowNewerConfig | RuntimeFlags::EnsureConfigDirExists | RuntimeFlags::EnsureDataDirExists;
|
2018-04-08 21:36:08 +02:00
|
|
|
};
|
|
|
|
|
2018-04-14 23:03:04 +02:00
|
|
|
enum class LogLevel : int {
|
|
|
|
Debug,
|
|
|
|
Verbose,
|
|
|
|
Info,
|
|
|
|
Warning,
|
|
|
|
Fatal,
|
|
|
|
};
|
|
|
|
constexpr auto lowestLogLevel = LogLevel::Debug;
|
|
|
|
constexpr auto highestLogLevel = LogLevel::Fatal;
|
|
|
|
|
|
|
|
using LoggingCallback = std::function<void(LogLevel, const char *message, std::size_t messageSize)>;
|
|
|
|
|
2020-01-29 18:51:10 +01:00
|
|
|
LIB_SYNCTHING_EXPORT void setLoggingCallback(const LoggingCallback &callback);
|
|
|
|
LIB_SYNCTHING_EXPORT void setLoggingCallback(LoggingCallback &&callback);
|
|
|
|
LIB_SYNCTHING_EXPORT std::int64_t runSyncthing(const RuntimeOptions &options = RuntimeOptions{});
|
|
|
|
LIB_SYNCTHING_EXPORT bool isSyncthingRunning();
|
|
|
|
LIB_SYNCTHING_EXPORT std::int64_t stopSyncthing();
|
|
|
|
LIB_SYNCTHING_EXPORT std::string ownDeviceId();
|
|
|
|
LIB_SYNCTHING_EXPORT std::string syncthingVersion();
|
|
|
|
LIB_SYNCTHING_EXPORT std::string longSyncthingVersion();
|
2022-06-26 02:25:23 +02:00
|
|
|
LIB_SYNCTHING_EXPORT long long runCli(const std::vector<const char *> &args);
|
2018-04-08 21:36:08 +02:00
|
|
|
|
|
|
|
} // namespace LibSyncthing
|
|
|
|
|
|
|
|
#endif // LIBSYNCTHING_INTERFACE_H
|