aboutsummaryrefslogtreecommitdiff
path: root/lib/csapi/profile.h
blob: 77eebdfa66bcde1014523998715314904bd7c8b2 (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
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
/******************************************************************************
 * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN
 */

#pragma once

#include "jobs/basejob.h"


namespace QMatrixClient
{
    // Operations

    class SetDisplayNameJob : public BaseJob
    {
        public:
            explicit SetDisplayNameJob(const QString& userId, const QString& displayname = {});
    };

    class GetDisplayNameJob : public BaseJob
    {
        public:
            explicit GetDisplayNameJob(const QString& userId);

            /** Construct a URL out of baseUrl and usual parameters passed to
             * GetDisplayNameJob. This function can be used when
             * a URL for GetDisplayNameJob is necessary but the job
             * itself isn't.
             */
            static QUrl makeRequestUrl(QUrl baseUrl, const QString& userId);

            ~GetDisplayNameJob() override;

            // Result properties

            const QString& displayname() const;

        protected:
            Status parseJson(const QJsonDocument& data) override;

        private:
            class Private;
            QScopedPointer<Private> d;
    };

    class SetAvatarUrlJob : public BaseJob
    {
        public:
            explicit SetAvatarUrlJob(const QString& userId, const QString& avatarUrl = {});
    };

    class GetAvatarUrlJob : public BaseJob
    {
        public:
            explicit GetAvatarUrlJob(const QString& userId);

            /** Construct a URL out of baseUrl and usual parameters passed to
             * GetAvatarUrlJob. This function can be used when
             * a URL for GetAvatarUrlJob is necessary but the job
             * itself isn't.
             */
            static QUrl makeRequestUrl(QUrl baseUrl, const QString& userId);

            ~GetAvatarUrlJob() override;

            // Result properties

            const QString& avatarUrl() const;

        protected:
            Status parseJson(const QJsonDocument& data) override;

        private:
            class Private;
            QScopedPointer<Private> d;
    };

    class GetUserProfileJob : public BaseJob
    {
        public:
            explicit GetUserProfileJob(const QString& userId);

            /** Construct a URL out of baseUrl and usual parameters passed to
             * GetUserProfileJob. This function can be used when
             * a URL for GetUserProfileJob is necessary but the job
             * itself isn't.
             */
            static QUrl makeRequestUrl(QUrl baseUrl, const QString& userId);

            ~GetUserProfileJob() override;

            // Result properties

            const QString& avatarUrl() const;
            const QString& displayname() const;

        protected:
            Status parseJson(const QJsonDocument& data) override;

        private:
            class Private;
            QScopedPointer<Private> d;
    };
} // namespace QMatrixClient
ss="k">const; QString plainBody() const; const EventContent::TypedBase* content() const { return _content.data(); } template <typename VisitorT> void editContent(VisitorT&& visitor) { visitor(*_content); editJson()[ContentKeyL] = assembleContentJson(plainBody(), rawMsgtype(), _content.data()); } QMimeType mimeType() const; //! \brief Determine whether the message has text content //! //! \return true, if the message type is one of m.text, m.notice, m.emote, //! or the message type is unspecified (in which case plainBody() //! can still be examined); false otherwise bool hasTextContent() const; //! \brief Determine whether the message has a file/attachment //! //! \return true, if the message has a data structure corresponding to //! a file (such as m.file or m.audio); false otherwise bool hasFileContent() const; //! \brief Determine whether the message has a thumbnail //! //! \return true, if the message has a data structure corresponding to //! a thumbnail (the message type may be one for visual content, //! such as m.image, or generic binary content, i.e. m.file); //! false otherwise bool hasThumbnail() const; //! \brief Obtain id of an event replaced by the current one //! \sa RoomEvent::isReplaced, RoomEvent::replacedBy QString replacedEvent() const; static QString rawMsgTypeForUrl(const QUrl& url); static QString rawMsgTypeForFile(const QFileInfo& fi); private: QScopedPointer<EventContent::TypedBase> _content; // FIXME: should it really be static? static QJsonObject assembleContentJson(const QString& plainBody, const QString& jsonMsgType, EventContent::TypedBase* content); Q_ENUM(MsgType) }; REGISTER_EVENT_TYPE(RoomMessageEvent) using MessageEventType = RoomMessageEvent::MsgType; namespace EventContent { struct [[deprecated("Use Quotient::EventRelation instead")]] RelatesTo : EventRelation { static constexpr auto ReplyTypeId() { return ReplyType; } static constexpr auto ReplacementTypeId() { return ReplacementType; } }; [[deprecated("Use EventRelation::replyTo() instead")]] inline auto replyTo(QString eventId) { return EventRelation::replyTo(std::move(eventId)); } [[deprecated("Use EventRelation::replace() instead")]] inline auto replacementOf(QString eventId) { return EventRelation::replace(std::move(eventId)); } // Additional event content types /** * Rich text content for m.text, m.emote, m.notice * * Available fields: mimeType, body. The body can be either rich text * or plain text, depending on what mimeType specifies. */ class QUOTIENT_API TextContent : public TypedBase { public: TextContent(QString text, const QString& contentType, Omittable<EventRelation> relatesTo = none); explicit TextContent(const QJsonObject& json); QMimeType type() const override { return mimeType; } QMimeType mimeType; QString body; Omittable<EventRelation> relatesTo; protected: void fillJson(QJsonObject& json) const override; }; /** * Content class for m.location * * Available fields: * - corresponding to the top-level JSON: * - geoUri ("geo_uri" in JSON) * - corresponding to the "info" subobject: * - thumbnail.url ("thumbnail_url" in JSON) * - corresponding to the "info/thumbnail_info" subobject: * - thumbnail.payloadSize * - thumbnail.mimeType * - thumbnail.imageSize */ class QUOTIENT_API LocationContent : public TypedBase { public: LocationContent(const QString& geoUri, const Thumbnail& thumbnail = {}); explicit LocationContent(const QJsonObject& json); QMimeType type() const override; public: QString geoUri; Thumbnail thumbnail; protected: void fillJson(QJsonObject& o) const override; }; /** * A base class for info types that include duration: audio and video */ template <typename InfoT> class PlayableContent : public UrlBasedContent<InfoT> { public: using UrlBasedContent<InfoT>::UrlBasedContent; PlayableContent(const QJsonObject& json) : UrlBasedContent<InfoT>(json) , duration(FileInfo::originalInfoJson["duration"_ls].toInt()) {} protected: void fillInfoJson(QJsonObject& infoJson) const override { infoJson.insert(QStringLiteral("duration"), duration); } public: int duration; }; /** * Content class for m.video * * Available fields: * - corresponding to the top-level JSON: * - url * - filename (extension to the CS API spec) * - corresponding to the "info" subobject: * - payloadSize ("size" in JSON) * - mimeType ("mimetype" in JSON) * - duration * - imageSize (QSize for a combination of "h" and "w" in JSON) * - thumbnail.url ("thumbnail_url" in JSON) * - corresponding to the "info/thumbnail_info" subobject: contents of * thumbnail field, in the same vein as for "info": * - payloadSize * - mimeType * - imageSize */ using VideoContent = PlayableContent<ImageInfo>; /** * Content class for m.audio * * Available fields: * - corresponding to the top-level JSON: * - url * - filename (extension to the CS API spec) * - corresponding to the "info" subobject: * - payloadSize ("size" in JSON) * - mimeType ("mimetype" in JSON) * - duration * - thumbnail.url ("thumbnail_url" in JSON - extension to the spec) * - corresponding to the "info/thumbnail_info" subobject: contents of * thumbnail field (extension to the spec): * - payloadSize * - mimeType * - imageSize */ using AudioContent = PlayableContent<FileInfo>; } // namespace EventContent } // namespace Quotient