mirror of
https://github.com/Rockbox/rockbox.git
synced 2025-12-09 13:15:18 -05:00
rbutil: Merge finding player by USB ID with PlayerBuildInfo.
Remaining rework of player info data handling. Change-Id: I0e10cdff43e0c9fef43b3b9a30af81f1cd7c4853
This commit is contained in:
parent
0e315e848a
commit
82b53ebf54
10 changed files with 60 additions and 160 deletions
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -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
|
||||
|
||||
|
|
@ -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"
|
||||
|
|
|
|||
|
|
@ -24,7 +24,6 @@
|
|||
#include "progressloggergui.h"
|
||||
#include "zipinstaller.h"
|
||||
#include "themesinstallwindow.h"
|
||||
#include "systeminfo.h"
|
||||
#include "playerbuildinfo.h"
|
||||
|
||||
class SelectiveInstallWidget : public QWidget
|
||||
|
|
|
|||
|
|
@ -22,7 +22,6 @@
|
|||
|
||||
#include "configure.h"
|
||||
#include "rbsettings.h"
|
||||
#include "systeminfo.h"
|
||||
#include "Logger.h"
|
||||
|
||||
InstallTalkWindow::InstallTalkWindow(QWidget *parent) : QDialog(parent)
|
||||
|
|
|
|||
|
|
@ -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"
|
||||
|
|
|
|||
|
|
@ -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 \
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue