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
51 changes: 19 additions & 32 deletions deepin-devicemanager-server/customgpuinfo/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,56 +51,43 @@ bool getGpuBaseInfo(QMap<QString, QString> &mapInfo)

bool getGpuMemInfoForFTDTM(QMap<QString, QString> &mapInfo)
{
const QString filePath = "/sys/kernel/debug/gc/meminfo";
const QString filePath = "/sys/kernel/debug/gc/total_mem";
QString totalValue;
bool foundTotal = false;

QFile file(filePath);
if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) {
qCritical() << "Error opening /sys/kernel/debug/gc/meminfo:" << file.errorString();
qCritical() << "Error opening /sys/kernel/debug/gc/total_mem:" << file.errorString();
return false;
}

QString content = QString::fromUtf8(file.readAll());
file.close();

if (content.isEmpty()) {
qCritical() << "Error: /sys/kernel/debug/gc/meminfo File is empty!";
qCritical() << "Error: /sys/kernel/debug/gc/total_mem File is empty!";
return false;
}

QRegularExpression system0Regex(R"(POOL SYSTEM0:*(.*?)POOL VIRTUAL:)",
QRegularExpression::DotMatchesEverythingOption);
QRegularExpressionMatch system0Match = system0Regex.match(content);
QRegularExpression regex(R"((\d+(?:\.\d+)?)\s*\(?(MB|GB|KB|B)\)?)",
QRegularExpression::CaseInsensitiveOption);
QRegularExpressionMatch memInfoMatch = regex.match(content);

if (!system0Match.hasMatch()) {
qCritical() << "Error: Failed to find SYSTEM0 section";
if (!memInfoMatch.hasMatch()) {
qCritical() << "Error: Failed to find memory info";
return false;
}

QString system0Content = system0Match.captured(1);
QRegularExpression totalRegex(R"(Total\s*:\s*(\d+)\s+B)");
QRegularExpressionMatch totalMatch = totalRegex.match(system0Content);
if (totalMatch.hasMatch()) {
totalValue = totalMatch.captured(1);
foundTotal = true;
}

if (!foundTotal || totalValue.isEmpty()) {
qCritical() << "Error: Failed to find Total value in SYSTEM0 content";
return false;
}

bool ok;
quint64 memSize = totalValue.trimmed().toULong(&ok, 10);
if (ok && memSize >= 1048576) {
memSize /= 1048576;
auto curSize = memSize / 1024.0;
if (curSize >= 1) {
totalValue = QString::number(curSize) + "GB";
} else {
totalValue = QString::number(memSize) + "MB";
}
double value = memInfoMatch.captured(1).toDouble();
QString unit = memInfoMatch.captured(2).toUpper();

if (unit == "MB") {
totalValue = QString("%1GB").arg(value / 1024.0, 0, 'f', 2);
} else if (unit == "GB") {
totalValue = QString("%1GB").arg(value, 0, 'f', 2);
} else if (unit == "KB") {
totalValue = QString("%1GB").arg(value / (1024.0 * 1024.0), 0, 'f', 2);
} else if (unit == "B") {
totalValue = QString("%1GB").arg(value / (1024.0 * 1024.0 * 1024.0), 0, 'f', 2);
}

mapInfo.insert(kGraphicsMemory, totalValue);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,12 @@
struct ifreq ifr;
struct ethtool_wolinfo wolinfo;
memset(&ifr, 0, sizeof(ifr));
strncpy(ifr.ifr_name, logicalName.toStdString().c_str(), sizeof(logicalName.toStdString().c_str()));
memset(&wolinfo, 0, sizeof(wolinfo));

QByteArray nameBytes = logicalName.toLocal8Bit();
strncpy(ifr.ifr_name, nameBytes.constData(), IFNAMSIZ - 1);
ifr.ifr_name[IFNAMSIZ - 1] = '\0';

wolinfo.cmd = ETHTOOL_GWOL;
ifr.ifr_data = reinterpret_cast<char *>(&wolinfo);
if (0 != ioctl(fd, SIOCETHTOOL, &ifr)) {
Expand Down Expand Up @@ -161,10 +166,15 @@
struct ifreq ifr;
struct ethtool_wolinfo wolinfo;
memset(&ifr, 0, sizeof(ifr));
strncpy(ifr.ifr_name, logicalName.toStdString().c_str(), sizeof(logicalName.toStdString().c_str()));
memset(&wolinfo, 0, sizeof(wolinfo));

QByteArray nameBytes = logicalName.toLocal8Bit();
strncpy(ifr.ifr_name, nameBytes.constData(), IFNAMSIZ - 1);
ifr.ifr_name[IFNAMSIZ - 1] = '\0';

wolinfo.cmd = ETHTOOL_SWOL;
if (open)
wolinfo.wolopts = 0 | WAKE_MAGIC;

Check warning on line 177 in deepin-devicemanager-server/deepin-devicecontrol/src/wakecontrol/wakeuputils.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Operator '|' with one operand equal to zero is redundant.
else
wolinfo.wolopts = 0;
ifr.ifr_data = reinterpret_cast<char *>(&wolinfo);
Expand Down
10 changes: 5 additions & 5 deletions deepin-devicemanager/src/DeviceManager/DeviceInput.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@

using namespace DDLog;

QStringList DeviceInput::m_supportInterfaces= {"PS/2", "Bluetooth", "I2C"};

DeviceInput::DeviceInput()
: DeviceBaseInfo()
, m_Model("")
Expand Down Expand Up @@ -496,11 +498,9 @@ bool DeviceInput::available()
// qCDebug(appLog) << "driver is empty";
m_Available = false;
}
if ("PS/2" == m_Interface || "Bluetooth" == m_Interface || "I2C" == m_Interface) {
// qCDebug(appLog) << "interface is PS/2 or Bluetooth";
m_Available = true;
}
// qCDebug(appLog) << "available end";

m_Available = m_supportInterfaces.contains(m_Interface, Qt::CaseInsensitive);

return m_forcedDisplay ? m_forcedDisplay : m_Available;
}

Expand Down
2 changes: 2 additions & 0 deletions deepin-devicemanager/src/DeviceManager/DeviceInput.h
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,8 @@ class DeviceInput : public DeviceBaseInfo
bool m_wakeupChanged = true; //<! 记录鼠标的唤醒状态

QString m_keysToPairedDevice; //<! 【用来标识蓝牙键盘】

static QStringList m_supportInterfaces; //<! 【支持的所有蓝牙接口】
};

#endif // DEVICEINPUT_H
21 changes: 21 additions & 0 deletions deepin-devicemanager/src/DeviceManager/DeviceMonitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,14 @@
}
}

if (!Common::isHwPlatform()) {
QString monitorName = getMonitorNameFromEdid(edid);
if (!m_Model.isEmpty() && !monitorName.isEmpty() && monitorName != "Unknown Monitor") {
if (!m_Model.contains(monitorName))
return false;
}
}

// 判断该显示器设备是否已经设置过从xrandr获取的消息
if (!m_Interface.isEmpty()) {
qCDebug(appLog) << "Interface is not empty, checking current resolution";
Expand Down Expand Up @@ -378,6 +386,9 @@
QString DeviceMonitor::subTitle()
{
// qCDebug(appLog) << "Getting monitor subtitle";
if (Common::specialComType >= 1) {
m_Name.clear();
}
return m_Name;
}

Expand Down Expand Up @@ -626,7 +637,17 @@
return true;
}

QString DeviceMonitor::getMonitorNameFromEdid(const QString &edid)
{
EDIDParser edidParse;
QString errormsg;
if (!edidParse.setEdid(edid, errormsg))
return "";

return edidParse.monitorName();
}

QMap<QString, QStringList> DeviceMonitor::getMonitorResolutionMap(QString rawText, QString key, bool round)

Check warning on line 650 in deepin-devicemanager/src/DeviceManager/DeviceMonitor.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Parameter 'rawText' is passed by value. It could be passed as a const reference which is usually faster and recommended in C++.
{
QMap<QString, QStringList> monitorResolutionMap;

Expand Down
2 changes: 2 additions & 0 deletions deepin-devicemanager/src/DeviceManager/DeviceMonitor.h
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,8 @@ class DeviceMonitor : public DeviceBaseInfo
*/
bool caculateScreenSize(const QString &edid);

QString getMonitorNameFromEdid(const QString &edid);

/**
* @brief getMonitorResolutionMap:从xrandr字符串获取格式化
* @param rawText:原始xrandr输出字符串
Expand Down
3 changes: 3 additions & 0 deletions deepin-devicemanager/src/DeviceManager/DeviceNetwork.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,9 @@ bool DeviceNetwork::setInfoFromHwinfo(const QMap<QString, QString> &mapInfo)
// 判断是否是无线网卡
setIsWireless(mapInfo["SysFS ID"]);

if (mapInfo.contains("Device")) {
m_Name = mapInfo["Device"];
}
return true;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,13 +133,13 @@ DBusDriverInterface::~DBusDriverInterface()
qCDebug(appLog) << "DBusDriverInterface destructor";
}

void DBusDriverInterface::slotProcessChange(qint32 value, QString detail)
void DBusDriverInterface::slotProcessChange(qint32 value, const QString &detail)
{
qCDebug(appLog) << "DBusDriverInterface::slotProcessChange";
emit processChange(value, detail);
}

void DBusDriverInterface::slotProcessEnd(bool success, QString msg)
void DBusDriverInterface::slotProcessEnd(bool success, const QString &msg)
{
qCDebug(appLog) << "DBusDriverInterface::slotProcessEnd";
if (success) {
Expand All @@ -157,7 +157,7 @@ void DBusDriverInterface::slotCallFinished(QDBusPendingCallWatcher *watcher)
watcher->deleteLater();
}

void DBusDriverInterface::slotDownloadProgressChanged(QStringList msg)
void DBusDriverInterface::slotDownloadProgressChanged(const QStringList &msg)
{
qCDebug(appLog) << "DBusDriverInterface::slotDownloadProgressChanged";
emit downloadProgressChanged(msg);
Expand Down
6 changes: 3 additions & 3 deletions deepin-devicemanager/src/DriverControl/DBusDriverInterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -123,13 +123,13 @@ private slots:
* @param value 当前处理的进度
* @param detail 发送过来的时时信息
*/
void slotProcessChange(qint32 value, QString detail);
void slotProcessChange(qint32 value, const QString &detail);

/**
* @brief slotProcessEnd 接收后台结束信号
* @param success
*/
void slotProcessEnd(bool success, QString msg);
void slotProcessEnd(bool success, const QString &msg);

/**
* @brief slotCallFinished 更新结束结束的回调
Expand All @@ -139,7 +139,7 @@ private slots:
/**
* @brief slotDownloadProgressChanged 驱动下载时回调,返回驱动下载进度、速度、已下载大小信息
*/
void slotDownloadProgressChanged(QStringList msg);
void slotDownloadProgressChanged(const QStringList &msg);

/**
* @brief slotDownloadFinished 驱动下载完成
Expand Down
2 changes: 1 addition & 1 deletion deepin-devicemanager/src/DriverControl/DriverScanner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@
}
}

void DriverScanner::setDriverList(QList<DriverInfo *> lstInfo)
void DriverScanner::setDriverList(const QList<DriverInfo *> &lstInfo)

Check warning on line 89 in deepin-devicemanager/src/DriverControl/DriverScanner.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

The function 'setDriverList' is never used.
{
qCDebug(appLog) << "Set driver list with" << lstInfo.size() << "items";
m_ListDriverInfo = lstInfo;
Expand Down
2 changes: 1 addition & 1 deletion deepin-devicemanager/src/DriverControl/DriverScanner.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class DriverScanner : public QThread
* @brief setDriverList
* @param lstInfo
*/
void setDriverList(QList<DriverInfo *> lstInfo);
void setDriverList(const QList<DriverInfo *> &lstInfo);

signals:
void scanInfo(const QString &info, int progress);
Expand Down
8 changes: 5 additions & 3 deletions deepin-devicemanager/src/GenerateDevice/CmdTool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ QString CmdTool::loadOemTomlFileName(const QMap<QString, QString> &mapInfo)
return QString();
}

bool CmdTool::parseOemTomlInfo(const QString filename)
bool CmdTool::parseOemTomlInfo(const QString &filename)
{
qCInfo(appLog) << "CmdTool::parseOemTomlInfo start, filename:" << filename;
bool tomlFileRead = false;
Expand Down Expand Up @@ -695,11 +695,13 @@ void CmdTool::getMulHwinfoInfo(const QString &info)
}
QMap<QString, QString> mapInfo;
getMapInfoFromHwinfo(item, mapInfo);
if (mapInfo["Hardware Class"] == "sound" || (mapInfo["Device"].contains("USB Audio") && mapInfo["Device"].contains("snd-usb-audio"))) {
if (mapInfo["Hardware Class"] == "sound"
|| (mapInfo["Device"].contains("USB Audio") && mapInfo["Device"].contains("snd-usb-audio"))
|| mapInfo["Driver"].contains("snd-usb-audio")) {
qCDebug(appLog) << "Found sound device.";
// mapInfo["Device"].contains("USB Audio") 是为了处理未识别的USB声卡 Bug-118773
addMapInfo("hwinfo_sound", mapInfo);
} else if (mapInfo["Hardware Class"].contains("network")) {
} else if (mapInfo["Hardware Class"].contains("network") || mapInfo["Device"].toUpper().contains("WI-FI")) {
qCDebug(appLog) << "Found network device.";
addMapInfo("hwinfo_network", mapInfo);
} else if ("keyboard" == mapInfo["Hardware Class"]) {
Expand Down
2 changes: 1 addition & 1 deletion deepin-devicemanager/src/GenerateDevice/CmdTool.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ class CmdTool
/**
* @brief parseOemTomlInfo: 解析并加载厂商适配信息
*/
bool parseOemTomlInfo(const QString filename);
bool parseOemTomlInfo(const QString &filename);

private:

Expand Down
2 changes: 1 addition & 1 deletion deepin-devicemanager/src/GenerateDevice/GetInfoPool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ using namespace DDLog;

static QMutex mutex;

CmdTask::CmdTask(QString key, QString file, QString info, GetInfoPool *parent)
CmdTask::CmdTask(const QString &key, const QString &file, const QString &info, GetInfoPool *parent)
: m_Key(key)
, m_File(file)
, m_Info(info)
Expand Down
4 changes: 2 additions & 2 deletions deepin-devicemanager/src/GenerateDevice/GetInfoPool.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ class CmdTask: public QObject, public QRunnable
{
Q_OBJECT
public:
CmdTask(QString key, QString file, QString info, GetInfoPool *parent);
~CmdTask();
CmdTask(const QString &key, const QString &file, const QString &info, GetInfoPool *parent);
~CmdTask() override;
protected:
void run() override;

Expand Down
2 changes: 1 addition & 1 deletion deepin-devicemanager/src/GenerateDevice/LoadInfoThread.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class LoadInfoThread : public QThread
Q_OBJECT
public:
LoadInfoThread();
~LoadInfoThread();
~LoadInfoThread() override;

/**
* @brief setFramework:设置架构
Expand Down
2 changes: 1 addition & 1 deletion deepin-devicemanager/src/Page/DeviceWidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class DeviceWidget : public DWidget
Q_OBJECT
public:
explicit DeviceWidget(QWidget *parent = nullptr);
~DeviceWidget();
~DeviceWidget() override;

/**
* @brief updateListView:更新ListView
Expand Down
2 changes: 1 addition & 1 deletion deepin-devicemanager/src/Page/MainWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -533,7 +533,7 @@ void MainWindow::refreshDataBase()
}
}

void MainWindow::slotSetPage(QString page)
void MainWindow::slotSetPage(const QString &page)
{
qCDebug(appLog) << "MainWindow::slotSetPage page:" << page;
if ("driver" == page) {
Expand Down
2 changes: 1 addition & 1 deletion deepin-devicemanager/src/Page/MainWindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ private slots:
* @brief slotSetPage
* @param page
*/
void slotSetPage(QString page);
void slotSetPage(const QString &page);

/**
* @brief loadingFinishSlot:加载设备信息结束 槽
Expand Down
7 changes: 3 additions & 4 deletions deepin-devicemanager/src/Page/PageMultiInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,12 +100,11 @@ void PageMultiInfo::updateInfo(const QList<DeviceBaseInfo *> &lst)
mp_Table->setFixedHeight(TABLE_HEIGHT);
mp_Table->updateTable(m_deviceList, m_menuControlList);
if (Common::specialComType >= 1) {
if (mp_Label->text() == tr("Storage") || mp_Label->text() == tr("Memory")) {
if (mp_Label->text() == tr("Storage") || mp_Label->text() == tr("Memory") || mp_Label->text() == tr("Monitor")) {
mp_Table->setVisible(false);
mp_Table->setFixedHeight(0);
}
}

// 更新详细信息
mp_Detail->showDeviceInfo(lst);
}
Expand Down Expand Up @@ -152,7 +151,7 @@ void PageMultiInfo::resizeEvent(QResizeEvent *e)
if (Common::specialComType <= 0) {
mp_Table->updateTable(m_deviceList, m_menuControlList, true, (LEAST_PAGE_HEIGHT - curHeight) / TREE_ROW_HEIGHT + 1);
} else {
if (mp_Label->text() != tr("Storage") && mp_Label->text() != tr("Memory"))
if (mp_Label->text() != tr("Storage") && mp_Label->text() != tr("Memory") && mp_Label->text() != tr("Monitor"))
mp_Table->updateTable(m_deviceList, m_menuControlList, true, (LEAST_PAGE_HEIGHT - curHeight) / TREE_ROW_HEIGHT + 1);
}
} else {
Expand All @@ -161,7 +160,7 @@ void PageMultiInfo::resizeEvent(QResizeEvent *e)
if (Common::specialComType <= 0) {
mp_Table->updateTable(m_deviceList, m_menuControlList, true, 0);
} else {
if (mp_Label->text() != tr("Storage") && mp_Label->text() != tr("Memory"))
if (mp_Label->text() != tr("Storage") && mp_Label->text() != tr("Memory") && mp_Label->text() != tr("Monitor"))
mp_Table->updateTable(m_deviceList, m_menuControlList, true, 0);
}
}
Expand Down
Loading