aboutsummaryrefslogtreecommitdiff
path: root/lib/events/stateevent.cpp
diff options
context:
space:
mode:
authorAndres Salomon <dilinger@queued.net>2021-01-18 04:00:14 -0500
committerAndres Salomon <dilinger@queued.net>2021-01-18 04:00:14 -0500
commit09eb39236666e81d5da014acea011dcd74d0999b (patch)
tree52876d96be71be1a39d5d935c1295a51995e8949 /lib/events/stateevent.cpp
parentf1788ee27f33e9339334e0d79bde9a27d9ce2e44 (diff)
parenta4e78956f105875625b572d8b98459ffa86fafe5 (diff)
downloadlibquotient-09eb39236666e81d5da014acea011dcd74d0999b.tar.gz
libquotient-09eb39236666e81d5da014acea011dcd74d0999b.zip
Update upstream source from tag 'upstream/0.6.4'
Update to upstream version '0.6.4' with Debian dir aa8705fd74743e79c043bc9e3e425d5064404cfe
Diffstat (limited to 'lib/events/stateevent.cpp')
-rw-r--r--lib/events/stateevent.cpp50
1 files changed, 28 insertions, 22 deletions
diff --git a/lib/events/stateevent.cpp b/lib/events/stateevent.cpp
index a84f302b..5909e8a6 100644
--- a/lib/events/stateevent.cpp
+++ b/lib/events/stateevent.cpp
@@ -1,33 +1,32 @@
/******************************************************************************
-* Copyright (C) 2018 Kitsune Ral <kitsune-ral@users.sf.net>
-*
-* This library is free software; you can redistribute it and/or
-* modify it under the terms of the GNU Lesser General Public
-* License as published by the Free Software Foundation; either
-* version 2.1 of the License, or (at your option) any later version.
-*
-* This library is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this library; if not, write to the Free Software
-* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
-*/
+ * Copyright (C) 2018 Kitsune Ral <kitsune-ral@users.sf.net>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
#include "stateevent.h"
-using namespace QMatrixClient;
+using namespace Quotient;
// Aside from the normal factory to instantiate StateEventBase inheritors
// StateEventBase itself can be instantiated if there's a state_key JSON key
// but the event type is unknown.
-[[gnu::unused]] static auto stateEventTypeInitialised =
+[[maybe_unused]] static auto stateEventTypeInitialised =
RoomEvent::factory_t::addMethod(
- [] (const QJsonObject& json, const QString& matrixType) -> StateEventPtr
- {
- if (!json.contains("state_key"_ls))
+ [](const QJsonObject& json, const QString& matrixType) -> StateEventPtr {
+ if (!json.contains(StateKeyKeyL))
return nullptr;
if (auto e = StateEventBase::factory_t::make(json, matrixType))
@@ -36,6 +35,12 @@ using namespace QMatrixClient;
return makeEvent<StateEventBase>(unknownEventTypeId(), json);
});
+StateEventBase::StateEventBase(Event::Type type, event_mtype_t matrixType,
+ const QString& stateKey,
+ const QJsonObject& contentJson)
+ : RoomEvent(type, basicStateEventJson(matrixType, contentJson, stateKey))
+{}
+
bool StateEventBase::repeatsState() const
{
const auto prevContentJson = unsignedJson().value(PrevContentKeyL);
@@ -53,6 +58,7 @@ void StateEventBase::dumpTo(QDebug dbg) const
dbg << '<' << stateKey() << "> ";
if (unsignedJson().contains(PrevContentKeyL))
dbg << QJsonDocument(unsignedJson()[PrevContentKeyL].toObject())
- .toJson(QJsonDocument::Compact) << " -> ";
+ .toJson(QJsonDocument::Compact)
+ << " -> ";
RoomEvent::dumpTo(dbg);
}