QXmpp: QXmppUri.h Source File

QXmpp Version: 1.14.2

Loading...
Searching...
No Matches
QXmppUri.h
1// SPDX-FileCopyrightText: 2019 Linus Jahn <lnj@kaidan.im>
2// SPDX-FileCopyrightText: 2019 Melvin Keskin <melvo@olomono.de>
3// SPDX-FileCopyrightText: 2020 Jonah Brüchert <jbb@kaidan.im>
4//
5// SPDX-License-Identifier: LGPL-2.1-or-later
6
7#ifndef QXMPPURI_H
8#define QXMPPURI_H
9
10#include <QXmppError.h>
11#include <QXmppMessage.h>
12
13#include <variant>
14
15class QUrlQuery;
16
17struct QXmppUriPrivate;
18
19namespace QXmpp::Uri {
20
21 struct Command {
23 QString node;
25 QString action;
26
28 bool operator==(const Command &) const = default;
29};
30
31 struct Invite {
33 QString inviteeJid;
35 QString password;
36
38 bool operator==(const Invite &) const = default;
39};
40
41 struct Join {
43 QString password;
44
46 bool operator==(const Join &) const = default;
47};
48
49 struct Login {
51 QString password;
52
54 bool operator==(const Login &) const = default;
55};
56
57 struct Message {
59 QString subject;
61 QString body;
63 QString thread;
65 QString id;
67 QString from;
69 std::optional<QXmppMessage::Type> type;
70
72 bool operator==(const Message &) const = default;
73};
74
75 struct Unregister {
77 bool operator==(const Unregister &) const = default;
78};
79
80 struct Unsubscribe {
82 bool operator==(const Unsubscribe &) const = default;
83};
84
85 struct Register {
87 bool operator==(const Register &) const = default;
88};
89
90 struct Remove {
92 bool operator==(const Remove &) const = default;
93};
94
95 struct Roster {
97 QString name;
99 QString group;
100
102 bool operator==(const Roster &) const = default;
103};
104
105 struct Subscribe {
107 bool operator==(const Subscribe &) const = default;
108};
109
110 struct TrustMessage {
112 QString encryption;
114 QList<QString> trustKeyIds;
116 QList<QString> distrustKeyIds;
117
119 bool operator==(const TrustMessage &) const = default;
120};
121
122 struct CustomQuery {
124 QString query;
126 QList<std::pair<QString, QString>> parameters;
127
129 bool operator==(const CustomQuery &) const = default;
130};
131
132} // namespace QXmpp::Uri
133
134 class QXMPP_EXPORT QXmppUri
135{
136public:
137 QXmppUri();
138 QXMPP_PRIVATE_DECLARE_RULE_OF_SIX(QXmppUri)
139
140 static std::variant<QXmppUri, QXmppError> fromString(const QString &);
141
142 QString toString();
143
144 QString jid() const;
145 void setJid(const QString &jid);
146
147 std::any query() const;
149 void setQuery(QXmpp::Uri::Command &&q) { setQuery(std::any(std::move(q))); }
151 void setQuery(QXmpp::Uri::Invite &&q) { setQuery(std::any(std::move(q))); }
153 void setQuery(QXmpp::Uri::Join &&q) { setQuery(std::any(std::move(q))); }
155 void setQuery(QXmpp::Uri::Login &&q) { setQuery(std::any(std::move(q))); }
157 void setQuery(QXmpp::Uri::Message &&q) { setQuery(std::any(std::move(q))); }
159 void setQuery(QXmpp::Uri::Unregister &&q) { setQuery(std::any(std::move(q))); }
161 void setQuery(QXmpp::Uri::Register &&q) { setQuery(std::any(std::move(q))); }
163 void setQuery(QXmpp::Uri::Remove &&q) { setQuery(std::any(std::move(q))); }
165 void setQuery(QXmpp::Uri::Roster &&q) { setQuery(std::any(std::move(q))); }
167 void setQuery(QXmpp::Uri::Subscribe &&q) { setQuery(std::any(std::move(q))); }
169 void setQuery(QXmpp::Uri::TrustMessage &&q) { setQuery(std::any(std::move(q))); }
171 void setQuery(QXmpp::Uri::CustomQuery &&q) { setQuery(std::any(std::move(q))); }
173 void resetQuery() { setQuery(std::any()); }
174
175private:
176 void setQuery(std::any &&);
177
178 QSharedDataPointer<QXmppUriPrivate> d;
179};
180
181#endif // QXMPPURI_H
QXmppUri::setQuery
void setQuery(QXmpp::Uri::Subscribe &&q)
Sets a subscribe query.
Definition QXmppUri.h:167
QXmppUri::setQuery
void setQuery(QXmpp::Uri::CustomQuery &&q)
Sets a query with custom name and key-value pairs.
Definition QXmppUri.h:171
QXmppUri::setQuery
void setQuery(QXmpp::Uri::Message &&q)
Sets a message query.
Definition QXmppUri.h:157
QXmppUri::fromString
static std::variant< QXmppUri, QXmppError > fromString(const QString &)
Definition QXmppUri.cpp:374
QXmppUri::setJid
void setJid(const QString &jid)
Definition QXmppUri.cpp:493
QXmppUri::setQuery
void setQuery(QXmpp::Uri::Command &&q)
Sets a "command" query.
Definition QXmppUri.h:149
QXmppUri::query
std::any query() const
Definition QXmppUri.cpp:504
QXmppUri::setQuery
void setQuery(QXmpp::Uri::Register &&q)
Sets a register query.
Definition QXmppUri.h:161
QXmppUri::setQuery
void setQuery(QXmpp::Uri::Join &&q)
Sets a MUC join query.
Definition QXmppUri.h:153
QXmppUri::setQuery
void setQuery(QXmpp::Uri::Unregister &&q)
Sets a unregister query.
Definition QXmppUri.h:159
QXmppUri::setQuery
void setQuery(QXmpp::Uri::Invite &&q)
Sets a MUC invite query.
Definition QXmppUri.h:151
QXmppUri::setQuery
void setQuery(QXmpp::Uri::Remove &&q)
Sets a remove query.
Definition QXmppUri.h:163
QXmppUri::setQuery
void setQuery(QXmpp::Uri::Roster &&q)
Sets a roster query.
Definition QXmppUri.h:165
QXmppUri::setQuery
void setQuery(QXmpp::Uri::Login &&q)
Sets a login query.
Definition QXmppUri.h:155
QXmppUri::resetQuery
void resetQuery()
Removes any query from the URI.
Definition QXmppUri.h:173
QXmppUri::setQuery
void setQuery(QXmpp::Uri::TrustMessage &&q)
Sets a trust message query.
Definition QXmppUri.h:169
QXmppUri::QXmppUri
QXmppUri()
Definition QXmppUri.cpp:362
QXmppUri::toString
QString toString()
Definition QXmppUri.cpp:449
QXmppUri::jid
QString jid() const
Definition QXmppUri.cpp:485
QXmpp::Uri
QXmpp::Uri::Command
Definition QXmppUri.h:21
QXmpp::Uri::Command::operator==
bool operator==(const Command &) const =default
Default comparison operator.
QXmpp::Uri::Command::action
QString action
the ad-hoc commands action type
Definition QXmppUri.h:25
QXmpp::Uri::Command::node
QString node
the command node
Definition QXmppUri.h:23
QXmpp::Uri::CustomQuery
Definition QXmppUri.h:122
QXmpp::Uri::CustomQuery::query
QString query
query name as string
Definition QXmppUri.h:124
QXmpp::Uri::CustomQuery::parameters
QList< std::pair< QString, QString > > parameters
list of parameters as key-value pairs
Definition QXmppUri.h:126
QXmpp::Uri::CustomQuery::operator==
bool operator==(const CustomQuery &) const =default
Default comparison operator.
QXmpp::Uri::Invite
Definition QXmppUri.h:31
QXmpp::Uri::Invite::operator==
bool operator==(const Invite &) const =default
Default comparison operator.
QXmpp::Uri::Invite::password
QString password
the password required to enter a multi-user chat room
Definition QXmppUri.h:35
QXmpp::Uri::Invite::inviteeJid
QString inviteeJid
the JID of the invitee
Definition QXmppUri.h:33
QXmpp::Uri::Join
Definition QXmppUri.h:41
QXmpp::Uri::Join::operator==
bool operator==(const Join &) const =default
Default comparison operator.
QXmpp::Uri::Join::password
QString password
the password required to enter a multi-user chat room
Definition QXmppUri.h:43
QXmpp::Uri::Login
Definition QXmppUri.h:49
QXmpp::Uri::Login::password
QString password
the password required to connect to the account
Definition QXmppUri.h:51
QXmpp::Uri::Login::operator==
bool operator==(const Login &) const =default
Default comparison operator.
QXmpp::Uri::Message
Definition QXmppUri.h:57
QXmpp::Uri::Message::subject
QString subject
a subject for the message per the "jabber:client" schema
Definition QXmppUri.h:59
QXmpp::Uri::Message::from
QString from
an ID for the message per the "jabber:client" schema
Definition QXmppUri.h:67
QXmpp::Uri::Message::id
QString id
a from address for the message per the "jabber:client" schema
Definition QXmppUri.h:65
QXmpp::Uri::Message::thread
QString thread
a Thread ID for the message per the "jabber:client" schema
Definition QXmppUri.h:63
QXmpp::Uri::Message::operator==
bool operator==(const Message &) const =default
Default comparison operator.
QXmpp::Uri::Message::type
std::optional< QXmppMessage::Type > type
the message type per the "jabber:client" schema
Definition QXmppUri.h:69
QXmpp::Uri::Message::body
QString body
a body for the message per the "jabber:client" schema
Definition QXmppUri.h:61
QXmpp::Uri::Register
Definition QXmppUri.h:85
QXmpp::Uri::Register::operator==
bool operator==(const Register &) const =default
Default comparison operator.
QXmpp::Uri::Remove
Definition QXmppUri.h:90
QXmpp::Uri::Remove::operator==
bool operator==(const Remove &) const =default
Default comparison operator.
QXmpp::Uri::Roster
Definition QXmppUri.h:95
QXmpp::Uri::Roster::name
QString name
the user-assigned group for the roster item
Definition QXmppUri.h:97
QXmpp::Uri::Roster::operator==
bool operator==(const Roster &) const =default
Default comparison operator.
QXmpp::Uri::Roster::group
QString group
the user-assigned name for the roster item
Definition QXmppUri.h:99
QXmpp::Uri::Subscribe
Definition QXmppUri.h:105
QXmpp::Uri::Subscribe::operator==
bool operator==(const Subscribe &) const =default
Default comparison operator.
QXmpp::Uri::TrustMessage
Definition QXmppUri.h:110
QXmpp::Uri::TrustMessage::trustKeyIds
QList< QString > trustKeyIds
list of Base16 encoded key identifiers to be trusted
Definition QXmppUri.h:114
QXmpp::Uri::TrustMessage::encryption
QString encryption
encryption of the keys to trust or distrust
Definition QXmppUri.h:112
QXmpp::Uri::TrustMessage::distrustKeyIds
QList< QString > distrustKeyIds
list of Base16 encoded key identifiers to be distrusted
Definition QXmppUri.h:116
QXmpp::Uri::TrustMessage::operator==
bool operator==(const TrustMessage &) const =default
Default comparison operator.
QXmpp::Uri::Unregister
Definition QXmppUri.h:75
QXmpp::Uri::Unregister::operator==
bool operator==(const Unregister &) const =default
Default comparison operator.
QXmpp::Uri::Unsubscribe
Definition QXmppUri.h:80
QXmpp::Uri::Unsubscribe::operator==
bool operator==(const Unsubscribe &) const =default
Default comparison operator.