Skip to content

Commit

Permalink
feat: 增加本地数据库查询条件 (#85)
Browse files Browse the repository at this point in the history
lastore配置版本高于1.0时才走本地数据库查询

Log: 增加本地数据库查询条件
Task: https://pms.uniontech.com/task-view-357591.html
Change-Id: I28ba40f05f09defc72bb6dfc480b3460dacb3554

Co-authored-by: ut002729 <liujinglin@uniontech.com>
  • Loading branch information
kingjinni and jinniliew authored Jul 25, 2024
1 parent 10b7555 commit 9a51632
Showing 1 changed file with 25 additions and 1 deletion.
26 changes: 25 additions & 1 deletion src/Common/vendor/zdrivermanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@

#include <map>

#include <DConfig>
DCORE_USE_NAMESPACE

static QMutex g_mutex;
static QMap<QString, QMap<QString, QString>> g_ppds; //所有ppd文件的字典,以device_id(没有device_id则以make_and_model)作为key
static QMap<QString, QMap<QString, QString> *> g_ppdsDirct; //将厂商和型号格式化之后作为key生成的字典,键值为g_ppds的key
Expand All @@ -49,6 +52,26 @@ static const QString g_dbpath = "/opt/deepin/dde-printer/printer-drivers/deb-rep
static const QString g_ppddbname = "ppd.db";
static const QString g_dbversion = "0.1.2";

static bool isLastoreConfigVerAccord()
{
QString name = "org.deepin.lastore";
DConfig *config = DConfig::create(name, name);

if (config == nullptr) {
return false;
}

QString version = config->value("version").toByteArray();
config->deleteLater();

qCDebug(COMMONMOUDLE) << "config ver:" << version;
if (!version.isEmpty() && QVersionNumber::fromString(version) > QVersionNumber::fromString("1.0")) {
return true;
}

return false;
}

static QMap<QString, QVariant> stringToVariant(const QMap<QString, QString> &driver)
{
QMap<QString, QVariant> info;
Expand Down Expand Up @@ -886,7 +909,8 @@ void DriverSearcher::askForFinish()
if (m_drivers.isEmpty() || m_matchLocalDriver) {
getLocalDrivers();
}
if (m_drivers.isEmpty() && supportArchs.contains(g_Settings->getSystemArch())) {

if (m_drivers.isEmpty() && supportArchs.contains(g_Settings->getSystemArch()) && isLastoreConfigVerAccord()) {
getLocalDbDrivers();
}

Expand Down

0 comments on commit 9a51632

Please sign in to comment.