forked from lavina/lavina
Sketch x tag internals
This commit is contained in:
parent
b2a06ef984
commit
a22017ee8f
|
@ -487,6 +487,7 @@ impl<T: ToXml> ToXml for Iq<T> {
|
||||||
|
|
||||||
#[derive(PartialEq, Eq, Debug)]
|
#[derive(PartialEq, Eq, Debug)]
|
||||||
pub struct Presence<T> {
|
pub struct Presence<T> {
|
||||||
|
pub id: Option<String>,
|
||||||
pub to: Option<Jid>,
|
pub to: Option<Jid>,
|
||||||
pub from: Option<Jid>,
|
pub from: Option<Jid>,
|
||||||
pub priority: Option<PresencePriority>,
|
pub priority: Option<PresencePriority>,
|
||||||
|
@ -499,6 +500,7 @@ pub struct Presence<T> {
|
||||||
impl<T> Default for Presence<T> {
|
impl<T> Default for Presence<T> {
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
Self {
|
Self {
|
||||||
|
id: Default::default(),
|
||||||
to: Default::default(),
|
to: Default::default(),
|
||||||
from: Default::default(),
|
from: Default::default(),
|
||||||
priority: Default::default(),
|
priority: Default::default(),
|
||||||
|
@ -573,6 +575,10 @@ impl<T: FromXml> FromXml for Presence<T> {
|
||||||
let s = std::str::from_utf8(&attr.value)?;
|
let s = std::str::from_utf8(&attr.value)?;
|
||||||
p.r#type = Some(s.into());
|
p.r#type = Some(s.into());
|
||||||
}
|
}
|
||||||
|
b"id" => {
|
||||||
|
let s = std::str::from_utf8(&attr.value)?;
|
||||||
|
p.r#type = Option::from(s.to_string());
|
||||||
|
}
|
||||||
_ => {}
|
_ => {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -660,6 +666,12 @@ impl<T: ToXml> ToXml for Presence<T> {
|
||||||
value: from.to_string().as_bytes().into(),
|
value: from.to_string().as_bytes().into(),
|
||||||
}]);
|
}]);
|
||||||
}
|
}
|
||||||
|
if let Some(ref id) = self.id {
|
||||||
|
start.extend_attributes([Attribute {
|
||||||
|
key: QName(b"id"),
|
||||||
|
value: id.to_string().as_bytes().into(),
|
||||||
|
}]);
|
||||||
|
}
|
||||||
events.push(Event::Start(start));
|
events.push(Event::Start(start));
|
||||||
if let Some(ref priority) = self.priority {
|
if let Some(ref priority) = self.priority {
|
||||||
let s = priority.0.to_string();
|
let s = priority.0.to_string();
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
#![allow(unused_variables)]
|
#![allow(unused_variables)]
|
||||||
|
|
||||||
use quick_xml::events::{BytesStart, Event};
|
use quick_xml::events::{BytesEnd, BytesStart, Event};
|
||||||
use quick_xml::name::ResolveResult;
|
use quick_xml::name::ResolveResult;
|
||||||
|
|
||||||
use crate::xml::*;
|
use crate::xml::*;
|
||||||
|
@ -150,7 +150,23 @@ impl ToXml for XUser {
|
||||||
fn serialize(&self, output: &mut Vec<Event<'static>>) {
|
fn serialize(&self, output: &mut Vec<Event<'static>>) {
|
||||||
let mut tag = BytesStart::new("x");
|
let mut tag = BytesStart::new("x");
|
||||||
tag.push_attribute(("xmlns", XMLNS_USER));
|
tag.push_attribute(("xmlns", XMLNS_USER));
|
||||||
output.push(Event::Empty(tag));
|
output.push(Event::Start(tag));
|
||||||
|
|
||||||
|
let mut meg = BytesStart::new("item");
|
||||||
|
meg.push_attribute(("affiliation", "owner"));
|
||||||
|
meg.push_attribute(("role", "moderator"));
|
||||||
|
meg.push_attribute(("jid", "sauer@localhost"));
|
||||||
|
output.push(Event::Empty(meg));
|
||||||
|
|
||||||
|
let mut veg = BytesStart::new("status");
|
||||||
|
veg.push_attribute(("code", "100"));
|
||||||
|
output.push(Event::Empty(veg));
|
||||||
|
|
||||||
|
let mut veg = BytesStart::new("status");
|
||||||
|
veg.push_attribute(("code", "110"));
|
||||||
|
output.push(Event::Empty(veg));
|
||||||
|
|
||||||
|
output.push(Event::End(BytesEnd::new("x")));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue