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
8 changes: 4 additions & 4 deletions deepin-devicemanager/src/DeviceManager/DeviceInput.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -437,12 +437,12 @@
}
if(e){
//鼠标启用时,唤醒能力打开
DBusWakeupInterface::getInstance()->setWakeupMachine(wakeupID(), sysPath(), true, name());
DBusWakeupInterface::getInstance()->setWakeupMachine(wakeupID(), sysPath(), true, name(), m_HardwareClass);
m_wakeupChanged = true;

} else if (m_wakeupChanged) { //鼠标禁用时,唤醒能力关闭
m_wakeupChanged = false;
DBusWakeupInterface::getInstance()->setWakeupMachine(wakeupID(), sysPath(), false, name());
DBusWakeupInterface::getInstance()->setWakeupMachine(wakeupID(), sysPath(), false, name(), m_HardwareClass);
}
bool res = DBusEnableInterface::getInstance()->enable(m_HardwareClass, m_Name, m_SysPath, m_UniqueID, e, m_Driver);
if (res) {
Expand All @@ -462,9 +462,9 @@
return m_Enable;
}

bool DeviceInput::canWakeupMachine()

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

View workflow job for this annotation

GitHub Actions / cppcheck

The function 'canWakeupMachine' is never used.
{
if (m_WakeupID.isEmpty() || (m_HardwareClass == "keyboard" && "PS/2" == m_Interface))
if (m_WakeupID.isEmpty())
return false;
QFile file(wakeupPath());
if (!file.open(QIODevice::ReadOnly)) {
Expand All @@ -488,7 +488,7 @@
// return false;
// }
// /proc/acpi/wakeup文件中状态未刷新,ps2设备通过dbus获取状态
return DBusWakeupInterface::getInstance()->isInputWakeupMachine(m_SysPath, m_Name);
return DBusWakeupInterface::getInstance()->isInputWakeupMachine(m_SysPath, m_Name, m_HardwareClass, m_Interface);

} else {
if (info.contains("disabled"))
Expand Down
2 changes: 2 additions & 0 deletions deepin-devicemanager/src/Page/PageMultiInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,8 @@ void PageMultiInfo::getTableListInfo(const QList<DeviceBaseInfo *> &lst, QList<Q
if (info->name().contains("PS/2")) {
menuControl.append(input->getBusInfo());
menuControl.append(input->name());
menuControl.append(input->hardwareClass());
menuControl.append(input->getInterface());
}
}

Expand Down
3 changes: 2 additions & 1 deletion deepin-devicemanager/src/Page/PageSingleInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,8 @@ void PageSingleInfo::slotWakeupMachine()
DBusWakeupInterface::getInstance()->setWakeupMachine(input->wakeupID(),
input->sysPath(),
mp_WakeupMachine->isChecked(),
input->getInterface());
input->getInterface(),
input->hardwareClass());
}

// 网卡的远程唤醒
Expand Down
20 changes: 14 additions & 6 deletions deepin-devicemanager/src/WakeupControl/DBusWakeupInterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,11 @@
init();
}

bool DBusWakeupInterface::setWakeupMachine(const QString &unique_id, const QString &path, bool wakeup, const QString &name)
bool DBusWakeupInterface::setWakeupMachine(const QString &unique_id,
const QString &path,

Check warning on line 39 in deepin-devicemanager/src/WakeupControl/DBusWakeupInterface.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Local variable 'path' shadows outer argument
bool wakeup,
const QString &name,
const QString &hardwareclass)
{
if (nullptr != mp_InputIface && mp_InputIface->isValid()) {
QStringList pathList = path.split("/", QString::SkipEmptyParts);
Expand All @@ -53,9 +57,9 @@
QMap<QString, QString> allSupportWakeupDevices;
arg >> allSupportWakeupDevices;
QStringList wakeupPathList = allSupportWakeupDevices.keys();

QString key = (hardwareclass == "mouse") ? "PS2M" : "PS2K";
for (QString path : wakeupPathList) {
if (path.contains("PS2")) {
if (path.contains(key)) {

Check warning on line 62 in deepin-devicemanager/src/WakeupControl/DBusWakeupInterface.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Consider using std::find_if algorithm instead of a raw loop.
mp_InputIface->call("SetWakeupDevices", path, wakeup ? "enabled" : "disabled");
return true;
}
Expand Down Expand Up @@ -110,7 +114,10 @@
return file.open(QIODevice::ReadOnly);
}

bool DBusWakeupInterface::isInputWakeupMachine(const QString &path, const QString &name)
bool DBusWakeupInterface::isInputWakeupMachine(const QString &path,

Check warning on line 117 in deepin-devicemanager/src/WakeupControl/DBusWakeupInterface.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Local variable 'path' shadows outer argument
const QString &name,
const QString &hardwareClass,
const QString &interfaceType)
{
if (nullptr != mp_InputIface && mp_InputIface->isValid()) {
QDBusInterface interface(INPUT_SERVICE_NAME, INPUT_WAKEUP_SERVICE_PATH, INPUT_WAKEUP_PROPERTIES_INTERFACE, QDBusConnection::systemBus());
Expand All @@ -122,9 +129,10 @@
QMap<QString, QString> allSupportWakeupDevices;
arg >> allSupportWakeupDevices;

if (name.contains("PS/2")) {
if (interfaceType.contains("PS/2")) {
QString key = (hardwareClass == "mouse") ? "PS2M" : "PS2K";
for(QString path : allSupportWakeupDevices.keys()) {

Check warning on line 134 in deepin-devicemanager/src/WakeupControl/DBusWakeupInterface.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Variable 'path' is used to iterate by value. It could be declared as a const reference which is usually faster and recommended in C++.
if (path.contains("PS2")) {
if (path.contains(key)) {

Check warning on line 135 in deepin-devicemanager/src/WakeupControl/DBusWakeupInterface.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Consider using std::find_if algorithm instead of a raw loop.
return allSupportWakeupDevices[path] == "enabled";
}
}
Expand Down
11 changes: 9 additions & 2 deletions deepin-devicemanager/src/WakeupControl/DBusWakeupInterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,11 @@ class DBusWakeupInterface
* @param wakeup 可唤醒 不可唤醒
* @return
*/
bool setWakeupMachine(const QString &unique_id, const QString &path, bool wakeup, const QString &name);
bool setWakeupMachine(const QString &unique_id,
const QString &path,
bool wakeup,
const QString &name,
const QString &hardwareclass);

/**
* @brief canWakeupMachine 获取input是否支持唤醒
Expand All @@ -54,7 +58,10 @@ class DBusWakeupInterface
* @param path 设备节点路径
* @return
*/
bool isInputWakeupMachine(const QString &path, const QString &name);
bool isInputWakeupMachine(const QString &path,
const QString &name,
const QString &hardwareClass,
const QString &interfaceType);

/**
* @brief isNetworkWakeup 获取网卡是否支持远程唤醒
Expand Down
4 changes: 3 additions & 1 deletion deepin-devicemanager/src/Widget/TableWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,9 @@ void TableWidget::slotShowMenu(const QPoint &point)
QString info = file.readAll();
if (wakeupPath.contains("/proc/acpi/wakeup")) {
bool wakedUp = DBusWakeupInterface::getInstance()->isInputWakeupMachine(item->data(Qt::UserRole+4).toString(),
item->data(Qt::UserRole+5).toString());
item->data(Qt::UserRole+5).toString(),
item->data(Qt::UserRole+6).toString(),
item->data(Qt::UserRole+7).toString());
isWakeup = wakedUp;
} else {
if(info.contains("disabled")) {
Expand Down
2 changes: 1 addition & 1 deletion deepin-devicemanager/src/Widget/TextBrowser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ void TextBrowser::setWakeupMachine(bool wakeup)
// 键盘鼠标唤醒机器
DeviceInput *input = qobject_cast<DeviceInput*>(mp_Info);
if(input && !input->wakeupID().isEmpty() && !input->sysPath().isEmpty()){
DBusWakeupInterface::getInstance()->setWakeupMachine(input->wakeupID(),input->sysPath(),wakeup, input->name());
DBusWakeupInterface::getInstance()->setWakeupMachine(input->wakeupID(),input->sysPath(),wakeup, input->name(), input->hardwareClass());
}

// 网卡的远程唤醒
Expand Down