summaryrefslogtreecommitdiff
path: root/rbutil
diff options
context:
space:
mode:
authorDominik Riebeling <Dominik.Riebeling@gmail.com>2020-12-05 17:37:20 +0100
committerDominik Riebeling <Dominik.Riebeling@gmail.com>2020-12-05 19:11:18 +0100
commit82b53ebf5400ab046c23231218415a2bb711c137 (patch)
treebe4c9364fd0860995fe1f4f04b6677fbf4a5ae91 /rbutil
parent0e315e848ae7ea5b226af4ab16c215119cbd3fb3 (diff)
rbutil: Merge finding player by USB ID with PlayerBuildInfo.
Remaining rework of player info data handling. Change-Id: I0e10cdff43e0c9fef43b3b9a30af81f1cd7c4853
Diffstat (limited to 'rbutil')
-rw-r--r--rbutil/rbutilqt/base/autodetection.cpp18
-rw-r--r--rbutil/rbutilqt/base/playerbuildinfo.cpp49
-rw-r--r--rbutil/rbutilqt/base/playerbuildinfo.h6
-rw-r--r--rbutil/rbutilqt/base/systeminfo.cpp90
-rw-r--r--rbutil/rbutilqt/base/systeminfo.h51
-rw-r--r--rbutil/rbutilqt/configure.cpp1
-rw-r--r--rbutil/rbutilqt/gui/selectiveinstallwidget.h1
-rw-r--r--rbutil/rbutilqt/installtalkwindow.cpp1
-rw-r--r--rbutil/rbutilqt/rbutilqt.cpp1
-rw-r--r--rbutil/rbutilqt/rbutilqt.pri2
10 files changed, 60 insertions, 160 deletions
diff --git a/rbutil/rbutilqt/base/autodetection.cpp b/rbutil/rbutilqt/base/autodetection.cpp
index 58e844b4c3..63ed9ad9ff 100644
--- a/rbutil/rbutilqt/base/autodetection.cpp
+++ b/rbutil/rbutilqt/base/autodetection.cpp
@@ -19,7 +19,6 @@
#include <QtCore>
#include "autodetection.h"
#include "rbsettings.h"
-#include "systeminfo.h"
#include "playerbuildinfo.h"
#include "../ipodpatcher/ipodpatcher.h"
@@ -82,30 +81,25 @@ bool Autodetection::detect(void)
*/
void Autodetection::detectUsb()
{
- // usbids holds the mapping in the form
- // ((VID<<16)|(PID)), targetname
- // the ini file needs to hold the IDs as hex values.
- QMap<int, QStringList> usbids = SystemInfo::usbIdMap(SystemInfo::MapDevice);
- QMap<int, QStringList> usberror = SystemInfo::usbIdMap(SystemInfo::MapError);
-
// usb pid detection
QList<uint32_t> attached;
attached = System::listUsbIds();
int i = attached.size();
while(i--) {
- if(usbids.contains(attached.at(i))) {
- // we found a USB device that might be ambiguous.
+ QStringList a = PlayerBuildInfo::instance()->value(PlayerBuildInfo::UsbIdTargetList, attached.at(i)).toStringList();
+ if(a.size() > 0) {
struct Detected d;
d.status = PlayerOk;
- d.usbdevices = usbids.value(attached.at(i));
+ d.usbdevices = a;
m_detected.append(d);
LOG_INFO() << "[USB] detected supported player" << d.usbdevices;
}
- if(usberror.contains(attached.at(i))) {
+ QStringList b = PlayerBuildInfo::instance()->value(PlayerBuildInfo::UsbIdErrorList, attached.at(i)).toStringList();
+ if(b.size() > 0) {
struct Detected d;
d.status = PlayerMtpMode;
- d.device = usberror.value(attached.at(i)).at(0);
+ d.usbdevices = b;
m_detected.append(d);
LOG_WARNING() << "[USB] detected problem with player" << d.device;
}
diff --git a/rbutil/rbutilqt/base/playerbuildinfo.cpp b/rbutil/rbutilqt/base/playerbuildinfo.cpp
index 4310991f40..f118a9fd7a 100644
--- a/rbutil/rbutilqt/base/playerbuildinfo.cpp
+++ b/rbutil/rbutilqt/base/playerbuildinfo.cpp
@@ -70,6 +70,8 @@ const static struct {
{ PlayerBuildInfo::TargetNamesEnabled, "_targets/enabled" },
{ PlayerBuildInfo::LanguageInfo, "languages/:target:" },
{ PlayerBuildInfo::LanguageList, "_languages/list" },
+ { PlayerBuildInfo::UsbIdErrorList, "_usb/error" },
+ { PlayerBuildInfo::UsbIdTargetList, "_usb/target" },
};
const static struct {
@@ -257,6 +259,52 @@ QVariant PlayerBuildInfo::value(DeviceInfo item, QString target)
return result;
}
+QVariant PlayerBuildInfo::value(DeviceInfo item, unsigned int match)
+{
+ QStringList result;
+ int i = 0;
+ while(PlayerInfoList[i].item != item)
+ i++;
+ QString s = PlayerInfoList[i].name;
+
+ switch(item) {
+ case UsbIdErrorList:
+ {
+ // go through all targets and find the one indicated by the usb id "target".
+ // return list of matching players (since it could be more than one)
+ QStringList targets = targetNames(true);
+ for(int i = 0; i < targets.size(); i++) {
+ QStringList usbids = playerInfo.value(targets.at(i) + "/usberror").toStringList();
+ for(int j = 0; j < usbids.size(); j++) {
+ if(usbids.at(j).toUInt(nullptr, 0) == match) {
+ result << targets.at(i);
+ }
+ }
+ }
+ break;
+ }
+
+ case UsbIdTargetList:
+ {
+ QStringList targets = targetNames(true);
+ for(int i = 0; i < targets.size(); i++) {
+ QStringList usbids = playerInfo.value(targets.at(i) + "/usbid").toStringList();
+ for(int j = 0; j < usbids.size(); j++) {
+ if(usbids.at(j).toUInt(nullptr, 0) == match) {
+ result << targets.at(i);
+ }
+ }
+ }
+ break;
+ }
+
+ default:
+ break;
+ }
+ LOG_INFO() << "T:" << s << result;
+ return result;
+}
+
QVariant PlayerBuildInfo::value(SystemUrl item)
{
// locate setting item in server info file
@@ -309,7 +357,6 @@ QStringList PlayerBuildInfo::targetNames(bool all)
result.append(target);
}
}
- result.removeDuplicates();
return result;
}
diff --git a/rbutil/rbutilqt/base/playerbuildinfo.h b/rbutil/rbutilqt/base/playerbuildinfo.h
index 52654312a0..85fc2ac6dc 100644
--- a/rbutil/rbutilqt/base/playerbuildinfo.h
+++ b/rbutil/rbutilqt/base/playerbuildinfo.h
@@ -71,6 +71,8 @@ public:
TargetNamesEnabled,
LanguageInfo,
LanguageList,
+ UsbIdErrorList,
+ UsbIdTargetList,
};
enum SystemUrl {
@@ -90,6 +92,10 @@ public:
// Get information about a device. This data does not depend on the build type.
QVariant value(DeviceInfo item, QString target = "");
+ // Get information about a device. Make a numeric match
+ // (only sensible implementation for USB IDs)
+ QVariant value(DeviceInfo item, unsigned int match);
+
// Get build information for currently selected player.
QVariant value(BuildInfo item, BuildType type);
diff --git a/rbutil/rbutilqt/base/systeminfo.cpp b/rbutil/rbutilqt/base/systeminfo.cpp
deleted file mode 100644
index 2b39300930..0000000000
--- a/rbutil/rbutilqt/base/systeminfo.cpp
+++ /dev/null
@@ -1,90 +0,0 @@
-/***************************************************************************
- * __________ __ ___.
- * Open \______ \ ____ ____ | | _\_ |__ _______ ___
- * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
- * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
- * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
- * \/ \/ \/ \/ \/
- *
- * Copyright (C) 2010 by Dominik Wenger
- *
- * All files in this archive are subject to the GNU General Public License.
- * See the file COPYING in the source tree root for full license agreement.
- *
- * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
- * KIND, either express or implied.
- *
- ****************************************************************************/
-
-#include "systeminfo.h"
-#include "rbsettings.h"
-
-#include <QSettings>
-#include "Logger.h"
-
-// device settings
-
-//! pointer to setting object to nullptr
-QSettings* SystemInfo::systemInfos = nullptr;
-
-void SystemInfo::ensureSystemInfoExists()
-{
- //check and create settings object
- if(systemInfos == nullptr)
- {
- // only use built-in rbutil.ini
- systemInfos = new QSettings(":/ini/rbutil.ini", QSettings::IniFormat);
- }
-}
-
-
-QMap<int, QStringList> SystemInfo::usbIdMap(enum MapType type)
-{
- ensureSystemInfoExists();
-
- QMap<int, QStringList> map;
- // get a list of ID -> target name
- QStringList platforms;
- systemInfos->beginGroup("platforms");
- platforms = systemInfos->childKeys();
- systemInfos->endGroup();
-
- QString t;
- switch(type) {
- case MapDevice:
- t = "usbid";
- break;
- case MapError:
- t = "usberror";
- break;
- case MapIncompatible:
- t = "usbincompat";
- break;
- }
-
- for(int i = 0; i < platforms.size(); i++)
- {
- systemInfos->beginGroup("platforms");
- QString target = systemInfos->value(platforms.at(i)).toString();
- systemInfos->endGroup();
- systemInfos->beginGroup(target);
- QStringList ids = systemInfos->value(t).toStringList();
- int j = ids.size();
- while(j--) {
- QStringList l;
- int id = ids.at(j).toInt(nullptr, 16);
- if(id == 0) {
- continue;
- }
- if(map.contains(id)) {
- l = map.take(id);
- }
- l.append(target);
- map.insert(id, l);
- }
- systemInfos->endGroup();
- }
- return map;
-}
-
-
diff --git a/rbutil/rbutilqt/base/systeminfo.h b/rbutil/rbutilqt/base/systeminfo.h
deleted file mode 100644
index 5ca5b35885..0000000000
--- a/rbutil/rbutilqt/base/systeminfo.h
+++ /dev/null
@@ -1,51 +0,0 @@
-/***************************************************************************
- * __________ __ ___.
- * Open \______ \ ____ ____ | | _\_ |__ _______ ___
- * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
- * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
- * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
- * \/ \/ \/ \/ \/
- *
- * Copyright (C) 2010 by Dominik Wenger
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
- * KIND, either express or implied.
- *
- ****************************************************************************/
-
-#ifndef SYSTEMINFO_H
-#define SYSTEMINFO_H
-
-#include <QtCore>
-
-class SystemInfo : public QObject
-{
- Q_OBJECT
- public:
- //! Type of requested usb-id map
- enum MapType {
- MapDevice,
- MapError,
- MapIncompatible,
- };
-
- //! returns a map of usb-ids and their targets
- static QMap<int, QStringList> usbIdMap(enum MapType type);
- //! get a value from system settings
-
- private:
- //! you shouldnt call this, its a fully static calls
- SystemInfo() {}
- //! create the setting objects if neccessary
- static void ensureSystemInfoExists();
- //! pointers to our setting objects
- static QSettings *systemInfos;
-};
-
-#endif
-
diff --git a/rbutil/rbutilqt/configure.cpp b/rbutil/rbutilqt/configure.cpp
index 721727f109..c2ab61b36d 100644
--- a/rbutil/rbutilqt/configure.cpp
+++ b/rbutil/rbutilqt/configure.cpp
@@ -33,7 +33,6 @@
#include "system.h"
#include "encttscfggui.h"
#include "rbsettings.h"
-#include "systeminfo.h"
#include "playerbuildinfo.h"
#include "utils.h"
#include "comboboxviewdelegate.h"
diff --git a/rbutil/rbutilqt/gui/selectiveinstallwidget.h b/rbutil/rbutilqt/gui/selectiveinstallwidget.h
index 40e904ea37..c961a387e0 100644
--- a/rbutil/rbutilqt/gui/selectiveinstallwidget.h
+++ b/rbutil/rbutilqt/gui/selectiveinstallwidget.h
@@ -24,7 +24,6 @@
#include "progressloggergui.h"
#include "zipinstaller.h"
#include "themesinstallwindow.h"
-#include "systeminfo.h"
#include "playerbuildinfo.h"
class SelectiveInstallWidget : public QWidget
diff --git a/rbutil/rbutilqt/installtalkwindow.cpp b/rbutil/rbutilqt/installtalkwindow.cpp
index 81552b03db..5499b9533c 100644
--- a/rbutil/rbutilqt/installtalkwindow.cpp
+++ b/rbutil/rbutilqt/installtalkwindow.cpp
@@ -22,7 +22,6 @@
#include "configure.h"
#include "rbsettings.h"
-#include "systeminfo.h"
#include "Logger.h"
InstallTalkWindow::InstallTalkWindow(QWidget *parent) : QDialog(parent)
diff --git a/rbutil/rbutilqt/rbutilqt.cpp b/rbutil/rbutilqt/rbutilqt.cpp
index a5c5967862..76ef67f799 100644
--- a/rbutil/rbutilqt/rbutilqt.cpp
+++ b/rbutil/rbutilqt/rbutilqt.cpp
@@ -36,7 +36,6 @@
#include "systrace.h"
#include "rbsettings.h"
#include "playerbuildinfo.h"
-#include "systeminfo.h"
#include "ziputil.h"
#include "infowidget.h"
#include "selectiveinstallwidget.h"
diff --git a/rbutil/rbutilqt/rbutilqt.pri b/rbutil/rbutilqt/rbutilqt.pri
index bf127819fd..15d415289f 100644
--- a/rbutil/rbutilqt/rbutilqt.pri
+++ b/rbutil/rbutilqt/rbutilqt.pri
@@ -48,7 +48,6 @@ SOURCES += \
base/voicefile.cpp \
createvoicewindow.cpp \
base/rbsettings.cpp \
- base/systeminfo.cpp \
base/system.cpp \
sysinfo.cpp \
systrace.cpp \
@@ -127,7 +126,6 @@ HEADERS += \
base/voicefile.h \
createvoicewindow.h \
base/rbsettings.h \
- base/systeminfo.h \
sysinfo.h \
base/system.h \
systrace.h \