libQuotient
A Qt library for building matrix clients
Loading...
Searching...
No Matches
user.h
Go to the documentation of this file.
1// SPDX-FileCopyrightText: 2015 Felix Rohrbach <kde@fxrh.de>
2// SPDX-FileCopyrightText: 2016 Kitsune Ral <Kitsune-Ral@users.sf.net>
3// SPDX-License-Identifier: LGPL-2.1-or-later
4
5#pragma once
6
7#include "avatar.h"
8#include "util.h"
9
10#include <QtCore/QObject>
11#include <QtQmlIntegration/qqmlintegration.h>
12
13namespace Quotient {
14class Connection;
15class Room;
16class RoomMemberEvent;
17
18//! This class provides an interface to a given user's profile.
19//!
20//! \note The User class is not intended for getting the data to visualise a user
21//! in the context of a particular room. For that a Quotient::RoomMember object
22//! should be obtained from a Quotient::Room as this will account for the
23//! user setting an avatar or name that applies to that room only.
24//!
25//! \sa Quotient::RoomMember
26class QUOTIENT_API User : public QObject {
30
38public:
40
42
43 //! \brief Get unique stable user id
44 //!
45 //! The Matrix user ID is generated by the server and is never changed.
46 QString id() const;
47
48 //! \brief Get the default user name.
49 //!
50 //! This may be empty if the user has not set one.
51 //!
52 //! \note If you are visualizing a user in a room context you should be using
53 //! Quotient::RoomMember->name() as that will account for the user
54 //! having a unique name in that room.
55 //!
56 //! \sa Quotient::RoomMember::name()
57 QString name() const;
58
59 //! \brief Get the name to show on the user's profile
60 //!
61 //! This is intended to always give you something that can be displayed in a
62 //! UI. If the user doesn't have a default name or one is not available the
63 //! user's matrix ID will be used.
64 //!
65 //! \note If you are visualizing a user in a room context you should be using
66 //! Quotient::RoomMember->displayName() as that will account for the user
67 //! having a unique name in that room.
68 //!
69 //! \sa Quotient::RoomMember::displayname()
71
72 //! \brief Get user's profilename and id in one string
73 //!
74 //! This is intended to always give you something that can be displayed in a
75 //! UI. If the user doesn't have a default name or one is not available the
76 //! fucntion will return the user's matrix ID only.
77 //!
78 //! \note If you are visualizing a user in a room context you should be using
79 //! Quotient::RoomMember->fullName() as that will account for the user
80 //! having a unique name in that room.
81 //!
82 //! \sa Quotient::RoomMember::fullName()
84
85 //! \brief Whether the user is a guest
86 //!
87 //! As of now, the function relies on the convention used in Synapse
88 //! that guests and only guests have all-numeric IDs. This may or
89 //! may not work with non-Synapse servers.
90 bool isGuest() const;
91
93
94 //! \brief The default mxc URL as a string for the user avatar
95 //!
96 //! This can be empty if none set.
97 //!
98 //! \note When visualising a user in the room context use
99 //! Quotient::RoomMember::avatarMediaId() instead.
100 //!
101 //! \sa RoomMember
103
104 //! \brief The default mxc URL for the user avatar
105 //!
106 //! This can be empty if none set.
107 //!
108 //! \note When visualising a user in the room context use
109 //! Quotient::RoomMember::avatarUrl() instead.
110 //!
111 //! \sa RoomMember
113
115
117
118 //! Upload the file and use it as an avatar
120
121 //! Upload contents of the QIODevice and set that as an avatar
123
124public Q_SLOTS:
125 //! Set a new name in the global user profile
126 void rename(const QString& newName);
127
128 //! Set a new name for the user in one room
129 void rename(const QString& newName, Room* r);
130
131 //! Removes the avatar from the profile
132 void removeAvatar() const;
133
134 //! \brief Create or find a direct chat with this user
135 //!
136 //! The resulting chat is returned asynchronously via
137 //! Connection::directChatAvailable().
139
140 //! Add the user to the ignore list
141 void ignore() const;
142
143 //! Remove the user from the ignore list
144 void unmarkIgnore() const;
145
146 //! Check whether the user is in ignore list
147 bool isIgnored() const;
148
149 //! \brief Force loading display name and avatar URL
150 //!
151 //! This is required in some cases where the you need a user's default details
152 //! independent of the room, e.g. in a profile page.
153 void load();
154
156 //! The default name of the user has changed
158
159 //! The default avatar of the user has changed
161
162private:
163 class Private;
165
166 void doSetAvatar(const QUrl& contentUri);
167};
168} // namespace Quotient
#define QUOTIENT_API