summary refs log tree commit diff
path: root/include
diff options
context:
space:
mode:
authorKonstantinos Sideris <sideris.konstantin@gmail.com>2017-05-07 17:15:38 +0300
committerKonstantinos Sideris <sideris.konstantin@gmail.com>2017-05-07 17:15:38 +0300
commit1f90c58076b9c40a609c88b9cdad51dd55da6954 (patch)
tree5a45ae1b5b1ca62cf8665aa892de904481dac215 /include
parentAdd matrix::events namespace (diff)
downloadnheko-1f90c58076b9c40a609c88b9cdad51dd55da6954.tar.xz
Use timeline to retrieve state events
- Rooms without any history will be shown.
- Room's state will be kept in sync and any updates will be visible.
Diffstat (limited to 'include')
-rw-r--r--include/ChatPage.h10
-rw-r--r--include/ImageItem.h10
-rw-r--r--include/RoomInfoListItem.h24
-rw-r--r--include/RoomList.h12
-rw-r--r--include/RoomState.h63
-rw-r--r--include/Sync.h13
-rw-r--r--include/TimelineItem.h17
-rw-r--r--include/TimelineView.h22
-rw-r--r--include/TimelineViewManager.h5
-rw-r--r--include/events/Event.h5
-rw-r--r--include/events/MessageEvent.h67
-rw-r--r--include/events/MessageEventContent.h78
-rw-r--r--include/events/RoomEvent.h5
-rw-r--r--include/events/messages/Audio.h65
-rw-r--r--include/events/messages/Emote.h (renamed from include/RoomInfo.h)44
-rw-r--r--include/events/messages/File.h76
-rw-r--r--include/events/messages/Image.h69
-rw-r--r--include/events/messages/Location.h65
-rw-r--r--include/events/messages/Notice.h40
-rw-r--r--include/events/messages/Text.h40
-rw-r--r--include/events/messages/Video.h70
21 files changed, 727 insertions, 73 deletions
diff --git a/include/ChatPage.h b/include/ChatPage.h

index 074b0753..2107eccf 100644 --- a/include/ChatPage.h +++ b/include/ChatPage.h
@@ -23,8 +23,8 @@ #include <QWidget> #include "MatrixClient.h" -#include "RoomInfo.h" #include "RoomList.h" +#include "RoomState.h" #include "TextInputWidget.h" #include "TimelineViewManager.h" #include "TopRoomBar.h" @@ -58,11 +58,13 @@ private slots: void initialSyncCompleted(const SyncResponse &response); void syncCompleted(const SyncResponse &response); void syncFailed(const QString &msg); - void changeTopRoomInfo(const RoomInfo &info); + void changeTopRoomInfo(const QString &room_id); void startSync(); void logout(); private: + void updateRoomState(RoomState &room_state, const QJsonArray &events); + Ui::ChatPage *ui; RoomList *room_list_; @@ -74,11 +76,13 @@ private: QTimer *sync_timer_; int sync_interval_; - RoomInfo current_room_; + QString current_room_; QMap<QString, QPixmap> room_avatars_; UserInfoWidget *user_info_widget_; + QMap<QString, RoomState> state_manager_; + // Matrix Client API provider. QSharedPointer<MatrixClient> client_; }; diff --git a/include/ImageItem.h b/include/ImageItem.h
index 7dc8773f..5d065b25 100644 --- a/include/ImageItem.h +++ b/include/ImageItem.h
@@ -23,16 +23,18 @@ #include <QSharedPointer> #include <QWidget> +#include "Image.h" #include "MatrixClient.h" +namespace events = matrix::events; +namespace msgs = matrix::events::messages; + class ImageItem : public QWidget { Q_OBJECT public: ImageItem(QSharedPointer<MatrixClient> client, - const Event &event, - const QString &body, - const QUrl &url, + const events::MessageEvent<msgs::Image> &event, QWidget *parent = nullptr); void setImage(const QPixmap &image); @@ -65,7 +67,7 @@ private: int bottom_height_ = 30; - Event event_; + events::MessageEvent<msgs::Image> event_; QSharedPointer<MatrixClient> client_; }; diff --git a/include/RoomInfoListItem.h b/include/RoomInfoListItem.h
index 5c403dc3..f45c9324 100644 --- a/include/RoomInfoListItem.h +++ b/include/RoomInfoListItem.h
@@ -26,26 +26,27 @@ #include "Avatar.h" #include "Badge.h" #include "RippleOverlay.h" -#include "RoomInfo.h" +#include "RoomState.h" class RoomInfoListItem : public QWidget { Q_OBJECT public: - RoomInfoListItem(RoomInfo info, QWidget *parent = 0); + RoomInfoListItem(RoomState state, QString room_id, QWidget *parent = 0); ~RoomInfoListItem(); void updateUnreadMessageCount(int count); void clearUnreadMessageCount(); + void setState(const RoomState &state); - inline bool isPressed(); - inline RoomInfo info(); + inline bool isPressed() const; + inline RoomState state() const; inline void setAvatar(const QImage &avatar_image); - inline int unreadMessageCount(); + inline int unreadMessageCount() const; signals: - void clicked(const RoomInfo &info_); + void clicked(const QString &room_id); public slots: void setPressedState(bool state); @@ -58,7 +59,8 @@ private: RippleOverlay *ripple_overlay_; - RoomInfo info_; + RoomState state_; + QString room_id_; QHBoxLayout *topLayout_; @@ -83,19 +85,19 @@ private: int unread_msg_count_; }; -inline int RoomInfoListItem::unreadMessageCount() +inline int RoomInfoListItem::unreadMessageCount() const { return unread_msg_count_; } -inline bool RoomInfoListItem::isPressed() +inline bool RoomInfoListItem::isPressed() const { return is_pressed_; } -inline RoomInfo RoomInfoListItem::info() +inline RoomState RoomInfoListItem::state() const { - return info_; + return state_; } inline void RoomInfoListItem::setAvatar(const QImage &avatar_image) diff --git a/include/RoomList.h b/include/RoomList.h
index e22f0954..8bb962e0 100644 --- a/include/RoomList.h +++ b/include/RoomList.h
@@ -24,8 +24,8 @@ #include <QWidget> #include "MatrixClient.h" -#include "RoomInfo.h" #include "RoomInfoListItem.h" +#include "RoomState.h" #include "Sync.h" namespace Ui @@ -41,18 +41,18 @@ public: RoomList(QSharedPointer<MatrixClient> client, QWidget *parent = 0); ~RoomList(); - void setInitialRooms(const Rooms &rooms); - void clear(); + void setInitialRooms(const QMap<QString, RoomState> &states); + void sync(const QMap<QString, RoomState> &states); - RoomInfo extractRoomInfo(const State &room_state); + void clear(); signals: - void roomChanged(const RoomInfo &info); + void roomChanged(const QString &room_id); void totalUnreadMessageCountUpdated(int count); public slots: void updateRoomAvatar(const QString &roomid, const QPixmap &img); - void highlightSelectedRoom(const RoomInfo &info); + void highlightSelectedRoom(const QString &room_id); void updateUnreadMessageCount(const QString &roomid, int count); private: diff --git a/include/RoomState.h b/include/RoomState.h new file mode 100644
index 00000000..a6cce540 --- /dev/null +++ b/include/RoomState.h
@@ -0,0 +1,63 @@ +/* + * nheko Copyright (C) 2017 Konstantinos Sideris <siderisk@auth.gr> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +#ifndef ROOM_STATE_H +#define ROOM_STATE_H + +#include <QPixmap> + +#include "AliasesEventContent.h" +#include "AvatarEventContent.h" +#include "CanonicalAliasEventContent.h" +#include "CreateEventContent.h" +#include "HistoryVisibilityEventContent.h" +#include "JoinRulesEventContent.h" +#include "NameEventContent.h" +#include "PowerLevelsEventContent.h" +#include "TopicEventContent.h" + +#include "Event.h" +#include "RoomEvent.h" +#include "StateEvent.h" + +namespace events = matrix::events; + +class RoomState +{ +public: + QString resolveName() const; + inline QString resolveTopic() const; + + QPixmap avatar_img_; + + events::StateEvent<events::AliasesEventContent> aliases; + events::StateEvent<events::AvatarEventContent> avatar; + events::StateEvent<events::CanonicalAliasEventContent> canonical_alias; + events::StateEvent<events::CreateEventContent> create; + events::StateEvent<events::HistoryVisibilityEventContent> history_visibility; + events::StateEvent<events::JoinRulesEventContent> join_rules; + events::StateEvent<events::NameEventContent> name; + events::StateEvent<events::PowerLevelsEventContent> power_levels; + events::StateEvent<events::TopicEventContent> topic; +}; + +inline QString RoomState::resolveTopic() const +{ + return topic.content().topic().simplified(); +} + +#endif // ROOM_STATE_H diff --git a/include/Sync.h b/include/Sync.h
index 6a227bcf..bfa03c1b 100644 --- a/include/Sync.h +++ b/include/Sync.h
@@ -18,6 +18,7 @@ #ifndef SYNC_H #define SYNC_H +#include <QJsonArray> #include <QJsonDocument> #include <QMap> #include <QString> @@ -90,13 +91,13 @@ class State : public Deserializable { public: void deserialize(const QJsonValue &data) override; - inline QList<Event> events() const; + inline QJsonArray events() const; private: - QList<Event> events_; + QJsonArray events_; }; -inline QList<Event> State::events() const +inline QJsonArray State::events() const { return events_; } @@ -104,19 +105,19 @@ inline QList<Event> State::events() const class Timeline : public Deserializable { public: - inline QList<Event> events() const; + inline QJsonArray events() const; inline QString previousBatch() const; inline bool limited() const; void deserialize(const QJsonValue &data) override; private: - QList<Event> events_; + QJsonArray events_; QString prev_batch_; bool limited_; }; -inline QList<Event> Timeline::events() const +inline QJsonArray Timeline::events() const { return events_; } diff --git a/include/TimelineItem.h b/include/TimelineItem.h
index e9f18f20..f23ad2c9 100644 --- a/include/TimelineItem.h +++ b/include/TimelineItem.h
@@ -25,20 +25,27 @@ #include "ImageItem.h" #include "Sync.h" +#include "Image.h" +#include "MessageEvent.h" +#include "Notice.h" +#include "Text.h" + +namespace events = matrix::events; +namespace msgs = matrix::events::messages; + class TimelineItem : public QWidget { Q_OBJECT public: - // For remote messages. - TimelineItem(const Event &event, bool with_sender, const QString &color, QWidget *parent = 0); + TimelineItem(const events::MessageEvent<msgs::Notice> &e, bool with_sender, const QString &color, QWidget *parent = 0); + TimelineItem(const events::MessageEvent<msgs::Text> &e, bool with_sender, const QString &color, QWidget *parent = 0); // For local messages. TimelineItem(const QString &userid, const QString &color, const QString &body, QWidget *parent = 0); TimelineItem(const QString &body, QWidget *parent = 0); - // For inline images. - TimelineItem(ImageItem *image, const Event &event, const QString &color, QWidget *parent); - TimelineItem(ImageItem *image, const Event &event, QWidget *parent); + TimelineItem(ImageItem *img, const events::MessageEvent<msgs::Image> &e, const QString &color, QWidget *parent); + TimelineItem(ImageItem *img, const events::MessageEvent<msgs::Image> &e, QWidget *parent); ~TimelineItem(); diff --git a/include/TimelineView.h b/include/TimelineView.h
index 4400c361..1808d735 100644 --- a/include/TimelineView.h +++ b/include/TimelineView.h
@@ -27,6 +27,13 @@ #include "Sync.h" #include "TimelineItem.h" +#include "Image.h" +#include "Notice.h" +#include "Text.h" + +namespace msgs = matrix::events::messages; +namespace events = matrix::events; + // Contains info about a message shown in the history view // but not yet confirmed by the homeserver through sync. struct PendingMessage { @@ -50,13 +57,14 @@ class TimelineView : public QWidget public: TimelineView(QSharedPointer<MatrixClient> client, QWidget *parent = 0); - TimelineView(const QList<Event> &events, QSharedPointer<MatrixClient> client, QWidget *parent = 0); + TimelineView(const QJsonArray &events, QSharedPointer<MatrixClient> client, QWidget *parent = 0); ~TimelineView(); - // FIXME: Reduce the parameters - void addHistoryItem(const Event &event, const QString &color, bool with_sender); - void addImageItem(const QString &body, const QUrl &url, const Event &event, const QString &color, bool with_sender); - int addEvents(const QList<Event> &events); + void addHistoryItem(const events::MessageEvent<msgs::Image> &e, const QString &color, bool with_sender); + void addHistoryItem(const events::MessageEvent<msgs::Notice> &e, const QString &color, bool with_sender); + void addHistoryItem(const events::MessageEvent<msgs::Text> &e, const QString &color, bool with_sender); + + int addEvents(const QJsonArray &events); void addUserTextMessage(const QString &msg, int txn_id); void updatePendingMessage(int txn_id, QString event_id); void clear(); @@ -66,8 +74,8 @@ public slots: private: void init(); - void removePendingMessage(const Event &event); - bool isPendingMessage(const Event &event, const QString &userid); + void removePendingMessage(const events::MessageEvent<msgs::Text> &e); + bool isPendingMessage(const events::MessageEvent<msgs::Text> &e, const QString &userid); QVBoxLayout *top_layout_; QVBoxLayout *scroll_layout_; diff --git a/include/TimelineViewManager.h b/include/TimelineViewManager.h
index bb4351c4..3c539305 100644 --- a/include/TimelineViewManager.h +++ b/include/TimelineViewManager.h
@@ -24,7 +24,6 @@ #include <QWidget> #include "MatrixClient.h" -#include "RoomInfo.h" #include "Sync.h" #include "TimelineView.h" @@ -48,14 +47,14 @@ signals: void unreadMessages(QString roomid, int count); public slots: - void setHistoryView(const RoomInfo &info); + void setHistoryView(const QString &room_id); void sendTextMessage(const QString &msg); private slots: void messageSent(const QString &eventid, const QString &roomid, int txnid); private: - RoomInfo active_room_; + QString active_room_; QMap<QString, TimelineView *> views_; QSharedPointer<MatrixClient> client_; }; diff --git a/include/events/Event.h b/include/events/Event.h
index 2621eadb..a7e4fb2d 100644 --- a/include/events/Event.h +++ b/include/events/Event.h
@@ -41,6 +41,8 @@ enum EventType { RoomJoinRules, /// m.room.member RoomMember, + /// m.room.message + RoomMessage, /// m.room.name RoomName, /// m.room.power_levels @@ -53,6 +55,9 @@ enum EventType { EventType extractEventType(const QJsonObject &data); +bool isMessageEvent(EventType type); +bool isStateEvent(EventType type); + template <class Content> class Event : public Deserializable { diff --git a/include/events/MessageEvent.h b/include/events/MessageEvent.h new file mode 100644
index 00000000..617514b0 --- /dev/null +++ b/include/events/MessageEvent.h
@@ -0,0 +1,67 @@ +/* + * nheko Copyright (C) 2017 Konstantinos Sideris <siderisk@auth.gr> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +#ifndef MATRIX_MESSAGE_EVENT_H +#define MATRIX_MESSAGE_EVENT_H + +#include "MessageEventContent.h" +#include "RoomEvent.h" + +namespace matrix +{ +namespace events +{ +template <class MsgContent> +class MessageEvent : public RoomEvent<MessageEventContent> +{ +public: + inline MsgContent msgContent() const; + + void deserialize(const QJsonValue &data) override; + +private: + MsgContent msg_content_; +}; + +template <class MsgContent> +inline MsgContent MessageEvent<MsgContent>::msgContent() const +{ + return msg_content_; +} + +template <class MsgContent> +void MessageEvent<MsgContent>::deserialize(const QJsonValue &data) +{ + RoomEvent<MessageEventContent>::deserialize(data); + + msg_content_.deserialize(data.toObject().value("content").toObject()); +} + +namespace messages +{ +struct ThumbnailInfo { + int h; + int w; + int size; + + QString mimetype; +}; +} // namespace messages +} // namespace events +} // namespace matrix + +#endif // MATRIX_MESSAGE_EVENT_H diff --git a/include/events/MessageEventContent.h b/include/events/MessageEventContent.h new file mode 100644
index 00000000..adc0f3ff --- /dev/null +++ b/include/events/MessageEventContent.h
@@ -0,0 +1,78 @@ +/* + * nheko Copyright (C) 2017 Konstantinos Sideris <siderisk@auth.gr> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +#ifndef MESSAGE_EVENT_CONTENT_H +#define MESSAGE_EVENT_CONTENT_H + +#include <QJsonValue> + +#include "Deserializable.h" + +namespace matrix +{ +namespace events +{ +enum MessageEventType { + // m.audio + Audio, + + // m.emote + Emote, + + // m.file + File, + + // m.image + Image, + + // m.location + Location, + + // m.notice + Notice, + + // m.text + Text, + + // m.video + Video, + + // Unrecognized message type + Unknown, +}; + +MessageEventType extractMessageEventType(const QJsonObject &data); + +class MessageEventContent : public Deserializable +{ +public: + void deserialize(const QJsonValue &data) override; + + inline QString body() const; + +private: + QString body_; +}; + +inline QString MessageEventContent::body() const +{ + return body_; +} +} // namespace events +} // namespace matrix + +#endif // MESSAGE_EVENT_CONTENT_H diff --git a/include/events/RoomEvent.h b/include/events/RoomEvent.h
index d8fa6e0e..9c2e9945 100644 --- a/include/events/RoomEvent.h +++ b/include/events/RoomEvent.h
@@ -83,8 +83,9 @@ void RoomEvent<Content>::deserialize(const QJsonValue &data) if (!object.contains("origin_server_ts")) throw DeserializationException("origin_server_ts key is missing"); - if (!object.contains("room_id")) - throw DeserializationException("room_id key is missing"); + // FIXME: Synapse doesn't include room id?! + /* if (!object.contains("room_id")) */ + /* throw DeserializationException("room_id key is missing"); */ if (!object.contains("sender")) throw DeserializationException("sender key is missing"); diff --git a/include/events/messages/Audio.h b/include/events/messages/Audio.h new file mode 100644
index 00000000..c3b5a4ef --- /dev/null +++ b/include/events/messages/Audio.h
@@ -0,0 +1,65 @@ +/* + * nheko Copyright (C) 2017 Konstantinos Sideris <siderisk@auth.gr> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +#ifndef MESSAGE_EVENT_AUDIO_H +#define MESSAGE_EVENT_AUDIO_H + +#include <QJsonObject> + +#include "Deserializable.h" + +namespace matrix +{ +namespace events +{ +namespace messages +{ +struct AudioInfo { + uint64_t duration; + int size; + + QString mimetype; +}; + +class Audio : public Deserializable +{ +public: + inline QString url() const; + inline AudioInfo info() const; + + void deserialize(const QJsonObject &object) override; + +private: + QString url_; + AudioInfo info_; +}; + +inline QString Audio::url() const +{ + return url_; +} + +inline AudioInfo Audio::info() const +{ + return info_; +} + +} // namespace messages +} // namespace events +} // namespace matrix + +#endif // MESSAGE_EVENT_AUDIO_H diff --git a/include/RoomInfo.h b/include/events/messages/Emote.h
index 9976ba8a..63b2b96b 100644 --- a/include/RoomInfo.h +++ b/include/events/messages/Emote.h
@@ -1,3 +1,4 @@ + /* * nheko Copyright (C) 2017 Konstantinos Sideris <siderisk@auth.gr> * @@ -15,35 +16,26 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ -#ifndef ROOM_INFO_H -#define ROOM_INFO_H +#ifndef MESSAGE_EVENT_EMOTE_H +#define MESSAGE_EVENT_EMOTE_H + +#include <QJsonObject> -#include <QList> -#include <QString> -#include <QUrl> +#include "Deserializable.h" -class RoomInfo +namespace matrix +{ +namespace events +{ +namespace messages +{ +class Emote : public Deserializable { public: - RoomInfo(); - RoomInfo(QString name, QString topic = "", QUrl avatar_url = QUrl("")); - - QString id() const; - QString name() const; - QString topic() const; - QUrl avatarUrl() const; - - void setAvatarUrl(const QUrl &url); - void setId(const QString &id); - void setName(const QString &name); - void setTopic(const QString &name); - -private: - QString id_; - QString name_; - QString topic_; - QUrl avatar_url_; - QList<QString> aliases_; + void deserialize(const QJsonObject &obj) override; }; +} // namespace messages +} // namespace events +} // namespace matrix -#endif // ROOM_INFO_H +#endif // MESSAGE_EVENT_EMOTE_H diff --git a/include/events/messages/File.h b/include/events/messages/File.h new file mode 100644
index 00000000..8fe61615 --- /dev/null +++ b/include/events/messages/File.h
@@ -0,0 +1,76 @@ +/* + * nheko Copyright (C) 2017 Konstantinos Sideris <siderisk@auth.gr> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +#ifndef MESSAGE_EVENT_FILE_H +#define MESSAGE_EVENT_FILE_H + +#include <QJsonObject> + +#include "Deserializable.h" +#include "MessageEvent.h" + +namespace matrix +{ +namespace events +{ +namespace messages +{ +struct FileInfo { + int size; + + QString mimetype; + QString thumbnail_url; + ThumbnailInfo thumbnail_info; +}; + +class File : public Deserializable +{ +public: + inline QString url() const; + inline QString filename() const; + + inline FileInfo info() const; + + void deserialize(const QJsonObject &object) override; + +private: + QString url_; + QString filename_; + + FileInfo info_; +}; + +inline QString File::filename() const +{ + return filename_; +} + +inline QString File::url() const +{ + return url_; +} + +inline FileInfo File::info() const +{ + return info_; +} + +} // namespace messages +} // namespace events +} // namespace matrix + +#endif // MESSAGE_EVENT_FILE_H diff --git a/include/events/messages/Image.h b/include/events/messages/Image.h new file mode 100644
index 00000000..5a329e4d --- /dev/null +++ b/include/events/messages/Image.h
@@ -0,0 +1,69 @@ +/* + * nheko Copyright (C) 2017 Konstantinos Sideris <siderisk@auth.gr> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +#ifndef MESSAGE_EVENT_IMAGE_H +#define MESSAGE_EVENT_IMAGE_H + +#include <QJsonObject> + +#include "Deserializable.h" +#include "MessageEvent.h" + +namespace matrix +{ +namespace events +{ +namespace messages +{ +struct ImageInfo { + int h; + int w; + int size; + + QString mimetype; + QString thumbnail_url; + ThumbnailInfo thumbnail_info; +}; + +class Image : public Deserializable +{ +public: + inline QString url() const; + inline ImageInfo info() const; + + void deserialize(const QJsonObject &object) override; + +private: + QString url_; + ImageInfo info_; +}; + +inline QString Image::url() const +{ + return url_; +} + +inline ImageInfo Image::info() const +{ + return info_; +} + +} // namespace messages +} // namespace events +} // namespace matrix + +#endif // MESSAGE_EVENT_IMAGE_H diff --git a/include/events/messages/Location.h b/include/events/messages/Location.h new file mode 100644
index 00000000..7c64cede --- /dev/null +++ b/include/events/messages/Location.h
@@ -0,0 +1,65 @@ +/* + * nheko Copyright (C) 2017 Konstantinos Sideris <siderisk@auth.gr> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +#ifndef MESSAGE_EVENT_LOCATION_H +#define MESSAGE_EVENT_LOCATION_H + +#include <QJsonObject> + +#include "Deserializable.h" +#include "MessageEvent.h" + +namespace matrix +{ +namespace events +{ +namespace messages +{ +struct LocationInfo { + QString thumbnail_url; + ThumbnailInfo thumbnail_info; +}; + +class Location : public Deserializable +{ +public: + inline QString geoUri() const; + inline LocationInfo info() const; + + void deserialize(const QJsonObject &object) override; + +private: + QString geo_uri_; + + LocationInfo info_; +}; + +inline QString Location::geoUri() const +{ + return geo_uri_; +} + +inline LocationInfo Location::info() const +{ + return info_; +} + +} // namespace messages +} // namespace events +} // namespace matrix + +#endif // MESSAGE_EVENT_LOCATION_H diff --git a/include/events/messages/Notice.h b/include/events/messages/Notice.h new file mode 100644
index 00000000..db94b273 --- /dev/null +++ b/include/events/messages/Notice.h
@@ -0,0 +1,40 @@ +/* + * nheko Copyright (C) 2017 Konstantinos Sideris <siderisk@auth.gr> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +#ifndef MESSAGE_EVENT_NOTICE_H +#define MESSAGE_EVENT_NOTICE_H + +#include <QJsonObject> + +#include "Deserializable.h" + +namespace matrix +{ +namespace events +{ +namespace messages +{ +class Notice : public Deserializable +{ +public: + void deserialize(const QJsonObject &obj) override; +}; +} // namespace messages +} // namespace events +} // namespace matrix + +#endif // MESSAGE_EVENT_NOTICE_H diff --git a/include/events/messages/Text.h b/include/events/messages/Text.h new file mode 100644
index 00000000..f116e78d --- /dev/null +++ b/include/events/messages/Text.h
@@ -0,0 +1,40 @@ +/* + * nheko Copyright (C) 2017 Konstantinos Sideris <siderisk@auth.gr> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +#ifndef MESSAGE_EVENT_TEXT_H +#define MESSAGE_EVENT_TEXT_H + +#include <QJsonObject> + +#include "Deserializable.h" + +namespace matrix +{ +namespace events +{ +namespace messages +{ +class Text : public Deserializable +{ +public: + void deserialize(const QJsonObject &obj) override; +}; +} // namespace messages +} // namespace events +} // namespace matrix + +#endif // MESSAGE_EVENT_TEXT_H diff --git a/include/events/messages/Video.h b/include/events/messages/Video.h new file mode 100644
index 00000000..bd307cf7 --- /dev/null +++ b/include/events/messages/Video.h
@@ -0,0 +1,70 @@ +/* + * nheko Copyright (C) 2017 Konstantinos Sideris <siderisk@auth.gr> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +#ifndef MESSAGE_EVENT_VIDEO_H +#define MESSAGE_EVENT_VIDEO_H + +#include <QJsonObject> + +#include "Deserializable.h" +#include "MessageEvent.h" + +namespace matrix +{ +namespace events +{ +namespace messages +{ +struct VideoInfo { + int h; + int w; + int size; + int duration; + + QString mimetype; + QString thumbnail_url; + ThumbnailInfo thumbnail_info; +}; + +class Video : public Deserializable +{ +public: + inline QString url() const; + inline VideoInfo info() const; + + void deserialize(const QJsonObject &object) override; + +private: + QString url_; + VideoInfo info_; +}; + +inline QString Video::url() const +{ + return url_; +} + +inline VideoInfo Video::info() const +{ + return info_; +} + +} // namespace messages +} // namespace events +} // namespace matrix + +#endif // MESSAGE_EVENT_VIDEO_H