summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--rbutil/rbutilqt/base/autodetection.cpp4
-rw-r--r--rbutil/rbutilqt/base/system.cpp (renamed from rbutil/rbutilqt/base/detect.cpp)64
-rw-r--r--rbutil/rbutilqt/base/system.h (renamed from rbutil/rbutilqt/base/detect.h)10
-rw-r--r--rbutil/rbutilqt/base/utils.cpp43
-rw-r--r--rbutil/rbutilqt/base/utils.h1
-rw-r--r--rbutil/rbutilqt/configure.cpp4
-rw-r--r--rbutil/rbutilqt/install.cpp4
-rw-r--r--rbutil/rbutilqt/rbutilqt.cpp8
-rw-r--r--rbutil/rbutilqt/rbutilqt.pro4
-rw-r--r--rbutil/rbutilqt/sysinfo.cpp10
10 files changed, 77 insertions, 75 deletions
diff --git a/rbutil/rbutilqt/base/autodetection.cpp b/rbutil/rbutilqt/base/autodetection.cpp
index 5bab1d62d3..e6819992cf 100644
--- a/rbutil/rbutilqt/base/autodetection.cpp
+++ b/rbutil/rbutilqt/base/autodetection.cpp
@@ -52,7 +52,7 @@
52#include <sys/mount.h> 52#include <sys/mount.h>
53#endif 53#endif
54 54
55#include "detect.h" 55#include "system.h"
56#include "utils.h" 56#include "utils.h"
57 57
58Autodetection::Autodetection(QObject* parent): QObject(parent) 58Autodetection::Autodetection(QObject* parent): QObject(parent)
@@ -404,7 +404,7 @@ bool Autodetection::detectUsb()
404 404
405 // usb pid detection 405 // usb pid detection
406 QList<uint32_t> attached; 406 QList<uint32_t> attached;
407 attached = Detect::listUsbIds(); 407 attached = System::listUsbIds();
408 408
409 int i = attached.size(); 409 int i = attached.size();
410 while(i--) { 410 while(i--) {
diff --git a/rbutil/rbutilqt/base/detect.cpp b/rbutil/rbutilqt/base/system.cpp
index 3b8547bdaf..054f1c59ef 100644
--- a/rbutil/rbutilqt/base/detect.cpp
+++ b/rbutil/rbutilqt/base/system.cpp
@@ -18,7 +18,7 @@
18 ****************************************************************************/ 18 ****************************************************************************/
19 19
20 20
21#include "detect.h" 21#include "system.h"
22 22
23#include <QtCore> 23#include <QtCore>
24#include <QDebug> 24#include <QDebug>
@@ -69,7 +69,7 @@
69 * @return enum userlevel. 69 * @return enum userlevel.
70 */ 70 */
71#if defined(Q_OS_WIN32) 71#if defined(Q_OS_WIN32)
72enum Detect::userlevel Detect::userPermissions(void) 72enum System::userlevel System::userPermissions(void)
73{ 73{
74 LPUSER_INFO_1 buf; 74 LPUSER_INFO_1 buf;
75 NET_API_STATUS napistatus; 75 NET_API_STATUS napistatus;
@@ -106,7 +106,7 @@ enum Detect::userlevel Detect::userPermissions(void)
106/** @brief detects user permissions (only Windows at moment). 106/** @brief detects user permissions (only Windows at moment).
107 * @return a user readable string with the permission. 107 * @return a user readable string with the permission.
108 */ 108 */
109QString Detect::userPermissionsString(void) 109QString System::userPermissionsString(void)
110{ 110{
111 QString result; 111 QString result;
112 int perm = userPermissions(); 112 int perm = userPermissions();
@@ -132,7 +132,7 @@ QString Detect::userPermissionsString(void)
132/** @brief detects current Username. 132/** @brief detects current Username.
133 * @return string with Username. 133 * @return string with Username.
134 */ 134 */
135QString Detect::userName(void) 135QString System::userName(void)
136{ 136{
137#if defined(Q_OS_WIN32) 137#if defined(Q_OS_WIN32)
138 wchar_t userbuf[UNLEN]; 138 wchar_t userbuf[UNLEN];
@@ -154,7 +154,7 @@ QString Detect::userName(void)
154/** @brief detects the OS Version 154/** @brief detects the OS Version
155 * @return String with OS Version. 155 * @return String with OS Version.
156 */ 156 */
157QString Detect::osVersionString(void) 157QString System::osVersionString(void)
158{ 158{
159 QString result; 159 QString result;
160#if defined(Q_OS_WIN32) 160#if defined(Q_OS_WIN32)
@@ -182,7 +182,7 @@ QString Detect::osVersionString(void)
182 return result; 182 return result;
183} 183}
184 184
185QList<uint32_t> Detect::listUsbIds(void) 185QList<uint32_t> System::listUsbIds(void)
186{ 186{
187 return listUsbDevices().keys(); 187 return listUsbDevices().keys();
188} 188}
@@ -190,11 +190,11 @@ QList<uint32_t> Detect::listUsbIds(void)
190/** @brief detect devices based on usb pid / vid. 190/** @brief detect devices based on usb pid / vid.
191 * @return list with usb VID / PID values. 191 * @return list with usb VID / PID values.
192 */ 192 */
193QMap<uint32_t, QString> Detect::listUsbDevices(void) 193QMap<uint32_t, QString> System::listUsbDevices(void)
194{ 194{
195 QMap<uint32_t, QString> usbids; 195 QMap<uint32_t, QString> usbids;
196 // usb pid detection 196 // usb pid detection
197 qDebug() << "[Detect] Searching for USB devices"; 197 qDebug() << "[System] Searching for USB devices";
198#if defined(Q_OS_LINUX) || defined(Q_OS_MACX) 198#if defined(Q_OS_LINUX) || defined(Q_OS_MACX)
199#if defined(LIBUSB1) 199#if defined(LIBUSB1)
200 libusb_device **devs; 200 libusb_device **devs;
@@ -225,7 +225,7 @@ QMap<uint32_t, QString> Detect::listUsbDevices(void)
225 name = QObject::tr("(no description available)"); 225 name = QObject::tr("(no description available)");
226 if(id) { 226 if(id) {
227 usbids.insert(id, name); 227 usbids.insert(id, name);
228 qDebug("[Detect] USB: 0x%08x, %s", id, name.toLocal8Bit().data()); 228 qDebug("[System] USB: 0x%08x, %s", id, name.toLocal8Bit().data());
229 } 229 }
230 } 230 }
231 } 231 }
@@ -271,7 +271,7 @@ QMap<uint32_t, QString> Detect::listUsbDevices(void)
271 271
272 if(id) { 272 if(id) {
273 usbids.insert(id, name); 273 usbids.insert(id, name);
274 qDebug() << "[Detect] USB:" << QString("0x%1").arg(id, 8, 16) << name; 274 qDebug() << "[System] USB:" << QString("0x%1").arg(id, 8, 16) << name;
275 } 275 }
276 u = u->next; 276 u = u->next;
277 } 277 }
@@ -346,7 +346,7 @@ QMap<uint32_t, QString> Detect::listUsbDevices(void)
346 uint32_t id; 346 uint32_t id;
347 id = vid << 16 | pid; 347 id = vid << 16 | pid;
348 usbids.insert(id, description); 348 usbids.insert(id, description);
349 qDebug("[Detect] USB VID: %04x, PID: %04x", vid, pid); 349 qDebug("[System] USB VID: %04x, PID: %04x", vid, pid);
350 } 350 }
351 if(buffer) free(buffer); 351 if(buffer) free(buffer);
352 } 352 }
@@ -360,7 +360,7 @@ QMap<uint32_t, QString> Detect::listUsbDevices(void)
360/** @brief detects current system proxy 360/** @brief detects current system proxy
361 * @return QUrl with proxy or empty 361 * @return QUrl with proxy or empty
362 */ 362 */
363QUrl Detect::systemProxy(void) 363QUrl System::systemProxy(void)
364{ 364{
365#if defined(Q_OS_LINUX) 365#if defined(Q_OS_LINUX)
366 return QUrl(getenv("http_proxy")); 366 return QUrl(getenv("http_proxy"));
@@ -396,43 +396,3 @@ QUrl Detect::systemProxy(void)
396} 396}
397 397
398 398
399/** @brief checks different Enviroment things. Ask if user wants to continue.
400 * @param settings A pointer to rbutils settings class
401 * @param permission if it should check for permission
402 * @param targetId the targetID to check for. if it is -1 no check is done.
403 * @return string with error messages if problems occurred, empty strings if none.
404 */
405QString Detect::check(bool permission)
406{
407 QString text = "";
408
409 // check permission
410 if(permission)
411 {
412#if defined(Q_OS_WIN32)
413 if(Detect::userPermissions() != Detect::ADMIN)
414 {
415 text += QObject::tr("<li>Permissions insufficient for bootloader "
416 "installation.\nAdministrator priviledges are necessary.</li>");
417 }
418#endif
419 }
420
421 // Check TargetId
422 RockboxInfo rbinfo(RbSettings::value(RbSettings::Mountpoint).toString());
423 QString installed = rbinfo.target();
424 if(!installed.isEmpty() && installed != RbSettings::value(RbSettings::CurConfigureModel).toString())
425 {
426 text += QObject::tr("<li>Target mismatch detected.\n"
427 "Installed target: %1, selected target: %2.</li>")
428 .arg(installed, RbSettings::value(RbSettings::CurPlatformName).toString());
429 // FIXME: replace installed by human-friendly name
430 }
431
432 if(!text.isEmpty())
433 return QObject::tr("Problem detected:") + "<ul>" + text + "</ul>";
434 else
435 return text;
436}
437
438
diff --git a/rbutil/rbutilqt/base/detect.h b/rbutil/rbutilqt/base/system.h
index fe4b01f1a1..25c404e37c 100644
--- a/rbutil/rbutilqt/base/detect.h
+++ b/rbutil/rbutilqt/base/system.h
@@ -20,18 +20,18 @@
20 ****************************************************************************/ 20 ****************************************************************************/
21 21
22 22
23#ifndef DETECT_H 23#ifndef SYSTEM_H
24#define DETECT_H 24#define SYSTEM_H
25 25
26#include <inttypes.h> 26#include <inttypes.h>
27 27
28#include <QString> 28#include <QString>
29#include <QUrl> 29#include <QUrl>
30 30
31class Detect 31class System
32{ 32{
33public: 33public:
34 Detect() {} 34 System() {}
35 35
36#if defined(Q_OS_WIN32) 36#if defined(Q_OS_WIN32)
37 enum userlevel { ERR, GUEST, USER, ADMIN }; 37 enum userlevel { ERR, GUEST, USER, ADMIN };
@@ -46,8 +46,6 @@ public:
46 46
47 static QUrl systemProxy(void); 47 static QUrl systemProxy(void);
48 48
49 static QString check(bool permission);
50
51}; 49};
52#endif 50#endif
53 51
diff --git a/rbutil/rbutilqt/base/utils.cpp b/rbutil/rbutilqt/base/utils.cpp
index a1b6e2bd0e..8b5127efbf 100644
--- a/rbutil/rbutilqt/base/utils.cpp
+++ b/rbutil/rbutilqt/base/utils.cpp
@@ -18,6 +18,9 @@
18 ****************************************************************************/ 18 ****************************************************************************/
19 19
20#include "utils.h" 20#include "utils.h"
21#include "system.h"
22#include "rbsettings.h"
23
21#ifdef UNICODE 24#ifdef UNICODE
22#define _UNICODE 25#define _UNICODE
23#endif 26#endif
@@ -159,6 +162,46 @@ QString findExecutable(QString name)
159} 162}
160 163
161 164
165/** @brief checks different Enviroment things. Ask if user wants to continue.
166 * @param settings A pointer to rbutils settings class
167 * @param permission if it should check for permission
168 * @param targetId the targetID to check for. if it is -1 no check is done.
169 * @return string with error messages if problems occurred, empty strings if none.
170 */
171QString check(bool permission)
172{
173 QString text = "";
174
175 // check permission
176 if(permission)
177 {
178#if defined(Q_OS_WIN32)
179 if(Detect::userPermissions() != Detect::ADMIN)
180 {
181 text += QObject::tr("<li>Permissions insufficient for bootloader "
182 "installation.\nAdministrator priviledges are necessary.</li>");
183 }
184#endif
185 }
186
187 // Check TargetId
188 RockboxInfo rbinfo(RbSettings::value(RbSettings::Mountpoint).toString());
189 QString installed = rbinfo.target();
190 if(!installed.isEmpty() && installed != RbSettings::value(RbSettings::CurConfigureModel).toString())
191 {
192 text += QObject::tr("<li>Target mismatch detected.\n"
193 "Installed target: %1, selected target: %2.</li>")
194 .arg(installed, RbSettings::value(RbSettings::CurPlatformName).toString());
195 // FIXME: replace installed by human-friendly name
196 }
197
198 if(!text.isEmpty())
199 return QObject::tr("Problem detected:") + "<ul>" + text + "</ul>";
200 else
201 return text;
202}
203
204
162RockboxInfo::RockboxInfo(QString mountpoint) 205RockboxInfo::RockboxInfo(QString mountpoint)
163{ 206{
164 qDebug() << "[RockboxInfo] trying to find rockbox-info at" << mountpoint; 207 qDebug() << "[RockboxInfo] trying to find rockbox-info at" << mountpoint;
diff --git a/rbutil/rbutilqt/base/utils.h b/rbutil/rbutilqt/base/utils.h
index 9113eba7df..ef7d30ec90 100644
--- a/rbutil/rbutilqt/base/utils.h
+++ b/rbutil/rbutilqt/base/utils.h
@@ -30,6 +30,7 @@ bool recRmdir( const QString &dirName );
30QString resolvePathCase(QString path); 30QString resolvePathCase(QString path);
31qulonglong filesystemFree(QString path); 31qulonglong filesystemFree(QString path);
32QString findExecutable(QString name); 32QString findExecutable(QString name);
33QString check(bool permission);
33 34
34class RockboxInfo 35class RockboxInfo
35{ 36{
diff --git a/rbutil/rbutilqt/configure.cpp b/rbutil/rbutilqt/configure.cpp
index e32cccb00f..23d275dd6e 100644
--- a/rbutil/rbutilqt/configure.cpp
+++ b/rbutil/rbutilqt/configure.cpp
@@ -26,7 +26,7 @@
26#include "browsedirtree.h" 26#include "browsedirtree.h"
27#include "encoders.h" 27#include "encoders.h"
28#include "tts.h" 28#include "tts.h"
29#include "detect.h" 29#include "system.h"
30#include "encttscfggui.h" 30#include "encttscfggui.h"
31#include "rbsettings.h" 31#include "rbsettings.h"
32#include "utils.h" 32#include "utils.h"
@@ -420,7 +420,7 @@ void Config::setSystemProxy(bool checked)
420 proxy.setHost(ui.proxyHost->text()); 420 proxy.setHost(ui.proxyHost->text());
421 proxy.setPort(ui.proxyPort->text().toInt()); 421 proxy.setPort(ui.proxyPort->text().toInt());
422 // show system values in input box 422 // show system values in input box
423 QUrl envproxy = Detect::systemProxy(); 423 QUrl envproxy = System::systemProxy();
424 424
425 ui.proxyHost->setText(envproxy.host()); 425 ui.proxyHost->setText(envproxy.host());
426 426
diff --git a/rbutil/rbutilqt/install.cpp b/rbutil/rbutilqt/install.cpp
index 34a4da17e4..8deaf95c29 100644
--- a/rbutil/rbutilqt/install.cpp
+++ b/rbutil/rbutilqt/install.cpp
@@ -20,7 +20,7 @@
20#include "install.h" 20#include "install.h"
21#include "ui_installfrm.h" 21#include "ui_installfrm.h"
22#include "rbzip.h" 22#include "rbzip.h"
23#include "detect.h" 23#include "system.h"
24#include "rbsettings.h" 24#include "rbsettings.h"
25#include "utils.h" 25#include "utils.h"
26 26
@@ -130,7 +130,7 @@ void Install::accept()
130 130
131 RbSettings::sync(); 131 RbSettings::sync();
132 132
133 QString warning = Detect::check(false); 133 QString warning = check(false);
134 if(!warning.isEmpty()) 134 if(!warning.isEmpty())
135 { 135 {
136 if(QMessageBox::warning(this, tr("Really continue?"), warning, 136 if(QMessageBox::warning(this, tr("Really continue?"), warning,
diff --git a/rbutil/rbutilqt/rbutilqt.cpp b/rbutil/rbutilqt/rbutilqt.cpp
index f7ddb37e4c..dff0395bc1 100644
--- a/rbutil/rbutilqt/rbutilqt.cpp
+++ b/rbutil/rbutilqt/rbutilqt.cpp
@@ -33,7 +33,7 @@
33#include "utils.h" 33#include "utils.h"
34#include "rbzip.h" 34#include "rbzip.h"
35#include "sysinfo.h" 35#include "sysinfo.h"
36#include "detect.h" 36#include "system.h"
37#include "rbsettings.h" 37#include "rbsettings.h"
38 38
39#include "progressloggerinterface.h" 39#include "progressloggerinterface.h"
@@ -308,7 +308,7 @@ void RbUtilQt::updateSettings()
308 updateDevice(); 308 updateDevice();
309 updateManual(); 309 updateManual();
310 if(RbSettings::value(RbSettings::ProxyType) == "system") { 310 if(RbSettings::value(RbSettings::ProxyType) == "system") {
311 HttpGet::setGlobalProxy(Detect::systemProxy()); 311 HttpGet::setGlobalProxy(System::systemProxy());
312 } 312 }
313 else if(RbSettings::value(RbSettings::ProxyType) == "manual") { 313 else if(RbSettings::value(RbSettings::ProxyType) == "manual") {
314 HttpGet::setGlobalProxy(RbSettings::value(RbSettings::Proxy).toString()); 314 HttpGet::setGlobalProxy(RbSettings::value(RbSettings::Proxy).toString());
@@ -526,7 +526,7 @@ bool RbUtilQt::installAuto()
526 buildInfo.close(); 526 buildInfo.close();
527 527
528 // check installed Version and Target 528 // check installed Version and Target
529 QString warning = Detect::check(false); 529 QString warning = check(false);
530 if(!warning.isEmpty()) 530 if(!warning.isEmpty())
531 { 531 {
532 if(QMessageBox::warning(this, tr("Really continue?"), warning, 532 if(QMessageBox::warning(this, tr("Really continue?"), warning,
@@ -1181,7 +1181,7 @@ QUrl RbUtilQt::proxy()
1181 if(RbSettings::value(RbSettings::ProxyType) == "manual") 1181 if(RbSettings::value(RbSettings::ProxyType) == "manual")
1182 return QUrl(RbSettings::value(RbSettings::Proxy).toString()); 1182 return QUrl(RbSettings::value(RbSettings::Proxy).toString());
1183 else if(RbSettings::value(RbSettings::ProxyType) == "system") 1183 else if(RbSettings::value(RbSettings::ProxyType) == "system")
1184 return Detect::systemProxy(); 1184 return System::systemProxy();
1185 return QUrl(""); 1185 return QUrl("");
1186} 1186}
1187 1187
diff --git a/rbutil/rbutilqt/rbutilqt.pro b/rbutil/rbutilqt/rbutilqt.pro
index 998bffc8ad..31b07bf068 100644
--- a/rbutil/rbutilqt/rbutilqt.pro
+++ b/rbutil/rbutilqt/rbutilqt.pro
@@ -75,7 +75,7 @@ SOURCES += rbutilqt.cpp \
75 base/rbsettings.cpp \ 75 base/rbsettings.cpp \
76 base/rbunzip.cpp \ 76 base/rbunzip.cpp \
77 base/rbzip.cpp \ 77 base/rbzip.cpp \
78 base/detect.cpp \ 78 base/system.cpp \
79 sysinfo.cpp \ 79 sysinfo.cpp \
80 base/bootloaderinstallbase.cpp \ 80 base/bootloaderinstallbase.cpp \
81 base/bootloaderinstallmi4.cpp \ 81 base/bootloaderinstallmi4.cpp \
@@ -129,7 +129,7 @@ HEADERS += rbutilqt.h \
129 base/rbunzip.h \ 129 base/rbunzip.h \
130 base/rbzip.h \ 130 base/rbzip.h \
131 sysinfo.h \ 131 sysinfo.h \
132 base/detect.h \ 132 base/system.h \
133 base/bootloaderinstallbase.h \ 133 base/bootloaderinstallbase.h \
134 base/bootloaderinstallmi4.h \ 134 base/bootloaderinstallmi4.h \
135 base/bootloaderinstallhex.h \ 135 base/bootloaderinstallhex.h \
diff --git a/rbutil/rbutilqt/sysinfo.cpp b/rbutil/rbutilqt/sysinfo.cpp
index f5c0e47eeb..ca34b4b063 100644
--- a/rbutil/rbutilqt/sysinfo.cpp
+++ b/rbutil/rbutilqt/sysinfo.cpp
@@ -20,7 +20,7 @@
20#include <QtGui> 20#include <QtGui>
21#include "sysinfo.h" 21#include "sysinfo.h"
22#include "ui_sysinfofrm.h" 22#include "ui_sysinfofrm.h"
23#include "detect.h" 23#include "system.h"
24#include "utils.h" 24#include "utils.h"
25#include "autodetection.h" 25#include "autodetection.h"
26 26
@@ -38,13 +38,13 @@ Sysinfo::Sysinfo(QWidget *parent) : QDialog(parent)
38void Sysinfo::updateSysinfo(void) 38void Sysinfo::updateSysinfo(void)
39{ 39{
40 QString info; 40 QString info;
41 info += tr("<b>OS</b><br/>") + Detect::osVersionString() + "<hr/>"; 41 info += tr("<b>OS</b><br/>") + System::osVersionString() + "<hr/>";
42 info += tr("<b>Username</b><br/>%1<hr/>").arg(Detect::userName()); 42 info += tr("<b>Username</b><br/>%1<hr/>").arg(System::userName());
43#if defined(Q_OS_WIN32) 43#if defined(Q_OS_WIN32)
44 info += tr("<b>Permissions</b><br/>%1<hr/>").arg(Detect::userPermissionsString()); 44 info += tr("<b>Permissions</b><br/>%1<hr/>").arg(System::userPermissionsString());
45#endif 45#endif
46 info += tr("<b>Attached USB devices</b><br/>"); 46 info += tr("<b>Attached USB devices</b><br/>");
47 QMap<uint32_t, QString> usbids = Detect::listUsbDevices(); 47 QMap<uint32_t, QString> usbids = System::listUsbDevices();
48 QList<uint32_t> usbkeys = usbids.keys(); 48 QList<uint32_t> usbkeys = usbids.keys();
49 for(int i = 0; i < usbkeys.size(); i++) { 49 for(int i = 0; i < usbkeys.size(); i++) {
50 info += tr("VID: %1 PID: %2, %3") 50 info += tr("VID: %1 PID: %2, %3")