aboutsummaryrefslogtreecommitdiff
path: root/lib/connection.cpp
AgeCommit message (Collapse)Author
2021-08-22Drop other stuff deprecated pre- or early 0.6Alexey Rusakov
BaseJob: StatusCode::JsonParseError Connection: resolved() and reconnected() signals; roomMap(); postReceipt() User: bridged() and rawName() ConnectionData: setHost() and setPort() StateEventBase: prev_content()
2021-07-18MembershipType -> Membership, also used for JoinStateAlexey Rusakov
Instead of being defined independently, JoinState now uses values from the Membership enumeration (former MemberEventContent::MembershipType) that was moved to quotient_common.h for that purpose. Both enumerations gained a Q_FLAG_NS decoration and operator<< overrides that strip "Quotient::" prefix when dumping member/join state values to the log - obviating toCString(JoinState) along the way. Quotient::MembershipType alias is deprecated from now.
2021-06-12connection.cpp: erase_if -> remove_ifAlexey Rusakov
erase_if is now also provided by Qt; doing pretty much the same thing, the Qt implementation only returns the number of removed entries instead of returning a collection of them, however. Worth admitting at this point that the function in connection.cpp has never had the semantics of STL's erase_if() and doesn't quite have the semantics of remove_if() either; but at least it's closer to remove_if().
2021-06-12Adjust to new moc/QMetaType requirementsAlexey Rusakov
See https://www.qt.io/blog/whats-new-in-qmetatype-qvariant#qmetatype-knows-your-properties-and-methods-types
2021-06-07Connection::joinRoom() shouldn't enforce room stateAlexey Rusakov
This is an adjustment to the earlier fix of #471: if a join is immediately followed by a leave (e.g. from another client/bot - you can't do it programmatically from libQuotient) the sync may bring the room already in the Leave state; therefore `joinRoom` should not impose the state but rather ask `provideRoom` to create a `Join` room - just as it's designed when passed an empty `joinState`.
2021-05-09Fix joinedRoom signal not being emitted in some casesAlexey Rusakov
An alternative implementation of #463 (and thanks to Carl for spotting the original problem).
2021-02-26Apply suggestionCarl Schwan
Co-authored-by: Alexey Rusakov <Kitsune-Ral@users.sf.net>
2021-02-26Add public method to determine if we can change the user passwordCarl Schwan
2021-01-16Updated copyright statements upon Git auditKitsune Ral
After going through all the files and the history of commits on them it was clear that some copyright statements are obsolete (the code has been overwritten since) and some are missing. This commit tries best to remedy that, along with adding SPDX tags where they were still not used. Also, a minimal SPDX convention is documented for further contributions. Closes #426.
2021-01-15Merge pull request #428 from ognarb/licensingKitsune Ral
Port existing copyright statement to reuse using licensedigger
2021-01-07Connection: don't explicitly reset QPointersKitsune Ral
See #437 for the discussion.
2021-01-07isJobRunning() -> isJobPending()Kitsune Ral
To be very clear what this function checks. See also #437.
2021-01-07Connection::resolveServer: abandon is not a failureKitsune Ral
So just reset the base URL and return, with no error signals. (cherry picked from commit be00308ad67286b45912202750fe49fb87f16e4a)
2021-01-07Prefer connecting to BaseJob::result(), not finished()Kitsune Ral
...because finished() includes abandoning and should only be relevant when lifecycle issues are involved. (cherry picked from commit 90d41b697af39253483d9bcca4e57b11d2197112)
2020-12-28Connection: fix FTBFS with Quotient_E2EE_ENABLEDKitsune Ral
2020-12-28Connection: refactor the resolve/login codeKitsune Ral
1. resolveServer() now emits homeserverChanged() even when there's no .well-known file found. 2. checkAndConnect() entirely removed from the header file. 3. Sunny-day scenario for assumeIdentity() is now asynchronous, triggering a call to /whoami to double-check the user. 4. LoginFlow aliases is moved out from LoginFlows to Quotient namespace.
2020-12-28More comments/documentationKitsune Ral
Notably, recommend using loginFlowsChanged() rather than homeserverChanged() to detect when a Connection object is ready for a login sequence. Related: #427.
2020-12-26Port existing copyright statement to reuse using licensediggerCarl Schwan
2020-12-24Fix clang-tidy/clazy warningsKitsune Ral
(cherry picked from commit 0a2acd750a4155969092be674ed3dd9a71b2354f)
2020-12-23Connection::resolveServer(): fix error handlingKitsune Ral
Part of the fix for #421. (cherry picked from commit 104356d945671762af23e346f7898a3208770d97)
2020-11-12More JSON key constantsKitsune Ral
2020-11-06More stringent serverpart checks in user idsKitsune Ral
May lead to new crashes due to nullptr returned from Connection::user() on more utterly invalid content from the wire that the library still doesn't properly invalidate. This has long been quite a good case for exceptions, or another error-handling framework: Connection::user() can return nullptr either when out of memory or when the id is invalid or empty, and other places are likely to treat invalid ids in different ways but probably just hope that memory exhaustion "never happens", or try to handle it in a quite different way than an empty or invalid id. Something to think of in 0.7. (cherry picked from commit 3c85f049389dec3b0ee6406f0be2cfaf0089f1fe)
2020-09-04Fixes of clazy warningsKitsune Ral
2020-08-04Connection: self-delete after emitting loggedOut()Kitsune Ral
The Connection object has quite few uses after logging out - neither rooms nor users under it no more represent actual situation, and the object cannot be cleanly reused for a new login (also, the use case for that is pretty dubious). This doesn't cover the case when the session has been forcibly logged-out by the server (causing loginError() to be emitted) - in that case re-authentication is an expected flow.
2020-08-04Connection: stop the sync loop on SyncJob::failureKitsune Ral
2020-07-21Connection: tolerate an empty set of room versionsKitsune Ral
Closes #314.
2020-06-19Revert adding a pause between syncs, use sane timeout defaultsKitsune Ral
This reverts commit b1071cf34b86685c3cdb5004d6112881966a7ce6. Passing -1 to sync() and, respectively, to SyncJob does not add any timeout; however, careful reading of the spec reveals that the default value for the timeout (0) means to return as soon as possible, not as late as possible. As a consequence, syncLoop() without parameters initiates a sync polling frenzy, with the client sending a new request as soon as the previous returns, while the server returns the request as soon as it practically can, not as soon as another event for the client comes around. To fix this, the default value for syncLoop() is changed to 30 seconds. The recently added msecBetween parameter is abolished; we really don't want to steer people to classic polling from long polling.
2020-06-12The previous commit is incomplete, this completes itKitsune Ral
2020-06-12Connection::syncLoop: give a pause between syncsKitsune Ral
As it's observed now, Synapse responds almost immediately on /sync requests - even if there are no events to return. This downgrades long-polling to simply polling, and since clients don't expect it, polling loops become pretty violent. To alleviate that somehow, syncLoop now accepts the second parameter, msecBetween (500 msecs by default), to configure waiting between the previous sync response and the next sync request. This is only for syncLoop(); Connection::sync() fires instantly, as before.
2020-06-07Small updates to match the new generated definitionsKitsune Ral
2020-06-05Use CBOR for binary JSON caching on Qt 5.15+Kitsune Ral
Qt 5.15 deprecates binary JSON format in favour of CBOR now used as a backend for its JSON classes.
2020-06-05Connection::run(): Q_INVOKABLE and chainingKitsune Ral
2020-05-31Move around and format codeKitsune Ral
No functional changes here.
2020-04-15Connection: track resolving and login flows jobs; isUsable()Kitsune Ral
This is to prevent the jobs from several resolveServer() / setHomeserver() invocations running in parallel.
2020-04-15Connection: cleanup and reformatKitsune Ral
2020-04-15Connection: connectToServer -> loginWithPasswordKitsune Ral
connectToServer() is left for compatibility but deprecated.
2020-04-14BaseJob::makeRequestUrl(): even more tolerance to slash separatorsKitsune Ral
The code is really defensive now, making sure there's exactly one slash between the base path and the endpoint. It's still very conservative about the path composition otherwise (no normalisation etc.).
2020-03-31Reparent all jobs to their connectionsKitsune Ral
(Mostly) fixes #397. Fixes #398. If there's a need to reparent the job to some other object, it should now be done after callApi()/run() call (not that there were many touch points before that moment, anyway). Collateral damage: job-starting methods are no more const (but that didn't belong them anyway, too).
2020-03-30Connection::resolveServer(): refactorKitsune Ral
Also: use 4-arg connect() to make sure lambdas are disconnected if the connection is gone.
2020-03-27Fix FTBFS with Quotient_ENABLE_E2EEKitsune Ral
2020-03-26Refactoring around Connection::onSyncSuccess()Kitsune Ral
The method grew large and a bit unwieldy over the years.
2020-03-24Connection: fix a deprecation warningKitsune Ral
2020-03-21Merge pull request #383 from ram-nad/msc2432-fixKitsune Ral
fixing msc2432
2020-03-18SsoSession and Connection::prepareForSso()Kitsune Ral
The response in the web browser is quite barebone, just enough to give feedback that things are alright. Closes #386. Closes #388.
2020-03-15Connection: loginWithToken(); connectWithToken() -> assumeIdentity()Kitsune Ral
2020-03-14Connection: minor cleanupKitsune Ral
2020-03-13Connection: support getting the list of login flowsKitsune Ral
The flows themselves are not facilitated in any way (yet).
2020-03-12E2EE: Make building E2EE optional. Contributes to #369Alexey Andreev
Signed-off-by: Alexey Andreev <aa13q@ya.ru>
2020-03-08fixing msc2432Ram Nad
2020-02-25E2EE: add connection session decrypt, handle to-device and ↵Alexey Andreyev
device_one_time_keys_count Signed-off-by: Alexey Andreev <aa13q@ya.ru>