Skip to content
Snippets Groups Projects
Commit 55e16e55 authored by kamathmanu's avatar kamathmanu
Browse files

Merge branch 'master' of https://github.com/kamathmanu/mtxclient into room-directory

Updated mtxclient with changes from remote master
parents 78671349 cad81d16
No related branches found
No related tags found
No related merge requests found
Pipeline #301 passed
Showing
with 2819 additions and 19 deletions
...@@ -13,28 +13,38 @@ $CMD perl -pi -w -e \ ...@@ -13,28 +13,38 @@ $CMD perl -pi -w -e \
( (
cat <<HEREDOC cat <<HEREDOC
rc_message: rc_message:
per_second: 1000 per_second: 10000
burst_count: 10000 burst_count: 100000
rc_registration: rc_registration:
per_second: 1000 per_second: 10000
burst_count: 3000 burst_count: 30000
rc_login: rc_login:
address: address:
per_second: 1000 per_second: 10000
burst_count: 3000 burst_count: 30000
account: account:
per_second: 1000 per_second: 10000
burst_count: 3000 burst_count: 30000
failed_attempts: failed_attempts:
per_second: 1000 per_second: 10000
burst_count: 3000 burst_count: 30000
rc_admin_redaction: rc_admin_redaction:
per_second: 1000 per_second: 1000
burst_count: 5000 burst_count: 5000
rc_joins:
local:
per_second: 10000
burst_count: 100000
remote:
per_second: 10000
burst_count: 100000
HEREDOC HEREDOC
) | $CMD tee -a data/homeserver.yaml ) | $CMD tee -a data/homeserver.yaml
......
...@@ -28,7 +28,8 @@ ...@@ -28,7 +28,8 @@
*.app *.app
# Build artifacts # Build artifacts
build*/ /build*/
/generated-docs/
# Editor # Editor
tags tags
...@@ -40,7 +41,7 @@ compile_commands.json ...@@ -40,7 +41,7 @@ compile_commands.json
.vscode .vscode
# Synapse data # Synapse data
data/ /data/
# Deps # Deps
.third-party .third-party
......
test-pages:
tags: [docker]
image: alpine
except:
- master
before_script:
- apk update
- apk add doxygen git texlive-full py3-jinja2 py3-pygments
- git clone git://github.com/mosra/m.css
script:
- ./m.css/documentation/doxygen.py Doxyfile-mcss
- mv generated-docs/html/ public/
artifacts:
paths:
- public
pages:
tags: [docker]
image: alpine
only:
- master
before_script:
- apk update
- apk add doxygen git texlive-full py3-jinja2 py3-pygments
- git clone git://github.com/mosra/m.css
script:
- ./m.css/documentation/doxygen.py Doxyfile-mcss
- mv generated-docs/html/ public/
artifacts:
paths:
- public
...@@ -169,6 +169,9 @@ target_sources(matrix_client ...@@ -169,6 +169,9 @@ target_sources(matrix_client
lib/structs/events/tombstone.cpp lib/structs/events/tombstone.cpp
lib/structs/events/topic.cpp lib/structs/events/topic.cpp
lib/structs/events/voip.cpp lib/structs/events/voip.cpp
lib/structs/events/account_data/fully_read.cpp
lib/structs/events/ephemeral/receipt.cpp
lib/structs/events/ephemeral/typing.cpp
lib/structs/events/nheko_extensions/hidden_events.cpp lib/structs/events/nheko_extensions/hidden_events.cpp
lib/structs/events/messages/audio.cpp lib/structs/events/messages/audio.cpp
lib/structs/events/messages/emote.cpp lib/structs/events/messages/emote.cpp
......
Doxyfile 0 → 100644
This diff is collapsed.
@INCLUDE = Doxyfile
GENERATE_HTML = NO
GENERATE_XML = YES
XML_PROGRAMLISTING = NO
FILES=`find lib include tests examples -type f -type f \( -iname "*.cpp" -o -iname "*.hpp" \)` FILES=`find lib include tests examples -type f -type f \( -iname "*.cpp" -o -iname "*.hpp" \)`
SYNAPSE_IMAGE="matrixdotorg/synapse:v1.7.2" SYNAPSE_IMAGE="matrixdotorg/synapse:v1.24.0"
DEPS_BUILD_DIR=.deps DEPS_BUILD_DIR=.deps
DEPS_SOURCE_DIR=deps DEPS_SOURCE_DIR=deps
......
/// @dir include
/// @brief Include directory. Add this to your include path.
/// @dir include/mtxclient
/// @brief The root directory for all the client callbacks.
/// @dir include/mtxclient/http
/// @brief Functions to invoke the API over HTTP.
/// @dir include/mtxclient/crypto
/// @brief Wrappers around the olm library as well as other encryption specific
/// functionality.
/// @dir include/mtx
/// @brief The root directory for all the type definitions listed in the
/// specifications.
/// @dir include/mtx/events
/// @brief The different event types in the Matrix API.
/// @dir include/mtx/events/messages
/// @brief The different types, that can be sent as a message event.
/// @dir include/mtx/events/ephemeral/
/// @brief Ephemeral events not part of the timeline like typing or read notifications.
/// @dir include/mtx/events/nheko_extensions
/// @brief Nheko specific event types not part of the official specification.
/// @dir include/mtx/responses
/// @brief The reponses returned from each request.
mtxclient {#mainpage}
=====================
mtxclient is a library for the [Matrix protocol](https://matrix.org/) used
primarily in the [Nheko client](https://nheko.im/nheko-reborn/nheko). This
library is not a full SDK. Rather it is a thin wrapper providing functions and
data structures to access the [Client-Server
API](https://matrix.org/docs/spec/client_server/latest). Most of the semantics
are described there and this library provides similarly named types and function
to invoke those endpoints.
mtxclient is built on top of
[Boost.Asio](https://www.boost.org/doc/libs/1_75_0/doc/html/boost_asio.html) and
[nlohmann/json](https://github.com/nlohmann/json). Many of the data structures
in this library can be serialized to and deserialized from JSON. Most endpoints
use a callback to inform the caller, if the request completed and what the
response was.
## Building
For build instructions please refer to the [README](README.md).
#pragma once #pragma once
/// @file
/// @brief A header including pretty much all the headers of the library.
/// Including this will have a significant compile time cost.
#include "mtx/identifiers.hpp" #include "mtx/identifiers.hpp"
#include "mtx/events.hpp" #include "mtx/events.hpp"
......
...@@ -10,7 +10,8 @@ ...@@ -10,7 +10,8 @@
#include <string> #include <string>
#include <vector> #include <vector>
//! Common types used by the crypto related endpoints. /// @file
/// @brief Common types used by the crypto related endpoints.
namespace mtx { namespace mtx {
namespace crypto { namespace crypto {
......
#pragma once #pragma once
/// @file
/// @brief The error struct returned by the Matrix API.
#include "lightweight_error.hpp" #include "lightweight_error.hpp"
#include "user_interactive.hpp" #include "user_interactive.hpp"
......
#pragma once #pragma once
/// @file
/// @brief Basetypes for events. Content is defined elsewhere.
#if __has_include(<nlohmann/json_fwd.hpp>) #if __has_include(<nlohmann/json_fwd.hpp>)
#include <nlohmann/json_fwd.hpp> #include <nlohmann/json_fwd.hpp>
#else #else
...@@ -194,5 +197,34 @@ getMessageType(const json &obj); ...@@ -194,5 +197,34 @@ getMessageType(const json &obj);
struct Sticker : public RoomEvent<mtx::events::msg::StickerImage> struct Sticker : public RoomEvent<mtx::events::msg::StickerImage>
{}; {};
/// @brief An ephemeral event like typing or read receipts
/// @sa Event
template<class Content>
struct EphemeralEvent
{
//! The fields in this object will vary depending on the type of event.
//! When interacting with the REST API, this is the HTTP body.
Content content;
//! The type of event.
//! This *should* be namespaced similar to Java package
//! naming conventions e.g. 'com.example.subdomain.event.type'
EventType type;
//! The room this was sent in. May not always be present.
std::string room_id;
};
template<class Content>
void
to_json(json &obj, const EphemeralEvent<Content> &event);
template<class Content>
void
from_json(const json &obj, EphemeralEvent<Content> &event);
/// @brief An account_data event like fully_read or tags.
/// @sa Event
template<class Content>
using AccountDataEvent = EphemeralEvent<Content>;
} // namespace events } // namespace events
} // namespace mtx } // namespace mtx
#pragma once
/// @file
/// @brief The fully read marker for this user.
#include <string>
#if __has_include(<nlohmann/json_fwd.hpp>)
#include <nlohmann/json_fwd.hpp>
#else
#include <nlohmann/json.hpp>
#endif
namespace mtx {
namespace events {
namespace account_data {
/// @brief The fully read marker for this user / `m.fully_read`.
///
/// The history for a given room may be split into three sections: messages the user has read (or
/// indicated they aren't interested in them), messages the user might have read some but not
/// others, and messages the user hasn't seen yet. The "fully read marker" (also known as a "read
/// marker") marks the last event of the first section, whereas the user's read receipt marks the
/// last event of the second section.
struct FullyRead
{
//! Required. The event the user's read marker is located at in the room.
std::string event_id;
};
//! Deserialization method needed by @p nlohmann::json.
void
from_json(const nlohmann::json &obj, FullyRead &content);
//! Serialization method needed by @p nlohmann::json.
void
to_json(nlohmann::json &obj, const FullyRead &content);
} // namespace state
} // namespace events
} // namespace mtx
#pragma once #pragma once
/// @file
/// @brief Alias events.
#include <string> #include <string>
#include <vector> #include <vector>
......
#pragma once #pragma once
/// @file
/// @brief Room avatar events.
#if __has_include(<nlohmann/json_fwd.hpp>) #if __has_include(<nlohmann/json_fwd.hpp>)
#include <nlohmann/json_fwd.hpp> #include <nlohmann/json_fwd.hpp>
#else #else
......
#pragma once #pragma once
/// @file
/// @brief Change the canonical or listed avatars of a room.
#include <string> #include <string>
#if __has_include(<nlohmann/json_fwd.hpp>) #if __has_include(<nlohmann/json_fwd.hpp>)
......
#pragma once #pragma once
/// @file
/// @brief Collections to store multiple events of different types
#include <variant> #include <variant>
#include "mtx/events.hpp" #include "mtx/events.hpp"
#include "mtx/events/account_data/fully_read.hpp"
#include "mtx/events/aliases.hpp" #include "mtx/events/aliases.hpp"
#include "mtx/events/avatar.hpp" #include "mtx/events/avatar.hpp"
#include "mtx/events/canonical_alias.hpp" #include "mtx/events/canonical_alias.hpp"
#include "mtx/events/create.hpp" #include "mtx/events/create.hpp"
#include "mtx/events/encrypted.hpp" #include "mtx/events/encrypted.hpp"
#include "mtx/events/encryption.hpp" #include "mtx/events/encryption.hpp"
#include "mtx/events/ephemeral/receipt.hpp"
#include "mtx/events/ephemeral/typing.hpp"
#include "mtx/events/guest_access.hpp" #include "mtx/events/guest_access.hpp"
#include "mtx/events/history_visibility.hpp" #include "mtx/events/history_visibility.hpp"
#include "mtx/events/join_rules.hpp" #include "mtx/events/join_rules.hpp"
...@@ -57,13 +63,16 @@ using DeviceEvents = std::variant<events::DeviceEvent<msgs::RoomKey>, ...@@ -57,13 +63,16 @@ using DeviceEvents = std::variant<events::DeviceEvent<msgs::RoomKey>,
events::DeviceEvent<msgs::KeyVerificationAccept>, events::DeviceEvent<msgs::KeyVerificationAccept>,
events::DeviceEvent<msgs::KeyVerificationCancel>, events::DeviceEvent<msgs::KeyVerificationCancel>,
events::DeviceEvent<msgs::KeyVerificationKey>, events::DeviceEvent<msgs::KeyVerificationKey>,
events::DeviceEvent<msgs::KeyVerificationMac>>; events::DeviceEvent<msgs::KeyVerificationMac>,
events::DeviceEvent<msgs::SecretRequest>,
events::DeviceEvent<msgs::SecretSend>>;
//! Collection of room specific account data //! Collection of room specific account data
using RoomAccountDataEvents = using RoomAccountDataEvents =
std::variant<events::Event<account_data::Tags>, std::variant<events::AccountDataEvent<account_data::Tags>,
events::Event<pushrules::GlobalRuleset>, events::AccountDataEvent<account_data::FullyRead>,
events::Event<account_data::nheko_extensions::HiddenEvents>>; events::AccountDataEvent<pushrules::GlobalRuleset>,
events::AccountDataEvent<account_data::nheko_extensions::HiddenEvents>>;
//! Collection of @p StateEvent only. //! Collection of @p StateEvent only.
using StateEvents = std::variant<events::StateEvent<states::Aliases>, using StateEvents = std::variant<events::StateEvent<states::Aliases>,
...@@ -139,6 +148,10 @@ using TimelineEvents = std::variant<events::StateEvent<states::Aliases>, ...@@ -139,6 +148,10 @@ using TimelineEvents = std::variant<events::StateEvent<states::Aliases>,
events::RoomEvent<msgs::CallAnswer>, events::RoomEvent<msgs::CallAnswer>,
events::RoomEvent<msgs::CallHangUp>>; events::RoomEvent<msgs::CallHangUp>>;
using EphemeralEvents = std::variant<events::EphemeralEvent<ephemeral::Typing>,
events::EphemeralEvent<ephemeral::Receipt>>;
//! A wapper around TimelineEvent, that produces less noisy compiler errors.
struct TimelineEvent struct TimelineEvent
{ {
TimelineEvents data; TimelineEvents data;
...@@ -149,6 +162,7 @@ from_json(const json &obj, TimelineEvent &e); ...@@ -149,6 +162,7 @@ from_json(const json &obj, TimelineEvent &e);
} // namespace collections } // namespace collections
//! Get the right event type for some type of message content.
template<typename Content> template<typename Content>
constexpr inline EventType message_content_to_type = EventType::Unsupported; constexpr inline EventType message_content_to_type = EventType::Unsupported;
...@@ -193,6 +207,7 @@ template<> ...@@ -193,6 +207,7 @@ template<>
constexpr inline EventType message_content_to_type<mtx::events::msg::CallHangUp> = constexpr inline EventType message_content_to_type<mtx::events::msg::CallHangUp> =
EventType::CallHangUp; EventType::CallHangUp;
//! Get the right event type for some type of state event content.
template<typename Content> template<typename Content>
constexpr inline EventType state_content_to_type = EventType::Unsupported; constexpr inline EventType state_content_to_type = EventType::Unsupported;
...@@ -237,6 +252,7 @@ constexpr inline EventType state_content_to_type<mtx::events::state::Tombstone> ...@@ -237,6 +252,7 @@ constexpr inline EventType state_content_to_type<mtx::events::state::Tombstone>
template<> template<>
constexpr inline EventType state_content_to_type<mtx::events::state::Topic> = EventType::RoomTopic; constexpr inline EventType state_content_to_type<mtx::events::state::Topic> = EventType::RoomTopic;
//! Get the right event type for some type of device message content.
template<typename Content> template<typename Content>
constexpr inline EventType to_device_content_to_type = EventType::Unsupported; constexpr inline EventType to_device_content_to_type = EventType::Unsupported;
...@@ -279,5 +295,11 @@ constexpr inline EventType to_device_content_to_type<mtx::events::msg::KeyVerifi ...@@ -279,5 +295,11 @@ constexpr inline EventType to_device_content_to_type<mtx::events::msg::KeyVerifi
template<> template<>
constexpr inline EventType to_device_content_to_type<mtx::events::msg::KeyVerificationMac> = constexpr inline EventType to_device_content_to_type<mtx::events::msg::KeyVerificationMac> =
EventType::KeyVerificationMac; EventType::KeyVerificationMac;
template<>
constexpr inline EventType to_device_content_to_type<mtx::events::msg::SecretSend> =
EventType::SecretSend;
template<>
constexpr inline EventType to_device_content_to_type<mtx::events::msg::SecretRequest> =
EventType::SecretRequest;
} // namespace events } // namespace events
} // namespace mtx } // namespace mtx
#pragma once #pragma once
/// @file
/// @brief Structs used in multiple different event types.
#if __has_include(<nlohmann/json_fwd.hpp>) #if __has_include(<nlohmann/json_fwd.hpp>)
#include <nlohmann/json_fwd.hpp> #include <nlohmann/json_fwd.hpp>
#else #else
......
#pragma once #pragma once
/// @file
/// @brief The first event in a room.
#include <optional> #include <optional>
#if __has_include(<nlohmann/json_fwd.hpp>) #if __has_include(<nlohmann/json_fwd.hpp>)
...@@ -11,7 +14,7 @@ ...@@ -11,7 +14,7 @@
namespace mtx { namespace mtx {
namespace events { namespace events {
namespace state { namespace state {
//! The predecessor of this room.
struct PreviousRoom struct PreviousRoom
{ {
//! Required. The ID of the old room. //! Required. The ID of the old room.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment