Features: iq::Bind and iq::Roster #4
Loading…
Reference in a new issue
No description provided.
Delete branch "feature_roster_on_login"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@ -0,0 +29,4 @@
return {};
}
auto* jid_el = dynamic_cast<const xmlpp::Element*>(jid_node);
You can create a structure that contains jid as an attribute and use automatic generation of serialization and deserialization
I tried, but roster result should has 'jid' attr, while with Serialization with BareJid I got
<NO_NAME username="n" server="s" >
Expected ResultRoster
See how it's done in SomeStruct5 in tests/serialization.cpp
Interesting, looks like last time I did something wrong and got <username="n" server="s"> instead. Will try t use BareJid
@ -0,0 +48,4 @@
using IqBind = Iq<Bind>;
inline auto MakeSetBind() {
return SetBind{.id = "1", .payload = Bind{}};
For what?
@ -126,2 +146,2 @@
}) //
| std::ranges::to<std::unordered_map<std::string_view, std::string_view>>();
auto params = std::views::split(decoded, ',') | std::views::transform([](auto param) {
return std::string_view{param};
Why? It was more readable before.
@ -72,0 +55,4 @@
std::string username;
std::string server;
constexpr operator FullJid() const {
return FullJid{.username = username, .server = server, .resource = ""};
Extra copying if there is an rvalue. Better to forward depending on the type with which it is called.
@ -0,0 +38,4 @@
}
friend constexpr auto operator<<(xmlpp::Element* element, const Roster& roster) {
element->set_attribute("xmlns", Roster::kDefaultNamespace);
std::ranges::for_each(roster.items, [element](const auto& item) {
Why not range based for?
@ -0,0 +51,4 @@
return {.items = item_nodes | std::views::transform([](const xmlpp::Node* node) {
auto item_element = dynamic_cast<const xmlpp::Element*>(node);
if(!item_element) {
throw std::runtime_error("Can't convert xmlpp::Node to xmlpp::Element");
You can create a structure that contains jid as an attribute and use automatic generation of serialization and deserialization
@ -0,0 +70,4 @@
using IqRoster = Iq<Roster>;
inline auto MakeGetRoster(const FullJid& jid) {
return GetRoster{.id = "1", .from = ToString(jid), .payload = Roster{}};
For what?
@ -297,1 +297,4 @@
template <typename T>
concept LengthCalculatable = requires(const T& obj) {
{ obj.length() } -> std::convertible_to<std::size_t>; // Checks if obj has a length() method returning a type convertible to std::size_t
A comment that doesn't explain anything and just repeats the code.
@ -0,0 +10,4 @@
FullJid jid{.username = "test", .server = "server", .resource = "res"}; // NOLINT
auto roster = iq::MakeGetRoster(jid);
roster.payload.items.emplace_back("u1", "s1");
roster.payload.items.emplace_back("u2", "s2");
Why not just throw all the necessary elements through the vector constructor in Roster constructor?
@ -0,0 +22,4 @@
ASSERT_EQ(roster.payload.items.size(), parse_res.payload.items.size());
for(const auto& [idx, expect_el, parsed_el] : std::views::zip(std::views::iota(0), roster.payload.items, parse_res.payload.items)) {
EXPECT_EQ(expect_el, parsed_el) << "Mismatched on idx: " << idx;
// std::cerr << " " << "idx: " << idx << "; expect_el: " << expect_el << "; parsed_el: " << parsed_el << '\n';
Code left in the comment
@ -0,0 +33,4 @@
roster.payload.items.emplace_back("u2", "s2");
roster.payload.items.emplace_back("u3", "s3");
EXPECT_NO_THROW({ std::cerr << "[ ] Roster payload: " << ToString(roster.payload) << '\n'; });
EXPECT_EQ and test content
@ -11,6 +12,8 @@ namespace iq {
template <auto& Name, typename PayloadType>
struct BaseImplWithPayload {
std::string id;
std::optional<std::string> from{};
Why std::string and not a more limited type like Jid ? Or for get or set use FullJid for from and BareJid in to, and in response or error make FullJid be in to and BareJid in from.
54b3535ebc
tod88f14a66d
@ -75,0 +95,4 @@
co_return;
}
auto UpdateListOfContacts() -> boost::asio::awaitable<void> {
Maybe we can change namings later
d88f14a66d
to1a9b293dee
1a9b293dee
to604b423d1c
604b423d1c
to30a5e69d14
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.