diff --git a/deepin-devicemanager/assets/oeminfo_sampleAnduseGuideLine_zh_CN.toml b/deepin-devicemanager/assets/oeminfo_sampleAnduseGuideLine_zh_CN.toml index abcd1460a..0afc0cc52 100755 --- a/deepin-devicemanager/assets/oeminfo_sampleAnduseGuideLine_zh_CN.toml +++ b/deepin-devicemanager/assets/oeminfo_sampleAnduseGuideLine_zh_CN.toml @@ -501,4 +501,6 @@ Device File ="toml_Device File" #10 : 设备文件 #4-3-2.双匹配key需要两个值同时匹配:key2:"Vendor_ID 和 Product_ID"("物理ID"中VID和PID值); key3:"Vendor 和 Name"(制造商和名称); 。 #4-4.匹配生效后表头下面每行key名与对应设备管理器中显示每条信息名一致,其值则会被显示到对应界面。 #4-3.若匹配key匹配上某一设备且值尾包括有"_NOUSE"则该个设备所有信息将被删除显示。 -#4-4.增加一个设备信息则不需要匹配;没有写入该文件的表头所代表设备将不会被修改;没有写入该文件的key值所代表设备信息将不会被修改。 \ No newline at end of file +#4-4.增加一个设备信息则不需要匹配;没有写入该文件的表头所代表设备将不会被修改;没有写入该文件的key值所代表设备信息将不会被修改。 +#4-5.1 增加 tomlmatchkey = { Size = "512", Name = "xname" } # 内联表 "{Size:512G}{Name:xx1}{Vendor:xx2}" # 匹配键名 +#4-5.2 增加 tomlconfigdemanding ="adjust" # 配置需求 “adjust delete add” diff --git a/deepin-devicemanager/assets/org.deepin.devicemanager.json b/deepin-devicemanager/assets/org.deepin.devicemanager.json index cbc0690f8..ee5975fb1 100644 --- a/deepin-devicemanager/assets/org.deepin.devicemanager.json +++ b/deepin-devicemanager/assets/org.deepin.devicemanager.json @@ -15,7 +15,7 @@ "permissions": "readwrite", "visibility": "public" }, - "specialComType": { + "specialComType": { "value": -1, "serial": 0, "flags": ["global"], @@ -24,6 +24,16 @@ "description": "special computer type:PGUW(value:1),KLVV/L540(value:2),KLVU(value:3),PGUV/W585(value:4),PGUX(value:5)", "permissions": "readwrite", "visibility": "private" - } - } -} + }, + "TomlFilesName": { + "value": "tomlFilesName", + "serial": 0, + "flags": ["global"], + "name": "config the toml name", + "name[zh_CN]": "设置toml文件名", + "description": "此配置项默认为无效的。如需让toml文件内容显示生效,请配置对应文件名。需保证操作者具备读取权限。", + "permissions": "readwrite", + "visibility": "private" + } + } +} \ No newline at end of file diff --git a/deepin-devicemanager/src/DeviceManager/DeviceAudio.cpp b/deepin-devicemanager/src/DeviceManager/DeviceAudio.cpp index 30ecd8a4f..ad43778b4 100644 --- a/deepin-devicemanager/src/DeviceManager/DeviceAudio.cpp +++ b/deepin-devicemanager/src/DeviceManager/DeviceAudio.cpp @@ -359,11 +359,11 @@ void DeviceAudio::loadTableData() QString tName = m_Name; if (!available()) { - tName = "(" + tr("Unavailable") + ") " + m_Name; + tName = "(" + translateStr("Unavailable") + ") " + m_Name; } if (!enable()) { - tName = "(" + tr("Disable") + ") " + m_Name; + tName = "(" + translateStr("Disable") + ") " + m_Name; } m_TableData.append(tName); diff --git a/deepin-devicemanager/src/DeviceManager/DeviceBios.cpp b/deepin-devicemanager/src/DeviceManager/DeviceBios.cpp index 3a8613b33..26ce6a7e1 100644 --- a/deepin-devicemanager/src/DeviceManager/DeviceBios.cpp +++ b/deepin-devicemanager/src/DeviceManager/DeviceBios.cpp @@ -157,7 +157,7 @@ bool DeviceBios::isBoard()const QString DeviceBios::subTitle() { - return QObject::tr(m_Name.toLatin1()); + return translateStr(m_Name); } const QString DeviceBios::getOverviewInfo() diff --git a/deepin-devicemanager/src/DeviceManager/DeviceBluetooth.cpp b/deepin-devicemanager/src/DeviceManager/DeviceBluetooth.cpp index 1dd0a01c4..3a5654d7c 100644 --- a/deepin-devicemanager/src/DeviceManager/DeviceBluetooth.cpp +++ b/deepin-devicemanager/src/DeviceManager/DeviceBluetooth.cpp @@ -134,24 +134,6 @@ TomlFixMethod DeviceBluetooth::setInfoFromTomlOneByOne(const QMap &mapInfo) -{ - // 机器自身蓝牙 - const QList > &otherAttribs = getOtherAttribs(); - QMap tmpMaps; - for (QPair attrib : otherAttribs) { - tmpMaps[attrib.first] = attrib.second; - } - - if ("UART" == tmpMaps[QObject::tr("Bus")]) {//内置:UART 外接USB:USB - setAttribute(mapInfo, "Chip Type", m_Name); - setAttribute(mapInfo, "Vendor", m_Vendor); - return true; - } else { - return false; - } -} - const QString &DeviceBluetooth::name()const { return m_Model; @@ -268,11 +250,11 @@ void DeviceBluetooth::loadTableData() QString tName = m_Name; if (!available()) { - tName = "(" + tr("Unavailable") + ") " + m_Name; + tName = "(" + translateStr("Unavailable") + ") " + m_Name; } if (!enable()) { - tName = "(" + tr("Disable") + ") " + m_Name; + tName = "(" + translateStr("Disable") + ") " + m_Name; } m_TableData.append(tName); diff --git a/deepin-devicemanager/src/DeviceManager/DeviceBluetooth.h b/deepin-devicemanager/src/DeviceManager/DeviceBluetooth.h index 68e0a9665..5480bac6f 100644 --- a/deepin-devicemanager/src/DeviceManager/DeviceBluetooth.h +++ b/deepin-devicemanager/src/DeviceManager/DeviceBluetooth.h @@ -45,13 +45,6 @@ class DeviceBluetooth : public DeviceBaseInfo */ TomlFixMethod setInfoFromTomlOneByOne(const QMap &mapInfo); - /** - * @brief setInfoFromWifiInfo:设置从cat /sys/hisys/wal/wifi_devices_info里面获取的信息 - * @param mapInfo: 由cat /sys/hisys/wal/wifi_devices_info获取的信息map - * @return 布尔值,true:信息设置成功;false:信息设置失败 - */ - bool setInfoFromWifiInfo(const QMap &mapInfo); - /** * @brief name:获取名称属性值 * @return QString:名称属性值 diff --git a/deepin-devicemanager/src/DeviceManager/DeviceCdrom.cpp b/deepin-devicemanager/src/DeviceManager/DeviceCdrom.cpp index b93c0005f..2ac00a7a7 100644 --- a/deepin-devicemanager/src/DeviceManager/DeviceCdrom.cpp +++ b/deepin-devicemanager/src/DeviceManager/DeviceCdrom.cpp @@ -150,11 +150,11 @@ void DeviceCdrom::loadTableData() QString tName = m_Name; if (!available()) { - tName = "(" + tr("Unavailable") + ") " + m_Name; + tName = "(" + translateStr("Unavailable") + ") " + m_Name; } if (!enable()) { - tName = "(" + tr("Disable") + ") " + m_Name; + tName = "(" + translateStr("Disable") + ") " + m_Name; } m_TableData.append(tName); diff --git a/deepin-devicemanager/src/DeviceManager/DeviceCpu.cpp b/deepin-devicemanager/src/DeviceManager/DeviceCpu.cpp index d80787613..be8846aa9 100644 --- a/deepin-devicemanager/src/DeviceManager/DeviceCpu.cpp +++ b/deepin-devicemanager/src/DeviceManager/DeviceCpu.cpp @@ -104,7 +104,7 @@ bool DeviceCpu::frequencyIsRange()const QString DeviceCpu::subTitle() { - return QString("%1 %2").arg(QObject::tr("Processor")).arg(m_PhysicalID); + return QString("%1 %2").arg(translateStr("Processor")).arg(m_PhysicalID); } const QString DeviceCpu::getOverviewInfo() @@ -115,9 +115,9 @@ const QString DeviceCpu::getOverviewInfo() QString ov = QString("%1 (%2%3 / %4%5)") \ .arg(m_Name) \ .arg(m_trNumber[m_CPUCoreNum]) \ - .arg(QObject::tr("Core(s)")) \ + .arg(translateStr("Core(s)")) \ .arg(m_trNumber[m_LogicalCPUNum]) \ - .arg(QObject::tr("Processor")); + .arg(translateStr("Processor")); return ov; } @@ -302,85 +302,85 @@ void DeviceCpu::loadTableData() void DeviceCpu::getTrNumber() { // 将数字转换为英文翻译 - m_trNumber.insert(1, QObject::tr("One")); - m_trNumber.insert(2, QObject::tr("Two")); - m_trNumber.insert(4, QObject::tr("Four")); - m_trNumber.insert(6, QObject::tr("Six")); - m_trNumber.insert(8, QObject::tr("Eight")); - m_trNumber.insert(9, QObject::tr("Nine")); - m_trNumber.insert(10, QObject::tr("Ten")); - m_trNumber.insert(12, QObject::tr("Twelve")); - m_trNumber.insert(14, QObject::tr("Fourteen")); - m_trNumber.insert(16, QObject::tr("Sixteen")); - m_trNumber.insert(18, QObject::tr("Eighteen")); - - m_trNumber.insert(20, QObject::tr("Twenty")); - m_trNumber.insert(22, QObject::tr("Twenty-two")); - m_trNumber.insert(24, QObject::tr("Twenty-four")); - m_trNumber.insert(26, QObject::tr("Twenty-six")); - m_trNumber.insert(28, QObject::tr("Twenty-eight")); - - m_trNumber.insert(30, QObject::tr("Thirty")); - m_trNumber.insert(32, QObject::tr("Thirty-two")); - m_trNumber.insert(34, QObject::tr("Thirty-four")); - m_trNumber.insert(36, QObject::tr("Thirty-six")); - m_trNumber.insert(38, QObject::tr("Thirty-eight")); - - m_trNumber.insert(40, QObject::tr("Forty")); - m_trNumber.insert(42, QObject::tr("Forty-two")); - m_trNumber.insert(44, QObject::tr("Forty-four")); - m_trNumber.insert(46, QObject::tr("Forty-six")); - m_trNumber.insert(48, QObject::tr("Forty-eight")); - - m_trNumber.insert(50, QObject::tr("Fifty")); - m_trNumber.insert(52, QObject::tr("Fifty-two")); - m_trNumber.insert(54, QObject::tr("Fifty-four")); - m_trNumber.insert(56, QObject::tr("Fifty-six")); - m_trNumber.insert(58, QObject::tr("Fifty-eight")); - - m_trNumber.insert(60, QObject::tr("Sixty")); - m_trNumber.insert(62, QObject::tr("Sixty-two")); - m_trNumber.insert(64, QObject::tr("Sixty-four")); - m_trNumber.insert(66, QObject::tr("Sixty-six")); - m_trNumber.insert(68, QObject::tr("Sixty-eight")); - - m_trNumber.insert(70, QObject::tr("Seventy")); - m_trNumber.insert(72, QObject::tr("Seventy-two")); - m_trNumber.insert(74, QObject::tr("Seventy-four")); - m_trNumber.insert(76, QObject::tr("Seventy-six")); - m_trNumber.insert(78, QObject::tr("Seventy-eight")); - - m_trNumber.insert(80, QObject::tr("Eighty")); - m_trNumber.insert(82, QObject::tr("Eighty-two")); - m_trNumber.insert(84, QObject::tr("Eighty-four")); - m_trNumber.insert(86, QObject::tr("Eighty-six")); - m_trNumber.insert(88, QObject::tr("Eighty-eight")); - - m_trNumber.insert(90, QObject::tr("Ninety")); - m_trNumber.insert(92, QObject::tr("Ninety-two")); - m_trNumber.insert(94, QObject::tr("Ninety-four")); - m_trNumber.insert(96, QObject::tr("Ninety-six")); - m_trNumber.insert(98, QObject::tr("Ninety-eight")); - - m_trNumber.insert(100, QObject::tr("One hundred")); - m_trNumber.insert(102, QObject::tr("One hundred and Two")); - m_trNumber.insert(104, QObject::tr("One hundred and four")); - m_trNumber.insert(106, QObject::tr("One hundred and Six")); - m_trNumber.insert(108, QObject::tr("One hundred and Eight")); - - m_trNumber.insert(110, QObject::tr("One hundred and Ten")); - m_trNumber.insert(112, QObject::tr("One hundred and Twelve")); - m_trNumber.insert(114, QObject::tr("One hundred and Fourteen")); - m_trNumber.insert(116, QObject::tr("One hundred and Sixteen")); - m_trNumber.insert(118, QObject::tr("One hundred and Eighteen")); - - m_trNumber.insert(120, QObject::tr("One hundred and Twenty")); - m_trNumber.insert(122, QObject::tr("One hundred and Twenty-two")); - m_trNumber.insert(124, QObject::tr("One hundred and Twenty-four")); - m_trNumber.insert(126, QObject::tr("One hundred and Twenty-six")); - m_trNumber.insert(128, QObject::tr("One hundred and Twenty-eight")); - m_trNumber.insert(192, QObject::tr("One hundred and Ninety-two")); - m_trNumber.insert(256, QObject::tr("Two hundred and fifty-six")); + m_trNumber.insert(1, translateStr("One")); + m_trNumber.insert(2, translateStr("Two")); + m_trNumber.insert(4, translateStr("Four")); + m_trNumber.insert(6, translateStr("Six")); + m_trNumber.insert(8, translateStr("Eight")); + m_trNumber.insert(9, translateStr("Nine")); + m_trNumber.insert(10, translateStr("Ten")); + m_trNumber.insert(12, translateStr("Twelve")); + m_trNumber.insert(14, translateStr("Fourteen")); + m_trNumber.insert(16, translateStr("Sixteen")); + m_trNumber.insert(18, translateStr("Eighteen")); + + m_trNumber.insert(20, translateStr("Twenty")); + m_trNumber.insert(22, translateStr("Twenty-two")); + m_trNumber.insert(24, translateStr("Twenty-four")); + m_trNumber.insert(26, translateStr("Twenty-six")); + m_trNumber.insert(28, translateStr("Twenty-eight")); + + m_trNumber.insert(30, translateStr("Thirty")); + m_trNumber.insert(32, translateStr("Thirty-two")); + m_trNumber.insert(34, translateStr("Thirty-four")); + m_trNumber.insert(36, translateStr("Thirty-six")); + m_trNumber.insert(38, translateStr("Thirty-eight")); + + m_trNumber.insert(40, translateStr("Forty")); + m_trNumber.insert(42, translateStr("Forty-two")); + m_trNumber.insert(44, translateStr("Forty-four")); + m_trNumber.insert(46, translateStr("Forty-six")); + m_trNumber.insert(48, translateStr("Forty-eight")); + + m_trNumber.insert(50, translateStr("Fifty")); + m_trNumber.insert(52, translateStr("Fifty-two")); + m_trNumber.insert(54, translateStr("Fifty-four")); + m_trNumber.insert(56, translateStr("Fifty-six")); + m_trNumber.insert(58, translateStr("Fifty-eight")); + + m_trNumber.insert(60, translateStr("Sixty")); + m_trNumber.insert(62, translateStr("Sixty-two")); + m_trNumber.insert(64, translateStr("Sixty-four")); + m_trNumber.insert(66, translateStr("Sixty-six")); + m_trNumber.insert(68, translateStr("Sixty-eight")); + + m_trNumber.insert(70, translateStr("Seventy")); + m_trNumber.insert(72, translateStr("Seventy-two")); + m_trNumber.insert(74, translateStr("Seventy-four")); + m_trNumber.insert(76, translateStr("Seventy-six")); + m_trNumber.insert(78, translateStr("Seventy-eight")); + + m_trNumber.insert(80, translateStr("Eighty")); + m_trNumber.insert(82, translateStr("Eighty-two")); + m_trNumber.insert(84, translateStr("Eighty-four")); + m_trNumber.insert(86, translateStr("Eighty-six")); + m_trNumber.insert(88, translateStr("Eighty-eight")); + + m_trNumber.insert(90, translateStr("Ninety")); + m_trNumber.insert(92, translateStr("Ninety-two")); + m_trNumber.insert(94, translateStr("Ninety-four")); + m_trNumber.insert(96, translateStr("Ninety-six")); + m_trNumber.insert(98, translateStr("Ninety-eight")); + + m_trNumber.insert(100, translateStr("One hundred")); + m_trNumber.insert(102, translateStr("One hundred and Two")); + m_trNumber.insert(104, translateStr("One hundred and four")); + m_trNumber.insert(106, translateStr("One hundred and Six")); + m_trNumber.insert(108, translateStr("One hundred and Eight")); + + m_trNumber.insert(110, translateStr("One hundred and Ten")); + m_trNumber.insert(112, translateStr("One hundred and Twelve")); + m_trNumber.insert(114, translateStr("One hundred and Fourteen")); + m_trNumber.insert(116, translateStr("One hundred and Sixteen")); + m_trNumber.insert(118, translateStr("One hundred and Eighteen")); + + m_trNumber.insert(120, translateStr("One hundred and Twenty")); + m_trNumber.insert(122, translateStr("One hundred and Twenty-two")); + m_trNumber.insert(124, translateStr("One hundred and Twenty-four")); + m_trNumber.insert(126, translateStr("One hundred and Twenty-six")); + m_trNumber.insert(128, translateStr("One hundred and Twenty-eight")); + m_trNumber.insert(192, translateStr("One hundred and Ninety-two")); + m_trNumber.insert(256, translateStr("Two hundred and fifty-six")); } diff --git a/deepin-devicemanager/src/DeviceManager/DeviceGpu.cpp b/deepin-devicemanager/src/DeviceManager/DeviceGpu.cpp index 841418fb4..84c320de1 100644 --- a/deepin-devicemanager/src/DeviceManager/DeviceGpu.cpp +++ b/deepin-devicemanager/src/DeviceManager/DeviceGpu.cpp @@ -348,7 +348,7 @@ void DeviceGpu::loadTableData() // 加载表格内容 QString tName = m_Name; if (!available()) { - tName = "(" + tr("Unavailable") + ") " + m_Name; + tName = "(" + translateStr("Unavailable") + ") " + m_Name; } m_TableData.append(tName); m_TableData.append(m_Vendor); diff --git a/deepin-devicemanager/src/DeviceManager/DeviceImage.cpp b/deepin-devicemanager/src/DeviceManager/DeviceImage.cpp index 324af8a6e..871a26947 100644 --- a/deepin-devicemanager/src/DeviceManager/DeviceImage.cpp +++ b/deepin-devicemanager/src/DeviceManager/DeviceImage.cpp @@ -189,11 +189,11 @@ void DeviceImage::loadTableData() QString tName = m_Name; if (!available()) { - tName = "(" + tr("Unavailable") + ") " + m_Name; + tName = "(" + translateStr("Unavailable") + ") " + m_Name; } if (!enable()) { - tName = "(" + tr("Disable") + ") " + m_Name; + tName = "(" + translateStr("Disable") + ") " + m_Name; } m_TableData.append(tName); diff --git a/deepin-devicemanager/src/DeviceManager/DeviceInfo.cpp b/deepin-devicemanager/src/DeviceManager/DeviceInfo.cpp index 661abbdff..4ff8f5960 100644 --- a/deepin-devicemanager/src/DeviceManager/DeviceInfo.cpp +++ b/deepin-devicemanager/src/DeviceManager/DeviceInfo.cpp @@ -127,8 +127,8 @@ const QStringList &DeviceBaseInfo::getTableData() loadTableData(); m_TableDataTr.clear(); for (const auto &item : m_TableData) { - QString trKey = translateStr(item); - if(trKey.isEmpty()) + QString trKey = (item); + if (trKey.isEmpty()) m_TableDataTr.append(item); else m_TableDataTr.append(trKey); @@ -147,7 +147,7 @@ bool DeviceBaseInfo::isValueValid(QString &value) if (value.isEmpty()) return false; - if (value == QObject::tr("Unknown")) + if (value == translateStr("Unknown")) return false; if (value == QString("Unknown")) @@ -633,7 +633,7 @@ const QString DeviceBaseInfo::getVendorOrModelId(const QString &sysPath, bool fl const QString DeviceBaseInfo::getDriverVersion() { QString outInfo = Common::executeClientCmd("modinfo", QStringList() << driver(), QString(), -1); - if(outInfo.isEmpty()) + if (outInfo.isEmpty()) return QString(""); foreach (QString out, outInfo.split("\n")) { @@ -728,7 +728,7 @@ const QString DeviceBaseInfo::readDeviceInfoKeyValue(const QString &key) } QList > allOtherAttribs = getOtherAttribs(); for (const QPair& pair : allOtherAttribs) { - if (key == key) + if (key == pair.first) return pair.second; } return QString(""); diff --git a/deepin-devicemanager/src/DeviceManager/DeviceInput.cpp b/deepin-devicemanager/src/DeviceManager/DeviceInput.cpp index 207e281e1..fccc4ce66 100644 --- a/deepin-devicemanager/src/DeviceManager/DeviceInput.cpp +++ b/deepin-devicemanager/src/DeviceManager/DeviceInput.cpp @@ -460,11 +460,11 @@ void DeviceInput::loadTableData() QString tName = m_Name; if (!available()) { - tName = "(" + tr("Unavailable") + ") " + m_Name; + tName = "(" + translateStr("Unavailable") + ") " + m_Name; } if (!enable()) { - tName = "(" + tr("Disable") + ") " + m_Name; + tName = "(" + translateStr("Disable") + ") " + m_Name; } m_TableData.append(tName); diff --git a/deepin-devicemanager/src/DeviceManager/DeviceManager.cpp b/deepin-devicemanager/src/DeviceManager/DeviceManager.cpp index f3f43b333..8fd576ac4 100644 --- a/deepin-devicemanager/src/DeviceManager/DeviceManager.cpp +++ b/deepin-devicemanager/src/DeviceManager/DeviceManager.cpp @@ -558,6 +558,43 @@ QString DeviceManager::tomlDeviceReadKeyValue(DeviceType deviceType, DeviceBaseI return QString(""); } +bool DeviceManager::tomlSetBytomlmatchkey(DeviceType deviceType, DeviceBaseInfo *device, const QString &tomltomlmatchkey, const QString &tomltomlconfigdemanding) +{ + Q_UNUSED(deviceType) + QMap itemMap; + QStringList keyValues = tomltomlmatchkey.split(","); + foreach (const QString &keyValue, keyValues) { + QStringList wordlst = keyValue.split("="); + if (2 == wordlst.size()) { + + QString key = wordlst[0].remove('"').trimmed(); + QString valuetmp = wordlst[1]; + QStringList valuelst; + QString value; + if (valuetmp.contains("#")) { + valuelst = valuetmp.split("#"); + value = valuelst[0].remove('\"').trimmed(); + } else + value = valuetmp.remove('\"').trimmed(); + + itemMap.insert(key, value); + } + } + if(itemMap.size() == 0 ) + return false; + + for (auto key : itemMap.keys()) { + QString tomlKey = key; + QString tomlVal = itemMap.value(key); + QString deviceVal = device->readDeviceInfoKeyValue(tomlKey); + if((0 != deviceVal.compare(tomlVal, Qt::CaseInsensitive))) { + return false; + } + } + + return true; +} + void DeviceManager::tomlDeviceSet(DeviceType deviceType) { @@ -565,7 +602,9 @@ void DeviceManager::tomlDeviceSet(DeviceType deviceType) const QList> &tomlMapLst = cmdInfo(deviceTypeName); for (int j = 0; j < tomlMapLst.size(); j++) { // 加载从toml中获取的信息 bool fixSameOne = false; //初始值设为该项信息没有用过 - bool isSameOne = false; + + QString tomltomlmatchkey = tomlMapLst[j]["tomlmatchkey"]; + QString tomltomlconfigdemanding = PhysID(tomlMapLst[j], "tomlconfigdemanding"); QList lst = convertDeviceList(deviceType); for (int i = 0; i < lst.size(); i++) { // toml中获取的信息 与 原设备信息遍历,相比较作处理 DeviceBaseInfo *device = lst[i]; @@ -574,27 +613,53 @@ void DeviceManager::tomlDeviceSet(DeviceType deviceType) QString pid = PhysID(tomlMapLst[j], "Product_ID"); QString vendor = PhysID(tomlMapLst[j], "Vendor"); QString name = PhysID(tomlMapLst[j], "Name"); - //取出toml中获取的关键字信息设备唯一标识硬件IDS "Modalias", "Vendor_ID", "Vendor","Name";作比较处理 - isSameOne = findByModalias(deviceType, device, modalias); - if (!isSameOne) { - isSameOne = findByVIDPID(deviceType, device, vid, pid); - } - if (!isSameOne) { - isSameOne = findByVendorName(deviceType, device, vendor, name); - } - if (isSameOne) { //存在 就合并信息 setInfoFromTomlOneByOne(const QMap &mapInfo); + bool isSameOne = false; //初始值设为该项信息不属于该设备 + + + isSameOne = tomlSetBytomlmatchkey(deviceType, device, tomltomlmatchkey,tomltomlconfigdemanding); + + if (tomltomlconfigdemanding == "adjust") { + fixSameOne = true; //标记为该项信息有用过 , + if (isSameOne) + tomlDeviceMapSet(deviceType, device, tomlMapLst[j]); + } else if (tomltomlconfigdemanding == "delete") { fixSameOne = true; //标记为该项信息有用过 , - if (TOML_Del == tomlDeviceMapSet(deviceType, device, tomlMapLst[j])) { + if (isSameOne) { tomlDeviceDel(deviceType, device); //toml 去掉该设备 delete (device); } + } else if (tomltomlconfigdemanding == "add" && !fixSameOne) { + + } else { + //取出toml中获取的关键字信息设备唯一标识硬件IDS "Modalias", "Vendor_ID", "Vendor","Name";作比较处理 + if (!isSameOne) + isSameOne = findByModalias(deviceType, device, modalias); + if (!isSameOne) { + isSameOne = findByVIDPID(deviceType, device, vid, pid); + } + if (!isSameOne) { + isSameOne = findByVendorName(deviceType, device, vendor, name); + } + if (isSameOne&& !fixSameOne) { //存在 就合并信息 + fixSameOne = true; //标记为该项信息有用过 , + if (TOML_Del == tomlDeviceMapSet(deviceType, device, tomlMapLst[j])) { + tomlDeviceDel(deviceType, device); //toml 去掉该设备 + delete (device); + } + } } } //与原设备信息遍历相比完再作添加设备 - if ((deviceType != DT_Bios) && (deviceType != DT_Computer) && !fixSameOne) { - fixSameOne = true; //标记为该项信息有用过 ,则不再增加了 - DeviceBaseInfo *device = createDevice(deviceType); - tomlDeviceMapSet(deviceType, device, tomlMapLst[j]); - tomlDeviceAdd(deviceType, device); //不存在 就加 + + if (tomltomlconfigdemanding == "add" && !fixSameOne) { + fixSameOne = true; //标记为该项信息有用过 + DeviceBaseInfo *newDevice = createDevice(deviceType); + tomlDeviceMapSet(deviceType, newDevice, tomlMapLst[j]); + tomlDeviceAdd(deviceType, newDevice); //加 + } else if ((deviceType != DT_Bios) && (deviceType != DT_Computer) && !fixSameOne) { + fixSameOne = true; //标记为该项信息有用过 ,则不再增加了 + DeviceBaseInfo *device = createDevice(deviceType); + tomlDeviceMapSet(deviceType, device, tomlMapLst[j]); + tomlDeviceAdd(deviceType, device); //不存在 就加 } } //end of for (int j = 0;... } @@ -1023,18 +1088,6 @@ bool DeviceManager::setBluetoothInfoFromHwinfo(const QMap &map return false; } -bool DeviceManager::setBluetoothInfoFromWifiInfo(const QMap &mapInfo) -{ - QList::iterator it = m_ListDeviceBluetooth.begin(); - for (; it != m_ListDeviceBluetooth.end(); ++it) { - DeviceBluetooth *device = dynamic_cast(*it); - if (device->setInfoFromWifiInfo(mapInfo)) { - return true; - } - } - return false; -} - DeviceBaseInfo *DeviceManager::getBluetoothDevice(const QString &unique_id) { for (QList::iterator it = m_ListDeviceBluetooth.begin(); it != m_ListDeviceBluetooth.end(); ++it) { @@ -1136,22 +1189,6 @@ void DeviceManager::addNetworkDevice(DeviceNetwork *const device) m_ListDeviceNetwork.append(device); } -bool DeviceManager::setNetworkInfoFromWifiInfo(const QMap &mapInfo) -{ - QList::iterator it = m_ListDeviceNetwork.begin(); - for (; it != m_ListDeviceNetwork.end(); ++it) { - - DeviceNetwork *device = dynamic_cast(*it); - if (!device) - continue; - - if (device->setInfoFromWifiInfo(mapInfo)) { - return true; - } - } - return false; -} - DeviceBaseInfo *DeviceManager::getNetworkDevice(const QString &unique_id) { for (QList::iterator it = m_ListDeviceNetwork.begin(); it != m_ListDeviceNetwork.end(); ++it) { diff --git a/deepin-devicemanager/src/DeviceManager/DeviceManager.h b/deepin-devicemanager/src/DeviceManager/DeviceManager.h index 0b2ebb7d3..a2682366b 100644 --- a/deepin-devicemanager/src/DeviceManager/DeviceManager.h +++ b/deepin-devicemanager/src/DeviceManager/DeviceManager.h @@ -108,7 +108,7 @@ class DeviceManager : public QObject void tomlDeviceDel(DeviceType deviceType, DeviceBaseInfo *const device); void tomlDeviceAdd(DeviceType deviceType, DeviceBaseInfo *const device); QString tomlDeviceReadKeyValue(DeviceType deviceType, DeviceBaseInfo *device, const QString &key); - + bool tomlSetBytomlmatchkey(DeviceType deviceType, DeviceBaseInfo *device, const QString &tomltomlmatchkey, const QString &tomltomlconfigdemanding); /** * @brief * toml 方案内容定义: @@ -131,14 +131,12 @@ class DeviceManager : public QObject * @param KeyID "Module Alias" "VID_PID" * @return */ - DeviceBaseInfo *findByModalias(DeviceType deviceType, const QString &modalias); - DeviceBaseInfo *findByVIDPID(DeviceType deviceType, const QString &vid, const QString &pid); - DeviceBaseInfo *findByVendorName(DeviceType deviceType, const QString &vendor, const QString &name); bool findByModalias(DeviceType deviceType, DeviceBaseInfo *device, const QString &modalias); bool findByVIDPID(DeviceType deviceType, DeviceBaseInfo *device, const QString &vid, const QString &pid); bool findByVendorName(DeviceType deviceType, DeviceBaseInfo *device, const QString &vendor, const QString &name); + /** * @brief getBluetoothAtIndex 根据索引获取device * @param index @@ -306,13 +304,6 @@ class DeviceManager : public QObject */ bool setBluetoothInfoFromHwinfo(const QMap &mapInfo); - /** - * @brief setBluetoothInfoFromWifiInfo:设置由WifiInfo获取的蓝牙信息 - * @param mapInfo:由WifiInfo获取的蓝牙信息map - * @return 布尔值:true设置成功;false设置失败 - */ - bool setBluetoothInfoFromWifiInfo(const QMap &mapInfo); - /** * @brief getBluetoothDevice * @param unique_id @@ -378,12 +369,6 @@ class DeviceManager : public QObject */ void addNetworkDevice(DeviceNetwork *const device); - /** - * @brief setNetworkInfoFromWifiInfo:设置网络适配器 - * @param mapInfo:由WifiInfo获取的网卡信息map - */ - bool setNetworkInfoFromWifiInfo(const QMap &mapInfo); - /** * @brief getNetworkDevice 获取网卡设备 * @param busInfo diff --git a/deepin-devicemanager/src/DeviceManager/DeviceMonitor.cpp b/deepin-devicemanager/src/DeviceManager/DeviceMonitor.cpp index c84ddf2c1..855474618 100644 --- a/deepin-devicemanager/src/DeviceManager/DeviceMonitor.cpp +++ b/deepin-devicemanager/src/DeviceManager/DeviceMonitor.cpp @@ -60,7 +60,7 @@ QString DeviceMonitor::parseMonitorSize(const QString &sizeDescription, double & double width = m_Width / 2.54; double height = m_Height / 2.54; inch = std::sqrt(width * width + height * height) / 10.0; - res = QString::number(inch, 10, 1) + " " + QObject::tr("inch") + " ("; + res = QString::number(inch, 10, 1) + " " + translateStr("inch") + " ("; res += sizeDescription; res += ")"; } @@ -77,7 +77,7 @@ QString DeviceMonitor::parseMonitorSize(const QString &sizeDescription, double & double width = m_Width / 2.54; double height = m_Height / 2.54; inch = std::sqrt(width * width + height * height) / 10.0; - res = QString::number(inch, 10, 1) + " " + QObject::tr("inch") + " ("; + res = QString::number(inch, 10, 1) + " " + translateStr("inch") + " ("; res += sizeDescription; res += ")"; } @@ -381,7 +381,7 @@ void DeviceMonitor::caculateScreenSize() m_Height = re.cap(2).toInt(); double inch = std::sqrt((m_Width / 2.54) * (m_Width / 2.54) + (m_Height / 2.54) * (m_Height / 2.54)) / 10.0; - m_ScreenSize = QString("%1 %2(%3mm X %4mm)").arg(QString::number(inch, '0', 1)).arg(QObject::tr("inch")).arg(m_Width).arg(m_Height); + m_ScreenSize = QString("%1 %2(%3mm X %4mm)").arg(QString::number(inch, '0', 1)).arg(translateStr("inch")).arg(m_Width).arg(m_Height); } } diff --git a/deepin-devicemanager/src/DeviceManager/DeviceNetwork.cpp b/deepin-devicemanager/src/DeviceManager/DeviceNetwork.cpp index b512df183..27fbe40f5 100644 --- a/deepin-devicemanager/src/DeviceManager/DeviceNetwork.cpp +++ b/deepin-devicemanager/src/DeviceManager/DeviceNetwork.cpp @@ -46,11 +46,6 @@ DeviceNetwork::DeviceNetwork() void DeviceNetwork::setInfoFromLshw(const QMap &mapInfo) { - if (!matchToLshw(mapInfo) - && Common::boardVendorType() != "KLVV" && Common::boardVendorType() != "KLVU" - && Common::boardVendorType() != "PGUW" && Common::boardVendorType() != "PGUV") { - return; - } // 设置由lshw获取的信息 setAttribute(mapInfo, "description", m_Model); setAttribute(mapInfo, "product", m_Name); @@ -185,20 +180,6 @@ bool DeviceNetwork::setInfoFromHwinfo(const QMap &mapInfo) return true; } -bool DeviceNetwork::setInfoFromWifiInfo(const QMap &mapInfo) -{ - // 机器自身蓝牙 - if (m_Name.contains(Common::specialHString(), Qt::CaseInsensitive)) { - setAttribute(mapInfo, "Chip Type", m_Name); - setAttribute(mapInfo, "Vendor", m_Vendor); - setAttribute(mapInfo, "Type", m_Model); - - return true; - } else { - return false; - } -} - void DeviceNetwork::setIsWireless(const QString &sysfs) { // 路径下包含 phy80211 或 wireless 是无线网卡 @@ -341,11 +322,11 @@ void DeviceNetwork::loadTableData() QString tName = m_Name; if (!available()) { - tName = "(" + tr("Unavailable") + ") " + m_Name; + tName = "(" + translateStr("Unavailable") + ") " + m_Name; } if (!enable()) { - tName = "(" + tr("Disable") + ") " + m_Name; + tName = "(" + translateStr("Disable") + ") " + m_Name; } // 加载表格数据信息 diff --git a/deepin-devicemanager/src/DeviceManager/DeviceNetwork.h b/deepin-devicemanager/src/DeviceManager/DeviceNetwork.h index 5e02a2183..6b050289a 100644 --- a/deepin-devicemanager/src/DeviceManager/DeviceNetwork.h +++ b/deepin-devicemanager/src/DeviceManager/DeviceNetwork.h @@ -39,13 +39,6 @@ class DeviceNetwork : public DeviceBaseInfo */ bool setInfoFromHwinfo(const QMap &mapInfo); - /** - * @brief setInfoFromWifiInfo:设置从cat /sys/hisys/wal/wifi_devices_info里面获取的信息 - * @param mapInfo: 由cat /sys/hisys/wal/wifi_devices_info获取的信息map - * @return 布尔值,true:信息设置成功;false:信息设置失败 - */ - bool setInfoFromWifiInfo(const QMap &mapInfo); - /** * @brief setIsWireless: 设置是否是无线网 * @param sysFSID: SysFS ID: /class/net/enp2s0 diff --git a/deepin-devicemanager/src/DeviceManager/DeviceOthers.cpp b/deepin-devicemanager/src/DeviceManager/DeviceOthers.cpp index bf5956366..96e1b6486 100644 --- a/deepin-devicemanager/src/DeviceManager/DeviceOthers.cpp +++ b/deepin-devicemanager/src/DeviceManager/DeviceOthers.cpp @@ -204,10 +204,10 @@ void DeviceOthers::loadTableData() // 加载表格数据 QString tName = m_Name; if (!available()) { - tName = "(" + tr("Unavailable") + ") " + m_Name; + tName = "(" + translateStr("Unavailable") + ") " + m_Name; } if (!enable()) { - tName = "(" + tr("Disable") + ") " + m_Name; + tName = "(" + translateStr("Disable") + ") " + m_Name; } m_TableData.append(tName); diff --git a/deepin-devicemanager/src/DeviceManager/DevicePower.cpp b/deepin-devicemanager/src/DeviceManager/DevicePower.cpp index 477bacf66..2146f2e96 100644 --- a/deepin-devicemanager/src/DeviceManager/DevicePower.cpp +++ b/deepin-devicemanager/src/DeviceManager/DevicePower.cpp @@ -69,7 +69,6 @@ bool DevicePower::setInfoFromUpower(const QMap &mapInfo) if (mapInfo["Device"].contains("line_power", Qt::CaseInsensitive)) { return false; } - // m_Name = QObject::tr("battery"); setAttribute(mapInfo, "", m_Vendor); setAttribute(mapInfo, "", m_Model); @@ -107,7 +106,7 @@ bool DevicePower::setInfoFromUpower(const QMap &mapInfo) void DevicePower::setDaemonInfo(const QMap &mapInfo) { // 设置守护进程信息 - if (m_Name == QObject::tr("battery")) + if (m_Name == translateStr("battery")) getOtherMapInfo(mapInfo); } diff --git a/deepin-devicemanager/src/DeviceManager/DevicePrint.cpp b/deepin-devicemanager/src/DeviceManager/DevicePrint.cpp index 63636b6fc..3fe00334f 100644 --- a/deepin-devicemanager/src/DeviceManager/DevicePrint.cpp +++ b/deepin-devicemanager/src/DeviceManager/DevicePrint.cpp @@ -160,7 +160,7 @@ void DevicePrint::loadOtherDeviceInfo() addOtherDeviceInfo(("URI"), m_URI); addOtherDeviceInfo(("Status"), m_Status); addOtherDeviceInfo(("Interface Type"), m_InterfaceType); - addOtherDeviceInfo(QObject::tr("printer-make-and-model"), m_MakeAndModel); + addOtherDeviceInfo(("printer-make-and-model"), m_MakeAndModel); // 将QMap内容转存为QList> mapInfoToList(); } @@ -170,7 +170,7 @@ void DevicePrint::loadTableData() // 加载表格数据 QString tName = m_Name; if (!enable()) { - tName = "(" + tr("Disable") + ") " + m_Name; + tName = "(" + translateStr("Disable") + ") " + m_Name; } m_TableData.append(tName); diff --git a/deepin-devicemanager/src/DeviceManager/DeviceStorage.cpp b/deepin-devicemanager/src/DeviceManager/DeviceStorage.cpp index 51089ba4b..3cefed1ed 100644 --- a/deepin-devicemanager/src/DeviceManager/DeviceStorage.cpp +++ b/deepin-devicemanager/src/DeviceManager/DeviceStorage.cpp @@ -124,19 +124,6 @@ void DeviceStorage::unitConvertByDecimal() { if(m_SizeBytes > 0) m_Size = decimalkilos(m_SizeBytes); - - quint64 gbyte = 1000000000; - if (m_Interface.contains("UFS", Qt::CaseInsensitive)) { - if(m_SizeBytes > 255*gbyte && m_SizeBytes < 257*gbyte) { - m_Size = "256 GB"; - } else if(m_SizeBytes > 511*gbyte && m_SizeBytes < 513*gbyte) { - m_Size = "512 GB"; - } else if(m_SizeBytes > 999*gbyte && m_SizeBytes < 1025*gbyte) { - m_Size = "1 TB"; - } else if(m_SizeBytes > 1999*gbyte && m_SizeBytes < 2049*gbyte) { - m_Size = "2 TB"; - } - } } bool DeviceStorage::setHwinfoInfo(const QMap &mapInfo) @@ -355,11 +342,11 @@ bool DeviceStorage::setMediaType(const QString &name, const QString &value) return false; if (QString("0") == value) - m_MediaType = QObject::tr("SSD"); + m_MediaType = "SSD"; else if (QString("1") == value) - m_MediaType = QObject::tr("HDD"); + m_MediaType = "HDD"; else - m_MediaType = QObject::tr("Unknown"); + m_MediaType = "Unknown"; return true; } @@ -416,7 +403,7 @@ void DeviceStorage::appendDisk(DeviceStorage *device) } quint64 size2 = device->getDiskSizeByte(); - if(m_SizeBytes == 0) + if (m_SizeBytes == 0) m_SizeBytes = size2; else if (size2 > 0) { m_SizeBytes += size2; @@ -435,11 +422,10 @@ void DeviceStorage::appendDisk(DeviceStorage *device) } QStringList keyList; - keyList.append(QObject::tr("bus info")); - keyList.append(QObject::tr("Device File")); - // keyList.append(QObject::tr("physical id")); - keyList.append(QObject::tr("Device Number")); - keyList.append(QObject::tr("logical name")); + keyList.append(translateStr("bus info")); + keyList.append(translateStr("Device File")); + keyList.append(translateStr("Device Number")); + keyList.append(translateStr("logical name")); for (QString keyStr : keyList) { QString curBusInfo = curAllOtherAttribMaps[keyStr]; QString busInfo = allAttribMaps[keyStr]; @@ -453,16 +439,31 @@ void DeviceStorage::appendDisk(DeviceStorage *device) void DeviceStorage::checkDiskSize() { - QRegExp reg("[0-9]*.?[0-9]*"); - int index = reg.indexIn(m_Size); - // index>0时,对于"32GB"(数字开头的字符串,index=0)无法获取正确的数据32 - // 所以要改为index >= 0 - if (index >= 0) { - double num = reg.cap(0).toDouble(); - double num1 = num - int(num); - QString type = m_Size.right(m_Size.length() - reg.cap(0).size()).trimmed(); - if (!qFuzzyCompare(num1, 0.0) && type == "GB") { - m_Size = QString::number(int(num) + 1) + " " + type; + if (Common::specialVendorType() != Common::specialHString()) { + return; //定制机型专用,其它慎用 + } + + quint64 gbyte = 1000000000; + if (m_Interface.contains("UFS", Qt::CaseInsensitive)) { + if (m_SizeBytes > 255*gbyte && m_SizeBytes < 257*gbyte) { + m_Size = "256 GB"; + } else if (m_SizeBytes > 511*gbyte && m_SizeBytes < 513*gbyte) { + m_Size = "512 GB"; + } else if (m_SizeBytes > 999*gbyte && m_SizeBytes < 1025*gbyte) { + m_Size = "1 TB"; + } else if (m_SizeBytes > 1999*gbyte && m_SizeBytes < 2049*gbyte) { + m_Size = "2 TB"; + } + } + if (m_Interface.contains("USB", Qt::CaseInsensitive)) { + if (m_SizeBytes > 15*gbyte && m_SizeBytes < 17*gbyte) { + m_Size = "16 GB"; + } else if (m_SizeBytes > 31*gbyte && m_SizeBytes < 33*gbyte) { + m_Size = "32 GB"; + } else if (m_SizeBytes > 63*gbyte && m_SizeBytes < 65*gbyte) { + m_Size = "64 GB"; + } else if (m_SizeBytes > 127*gbyte && m_SizeBytes < 129*gbyte) { + m_Size = "128 GB"; } } } @@ -542,7 +543,7 @@ void DeviceStorage::loadBaseDeviceInfo() // 添加基本信息 addBaseDeviceInfo(("Name"), m_Name); addBaseDeviceInfo(("Vendor"), m_Vendor); - addBaseDeviceInfo(("Media Type"), m_MediaType); + addBaseDeviceInfo(("Media Type"), translateStr(m_MediaType)); addBaseDeviceInfo(("Size"), m_Size); addBaseDeviceInfo(("Version"), m_Version); addBaseDeviceInfo(("Capabilities"), m_Capabilities); @@ -572,7 +573,7 @@ void DeviceStorage::loadOtherDeviceInfo() addOtherDeviceInfo(("Physical ID"), m_PhysID); if (m_RotationRate == QString("Solid State Device")) { - m_MediaType = QObject::tr("SSD"); + m_MediaType = "SSD"; } // 将QMap内容转存为QList> @@ -597,7 +598,7 @@ void DeviceStorage::loadTableData() } m_TableData.append(model); m_TableData.append(m_Vendor); - m_TableData.append(m_MediaType); + m_TableData.append(translateStr(m_MediaType)); m_TableData.append(m_Size); } @@ -633,7 +634,7 @@ void DeviceStorage::getInfoFromsmartctl(const QMap &mapInfo) { if (mapInfo.size() < 5) { if (!mapInfo.isEmpty() && m_Interface.contains("USB", Qt::CaseInsensitive)) { - m_MediaType = QObject::tr("SSD"); + m_MediaType = "SSD"; } return; } @@ -648,12 +649,9 @@ void DeviceStorage::getInfoFromsmartctl(const QMap &mapInfo) setAttribute(mapInfo, "Rotation Rate", m_RotationRate); // 解决Bug45428,INTEL SSDSA2BW160G3L 这个型号的硬盘通过lsblk获取的rota是1,所以这里需要特殊处理 - if (m_RotationRate == QString("Solid State Device")) - m_MediaType = QObject::tr("SSD"); - - // 按照HW的需求,如果是固态硬盘就不显示转速 - if (m_RotationRate == QString("HW_SSD")) { - m_MediaType = QObject::tr("SSD"); + // 按照H的需求,如果是固态硬盘就不显示转速 + if (m_RotationRate == QString("Solid State Device")) { + m_MediaType = "SSD"; m_RotationRate = ""; } diff --git a/deepin-devicemanager/src/GenerateDevice/CmdTool.cpp b/deepin-devicemanager/src/GenerateDevice/CmdTool.cpp index 826d15196..98a62038d 100644 --- a/deepin-devicemanager/src/GenerateDevice/CmdTool.cpp +++ b/deepin-devicemanager/src/GenerateDevice/CmdTool.cpp @@ -7,6 +7,7 @@ #include #include #include "DDLog.h" +#include "commonfunction.h" // Qt库文件 #include @@ -204,6 +205,16 @@ bool CmdTool::parseOemTomlInfo(const QString filename) file.close(); } } + QString curPathFile2 = "/usr/share/deepin-devicemanager/" + filename; + if (QFile::exists(curPathFile2) && !tomlFileRead) { + QFile file(curPathFile2); + if (file.open(QIODevice::ReadOnly)) { + info = file.readAll().data(); + tomlFileRead = true; + file.close(); + } + } + if (!tomlFileRead) { curPathFile = "/etc/deepin/hardware/oeminfodebug.toml"; //方便调试,并不开放给用户用 QFile file(curPathFile); @@ -240,8 +251,18 @@ bool CmdTool::parseOemTomlInfo(const QString filename) itemMap.clear(); ValueKeyList.clear(); deviceClassesList.append(regClass.cap(2)); -// } else if (regKeyValue.exactMatch(line)) { //键值对= - } else if (line.contains("=")) { + } else if (line.contains("=") && line.contains("{") && line.contains("}")) { //内联表 + int start = line.indexOf("{") + 1; + int end = line.indexOf("}"); + QString value = line.mid(start, end - start).trimmed(); + wordlst = line.split("="); + if (2 <= wordlst.size()) { + QString key = wordlst[0].remove('"').trimmed(); + itemMap.insert(key, value); + ValueKeyList.append(key); + } + + } else if (line.contains("=")) { //键值对= wordlst = line.split("="); if (2 == wordlst.size()) { @@ -638,6 +659,12 @@ void CmdTool::loadDmidecodeInfo(const QString &key, const QString &debugfile) if (("dmidecode1" == key) && (mapInfo.size() > 0)) { QString filename = loadOemTomlFileName(mapInfo); parseOemTomlInfo(filename); + + QString tomlFilesName = Common::tomlFilesNameGet(); + if (!tomlFilesName.isEmpty() && tomlFilesName != "tomlFilesName") { + if (parseOemTomlInfo(tomlFilesName)) + qCInfo(appLog) << "config Toml File name is: /usr/share/deepin-devicemanager/" << tomlFilesName ; + } } // 过滤空cpu卡槽信息 diff --git a/deepin-devicemanager/src/GenerateDevice/DeviceGenerator.cpp b/deepin-devicemanager/src/GenerateDevice/DeviceGenerator.cpp index 0caccbad8..2eed3e0c7 100644 --- a/deepin-devicemanager/src/GenerateDevice/DeviceGenerator.cpp +++ b/deepin-devicemanager/src/GenerateDevice/DeviceGenerator.cpp @@ -32,6 +32,7 @@ // Qt库文件 #include #include +#include DeviceGenerator::DeviceGenerator(QObject *parent) : QObject(parent) @@ -245,85 +246,72 @@ void DeviceGenerator::generatorMonitorDevice() void DeviceGenerator::generatorNetworkDevice() { + bool hasWlan =false; QList lstDevice; - - QDir dir("/sys/class/net"); - // 获取所有的子目录 - QStringList subDirs = dir.entryList(QDir::Dirs | QDir::NoDotAndDotDot); - - foreach (const QString &subDir, subDirs) { - if (subDir.contains("lo", Qt::CaseInsensitive) || subDir.contains("p2p", Qt::CaseInsensitive)) - continue; - - QString addressFilePath = dir.filePath(subDir + "/address"); - QFile addressFile(addressFilePath); - - // 尝试打开文件 - if (addressFile.open(QIODevice::ReadOnly | QIODevice::Text)) { - QTextStream in(&addressFile); - QString address = in.readLine(); // 读取内容 - qDebug() << "Interface:" << subDir << "Address:" << address; - if (address.length() == 17 - && !address.contains("00:00:00:00", Qt::CaseInsensitive) - && !address.contains("ff:ff:ff:ff", Qt::CaseInsensitive)) { - - DeviceNetwork *device = new DeviceNetwork(); - QMap tempMap; - tempMap["Logical Name"] = subDir; - tempMap["MAC Address"] = address; - DeviceManager::instance()->tomlDeviceMapSet(DT_Network, device,tempMap); - lstDevice.append(device); - } - addressFile.close(); - } else { - qDebug() << "Failed to open file:" << addressFilePath; - } - } - // 设置从lshw中获取的信息 const QList> &lstLshw = DeviceManager::instance()->cmdInfo("lshw_network"); for (QList >::const_iterator it = lstLshw.begin(); it != lstLshw.end(); ++it) { - if ((*it).find("serial") == (*it).end() && (*it).find("logical name") == (*it).end()) + if ((*it).find("serial") == (*it).end() || (*it).find("logical name") == (*it).end()) continue; - const QString &serialNumberLshw = (*it)["serial"]; const QString &logicalNameLshw = (*it)["logical name"]; - for (QList::iterator itDevice = lstDevice.begin(); itDevice != lstDevice.end(); ++itDevice) { - const QString &serialNumberLst = (*itDevice)->hwAddress(); - const QString &logicalNameLst = (*itDevice)->logicalName(); - if (serialNumberLshw == serialNumberLst || logicalNameLshw == logicalNameLst) { - (*itDevice)->setInfoFromLshw(*it); - } - } - } - - const QList> &lstHWInfo = DeviceManager::instance()->cmdInfo("hwinfo_network"); - for (QList >::const_iterator it = lstHWInfo.begin(); it != lstHWInfo.end(); ++it) { - - // 先判断是否是有效网卡信息 - // 符合两种情况中的一种 1. "HW Address" 和 "Permanent HW Address" 都必须有 2. 有 "unique_id" - if (((*it).find("HW Address") == (*it).end() && (*it).find("Permanent HW Address") == (*it).end()) && ((*it).find("unique_id") == (*it).end())) { + const QString &macAddressLshw = (*it)["serial"]; + if (logicalNameLshw.contains("p2p", Qt::CaseInsensitive)) continue; + if (logicalNameLshw.contains("wlan", Qt::CaseInsensitive) && hasWlan) //common sense: one PC only have 1 wlan device + continue; + if (macAddressLshw.contains("00:00:00:00:00:00", Qt::CaseInsensitive) || macAddressLshw.contains("ff:ff:ff:ff:ff:ff", Qt::CaseInsensitive) || macAddressLshw.isEmpty()) + continue; + // Regular expression for validating MAC address + QRegularExpression macRegex("([0-9A-Fa-f]{2}[:-]){5}([0-9A-Fa-f]{2})"); + if (!macRegex.match(macAddressLshw).hasMatch()) + continue; + + QString addressFilePath = "/sys/class/net/" + logicalNameLshw; + QDir dir(addressFilePath); + if (dir.exists()) { + DeviceNetwork *device = new DeviceNetwork(); + device->setInfoFromLshw(*it); + lstDevice.append(device); + if (logicalNameLshw.contains("wlan", Qt::CaseInsensitive)) + hasWlan = true; } - - const QString &serialNumberLshw = (*it)["HW Address"]; - const QString &logicalNameLshw = (*it)["Device File"]; - for (QList::iterator itDevice = lstDevice.begin(); itDevice != lstDevice.end(); ++itDevice) { - const QString &serialNumberLst = (*itDevice)->hwAddress(); - const QString &logicalNameLst = (*itDevice)->logicalName(); - if (serialNumberLshw == serialNumberLst || logicalNameLshw == logicalNameLst) { - // (*itDevice)->setEnableValue(false); - (*itDevice)->setInfoFromHwinfo(*it); - } - } - } + const QList> &lstHWInfo = DeviceManager::instance()->cmdInfo("hwinfo_network"); + for (QList >::const_iterator it = lstHWInfo.begin(); it != lstHWInfo.end(); ++it) { + + // 先判断是否是有效网卡信息 + // 符合两种情况中的一种 1. "HW Address" 和 "Permanent HW Address" 都必须有 2. 有 "unique_id" + if (((*it).find("HW Address") == (*it).end() && (*it).find("Permanent HW Address") == (*it).end()) && ((*it).find("unique_id") == (*it).end())) { + continue; + } + + const QString &serialNumberHwinfo = (*it)["HW Address"]; + const QString &logicalNameHwinfo = (*it)["Device File"]; + for (QList::iterator itDevice = lstDevice.begin(); itDevice != lstDevice.end(); ++itDevice) { + const QString &serialNumberLst = (*itDevice)->hwAddress(); + const QString &logicalNameLst = (*itDevice)->logicalName(); + // 如果(*it)中包含unique_id属性,则说明是从数据库里面获取的,否则是从hwinfo中获取的 + if ((*it).find("unique_id") != (*it).end()) { + const QString &unique_id = (*it)["unique_id"]; + if (!unique_id.isEmpty() && (*itDevice)->uniqueID() == unique_id) { + (*itDevice)->setEnableValue(false); + } + + } else if (serialNumberHwinfo == serialNumberLst || logicalNameHwinfo == logicalNameLst) { + (*itDevice)->setInfoFromHwinfo(*it); + } else { + (*itDevice)->setCanUninstall(false); + (*itDevice)->setForcedDisplay(true); + } + } + } + foreach (DeviceNetwork *device, lstDevice) { DeviceManager::instance()->addNetworkDevice(device); } } - void DeviceGenerator::generatorAudioDevice() { // 生成音频适配器 @@ -604,6 +592,9 @@ void DeviceGenerator::getDiskInfoFromSmartCtl() const QList> &lstMap = DeviceManager::instance()->cmdInfo("smart"); QList >::const_iterator it = lstMap.begin(); for (; it != lstMap.end(); ++it) { + // 剔除未识别的磁盘 + if (!(*it).contains("ln")) + continue; DeviceManager::instance()->setStorageInfoFromSmartctl((*it)["ln"], *it); } } diff --git a/deepin-devicemanager/src/GenerateDevice/HWGenerator.cpp b/deepin-devicemanager/src/GenerateDevice/HWGenerator.cpp index c067a1813..a06420f3a 100644 --- a/deepin-devicemanager/src/GenerateDevice/HWGenerator.cpp +++ b/deepin-devicemanager/src/GenerateDevice/HWGenerator.cpp @@ -14,6 +14,7 @@ #include #include #include +#include // 其它头文件 #include "DeviceManager/DeviceManager.h" @@ -90,16 +91,6 @@ void HWGenerator::generatorCpuDevice() { DeviceGenerator::generatorCpuDevice(); DeviceManager::instance()->setCpuFrequencyIsCur(false); - - if (boardVendorType == "KLVV") { - QList lst = DeviceManager::instance()->convertDeviceList(DT_Cpu); - for (int i = 0; i < lst.size(); i++) { - QMap tempMap; - tempMap["Name"] = "Kirin 9006C"; - DeviceBaseInfo *device = lst[i]; - DeviceManager::instance()->tomlDeviceMapSet(DT_Cpu, device,tempMap); - } - } } void HWGenerator::generatorAudioDevice() @@ -107,19 +98,70 @@ void HWGenerator::generatorAudioDevice() getAudioInfoFromCatAudio(); } +QList > readFileSysWifi() +{ + QList > lstWifiInfo; + QString wifiDevicesInfoPath("/sys/hisys/wal/wifi_devices_info"); + QFile file(wifiDevicesInfoPath); + if (file.open(QIODevice::ReadOnly)) { + QMap wifiInfo; + QString allStr = file.readAll(); + file.close(); + + // 解析数据 + QStringList items = allStr.split("\n"); + foreach (const QString &item, items) { + if (item.isEmpty()) + continue; + + QStringList strList = item.split(':', QString::SkipEmptyParts); + if (strList.size() == 2) + wifiInfo[strList[0] ] = strList[1]; + } + + if (!wifiInfo.isEmpty()) + lstWifiInfo.append(wifiInfo); + } + return lstWifiInfo; +} void HWGenerator::generatorBluetoothDevice() { getBluetoothInfoFromHciconfig(); getBlueToothInfoFromHwinfo(); getBluetoothInfoFromLshw(); - getBluetoothInfoFromCatWifiInfo(); + + QList > lstWifiInfo = readFileSysWifi(); + if (lstWifiInfo.size() == 0) { + return; + } + QList >::const_iterator it = lstWifiInfo.begin(); + QMap tempMap; + for (; it != lstWifiInfo.end(); ++it) { + if ((*it).size() < 3) { + continue; + } + + // KLU的问题特殊处理 + foreach (const QString &key, (*it).keys()) { + tempMap.insert(key, (*it)[key]); + } + + // cat /sys/hisys/wal/wifi_devices_info 获取结果为 HI103 + if (tempMap["Chip Type"].contains(Common::specialHString(), Qt::CaseInsensitive)) { + tempMap["Chip Type"] = tempMap["Chip Type"].remove(Common::specialHString()).trimmed(); + } + + // 按照华为的需求,设置蓝牙制造商和类型 + tempMap["Vendor"] = Common::specialHString(); + tempMap["Type"] = "Bluetooth Device"; + tempMap["Name"] = tempMap["Chip Type"]; + } + QList lst = DeviceManager::instance()->convertDeviceList(DT_Bluetoorh); for (int i = 0; i < lst.size(); i++) { DeviceBaseInfo *device = lst[i]; - QString vendor = DeviceManager::instance()->tomlDeviceReadKeyValue(DT_Bluetoorh, device, "Vendor"); - if (vendor.contains("HISILICON",Qt::CaseInsensitive)) { - QMap tempMap; - tempMap["Vendor"] = Common::specialHString(); + QString bus = DeviceManager::instance()->tomlDeviceReadKeyValue(DT_Bluetoorh, device, "Bus"); //内置:UART 外接USB:USB + if (bus.contains("UART",Qt::CaseInsensitive)) { DeviceManager::instance()->tomlDeviceMapSet(DT_Bluetoorh, device,tempMap); } } @@ -171,16 +213,49 @@ void HWGenerator::generatorNetworkDevice() { DeviceGenerator::generatorNetworkDevice(); - if (boardVendorType == "KLVV") { - getNetworkInfoFromCatWifiInfo(); + QList > lstWifiInfo = readFileSysWifi(); + if (lstWifiInfo.size() == 0) { + return; } + QList >::const_iterator it = lstWifiInfo.begin(); + for (; it != lstWifiInfo.end(); ++it) { + if ((*it).size() < 3) { + continue; + } + + // cat /sys/hisys/wal/wifi_devices_info的问题特殊处理 获取结果为 HI103 + QMap tempMap; + foreach (const QString &key, (*it).keys()) { + tempMap.insert(key, (*it)[key]); + } + + tempMap["Name"] = tempMap["Chip Type"]; + if (tempMap["Chip Type"].contains(Common::specialHString(), Qt::CaseInsensitive)) { + tempMap["Name"] = tempMap["Chip Type"].remove(Common::specialHString()).trimmed(); + } + + if (tempMap["NIC Type"].contains("WLAN", Qt::CaseInsensitive)) { + } + + // 按照华为的需求,设置蓝牙制造商和类型 + tempMap["Vendor"] = "HISILICON"; + tempMap["Type"] = "Wireless network"; + + QList lst = DeviceManager::instance()->convertDeviceList(DT_Network); + for (int i = 0; i < lst.size(); i++) { + DeviceBaseInfo *device = lst[i]; + QString logicalName = DeviceManager::instance()->tomlDeviceReadKeyValue(DT_Network, device, "Logical Name"); + if (logicalName.contains("wlan", Qt::CaseInsensitive)) { + DeviceManager::instance()->tomlDeviceMapSet(DT_Network, device,tempMap); + } + } + } } void HWGenerator::generatorDiskDevice() { DeviceGenerator::generatorDiskDevice(); - DeviceManager::instance()->checkDiskSize(); QString bootdevicePath("/proc/bootdevice/product_name"); QString modelStr = ""; @@ -189,7 +264,7 @@ void HWGenerator::generatorDiskDevice() modelStr = file.readLine().simplified(); file.close(); } - if(modelStr.isEmpty()) + if (modelStr.isEmpty()) return; QList lst = DeviceManager::instance()->convertDeviceList(DT_Storage); @@ -205,28 +280,26 @@ void HWGenerator::generatorDiskDevice() tempMap["Name"] = "nouse"; // 应HW的要求,将描述固定为 Universal Flash Storage tempMap["Description"] = "Universal Flash Storage"; - // 应HW的要求,添加interface UFS 3.1 - - if (boardVendorType == "KLVV") - tempMap["Interface"] = "UFS 3.1"; - else if (boardVendorType == "KLVU") { - // 读取interface版本 - QProcess process; - process.start("cat /sys/devices/platform/f8200000.ufs/host0/scsi_host/host0/wb_en"); - process.waitForFinished(-1); - int exitCode = process.exitCode(); - if (exitCode != 127 && exitCode != 126) { - QString deviceInfo = process.readAllStandardOutput(); - if (deviceInfo.trimmed() == "true") { - process.start("cat /sys/block/sdd/device/spec_version"); - process.waitForFinished(-1); - exitCode = process.exitCode(); - if (exitCode != 127 && exitCode != 126) { - deviceInfo = process.readAllStandardOutput(); - if (deviceInfo.trimmed() == "310") { - tempMap["interface"] = "UFS 3.1"; - } - } + // 应H的要求,添加interface UFS 3.1 + tempMap["Interface"] = "UFS 3.1"; + + // 读取interface版本 + QProcess process; + process.start("cat /sys/devices/platform/f8200000.ufs/host0/scsi_host/host0/wb_en"); + process.waitForFinished(-1); + int exitCode = process.exitCode(); + if (exitCode != 127 && exitCode != 126) { + QString deviceInfo = process.readAllStandardOutput(); + if (deviceInfo.trimmed() == "true") { + process.start("cat /sys/block/sdd/device/spec_version"); + process.waitForFinished(-1); + exitCode = process.exitCode(); + if (exitCode != 127 && exitCode != 126) { + deviceInfo = process.readAllStandardOutput(); + if (deviceInfo.trimmed() == "310") { + tempMap["interface"] = "UFS 3.1"; + } else if (deviceInfo.trimmed() == "300") + tempMap["interface"] = "UFS 3.0"; } } } @@ -234,6 +307,8 @@ void HWGenerator::generatorDiskDevice() DeviceManager::instance()->tomlDeviceMapSet(DT_Storage, device,tempMap); } } + + DeviceManager::instance()->checkDiskSize(); //place in the end } void HWGenerator::getAudioInfoFromCatAudio() @@ -263,29 +338,6 @@ void HWGenerator::getAudioInfoFromCatAudio() } } -void HWGenerator::getDiskInfoFromSmartCtl() -{ - const QList> lstMap = DeviceManager::instance()->cmdInfo("smart"); - QList >::const_iterator it = lstMap.begin(); - for (; it != lstMap.end(); ++it) { - // 剔除未识别的磁盘 - if (!(*it).contains("ln")) - continue; - - // KLU的问题特殊处理 - QMap tempMap; - foreach (const QString &key, (*it).keys()) { - tempMap.insert(key, (*it)[key]); - } - - // 按照HW的需求,如果是固态硬盘就不显示转速 - if (tempMap["Rotation Rate"] == "Solid State Device") - tempMap["Rotation Rate"] = "HW_SSD"; - - DeviceManager::instance()->setStorageInfoFromSmartctl(tempMap["ln"], tempMap); - } -} - void HWGenerator::getBluetoothInfoFromHciconfig() { const QList> lstMap = DeviceManager::instance()->cmdInfo("hciconfig"); @@ -332,60 +384,6 @@ void HWGenerator::getBluetoothInfoFromLshw() } } -void HWGenerator::getBluetoothInfoFromCatWifiInfo() -{ - QList > lstWifiInfo; - QString wifiDevicesInfoPath("/sys/hisys/wal/wifi_devices_info"); - QFile file(wifiDevicesInfoPath); - if (file.open(QIODevice::ReadOnly)) { - QMap wifiInfo; - QString allStr = file.readAll(); - file.close(); - - // 解析数据 - QStringList items = allStr.split("\n"); - foreach (const QString &item, items) { - if (item.isEmpty()) - continue; - - QStringList strList = item.split(':', QString::SkipEmptyParts); - if (strList.size() == 2) - wifiInfo[strList[0] ] = strList[1]; - } - - if (!wifiInfo.isEmpty()) - lstWifiInfo.append(wifiInfo); - } - - if (lstWifiInfo.size() == 0) { - return; - } - QList >::const_iterator it = lstWifiInfo.begin(); - - for (; it != lstWifiInfo.end(); ++it) { - if ((*it).size() < 3) { - continue; - } - - // KLU的问题特殊处理 - QMap tempMap; - foreach (const QString &key, (*it).keys()) { - tempMap.insert(key, (*it)[key]); - } - - // cat /sys/hisys/wal/wifi_devices_info 获取结果为 HI103 - if (tempMap["Chip Type"].contains(Common::specialHString(), Qt::CaseInsensitive)) { - tempMap["Chip Type"] = tempMap["Chip Type"].remove(Common::specialHString()).trimmed(); - } - - // 按照华为的需求,设置蓝牙制造商和类型 - tempMap["Vendor"] = "HISILICON"; - tempMap["Type"] = "Bluetooth Device"; - - DeviceManager::instance()->setBluetoothInfoFromWifiInfo(tempMap); - } -} - void HWGenerator::getMemoryInfoFromLshw() { // 从lshw中获取内存信息 @@ -422,14 +420,14 @@ static void parseEDID(QStringList allEDIDS,QString input) process.waitForFinished(-1); QString deviceInfo = process.readAllStandardOutput(); - if(deviceInfo.isEmpty()) + if (deviceInfo.isEmpty()) continue; QString edidStr; QStringList lines = deviceInfo.split("\n"); for (auto line:lines) { QStringList words = line.trimmed().split(" "); - if(words.size() != 9) + if (words.size() != 9) continue; words.removeAt(0); @@ -439,7 +437,7 @@ static void parseEDID(QStringList allEDIDS,QString input) } lines = edidStr.split("\n"); - if(lines.size() > 3){ + if (lines.size() > 3){ EDIDParser edidParser; QString errorMsg; edidParser.setEdid(edidStr,errorMsg,"\n", false); @@ -460,20 +458,18 @@ static void parseEDID(QStringList allEDIDS,QString input) void HWGenerator::generatorMonitorDevice() { - if (boardVendorType == "KLVV" || boardVendorType == "KLVU") { - QMap mapInfo; - mapInfo.insert("Name", "LCD"); - mapInfo.insert("Current Resolution", "2160x1440"); - mapInfo.insert("Support Resolution", "2160x1440"); - mapInfo.insert("Size", "14 Inch"); - mapInfo.insert("Interface Type", "eDP"); - mapInfo.insert("Refresh Rate", "60Hz"); - - DeviceMonitor *monitor = new DeviceMonitor(); - monitor->setInfoFromTomlBase(mapInfo); - monitor->setInfoFromTomlOneByOne(mapInfo); - DeviceManager::instance()->addMonitor(monitor); - } + QMap mapInfo; + mapInfo.insert("Name", "LCD"); + mapInfo.insert("Current Resolution", "2160x1440"); + mapInfo.insert("Support Resolution", "2160x1440"); + mapInfo.insert("Size", "14 Inch"); + mapInfo.insert("Interface Type", "eDP"); + mapInfo.insert("Refresh Rate", "60Hz"); + + DeviceMonitor *monitor = new DeviceMonitor(); + monitor->setInfoFromTomlBase(mapInfo); + monitor->setInfoFromTomlOneByOne(mapInfo); + DeviceManager::instance()->addMonitor(monitor); QString toDir = "/sys/class/drm"; QDir toDir_(toDir); @@ -483,10 +479,10 @@ void HWGenerator::generatorMonitorDevice() QFileInfoList fileInfoList = toDir_.entryInfoList(); foreach(QFileInfo fileInfo, fileInfoList) { - if(fileInfo.fileName() == "." || fileInfo.fileName() == ".." || !fileInfo.fileName().startsWith("card")) + if (fileInfo.fileName() == "." || fileInfo.fileName() == ".." || !fileInfo.fileName().startsWith("card")) continue; - if(QFile::exists(fileInfo.filePath() + "/" + "edid")) { + if (QFile::exists(fileInfo.filePath() + "/" + "edid")) { QStringList allEDIDS_all; allEDIDS_all.append(fileInfo.filePath() + "/" + "edid"); QString interface = fileInfo.fileName().remove("card0-").remove("card1-").remove("card2-"); @@ -498,136 +494,30 @@ void HWGenerator::generatorMonitorDevice() void HWGenerator::generatorPowerDevice() { DeviceGenerator::generatorPowerDevice(); - - QList lst = DeviceManager::instance()->convertDeviceList(DT_Power); - for (int i = 0; i < lst.size(); i++) { - DeviceBaseInfo *device = lst[i]; - QMap tempMap; - tempMap["energy-full-design"] = "nouse"; - tempMap["energy-full"] = "nouse"; - tempMap["Design Capacity"] = "56 Wh"; - DeviceManager::instance()->tomlDeviceMapSet(DT_Power, device,tempMap); - } } void HWGenerator::generatorKeyboardDevice() { DeviceGenerator::generatorKeyboardDevice(); - - QList lst = DeviceManager::instance()->convertDeviceList(DT_Keyboard); - for (int i = 0; i < lst.size(); i++) { - DeviceBaseInfo *device = lst[i]; - QString vendor = DeviceManager::instance()->tomlDeviceReadKeyValue(DT_Keyboard, device, "Vendor"); - if (vendor.contains("14f3",Qt::CaseInsensitive)) { - QMap tempMap; - tempMap["Vendor"] = Common::specialHString(); - DeviceManager::instance()->tomlDeviceMapSet(DT_Keyboard, device,tempMap); - } - } } void HWGenerator::generatorMemoryDevice() { DeviceGenerator::generatorMemoryDevice(); - - QList lst = DeviceManager::instance()->convertDeviceList(DT_Memory); - for (int i = 0; i < lst.size(); i++) { - DeviceBaseInfo *device = lst[i]; - QString vendor = DeviceManager::instance()->tomlDeviceReadKeyValue(DT_Memory, device, "Vendor"); - QString partNumber = DeviceManager::instance()->tomlDeviceReadKeyValue(DT_Memory, device, "Name"); - if (vendor.contains("Samsung",Qt::CaseInsensitive)) { - QMap tempMap; - tempMap["Vendor"] = "nouse"; - tempMap["Part Number"] = "nouse"; - DeviceManager::instance()->tomlDeviceMapSet(DT_Memory, device,tempMap); - } - if (partNumber.contains("K3LK7K70BM",Qt::CaseInsensitive)) { - QMap tempMap; - tempMap["Name"] = "nouse"; - tempMap["Part Number"] = "nouse"; - DeviceManager::instance()->tomlDeviceMapSet(DT_Memory, device,tempMap); - } - } } void HWGenerator::generatorCameraDevice() { DeviceGenerator::generatorCameraDevice(); - if (boardVendorType == "KLVV") { - QList lst = DeviceManager::instance()->convertDeviceList(DT_Image); - for (int i = 0; i < lst.size(); i++) { - DeviceBaseInfo *device = lst[i]; - QString vendor = DeviceManager::instance()->tomlDeviceReadKeyValue(DT_Image, device, "Vendor"); - if (vendor.contains("0000058020",Qt::CaseInsensitive)) { - QMap tempMap; - tempMap["Vendor"] = "nouse"; - DeviceManager::instance()->tomlDeviceMapSet(DT_Image, device,tempMap); - } - } - } -} - -void HWGenerator::getNetworkInfoFromCatWifiInfo() -{ - QList > lstWifiInfo; - QString wifiDevicesInfoPath("/sys/hisys/wal/wifi_devices_info"); - QFile file(wifiDevicesInfoPath); - if (file.open(QIODevice::ReadOnly)) { - QMap wifiInfo; - QString allStr = file.readAll(); - file.close(); - - // 解析数据 - QStringList items = allStr.split("\n"); - foreach (const QString &item, items) { - if (item.isEmpty()) - continue; - - QStringList strList = item.split(':', QString::SkipEmptyParts); - if (strList.size() == 2) - wifiInfo[strList[0] ] = strList[1]; - } - - if (!wifiInfo.isEmpty()) - lstWifiInfo.append(wifiInfo); - } - if (lstWifiInfo.size() == 0) { - return; - } - - QList >::const_iterator it = lstWifiInfo.begin(); - for (; it != lstWifiInfo.end(); ++it) { - if ((*it).size() < 3) { - continue; - } - - // KLU的问题特殊处理 - QMap tempMap; - foreach (const QString &key, (*it).keys()) { - tempMap.insert(key, (*it)[key]); - } - - // cat /sys/hisys/wal/wifi_devices_info 获取结果为 HI103 - tempMap["Name"] = tempMap["Chip Type"]; - if (tempMap["Chip Type"].contains(Common::specialHString(), Qt::CaseInsensitive)) { - tempMap["Name"] = tempMap["Chip Type"].remove(Common::specialHString()).trimmed(); - } - - if (tempMap["NIC Type"].contains("WLAN", Qt::CaseInsensitive)) { - } - - // 按照华为的需求,设置蓝牙制造商和类型 - tempMap["Vendor"] = "HISILICON"; - tempMap["Type"] = "Wireless network"; - - QList lst = DeviceManager::instance()->convertDeviceList(DT_Network); - for (int i = 0; i < lst.size(); i++) { - DeviceBaseInfo *device = lst[i]; - QString logicalName = DeviceManager::instance()->tomlDeviceReadKeyValue(DT_Network, device, "Logical Name"); - if (logicalName.contains("wlan", Qt::CaseInsensitive)) { - DeviceManager::instance()->tomlDeviceMapSet(DT_Network, device,tempMap); - } + QList lst = DeviceManager::instance()->convertDeviceList(DT_Image); + for (int i = 0; i < lst.size(); i++) { + DeviceBaseInfo *device = lst[i]; + QString vendor = DeviceManager::instance()->tomlDeviceReadKeyValue(DT_Image, device, "Vendor"); + if (vendor.contains("0000058020",Qt::CaseInsensitive)) { + QMap tempMap; + tempMap["Vendor"] = "nouse"; + DeviceManager::instance()->tomlDeviceMapSet(DT_Image, device,tempMap); } } } diff --git a/deepin-devicemanager/src/GenerateDevice/HWGenerator.h b/deepin-devicemanager/src/GenerateDevice/HWGenerator.h index 38a9963e8..45276e13b 100644 --- a/deepin-devicemanager/src/GenerateDevice/HWGenerator.h +++ b/deepin-devicemanager/src/GenerateDevice/HWGenerator.h @@ -85,16 +85,6 @@ class HWGenerator : public DeviceGenerator */ virtual void getAudioInfoFromCatAudio() ; - // /** - // * @brief getDiskInfoFromLshw:从lshw获取存储设备信息 - // */ - // virtual void getDiskInfoFromLshw() override; - - /** - * @brief getDiskInfoFromSmartCtl:从smartctl获取存储设备信息 - */ - virtual void getDiskInfoFromSmartCtl() override; - /** * @brief getBluetoothInfoFromHciconfig:hciconfig获取蓝牙信息 */ @@ -110,16 +100,11 @@ class HWGenerator : public DeviceGenerator */ virtual void getBluetoothInfoFromLshw() override; - /**@brief:generator bluetooth info*/ - virtual void getBluetoothInfoFromCatWifiInfo(); - /** * @brief getMemoryInfoFromLshw:从lshw获取内存信息 */ virtual void getMemoryInfoFromLshw() override; - /**@brief:generator network info*/ - virtual void getNetworkInfoFromCatWifiInfo(); }; diff --git a/deepin-devicemanager/src/Page/MainWindow.cpp b/deepin-devicemanager/src/Page/MainWindow.cpp index b1ed0d939..ad4043a43 100644 --- a/deepin-devicemanager/src/Page/MainWindow.cpp +++ b/deepin-devicemanager/src/Page/MainWindow.cpp @@ -427,6 +427,12 @@ void MainWindow::initWindowTitle() Common::specialComType = dconfig->value("specialComType").toInt(); } qCInfo(appLog) << "Common::specialComType value is:" << Common::specialComType; + + if (dconfig && dconfig->isValid() && dconfig->keyList().contains("TomlFilesName")) { + QString tomlFilesName = dconfig->value("TomlFilesName").toString(); + Common::tomlFilesNameSet(tomlFilesName); + } + #endif // 特殊处理 if (!Common::boardVendorType().isEmpty()) diff --git a/deepin-devicemanager/src/commonfunction.cpp b/deepin-devicemanager/src/commonfunction.cpp index 1326e133b..40c94cbe6 100644 --- a/deepin-devicemanager/src/commonfunction.cpp +++ b/deepin-devicemanager/src/commonfunction.cpp @@ -32,7 +32,7 @@ static QMap mapArch = { {"aarch64", "arm64"} static bool initBoardVendorFlag = false; static QString boardVendorKey = ""; int Common::specialComType = -1; - +static QString tomlFilesName = "tomlFilesName"; QString Common::getArch() { QString arch; @@ -197,6 +197,16 @@ QString Common::specialHString() return result; } +void Common::tomlFilesNameSet(QString name) +{ + tomlFilesName = name; +} + +QString Common::tomlFilesNameGet() +{ + return tomlFilesName; +} + QByteArray Common::executeClientCmd(const QString &cmd, const QStringList &args, const QString &workPath, int msecsWaiting/* = 30000*/) { QProcess process; diff --git a/deepin-devicemanager/src/commonfunction.h b/deepin-devicemanager/src/commonfunction.h index 68808b5a7..32a5124dc 100644 --- a/deepin-devicemanager/src/commonfunction.h +++ b/deepin-devicemanager/src/commonfunction.h @@ -33,6 +33,9 @@ class Common static QString boardVendorType(); static QString specialVendorType(); static QString specialHString(); + static QString tomlFilesNameGet(); + static void tomlFilesNameSet(QString name); + /** * @brief specialComType * special computer type:PGUW(value:1),KLVV/L540(value:2),KLVU(value:3),PGUV/W585(value:4) diff --git a/deepin-devicemanager/src/main.cpp b/deepin-devicemanager/src/main.cpp index b385d2f6f..c12e182c0 100644 --- a/deepin-devicemanager/src/main.cpp +++ b/deepin-devicemanager/src/main.cpp @@ -89,12 +89,13 @@ int main(int argc, char *argv[]) if (!DGuiApplicationHelper::instance()->setSingleInstance(app.applicationName(), DGuiApplicationHelper::UserScope)) { exit(0); } +#ifndef DISABLE_POLKIT Authority::Result result = Authority::instance()->checkAuthorizationSync("com.deepin.deepin-devicemanager.checkAuthentication", UnixProcessSubject(getpid()), Authority::AllowUserInteraction); if (result != Authority::Yes) return 0; - +#endif DApplicationSettings settinAgs; Dtk::Core::DLogManager::registerFileAppender(); diff --git a/deepin-devicemanager/translations/deepin-devicemanager_zh_CN.ts b/deepin-devicemanager/translations/deepin-devicemanager_zh_CN.ts index 92b65179c..0896238af 100644 --- a/deepin-devicemanager/translations/deepin-devicemanager_zh_CN.ts +++ b/deepin-devicemanager/translations/deepin-devicemanager_zh_CN.ts @@ -885,6 +885,91 @@ 卸载驱动 + + TableWidget + + + + Disable + 禁用 + + + + Refresh + 刷新 + + + + Export + 导出 + + + + Update drivers + 更新驱动 + + + + Uninstall drivers + 卸载驱动 + + + + Allow it to wake the computer + 允许唤起电脑 + + + + + Enable + 启用 + + + + + TextBrowser + + + Refresh + 刷新 + + + + Export + 导出 + + + + Copy + 复制 + + + + Disable + 禁用 + + + + Unavailable + 不可用 + + + + UrlChooserEdit + + + Select a local folder please + 请选择本地文件夹 + + + + WaitingWidget + + + Loading... + 正在载入... + + QObject @@ -919,14 +1004,6 @@ No motherboard found 未发现主板 - - - - - - Memory - 内存 - @@ -1584,1821 +1661,1686 @@ Install 安装 + + + DeviceBaseInfo - + One - + Two - + Four - + Six - + Eight - + Nine - + Ten - + Twelve 十二 - + Fourteen 十四 - + Sixteen 十六 - + Eighteen 十八 - + Twenty 二十 - + Twenty-two 二十二 - + Twenty-four 二十四 - + Twenty-six 二十六 - + Twenty-eight 二十八 - + Thirty 三十 - + Thirty-two 三十二 - + Thirty-four 三十四 - + Thirty-six 三十六 - + Thirty-eight 三十八 - + Forty 四十 - + Forty-two 四十二 - + Forty-four 四十四 - + Forty-six 四十六 - + Forty-eight 四十八 - + Fifty 五十 - + Fifty-two 五十二 - + Fifty-four 五十四 - + Fifty-six 五十六 - + Fifty-eight 五十八 - + Sixty 六十 - + Sixty-two 六十二 - + Sixty-four 六十四 - + Sixty-six 六十六 - + Sixty-eight 六十八 - + Seventy 七十 - + Seventy-two 七十二 - + Seventy-four 七十四 - + Seventy-six 七十六 - + Seventy-eight 七十八 - + Eighty 八十 - + Eighty-two 八十二 - + Eighty-four 八十四 - + Eighty-six 八十六 - + Eighty-eight 八十八 - + Ninety 九十 - + Ninety-two 九十二 - + Ninety-four 九十四 - + Ninety-six 九十六 - + Ninety-eight 九十八 - + One hundred 一百 - + One hundred and Two 一百零二 - + One hundred and four 一百零四 - + One hundred and Six 一百零六 - + One hundred and Eight 一百零八 - + One hundred and Ten 一百一十 - + One hundred and Twelve 一百一十二 - + One hundred and Fourteen 一百一十四 - + One hundred and Sixteen 一百一十六 - + One hundred and Eighteen 一百一十八 - + One hundred and Twenty 一百二十 - + One hundred and Twenty-two 一百二十二 - + One hundred and Twenty-four 一百二十四 - + One hundred and Twenty-six 一百二十六 - + One hundred and Twenty-eight 一百二十八 - + One hundred and Ninety-two 一百九十二 - + Two hundred and fifty-six 二百五十六 - - Core(s) - - - - - BIOS Information - BIOS信息 - - - - Base Board Information - 主板信息 - - - - System Information - 系统信息 - - - - Chassis Information - 机箱信息 - - - - Physical Memory Array - 内存插槽信息 - - - - Processor - 逻辑处理器 - - - - - inch - 英寸 - - - - - - - - - SSD - 固态 - - - - TableWidget - - - - Disable - 禁用 - - - - Refresh - 刷新 - - - - Export - 导出 - - - - Update drivers - 更新驱动 - - - - Uninstall drivers - 卸载驱动 - - - - Allow it to wake the computer - 允许唤起电脑 - - - - - Enable - 启用 - - - - - TextBrowser - - - Refresh - 刷新 - - - - Export - 导出 - - - - Copy - 复制 - - - - Disable - 禁用 - - - - Unavailable - 不可用 - - - - UrlChooserEdit - - - Select a local folder please - 请选择本地文件夹 - - - - WaitingWidget - - - Loading... - 正在载入... - - - - DeviceBaseInfo - - + Device Name 设备名称 - - + + Vendor 制造商 - + Chip 芯片 - - + + Physical ID 物理ID - + SysFS_Path - + Revision - + KernelModeDriver - + IRQ 中断 - + Disable 禁用 - + Version 版本 - + Chipset 芯片组 - + Module Alias 模块别名 - + Speed 速度 - + Maximum Power 最大功率 - + Driver 驱动 - + Driver Version 驱动版本 - + Capabilities 功能 - + logical name 逻辑名称 - + Logical Name 逻辑名称 - + MAC Address 物理地址 - + CPU ID 处理器ID - + Core ID 核心ID - + Threads 线程数 - + BogoMIPS 运行速度(Bogomips) - + Architecture 架构 - + CPU Family 家族 - - + + Processor 逻辑处理器 - + Core(s) - + Virtualization 虚拟化 - + Flags 特性 - + Extensions 扩展指令集 - + L3 Cache L3缓存 - + L4 Cache L4缓存 - + L2 Cache L2缓存 - + L1i Cache L1缓存(指令) - + L1d Cache L1缓存(数据) - + Stepping 步进 - + Frequency 频率 - - - + + + Max Frequency 最大频率 - + Graphics Memory 显存 - + Memory Address 内存地址 - + IO Port I/O端口 - + Maximum Resolution 最大分辨率 - + Minimum Resolution 最小分辨率 - + Description 描述 - + DP DP - + eDP eDP - + HDMI HDMI - + VGA VGA - + DVI DVI - + DigitalOutput DigitalOutput - + Display Output 显示输出 - + Interface 接口 - + Bus Info 总线信息 - + bus info 总线信息 - + Maximum Current 最大电流 - + Unavailable 不可用 - + Type 类型 - + Total Width 总位宽 - + Locator 插槽 - + Configured Voltage 配置电压 - + Maximum Voltage 最高电压 - + Minimum Voltage 最低电压 - + Configured Speed 配置速度 - + Data Width 数据位宽 - + Display Input 显示输入 - + Interface Type 接口类型 - + Support Resolution 支持分辨率 - + Current Resolution 当前分辨率 - + Refresh Rate 刷新率 - + Display Ratio 显示比例 - + Primary Monitor 主显示器 - + Size 大小 - + Maximum Rate 最大速率 - + Negotiation Rate 协商速率 - + Port 端口 - + Multicast 组播 - + Link 连接 - + Latency 延迟 - + IP IP - + Firmware 固件 - + Duplex 双工 - + Broadcast 广播 - + Auto Negotiation 自动协商 - + Input/Output 输入/输出 - + Memory 内存 - + Model 型号 - + Status 状态 - + Capacity 最大容量 - + Voltage 电压 - + Slot 插槽 - + Design Capacity 设计容量 - + Design Voltage 设计电压 - + SBDS Version SBDS版本 - + SBDS Serial Number SBDS序列号 - + SBDS Manufacture Date SBDS制造日期 - + SBDS Chemistry SBDS材料 - + Temperature 温度 - + Name 名称 - + Shared 已共享 - + URI URI - + Media Type 介质类型 - + Firmware Version 固件版本 - + Serial Number 序列号 - + Rotation Rate 转速 - + SubVendor 子制造商 - + SubDevice 子设备 - + Driver Status 驱动状态 - + Config Status 配置状态 - + Phys Phys - + Sysfs Sysfs - + Handlers 处理程序 - + PROP PROP - + EV EV - + KEY KEY - + Bus 总线 - + BIOS Information BIOS信息 - + Base Board Information 主板信息 - + System Information 系统信息 - + Chassis Information 机箱信息 - + Physical Memory Array 内存插槽信息 - + Release Date 发布日期 - + Address 地址 - + Runtime Size 运行内存大小 - + ROM Size ROM大小 - + Characteristics 特性 - + BIOS Revision BIOS修订版本 - + Firmware Revision 固件修订版本 - + Product Name 产品名称 - + Asset Tag 资产编号 - + Features 特征 - + Location In Chassis 机箱内位置 - + Chassis Handle 机箱程序 - + Contained Object Handles 包含对象程序 - + UUID UUID - + Wake-up Type 唤醒类型 - + SKU Number SKU号 - + Family 家族 - + Lock - + Boot-up State 开机状态 - + Power Supply State 供电状态 - + Thermal State 散热状态 - + Security Status 安全状态 - + OEM Information OEM信息 - + Height 高度 - + Number Of Power Cords 电源线数 - + Contained Elements 包含组件数 - + Location 位置 - + Error Correction Type 纠错类型 - + Maximum Capacity 最大容量 - + Error Information Handle 错误信息程序 - + Number Of Devices 卡槽数量 - + BIOS ROMSIZE BIOS ROM大小 - + Release date 发布日期 - + Board name 主板名称 - + SMBIOS Version SMBIOS版本 - + Language Description Format 语言描述格式 - + Installable Languages 可安装语言数 - + Currently Installed Language 当前安装语言 - + BD Address 蓝牙设备地址 - + ACL MTU ACL MTU - + SCO MTU SCO MTU - + Packet type 数据包类型 - + Link policy 连接策略 - + Link mode 连接模式 - + Class 类别 - + Service Classes 服务类别 - + Device Class 设备类别 - + HCI Version HCI版本 - + LMP Version LMP版本 - + Subversion 子版本 - + Device 设备 - + Serial ID 序列号 - + product 产品 - + Powered 供电 - + Discoverable 可发现 - + Pairable 可配对 - + Modalias 设置命令别名 - + Discovering 搜索中 - + Device File 设备文件 - + Device Files 设备文件 - + Device Number 设备编号 - + Application 应用 - + ansiversion ANSI版本 - + CPU implementer CPU程序 - + CPU architecture CPU架构 - + CPU variant CPU变量 - + CPU part CPU部件 - + CPU revision CPU版本 - + GDDR capacity GDDR容量 - + GPU vendor GPU供应商 - + GPU type GPU类型 - + EGL version EGL版本 - + EGL client APIs EGL接口 - + GL version GL版本 - + GLSL version GLSL版本 - - - + + + Unknown 未知 - + Uniq Uniq - + MSC MSC - - - + + + Hardware Class 硬件类别 - + Array Handle 数组程序 - + Form Factor 尺寸型号 - + Set 设置 - + Bank Locator 内存通道 - + Part Number 部件号码 - + Rank 位列 - + Memory Technology 内存技术 - + Memory Operating Mode Capability 内存操作模式 - + Module Manufacturer ID 组件制造商 - + Module Product ID 组件产品ID - + Memory Subsystem Controller Manufacturer ID 内存子系统控制器制造商 - + Memory Subsystem Controller Product ID 内存子系统控制器产品ID - + Non-Volatile Size 不易丢失大小 - + Volatile Size 易丢失大小 - + Cache Size 缓存大小 - + Logical Size 逻辑大小 - + + inch 英寸 - + Date 日期 - + ioport I/O端口 - + network 网络 - + battery 电池 - + native-path 安装路径 - + power supply 供电 - + updated 更新时间 - + has history 历史记录 - + has statistics 用电统计 - + rechargeable 可再充电 - + state 状态 - + warning-level 警告等级 - + energy 容量 - + energy-empty 最低容量 - + energy-full 完全充满容量 - + energy-full-design 设计容量 - + energy-rate 能量密度 - + percentage 电量 - + technology 电池技术 - + icon-name 图标 - + online 在线 - + daemon-version Daemon版本 - + on-battery 使用电池 - + lid-is-closed 笔记本合盖 - + lid-is-present 打开笔记本盖子 - + critical-action 电量极低时执行 - + copies 复印数量 - + job-cancel-after 此时取消打印任务 - + job-hold-until 保留打印任务直至 - + job-priority 任务优先级 - + marker-change-time 标记修改次数 - + number-up 编号 - + orientation-requested 打印方向 - + print-color-mode 颜色模式 - + printer-is-accepting-jobs 当前可打印 - + printer-is-shared 打印机已共享 - + printer-is-temporary 临时打印机 - + printer-make-and-model 制造商和型号 - + printer-state-change-time 打印机状态修改时间 - + printer-state-reasons 打印机状态信息 - + printer-type 打印机类型 - + printer-uri-supported 支持的URI - + sides 打印面数 - + SSD 固态 - + HDD 机械 - + logicalsectorsize 逻辑分区大小 - + sectorsize 扇区大小 - + guid 全局唯一标识符 - + Geometry (Logical) 几何数据(逻辑)