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
7#[cfg(feature = "avatars")]
8use tokio_xmpp::parsers::Jid;
9use tokio_xmpp::parsers::{bookmarks2, message::Body, roster::Item as RosterItem, BareJid};
10
11use crate::{delay::StanzaTimeInfo, Error, Id, RoomNick};
12
13#[derive(Debug)]
14pub enum Event {
15 Online,
16 Disconnected(Error),
17 ContactAdded(RosterItem),
18 ContactRemoved(RosterItem),
19 ContactChanged(RosterItem),
20 #[cfg(feature = "avatars")]
21 AvatarRetrieved(Jid, String),
22 /// A chat message was received. It may have been delayed on the network.
23 /// - The [`Id`] is a unique identifier for this message.
24 /// - The [`BareJid`] is the sender's JID.
25 /// - The [`Body`] is the message body.
26 /// - The [`StanzaTimeInfo`] about when message was received, and when the message was claimed sent.
27 ChatMessage(Id, BareJid, Body, StanzaTimeInfo),
28 JoinRoom(BareJid, bookmarks2::Conference),
29 LeaveRoom(BareJid),
30 LeaveAllRooms,
31 RoomJoined(BareJid),
32 RoomLeft(BareJid),
33 RoomMessage(Id, BareJid, RoomNick, Body, StanzaTimeInfo),
34 /// The subject of a room was received.
35 /// - The BareJid is the room's address.
36 /// - The RoomNick is the nickname of the room member who set the subject.
37 /// - The String is the new subject.
38 RoomSubject(BareJid, Option<RoomNick>, String, StanzaTimeInfo),
39 /// A private message received from a room, containing the message ID, the room's BareJid,
40 /// the sender's nickname, and the message body.
41 RoomPrivateMessage(Id, BareJid, RoomNick, Body, StanzaTimeInfo),
42 ServiceMessage(Id, BareJid, Body, StanzaTimeInfo),
43 HttpUploadedFile(String),
44}