aboutsummaryrefslogtreecommitdiff
path: root/lib/csapi/message_pagination.cpp
blob: c59a51ab71582ded2a0e57d756edfeb9c4a45ed4 (plain)
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
/******************************************************************************
 * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN
 */

#include "message_pagination.h"

#include "converters.h"

#include <QtCore/QStringBuilder>

using namespace QMatrixClient;

static const auto basePath = QStringLiteral("/_matrix/client/r0");

class GetRoomEventsJob::Private
{
    public:
        QString begin;
        QString end;
        RoomEvents chunk;
};

BaseJob::Query queryToGetRoomEvents(const QString& from, const QString& to, const QString& dir, Omittable<int> limit, const QString& filter)
{
    BaseJob::Query _q;
    addParam<>(_q, QStringLiteral("from"), from);
    addParam<IfNotEmpty>(_q, QStringLiteral("to"), to);
    addParam<>(_q, QStringLiteral("dir"), dir);
    addParam<IfNotEmpty>(_q, QStringLiteral("limit"), limit);
    addParam<IfNotEmpty>(_q, QStringLiteral("filter"), filter);
    return _q;
}

QUrl GetRoomEventsJob::makeRequestUrl(QUrl baseUrl, const QString& roomId, const QString& from, const QString& dir, const QString& to, Omittable<int> limit, const QString& filter)
{
    return BaseJob::makeRequestUrl(std::move(baseUrl),
            basePath % "/rooms/" % roomId % "/messages",
            queryToGetRoomEvents(from, to, dir, limit, filter));
}

static const auto GetRoomEventsJobName = QStringLiteral("GetRoomEventsJob");

GetRoomEventsJob::GetRoomEventsJob(const QString& roomId, const QString& from, const QString& dir, const QString& to, Omittable<int> limit, const QString& filter)
    : BaseJob(HttpVerb::Get, GetRoomEventsJobName,
        basePath % "/rooms/" % roomId % "/messages",
        queryToGetRoomEvents(from, to, dir, limit, filter))
    , d(new Private)
{
}

GetRoomEventsJob::~GetRoomEventsJob() = default;

const QString& GetRoomEventsJob::begin() const
{
    return d->begin;
}

const QString& GetRoomEventsJob::end() const
{
    return d->end;
}

RoomEvents&& GetRoomEventsJob::chunk()
{
    return std::move(d->chunk);
}

BaseJob::Status GetRoomEventsJob::parseJson(const QJsonDocument& data)
{
    auto json = data.object();
    d->begin = fromJson<QString>(json.value("start"_ls));
    d->end = fromJson<QString>(json.value("end"_ls));
    d->chunk = fromJson<RoomEvents>(json.value("chunk"_ls));
    return Success;
}
ass="p p-Indicator">- array: - string: QStringList - +set: { moveOnly: } +on: - /^Notification|Result$/: type: "std::vector<{{1}}>" imports: '"events/eventloader.h"' - /m\.room\.member$/: type: "EventsArray<RoomMemberEvent>" imports: '"events/roommemberevent.h"' - /state_event.yaml$/: type: StateEvents - /room_event.yaml$/: type: RoomEvents - /event.yaml$/: type: Events - //: { type: "QVector<{{1}}>", imports: <QtCore/QVector> } - map: # `additionalProperties` in OpenAPI - RoomState: type: "std::unordered_map<QString, {{1}}>" moveOnly: imports: <unordered_map> - /.+/: type: "QHash<QString, {{1}}>" imports: <QtCore/QHash> - //: type: QVariantHash imports: <QtCore/QVariant> - variant: # A sequence `type` (multitype) in OpenAPI - /^string,null|null,string$/: *QString - //: { type: QVariant, imports: <QtCore/QVariant> } #operations: mustache: constants: # Syntax elements used by GTAD # _quote: '"' # Common quote for left and right # _leftQuote: '"' # _rightQuote: '"' # _joinChar: ',' # The character used by {{_join}} - not working yet _comment: '//' partials: _typeRenderer: "{{#scope}}{{scopeCamelCase}}Job::{{/scope}}{{>name}}" omittedValue: '{}' # default value to initialize omitted parameters with initializer: '{{defaultValue}}' cjoin: '{{#hasMore}}, {{/hasMore}}' openOmittable: "{{^required?}}{{#useOmittable}}{{^defaultValue}}Omittable<{{/defaultValue}}{{/useOmittable}}{{/required?}}" closeOmittable: "{{^required?}}{{#useOmittable}}{{^defaultValue}}>{{/defaultValue}}{{/useOmittable}}{{/required?}}" maybeOmittableType: "{{>openOmittable}}{{dataType.name}}{{>closeOmittable}}" qualifiedMaybeOmittableType: "{{>openOmittable}}{{dataType.qualifiedName}}{{>closeOmittable}}" maybeCrefType: "{{#avoidCopy}}const {{/avoidCopy}}{{>maybeOmittableType}}{{#avoidCopy}}&{{/avoidCopy}}{{#moveOnly}}&&{{/moveOnly}}" qualifiedMaybeCrefType: "{{#avoidCopy}}const {{/avoidCopy}}{{>qualifiedMaybeOmittableType}}{{#avoidCopy}}&{{/avoidCopy}}{{#moveOnly}}&&{{/moveOnly}}" initializeDefaultValue: "{{#defaultValue}}{{>initializer}}{{/defaultValue}}{{^defaultValue}}{{>omittedValue}}{{/defaultValue}}" joinedParamDecl: '{{>maybeCrefType}} {{paramName}}{{^required?}} = {{>initializeDefaultValue}}{{/required?}}{{>cjoin}}' joinedParamDef: '{{>maybeCrefType}} {{paramName}}{{>cjoin}}' passQueryParams: '{{#queryParams}}{{paramName}}{{>cjoin}}{{/queryParams}}' copyrightName: Kitsune Ral copyrightEmail: <kitsune-ral@users.sf.net> templates: - "{{base}}.h.mustache" - "{{base}}.cpp.mustache" #outFilesList: apifiles.txt