Commit graph

306 commits

Author SHA1 Message Date
Jonas Schäfer
58698f633f xso: only take reference in transform
This avoids the need for an expensive clone. Since we switched to AsXml
instead of IntoXml, we don't necessarily have to clone the data when
building new elements, only when it's absolutely necessary. The clones
then happen implicitly in the ItemToEvent iterator used internally.

This mostly fixes #86, with the caveat that there's no absolutely cheap
test: On success, the entire element will be copied, while on failure,
you learn about it rather quickly.
2024-12-20 12:44:43 +01:00
xmppftw
9901141b5f parsers: Rename Message::get_best_owned to get_best_cloned 2024-12-20 00:29:03 +01:00
xmppftw
087534be1e parsers: Replace std stuff with alloc/core stuff 2024-12-19 20:45:38 +01:00
xmppftw
6e3f31ef46 parsers: Add get_best_{body,subject}_owned methods for Message 2024-12-19 17:46:01 +01:00
xmppftw
50425617b5 parsers: Add Message::extract_valid_payload helper 2024-12-19 17:36:10 +01:00
xmppftw
7991cef904 Add tests for crate exports ; add structure to imports/exports 2024-12-18 18:03:18 +00:00
Emmanuel Gil Peyrot
1b4a307919 xmpp-parsers: Convert DiscoInfoResult to xso
This disables some tests, but those were controversial anyway.

I was thinking about replacing the Feature struct with a plain String,
what do you think about it?
2024-12-18 18:50:50 +01:00
Emmanuel Gil Peyrot
893a2f8e47 xmpp-parsers: Convert Presence to xso
The two remaining issues, which led to two ignored tests, are that
priority now gets always serialized, and that we don’t reject duplicated
identical xml:lang in statuses.
2024-12-18 15:49:06 +00:00
xmppftw
c16456f381 parsers/xmpp: MUC bookmarks have nickname typed as ResourcePart 2024-12-18 15:43:09 +00:00
Emmanuel Gil Peyrot
3c77ee0cc7 xmpp-parsers: Add support for <alternative-session><sid/></>
This was previously unimplemented due to how the enum was treated, now
that we moved the reason element to xso we can describe it properly and
thus implement everything it supports.

This causes one regression on xml:lang validation, but we can live with
that until xso implements such verification.
2024-12-18 16:08:24 +01:00
Emmanuel Gil Peyrot
cd43aa2fcb xmpp-parsers: Convert the Actor enum into a struct
XEP-0045 doesn’t specify what to do in the case the actor contains both
a @jid and a @nick, so let’s not encode anything special about that
here.

In addition this converted it to use xso.

Supersedes !196.

Fixes #88.
2024-12-17 18:20:52 +01:00
Jonas Schäfer
80f899daa0 tokio_xmpp: implement high-level, resilient stanza stream 2024-12-17 18:16:02 +01:00
Emmanuel Gil Peyrot
7fca02958b xmpp-parsers: Fix jingle thumbnails wrt the XEP changes
Version 0.4.2 added a restriction on width and height to be in the
0..65535 range.  The media-type attribute has always been optional as
well.
2024-12-17 00:27:15 +01:00
xmppftw
580fdeffa9 Added a test for prosody bug 1664 workaround 2024-12-16 15:19:54 +00:00
Emmanuel Gil Peyrot
011585594f xmpp: Adapt to xmpp-parsers changes wrt autojoin
This attribute is now a simple bool instead of an enum.
2024-12-16 13:32:49 +00:00
Emmanuel Gil Peyrot
866991bda5 xmpp-parsers: Replace all instances of bool attributes with bool
These bring basically nothing, so we can throw them away alongside their
generator macro.
2024-12-16 13:32:49 +00:00
Emmanuel Gil Peyrot
16b232523d xmpp-parsers: Convert vCard-temp to xso
This also keeps all additional elements in the vCard, so they get
serialized back on the wire instead of being dropped.
2024-12-15 17:38:56 +00:00
Emmanuel Gil Peyrot
aaf2dd7925 xmpp-parsers: Convert bookmarks2 to xso 2024-12-15 17:38:56 +00:00
Emmanuel Gil Peyrot
1c22e17955 xmpp-parsers: Convert Jingle File Transfer to xso 2024-12-15 17:38:56 +00:00
Emmanuel Gil Peyrot
af0bd35e7a xmpp-parsers: Implement XEP-0490: Message Displayed Synchronization
This XEP is used to synchronize where each client has stopped reading a
conversation, so that we can e.g. stop displaying a notification when
the user has read this particular message on a different device.
2024-12-15 17:30:24 +00:00
Emmanuel Gil Peyrot
d738939f89 xmpp-parsers: Simplify hash conversion to Vec
Use `GenericArray::to_vec()` and `slice::to_vec()` directly.
2024-12-15 17:17:01 +00:00
Emmanuel Gil Peyrot
57e6e98c6a xmpp-parsers: Add test for StartTLS
This tests each element we support, and also keep track of the sizes.

Additionally the copyright year was wrong.
2024-12-15 17:45:26 +01:00
Jonas Schäfer
7d8ffe45a7 xso: add support for ignoring unknown stuff in extracts 2024-10-26 17:37:32 +00:00
Jonas Schäfer
66233b0150 xso: add support for ignoring unknown children 2024-10-26 17:37:32 +00:00
Jonas Schäfer
290460ba9d xso: add support for ignoring unknown attributes 2024-10-26 17:37:32 +00:00
Alvaro Parker
2ff89a9e42 fix typos 2024-09-16 18:29:44 -03:00
Jonas Schäfer
a503c8534f parsers: add support for handled-count-too-high error 2024-09-01 13:01:29 +02:00
Jonas Schäfer
0f0759b207 parsers: add support for <optional/> in stream management feature 2024-09-01 13:01:29 +02:00
Jonas Schäfer
bfe723cf46 parsers: make stream errors more ergonomic for error processing 2024-09-01 08:54:50 +00:00
Jonas Schäfer
b39ad99ecd parsers: add stream error XSO 2024-09-01 08:54:50 +00:00
xmppftw
df106dfbaf Relative dependencies 2024-08-12 10:39:09 +00:00
Jonas Schäfer
54e1a98cde parsers: add starttls XSOs 2024-08-12 12:35:26 +02:00
Jonas Schäfer
3c78310272 parsers: add umbrella enum for SASL elements
This is useful if, for example during stream negotiation, you want to
parse SASL elements and nothing else. It is also useful if you want to
write down an enum of all XMPP-related stream-level elements you accept
and don't want to loose your fingers typing all the SASL options.
2024-08-12 12:32:12 +02:00
Jonas Schäfer
fc68a57757 parsers: provide stub FromXml/AsXml implementations on Presence 2024-08-12 12:32:12 +02:00
Jonas Schäfer
b931af3c25 parsers: provide stub FromXml/AsXml implementations on Iq 2024-08-12 12:32:12 +02:00
xmppftw
e153468117 Link is link, remove doc warning 2024-08-11 17:22:31 +00:00
Jonas Schäfer
cbc4648b3c parsers: port SASL over to derive macros
You may note that I removed the `exhaustive` flag on the
DefinedCondition enum. This is because other elements in the same
namespace may occur as siblings of that enum, hence using `exhaustive`
may cause incorrect parse errors.

(If parsing attempts to process the `<text/>` child as DefinedCondition
first, DefinedCondition will return a fatal parser error if it is set as
exhaustive because no condition matches `text`.)
2024-08-11 07:58:13 +02:00
Jonas Schäfer
1ecb95881c xso: add support for extracting tuples 2024-08-11 07:58:12 +02:00
Jonas Schäfer
2ff81b3923 xso: add support for fallible parsing and serialisation 2024-08-11 07:45:05 +02:00
Emmanuel Gil Peyrot
d706b318c3 xmpp-parsers: Remove the generate_element!() macro
The last users have now been converted to xso.
2024-08-09 16:08:26 +02:00
Emmanuel Gil Peyrot
4f81411410 xmpp-parsers: Convert Jingle to xso 2024-08-09 16:08:26 +02:00
Emmanuel Gil Peyrot
cb2c4133fe xmpp-parsers: Convert Forwarded to xso 2024-08-09 16:08:26 +02:00
Emmanuel Gil Peyrot
6b167ed677 xmpp-parsers: Convert disco#info identity to xso 2024-08-09 16:08:26 +02:00
Emmanuel Gil Peyrot
2690e62060 xmpp-parsers: Convert roster item to xso 2024-08-09 16:08:26 +02:00
Emmanuel Gil Peyrot
d4f6812386 xmpp-parsers: Convert cert_management to xso
This introduces a breaking change by moving from a bool to an
Option<NoCertManagement>, which will be reverted eventually once we add
support for #[xml(flag)] types of children.
2024-08-09 16:08:26 +02:00
Jonas Schäfer
fb80bb7532 xso: add support for dynamic enums 2024-08-08 15:25:40 +00:00
Emmanuel Gil Peyrot
8e16ae1cbb xmpp-parsers: Integrate sasl2 and sasl_cb into stream:features 2024-08-08 13:52:01 +00:00
Emmanuel Gil Peyrot
7238ebc35e xmpp-parsers: Integrate bind2 and sm into sasl2 2024-08-08 13:52:01 +00:00
Emmanuel Gil Peyrot
27e4499153 xmpp-parsers: Simplify SASL mechanisms type
These can be a simple String for now.
2024-08-08 13:52:01 +00:00
Emmanuel Gil Peyrot
d8e08df464 xmpp-parsers: Implement XEP-0478: Stream Limits Advertisement
This allows servers to communicate their maximum stanza limit, as well
as idle time limit.
2024-08-07 20:59:30 +02:00