1 /***************************************************************************
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
9 * Copyright (C) 2007 by Dominik Riebeling
11 * All files in this archive are subject to the GNU General Public License.
12 * See the file COPYING in the source tree root for full license agreement.
14 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
15 * KIND, either express or implied.
17 ****************************************************************************/
23 #include "ui_rbutilqtfrm.h"
24 #include "ui_aboutbox.h"
25 #include "configure.h"
26 #include "installwindow.h"
27 #include "installtalkwindow.h"
28 #include "createvoicewindow.h"
30 #include "themesinstallwindow.h"
31 #include "uninstallwindow.h"
33 #include "rockboxinfo.h"
37 #include "rbsettings.h"
38 #include "serverinfo.h"
39 #include "systeminfo.h"
41 #include "manualwidget.h"
42 #include "infowidget.h"
44 #include "progressloggerinterface.h"
46 #include "bootloaderinstallbase.h"
47 #include "bootloaderinstallhelper.h"
49 #if defined(Q_OS_LINUX)
52 #if defined(Q_OS_WIN32)
61 QList
<QTranslator
*> RbUtilQt::translators
;
63 RbUtilQt::RbUtilQt(QWidget
*parent
) : QMainWindow(parent
)
66 qDebug() << "======================================";
67 qDebug() << "[System] Rockbox Utility " VERSION
;
68 qDebug() << "[System] Qt version:" << qVersion();
69 qDebug() << "======================================";
71 absolutePath
= qApp
->applicationDirPath();
73 HttpGet::setGlobalUserAgent("rbutil/"VERSION
);
74 HttpGet::setGlobalProxy(proxy());
75 // init startup & autodetection
77 #if defined(Q_OS_LINUX)
78 QIcon
windowIcon(":/icons/rockbox-clef.svg");
79 this->setWindowIcon(windowIcon
);
81 #if defined(Q_OS_WIN32)
82 QIcon windowIcon
= QIcon();
83 windowIcon
.addFile(":/icons/rockbox-16.png");
84 windowIcon
.addFile(":/icons/rockbox-32.png");
85 windowIcon
.addFile(":/icons/rockbox-48.png");
86 windowIcon
.addFile(":/icons/rockbox-64.png");
87 windowIcon
.addFile(":/icons/rockbox-128.png");
88 windowIcon
.addFile(":/icons/rockbox-256.png");
89 this->setWindowIcon(windowIcon
);
91 #if defined(Q_OS_MACX)
92 // don't translate menu entries that are handled specially on OS X
93 // (Configure, Quit). Qt handles them for us if they use english string.
94 ui
.action_Configure
->setText("Configure");
95 ui
.actionE_xit
->setText("Quit");
97 #if defined(Q_OS_WIN32)
100 ret
= RegOpenKeyEx(HKEY_CURRENT_USER
, _TEXT("Software\\Wine"),
101 0, KEY_QUERY_VALUE
, &hk
);
102 if(ret
== ERROR_SUCCESS
) {
103 QMessageBox::warning(this, tr("Wine detected!"),
104 tr("It seems you are trying to run this program under Wine. "
105 "Please don't do this, running under Wine will fail. "
106 "Use the native Linux binary instead."),
107 QMessageBox::Ok
, QMessageBox::Ok
);
108 qDebug() << "[RbUtil] WINE DETECTED!";
118 // insert ManualWidget() widget in manual tab
119 QGridLayout
*mantablayout
= new QGridLayout(this);
120 ui
.manual
->setLayout(mantablayout
);
121 manual
= new ManualWidget(this);
122 mantablayout
->addWidget(manual
);
125 QGridLayout
*infotablayout
= new QGridLayout(this);
126 ui
.info
->setLayout(infotablayout
);
127 info
= new InfoWidget(this);
128 infotablayout
->addWidget(info
);
130 // disable quick install until version info is available
131 ui
.buttonSmall
->setEnabled(false);
132 ui
.buttonComplete
->setEnabled(false);
133 ui
.actionSmall_Installation
->setEnabled(false);
134 ui
.actionComplete_Installation
->setEnabled(false);
136 connect(ui
.tabWidget
, SIGNAL(currentChanged(int)), this, SLOT(updateTabs(int)));
137 connect(ui
.actionAbout_Qt
, SIGNAL(triggered()), qApp
, SLOT(aboutQt()));
138 connect(ui
.action_About
, SIGNAL(triggered()), this, SLOT(about()));
139 connect(ui
.action_Help
, SIGNAL(triggered()), this, SLOT(help()));
140 connect(ui
.action_Configure
, SIGNAL(triggered()), this, SLOT(configDialog()));
141 connect(ui
.actionE_xit
, SIGNAL(triggered()), this, SLOT(shutdown()));
142 connect(ui
.buttonChangeDevice
, SIGNAL(clicked()), this, SLOT(configDialog()));
143 connect(ui
.buttonRockbox
, SIGNAL(clicked()), this, SLOT(installBtn()));
144 connect(ui
.buttonBootloader
, SIGNAL(clicked()), this, SLOT(installBootloaderBtn()));
145 connect(ui
.buttonFonts
, SIGNAL(clicked()), this, SLOT(installFontsBtn()));
146 connect(ui
.buttonGames
, SIGNAL(clicked()), this, SLOT(installDoomBtn()));
147 connect(ui
.buttonTalk
, SIGNAL(clicked()), this, SLOT(createTalkFiles()));
148 connect(ui
.buttonCreateVoice
, SIGNAL(clicked()), this, SLOT(createVoiceFile()));
149 connect(ui
.buttonVoice
, SIGNAL(clicked()), this, SLOT(installVoice()));
150 connect(ui
.buttonThemes
, SIGNAL(clicked()), this, SLOT(installThemes()));
151 connect(ui
.buttonRemoveRockbox
, SIGNAL(clicked()), this, SLOT(uninstall()));
152 connect(ui
.buttonRemoveBootloader
, SIGNAL(clicked()), this, SLOT(uninstallBootloader()));
153 connect(ui
.buttonSmall
, SIGNAL(clicked()), this, SLOT(smallInstall()));
154 connect(ui
.buttonComplete
, SIGNAL(clicked()), this, SLOT(completeInstall()));
156 // actions accessible from the menu
157 connect(ui
.actionComplete_Installation
, SIGNAL(triggered()), this, SLOT(completeInstall()));
158 connect(ui
.actionSmall_Installation
, SIGNAL(triggered()), this, SLOT(smallInstall()));
159 connect(ui
.actionInstall_Bootloader
, SIGNAL(triggered()), this, SLOT(installBootloaderBtn()));
160 connect(ui
.actionInstall_Rockbox
, SIGNAL(triggered()), this, SLOT(installBtn()));
161 connect(ui
.actionFonts_Package
, SIGNAL(triggered()), this, SLOT(installFontsBtn()));
162 connect(ui
.actionInstall_Themes
, SIGNAL(triggered()), this, SLOT(installThemes()));
163 connect(ui
.actionInstall_Game_Files
, SIGNAL(triggered()), this, SLOT(installDoomBtn()));
164 connect(ui
.actionInstall_Voice_File
, SIGNAL(triggered()), this, SLOT(installVoice()));
165 connect(ui
.actionCreate_Voice_File
, SIGNAL(triggered()), this, SLOT(createVoiceFile()));
166 connect(ui
.actionCreate_Talk_Files
, SIGNAL(triggered()), this, SLOT(createTalkFiles()));
167 connect(ui
.actionRemove_bootloader
, SIGNAL(triggered()), this, SLOT(uninstallBootloader()));
168 connect(ui
.actionUninstall_Rockbox
, SIGNAL(triggered()), this, SLOT(uninstall()));
169 connect(ui
.action_System_Info
, SIGNAL(triggered()), this, SLOT(sysinfo()));
170 connect(ui
.action_Trace
, SIGNAL(triggered()), this, SLOT(trace()));
173 ui
.actionInstall_Rockbox_Utility_on_player
->setEnabled(false);
175 connect(ui
.actionInstall_Rockbox_Utility_on_player
, SIGNAL(triggered()), this, SLOT(installPortable()));
177 Utils::findRunningProcess(QStringList("iTunes"));
182 void RbUtilQt::shutdown(void)
184 // restore default message handler to prevent trace accesses during
185 // object destruction -- the trace object could already be destroyed.
186 // Fixes segfaults on exit.
187 qInstallMsgHandler(0);
193 void RbUtilQt::trace(void)
199 void RbUtilQt::sysinfo(void)
205 void RbUtilQt::updateTabs(int count
)
217 void RbUtilQt::downloadInfo()
219 // try to get the current build information
220 daily
= new HttpGet(this);
221 connect(daily
, SIGNAL(done(bool)), this, SLOT(downloadDone(bool)));
222 connect(qApp
, SIGNAL(lastWindowClosed()), daily
, SLOT(abort()));
223 if(RbSettings::value(RbSettings::CacheOffline
).toBool())
224 daily
->setCache(true);
226 daily
->setCache(false);
227 ui
.statusbar
->showMessage(tr("Downloading build information, please wait ..."));
228 qDebug() << "[RbUtil] downloading build info";
229 daily
->setFile(&buildInfo
);
230 daily
->getFile(QUrl(SystemInfo::value(SystemInfo::ServerConfUrl
).toString()));
234 void RbUtilQt::downloadDone(bool error
)
237 qDebug() << "[RbUtil] network error:" << daily
->error();
238 ui
.statusbar
->showMessage(tr("Can't get version information!"));
239 QMessageBox::critical(this, tr("Network error"),
240 tr("Can't get version information.\n"
241 "Network error: %1. Please check your network and proxy settings.")
242 .arg(daily
->errorString()));
245 qDebug() << "[RbUtil] network status:" << daily
->error();
247 // read info into ServerInfo object
249 ServerInfo::readBuildInfo(buildInfo
.fileName());
252 // start bleeding info download
253 bleeding
= new HttpGet(this);
254 connect(bleeding
, SIGNAL(done(bool)), this, SLOT(downloadBleedingDone(bool)));
255 connect(qApp
, SIGNAL(lastWindowClosed()), bleeding
, SLOT(abort()));
256 if(RbSettings::value(RbSettings::CacheOffline
).toBool())
257 bleeding
->setCache(true);
258 bleeding
->setFile(&bleedingInfo
);
259 bleeding
->getFile(QUrl(SystemInfo::value(SystemInfo::BleedingInfo
).toString()));
260 ui
.statusbar
->showMessage(tr("Downloading build information, please wait ..."));
265 void RbUtilQt::downloadBleedingDone(bool error
)
268 qDebug() << "[RbUtil] network error:" << bleeding
->error();
269 ui
.statusbar
->showMessage(tr("Can't get version information!"));
270 QMessageBox::critical(this, tr("Network error"),
271 tr("Can't get version information.\n"
272 "Network error: %1. Please check your network and proxy settings.")
273 .arg(bleeding
->errorString()));
278 ServerInfo::readBleedingInfo(bleedingInfo
.fileName());
279 bleedingInfo
.close();
281 ui
.statusbar
->showMessage(tr("Download build information finished."), 5000);
285 //start check for updates
291 void RbUtilQt::about()
293 QDialog
*window
= new QDialog(this);
295 about
.setupUi(window
);
296 window
->setLayoutDirection(Qt::LeftToRight
);
297 window
->setModal(true);
299 QFile
licence(":/docs/gpl-2.0.html");
300 licence
.open(QIODevice::ReadOnly
);
301 QTextStream
c(&licence
);
302 about
.browserLicense
->insertHtml(c
.readAll());
303 about
.browserLicense
->moveCursor(QTextCursor::Start
, QTextCursor::MoveAnchor
);
305 QFile
speexlicense(":/docs/COPYING.SPEEX");
306 speexlicense
.open(QIODevice::ReadOnly
);
307 QTextStream
s(&speexlicense
);
308 about
.browserSpeexLicense
->insertHtml("<pre>" + s
.readAll() + "</pre>");
309 about
.browserSpeexLicense
->moveCursor(QTextCursor::Start
, QTextCursor::MoveAnchor
);
311 QFile
credits(":/docs/CREDITS");
312 credits
.open(QIODevice::ReadOnly
);
313 QTextStream
r(&credits
);
314 r
.setCodec(QTextCodec::codecForName("UTF-8"));
316 QString line
= r
.readLine();
317 // filter out header.
318 line
.remove(QRegExp("^ +.*"));
319 line
.remove(QRegExp("^People.*"));
320 about
.browserCredits
->append(line
);
322 about
.browserCredits
->moveCursor(QTextCursor::Start
, QTextCursor::MoveAnchor
);
323 QString title
= QString("<b>The Rockbox Utility</b><br/>Version %1").arg(FULLVERSION
);
324 about
.labelTitle
->setText(title
);
331 void RbUtilQt::help()
333 QUrl
helpurl("http://www.rockbox.org/wiki/RockboxUtility");
334 QDesktopServices::openUrl(helpurl
);
338 void RbUtilQt::configDialog()
340 Config
*cw
= new Config(this);
341 connect(cw
, SIGNAL(settingsUpdated()), this, SLOT(updateSettings()));
346 void RbUtilQt::updateSettings()
348 qDebug() << "[RbUtil] updating current settings";
350 manual
->updateManual();
351 HttpGet::setGlobalProxy(proxy());
352 HttpGet::setGlobalCache(RbSettings::value(RbSettings::CachePath
).toString());
353 HttpGet::setGlobalDumbCache(RbSettings::value(RbSettings::CacheOffline
).toBool());
355 if(RbSettings::value(RbSettings::RbutilVersion
) != PUREVERSION
) {
356 QApplication::processEvents();
357 QMessageBox::information(this, tr("New installation"),
358 tr("This is a new installation of Rockbox Utility, or a new version. "
359 "The configuration dialog will now open to allow you to setup the program, "
360 " or review your settings."));
363 else if(chkConfig(0)) {
364 QApplication::processEvents();
365 QMessageBox::critical(this, tr("Configuration error"),
366 tr("Your configuration is invalid. This is most likely due "
367 "to a changed device path. The configuration dialog will "
368 "now open to allow you to correct the problem."));
374 void RbUtilQt::updateDevice()
376 /* TODO: We should check the flags of the bootloaderinstall classes, and not
377 * just check if its != none or != "fwpatcher" */
379 /* Enable bootloader installation, if possible */
380 bool bootloaderInstallable
=
381 SystemInfo::value(SystemInfo::CurBootloaderMethod
) != "none";
382 ui
.buttonBootloader
->setEnabled(bootloaderInstallable
);
383 ui
.labelBootloader
->setEnabled(bootloaderInstallable
);
384 ui
.actionInstall_Bootloader
->setEnabled(bootloaderInstallable
);
386 /* Enable bootloader uninstallation, if possible */
387 bool bootloaderUninstallable
= bootloaderInstallable
&&
388 SystemInfo::value(SystemInfo::CurBootloaderMethod
) != "fwpatcher";
389 ui
.labelRemoveBootloader
->setEnabled(bootloaderUninstallable
);
390 ui
.buttonRemoveBootloader
->setEnabled(bootloaderUninstallable
);
391 ui
.actionRemove_bootloader
->setEnabled(bootloaderUninstallable
);
393 /* Disable the whole tab widget if configuration is invalid */
394 bool configurationValid
= !chkConfig(0);
395 ui
.tabWidget
->setEnabled(configurationValid
);
396 ui
.menuA_ctions
->setEnabled(configurationValid
);
398 // displayed device info
399 QString mountpoint
= RbSettings::value(RbSettings::Mountpoint
).toString();
400 QString brand
= SystemInfo::value(SystemInfo::CurBrand
).toString();
401 QString name
= SystemInfo::value(SystemInfo::CurName
).toString() +
402 " (" + ServerInfo::value(ServerInfo::CurStatus
).toString() + ")";
403 QString mountdisplay
= QDir::toNativeSeparators(mountpoint
);
404 QString label
= Utils::filesystemName(mountpoint
);
406 mountdisplay
+= " (" + label
+ ")";
408 if(name
.isEmpty()) name
= "<none>";
409 if(mountpoint
.isEmpty())
410 mountpoint
= "<invalid>";
411 ui
.labelDevice
->setText(tr("<b>%1 %2</b> at <b>%3</b>")
412 .arg(brand
, name
, mountdisplay
));
414 // hide quickstart buttons if no release available
415 bool installable
= !ServerInfo::value(ServerInfo::CurReleaseVersion
).toString().isEmpty();
416 ui
.buttonSmall
->setEnabled(installable
);
417 ui
.buttonComplete
->setEnabled(installable
);
418 ui
.actionSmall_Installation
->setEnabled(installable
);
419 ui
.actionComplete_Installation
->setEnabled(installable
);
423 void RbUtilQt::completeInstall()
425 if(chkConfig(this)) return;
426 if(QMessageBox::question(this, tr("Confirm Installation"),
427 tr("Do you really want to perform a complete installation?\n\n"
428 "This will install Rockbox %1. To install the most recent "
429 "development build available press \"Cancel\" and "
430 "use the \"Installation\" tab.")
431 .arg(ServerInfo::value(ServerInfo::CurReleaseVersion
).toString()),
432 QMessageBox::Ok
| QMessageBox::Cancel
) != QMessageBox::Ok
)
435 logger
= new ProgressLoggerGui(this);
438 if(smallInstallInner())
440 logger
->setRunning();
444 if(!installFontsAuto())
448 // wait for installation finished
450 QApplication::processEvents();
453 logger
->setRunning();
460 if(!installDoomAuto())
464 // wait for installation finished
466 QApplication::processEvents();
473 // it has its own logger window,so close our.
479 void RbUtilQt::smallInstall()
481 if(chkConfig(this)) return;
482 if(QMessageBox::question(this, tr("Confirm Installation"),
483 tr("Do you really want to perform a minimal installation? "
484 "A minimal installation will contain only the absolutely "
485 "necessary parts to run Rockbox.\n\n"
486 "This will install Rockbox %1. To install the most recent "
487 "development build available press \"Cancel\" and "
488 "use the \"Installation\" tab.")
489 .arg(ServerInfo::value(ServerInfo::CurReleaseVersion
).toString()),
490 QMessageBox::Ok
| QMessageBox::Cancel
) != QMessageBox::Ok
)
494 logger
= new ProgressLoggerGui(this);
500 bool RbUtilQt::smallInstallInner()
502 QString mountpoint
= RbSettings::value(RbSettings::Mountpoint
).toString();
503 // show dialog with error if mount point is wrong
504 if(!QFileInfo(mountpoint
).isDir()) {
505 logger
->addItem(tr("Mount point is wrong!"),LOGERROR
);
506 logger
->setFinished();
510 if(SystemInfo::value(SystemInfo::CurBootloaderMethod
) != "none")
515 if(!installBootloaderAuto()) {
516 logger
->setFinished();
521 // wait for boot loader installation finished
523 QApplication::processEvents();
526 if(m_error
) return true;
527 logger
->setRunning();
537 // wait for installation finished
539 QApplication::processEvents();
542 installBootloaderPost(false);
546 void RbUtilQt::installdone(bool error
)
548 qDebug() << "[RbUtil] install done";
553 void RbUtilQt::installBtn()
555 if(chkConfig(this)) return;
559 bool RbUtilQt::installAuto()
561 QString file
= SystemInfo::value(SystemInfo::ReleaseUrl
).toString();
562 file
.replace("%MODEL%", SystemInfo::value(SystemInfo::CurBuildserverModel
).toString());
563 file
.replace("%RELVERSION%", ServerInfo::value(ServerInfo::CurReleaseVersion
).toString());
565 // check installed Version and Target
566 QString warning
= Utils::checkEnvironment(false);
567 if(!warning
.isEmpty())
569 if(QMessageBox::warning(this, tr("Really continue?"), warning
,
570 QMessageBox::Ok
| QMessageBox::Abort
, QMessageBox::Abort
)
571 == QMessageBox::Abort
)
573 logger
->addItem(tr("Aborted!"), LOGERROR
);
574 logger
->setFinished();
580 RockboxInfo
rbinfo(RbSettings::value(RbSettings::Mountpoint
).toString());
581 if(rbinfo
.version() != "")
583 if(QMessageBox::question(this, tr("Installed Rockbox detected"),
584 tr("Rockbox installation detected. Do you want to backup first?"),
585 QMessageBox::Yes
| QMessageBox::No
) == QMessageBox::Yes
)
588 logger
->addItem(tr("Starting backup..."),LOGINFO
);
589 QString backupName
= RbSettings::value(RbSettings::Mountpoint
).toString()
590 + "/.backup/rockbox-backup-" + rbinfo
.version() + ".zip";
592 //! create dir, if it doesnt exist
593 QFileInfo
backupFile(backupName
);
594 if(!QDir(backupFile
.path()).exists())
597 a
.mkpath(backupFile
.path());
600 logger
->addItem(tr("Beginning Backup..."),LOGINFO
);
601 QCoreApplication::processEvents();
605 connect(&zip
, SIGNAL(logProgress(int, int)), logger
, SLOT(setProgress(int, int)));
606 connect(&zip
, SIGNAL(logItem(QString
, int)), logger
, SLOT(addItem(QString
, int)));
607 zip
.open(backupName
, QuaZip::mdCreate
);
608 QString mp
= RbSettings::value(RbSettings::Mountpoint
).toString();
609 QString folder
= mp
+ "/.rockbox";
610 result
= zip
.appendDirToArchive(folder
, mp
);
614 logger
->addItem(tr("Backup successful"),LOGOK
);
618 logger
->addItem(tr("Backup failed!"),LOGERROR
);
619 logger
->setFinished();
625 //! install current build
626 ZipInstaller
* installer
= new ZipInstaller(this);
627 installer
->setUrl(file
);
628 installer
->setLogSection("Rockbox (Base)");
629 installer
->setLogVersion(ServerInfo::value(ServerInfo::CurReleaseVersion
).toString());
630 if(!RbSettings::value(RbSettings::CacheDisabled
).toBool())
631 installer
->setCache(true);
632 installer
->setMountPoint(RbSettings::value(RbSettings::Mountpoint
).toString());
634 connect(installer
, SIGNAL(done(bool)), this, SLOT(installdone(bool)));
635 connect(installer
, SIGNAL(logItem(QString
, int)), logger
, SLOT(addItem(QString
, int)));
636 connect(installer
, SIGNAL(logProgress(int, int)), logger
, SLOT(setProgress(int, int)));
637 connect(installer
, SIGNAL(done(bool)), logger
, SLOT(setFinished()));
638 connect(logger
, SIGNAL(aborted()), installer
, SLOT(abort()));
639 installer
->install();
644 void RbUtilQt::install()
646 InstallWindow
*installWindow
= new InstallWindow(this);
647 installWindow
->show();
650 bool RbUtilQt::installBootloaderAuto()
656 void RbUtilQt::installBootloaderBtn()
658 if(chkConfig(this)) return;
659 if(QMessageBox::question(this, tr("Confirm Installation"),
660 tr("Do you really want to install the Bootloader?"),
661 QMessageBox::Yes
| QMessageBox::No
) != QMessageBox::Yes
) return;
664 logger
= new ProgressLoggerGui(this);
669 void RbUtilQt::installBootloader()
671 QString platform
= RbSettings::value(RbSettings::Platform
).toString();
672 QString backupDestination
= "";
676 BootloaderInstallBase
*bl
=
677 BootloaderInstallHelper::createBootloaderInstaller(this,
678 SystemInfo::value(SystemInfo::CurBootloaderMethod
).toString());
680 logger
->addItem(tr("No install method known."), LOGERROR
);
681 logger
->setFinished();
685 // the bootloader install class does NOT use any GUI stuff.
686 // All messages are passed via signals.
687 connect(bl
, SIGNAL(done(bool)), logger
, SLOT(setFinished()));
688 connect(bl
, SIGNAL(done(bool)), this, SLOT(installBootloaderPost(bool)));
689 connect(bl
, SIGNAL(logItem(QString
, int)), logger
, SLOT(addItem(QString
, int)));
690 connect(bl
, SIGNAL(logProgress(int, int)), logger
, SLOT(setProgress(int, int)));
692 // set bootloader filename. Do this now as installed() needs it.
693 QStringList blfile
= SystemInfo::value(SystemInfo::CurBootloaderFile
).toStringList();
694 QStringList blfilepath
;
695 for(int a
= 0; a
< blfile
.size(); a
++) {
696 blfilepath
.append(RbSettings::value(RbSettings::Mountpoint
).toString()
699 bl
->setBlFile(blfilepath
);
700 QUrl
url(SystemInfo::value(SystemInfo::BootloaderUrl
).toString()
701 + SystemInfo::value(SystemInfo::CurBootloaderName
).toString());
703 bl
->setLogfile(RbSettings::value(RbSettings::Mountpoint
).toString()
704 + "/.rockbox/rbutil.log");
706 if(bl
->installed() == BootloaderInstallBase::BootloaderRockbox
) {
707 if(QMessageBox::question(this, tr("Bootloader detected"),
708 tr("Bootloader already installed. Do you want to reinstall the bootloader?"),
709 QMessageBox::Yes
| QMessageBox::No
) == QMessageBox::No
) {
711 // keep logger open for auto installs.
712 // don't consider abort as error in auto-mode.
713 logger
->addItem(tr("Bootloader installation skipped"), LOGINFO
);
714 installBootloaderPost(false);
718 installBootloaderPost(true);
724 else if(bl
->installed() == BootloaderInstallBase::BootloaderOther
725 && bl
->capabilities() & BootloaderInstallBase::Backup
)
727 QString targetFolder
= SystemInfo::value(SystemInfo::CurPlatformName
).toString()
728 + " Firmware Backup";
729 // remove invalid character(s)
730 targetFolder
.remove(QRegExp("[:/]"));
731 if(QMessageBox::question(this, tr("Create Bootloader backup"),
732 tr("You can create a backup of the original bootloader "
733 "file. Press \"Yes\" to select an output folder on your "
734 "computer to save the file to. The file will get placed "
735 "in a new folder \"%1\" created below the selected folder.\n"
736 "Press \"No\" to skip this step.").arg(targetFolder
),
737 QMessageBox::Yes
| QMessageBox::No
) == QMessageBox::Yes
) {
738 backupDestination
= QFileDialog::getExistingDirectory(this,
739 tr("Browse backup folder"), QDir::homePath());
740 if(!backupDestination
.isEmpty())
741 backupDestination
+= "/" + targetFolder
;
743 qDebug() << "[RbUtil] backing up to" << backupDestination
;
744 // backup needs to be done after the logger has been set up.
748 if(bl
->capabilities() & BootloaderInstallBase::NeedsOf
)
751 ret
= QMessageBox::information(this, tr("Prerequisites"),
752 bl
->ofHint(),QMessageBox::Ok
| QMessageBox::Abort
);
753 if(ret
!= QMessageBox::Ok
) {
754 // consider aborting an error to close window / abort automatic
757 logger
->addItem(tr("Bootloader installation aborted"), LOGINFO
);
758 logger
->setFinished();
761 // open dialog to browse to of file
764 = SystemInfo::value(SystemInfo::CurBootloaderFilter
).toString();
765 if(!filter
.isEmpty()) {
766 filter
= tr("Bootloader files (%1)").arg(filter
) + ";;";
768 filter
+= tr("All files (*)");
769 offile
= QFileDialog::getOpenFileName(this,
770 tr("Select firmware file"), QDir::homePath(), filter
);
771 if(!QFileInfo(offile
).isReadable()) {
772 logger
->addItem(tr("Error opening firmware file"), LOGERROR
);
773 logger
->setFinished();
777 if(!bl
->setOfFile(offile
, blfile
)) {
778 logger
->addItem(tr("Error reading firmware file"), LOGERROR
);
779 logger
->setFinished();
786 if(!backupDestination
.isEmpty()) {
787 if(!bl
->backup(backupDestination
)) {
788 if(QMessageBox::warning(this, tr("Backup error"),
789 tr("Could not create backup file. Continue?"),
790 QMessageBox::No
| QMessageBox::Yes
)
791 == QMessageBox::No
) {
792 logger
->setFinished();
800 void RbUtilQt::installBootloaderPost(bool error
)
802 qDebug() << "[RbUtil] Bootloader Post-Installation, error state:" << error
;
803 // if an error occured don't perform post install steps.
812 // end here if automated install
816 QString msg
= BootloaderInstallHelper::postinstallHints(
817 RbSettings::value(RbSettings::Platform
).toString());
819 QMessageBox::information(this, tr("Manual steps required"), msg
);
825 void RbUtilQt::installFontsBtn()
827 if(chkConfig(this)) return;
828 QString mountpoint
= RbSettings::value(RbSettings::Mountpoint
).toString();
829 RockboxInfo
installInfo(mountpoint
);
830 if(installInfo
.revision().isEmpty() && installInfo
.release().isEmpty()) {
831 QMessageBox::critical(this, tr("No Rockbox installation found"),
832 tr("Could not determine the installed Rockbox version. "
833 "Please install a Rockbox build before installing "
837 if(QMessageBox::question(this, tr("Confirm Installation"),
838 tr("Do you really want to install the fonts package?"),
839 QMessageBox::Yes
| QMessageBox::No
) != QMessageBox::Yes
) return;
841 logger
= new ProgressLoggerGui(this);
846 bool RbUtilQt::installFontsAuto()
853 void RbUtilQt::installFonts()
855 QString mountpoint
= RbSettings::value(RbSettings::Mountpoint
).toString();
856 RockboxInfo
installInfo(mountpoint
);
859 QString relversion
= installInfo
.release();
860 if(relversion
.isEmpty()) {
861 // release is empty for non-release versions (i.e. daily / current)
862 fontsurl
= SystemInfo::value(SystemInfo::DailyFontUrl
).toString();
863 logversion
= installInfo
.revision();
866 fontsurl
= SystemInfo::value(SystemInfo::ReleaseFontUrl
).toString();
867 logversion
= installInfo
.release();
869 fontsurl
.replace("%RELEASEVER%", relversion
);
871 // create zip installer
872 installer
= new ZipInstaller(this);
873 installer
->setUrl(fontsurl
);
874 installer
->setLogSection("Fonts");
875 installer
->setLogVersion(logversion
);
876 installer
->setMountPoint(mountpoint
);
877 if(!RbSettings::value(RbSettings::CacheDisabled
).toBool())
878 installer
->setCache(true);
880 connect(installer
, SIGNAL(done(bool)), this, SLOT(installdone(bool)));
881 connect(installer
, SIGNAL(logItem(QString
, int)), logger
, SLOT(addItem(QString
, int)));
882 connect(installer
, SIGNAL(logProgress(int, int)), logger
, SLOT(setProgress(int, int)));
883 connect(installer
, SIGNAL(done(bool)), logger
, SLOT(setFinished()));
884 connect(logger
, SIGNAL(aborted()), installer
, SLOT(abort()));
885 installer
->install();
889 void RbUtilQt::installVoice()
891 if(chkConfig(this)) return;
893 if(m_gotInfo
== false)
895 QMessageBox::warning(this, tr("Warning"),
896 tr("The Application is still downloading Information about new Builds."
897 " Please try again shortly."));
901 QString mountpoint
= RbSettings::value(RbSettings::Mountpoint
).toString();
902 RockboxInfo
installInfo(mountpoint
);
906 QString relversion
= installInfo
.release();
907 // if no version is found abort.
908 if(installInfo
.revision().isEmpty() && relversion
.isEmpty()) {
909 QMessageBox::critical(this, tr("No Rockbox installation found"),
910 tr("Could not determine the installed Rockbox version. "
911 "Please install a Rockbox build before installing "
915 if(relversion
.isEmpty()) {
916 // release is empty for non-release versions (i.e. daily / current)
917 voiceurl
= SystemInfo::value(SystemInfo::DailyVoiceUrl
).toString();
918 logversion
= installInfo
.revision();
921 voiceurl
= SystemInfo::value(SystemInfo::ReleaseVoiceUrl
).toString();
922 logversion
= installInfo
.release();
924 if(QMessageBox::question(this, tr("Confirm Installation"),
925 tr("Do you really want to install the voice file?"),
926 QMessageBox::Yes
| QMessageBox::No
) != QMessageBox::Yes
)
929 QDate date
= QDate::fromString(
930 ServerInfo::value(ServerInfo::DailyDate
).toString(), Qt::ISODate
);
931 QString model
= SystemInfo::value(SystemInfo::CurBuildserverModel
).toString();
932 // replace placeholder in voice url
933 voiceurl
.replace("%DATE%", date
.toString("yyyyMMdd"));
934 voiceurl
.replace("%MODEL%", model
);
935 voiceurl
.replace("%RELVERSION%", relversion
);
937 qDebug() << "[RbUtil] voicefile URL:" << voiceurl
;
940 logger
= new ProgressLoggerGui(this);
942 // create zip installer
943 installer
= new ZipInstaller(this);
945 installer
->setUrl(voiceurl
);
946 installer
->setLogSection("Voice");
947 installer
->setLogVersion(logversion
);
948 installer
->setMountPoint(mountpoint
);
949 if(!RbSettings::value(RbSettings::CacheDisabled
).toBool())
950 installer
->setCache(true);
951 connect(installer
, SIGNAL(logItem(QString
, int)), logger
, SLOT(addItem(QString
, int)));
952 connect(installer
, SIGNAL(logProgress(int, int)), logger
, SLOT(setProgress(int, int)));
953 connect(installer
, SIGNAL(done(bool)), logger
, SLOT(setFinished()));
954 connect(logger
, SIGNAL(aborted()), installer
, SLOT(abort()));
955 installer
->install();
959 void RbUtilQt::installDoomBtn()
961 if(chkConfig(this)) return;
963 QMessageBox::critical(this, tr("Error"),
964 tr("Your device doesn't have a doom plugin. Aborting."));
968 if(QMessageBox::question(this, tr("Confirm Installation"),
969 tr("Do you really want to install the game addon files?"),
970 QMessageBox::Yes
| QMessageBox::No
) != QMessageBox::Yes
) return;
972 logger
= new ProgressLoggerGui(this);
977 bool RbUtilQt::installDoomAuto()
983 bool RbUtilQt::hasDoom()
985 QFile
doomrock(RbSettings::value(RbSettings::Mountpoint
).toString()
986 +"/.rockbox/rocks/games/doom.rock");
987 return doomrock
.exists();
990 void RbUtilQt::installDoom()
992 // create zip installer
993 installer
= new ZipInstaller(this);
995 installer
->setUrl(SystemInfo::value(SystemInfo::DoomUrl
).toString());
996 installer
->setLogSection("Game Addons");
997 installer
->setLogVersion(ServerInfo::value(ServerInfo::DailyDate
).toString());
998 installer
->setMountPoint(RbSettings::value(RbSettings::Mountpoint
).toString());
999 if(!RbSettings::value(RbSettings::CacheDisabled
).toBool())
1000 installer
->setCache(true);
1001 connect(installer
, SIGNAL(done(bool)), this, SLOT(installdone(bool)));
1002 connect(installer
, SIGNAL(logItem(QString
, int)), logger
, SLOT(addItem(QString
, int)));
1003 connect(installer
, SIGNAL(logProgress(int, int)), logger
, SLOT(setProgress(int, int)));
1004 connect(installer
, SIGNAL(done(bool)), logger
, SLOT(setFinished()));
1005 connect(logger
, SIGNAL(aborted()), installer
, SLOT(abort()));
1006 installer
->install();
1010 void RbUtilQt::installThemes()
1012 if(chkConfig(this)) return;
1013 ThemesInstallWindow
* tw
= new ThemesInstallWindow(this);
1018 void RbUtilQt::createTalkFiles(void)
1020 if(chkConfig(this)) return;
1021 InstallTalkWindow
*installWindow
= new InstallTalkWindow(this);
1022 connect(installWindow
, SIGNAL(settingsUpdated()), this, SLOT(updateSettings()));
1023 installWindow
->show();
1027 void RbUtilQt::createVoiceFile(void)
1029 if(chkConfig(this)) return;
1030 CreateVoiceWindow
*installWindow
= new CreateVoiceWindow(this);
1032 connect(installWindow
, SIGNAL(settingsUpdated()), this, SLOT(updateSettings()));
1033 installWindow
->show();
1036 void RbUtilQt::uninstall(void)
1038 if(chkConfig(this)) return;
1039 UninstallWindow
*uninstallWindow
= new UninstallWindow(this);
1040 uninstallWindow
->show();
1044 void RbUtilQt::uninstallBootloader(void)
1046 if(chkConfig(this)) return;
1047 if(QMessageBox::question(this, tr("Confirm Uninstallation"),
1048 tr("Do you really want to uninstall the Bootloader?"),
1049 QMessageBox::Yes
| QMessageBox::No
) != QMessageBox::Yes
) return;
1051 ProgressLoggerGui
* logger
= new ProgressLoggerGui(this);
1052 logger
->setProgressVisible(false);
1055 QString platform
= RbSettings::value(RbSettings::Platform
).toString();
1058 BootloaderInstallBase
*bl
1059 = BootloaderInstallHelper::createBootloaderInstaller(this,
1060 SystemInfo::value(SystemInfo::CurBootloaderMethod
).toString());
1063 logger
->addItem(tr("No uninstall method for this target known."), LOGERROR
);
1064 logger
->setFinished();
1067 QStringList blfile
= SystemInfo::value(SystemInfo::CurBootloaderFile
).toStringList();
1068 QStringList blfilepath
;
1069 for(int a
= 0; a
< blfile
.size(); a
++) {
1070 blfilepath
.append(RbSettings::value(RbSettings::Mountpoint
).toString()
1073 bl
->setBlFile(blfilepath
);
1075 BootloaderInstallBase::BootloaderType currentbl
= bl
->installed();
1076 if((bl
->capabilities() & BootloaderInstallBase::Uninstall
) == 0
1077 || currentbl
== BootloaderInstallBase::BootloaderUnknown
1078 || currentbl
== BootloaderInstallBase::BootloaderOther
)
1080 logger
->addItem(tr("Rockbox Utility can not uninstall the bootloader on this target. "
1081 "Try a normal firmware update to remove the booloader."), LOGERROR
);
1082 logger
->setFinished();
1087 connect(bl
, SIGNAL(logItem(QString
, int)), logger
, SLOT(addItem(QString
, int)));
1088 connect(bl
, SIGNAL(logProgress(int, int)), logger
, SLOT(setProgress(int, int)));
1092 logger
->setFinished();
1097 void RbUtilQt::installPortable(void)
1099 if(QMessageBox::question(this, tr("Confirm installation"),
1100 tr("Do you really want to install Rockbox Utility to your player? "
1101 "After installation you can run it from the players hard drive."),
1102 QMessageBox::Yes
| QMessageBox::No
) != QMessageBox::Yes
)
1105 ProgressLoggerGui
* logger
= new ProgressLoggerGui(this);
1106 logger
->setProgressMax(0);
1107 logger
->setProgressValue(0);
1109 logger
->addItem(tr("Installing Rockbox Utility"), LOGINFO
);
1112 if(!QFileInfo(RbSettings::value(RbSettings::Mountpoint
).toString()).isDir()) {
1113 logger
->addItem(tr("Mount point is wrong!"),LOGERROR
);
1114 logger
->setFinished();
1118 // remove old files first.
1119 QFile::remove(RbSettings::value(RbSettings::Mountpoint
).toString()
1120 + "/RockboxUtility.exe");
1121 QFile::remove(RbSettings::value(RbSettings::Mountpoint
).toString()
1122 + "/RockboxUtility.ini");
1123 // copy currently running binary and currently used settings file
1124 if(!QFile::copy(qApp
->applicationFilePath(),
1125 RbSettings::value(RbSettings::Mountpoint
).toString()
1126 + "/RockboxUtility.exe")) {
1127 logger
->addItem(tr("Error installing Rockbox Utility"), LOGERROR
);
1128 logger
->setFinished();
1131 logger
->addItem(tr("Installing user configuration"), LOGINFO
);
1132 if(!QFile::copy(RbSettings::userSettingFilename(),
1133 RbSettings::value(RbSettings::Mountpoint
).toString()
1134 + "/RockboxUtility.ini")) {
1135 logger
->addItem(tr("Error installing user configuration"), LOGERROR
);
1136 logger
->setFinished();
1139 logger
->addItem(tr("Successfully installed Rockbox Utility."), LOGOK
);
1140 logger
->setFinished();
1141 logger
->setProgressMax(1);
1142 logger
->setProgressValue(1);
1147 QUrl
RbUtilQt::proxy()
1150 if(RbSettings::value(RbSettings::ProxyType
) == "manual")
1151 proxy
.setEncodedUrl(RbSettings::value(RbSettings::Proxy
).toByteArray());
1152 else if(RbSettings::value(RbSettings::ProxyType
) == "system")
1153 proxy
= System::systemProxy();
1154 qDebug() << proxy
.userName() << proxy
.password() << proxy
.host() << proxy
.port();
1159 bool RbUtilQt::chkConfig(QWidget
*parent
)
1162 if(RbSettings::value(RbSettings::Platform
).toString().isEmpty()
1163 || RbSettings::value(RbSettings::Mountpoint
).toString().isEmpty()
1164 || !QFileInfo(RbSettings::value(RbSettings::Mountpoint
).toString()).isWritable()) {
1167 if(parent
) QMessageBox::critical(parent
, tr("Configuration error"),
1168 tr("Your configuration is invalid. Please go to the configuration "
1169 "dialog and make sure the selected values are correct."));
1174 void RbUtilQt::checkUpdate(void)
1176 QString url
= SystemInfo::value(SystemInfo::RbutilUrl
).toString();
1177 #if defined(Q_OS_WIN32)
1179 #elif defined(Q_OS_LINUX)
1181 #elif defined(Q_OS_MACX)
1185 update
= new HttpGet(this);
1186 connect(update
, SIGNAL(done(bool)), this, SLOT(downloadUpdateDone(bool)));
1187 connect(qApp
, SIGNAL(lastWindowClosed()), update
, SLOT(abort()));
1188 if(RbSettings::value(RbSettings::CacheOffline
).toBool())
1189 update
->setCache(true);
1191 ui
.statusbar
->showMessage(tr("Checking for update ..."));
1192 update
->getFile(QUrl(url
));
1195 void RbUtilQt::downloadUpdateDone(bool error
)
1198 qDebug() << "[RbUtil] network error:" << update
->error();
1201 QString
toParse(update
->readAll());
1203 QRegExp
searchString("<a[^>]*>([a-zA-Z]+[^<]*)</a>");
1204 QStringList rbutilList
;
1206 while ((pos
= searchString
.indexIn(toParse
, pos
)) != -1)
1208 rbutilList
<< searchString
.cap(1);
1209 pos
+= searchString
.matchedLength();
1211 qDebug() << "[RbUtilQt] Checking for update";
1213 QString newVersion
= "";
1214 QString foundVersion
= "";
1215 // check if there is a binary with higher version in this list
1216 for(int i
=0; i
< rbutilList
.size(); i
++)
1218 QString item
= rbutilList
.at(i
);
1219 #if defined(Q_OS_LINUX)
1220 #if defined(__amd64__)
1221 // skip if it isn't a 64 bit build
1222 if( !item
.contains("64bit"))
1224 // strip the "64bit" suffix for comparison
1225 item
= item
.remove("64bit");
1227 //skip if it is a 64bit build
1228 if(item
.contains("64bit"))
1232 // check if it is newer, and remember newest
1233 if(Utils::compareVersionStrings(VERSION
, item
) == 1)
1235 if(Utils::compareVersionStrings(newVersion
, item
) == 1)
1238 foundVersion
= rbutilList
.at(i
);
1243 // if we found something newer, display info
1244 if(foundVersion
!= "")
1246 QString url
= SystemInfo::value(SystemInfo::RbutilUrl
).toString();
1247 #if defined(Q_OS_WIN32)
1249 #elif defined(Q_OS_LINUX)
1251 #elif defined(Q_OS_MACX)
1254 url
+= foundVersion
;
1256 QMessageBox::information(this,tr("RockboxUtility Update available"),
1257 tr("<b>New RockboxUtility Version available.</b> <br><br>"
1258 "Download it from here: <a href='%1'>%2</a>")
1259 .arg(url
).arg(foundVersion
));
1260 ui
.statusbar
->showMessage(tr("New version of Rockbox Utility available."));
1263 ui
.statusbar
->showMessage(tr("Rockbox Utility is up to date."), 5000);
1269 void RbUtilQt::changeEvent(QEvent
*e
)
1271 if(e
->type() == QEvent::LanguageChange
) {
1272 ui
.retranslateUi(this);
1274 ServerInfo::readBuildInfo(buildInfo
.fileName());
1278 QMainWindow::changeEvent(e
);