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
12
namespace
Quotient
{
13
class
Connection;
14
class
Room;
15
class
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
25
class
QUOTIENT_API
User
:
public
QObject
{
26
Q_OBJECT
27
Q_PROPERTY
(
QString
id
READ
id
CONSTANT
)
28
Q_PROPERTY
(
bool
isGuest
READ
isGuest
CONSTANT
)
29
Q_PROPERTY
(
QString
name
READ
name
NOTIFY
defaultNameChanged
)
30
Q_PROPERTY
(
QString
displayName
READ
displayname
NOTIFY
defaultNameChanged
STORED
false
)
31
Q_PROPERTY
(
QString
fullName
READ
fullName
NOTIFY
defaultNameChanged
STORED
false
)
32
Q_PROPERTY
(
QString
avatarMediaId
READ
avatarMediaId
NOTIFY
defaultAvatarChanged
STORED
false
)
33
Q_PROPERTY
(
QUrl
avatarUrl
READ
avatarUrl
NOTIFY
defaultAvatarChanged
)
34
public
:
35
User
(
QString
userId
,
Connection
*
connection
);
36
37
Connection
*
connection
()
const
;
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()
66
QString
displayname
()
const
;
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()
79
QString
fullName
()
const
;
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
88
Avatar
&
avatarObject
();
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
98
QString
avatarMediaId
()
const
;
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
108
QUrl
avatarUrl
()
const
;
109
110
QImage
avatar
(
int
width
,
int
height
,
Avatar
::
get_callback_t
callback
);
111
112
QImage
avatar
(
int
dimension
,
Avatar
::
get_callback_t
callback
);
113
114
//! Upload the file and use it as an avatar
115
Q_INVOKABLE
bool
setAvatar
(
const
QString
&
fileName
);
116
117
//! Upload contents of the QIODevice and set that as an avatar
118
Q_INVOKABLE
bool
setAvatar
(
QIODevice
*
source
);
119
120
public
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().
134
void
requestDirectChat
();
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
151
Q_SIGNALS
:
152
//! The default name of the user has changed
153
void
defaultNameChanged
();
154
155
//! The default avatar of the user has changed
156
void
defaultAvatarChanged
();
157
158
private
:
159
class
Private
;
160
ImplPtr
<
Private
>
d
;
161
162
void
doSetAvatar
(
const
QUrl
&
contentUri
);
163
};
164
}
// namespace Quotient
Quotient::User
Definition
user.h:25
Quotient
Definition
accountregistry.h:13
QUOTIENT_API
#define QUOTIENT_API
Definition
quotient_export.h:22
Quotient
user.h
Generated by
1.9.8