TRSLPEEJUTUZXFDXLNUYPGTHZREGH5KGFHQFHVCD2AXOD5YAGBNQC impl IqHandler for SelfDiscoveryIqHandler {fn result(self: Box<Self>,conn: &mut XmppConnection,opt_element: Option<xmpp_parsers::Element>,) -> bool {if let Some(result) = opt_element {use std::convert::TryInto;match result.try_into() as Result<xmpp_parsers::disco::DiscoInfoResult, _> {Ok(self_discovery) => {conn.state.data.self_discovery_init = true;conn.state.data.self_pubsub_pep = false;for i in self_discovery.identities {if i.category == "pubsub" && i.type_ == "pep" {conn.state.data.self_pubsub_pep = true;break;}}info!("Support XEP-0163: Personal Eventing Protocol: {}",conn.state.data.self_pubsub_pep);true}Err(e) => {error!("Cann't parse self discovery: {}", e);false}}} else {error!("No self discovery");false}}fn error(self: Box<Self>,_conn: &mut XmppConnection,_error: xmpp_parsers::stanza_error::StanzaError,) -> bool {false}fn timeout(self: Box<Self>, _conn: &mut XmppConnection) -> bool {false}}
async fn self_discovery<F>(mut self,mut stop_future: F,) -> (Result<Self, std::rc::Rc<config::Account>>, Either<F, ()>)whereF: std::future::Future<Output = ()> + Unpin,{self.state.data.counter += 1;let id_self_discovery = format!("id_self_discovery{}", self.state.data.counter);let self_discovery = stanzas::make_disco_get(id_self_discovery.clone(),Some(self.account.jid.clone()),Some(xmpp_parsers::BareJid::from(self.account.jid.clone()).into()),);self.state.data.pending_ids.insert(id_self_discovery,IqWait::new(60, SelfDiscoveryIqHandler {}),);info!("Sending self discovery... {}",String::from(&self_discovery));let opt_stop_future = {let send_future = self.state.client.send_stanza(self_discovery);tokio::pin!(send_future);match futures_util::future::select(stop_future, send_future).await {Either::Left(((), _)) => None,Either::Right((Ok(_), stop_future)) => Some(stop_future),Either::Right((Err(e), f)) => {error!("Send self discovery error: {}", e);return (Err(self.account), Either::Left(f));}}};if let Some(f) = opt_stop_future {stop_future = f;} else {return (Ok(self), Either::Right(()));}(Ok(self), Either::Left(stop_future))}
pub fn make_disco_get(id: String,from: Option<xmpp_parsers::Jid>,to: Option<xmpp_parsers::Jid>,) -> Element {let mut get = Iq::from_get(id, DiscoInfoQuery { node: None });get.from = from;get.to = to;get.into()}