aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/csapi/versions.cpp10
-rw-r--r--lib/csapi/versions.h19
2 files changed, 29 insertions, 0 deletions
diff --git a/lib/csapi/versions.cpp b/lib/csapi/versions.cpp
index c853ec06..6ee6725d 100644
--- a/lib/csapi/versions.cpp
+++ b/lib/csapi/versions.cpp
@@ -16,6 +16,7 @@ class GetVersionsJob::Private
{
public:
QStringList versions;
+ QHash<QString, bool> unstableFeatures;
};
QUrl GetVersionsJob::makeRequestUrl(QUrl baseUrl)
@@ -40,10 +41,19 @@ const QStringList& GetVersionsJob::versions() const
return d->versions;
}
+const QHash<QString, bool>& GetVersionsJob::unstableFeatures() const
+{
+ return d->unstableFeatures;
+}
+
BaseJob::Status GetVersionsJob::parseJson(const QJsonDocument& data)
{
auto json = data.object();
+ if (!json.contains("versions"_ls))
+ return { JsonParseError,
+ "The key 'versions' not found in the response" };
fromJson(json.value("versions"_ls), d->versions);
+ fromJson(json.value("unstable_features"_ls), d->unstableFeatures);
return Success;
}
diff --git a/lib/csapi/versions.h b/lib/csapi/versions.h
index 309de184..b56f293f 100644
--- a/lib/csapi/versions.h
+++ b/lib/csapi/versions.h
@@ -6,6 +6,8 @@
#include "jobs/basejob.h"
+#include <QtCore/QHash>
+#include "converters.h"
namespace QMatrixClient
{
@@ -19,6 +21,19 @@ namespace QMatrixClient
///
/// Only the latest ``Z`` value will be reported for each supported ``X.Y`` value.
/// i.e. if the server implements ``r0.0.0``, ``r0.0.1``, and ``r1.2.0``, it will report ``r0.0.1`` and ``r1.2.0``.
+ ///
+ /// The server may additionally advertise experimental features it supports
+ /// through ``unstable_features``. These features should be namespaced and
+ /// may optionally include version information within their name if desired.
+ /// Features listed here are not for optionally toggling parts of the Matrix
+ /// specification and should only be used to advertise support for a feature
+ /// which has not yet landed in the spec. For example, a feature currently
+ /// undergoing the proposal process may appear here and eventually be taken
+ /// off this list once the feature lands in the spec and the server deems it
+ /// reasonable to do so. Servers may wish to keep advertising features here
+ /// after they've been released into the spec to give clients a chance to
+ /// upgrade appropriately. Additionally, clients should avoid using unstable
+ /// features in their stable releases.
class GetVersionsJob : public BaseJob
{
public:
@@ -38,6 +53,10 @@ namespace QMatrixClient
/// The supported versions.
const QStringList& versions() const;
+ /// Experimental features the server supports. Features not listed here,
+ /// or the lack of this property all together, indicate that a feature is
+ /// not supported.
+ const QHash<QString, bool>& unstableFeatures() const;
protected:
Status parseJson(const QJsonDocument& data) override;