libQuotient
A Qt library for building matrix clients
versions.h
Go to the documentation of this file.
1 // THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN
2 
3 #pragma once
4 
5 #include <Quotient/jobs/basejob.h>
6 
7 namespace Quotient {
8 
9 //! \brief Gets the versions of the specification supported by the server.
10 //!
11 //! Gets the versions of the specification supported by the server.
12 //!
13 //! Values will take the form `vX.Y` or `rX.Y.Z` in historical cases. See
14 //! [the Specification Versioning](../#specification-versions) for more
15 //! information.
16 //!
17 //! The server may additionally advertise experimental features it supports
18 //! through `unstable_features`. These features should be namespaced and
19 //! may optionally include version information within their name if desired.
20 //! Features listed here are not for optionally toggling parts of the Matrix
21 //! specification and should only be used to advertise support for a feature
22 //! which has not yet landed in the spec. For example, a feature currently
23 //! undergoing the proposal process may appear here and eventually be taken
24 //! off this list once the feature lands in the spec and the server deems it
25 //! reasonable to do so. Servers can choose to enable some features only for
26 //! some users, so clients should include authentication in the request to
27 //! get all the features available for the logged-in user. If no
28 //! authentication is provided, the server should only return the features
29 //! available to all users. Servers may wish to keep advertising features
30 //! here after they've been released into the spec to give clients a chance
31 //! to upgrade appropriately. Additionally, clients should avoid using
32 //! unstable features in their stable releases.
33 class QUOTIENT_API GetVersionsJob : public BaseJob {
34 public:
35  explicit GetVersionsJob();
36 
37  //! \brief Construct a URL without creating a full-fledged job object
38  //!
39  //! This function can be used when a URL for GetVersionsJob
40  //! is necessary but the job itself isn't.
41  static QUrl makeRequestUrl(const HomeserverData& hsData);
42 
43  // Result properties
44 
45  //! The supported versions.
46  QStringList versions() const { return loadFromJson<QStringList>("versions"_L1); }
47 
48  //! Experimental features the server supports. Features not listed here,
49  //! or the lack of this property all together, indicate that a feature is
50  //! not supported.
51  QHash<QString, bool> unstableFeatures() const
52  {
53  return loadFromJson<QHash<QString, bool>>("unstable_features"_L1);
54  }
55 
56  struct Response {
57  //! The supported versions.
58  QStringList versions{};
59 
60  //! Experimental features the server supports. Features not listed here,
61  //! or the lack of this property all together, indicate that a feature is
62  //! not supported.
63  QHash<QString, bool> unstableFeatures{};
64  };
65 };
66 
67 template <std::derived_from<GetVersionsJob> JobT>
68 constexpr inline auto doCollectResponse<JobT> =
69  [](JobT* j) -> GetVersionsJob::Response { return { j->versions(), j->unstableFeatures() }; };
70 
71 } // namespace Quotient