Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: sync 1071develop #325

Merged
merged 2 commits into from
May 30, 2024
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
3 changes: 1 addition & 2 deletions .reuse/dep5
Original file line number Diff line number Diff line change
Expand Up @@ -66,5 +66,4 @@ License: GPL-3.0-or-later
# 3rdparty/QtXlsxWriter
Files: deepin-devicemanager/3rdparty/QtXlsxWriter/*
Copyright: 2013-2014 Debao Zhang <[email protected]>
License: MIT

License: MIT
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@ add_subdirectory(${CMAKE_SOURCE_DIR}/deepin-devicemanager-server)
if(CMAKE_COVERAGE_ARG STREQUAL "CMAKE_COVERAGE_ARG_ON")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g -Wall -fprofile-arcs -ftest-coverage")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -Wall -fprofile-arcs -ftest-coverage")
endif()
endif()
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ MACRO(SUBDIRLIST result curdir)
SET(${result} ${dirlist})
ENDMACRO()
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/src)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../../deepin-devicemanager/src/DDLog)
SUBDIRLIST(dirs ${CMAKE_CURRENT_SOURCE_DIR}/src)
foreach(dir ${dirs})
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/src/${dir})
Expand Down Expand Up @@ -80,4 +81,4 @@ install(TARGETS ${BIN_NAME} DESTINATION ${CMAKE_INSTALL_BINDIR})
install(FILES ${BIN_NAME}.json DESTINATION share/deepin-service-manager/other/)
install(FILES org.deepin.devicecontrol.conf DESTINATION share/dbus-1/system.d/)
install(FILES org.deepin.DeviceControl.service DESTINATION share/dbus-1/system-services/)
install(FILES deepin-devicecontrol.service DESTINATION lib/systemd/system/)
install(FILES deepin-devicecontrol.service DESTINATION lib/systemd/system/)
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@
#include "enablesqlmanager.h"
#include "enableutils.h"
#include "wakeuputils.h"
#include "DDLog.h"

#include <QDebug>
#include <QLoggingCategory>
#include <QProcess>
#include <QDir>
#include <QDBusConnection>
Expand All @@ -25,7 +26,7 @@
#include <string>

using namespace PolkitQt1;

using namespace DDLog;
static int getPidByName(const QString &taskName)
{
DIR *dir = opendir("/proc");
Expand Down Expand Up @@ -418,7 +419,7 @@ bool ControlInterface::removeEnable(const QString &hclass, const QString &name,
// 1. 直接remove写入
// 通过remove文件禁用
// 1:表示禁用 ,0:表示启用
qInfo() << "" << "/sys" + path + QString("/remove");
qCInfo(appLog) << "" << "/sys" + path + QString("/remove");
// return false;
QFile file("/sys" + path + QString("/remove"));
if (!file.open(QIODevice::WriteOnly)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,17 @@

#include "debinstaller.h"
#include "utils.h"
#include "DDLog.h"

#include <QDebug>
#include <QLoggingCategory>
#include <QTimer>

#include <QApt/Backend>
#include <QApt/DebFile>
#include <QApt/Transaction>

using namespace DDLog;

const int MAX_DPKGRUNING_TEST = 20;
const int TEST_TIME_INTERVAL = 2000;

Expand Down Expand Up @@ -55,15 +58,15 @@ void DebInstaller::initBackend()
m_backend = new QApt::Backend;
m_bValid = m_backend->init();
if (!m_bValid) {
qInfo() << m_backend->initErrorMessage();
qCInfo(appLog) << m_backend->initErrorMessage();
}
}

void DebInstaller::reset()
{
m_bValid = m_backend->reloadCache();
if (!m_bValid) {
qInfo() << m_backend->initErrorMessage();
qCInfo(appLog) << m_backend->initErrorMessage();
}
m_iRuningTestCount = 0;
m_pTrans = nullptr;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,12 @@
#include "driverinstaller.h"
#include "utils.h"
#include "commonfunction.h"
#include "DDLog.h"

#include <QApt/Backend>
#include <QApt/DebFile>
#include <QApt/Transaction>
#include <QDebug>
#include <QLoggingCategory>
#include <QProcess>
#include <QTimer>

Expand All @@ -20,6 +21,7 @@
#include <string>
#include <vector>

using namespace DDLog;
const int MAX_DPKGRUNING_TEST = 20;
const int TEST_TIME_INTERVAL = 2000;

Expand Down Expand Up @@ -69,7 +71,7 @@ void DriverInstaller::undoInstallDriver()
mp_Trans->setProperty("isCancelled", true);
mp_Trans->cancel();
m_Cancel = true;
qInfo() << "DRIVER_LOG **************************** 取消操作";
qCInfo(appLog) << "DRIVER_LOG **************************** 取消操作";
}

}
Expand Down Expand Up @@ -126,21 +128,21 @@ void DriverInstaller::doOperate(const QString &package, const QString &version)
{
if (!initBackend()) {
emit errorOccurred(EC_NULL);
qInfo() << "DRIVER_LOG : ************************** 初始化backend失败";
qCInfo(appLog) << "DRIVER_LOG : ************************** 初始化backend失败";
return;
}

QApt::Package *p = mp_Backend->package(package);
// 判断包是否存在
if (nullptr == p) {
emit errorOccurred(EC_NOTFOUND);
qInfo() << "DRIVER_LOG : ************************** 安装包不存在";
qCInfo(appLog) << "DRIVER_LOG : ************************** 安装包不存在";
return;
}

// 版本不存在
if (!p->setVersion(version)) {
qInfo() << "DRIVER_LOG : ************************** 安装包版本不存在";
qCInfo(appLog) << "DRIVER_LOG : ************************** 安装包版本不存在";
emit errorOccurred(EC_NOTFOUND);
delete p;
p = nullptr;
Expand All @@ -153,7 +155,7 @@ void DriverInstaller::doOperate(const QString &package, const QString &version)
mp_Trans = mp_Backend->installPackages(lst);
if (nullptr == mp_Trans) {
emit errorOccurred(EC_NULL);
qInfo() << "DRIVER_LOG : ************************** installPackages";
qCInfo(appLog) << "DRIVER_LOG : ************************** installPackages";
return;
}

Expand All @@ -179,21 +181,21 @@ void DriverInstaller::doOperate(const QString &package, const QString &version)
emit errorOccurred(EC_CANCEL);
}

qInfo() << "DRIVER_LOG : ************************** 安装结束 结束状态码" << status;
qInfo() << "DRIVER_LOG : ************************** 安装结束 结束错误码" << code;
qCInfo(appLog) << "DRIVER_LOG : ************************** 安装结束 结束状态码" << status;
qCInfo(appLog) << "DRIVER_LOG : ************************** 安装结束 结束错误码" << code;

mp_Trans->disconnect();
mp_Trans->deleteLater();
mp_Trans = nullptr;
});

connect(mp_Trans, &QApt::Transaction::downloadProgressChanged, this, [this](QApt::DownloadProgress dp) {
qInfo() << "DRIVER_LOG : ************************** 下载进度 " << dp.progress();
qCInfo(appLog) << "DRIVER_LOG : ************************** 下载进度 " << dp.progress();
if (m_Cancel) {
mp_Trans->setProperty("isCancellable", true);
mp_Trans->setProperty("isCancelled", true);
mp_Trans->cancel();
qInfo() << "DRIVER_LOG *************downloadProgressChanged*************** 取消操作";
qCInfo(appLog) << "DRIVER_LOG *************downloadProgressChanged*************** 取消操作";
}
});

Expand All @@ -202,11 +204,11 @@ void DriverInstaller::doOperate(const QString &package, const QString &version)
mp_Trans->setProperty("isCancellable", true);
mp_Trans->setProperty("isCancelled", true);
mp_Trans->cancel();
qInfo() << "DRIVER_LOG *************progressChanged*************** 取消操作";
qCInfo(appLog) << "DRIVER_LOG *************progressChanged*************** 取消操作";
}
if (false == m_Cancel)
emit installProgressChanged(progress);
qInfo() << "DRIVER_LOG : ************************** 总进度 " << progress << " 下载状态 " << mp_Trans->downloadProgress().uri();
qCInfo(appLog) << "DRIVER_LOG : ************************** 总进度 " << progress << " 下载状态 " << mp_Trans->downloadProgress().uri();
});

mp_Trans->run();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,15 @@
#include "driverinstaller.h"
//#include "DeviceInfoManager.h"
#include "httpdriverinterface.h"
#include "DDLog.h"

#include <QThread>
#include <QFile>
#include <QMimeDatabase>
#include <QMimeType>
#include <QDir>
#include <QFileInfo>
#include <QDebug>
#include <QLoggingCategory>
#include <QPair>
#include <QJsonObject>
#include <QNetworkAccessManager>
Expand All @@ -34,7 +35,7 @@
#include <QNetworkConfigurationManager>
#include <QDir>
#include <QFileInfoList>
#include <QDebug>
#include <QLoggingCategory>

#include <fstream>
#include <string>
Expand Down Expand Up @@ -63,6 +64,7 @@
sigFinished(flag, errmsg);\
return flag; \
}
using namespace DDLog;

DriverManager::DriverManager(QObject *parent)
: QObject(parent)
Expand Down Expand Up @@ -104,8 +106,8 @@
m_installprocess = 20 + static_cast<int>(iprocess * 0.8);
sigProgressDetail(m_installprocess, errmsg);
});
connect(mp_debinstaller, &DebInstaller::errorOccurred, [&](QString errmsg) {

Check warning on line 109 in deepin-devicemanager-server/deepin-devicecontrol/src/drivercontrol/drivermanager.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Parameter 'errmsg' is passed by value. It could be passed as a const reference which is usually faster and recommended in C++.
qInfo() << "signal_installFailedReason:" << errmsg;
qCInfo(appLog) << "signal_installFailedReason:" << errmsg;
sigFinished(false, errmsg);
this->errmsg = errmsg;
});
Expand All @@ -115,23 +117,23 @@
connect(mp_driverInstaller, &DriverInstaller::installProgressFinished, [&](bool bsuccess) {
if (bsuccess) {
sigInstallProgressFinished(bsuccess, EC_NULL);
qInfo() << "Driver installed successfully";
qCInfo(appLog) << "Driver installed successfully";
} else {
qInfo() << "Driver installation failed , reason : unknow";
qCInfo(appLog) << "Driver installation failed , reason : unknow";
}
});

connect(mp_driverInstaller, &DriverInstaller::errorOccurred, [this](int err) {
if (EC_NETWORK != err) {
qInfo() << "Driver installation failed , reason : " << err;
qCInfo(appLog) << "Driver installation failed , reason : " << err;
sigInstallProgressFinished(false, err);
return;
}

// 如果错误是网络异常,则需要尝试60s
// 先通知前台网络异常
sigInstallProgressFinished(false, EC_NOTIFY_NETWORK);
qInfo() << "Network error : We are listening to the network";
qCInfo(appLog) << "Network error : We are listening to the network";

// 60s等待操作
m_IsNetworkOnline = false;
Expand All @@ -157,7 +159,7 @@

connect(mp_driverInstaller, &DriverInstaller::installProgressChanged, [&](int progress) {
sigInstallProgressChanged(progress);
qInfo() << "Installing driver , installation progress : " << progress;
qCInfo(appLog) << "Installing driver , installation progress : " << progress;
});
}

Expand Down Expand Up @@ -239,7 +241,7 @@
QMimeDatabase typedb;
QMimeType filetype = typedb.mimeTypeForFile(fileinfo);
if (filetype.filterString().contains("deb")) {
qInfo() << __func__ << "deb install start";
qCInfo(appLog) << __func__ << "deb install start";
sigProgressDetail(15, "");
emit sigDebInstall(filepath);
sigProgressDetail(20, "");
Expand Down Expand Up @@ -645,13 +647,13 @@

//拷贝子目录
if (fileInfo.isDir()) {
qInfo() << "del isDir";
qCInfo(appLog) << "del isDir";
//递归调用拷贝
if (!qdelDirectory(toDir_.filePath(fileInfo.fileName())))
return false;
} else {
toDir_.remove(fileInfo.fileName());
qInfo() << "del remove";
qCInfo(appLog) << "del remove";
}
}
return true;
Expand Down Expand Up @@ -704,7 +706,7 @@
QString backupPath = QString("%1/driver/%2").arg(DB_PATH).arg(debname);
QDir destdir(backupPath);
if (destdir.exists()) {
qInfo() << "delDeb" << backupPath << destdir.absolutePath();
qCInfo(appLog) << "delDeb" << backupPath << destdir.absolutePath();
qdelDirectory(backupPath);
destdir.rmdir(destdir.absolutePath());
}
Expand All @@ -718,7 +720,7 @@
QByteArray outArry = process.readAllStandardOutput();
QList<QString> lines = QString(outArry).split('\n', QString::SkipEmptyParts);
for (const QString &line : qAsConst(lines)) {
// qDebug() << line;
// qCDebug() << line;
// error handling...
}
}); */
Expand All @@ -737,7 +739,7 @@
{
QDir formDir_(debpath);
if (!formDir_.exists()) { //检查传入路径是否存在
qInfo() << "no bank up file";
qCInfo(appLog) << "no bank up file";
return false;
}

Expand All @@ -758,7 +760,7 @@
return false;
}
}
qInfo() << "copy file" << fromPath << backupPath << debname;
qCInfo(appLog) << "copy file" << fromPath << backupPath << debname;
return qCopyDirectory(fromPath, backupPath, true);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include "httpdriverinterface.h"
#include "commonfunction.h"
#include "utils.h"
#include "DDLog.h"

#include <QJsonDocument>
#include <QtNetwork>
Expand All @@ -13,6 +14,7 @@

#include <DSysInfo>

using namespace DDLog;
// 以下这个问题可以避免单例的内存泄露问题
std::atomic<HttpDriverInterface *> HttpDriverInterface::s_Instance;
std::mutex HttpDriverInterface::m_mutex;
Expand Down Expand Up @@ -96,7 +98,7 @@ QString HttpDriverInterface::getRequestBoard(QString strManufacturer, QString st
if (0 < iClass) {
strUrl += "&class=" + QString(iClass);
}
qInfo() << strUrl;
qCInfo(appLog) << strUrl;
return getRequestJson(strUrl);
}

Expand Down Expand Up @@ -168,15 +170,15 @@ bool HttpDriverInterface::checkDriverInfo(QString strJson, DriverInfo &driverInf
}
}
}
qInfo() << "packages: " << driverInfo.packages;
qInfo() << "debVersion: " << driverInfo.debVersion;
qInfo() << "driverName: " << driverInfo.driverName;
qInfo() << "version: " << driverInfo.version;
qCInfo(appLog) << "packages: " << driverInfo.packages;
qCInfo(appLog) << "debVersion: " << driverInfo.debVersion;
qCInfo(appLog) << "driverName: " << driverInfo.driverName;
qCInfo(appLog) << "version: " << driverInfo.version;

qInfo() << lstDriverInfo.size();
qCInfo(appLog) << lstDriverInfo.size();
foreach (const RepoDriverInfo &di, lstDriverInfo) {
qInfo() << "strPackages: " << di.strPackages;
qInfo() << "strDebVersion: " << di.strDebVersion;
qCInfo(appLog) << "strPackages: " << di.strPackages;
qCInfo(appLog) << "strDebVersion: " << di.strDebVersion;
}
return true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#include "commonfunction.h"

#include <QObject>
#include <QDebug>
#include <QLoggingCategory>
#include <QNetworkAccessManager>
#include <QUrl>

Expand Down
Loading
Loading