matrixion/src/ui/UserProfile.h

72 lines
2 KiB
C
Raw Normal View History

2020-05-17 16:34:47 +03:00
#pragma once
#include <QObject>
#include <QString>
2020-05-27 11:49:26 +03:00
#include <QVector>
2020-05-17 16:34:47 +03:00
2020-05-22 08:47:02 +03:00
#include "MatrixClient.h"
2020-05-27 11:49:26 +03:00
2020-07-01 15:17:10 +03:00
class DeviceInfo;
2020-05-17 16:34:47 +03:00
class UserProfile : public QObject
{
Q_OBJECT
2020-05-27 11:49:26 +03:00
Q_PROPERTY(QString userId READ getUserId WRITE setUserId NOTIFY userIdChanged)
2020-07-01 15:17:10 +03:00
Q_PROPERTY(std::vector<DeviceInfo> deviceList READ getDeviceList NOTIFY deviceListUpdated)
2020-05-17 16:34:47 +03:00
public:
2020-05-22 08:47:02 +03:00
// constructor
2020-05-17 16:34:47 +03:00
explicit UserProfile(QObject *parent = 0);
2020-05-22 08:47:02 +03:00
// getters
2020-07-01 15:17:10 +03:00
std::vector<DeviceInfo> getDeviceList();
2020-05-22 08:47:02 +03:00
QString getUserId();
// setters
void setUserId(const QString &userId);
2020-05-17 16:34:47 +03:00
2020-07-01 15:17:10 +03:00
enum Status
{
VERIFIED,
UNVERIFIED,
BLOCKED
};
Q_ENUM(Status)
void fetchDeviceList(const QString &userID);
2020-06-26 01:54:42 +03:00
Q_INVOKABLE void banUser();
// Q_INVOKABLE void ignoreUser();
Q_INVOKABLE void kickUser();
Q_INVOKABLE void startChat();
2020-05-17 16:34:47 +03:00
signals:
2020-05-27 11:49:26 +03:00
void userIdChanged();
2020-05-22 08:47:02 +03:00
void deviceListUpdated();
2020-07-01 15:17:10 +03:00
void updateDeviceList();
void appendDeviceList(const QString device_id,
const QString device_naem,
const UserProfile::Status verification_status);
2020-05-17 16:34:47 +03:00
private:
2020-07-01 15:17:10 +03:00
std::vector<DeviceInfo> deviceList;
2020-05-22 08:47:02 +03:00
QString userId;
2020-07-01 15:17:10 +03:00
std::optional<std::string> cross_verified;
2020-06-28 18:31:34 +03:00
void callback_fn(const mtx::responses::QueryKeys &res,
mtx::http::RequestErr err,
2020-07-01 15:17:10 +03:00
std::string user_id,
std::optional<std::vector<std::string>> cross_verified);
};
class DeviceInfo
{
public:
DeviceInfo(const QString deviceID,
const QString displayName,
UserProfile::Status verification_status_)
: device_id(deviceID)
, display_name(displayName)
, verification_status(verification_status_)
{}
QString device_id;
QString display_name;
UserProfile::Status verification_status;
2020-05-17 16:34:47 +03:00
};