forked from len0rd/rockbox
Clean up and rename Detect class.
Move check() function out of the Detect class and place it into utils.cpp for now. Rename Detect class to System, as it now only retrieves data about the underlying system and doesn't detect anything anymore. Cleans up with the confusion between Detect and Autodetection. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@22238 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
84ced00bbd
commit
e2f5086916
10 changed files with 77 additions and 75 deletions
|
@ -52,7 +52,7 @@
|
|||
#include <sys/mount.h>
|
||||
#endif
|
||||
|
||||
#include "detect.h"
|
||||
#include "system.h"
|
||||
#include "utils.h"
|
||||
|
||||
Autodetection::Autodetection(QObject* parent): QObject(parent)
|
||||
|
@ -404,7 +404,7 @@ bool Autodetection::detectUsb()
|
|||
|
||||
// usb pid detection
|
||||
QList<uint32_t> attached;
|
||||
attached = Detect::listUsbIds();
|
||||
attached = System::listUsbIds();
|
||||
|
||||
int i = attached.size();
|
||||
while(i--) {
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
****************************************************************************/
|
||||
|
||||
|
||||
#include "detect.h"
|
||||
#include "system.h"
|
||||
|
||||
#include <QtCore>
|
||||
#include <QDebug>
|
||||
|
@ -69,7 +69,7 @@
|
|||
* @return enum userlevel.
|
||||
*/
|
||||
#if defined(Q_OS_WIN32)
|
||||
enum Detect::userlevel Detect::userPermissions(void)
|
||||
enum System::userlevel System::userPermissions(void)
|
||||
{
|
||||
LPUSER_INFO_1 buf;
|
||||
NET_API_STATUS napistatus;
|
||||
|
@ -106,7 +106,7 @@ enum Detect::userlevel Detect::userPermissions(void)
|
|||
/** @brief detects user permissions (only Windows at moment).
|
||||
* @return a user readable string with the permission.
|
||||
*/
|
||||
QString Detect::userPermissionsString(void)
|
||||
QString System::userPermissionsString(void)
|
||||
{
|
||||
QString result;
|
||||
int perm = userPermissions();
|
||||
|
@ -132,7 +132,7 @@ QString Detect::userPermissionsString(void)
|
|||
/** @brief detects current Username.
|
||||
* @return string with Username.
|
||||
*/
|
||||
QString Detect::userName(void)
|
||||
QString System::userName(void)
|
||||
{
|
||||
#if defined(Q_OS_WIN32)
|
||||
wchar_t userbuf[UNLEN];
|
||||
|
@ -154,7 +154,7 @@ QString Detect::userName(void)
|
|||
/** @brief detects the OS Version
|
||||
* @return String with OS Version.
|
||||
*/
|
||||
QString Detect::osVersionString(void)
|
||||
QString System::osVersionString(void)
|
||||
{
|
||||
QString result;
|
||||
#if defined(Q_OS_WIN32)
|
||||
|
@ -182,7 +182,7 @@ QString Detect::osVersionString(void)
|
|||
return result;
|
||||
}
|
||||
|
||||
QList<uint32_t> Detect::listUsbIds(void)
|
||||
QList<uint32_t> System::listUsbIds(void)
|
||||
{
|
||||
return listUsbDevices().keys();
|
||||
}
|
||||
|
@ -190,11 +190,11 @@ QList<uint32_t> Detect::listUsbIds(void)
|
|||
/** @brief detect devices based on usb pid / vid.
|
||||
* @return list with usb VID / PID values.
|
||||
*/
|
||||
QMap<uint32_t, QString> Detect::listUsbDevices(void)
|
||||
QMap<uint32_t, QString> System::listUsbDevices(void)
|
||||
{
|
||||
QMap<uint32_t, QString> usbids;
|
||||
// usb pid detection
|
||||
qDebug() << "[Detect] Searching for USB devices";
|
||||
qDebug() << "[System] Searching for USB devices";
|
||||
#if defined(Q_OS_LINUX) || defined(Q_OS_MACX)
|
||||
#if defined(LIBUSB1)
|
||||
libusb_device **devs;
|
||||
|
@ -225,7 +225,7 @@ QMap<uint32_t, QString> Detect::listUsbDevices(void)
|
|||
name = QObject::tr("(no description available)");
|
||||
if(id) {
|
||||
usbids.insert(id, name);
|
||||
qDebug("[Detect] USB: 0x%08x, %s", id, name.toLocal8Bit().data());
|
||||
qDebug("[System] USB: 0x%08x, %s", id, name.toLocal8Bit().data());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -271,7 +271,7 @@ QMap<uint32_t, QString> Detect::listUsbDevices(void)
|
|||
|
||||
if(id) {
|
||||
usbids.insert(id, name);
|
||||
qDebug() << "[Detect] USB:" << QString("0x%1").arg(id, 8, 16) << name;
|
||||
qDebug() << "[System] USB:" << QString("0x%1").arg(id, 8, 16) << name;
|
||||
}
|
||||
u = u->next;
|
||||
}
|
||||
|
@ -346,7 +346,7 @@ QMap<uint32_t, QString> Detect::listUsbDevices(void)
|
|||
uint32_t id;
|
||||
id = vid << 16 | pid;
|
||||
usbids.insert(id, description);
|
||||
qDebug("[Detect] USB VID: %04x, PID: %04x", vid, pid);
|
||||
qDebug("[System] USB VID: %04x, PID: %04x", vid, pid);
|
||||
}
|
||||
if(buffer) free(buffer);
|
||||
}
|
||||
|
@ -360,7 +360,7 @@ QMap<uint32_t, QString> Detect::listUsbDevices(void)
|
|||
/** @brief detects current system proxy
|
||||
* @return QUrl with proxy or empty
|
||||
*/
|
||||
QUrl Detect::systemProxy(void)
|
||||
QUrl System::systemProxy(void)
|
||||
{
|
||||
#if defined(Q_OS_LINUX)
|
||||
return QUrl(getenv("http_proxy"));
|
||||
|
@ -396,43 +396,3 @@ QUrl Detect::systemProxy(void)
|
|||
}
|
||||
|
||||
|
||||
/** @brief checks different Enviroment things. Ask if user wants to continue.
|
||||
* @param settings A pointer to rbutils settings class
|
||||
* @param permission if it should check for permission
|
||||
* @param targetId the targetID to check for. if it is -1 no check is done.
|
||||
* @return string with error messages if problems occurred, empty strings if none.
|
||||
*/
|
||||
QString Detect::check(bool permission)
|
||||
{
|
||||
QString text = "";
|
||||
|
||||
// check permission
|
||||
if(permission)
|
||||
{
|
||||
#if defined(Q_OS_WIN32)
|
||||
if(Detect::userPermissions() != Detect::ADMIN)
|
||||
{
|
||||
text += QObject::tr("<li>Permissions insufficient for bootloader "
|
||||
"installation.\nAdministrator priviledges are necessary.</li>");
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
// Check TargetId
|
||||
RockboxInfo rbinfo(RbSettings::value(RbSettings::Mountpoint).toString());
|
||||
QString installed = rbinfo.target();
|
||||
if(!installed.isEmpty() && installed != RbSettings::value(RbSettings::CurConfigureModel).toString())
|
||||
{
|
||||
text += QObject::tr("<li>Target mismatch detected.\n"
|
||||
"Installed target: %1, selected target: %2.</li>")
|
||||
.arg(installed, RbSettings::value(RbSettings::CurPlatformName).toString());
|
||||
// FIXME: replace installed by human-friendly name
|
||||
}
|
||||
|
||||
if(!text.isEmpty())
|
||||
return QObject::tr("Problem detected:") + "<ul>" + text + "</ul>";
|
||||
else
|
||||
return text;
|
||||
}
|
||||
|
||||
|
|
@ -20,18 +20,18 @@
|
|||
****************************************************************************/
|
||||
|
||||
|
||||
#ifndef DETECT_H
|
||||
#define DETECT_H
|
||||
#ifndef SYSTEM_H
|
||||
#define SYSTEM_H
|
||||
|
||||
#include <inttypes.h>
|
||||
|
||||
#include <QString>
|
||||
#include <QUrl>
|
||||
|
||||
class Detect
|
||||
class System
|
||||
{
|
||||
public:
|
||||
Detect() {}
|
||||
System() {}
|
||||
|
||||
#if defined(Q_OS_WIN32)
|
||||
enum userlevel { ERR, GUEST, USER, ADMIN };
|
||||
|
@ -46,8 +46,6 @@ public:
|
|||
|
||||
static QUrl systemProxy(void);
|
||||
|
||||
static QString check(bool permission);
|
||||
|
||||
};
|
||||
#endif
|
||||
|
|
@ -18,6 +18,9 @@
|
|||
****************************************************************************/
|
||||
|
||||
#include "utils.h"
|
||||
#include "system.h"
|
||||
#include "rbsettings.h"
|
||||
|
||||
#ifdef UNICODE
|
||||
#define _UNICODE
|
||||
#endif
|
||||
|
@ -159,6 +162,46 @@ QString findExecutable(QString name)
|
|||
}
|
||||
|
||||
|
||||
/** @brief checks different Enviroment things. Ask if user wants to continue.
|
||||
* @param settings A pointer to rbutils settings class
|
||||
* @param permission if it should check for permission
|
||||
* @param targetId the targetID to check for. if it is -1 no check is done.
|
||||
* @return string with error messages if problems occurred, empty strings if none.
|
||||
*/
|
||||
QString check(bool permission)
|
||||
{
|
||||
QString text = "";
|
||||
|
||||
// check permission
|
||||
if(permission)
|
||||
{
|
||||
#if defined(Q_OS_WIN32)
|
||||
if(Detect::userPermissions() != Detect::ADMIN)
|
||||
{
|
||||
text += QObject::tr("<li>Permissions insufficient for bootloader "
|
||||
"installation.\nAdministrator priviledges are necessary.</li>");
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
// Check TargetId
|
||||
RockboxInfo rbinfo(RbSettings::value(RbSettings::Mountpoint).toString());
|
||||
QString installed = rbinfo.target();
|
||||
if(!installed.isEmpty() && installed != RbSettings::value(RbSettings::CurConfigureModel).toString())
|
||||
{
|
||||
text += QObject::tr("<li>Target mismatch detected.\n"
|
||||
"Installed target: %1, selected target: %2.</li>")
|
||||
.arg(installed, RbSettings::value(RbSettings::CurPlatformName).toString());
|
||||
// FIXME: replace installed by human-friendly name
|
||||
}
|
||||
|
||||
if(!text.isEmpty())
|
||||
return QObject::tr("Problem detected:") + "<ul>" + text + "</ul>";
|
||||
else
|
||||
return text;
|
||||
}
|
||||
|
||||
|
||||
RockboxInfo::RockboxInfo(QString mountpoint)
|
||||
{
|
||||
qDebug() << "[RockboxInfo] trying to find rockbox-info at" << mountpoint;
|
||||
|
|
|
@ -30,6 +30,7 @@ bool recRmdir( const QString &dirName );
|
|||
QString resolvePathCase(QString path);
|
||||
qulonglong filesystemFree(QString path);
|
||||
QString findExecutable(QString name);
|
||||
QString check(bool permission);
|
||||
|
||||
class RockboxInfo
|
||||
{
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
#include "browsedirtree.h"
|
||||
#include "encoders.h"
|
||||
#include "tts.h"
|
||||
#include "detect.h"
|
||||
#include "system.h"
|
||||
#include "encttscfggui.h"
|
||||
#include "rbsettings.h"
|
||||
#include "utils.h"
|
||||
|
@ -420,7 +420,7 @@ void Config::setSystemProxy(bool checked)
|
|||
proxy.setHost(ui.proxyHost->text());
|
||||
proxy.setPort(ui.proxyPort->text().toInt());
|
||||
// show system values in input box
|
||||
QUrl envproxy = Detect::systemProxy();
|
||||
QUrl envproxy = System::systemProxy();
|
||||
|
||||
ui.proxyHost->setText(envproxy.host());
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
#include "install.h"
|
||||
#include "ui_installfrm.h"
|
||||
#include "rbzip.h"
|
||||
#include "detect.h"
|
||||
#include "system.h"
|
||||
#include "rbsettings.h"
|
||||
#include "utils.h"
|
||||
|
||||
|
@ -130,7 +130,7 @@ void Install::accept()
|
|||
|
||||
RbSettings::sync();
|
||||
|
||||
QString warning = Detect::check(false);
|
||||
QString warning = check(false);
|
||||
if(!warning.isEmpty())
|
||||
{
|
||||
if(QMessageBox::warning(this, tr("Really continue?"), warning,
|
||||
|
|
|
@ -33,7 +33,7 @@
|
|||
#include "utils.h"
|
||||
#include "rbzip.h"
|
||||
#include "sysinfo.h"
|
||||
#include "detect.h"
|
||||
#include "system.h"
|
||||
#include "rbsettings.h"
|
||||
|
||||
#include "progressloggerinterface.h"
|
||||
|
@ -308,7 +308,7 @@ void RbUtilQt::updateSettings()
|
|||
updateDevice();
|
||||
updateManual();
|
||||
if(RbSettings::value(RbSettings::ProxyType) == "system") {
|
||||
HttpGet::setGlobalProxy(Detect::systemProxy());
|
||||
HttpGet::setGlobalProxy(System::systemProxy());
|
||||
}
|
||||
else if(RbSettings::value(RbSettings::ProxyType) == "manual") {
|
||||
HttpGet::setGlobalProxy(RbSettings::value(RbSettings::Proxy).toString());
|
||||
|
@ -526,7 +526,7 @@ bool RbUtilQt::installAuto()
|
|||
buildInfo.close();
|
||||
|
||||
// check installed Version and Target
|
||||
QString warning = Detect::check(false);
|
||||
QString warning = check(false);
|
||||
if(!warning.isEmpty())
|
||||
{
|
||||
if(QMessageBox::warning(this, tr("Really continue?"), warning,
|
||||
|
@ -1181,7 +1181,7 @@ QUrl RbUtilQt::proxy()
|
|||
if(RbSettings::value(RbSettings::ProxyType) == "manual")
|
||||
return QUrl(RbSettings::value(RbSettings::Proxy).toString());
|
||||
else if(RbSettings::value(RbSettings::ProxyType) == "system")
|
||||
return Detect::systemProxy();
|
||||
return System::systemProxy();
|
||||
return QUrl("");
|
||||
}
|
||||
|
||||
|
|
|
@ -75,7 +75,7 @@ SOURCES += rbutilqt.cpp \
|
|||
base/rbsettings.cpp \
|
||||
base/rbunzip.cpp \
|
||||
base/rbzip.cpp \
|
||||
base/detect.cpp \
|
||||
base/system.cpp \
|
||||
sysinfo.cpp \
|
||||
base/bootloaderinstallbase.cpp \
|
||||
base/bootloaderinstallmi4.cpp \
|
||||
|
@ -129,7 +129,7 @@ HEADERS += rbutilqt.h \
|
|||
base/rbunzip.h \
|
||||
base/rbzip.h \
|
||||
sysinfo.h \
|
||||
base/detect.h \
|
||||
base/system.h \
|
||||
base/bootloaderinstallbase.h \
|
||||
base/bootloaderinstallmi4.h \
|
||||
base/bootloaderinstallhex.h \
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
#include <QtGui>
|
||||
#include "sysinfo.h"
|
||||
#include "ui_sysinfofrm.h"
|
||||
#include "detect.h"
|
||||
#include "system.h"
|
||||
#include "utils.h"
|
||||
#include "autodetection.h"
|
||||
|
||||
|
@ -38,13 +38,13 @@ Sysinfo::Sysinfo(QWidget *parent) : QDialog(parent)
|
|||
void Sysinfo::updateSysinfo(void)
|
||||
{
|
||||
QString info;
|
||||
info += tr("<b>OS</b><br/>") + Detect::osVersionString() + "<hr/>";
|
||||
info += tr("<b>Username</b><br/>%1<hr/>").arg(Detect::userName());
|
||||
info += tr("<b>OS</b><br/>") + System::osVersionString() + "<hr/>";
|
||||
info += tr("<b>Username</b><br/>%1<hr/>").arg(System::userName());
|
||||
#if defined(Q_OS_WIN32)
|
||||
info += tr("<b>Permissions</b><br/>%1<hr/>").arg(Detect::userPermissionsString());
|
||||
info += tr("<b>Permissions</b><br/>%1<hr/>").arg(System::userPermissionsString());
|
||||
#endif
|
||||
info += tr("<b>Attached USB devices</b><br/>");
|
||||
QMap<uint32_t, QString> usbids = Detect::listUsbDevices();
|
||||
QMap<uint32_t, QString> usbids = System::listUsbDevices();
|
||||
QList<uint32_t> usbkeys = usbids.keys();
|
||||
for(int i = 0; i < usbkeys.size(); i++) {
|
||||
info += tr("VID: %1 PID: %2, %3")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue