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

#pragma once

#include "jobs/basejob.h"

#include "events/eventloader.h"
#include "converters.h"

namespace QMatrixClient
{
    // Operations

    /// Update this user's presence state.
    /// 
    /// This API sets the given user's presence state. When setting the status,
    /// the activity time is updated to reflect that activity; the client does
    /// not need to specify the ``last_active_ago`` field. You cannot set the
    /// presence state of another user.
    class SetPresenceJob : public BaseJob
    {
        public:
            /*! Update this user's presence state.
             * \param userId 
             *   The user whose presence state to update.
             * \param presence 
             *   The new presence state.
             * \param statusMsg 
             *   The status message to attach to this state.
             */
            explicit SetPresenceJob(const QString& userId, const QString& presence, const QString& statusMsg = {});
    };

    /// Get this user's presence state.
    /// 
    /// Get the given user's presence state.
    class GetPresenceJob : public BaseJob
    {
        public:
            /*! Get this user's presence state.
             * \param userId 
             *   The user whose presence state to get.
             */
            explicit GetPresenceJob(const QString& userId);

            /*! Construct a URL without creating a full-fledged job object
             *
             * This function can be used when a URL for
             * GetPresenceJob is necessary but the job
             * itself isn't.
             */
            static QUrl makeRequestUrl(QUrl baseUrl, const QString& userId);

            ~GetPresenceJob() override;

            // Result properties

            /// This user's presence.
            const QString& presence() const;
            /// The length of time in milliseconds since an action was performed
            /// by this user.
            Omittable<int> lastActiveAgo() const;
            /// The state message for this user if one was set.
            const QString& statusMsg() const;
            /// Whether the user is currently active
            bool currentlyActive() const;

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

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

    /// Add or remove users from this presence list.
    /// 
    /// Adds or removes users from this presence list.
    class ModifyPresenceListJob : public BaseJob
    {
        public:
            /*! Add or remove users from this presence list.
             * \param userId 
             *   The user whose presence list is being modified.
             * \param invite 
             *   A list of user IDs to add to the list.
             * \param drop 
             *   A list of user IDs to remove from the list.
             */
            explicit ModifyPresenceListJob(const QString& userId, const QStringList& invite = {}, const QStringList& drop = {});
    };

    /// Get presence events for this presence list.
    /// 
    /// Retrieve a list of presence events for every user on this list.
    class GetPresenceForListJob : public BaseJob
    {
        public:
            /*! Get presence events for this presence list.
             * \param userId 
             *   The user whose presence list should be retrieved.
             */
            explicit GetPresenceForListJob(const QString& userId);

            /*! Construct a URL without creating a full-fledged job object
             *
             * This function can be used when a URL for
             * GetPresenceForListJob is necessary but the job
             * itself isn't.
             */
            static QUrl makeRequestUrl(QUrl baseUrl, const QString& userId);

            ~GetPresenceForListJob() override;

            // Result properties

            /// A list of presence events for this list.
            Events&& data();

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

        private:
            class Private;
            QScopedPointer<Private> d;
    };
} // namespace QMatrixClient