xmpp_parsers/gc3.rs
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121
// Copyright (c) 2025 Jonas Schäfer <jonas@zombofant.net>
//
// 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/.
//! Provide protocol pieces for upcoming Group Chat 3
use xso::{AsXml, FromXml};
use jid::BareJid;
use crate::nick::Nick;
use crate::ns;
use crate::occupant_id::OccupantId;
/// Request to create a new GC3 Group.
///
/// This may be sent to the domain JID of a GC3 service in order to let the
/// service allocate a group address. It may also be sent to a valid group
/// address on a GC3 service in order to request that specific address.
///
/// In either case, this must be sent as IQ `set` payload.
#[derive(FromXml, AsXml)]
#[xml(namespace = ns::GC3, name = "create")]
pub struct Create;
/// GC3 group was created successfully.
#[derive(FromXml, AsXml)]
#[xml(namespace = ns::GC3, name = "created")]
pub struct Created {
/// Address of the created GC3 group.
///
/// This is omitted by the server if the [`Create`] was sent to a JID with
/// localpart included.
#[xml(extract(name = "address", fields(text(type_ = BareJid)), default))]
pub address: Option<BareJid>,
}
/// Request to destroy a GC3 group.
///
/// Must be sent as IQ `set` payload to the group's address.
#[derive(FromXml, AsXml)]
#[xml(namespace = ns::GC3, name = "destroy")]
pub struct Destroy;
/// Confirmation of GC3 group destruction.
#[derive(FromXml, AsXml)]
#[xml(namespace = ns::GC3, name = "destroyed")]
pub struct Destroyed;
/// Request to join a GC3 group.
///
/// Must be sent as IQ `set` payload to the group's address.
#[derive(FromXml, AsXml)]
#[xml(namespace = ns::GC3, name = "join")]
pub struct Join {
/// Nickname request.
#[xml(child)]
pub nick: Nick,
}
/// Confirmation of a join to a GC3 group.
#[derive(FromXml, AsXml)]
#[xml(namespace = ns::GC3, name = "joined")]
pub struct Joined {
/// Nickname assigned by the service.
///
/// This may differ if the service applies normalisation rules to
/// nicknames.
#[xml(child)]
pub nick: Nick,
/// Participant ID assigned by the server.
#[xml(child)]
pub participant_id: OccupantId,
}
/// Application-defined error conditions in Group Chat 3.
#[derive(FromXml, AsXml)]
#[xml(namespace = ns::GC3)]
pub enum Error {
/// The requester is not joined and may thus not perform the requested
/// operation.
#[xml(name = "not-joined")]
NotJoined,
/// The requester does not have sufficient permissions to perform the
/// requested operation, but the lack of permissions is not because the
/// requester is not joined.
#[xml(name = "permission-denied")]
PermissionDenied,
/// The group at which the request was directed does not exist.
#[xml(name = "no-such-group")]
NoSuchGroup,
/// Relaying of an IQ or a message to a specific participant was denied.
#[xml(name = "relay-denied")]
RelayDenied,
/// A XEP-0045-based operation was rejected because it is not available on
/// GC3 Groups.
///
/// This must only be returned on requests as defined in the GC3 spec and
/// must be clearly distinguished from [`Self::CoreProfileOnly`]. The
/// latter is used when a service does not implement the compatibility
/// profile, while [`Self::Gc3Service`] is used for operations which are
/// not even part of the compatibility profile.
#[xml(name = "gc3-service")]
Gc3Service,
/// The GC3 service does not offer the XEP-0045 compatibility profile.
#[xml(name = "core-profile-only")]
CoreProfileOnly,
/// The requester attempted to use a XEP-0045 feature on a GC3 session,
/// or a GC3 feature on a XEP-0045 session.
#[xml(name = "protocol-mismatch")]
ProtocolMismatch,
}