summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--rbutil/rbutilqt/autodetection.cpp140
-rw-r--r--rbutil/rbutilqt/icons/view-refresh.pngbin0 -> 912 bytes
-rw-r--r--rbutil/rbutilqt/rbutilqt.cpp9
-rw-r--r--rbutil/rbutilqt/rbutilqt.h1
-rw-r--r--rbutil/rbutilqt/rbutilqt.pro11
-rw-r--r--rbutil/rbutilqt/rbutilqt.qrc1
-rw-r--r--rbutil/rbutilqt/rbutilqtfrm.ui14
-rw-r--r--rbutil/rbutilqt/sysinfo.cpp54
-rw-r--r--rbutil/rbutilqt/sysinfo.h42
-rw-r--r--rbutil/rbutilqt/sysinfofrm.ui66
-rw-r--r--rbutil/rbutilqt/utils.cpp221
-rw-r--r--rbutil/rbutilqt/utils.h9
12 files changed, 435 insertions, 133 deletions
diff --git a/rbutil/rbutilqt/autodetection.cpp b/rbutil/rbutilqt/autodetection.cpp
index 3684d55908..f257f5c0c9 100644
--- a/rbutil/rbutilqt/autodetection.cpp
+++ b/rbutil/rbutilqt/autodetection.cpp
@@ -40,6 +40,7 @@
#include <windows.h>
#include <setupapi.h>
#endif
+#include "utils.h"
Autodetection::Autodetection(QObject* parent): QObject(parent)
{
@@ -265,132 +266,27 @@ bool Autodetection::detectUsb()
QMap<int, QString> usbincompat = settings->usbIdIncompatMap();
// usb pid detection
-#if defined(Q_OS_LINUX) | defined(Q_OS_MACX)
- usb_init();
- usb_find_busses();
- usb_find_devices();
- struct usb_bus *b;
- b = usb_get_busses();
-
- while(b) {
- qDebug() << "bus:" << b->dirname << b->devices;
- if(b->devices) {
- qDebug() << "devices present.";
- struct usb_device *u;
- u = b->devices;
- while(u) {
- uint32_t id;
- id = u->descriptor.idVendor << 16 | u->descriptor.idProduct;
- m_usbconid.append(id);
- qDebug("%x", id);
-
- if(usbids.contains(id)) {
- m_device = usbids.value(id);
- return true;
- }
- if(usberror.contains(id)) {
- m_errdev = usberror.value(id);
- // we detected something, so return true
- qDebug() << "detected device with problems via usb!";
- return true;
- }
- if(usbincompat.contains(id)) {
- m_incompat = usbincompat.value(id);
- qDebug() << "detected incompatible player variant";
- return true;
- }
- u = u->next;
- }
+ QList<uint32_t> attached;
+ attached = listUsbIds();
+
+ int i = attached.size();
+ while(i--) {
+ if(usbids.contains(attached.at(i))) {
+ m_device = usbids.value(attached.at(i));
+ qDebug() << "[USB] detected supported player" << m_device;
+ return true;
}
- b = b->next;
- }
-#endif
-
-#if defined(Q_OS_WIN32)
- HDEVINFO deviceInfo;
- SP_DEVINFO_DATA infoData;
- DWORD i;
-
- // Iterate over all devices
- // by doing it this way it's unneccessary to use GUIDs which might be not
- // present in current MinGW. It also seemed to be more reliably than using
- // a GUID.
- // See KB259695 for an example.
- deviceInfo = SetupDiGetClassDevs(NULL, NULL, NULL, DIGCF_ALLCLASSES | DIGCF_PRESENT);
-
- infoData.cbSize = sizeof(SP_DEVINFO_DATA);
-
- for(i = 0; SetupDiEnumDeviceInfo(deviceInfo, i, &infoData); i++) {
- DWORD data;
- LPTSTR buffer = NULL;
- DWORD buffersize = 0;
-
- // get device desriptor first
- // for some reason not doing so results in bad things (tm)
- while(!SetupDiGetDeviceRegistryProperty(deviceInfo, &infoData,
- SPDRP_DEVICEDESC,&data, (PBYTE)buffer, buffersize, &buffersize)) {
- if(GetLastError() == ERROR_INSUFFICIENT_BUFFER) {
- if(buffer) free(buffer);
- // double buffer size to avoid problems as per KB888609
- buffer = (LPTSTR)malloc(buffersize * 2);
- }
- else {
- break;
- }
+ if(usberror.contains(attached.at(i))) {
+ m_errdev = usberror.value(attached.at(i));
+ qDebug() << "[USB] detected problem with player" << m_errdev;
+ return true;
}
-
- // now get the hardware id, which contains PID and VID.
- while(!SetupDiGetDeviceRegistryProperty(deviceInfo, &infoData,
- SPDRP_HARDWAREID,&data, (PBYTE)buffer, buffersize, &buffersize)) {
- if(GetLastError() == ERROR_INSUFFICIENT_BUFFER) {
- if(buffer) free(buffer);
- // double buffer size to avoid problems as per KB888609
- buffer = (LPTSTR)malloc(buffersize * 2);
- }
- else {
- break;
- }
- }
-
- unsigned int vid, pid, rev;
- if(_stscanf(buffer, _TEXT("USB\\Vid_%x&Pid_%x&Rev_%x"), &vid, &pid, &rev) != 3) {
- qDebug() << "Error getting USB ID -- possibly no USB device";
+ if(usbincompat.contains(attached.at(i))) {
+ m_incompat = usbincompat.value(attached.at(i));
+ qDebug() << "[USB] detected incompatible player" << m_incompat;
+ return true;
}
- else {
- uint32_t id;
- id = vid << 16 | pid;
- m_usbconid.append(id);
- qDebug("VID: %04x PID: %04x", vid, pid);
- if(usbids.contains(id)) {
- m_device = usbids.value(id);
- if(buffer) free(buffer);
- SetupDiDestroyDeviceInfoList(deviceInfo);
- qDebug() << "detectUsb: Got" << m_device;
- return true;
- }
- if(usberror.contains(id)) {
- m_errdev = usberror.value(id);
- // we detected something, so return true
- if(buffer) free(buffer);
- SetupDiDestroyDeviceInfoList(deviceInfo);
- qDebug() << "detectUsb: Got" << m_device;
- qDebug() << "detected device with problems via usb!";
- return true;
- }
- if(usbincompat.contains(id)) {
- m_incompat = usbincompat.value(id);
- // we detected an incompatible player variant
- if(buffer) free(buffer);
- SetupDiDestroyDeviceInfoList(deviceInfo);
- qDebug() << "detectUsb: detected incompatible variant";
- return true;
- }
- }
- if(buffer) free(buffer);
}
- SetupDiDestroyDeviceInfoList(deviceInfo);
-
-#endif
return false;
}
diff --git a/rbutil/rbutilqt/icons/view-refresh.png b/rbutil/rbutilqt/icons/view-refresh.png
new file mode 100644
index 0000000000..3fd71d6e59
--- /dev/null
+++ b/rbutil/rbutilqt/icons/view-refresh.png
Binary files differ
diff --git a/rbutil/rbutilqt/rbutilqt.cpp b/rbutil/rbutilqt/rbutilqt.cpp
index c1523cb92e..a669949aa9 100644
--- a/rbutil/rbutilqt/rbutilqt.cpp
+++ b/rbutil/rbutilqt/rbutilqt.cpp
@@ -34,6 +34,8 @@
#include "browseof.h"
#include "utils.h"
#include "rbzip.h"
+#include "sysinfo.h"
+
#if defined(Q_OS_LINUX)
#include <stdio.h>
@@ -101,6 +103,7 @@ RbUtilQt::RbUtilQt(QWidget *parent) : QMainWindow(parent)
connect(ui.actionCreate_Talk_Files, SIGNAL(triggered()), this, SLOT(createTalkFiles()));
connect(ui.actionRemove_bootloader, SIGNAL(triggered()), this, SLOT(uninstallBootloader()));
connect(ui.actionUninstall_Rockbox, SIGNAL(triggered()), this, SLOT(uninstall()));
+ connect(ui.action_System_Info, SIGNAL(triggered()), this, SLOT(sysinfo()));
#if !defined(STATIC)
ui.actionInstall_Rockbox_Utility_on_player->setEnabled(false);
@@ -115,6 +118,12 @@ RbUtilQt::RbUtilQt(QWidget *parent) : QMainWindow(parent)
}
+void RbUtilQt::sysinfo(void)
+{
+ Sysinfo *info = new Sysinfo(this);
+ info->show();
+}
+
void RbUtilQt::updateTabs(int count)
{
switch(count) {
diff --git a/rbutil/rbutilqt/rbutilqt.h b/rbutil/rbutilqt/rbutilqt.h
index 8de5ea0113..3c6cbd0784 100644
--- a/rbutil/rbutilqt/rbutilqt.h
+++ b/rbutil/rbutilqt/rbutilqt.h
@@ -66,6 +66,7 @@ class RbUtilQt : public QMainWindow
private slots:
void about(void);
void help(void);
+ void sysinfo(void);
void configDialog(void);
void updateDevice(void);
void updateSettings(void);
diff --git a/rbutil/rbutilqt/rbutilqt.pro b/rbutil/rbutilqt/rbutilqt.pro
index a10d06591e..9e9e8c4976 100644
--- a/rbutil/rbutilqt/rbutilqt.pro
+++ b/rbutil/rbutilqt/rbutilqt.pro
@@ -62,7 +62,8 @@ SOURCES += rbutilqt.cpp \
createvoicewindow.cpp \
rbsettings.cpp \
rbunzip.cpp \
- rbzip.cpp
+ rbzip.cpp \
+ sysinfo.cpp
HEADERS += rbutilqt.h \
install.h \
@@ -109,7 +110,8 @@ HEADERS += rbutilqt.h \
createvoicewindow.h \
rbsettings.h \
rbunzip.h \
- rbzip.h
+ rbzip.h \
+ sysinfo.h
# Needed by QT on Win
INCLUDEPATH = . irivertools zip zlib ../ipodpatcher ../sansapatcher ../../tools/rbspeex ../../tools
@@ -145,7 +147,8 @@ FORMS += rbutilqtfrm.ui \
encexescfgfrm.ui \
ttsexescfgfrm.ui \
sapicfgfrm.ui \
- createvoicefrm.ui
+ createvoicefrm.ui \
+ sysinfofrm.ui
RESOURCES += rbutilqt.qrc
win32 {
@@ -164,7 +167,7 @@ win32 {
SOURCES += ../ipodpatcher/ipodio-win32.c
SOURCES += ../sansapatcher/sansaio-win32.c
RC_FILE = rbutilqt.rc
- LIBS += -lsetupapi
+ LIBS += -lsetupapi -lnetapi32
}
unix {
diff --git a/rbutil/rbutilqt/rbutilqt.qrc b/rbutil/rbutilqt/rbutilqt.qrc
index 694836c781..62a804180c 100644
--- a/rbutil/rbutilqt/rbutilqt.qrc
+++ b/rbutil/rbutilqt/rbutilqt.qrc
@@ -31,6 +31,7 @@
<file>icons/talkfile_btn.png</file>
<file>icons/themes_btn.png</file>
<file>icons/user-trash-full.png</file>
+ <file>icons/view-refresh.png</file>
<file>icons/wizard.xpm</file>
</qresource>
<qresource prefix="/ini" >
diff --git a/rbutil/rbutilqt/rbutilqtfrm.ui b/rbutil/rbutilqt/rbutilqtfrm.ui
index 90018a3301..804856414f 100644
--- a/rbutil/rbutilqt/rbutilqtfrm.ui
+++ b/rbutil/rbutilqt/rbutilqtfrm.ui
@@ -94,9 +94,9 @@
<item row="0" column="1" >
<widget class="QLabel" name="labelDevice" >
<property name="text" >
- <string>&lt;html>&lt;head>&lt;meta name="qrichtext" content="1" />&lt;style type="text/css">
-p, li { white-space: pre-wrap; }
-&lt;/style>&lt;/head>&lt;body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;">
+ <string>&lt;html>&lt;head>&lt;meta name="qrichtext" content="1" />&lt;style type="text/css">&#xd;
+p, li { white-space: pre-wrap; }&#xd;
+&lt;/style>&lt;/head>&lt;body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;">&#xd;
&lt;p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">&lt;span style=" font-weight:600;">none&lt;/span> at &lt;span style=" font-weight:600;">unknown&lt;/span>&lt;/p>&lt;/body>&lt;/html></string>
</property>
</widget>
@@ -539,7 +539,7 @@ p, li { white-space: pre-wrap; }
<item row="1" column="1" >
<widget class="QLabel" name="labelCreateVoice" >
<property name="text" >
- <string>&lt;b>Create Voice file&lt;/b>&lt;br/>Voice files are needed to make Rockbox speak the user interface. Speaking is enabled by default, so
+ <string>&lt;b>Create Voice file&lt;/b>&lt;br/>Voice files are needed to make Rockbox speak the user interface. Speaking is enabled by default, so&#xd;
if you installed the voice file Rockbox will speak.</string>
</property>
<property name="wordWrap" >
@@ -806,6 +806,7 @@ p, li { white-space: pre-wrap; }
<addaction name="action_About" />
<addaction name="actionAbout_Qt" />
<addaction name="separator" />
+ <addaction name="action_System_Info" />
<addaction name="action_Help" />
</widget>
<widget class="QMenu" name="menuA_ctions" >
@@ -1022,6 +1023,11 @@ p, li { white-space: pre-wrap; }
<string>Create Voice File</string>
</property>
</action>
+ <action name="action_System_Info" >
+ <property name="text" >
+ <string>&amp;System Info</string>
+ </property>
+ </action>
</widget>
<tabstops>
<tabstop>tabWidget</tabstop>
diff --git a/rbutil/rbutilqt/sysinfo.cpp b/rbutil/rbutilqt/sysinfo.cpp
new file mode 100644
index 0000000000..413494c679
--- /dev/null
+++ b/rbutil/rbutilqt/sysinfo.cpp
@@ -0,0 +1,54 @@
+/***************************************************************************
+ * __________ __ ___.
+ * Open \______ \ ____ ____ | | _\_ |__ _______ ___
+ * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
+ * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
+ * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
+ * \/ \/ \/ \/ \/
+ *
+ * Copyright (C) 2007 by Dominik Riebeling
+ * $Id$
+ *
+ * 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 <QtGui>
+#include "sysinfo.h"
+#include "ui_sysinfofrm.h"
+#include "utils.h"
+
+
+Sysinfo::Sysinfo(QWidget *parent) : QDialog(parent)
+{
+ ui.setupUi(this);
+ this->setModal(true);
+
+ updateSysinfo();
+ connect(ui.buttonOk, SIGNAL(clicked()), this, SLOT(close()));
+ connect(ui.buttonRefresh, SIGNAL(clicked()), this, SLOT(updateSysinfo()));
+}
+
+
+void Sysinfo::updateSysinfo(void)
+{
+ QString info;
+ info += tr("<b>OS</b><br/>") + getOsVersionString() + "<hr/>";
+ info += tr("<b>Username:</b><br/>%1<hr/>").arg(getUserName());
+#if defined(Q_OS_WIN32)
+ info += tr("<b>Permissions:</b><br/>%1<hr/>").arg(getUserPermissionsString());
+#endif
+ info += tr("<b>Attached USB devices:</b><br/>");
+ QList<uint32_t> usbids = listUsbIds();
+ for(int i = 0; i < usbids.size(); i++)
+ info += tr("VID: %1 PID: %2<br/>")
+ .arg((usbids.at(i)&0xffff0000)>>16, 4, 16, QChar('0'))
+ .arg(usbids.at(i)&0xffff, 4, 16, QChar('0'));
+
+ ui.textBrowser->setHtml(info);
+}
+
diff --git a/rbutil/rbutilqt/sysinfo.h b/rbutil/rbutilqt/sysinfo.h
new file mode 100644
index 0000000000..a3dbed9941
--- /dev/null
+++ b/rbutil/rbutilqt/sysinfo.h
@@ -0,0 +1,42 @@
+/***************************************************************************
+ * __________ __ ___.
+ * Open \______ \ ____ ____ | | _\_ |__ _______ ___
+ * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
+ * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
+ * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
+ * \/ \/ \/ \/ \/
+ *
+ * Copyright (C) 2007 by Dominik Riebeling
+ * $Id$
+ *
+ * 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.
+ *
+ ****************************************************************************/
+
+#ifndef SYSINFO_H
+#define SYSINFO_H
+
+#include <QtGui>
+#include "ui_sysinfofrm.h"
+
+class Sysinfo : public QDialog
+{
+ Q_OBJECT
+
+ public:
+ Sysinfo(QWidget *parent = 0);
+
+ private:
+ Ui::SysinfoFrm ui;
+
+ private slots:
+ void updateSysinfo(void);
+
+};
+
+#endif
+
diff --git a/rbutil/rbutilqt/sysinfofrm.ui b/rbutil/rbutilqt/sysinfofrm.ui
new file mode 100644
index 0000000000..b2340a6310
--- /dev/null
+++ b/rbutil/rbutilqt/sysinfofrm.ui
@@ -0,0 +1,66 @@
+<ui version="4.0" >
+ <class>SysinfoFrm</class>
+ <widget class="QWidget" name="SysinfoFrm" >
+ <property name="geometry" >
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>400</width>
+ <height>300</height>
+ </rect>
+ </property>
+ <property name="windowTitle" >
+ <string>System Info</string>
+ </property>
+ <layout class="QGridLayout" >
+ <item row="0" column="0" colspan="3" >
+ <widget class="QTextBrowser" name="textBrowser" />
+ </item>
+ <item row="1" column="0" >
+ <widget class="QPushButton" name="buttonRefresh" >
+ <property name="text" >
+ <string>&amp;Refresh</string>
+ </property>
+ <property name="icon" >
+ <iconset resource="rbutilqt.qrc" >:/icons/view-refresh.png</iconset>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="1" >
+ <spacer>
+ <property name="orientation" >
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeHint" >
+ <size>
+ <width>40</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item row="1" column="2" >
+ <widget class="QPushButton" name="buttonOk" >
+ <property name="text" >
+ <string>&amp;OK</string>
+ </property>
+ <property name="icon" >
+ <iconset resource="rbutilqt.qrc" >:/icons/go-next.png</iconset>
+ </property>
+ <property name="default" >
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ <tabstops>
+ <tabstop>buttonOk</tabstop>
+ <tabstop>buttonRefresh</tabstop>
+ <tabstop>textBrowser</tabstop>
+ </tabstops>
+ <resources>
+ <include location="rbutilqt.qrc" />
+ </resources>
+ <connections/>
+</ui>
diff --git a/rbutil/rbutilqt/utils.cpp b/rbutil/rbutilqt/utils.cpp
index a552b5cd5e..c95c5cf0eb 100644
--- a/rbutil/rbutilqt/utils.cpp
+++ b/rbutil/rbutilqt/utils.cpp
@@ -19,9 +19,10 @@
#include "utils.h"
+#include <QtCore>
+#include <QDebug>
#include <cstdlib>
-
-#include <QDir>
+#include <stdio.h>
#if defined(Q_OS_WIN32)
#if defined(UNICODE)
@@ -29,8 +30,29 @@
#endif
#include <windows.h>
#include <tchar.h>
+#include <lm.h>
+#endif
+#if defined(Q_OS_LINUX) || defined(Q_OS_MACX)
+#include <usb.h>
+#include <sys/utsname.h>
+#include <unistd.h>
+#endif
+#if defined(Q_OS_LINUX)
+#include <mntent.h>
+#endif
+#if defined(Q_OS_MACX)
+#include <sys/param.h>
+#include <sys/ucred.h>
+#include <sys/mount.h>
+#endif
+#if defined(Q_OS_WIN32)
+#if defined(UNICODE)
+#define _UNICODE
+#endif
+#include <tchar.h>
+#include <windows.h>
+#include <setupapi.h>
#endif
-#include <QDebug>
// recursive function to delete a dir with files
bool recRmdir( const QString &dirName )
@@ -157,3 +179,196 @@ QString installedVersion(QString mountpoint)
return "";
}
+
+QString getUserName(void)
+{
+#if defined(Q_OS_WIN32)
+ wchar_t userbuf[UNLEN];
+ DWORD usersize = UNLEN;
+ BOOL status;
+
+ status = GetUserNameW(userbuf, &usersize);
+
+ return QString::fromWCharArray(userbuf);
+#endif
+#if defined(Q_OS_LINUX) || defined(Q_OS_MACX)
+ return QString(getlogin());
+#endif
+}
+
+
+#if defined(Q_OS_WIN32)
+enum userlevel getUserPermissions(void)
+{
+ LPUSER_INFO_1 buf;
+ NET_API_STATUS napistatus;
+ wchar_t userbuf[UNLEN];
+ DWORD usersize = UNLEN;
+ BOOL status;
+ enum userlevel result;
+
+ status = GetUserNameW(userbuf, &usersize);
+ if(!status)
+ return ERR;
+
+ napistatus = NetUserGetInfo(NULL, userbuf, (DWORD)1, (LPBYTE*)&buf);
+
+ switch(buf->usri1_priv) {
+ case USER_PRIV_GUEST:
+ result = GUEST;
+ break;
+ case USER_PRIV_USER:
+ result = USER;
+ break;
+ case USER_PRIV_ADMIN:
+ result = ADMIN;
+ break;
+ default:
+ result = ERR;
+ break;
+ }
+ NetApiBufferFree(buf);
+
+ return result;
+}
+
+QString getUserPermissionsString(void)
+{
+ QString result;
+ int perm = getUserPermissions();
+ switch(perm) {
+ case GUEST:
+ result = tr("Guest");
+ break;
+ case ADMIN:
+ result = tr("Admin");
+ break;
+ case USER:
+ result = tr("User");
+ break;
+ default:
+ result = tr("Error");
+ break;
+ }
+ return result;
+}
+#endif
+
+QString getOsVersionString(void)
+{
+ QString result;
+#if defined(Q_OS_WIN32)
+ OSVERSIONINFO osvi;
+ ZeroMemory(&osvi, sizeof(OSVERSIONINFO));
+ osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
+ GetVersionEx(&osvi);
+
+ result = QString("Windows version %1.%2, ").arg(osvi.dwMajorVersion).arg(osvi.dwMinorVersion);
+ result += QString("build %1 (%2)").arg(osvi.dwBuildNumber).arg(QString::fromWCharArray(osvi.szCSDVersion));
+#endif
+#if defined(Q_OS_LINUX) || defined(Q_OS_MACX)
+ struct utsname u;
+ int ret;
+ ret = uname(&u);
+
+ result = QString("CPU: %1<br/>System: %2<br/>Release: %3<br/>Version: %4")
+ .arg(u.machine).arg(u.sysname).arg(u.release).arg(u.version);
+#endif
+ return result;
+
+}
+
+/** @brief detect devices based on usb pid / vid.
+ * @return list with usb VID / PID values.
+ */
+QList<uint32_t> listUsbIds(void)
+{
+ QList<uint32_t> usbids;
+ // usb pid detection
+#if defined(Q_OS_LINUX) | defined(Q_OS_MACX)
+ usb_init();
+ usb_find_busses();
+ usb_find_devices();
+ struct usb_bus *b;
+ b = usb_busses;
+
+ while(b) {
+ qDebug() << "bus:" << b->dirname << b->devices;
+ if(b->devices) {
+ qDebug() << "devices present.";
+ struct usb_device *u;
+ u = b->devices;
+ while(u) {
+ uint32_t id;
+ id = u->descriptor.idVendor << 16 | u->descriptor.idProduct;
+ if(id) usbids.append(id);
+ u = u->next;
+ }
+ }
+ b = b->next;
+ }
+#endif
+
+#if defined(Q_OS_WIN32)
+ HDEVINFO deviceInfo;
+ SP_DEVINFO_DATA infoData;
+ DWORD i;
+
+ // Iterate over all devices
+ // by doing it this way it's unneccessary to use GUIDs which might be not
+ // present in current MinGW. It also seemed to be more reliably than using
+ // a GUID.
+ // See KB259695 for an example.
+ deviceInfo = SetupDiGetClassDevs(NULL, NULL, NULL, DIGCF_ALLCLASSES | DIGCF_PRESENT);
+
+ infoData.cbSize = sizeof(SP_DEVINFO_DATA);
+
+ for(i = 0; SetupDiEnumDeviceInfo(deviceInfo, i, &infoData); i++) {
+ DWORD data;
+ LPTSTR buffer = NULL;
+ DWORD buffersize = 0;
+
+ // get device desriptor first
+ // for some reason not doing so results in bad things (tm)
+ while(!SetupDiGetDeviceRegistryProperty(deviceInfo, &infoData,
+ SPDRP_DEVICEDESC,&data, (PBYTE)buffer, buffersize, &buffersize)) {
+ if(GetLastError() == ERROR_INSUFFICIENT_BUFFER) {
+ if(buffer) free(buffer);
+ // double buffer size to avoid problems as per KB888609
+ buffer = (LPTSTR)malloc(buffersize * 2);
+ }
+ else {
+ break;
+ }
+ }
+
+ // now get the hardware id, which contains PID and VID.
+ while(!SetupDiGetDeviceRegistryProperty(deviceInfo, &infoData,
+ SPDRP_HARDWAREID,&data, (PBYTE)buffer, buffersize, &buffersize)) {
+ if(GetLastError() == ERROR_INSUFFICIENT_BUFFER) {
+ if(buffer) free(buffer);
+ // double buffer size to avoid problems as per KB888609
+ buffer = (LPTSTR)malloc(buffersize * 2);
+ }
+ else {
+ break;
+ }
+ }
+
+ unsigned int vid, pid, rev;
+ if(_stscanf(buffer, _TEXT("USB\\Vid_%x&Pid_%x&Rev_%x"), &vid, &pid, &rev) != 3) {
+ qDebug() << "Error getting USB ID -- possibly no USB device";
+ }
+ else {
+ uint32_t id;
+ id = vid << 16 | pid;
+ usbids.append(id);
+ qDebug("VID: %04x PID: %04x", vid, pid);
+ }
+ if(buffer) free(buffer);
+ }
+ SetupDiDestroyDeviceInfoList(deviceInfo);
+
+#endif
+ return usbids;
+}
diff --git a/rbutil/rbutilqt/utils.h b/rbutil/rbutilqt/utils.h
index 9b0b026921..a7be093520 100644
--- a/rbutil/rbutilqt/utils.h
+++ b/rbutil/rbutilqt/utils.h
@@ -24,6 +24,15 @@
#include <QString>
#include <QUrl>
+#if defined(Q_OS_WIN32)
+enum userlevel { ERR, GUEST, USER, ADMIN };
+enum userlevel getUserPermissions(void);
+QString getUserPermissionsString(void);
+#endif
+QString getUserName(void);
+QString getOsVersionString(void);
+QList<uint32_t> listUsbIds(void);
+
bool recRmdir( const QString &dirName );
QString resolvePathCase(QString path);