presence: Wire up idle as a payload.

This commit is contained in:
Emmanuel Gil Peyrot 2017-05-21 20:30:42 +01:00
parent dc530a1912
commit 34ee6d52dc

View file

@ -18,6 +18,7 @@ use ns;
use stanza_error::StanzaError; use stanza_error::StanzaError;
use delay::Delay; use delay::Delay;
use idle::Idle;
use ecaps2::ECaps2; use ecaps2::ECaps2;
#[derive(Debug, Clone, PartialEq)] #[derive(Debug, Clone, PartialEq)]
@ -50,6 +51,7 @@ pub type Priority = i8;
pub enum PresencePayload { pub enum PresencePayload {
StanzaError(StanzaError), StanzaError(StanzaError),
Delay(Delay), Delay(Delay),
Idle(Idle),
ECaps2(ECaps2), ECaps2(ECaps2),
Unknown(Element), Unknown(Element),
@ -65,6 +67,9 @@ impl<'a> TryFrom<&'a Element> for PresencePayload {
// XEP-0203 // XEP-0203
("delay", ns::DELAY) => PresencePayload::Delay(Delay::try_from(elem)?), ("delay", ns::DELAY) => PresencePayload::Delay(Delay::try_from(elem)?),
// XEP-0319
("idle", ns::IDLE) => PresencePayload::Idle(Idle::try_from(elem)?),
// XEP-0390 // XEP-0390
("c", ns::ECAPS2) => PresencePayload::ECaps2(ECaps2::try_from(elem)?), ("c", ns::ECAPS2) => PresencePayload::ECaps2(ECaps2::try_from(elem)?),
@ -78,6 +83,7 @@ impl<'a> Into<Element> for &'a PresencePayload {
match *self { match *self {
PresencePayload::StanzaError(ref stanza_error) => stanza_error.into(), PresencePayload::StanzaError(ref stanza_error) => stanza_error.into(),
PresencePayload::Delay(ref delay) => delay.into(), PresencePayload::Delay(ref delay) => delay.into(),
PresencePayload::Idle(ref idle) => idle.into(),
PresencePayload::ECaps2(ref ecaps2) => ecaps2.into(), PresencePayload::ECaps2(ref ecaps2) => ecaps2.into(),
PresencePayload::Unknown(ref elem) => elem.clone(), PresencePayload::Unknown(ref elem) => elem.clone(),