DtkSystemSettings
dtk library for systemsettings.
载入中...
搜索中...
未找到
daccountsmanager.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#include <QObject>
11#include <QSharedPointer>
12#include <QStringList>
13
14DACCOUNTS_BEGIN_NAMESPACE
15class DAccountsUser;
16DACCOUNTS_END_NAMESPACE
17
18using AccountsUserPtr = QSharedPointer<DTK_ACCOUNTS_NAMESPACE::DAccountsUser>;
19using AccountsValidMsg = DTK_ACCOUNTS_NAMESPACE::ValidMsg;
20using DAccountTypes = DTK_ACCOUNTS_NAMESPACE::AccountTypes;
21
22DACCOUNTS_BEGIN_NAMESPACE
23using DCORE_NAMESPACE::DExpected;
24
25class DAccountsManagerPrivate;
26
27class DAccountsManager : public QObject
28{
29 Q_OBJECT
30
31public:
32 explicit DAccountsManager(QObject *parent = nullptr);
33 virtual ~DAccountsManager();
34
35public slots:
36 DExpected<QList<quint64>>
37 userList() const; // TODO:创建或删除 userlist 无法及时刷新,调用 sleep(1) 正常
38 DExpected<AccountsUserPtr> createUser(const QString &name,
39 const QString &fullName,
40 const DAccountTypes &type);
41 DExpected<void> deleteUser(const QString &name, const bool rmFiles);
42 DExpected<AccountsUserPtr> findUserByName(const QString &name);
43 DExpected<AccountsUserPtr> findUserById(const qint64 uid);
44 DExpected<QStringList> groups();
45 DExpected<QStringList> presetGroups(const DAccountTypes &type);
46 DExpected<AccountsValidMsg> isPasswordValid(const QString &password);
47 DExpected<AccountsValidMsg> isUsernameValid(const QString &name);
48
49signals:
50 void UserAdded(const quint64 uid);
51 void UserDeleted(const quint64 uid);
52
53private:
54 QScopedPointer<DAccountsManagerPrivate> d_ptr;
55 Q_DECLARE_PRIVATE(DAccountsManager)
56};
57
58DACCOUNTS_END_NAMESPACE
管理用户账户信息
Definition daccountsmanager.h:28
DExpected< AccountsUserPtr > findUserByName(const QString &name)
使用用户名来寻找用户
DExpected< QStringList > groups()
列出系统中的所有用户组
DExpected< AccountsUserPtr > createUser(const QString &name, const QString &fullName, const DAccountTypes &type)
创建一个新用户
void UserAdded(const quint64 uid)
当添加用户时发送信号
DExpected< AccountsUserPtr > findUserById(const qint64 uid)
使用uid来寻找用户
DExpected< void > deleteUser(const QString &name, const bool rmFiles)
删除一个用户
DExpected< QList< quint64 > > userList() const
列出之前在本地系统中登录过的用户
DExpected< AccountsValidMsg > isPasswordValid(const QString &password)
判断密码是否合法
DExpected< AccountsValidMsg > isUsernameValid(const QString &name)
判断用户名是否合法
void UserDeleted(const quint64 uid)
当用户被删除时发送信号
DAccountsManager(QObject *parent=nullptr)
构造manager对象,并且进行信号的连接
DExpected< QStringList > presetGroups(const DAccountTypes &type)
根据用户类型获取用户的预定义用户组
在daccountstypes.h中定义了一些dtkaccounts模块中所用到的自定义类型。