event.rs

 1// Copyright (c) 2023 xmpp-rs contributors.
 2//
 3// This Source Code Form is subject to the terms of the Mozilla Public
 4// License, v. 2.0. If a copy of the MPL was not distributed with this
 5// file, You can obtain one at http://mozilla.org/MPL/2.0/.
 6
 7use tokio_xmpp::jid::BareJid;
 8#[cfg(feature = "avatars")]
 9use tokio_xmpp::jid::Jid;
10use tokio_xmpp::parsers::{bookmarks2, message::Body, roster::Item as RosterItem};
11
12use crate::{delay::StanzaTimeInfo, Error, Id, RoomNick};
13
14#[derive(Debug)]
15pub enum Event {
16    Online,
17    Disconnected(Error),
18    ContactAdded(RosterItem),
19    ContactRemoved(RosterItem),
20    ContactChanged(RosterItem),
21    #[cfg(feature = "avatars")]
22    AvatarRetrieved(Jid, String),
23    /// A chat message was received. It may have been delayed on the network.
24    /// - The [`Id`] is a unique identifier for this message.
25    /// - The [`BareJid`] is the sender's JID.
26    /// - The [`Body`] is the message body.
27    /// - The [`StanzaTimeInfo`] about when message was received, and when the message was claimed sent.
28    ChatMessage(Id, BareJid, Body, StanzaTimeInfo),
29    JoinRoom(BareJid, bookmarks2::Conference),
30    LeaveRoom(BareJid),
31    LeaveAllRooms,
32    RoomJoined(BareJid),
33    RoomLeft(BareJid),
34    RoomMessage(Id, BareJid, RoomNick, Body, StanzaTimeInfo),
35    /// The subject of a room was received.
36    /// - The BareJid is the room's address.
37    /// - The RoomNick is the nickname of the room member who set the subject.
38    /// - The String is the new subject.
39    RoomSubject(BareJid, Option<RoomNick>, String, StanzaTimeInfo),
40    /// A private message received from a room, containing the message ID, the room's BareJid,
41    /// the sender's nickname, and the message body.
42    RoomPrivateMessage(Id, BareJid, RoomNick, Body, StanzaTimeInfo),
43    ServiceMessage(Id, BareJid, Body, StanzaTimeInfo),
44    HttpUploadedFile(String),
45}