1 /******************************************************************************
2  * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN
3  */
4 
5 #pragma once
6 
7 #include "converters.h"
8 
9 #include "events/eventloader.h"
10 #include "events/roommemberevent.h"
11 #include "jobs/basejob.h"
12 
13 #include <QtCore/QHash>
14 
15 namespace Quotient
16 {
17 
18 // Operations
19 
20 /// Get a single event by event ID.
21 /*!
22  * Get a single event based on ``roomId/eventId``. You must have permission to
23  * retrieve this event e.g. by being a member in the room for this event.
24  */
25 class GetOneRoomEventJob : public BaseJob
26 {
27 public:
28     /*! Get a single event by event ID.
29      * \param roomId
30      *   The ID of the room the event is in.
31      * \param eventId
32      *   The event ID to get.
33      */
34     explicit GetOneRoomEventJob(const QString& roomId, const QString& eventId);
35 
36     /*! Construct a URL without creating a full-fledged job object
37      *
38      * This function can be used when a URL for
39      * GetOneRoomEventJob is necessary but the job
40      * itself isn't.
41      */
42     static QUrl makeRequestUrl(QUrl baseUrl, const QString& roomId,
43                                const QString& eventId);
44 
45     ~GetOneRoomEventJob() override;
46 
47     // Result properties
48 
49     /// The full event.
50     EventPtr&& data();
51 
52 protected:
53     Status parseJson(const QJsonDocument& data) override;
54 
55 private:
56     class Private;
57     QScopedPointer<Private> d;
58 };
59 
60 /// Get the state identified by the type and key.
61 /*!
62  * Looks up the contents of a state event in a room. If the user is
63  * joined to the room then the state is taken from the current
64  * state of the room. If the user has left the room then the state is
65  * taken from the state of the room when they left.
66  */
67 class GetRoomStateWithKeyJob : public BaseJob
68 {
69 public:
70     /*! Get the state identified by the type and key.
71      * \param roomId
72      *   The room to look up the state in.
73      * \param eventType
74      *   The type of state to look up.
75      * \param stateKey
76      *   The key of the state to look up.
77      */
78     explicit GetRoomStateWithKeyJob(const QString& roomId,
79                                     const QString& eventType,
80                                     const QString& stateKey);
81 
82     /*! Construct a URL without creating a full-fledged job object
83      *
84      * This function can be used when a URL for
85      * GetRoomStateWithKeyJob is necessary but the job
86      * itself isn't.
87      */
88     static QUrl makeRequestUrl(QUrl baseUrl, const QString& roomId,
89                                const QString& eventType,
90                                const QString& stateKey);
91 };
92 
93 /// Get the state identified by the type, with the empty state key.
94 /*!
95  * Looks up the contents of a state event in a room. If the user is
96  * joined to the room then the state is taken from the current
97  * state of the room. If the user has left the room then the state is
98  * taken from the state of the room when they left.
99  *
100  * This looks up the state event with the empty state key.
101  */
102 class GetRoomStateByTypeJob : public BaseJob
103 {
104 public:
105     /*! Get the state identified by the type, with the empty state key.
106      * \param roomId
107      *   The room to look up the state in.
108      * \param eventType
109      *   The type of state to look up.
110      */
111     explicit GetRoomStateByTypeJob(const QString& roomId,
112                                    const QString& eventType);
113 
114     /*! Construct a URL without creating a full-fledged job object
115      *
116      * This function can be used when a URL for
117      * GetRoomStateByTypeJob is necessary but the job
118      * itself isn't.
119      */
120     static QUrl makeRequestUrl(QUrl baseUrl, const QString& roomId,
121                                const QString& eventType);
122 };
123 
124 /// Get all state events in the current state of a room.
125 /*!
126  * Get the state events for the current state of a room.
127  */
128 class GetRoomStateJob : public BaseJob
129 {
130 public:
131     /*! Get all state events in the current state of a room.
132      * \param roomId
133      *   The room to look up the state for.
134      */
135     explicit GetRoomStateJob(const QString& roomId);
136 
137     /*! Construct a URL without creating a full-fledged job object
138      *
139      * This function can be used when a URL for
140      * GetRoomStateJob is necessary but the job
141      * itself isn't.
142      */
143     static QUrl makeRequestUrl(QUrl baseUrl, const QString& roomId);
144 
145     ~GetRoomStateJob() override;
146 
147     // Result properties
148 
149     /// If the user is a member of the room this will be the
150     /// current state of the room as a list of events. If the user
151     /// has left the room then this will be the state of the room
152     /// when they left as a list of events.
153     StateEvents&& data();
154 
155 protected:
156     Status parseJson(const QJsonDocument& data) override;
157 
158 private:
159     class Private;
160     QScopedPointer<Private> d;
161 };
162 
163 /// Get the m.room.member events for the room.
164 /*!
165  * Get the list of members for this room.
166  */
167 class GetMembersByRoomJob : public BaseJob
168 {
169 public:
170     /*! Get the m.room.member events for the room.
171      * \param roomId
172      *   The room to get the member events for.
173      * \param at
174      *   The token defining the timeline position as-of which to return
175      *   the list of members. This token can be obtained from a batch token
176      *   returned for each room by the sync API, or from
177      *   a ``start``/``end`` token returned by a ``/messages`` request.
178      * \param membership
179      *   Only return users with the specified membership
180      * \param notMembership
181      *   Only return users with membership state other than specified
182      */
183     explicit GetMembersByRoomJob(const QString& roomId, const QString& at = {},
184                                  const QString& membership = {},
185                                  const QString& notMembership = {});
186 
187     /*! Construct a URL without creating a full-fledged job object
188      *
189      * This function can be used when a URL for
190      * GetMembersByRoomJob is necessary but the job
191      * itself isn't.
192      */
193     static QUrl makeRequestUrl(QUrl baseUrl, const QString& roomId,
194                                const QString& at = {},
195                                const QString& membership = {},
196                                const QString& notMembership = {});
197 
198     ~GetMembersByRoomJob() override;
199 
200     // Result properties
201 
202     /// Get the list of members for this room.
203     EventsArray<RoomMemberEvent>&& chunk();
204 
205 protected:
206     Status parseJson(const QJsonDocument& data) override;
207 
208 private:
209     class Private;
210     QScopedPointer<Private> d;
211 };
212 
213 /// Gets the list of currently joined users and their profile data.
214 /*!
215  * This API returns a map of MXIDs to member info objects for members of the
216  * room. The current user must be in the room for it to work, unless it is an
217  * Application Service in which case any of the AS's users must be in the room.
218  * This API is primarily for Application Services and should be faster to
219  * respond than ``/members`` as it can be implemented more efficiently on the
220  * server.
221  */
222 class GetJoinedMembersByRoomJob : public BaseJob
223 {
224 public:
225     // Inner data structures
226 
227     /// This API returns a map of MXIDs to member info objects for members of
228     /// the room. The current user must be in the room for it to work, unless it
229     /// is an Application Service in which case any of the AS's users must be in
230     /// the room. This API is primarily for Application Services and should be
231     /// faster to respond than ``/members`` as it can be implemented more
232     /// efficiently on the server.
233     struct RoomMember
234     {
235         /// The display name of the user this object is representing.
236         QString displayName;
237         /// The mxc avatar url of the user this object is representing.
238         QString avatarUrl;
239     };
240 
241     // Construction/destruction
242 
243     /*! Gets the list of currently joined users and their profile data.
244      * \param roomId
245      *   The room to get the members of.
246      */
247     explicit GetJoinedMembersByRoomJob(const QString& roomId);
248 
249     /*! Construct a URL without creating a full-fledged job object
250      *
251      * This function can be used when a URL for
252      * GetJoinedMembersByRoomJob is necessary but the job
253      * itself isn't.
254      */
255     static QUrl makeRequestUrl(QUrl baseUrl, const QString& roomId);
256 
257     ~GetJoinedMembersByRoomJob() override;
258 
259     // Result properties
260 
261     /// A map from user ID to a RoomMember object.
262     const QHash<QString, RoomMember>& joined() const;
263 
264 protected:
265     Status parseJson(const QJsonDocument& data) override;
266 
267 private:
268     class Private;
269     QScopedPointer<Private> d;
270 };
271 
272 } // namespace Quotient
273