From 3161bf763d1a79991f6c7bdcd1b688c1c07ac8e5 Mon Sep 17 00:00:00 2001 From: sha512sum Date: Sat, 31 Aug 2024 18:35:55 +0000 Subject: [PATCH] Add client options --- library/include/larra/client/options.hpp | 40 ++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 library/include/larra/client/options.hpp diff --git a/library/include/larra/client/options.hpp b/library/include/larra/client/options.hpp new file mode 100644 index 0000000..db6a81b --- /dev/null +++ b/library/include/larra/client/options.hpp @@ -0,0 +1,40 @@ +#pragma once +#include +#include + +namespace larra::xmpp::client { + +struct Options { + enum UseTls { kNever, kWhenAvailable, kRequire }; + UseTls useTls = kWhenAvailable; + bool allowPlainWithoutTls = false; + std::optional hostname = std::nullopt; + std::optional port = std::nullopt; + Proxy proxy = SystemConfiguredProxy{}; + + template + constexpr auto UseTls(this Self&& self, UseTls value) -> Options { + return utils::FieldSetHelper::With<"useTls", Options>(std::forward(self), std::move(value)); + } + template + constexpr auto AllowPlainWithoutTls(this Self&& self, bool value) -> Options { + return utils::FieldSetHelper::With<"allowPlainWithoutTls", Options>(std::forward(self), std::move(value)); + } + + template + constexpr auto Hostname(this Self&& self, std::optional value) -> Options { + return utils::FieldSetHelper::With<"hostname", Options>(std::forward(self), std::move(value)); + } + + template + constexpr auto Port(this Self&& self, std::optional value) -> Options { + return utils::FieldSetHelper::With<"port", Options>(std::forward(self), std::move(value)); + } + + template + constexpr auto Proxy(this Self&& self, Proxy value) -> Options { + return utils::FieldSetHelper::With<"proxy", Options>(std::forward(self), std::move(value)); + } +}; + +} // namespace larra::xmpp::client