Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// Copyright (C) 2019 ~ 2026 Uniontech Software Technology Co.,Ltd
// SPDX-FileCopyrightText: 2019 ~ 2023 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: GPL-3.0-or-later
Expand Down Expand Up @@ -32,8 +33,13 @@ bool ControlInterface::getUserAuthorPasswd()
#ifdef DISABLE_POLKIT
return true;
#endif
if (connection().interface()->serviceUid(message().service()).value() == 0) {
return true;
auto uidReply = connection().interface()->serviceUid(message().service());
if (uidReply.isValid()) {
if (uidReply.value() == 0) {
return true;
}
} else {
qWarning() << "D-Bus serviceUid query failed for" << message().service() << ":" << uidReply.error().message();
}

Authority::Result result = Authority::instance()->checkAuthorizationSync("com.deepin.deepin-devicemanager.checkAuthentication",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
// Copyright (C) 2019 ~ 2026 Uniontech Software Technology Co.,Ltd
// SPDX-FileCopyrightText: 2019 ~ 2023 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: GPL-3.0-or-later

#include "deviceinterface.h"
#include "deviceinfomanager.h"
#include "mainjob.h"

Check warning on line 8 in deepin-devicemanager-server/deepin-deviceinfo/src/loadinfo/deviceinterface.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: "mainjob.h" not found.

Check warning on line 8 in deepin-devicemanager-server/deepin-deviceinfo/src/loadinfo/deviceinterface.cpp

View workflow job for this annotation

GitHub Actions / static-check / static-check

Include file: "mainjob.h" not found.

#include <QDBusConnection>

Check warning on line 10 in deepin-devicemanager-server/deepin-deviceinfo/src/loadinfo/deviceinterface.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <QDBusConnection> not found. Please note: Cppcheck does not need standard library headers to get proper results.

Check warning on line 10 in deepin-devicemanager-server/deepin-deviceinfo/src/loadinfo/deviceinterface.cpp

View workflow job for this annotation

GitHub Actions / static-check / static-check

Include file: <QDBusConnection> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <QDBusConnectionInterface>

Check warning on line 11 in deepin-devicemanager-server/deepin-deviceinfo/src/loadinfo/deviceinterface.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <QDBusConnectionInterface> not found. Please note: Cppcheck does not need standard library headers to get proper results.

Check warning on line 11 in deepin-devicemanager-server/deepin-deviceinfo/src/loadinfo/deviceinterface.cpp

View workflow job for this annotation

GitHub Actions / static-check / static-check

Include file: <QDBusConnectionInterface> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <QDBusMessage>

Check warning on line 12 in deepin-devicemanager-server/deepin-deviceinfo/src/loadinfo/deviceinterface.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <QDBusMessage> not found. Please note: Cppcheck does not need standard library headers to get proper results.

Check warning on line 12 in deepin-devicemanager-server/deepin-deviceinfo/src/loadinfo/deviceinterface.cpp

View workflow job for this annotation

GitHub Actions / static-check / static-check

Include file: <QDBusMessage> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <QProcess>

Check warning on line 13 in deepin-devicemanager-server/deepin-deviceinfo/src/loadinfo/deviceinterface.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <QProcess> not found. Please note: Cppcheck does not need standard library headers to get proper results.

Check warning on line 13 in deepin-devicemanager-server/deepin-deviceinfo/src/loadinfo/deviceinterface.cpp

View workflow job for this annotation

GitHub Actions / static-check / static-check

Include file: <QProcess> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <QDebug>

Check warning on line 14 in deepin-devicemanager-server/deepin-deviceinfo/src/loadinfo/deviceinterface.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <QDebug> not found. Please note: Cppcheck does not need standard library headers to get proper results.

Check warning on line 14 in deepin-devicemanager-server/deepin-deviceinfo/src/loadinfo/deviceinterface.cpp

View workflow job for this annotation

GitHub Actions / static-check / static-check

Include file: <QDebug> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <QFile>
#include <QRegularExpression>

Expand All @@ -23,8 +25,18 @@
#ifdef DISABLE_POLKIT
return true;
#endif
const QString service = message().service();
auto uidReply = connection().interface()->serviceUid(service);
if (uidReply.isValid()) {
if (uidReply.value() == 0) {
return true;
}
} else {
qWarning() << "D-Bus serviceUid query failed for" << service << ":" << uidReply.error().message();
}

Authority::Result result = Authority::instance()->checkAuthorizationSync("com.deepin.deepin-devicemanager.checkAuthentication",
SystemBusNameSubject(message().service()),
SystemBusNameSubject(service),
Authority::AllowUserInteraction);
return result == Authority::Yes;
}
Expand Down Expand Up @@ -87,6 +99,10 @@

QString DeviceInterface::getInfo(const QString &key)
{
if (!getUserAuthorPasswd()) {
return {};
}

// 不能返回用常引用
if ("is_server_running" != key) {
return DeviceInfoManager::getInstance()->getInfo(key);
Expand All @@ -99,11 +115,19 @@

void DeviceInterface::refreshInfo()
{
if (!getUserAuthorPasswd()) {
return;
}

emit sigUpdate();
}

void DeviceInterface::setMonitorDeviceFlag(bool flag)
{
if (!getUserAuthorPasswd()) {
return;
}

MainJob *parentMainJob = dynamic_cast<MainJob *>(parent());
if (parentMainJob != nullptr) {
parentMainJob->setWorkingFlag(flag);
Expand All @@ -112,6 +136,10 @@

QString DeviceInterface::getGpuInfoForFTDTM()
{
if (!getUserAuthorPasswd()) {
return {};
}

static QString gpuMemInfo { "" };
if (gpuMemInfo.isEmpty()) {
QMap<QString, QString> mapInfo;
Expand Down
Loading