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
Expand Up @@ -9,12 +9,13 @@
#include <QStringList>
#include <QMap>
#include <QFile>
#include <QProcess>

Check warning on line 12 in deepin-devicemanager-server/deepin-devicecontrol/src/enablecontrol/enableutils.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.
#include <QCryptographicHash>

Check warning on line 13 in deepin-devicemanager-server/deepin-devicecontrol/src/enablecontrol/enableutils.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

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

Check warning on line 14 in deepin-devicemanager-server/deepin-devicecontrol/src/enablecontrol/enableutils.cpp

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.
#include <QDebug>

Check warning on line 15 in deepin-devicemanager-server/deepin-devicecontrol/src/enablecontrol/enableutils.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.

#include <net/if.h>

Check warning on line 17 in deepin-devicemanager-server/deepin-devicecontrol/src/enablecontrol/enableutils.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <net/if.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <sys/ioctl.h>

Check warning on line 18 in deepin-devicemanager-server/deepin-devicecontrol/src/enablecontrol/enableutils.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <sys/ioctl.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <unistd.h>

using namespace DDLog;
Expand Down Expand Up @@ -154,34 +155,51 @@
bool EnableUtils::ioctlOperateNetworkLogicalName(const QString &logicalName, bool enable)
{
qCDebug(appLog) << "Performing ioctl operation on network interface:" << logicalName << "enable:" << enable;
// 1. 通过ioctl禁用
int fd = socket(AF_INET, SOCK_STREAM, 0);
if (fd < 0)
return false;
struct ifreq ifr;
strncpy(ifr.ifr_name, logicalName.toStdString().c_str(),IFNAMSIZ);
ifr.ifr_name[IFNAMSIZ - 1] = '\0';
short flag;
if (enable) {
flag = IFF_UP | IFF_PROMISC;
} else {
flag = ~(IFF_UP | IFF_PROMISC);
}
// 先获取标识
if (ioctl(fd, SIOCGIFFLAGS, &ifr) < 0) {
close(fd);
return false;
}
// 获取后重新设置标识
if (enable) {
ifr.ifr_ifru.ifru_flags |= flag;
if (logicalName.startsWith("wlan") || logicalName.startsWith("wlp")) { // Wireless LAN
QString cmd = QString("rfkill %1 $(rfkill list | grep -A 2 \"phy$(iw dev %2 info 2>/dev/null | awk '/wiphy/{print $2}')\" | awk 'NR==1{print $1}' | tr -d ':')")
.arg(enable ? "unblock" : "block")
.arg(logicalName);
int ret = system(cmd.toStdString().c_str());
if (ret != 0) {
qCritical() << "Failed to block/unblock wifi: " << " error code: " << ret ;
}
cmd = QString("/sbin/ifconfig %1 %2").arg(logicalName).arg(enable ? "up" : "down");
ret = system(cmd.toStdString().c_str());
if (ret != 0) {
qCritical() << "Failed to up/down network: " << logicalName << enable << " error code: " << ret ;
return false;
}
} else {
ifr.ifr_ifru.ifru_flags &= flag;
}
// 1. 通过ioctl禁用
int fd = socket(AF_INET, SOCK_STREAM, 0);
if (fd < 0)
return false;

struct ifreq ifr;
strncpy(ifr.ifr_name, logicalName.toStdString().c_str(),IFNAMSIZ);
ifr.ifr_name[IFNAMSIZ - 1] = '\0';
short flag;
if (enable) {
flag = IFF_UP | IFF_PROMISC;
} else {
flag = ~(IFF_UP | IFF_PROMISC);
}
// 先获取标识
if (ioctl(fd, SIOCGIFFLAGS, &ifr) < 0) {
close(fd);
return false;
}
// 获取后重新设置标识
if (enable) {
ifr.ifr_ifru.ifru_flags |= flag;
} else {
ifr.ifr_ifru.ifru_flags &= flag;
}

if (ioctl(fd, SIOCSIFFLAGS, &ifr) < 0) {
close(fd);
return false;
if (ioctl(fd, SIOCSIFFLAGS, &ifr) < 0) {
close(fd);
return false;
}
}
return true;
}
Expand Down
12 changes: 11 additions & 1 deletion deepin-devicemanager/src/DeviceManager/DeviceInput.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -361,6 +361,16 @@
return "";
}

QString DeviceInput::getBusInfo() const

Check warning on line 364 in deepin-devicemanager/src/DeviceManager/DeviceInput.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

The function 'getBusInfo' is never used.
{
return m_SysPath;
}

QString DeviceInput::getInterface() const

Check warning on line 369 in deepin-devicemanager/src/DeviceManager/DeviceInput.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

The function 'getInterface' is never used.
{
return m_Interface;
}

const QString &DeviceInput::name() const
{
// qCDebug(appLog) << "Entering name() const.";
Expand Down Expand Up @@ -501,7 +511,7 @@
}
QString info = file.readAll();

if (m_Name.contains("PS/2")) {
if (m_Name.contains("PS/2") || m_Interface.contains("PS/2")) {
// QStringList lines = info.split("\n");
// for (QString line : lines) {
// if (line.startsWith("PS2M" && line.contains("disabled"))) {
Expand Down
5 changes: 4 additions & 1 deletion deepin-devicemanager/src/DeviceManager/DeviceInput.h
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,10 @@ class DeviceInput : public DeviceBaseInfo
*/
bool bluetoothIsConnected();

QString getBusInfo() const;

QString getInterface() const;

protected:
/**
* @brief initFilterKey:初始化可现实的可显示的属性,m_FilterKey
Expand Down Expand Up @@ -181,7 +185,6 @@ class DeviceInput : public DeviceBaseInfo
bool m_wakeupChanged = true; //<! 记录鼠标的唤醒状态

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

};

#endif // DEVICEINPUT_H
5 changes: 3 additions & 2 deletions deepin-devicemanager/src/DeviceManager/DeviceMemory.cpp
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -254,12 +254,13 @@ const QString DeviceMemory::getOverviewInfo()
qCDebug(appLog) << "Name string is '--', clearing it";
nameStr.clear();
}
ov += QString("%1(%2 %3 %4)") \
ov += QString("%1(%2%3 %4)") \
.arg(m_Size) \
.arg(nameStr) \
.arg(nameStr + (nameStr.isEmpty() ? "" : " ")) \
.arg(m_Type) \
.arg(m_Speed);

ov = ov.trimmed();
qCDebug(appLog) << "Memory overview info:" << ov;
return ov;
}
4 changes: 4 additions & 0 deletions deepin-devicemanager/src/Page/PageMultiInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,10 @@ void PageMultiInfo::getTableListInfo(const QList<DeviceBaseInfo *> &lst, QList<Q
if (input) {
menuControl.append(input->canWakeupMachine() ? "true" : "false");
menuControl.append(input->wakeupPath());
if (info->name().contains("PS/2")) {
menuControl.append(input->getBusInfo());
menuControl.append(input->name());
}
}

DeviceNetwork *network = dynamic_cast<DeviceNetwork *>(info);
Expand Down
5 changes: 4 additions & 1 deletion deepin-devicemanager/src/Page/PageSingleInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,10 @@ void PageSingleInfo::slotWakeupMachine()
// 键盘鼠标唤醒机器
DeviceInput *input = qobject_cast<DeviceInput *>(mp_Device);
if (input && !input->wakeupID().isEmpty() && !input->sysPath().isEmpty()) {
DBusWakeupInterface::getInstance()->setWakeupMachine(input->wakeupID(), input->sysPath(), mp_WakeupMachine->isChecked(), input->name());
DBusWakeupInterface::getInstance()->setWakeupMachine(input->wakeupID(),
input->sysPath(),
mp_WakeupMachine->isChecked(),
input->getInterface());
}

// 网卡的远程唤醒
Expand Down
6 changes: 3 additions & 3 deletions deepin-devicemanager/src/Tool/ThreadExecXrandr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ void ThreadExecXrandr::loadXrandrInfo(QList<QMap<QString, QString>> &lstMap, con
QRegularExpressionMatch match = re.match(line);
if (match.hasMatch()) {
lstMap[lstMap.count() - 1].insert("minResolution", match.captured(1));
lstMap[lstMap.count() - 1].insert("curResolution", match.captured(2));
lstMap[lstMap.count() - 1].insert("curResolution", match.captured(2).replace(" ", "").replace("x", "×", Qt::CaseInsensitive));
lstMap[lstMap.count() - 1].insert("maxResolution", match.captured(3));
qCDebug(appLog) << "Parsed resolutions: min" << match.captured(1) << "cur" << match.captured(2) << "max" << match.captured(3);
}
Expand Down Expand Up @@ -392,8 +392,8 @@ void ThreadExecXrandr::getResolutionFromDBus(QMap<QString, QString> &lstMap)
}

if (maxResolutionWidth != -1) {
lstMap.insert("maxResolution", QString("%1×%2").arg(maxResolutionWidth).arg(maxResolutionHeight));
lstMap.insert("minResolution", QString("%1×%2").arg(minResolutionWidth).arg(minResolutionHeight));
lstMap.insert("maxResolution", QString("%1 x %2").arg(maxResolutionWidth).arg(maxResolutionHeight));
lstMap.insert("minResolution", QString("%1 x %2").arg(minResolutionWidth).arg(minResolutionHeight));
}
}

Expand Down
16 changes: 12 additions & 4 deletions deepin-devicemanager/src/Widget/TableWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -320,10 +320,18 @@ void TableWidget::slotShowMenu(const QPoint &point)
bool isWakeup = false;
if(file.open(QIODevice::ReadOnly)){
QString info = file.readAll();
if(info.contains("disabled"))
isWakeup = false;
else
isWakeup = true;
if (wakeupPath.contains("/proc/acpi/wakeup")) {
bool wakedUp = DBusWakeupInterface::getInstance()->isInputWakeupMachine(item->data(Qt::UserRole+4).toString(),
item->data(Qt::UserRole+5).toString());
isWakeup = wakedUp;
} else {
if(info.contains("disabled")) {
isWakeup = false;
}
else {
isWakeup = true;
}
}
}
mp_WakeupMachine->setChecked(isWakeup);
}else{
Expand Down