QXmpp Version: 1.10.0
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
21struct Command {
23 QString node;
25 QString action;
26
28 bool operator==(const Command &) const = default;
29};
30
31struct Invite {
33 QString inviteeJid;
35 QString password;
36
38 bool operator==(const Invite &) const = default;
39};
40
41struct Join {
43 QString password;
44
46 bool operator==(const Join &) const = default;
47};
48
49struct Login {
51 QString password;
52
54 bool operator==(const Login &) const = default;
55};
56
57struct 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
75struct Unregister {
77 bool operator==(const Unregister &) const = default;
78};
79
82 bool operator==(const Unsubscribe &) const = default;
83};
84
85struct Register {
87 bool operator==(const Register &) const = default;
88};
89
90struct Remove {
92 bool operator==(const Remove &) const = default;
93};
94
95struct Roster {
97 QString name;
99 QString group;
100
102 bool operator==(const Roster &) const = default;
103};
104
105struct Subscribe {
107 bool operator==(const Subscribe &) const = default;
108};
109
112 QString encryption;
114 QList<QString> trustKeyIds;
116 QList<QString> distrustKeyIds;
117
119 bool operator==(const TrustMessage &) const = default;
120};
121
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
134class 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
Definition: QXmppUri.h:135
void setQuery(QXmpp::Uri::Subscribe &&q)
Sets a subscribe query.
Definition: QXmppUri.h:167
void setQuery(QXmpp::Uri::CustomQuery &&q)
Sets a query with custom name and key-value pairs.
Definition: QXmppUri.h:171
void setQuery(QXmpp::Uri::Message &&q)
Sets a message query.
Definition: QXmppUri.h:157
void setQuery(QXmpp::Uri::Command &&q)
Sets a "command" query.
Definition: QXmppUri.h:149
void setQuery(QXmpp::Uri::Register &&q)
Sets a register query.
Definition: QXmppUri.h:161
void setQuery(QXmpp::Uri::Join &&q)
Sets a MUC join query.
Definition: QXmppUri.h:153
void setQuery(QXmpp::Uri::Unregister &&q)
Sets a unregister query.
Definition: QXmppUri.h:159
void setQuery(QXmpp::Uri::Invite &&q)
Sets a MUC invite query.
Definition: QXmppUri.h:151
void setQuery(QXmpp::Uri::Remove &&q)
Sets a remove query.
Definition: QXmppUri.h:163
void setQuery(QXmpp::Uri::Roster &&q)
Sets a roster query.
Definition: QXmppUri.h:165
void setQuery(QXmpp::Uri::Login &&q)
Sets a login query.
Definition: QXmppUri.h:155
void resetQuery()
Removes any query from the URI.
Definition: QXmppUri.h:173
void setQuery(QXmpp::Uri::TrustMessage &&q)
Sets a trust message query.
Definition: QXmppUri.h:169
Definition: QXmppUri.h:21
bool operator==(const Command &) const =default
Default comparison operator.
QString action
the ad-hoc commands action type
Definition: QXmppUri.h:25
QString node
the command node
Definition: QXmppUri.h:23
Definition: QXmppUri.h:122
QString query
query name as string
Definition: QXmppUri.h:124
QList< std::pair< QString, QString > > parameters
list of parameters as key-value pairs
Definition: QXmppUri.h:126
bool operator==(const CustomQuery &) const =default
Default comparison operator.
Definition: QXmppUri.h:31
bool operator==(const Invite &) const =default
Default comparison operator.
QString password
the password required to enter a multi-user chat room
Definition: QXmppUri.h:35
QString inviteeJid
the JID of the invitee
Definition: QXmppUri.h:33
Definition: QXmppUri.h:41
bool operator==(const Join &) const =default
Default comparison operator.
QString password
the password required to enter a multi-user chat room
Definition: QXmppUri.h:43
Definition: QXmppUri.h:49
QString password
the password required to connect to the account
Definition: QXmppUri.h:51
bool operator==(const Login &) const =default
Default comparison operator.
Definition: QXmppUri.h:57
QString subject
a subject for the message per the "jabber:client" schema
Definition: QXmppUri.h:59
QString from
an ID for the message per the "jabber:client" schema
Definition: QXmppUri.h:67
QString id
a from address for the message per the "jabber:client" schema
Definition: QXmppUri.h:65
QString thread
a Thread ID for the message per the "jabber:client" schema
Definition: QXmppUri.h:63
bool operator==(const Message &) const =default
Default comparison operator.
std::optional< QXmppMessage::Type > type
the message type per the "jabber:client" schema
Definition: QXmppUri.h:69
QString body
a body for the message per the "jabber:client" schema
Definition: QXmppUri.h:61
Definition: QXmppUri.h:85
bool operator==(const Register &) const =default
Default comparison operator.
Definition: QXmppUri.h:90
bool operator==(const Remove &) const =default
Default comparison operator.
Definition: QXmppUri.h:95
QString name
the user-assigned group for the roster item
Definition: QXmppUri.h:97
bool operator==(const Roster &) const =default
Default comparison operator.
QString group
the user-assigned name for the roster item
Definition: QXmppUri.h:99
Definition: QXmppUri.h:105
bool operator==(const Subscribe &) const =default
Default comparison operator.
Definition: QXmppUri.h:110
QList< QString > trustKeyIds
list of Base16 encoded key identifiers to be trusted
Definition: QXmppUri.h:114
QString encryption
encryption of the keys to trust or distrust
Definition: QXmppUri.h:112
QList< QString > distrustKeyIds
list of Base16 encoded key identifiers to be distrusted
Definition: QXmppUri.h:116
bool operator==(const TrustMessage &) const =default
Default comparison operator.
Definition: QXmppUri.h:75
bool operator==(const Unregister &) const =default
Default comparison operator.
Definition: QXmppUri.h:80
bool operator==(const Unsubscribe &) const =default
Default comparison operator.