mirror of
https://gitlab.com/xmpp-rs/xmpp-rs.git
synced 2024-07-12 22:21:53 +00:00
Add a new CSI parser (XEP-0352).
This commit is contained in:
parent
b307652421
commit
05ab0cdc38
5 changed files with 74 additions and 0 deletions
|
@ -1,6 +1,7 @@
|
|||
Version NEXT:
|
||||
DATE Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
|
||||
* New parsers/serialisers:
|
||||
- Client State Indication (XEP-0352)
|
||||
- OpenPGP for XMPP (XEP-0373)
|
||||
* Breaking changes:
|
||||
- Presence constructors now take Into<Jid> and assume Some.
|
||||
|
|
8
doap.xml
8
doap.xml
|
@ -392,6 +392,14 @@
|
|||
<xmpp:since>0.13.0</xmpp:since>
|
||||
</xmpp:SupportedXep>
|
||||
</implements>
|
||||
<implements>
|
||||
<xmpp:SupportedXep>
|
||||
<xmpp:xep rdf:resource="https://xmpp.org/extensions/xep-0352.html"/>
|
||||
<xmpp:status>complete</xmpp:status>
|
||||
<xmpp:version>0.3.0</xmpp:version>
|
||||
<xmpp:since>NEXT</xmpp:since>
|
||||
</xmpp:SupportedXep>
|
||||
</implements>
|
||||
<implements>
|
||||
<xmpp:SupportedXep>
|
||||
<xmpp:xep rdf:resource="https://xmpp.org/extensions/xep-0353.html"/>
|
||||
|
|
59
src/csi.rs
Normal file
59
src/csi.rs
Normal file
|
@ -0,0 +1,59 @@
|
|||
// Copyright (c) 2019 Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
|
||||
//
|
||||
// This Source Code Form is subject to the terms of the Mozilla Public
|
||||
// License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
generate_empty_element!(
|
||||
/// Stream:feature sent by the server to advertise it supports CSI.
|
||||
Feature, "csi", CSI
|
||||
);
|
||||
|
||||
generate_empty_element!(
|
||||
/// Client indicates it is inactive.
|
||||
Inactive, "inactive", CSI
|
||||
);
|
||||
|
||||
generate_empty_element!(
|
||||
/// Client indicates it is active again.
|
||||
Active, "active", CSI
|
||||
);
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use minidom::Element;
|
||||
use std::convert::TryFrom;
|
||||
use crate::ns;
|
||||
|
||||
#[test]
|
||||
fn test_size() {
|
||||
assert_size!(Feature, 0);
|
||||
assert_size!(Inactive, 0);
|
||||
assert_size!(Active, 0);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn parsing() {
|
||||
let elem: Element = "<csi xmlns='urn:xmpp:csi:0'/>".parse().unwrap();
|
||||
Feature::try_from(elem).unwrap();
|
||||
|
||||
let elem: Element = "<inactive xmlns='urn:xmpp:csi:0'/>".parse().unwrap();
|
||||
Inactive::try_from(elem).unwrap();
|
||||
|
||||
let elem: Element = "<active xmlns='urn:xmpp:csi:0'/>".parse().unwrap();
|
||||
Active::try_from(elem).unwrap();
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn serialising() {
|
||||
let elem: Element = Feature.into();
|
||||
assert!(elem.is("csi", ns::CSI));
|
||||
|
||||
let elem: Element = Inactive.into();
|
||||
assert!(elem.is("inactive", ns::CSI));
|
||||
|
||||
let elem: Element = Active.into();
|
||||
assert!(elem.is("active", ns::CSI));
|
||||
}
|
||||
}
|
|
@ -177,6 +177,9 @@ pub mod idle;
|
|||
/// XEP-0320: Use of DTLS-SRTP in Jingle Sessions
|
||||
pub mod jingle_dtls_srtp;
|
||||
|
||||
/// XEP-0352: Client State Indication
|
||||
pub mod csi;
|
||||
|
||||
/// XEP-0353: Jingle Message Initiation
|
||||
pub mod jingle_message;
|
||||
|
||||
|
|
|
@ -182,6 +182,9 @@ pub const IDLE: &str = "urn:xmpp:idle:1";
|
|||
/// XEP-0320: Use of DTLS-SRTP in Jingle Sessions
|
||||
pub const JINGLE_DTLS: &str = "urn:xmpp:jingle:apps:dtls:0";
|
||||
|
||||
/// XEP-0352: Client State Indication
|
||||
pub const CSI: &str = "urn:xmpp:csi:0";
|
||||
|
||||
/// XEP-0353: Jingle Message Initiation
|
||||
pub const JINGLE_MESSAGE: &str = "urn:xmpp:jingle-message:0";
|
||||
|
||||
|
|
Loading…
Reference in a new issue