Skip to content

Commit

Permalink
WIP: Implement MIX
Browse files Browse the repository at this point in the history
TODO: Create PR that includes xsf/xeps#919 and a version block
  • Loading branch information
melvo committed Nov 5, 2023
1 parent 4e6202f commit 6466c3a
Show file tree
Hide file tree
Showing 19 changed files with 5,209 additions and 155 deletions.
18 changes: 13 additions & 5 deletions doc/doap.xml
Original file line number Diff line number Diff line change
Expand Up @@ -540,10 +540,10 @@ SPDX-License-Identifier: CC0-1.0
<implements>
<xmpp:SupportedXep>
<xmpp:xep rdf:resource='https://xmpp.org/extensions/xep-0369.html'/>
<xmpp:status>partial</xmpp:status>
<xmpp:status>complete</xmpp:status>
<xmpp:version>0.14</xmpp:version>
<xmpp:since>1.1</xmpp:since>
<xmpp:note>Only IQ queries implemented</xmpp:note>
<xmpp:note>IQ stanzas for participants and channel information since 1.5; Manager since 1.6</xmpp:note>
</xmpp:SupportedXep>
</implements>
<implements>
Expand Down Expand Up @@ -573,10 +573,18 @@ SPDX-License-Identifier: CC0-1.0
<implements>
<xmpp:SupportedXep>
<xmpp:xep rdf:resource='https://xmpp.org/extensions/xep-0405.html'/>
<xmpp:status>partial</xmpp:status>
<xmpp:status>complete</xmpp:status>
<xmpp:version>0.5</xmpp:version>
<xmpp:since>1.3</xmpp:since>
<xmpp:note>Only IQ queries implemented</xmpp:note>
<xmpp:note>Manager since 1.6</xmpp:note>
</xmpp:SupportedXep>
</implements>
<implements>
<xmpp:SupportedXep>
<xmpp:xep rdf:resource='https://xmpp.org/extensions/xep-0406.html'/>
<xmpp:status>complete</xmpp:status>
<xmpp:version>0.3</xmpp:version>
<xmpp:since>1.6</xmpp:since>
</xmpp:SupportedXep>
</implements>
<implements>
Expand All @@ -585,7 +593,7 @@ SPDX-License-Identifier: CC0-1.0
<xmpp:status>partial</xmpp:status>
<xmpp:version>0.1</xmpp:version>
<xmpp:since>1.4</xmpp:since>
<xmpp:note>Only invitations implemented</xmpp:note>
<xmpp:note>Only invitations implemented; Manager since 1.6</xmpp:note>
</xmpp:SupportedXep>
</implements>
<implements>
Expand Down
3 changes: 3 additions & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ set(INSTALL_HEADER_FILES
base/QXmppMamIq.h
base/QXmppMessage.h
base/QXmppMessageReaction.h
base/QXmppMixConfigItem.h
base/QXmppMixInfoItem.h
base/QXmppMixInvitation.h
base/QXmppMixIq.h
Expand Down Expand Up @@ -115,6 +116,7 @@ set(INSTALL_HEADER_FILES
client/QXmppMamManager.h
client/QXmppMessageHandler.h
client/QXmppMessageReceiptManager.h
client/QXmppMixManager.h
client/QXmppMucManager.h
client/QXmppOutgoingClient.h
client/QXmppRegistrationManager.h
Expand Down Expand Up @@ -252,6 +254,7 @@ set(SOURCE_FILES
client/QXmppJingleMessageInitiationManager.cpp
client/QXmppMamManager.cpp
client/QXmppMessageReceiptManager.cpp
client/QXmppMixManager.cpp
client/QXmppMucManager.cpp
client/QXmppOutgoingClient.cpp
client/QXmppRosterManager.cpp
Expand Down
16 changes: 13 additions & 3 deletions src/base/QXmppConstants.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,9 @@ const char *ns_authFeature = "http://jabber.org/features/iq-auth";
// XEP-0080: User Location
const char *ns_geoloc = "http://jabber.org/protocol/geoloc";
const char *ns_geoloc_notify = "http://jabber.org/protocol/geoloc+notify";
// XEP-0084: User Avatar
const char *ns_user_avatar_data = "urn:xmpp:avatar:data";
const char *ns_user_avatar_metadata = "urn:xmpp:avatar:metadata";
// XEP-0085: Chat State Notifications
const char *ns_chat_states = "http://jabber.org/protocol/chatstates";
// XEP-0091: Legacy Delayed Delivery
Expand Down Expand Up @@ -176,11 +179,13 @@ const char *ns_message_attaching = "urn:xmpp:message-attaching:1";
const char *ns_mix = "urn:xmpp:mix:core:1";
const char *ns_mix_create_channel = "urn:xmpp:mix:core:1#create-channel";
const char *ns_mix_searchable = "urn:xmpp:mix:core:1#searchable";
const char *ns_mix_node_allowed = "urn:xmpp:mix:nodes:allowed";
const char *ns_mix_node_banned = "urn:xmpp:mix:nodes:banned";
const char *ns_mix_node_config = "urn:xmpp:mix:nodes:config";
const char *ns_mix_node_info = "urn:xmpp:mix:nodes:info";
const char *ns_mix_node_messages = "urn:xmpp:mix:nodes:messages";
const char *ns_mix_node_participants = "urn:xmpp:mix:nodes:participants";
const char *ns_mix_node_presence = "urn:xmpp:mix:nodes:presence";
const char *ns_mix_node_config = "urn:xmpp:mix:nodes:config";
const char *ns_mix_node_info = "urn:xmpp:mix:nodes:info";
// XEP-0373: OpenPGP for XMPP
const char *ns_ox = "urn:xmpp:openpgp:0";
// XEP-0380: Explicit Message Encryption
Expand All @@ -193,10 +198,15 @@ const char *ns_omemo_1 = "urn:xmpp:omemo:1";
const char *ns_omemo_2 = "urn:xmpp:omemo:2";
const char *ns_omemo_2_bundles = "urn:xmpp:omemo:2:bundles";
const char *ns_omemo_2_devices = "urn:xmpp:omemo:2:devices";
// XEP-0404: Mediated Information eXchange (MIX): JID Hidden Channels
const char *ns_mix_node_jidmap = "urn:xmpp:mix:nodes:jidmap";
// XEP-0405: Mediated Information eXchange (MIX): Participant Server Requirements
const char *ns_mix_pam = "urn:xmpp:mix:pam:1";
const char *ns_mix_pam = "urn:xmpp:mix:pam:2";
const char *ns_mix_pam_archiving = "urn:xmpp:mix:pam:2#archive";
const char *ns_mix_roster = "urn:xmpp:mix:roster:0";
const char *ns_mix_presence = "urn:xmpp:presence:0";
// XEP-0406: Mediated Information eXchange (MIX): MIX Administration
const char *ns_mix_admin = "urn:xmpp:mix:admin:0";
// XEP-0407: Mediated Information eXchange (MIX): Miscellaneous Capabilities
const char *ns_mix_misc = "urn:xmpp:mix:misc:0";
// XEP-0428: Fallback Indication
Expand Down
10 changes: 10 additions & 0 deletions src/base/QXmppConstants_p.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,9 @@ extern const char *ns_authFeature;
// XEP-0080: User Location
extern const char *ns_geoloc;
extern const char *ns_geoloc_notify;
// XEP-0084: User Avatar
extern const char *ns_user_avatar_data;
extern const char *ns_user_avatar_metadata;
// XEP-0085: Chat State Notifications
extern const char *ns_chat_states;
// XEP-0091: Legacy Delayed Delivery
Expand Down Expand Up @@ -193,6 +196,8 @@ extern const char *ns_mix_node_participants;
extern const char *ns_mix_node_presence;
extern const char *ns_mix_node_config;
extern const char *ns_mix_node_info;
extern const char *ns_mix_node_allowed;
extern const char *ns_mix_node_banned;
// XEP-0373: OpenPGP for XMPP
extern const char *ns_ox;
// XEP-0380: Explicit Message Encryption
Expand All @@ -205,10 +210,15 @@ extern const char *ns_omemo_1;
extern const char *ns_omemo_2;
extern const char *ns_omemo_2_bundles;
extern const char *ns_omemo_2_devices;
// XEP-0404: Mediated Information eXchange (MIX): JID Hidden Channels
extern const char *ns_mix_node_jidmap;
// XEP-0405: Mediated Information eXchange (MIX): Participant Server Requirements
extern const char *ns_mix_pam;
extern const char *ns_mix_pam_archiving;
extern const char *ns_mix_roster;
extern const char *ns_mix_presence;
// XEP-0406: Mediated Information eXchange (MIX): MIX Administration
extern const char *ns_mix_admin;
// XEP-0407: Mediated Information eXchange (MIX): Miscellaneous Capabilities
extern const char *ns_mix_misc;
// XEP-0428: Fallback Indication
Expand Down
131 changes: 131 additions & 0 deletions src/base/QXmppMixConfigItem.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
// SPDX-FileCopyrightText: 2023 Melvin Keskin <[email protected]>
//
// SPDX-License-Identifier: LGPL-2.1-or-later

#pragma once

#include "QXmppDataForm.h"
#include "QXmppPubSubBaseItem.h"

class QXmppMixConfigItemPrivate;

class QXMPP_EXPORT QXmppMixConfigItem : public QXmppPubSubBaseItem
{
public:
enum class Role {
None,
Owner,
Administrator,
Participant,
Allowed,
Anyone,
Nobody,
};

enum class Node {
AllowedJids = 1 << 0,
AvatarData = 1 << 1,
AvatarMetadata = 1 << 2,
BannedJids = 1 << 3,
Configuration = 1 << 4,
Information = 1 << 5,
JidMap = 1 << 6,
Messages = 1 << 7,
Participants = 1 << 8,
Presence = 1 << 9,
};
Q_DECLARE_FLAGS(Nodes, Node)

QXmppMixConfigItem();
QXmppMixConfigItem(const QXmppMixConfigItem &);
QXmppMixConfigItem(QXmppMixConfigItem &&);
~QXmppMixConfigItem();

QXmppMixConfigItem &operator=(const QXmppMixConfigItem &);
QXmppMixConfigItem &operator=(QXmppMixConfigItem &&);

QXmppDataForm::Type formType() const;
void setFormType(QXmppDataForm::Type formType);

QString lastEditorJid() const;
void setLastEditorJid(const QString &lastEditorJid);

QStringList ownerJids() const;
void setOwnerJids(const QStringList &ownerJids);

QStringList administratorJids() const;
void setAdministratorJids(const QStringList &administratorJids);

QDateTime channelDeletion() const;
void setChannelDeletion(const QDateTime &channelDeletion);

Nodes nodes() const;
void setNodes(Nodes nodes);

Role messagesSubscribeRole() const;
void setMessagesSubscribeRole(Role messagesSubscribeRole);

Role messagesRetractRole() const;
void setMessagesRetractRole(Role messagesRetractRole);

Role presenceSubscribeRole() const;
void setPresenceSubscribeRole(Role presenceSubscribeRole);

Role participantsSubscribeRole() const;
void setParticipantsSubscribeRole(Role participantsSubscribeRole);

Role informationSubscribeRole() const;
void setInformationSubscribeRole(Role informationSubscribeRole);

Role informationUpdateRole() const;
void setInformationUpdateRole(Role informationUpdateRole);

Role allowedJidsSubscribeRole() const;
void setAllowedJidsSubscribeRole(Role allowedJidsSubscribeRole);

Role bannedJidsSubscribeRole() const;
void setBannedJidsSubscribeRole(Role bannedJidsSubscribeRole);

Role configurationReadRole() const;
void setConfigurationReadRole(Role configurationReadRole);

Role avatarUpdateRole() const;
void setAvatarUpdateRole(Role avatarUpdateRole);

std::optional<bool> nicknameRequired() const;
void setNicknameRequired(std::optional<bool> nicknameRequired);

std::optional<bool> presenceRequired() const;
void setPresenceRequired(std::optional<bool> presenceRequired);

std::optional<bool> onlyParticipantsPermittedToSubmitPresence() const;
void setOnlyParticipantsPermittedToSubmitPresence(std::optional<bool> onlyParticipantsPermittedToSubmitPresence);

std::optional<bool> ownMessageRetractionPermitted() const;
void setOwnMessageRetractionPermitted(std::optional<bool> ownMessageRetractionPermitted);

std::optional<bool> invitationsPermitted() const;
void setInvitationsPermitted(std::optional<bool> invitationsPermitted);

std::optional<bool> privateMessagesPermitted() const;
void setPrivateMessagesPermitted(std::optional<bool> privateMessagesPermitted);

static bool isItem(const QDomElement &itemElement);

protected:
/// \cond
void parsePayload(const QDomElement &payloadElement) override;
void serializePayload(QXmlStreamWriter *writer) const override;
/// \endcond

private:
QSharedDataPointer<QXmppMixConfigItemPrivate> d;
};

Q_DECLARE_OPERATORS_FOR_FLAGS(QXmppMixConfigItem::Nodes)
/// \cond
// Scoped enums (enum class) are not implicitly converted to int.
inline uint qHash(QXmppMixConfigItem::Node key, uint seed) noexcept { return qHash(std::underlying_type_t<QXmppMixConfigItem::Node>(key), seed); }
/// \endcond

Q_DECLARE_METATYPE(QXmppMixConfigItem)
10 changes: 7 additions & 3 deletions src/base/QXmppMixInfoItem.h
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
// SPDX-FileCopyrightText: 2019 Linus Jahn <[email protected]>
// SPDX-FileCopyrightText: 2023 Melvin Keskin <[email protected]>
//
// SPDX-License-Identifier: LGPL-2.1-or-later

#ifndef QXMPPMIXINFOITEM_H
#define QXMPPMIXINFOITEM_H
#pragma once

#include "QXmppDataForm.h"
#include "QXmppPubSubBaseItem.h"

class QXmppMixInfoItemPrivate;
Expand All @@ -20,6 +21,9 @@ class QXMPP_EXPORT QXmppMixInfoItem : public QXmppPubSubBaseItem
QXmppMixInfoItem &operator=(const QXmppMixInfoItem &);
QXmppMixInfoItem &operator=(QXmppMixInfoItem &&);

QXmppDataForm::Type formType() const;
void setFormType(QXmppDataForm::Type formType);

const QString &name() const;
void setName(QString);

Expand All @@ -41,4 +45,4 @@ class QXMPP_EXPORT QXmppMixInfoItem : public QXmppPubSubBaseItem
QSharedDataPointer<QXmppMixInfoItemPrivate> d;
};

#endif // QXMPPMIXINFOITEM_H
Q_DECLARE_METATYPE(QXmppMixInfoItem)
10 changes: 10 additions & 0 deletions src/base/QXmppMixInvitation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,16 @@ class QXmppMixInvitationPrivate : public QSharedData
QString token;
};

///
/// \brief The QXmppMixInvitation class is used to invite a user to a
/// \xep{0369}: Mediated Information eXchange (MIX) channel as defined by
/// \xep{0407}: Mediated Information eXchange (MIX): Miscellaneous Capabilities.
///
/// \ingroup Stanzas
///
/// \since QXmpp 1.4
///

///
/// Default constructor
///
Expand Down
9 changes: 0 additions & 9 deletions src/base/QXmppMixInvitation.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,6 @@

class QXmppMixInvitationPrivate;

///
/// \brief The QXmppMixInvitation class is used to invite a user to a
/// \xep{0369}: Mediated Information eXchange (MIX) channel as defined by
/// \xep{0407}: Mediated Information eXchange (MIX): Miscellaneous Capabilities.
///
/// \ingroup Stanzas
///
/// \since QXmpp 1.4
///
class QXMPP_EXPORT QXmppMixInvitation
{
public:
Expand Down
Loading

0 comments on commit 6466c3a

Please sign in to comment.