aboutsummaryrefslogtreecommitdiffstats
path: root/stanza/src/client
diff options
context:
space:
mode:
Diffstat (limited to 'stanza/src/client')
-rw-r--r--stanza/src/client/iq.rs9
-rw-r--r--stanza/src/client/message.rs15
-rw-r--r--stanza/src/client/presence.rs17
3 files changed, 37 insertions, 4 deletions
diff --git a/stanza/src/client/iq.rs b/stanza/src/client/iq.rs
index 6d0c671..50884aa 100644
--- a/stanza/src/client/iq.rs
+++ b/stanza/src/client/iq.rs
@@ -17,6 +17,9 @@ use crate::roster;
#[cfg(feature = "xep_0030")]
use crate::xep_0030::{self, info, items};
+#[cfg(feature = "xep_0060")]
+use crate::xep_0060::pubsub::{self, Pubsub};
+
#[cfg(feature = "xep_0199")]
use crate::xep_0199::{self, Ping};
@@ -42,6 +45,8 @@ pub enum Query {
DiscoInfo(info::Query),
#[cfg(feature = "xep_0030")]
DiscoItems(items::Query),
+ #[cfg(feature = "xep_0060")]
+ Pubsub(Pubsub),
#[cfg(feature = "xep_0199")]
Ping(Ping),
#[cfg(feature = "rfc_6121")]
@@ -67,6 +72,8 @@ impl FromElement for Query {
(Some(xep_0030::items::XMLNS), "query") => {
Ok(Query::DiscoItems(items::Query::from_element(element)?))
}
+ #[cfg(feature = "xep_0060")]
+ (Some(pubsub::XMLNS), "pubsub") => Ok(Query::Pubsub(Pubsub::from_element(element)?)),
_ => Ok(Query::Unsupported),
}
}
@@ -86,6 +93,8 @@ impl IntoElement for Query {
Query::DiscoInfo(query) => query.builder(),
#[cfg(feature = "xep_0030")]
Query::DiscoItems(query) => query.builder(),
+ #[cfg(feature = "xep_0060")]
+ Query::Pubsub(pubsub) => pubsub.builder(),
}
}
}
diff --git a/stanza/src/client/message.rs b/stanza/src/client/message.rs
index e521613..d94b82e 100644
--- a/stanza/src/client/message.rs
+++ b/stanza/src/client/message.rs
@@ -8,12 +8,14 @@ use peanuts::{
#[cfg(feature = "xep_0131")]
use crate::xep_0131::Headers;
+#[cfg(feature = "xep_0172")]
+use crate::xep_0172::Nick;
#[cfg(feature = "xep_0203")]
use crate::xep_0203::Delay;
use super::XMLNS;
-#[derive(Debug, Clone)]
+#[derive(Debug, Clone, Default)]
pub struct Message {
pub from: Option<JID>,
pub id: Option<String>,
@@ -29,6 +31,8 @@ pub struct Message {
pub delay: Option<Delay>,
#[cfg(feature = "xep_0131")]
pub headers: Option<Headers>,
+ #[cfg(feature = "xep_0172")]
+ pub nick: Option<Nick>,
}
impl FromElement for Message {
@@ -52,6 +56,9 @@ impl FromElement for Message {
#[cfg(feature = "xep_0131")]
let headers = element.child_opt()?;
+ #[cfg(feature = "xep_0172")]
+ let nick = element.child_opt()?;
+
Ok(Message {
from,
id,
@@ -65,6 +72,8 @@ impl FromElement for Message {
delay,
#[cfg(feature = "xep_0131")]
headers,
+ #[cfg(feature = "xep_0172")]
+ nick,
})
}
}
@@ -93,6 +102,9 @@ impl IntoElement for Message {
#[cfg(feature = "xep_0131")]
let builder = builder.push_child_opt(self.headers.clone());
+ #[cfg(feature = "xep_0172")]
+ let builder = builder.push_child_opt(self.nick.clone());
+
builder
}
}
@@ -137,6 +149,7 @@ impl ToString for MessageType {
#[derive(Clone, Debug)]
pub struct Body {
pub lang: Option<String>,
+ // TODO: string stuff
pub body: Option<String>,
}
diff --git a/stanza/src/client/presence.rs b/stanza/src/client/presence.rs
index 8fb96be..bffb0d0 100644
--- a/stanza/src/client/presence.rs
+++ b/stanza/src/client/presence.rs
@@ -8,12 +8,14 @@ use peanuts::{
#[cfg(feature = "xep_0131")]
use crate::xep_0131::Headers;
+#[cfg(feature = "xep_0172")]
+use crate::xep_0172::Nick;
#[cfg(feature = "xep_0203")]
use crate::xep_0203::Delay;
use super::{error::Error, XMLNS};
-#[derive(Debug, Clone)]
+#[derive(Debug, Clone, Default)]
pub struct Presence {
pub from: Option<JID>,
pub id: Option<String>,
@@ -28,8 +30,9 @@ pub struct Presence {
pub delay: Option<Delay>,
#[cfg(feature = "xep_0131")]
pub headers: Option<Headers>,
- // TODO: ##other
- // other: Vec<Other>,
+ #[cfg(feature = "xep_0172")]
+ pub nick: Option<Nick>,
+ // ##other
pub errors: Vec<Error>,
}
@@ -55,6 +58,9 @@ impl FromElement for Presence {
#[cfg(feature = "xep_0131")]
let headers = element.child_opt()?;
+ #[cfg(feature = "xep_0172")]
+ let nick = element.child_opt()?;
+
Ok(Presence {
from,
id,
@@ -69,6 +75,8 @@ impl FromElement for Presence {
delay,
#[cfg(feature = "xep_0131")]
headers,
+ #[cfg(feature = "xep_0172")]
+ nick,
})
}
}
@@ -92,6 +100,9 @@ impl IntoElement for Presence {
#[cfg(feature = "xep_0131")]
let builder = builder.push_child_opt(self.headers.clone());
+ #[cfg(feature = "xep_0172")]
+ let builder = builder.push_child_opt(self.nick.clone());
+
builder
}
}