2019-03-21 18:41:29 +01:00
|
|
|
// Copyright (c) 2019 Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
|
|
|
|
|
//
|
|
|
|
|
// This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
|
// License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
|
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
|
|
|
|
2019-07-25 15:03:22 +02:00
|
|
|
#![deny(bare_trait_objects)]
|
2024-08-04 22:35:01 +02:00
|
|
|
#![cfg_attr(docsrs, feature(doc_auto_cfg))]
|
2019-07-25 15:03:22 +02:00
|
|
|
|
2024-07-31 14:28:15 +02:00
|
|
|
pub use tokio_xmpp;
|
2024-07-24 20:52:10 +02:00
|
|
|
pub use tokio_xmpp::jid;
|
|
|
|
|
pub use tokio_xmpp::minidom;
|
2023-08-21 10:57:33 +02:00
|
|
|
pub use tokio_xmpp::parsers;
|
2019-09-29 04:08:56 +02:00
|
|
|
#[macro_use]
|
|
|
|
|
extern crate log;
|
2019-03-21 18:41:29 +01:00
|
|
|
|
2023-12-30 00:43:10 +01:00
|
|
|
pub mod agent;
|
2023-12-29 20:58:26 +01:00
|
|
|
pub mod builder;
|
2023-12-31 21:06:15 +01:00
|
|
|
pub mod delay;
|
2023-12-29 22:07:46 +01:00
|
|
|
pub mod disco;
|
2023-12-29 21:56:37 +01:00
|
|
|
pub mod event;
|
2023-12-30 00:13:25 +01:00
|
|
|
pub mod event_loop;
|
2023-12-29 21:41:09 +01:00
|
|
|
pub mod feature;
|
2023-12-29 18:18:38 +01:00
|
|
|
pub mod iq;
|
2023-12-29 18:08:04 +01:00
|
|
|
pub mod message;
|
2023-12-30 00:28:57 +01:00
|
|
|
pub mod muc;
|
2023-12-29 18:08:04 +01:00
|
|
|
pub mod presence;
|
|
|
|
|
pub mod pubsub;
|
2023-12-29 18:29:22 +01:00
|
|
|
pub mod upload;
|
2019-03-21 18:41:29 +01:00
|
|
|
|
2023-12-29 20:58:26 +01:00
|
|
|
// Module re-exports
|
2023-12-30 00:43:10 +01:00
|
|
|
pub use agent::Agent;
|
2023-12-29 20:58:26 +01:00
|
|
|
pub use builder::{ClientBuilder, ClientType};
|
2023-12-29 21:56:37 +01:00
|
|
|
pub use event::Event;
|
2023-12-29 21:41:09 +01:00
|
|
|
pub use feature::ClientFeature;
|
2019-03-21 18:41:29 +01:00
|
|
|
|
2023-12-29 20:58:26 +01:00
|
|
|
pub type Error = tokio_xmpp::Error;
|
|
|
|
|
pub type Id = Option<String>;
|
|
|
|
|
pub type RoomNick = String;
|
2019-03-21 18:41:29 +01:00
|
|
|
|
2024-08-20 16:54:48 +02:00
|
|
|
// The test below is dysfunctional since we have moved to StanzaStream. The
|
|
|
|
|
// StanzaStream will attempt to connect to foo@bar indefinitely.
|
|
|
|
|
// Keeping it here as inspiration for future integration tests.
|
|
|
|
|
/*
|
2024-01-03 20:01:05 -05:00
|
|
|
#[cfg(all(test, any(feature = "starttls-rust", feature = "starttls-native")))]
|
2019-10-22 23:46:50 +02:00
|
|
|
mod tests {
|
2024-07-24 20:52:10 +02:00
|
|
|
use super::jid::BareJid;
|
|
|
|
|
use super::{ClientBuilder, ClientFeature, ClientType, Event};
|
2023-06-01 11:58:04 +02:00
|
|
|
use std::str::FromStr;
|
2024-08-06 21:00:11 +02:00
|
|
|
use tokio_xmpp::Client as TokioXmppClient;
|
2019-10-22 23:46:50 +02:00
|
|
|
|
2020-03-08 19:57:59 +01:00
|
|
|
#[tokio::test]
|
|
|
|
|
async fn test_simple() {
|
2023-06-01 11:58:04 +02:00
|
|
|
let jid = BareJid::from_str("foo@bar").unwrap();
|
|
|
|
|
|
|
|
|
|
let client = TokioXmppClient::new(jid.clone(), "meh");
|
2019-10-22 23:46:50 +02:00
|
|
|
|
|
|
|
|
// Client instance
|
2023-06-01 11:58:04 +02:00
|
|
|
let client_builder = ClientBuilder::new(jid, "meh")
|
2019-10-22 23:46:50 +02:00
|
|
|
.set_client(ClientType::Bot, "xmpp-rs")
|
|
|
|
|
.set_website("https://gitlab.com/xmpp-rs/xmpp-rs")
|
|
|
|
|
.set_default_nick("bot")
|
|
|
|
|
.enable_feature(ClientFeature::ContactList);
|
|
|
|
|
|
2023-08-17 22:29:04 +02:00
|
|
|
#[cfg(feature = "avatars")]
|
|
|
|
|
let client_builder = client_builder.enable_feature(ClientFeature::Avatars);
|
|
|
|
|
|
2023-12-31 01:17:29 -05:00
|
|
|
let mut agent = client_builder.build_impl(client);
|
2019-10-22 23:46:50 +02:00
|
|
|
|
2024-08-08 15:14:57 +02:00
|
|
|
loop {
|
|
|
|
|
let events = agent.wait_for_events().await;
|
2020-03-08 19:57:59 +01:00
|
|
|
assert!(match events[0] {
|
2023-12-11 13:48:39 +01:00
|
|
|
Event::Disconnected(_) => true,
|
2020-03-08 19:57:59 +01:00
|
|
|
_ => false,
|
|
|
|
|
});
|
|
|
|
|
assert_eq!(events.len(), 1);
|
|
|
|
|
break;
|
|
|
|
|
}
|
2019-10-22 23:46:50 +02:00
|
|
|
}
|
|
|
|
|
}
|
2024-08-20 16:54:48 +02:00
|
|
|
*/
|