1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
|
/******************************************************************************
* THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN
*/
#pragma once
#include "jobs/basejob.h"
#include <QtCore/QIODevice>
#include <QtNetwork/QNetworkReply>
namespace Quotient {
/*! \brief Upload some content to the content repository.
*
*/
class UploadContentJob : public BaseJob {
public:
/*! \brief Upload some content to the content repository.
*
* \param content
* The content to be uploaded.
*
* \param filename
* The name of the file being uploaded
*
* \param contentType
* The content type of the file being uploaded
*/
explicit UploadContentJob(QIODevice* content, const QString& filename = {},
const QString& contentType = {});
// Result properties
/// The `MXC URI`_ to the uploaded content.
QString contentUri() const
{
return loadFromJson<QString>("content_uri"_ls);
}
};
/*! \brief Download content from the content repository.
*
*/
class GetContentJob : public BaseJob {
public:
/*! \brief Download content from the content repository.
*
* \param serverName
* The server name from the ``mxc://`` URI (the authoritory component)
*
* \param mediaId
* The media ID from the ``mxc://`` URI (the path component)
*
* \param allowRemote
* Indicates to the server that it should not attempt to fetch the media
* if it is deemed remote. This is to prevent routing loops where the server
* contacts itself. Defaults to true if not provided.
*/
explicit GetContentJob(const QString& serverName, const QString& mediaId,
bool allowRemote = true);
/*! \brief Construct a URL without creating a full-fledged job object
*
* This function can be used when a URL for GetContentJob
* is necessary but the job itself isn't.
*/
static QUrl makeRequestUrl(QUrl baseUrl, const QString& serverName,
const QString& mediaId, bool allowRemote = true);
// Result properties
/// The content type of the file that was previously uploaded.
QString contentType() const { return reply()->rawHeader("Content-Type"); }
/// The name of the file that was previously uploaded, if set.
QString contentDisposition() const
{
return reply()->rawHeader("Content-Disposition");
}
/// The content that was previously uploaded.
QIODevice* data() { return reply(); }
};
/*! \brief Download content from the content repository overriding the file name
*
* This will download content from the content repository (same as
* the previous endpoint) but replace the target file name with the one
* provided by the caller.
*/
class GetContentOverrideNameJob : public BaseJob {
public:
/*! \brief Download content from the content repository overriding the file
* name
*
* \param serverName
* The server name from the ``mxc://`` URI (the authoritory component)
*
* \param mediaId
* The media ID from the ``mxc://`` URI (the path component)
*
* \param fileName
* A filename to give in the ``Content-Disposition`` header.
*
* \param allowRemote
* Indicates to the server that it should not attempt to fetch the media
* if it is deemed remote. This is to prevent routing loops where the server
* contacts itself. Defaults to true if not provided.
*/
explicit GetContentOverrideNameJob(const QString& serverName,
const QString& mediaId,
const QString& fileName,
bool allowRemote = true);
/*! \brief Construct a URL without creating a full-fledged job object
*
* This function can be used when a URL for GetContentOverrideNameJob
* is necessary but the job itself isn't.
*/
static QUrl makeRequestUrl(QUrl baseUrl, const QString& serverName,
const QString& mediaId, const QString& fileName,
bool allowRemote = true);
// Result properties
/// The content type of the file that was previously uploaded.
QString contentType() const { return reply()->rawHeader("Content-Type"); }
/// The ``fileName`` requested or the name of the file that was previously
/// uploaded, if set.
QString contentDisposition() const
{
return reply()->rawHeader("Content-Disposition");
}
/// The content that was previously uploaded.
QIODevice* data() { return reply(); }
};
/*! \brief Download a thumbnail of content from the content repository
*
* Download a thumbnail of content from the content repository.
* See the `thumbnailing <#thumbnails>`_ section for more information.
*/
class GetContentThumbnailJob : public BaseJob {
public:
/*! \brief Download a thumbnail of content from the content repository
*
* \param serverName
* The server name from the ``mxc://`` URI (the authoritory component)
*
* \param mediaId
* The media ID from the ``mxc://`` URI (the path component)
*
* \param width
* The *desired* width of the thumbnail. The actual thumbnail may be
* larger than the size specified.
*
* \param height
* The *desired* height of the thumbnail. The actual thumbnail may be
* larger than the size specified.
*
* \param method
* The desired resizing method. See the `thumbnailing <#thumbnails>`_
* section for more information.
*
* \param allowRemote
* Indicates to the server that it should not attempt to fetch
* the media if it is deemed remote. This is to prevent routing loops
* where the server contacts itself. Defaults to true if not provided.
*/
explicit GetContentThumbnailJob(const QString& serverName,
const QString& mediaId, int width,
int height, const QString& method = {},
bool allowRemote = true);
/*! \brief Construct a URL without creating a full-fledged job object
*
* This function can be used when a URL for GetContentThumbnailJob
* is necessary but the job itself isn't.
*/
static QUrl makeRequestUrl(QUrl baseUrl, const QString& serverName,
const QString& mediaId, int width, int height,
const QString& method = {},
bool allowRemote = true);
// Result properties
/// The content type of the thumbnail.
QString contentType() const { return reply()->rawHeader("Content-Type"); }
/// A thumbnail of the requested content.
QIODevice* data() { return reply(); }
};
/*! \brief Get information about a URL for a client
*
* Get information about a URL for the client. Typically this is called when a
* client sees a URL in a message and wants to render a preview for the user.
*
* .. Note::
* Clients should consider avoiding this endpoint for URLs posted in encrypted
* rooms. Encrypted rooms often contain more sensitive information the users
* do not want to share with the homeserver, and this can mean that the URLs
* being shared should also not be shared with the homeserver.
*/
class GetUrlPreviewJob : public BaseJob {
public:
/*! \brief Get information about a URL for a client
*
* \param url
* The URL to get a preview of.
*
* \param ts
* The preferred point in time to return a preview for. The server may
* return a newer version if it does not have the requested version
* available.
*/
explicit GetUrlPreviewJob(const QString& url, Omittable<qint64> ts = none);
/*! \brief Construct a URL without creating a full-fledged job object
*
* This function can be used when a URL for GetUrlPreviewJob
* is necessary but the job itself isn't.
*/
static QUrl makeRequestUrl(QUrl baseUrl, const QString& url,
Omittable<qint64> ts = none);
// Result properties
/// The byte-size of the image. Omitted if there is no image attached.
Omittable<qint64> matrixImageSize() const
{
return loadFromJson<Omittable<qint64>>("matrix:image:size"_ls);
}
/// An `MXC URI`_ to the image. Omitted if there is no image.
QString ogImage() const { return loadFromJson<QString>("og:image"_ls); }
};
/*! \brief Get the configuration for the content repository.
*
* This endpoint allows clients to retrieve the configuration of the content
* repository, such as upload limitations.
* Clients SHOULD use this as a guide when using content repository endpoints.
* All values are intentionally left optional. Clients SHOULD follow
* the advice given in the field description when the field is not available.
*
* **NOTE:** Both clients and server administrators should be aware that proxies
* between the client and the server may affect the apparent behaviour of
* content repository APIs, for example, proxies may enforce a lower upload size
* limit than is advertised by the server on this endpoint.
*/
class GetConfigJob : public BaseJob {
public:
/// Get the configuration for the content repository.
explicit GetConfigJob();
/*! \brief Construct a URL without creating a full-fledged job object
*
* This function can be used when a URL for GetConfigJob
* is necessary but the job itself isn't.
*/
static QUrl makeRequestUrl(QUrl baseUrl);
// Result properties
/// The maximum size an upload can be in bytes.
/// Clients SHOULD use this as a guide when uploading content.
/// If not listed or null, the size limit should be treated as unknown.
Omittable<qint64> uploadSize() const
{
return loadFromJson<Omittable<qint64>>("m.upload.size"_ls);
}
};
} // namespace Quotient
|