diff --git a/.gitmodules b/.gitmodules index 044f278..626982d 100644 --- a/.gitmodules +++ b/.gitmodules @@ -7,3 +7,6 @@ [submodule "deps/optional"] path = deps/optional url = https://github.com/TartanLlama/optional +[submodule "deps/range-v3"] + path = deps/range-v3 + url = https://github.com/ericniebler/range-v3 diff --git a/deps/range-v3 b/deps/range-v3 new file mode 160000 index 0000000..d800a03 --- /dev/null +++ b/deps/range-v3 @@ -0,0 +1 @@ +Subproject commit d800a032132512a54c291ce55a2a43e0460591c7 diff --git a/makefile b/makefile index af958d7..bab3dd2 100644 --- a/makefile +++ b/makefile @@ -8,7 +8,7 @@ FIND ?= find CC = gcc CXX = g++ -INCLUDES=-Ilibstrophe -Ideps -Ideps/optional/include -Ideps/fmt/include \ +INCLUDES=-Ilibstrophe -Ideps -Ideps/optional/include -Ideps/range-v3/include -Ideps/fmt/include \ $(shell xml2-config --cflags) \ $(shell pkg-config --cflags gpgme) \ $(shell pkg-config --cflags libsignal-protocol-c) @@ -174,11 +174,11 @@ depend: $(SRCS) $(HDRS) echo > ./.depend for src in $(SRCS) ; do \ if [[ $$src == *.cpp ]]; then \ - $(CXX) $(CPPFLAGS) -MM -MMD -MP -MF - \ - -MT .$${src/.cpp/.o} $$src >> ./.depend ; \ + g++ $(CPPFLAGS) -MM -MMD -MP -MF - \ + -MT .$${src/.cpp/.o} $$src >> ./.depend || true ; \ elif [[ $$src == *.c ]]; then \ - $(CC) $(CFLAGS) -MM -MMD -MP -MF - \ - -MT .$${src/.c/.o} $$src >> ./.depend ; \ + gcc $(CFLAGS) -MM -MMD -MP -MF - \ + -MT .$${src/.c/.o} $$src >> ./.depend || true ; \ fi \ done sed -i 's/\.\([a-z]*\/\)/\1./' .depend diff --git a/omemo.cpp b/omemo.cpp index 6a3d5e7..d4843a8 100644 --- a/omemo.cpp +++ b/omemo.cpp @@ -5,8 +5,6 @@ #include #include #include -#include -#include #include #include #include @@ -17,6 +15,7 @@ #include #include #include +#include #include #include @@ -1614,9 +1613,9 @@ int dls_load_devicelist(signal_int_list **devicelist, const char *jid, t_omemo * omemo->dbi.omemo.get(transaction, k_devicelist, v_devicelist); auto devices = v_devicelist - | std::ranges::views::split(';') - | std::ranges::views::transform([](auto&& str) { - return std::stoul(std::string(&*str.begin(), std::ranges::distance(str))); + | ranges::views::split(';') + | ranges::views::transform([](auto&& str) { + return std::stoul(std::string(&*str.begin(), ranges::distance(str))); }); *devicelist = signal_int_list_alloc(); @@ -1718,9 +1717,9 @@ tl::optional bks_load_bundle(struct signal_protocol_a omemo->dbi.omemo.get(transaction, k_bundle_ik, v_bundle_ik); auto r_bundle_pks = v_bundle_pk - | std::ranges::views::split(';') - | std::ranges::views::transform([](auto&& str) { - return std::string_view(&*str.begin(), std::ranges::distance(str)); + | ranges::views::split(';') + | ranges::views::transform([](auto&& str) { + return std::string_view(&*str.begin(), ranges::distance(str)); }); auto bundle_pks = std::vector{r_bundle_pks.begin(), r_bundle_pks.begin()}; if (bundle_pks.size() > 0) @@ -1739,9 +1738,9 @@ tl::optional bks_load_bundle(struct signal_protocol_a libsignal::public_key pre_key(key_buf, key_len, omemo->context); auto r_bundle_sks = v_bundle_sk - | std::ranges::views::split(';') - | std::ranges::views::transform([](auto&& str) { - return std::string_view(&*str.begin(), std::ranges::distance(str)); + | ranges::views::split(';') + | ranges::views::transform([](auto&& str) { + return std::string_view(&*str.begin(), ranges::distance(str)); }); auto bundle_sks = std::vector{r_bundle_sks.begin(), r_bundle_sks.begin()}; if (bundle_sks.size() > 0) diff --git a/signal.hh b/signal.hh index 1f5e383..35bcee1 100644 --- a/signal.hh +++ b/signal.hh @@ -48,7 +48,7 @@ namespace libsignal { template>>> - inline std::invoke_result::type + inline typename std::invoke_result::type call(Args&&... args) { return func(*this, std::forward(args)...); } diff --git a/xmpp/node.hh b/xmpp/node.hh index 5247a0a..b418205 100644 --- a/xmpp/node.hh +++ b/xmpp/node.hh @@ -108,7 +108,12 @@ namespace xml { } namespace stanza { - template struct overloaded : Ts... { using Ts::operator()...; }; + template struct overloaded : Fs... { + overloaded(const Fs& ...ts) : Fs{ts}... {} + overloaded(Fs&& ...ts) : Fs{ts}... {} + using Fs::operator()...; + }; + template overloaded(Ts&&...) -> overloaded...>; extern std::string uuid(xmpp_ctx_t *context); @@ -150,7 +155,7 @@ namespace stanza { [&](spec& child) { xmpp_stanza_add_child(stanza, child.build(context).get()); }, - [&](std::string s) { + [&](std::string& s) { auto child = xmpp_stanza_new(context); xmpp_stanza_set_text(child, s.data()); xmpp_stanza_add_child(stanza, child);