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(settings
->curVersion() != PUREVERSION
) {
180 QApplication::processEvents();
181 QMessageBox::information(this, tr("New installation"),
182 tr("This is a new installation of Rockbox Utility, or a new version. "
183 "The configuration dialog will now open to allow you to setup the program, "
184 " or review your settings."));
187 else if(chkConfig(false)) {
188 QApplication::processEvents();
189 QMessageBox::critical(this, tr("Configuration error"),
190 tr("Your configuration is invalid. This is most likely due "
191 "to a changed device path. The configuration dialog will "
192 "now open to allow you to correct the problem."));
198 void RbUtilQt::downloadBleedingDone(bool error
)
200 if(error
) qDebug() << "network error:" << bleeding
->error();
203 QSettings
info(bleedingInfo
.fileName(), QSettings::IniFormat
, this);
204 bleedingInfo
.close();
205 versmap
.insert("bleed_rev", info
.value("bleeding/rev").toString());
206 versmap
.insert("bleed_date", info
.value("bleeding/timestamp").toString());
207 qDebug() << "versmap =" << versmap
;
213 void RbUtilQt::downloadDone(int id
, bool error
)
216 errorString
= tr("Network error: %1. Please check your network and proxy settings.")
217 .arg(daily
->errorString());
219 QMessageBox::about(this, "Network Error", errorString
);
221 qDebug() << "downloadDone:" << id
<< error
;
225 void RbUtilQt::about()
227 QDialog
*window
= new QDialog(this);
229 about
.setupUi(window
);
230 window
->setModal(true);
232 QFile
licence(":/docs/gpl-2.0.html");
233 licence
.open(QIODevice::ReadOnly
);
234 QTextStream
c(&licence
);
235 QString cline
= c
.readAll();
236 about
.browserLicense
->insertHtml(cline
);
237 about
.browserLicense
->moveCursor(QTextCursor::Start
, QTextCursor::MoveAnchor
);
238 QFile
credits(":/docs/CREDITS");
239 credits
.open(QIODevice::ReadOnly
);
240 QTextStream
r(&credits
);
241 QString rline
= r
.readAll();
242 about
.browserCredits
->insertPlainText(rline
);
243 about
.browserCredits
->moveCursor(QTextCursor::Start
, QTextCursor::MoveAnchor
);
244 QString title
= QString("<b>The Rockbox Utility</b><br/>Version %1").arg(VERSION
);
245 about
.labelTitle
->setText(title
);
246 about
.labelHomepage
->setText("<a href='http://www.rockbox.org'>http://www.rockbox.org</a>");
253 void RbUtilQt::help()
255 QUrl
helpurl("http://www.rockbox.org/wiki/RockboxUtility");
256 QDesktopServices::openUrl(helpurl
);
260 void RbUtilQt::configDialog()
262 Config
*cw
= new Config(this);
263 cw
->setSettings(settings
);
264 connect(cw
, SIGNAL(settingsUpdated()), this, SLOT(updateSettings()));
265 connect(cw
, SIGNAL(settingsUpdated()), this, SLOT(downloadInfo()));
270 void RbUtilQt::updateSettings()
272 qDebug() << "updateSettings()";
275 if(settings
->proxyType() == "system") {
276 HttpGet::setGlobalProxy(Detect::systemProxy());
278 else if(settings
->proxyType() == "manual") {
279 HttpGet::setGlobalProxy(settings
->proxy());
282 HttpGet::setGlobalProxy(QUrl(""));
284 HttpGet::setGlobalCache(settings
->cachePath());
285 HttpGet::setGlobalDumbCache(settings
->cacheOffline());
289 void RbUtilQt::updateDevice()
291 if(!settings
->curNeedsBootloader() ) {
292 ui
.buttonBootloader
->setEnabled(false);
293 ui
.buttonRemoveBootloader
->setEnabled(false);
294 ui
.labelBootloader
->setEnabled(false);
295 ui
.labelRemoveBootloader
->setEnabled(false);
298 ui
.buttonBootloader
->setEnabled(true);
299 ui
.labelBootloader
->setEnabled(true);
300 if(settings
->curBootloaderMethod() == "fwpatcher") {
301 ui
.labelRemoveBootloader
->setEnabled(false);
302 ui
.buttonRemoveBootloader
->setEnabled(false);
305 ui
.labelRemoveBootloader
->setEnabled(true);
306 ui
.buttonRemoveBootloader
->setEnabled(true);
310 // displayed device info
311 QString mountpoint
= settings
->mountpoint();
312 QString brand
= settings
->curBrand();
313 QString name
= settings
->curName();
314 if(name
.isEmpty()) name
= "<none>";
315 if(mountpoint
.isEmpty()) mountpoint
= "<invalid>";
316 ui
.labelDevice
->setText(tr("<b>%1 %2</b> at <b>%3</b>")
317 .arg(brand
, name
, QDir::toNativeSeparators(mountpoint
)));
321 void RbUtilQt::updateManual()
323 if(settings
->curPlatform() != "")
325 QString manual
= settings
->curManual();
328 manual
= "rockbox-" + settings
->curPlatform();
330 pdfmanual
= settings
->manualUrl() + "/" + manual
+ ".pdf";
332 htmlmanual
= settings
->manualUrl() + "/" + manual
+ "/rockbox-build.html";
333 ui
.labelPdfManual
->setText(tr("<a href='%1'>PDF Manual</a>")
335 ui
.labelHtmlManual
->setText(tr("<a href='%1'>HTML Manual (opens in browser)</a>")
339 ui
.labelPdfManual
->setText(tr("Select a device for a link to the correct manual"));
340 ui
.labelHtmlManual
->setText(tr("<a href='%1'>Manual Overview</a>")
341 .arg("http://www.rockbox.org/manual.shtml"));
346 void RbUtilQt::completeInstall()
348 if(chkConfig(true)) return;
349 if(QMessageBox::question(this, tr("Confirm Installation"),
350 tr("Do you really want to make a complete Installation?"),
351 QMessageBox::Yes
| QMessageBox::No
) != QMessageBox::Yes
) return;
354 logger
= new ProgressLoggerGui(this);
357 if(smallInstallInner())
363 if(!installFontsAuto())
367 // wait for installation finished
369 QApplication::processEvents();
379 if(!installDoomAuto())
383 // wait for installation finished
385 QApplication::processEvents();
392 // it has its own logger window,so close our.
398 void RbUtilQt::smallInstall()
400 if(chkConfig(true)) return;
401 if(QMessageBox::question(this, tr("Confirm Installation"),
402 tr("Do you really want to make a small Installation?"),
403 QMessageBox::Yes
| QMessageBox::No
) != QMessageBox::Yes
) return;
406 logger
= new ProgressLoggerGui(this);
412 bool RbUtilQt::smallInstallInner()
414 QString mountpoint
= settings
->mountpoint();
415 // show dialog with error if mount point is wrong
416 if(!QFileInfo(mountpoint
).isDir()) {
417 logger
->addItem(tr("Mount point is wrong!"),LOGERROR
);
422 if(settings
->curNeedsBootloader())
426 if(!installBootloaderAuto())
430 // wait for boot loader installation finished
432 QApplication::processEvents();
434 if(m_error
) return true;
445 // wait for installation finished
447 QApplication::processEvents();
453 void RbUtilQt::installdone(bool error
)
455 qDebug() << "install done";
460 void RbUtilQt::installBtn()
462 if(chkConfig(true)) return;
466 bool RbUtilQt::installAuto()
468 QString file
= QString("%1%2/rockbox.zip")
469 .arg(settings
->bleedingUrl(), settings
->curPlatform());
472 QSettings
info(buildInfo
.fileName(), QSettings::IniFormat
, this);
475 if(settings
->curReleased()) {
476 // only set the keys if needed -- querying will yield an empty string
478 versmap
.insert("rel_rev", settings
->lastRelease());
479 versmap
.insert("rel_date", ""); // FIXME: provide the release timestamp
482 QString myversion
= "r" + versmap
.value("bleed_rev");
484 // check installed Version and Target
485 QString rbVersion
= Detect::installedVersion(settings
->mountpoint());
487 if(Detect::check(settings
,false,settings
->curTargetId()) == false)
489 logger
->addItem(tr("Aborted!"),LOGERROR
);
497 if(QMessageBox::question(this, tr("Installed Rockbox detected"),
498 tr("Rockbox installation detected. Do you want to backup first?"),
499 QMessageBox::Yes
| QMessageBox::No
) == QMessageBox::Yes
)
501 logger
->addItem(tr("Starting backup..."),LOGINFO
);
502 QString backupName
= settings
->mountpoint() + "/.backup/rockbox-backup-"+rbVersion
+".zip";
504 //! create dir, if it doesnt exist
505 QFileInfo
backupFile(backupName
);
506 if(!QDir(backupFile
.path()).exists())
509 a
.mkpath(backupFile
.path());
514 connect(&backup
,SIGNAL(zipProgress(int,int)),logger
, SLOT(setProgress(int,int)));
515 if(backup
.createZip(backupName
,settings
->mountpoint() + "/.rockbox") == Zip::Ok
)
517 logger
->addItem(tr("Backup successful"),LOGOK
);
521 logger
->addItem(tr("Backup failed!"),LOGERROR
);
528 //! install current build
529 ZipInstaller
* installer
= new ZipInstaller(this);
530 installer
->setUrl(file
);
531 installer
->setLogSection("Rockbox (Base)");
532 installer
->setLogVersion(myversion
);
533 if(!settings
->cacheDisabled())
534 installer
->setCache(true);
535 installer
->setMountPoint(settings
->mountpoint());
537 connect(installer
, SIGNAL(done(bool)), this, SLOT(installdone(bool)));
539 installer
->install(logger
);
544 void RbUtilQt::install()
546 Install
*installWindow
= new Install(settings
,this);
549 QSettings
info(buildInfo
.fileName(), QSettings::IniFormat
, this);
552 if(settings
->curReleased()) {
553 // only set the keys if needed -- querying will yield an empty string
555 versmap
.insert("rel_rev", settings
->lastRelease());
556 versmap
.insert("rel_date", ""); // FIXME: provide the release timestamp
558 installWindow
->setVersionStrings(versmap
);
560 installWindow
->show();
563 bool RbUtilQt::installBootloaderAuto()
569 void RbUtilQt::installBootloaderBtn()
571 if(chkConfig(true)) return;
572 if(QMessageBox::question(this, tr("Confirm Installation"),
573 tr("Do you really want to install the Bootloader?"),
574 QMessageBox::Yes
| QMessageBox::No
) != QMessageBox::Yes
) return;
577 logger
= new ProgressLoggerGui(this);
583 void RbUtilQt::installBootloader()
585 QString platform
= settings
->curPlatform();
588 blinstaller
= new BootloaderInstaller(this);
590 blinstaller
->setMountPoint(settings
->mountpoint());
592 blinstaller
->setDevice(platform
);
593 blinstaller
->setBootloaderMethod(settings
->curBootloaderMethod());
594 blinstaller
->setBootloaderName(settings
->curBootloaderName());
595 blinstaller
->setBootloaderBaseUrl(settings
->bootloaderUrl());
596 blinstaller
->setBootloaderInfoUrl(settings
->bootloaderInfoUrl());
597 if(!blinstaller
->downloadInfo())
599 logger
->addItem(tr("Could not get the bootloader info file!"),LOGERROR
);
605 if(blinstaller
->uptodate())
607 int ret
= QMessageBox::question(this, tr("Bootloader Installation"),
608 tr("The bootloader is already installed and up to date.\n"
609 "Do want to replace the current bootloader?"),
610 QMessageBox::Yes
| QMessageBox::No
, QMessageBox::No
);
611 if(ret
== QMessageBox::No
)
613 logger
->addItem(tr("Bootloader installation skipped!"), LOGINFO
);
620 // if fwpatcher , ask for extra file
622 if(settings
->curBootloaderMethod() == "fwpatcher")
624 BrowseOF
ofbrowser(this);
625 ofbrowser
.setFile(settings
->ofPath());
626 if(ofbrowser
.exec() == QDialog::Accepted
)
628 offirmware
= ofbrowser
.getFile();
629 qDebug() << offirmware
;
630 if(!QFileInfo(offirmware
).exists())
632 logger
->addItem(tr("Original Firmware Path is wrong!"),LOGERROR
);
639 settings
->setOfPath(offirmware
);
645 logger
->addItem(tr("Original Firmware selection Canceled!"),LOGERROR
);
651 blinstaller
->setOrigFirmwarePath(offirmware
);
652 connect(blinstaller
,SIGNAL(done(bool)),this,SLOT(installdone(bool)));
653 blinstaller
->install(logger
);
656 void RbUtilQt::installFontsBtn()
658 if(chkConfig(true)) return;
659 if(QMessageBox::question(this, tr("Confirm Installation"),
660 tr("Do you really want to install the fonts package?"),
661 QMessageBox::Yes
| QMessageBox::No
) != QMessageBox::Yes
) return;
663 logger
= new ProgressLoggerGui(this);
668 bool RbUtilQt::installFontsAuto()
675 void RbUtilQt::installFonts()
677 // create zip installer
678 installer
= new ZipInstaller(this);
680 installer
->setUrl(settings
->fontUrl());
681 installer
->setLogSection("Fonts");
682 installer
->setLogVersion(versmap
.value("arch_date"));
683 installer
->setMountPoint(settings
->mountpoint());
684 if(!settings
->cacheDisabled())
685 installer
->setCache(true);
687 connect(installer
, SIGNAL(done(bool)), this, SLOT(installdone(bool)));
688 installer
->install(logger
);
692 void RbUtilQt::installVoice()
694 if(chkConfig(true)) return;
696 if(m_gotInfo
== false)
698 QMessageBox::warning(this, tr("Warning"),
699 tr("The Application is still downloading Information about new Builds. Please try again shortly."));
703 if(QMessageBox::question(this, tr("Confirm Installation"),
704 tr("Do you really want to install the voice file?"),
705 QMessageBox::Yes
| QMessageBox::No
) != QMessageBox::Yes
) return;
707 logger
= new ProgressLoggerGui(this);
710 // create zip installer
711 installer
= new ZipInstaller(this);
713 QString voiceurl
= settings
->voiceUrl();
715 voiceurl
+= settings
->curVoiceName() + "-" +
716 versmap
.value("arch_date") + "-english.zip";
717 qDebug() << voiceurl
;
719 installer
->setUrl(voiceurl
);
720 installer
->setLogSection("Voice");
721 installer
->setLogVersion(versmap
.value("arch_date"));
722 installer
->setMountPoint(settings
->mountpoint());
723 if(!settings
->cacheDisabled())
724 installer
->setCache(true);
725 installer
->install(logger
);
729 void RbUtilQt::installDoomBtn()
731 if(chkConfig(true)) return;
733 QMessageBox::critical(this, tr("Error"), tr("Your device doesn't have a doom plugin. Aborting."));
737 if(QMessageBox::question(this, tr("Confirm Installation"),
738 tr("Do you really want to install the game addon files?"),
739 QMessageBox::Yes
| QMessageBox::No
) != QMessageBox::Yes
) return;
741 logger
= new ProgressLoggerGui(this);
746 bool RbUtilQt::installDoomAuto()
752 bool RbUtilQt::hasDoom()
754 QFile
doomrock(settings
->mountpoint() +"/.rockbox/rocks/games/doom.rock");
755 return doomrock
.exists();
758 void RbUtilQt::installDoom()
760 // create zip installer
761 installer
= new ZipInstaller(this);
763 installer
->setUrl(settings
->doomUrl());
764 installer
->setLogSection("Game Addons");
765 installer
->setLogVersion(versmap
.value("arch_date"));
766 installer
->setMountPoint(settings
->mountpoint());
767 if(!settings
->cacheDisabled())
768 installer
->setCache(true);
769 connect(installer
, SIGNAL(done(bool)), this, SLOT(installdone(bool)));
770 installer
->install(logger
);
774 void RbUtilQt::installThemes()
776 if(chkConfig(true)) return;
777 ThemesInstallWindow
* tw
= new ThemesInstallWindow(this);
778 tw
->setSettings(settings
);
783 void RbUtilQt::createTalkFiles(void)
785 if(chkConfig(true)) return;
786 InstallTalkWindow
*installWindow
= new InstallTalkWindow(this);
787 installWindow
->setSettings(settings
);
789 connect(installWindow
, SIGNAL(settingsUpdated()), this, SLOT(downloadInfo()));
790 connect(installWindow
, SIGNAL(settingsUpdated()), this, SLOT(updateSettings()));
791 installWindow
->show();
795 void RbUtilQt::createVoiceFile(void)
797 if(chkConfig(true)) return;
798 CreateVoiceWindow
*installWindow
= new CreateVoiceWindow(this);
799 installWindow
->setSettings(settings
);
801 connect(installWindow
, SIGNAL(settingsUpdated()), this, SLOT(downloadInfo()));
802 connect(installWindow
, SIGNAL(settingsUpdated()), this, SLOT(updateSettings()));
803 installWindow
->show();
806 void RbUtilQt::uninstall(void)
808 if(chkConfig(true)) return;
809 UninstallWindow
*uninstallWindow
= new UninstallWindow(this);
810 uninstallWindow
->setSettings(settings
);
811 uninstallWindow
->show();
815 void RbUtilQt::uninstallBootloader(void)
817 if(chkConfig(true)) return;
818 if(QMessageBox::question(this, tr("Confirm Uninstallation"),
819 tr("Do you really want to uninstall the Bootloader?"),
820 QMessageBox::Yes
| QMessageBox::No
) != QMessageBox::Yes
) return;
822 ProgressLoggerGui
* logger
= new ProgressLoggerGui(this);
825 BootloaderInstaller
blinstaller(this);
826 blinstaller
.setMountPoint(settings
->mountpoint());
827 blinstaller
.setDevice(settings
->curPlatform());
828 blinstaller
.setBootloaderMethod(settings
->curBootloaderMethod());
829 blinstaller
.setBootloaderName(settings
->curBootloaderName());
830 blinstaller
.setBootloaderBaseUrl(settings
->bootloaderUrl());
831 blinstaller
.setBootloaderInfoUrl(settings
->bootloaderInfoUrl());
832 if(!blinstaller
.downloadInfo())
834 logger
->addItem(tr("Could not get the bootloader info file!"),LOGERROR
);
839 blinstaller
.uninstall(logger
);
844 void RbUtilQt::downloadManual(void)
846 if(chkConfig(true)) return;
847 if(QMessageBox::question(this, tr("Confirm download"),
848 tr("Do you really want to download the manual? The manual will be saved "
849 "to the root folder of your player."),
850 QMessageBox::Yes
| QMessageBox::No
) != QMessageBox::Yes
)
854 QSettings
info(buildInfo
.fileName(), QSettings::IniFormat
, this);
857 QString manual
= settings
->curManual();
859 QString date
= (info
.value("dailies/date").toString());
864 if(ui
.radioPdf
->isChecked()) {
865 target
= "/" + manual
+ ".pdf";
866 section
= "Manual (PDF)";
869 target
= "/" + manual
+ "-" + date
+ "-html.zip";
870 section
= "Manual (HTML)";
872 manualurl
= settings
->manualUrl() + "/" + target
;
873 qDebug() << "manualurl =" << manualurl
;
875 ProgressLoggerGui
* logger
= new ProgressLoggerGui(this);
877 installer
= new ZipInstaller(this);
878 installer
->setMountPoint(settings
->mountpoint());
879 if(!settings
->cacheDisabled())
880 installer
->setCache(true);
881 installer
->setLogSection(section
);
882 installer
->setLogVersion(date
);
883 installer
->setUrl(manualurl
);
884 installer
->setUnzip(false);
885 installer
->setTarget(target
);
886 installer
->install(logger
);
890 void RbUtilQt::installPortable(void)
892 if(QMessageBox::question(this, tr("Confirm installation"),
893 tr("Do you really want to install Rockbox Utility to your player? "
894 "After installation you can run it from the players hard drive."),
895 QMessageBox::Yes
| QMessageBox::No
) != QMessageBox::Yes
)
898 ProgressLoggerGui
* logger
= new ProgressLoggerGui(this);
899 logger
->setProgressMax(0);
900 logger
->setProgressValue(0);
902 logger
->addItem(tr("Installing Rockbox Utility"), LOGINFO
);
905 if(!QFileInfo(settings
->mountpoint()).isDir()) {
906 logger
->addItem(tr("Mount point is wrong!"),LOGERROR
);
911 // remove old files first.
912 QFile::remove(settings
->mountpoint() + "/RockboxUtility.exe");
913 QFile::remove(settings
->mountpoint() + "/RockboxUtility.ini");
914 // copy currently running binary and currently used settings file
915 if(!QFile::copy(qApp
->applicationFilePath(), settings
->mountpoint() + "/RockboxUtility.exe")) {
916 logger
->addItem(tr("Error installing Rockbox Utility"), LOGERROR
);
920 logger
->addItem(tr("Installing user configuration"), LOGINFO
);
921 if(!QFile::copy(settings
->userSettingFilename(), settings
->mountpoint() + "/RockboxUtility.ini")) {
922 logger
->addItem(tr("Error installing user configuration"), LOGERROR
);
926 logger
->addItem(tr("Successfully installed Rockbox Utility."), LOGOK
);
928 logger
->setProgressMax(1);
929 logger
->setProgressValue(1);
934 void RbUtilQt::updateInfo()
936 qDebug() << "RbUtilQt::updateInfo()";
938 QSettings
log(settings
->mountpoint() + "/.rockbox/rbutil.log", QSettings::IniFormat
, this);
939 QStringList groups
= log
.childGroups();
940 QList
<QTreeWidgetItem
*> items
;
941 QTreeWidgetItem
*w
, *w2
;
945 // remove old list entries (if any)
946 int l
= ui
.treeInfo
->topLevelItemCount();
949 m
= ui
.treeInfo
->takeTopLevelItem(l
);
950 // delete childs (single level deep, no recursion here)
951 int n
= m
->childCount();
955 // get and populate new items
956 for(int a
= 0; a
< groups
.size(); a
++) {
957 log
.beginGroup(groups
.at(a
));
958 QStringList keys
= log
.allKeys();
959 w
= new QTreeWidgetItem
;
960 w
->setFlags(Qt::ItemIsEnabled
);
961 w
->setText(0, groups
.at(a
));
963 // get minimum and maximum version information so we can hilight old files
964 min
= max
= log
.value(keys
.at(0)).toString();
965 for(int b
= 0; b
< keys
.size(); b
++) {
966 if(log
.value(keys
.at(b
)).toString() > max
)
967 max
= log
.value(keys
.at(b
)).toString();
968 if(log
.value(keys
.at(b
)).toString() < min
)
969 min
= log
.value(keys
.at(b
)).toString();
972 for(int b
= 0; b
< keys
.size(); b
++) {
974 file
= settings
->mountpoint() + "/" + keys
.at(b
);
975 if(QFileInfo(file
).isDir())
977 w2
= new QTreeWidgetItem(w
, QStringList() << "/"
978 + keys
.at(b
) << log
.value(keys
.at(b
)).toString());
979 if(log
.value(keys
.at(b
)).toString() != max
) {
980 w2
->setForeground(0, QBrush(QColor(255, 0, 0)));
981 w2
->setForeground(1, QBrush(QColor(255, 0, 0)));
988 w
->setData(1, Qt::DisplayRole
, QString("%1 / %2").arg(min
, max
));
990 w
->setData(1, Qt::DisplayRole
, max
);
992 ui
.treeInfo
->insertTopLevelItems(0, items
);
993 ui
.treeInfo
->resizeColumnToContents(0);
997 QUrl
RbUtilQt::proxy()
999 if(settings
->proxyType() == "manual")
1000 return QUrl(settings
->proxy());
1001 else if(settings
->proxy() == "system")
1003 return Detect::systemProxy();
1009 bool RbUtilQt::chkConfig(bool warn
)
1012 if(settings
->curPlatform().isEmpty()
1013 || settings
->mountpoint().isEmpty()
1014 || !QFileInfo(settings
->mountpoint()).isWritable()) {
1017 if(warn
) QMessageBox::critical(this, tr("Configuration error"),
1018 tr("Your configuration is invalid. Please go to the configuration "
1019 "dialog and make sure the selected values are correct."));