aboutsummaryrefslogtreecommitdiff
path: root/lib/events
AgeCommit message (Collapse)Author
2022-02-26Merge pull request #477 from TobiasFella/work/readencryptedmessagesAlexey Rusakov
2022-02-16More cleanup, especially in EncryptedFileAlexey Rusakov
For EncryptedFile: - JSON converter bodies moved away to .cpp; - instead of C-style casts, reinterpret_cast is used to convert from (const) char* to (const) unsigned char*; - the size for the target plain text takes into account the case where the cipher block size can be larger than 1 (after reading https://www.openssl.org/docs/man1.1.1/man3/EVP_DecryptUpdate.html). - file decryption is wrapped in #ifdef Quotient_E2EE_ENABLED, to avoid OpenSSL linking errors when compiling without E2EE.
2022-02-16isSupportedAlgorithm()Alexey Rusakov
That's a better primitive than just exposing SupportedAlgorithms list.
2022-02-16Fix file decryptionTobias Fella
2022-02-16CleanupAlexey Rusakov
A note on switching to QLatin1String for JSON key constants - this is more concise and barely affects (if at all) runtime performance (padding each QChar with zeros is trivial for assignment; and comparison can be done directly with the same performance as for two QStrings).
2022-02-16Add a few missing QUOTIENT_API stanzasAlexey Rusakov
Also, removed Q_GADGET macros from key verification events as those don't seem to do anything (no Q_ENUM/Q_FLAG things, namely).
2022-02-14Don't set lifetime as version in call invitesTobias Fella
2022-02-14Revert "Don't #include "logging.h" from headers"Alexey Rusakov
This reverts commit 2cf44607cf0f057e147c2c4fe6dded6c13c58a8a (that was stupid, honestly).
2022-02-14Don't #include "logging.h" from headersAlexey Rusakov
Logging categories used by Quotient are not supposed to be exposed externally, which basically forbids usage of logging in header files. A more flexible solution would involve moving logging.h to private headers but Quotient doesn't have that thing yet.
2022-02-13Merge branch 'dev'Alexey Rusakov
The result is FTBFS as yet; next commits will fix that, along with a few other things.
2022-02-11EventRelation: defer to non-deprecated symbolsAlexey Rusakov
2022-02-09Move includes to .cpp fileTobias Fella
2022-02-07Refactor KeyVerificationEventsTobias Fella
2022-02-07Remove encryptionmanager and various fixesTobias Fella
2022-01-28Merge pull request #525 from quotient-im/kitsune/query-current-stateAlexey Rusakov
Move out current room state to its own class
2022-01-28QUO_IMPLICITAlexey Rusakov
Because Apple Clang choked on `explicit(false)`.
2022-01-23No more default construction of eventsAlexey Rusakov
Default construction was only done to support stubbed state in Room and even that did not really use those, opting to construct an event from an empty QJsonObject instead. Now that Room doesn't have stubbed state, default constructors are even less needed.
2022-01-23Cleanup some #includesAlexey Rusakov
2022-01-23Fix visit() return typeAlexey Rusakov
It's too restrictive compared to switchOnType() overloads and doesn't map to the case with a default value.
2022-01-21Refactor assembleContentJson()Alexey Rusakov
Get rid of that Q_ASSERT() in the middle that only worked in Debug builds anyway.
2022-01-21Redo EventRelation; deprecate RelatesToAlexey Rusakov
RelatesTo and EventRelation have been two means to the same end in two different contexts. (Modernised) EventRelation is the one used now both for ReactionEvent and EventContent::TextContent. The modernisation mostly boils down to using inline variables instead of functions to return relation types and switching to QLatin1String from const char* (because we know exactly that those constants are Latin-1 and QLatin1String is more efficient than const char* to compare/convert to QString).
2022-01-18Don't use 'static' on top-level/namespace scopeAlexey Rusakov
When internal linkage is necessary, anonymous namespaces fulfil the same purpose in a better way. See also: https://stackoverflow.com/questions/4422507/superiority-of-unnamed-namespace-over-static
2022-01-18Move over non-interface code to QLatin1StringAlexey Rusakov
It's better than const char* because any interaction between const char* and QString assumes that const char* contains UTF-8, which is pessimistic and therefore inefficient; at the same time: - construction of QString from QLatin1String is extremely fast (boiling down to padding null bytes) - "something"_ls is much shorter than QStringLiteral("something") - "something"_ls produces a direct pointer to the literal at compile time, using the benefits of raw string literals (deduplication, e.g.) The library API will also transition to QLatin1String where applicable, likely in 0.8.
2022-01-18Revise inline keyword usageAlexey Rusakov
- Templates and constexpr imply inline - A function called from a single site better be inlined.
2022-01-05DEFINE_EVENT_TYPEID: fix up deprecation warningsAlexey Rusakov
2022-01-05Make TagRecord generally betterAlexey Rusakov
It doesn't need all those things inside - order_type alias is no more in use; operator<() is better outside; QLatin1String is better to compare against than const char* (because const char* is assumed to be UTF-8); and TagRecord is really small so it doesn't need const& for parameters.
2022-01-05Thumbnail: drop unneeded constructorsAlexey Rusakov
Those are already inherited with 'using'.
2022-01-02Manage symbols visibility for dynamic linkingAlexey Rusakov
2022-01-01Fix more Sonar warningsAlexey Rusakov
2022-01-01Don't use QUOTIENT_API inside REGISTER_EVENT_TYPEAlexey Rusakov
On Windows QUOTIENT_API expands to different things depending on whether the library is built or used. This results in confusing statements (and MSVC erroring out on them, in some cases - see below - quite legitimately) not only when the application includes Quotient headers but also when the application defines custom events and uses REGISTER_EVENT_TYPE to make them creatable from /sync responses. To avoid repeated registration when dynamic linking is involved, EventFactory<>::addMethod() now bluntly looks up the method for this type in the vector of already registered methods. It would surely be quicker to use a static variable instead; but since the refreshed API for addMethod returns a reference to the factory method it's necessary to do this lookup anyway. Once the primary goal of this branch is achieved across platforms I might experiment with lighter ways to register factory methods; for now here's a minimal change to make the code build on Windows.
2022-01-01Drop inline next to constexprAlexey Rusakov
Thanks to Sonar for reminding that constexpr implies inline.
2022-01-01Merge pull request #458 from arawaaa/pinnedAlexey Rusakov
Pinned message support
2021-12-29Use QLatin1String for event typeId'sAlexey Rusakov
Before all, this fixes the problem with double-initialising of type ids; it could have been fixed with a smaller change but EventTypeRegistry is fairly superfluous now when inline variables are a thing and it's possible to have an extensible registry system using literally pointers to the memory that are guaranteed to be unique. That being said, event_type_t is still QLatin1String and not a bare const char* (or void*), mostly to stay on the safe side when it comes to type identities: unlike const char*, QLatin1String's are deep-compared, meaning that matching for switchOnType (former visit) occurs a bit slower now. This may change in the future; but this is the first step in getting rid of EventTypeRegistry. This change means that initializeTypeId is no more needed; also, two static member functions, typeId() and matrixTypeId(), are being replaced with a single inline static member variable, TypeId. This commit doesn't apply that transition across the event types, meaning that you'll get a pile of warnings when compiling the library. These warnings will be tackled in further commits within this branch.
2021-12-29Refactor EventFactory and move it out of _impl::Alexey Rusakov
Strictly speaking, EventFactory can be further instantiated if any client application figures they need a whole new base class for events and respectively a separate EventFactory specialisation for it. Where this whole commit started though was a linkage error because I did not plan to expose Quotient-specific logging categories for linkage (effectively, usage) from the client code - meanwhile the inline code of EventFactory uses qDebug(EVENTS), meaning I had to either add QUOTIENT_API to EVENTS or hide those invocations. This in turn led to trimming the EventFactory constructor back to trivial implementation and dropping the guard variable that was supposed to trace duplicate EventFactory<BaseEventT> objects for the same BaseEventT - with the reasoning that such situation is not really dangerous (unlike EventTypeRegistry double-initialisation fiasco, see #413), and at the same time it can be easily detected in the logs by duplicated factory method registration messages. And while I was at it, I replaced the meaningless bool in the return type of EventFactory<>::addMethod with the slightly more (but still barely) useful reference to the inserted factory method. One can (in theory) use it now if they need to turn some event JSON into an object of some specific event type or nullptr if the event type in the JSON payload doesn't match - but at the same rate (for now at least) one can call makeIfMatches<EventT>() directly. With this commit, both Quotest and Quaternion build and link using either Clang or GCC even under -fvisibility=hidden. However, running quotest now reproduces #413, which is a matter of event typeId infrastructure refactoring, coming in further commits.
2021-12-29Add QUOTIENT_API throughout non-generated codeAlexey Rusakov
This include all (hopefully) classes/structures and functions that have non-inline definitions, as well as namespaces with Q_NAMESPACE since those have non-inline (as of Qt 5.15) QMetaObject - for that a new macro, QUO_NAMESPACE, has been devised to accommodate the lack of Q_NAMESPACE_EXPORT in Qt before 5.14.
2021-12-28EventContent::FileInfo: default payloadSize to 0Alexey Rusakov
Fixes a clang-tidy warning.
2021-12-27Merge branch 'dev' into pinnedarawaaa
2021-12-27EventFactory: remove default constructorAlexey Rusakov
This is a leftover from deferred `name` initialisation that wasn't needed in the end.
2021-12-27Key* strings: drop 'static'; add 'constexpr' where okAlexey Rusakov
2021-12-24Prune empty/ish call*event.cpp filesAlexey Rusakov
2021-12-22StateEventBase: force type to unknown if stateKey is not in JSONAlexey Rusakov
2021-12-22Simplify the code around EventFactory<>Alexey Rusakov
The former code assumed that EventFactory<> is just a class-level shell for a bunch of functions and a static data member that only exists to allow specialisations to occur for the whole group together. On top of that, setupFactory() and registerEventType() strived to protect this group from double registration coming from static variables in an anonymous namespace produced by REGISTER_EVENT_TYPE. The whole thing is now de-static-ed: resolving the factory now relies on class-static Event/RoomEvent/StateEventBase::factory variables instead of factory_t type aliases; and REGISTER_EVENT_TYPE produces non-static inline variables instead, obviating the need of registerEventType/setupFactory kludge.
2021-12-21Don't chain RoomEvent to Event factory any moreAlexey Rusakov
Objects derived from Event are not room events (in the spec sense) and never occur in the same arrays as room events; therefore this chaining has always been superfluous.
2021-12-17RoomMemberEvent: fix an off-by-one errorAlexey Rusakov
Also: extended quotest to cover member renames, not just user profile renames.
2021-12-10Apply suggestions from code reviewTobias Fella
Co-authored-by: Alexey Rusakov <Kitsune-Ral@users.sf.net>
2021-12-09Ifdef all the thingsTobias Fella
2021-12-08Store encryptedevent in decrypted roomeventsTobias Fella
2021-12-07Rename "crypto" -> "e2ee"Tobias Fella
2021-12-07Port E2EE to database instead of JSON filesTobias Fella
2021-12-03Cleanup; drop an unused RoomAliasesEvent constructorAlexey Rusakov
Also, RoomAliasesEvent is to be completely gone after 0.7.