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