diff options
author | Kitsune Ral <Kitsune-Ral@users.sf.net> | 2018-02-25 17:24:59 +0900 |
---|---|---|
committer | Kitsune Ral <Kitsune-Ral@users.sf.net> | 2018-02-26 09:06:37 +0900 |
commit | 7c10807549b2a73527bd594789d0e5b9ab58c874 (patch) | |
tree | ed624b2af356ac0e148862a3cee736d9fd894268 /events/tagevent.h | |
parent | a2f991555bec7b317606093e95ec2b5684b0005a (diff) | |
download | libquotient-7c10807549b2a73527bd594789d0e5b9ab58c874.tar.gz libquotient-7c10807549b2a73527bd594789d0e5b9ab58c874.zip |
TagEvent: m.tag events parsing
Using them in rooms and connection comes in the next commit.
Diffstat (limited to 'events/tagevent.h')
-rw-r--r-- | events/tagevent.h | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/events/tagevent.h b/events/tagevent.h new file mode 100644 index 00000000..23b0b703 --- /dev/null +++ b/events/tagevent.h @@ -0,0 +1,53 @@ +/****************************************************************************** + * 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 + */ + +#pragma once + +#include "event.h" + +namespace QMatrixClient +{ + struct TagRecord + { + explicit TagRecord(const QJsonObject& json = {}); + + QString order; + }; + + class TagEvent : public Event + { + public: + explicit TagEvent(const QJsonObject& obj); + + /** Get the list of tag names */ + QStringList tagNames() const; + + /** Get the list of tags along with information on each */ + QHash<QString, TagRecord> tags() const; + + /** Check whether the list of tags has m.favourite */ + bool isFavourite() const; + /** Check whether the list of tags has m.lowpriority */ + bool isLowPriority() const; + + static constexpr const char * TypeId = "m.tag"; + + protected: + QJsonObject tagsObject() const; + }; +} |