diff -Nru libqmatrixclient-0.4.1/CMakeLists.txt libqmatrixclient-0.4.2.1/CMakeLists.txt --- libqmatrixclient-0.4.1/CMakeLists.txt 2018-12-06 12:01:06.000000000 +0000 +++ libqmatrixclient-0.4.2.1/CMakeLists.txt 2019-01-13 09:54:44.000000000 +0000 @@ -140,7 +140,7 @@ ${libqmatrixclient_cswellknown_SRCS} ${libqmatrixclient_asdef_SRCS} ${libqmatrixclient_isdef_SRCS}) set(API_VERSION "0.4") -set_property(TARGET QMatrixClient PROPERTY VERSION "${API_VERSION}.0") +set_property(TARGET QMatrixClient PROPERTY VERSION "${API_VERSION}.2.1") set_property(TARGET QMatrixClient PROPERTY SOVERSION ${API_VERSION} ) set_property(TARGET QMatrixClient PROPERTY INTERFACE_QMatrixClient_MAJOR_VERSION ${API_VERSION}) diff -Nru libqmatrixclient-0.4.1/debian/changelog libqmatrixclient-0.4.2.1/debian/changelog --- libqmatrixclient-0.4.1/debian/changelog 2018-12-24 20:11:03.000000000 +0000 +++ libqmatrixclient-0.4.2.1/debian/changelog 2019-01-14 16:21:36.000000000 +0000 @@ -1,3 +1,9 @@ +libqmatrixclient (0.4.2.1-1) unstable; urgency=medium + + * New upstream release. + + -- Hubert Chathi Mon, 14 Jan 2019 11:21:36 -0500 + libqmatrixclient (0.4.1-1) unstable; urgency=medium * Initial release of splitting the library out from quaternion. diff -Nru libqmatrixclient-0.4.1/examples/qmc-example.cpp libqmatrixclient-0.4.2.1/examples/qmc-example.cpp --- libqmatrixclient-0.4.1/examples/qmc-example.cpp 2018-12-06 12:01:06.000000000 +0000 +++ libqmatrixclient-0.4.2.1/examples/qmc-example.cpp 2019-01-13 09:54:44.000000000 +0000 @@ -5,6 +5,7 @@ #include "csapi/room_send.h" #include "csapi/joining.h" #include "csapi/leaving.h" +#include "events/simplestateevents.h" #include #include @@ -27,6 +28,7 @@ void onNewRoom(Room* r); void startTests(); void sendMessage(); + void setTopic(); void addAndRemoveTag(); void sendAndRedact(); void checkRedactionOutcome(const QString& evtIdToRedact, @@ -143,6 +145,7 @@ { cout << "Starting tests" << endl; sendMessage(); + setTopic(); addAndRemoveTag(); sendAndRedact(); markDirectChat(); @@ -168,6 +171,49 @@ // Independently, check when it shows up in the timeline. } +void QMCTest::setTopic() +{ + running.push_back("State setting test"); + running.push_back("Fake state event immunity test"); + auto initialTopic = targetRoom->topic(); + + const auto newTopic = c->generateTxnId(); + targetRoom->setTopic(newTopic); // Sets the state by proper means + const auto fakeTopic = c->generateTxnId(); + targetRoom->postJson(RoomTopicEvent::matrixTypeId(), // Fake state event + RoomTopicEvent(fakeTopic).contentJson()); + + { + auto* context = new QObject; + connect(targetRoom, &Room::topicChanged, context, + [this,newTopic,fakeTopic,initialTopic,context] { + if (targetRoom->topic() == newTopic) + { + QMC_CHECK("State setting test", true); + // Don't reset the topic yet if the negative test still runs + if (!running.contains("Fake state event immunity test")) + targetRoom->setTopic(initialTopic); + + context->deleteLater(); + } + }); + } + + { + auto* context = new QObject; + connect(targetRoom, &Room::pendingEventAboutToMerge, context, + [this,fakeTopic,initialTopic,context] (const RoomEvent* e, int) { + if (e->contentJson().value("topic").toString() != fakeTopic) + return; // Wait on for the right event + + QMC_CHECK("Fake state event immunity test", !e->isStateEvent()); + if (!running.contains("State setting test")) + targetRoom->setTopic(initialTopic); + context->deleteLater(); + }); + } +} + void QMCTest::addAndRemoveTag() { running.push_back("Tagging test"); diff -Nru libqmatrixclient-0.4.1/lib/events/stateevent.cpp libqmatrixclient-0.4.2.1/lib/events/stateevent.cpp --- libqmatrixclient-0.4.1/lib/events/stateevent.cpp 2018-12-06 12:01:06.000000000 +0000 +++ libqmatrixclient-0.4.2.1/lib/events/stateevent.cpp 2019-01-13 09:54:44.000000000 +0000 @@ -21,7 +21,17 @@ using namespace QMatrixClient; [[gnu::unused]] static auto stateEventTypeInitialised = - RoomEvent::factory_t::chainFactory(); + RoomEvent::factory_t::addMethod( + [] (const QJsonObject& json, const QString& matrixType) -> StateEventPtr + { + if (!json.contains("state_key")) + return nullptr; + + if (auto e = StateEventBase::factory_t::make(json, matrixType)) + return e; + + return nullptr; + }); bool StateEventBase::repeatsState() const {