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(Detect::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
= Detect::installedVersion(settings
->mountpoint());
480 if(Detect::check(settings
,false,settings
->curTargetId()) == false)
482 logger
->addItem(tr("Aborted!"),LOGERROR
);
490 if(QMessageBox::question(this, tr("Installed Rockbox detected"),
491 tr("Rockbox installation detected. Do you want to backup first?"),
492 QMessageBox::Yes
| QMessageBox::No
) == QMessageBox::Yes
)
494 logger
->addItem(tr("Starting backup..."),LOGINFO
);
495 QString backupName
= settings
->mountpoint() + "/.backup/rockbox-backup-"+rbVersion
+".zip";
497 //! create dir, if it doesnt exist
498 QFileInfo
backupFile(backupName
);
499 if(!QDir(backupFile
.path()).exists())
502 a
.mkpath(backupFile
.path());
507 connect(&backup
,SIGNAL(zipProgress(int,int)),logger
, SLOT(setProgress(int,int)));
508 if(backup
.createZip(backupName
,settings
->mountpoint() + "/.rockbox") == Zip::Ok
)
510 logger
->addItem(tr("Backup successfull"),LOGOK
);
514 logger
->addItem(tr("Backup failed!"),LOGERROR
);
521 //! install current build
522 ZipInstaller
* installer
= new ZipInstaller(this);
523 installer
->setUrl(file
);
524 installer
->setLogSection("Rockbox (Base)");
525 installer
->setLogVersion(myversion
);
526 if(!settings
->cacheDisabled())
527 installer
->setCache(true);
528 installer
->setMountPoint(settings
->mountpoint());
530 connect(installer
, SIGNAL(done(bool)), this, SLOT(installdone(bool)));
532 installer
->install(logger
);
537 void RbUtilQt::install()
539 Install
*installWindow
= new Install(settings
,this);
542 QSettings
info(buildInfo
.fileName(), QSettings::IniFormat
, this);
545 if(settings
->curReleased()) {
546 // only set the keys if needed -- querying will yield an empty string
548 versmap
.insert("rel_rev", settings
->lastRelease());
549 versmap
.insert("rel_date", ""); // FIXME: provide the release timestamp
551 installWindow
->setVersionStrings(versmap
);
553 installWindow
->show();
556 bool RbUtilQt::installBootloaderAuto()
562 void RbUtilQt::installBootloaderBtn()
564 if(chkConfig(true)) return;
565 if(QMessageBox::question(this, tr("Confirm Installation"),
566 tr("Do you really want to install the Bootloader?"),
567 QMessageBox::Yes
| QMessageBox::No
) != QMessageBox::Yes
) return;
570 logger
= new ProgressLoggerGui(this);
576 void RbUtilQt::installBootloader()
578 QString platform
= settings
->curPlatform();
581 blinstaller
= new BootloaderInstaller(this);
583 blinstaller
->setMountPoint(settings
->mountpoint());
585 blinstaller
->setDevice(platform
);
586 blinstaller
->setBootloaderMethod(settings
->curBootloaderMethod());
587 blinstaller
->setBootloaderName(settings
->curBootloaderName());
588 blinstaller
->setBootloaderBaseUrl(settings
->bootloaderUrl());
589 blinstaller
->setBootloaderInfoUrl(settings
->bootloaderInfoUrl());
590 if(!blinstaller
->downloadInfo())
592 logger
->addItem(tr("Could not get the bootloader info file!"),LOGERROR
);
598 if(blinstaller
->uptodate())
600 int ret
= QMessageBox::question(this, tr("Bootloader Installation"),
601 tr("The bootloader is already installed and up to date.\n"
602 "Do want to replace the current bootloader?"),
603 QMessageBox::Yes
| QMessageBox::No
, QMessageBox::No
);
604 if(ret
== QMessageBox::No
)
606 logger
->addItem(tr("Bootloader installation skipped!"), LOGINFO
);
613 // if fwpatcher , ask for extra file
615 if(settings
->curBootloaderMethod() == "fwpatcher")
617 BrowseOF
ofbrowser(this);
618 ofbrowser
.setFile(settings
->ofPath());
619 if(ofbrowser
.exec() == QDialog::Accepted
)
621 offirmware
= ofbrowser
.getFile();
622 qDebug() << offirmware
;
623 if(!QFileInfo(offirmware
).exists())
625 logger
->addItem(tr("Original Firmware Path is wrong!"),LOGERROR
);
632 settings
->setOfPath(offirmware
);
638 logger
->addItem(tr("Original Firmware selection Canceled!"),LOGERROR
);
644 blinstaller
->setOrigFirmwarePath(offirmware
);
645 connect(blinstaller
,SIGNAL(done(bool)),this,SLOT(installdone(bool)));
646 blinstaller
->install(logger
);
649 void RbUtilQt::installFontsBtn()
651 if(chkConfig(true)) return;
652 if(QMessageBox::question(this, tr("Confirm Installation"),
653 tr("Do you really want to install the fonts package?"),
654 QMessageBox::Yes
| QMessageBox::No
) != QMessageBox::Yes
) return;
656 logger
= new ProgressLoggerGui(this);
661 bool RbUtilQt::installFontsAuto()
668 void RbUtilQt::installFonts()
670 // create zip installer
671 installer
= new ZipInstaller(this);
673 installer
->setUrl(settings
->fontUrl());
674 installer
->setLogSection("Fonts");
675 installer
->setLogVersion(versmap
.value("arch_date"));
676 installer
->setMountPoint(settings
->mountpoint());
677 if(!settings
->cacheDisabled())
678 installer
->setCache(true);
680 connect(installer
, SIGNAL(done(bool)), this, SLOT(installdone(bool)));
681 installer
->install(logger
);
685 void RbUtilQt::installVoice()
687 if(chkConfig(true)) return;
689 if(m_gotInfo
== false)
691 QMessageBox::warning(this, tr("Warning"),
692 tr("The Application is still downloading Information about new Builds. Please try again shortly."));
696 if(QMessageBox::question(this, tr("Confirm Installation"),
697 tr("Do you really want to install the voice file?"),
698 QMessageBox::Yes
| QMessageBox::No
) != QMessageBox::Yes
) return;
700 logger
= new ProgressLoggerGui(this);
703 // create zip installer
704 installer
= new ZipInstaller(this);
706 QString voiceurl
= settings
->voiceUrl();
708 voiceurl
+= settings
->curVoiceName() + "-" +
709 versmap
.value("arch_date") + "-english.zip";
710 qDebug() << voiceurl
;
712 installer
->setUrl(voiceurl
);
713 installer
->setLogSection("Voice");
714 installer
->setLogVersion(versmap
.value("arch_date"));
715 installer
->setMountPoint(settings
->mountpoint());
716 if(!settings
->cacheDisabled())
717 installer
->setCache(true);
718 installer
->install(logger
);
722 void RbUtilQt::installDoomBtn()
724 if(chkConfig(true)) return;
726 QMessageBox::critical(this, tr("Error"), tr("Your device doesn't have a doom plugin. Aborting."));
730 if(QMessageBox::question(this, tr("Confirm Installation"),
731 tr("Do you really want to install the game addon files?"),
732 QMessageBox::Yes
| QMessageBox::No
) != QMessageBox::Yes
) return;
734 logger
= new ProgressLoggerGui(this);
739 bool RbUtilQt::installDoomAuto()
745 bool RbUtilQt::hasDoom()
747 QFile
doomrock(settings
->mountpoint() +"/.rockbox/rocks/games/doom.rock");
748 return doomrock
.exists();
751 void RbUtilQt::installDoom()
753 // create zip installer
754 installer
= new ZipInstaller(this);
756 installer
->setUrl(settings
->doomUrl());
757 installer
->setLogSection("Game Addons");
758 installer
->setLogVersion(versmap
.value("arch_date"));
759 installer
->setMountPoint(settings
->mountpoint());
760 if(!settings
->cacheDisabled())
761 installer
->setCache(true);
762 connect(installer
, SIGNAL(done(bool)), this, SLOT(installdone(bool)));
763 installer
->install(logger
);
767 void RbUtilQt::installThemes()
769 if(chkConfig(true)) return;
770 ThemesInstallWindow
* tw
= new ThemesInstallWindow(this);
771 tw
->setSettings(settings
);
776 void RbUtilQt::createTalkFiles(void)
778 if(chkConfig(true)) return;
779 InstallTalkWindow
*installWindow
= new InstallTalkWindow(this);
780 installWindow
->setSettings(settings
);
782 connect(installWindow
, SIGNAL(settingsUpdated()), this, SLOT(downloadInfo()));
783 connect(installWindow
, SIGNAL(settingsUpdated()), this, SLOT(updateSettings()));
784 installWindow
->show();
788 void RbUtilQt::createVoiceFile(void)
790 if(chkConfig(true)) return;
791 CreateVoiceWindow
*installWindow
= new CreateVoiceWindow(this);
792 installWindow
->setSettings(settings
);
794 connect(installWindow
, SIGNAL(settingsUpdated()), this, SLOT(downloadInfo()));
795 connect(installWindow
, SIGNAL(settingsUpdated()), this, SLOT(updateSettings()));
796 installWindow
->show();
799 void RbUtilQt::uninstall(void)
801 if(chkConfig(true)) return;
802 UninstallWindow
*uninstallWindow
= new UninstallWindow(this);
803 uninstallWindow
->setSettings(settings
);
804 uninstallWindow
->show();
808 void RbUtilQt::uninstallBootloader(void)
810 if(chkConfig(true)) return;
811 if(QMessageBox::question(this, tr("Confirm Uninstallation"),
812 tr("Do you really want to uninstall the Bootloader?"),
813 QMessageBox::Yes
| QMessageBox::No
) != QMessageBox::Yes
) return;
815 ProgressLoggerGui
* logger
= new ProgressLoggerGui(this);
818 BootloaderInstaller
blinstaller(this);
819 blinstaller
.setMountPoint(settings
->mountpoint());
820 blinstaller
.setDevice(settings
->curPlatform());
821 blinstaller
.setBootloaderMethod(settings
->curBootloaderMethod());
822 blinstaller
.setBootloaderName(settings
->curBootloaderName());
823 blinstaller
.setBootloaderBaseUrl(settings
->bootloaderUrl());
824 blinstaller
.setBootloaderInfoUrl(settings
->bootloaderInfoUrl());
825 if(!blinstaller
.downloadInfo())
827 logger
->addItem(tr("Could not get the bootloader info file!"),LOGERROR
);
832 blinstaller
.uninstall(logger
);
837 void RbUtilQt::downloadManual(void)
839 if(chkConfig(true)) return;
840 if(QMessageBox::question(this, tr("Confirm download"),
841 tr("Do you really want to download the manual? The manual will be saved "
842 "to the root folder of your player."),
843 QMessageBox::Yes
| QMessageBox::No
) != QMessageBox::Yes
)
847 QSettings
info(buildInfo
.fileName(), QSettings::IniFormat
, this);
850 QString manual
= settings
->curManual();
852 QString date
= (info
.value("dailies/date").toString());
857 if(ui
.radioPdf
->isChecked()) {
858 target
= "/" + manual
+ ".pdf";
859 section
= "Manual (PDF)";
862 target
= "/" + manual
+ "-" + date
+ "-html.zip";
863 section
= "Manual (HTML)";
865 manualurl
= settings
->manualUrl() + "/" + target
;
866 qDebug() << "manualurl =" << manualurl
;
868 ProgressLoggerGui
* logger
= new ProgressLoggerGui(this);
870 installer
= new ZipInstaller(this);
871 installer
->setMountPoint(settings
->mountpoint());
872 if(!settings
->cacheDisabled())
873 installer
->setCache(true);
874 installer
->setLogSection(section
);
875 installer
->setLogVersion(date
);
876 installer
->setUrl(manualurl
);
877 installer
->setUnzip(false);
878 installer
->setTarget(target
);
879 installer
->install(logger
);
883 void RbUtilQt::installPortable(void)
885 if(QMessageBox::question(this, tr("Confirm installation"),
886 tr("Do you really want to install Rockbox Utility to your player? "
887 "After installation you can run it from the players hard drive."),
888 QMessageBox::Yes
| QMessageBox::No
) != QMessageBox::Yes
)
891 ProgressLoggerGui
* logger
= new ProgressLoggerGui(this);
892 logger
->setProgressMax(0);
893 logger
->setProgressValue(0);
895 logger
->addItem(tr("Installing Rockbox Utility"), LOGINFO
);
898 if(!QFileInfo(settings
->mountpoint()).isDir()) {
899 logger
->addItem(tr("Mount point is wrong!"),LOGERROR
);
904 // remove old files first.
905 QFile::remove(settings
->mountpoint() + "/RockboxUtility.exe");
906 QFile::remove(settings
->mountpoint() + "/RockboxUtility.ini");
907 // copy currently running binary and currently used settings file
908 if(!QFile::copy(qApp
->applicationFilePath(), settings
->mountpoint() + "/RockboxUtility.exe")) {
909 logger
->addItem(tr("Error installing Rockbox Utility"), LOGERROR
);
913 logger
->addItem(tr("Installing user configuration"), LOGINFO
);
914 if(!QFile::copy(settings
->userSettingFilename(), settings
->mountpoint() + "/RockboxUtility.ini")) {
915 logger
->addItem(tr("Error installing user configuration"), LOGERROR
);
919 logger
->addItem(tr("Successfully installed Rockbox Utility."), LOGOK
);
921 logger
->setProgressMax(1);
922 logger
->setProgressValue(1);
927 void RbUtilQt::updateInfo()
929 qDebug() << "RbUtilQt::updateInfo()";
931 QSettings
log(settings
->mountpoint() + "/.rockbox/rbutil.log", QSettings::IniFormat
, this);
932 QStringList groups
= log
.childGroups();
933 QList
<QTreeWidgetItem
*> items
;
934 QTreeWidgetItem
*w
, *w2
;
938 // remove old list entries (if any)
939 int l
= ui
.treeInfo
->topLevelItemCount();
942 m
= ui
.treeInfo
->takeTopLevelItem(l
);
943 // delete childs (single level deep, no recursion here)
944 int n
= m
->childCount();
948 // get and populate new items
949 for(int a
= 0; a
< groups
.size(); a
++) {
950 log
.beginGroup(groups
.at(a
));
951 QStringList keys
= log
.allKeys();
952 w
= new QTreeWidgetItem
;
953 w
->setFlags(Qt::ItemIsEnabled
);
954 w
->setText(0, groups
.at(a
));
956 // get minimum and maximum version information so we can hilight old files
957 min
= max
= log
.value(keys
.at(0)).toString();
958 for(int b
= 0; b
< keys
.size(); b
++) {
959 if(log
.value(keys
.at(b
)).toString() > max
)
960 max
= log
.value(keys
.at(b
)).toString();
961 if(log
.value(keys
.at(b
)).toString() < min
)
962 min
= log
.value(keys
.at(b
)).toString();
965 for(int b
= 0; b
< keys
.size(); b
++) {
967 file
= settings
->mountpoint() + "/" + keys
.at(b
);
968 if(QFileInfo(file
).isDir())
970 w2
= new QTreeWidgetItem(w
, QStringList() << "/"
971 + keys
.at(b
) << log
.value(keys
.at(b
)).toString());
972 if(log
.value(keys
.at(b
)).toString() != max
) {
973 w2
->setForeground(0, QBrush(QColor(255, 0, 0)));
974 w2
->setForeground(1, QBrush(QColor(255, 0, 0)));
981 w
->setData(1, Qt::DisplayRole
, QString("%1 / %2").arg(min
, max
));
983 w
->setData(1, Qt::DisplayRole
, max
);
985 ui
.treeInfo
->insertTopLevelItems(0, items
);
986 ui
.treeInfo
->resizeColumnToContents(0);
990 QUrl
RbUtilQt::proxy()
992 if(settings
->proxyType() == "manual")
993 return QUrl(settings
->proxy());
994 else if(settings
->proxy() == "system")
996 return Detect::systemProxy();
1002 bool RbUtilQt::chkConfig(bool warn
)
1005 if(settings
->curPlatform().isEmpty()
1006 || settings
->mountpoint().isEmpty()
1007 || !QFileInfo(settings
->mountpoint()).isWritable()) {
1010 if(warn
) QMessageBox::critical(this, tr("Configuration error"),
1011 tr("Your configuration is invalid. Please go to the configuration "
1012 "dialog and make sure the selected values are correct."));