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
13
namespace
Quotient
{
14
class
Connection;
15
class
Room;
16
class
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
26
class
QUOTIENT_API
User
:
public
QObject
{
27
Q_OBJECT
28
QML_ELEMENT
29
QML_UNCREATABLE
(
""
)
30
31
Q_PROPERTY
(
QString
id
READ
id
CONSTANT
)
32
Q_PROPERTY
(
bool
isGuest
READ
isGuest
CONSTANT
)
33
Q_PROPERTY
(
QString
name
READ
name
NOTIFY
defaultNameChanged
)
34
Q_PROPERTY
(
QString
displayName
READ
displayname
NOTIFY
defaultNameChanged
STORED
false
)
35
Q_PROPERTY
(
QString
fullName
READ
fullName
NOTIFY
defaultNameChanged
STORED
false
)
36
Q_PROPERTY
(
QString
avatarMediaId
READ
avatarMediaId
NOTIFY
defaultAvatarChanged
STORED
false
)
37
Q_PROPERTY
(
QUrl
avatarUrl
READ
avatarUrl
NOTIFY
defaultAvatarChanged
)
38
public
:
39
User
(
QString
userId
,
Connection
*
connection
);
40
41
Connection
*
connection
()
const
;
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()
70
QString
displayname
()
const
;
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()
83
QString
fullName
()
const
;
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
92
Avatar
&
avatarObject
();
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
102
QString
avatarMediaId
()
const
;
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
112
QUrl
avatarUrl
()
const
;
113
114
QImage
avatar
(
int
width
,
int
height
,
Avatar
::
get_callback_t
callback
);
115
116
QImage
avatar
(
int
dimension
,
Avatar
::
get_callback_t
callback
);
117
118
//! Upload the file and use it as an avatar
119
Q_INVOKABLE
bool
setAvatar
(
const
QString
&
fileName
);
120
121
//! Upload contents of the QIODevice and set that as an avatar
122
Q_INVOKABLE
bool
setAvatar
(
QIODevice
*
source
);
123
124
public
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().
138
void
requestDirectChat
();
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
155
Q_SIGNALS
:
156
//! The default name of the user has changed
157
void
defaultNameChanged
();
158
159
//! The default avatar of the user has changed
160
void
defaultAvatarChanged
();
161
162
private
:
163
class
Private
;
164
ImplPtr
<
Private
>
d
;
165
166
void
doSetAvatar
(
const
QUrl
&
contentUri
);
167
};
168
}
// namespace Quotient
Quotient::User
Definition
user.h:26
Quotient
Definition
accountregistry.h:13
QUOTIENT_API
#define QUOTIENT_API
Definition
quotient_export.h:22
Quotient
user.h
Generated by
1.9.8