249 lines
8.0 KiB
Diff
249 lines
8.0 KiB
Diff
From 1113ae6574950d672514621e0f8090d1f1241a72 Mon Sep 17 00:00:00 2001
|
|
From: tanyulong <tanyulong@kylinos.cn>
|
|
Date: Thu, 8 Jul 2021 13:46:27 +0800
|
|
Subject: [PATCH] Fix Group members are not displayed
|
|
|
|
---
|
|
.../account/userinfo/creategroupdialog.cpp | 61 +++++++++++++++++-
|
|
plugins/account/userinfo/creategroupdialog.h | 22 ++++++-
|
|
plugins/account/userinfo/editgroupdialog.cpp | 62 ++++++++++++++++++-
|
|
plugins/account/userinfo/editgroupdialog.h | 19 +++++-
|
|
4 files changed, 155 insertions(+), 9 deletions(-)
|
|
|
|
diff --git a/plugins/account/userinfo/creategroupdialog.cpp b/plugins/account/userinfo/creategroupdialog.cpp
|
|
index 56f7b2c..4507260 100755
|
|
--- a/plugins/account/userinfo/creategroupdialog.cpp
|
|
+++ b/plugins/account/userinfo/creategroupdialog.cpp
|
|
@@ -70,12 +70,67 @@ void CreateGroupDialog::refreshCertainBtnStatus(){
|
|
ui->certainBtn->setEnabled(_nameHasModified || _idHasModified);
|
|
}
|
|
|
|
+UserInfomationss CreateGroupDialog::_acquireUserInfo(QString objpath){
|
|
+ UserInfomationss user;
|
|
+
|
|
+ //默认值
|
|
+ user.current = false;
|
|
+ user.logined = false;
|
|
+ user.autologin = false;
|
|
+
|
|
+ QDBusInterface * iproperty = new QDBusInterface("org.freedesktop.Accounts",
|
|
+ objpath,
|
|
+ "org.freedesktop.DBus.Properties",
|
|
+ QDBusConnection::systemBus());
|
|
+ QDBusReply<QMap<QString, QVariant> > reply = iproperty->call("GetAll", "org.freedesktop.Accounts.User");
|
|
+ if (reply.isValid()){
|
|
+ QMap<QString, QVariant> propertyMap;
|
|
+ propertyMap = reply.value();
|
|
+ user.username = propertyMap.find("UserName").value().toString();
|
|
+ if (user.username == QString(g_get_user_name())) {
|
|
+ user.current = true;
|
|
+ user.logined = true;
|
|
+ }
|
|
+ }
|
|
+ else
|
|
+ qDebug() << "reply failed";
|
|
+
|
|
+ delete iproperty;
|
|
+
|
|
+ return user;
|
|
+}
|
|
+
|
|
void CreateGroupDialog::getUsersList()
|
|
{
|
|
qDebug() << "当前文件 :" << __FILE__ << "当前函数 :" << __FUNCTION__ << "当前行号 :" << __LINE__;
|
|
- UserInfo * userinfo = new UserInfo;
|
|
- QStringList usersList = userinfo->getUsersList();
|
|
-// qDebug() << "CreateGroupDialog::getUsersList" << usersList.at(0) << usersList.at(1);
|
|
+ QStringList allUsers;
|
|
+ sysdispatcher = new SystemDbusDispatcher(this);
|
|
+
|
|
+ QStringList objectpaths = sysdispatcher->list_cached_users();
|
|
+ allUserInfoMap.clear();
|
|
+ //root
|
|
+ if (!getuid()){
|
|
+ UserInfomationss root;
|
|
+ root.username = g_get_user_name();
|
|
+ root.current = true;
|
|
+ root.logined = true;
|
|
+ root.autologin = false;
|
|
+ root.uid = 0;
|
|
+ root.accounttype = ADMINISTRATOR;
|
|
+ // root.iconfile = DEFAULTFACE;
|
|
+ allUserInfoMap.insert(root.username, root);
|
|
+ }
|
|
+ for (QString objectpath : objectpaths){
|
|
+ UserInfomationss user;
|
|
+ user = _acquireUserInfo(objectpath);
|
|
+ allUserInfoMap.insert(user.username, user);
|
|
+ }
|
|
+ for (QVariant tmp : allUserInfoMap.keys()){
|
|
+ allUsers << tmp.toString();
|
|
+
|
|
+ }
|
|
+ QStringList usersList = allUsers;
|
|
+
|
|
for(int i = 0; i < usersList.size(); i++){
|
|
QListWidgetItem * item = new QListWidgetItem(ui->listWidget);
|
|
item->setSizeHint(QSize(ui->listWidget->width(), 36));
|
|
diff --git a/plugins/account/userinfo/creategroupdialog.h b/plugins/account/userinfo/creategroupdialog.h
|
|
index e0432fc..1ca0225 100755
|
|
--- a/plugins/account/userinfo/creategroupdialog.h
|
|
+++ b/plugins/account/userinfo/creategroupdialog.h
|
|
@@ -30,7 +30,22 @@
|
|
#include <QLineEdit>
|
|
#include <QListWidget>
|
|
|
|
-class UserInfo;
|
|
+#include "qtdbus/systemdbusdispatcher.h"
|
|
+
|
|
+typedef struct _UserInfomationss {
|
|
+ QString objpath;
|
|
+ QString username;
|
|
+ QString iconfile;
|
|
+ QString passwd;
|
|
+ int accounttype;
|
|
+ int passwdtype;
|
|
+ bool current;
|
|
+ bool logined;
|
|
+ bool autologin;
|
|
+ bool noPwdLogin;
|
|
+ qint64 uid;
|
|
+}UserInfomationss;
|
|
+
|
|
class ChangeGroupDialog;
|
|
namespace Ui {
|
|
class CreateGroupDialog;
|
|
@@ -62,9 +77,12 @@ private:
|
|
bool _nameHasModified;
|
|
bool _idHasModified;
|
|
bool _boxModified;
|
|
-
|
|
+ QMap<QString, UserInfomationss> allUserInfoMap;
|
|
+ SystemDbusDispatcher * sysdispatcher;
|
|
+
|
|
void setupInit();
|
|
void signalsBind();
|
|
+ UserInfomationss _acquireUserInfo(QString objpath);
|
|
};
|
|
|
|
#endif // CREATEGROUPDIALOG_H
|
|
diff --git a/plugins/account/userinfo/editgroupdialog.cpp b/plugins/account/userinfo/editgroupdialog.cpp
|
|
index a90b9cd..d3971cd 100755
|
|
--- a/plugins/account/userinfo/editgroupdialog.cpp
|
|
+++ b/plugins/account/userinfo/editgroupdialog.cpp
|
|
@@ -73,11 +73,67 @@ void EditGroupDialog::refreshCertainBtnStatus(){
|
|
ui->certainBtn->setEnabled(_nameHasModified || _idHasModified || _boxModified);
|
|
}
|
|
|
|
+UserInfomations EditGroupDialog::_acquireUserInfo(QString objpath){
|
|
+ UserInfomations user;
|
|
+
|
|
+ //默认值
|
|
+ user.current = false;
|
|
+ user.logined = false;
|
|
+ user.autologin = false;
|
|
+
|
|
+ QDBusInterface * iproperty = new QDBusInterface("org.freedesktop.Accounts",
|
|
+ objpath,
|
|
+ "org.freedesktop.DBus.Properties",
|
|
+ QDBusConnection::systemBus());
|
|
+ QDBusReply<QMap<QString, QVariant> > reply = iproperty->call("GetAll", "org.freedesktop.Accounts.User");
|
|
+ if (reply.isValid()){
|
|
+ QMap<QString, QVariant> propertyMap;
|
|
+ propertyMap = reply.value();
|
|
+ user.username = propertyMap.find("UserName").value().toString();
|
|
+ if (user.username == QString(g_get_user_name())) {
|
|
+ user.current = true;
|
|
+ user.logined = true;
|
|
+ }
|
|
+ }
|
|
+ else
|
|
+ qDebug() << "reply failed";
|
|
+
|
|
+ delete iproperty;
|
|
+
|
|
+ return user;
|
|
+}
|
|
+
|
|
+
|
|
void EditGroupDialog::getUsersList(QString usergroup)
|
|
{
|
|
- UserInfo * userinfo = new UserInfo;
|
|
- QStringList usersList = userinfo->getUsersList();
|
|
- qDebug() << "EditGroupDialog::getUsersList";
|
|
+ QStringList usergroupList = usergroup.split(",");
|
|
+ QStringList allUsers;
|
|
+ sysdispatcher = new SystemDbusDispatcher(this);
|
|
+
|
|
+ QStringList objectpaths = sysdispatcher->list_cached_users();
|
|
+ allUserInfoMap.clear();
|
|
+ //root
|
|
+ if (!getuid()){
|
|
+ UserInfomations root;
|
|
+ root.username = g_get_user_name();
|
|
+ root.current = true;
|
|
+ root.logined = true;
|
|
+ root.autologin = false;
|
|
+ root.uid = 0;
|
|
+ root.accounttype = ADMINISTRATOR;
|
|
+ // root.iconfile = DEFAULTFACE;
|
|
+ allUserInfoMap.insert(root.username, root);
|
|
+ }
|
|
+ for (QString objectpath : objectpaths){
|
|
+ UserInfomations user;
|
|
+ user = _acquireUserInfo(objectpath);
|
|
+ allUserInfoMap.insert(user.username, user);
|
|
+ }
|
|
+ for (QVariant tmp : allUserInfoMap.keys()){
|
|
+ allUsers << tmp.toString();
|
|
+
|
|
+ }
|
|
+ QStringList usersList = allUsers;
|
|
QStringList usergroupList = usergroup.split(",");
|
|
|
|
for(int i = 0; i < usersList.size(); i++){
|
|
diff --git a/plugins/account/userinfo/editgroupdialog.h b/plugins/account/userinfo/editgroupdialog.h
|
|
index 9a065fb..b66ea55 100755
|
|
--- a/plugins/account/userinfo/editgroupdialog.h
|
|
+++ b/plugins/account/userinfo/editgroupdialog.h
|
|
@@ -29,8 +29,22 @@
|
|
#include <QRegExpValidator>
|
|
#include <QLineEdit>
|
|
#include <QListWidget>
|
|
+#include "qtdbus/systemdbusdispatcher.h"
|
|
+
|
|
+typedef struct _UserInfomations {
|
|
+ QString objpath;
|
|
+ QString username;
|
|
+ QString iconfile;
|
|
+ QString passwd;
|
|
+ int accounttype;
|
|
+ int passwdtype;
|
|
+ bool current;
|
|
+ bool logined;
|
|
+ bool autologin;
|
|
+ bool noPwdLogin;
|
|
+ qint64 uid;
|
|
+}UserInfomations;
|
|
|
|
-class UserInfo;
|
|
class ChangeGroupDialog;
|
|
namespace Ui {
|
|
class EditGroupDialog;
|
|
@@ -63,9 +77,12 @@ private:
|
|
bool _boxModified;
|
|
QString userGroup;
|
|
QString groupId;
|
|
+ QMap<QString, UserInfomations> allUserInfoMap;
|
|
+ SystemDbusDispatcher * sysdispatcher;
|
|
|
|
void setupInit();
|
|
void signalsBind();
|
|
+ UserInfomations _acquireUserInfo(QString objpath);
|
|
|
|
signals:
|
|
void needRefresh();
|
|
--
|
|
2.23.0
|
|
|