5GINRCKLDLAQ7J32MLENDUBXZTVSLGPJFARMHUPKSRXVBT75BG3QC
DISBBP3IQHP5YL654247RYGOB3KGEF5TG62HZTYLMZBGDTVNV7ZAC
J7VX56FW5BPM77MEFTKK6HP2ZOWRXP6GFUTBTQKBO52EBGFTVXMQC
FV6BJ5K64QG63YI2PTII44ZEBAYNJBQZ5FSBHW65EPHGBKFGUW4AC
37OMJ4CKEJIHMGWDGILSULMALWUTXSIL2DK2SBEHLKECFZUG2P5QC
OB3HA2MD7TDBGGURKXNQKLLLC5FAAD5OX5BENF3M2XNU7OTJ5HHAC
VS6AHRWIPIMQNQAFX7INQGSUB72OW2K6HM6NGOV76RBRF6COQFRQC
RGOSS73USO7B6YLKHSZ5R3K4OIZA56JXFVHPFFCNKSTWG7INPC7QC
FVVPKFTLD5VOGVDF7MOSSKQ3KPCT4HDGTNTTC6I6B4TWXOTPCJ7AC
X6L47BHQPIWFWO53QU6GMRYZC7VPFR4AFTJV7MZIJWIMZG5L65WQC
5Y6YJ6UH55XJLPQ627ZGKTHW3IUFPFS5C4AYNCS6BX4BAWPLEZQAC
HKSQO7JZEW6GXKPDJD4VJSYCJJBUDLKVN7SGUU5ZEMIVGII455RAC
AA2ZWGRLFD5XV3LYOFJU7ELWMVKGXTNUSH4BJNLXFWPSSTDZWO2AC
}
pub fn make_muc_presence_leave(from: xmpp_parsers::Jid, to: xmpp_parsers::Jid) -> Element {
let mut presence = Presence::new(PresenceType::Unavailable);
presence.from = Some(from);
presence.to = Some(to);
presence.into()
}
pub fn make_ping(id: &str, from: xmpp_parsers::Jid) -> Element {
let mut ping = Iq::from_get(Ping);
ping.id = Some(id.to_string());
ping.to = Some(from.clone().into_domain_jid());
ping.from = Some(from);
ping.into()
}
fn shutdown(self) -> impl Future<Item = (), Error = failure::Error> {
info!("Shutdown connection");
let XmppConnection { account, state } = self;
stream::iter_ok(
state
.data
.mucs
.values()
.map(std::clone::Clone::clone)
.collect::<Vec<_>>(),
)
.fold(state, move |XmppState { client, data }, muc_jid| {
let muc_presence =
stanzas::make_muc_presence_leave(account.jid.clone(), muc_jid.clone());
info!("Sending muc leave presence... {:?}", muc_presence);
use tokio::prelude::Sink;
client
.send(Packet::Stanza(muc_presence))
.map_err(|e| {
error!("Error on send muc presence: {}", e);
e
})
.and_then(|client| future::ok(XmppState { client, data }))
})
.map(|_| ())
.and_then(|s| {
std::str::FromStr::from_str(s)
.map_err(std::convert::Into::into)
})
.and_then(|s| std::str::FromStr::from_str(s).map_err(std::convert::Into::into))
if let Some(ping) = config.account.ping {
let ping = tokio::timer::Interval::new_interval(std::time::Duration::from_secs(ping));
rt.spawn(
ping.map_err(|e| {
error!("Ping error: {}", e);
})
.for_each(move |_| {
cmd_send
.clone()
.send(XmppCommand::Ping)
.map_err(|e| {
error!("Ping command error: {}", e);
})
.map(|_| ())
})
.select(
ctrl_c
.clone()
.map(|_| ())
.map_err(|e| error!("ping server error: {}", e)),
)
.map(|_| ())
.map_err(|_| ()),
);
}
}
fn deserialize_jid_map<'de, D>(
deserializer: D,
) -> Result<HashMap<String, xmpp_parsers::Jid>, D::Error>
where
D: serde::Deserializer<'de>,
{
use serde::Deserialize;
let s = HashMap::<String, String>::deserialize(deserializer)?;
let size = s.len();
s.into_iter()
.map(|(k, v)| (k, std::str::FromStr::from_str(&v)))
.take_while(|(_k, r)| r.is_ok())
.fold(Ok(HashMap::with_capacity(size)), |res, (k, r)| match res {
Ok(mut res) => match r {
Ok(v) => {
res.insert(k, v);
Ok(res)
}
Err(e) => Err(e),
},
Err(e) => Err(e),
})
.map_err(serde::de::Error::custom)
"cfg-if 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)",
"cfg-if 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.49 (registry+https://github.com/rust-lang/crates.io-index)",
"cfg-if 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)",
"cfg-if 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.49 (registry+https://github.com/rust-lang/crates.io-index)",
"cfg-if 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)",
"cfg-if 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.49 (registry+https://github.com/rust-lang/crates.io-index)",
"cfg-if 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)",
"cfg-if 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.49 (registry+https://github.com/rust-lang/crates.io-index)",
"checksum bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)" = "206fdffcfa2df7cbe15601ef46c813fce0965eb3286db6b56c583b814b51c81c"
"checksum bytes 0.4.11 (registry+https://github.com/rust-lang/crates.io-index)" = "40ade3d27603c2cb345eb0912aec461a6dec7e06a4ae48589904e808335c7afa"
"checksum cfg-if 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)" = "11d43355396e872eefb45ce6342e4374ed7bc2b3a502d1b28e36d6e23c05d1f4"
"checksum cfg-if 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "082bb9b28e00d3c9d39cc03e64ce4cea0f1bb9b3fde493f0cbc008472d22bdf4"
"checksum env_logger 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b61fa891024a945da30a9581546e8cfaf5602c7b3f4c137a2805cf388f92075a"
"checksum env_logger 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "afb070faf94c85d17d50ca44f6ad076bce18ae92f0037d350947240a36e9d42e"
"checksum libc 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)" = "aab692d7759f5cd8c859e169db98ae5b52c924add2af5fbbca11d12fefb567c1"
"checksum libc 0.2.49 (registry+https://github.com/rust-lang/crates.io-index)" = "413f3dfc802c5dc91dc570b05125b6cda9855edfaa9825c9849807876376e70e"
"checksum rand_os 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "7b75f676a1e053fc562eafbb47838d67c84801e38fc1ba459e8f180deabd5071"
"checksum rand_os 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "b7c690732391ae0abafced5015ffb53656abfaec61b342290e5eb56b286a679d"
"checksum syn 0.15.28 (registry+https://github.com/rust-lang/crates.io-index)" = "218aa5a01ab9805df6e9e48074c8d88f317cc9660b1ad6c3dabac2d627d185d6"
"checksum syn 0.15.27 (registry+https://github.com/rust-lang/crates.io-index)" = "525bd55255f03c816e5d7f615587bd13030c7103354fadb104993dcee6a788ec"