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
20 changes: 15 additions & 5 deletions dconfig-center/dde-dconfig-daemon/dconfig_global.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@

#pragma once

#include <QFile>

Check warning on line 7 in dconfig-center/dde-dconfig-daemon/dconfig_global.h

View workflow job for this annotation

GitHub Actions / cppcheck

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

Check warning on line 7 in dconfig-center/dde-dconfig-daemon/dconfig_global.h

View workflow job for this annotation

GitHub Actions / static-check / static-check

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

Check warning on line 8 in dconfig-center/dde-dconfig-daemon/dconfig_global.h

View workflow job for this annotation

GitHub Actions / cppcheck

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

Check warning on line 8 in dconfig-center/dde-dconfig-daemon/dconfig_global.h

View workflow job for this annotation

GitHub Actions / static-check / static-check

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

Check warning on line 9 in dconfig-center/dde-dconfig-daemon/dconfig_global.h

View workflow job for this annotation

GitHub Actions / cppcheck

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

Check warning on line 9 in dconfig-center/dde-dconfig-daemon/dconfig_global.h

View workflow job for this annotation

GitHub Actions / static-check / static-check

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

Check warning on line 10 in dconfig-center/dde-dconfig-daemon/dconfig_global.h

View workflow job for this annotation

GitHub Actions / cppcheck

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

Check warning on line 10 in dconfig-center/dde-dconfig-daemon/dconfig_global.h

View workflow job for this annotation

GitHub Actions / static-check / static-check

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

Check warning on line 11 in dconfig-center/dde-dconfig-daemon/dconfig_global.h

View workflow job for this annotation

GitHub Actions / cppcheck

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

Check warning on line 11 in dconfig-center/dde-dconfig-daemon/dconfig_global.h

View workflow job for this annotation

GitHub Actions / static-check / static-check

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

Check warning on line 12 in dconfig-center/dde-dconfig-daemon/dconfig_global.h

View workflow job for this annotation

GitHub Actions / cppcheck

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

Check warning on line 12 in dconfig-center/dde-dconfig-daemon/dconfig_global.h

View workflow job for this annotation

GitHub Actions / static-check / static-check

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

Check warning on line 13 in dconfig-center/dde-dconfig-daemon/dconfig_global.h

View workflow job for this annotation

GitHub Actions / cppcheck

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

Check warning on line 13 in dconfig-center/dde-dconfig-daemon/dconfig_global.h

View workflow job for this annotation

GitHub Actions / static-check / static-check

Include file: <DStandardPaths> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <QLoggingCategory>
#include "helper.hpp"

Expand Down Expand Up @@ -175,15 +176,24 @@
InitFunc m_initFunc;
};

inline QString getProcessNameByPid(const uint pid)

Check warning on line 179 in dconfig-center/dde-dconfig-daemon/dconfig_global.h

View workflow job for this annotation

GitHub Actions / cppcheck

The function 'getProcessNameByPid' is never used.

Check warning on line 179 in dconfig-center/dde-dconfig-daemon/dconfig_global.h

View workflow job for this annotation

GitHub Actions / static-check / static-check

The function 'getProcessNameByPid' is never used.
{
#ifdef Q_OS_LINUX
const QString desc = QString("/proc/%1/cmdline").arg(pid);

QFile file(desc);
if(file.open(QIODevice::ReadOnly)) {
// Prefer /proc/{pid}/exe symlink for process name.
// May fail due to permission (daemon runs as deepin-daemon, target process
// may belong to another user). Fallback to /proc/{pid}/cmdline in that case.
const QString exePath = QFile::symLinkTarget(QString("/proc/%1/exe").arg(pid));
if (!exePath.isEmpty())
return exePath;

// Fallback: /proc/{pid}/cmdline is world-readable (0444)
const QString cmdlinePath = QString("/proc/%1/cmdline").arg(pid);
QFile file(cmdlinePath);
if (file.open(QIODevice::ReadOnly)) {
const QByteArray &name = file.readLine();
return name.split('\0').join(" ").trimmed();
const QString cmd = name.split('\0').join(" ").trimmed();
if (!cmd.isEmpty())
return cmd;
}
#endif // Q_OS_LINUX
return QString::number(pid);
Expand Down
12 changes: 6 additions & 6 deletions dconfig-center/dde-dconfig-daemon/dconfigconn.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -240,15 +240,15 @@ int DSGConfigConn::flags(const QString &key)

QString DSGConfigConn::getAppid() const
{
if (m_appName.isEmpty()) {
if (calledFromDBus()) {
const QString &service = message().service();
if (calledFromDBus()) {
const QString &service = message().service();
if (m_lastService != service) {
Comment thread
18202781743 marked this conversation as resolved.
const_cast<DSGConfigConn *>(this)->m_lastService = service;
const_cast<DSGConfigConn *>(this)->m_appName = getProcessNameByPid(connection().interface()->servicePid(service));
} else {
const_cast<DSGConfigConn *>(this)->m_appName = QString("testappid");
}
return m_appName;
}
return m_appName;
return QString("testappid");
}

bool DSGConfigConn::contains(const QString &key)
Expand Down
2 changes: 1 addition & 1 deletion dconfig-center/dde-dconfig-daemon/dconfigconn.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,5 +72,5 @@ public Q_SLOTS: // METHODS
ConnKey m_key;
DSGConfigResource *m_resource = nullptr;
QString m_appName;
QString m_lastService;
};

Loading