|
|
|
@ -27,15 +27,15 @@ |
|
|
|
|
class Event : public Deserializable |
|
|
|
|
{ |
|
|
|
|
public: |
|
|
|
|
inline QJsonObject content() const; |
|
|
|
|
inline QJsonObject unsigned_content() const; |
|
|
|
|
QJsonObject content() const { return content_; }; |
|
|
|
|
QJsonObject unsigned_content() const { return unsigned_; }; |
|
|
|
|
|
|
|
|
|
inline QString sender() const; |
|
|
|
|
inline QString state_key() const; |
|
|
|
|
inline QString type() const; |
|
|
|
|
inline QString eventId() const; |
|
|
|
|
QString sender() const { return sender_; }; |
|
|
|
|
QString state_key() const { return state_key_; }; |
|
|
|
|
QString type() const { return type_; }; |
|
|
|
|
QString eventId() const { return event_id_; }; |
|
|
|
|
|
|
|
|
|
inline uint64_t timestamp() const; |
|
|
|
|
uint64_t timestamp() const { return origin_server_ts_; }; |
|
|
|
|
|
|
|
|
|
void deserialize(const QJsonValue &data) override; |
|
|
|
|
|
|
|
|
@ -51,70 +51,22 @@ private: |
|
|
|
|
uint64_t origin_server_ts_; |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
inline QJsonObject |
|
|
|
|
Event::content() const |
|
|
|
|
{ |
|
|
|
|
return content_; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
inline QJsonObject |
|
|
|
|
Event::unsigned_content() const |
|
|
|
|
{ |
|
|
|
|
return unsigned_; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
inline QString |
|
|
|
|
Event::sender() const |
|
|
|
|
{ |
|
|
|
|
return sender_; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
inline QString |
|
|
|
|
Event::state_key() const |
|
|
|
|
{ |
|
|
|
|
return state_key_; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
inline QString |
|
|
|
|
Event::type() const |
|
|
|
|
{ |
|
|
|
|
return type_; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
inline QString |
|
|
|
|
Event::eventId() const |
|
|
|
|
{ |
|
|
|
|
return event_id_; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
inline uint64_t |
|
|
|
|
Event::timestamp() const |
|
|
|
|
{ |
|
|
|
|
return origin_server_ts_; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
class State : public Deserializable |
|
|
|
|
{ |
|
|
|
|
public: |
|
|
|
|
void deserialize(const QJsonValue &data) override; |
|
|
|
|
inline QJsonArray events() const; |
|
|
|
|
QJsonArray events() const { return events_; }; |
|
|
|
|
|
|
|
|
|
private: |
|
|
|
|
QJsonArray events_; |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
inline QJsonArray |
|
|
|
|
State::events() const |
|
|
|
|
{ |
|
|
|
|
return events_; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
class Timeline : public Deserializable |
|
|
|
|
{ |
|
|
|
|
public: |
|
|
|
|
inline QJsonArray events() const; |
|
|
|
|
inline QString previousBatch() const; |
|
|
|
|
inline bool limited() const; |
|
|
|
|
QJsonArray events() const { return events_; }; |
|
|
|
|
QString previousBatch() const { return prev_batch_; }; |
|
|
|
|
bool limited() const { return limited_; }; |
|
|
|
|
|
|
|
|
|
void deserialize(const QJsonValue &data) override; |
|
|
|
|
|
|
|
|
@ -124,31 +76,13 @@ private: |
|
|
|
|
bool limited_; |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
inline QJsonArray |
|
|
|
|
Timeline::events() const |
|
|
|
|
{ |
|
|
|
|
return events_; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
inline QString |
|
|
|
|
Timeline::previousBatch() const |
|
|
|
|
{ |
|
|
|
|
return prev_batch_; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
inline bool |
|
|
|
|
Timeline::limited() const |
|
|
|
|
{ |
|
|
|
|
return limited_; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// TODO: Add support for account_data, undread_notifications
|
|
|
|
|
class JoinedRoom : public Deserializable |
|
|
|
|
{ |
|
|
|
|
public: |
|
|
|
|
inline State state() const; |
|
|
|
|
inline Timeline timeline() const; |
|
|
|
|
inline QList<QString> typingUserIDs() const; |
|
|
|
|
State state() const { return state_; }; |
|
|
|
|
Timeline timeline() const { return timeline_; }; |
|
|
|
|
QList<QString> typingUserIDs() const { return typingUserIDs_; }; |
|
|
|
|
|
|
|
|
|
void deserialize(const QJsonValue &data) override; |
|
|
|
|
|
|
|
|
@ -160,29 +94,11 @@ private: |
|
|
|
|
/* UnreadNotifications unread_notifications_; */ |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
inline QList<QString> |
|
|
|
|
JoinedRoom::typingUserIDs() const |
|
|
|
|
{ |
|
|
|
|
return typingUserIDs_; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
inline State |
|
|
|
|
JoinedRoom::state() const |
|
|
|
|
{ |
|
|
|
|
return state_; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
inline Timeline |
|
|
|
|
JoinedRoom::timeline() const |
|
|
|
|
{ |
|
|
|
|
return timeline_; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
class LeftRoom : public Deserializable |
|
|
|
|
{ |
|
|
|
|
public: |
|
|
|
|
inline State state() const; |
|
|
|
|
inline Timeline timeline() const; |
|
|
|
|
State state() const { return state_; }; |
|
|
|
|
Timeline timeline() const { return timeline_; }; |
|
|
|
|
|
|
|
|
|
void deserialize(const QJsonValue &data) override; |
|
|
|
|
|
|
|
|
@ -191,24 +107,12 @@ private: |
|
|
|
|
Timeline timeline_; |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
inline State |
|
|
|
|
LeftRoom::state() const |
|
|
|
|
{ |
|
|
|
|
return state_; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
inline Timeline |
|
|
|
|
LeftRoom::timeline() const |
|
|
|
|
{ |
|
|
|
|
return timeline_; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// TODO: Add support for invited and left rooms.
|
|
|
|
|
class Rooms : public Deserializable |
|
|
|
|
{ |
|
|
|
|
public: |
|
|
|
|
inline QMap<QString, JoinedRoom> join() const; |
|
|
|
|
inline QMap<QString, LeftRoom> leave() const; |
|
|
|
|
QMap<QString, JoinedRoom> join() const { return join_; }; |
|
|
|
|
QMap<QString, LeftRoom> leave() const { return leave_; }; |
|
|
|
|
void deserialize(const QJsonValue &data) override; |
|
|
|
|
|
|
|
|
|
private: |
|
|
|
@ -216,38 +120,14 @@ private: |
|
|
|
|
QMap<QString, LeftRoom> leave_; |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
inline QMap<QString, JoinedRoom> |
|
|
|
|
Rooms::join() const |
|
|
|
|
{ |
|
|
|
|
return join_; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
inline QMap<QString, LeftRoom> |
|
|
|
|
Rooms::leave() const |
|
|
|
|
{ |
|
|
|
|
return leave_; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
class SyncResponse : public Deserializable |
|
|
|
|
{ |
|
|
|
|
public: |
|
|
|
|
void deserialize(const QJsonDocument &data) override; |
|
|
|
|
inline QString nextBatch() const; |
|
|
|
|
inline Rooms rooms() const; |
|
|
|
|
QString nextBatch() const { return next_batch_; }; |
|
|
|
|
Rooms rooms() const { return rooms_; }; |
|
|
|
|
|
|
|
|
|
private: |
|
|
|
|
QString next_batch_; |
|
|
|
|
Rooms rooms_; |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
inline Rooms |
|
|
|
|
SyncResponse::rooms() const |
|
|
|
|
{ |
|
|
|
|
return rooms_; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
inline QString |
|
|
|
|
SyncResponse::nextBatch() const |
|
|
|
|
{ |
|
|
|
|
return next_batch_; |
|
|
|
|
} |
|
|
|
|