2007-07-29 17:35:31 +00:00
|
|
|
/***************************************************************************
|
|
|
|
* __________ __ ___.
|
|
|
|
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
|
|
|
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
|
|
|
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
|
|
|
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
|
|
|
* \/ \/ \/ \/ \/
|
|
|
|
*
|
|
|
|
* Copyright (C) 2007 by Dominik Riebeling
|
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
2013-01-27 11:01:56 +00:00
|
|
|
#include <QMainWindow>
|
|
|
|
#include <QMessageBox>
|
2007-07-29 17:35:31 +00:00
|
|
|
|
|
|
|
#include "version.h"
|
|
|
|
#include "rbutilqt.h"
|
|
|
|
#include "ui_rbutilqtfrm.h"
|
|
|
|
#include "ui_aboutbox.h"
|
|
|
|
#include "configure.h"
|
2007-08-05 16:17:35 +00:00
|
|
|
#include "installtalkwindow.h"
|
2008-01-11 23:59:12 +00:00
|
|
|
#include "createvoicewindow.h"
|
2007-07-29 17:35:31 +00:00
|
|
|
#include "httpget.h"
|
2009-03-31 19:50:43 +00:00
|
|
|
#include "themesinstallwindow.h"
|
2007-08-10 22:17:43 +00:00
|
|
|
#include "uninstallwindow.h"
|
2008-01-24 20:02:40 +00:00
|
|
|
#include "utils.h"
|
2010-04-02 21:24:19 +00:00
|
|
|
#include "rockboxinfo.h"
|
2008-06-21 10:28:10 +00:00
|
|
|
#include "sysinfo.h"
|
2009-08-10 19:46:51 +00:00
|
|
|
#include "system.h"
|
2009-08-15 17:02:25 +00:00
|
|
|
#include "systrace.h"
|
2009-05-09 16:59:14 +00:00
|
|
|
#include "rbsettings.h"
|
2010-01-24 21:12:11 +00:00
|
|
|
#include "serverinfo.h"
|
|
|
|
#include "systeminfo.h"
|
2011-03-25 22:16:12 +00:00
|
|
|
#include "ziputil.h"
|
2012-02-14 20:02:52 +00:00
|
|
|
#include "manualwidget.h"
|
2012-02-19 17:06:56 +00:00
|
|
|
#include "infowidget.h"
|
2012-06-26 16:41:25 +00:00
|
|
|
#include "selectiveinstallwidget.h"
|
2012-06-25 22:24:58 +00:00
|
|
|
#include "backupdialog.h"
|
2013-09-20 21:03:56 +00:00
|
|
|
#include "changelog.h"
|
2007-07-29 17:35:31 +00:00
|
|
|
|
2008-09-28 17:02:36 +00:00
|
|
|
#include "progressloggerinterface.h"
|
|
|
|
|
|
|
|
#include "bootloaderinstallbase.h"
|
2012-05-01 08:09:14 +00:00
|
|
|
#include "bootloaderinstallhelper.h"
|
2008-09-28 17:02:36 +00:00
|
|
|
|
2013-11-03 10:08:18 +00:00
|
|
|
#include "Logger.h"
|
|
|
|
|
2007-09-23 13:12:34 +00:00
|
|
|
#if defined(Q_OS_LINUX)
|
2007-07-29 18:41:15 +00:00
|
|
|
#include <stdio.h>
|
|
|
|
#endif
|
2007-09-23 13:12:34 +00:00
|
|
|
#if defined(Q_OS_WIN32)
|
|
|
|
#if defined(UNICODE)
|
|
|
|
#define _UNICODE
|
|
|
|
#endif
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <tchar.h>
|
|
|
|
#include <windows.h>
|
|
|
|
#endif
|
2007-07-29 18:41:15 +00:00
|
|
|
|
2011-10-02 14:30:05 +00:00
|
|
|
QList<QTranslator*> RbUtilQt::translators;
|
|
|
|
|
2007-07-29 17:35:31 +00:00
|
|
|
RbUtilQt::RbUtilQt(QWidget *parent) : QMainWindow(parent)
|
|
|
|
{
|
2009-06-05 21:49:53 +00:00
|
|
|
// startup log
|
2013-11-03 10:08:18 +00:00
|
|
|
LOG_INFO() << "======================================";
|
|
|
|
LOG_INFO() << "Rockbox Utility" << VERSION;
|
|
|
|
LOG_INFO() << "Qt version:" << qVersion();
|
2015-03-25 21:02:19 +00:00
|
|
|
#if defined(__clang__)
|
|
|
|
LOG_INFO("compiled using clang %i.%i.%i",
|
|
|
|
__clang_major__, __clang_minor__, __clang_patchlevel__);
|
|
|
|
#elif defined(__GNUC__)
|
|
|
|
LOG_INFO("compiled using gcc %i.%i.%i",
|
|
|
|
__GNUC__, __GNUC_MINOR__, __GNUC_PATCHLEVEL__);
|
|
|
|
#elif defined(_MSC_VER)
|
2015-05-14 20:18:58 +00:00
|
|
|
LOG_INFO() << "compiled using MSVC" << _MSC_FULL_VER;
|
2015-03-25 21:02:19 +00:00
|
|
|
#endif
|
2013-11-03 10:08:18 +00:00
|
|
|
LOG_INFO() << "======================================";
|
2009-06-05 21:49:53 +00:00
|
|
|
|
2007-08-09 18:40:32 +00:00
|
|
|
absolutePath = qApp->applicationDirPath();
|
2008-09-28 17:02:36 +00:00
|
|
|
|
2013-06-09 14:41:45 +00:00
|
|
|
QString c = RbSettings::value(RbSettings::CachePath).toString();
|
|
|
|
HttpGet::setGlobalCache(c.isEmpty() ? QDir::tempPath() : c);
|
2008-08-30 20:51:50 +00:00
|
|
|
HttpGet::setGlobalUserAgent("rbutil/"VERSION);
|
2010-06-03 06:29:10 +00:00
|
|
|
HttpGet::setGlobalProxy(proxy());
|
2008-09-28 17:02:36 +00:00
|
|
|
// init startup & autodetection
|
|
|
|
ui.setupUi(this);
|
2010-03-29 19:55:51 +00:00
|
|
|
#if defined(Q_OS_LINUX)
|
|
|
|
QIcon windowIcon(":/icons/rockbox-clef.svg");
|
|
|
|
this->setWindowIcon(windowIcon);
|
|
|
|
#endif
|
2011-10-01 21:00:09 +00:00
|
|
|
#if defined(Q_OS_WIN32)
|
|
|
|
QIcon windowIcon = QIcon();
|
2011-10-02 08:57:10 +00:00
|
|
|
windowIcon.addFile(":/icons/rockbox-16.png");
|
|
|
|
windowIcon.addFile(":/icons/rockbox-32.png");
|
|
|
|
windowIcon.addFile(":/icons/rockbox-48.png");
|
|
|
|
windowIcon.addFile(":/icons/rockbox-64.png");
|
|
|
|
windowIcon.addFile(":/icons/rockbox-128.png");
|
|
|
|
windowIcon.addFile(":/icons/rockbox-256.png");
|
2011-10-01 21:00:09 +00:00
|
|
|
this->setWindowIcon(windowIcon);
|
|
|
|
#endif
|
2011-07-17 08:58:55 +00:00
|
|
|
#if defined(Q_OS_MACX)
|
|
|
|
// don't translate menu entries that are handled specially on OS X
|
|
|
|
// (Configure, Quit). Qt handles them for us if they use english string.
|
|
|
|
ui.action_Configure->setText("Configure");
|
|
|
|
ui.actionE_xit->setText("Quit");
|
|
|
|
#endif
|
2010-04-04 21:08:17 +00:00
|
|
|
#if defined(Q_OS_WIN32)
|
|
|
|
long ret;
|
|
|
|
HKEY hk;
|
|
|
|
ret = RegOpenKeyEx(HKEY_CURRENT_USER, _TEXT("Software\\Wine"),
|
|
|
|
0, KEY_QUERY_VALUE, &hk);
|
|
|
|
if(ret == ERROR_SUCCESS) {
|
|
|
|
QMessageBox::warning(this, tr("Wine detected!"),
|
|
|
|
tr("It seems you are trying to run this program under Wine. "
|
|
|
|
"Please don't do this, running under Wine will fail. "
|
|
|
|
"Use the native Linux binary instead."),
|
|
|
|
QMessageBox::Ok, QMessageBox::Ok);
|
2013-11-03 10:08:18 +00:00
|
|
|
LOG_WARNING() << "WINE DETECTED!";
|
2010-04-04 21:08:17 +00:00
|
|
|
RegCloseKey(hk);
|
|
|
|
}
|
|
|
|
#endif
|
2012-09-08 18:34:36 +00:00
|
|
|
|
2012-09-16 19:07:46 +00:00
|
|
|
#if !defined(Q_OS_WIN32) && !defined(Q_OS_MACX)
|
2013-06-09 14:41:45 +00:00
|
|
|
/* eject funtionality is not available on Linux right now. */
|
2012-09-08 18:34:36 +00:00
|
|
|
ui.buttonEject->setEnabled(false);
|
|
|
|
#endif
|
2012-01-06 19:26:56 +00:00
|
|
|
updateDevice();
|
2008-09-28 17:02:36 +00:00
|
|
|
downloadInfo();
|
2008-08-30 20:51:50 +00:00
|
|
|
|
2008-04-01 18:02:56 +00:00
|
|
|
m_gotInfo = false;
|
2008-09-28 17:02:36 +00:00
|
|
|
m_auto = false;
|
|
|
|
|
2012-02-14 20:02:52 +00:00
|
|
|
// insert ManualWidget() widget in manual tab
|
|
|
|
QGridLayout *mantablayout = new QGridLayout(this);
|
|
|
|
ui.manual->setLayout(mantablayout);
|
|
|
|
manual = new ManualWidget(this);
|
|
|
|
mantablayout->addWidget(manual);
|
2007-07-29 17:35:31 +00:00
|
|
|
|
2012-06-26 16:41:25 +00:00
|
|
|
// selective "install" tab.
|
|
|
|
QGridLayout *selectivetablayout = new QGridLayout(this);
|
|
|
|
ui.selective->setLayout(selectivetablayout);
|
|
|
|
selectiveinstallwidget = new SelectiveInstallWidget(this);
|
|
|
|
selectivetablayout->addWidget(selectiveinstallwidget);
|
|
|
|
connect(ui.buttonChangeDevice, SIGNAL(clicked()), selectiveinstallwidget, SLOT(saveSettings()));
|
|
|
|
|
2007-08-26 16:03:56 +00:00
|
|
|
// info tab
|
2012-02-19 17:06:56 +00:00
|
|
|
QGridLayout *infotablayout = new QGridLayout(this);
|
|
|
|
ui.info->setLayout(infotablayout);
|
|
|
|
info = new InfoWidget(this);
|
|
|
|
infotablayout->addWidget(info);
|
|
|
|
|
2007-08-26 16:03:56 +00:00
|
|
|
connect(ui.tabWidget, SIGNAL(currentChanged(int)), this, SLOT(updateTabs(int)));
|
2007-07-29 17:35:31 +00:00
|
|
|
connect(ui.actionAbout_Qt, SIGNAL(triggered()), qApp, SLOT(aboutQt()));
|
|
|
|
connect(ui.action_About, SIGNAL(triggered()), this, SLOT(about()));
|
2007-08-29 17:43:11 +00:00
|
|
|
connect(ui.action_Help, SIGNAL(triggered()), this, SLOT(help()));
|
2007-07-29 17:35:31 +00:00
|
|
|
connect(ui.action_Configure, SIGNAL(triggered()), this, SLOT(configDialog()));
|
2010-02-11 19:51:50 +00:00
|
|
|
connect(ui.actionE_xit, SIGNAL(triggered()), this, SLOT(shutdown()));
|
2007-08-02 21:29:31 +00:00
|
|
|
connect(ui.buttonChangeDevice, SIGNAL(clicked()), this, SLOT(configDialog()));
|
2012-09-08 18:34:36 +00:00
|
|
|
connect(ui.buttonEject, SIGNAL(clicked()), this, SLOT(eject()));
|
2007-08-05 16:17:35 +00:00
|
|
|
connect(ui.buttonTalk, SIGNAL(clicked()), this, SLOT(createTalkFiles()));
|
2008-01-11 23:59:12 +00:00
|
|
|
connect(ui.buttonCreateVoice, SIGNAL(clicked()), this, SLOT(createVoiceFile()));
|
2007-08-09 16:06:27 +00:00
|
|
|
connect(ui.buttonVoice, SIGNAL(clicked()), this, SLOT(installVoice()));
|
2007-08-10 22:17:43 +00:00
|
|
|
connect(ui.buttonRemoveRockbox, SIGNAL(clicked()), this, SLOT(uninstall()));
|
|
|
|
connect(ui.buttonRemoveBootloader, SIGNAL(clicked()), this, SLOT(uninstallBootloader()));
|
2012-06-25 22:24:58 +00:00
|
|
|
connect(ui.buttonBackup, SIGNAL(clicked()), this, SLOT(backup()));
|
2007-09-15 22:57:07 +00:00
|
|
|
|
2007-10-12 16:19:35 +00:00
|
|
|
// actions accessible from the menu
|
|
|
|
connect(ui.actionInstall_Voice_File, SIGNAL(triggered()), this, SLOT(installVoice()));
|
2008-01-11 23:59:12 +00:00
|
|
|
connect(ui.actionCreate_Voice_File, SIGNAL(triggered()), this, SLOT(createVoiceFile()));
|
2007-10-12 16:19:35 +00:00
|
|
|
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()));
|
2008-06-21 10:28:10 +00:00
|
|
|
connect(ui.action_System_Info, SIGNAL(triggered()), this, SLOT(sysinfo()));
|
2009-08-15 17:02:25 +00:00
|
|
|
connect(ui.action_Trace, SIGNAL(triggered()), this, SLOT(trace()));
|
2013-09-20 21:03:56 +00:00
|
|
|
connect(ui.actionShow_Changelog, SIGNAL(triggered()), this, SLOT(changelog()));
|
2007-10-12 16:19:35 +00:00
|
|
|
|
2007-08-22 22:25:04 +00:00
|
|
|
#if !defined(STATIC)
|
|
|
|
ui.actionInstall_Rockbox_Utility_on_player->setEnabled(false);
|
|
|
|
#else
|
|
|
|
connect(ui.actionInstall_Rockbox_Utility_on_player, SIGNAL(triggered()), this, SLOT(installPortable()));
|
|
|
|
#endif
|
2012-01-22 21:23:49 +00:00
|
|
|
Utils::findRunningProcess(QStringList("iTunes"));
|
2007-07-29 17:35:31 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-02-11 19:51:50 +00:00
|
|
|
void RbUtilQt::shutdown(void)
|
|
|
|
{
|
|
|
|
this->close();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-08-15 17:02:25 +00:00
|
|
|
void RbUtilQt::trace(void)
|
|
|
|
{
|
|
|
|
SysTrace wnd(this);
|
|
|
|
wnd.exec();
|
|
|
|
}
|
|
|
|
|
2008-06-21 10:28:10 +00:00
|
|
|
void RbUtilQt::sysinfo(void)
|
|
|
|
{
|
2012-06-25 22:11:38 +00:00
|
|
|
Sysinfo sysinfo(this);
|
|
|
|
sysinfo.exec();
|
2008-06-21 10:28:10 +00:00
|
|
|
}
|
|
|
|
|
2013-09-20 21:03:56 +00:00
|
|
|
void RbUtilQt::changelog(void)
|
|
|
|
{
|
|
|
|
|
|
|
|
Changelog cl(this);
|
|
|
|
cl.exec();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-08-26 16:03:56 +00:00
|
|
|
void RbUtilQt::updateTabs(int count)
|
|
|
|
{
|
2012-06-25 22:11:38 +00:00
|
|
|
if(count == ui.tabWidget->indexOf(info->parentWidget()))
|
|
|
|
info->updateInfo();
|
2007-08-26 16:03:56 +00:00
|
|
|
}
|
2007-08-10 22:17:43 +00:00
|
|
|
|
|
|
|
|
2007-07-29 17:35:31 +00:00
|
|
|
void RbUtilQt::downloadInfo()
|
|
|
|
{
|
|
|
|
// try to get the current build information
|
|
|
|
daily = new HttpGet(this);
|
|
|
|
connect(daily, SIGNAL(done(bool)), this, SLOT(downloadDone(bool)));
|
2007-09-03 09:46:15 +00:00
|
|
|
connect(qApp, SIGNAL(lastWindowClosed()), daily, SLOT(abort()));
|
2013-01-13 18:45:29 +00:00
|
|
|
daily->setCache(false);
|
2009-10-27 19:28:51 +00:00
|
|
|
ui.statusbar->showMessage(tr("Downloading build information, please wait ..."));
|
2013-11-03 10:08:18 +00:00
|
|
|
LOG_INFO() << "downloading build info";
|
2007-07-29 17:35:31 +00:00
|
|
|
daily->setFile(&buildInfo);
|
2012-06-02 22:50:01 +00:00
|
|
|
daily->getFile(QUrl(SystemInfo::value(SystemInfo::BuildInfoUrl).toString()));
|
2007-07-29 17:35:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void RbUtilQt::downloadDone(bool error)
|
|
|
|
{
|
2007-08-26 16:03:56 +00:00
|
|
|
if(error) {
|
2013-11-03 10:08:18 +00:00
|
|
|
LOG_INFO() << "network error:" << daily->errorString();
|
2009-10-27 19:28:51 +00:00
|
|
|
ui.statusbar->showMessage(tr("Can't get version information!"));
|
2008-09-28 17:02:36 +00:00
|
|
|
QMessageBox::critical(this, tr("Network error"),
|
2010-04-01 22:06:49 +00:00
|
|
|
tr("Can't get version information.\n"
|
|
|
|
"Network error: %1. Please check your network and proxy settings.")
|
|
|
|
.arg(daily->errorString()));
|
2007-08-26 16:03:56 +00:00
|
|
|
return;
|
|
|
|
}
|
2013-11-03 10:08:18 +00:00
|
|
|
LOG_INFO() << "network status:" << daily->errorString();
|
2007-09-15 22:57:07 +00:00
|
|
|
|
2010-01-24 21:12:11 +00:00
|
|
|
// read info into ServerInfo object
|
2007-08-26 16:03:56 +00:00
|
|
|
buildInfo.open();
|
2010-01-24 21:12:11 +00:00
|
|
|
ServerInfo::readBuildInfo(buildInfo.fileName());
|
2007-08-26 16:03:56 +00:00
|
|
|
buildInfo.close();
|
2012-01-03 21:52:19 +00:00
|
|
|
|
2012-06-02 22:50:01 +00:00
|
|
|
ui.statusbar->showMessage(tr("Download build information finished."), 5000);
|
2013-11-04 22:43:34 +00:00
|
|
|
if(RbSettings::value(RbSettings::RbutilVersion) != PUREVERSION
|
|
|
|
|| RbSettings::value(RbSettings::ShowChangelog).toBool()) {
|
|
|
|
changelog();
|
|
|
|
}
|
2012-06-02 22:50:01 +00:00
|
|
|
updateSettings();
|
|
|
|
m_gotInfo = true;
|
2007-08-26 16:03:56 +00:00
|
|
|
|
2012-06-02 22:50:01 +00:00
|
|
|
//start check for updates
|
|
|
|
checkUpdate();
|
2007-08-26 16:03:56 +00:00
|
|
|
|
2007-07-29 17:35:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void RbUtilQt::about()
|
|
|
|
{
|
2007-07-30 19:35:48 +00:00
|
|
|
QDialog *window = new QDialog(this);
|
2007-07-29 17:35:31 +00:00
|
|
|
Ui::aboutBox about;
|
|
|
|
about.setupUi(window);
|
2009-10-31 17:16:34 +00:00
|
|
|
window->setLayoutDirection(Qt::LeftToRight);
|
2007-07-30 19:35:48 +00:00
|
|
|
window->setModal(true);
|
2007-09-15 22:57:07 +00:00
|
|
|
|
2007-07-29 17:35:31 +00:00
|
|
|
QFile licence(":/docs/gpl-2.0.html");
|
|
|
|
licence.open(QIODevice::ReadOnly);
|
|
|
|
QTextStream c(&licence);
|
2011-10-21 19:46:36 +00:00
|
|
|
about.browserLicense->insertHtml(c.readAll());
|
2007-07-29 17:35:31 +00:00
|
|
|
about.browserLicense->moveCursor(QTextCursor::Start, QTextCursor::MoveAnchor);
|
2011-10-21 19:46:36 +00:00
|
|
|
|
|
|
|
QFile speexlicense(":/docs/COPYING.SPEEX");
|
|
|
|
speexlicense.open(QIODevice::ReadOnly);
|
|
|
|
QTextStream s(&speexlicense);
|
|
|
|
about.browserSpeexLicense->insertHtml("<pre>" + s.readAll() + "</pre>");
|
|
|
|
about.browserSpeexLicense->moveCursor(QTextCursor::Start, QTextCursor::MoveAnchor);
|
|
|
|
|
2007-07-29 17:35:31 +00:00
|
|
|
QFile credits(":/docs/CREDITS");
|
|
|
|
credits.open(QIODevice::ReadOnly);
|
|
|
|
QTextStream r(&credits);
|
2009-03-08 18:53:32 +00:00
|
|
|
r.setCodec(QTextCodec::codecForName("UTF-8"));
|
2010-01-24 20:48:38 +00:00
|
|
|
while(!r.atEnd()) {
|
|
|
|
QString line = r.readLine();
|
|
|
|
// filter out header.
|
2011-04-30 21:09:15 +00:00
|
|
|
line.remove(QRegExp("^ +.*"));
|
2010-01-24 20:48:38 +00:00
|
|
|
line.remove(QRegExp("^People.*"));
|
|
|
|
about.browserCredits->append(line);
|
|
|
|
}
|
2007-07-29 17:35:31 +00:00
|
|
|
about.browserCredits->moveCursor(QTextCursor::Start, QTextCursor::MoveAnchor);
|
2008-08-30 20:51:50 +00:00
|
|
|
QString title = QString("<b>The Rockbox Utility</b><br/>Version %1").arg(FULLVERSION);
|
2007-07-29 17:35:31 +00:00
|
|
|
about.labelTitle->setText(title);
|
|
|
|
|
|
|
|
window->show();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-08-29 17:43:11 +00:00
|
|
|
void RbUtilQt::help()
|
|
|
|
{
|
2007-12-16 18:56:45 +00:00
|
|
|
QUrl helpurl("http://www.rockbox.org/wiki/RockboxUtility");
|
2007-08-29 17:43:11 +00:00
|
|
|
QDesktopServices::openUrl(helpurl);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-07-29 17:35:31 +00:00
|
|
|
void RbUtilQt::configDialog()
|
|
|
|
{
|
|
|
|
Config *cw = new Config(this);
|
2007-08-02 21:29:31 +00:00
|
|
|
connect(cw, SIGNAL(settingsUpdated()), this, SLOT(updateSettings()));
|
2008-04-06 19:50:38 +00:00
|
|
|
cw->show();
|
2007-07-29 17:35:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-08-02 21:29:31 +00:00
|
|
|
void RbUtilQt::updateSettings()
|
2007-07-29 17:35:31 +00:00
|
|
|
{
|
2013-11-03 10:08:18 +00:00
|
|
|
LOG_INFO() << "updating current settings";
|
2007-08-02 21:29:31 +00:00
|
|
|
updateDevice();
|
2012-02-14 20:02:52 +00:00
|
|
|
manual->updateManual();
|
2013-06-09 14:41:45 +00:00
|
|
|
QString c = RbSettings::value(RbSettings::CachePath).toString();
|
|
|
|
HttpGet::setGlobalCache(c.isEmpty() ? QDir::tempPath() : c);
|
2010-06-03 06:29:10 +00:00
|
|
|
HttpGet::setGlobalProxy(proxy());
|
2012-01-03 21:52:19 +00:00
|
|
|
|
2012-01-06 19:26:56 +00:00
|
|
|
if(RbSettings::value(RbSettings::RbutilVersion) != PUREVERSION) {
|
2010-01-20 22:18:36 +00:00
|
|
|
QApplication::processEvents();
|
|
|
|
QMessageBox::information(this, tr("New installation"),
|
|
|
|
tr("This is a new installation of Rockbox Utility, or a new version. "
|
|
|
|
"The configuration dialog will now open to allow you to setup the program, "
|
|
|
|
" or review your settings."));
|
|
|
|
configDialog();
|
|
|
|
}
|
2012-02-14 19:51:49 +00:00
|
|
|
else if(chkConfig(0)) {
|
2010-01-20 22:18:36 +00:00
|
|
|
QApplication::processEvents();
|
|
|
|
QMessageBox::critical(this, tr("Configuration error"),
|
|
|
|
tr("Your configuration is invalid. This is most likely due "
|
|
|
|
"to a changed device path. The configuration dialog will "
|
|
|
|
"now open to allow you to correct the problem."));
|
|
|
|
configDialog();
|
2012-01-06 19:26:56 +00:00
|
|
|
}
|
2012-06-26 16:41:25 +00:00
|
|
|
selectiveinstallwidget->updateVersion();
|
2007-07-29 17:35:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-08-02 21:29:31 +00:00
|
|
|
void RbUtilQt::updateDevice()
|
2007-07-29 17:35:31 +00:00
|
|
|
{
|
2009-11-01 17:16:02 +00:00
|
|
|
/* TODO: We should check the flags of the bootloaderinstall classes, and not
|
|
|
|
* just check if its != none or != "fwpatcher" */
|
|
|
|
|
|
|
|
/* Enable bootloader installation, if possible */
|
|
|
|
bool bootloaderInstallable =
|
2010-01-24 21:12:11 +00:00
|
|
|
SystemInfo::value(SystemInfo::CurBootloaderMethod) != "none";
|
2009-11-01 17:16:02 +00:00
|
|
|
|
|
|
|
/* Enable bootloader uninstallation, if possible */
|
|
|
|
bool bootloaderUninstallable = bootloaderInstallable &&
|
2010-01-24 21:12:11 +00:00
|
|
|
SystemInfo::value(SystemInfo::CurBootloaderMethod) != "fwpatcher";
|
2009-11-01 17:16:02 +00:00
|
|
|
ui.labelRemoveBootloader->setEnabled(bootloaderUninstallable);
|
|
|
|
ui.buttonRemoveBootloader->setEnabled(bootloaderUninstallable);
|
|
|
|
ui.actionRemove_bootloader->setEnabled(bootloaderUninstallable);
|
|
|
|
|
|
|
|
/* Disable the whole tab widget if configuration is invalid */
|
2012-02-14 19:51:49 +00:00
|
|
|
bool configurationValid = !chkConfig(0);
|
2009-11-01 17:16:02 +00:00
|
|
|
ui.tabWidget->setEnabled(configurationValid);
|
|
|
|
ui.menuA_ctions->setEnabled(configurationValid);
|
2009-01-25 17:48:38 +00:00
|
|
|
|
2007-08-02 21:29:31 +00:00
|
|
|
// displayed device info
|
2010-01-24 21:12:11 +00:00
|
|
|
QString brand = SystemInfo::value(SystemInfo::CurBrand).toString();
|
2012-06-20 19:00:43 +00:00
|
|
|
QString name
|
|
|
|
= QString("%1 (%2)").arg(SystemInfo::value(SystemInfo::CurName).toString(),
|
|
|
|
ServerInfo::value(ServerInfo::CurStatus).toString());
|
2012-07-01 13:02:32 +00:00
|
|
|
ui.labelDevice->setText(QString("<b>%1 %2</b>").arg(brand, name));
|
2012-06-20 19:00:43 +00:00
|
|
|
|
|
|
|
QString mountpoint = RbSettings::value(RbSettings::Mountpoint).toString();
|
2011-07-16 22:07:52 +00:00
|
|
|
QString mountdisplay = QDir::toNativeSeparators(mountpoint);
|
2012-06-20 19:00:43 +00:00
|
|
|
if(!mountdisplay.isEmpty()) {
|
|
|
|
QString label = Utils::filesystemName(mountpoint);
|
|
|
|
if(!label.isEmpty()) mountdisplay += QString(" (%1)").arg(label);
|
2012-07-01 13:02:32 +00:00
|
|
|
ui.labelMountpoint->setText(QString("<b>%1</b>").arg(mountdisplay));
|
2012-06-20 19:00:43 +00:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
mountdisplay = "(unknown)";
|
|
|
|
}
|
2011-07-16 22:07:52 +00:00
|
|
|
|
2012-06-20 19:00:43 +00:00
|
|
|
QPixmap pm;
|
|
|
|
QString m = SystemInfo::value(SystemInfo::CurPlayerPicture).toString();
|
|
|
|
pm.load(":/icons/players/" + m + "-small.png");
|
|
|
|
pm = pm.scaledToHeight(QFontMetrics(QApplication::font()).height() * 3);
|
|
|
|
ui.labelPlayerPic->setPixmap(pm);
|
2011-07-16 22:07:52 +00:00
|
|
|
|
2007-07-30 18:11:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-06-25 22:24:58 +00:00
|
|
|
void RbUtilQt::backup(void)
|
|
|
|
{
|
|
|
|
backupdialog = new BackupDialog(this);
|
|
|
|
backupdialog->show();
|
2007-08-26 19:06:40 +00:00
|
|
|
|
2007-09-15 23:00:02 +00:00
|
|
|
}
|
|
|
|
|
2007-08-26 20:32:20 +00:00
|
|
|
|
|
|
|
void RbUtilQt::installdone(bool error)
|
|
|
|
{
|
2013-11-03 10:08:18 +00:00
|
|
|
LOG_INFO() << "install done";
|
2007-08-26 20:32:20 +00:00
|
|
|
m_installed = true;
|
|
|
|
m_error = error;
|
|
|
|
}
|
|
|
|
|
2007-08-09 16:06:27 +00:00
|
|
|
void RbUtilQt::installVoice()
|
|
|
|
{
|
2012-02-14 19:51:49 +00:00
|
|
|
if(chkConfig(this)) return;
|
2008-12-18 22:42:24 +00:00
|
|
|
|
2008-04-01 18:02:56 +00:00
|
|
|
if(m_gotInfo == false)
|
|
|
|
{
|
|
|
|
QMessageBox::warning(this, tr("Warning"),
|
2008-12-18 22:42:24 +00:00
|
|
|
tr("The Application is still downloading Information about new Builds."
|
|
|
|
" Please try again shortly."));
|
|
|
|
return;
|
2008-04-01 18:02:56 +00:00
|
|
|
}
|
2008-12-18 22:42:24 +00:00
|
|
|
|
2010-06-06 18:02:08 +00:00
|
|
|
QString mountpoint = RbSettings::value(RbSettings::Mountpoint).toString();
|
|
|
|
RockboxInfo installInfo(mountpoint);
|
|
|
|
|
|
|
|
QString voiceurl;
|
|
|
|
QString logversion;
|
|
|
|
QString relversion = installInfo.release();
|
|
|
|
// if no version is found abort.
|
|
|
|
if(installInfo.revision().isEmpty() && relversion.isEmpty()) {
|
|
|
|
QMessageBox::critical(this, tr("No Rockbox installation found"),
|
|
|
|
tr("Could not determine the installed Rockbox version. "
|
|
|
|
"Please install a Rockbox build before installing "
|
|
|
|
"voice files."));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if(relversion.isEmpty()) {
|
2012-06-02 22:46:33 +00:00
|
|
|
// release is empty for development builds.
|
|
|
|
// No voice files are available for development builds.
|
|
|
|
QMessageBox::critical(this, tr("No voice file available"),
|
2012-06-01 22:07:30 +00:00
|
|
|
tr("The installed version of Rockbox is a development version. "
|
|
|
|
"Pre-built voices are only available for release versions "
|
|
|
|
"of Rockbox. Please generate a voice yourself using the "
|
|
|
|
"\"Create voice file\" functionality."));
|
|
|
|
return;
|
2010-06-06 18:02:08 +00:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
voiceurl = SystemInfo::value(SystemInfo::ReleaseVoiceUrl).toString();
|
|
|
|
logversion = installInfo.release();
|
|
|
|
}
|
2007-08-09 16:06:27 +00:00
|
|
|
if(QMessageBox::question(this, tr("Confirm Installation"),
|
|
|
|
tr("Do you really want to install the voice file?"),
|
2010-06-06 18:02:08 +00:00
|
|
|
QMessageBox::Yes | QMessageBox::No) != QMessageBox::Yes)
|
|
|
|
return;
|
|
|
|
|
|
|
|
QString model = SystemInfo::value(SystemInfo::CurBuildserverModel).toString();
|
|
|
|
// replace placeholder in voice url
|
|
|
|
voiceurl.replace("%MODEL%", model);
|
|
|
|
voiceurl.replace("%RELVERSION%", relversion);
|
|
|
|
|
2013-11-03 10:08:18 +00:00
|
|
|
LOG_INFO() << "voicefile URL:" << voiceurl;
|
2010-06-06 18:02:08 +00:00
|
|
|
|
2007-08-09 16:06:27 +00:00
|
|
|
// create logger
|
|
|
|
logger = new ProgressLoggerGui(this);
|
|
|
|
logger->show();
|
|
|
|
// create zip installer
|
|
|
|
installer = new ZipInstaller(this);
|
2008-12-18 22:42:24 +00:00
|
|
|
|
2007-08-09 16:06:27 +00:00
|
|
|
installer->setUrl(voiceurl);
|
|
|
|
installer->setLogSection("Voice");
|
2010-06-06 18:02:08 +00:00
|
|
|
installer->setLogVersion(logversion);
|
|
|
|
installer->setMountPoint(mountpoint);
|
2009-05-09 16:59:14 +00:00
|
|
|
if(!RbSettings::value(RbSettings::CacheDisabled).toBool())
|
2008-03-05 21:12:24 +00:00
|
|
|
installer->setCache(true);
|
2009-05-02 18:50:31 +00:00
|
|
|
connect(installer, SIGNAL(logItem(QString, int)), logger, SLOT(addItem(QString, int)));
|
|
|
|
connect(installer, SIGNAL(logProgress(int, int)), logger, SLOT(setProgress(int, int)));
|
|
|
|
connect(installer, SIGNAL(done(bool)), logger, SLOT(setFinished()));
|
|
|
|
connect(logger, SIGNAL(aborted()), installer, SLOT(abort()));
|
|
|
|
installer->install();
|
2007-09-15 22:57:07 +00:00
|
|
|
|
2007-08-09 16:06:27 +00:00
|
|
|
}
|
|
|
|
|
2007-08-15 21:54:15 +00:00
|
|
|
|
2007-08-05 16:17:35 +00:00
|
|
|
void RbUtilQt::createTalkFiles(void)
|
|
|
|
{
|
2012-02-14 19:51:49 +00:00
|
|
|
if(chkConfig(this)) return;
|
2007-08-08 20:16:33 +00:00
|
|
|
InstallTalkWindow *installWindow = new InstallTalkWindow(this);
|
2007-12-14 19:49:11 +00:00
|
|
|
connect(installWindow, SIGNAL(settingsUpdated()), this, SLOT(updateSettings()));
|
2008-04-06 19:50:38 +00:00
|
|
|
installWindow->show();
|
2007-08-05 16:17:35 +00:00
|
|
|
|
|
|
|
}
|
2007-08-10 22:17:43 +00:00
|
|
|
|
2008-01-11 23:59:12 +00:00
|
|
|
void RbUtilQt::createVoiceFile(void)
|
|
|
|
{
|
2012-02-14 19:51:49 +00:00
|
|
|
if(chkConfig(this)) return;
|
2008-01-11 23:59:12 +00:00
|
|
|
CreateVoiceWindow *installWindow = new CreateVoiceWindow(this);
|
2012-02-14 19:51:49 +00:00
|
|
|
|
2008-01-11 23:59:12 +00:00
|
|
|
connect(installWindow, SIGNAL(settingsUpdated()), this, SLOT(updateSettings()));
|
2008-04-06 19:50:38 +00:00
|
|
|
installWindow->show();
|
2008-01-11 23:59:12 +00:00
|
|
|
}
|
|
|
|
|
2007-08-10 22:17:43 +00:00
|
|
|
void RbUtilQt::uninstall(void)
|
|
|
|
{
|
2012-02-14 19:51:49 +00:00
|
|
|
if(chkConfig(this)) return;
|
2007-08-10 22:17:43 +00:00
|
|
|
UninstallWindow *uninstallWindow = new UninstallWindow(this);
|
|
|
|
uninstallWindow->show();
|
2007-12-14 19:49:11 +00:00
|
|
|
|
2007-08-10 22:17:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void RbUtilQt::uninstallBootloader(void)
|
|
|
|
{
|
2012-02-14 19:51:49 +00:00
|
|
|
if(chkConfig(this)) return;
|
2007-08-10 22:17:43 +00:00
|
|
|
if(QMessageBox::question(this, tr("Confirm Uninstallation"),
|
|
|
|
tr("Do you really want to uninstall the Bootloader?"),
|
|
|
|
QMessageBox::Yes | QMessageBox::No) != QMessageBox::Yes) return;
|
|
|
|
// create logger
|
|
|
|
ProgressLoggerGui* logger = new ProgressLoggerGui(this);
|
2008-09-28 17:02:36 +00:00
|
|
|
logger->setProgressVisible(false);
|
2007-08-10 22:17:43 +00:00
|
|
|
logger->show();
|
2007-09-15 22:57:07 +00:00
|
|
|
|
2009-05-09 16:59:14 +00:00
|
|
|
QString platform = RbSettings::value(RbSettings::Platform).toString();
|
2008-09-28 17:02:36 +00:00
|
|
|
|
|
|
|
// create installer
|
2012-05-01 08:09:14 +00:00
|
|
|
BootloaderInstallBase *bl
|
|
|
|
= BootloaderInstallHelper::createBootloaderInstaller(this,
|
|
|
|
SystemInfo::value(SystemInfo::CurBootloaderMethod).toString());
|
2011-06-25 17:20:56 +00:00
|
|
|
|
2012-05-01 08:09:14 +00:00
|
|
|
if(bl == NULL) {
|
2010-05-07 18:18:43 +00:00
|
|
|
logger->addItem(tr("No uninstall method for this target known."), LOGERROR);
|
|
|
|
logger->setFinished();
|
|
|
|
return;
|
2008-09-28 17:02:36 +00:00
|
|
|
}
|
2010-01-24 21:12:11 +00:00
|
|
|
QStringList blfile = SystemInfo::value(SystemInfo::CurBootloaderFile).toStringList();
|
2009-08-09 10:57:39 +00:00
|
|
|
QStringList blfilepath;
|
|
|
|
for(int a = 0; a < blfile.size(); a++) {
|
|
|
|
blfilepath.append(RbSettings::value(RbSettings::Mountpoint).toString()
|
|
|
|
+ blfile.at(a));
|
2008-09-28 17:02:36 +00:00
|
|
|
}
|
2009-08-09 10:57:39 +00:00
|
|
|
bl->setBlFile(blfilepath);
|
2016-01-09 01:41:17 +00:00
|
|
|
bl->setLogfile(RbSettings::value(RbSettings::Mountpoint).toString()
|
|
|
|
+ "/.rockbox/rbutil.log");
|
2008-09-28 17:02:36 +00:00
|
|
|
|
2011-06-25 17:21:01 +00:00
|
|
|
BootloaderInstallBase::BootloaderType currentbl = bl->installed();
|
2012-07-01 10:33:06 +00:00
|
|
|
if((bl->capabilities() & BootloaderInstallBase::Uninstall) == 0) {
|
2014-11-14 21:32:17 +00:00
|
|
|
logger->addItem(tr("Rockbox Utility can not uninstall the bootloader on your player. "
|
|
|
|
"Please perform a firmware update using your player vendors "
|
|
|
|
"firmware update process."), LOGERROR);
|
|
|
|
logger->addItem(tr("Important: make sure to boot your player into the original "
|
|
|
|
"firmware before using the vendors firmware update process."), LOGERROR);
|
2011-06-25 17:21:01 +00:00
|
|
|
logger->setFinished();
|
|
|
|
delete bl;
|
|
|
|
return;
|
|
|
|
}
|
2012-07-01 10:33:06 +00:00
|
|
|
if(currentbl == BootloaderInstallBase::BootloaderUnknown
|
|
|
|
|| currentbl == BootloaderInstallBase::BootloaderOther) {
|
|
|
|
logger->addItem(tr("No Rockbox bootloader found."), LOGERROR);
|
|
|
|
logger->setFinished();
|
|
|
|
delete bl;
|
|
|
|
return;
|
|
|
|
}
|
2011-06-25 17:21:01 +00:00
|
|
|
|
2008-09-28 17:02:36 +00:00
|
|
|
connect(bl, SIGNAL(logItem(QString, int)), logger, SLOT(addItem(QString, int)));
|
|
|
|
connect(bl, SIGNAL(logProgress(int, int)), logger, SLOT(setProgress(int, int)));
|
|
|
|
|
2011-05-29 19:46:20 +00:00
|
|
|
bl->uninstall();
|
2008-09-28 17:02:36 +00:00
|
|
|
|
2009-05-02 18:40:04 +00:00
|
|
|
logger->setFinished();
|
2007-09-15 22:57:07 +00:00
|
|
|
|
2007-08-10 22:17:43 +00:00
|
|
|
}
|
2007-08-22 10:55:05 +00:00
|
|
|
|
|
|
|
|
2007-08-22 22:25:04 +00:00
|
|
|
void RbUtilQt::installPortable(void)
|
|
|
|
{
|
|
|
|
if(QMessageBox::question(this, tr("Confirm installation"),
|
|
|
|
tr("Do you really want to install Rockbox Utility to your player? "
|
|
|
|
"After installation you can run it from the players hard drive."),
|
|
|
|
QMessageBox::Yes | QMessageBox::No) != QMessageBox::Yes)
|
|
|
|
return;
|
|
|
|
|
|
|
|
ProgressLoggerGui* logger = new ProgressLoggerGui(this);
|
2007-10-16 21:30:13 +00:00
|
|
|
logger->setProgressMax(0);
|
|
|
|
logger->setProgressValue(0);
|
2007-08-22 22:25:04 +00:00
|
|
|
logger->show();
|
|
|
|
logger->addItem(tr("Installing Rockbox Utility"), LOGINFO);
|
|
|
|
|
|
|
|
// check mountpoint
|
2009-05-09 16:59:14 +00:00
|
|
|
if(!QFileInfo(RbSettings::value(RbSettings::Mountpoint).toString()).isDir()) {
|
2007-08-22 22:25:04 +00:00
|
|
|
logger->addItem(tr("Mount point is wrong!"),LOGERROR);
|
2009-05-02 18:40:04 +00:00
|
|
|
logger->setFinished();
|
2007-08-22 22:25:04 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// remove old files first.
|
2009-05-09 16:59:14 +00:00
|
|
|
QFile::remove(RbSettings::value(RbSettings::Mountpoint).toString()
|
2009-04-29 20:58:47 +00:00
|
|
|
+ "/RockboxUtility.exe");
|
2009-05-09 16:59:14 +00:00
|
|
|
QFile::remove(RbSettings::value(RbSettings::Mountpoint).toString()
|
2009-04-29 20:58:47 +00:00
|
|
|
+ "/RockboxUtility.ini");
|
2007-08-22 22:25:04 +00:00
|
|
|
// copy currently running binary and currently used settings file
|
2009-04-29 20:58:47 +00:00
|
|
|
if(!QFile::copy(qApp->applicationFilePath(),
|
2009-05-09 16:59:14 +00:00
|
|
|
RbSettings::value(RbSettings::Mountpoint).toString()
|
2008-12-18 22:42:24 +00:00
|
|
|
+ "/RockboxUtility.exe")) {
|
2007-08-22 22:25:04 +00:00
|
|
|
logger->addItem(tr("Error installing Rockbox Utility"), LOGERROR);
|
2009-05-02 18:40:04 +00:00
|
|
|
logger->setFinished();
|
2007-08-22 22:25:04 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
logger->addItem(tr("Installing user configuration"), LOGINFO);
|
2009-05-09 16:59:14 +00:00
|
|
|
if(!QFile::copy(RbSettings::userSettingFilename(),
|
|
|
|
RbSettings::value(RbSettings::Mountpoint).toString()
|
2008-12-18 22:42:24 +00:00
|
|
|
+ "/RockboxUtility.ini")) {
|
2007-08-22 22:25:04 +00:00
|
|
|
logger->addItem(tr("Error installing user configuration"), LOGERROR);
|
2009-05-02 18:40:04 +00:00
|
|
|
logger->setFinished();
|
2007-08-22 22:25:04 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
logger->addItem(tr("Successfully installed Rockbox Utility."), LOGOK);
|
2009-05-02 18:40:04 +00:00
|
|
|
logger->setFinished();
|
2007-10-16 21:30:13 +00:00
|
|
|
logger->setProgressMax(1);
|
|
|
|
logger->setProgressValue(1);
|
2007-09-15 22:57:07 +00:00
|
|
|
|
2007-08-22 22:25:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-08-26 11:31:55 +00:00
|
|
|
QUrl RbUtilQt::proxy()
|
|
|
|
{
|
2011-06-25 17:21:06 +00:00
|
|
|
QUrl proxy;
|
2012-06-24 16:37:47 +00:00
|
|
|
QString proxytype = RbSettings::value(RbSettings::ProxyType).toString();
|
2013-03-19 21:20:23 +00:00
|
|
|
if(proxytype == "manual") {
|
|
|
|
proxy.setUrl(RbSettings::value(RbSettings::Proxy).toString(),
|
|
|
|
QUrl::TolerantMode);
|
|
|
|
QByteArray pw = QByteArray::fromBase64(proxy.password().toUtf8());
|
|
|
|
proxy.setPassword(pw);
|
|
|
|
}
|
2012-06-24 16:37:47 +00:00
|
|
|
else if(proxytype == "system")
|
2011-06-25 17:21:06 +00:00
|
|
|
proxy = System::systemProxy();
|
2012-06-24 16:37:47 +00:00
|
|
|
|
2013-11-03 10:08:18 +00:00
|
|
|
LOG_INFO() << "Proxy is" << proxy;
|
2011-06-25 17:21:06 +00:00
|
|
|
return proxy;
|
2007-08-26 11:31:55 +00:00
|
|
|
}
|
|
|
|
|
2007-09-16 18:32:49 +00:00
|
|
|
|
2012-02-14 19:51:49 +00:00
|
|
|
bool RbUtilQt::chkConfig(QWidget *parent)
|
2007-09-16 18:32:49 +00:00
|
|
|
{
|
|
|
|
bool error = false;
|
2009-05-09 16:59:14 +00:00
|
|
|
if(RbSettings::value(RbSettings::Platform).toString().isEmpty()
|
|
|
|
|| RbSettings::value(RbSettings::Mountpoint).toString().isEmpty()
|
|
|
|
|| !QFileInfo(RbSettings::value(RbSettings::Mountpoint).toString()).isWritable()) {
|
2007-09-16 18:32:49 +00:00
|
|
|
error = true;
|
|
|
|
|
2012-02-14 19:51:49 +00:00
|
|
|
if(parent) QMessageBox::critical(parent, tr("Configuration error"),
|
2007-09-17 08:50:46 +00:00
|
|
|
tr("Your configuration is invalid. Please go to the configuration "
|
2007-09-16 18:32:49 +00:00
|
|
|
"dialog and make sure the selected values are correct."));
|
|
|
|
}
|
|
|
|
return error;
|
|
|
|
}
|
|
|
|
|
2009-09-18 22:28:09 +00:00
|
|
|
void RbUtilQt::checkUpdate(void)
|
|
|
|
{
|
2010-01-24 21:12:11 +00:00
|
|
|
QString url = SystemInfo::value(SystemInfo::RbutilUrl).toString();
|
2009-09-18 22:28:09 +00:00
|
|
|
#if defined(Q_OS_WIN32)
|
|
|
|
url += "win32/";
|
|
|
|
#elif defined(Q_OS_LINUX)
|
|
|
|
url += "linux/";
|
|
|
|
#elif defined(Q_OS_MACX)
|
|
|
|
url += "macosx/";
|
|
|
|
#endif
|
2011-03-25 22:16:12 +00:00
|
|
|
|
2009-09-18 22:28:09 +00:00
|
|
|
update = new HttpGet(this);
|
|
|
|
connect(update, SIGNAL(done(bool)), this, SLOT(downloadUpdateDone(bool)));
|
|
|
|
connect(qApp, SIGNAL(lastWindowClosed()), update, SLOT(abort()));
|
2011-03-25 22:16:12 +00:00
|
|
|
|
2010-06-11 19:18:13 +00:00
|
|
|
ui.statusbar->showMessage(tr("Checking for update ..."));
|
2009-09-18 22:28:09 +00:00
|
|
|
update->getFile(QUrl(url));
|
|
|
|
}
|
2009-08-16 20:39:00 +00:00
|
|
|
|
2009-09-18 22:28:09 +00:00
|
|
|
void RbUtilQt::downloadUpdateDone(bool error)
|
|
|
|
{
|
|
|
|
if(error) {
|
2013-11-03 10:08:18 +00:00
|
|
|
LOG_INFO() << "network error:" << update->errorString();
|
2009-09-18 22:28:09 +00:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
QString toParse(update->readAll());
|
2011-03-19 11:47:10 +00:00
|
|
|
|
2010-02-28 20:28:45 +00:00
|
|
|
QRegExp searchString("<a[^>]*>([a-zA-Z]+[^<]*)</a>");
|
2009-09-18 22:28:09 +00:00
|
|
|
QStringList rbutilList;
|
|
|
|
int pos = 0;
|
2011-03-19 11:47:10 +00:00
|
|
|
while ((pos = searchString.indexIn(toParse, pos)) != -1)
|
2009-09-18 22:28:09 +00:00
|
|
|
{
|
|
|
|
rbutilList << searchString.cap(1);
|
|
|
|
pos += searchString.matchedLength();
|
|
|
|
}
|
2013-11-03 10:08:18 +00:00
|
|
|
LOG_INFO() << "Checking for update";
|
2011-03-19 11:47:10 +00:00
|
|
|
|
2010-06-11 19:18:13 +00:00
|
|
|
QString newVersion = "";
|
2011-03-19 11:47:10 +00:00
|
|
|
QString foundVersion = "";
|
|
|
|
// check if there is a binary with higher version in this list
|
2009-09-18 22:28:09 +00:00
|
|
|
for(int i=0; i < rbutilList.size(); i++)
|
|
|
|
{
|
2011-03-19 11:47:10 +00:00
|
|
|
QString item = rbutilList.at(i);
|
2009-09-18 22:28:09 +00:00
|
|
|
#if defined(Q_OS_LINUX)
|
|
|
|
#if defined(__amd64__)
|
2011-03-19 11:47:10 +00:00
|
|
|
// skip if it isn't a 64 bit build
|
|
|
|
if( !item.contains("64bit"))
|
2009-09-18 22:28:09 +00:00
|
|
|
continue;
|
2011-03-19 11:47:10 +00:00
|
|
|
// strip the "64bit" suffix for comparison
|
|
|
|
item = item.remove("64bit");
|
2009-09-18 22:28:09 +00:00
|
|
|
#else
|
|
|
|
//skip if it is a 64bit build
|
2011-03-19 11:47:10 +00:00
|
|
|
if(item.contains("64bit"))
|
2009-09-18 22:28:09 +00:00
|
|
|
continue;
|
2011-03-19 11:47:10 +00:00
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
// check if it is newer, and remember newest
|
|
|
|
if(Utils::compareVersionStrings(VERSION, item) == 1)
|
2009-09-18 22:28:09 +00:00
|
|
|
{
|
2011-03-19 11:47:10 +00:00
|
|
|
if(Utils::compareVersionStrings(newVersion, item) == 1)
|
2009-09-18 22:28:09 +00:00
|
|
|
{
|
2011-03-19 11:47:10 +00:00
|
|
|
newVersion = item;
|
|
|
|
foundVersion = rbutilList.at(i);
|
2009-09-18 22:28:09 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// if we found something newer, display info
|
2011-03-19 11:47:10 +00:00
|
|
|
if(foundVersion != "")
|
2009-09-18 22:28:09 +00:00
|
|
|
{
|
2010-01-24 21:12:11 +00:00
|
|
|
QString url = SystemInfo::value(SystemInfo::RbutilUrl).toString();
|
2009-09-18 22:28:09 +00:00
|
|
|
#if defined(Q_OS_WIN32)
|
|
|
|
url += "win32/";
|
|
|
|
#elif defined(Q_OS_LINUX)
|
|
|
|
url += "linux/";
|
|
|
|
#elif defined(Q_OS_MACX)
|
|
|
|
url += "macosx/";
|
|
|
|
#endif
|
2011-03-19 11:47:10 +00:00
|
|
|
url += foundVersion;
|
|
|
|
|
2015-01-31 17:30:42 +00:00
|
|
|
QMessageBox::information(this,tr("Rockbox Utility Update available"),
|
|
|
|
tr("<b>New Rockbox Utility version available.</b><br><br>"
|
|
|
|
"You are currently using version %1. "
|
|
|
|
"Get version %2 at <a href='%3'>%3</a>")
|
|
|
|
.arg(VERSION).arg(Utils::trimVersionString(foundVersion)).arg(url));
|
2010-06-11 19:18:13 +00:00
|
|
|
ui.statusbar->showMessage(tr("New version of Rockbox Utility available."));
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
ui.statusbar->showMessage(tr("Rockbox Utility is up to date."), 5000);
|
2009-09-18 22:28:09 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-10-02 14:30:05 +00:00
|
|
|
|
|
|
|
void RbUtilQt::changeEvent(QEvent *e)
|
|
|
|
{
|
|
|
|
if(e->type() == QEvent::LanguageChange) {
|
|
|
|
ui.retranslateUi(this);
|
2011-10-04 18:30:27 +00:00
|
|
|
buildInfo.open();
|
|
|
|
ServerInfo::readBuildInfo(buildInfo.fileName());
|
|
|
|
buildInfo.close();
|
|
|
|
updateDevice();
|
2011-10-02 14:30:05 +00:00
|
|
|
} else {
|
|
|
|
QMainWindow::changeEvent(e);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-09-08 18:34:36 +00:00
|
|
|
void RbUtilQt::eject(void)
|
|
|
|
{
|
|
|
|
QString mountpoint = RbSettings::value(RbSettings::Mountpoint).toString();
|
|
|
|
if(Utils::ejectDevice(mountpoint)) {
|
|
|
|
QMessageBox::information(this, tr("Device ejected"),
|
|
|
|
tr("Device successfully ejected. "
|
|
|
|
"You may now disconnect the player from the PC."));
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
QMessageBox::critical(this, tr("Ejecting failed"),
|
|
|
|
tr("Ejecting the device failed. Please make sure no programs "
|
|
|
|
"are accessing files on the device. If ejecting still "
|
|
|
|
"fails please use your computers eject funtionality."));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|