1 /***************************************************************************
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
9 * Copyright (C) 2007 by Dominik Riebeling
12 * All files in this archive are subject to the GNU General Public License.
13 * See the file COPYING in the source tree root for full license agreement.
15 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
16 * KIND, either express or implied.
18 ****************************************************************************/
24 #include "ui_rbutilqtfrm.h"
25 #include "ui_aboutbox.h"
26 #include "configure.h"
28 #include "installtalkwindow.h"
29 #include "createvoicewindow.h"
31 #include "installbootloader.h"
32 #include "installthemes.h"
33 #include "uninstallwindow.h"
40 #if defined(Q_OS_LINUX)
43 #if defined(Q_OS_WIN32)
52 RbUtilQt::RbUtilQt(QWidget
*parent
) : QMainWindow(parent
)
54 absolutePath
= qApp
->applicationDirPath();
58 settings
= new RbSettings();
65 ui
.radioPdf
->setChecked(true);
68 ui
.treeInfo
->setAlternatingRowColors(true);
69 ui
.treeInfo
->setHeaderLabels(QStringList() << tr("File") << tr("Version"));
70 ui
.treeInfo
->expandAll();
71 ui
.treeInfo
->setColumnCount(2);
73 connect(ui
.tabWidget
, SIGNAL(currentChanged(int)), this, SLOT(updateTabs(int)));
74 connect(ui
.actionAbout_Qt
, SIGNAL(triggered()), qApp
, SLOT(aboutQt()));
75 connect(ui
.action_About
, SIGNAL(triggered()), this, SLOT(about()));
76 connect(ui
.action_Help
, SIGNAL(triggered()), this, SLOT(help()));
77 connect(ui
.action_Configure
, SIGNAL(triggered()), this, SLOT(configDialog()));
78 connect(ui
.buttonChangeDevice
, SIGNAL(clicked()), this, SLOT(configDialog()));
79 connect(ui
.buttonRockbox
, SIGNAL(clicked()), this, SLOT(installBtn()));
80 connect(ui
.buttonBootloader
, SIGNAL(clicked()), this, SLOT(installBootloaderBtn()));
81 connect(ui
.buttonFonts
, SIGNAL(clicked()), this, SLOT(installFontsBtn()));
82 connect(ui
.buttonGames
, SIGNAL(clicked()), this, SLOT(installDoomBtn()));
83 connect(ui
.buttonTalk
, SIGNAL(clicked()), this, SLOT(createTalkFiles()));
84 connect(ui
.buttonCreateVoice
, SIGNAL(clicked()), this, SLOT(createVoiceFile()));
85 connect(ui
.buttonVoice
, SIGNAL(clicked()), this, SLOT(installVoice()));
86 connect(ui
.buttonThemes
, SIGNAL(clicked()), this, SLOT(installThemes()));
87 connect(ui
.buttonRemoveRockbox
, SIGNAL(clicked()), this, SLOT(uninstall()));
88 connect(ui
.buttonRemoveBootloader
, SIGNAL(clicked()), this, SLOT(uninstallBootloader()));
89 connect(ui
.buttonDownloadManual
, SIGNAL(clicked()), this, SLOT(downloadManual()));
90 connect(ui
.buttonSmall
, SIGNAL(clicked()), this, SLOT(smallInstall()));
91 connect(ui
.buttonComplete
, SIGNAL(clicked()), this, SLOT(completeInstall()));
93 // actions accessible from the menu
94 connect(ui
.actionComplete_Installation
, SIGNAL(triggered()), this, SLOT(completeInstall()));
95 connect(ui
.actionSmall_Installation
, SIGNAL(triggered()), this, SLOT(smallInstall()));
96 connect(ui
.actionInstall_Bootloader
, SIGNAL(triggered()), this, SLOT(installBootloaderBtn()));
97 connect(ui
.actionInstall_Rockbox
, SIGNAL(triggered()), this, SLOT(installBtn()));
98 connect(ui
.actionFonts_Package
, SIGNAL(triggered()), this, SLOT(installFontsBtn()));
99 connect(ui
.actionInstall_Themes
, SIGNAL(triggered()), this, SLOT(installThemes()));
100 connect(ui
.actionInstall_Game_Files
, SIGNAL(triggered()), this, SLOT(installDoomBtn()));
101 connect(ui
.actionInstall_Voice_File
, SIGNAL(triggered()), this, SLOT(installVoice()));
102 connect(ui
.actionCreate_Voice_File
, SIGNAL(triggered()), this, SLOT(createVoiceFile()));
103 connect(ui
.actionCreate_Talk_Files
, SIGNAL(triggered()), this, SLOT(createTalkFiles()));
104 connect(ui
.actionRemove_bootloader
, SIGNAL(triggered()), this, SLOT(uninstallBootloader()));
105 connect(ui
.actionUninstall_Rockbox
, SIGNAL(triggered()), this, SLOT(uninstall()));
106 connect(ui
.action_System_Info
, SIGNAL(triggered()), this, SLOT(sysinfo()));
109 ui
.actionInstall_Rockbox_Utility_on_player
->setEnabled(false);
111 connect(ui
.actionInstall_Rockbox_Utility_on_player
, SIGNAL(triggered()), this, SLOT(installPortable()));
121 void RbUtilQt::sysinfo(void)
123 Sysinfo
*info
= new Sysinfo(this);
127 void RbUtilQt::updateTabs(int count
)
139 void RbUtilQt::downloadInfo()
141 // try to get the current build information
142 daily
= new HttpGet(this);
143 connect(daily
, SIGNAL(done(bool)), this, SLOT(downloadDone(bool)));
144 connect(daily
, SIGNAL(requestFinished(int, bool)), this, SLOT(downloadDone(int, bool)));
145 connect(qApp
, SIGNAL(lastWindowClosed()), daily
, SLOT(abort()));
146 if(settings
->cacheOffline())
147 daily
->setCache(true);
149 daily
->setCache(false);
150 qDebug() << "downloading build info";
151 daily
->setFile(&buildInfo
);
152 daily
->getFile(QUrl(settings
->serverConfUrl()));
156 void RbUtilQt::downloadDone(bool error
)
159 qDebug() << "network error:" << daily
->error();
162 qDebug() << "network status:" << daily
->error();
165 QSettings
info(buildInfo
.fileName(), QSettings::IniFormat
, this);
167 versmap
.insert("arch_rev", info
.value("dailies/rev").toString());
168 versmap
.insert("arch_date", info
.value("dailies/date").toString());
170 bleeding
= new HttpGet(this);
171 connect(bleeding
, SIGNAL(done(bool)), this, SLOT(downloadBleedingDone(bool)));
172 connect(bleeding
, SIGNAL(requestFinished(int, bool)), this, SLOT(downloadDone(int, bool)));
173 connect(qApp
, SIGNAL(lastWindowClosed()), daily
, SLOT(abort()));
174 if(settings
->cacheOffline())
175 bleeding
->setCache(true);
176 bleeding
->setFile(&bleedingInfo
);
177 bleeding
->getFile(QUrl(settings
->bleedingInfo()));
179 if(chkConfig(false)) {
180 QApplication::processEvents();
181 QMessageBox::critical(this, tr("Configuration error"),
182 tr("Your configuration is invalid. This is most likely due "
183 "to a new installation of Rockbox Utility or a changed device "
184 "path. The configuration dialog will now open to allow you "
185 "correcting the problem."));
191 void RbUtilQt::downloadBleedingDone(bool error
)
193 if(error
) qDebug() << "network error:" << bleeding
->error();
196 QSettings
info(bleedingInfo
.fileName(), QSettings::IniFormat
, this);
197 bleedingInfo
.close();
198 versmap
.insert("bleed_rev", info
.value("bleeding/rev").toString());
199 versmap
.insert("bleed_date", info
.value("bleeding/timestamp").toString());
200 qDebug() << "versmap =" << versmap
;
206 void RbUtilQt::downloadDone(int id
, bool error
)
209 errorString
= tr("Network error: %1. Please check your network and proxy settings.")
210 .arg(daily
->errorString());
212 QMessageBox::about(this, "Network Error", errorString
);
214 qDebug() << "downloadDone:" << id
<< error
;
218 void RbUtilQt::about()
220 QDialog
*window
= new QDialog(this);
222 about
.setupUi(window
);
223 window
->setModal(true);
225 QFile
licence(":/docs/gpl-2.0.html");
226 licence
.open(QIODevice::ReadOnly
);
227 QTextStream
c(&licence
);
228 QString cline
= c
.readAll();
229 about
.browserLicense
->insertHtml(cline
);
230 about
.browserLicense
->moveCursor(QTextCursor::Start
, QTextCursor::MoveAnchor
);
231 QFile
credits(":/docs/CREDITS");
232 credits
.open(QIODevice::ReadOnly
);
233 QTextStream
r(&credits
);
234 QString rline
= r
.readAll();
235 about
.browserCredits
->insertPlainText(rline
);
236 about
.browserCredits
->moveCursor(QTextCursor::Start
, QTextCursor::MoveAnchor
);
237 QString title
= QString("<b>The Rockbox Utility</b><br/>Version %1").arg(VERSION
);
238 about
.labelTitle
->setText(title
);
239 about
.labelHomepage
->setText("<a href='http://www.rockbox.org'>http://www.rockbox.org</a>");
246 void RbUtilQt::help()
248 QUrl
helpurl("http://www.rockbox.org/wiki/RockboxUtility");
249 QDesktopServices::openUrl(helpurl
);
253 void RbUtilQt::configDialog()
255 Config
*cw
= new Config(this);
256 cw
->setSettings(settings
);
257 connect(cw
, SIGNAL(settingsUpdated()), this, SLOT(updateSettings()));
258 connect(cw
, SIGNAL(settingsUpdated()), this, SLOT(downloadInfo()));
263 void RbUtilQt::updateSettings()
265 qDebug() << "updateSettings()";
268 if(settings
->proxyType() == "system") {
269 HttpGet::setGlobalProxy(systemProxy());
271 else if(settings
->proxyType() == "manual") {
272 HttpGet::setGlobalProxy(settings
->proxy());
275 HttpGet::setGlobalProxy(QUrl(""));
277 HttpGet::setGlobalCache(settings
->cachePath());
278 HttpGet::setGlobalDumbCache(settings
->cacheOffline());
282 void RbUtilQt::updateDevice()
284 if(!settings
->curNeedsBootloader() ) {
285 ui
.buttonBootloader
->setEnabled(false);
286 ui
.buttonRemoveBootloader
->setEnabled(false);
287 ui
.labelBootloader
->setEnabled(false);
288 ui
.labelRemoveBootloader
->setEnabled(false);
291 ui
.buttonBootloader
->setEnabled(true);
292 ui
.labelBootloader
->setEnabled(true);
293 if(settings
->curBootloaderMethod() == "fwpatcher") {
294 ui
.labelRemoveBootloader
->setEnabled(false);
295 ui
.buttonRemoveBootloader
->setEnabled(false);
298 ui
.labelRemoveBootloader
->setEnabled(true);
299 ui
.buttonRemoveBootloader
->setEnabled(true);
303 // displayed device info
304 QString mountpoint
= settings
->mountpoint();
305 QString brand
= settings
->curBrand();
306 QString name
= settings
->curName();
307 if(name
.isEmpty()) name
= "<none>";
308 if(mountpoint
.isEmpty()) mountpoint
= "<invalid>";
309 ui
.labelDevice
->setText(tr("<b>%1 %2</b> at <b>%3</b>")
310 .arg(brand
, name
, QDir::toNativeSeparators(mountpoint
)));
314 void RbUtilQt::updateManual()
316 if(settings
->curPlatform() != "")
318 QString manual
= settings
->curManual();
321 manual
= "rockbox-" + settings
->curPlatform();
323 pdfmanual
= settings
->manualUrl() + "/" + manual
+ ".pdf";
325 htmlmanual
= settings
->manualUrl() + "/" + manual
+ "/rockbox-build.html";
326 ui
.labelPdfManual
->setText(tr("<a href='%1'>PDF Manual</a>")
328 ui
.labelHtmlManual
->setText(tr("<a href='%1'>HTML Manual (opens in browser)</a>")
332 ui
.labelPdfManual
->setText(tr("Select a device for a link to the correct manual"));
333 ui
.labelHtmlManual
->setText(tr("<a href='%1'>Manual Overview</a>")
334 .arg("http://www.rockbox.org/manual.shtml"));
339 void RbUtilQt::completeInstall()
341 if(chkConfig(true)) return;
342 if(QMessageBox::question(this, tr("Confirm Installation"),
343 tr("Do you really want to make a complete Installation?"),
344 QMessageBox::Yes
| QMessageBox::No
) != QMessageBox::Yes
) return;
347 logger
= new ProgressLoggerGui(this);
350 if(smallInstallInner())
356 if(!installFontsAuto())
360 // wait for installation finished
362 QApplication::processEvents();
372 if(!installDoomAuto())
376 // wait for installation finished
378 QApplication::processEvents();
385 // it has its own logger window,so close our.
391 void RbUtilQt::smallInstall()
393 if(chkConfig(true)) return;
394 if(QMessageBox::question(this, tr("Confirm Installation"),
395 tr("Do you really want to make a small Installation?"),
396 QMessageBox::Yes
| QMessageBox::No
) != QMessageBox::Yes
) return;
399 logger
= new ProgressLoggerGui(this);
405 bool RbUtilQt::smallInstallInner()
407 QString mountpoint
= settings
->mountpoint();
408 // show dialog with error if mount point is wrong
409 if(!QFileInfo(mountpoint
).isDir()) {
410 logger
->addItem(tr("Mount point is wrong!"),LOGERROR
);
415 if(settings
->curNeedsBootloader())
419 if(!installBootloaderAuto())
423 // wait for boot loader installation finished
425 QApplication::processEvents();
427 if(m_error
) return true;
438 // wait for installation finished
440 QApplication::processEvents();
446 void RbUtilQt::installdone(bool error
)
448 qDebug() << "install done";
453 void RbUtilQt::installBtn()
455 if(chkConfig(true)) return;
459 bool RbUtilQt::installAuto()
461 QString file
= QString("%1%2/rockbox.zip")
462 .arg(settings
->bleedingUrl(), settings
->curPlatform());
465 QSettings
info(buildInfo
.fileName(), QSettings::IniFormat
, this);
468 if(settings
->curReleased()) {
469 // only set the keys if needed -- querying will yield an empty string
471 versmap
.insert("rel_rev", settings
->lastRelease());
472 versmap
.insert("rel_date", ""); // FIXME: provide the release timestamp
475 QString myversion
= "r" + versmap
.value("bleed_rev");
477 // check installed Version and Target
478 QString rbVersion
= installedVersion(settings
->mountpoint());
479 int rbTarget
= installedTargetId(settings
->mountpoint());
480 if(rbTarget
!= -1 && rbTarget
!= settings
->curTargetId())
482 if(QMessageBox::question(this, tr("Target mismatch detected"),
483 tr("Target mismatch detected. \n\n"
484 "Installed target: %1.\n"
485 "New Target: %2.\n\n"
486 "Do you want to continue?").arg(settings
->nameOfTargetId(rbTarget
),settings
->curName()),
487 QMessageBox::Yes
| QMessageBox::No
) == QMessageBox::No
)
489 logger
->addItem(tr("Aborted!"),LOGERROR
);
498 if(QMessageBox::question(this, tr("Installed Rockbox detected"),
499 tr("Rockbox installation detected. Do you want to backup first?"),
500 QMessageBox::Yes
| QMessageBox::No
) == QMessageBox::Yes
)
502 logger
->addItem(tr("Beginning Backup..."),LOGINFO
);
503 QString backupName
= settings
->mountpoint() + "/.backup/rockbox-backup-"+rbVersion
+".zip";
505 //! create dir, if it doesnt exist
506 QFileInfo
backupFile(backupName
);
507 if(!QDir(backupFile
.path()).exists())
510 a
.mkpath(backupFile
.path());
515 connect(&backup
,SIGNAL(zipProgress(int,int)),this,SLOT(updateDataReadProgress(int,int)));
516 if(backup
.createZip(backupName
,settings
->mountpoint() + "/.rockbox") == Zip::Ok
)
518 logger
->addItem(tr("Backup successfull"),LOGOK
);
522 logger
->addItem(tr("Backup failed!"),LOGERROR
);
529 //! install current build
530 ZipInstaller
* installer
= new ZipInstaller(this);
531 installer
->setUrl(file
);
532 installer
->setLogSection("Rockbox (Base)");
533 installer
->setLogVersion(myversion
);
534 if(!settings
->cacheDisabled())
535 installer
->setCache(true);
536 installer
->setMountPoint(settings
->mountpoint());
538 connect(installer
, SIGNAL(done(bool)), this, SLOT(installdone(bool)));
540 installer
->install(logger
);
544 void RbUtilQt::updateDataReadProgress(int read
, int total
)
546 logger
->setProgressMax(total
);
547 logger
->setProgressValue(read
);
548 //qDebug() << "progress:" << read << "/" << total;
552 void RbUtilQt::install()
554 Install
*installWindow
= new Install(settings
,this);
557 QSettings
info(buildInfo
.fileName(), QSettings::IniFormat
, this);
560 if(settings
->curReleased()) {
561 // only set the keys if needed -- querying will yield an empty string
563 versmap
.insert("rel_rev", settings
->lastRelease());
564 versmap
.insert("rel_date", ""); // FIXME: provide the release timestamp
566 installWindow
->setVersionStrings(versmap
);
568 installWindow
->show();
571 bool RbUtilQt::installBootloaderAuto()
577 void RbUtilQt::installBootloaderBtn()
579 if(chkConfig(true)) return;
580 if(QMessageBox::question(this, tr("Confirm Installation"),
581 tr("Do you really want to install the Bootloader?"),
582 QMessageBox::Yes
| QMessageBox::No
) != QMessageBox::Yes
) return;
585 logger
= new ProgressLoggerGui(this);
591 void RbUtilQt::installBootloader()
593 QString platform
= settings
->curPlatform();
596 blinstaller
= new BootloaderInstaller(this);
598 blinstaller
->setMountPoint(settings
->mountpoint());
600 blinstaller
->setDevice(platform
);
601 blinstaller
->setBootloaderMethod(settings
->curBootloaderMethod());
602 blinstaller
->setBootloaderName(settings
->curBootloaderName());
603 blinstaller
->setBootloaderBaseUrl(settings
->bootloaderUrl());
604 blinstaller
->setBootloaderInfoUrl(settings
->bootloaderInfoUrl());
605 if(!blinstaller
->downloadInfo())
607 logger
->addItem(tr("Could not get the bootloader info file!"),LOGERROR
);
613 if(blinstaller
->uptodate())
615 int ret
= QMessageBox::question(this, tr("Bootloader Installation"),
616 tr("The bootloader is already installed and up to date.\n"
617 "Do want to replace the current bootloader?"),
618 QMessageBox::Yes
| QMessageBox::No
, QMessageBox::No
);
619 if(ret
== QMessageBox::No
)
621 logger
->addItem(tr("Bootloader installation skipped!"), LOGINFO
);
628 // if fwpatcher , ask for extra file
630 if(settings
->curBootloaderMethod() == "fwpatcher")
632 BrowseOF
ofbrowser(this);
633 ofbrowser
.setFile(settings
->ofPath());
634 if(ofbrowser
.exec() == QDialog::Accepted
)
636 offirmware
= ofbrowser
.getFile();
637 qDebug() << offirmware
;
638 if(!QFileInfo(offirmware
).exists())
640 logger
->addItem(tr("Original Firmware Path is wrong!"),LOGERROR
);
647 settings
->setOfPath(offirmware
);
653 logger
->addItem(tr("Original Firmware selection Canceled!"),LOGERROR
);
659 blinstaller
->setOrigFirmwarePath(offirmware
);
660 connect(blinstaller
,SIGNAL(done(bool)),this,SLOT(installdone(bool)));
661 blinstaller
->install(logger
);
664 void RbUtilQt::installFontsBtn()
666 if(chkConfig(true)) return;
667 if(QMessageBox::question(this, tr("Confirm Installation"),
668 tr("Do you really want to install the fonts package?"),
669 QMessageBox::Yes
| QMessageBox::No
) != QMessageBox::Yes
) return;
671 logger
= new ProgressLoggerGui(this);
676 bool RbUtilQt::installFontsAuto()
683 void RbUtilQt::installFonts()
685 // create zip installer
686 installer
= new ZipInstaller(this);
688 installer
->setUrl(settings
->fontUrl());
689 installer
->setLogSection("Fonts");
690 installer
->setLogVersion(versmap
.value("arch_date"));
691 installer
->setMountPoint(settings
->mountpoint());
692 if(!settings
->cacheDisabled())
693 installer
->setCache(true);
695 connect(installer
, SIGNAL(done(bool)), this, SLOT(installdone(bool)));
696 installer
->install(logger
);
700 void RbUtilQt::installVoice()
702 if(chkConfig(true)) return;
704 if(m_gotInfo
== false)
706 QMessageBox::warning(this, tr("Warning"),
707 tr("The Application is still downloading Information about new Builds. Please try again shortly."));
711 if(QMessageBox::question(this, tr("Confirm Installation"),
712 tr("Do you really want to install the voice file?"),
713 QMessageBox::Yes
| QMessageBox::No
) != QMessageBox::Yes
) return;
715 logger
= new ProgressLoggerGui(this);
718 // create zip installer
719 installer
= new ZipInstaller(this);
721 QString voiceurl
= settings
->voiceUrl();
723 voiceurl
+= settings
->curVoiceName() + "-" +
724 versmap
.value("arch_date") + "-english.zip";
725 qDebug() << voiceurl
;
727 installer
->setUrl(voiceurl
);
728 installer
->setLogSection("Voice");
729 installer
->setLogVersion(versmap
.value("arch_date"));
730 installer
->setMountPoint(settings
->mountpoint());
731 if(!settings
->cacheDisabled())
732 installer
->setCache(true);
733 installer
->install(logger
);
737 void RbUtilQt::installDoomBtn()
739 if(chkConfig(true)) return;
741 QMessageBox::critical(this, tr("Error"), tr("Your device doesn't have a doom plugin. Aborting."));
745 if(QMessageBox::question(this, tr("Confirm Installation"),
746 tr("Do you really want to install the game addon files?"),
747 QMessageBox::Yes
| QMessageBox::No
) != QMessageBox::Yes
) return;
749 logger
= new ProgressLoggerGui(this);
754 bool RbUtilQt::installDoomAuto()
760 bool RbUtilQt::hasDoom()
762 QFile
doomrock(settings
->mountpoint() +"/.rockbox/rocks/games/doom.rock");
763 return doomrock
.exists();
766 void RbUtilQt::installDoom()
768 // create zip installer
769 installer
= new ZipInstaller(this);
771 installer
->setUrl(settings
->doomUrl());
772 installer
->setLogSection("Game Addons");
773 installer
->setLogVersion(versmap
.value("arch_date"));
774 installer
->setMountPoint(settings
->mountpoint());
775 if(!settings
->cacheDisabled())
776 installer
->setCache(true);
777 connect(installer
, SIGNAL(done(bool)), this, SLOT(installdone(bool)));
778 installer
->install(logger
);
782 void RbUtilQt::installThemes()
784 if(chkConfig(true)) return;
785 ThemesInstallWindow
* tw
= new ThemesInstallWindow(this);
786 tw
->setSettings(settings
);
791 void RbUtilQt::createTalkFiles(void)
793 if(chkConfig(true)) return;
794 InstallTalkWindow
*installWindow
= new InstallTalkWindow(this);
795 installWindow
->setSettings(settings
);
797 connect(installWindow
, SIGNAL(settingsUpdated()), this, SLOT(downloadInfo()));
798 connect(installWindow
, SIGNAL(settingsUpdated()), this, SLOT(updateSettings()));
799 installWindow
->show();
803 void RbUtilQt::createVoiceFile(void)
805 if(chkConfig(true)) return;
806 CreateVoiceWindow
*installWindow
= new CreateVoiceWindow(this);
807 installWindow
->setSettings(settings
);
809 connect(installWindow
, SIGNAL(settingsUpdated()), this, SLOT(downloadInfo()));
810 connect(installWindow
, SIGNAL(settingsUpdated()), this, SLOT(updateSettings()));
811 installWindow
->show();
814 void RbUtilQt::uninstall(void)
816 if(chkConfig(true)) return;
817 UninstallWindow
*uninstallWindow
= new UninstallWindow(this);
818 uninstallWindow
->setSettings(settings
);
819 uninstallWindow
->show();
823 void RbUtilQt::uninstallBootloader(void)
825 if(chkConfig(true)) return;
826 if(QMessageBox::question(this, tr("Confirm Uninstallation"),
827 tr("Do you really want to uninstall the Bootloader?"),
828 QMessageBox::Yes
| QMessageBox::No
) != QMessageBox::Yes
) return;
830 ProgressLoggerGui
* logger
= new ProgressLoggerGui(this);
833 BootloaderInstaller
blinstaller(this);
834 blinstaller
.setMountPoint(settings
->mountpoint());
835 blinstaller
.setDevice(settings
->curPlatform());
836 blinstaller
.setBootloaderMethod(settings
->curBootloaderMethod());
837 blinstaller
.setBootloaderName(settings
->curBootloaderName());
838 blinstaller
.setBootloaderBaseUrl(settings
->bootloaderUrl());
839 blinstaller
.setBootloaderInfoUrl(settings
->bootloaderInfoUrl());
840 if(!blinstaller
.downloadInfo())
842 logger
->addItem(tr("Could not get the bootloader info file!"),LOGERROR
);
847 blinstaller
.uninstall(logger
);
852 void RbUtilQt::downloadManual(void)
854 if(chkConfig(true)) return;
855 if(QMessageBox::question(this, tr("Confirm download"),
856 tr("Do you really want to download the manual? The manual will be saved "
857 "to the root folder of your player."),
858 QMessageBox::Yes
| QMessageBox::No
) != QMessageBox::Yes
)
862 QSettings
info(buildInfo
.fileName(), QSettings::IniFormat
, this);
865 QString manual
= settings
->curManual();
867 QString date
= (info
.value("dailies/date").toString());
872 if(ui
.radioPdf
->isChecked()) {
873 target
= "/" + manual
+ ".pdf";
874 section
= "Manual (PDF)";
877 target
= "/" + manual
+ "-" + date
+ "-html.zip";
878 section
= "Manual (HTML)";
880 manualurl
= settings
->manualUrl() + "/" + target
;
881 qDebug() << "manualurl =" << manualurl
;
883 ProgressLoggerGui
* logger
= new ProgressLoggerGui(this);
885 installer
= new ZipInstaller(this);
886 installer
->setMountPoint(settings
->mountpoint());
887 if(!settings
->cacheDisabled())
888 installer
->setCache(true);
889 installer
->setLogSection(section
);
890 installer
->setLogVersion(date
);
891 installer
->setUrl(manualurl
);
892 installer
->setUnzip(false);
893 installer
->setTarget(target
);
894 installer
->install(logger
);
898 void RbUtilQt::installPortable(void)
900 if(QMessageBox::question(this, tr("Confirm installation"),
901 tr("Do you really want to install Rockbox Utility to your player? "
902 "After installation you can run it from the players hard drive."),
903 QMessageBox::Yes
| QMessageBox::No
) != QMessageBox::Yes
)
906 ProgressLoggerGui
* logger
= new ProgressLoggerGui(this);
907 logger
->setProgressMax(0);
908 logger
->setProgressValue(0);
910 logger
->addItem(tr("Installing Rockbox Utility"), LOGINFO
);
913 if(!QFileInfo(settings
->mountpoint()).isDir()) {
914 logger
->addItem(tr("Mount point is wrong!"),LOGERROR
);
919 // remove old files first.
920 QFile::remove(settings
->mountpoint() + "/RockboxUtility.exe");
921 QFile::remove(settings
->mountpoint() + "/RockboxUtility.ini");
922 // copy currently running binary and currently used settings file
923 if(!QFile::copy(qApp
->applicationFilePath(), settings
->mountpoint() + "/RockboxUtility.exe")) {
924 logger
->addItem(tr("Error installing Rockbox Utility"), LOGERROR
);
928 logger
->addItem(tr("Installing user configuration"), LOGINFO
);
929 if(!QFile::copy(settings
->userSettingFilename(), settings
->mountpoint() + "/RockboxUtility.ini")) {
930 logger
->addItem(tr("Error installing user configuration"), LOGERROR
);
934 logger
->addItem(tr("Successfully installed Rockbox Utility."), LOGOK
);
936 logger
->setProgressMax(1);
937 logger
->setProgressValue(1);
942 void RbUtilQt::updateInfo()
944 qDebug() << "RbUtilQt::updateInfo()";
946 QSettings
log(settings
->mountpoint() + "/.rockbox/rbutil.log", QSettings::IniFormat
, this);
947 QStringList groups
= log
.childGroups();
948 QList
<QTreeWidgetItem
*> items
;
949 QTreeWidgetItem
*w
, *w2
;
953 // remove old list entries (if any)
954 int l
= ui
.treeInfo
->topLevelItemCount();
957 m
= ui
.treeInfo
->takeTopLevelItem(l
);
958 // delete childs (single level deep, no recursion here)
959 int n
= m
->childCount();
963 // get and populate new items
964 for(int a
= 0; a
< groups
.size(); a
++) {
965 log
.beginGroup(groups
.at(a
));
966 QStringList keys
= log
.allKeys();
967 w
= new QTreeWidgetItem
;
968 w
->setFlags(Qt::ItemIsEnabled
);
969 w
->setText(0, groups
.at(a
));
971 // get minimum and maximum version information so we can hilight old files
972 min
= max
= log
.value(keys
.at(0)).toString();
973 for(int b
= 0; b
< keys
.size(); b
++) {
974 if(log
.value(keys
.at(b
)).toString() > max
)
975 max
= log
.value(keys
.at(b
)).toString();
976 if(log
.value(keys
.at(b
)).toString() < min
)
977 min
= log
.value(keys
.at(b
)).toString();
980 for(int b
= 0; b
< keys
.size(); b
++) {
982 file
= settings
->mountpoint() + "/" + keys
.at(b
);
983 if(QFileInfo(file
).isDir())
985 w2
= new QTreeWidgetItem(w
, QStringList() << "/"
986 + keys
.at(b
) << log
.value(keys
.at(b
)).toString());
987 if(log
.value(keys
.at(b
)).toString() != max
) {
988 w2
->setForeground(0, QBrush(QColor(255, 0, 0)));
989 w2
->setForeground(1, QBrush(QColor(255, 0, 0)));
996 w
->setData(1, Qt::DisplayRole
, QString("%1 / %2").arg(min
, max
));
998 w
->setData(1, Qt::DisplayRole
, max
);
1000 ui
.treeInfo
->insertTopLevelItems(0, items
);
1001 ui
.treeInfo
->resizeColumnToContents(0);
1005 QUrl
RbUtilQt::proxy()
1007 if(settings
->proxyType() == "manual")
1008 return QUrl(settings
->proxy());
1009 else if(settings
->proxy() == "system")
1011 return systemProxy();
1017 bool RbUtilQt::chkConfig(bool warn
)
1020 if(settings
->curPlatform().isEmpty()
1021 || settings
->mountpoint().isEmpty()
1022 || !QFileInfo(settings
->mountpoint()).isWritable()) {
1025 if(warn
) QMessageBox::critical(this, tr("Configuration error"),
1026 tr("Your configuration is invalid. Please go to the configuration "
1027 "dialog and make sure the selected values are correct."));