aboutsummaryrefslogtreecommitdiff
AgeCommit message (Collapse)Author
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-12Replace QPair with std::pairTobias Fella
2022-02-11Implement more suggestionsTobias Fella
2022-02-11Enable to/fromJson to work with non-assignable objectsAlexey Rusakov
Previously you could not use toJson() on a polymorphic structure such as one of those defined in eventcontent.h because it is not assignable and the default specialisation of JsonObjectConverter used assignment. To avoid that limitation, one had to specialise JsonObjectConverter for each descendant of EventContent::Base, which is a lot of boilerplate. The new JsonConverter (the template underpinning the "default" to/fromJson implementation) improves on two things: 1. dump() allows to construct your own QJsonObject - or anything else convertable to QJsonValue - instead of requiring to fill in the pre-constructed one. 2. load() allows to construct your value type directly from QJsonObject instead of default-constructing it in advance.
2022-02-11Better documentation for QUO_DECLARE_FLAGS[_NS]Alexey Rusakov
2022-02-11EventRelation: defer to non-deprecated symbolsAlexey Rusakov
2022-02-09Fix compilation without E2EETobias Fella
2022-02-09Move includes to .cpp fileTobias Fella
2022-02-07Refactor KeyVerificationEventsTobias Fella
2022-02-07Remove encryptionmanager and various fixesTobias Fella
2022-02-06Update lib/e2ee/qolmaccount.cppTobias Fella
Co-authored-by: Alexey Rusakov <Kitsune-Ral@users.sf.net>
2022-02-06Only create one databaseTobias Fella
2022-02-06Port to QRandomGeneratorTobias Fella
2022-02-06Update lib/e2ee/qolminboundsession.cppTobias Fella
Co-authored-by: Alexey Rusakov <Kitsune-Ral@users.sf.net>
2022-01-30Apply suggestions from code reviewTobias Fella
Co-authored-by: Alexey Rusakov <Kitsune-Ral@users.sf.net>
2022-01-30Port devices list to databaseTobias Fella
2022-01-30Use room() instead of provideRoom()Tobias Fella
2022-01-29Apply suggestions from code reviewTobias Fella
Co-authored-by: Alexey Rusakov <Kitsune-Ral@users.sf.net>
2022-01-29SyncData: expect self-contained /sync responseAlexey Rusakov
SyncData can load room objects out-of-line. This is only expected when loading data from the cache (and since quite long ago, the cache always saves room objects out of line, avoiding too large JSON payloads that Qt parser chokes on). However, the code processed /sync response in the same way; in particular, this meant that SyncData filled the vector of unresolved room ids even when it came from /sync. SyncJob then looked at this vector and entered an error state if it was not empty. Well, payloads from the wire can be weird and it ultimately came to pass that a homeserver returned a non-object against a given room key, triggering the unresolved rooms branch in SyncJob - and stalling the whole sync loop as a result (https://invent.kde.org/network/neochat/-/issues/500). With this commit SyncData only fills unresolvedRoomIds when loading rooms from the cache (with the implied fallback of discarding the cache and loading from /sync anew instead). Respectively, SyncJob must never end up with SyncData that has unresolved rooms (even if those occur in the actual payload like in the mentioned issue, those rooms will be completely empty instead); the added assertion only guards for internal consistency.
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-23Refactor Room::setState()Alexey Rusakov
There are two important aspects here: - Introducing Room::setState(evtType, stateKey, contentJson). These components are ultimately what is getting sent to the homeserver, so it makes sense to expose a respective `setState()` overload. Unlike setState(event) the new overload can be Q_INVOKABLE. - Room::setState() is no more const. Although it doesn't cause any changes in Room class (and only transient changes in Room::Private), it ultimately initiates a change in the room state, so calling it const has always been a bit of hypocrisy. If you relied on that, you most likely do something wrong (see the fix to User::rename() in this very commit for a simple example of such wrongness). Also: the backend is simplified by calling the original templated Room::setState() instead of calling Room::Private::requestSetState() that does exactly the same thing.
2022-01-23Move away Omittable static tests to autotests/Alexey Rusakov
These are not required to build libQuotient, and omittable.cpp entirely consisted of them.
2022-01-23RoomStateViewAlexey Rusakov
This class is called to provide an arbitrary snapshot of a room state; as the first step, Room::currentState() returns an instance of this class that stores, well, the current state. Implelementation-wise it's the same hash map of two-part state event keys to const event pointers; however, RoomStateView provides additional operations: - get(), that deprecates Room::getCurrentState(), returns a pointer to a particular event if the current state has it. Unlike the original method, the pointer returned from this one can be nullptr; this is done to get rid of stubbed state events that have to be created everytime a "state miss" occurred (i.e., when getCurrentState() does not find an existing event in the current state). - eventsOfType() - this is a new place for Room::stateEventsOfType() introduced recently. - query() - this is a way to specify a piece of the state content that you need to retrieve by passing a member function or a function object that retrieves it. That is especially convenient with member functions of the event class; just pass the pointer to this member function, and query() will parse the event type it has to retrieve out of it and call that member function on the event object. Returns an Omittable<>; if the respective piece of state doesn't exist, you'll get `Quotient::none` (the same as `std::nullopt`). - queryOr() - the same but with the fallback value; instead of an Omittable<>, the fallback value will be returned if the needed event is not found.
2022-01-23converters.h: slightly clearer code in _impl::addToAlexey Rusakov
2022-01-23Cleanup some #includesAlexey Rusakov
2022-01-23Omittable: split out from util.h and refreshAlexey Rusakov
Improvements: - Quotient::lift() - a way to invoke a function on an optional (including Omittable) or a pointer if it's 'truthy'. Doesn't need enhanced function_traits<>, only the standard library; works on any number of arguments that can be dereferenced and casted to bool. - then() - the version of lift() as a member function. - edit() was renamed to ensure() (edit() might become a read-write counterpart of then() at some point). It's not really used across libQuotient codebase (or elsewhere) but is staying there just in case. It can also accept an initializer, removing the requirement of default-constructibility. - Quotient::merge() is simplified, with one universal implementation covering both Omittable/optional and plain values. - All that now lives in its dedicated pair of files, further decluttering util.h
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-22Quotest: fix changeName testAlexey Rusakov
This test was very unreliable because memberRenamed() signal was emitted upon lazy-loading of past member renames. The new code connects to aboutToAddNewMessages() instead, which should only contain the latest renaming event (past events are delivered in the 'state' object).
2022-01-21Merge: merge event relation structures into oneAlexey Rusakov
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-19CMakeLists: Bring back ARCHIVE DESTINATION in install()Alexey Rusakov
The older CMake used by LGTM is still unhappy without it. (See also recent changes to this file.)
2022-01-18Merge branch 'kitsune/cleanup2' into devAlexey Rusakov
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-18Drop unused forward declarationsAlexey Rusakov
2022-01-18Add [[maybe_unused]] to things the lib doesn't useAlexey Rusakov
2022-01-18AccountRegistry: derive from QVector and clean upAlexey Rusakov
Notably, Quotient::AccountRegistry::instance() is now deprecated in favour of Quotient::Accounts inline variable.
2022-01-18.clang-format: try harder to avoid return type on its own lineAlexey Rusakov
In reality it's often not just the return type but the return type and the preceding attribute, in particular [[deprecated("...")]] - and unfortunately this attribute (and any other, actually) cannot be given its own line using ClangFormat. So at least try to glue those two to the function name as much as possible...
2022-01-18Revise inline keyword usageAlexey Rusakov
- Templates and constexpr imply inline - A function called from a single site better be inlined.
2022-01-06Brush up SsoSession; document Connection::prepareForSsoAlexey Rusakov
Although parented to Connection, SsoSession was pretty leaky in that unsuccessful login attempts didn't delete the object and in some errors didn't even close the local HTTP socket (though new connections would no more be accepted). Also, without the documentation it wasn't clear who owns the object returned by Connection::prepareForSso(). Now it is. Unfortunately, it's not easy to cover SsoSession with tests. Basically, it takes a homeserver and a mock "SSO agent" that would check the SSO URL for validity and then both send the login authorisation to the homeserver as well as ping the callback given by SsoSession. Maybe for another time.
2022-01-06Cleanup Room::pinnedEvents()Alexey Rusakov
Use 'auto'; range-for instead of an iterator loop.
2022-01-05Fully-qualify types passed to slotsAlexey Rusakov
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-05CMakeLists: add install(TARGETS) components againAlexey Rusakov
Older CMake versions fail if they don't find those (LGTM uses CMake 3.13 and that one does, at least).
2022-01-05Merge pull request #532 from quotient-im/kitsune/implptrAlexey Rusakov
ImplPtr