DtkSystemSettings  1.0.3
dtk library for systemsettings.
daccountsuser.h
浏览该文件的文档.
1// SPDX-FileCopyrightText: 2022 Uniontech Software Technology Co., Ltd.
2//
3// SPDX-License-Identifier: LGPL-3.0-or-later
4
5#pragma once
6
7#include "daccountstypes.h"
8#include <QDateTime>
9#include <QUrl>
10#include <QObject>
11#include <DExpected>
12using AccountsReminderInfo = DTK_ACCOUNTS_NAMESPACE::ReminderInfo;
13using AccountsPasswdExpirInfo = DTK_ACCOUNTS_NAMESPACE::PasswdExpirInfo;
14DACCOUNTS_BEGIN_NAMESPACE
15
16DCORE_USE_NAMESPACE
17
18class DAccountsUserPrivate;
19
20class DAccountsUser : public QObject
21{
22 Q_OBJECT
23
24public:
25 virtual ~DAccountsUser();
26
27 Q_PROPERTY(AccountTypes accountType READ accountType)
28 Q_PROPERTY(bool automaticLogin READ automaticLogin WRITE setAutomaticLogin NOTIFY automaticLoginChanged)
29 Q_PROPERTY(QString fullName READ fullName WRITE setFullName)
30 Q_PROPERTY(quint64 GID READ GID)
31 Q_PROPERTY(quint64 UID READ UID)
32 Q_PROPERTY(QStringList groups READ groups WRITE setGroups NOTIFY groupsChanged)
33 Q_PROPERTY(QList<QByteArray> layoutList READ layoutList WRITE setLayoutList NOTIFY layoutListChanged)
34 Q_PROPERTY(QString homeDir READ homeDir WRITE setHomeDir)
35 Q_PROPERTY(QList<QByteArray> iconFileList READ iconFileList NOTIFY iconFileListChanged)
36 Q_PROPERTY(QUrl iconFile READ iconFile WRITE setIconFile NOTIFY iconFileChanged)
37 Q_PROPERTY(QByteArray layout READ layout WRITE setLayout NOTIFY layoutChanged)
38 Q_PROPERTY(QByteArray locale READ locale WRITE setLocale NOTIFY localeChanged)
39 Q_PROPERTY(bool locked READ locked WRITE setLocked NOTIFY lockedChanged)
40 Q_PROPERTY(qint32 maxPasswordAge READ maxPasswordAge WRITE setMaxPasswordAge NOTIFY maxPasswordAgeChanged)
41 Q_PROPERTY(QString passwordHint READ passwordHint WRITE setPasswordHint NOTIFY passwordHintChanged)
42 Q_PROPERTY(QDateTime passwordLastChange READ passwordLastChange)
43 Q_PROPERTY(PasswdStatus passwordStatus READ passwordStatus)
44 Q_PROPERTY(QString shell READ shell WRITE setShell)
45 Q_PROPERTY(QByteArray UUID READ UUID)
46 Q_PROPERTY(QByteArray userName READ userName)
47 Q_PROPERTY(bool noPasswdLogin READ noPasswdLogin WRITE setNopasswdLogin NOTIFY noPasswdLoginChanged)
48 Q_PROPERTY(QDateTime loginTime READ loginTime)
49 Q_PROPERTY(QDateTime createdTime READ createdTime)
50
51 AccountTypes accountType() const;
52 bool automaticLogin() const;
53 QString fullName() const;
54 quint64 GID() const;
55 quint64 UID() const;
56 QStringList groups() const;
57 QList<QByteArray> layoutList() const;
58 QString homeDir() const;
59 QList<QByteArray> iconFileList() const;
60 QByteArray iconFile() const;
61 QByteArray layout() const;
62 QByteArray locale() const;
63 bool locked() const;
64 qint32 maxPasswordAge() const;
65 QString passwordHint() const;
66 QDateTime passwordLastChange() const;
67 PasswdStatus passwordStatus() const;
68 QString shell() const;
69 QByteArray UUID() const;
70 QByteArray userName() const;
71 bool noPasswdLogin() const;
72 QDateTime loginTime() const;
73 QDateTime createdTime() const;
74
75public slots:
76
77 DExpected<void> setAutomaticLogin(const bool enabled);
78 DExpected<void> setFullName(const QString &newfullname);
79 DExpected<void> setGroups(const QStringList &newgroups);
80 DExpected<void> setLayoutList(const QList<QByteArray> &newlayouts);
81 DExpected<void> setHomeDir(const QString &newhomedir);
82 DExpected<void> setIconFile(const QUrl &newiconURL);
83 DExpected<void> setLayout(const QByteArray &newlayout);
84 DExpected<void> setLocale(const QByteArray &newlocale); // TODO:这个方法只能由控制中心调用
85 DExpected<void> setLocked(const bool locked);
86 DExpected<void> setMaxPasswordAge(const int newndays);
87 DExpected<void> setPassword(const QByteArray &newpassword);
88 DExpected<void> setPasswordHint(const QString &newpasswordhint);
89 DExpected<void> setShell(const QString &newshellpath);
90 DExpected<void> setNopasswdLogin(const bool enabled);
91
92 DExpected<void> addGroup(const QString &group);
93 DExpected<void> deleteGroup(const QString &group);
94 DExpected<void> deleteIconFile(const QUrl &iconURL);
95 DExpected<bool> isPasswordExpired() const;
96 DExpected<AccountsReminderInfo> getReminderInfo() const;
97 DExpected<AccountsPasswdExpirInfo> passwordExpirationInfo(qint64 &dayLeft) const;
98
99signals:
100 void automaticLoginChanged(const bool enabled);
101 void groupsChanged(const QStringList &list);
102 void layoutListChanged(const QList<QByteArray> &list);
103 void iconFileListChanged(const QList<QByteArray> &list);
104 void iconFileChanged(const QUrl &url);
105 void layoutChanged(const QByteArray &layout);
106 void localeChanged(const QByteArray &locale);
107 void lockedChanged(const bool locked);
108 void maxPasswordAgeChanged(const qint32 age);
109 void passwordHintChanged(const QString &hint);
110 void noPasswdLoginChanged(const bool enabled);
111
112private:
113 explicit DAccountsUser(const quint64 uid, QObject *parent = nullptr);
114 QScopedPointer<DAccountsUserPrivate> d_ptr;
115 friend class DAccountsManager;
116 Q_DECLARE_PRIVATE(DAccountsUser)
117 Q_DISABLE_COPY(DAccountsUser)
118};
119
120DACCOUNTS_END_NAMESPACE
管理用户账户信息
Definition: daccountsmanager.h:26
用户属性相关信息的封装类
Definition: daccountsuser.h:21
在daccountstypes.h中定义了一些dtkaccounts模块中所用到的自定义类型。
PasswdStatus
密码状态
Definition: daccountstypes.h:16
AccountTypes
账户类型
Definition: daccountstypes.h:14