Add counter for id. Check for jid in roster

[?]
Jan 1, 2019, 11:33 AM
EBETRYK7RNRATWD75LTFUTPF6M6KB6YPKTQUX4K232JB6CKVOZOQC

Dependencies

  • [2] UMTLHH77 Process commands in the separate function
  • [3] XGP44R5H Rework stopping xmpp connection
  • [4] UIXIQHDY Wait for commands via new processing code
  • [5] WJNXI6Z4 Fill roster
  • [6] QTCUURXN Add additional requirement for command stream
  • [7] UWY5EVZ6 Add dummy roster data
  • [8] OANBCLN5 Move xmpp client into XmppState
  • [9] FWJDW3G5 Allow process xmpp incoming stanzas with futures
  • [10] ALP2YJIU Rename XmppState to XmppProcessState
  • [11] VS6AHRWI Move XMPP to separate dir
  • [12] 5IKA4GO7 Rename xmpp client field from "inner" to "client"
  • [13] BWDUANCV Second part of processing result is only about stop_future
  • [*] QWE26TMV update deps
  • [*] FV6BJ5K6 Send self-presence and store account info in Rc so it willbe used in some future in parallel

Change contents

  • edit in src/xmpp/mod.rs at line 7
    [15.48]
    [16.420]
    use std::collections::HashMap;
  • edit in src/xmpp/mod.rs at line 16
    [3.393]
    [3.428]
    roster: HashMap<jid::Jid, ()>,
    counter: usize,
  • replacement in src/xmpp/mod.rs at line 94
    [3.435][2.483:556]()
    state: XmppState { client },
    [3.435]
    [3.494]
    state: XmppState {
    client,
    roster: HashMap::new(),
    counter: 0,
    },
  • edit in src/xmpp/mod.rs at line 102
    [3.1403][2.557:620]()
    .map(|(conn, _)| conn)
  • edit in src/xmpp/mod.rs at line 103
    [3.1468]
    [3.1838]
    .and_then(|(conn, r)| match r {
    Ok(Either::A(_)) => future::ok(conn),
    Ok(Either::B(_)) => future::err(conn.account),
    Err(_e) => future::err(conn.account),
    })
  • replacement in src/xmpp/mod.rs at line 137
    [3.3788][2.621:672]()
    fn xmpp_processing(&mut self, event: &Event) {
    [3.3788]
    [3.2073]
    fn xmpp_processing(
    self,
    event: &Event,
    ) -> impl Future<Item = Self, Error = std::rc::Rc<config::Account>> {
  • edit in src/xmpp/mod.rs at line 142
    [3.2124]
    [3.2124]
    future::ok(self)
  • replacement in src/xmpp/mod.rs at line 147
    [3.3983][2.673:709]()
    /// or stop future was resolved
    [3.3983]
    [3.4019]
    /// or stop future was resolved.
    /// Return item if connection was preserved or error otherwise.
    /// Second part is a state of stop_future
  • replacement in src/xmpp/mod.rs at line 155
    [3.4137][2.710:892]()
    Item = (Self, Result<Either<F, T>, failure::Error>),
    Error = (
    std::rc::Rc<config::Account>,
    Result<Either<F, T>, failure::Error>,
    ),
    [3.4137]
    [3.4319]
    Item = (Self, Result<Either<F, T>, E>),
    Error = (std::rc::Rc<config::Account>, Result<Either<F, T>, E>),
  • replacement in src/xmpp/mod.rs at line 159
    [3.4335][2.893:1034]()
    F: Future<Item = T, Error = E>,
    E: Into<failure::Error>,
    S: FnMut(&mut Self, Event) -> Result<bool, failure::Error>,
    [3.4335]
    [3.4476]
    F: Future<Item = T, Error = E> + 'static,
    S: FnMut(&mut Self, Event) -> Result<bool, ()> + 'static,
    T: 'static,
    E: 'static,
  • replacement in src/xmpp/mod.rs at line 167
    [3.4612][2.1035:1147]()
    let XmppConnection { state, account } = xmpp;
    state
    .client
    [3.4612]
    [2.1147]
    let XmppConnection {
    state:
    XmppState {
    client,
    roster,
    counter,
    },
    account,
    } = xmpp;
    client
  • replacement in src/xmpp/mod.rs at line 179
    [2.1224][2.1224:1264]()
    .then(|r| match r {
    [2.1224]
    [2.1264]
    .then(move |r| match r {
  • replacement in src/xmpp/mod.rs at line 182
    [2.1386][2.1386:1515]()
    let mut xmpp = XmppConnection {
    state: XmppState { client },
    [2.1386]
    [2.1515]
    let xmpp = XmppConnection {
    state: XmppState {
    client,
    roster,
    counter,
    },
  • replacement in src/xmpp/mod.rs at line 190
    [2.1595][2.1595:1730](),[2.1730][3.1639:2096](),[3.2169][3.1639:2096](),[3.1639][3.1639:2096](),[3.2096][2.1731:1848]()
    xmpp.xmpp_processing(&event);
    match stop_condition(&mut xmpp, event) {
    Ok(true) => {
    future::ok(future::Loop::Break((xmpp, Ok(Either::A(b)))))
    }
    Ok(false) => future::ok(future::Loop::Continue((
    xmpp,
    b,
    stop_condition,
    ))),
    Err(e) => future::err((xmpp.account, Err(e))),
    }
    [2.1595]
    [2.1848]
    Box::new(xmpp.xmpp_processing(&event).then(|r| match r {
    Ok(mut xmpp) => match stop_condition(&mut xmpp, event) {
    Ok(true) => future::ok(future::Loop::Break((
    xmpp,
    Ok(Either::A(b)),
    ))),
    Ok(false) => future::ok(future::Loop::Continue((
    xmpp,
    b,
    stop_condition,
    ))),
    Err(_e) => future::err((xmpp.account, Ok(Either::A(b)))),
    },
    Err(account) => future::err((account, Ok(Either::A(b)))),
    }))
    as Box<dyn Future<Item = _, Error = _>>
  • replacement in src/xmpp/mod.rs at line 207
    [2.1885][2.1885:1958]()
    future::err((account, Ok(Either::A(b))))
    [2.1885]
    [2.1958]
    Box::new(future::err((account, Ok(Either::A(b)))))
  • replacement in src/xmpp/mod.rs at line 210
    [2.2014][2.2014:2368]()
    Ok(Either::B((t, a))) => {
    if let Some(client) = a.into_inner() {
    future::ok(future::Loop::Break((
    XmppConnection {
    state: XmppState { client },
    account,
    [2.2014]
    [2.2368]
    Ok(Either::B((t, a))) => Box::new(if let Some(client) = a.into_inner() {
    future::ok(future::Loop::Break((
    XmppConnection {
    state: XmppState {
    client,
    roster,
    counter,
  • replacement in src/xmpp/mod.rs at line 218
    [2.2407][2.2407:2663]()
    Ok(Either::B(t)),
    )))
    } else {
    future::err((account, Ok(Either::B(t))))
    }
    }
    [2.2407]
    [2.2663]
    account,
    },
    Ok(Either::B(t)),
    )))
    } else {
    future::err((account, Ok(Either::B(t))))
    }),
  • replacement in src/xmpp/mod.rs at line 227
    [2.2773][2.2773:2842]()
    future::err((account, Ok(Either::A(b))))
    [2.2773]
    [2.2842]
    Box::new(future::err((account, Ok(Either::A(b)))))
  • replacement in src/xmpp/mod.rs at line 229
    [2.2868][2.2868:3223]()
    Err(Either::B((e, a))) => {
    if let Some(client) = a.into_inner() {
    future::ok(future::Loop::Break((
    XmppConnection {
    state: XmppState { client },
    account,
    [2.2868]
    [2.3223]
    Err(Either::B((e, a))) => Box::new(if let Some(client) = a.into_inner() {
    future::ok(future::Loop::Break((
    XmppConnection {
    state: XmppState {
    client,
    roster,
    counter,
  • replacement in src/xmpp/mod.rs at line 237
    [2.3262][2.3262:3486](),[2.3486][3.2940:2966](),[3.2573][3.2940:2966](),[3.2940][3.2940:2966]()
    Err(e.into()),
    )))
    } else {
    future::err((account, Err(e.into())))
    }
    }
    [2.3262]
    [2.3487]
    account,
    },
    Err(e),
    )))
    } else {
    future::err((account, Err(e)))
    }),
  • replacement in src/xmpp/mod.rs at line 250
    [3.6691][2.3511:3630]()
    /// returns error if something went wrong
    fn online(&mut self, event: Event) -> Result<bool, failure::Error> {
    [3.6691]
    [3.4011]
    /// returns error if something went wrong and xmpp connection is broken
    fn online(&mut self, event: Event) -> Result<bool, ()> {
  • replacement in src/xmpp/mod.rs at line 263
    [3.4339][2.3631:3693]()
    Err(format_err!("Disconnected while online"))
    [3.4339]
    [3.4363]
    Err(())
  • replacement in src/xmpp/mod.rs at line 268
    [3.4394][2.3694:3783]()
    fn process_initial_roster(&mut self, event: Event) -> Result<bool, failure::Error> {
    [3.4394]
    [3.4471]
    fn process_initial_roster(&mut self, event: Event) -> Result<bool, ()> {
  • replacement in src/xmpp/mod.rs at line 277
    [3.4859][2.3784:3868]()
    Err(format_err!("Get error instead of roster"))
    [3.4859]
    [3.4978]
    error!("Get error instead of roster");
    Err(())
  • replacement in src/xmpp/mod.rs at line 291
    [3.4441][2.3869:3967]()
    Err(e) => Err(format_err!("Cann't parse roster: {}", e)),
    [3.4441]
    [3.5907]
    Err(e) => {
    error!("Cann't parse roster: {}", e);
    Err(())
    }
  • replacement in src/xmpp/mod.rs at line 297
    [3.4631][2.3968:4051]()
    _ => Err(format_err!("Unknown result of roster")),
    [3.4631]
    [3.6168]
    _ => {
    error!("Unknown result of roster");
    Err(())
    }
  • replacement in src/xmpp/mod.rs at line 306
    [3.6299][2.4052:4117]()
    Err(format_err!("Iq stanza without id"))
    [3.6299]
    [3.8819]
    error!("Iq stanza without id");
    Err(())
  • replacement in src/xmpp/mod.rs at line 313
    [3.6475][2.4118:4183]()
    Err(format_err!("Wrong event while waiting roster"))
    [3.6475]
    [3.6551]
    error!("Wrong event while waiting roster");
    Err(())
  • replacement in src/xmpp/mod.rs at line 323
    [3.6717][2.4184:4247]()
    F: Future<Error = E>,
    E: Into<failure::Error>,
    [3.6717]
    [3.6747]
    F: Future<Error = E> + 'static,
    E: 'static,
  • replacement in src/xmpp/mod.rs at line 326
    [3.6753][2.4248:4302]()
    let XmppConnection { account, state } = self;
    [3.6753]
    [3.6870]
    let XmppConnection {
    account,
    state:
    XmppState {
    client,
    roster,
    counter,
    },
    } = self;
  • replacement in src/xmpp/mod.rs at line 341
    [3.7065][2.4303:4337]()
    state
    .client
    [3.7065]
    [3.7080]
    client
  • replacement in src/xmpp/mod.rs at line 345
    [3.7201][2.4338:4407]()
    (account2, Err(failure::SyncFailure::new(e).into()))
    [3.7201]
    [3.7226]
    account2
  • replacement in src/xmpp/mod.rs at line 349
    [3.7312][2.4408:4457]()
    state: XmppState { client },
    [3.7312]
    [3.7369]
    state: XmppState {
    client,
    roster,
    counter,
    },
  • replacement in src/xmpp/mod.rs at line 357
    [3.7497][2.4458:4946]()
    })
    .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),
    [3.7497]
    [3.7778]
    .map_err(|(account, _)| account)
    .and_then(|(conn, r)| match r {
    Ok(Either::A(_)) => future::ok(conn),
    Ok(Either::B(_)) => future::err(conn.account),
    Err(_e) => future::err(conn.account),
    })
  • replacement in src/xmpp/mod.rs at line 371
    [3.7942][2.4947:5010]()
    F: Future<Error = E>,
    E: Into<failure::Error>,
    [3.7942]
    [3.8005]
    F: Future<Error = E> + 'static,
    E: Into<failure::Error> + 'static,
  • replacement in src/xmpp/mod.rs at line 374
    [3.8011][2.5011:5065]()
    let XmppConnection { account, state } = self;
    [3.8011]
    [3.10624]
    let XmppConnection {
    account,
    state:
    XmppState {
    client,
    roster,
    counter,
    },
    } = self;
  • replacement in src/xmpp/mod.rs at line 389
    [3.8183][2.5066:5100]()
    state
    .client
    [3.8183]
    [3.8198]
    client
  • replacement in src/xmpp/mod.rs at line 393
    [3.8315][2.5101:5170]()
    (account2, Err(failure::SyncFailure::new(e).into()))
    [3.8315]
    [3.8340]
    account2
  • replacement in src/xmpp/mod.rs at line 397
    [3.8426][2.5171:5220]()
    state: XmppState { client },
    [3.8426]
    [3.8483]
    state: XmppState {
    client,
    roster,
    counter,
    },
  • replacement in src/xmpp/mod.rs at line 416
    [3.9105][2.5221:5309]()
    Err(format_err!("Wrong event while waiting self-presence"))
    [3.9105]
    [3.9220]
    error!("Wrong event while waiting self-presence");
    Err(())
  • edit in src/xmpp/mod.rs at line 422
    [3.9320]
    [2.5310]
    .map_err(|(account, _)| account)
    .and_then(|(conn, r)| match r {
    Ok(Either::A(_)) => future::ok(conn),
    Ok(Either::B(_)) => future::err(conn.account),
    Err(_e) => future::err(conn.account),
    })
  • edit in src/xmpp/mod.rs at line 429
    [2.5325][2.5325:5597](),[2.5597][3.5425:5440](),[3.6094][3.5425:5440](),[3.9320][3.5425:5440](),[3.5440][2.5598:5631]()
    >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
    .then(|r| match r {
    Err((account, _e)) => {
    error!("Cann't wait self-presence");
    future::err(account)
    }
    Ok((conn, _)) => future::ok(conn),
    })
    ================================
  • replacement in src/xmpp/mod.rs at line 433
    [2.5676][2.5676:5704]()
    _cmd: &XmppCommand,
    [2.5676]
    [2.5704]
    cmd: &XmppCommand,
  • edit in src/xmpp/mod.rs at line 436
    [2.5808]
    [2.5808]
    if let Some(_jid_data) = self.state.roster.get(&cmd.xmpp_to) {
    info!("Jid {} in roster", cmd.xmpp_to);
    } else {
    info!("Jid {} not in roster", cmd.xmpp_to);
    }
  • edit in src/xmpp/mod.rs at line 442
    [2.5833][2.5833:5866]()
    <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<