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
12namespace Quotient {
13class Connection;
14class Room;
15class RoomMemberEvent;
16
17//! This class provides an interface to a given user's profile.
18//!
19//! \note The User class is not intended for getting the data to visualise a user
20//! in the context of a particular room. For that a Quotient::RoomMember object
21//! should be obtained from a Quotient::Room as this will account for the
22//! user setting an avatar or name that applies to that room only.
23//!
24//! \sa Quotient::RoomMember
25class QUOTIENT_API User : public QObject {
34public:
36
38
39 //! \brief Get unique stable user id
40 //!
41 //! The Matrix user ID is generated by the server and is never changed.
42 QString id() const;
43
44 //! \brief Get the default user name.
45 //!
46 //! This may be empty if the user has not set one.
47 //!
48 //! \note If you are visualizing a user in a room context you should be using
49 //! Quotient::RoomMember->name() as that will account for the user
50 //! having a unique name in that room.
51 //!
52 //! \sa Quotient::RoomMember::name()
53 QString name() const;
54
55 //! \brief Get the name to show on the user's profile
56 //!
57 //! This is intended to always give you something that can be displayed in a
58 //! UI. If the user doesn't have a default name or one is not available the
59 //! user's matrix ID will be used.
60 //!
61 //! \note If you are visualizing a user in a room context you should be using
62 //! Quotient::RoomMember->displayName() as that will account for the user
63 //! having a unique name in that room.
64 //!
65 //! \sa Quotient::RoomMember::displayname()
67
68 //! \brief Get user's profilename and id in one string
69 //!
70 //! This is intended to always give you something that can be displayed in a
71 //! UI. If the user doesn't have a default name or one is not available the
72 //! fucntion will return the user's matrix ID only.
73 //!
74 //! \note If you are visualizing a user in a room context you should be using
75 //! Quotient::RoomMember->fullName() as that will account for the user
76 //! having a unique name in that room.
77 //!
78 //! \sa Quotient::RoomMember::fullName()
80
81 //! \brief Whether the user is a guest
82 //!
83 //! As of now, the function relies on the convention used in Synapse
84 //! that guests and only guests have all-numeric IDs. This may or
85 //! may not work with non-Synapse servers.
86 bool isGuest() const;
87
89
90 //! \brief The default mxc URL as a string for the user avatar
91 //!
92 //! This can be empty if none set.
93 //!
94 //! \note When visualising a user in the room context use
95 //! Quotient::RoomMember::avatarMediaId() instead.
96 //!
97 //! \sa RoomMember
99
100 //! \brief The default mxc URL for the user avatar
101 //!
102 //! This can be empty if none set.
103 //!
104 //! \note When visualising a user in the room context use
105 //! Quotient::RoomMember::avatarUrl() instead.
106 //!
107 //! \sa RoomMember
109
111
113
114 //! Upload the file and use it as an avatar
116
117 //! Upload contents of the QIODevice and set that as an avatar
119
120public Q_SLOTS:
121 //! Set a new name in the global user profile
122 void rename(const QString& newName);
123
124 //! Set a new name for the user in one room
125 void rename(const QString& newName, Room* r);
126
127 //! Removes the avatar from the profile
128 void removeAvatar() const;
129
130 //! \brief Create or find a direct chat with this user
131 //!
132 //! The resulting chat is returned asynchronously via
133 //! Connection::directChatAvailable().
135
136 //! Add the user to the ignore list
137 void ignore() const;
138
139 //! Remove the user from the ignore list
140 void unmarkIgnore() const;
141
142 //! Check whether the user is in ignore list
143 bool isIgnored() const;
144
145 //! \brief Force loading display name and avatar URL
146 //!
147 //! This is required in some cases where the you need a user's default details
148 //! independent of the room, e.g. in a profile page.
149 void load();
150
152 //! The default name of the user has changed
154
155 //! The default avatar of the user has changed
157
158private:
159 class Private;
161
162 void doSetAvatar(const QUrl& contentUri);
163};
164} // namespace Quotient
#define QUOTIENT_API