Query roster

[?]
Dec 30, 2018, 10:28 AM
PFC7OJQFPAFGRAF4CDWVSFR5DERUNOBAIYOW2TKLROPL3VKKSBPQC

Dependencies

  • [2] HU3NZX5Z Process self-presence via new processing code
  • [3] PBRUH4BJ Rename optional XmppConnection to MaybeXmppConnection
  • [4] BTOZT4JP Use failure
  • [5] VS6AHRWI Move XMPP to separate dir
  • [6] XGP44R5H Rework stopping xmpp connection
  • [7] X6L47BHQ Use different structure for established xmpp connection
  • [8] IK3YDPTY Update deps
  • [9] AGIW6YR3 Use shared future for signal everywhere
  • [10] FV6BJ5K6 Send self-presence and store account info in Rc so it willbe used in some future in parallel
  • [11] QWE26TMV update deps
  • [12] TDOR5XQU Accept destination
  • [*] FVVPKFTL Initial commit

Change contents

  • edit in src/xmpp/stanzas.rs at line 2
    [3.57]
    [3.57]
    use xmpp_parsers::iq::Iq;
  • edit in src/xmpp/stanzas.rs at line 4
    [3.141]
    [3.141]
    use xmpp_parsers::roster::Roster;
  • edit in src/xmpp/stanzas.rs at line 14
    [3.419]
    pub fn make_get_roster(id: &str) -> Element {
    let mut get_roster = Iq::from_get(Roster {
    ver: None,
    items: vec![],
    });
    get_roster.id = Some(id.to_string());
    get_roster.into()
    }
  • edit in src/xmpp/mod.rs at line 68
    [2.1695]
    [2.1695]
    let stop_future3 = stop_future.clone();
  • replacement in src/xmpp/mod.rs at line 79
    [2.2243][2.2243:2334]()
    .and_then(|conn| conn.self_presence(stop_future2))
    [2.2243]
    [2.2334]
    .and_then(|conn| conn.initial_roster(stop_future2))
    .and_then(|conn| conn.self_presence(stop_future3))
  • replacement in src/xmpp/mod.rs at line 129
    [2.4047][2.4047:4116]()
    S: FnMut(&mut Self, &Event) -> Result<bool, failure::Error>,
    [2.4047]
    [2.4116]
    S: FnMut(&mut Self, Event) -> Result<bool, failure::Error>,
  • replacement in src/xmpp/mod.rs at line 143
    [2.4701][2.4701:4771]()
    match stop_condition(&mut xmpp, &event) {
    [2.4701]
    [2.4771]
    match stop_condition(&mut xmpp, event) {
  • replacement in src/xmpp/mod.rs at line 184
    [2.6432][2.6432:6506]()
    fn online(&mut self, event: &Event) -> Result<bool, failure::Error> {
    [2.6432]
    [2.6506]
    fn online(&mut self, event: Event) -> Result<bool, failure::Error> {
  • edit in src/xmpp/mod.rs at line 200
    [2.6926]
    [2.6926]
    fn initial_roster<F, E>(
    self,
    stop_future: F,
    ) -> impl Future<Item = Self, Error = std::rc::Rc<config::Account>>
    where
    F: Future<Error = E>,
    E: Into<failure::Error>,
    {
    let XmppConnection {
    account,
    inner: client,
    } = self;
    use tokio::prelude::Sink;
    let id_get_roster: String = "id_get_roster0".to_string();
  • edit in src/xmpp/mod.rs at line 217
    [2.6927]
    [2.6927]
    let get_roster = stanzas::make_get_roster(&id_get_roster);
    let account2 = account.clone();
    info!("Quering roster... {:?}", get_roster);
    client
    .send(get_roster)
    .map_err(move |e| {
    error!("Error on querying roster: {}", e);
    (account2, Err(failure::SyncFailure::new(e).into()))
    })
    .and_then(move |client| {
    XmppConnection {
    inner: client,
    account,
    }
    .processing(
    move |_conn, event| {
    if let Event::Stanza(s) = event {
    use try_from::TryInto;
    match s.try_into() as Result<xmpp_parsers::iq::Iq, _> {
    Ok(iq) => {
    if let Some(id) = iq.id {
    if id == id_get_roster {
    match iq.payload {
    xmpp_parsers::iq::IqType::Error(_e) => {
    Err(format_err!("Get error instead of roster"))
    }
    _ => Ok(true),
    }
    } else {
    Ok(false)
    }
    } else {
    Err(format_err!("Iq stanza without id"))
    }
    }
    Err(_e) => Ok(false),
    }
    } else {
    Err(format_err!("Wrong event while waiting roster"))
    }
    },
    stop_future,
    )
    })
    .then(|r| match r {
    Err((account, e)) => {
    error!(
    "Cann't wait roster: {}",
    e.err().map_or_else(
    || std::borrow::Cow::Borrowed("None"),
    |e| e.to_string().into()
    )
    );
    future::err(account)
    }
    Ok((conn, _)) => future::ok(conn),
    })
    }
  • replacement in src/xmpp/mod.rs at line 285
    [2.7144][3.6101:6155](),[3.745][3.6101:6155](),[3.6155][2.7145:7173]()
    let XmppConnection { account, inner } = self;
    let client = inner;
    [2.7144]
    [2.7173]
    let XmppConnection {
    account,
    inner: client,
    } = self;
  • edit in src/xmpp/mod.rs at line 292
    [2.7265][2.7265:7303]()
    info!("Sending presence...");
  • edit in src/xmpp/mod.rs at line 293
    [2.7343]
    [2.7343]
    info!("Sending presence... {:?}", presence);
  • replacement in src/xmpp/mod.rs at line 325
    [2.8497][2.8497:8536]()
    Err((account, e)) => {
    [2.8497]
    [2.8536]
    Err((account, _e)) => {
  • replacement in src/xmpp/mod.rs at line 400
    [3.6342][2.9797:9859]()
    future::err(format_err!("Cmd error"))
    [3.6342]
    [3.6572]
    future::err(e)
  • edit in Cargo.toml at line 23
    [3.7111]
    [3.7111]
    try_from = "=0.2.2" # dependency of xmpp-parsers
  • edit in Cargo.lock at line 1110
    [3.44807]
    [3.44807]
    "try_from 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",