Change summary
examples/client.rs | 1 +
src/plugins/ibb.rs | 20 ++++++++++++++++++++
2 files changed, 21 insertions(+)
Detailed changes
@@ -28,6 +28,7 @@ fn main() {
client.register_plugin(IbbPlugin::new());
client.register_plugin(PingPlugin::new());
client.plugin::<PingPlugin>().init();
+ client.plugin::<IbbPlugin>().init();
client.register_handler(Priority::Max, |e: &MessageEvent| {
println!("{:?}", e);
Propagation::Continue
@@ -8,9 +8,11 @@ use event::{Event, Priority, Propagation};
use jid::Jid;
use plugins::stanza::Iq;
+use plugins::disco::DiscoPlugin;
use xmpp_parsers::iq::{IqType, IqPayload};
use xmpp_parsers::ibb::{IBB, Stanza};
use xmpp_parsers::stanza_error::{StanzaError, ErrorType, DefinedCondition};
+use xmpp_parsers::ns;
#[derive(Debug, Clone)]
pub struct Session {
@@ -66,6 +68,24 @@ impl IbbPlugin {
}
}
+ // TODO: make that called automatically after plugins are created.
+ pub fn init(&self) {
+ if let Some(disco) = self.proxy.plugin::<DiscoPlugin>() {
+ disco.add_feature(ns::IBB);
+ } else {
+ panic!("Please handle dependencies in the correct order.");
+ }
+ }
+
+ // TODO: make that called automatically before removal.
+ pub fn deinit(&self) {
+ if let Some(disco) = self.proxy.plugin::<DiscoPlugin>() {
+ disco.remove_feature(ns::IBB);
+ } else {
+ panic!("Please handle dependencies in the correct order.");
+ }
+ }
+
fn handle_ibb(&self, from: Jid, ibb: IBB) -> Result<(), StanzaError> {
let mut sessions = self.sessions.lock().unwrap();
match ibb {