aboutsummaryrefslogtreecommitdiff
path: root/lib
AgeCommit message (Collapse)Author
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-29Regenerate CS API filesAlexey Rusakov
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-29Introduce quotient_export.hAlexey Rusakov
Instead of using CMake's generate_export_header macro, it's a bit easier to maintain a static file (that is not supposed to ever change) with necessary export/import/hidden visibility macros.
2021-12-28EventContent::FileInfo: default payloadSize to 0Alexey Rusakov
Fixes a clang-tidy warning.
2021-12-28Settings classes: unify on QUO_ macro prefixAlexey Rusakov
At some point macros were prepended with QTNT (pronounced "cute-n't", "Quotient" with vowels dropped) but that didn't go very far. Having forgotten about this, I introduced QUO prefix in a few places. Being initial letters of "Quotient", QUO feels more understandable (and coincidentally is a well-known Latin word); so let's unify on this.
2021-12-28Convert struct LoginFlows to namespaceAlexey Rusakov
Because that's what it really is.
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-27EventItem::setUserData: use std::moveAlexey Rusakov
Fixes a clang-tidy warning.
2021-12-27Key* strings: drop 'static'; add 'constexpr' where okAlexey Rusakov
2021-12-27Connection: Simplify room/user factory codeAlexey Rusakov
There's no need to return lambdas where pointers to specialised function templates would work just fine.
2021-12-26Merge #528: Make canChangePassword available from QMLAlexey Rusakov
2021-12-25Make canChangePassword available from QMLCarl Schwan
2021-12-25Apply suggestions from code reviewTobias Fella
Co-authored-by: Alexey Rusakov <Kitsune-Ral@users.sf.net>
2021-12-25Remove assertTobias Fella
2021-12-25Update lib/e2ee/qolmoutboundsession.hTobias Fella
Co-authored-by: Alexey Rusakov <Kitsune-Ral@users.sf.net>
2021-12-25Update lib/e2ee/qolmoutboundsession.hTobias Fella
Co-authored-by: Alexey Rusakov <Kitsune-Ral@users.sf.net>
2021-12-25Don't save olm account ón shutdownTobias Fella
It causes the program to crash for some reason
2021-12-25Remove irrelevant includeTobias Fella
2021-12-25Remove unneeded codeTobias Fella
2021-12-25Apply suggestionsTobias Fella
2021-12-25Update lib/e2ee/qolmoutboundsession.cppTobias Fella
Co-authored-by: Alexey Rusakov <Kitsune-Ral@users.sf.net>
2021-12-24Apply suggestionsTobias Fella
2021-12-24Prune empty/ish call*event.cpp filesAlexey Rusakov
2021-12-24Cache deviceslist to binary when possibleTobias Fella
2021-12-24Fix reading unencrypted imagesTobias Fella
2021-12-22Another improvementTobias Fella
2021-12-22Apply suggestions from code reviewTobias Fella
Co-authored-by: Alexey Rusakov <Kitsune-Ral@users.sf.net>
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-10Remove data from database when leaving roomTobias Fella
2021-12-10Apply suggestions from code reviewTobias Fella
Co-authored-by: Alexey Rusakov <Kitsune-Ral@users.sf.net>
2021-12-10Apply suggestions from code reviewTobias Fella
Co-authored-by: Alexey Rusakov <Kitsune-Ral@users.sf.net>
2021-12-10Use individual databases for each connectionTobias Fella
2021-12-10ifdef more thingsTobias Fella
2021-12-09Rename databaseTobias Fella
2021-12-09Ifdef all the thingsTobias Fella
2021-12-09Update lib/connection.cppTobias Fella
Co-authored-by: Alexey Rusakov <Kitsune-Ral@users.sf.net>
2021-12-08Update logging categoriesTobias Fella
2021-12-08Store encryptedevent in decrypted roomeventsTobias Fella
2021-12-07Maintain list of undecrypted events to speed up decryption of oldTobias Fella
messages
2021-12-07Remove default constructorTobias Fella
2021-12-07snake_case table namesTobias Fella
2021-12-07FixesTobias Fella
2021-12-07id -> matrixIdTobias Fella
2021-12-07Rename "crypto" -> "e2ee"Tobias Fella