aboutsummaryrefslogtreecommitdiff
path: root/lib/user.h
diff options
context:
space:
mode:
Diffstat (limited to 'lib/user.h')
-rw-r--r--lib/user.h101
1 files changed, 29 insertions, 72 deletions
diff --git a/lib/user.h b/lib/user.h
index a4985877..dfbff4a0 100644
--- a/lib/user.h
+++ b/lib/user.h
@@ -1,24 +1,11 @@
-/******************************************************************************
- * Copyright (C) 2015 Felix Rohrbach <kde@fxrh.de>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
+// SPDX-FileCopyrightText: 2015 Felix Rohrbach <kde@fxrh.de>
+// SPDX-FileCopyrightText: 2016 Kitsune Ral <Kitsune-Ral@users.sf.net>
+// SPDX-License-Identifier: LGPL-2.1-or-later
#pragma once
#include "avatar.h"
+#include "util.h"
#include <QtCore/QObject>
@@ -27,22 +14,19 @@ class Connection;
class Room;
class RoomMemberEvent;
-class User : public QObject {
+class QUOTIENT_API User : public QObject {
Q_OBJECT
Q_PROPERTY(QString id READ id CONSTANT)
Q_PROPERTY(bool isGuest READ isGuest CONSTANT)
Q_PROPERTY(int hue READ hue CONSTANT)
Q_PROPERTY(qreal hueF READ hueF CONSTANT)
- Q_PROPERTY(QString name READ name NOTIFY nameChanged)
- Q_PROPERTY(QString displayName READ displayname NOTIFY nameChanged STORED false)
- Q_PROPERTY(QString fullName READ fullName NOTIFY nameChanged STORED false)
- Q_PROPERTY(QString bridgeName READ bridged NOTIFY nameChanged STORED false)
- Q_PROPERTY(QString avatarMediaId READ avatarMediaId NOTIFY avatarChanged
- STORED false)
- Q_PROPERTY(QUrl avatarUrl READ avatarUrl NOTIFY avatarChanged)
+ Q_PROPERTY(QString name READ name NOTIFY defaultNameChanged)
+ Q_PROPERTY(QString displayName READ displayname NOTIFY defaultNameChanged STORED false)
+ Q_PROPERTY(QString fullName READ fullName NOTIFY defaultNameChanged STORED false)
+ Q_PROPERTY(QString avatarMediaId READ avatarMediaId NOTIFY defaultAvatarChanged STORED false)
+ Q_PROPERTY(QUrl avatarUrl READ avatarUrl NOTIFY defaultAvatarChanged)
public:
User(QString userId, Connection* connection);
- ~User() override;
Connection* connection() const;
@@ -55,18 +39,10 @@ public:
* This may be empty if the user didn't choose the name or cleared
* it. If the user is bridged, the bridge postfix (such as '(IRC)')
* is stripped out. No disambiguation for the room is done.
- * \sa displayName, rawName
+ * \sa displayName
*/
QString name(const Room* room = nullptr) const;
- /** Get the user name along with the bridge postfix
- * This function is similar to name() but appends the bridge postfix
- * (such as '(IRC)') to the user name. No disambiguation is done.
- * \sa name, displayName
- */
- [[deprecated("Bridge postfixes exist no more, use name() instead")]]
- QString rawName(const Room* room = nullptr) const;
-
/** Get the displayed user name
* When \p room is null, this method returns result of name() if
* the name is non-empty; otherwise it returns user id.
@@ -85,13 +61,6 @@ public:
*/
QString fullName(const Room* room = nullptr) const;
- /**
- * Returns the name of bridge the user is connected from or empty.
- */
- [[deprecated("Bridged status is no more supported; this always returns"
- " an empty string")]]
- QString bridged() const;
-
/** Whether the user is a guest
* As of now, the function relies on the convention used in Synapse
* that guests and only guests have all-numeric IDs. This may or
@@ -114,31 +83,26 @@ public:
*/
const Avatar& avatarObject(const Room* room = nullptr) const;
Q_INVOKABLE QImage avatar(int dimension,
- const Quotient::Room* room = nullptr);
+ const Quotient::Room* room = nullptr) const;
Q_INVOKABLE QImage avatar(int requestedWidth, int requestedHeight,
- const Quotient::Room* room = nullptr);
+ const Quotient::Room* room = nullptr) const;
QImage avatar(int width, int height, const Room* room,
- const Avatar::get_callback_t& callback);
+ const Avatar::get_callback_t& callback) const;
QString avatarMediaId(const Room* room = nullptr) const;
QUrl avatarUrl(const Room* room = nullptr) const;
- // TODO: This method is only there to emit obsolete signals:
- // nameAboutToChange(), nameChanged() and avatarChanged() - all of these
- // to be removed in 0.7
- /// \deprecated
- void processEvent(const RoomMemberEvent& event, const Room* r,
- bool firstMention);
-
-public slots:
+public Q_SLOTS:
/// Set a new name in the global user profile
void rename(const QString& newName);
/// Set a new name for the user in one room
- void rename(const QString& newName, const Room* r);
+ void rename(const QString& newName, Room* r);
/// Upload the file and use it as an avatar
bool setAvatar(const QString& fileName);
/// Upload contents of the QIODevice and set that as an avatar
bool setAvatar(QIODevice* source);
+ /// Removes the avatar from the profile
+ void removeAvatar();
/// Create or find a direct chat with this user
/*! The resulting chat is returned asynchronously via
* Connection::directChatAvailable()
@@ -150,27 +114,20 @@ public slots:
void unmarkIgnore();
/// Check whether the user is in ignore list
bool isIgnored() const;
+ /// Force loading displayName and avartar url. This is required in
+ /// some cases where the you need to use an user independent of the
+ /// room.
+ void load();
-signals:
- /// \deprecated Use Room::memberListChanged() for member changes
- void nameAboutToChange(QString newName, QString oldName,
- const Quotient::Room* roomContext);
- /// \deprecated Use Room::memberListChanged() for member changes
- void nameChanged(QString newName, QString oldName,
- const Quotient::Room* roomContext);
- /// \deprecated Use Room::memberListChanged() for member changes
- void avatarChanged(Quotient::User* user, const Quotient::Room* roomContext);
-
-private slots: // TODO: remove in 0.7
- /// \deprecated
- void updateName(const QString& newName, const Room* r = nullptr);
- /// \deprecated
- void updateName(const QString&, const QString&, const Room* = nullptr);
- /// \deprecated
- void updateAvatarUrl(const QUrl&, const QUrl&, const Room* = nullptr);
+Q_SIGNALS:
+ void defaultNameChanged();
+ void defaultAvatarChanged();
private:
class Private;
- QScopedPointer<Private> d;
+ ImplPtr<Private> d;
+
+ template <typename SourceT>
+ bool doSetAvatar(SourceT&& source);
};
} // namespace Quotient