mirror of https://github.com/bqv/weechat-xmpp
something something inheritance
parent
0199da610e
commit
134bd388f4
@ -1,13 +0,0 @@
|
||||
// This Source Code Form is subject to the terms of the Mozilla Public
|
||||
// License, version 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/.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <memory>
|
||||
#include <functional>
|
||||
#include <strophe.h>
|
||||
|
||||
namespace strophe {
|
||||
|
||||
}
|
@ -0,0 +1,166 @@
|
||||
// This Source Code Form is subject to the terms of the Mozilla Public
|
||||
// License, version 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/.
|
||||
|
||||
#include "node.hh"
|
||||
#pragma GCC visibility push(default)
|
||||
#include "ns.hh"
|
||||
#pragma GCC visibility pop
|
||||
|
||||
std::string get_name(xmpp_stanza_t *stanza) {
|
||||
const char *result = NULL;
|
||||
result = xmpp_stanza_get_name(stanza);
|
||||
if (result)
|
||||
return result;
|
||||
else
|
||||
return {};
|
||||
}
|
||||
|
||||
std::optional<std::string> get_attribute(xmpp_stanza_t *stanza, const char *name) {
|
||||
const char *result = NULL;
|
||||
result = xmpp_stanza_get_attribute(stanza, name);
|
||||
if (result)
|
||||
return result;
|
||||
else
|
||||
return {};
|
||||
}
|
||||
|
||||
std::string get_text(xmpp_stanza_t *stanza) {
|
||||
const char *result = NULL;
|
||||
result = xmpp_stanza_get_text_ptr(stanza);
|
||||
if (result)
|
||||
return result;
|
||||
else
|
||||
return {};
|
||||
}
|
||||
|
||||
std::chrono::system_clock::time_point get_time(const std::string& text) {
|
||||
std::tm tm = {};
|
||||
std::istringstream ss(text);
|
||||
//ss.imbue(std::locale("en_GB.utf-8"));
|
||||
ss >> std::get_time(&tm, "%Y-%m-%dT%H:%M:%S%z");
|
||||
if (ss.fail()) {
|
||||
throw std::invalid_argument("Bad time format");
|
||||
} else {
|
||||
return std::chrono::system_clock::from_time_t(std::mktime(&tm));
|
||||
}
|
||||
}
|
||||
|
||||
jid::jid(xmpp_ctx_t *context, std::string s) {
|
||||
char *result = NULL;
|
||||
result = xmpp_jid_node(context, s.data());
|
||||
if (result)
|
||||
{
|
||||
local = result;
|
||||
xmpp_free(context, result);
|
||||
result = NULL;
|
||||
}
|
||||
result = xmpp_jid_domain(context, s.data());
|
||||
if (result)
|
||||
{
|
||||
domain = result;
|
||||
xmpp_free(context, result);
|
||||
result = NULL;
|
||||
}
|
||||
else
|
||||
throw std::invalid_argument("Invalid JID");
|
||||
result = xmpp_jid_resource(context, s.data());
|
||||
if (result)
|
||||
{
|
||||
resource = result;
|
||||
xmpp_free(context, result);
|
||||
result = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
std::string jid::full() const {
|
||||
return fmt::format("{}{}{}{}{}", *local, local ? "@" : "", domain,
|
||||
resource ? "/" : "", *resource);
|
||||
}
|
||||
|
||||
std::string jid::bare() const {
|
||||
return fmt::format("{}{}{}", *local, local ? "@" : "", domain);
|
||||
}
|
||||
|
||||
bool jid::is_bare() const {
|
||||
return !resource;
|
||||
}
|
||||
|
||||
xml::node::node() {}
|
||||
|
||||
void xml::node::bind(xmpp_ctx_t *context, xmpp_stanza_t *stanza) {
|
||||
name = get_name(stanza);
|
||||
|
||||
id = get_attribute(stanza, "id");
|
||||
ns = get_attribute(stanza, "xmlns");
|
||||
|
||||
int count = xmpp_stanza_get_attribute_count(stanza);
|
||||
std::vector<const char*> attrvec(count * 2, nullptr);
|
||||
const char **attrs = attrvec.data();
|
||||
xmpp_stanza_get_attributes(stanza, attrs, count * 2);
|
||||
for (int i = 0; i < count; i++) {
|
||||
const char *key = attrs[(2*i)];
|
||||
const char *value = attrs[(2*i)+1];
|
||||
attributes.emplace(key, value);
|
||||
}
|
||||
|
||||
text = get_text(stanza);
|
||||
|
||||
for (xmpp_stanza_t *child = xmpp_stanza_get_children(stanza);
|
||||
child; child = xmpp_stanza_get_next(child)) {
|
||||
if (xmpp_stanza_is_text(child))
|
||||
text += get_text(child);
|
||||
else
|
||||
children.emplace_back(context, child);
|
||||
}
|
||||
}
|
||||
|
||||
void xml::message::bind(xmpp_ctx_t *context, xmpp_stanza_t *stanza) {
|
||||
auto result = get_attribute(stanza, "from");
|
||||
if (result)
|
||||
from = jid(context, *result);
|
||||
result = get_attribute(stanza, "to");
|
||||
if (result)
|
||||
to = jid(context, *result);
|
||||
type = get_attribute(stanza, "type");
|
||||
|
||||
node::bind(context, stanza);
|
||||
}
|
||||
|
||||
std::optional<std::string> xml::presence::show() {
|
||||
auto child = get_children("show");
|
||||
if (child.size() > 0)
|
||||
return child.front().get().text;
|
||||
return {};
|
||||
}
|
||||
|
||||
std::optional<std::string> xml::presence::status() {
|
||||
auto child = get_children("status");
|
||||
if (child.size() > 0)
|
||||
return child.front().get().text;
|
||||
return {};
|
||||
}
|
||||
|
||||
void xml::presence::bind(xmpp_ctx_t *context, xmpp_stanza_t *stanza) {
|
||||
auto result = get_attribute(stanza, "from");
|
||||
if (result)
|
||||
from = jid(context, *result);
|
||||
result = get_attribute(stanza, "to");
|
||||
if (result)
|
||||
to = jid(context, *result);
|
||||
type = get_attribute(stanza, "type");
|
||||
|
||||
node::bind(context, stanza);
|
||||
}
|
||||
|
||||
void xml::iq::bind(xmpp_ctx_t *context, xmpp_stanza_t *stanza) {
|
||||
auto result = get_attribute(stanza, "from");
|
||||
if (result)
|
||||
from = jid(context, *result);
|
||||
result = get_attribute(stanza, "to");
|
||||
if (result)
|
||||
to = jid(context, *result);
|
||||
type = get_attribute(stanza, "type");
|
||||
|
||||
node::bind(context, stanza);
|
||||
}
|
@ -0,0 +1,138 @@
|
||||
// This Source Code Form is subject to the terms of the Mozilla Public
|
||||
// License, version 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/.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <optional>
|
||||
#include <stdexcept>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
#include <vector>
|
||||
#include <chrono>
|
||||
#include <sstream>
|
||||
#include <locale>
|
||||
#include <iomanip>
|
||||
#include <fmt/core.h>
|
||||
#include <strophe.h>
|
||||
|
||||
std::string get_name(xmpp_stanza_t *stanza);
|
||||
|
||||
std::optional<std::string> get_attribute(xmpp_stanza_t *stanza, const char *name);
|
||||
|
||||
std::string get_text(xmpp_stanza_t *stanza);
|
||||
|
||||
std::chrono::system_clock::time_point get_time(const std::string& text);
|
||||
|
||||
class jid {
|
||||
public:
|
||||
std::optional<std::string> local;
|
||||
std::string domain;
|
||||
std::optional<std::string> resource;
|
||||
|
||||
jid(xmpp_ctx_t *context, std::string s);
|
||||
|
||||
std::string full() const;
|
||||
std::string bare() const;
|
||||
bool is_bare() const;
|
||||
};
|
||||
|
||||
namespace xml {
|
||||
|
||||
class node {
|
||||
protected:
|
||||
explicit node();
|
||||
|
||||
public:
|
||||
inline node(xmpp_ctx_t *context, xmpp_stanza_t *stanza) {
|
||||
bind(context, stanza);
|
||||
}
|
||||
|
||||
std::optional<std::string> name;
|
||||
|
||||
std::optional<std::string> id;
|
||||
std::optional<std::string> ns;
|
||||
|
||||
std::map<std::string, std::string> attributes;
|
||||
std::vector<node> children;
|
||||
|
||||
std::string text;
|
||||
|
||||
virtual void bind(xmpp_ctx_t *context, xmpp_stanza_t *stanza);
|
||||
|
||||
template<typename xmlns>
|
||||
inline std::vector<std::reference_wrapper<node>>
|
||||
get_children(std::string_view name) {
|
||||
std::vector<std::reference_wrapper<node>> list;
|
||||
std::copy_if(children.begin(), children.end(),
|
||||
std::back_inserter(list),
|
||||
[&](node& x) {
|
||||
return x.name == name
|
||||
&& x.ns == std::string_view(xmlns());
|
||||
});
|
||||
return list;
|
||||
}
|
||||
|
||||
inline std::vector<std::reference_wrapper<node>>
|
||||
get_children(std::string_view name) {
|
||||
std::vector<std::reference_wrapper<node>> list;
|
||||
std::copy_if(children.begin(), children.end(),
|
||||
std::back_inserter(list),
|
||||
[&](node& x) {
|
||||
return x.name == name;
|
||||
});
|
||||
return list;
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#include "xep-0027.inl"
|
||||
#include "xep-0045.inl"
|
||||
#include "xep-0115.inl"
|
||||
#include "xep-0319.inl"
|
||||
|
||||
namespace xml {
|
||||
|
||||
class message : virtual public node, public xep0027 {
|
||||
public:
|
||||
using node::node;
|
||||
|
||||
std::optional<jid> from;
|
||||
std::optional<jid> to;
|
||||
|
||||
std::optional<std::string> type;
|
||||
|
||||
void bind(xmpp_ctx_t *context, xmpp_stanza_t *stanza) override;
|
||||
};
|
||||
|
||||
class presence : virtual public node, public xep0045, public xep0115, public xep0319 {
|
||||
public:
|
||||
using node::node;
|
||||
|
||||
std::optional<jid> from;
|
||||
std::optional<jid> to;
|
||||
|
||||
std::optional<std::string> type;
|
||||
|
||||
std::optional<std::string> show();
|
||||
std::optional<std::string> status();
|
||||
|
||||
void bind(xmpp_ctx_t *context, xmpp_stanza_t *stanza) override;
|
||||
};
|
||||
|
||||
class iq : virtual public node {
|
||||
public:
|
||||
using node::node;
|
||||
|
||||
std::optional<jid> from;
|
||||
std::optional<jid> to;
|
||||
|
||||
std::optional<std::string> type;
|
||||
|
||||
void bind(xmpp_ctx_t *context, xmpp_stanza_t *stanza) override;
|
||||
};
|
||||
|
||||
}
|
@ -0,0 +1,276 @@
|
||||
// This Source Code Form is subject to the terms of the Mozilla Public
|
||||
// License, version 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/.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <string_view>
|
||||
|
||||
class xmlns {
|
||||
private:
|
||||
const char *const _uri;
|
||||
protected:
|
||||
inline xmlns(const char *uri) : _uri(uri) {}
|
||||
public:
|
||||
inline const char *ns() { return _uri; }
|
||||
inline operator const char *() { return _uri; }
|
||||
};
|
||||
|
||||
struct etherx_jabber_org {
|
||||
struct streams : public xmlns { streams() : xmlns("http://etherx.jabber.org/streams") {} };
|
||||
};
|
||||
struct jabber_org {
|
||||
struct features {
|
||||
struct amp : public xmlns { amp() : xmlns("http://jabber.org/features/amp") {} };
|
||||
struct compress : public xmlns { compress() : xmlns("http://jabber.org/features/compress") {} };
|
||||
};
|
||||
struct protocol {
|
||||
struct activity : public xmlns { activity() : xmlns("http://jabber.org/protocol/activity") {} };
|
||||
struct address : public xmlns { address() : xmlns("http://jabber.org/protocol/address") {} };
|
||||
struct amp : public xmlns { amp() : xmlns("http://jabber.org/protocol/amp") {}
|
||||
struct errors : public xmlns { errors() : xmlns("http://jabber.org/protocol/amp#errors") {} };
|
||||
};
|
||||
struct bytestreams : public xmlns { bytestreams() : xmlns("http://jabber.org/protocol/bytestreams") {} };
|
||||
struct caps : public xmlns { caps() : xmlns("http://jabber.org/protocol/caps") {} };
|
||||
struct chatstates : public xmlns { chatstates() : xmlns("http://jabber.org/protocol/chatstates") {} };
|
||||
struct commands : public xmlns { commands() : xmlns("http://jabber.org/protocol/commands") {} };
|
||||
struct compress : public xmlns { compress() : xmlns("http://jabber.org/protocol/compress") {}
|
||||
struct exi : public xmlns { exi() : xmlns("http://jabber.org/protocol/compress/exi") {} };
|
||||
};
|
||||
struct disco {
|
||||
struct info : public xmlns { info() : xmlns("http://jabber.org/protocol/disco#info") {} };
|
||||
struct items : public xmlns { items() : xmlns("http://jabber.org/protocol/disco#items") {} };
|
||||
};
|
||||
struct feature_neg : public xmlns { feature_neg() : xmlns("http://jabber.org/protocol/feature-neg") {} };
|
||||
struct files : public xmlns { files() : xmlns("http://jabber.org/protocol/files") {} };
|
||||
struct geoloc : public xmlns { geoloc() : xmlns("http://jabber.org/protocol/geoloc") {} };
|
||||
struct http_auth : public xmlns { http_auth() : xmlns("http://jabber.org/protocol/http-auth") {} };
|
||||
struct httpbind : public xmlns { httpbind() : xmlns("http://jabber.org/protocol/httpbind") {} };
|
||||
struct ibb : public xmlns { ibb() : xmlns("http://jabber.org/protocol/ibb") {} };
|
||||
struct jinglenodes : public xmlns { jinglenodes() : xmlns("http://jabber.org/protocol/jinglenodes") {} };
|
||||
struct mood : public xmlns { mood() : xmlns("http://jabber.org/protocol/mood") {} };
|
||||
struct muc : public xmlns { muc() : xmlns("http://jabber.org/protocol/muc") {}
|
||||
struct admin : public xmlns { admin() : xmlns("http://jabber.org/protocol/muc#admin") {} };
|
||||
struct owner : public xmlns { owner() : xmlns("http://jabber.org/protocol/muc#owner") {} };
|
||||
struct unique : public xmlns { unique() : xmlns("http://jabber.org/protocol/muc#unique") {} };
|
||||
struct user : public xmlns { user() : xmlns("http://jabber.org/protocol/muc#user") {} };
|
||||
};
|
||||
struct nick : public xmlns { nick() : xmlns("http://jabber.org/protocol/nick") {} };
|
||||
struct offline : public xmlns { offline() : xmlns("http://jabber.org/protocol/offline") {} };
|
||||
struct physloc : public xmlns { physloc() : xmlns("http://jabber.org/protocol/physloc") {} };
|
||||
struct poke : public xmlns { poke() : xmlns("http://jabber.org/protocol/poke") {} };
|
||||
struct pubsub : public xmlns { pubsub() : xmlns("http://jabber.org/protocol/pubsub") {}
|
||||
struct errors : public xmlns { errors() : xmlns("http://jabber.org/protocol/pubsub#errors") {} };
|
||||
struct event : public xmlns { event() : xmlns("http://jabber.org/protocol/pubsub#event") {} };
|
||||
struct owner : public xmlns { owner() : xmlns("http://jabber.org/protocol/pubsub#owner") {} };
|
||||
};
|
||||
struct rosterx : public xmlns { rosterx() : xmlns("http://jabber.org/protocol/rosterx") {} };
|
||||
struct rsm : public xmlns { rsm() : xmlns("http://jabber.org/protocol/rsm") {} };
|
||||
struct shim : public xmlns { shim() : xmlns("http://jabber.org/protocol/shim") {} };
|
||||
struct si : public xmlns { si() : xmlns("http://jabber.org/protocol/si") {}
|
||||
struct profile {
|
||||
struct file_transfer : public xmlns { file_transfer() : xmlns("http://jabber.org/protocol/si/profile/file-transfer") {} };
|
||||
};
|
||||
};
|
||||
struct sipub : public xmlns { sipub() : xmlns("http://jabber.org/protocol/sipub") {} };
|
||||
struct soap {
|
||||
struct fault : public xmlns { fault() : xmlns("http://jabber.org/protocol/soap#fault") {} };
|
||||
};
|
||||
struct tune : public xmlns { tune() : xmlns("http://jabber.org/protocol/tune") {} };
|
||||
struct waitinglist : public xmlns { waitinglist() : xmlns("http://jabber.org/protocol/waitinglist") {} };
|
||||
struct workgroup : public xmlns { workgroup() : xmlns("http://jabber.org/protocol/workgroup") {} };
|
||||
struct xdata_layout : public xmlns { xdata_layout() : xmlns("http://jabber.org/protocol/xdata-layout") {} };
|
||||
struct xdata_validate : public xmlns { xdata_validate() : xmlns("http://jabber.org/protocol/xdata-validate") {} };
|
||||
struct xhtml_im : public xmlns { xhtml_im() : xmlns("http://jabber.org/protocol/xhtml-im") {} };
|
||||
};
|
||||
};
|
||||
struct jabber {
|
||||
struct client : public xmlns { client() : xmlns("jabber:client") {} };
|
||||
struct component {
|
||||
struct accept : public xmlns { accept() : xmlns("jabber:component:accept") {} };
|
||||
struct connect : public xmlns { connect() : xmlns("jabber:component:connect") {} };
|
||||
};
|
||||
struct iq {
|
||||
struct auth : public xmlns { auth() : xmlns("jabber:iq:auth") {} };
|
||||
struct gateway : public xmlns { gateway() : xmlns("jabber:iq:gateway") {} };
|
||||
struct last : public xmlns { last() : xmlns("jabber:iq:last") {} };
|
||||
struct oob : public xmlns { oob() : xmlns("jabber:iq:oob") {} };
|
||||
struct pass : public xmlns { pass() : xmlns("jabber:iq:pass") {} };
|
||||
struct privacy : public xmlns { privacy() : xmlns("jabber:iq:privacy") {} };
|
||||
struct private_ : public xmlns { private_() : xmlns("jabber:iq:private") {} };
|
||||
struct register_ : public xmlns { register_() : xmlns("jabber:iq:register") {} };
|
||||
struct roster : public xmlns { roster() : xmlns("jabber:iq:roster") {} };
|
||||
struct rpc : public xmlns { rpc() : xmlns("jabber:iq:rpc") {} };
|
||||
struct search : public xmlns { search() : xmlns("jabber:iq:search") {} };
|
||||
struct time : public xmlns { time() : xmlns("jabber:iq:time") {} };
|
||||
struct version : public xmlns { version() : xmlns("jabber:iq:version") {} };
|
||||
};
|
||||
struct server : public xmlns { server() : xmlns("jabber:server") {}
|
||||
struct dialback : public xmlns { dialback() : xmlns("jabber:server:dialback") {} };
|
||||
};
|
||||
struct x {
|
||||
struct conference : public xmlns { conference() : xmlns("jabber:x:conference") {} };
|
||||
struct data : public xmlns { data() : xmlns("jabber:x:data") {} };
|
||||
struct delay : public xmlns { delay() : xmlns("jabber:x:delay") {} };
|
||||
struct encrypted : public xmlns { encrypted() : xmlns("jabber:x:encrypted") {} };
|
||||
struct event : public xmlns { event() : xmlns("jabber:x:event") {} };
|
||||
struct expire : public xmlns { expire() : xmlns("jabber:x:expire") {} };
|
||||
struct oob : public xmlns { oob() : xmlns("jabber:x:oob") {} };
|
||||
struct roster : public xmlns { roster() : xmlns("jabber:x:roster") {} };
|
||||
struct signed_ : public xmlns { signed_() : xmlns("jabber:x:signed") {} };
|
||||
};
|
||||
};
|
||||
struct roster {
|
||||
struct delimiter : public xmlns { delimiter() : xmlns("roster:delimiter") {} };
|
||||
};
|
||||
struct storage {
|
||||
struct bookmarks : public xmlns { bookmarks() : xmlns("storage:bookmarks") {} };
|
||||
struct metacontacts : public xmlns { metacontacts() : xmlns("storage:metacontacts") {} };
|
||||
struct pubsubs : public xmlns { pubsubs() : xmlns("storage:pubsubs") {} };
|
||||
struct rosternotes : public xmlns { rosternotes() : xmlns("storage:rosternotes") {} };
|
||||
};
|
||||
struct urn {
|
||||
struct ietf {
|
||||
struct params {
|
||||
struct xml {
|
||||
struct ns {
|
||||
struct xmpp_bind : public xmlns { xmpp_bind() : xmlns("urn:ietf:params:xml:ns:xmpp-bind") {} };
|
||||
struct xmpp_e2e : public xmlns { xmpp_e2e() : xmlns("urn:ietf:params:xml:ns:xmpp-e2e") {} };
|
||||
struct xmpp_sasl : public xmlns { xmpp_sasl() : xmlns("urn:ietf:params:xml:ns:xmpp-sasl") {} };
|
||||
struct xmpp_session : public xmlns { xmpp_session() : xmlns("urn:ietf:params:xml:ns:xmpp-session") {} };
|
||||
struct xmpp_stanzas : public xmlns { xmpp_stanzas() : xmlns("urn:ietf:params:xml:ns:xmpp-stanzas") {} };
|
||||
struct xmpp_streams : public xmlns { xmpp_streams() : xmlns("urn:ietf:params:xml:ns:xmpp-streams") {} };
|
||||
struct xmpp_tls : public xmlns { xmpp_tls() : xmlns("urn:ietf:params:xml:ns:xmpp-tls") {} };
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
struct xmpp {
|
||||
struct ago { struct _0 : public xmlns { _0() : xmlns("urn:xmpp:ago:0") {} }; };
|
||||
struct archive : public xmlns { archive() : xmlns("urn:xmpp:archive") {} };
|
||||
struct attention { struct _0 : public xmlns { _0() : xmlns("urn:xmpp:attention:0") {} }; };
|
||||
struct avatar {
|
||||
struct data : public xmlns { data() : xmlns("urn:xmpp:avatar:data") {} };
|
||||
struct metadata : public xmlns { metadata() : xmlns("urn:xmpp:avatar:metadata") {} };
|
||||
};
|
||||
struct bidi : public xmlns { bidi() : xmlns("urn:xmpp:bidi") {} };
|
||||
struct blocking : public xmlns { blocking() : xmlns("urn:xmpp:blocking") {}
|
||||
struct errors : public xmlns { errors() : xmlns("urn:xmpp:blocking:errors") {} };
|
||||
};
|
||||
struct bob : public xmlns { bob() : xmlns("urn:xmpp:bob") {} };
|
||||
struct bookmarks { struct _1 : public xmlns { _1() : xmlns("urn:xmpp:bookmarks:1") {} }; };
|
||||
struct browsing { struct _0 : public xmlns { _0() : xmlns("urn:xmpp:browsing:0") {} }; };
|
||||
struct bxmpp : public xmlns { bxmpp() : xmlns("urn:xmpp:bxmpp") {} };
|
||||
struct caps : public xmlns { caps() : xmlns("urn:xmpp:caps") {} };
|
||||
struct captcha : public xmlns { captcha() : xmlns("urn:xmpp:captcha") {} };
|
||||
struct carbons { struct _2 : public xmlns { _2() : xmlns("urn:xmpp:carbons:2") {} }; };
|
||||
struct chatting { struct _0 : public xmlns { _0() : xmlns("urn:xmpp:chatting:0") {} }; };
|
||||
struct cmr { struct _0 : public xmlns { _0() : xmlns("urn:xmpp:cmr:0") {} }; };
|
||||
struct component { struct _0 : public xmlns { _0() : xmlns("urn:xmpp:component:0") {} }; };
|
||||
struct decloak { struct _0 : public xmlns { _0() : xmlns("urn:xmpp:decloak:0") {} }; };
|
||||
struct delay : public xmlns { delay() : xmlns("urn:xmpp:delay") {} };
|
||||
struct delegation { struct _2 : public xmlns { _2() : xmlns("urn:xmpp:delegation:2") {} }; };
|
||||
struct domain_based_name { struct _1 : public xmlns { _1() : xmlns("urn:xmpp:domain-based-name:1") {} }; };
|
||||
struct dox { struct _0 : public xmlns { _0() : xmlns("urn:xmpp:dox:0") {} }; };
|
||||
struct eventlog : public xmlns { eventlog() : xmlns("urn:xmpp:eventlog") {} };
|
||||
struct extdisco { struct _2 : public xmlns { _2() : xmlns("urn:xmpp:extdisco:2") {} }; };
|
||||
struct features {
|
||||
struct rosterver : public xmlns { rosterver() : xmlns("urn:xmpp:features:rosterver") {} };
|
||||
};
|
||||
struct forward { struct _0 : public xmlns { _0() : xmlns("urn:xmpp:forward:0") {} }; };
|
||||
struct gaming { struct _0 : public xmlns { _0() : xmlns("urn:xmpp:gaming:0") {} }; };
|
||||
struct hashes { struct _2 : public xmlns { _2() : xmlns("urn:xmpp:hashes:2") {} }; };
|
||||
struct http : public xmlns { http() : xmlns("urn:xmpp:http") {}
|
||||
struct upload { struct _0 : public xmlns { _0() : xmlns("urn:xmpp:http:upload:0") {} }; };
|
||||
};
|
||||
struct idle { struct _1 : public xmlns { _1() : xmlns("urn:xmpp:idle:1") {} }; };
|
||||
struct incident { struct _2 : public xmlns { _2() : xmlns("urn:xmpp:incident:2") {} }; };
|
||||
struct invisible { struct _1 : public xmlns { _1() : xmlns("urn:xmpp:invisible:1") {} }; };
|
||||
struct iot {
|
||||
struct concentrators : public xmlns { concentrators() : xmlns("urn:xmpp:iot:concentrators") {} };
|
||||
struct control : public xmlns { control() : xmlns("urn:xmpp:iot:control") {} };
|
||||
struct discovery : public xmlns { discovery() : xmlns("urn:xmpp:iot:discovery") {} };
|
||||
struct provisioning : public xmlns { provisioning() : xmlns("urn:xmpp:iot:provisioning") {} };
|
||||
struct sensordata : public xmlns { sensordata() : xmlns("urn:xmpp:iot:sensordata") {} };
|
||||
};
|
||||
struct jid { struct _0 : public xmlns { _0() : xmlns("urn:xmpp:jid:0") {} }; };
|
||||
struct jingle { struct _1 : public xmlns { _1() : xmlns("urn:xmpp:jingle:1") {} };
|
||||
struct apps {
|
||||
struct dtls { struct _0 : public xmlns { _0() : xmlns("urn:xmpp:jingle:apps:dtls:0") {} }; };
|
||||
struct rtp { struct _1 : public xmlns { _1() : xmlns("urn:xmpp:jingle:apps:rtp:1") {} };
|
||||
struct errors { struct _1 : public xmlns { _1() : xmlns("urn:xmpp:jingle:apps:rtp:errors:1") {} }; };
|
||||
struct info { struct _1 : public xmlns { _1() : xmlns("urn:xmpp:jingle:apps:rtp:info:1") {} }; };
|
||||
struct rtcp_fb { struct _0 : public xmlns { _0() : xmlns("urn:xmpp:jingle:apps:rtp:rtcp-fb:0") {} }; };
|
||||
struct rtp_hdrext { struct _0 : public xmlns { _0() : xmlns("urn:xmpp:jingle:apps:rtp:rtp-hdrext:0") {} }; };
|
||||
struct ssma { struct _0 : public xmlns { _0() : xmlns("urn:xmpp:jingle:apps:rtp:ssma:0") {} }; };
|
||||
struct zrtp { struct _1 : public xmlns { _1() : xmlns("urn:xmpp:jingle:apps:rtp:zrtp:1") {} }; };
|
||||
};
|
||||
struct xmlstream { struct _0 : public xmlns { _0() : xmlns("urn:xmpp:jingle:apps:xmlstream:0") {} }; };
|
||||
};
|
||||
struct dtmf { struct _0 : public xmlns { _0() : xmlns("urn:xmpp:jingle:dtmf:0") {} }; };
|
||||
struct errors { struct _1 : public xmlns { _1() : xmlns("urn:xmpp:jingle:errors:1") {} }; };
|
||||
struct transfer { struct _0 : public xmlns { _0() : xmlns("urn:xmpp:jingle:transfer:0") {} }; };
|
||||
struct transports {
|
||||
struct dtls_sctp { struct _1 : public xmlns { _1() : xmlns("urn:xmpp:jingle:transports:dtls-sctp:1") {} }; };
|
||||
struct ibb { struct _1 : public xmlns { _1() : xmlns("urn:xmpp:jingle:transports:ibb:1") {} }; };
|
||||
struct ice { struct _0 : public xmlns { _0() : xmlns("urn:xmpp:jingle:transports:ice:0") {} }; };
|
||||
struct ice_udp { struct _1 : public xmlns { _1() : xmlns("urn:xmpp:jingle:transports:ice-udp:1") {} }; };
|
||||
struct raw_udp { struct _1 : public xmlns { _1() : xmlns("urn:xmpp:jingle:transports:raw-udp:1") {} }; };
|
||||
struct s5b { struct _1 : public xmlns { _1() : xmlns("urn:xmpp:jingle:transports:s5b:1") {} }; };
|
||||
struct webrtc_datachannel { struct _0 : public xmlns { _0() : xmlns("urn:xmpp:jingle:transports:webrtc-datachannel:0") {} }; };
|
||||
};
|
||||
};
|
||||
struct jingle_message { struct _1 : public xmlns { _1() : xmlns("urn:xmpp:jingle-message:1") {} }; };
|
||||
struct jinglepub { struct _1 : public xmlns { _1() : xmlns("urn:xmpp:jinglepub:1") {} }; };
|
||||
struct json { struct _0 : public xmlns { _0() : xmlns("urn:xmpp:json:0") {} }; };
|
||||
struct keepalive { struct _0 : public xmlns { _0() : xmlns("urn:xmpp:keepalive:0") {} }; };
|
||||
struct langtrans : public xmlns { langtrans() : xmlns("urn:xmpp:langtrans") {}
|
||||
struct items : public xmlns { items() : xmlns("urn:xmpp:langtrans:items") {} };
|
||||
};
|
||||
struct locationquery { struct _0 : public xmlns { _0() : xmlns("urn:xmpp:locationquery:0") {} }; };
|
||||
struct media_element : public xmlns { media_element() : xmlns("urn:xmpp:media-element") {} };
|
||||
struct message_attaching { struct _1 : public xmlns { _1() : xmlns("urn:xmpp:message-attaching:1") {} }; };
|
||||
struct message_correct { struct _0 : public xmlns { _0() : xmlns("urn:xmpp:message-correct:0") {} }; };
|
||||
struct message_moderate { struct _0 : public xmlns { _0() : xmlns("urn:xmpp:message-moderate:0") {} }; };
|
||||
struct message_retract { struct _0 : public xmlns { _0() : xmlns("urn:xmpp:message-retract:0") {} }; };
|
||||
struct muc {
|
||||
struct conditions { struct _1 : public xmlns { _1() : xmlns("urn:xmpp:muc:conditions:1") {} }; };
|
||||
};
|
||||
struct omemo { struct _2 : public xmlns { _2() : xmlns("urn:xmpp:omemo:2") {} }; };
|
||||
struct order_by { struct _1 : public xmlns { _1() : xmlns("urn:xmpp:order-by:1") {} }; };
|
||||
struct pie { struct _0 : public xmlns { _0() : xmlns("urn:xmpp:pie:0") {} }; };
|
||||
struct ping : public xmlns { ping() : xmlns("urn:xmpp:ping") {} };
|
||||
struct privilege { struct _1 : public xmlns { _1() : xmlns("urn:xmpp:privilege:1") {} }; };
|
||||
struct reach { struct _0 : public xmlns { _0() : xmlns("urn:xmpp:reach:0") {} }; };
|
||||
struct receipts : public xmlns { receipts() : xmlns("urn:xmpp:receipts") {} };
|
||||
struct reputation { struct _0 : public xmlns { _0() : xmlns("urn:xmpp:reputation:0") {} }; };
|
||||
struct sec_label { struct _0 : public xmlns { _0() : xmlns("urn:xmpp:sec-label:0") {} };
|
||||
struct catalog { struct _2 : public xmlns { _2() : xmlns("urn:xmpp:sec-label:catalog:2") {} }; };
|
||||
struct ess { struct _0 : public xmlns { _0() : xmlns("urn:xmpp:sec-label:ess:0") {} }; };
|
||||
};
|
||||
struct sic { struct _1 : public xmlns { _1() : xmlns("urn:xmpp:sic:1") {} }; };
|
||||
struct sift { struct _2 : public xmlns { _2() : xmlns("urn:xmpp:sift:2") {} }; };
|
||||
struct sm { struct _3 : public xmlns { _3() : xmlns("urn:xmpp:sm:3") {} }; };
|
||||
struct spoiler { struct _0 : public xmlns { _0() : xmlns("urn:xmpp:spoiler:0") {} }; };
|
||||
struct thumbs { struct _0 : public xmlns { _0() : xmlns("urn:xmpp:thumbs:0") {} }; };
|
||||
struct time : public xmlns { time() : xmlns("urn:xmpp:time") {} };
|
||||
struct tmp {
|
||||
struct abuse : public xmlns { abuse() : xmlns("urn:xmpp:tmp:abuse") {} };
|
||||
struct io_data : public xmlns { io_data() : xmlns("urn:xmpp:tmp:io-data") {} };
|
||||
struct mine { struct _0 : public xmlns { _0() : xmlns("urn:xmpp:tmp:mine:0") {} }; };
|
||||
struct profile : public xmlns { profile() : xmlns("urn:xmpp:tmp:profile") {} };
|
||||
struct roster_management { struct _0 : public xmlns { _0() : xmlns("urn:xmpp:tmp:roster-management:0") {} }; };
|
||||
};
|
||||
struct viewing { struct _0 : public xmlns { _0() : xmlns("urn:xmpp:viewing:0") {} }; };
|
||||
struct xbosh : public xmlns { xbosh() : xmlns("urn:xmpp:xbosh") {} };
|
||||
struct xdata {
|
||||
struct dynamic : public xmlns { dynamic() : xmlns("urn:xmpp:xdata:dynamic") {} };
|
||||
};
|
||||
};
|
||||
};
|
||||
struct vcard_temp_filter : public xmlns { vcard_temp_filter() : xmlns("vcard-temp-filter") {} };
|
||||
struct vcard_temp {
|
||||
struct x {
|
||||
struct update : public xmlns { update() : xmlns("vcard-temp:x:update") {} };
|
||||
};
|
||||
};
|
@ -0,0 +1,34 @@
|
||||
// This Source Code Form is subject to the terms of the Mozilla Public
|
||||
// License, version 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/.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <optional>
|
||||
#include <string>
|
||||
|
||||
#include "node.hh"
|
||||
#pragma GCC visibility push(default)
|
||||
#include "ns.hh"
|
||||
#pragma GCC visibility pop
|
||||
|
||||
namespace xml {
|
||||
|
||||
class xep0027 : virtual public node {
|
||||
public:
|
||||
std::optional<std::string> signature() {
|
||||
auto child = get_children<jabber::x::signed_>("x");
|
||||
if (child.size() > 0)
|
||||
return child.front().get().text;
|
||||
return {};
|
||||
}
|
||||
|
||||
std::optional<std::string> encrypted() {
|
||||
auto child = get_children<jabber::x::encrypted>("x");
|
||||
if (child.size() > 0)
|
||||
return child.front().get().text;
|
||||
return {};
|
||||
}
|
||||
};
|
||||
|
||||
}
|
@ -0,0 +1,62 @@
|
||||
// This Source Code Form is subject to the terms of the Mozilla Public
|
||||
// License, version 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/.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <optional>
|
||||
#include <string>
|
||||
|
||||
#include "node.hh"
|
||||
#pragma GCC visibility push(default)
|
||||
#include "ns.hh"
|
||||
#pragma GCC visibility pop
|
||||
|
||||
namespace xml {
|
||||
|
||||
class xep0045 : virtual public node {
|
||||
public:
|
||||
class x {
|
||||
private:
|
||||
struct decline {
|
||||
std::string reason;
|
||||
std::optional<jid> from;
|
||||
std::optional<jid> to;
|
||||
};
|
||||
|
||||
struct destroy {
|
||||
std::string reason;
|
||||
std::optional<jid> target;
|
||||
};
|
||||
|
||||
struct invite {
|
||||
std::string reason;
|
||||
std::optional<jid> from;
|
||||
std::optional<jid> to;
|
||||
};
|
||||
|
||||
struct item {
|
||||
std::string reason;
|
||||
};
|
||||
|
||||
public:
|
||||
x(const node& node) {
|
||||
}
|
||||
|
||||
std::vector<decline> declines;
|
||||
std::vector<destroy> destroys;
|
||||
std::vector<invite> invites;
|
||||
std::vector<item> items;
|
||||
std::vector<std::string> passwords;
|
||||
std::vector<int> statuses;
|
||||
};
|
||||
|
||||
std::optional<x> muc_user() {
|
||||
auto child = get_children<jabber_org::protocol::muc::user>("x");
|
||||
if (child.size() > 0)
|
||||
return child.front().get();
|
||||
return {};
|
||||
}
|
||||
};
|
||||
|
||||
}
|
@ -0,0 +1,27 @@
|
||||
// This Source Code Form is subject to the terms of the Mozilla Public
|
||||
// License, version 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/.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <optional>
|
||||
#include <string>
|
||||
|
||||
#include "node.hh"
|
||||
#pragma GCC visibility push(default)
|
||||
#include "ns.hh"
|
||||
#pragma GCC visibility pop
|
||||
|
||||
namespace xml{
|
||||
|
||||
class xep0115 : virtual public node {
|
||||
public:
|
||||
std::optional<node> caps() {
|
||||
auto child = get_children<jabber_org::protocol::caps>("c");
|
||||
if (child.size() > 0)
|
||||
return child.front().get();
|
||||
return {};
|
||||
}
|
||||
};
|
||||
|
||||
}
|
@ -0,0 +1,38 @@
|
||||
// This Source Code Form is subject to the terms of the Mozilla Public
|
||||
// License, version 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/.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <chrono>
|
||||
#include <optional>
|
||||
#include <stdexcept>
|
||||
#include <string>
|
||||
|
||||
#include "node.hh"
|
||||
#pragma GCC visibility push(default)
|
||||
#include "ns.hh"
|
||||
#pragma GCC visibility pop
|
||||
|
||||
namespace xml {
|
||||
|
||||
class xep0319 : virtual public node {
|
||||
public:
|
||||
std::optional<std::chrono::system_clock::time_point> idle_since() {
|
||||
auto children = get_children<urn::xmpp::idle::_1>("idle");
|
||||
if (children.size() <= 0)
|
||||
return {};
|
||||
auto child = children.front().get();
|
||||
auto since = child.attributes.find("since");
|
||||
if (since == child.attributes.end())
|
||||
return {};
|
||||
try {
|
||||
return get_time(since->second);
|
||||
}
|
||||
catch (const std::invalid_argument& ex) {
|
||||
return {};
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
}
|
Loading…
Reference in New Issue