muc: Document these modules.
This commit is contained in:
parent
d3890d21fb
commit
16b9291475
3 changed files with 91 additions and 20 deletions
|
|
@ -4,9 +4,10 @@
|
||||||
// License, v. 2.0. If a copy of the MPL was not distributed with this
|
// 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/.
|
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||||
|
|
||||||
#![allow(missing_docs)]
|
/// The http://jabber.org/protocol/muc protocol.
|
||||||
|
|
||||||
pub mod muc;
|
pub mod muc;
|
||||||
|
|
||||||
|
/// The http://jabber.org/protocol/muc#user protocol.
|
||||||
pub mod user;
|
pub mod user;
|
||||||
|
|
||||||
pub use self::muc::Muc;
|
pub use self::muc::Muc;
|
||||||
|
|
|
||||||
|
|
@ -8,18 +8,30 @@
|
||||||
use date::DateTime;
|
use date::DateTime;
|
||||||
|
|
||||||
generate_element!(
|
generate_element!(
|
||||||
|
/// Represents the query for messages before our join.
|
||||||
History, "history", MUC,
|
History, "history", MUC,
|
||||||
attributes: [
|
attributes: [
|
||||||
|
/// How many characters of history to send, in XML characters.
|
||||||
maxchars: Option<u32> = "maxchars" => optional,
|
maxchars: Option<u32> = "maxchars" => optional,
|
||||||
|
|
||||||
|
/// How many messages to send.
|
||||||
maxstanzas: Option<u32> = "maxstanzas" => optional,
|
maxstanzas: Option<u32> = "maxstanzas" => optional,
|
||||||
|
|
||||||
|
/// Only send messages received in these last seconds.
|
||||||
seconds: Option<u32> = "seconds" => optional,
|
seconds: Option<u32> = "seconds" => optional,
|
||||||
|
|
||||||
|
/// Only send messages after this date.
|
||||||
since: Option<DateTime> = "since" => optional,
|
since: Option<DateTime> = "since" => optional,
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
|
||||||
generate_element!(
|
generate_element!(
|
||||||
|
/// Represents a room join request.
|
||||||
Muc, "x", MUC, children: [
|
Muc, "x", MUC, children: [
|
||||||
|
/// Password to use when the room is protected by a password.
|
||||||
password: Option<String> = ("password", MUC) => String,
|
password: Option<String> = ("password", MUC) => String,
|
||||||
|
|
||||||
|
/// Controls how much and how old we want to receive history on join.
|
||||||
history: Option<History> = ("history", MUC) => History
|
history: Option<History> = ("history", MUC) => History
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
|
|
||||||
|
|
@ -85,7 +85,10 @@ Status, "status", MUC_USER, "code", {
|
||||||
/// JID or to a roomnick. -- CHANGELOG 1.25 (2012-02-08)
|
/// JID or to a roomnick. -- CHANGELOG 1.25 (2012-02-08)
|
||||||
#[derive(Debug, Clone, PartialEq)]
|
#[derive(Debug, Clone, PartialEq)]
|
||||||
pub enum Actor {
|
pub enum Actor {
|
||||||
|
/// The full JID associated with this user.
|
||||||
Jid(Jid),
|
Jid(Jid),
|
||||||
|
|
||||||
|
/// The nickname of this user.
|
||||||
Nick(String),
|
Nick(String),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -120,42 +123,93 @@ impl From<Actor> for Element {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
generate_element!(Continue, "continue", MUC_USER,
|
generate_element!(
|
||||||
attributes: [
|
/// Used to continue a one-to-one discussion in a room, with more than one
|
||||||
thread: Option<String> = "thread" => optional,
|
/// participant.
|
||||||
]);
|
Continue, "continue", MUC_USER,
|
||||||
|
attributes: [
|
||||||
|
/// The thread to continue in this room.
|
||||||
|
thread: Option<String> = "thread" => optional,
|
||||||
|
]
|
||||||
|
);
|
||||||
|
|
||||||
generate_elem_id!(Reason, "reason", MUC_USER);
|
generate_elem_id!(
|
||||||
|
/// A reason for inviting, declining, etc. a request.
|
||||||
|
Reason, "reason", MUC_USER
|
||||||
|
);
|
||||||
|
|
||||||
generate_attribute!(Affiliation, "affiliation", {
|
generate_attribute!(
|
||||||
Owner => "owner",
|
/// The affiliation of an entity with a room, which isn’t tied to its
|
||||||
Admin => "admin",
|
/// presence in it.
|
||||||
Member => "member",
|
Affiliation, "affiliation", {
|
||||||
Outcast => "outcast",
|
/// The user who created the room, or who got appointed by its creator
|
||||||
None => "none",
|
/// to be their equal.
|
||||||
}, Default = None);
|
Owner => "owner",
|
||||||
|
|
||||||
generate_attribute!(Role, "role", {
|
/// A user who has been empowered by an owner to do administrative
|
||||||
Moderator => "moderator",
|
/// operations.
|
||||||
Participant => "participant",
|
Admin => "admin",
|
||||||
Visitor => "visitor",
|
|
||||||
None => "none",
|
/// A user who is whitelisted to speak in moderated rooms, or to join a
|
||||||
}, Default = None);
|
/// member-only room.
|
||||||
|
Member => "member",
|
||||||
|
|
||||||
|
/// A user who has been banned from this room.
|
||||||
|
Outcast => "outcast",
|
||||||
|
|
||||||
|
/// A normal participant.
|
||||||
|
None => "none",
|
||||||
|
}, Default = None
|
||||||
|
);
|
||||||
|
|
||||||
|
generate_attribute!(
|
||||||
|
/// The current role of an entity in a room, it can be changed by an owner
|
||||||
|
/// or an administrator but will be lost once they leave the room.
|
||||||
|
Role, "role", {
|
||||||
|
/// This user can kick other participants, as well as grant and revoke
|
||||||
|
/// them voice.
|
||||||
|
Moderator => "moderator",
|
||||||
|
|
||||||
|
/// A user who can speak in this room.
|
||||||
|
Participant => "participant",
|
||||||
|
|
||||||
|
/// A user who cannot speak in this room, and must request voice before
|
||||||
|
/// doing so.
|
||||||
|
Visitor => "visitor",
|
||||||
|
|
||||||
|
/// A user who is absent from the room.
|
||||||
|
None => "none",
|
||||||
|
}, Default = None
|
||||||
|
);
|
||||||
|
|
||||||
generate_element!(
|
generate_element!(
|
||||||
|
/// An item representing a user in a room.
|
||||||
Item, "item", MUC_USER, attributes: [
|
Item, "item", MUC_USER, attributes: [
|
||||||
|
/// The affiliation of this user with the room.
|
||||||
affiliation: Affiliation = "affiliation" => required,
|
affiliation: Affiliation = "affiliation" => required,
|
||||||
|
|
||||||
|
/// The real JID of this user, if you are allowed to see it.
|
||||||
jid: Option<Jid> = "jid" => optional,
|
jid: Option<Jid> = "jid" => optional,
|
||||||
|
|
||||||
|
/// The current nickname of this user.
|
||||||
nick: Option<String> = "nick" => optional,
|
nick: Option<String> = "nick" => optional,
|
||||||
|
|
||||||
|
/// The current role of this user.
|
||||||
role: Role = "role" => required
|
role: Role = "role" => required
|
||||||
], children: [
|
], children: [
|
||||||
|
/// The actor affected by this item.
|
||||||
actor: Option<Actor> = ("actor", MUC_USER) => Actor,
|
actor: Option<Actor> = ("actor", MUC_USER) => Actor,
|
||||||
|
|
||||||
|
/// Whether this continues a one-to-one discussion.
|
||||||
continue_: Option<Continue> = ("continue", MUC_USER) => Continue,
|
continue_: Option<Continue> = ("continue", MUC_USER) => Continue,
|
||||||
|
|
||||||
|
/// A reason for this item.
|
||||||
reason: Option<Reason> = ("reason", MUC_USER) => Reason
|
reason: Option<Reason> = ("reason", MUC_USER) => Reason
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
|
||||||
impl Item {
|
impl Item {
|
||||||
|
/// Creates a new item with the given affiliation and role.
|
||||||
pub fn new(affiliation: Affiliation, role: Role) -> Item {
|
pub fn new(affiliation: Affiliation, role: Role) -> Item {
|
||||||
Item {
|
Item {
|
||||||
affiliation,
|
affiliation,
|
||||||
|
|
@ -170,8 +224,12 @@ impl Item {
|
||||||
}
|
}
|
||||||
|
|
||||||
generate_element!(
|
generate_element!(
|
||||||
|
/// The main muc#user element.
|
||||||
MucUser, "x", MUC_USER, children: [
|
MucUser, "x", MUC_USER, children: [
|
||||||
|
/// List of statuses applying to this item.
|
||||||
status: Vec<Status> = ("status", MUC_USER) => Status,
|
status: Vec<Status> = ("status", MUC_USER) => Status,
|
||||||
|
|
||||||
|
/// List of items.
|
||||||
items: Vec<Item> = ("item", MUC_USER) => Item
|
items: Vec<Item> = ("item", MUC_USER) => Item
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue