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"
38 #if defined(Q_OS_LINUX)
41 #if defined(Q_OS_WIN32)
50 RbUtilQt::RbUtilQt(QWidget
*parent
) : QMainWindow(parent
)
52 absolutePath
= qApp
->applicationDirPath();
56 settings
= new RbSettings();
63 ui
.radioPdf
->setChecked(true);
66 ui
.treeInfo
->setAlternatingRowColors(true);
67 ui
.treeInfo
->setHeaderLabels(QStringList() << tr("File") << tr("Version"));
68 ui
.treeInfo
->expandAll();
69 ui
.treeInfo
->setColumnCount(2);
71 connect(ui
.tabWidget
, SIGNAL(currentChanged(int)), this, SLOT(updateTabs(int)));
72 connect(ui
.actionAbout_Qt
, SIGNAL(triggered()), qApp
, SLOT(aboutQt()));
73 connect(ui
.action_About
, SIGNAL(triggered()), this, SLOT(about()));
74 connect(ui
.action_Help
, SIGNAL(triggered()), this, SLOT(help()));
75 connect(ui
.action_Configure
, SIGNAL(triggered()), this, SLOT(configDialog()));
76 connect(ui
.buttonChangeDevice
, SIGNAL(clicked()), this, SLOT(configDialog()));
77 connect(ui
.buttonRockbox
, SIGNAL(clicked()), this, SLOT(installBtn()));
78 connect(ui
.buttonBootloader
, SIGNAL(clicked()), this, SLOT(installBootloaderBtn()));
79 connect(ui
.buttonFonts
, SIGNAL(clicked()), this, SLOT(installFontsBtn()));
80 connect(ui
.buttonGames
, SIGNAL(clicked()), this, SLOT(installDoomBtn()));
81 connect(ui
.buttonTalk
, SIGNAL(clicked()), this, SLOT(createTalkFiles()));
82 connect(ui
.buttonCreateVoice
, SIGNAL(clicked()), this, SLOT(createVoiceFile()));
83 connect(ui
.buttonVoice
, SIGNAL(clicked()), this, SLOT(installVoice()));
84 connect(ui
.buttonThemes
, SIGNAL(clicked()), this, SLOT(installThemes()));
85 connect(ui
.buttonRemoveRockbox
, SIGNAL(clicked()), this, SLOT(uninstall()));
86 connect(ui
.buttonRemoveBootloader
, SIGNAL(clicked()), this, SLOT(uninstallBootloader()));
87 connect(ui
.buttonDownloadManual
, SIGNAL(clicked()), this, SLOT(downloadManual()));
88 connect(ui
.buttonSmall
, SIGNAL(clicked()), this, SLOT(smallInstall()));
89 connect(ui
.buttonComplete
, SIGNAL(clicked()), this, SLOT(completeInstall()));
91 // actions accessible from the menu
92 connect(ui
.actionComplete_Installation
, SIGNAL(triggered()), this, SLOT(completeInstall()));
93 connect(ui
.actionSmall_Installation
, SIGNAL(triggered()), this, SLOT(smallInstall()));
94 connect(ui
.actionInstall_Bootloader
, SIGNAL(triggered()), this, SLOT(installBootloaderBtn()));
95 connect(ui
.actionInstall_Rockbox
, SIGNAL(triggered()), this, SLOT(installBtn()));
96 connect(ui
.actionFonts_Package
, SIGNAL(triggered()), this, SLOT(installFontsBtn()));
97 connect(ui
.actionInstall_Themes
, SIGNAL(triggered()), this, SLOT(installThemes()));
98 connect(ui
.actionInstall_Game_Files
, SIGNAL(triggered()), this, SLOT(installDoomBtn()));
99 connect(ui
.actionInstall_Voice_File
, SIGNAL(triggered()), this, SLOT(installVoice()));
100 connect(ui
.actionCreate_Voice_File
, SIGNAL(triggered()), this, SLOT(createVoiceFile()));
101 connect(ui
.actionCreate_Talk_Files
, SIGNAL(triggered()), this, SLOT(createTalkFiles()));
102 connect(ui
.actionRemove_bootloader
, SIGNAL(triggered()), this, SLOT(uninstallBootloader()));
103 connect(ui
.actionUninstall_Rockbox
, SIGNAL(triggered()), this, SLOT(uninstall()));
106 ui
.actionInstall_Rockbox_Utility_on_player
->setEnabled(false);
108 connect(ui
.actionInstall_Rockbox_Utility_on_player
, SIGNAL(triggered()), this, SLOT(installPortable()));
118 void RbUtilQt::updateTabs(int count
)
130 void RbUtilQt::downloadInfo()
132 // try to get the current build information
133 daily
= new HttpGet(this);
134 connect(daily
, SIGNAL(done(bool)), this, SLOT(downloadDone(bool)));
135 connect(daily
, SIGNAL(requestFinished(int, bool)), this, SLOT(downloadDone(int, bool)));
136 connect(qApp
, SIGNAL(lastWindowClosed()), daily
, SLOT(abort()));
137 if(settings
->cacheOffline())
138 daily
->setCache(true);
140 daily
->setCache(false);
141 qDebug() << "downloading build info";
142 daily
->setFile(&buildInfo
);
143 daily
->getFile(QUrl(settings
->serverConfUrl()));
147 void RbUtilQt::downloadDone(bool error
)
150 qDebug() << "network error:" << daily
->error();
153 qDebug() << "network status:" << daily
->error();
156 QSettings
info(buildInfo
.fileName(), QSettings::IniFormat
, this);
158 versmap
.insert("arch_rev", info
.value("dailies/rev").toString());
159 versmap
.insert("arch_date", info
.value("dailies/date").toString());
161 bleeding
= new HttpGet(this);
162 connect(bleeding
, SIGNAL(done(bool)), this, SLOT(downloadBleedingDone(bool)));
163 connect(bleeding
, SIGNAL(requestFinished(int, bool)), this, SLOT(downloadDone(int, bool)));
164 connect(qApp
, SIGNAL(lastWindowClosed()), daily
, SLOT(abort()));
165 if(settings
->cacheOffline())
166 bleeding
->setCache(true);
167 bleeding
->setFile(&bleedingInfo
);
168 bleeding
->getFile(QUrl(settings
->bleedingInfo()));
170 if(chkConfig(false)) {
171 QApplication::processEvents();
172 QMessageBox::critical(this, tr("Configuration error"),
173 tr("Your configuration is invalid. This is most likely due "
174 "to a new installation of Rockbox Utility or a changed device "
175 "path. The configuation dialog will now open to allow you "
176 "correcting the problem."));
182 void RbUtilQt::downloadBleedingDone(bool error
)
184 if(error
) qDebug() << "network error:" << bleeding
->error();
187 QSettings
info(bleedingInfo
.fileName(), QSettings::IniFormat
, this);
188 bleedingInfo
.close();
189 versmap
.insert("bleed_rev", info
.value("bleeding/rev").toString());
190 versmap
.insert("bleed_date", info
.value("bleeding/timestamp").toString());
191 qDebug() << "versmap =" << versmap
;
197 void RbUtilQt::downloadDone(int id
, bool error
)
200 errorString
= tr("Network error: %1. Please check your network and proxy settings.")
201 .arg(daily
->errorString());
203 QMessageBox::about(this, "Network Error", errorString
);
205 qDebug() << "downloadDone:" << id
<< error
;
209 void RbUtilQt::about()
211 QDialog
*window
= new QDialog(this);
213 about
.setupUi(window
);
214 window
->setModal(true);
216 QFile
licence(":/docs/gpl-2.0.html");
217 licence
.open(QIODevice::ReadOnly
);
218 QTextStream
c(&licence
);
219 QString cline
= c
.readAll();
220 about
.browserLicense
->insertHtml(cline
);
221 about
.browserLicense
->moveCursor(QTextCursor::Start
, QTextCursor::MoveAnchor
);
222 QFile
credits(":/docs/CREDITS");
223 credits
.open(QIODevice::ReadOnly
);
224 QTextStream
r(&credits
);
225 QString rline
= r
.readAll();
226 about
.browserCredits
->insertPlainText(rline
);
227 about
.browserCredits
->moveCursor(QTextCursor::Start
, QTextCursor::MoveAnchor
);
228 QString title
= QString("<b>The Rockbox Utility</b><br/>Version %1").arg(VERSION
);
229 about
.labelTitle
->setText(title
);
230 about
.labelHomepage
->setText("<a href='http://www.rockbox.org'>http://www.rockbox.org</a>");
237 void RbUtilQt::help()
239 QUrl
helpurl("http://www.rockbox.org/wiki/RockboxUtility");
240 QDesktopServices::openUrl(helpurl
);
244 void RbUtilQt::configDialog()
246 Config
*cw
= new Config(this);
247 cw
->setSettings(settings
);
248 connect(cw
, SIGNAL(settingsUpdated()), this, SLOT(updateSettings()));
249 connect(cw
, SIGNAL(settingsUpdated()), this, SLOT(downloadInfo()));
254 void RbUtilQt::updateSettings()
256 qDebug() << "updateSettings()";
259 if(settings
->proxyType() == "system") {
260 HttpGet::setGlobalProxy(systemProxy());
262 else if(settings
->proxyType() == "manual") {
263 HttpGet::setGlobalProxy(settings
->proxy());
266 HttpGet::setGlobalProxy(QUrl(""));
268 HttpGet::setGlobalCache(settings
->cachePath());
269 HttpGet::setGlobalDumbCache(settings
->cacheOffline());
273 void RbUtilQt::updateDevice()
275 if(!settings
->curNeedsBootloader() ) {
276 ui
.buttonBootloader
->setEnabled(false);
277 ui
.buttonRemoveBootloader
->setEnabled(false);
278 ui
.labelBootloader
->setEnabled(false);
279 ui
.labelRemoveBootloader
->setEnabled(false);
282 ui
.buttonBootloader
->setEnabled(true);
283 ui
.labelBootloader
->setEnabled(true);
284 if(settings
->curBootloaderMethod() == "fwpatcher") {
285 ui
.labelRemoveBootloader
->setEnabled(false);
286 ui
.buttonRemoveBootloader
->setEnabled(false);
289 ui
.labelRemoveBootloader
->setEnabled(true);
290 ui
.buttonRemoveBootloader
->setEnabled(true);
294 // displayed device info
295 QString mountpoint
= settings
->mountpoint();
296 QString brand
= settings
->curBrand();
297 QString name
= settings
->curName();
298 if(name
.isEmpty()) name
= "<none>";
299 if(mountpoint
.isEmpty()) mountpoint
= "<invalid>";
300 ui
.labelDevice
->setText(tr("<b>%1 %2</b> at <b>%3</b>")
301 .arg(brand
, name
, QDir::toNativeSeparators(mountpoint
)));
305 void RbUtilQt::updateManual()
307 if(settings
->curPlatform() != "")
309 QString manual
= settings
->curManual();
312 manual
= "rockbox-" + settings
->curPlatform();
314 pdfmanual
= settings
->manualUrl() + "/" + manual
+ ".pdf";
316 htmlmanual
= settings
->manualUrl() + "/" + manual
+ "/rockbox-build.html";
317 ui
.labelPdfManual
->setText(tr("<a href='%1'>PDF Manual</a>")
319 ui
.labelHtmlManual
->setText(tr("<a href='%1'>HTML Manual (opens in browser)</a>")
323 ui
.labelPdfManual
->setText(tr("Select a device for a link to the correct manual"));
324 ui
.labelHtmlManual
->setText(tr("<a href='%1'>Manual Overview</a>")
325 .arg("http://www.rockbox.org/manual.shtml"));
330 void RbUtilQt::completeInstall()
332 if(chkConfig(true)) return;
333 if(QMessageBox::question(this, tr("Confirm Installation"),
334 tr("Do you really want to make a complete Installation?"),
335 QMessageBox::Yes
| QMessageBox::No
) != QMessageBox::Yes
) return;
338 logger
= new ProgressLoggerGui(this);
341 if(smallInstallInner())
347 if(!installFontsAuto())
351 // wait for installation finished
353 QApplication::processEvents();
363 if(!installDoomAuto())
367 // wait for installation finished
369 QApplication::processEvents();
376 // it has its own logger window,so close our.
382 void RbUtilQt::smallInstall()
384 if(chkConfig(true)) return;
385 if(QMessageBox::question(this, tr("Confirm Installation"),
386 tr("Do you really want to make a small Installation?"),
387 QMessageBox::Yes
| QMessageBox::No
) != QMessageBox::Yes
) return;
390 logger
= new ProgressLoggerGui(this);
396 bool RbUtilQt::smallInstallInner()
398 QString mountpoint
= settings
->mountpoint();
399 // show dialog with error if mount point is wrong
400 if(!QFileInfo(mountpoint
).isDir()) {
401 logger
->addItem(tr("Mount point is wrong!"),LOGERROR
);
406 if(settings
->curNeedsBootloader())
410 if(!installBootloaderAuto())
414 // wait for boot loader installation finished
416 QApplication::processEvents();
418 if(m_error
) return true;
429 // wait for installation finished
431 QApplication::processEvents();
437 void RbUtilQt::installdone(bool error
)
439 qDebug() << "install done";
444 void RbUtilQt::installBtn()
446 if(chkConfig(true)) return;
450 bool RbUtilQt::installAuto()
452 QString file
= QString("%1%2/rockbox.zip")
453 .arg(settings
->bleedingUrl(), settings
->curPlatform());
456 QSettings
info(buildInfo
.fileName(), QSettings::IniFormat
, this);
459 if(settings
->curReleased()) {
460 // only set the keys if needed -- querying will yield an empty string
462 versmap
.insert("rel_rev", settings
->lastRelease());
463 versmap
.insert("rel_date", ""); // FIXME: provide the release timestamp
466 QString myversion
= "r" + versmap
.value("bleed_rev");
468 //! check if rockbox is already installed
469 QString rbVersion
= installedVersion(settings
->mountpoint());
472 if(QMessageBox::question(this, tr("Installed Rockbox detected"),
473 tr("Rockbox installation detected. Do you want to backup first?"),
474 QMessageBox::Yes
| QMessageBox::No
) == QMessageBox::Yes
)
476 logger
->addItem(tr("Beginning Backup..."),LOGINFO
);
477 QString backupName
= settings
->mountpoint() + "/.backup/rockbox-backup-"+rbVersion
+".zip";
479 //! create dir, if it doesnt exist
480 QFileInfo
backupFile(backupName
);
481 if(!QDir(backupFile
.path()).exists())
484 a
.mkpath(backupFile
.path());
489 connect(&backup
,SIGNAL(zipProgress(int,int)),this,SLOT(updateDataReadProgress(int,int)));
490 if(backup
.createZip(backupName
,settings
->mountpoint() + "/.rockbox") == Zip::Ok
)
492 logger
->addItem(tr("Backup successfull"),LOGOK
);
496 logger
->addItem(tr("Backup failed!"),LOGERROR
);
503 //! install current build
504 ZipInstaller
* installer
= new ZipInstaller(this);
505 installer
->setUrl(file
);
506 installer
->setLogSection("Rockbox (Base)");
507 installer
->setLogVersion(myversion
);
508 if(!settings
->cacheDisabled())
509 installer
->setCache(true);
510 installer
->setMountPoint(settings
->mountpoint());
512 connect(installer
, SIGNAL(done(bool)), this, SLOT(installdone(bool)));
514 installer
->install(logger
);
518 void RbUtilQt::updateDataReadProgress(int read
, int total
)
520 logger
->setProgressMax(total
);
521 logger
->setProgressValue(read
);
522 //qDebug() << "progress:" << read << "/" << total;
526 void RbUtilQt::install()
528 Install
*installWindow
= new Install(settings
,this);
531 QSettings
info(buildInfo
.fileName(), QSettings::IniFormat
, this);
534 if(settings
->curReleased()) {
535 // only set the keys if needed -- querying will yield an empty string
537 versmap
.insert("rel_rev", settings
->lastRelease());
538 versmap
.insert("rel_date", ""); // FIXME: provide the release timestamp
540 installWindow
->setVersionStrings(versmap
);
542 installWindow
->show();
545 bool RbUtilQt::installBootloaderAuto()
551 void RbUtilQt::installBootloaderBtn()
553 if(chkConfig(true)) return;
554 if(QMessageBox::question(this, tr("Confirm Installation"),
555 tr("Do you really want to install the Bootloader?"),
556 QMessageBox::Yes
| QMessageBox::No
) != QMessageBox::Yes
) return;
559 logger
= new ProgressLoggerGui(this);
565 void RbUtilQt::installBootloader()
567 QString platform
= settings
->curPlatform();
570 blinstaller
= new BootloaderInstaller(this);
572 blinstaller
->setMountPoint(settings
->mountpoint());
574 blinstaller
->setDevice(platform
);
575 blinstaller
->setBootloaderMethod(settings
->curBootloaderMethod());
576 blinstaller
->setBootloaderName(settings
->curBootloaderName());
577 blinstaller
->setBootloaderBaseUrl(settings
->bootloaderUrl());
578 blinstaller
->setBootloaderInfoUrl(settings
->bootloaderInfoUrl());
579 if(!blinstaller
->downloadInfo())
581 logger
->addItem(tr("Could not get the bootloader info file!"),LOGERROR
);
587 if(blinstaller
->uptodate())
589 int ret
= QMessageBox::question(this, tr("Bootloader Installation"),
590 tr("The bootloader is already installed and up to date.\n"
591 "Do want to replace the current bootloader?"),
592 QMessageBox::Yes
| QMessageBox::No
, QMessageBox::No
);
593 if(ret
== QMessageBox::No
)
595 logger
->addItem(tr("Bootloader installation skipped!"), LOGINFO
);
602 // if fwpatcher , ask for extra file
604 if(settings
->curBootloaderMethod() == "fwpatcher")
606 BrowseOF
ofbrowser(this);
607 ofbrowser
.setFile(settings
->ofPath());
608 if(ofbrowser
.exec() == QDialog::Accepted
)
610 offirmware
= ofbrowser
.getFile();
611 qDebug() << offirmware
;
612 if(!QFileInfo(offirmware
).exists())
614 logger
->addItem(tr("Original Firmware Path is wrong!"),LOGERROR
);
621 settings
->setOfPath(offirmware
);
627 logger
->addItem(tr("Original Firmware selection Canceled!"),LOGERROR
);
633 blinstaller
->setOrigFirmwarePath(offirmware
);
634 connect(blinstaller
,SIGNAL(done(bool)),this,SLOT(installdone(bool)));
635 blinstaller
->install(logger
);
638 void RbUtilQt::installFontsBtn()
640 if(chkConfig(true)) return;
641 if(QMessageBox::question(this, tr("Confirm Installation"),
642 tr("Do you really want to install the fonts package?"),
643 QMessageBox::Yes
| QMessageBox::No
) != QMessageBox::Yes
) return;
645 logger
= new ProgressLoggerGui(this);
650 bool RbUtilQt::installFontsAuto()
657 void RbUtilQt::installFonts()
659 // create zip installer
660 installer
= new ZipInstaller(this);
662 installer
->setUrl(settings
->fontUrl());
663 installer
->setLogSection("Fonts");
664 installer
->setLogVersion(versmap
.value("arch_date"));
665 installer
->setMountPoint(settings
->mountpoint());
666 if(!settings
->cacheDisabled())
667 installer
->setCache(true);
669 connect(installer
, SIGNAL(done(bool)), this, SLOT(installdone(bool)));
670 installer
->install(logger
);
674 void RbUtilQt::installVoice()
676 if(chkConfig(true)) return;
678 if(m_gotInfo
== false)
680 QMessageBox::warning(this, tr("Warning"),
681 tr("The Application is still downloading Information about new Builds. Please try again shortly."));
685 if(QMessageBox::question(this, tr("Confirm Installation"),
686 tr("Do you really want to install the voice file?"),
687 QMessageBox::Yes
| QMessageBox::No
) != QMessageBox::Yes
) return;
689 logger
= new ProgressLoggerGui(this);
692 // create zip installer
693 installer
= new ZipInstaller(this);
695 QString voiceurl
= settings
->voiceUrl();
697 voiceurl
+= settings
->curVoiceName() + "-" +
698 versmap
.value("arch_date") + "-english.zip";
699 qDebug() << voiceurl
;
701 installer
->setUrl(voiceurl
);
702 installer
->setLogSection("Voice");
703 installer
->setLogVersion(versmap
.value("arch_date"));
704 installer
->setMountPoint(settings
->mountpoint());
705 if(!settings
->cacheDisabled())
706 installer
->setCache(true);
707 installer
->install(logger
);
711 void RbUtilQt::installDoomBtn()
713 if(chkConfig(true)) return;
715 QMessageBox::critical(this, tr("Error"), tr("Your device doesn't have a doom plugin. Aborting."));
719 if(QMessageBox::question(this, tr("Confirm Installation"),
720 tr("Do you really want to install the game addon files?"),
721 QMessageBox::Yes
| QMessageBox::No
) != QMessageBox::Yes
) return;
723 logger
= new ProgressLoggerGui(this);
728 bool RbUtilQt::installDoomAuto()
734 bool RbUtilQt::hasDoom()
736 QFile
doomrock(settings
->mountpoint() +"/.rockbox/rocks/games/doom.rock");
737 return doomrock
.exists();
740 void RbUtilQt::installDoom()
742 // create zip installer
743 installer
= new ZipInstaller(this);
745 installer
->setUrl(settings
->doomUrl());
746 installer
->setLogSection("Game Addons");
747 installer
->setLogVersion(versmap
.value("arch_date"));
748 installer
->setMountPoint(settings
->mountpoint());
749 if(!settings
->cacheDisabled())
750 installer
->setCache(true);
751 connect(installer
, SIGNAL(done(bool)), this, SLOT(installdone(bool)));
752 installer
->install(logger
);
756 void RbUtilQt::installThemes()
758 if(chkConfig(true)) return;
759 ThemesInstallWindow
* tw
= new ThemesInstallWindow(this);
760 tw
->setSettings(settings
);
765 void RbUtilQt::createTalkFiles(void)
767 if(chkConfig(true)) return;
768 InstallTalkWindow
*installWindow
= new InstallTalkWindow(this);
769 installWindow
->setSettings(settings
);
771 connect(installWindow
, SIGNAL(settingsUpdated()), this, SLOT(downloadInfo()));
772 connect(installWindow
, SIGNAL(settingsUpdated()), this, SLOT(updateSettings()));
773 installWindow
->show();
777 void RbUtilQt::createVoiceFile(void)
779 if(chkConfig(true)) return;
780 CreateVoiceWindow
*installWindow
= new CreateVoiceWindow(this);
781 installWindow
->setSettings(settings
);
783 connect(installWindow
, SIGNAL(settingsUpdated()), this, SLOT(downloadInfo()));
784 connect(installWindow
, SIGNAL(settingsUpdated()), this, SLOT(updateSettings()));
785 installWindow
->show();
788 void RbUtilQt::uninstall(void)
790 if(chkConfig(true)) return;
791 UninstallWindow
*uninstallWindow
= new UninstallWindow(this);
792 uninstallWindow
->setSettings(settings
);
793 uninstallWindow
->show();
797 void RbUtilQt::uninstallBootloader(void)
799 if(chkConfig(true)) return;
800 if(QMessageBox::question(this, tr("Confirm Uninstallation"),
801 tr("Do you really want to uninstall the Bootloader?"),
802 QMessageBox::Yes
| QMessageBox::No
) != QMessageBox::Yes
) return;
804 ProgressLoggerGui
* logger
= new ProgressLoggerGui(this);
807 BootloaderInstaller
blinstaller(this);
808 blinstaller
.setMountPoint(settings
->mountpoint());
809 blinstaller
.setDevice(settings
->curPlatform());
810 blinstaller
.setBootloaderMethod(settings
->curBootloaderMethod());
811 blinstaller
.setBootloaderName(settings
->curBootloaderName());
812 blinstaller
.setBootloaderBaseUrl(settings
->bootloaderUrl());
813 blinstaller
.setBootloaderInfoUrl(settings
->bootloaderInfoUrl());
814 if(!blinstaller
.downloadInfo())
816 logger
->addItem(tr("Could not get the bootloader info file!"),LOGERROR
);
821 blinstaller
.uninstall(logger
);
826 void RbUtilQt::downloadManual(void)
828 if(chkConfig(true)) return;
829 if(QMessageBox::question(this, tr("Confirm download"),
830 tr("Do you really want to download the manual? The manual will be saved "
831 "to the root folder of your player."),
832 QMessageBox::Yes
| QMessageBox::No
) != QMessageBox::Yes
)
836 QSettings
info(buildInfo
.fileName(), QSettings::IniFormat
, this);
839 QString manual
= settings
->curManual();
841 QString date
= (info
.value("dailies/date").toString());
846 if(ui
.radioPdf
->isChecked()) {
847 target
= "/" + manual
+ ".pdf";
848 section
= "Manual (PDF)";
851 target
= "/" + manual
+ "-" + date
+ "-html.zip";
852 section
= "Manual (HTML)";
854 manualurl
= settings
->manualUrl() + "/" + target
;
855 qDebug() << "manualurl =" << manualurl
;
857 ProgressLoggerGui
* logger
= new ProgressLoggerGui(this);
859 installer
= new ZipInstaller(this);
860 installer
->setMountPoint(settings
->mountpoint());
861 if(!settings
->cacheDisabled())
862 installer
->setCache(true);
863 installer
->setLogSection(section
);
864 installer
->setLogVersion(date
);
865 installer
->setUrl(manualurl
);
866 installer
->setUnzip(false);
867 installer
->setTarget(target
);
868 installer
->install(logger
);
872 void RbUtilQt::installPortable(void)
874 if(QMessageBox::question(this, tr("Confirm installation"),
875 tr("Do you really want to install Rockbox Utility to your player? "
876 "After installation you can run it from the players hard drive."),
877 QMessageBox::Yes
| QMessageBox::No
) != QMessageBox::Yes
)
880 ProgressLoggerGui
* logger
= new ProgressLoggerGui(this);
881 logger
->setProgressMax(0);
882 logger
->setProgressValue(0);
884 logger
->addItem(tr("Installing Rockbox Utility"), LOGINFO
);
887 if(!QFileInfo(settings
->mountpoint()).isDir()) {
888 logger
->addItem(tr("Mount point is wrong!"),LOGERROR
);
893 // remove old files first.
894 QFile::remove(settings
->mountpoint() + "/RockboxUtility.exe");
895 QFile::remove(settings
->mountpoint() + "/RockboxUtility.ini");
896 // copy currently running binary and currently used settings file
897 if(!QFile::copy(qApp
->applicationFilePath(), settings
->mountpoint() + "/RockboxUtility.exe")) {
898 logger
->addItem(tr("Error installing Rockbox Utility"), LOGERROR
);
902 logger
->addItem(tr("Installing user configuration"), LOGINFO
);
903 if(!QFile::copy(settings
->userSettingFilename(), settings
->mountpoint() + "/RockboxUtility.ini")) {
904 logger
->addItem(tr("Error installing user configuration"), LOGERROR
);
908 logger
->addItem(tr("Successfully installed Rockbox Utility."), LOGOK
);
910 logger
->setProgressMax(1);
911 logger
->setProgressValue(1);
916 void RbUtilQt::updateInfo()
918 qDebug() << "RbUtilQt::updateInfo()";
920 QSettings
log(settings
->mountpoint() + "/.rockbox/rbutil.log", QSettings::IniFormat
, this);
921 QStringList groups
= log
.childGroups();
922 QList
<QTreeWidgetItem
*> items
;
923 QTreeWidgetItem
*w
, *w2
;
927 // remove old list entries (if any)
928 int l
= ui
.treeInfo
->topLevelItemCount();
931 m
= ui
.treeInfo
->takeTopLevelItem(l
);
932 // delete childs (single level deep, no recursion here)
933 int n
= m
->childCount();
937 // get and populate new items
938 for(int a
= 0; a
< groups
.size(); a
++) {
939 log
.beginGroup(groups
.at(a
));
940 QStringList keys
= log
.allKeys();
941 w
= new QTreeWidgetItem
;
942 w
->setFlags(Qt::ItemIsEnabled
);
943 w
->setText(0, groups
.at(a
));
945 // get minimum and maximum version information so we can hilight old files
946 min
= max
= log
.value(keys
.at(0)).toString();
947 for(int b
= 0; b
< keys
.size(); b
++) {
948 if(log
.value(keys
.at(b
)).toString() > max
)
949 max
= log
.value(keys
.at(b
)).toString();
950 if(log
.value(keys
.at(b
)).toString() < min
)
951 min
= log
.value(keys
.at(b
)).toString();
954 for(int b
= 0; b
< keys
.size(); b
++) {
956 file
= settings
->mountpoint() + "/" + keys
.at(b
);
957 if(QFileInfo(file
).isDir())
959 w2
= new QTreeWidgetItem(w
, QStringList() << "/"
960 + keys
.at(b
) << log
.value(keys
.at(b
)).toString());
961 if(log
.value(keys
.at(b
)).toString() != max
) {
962 w2
->setForeground(0, QBrush(QColor(255, 0, 0)));
963 w2
->setForeground(1, QBrush(QColor(255, 0, 0)));
970 w
->setData(1, Qt::DisplayRole
, QString("%1 / %2").arg(min
, max
));
972 w
->setData(1, Qt::DisplayRole
, max
);
974 ui
.treeInfo
->insertTopLevelItems(0, items
);
975 ui
.treeInfo
->resizeColumnToContents(0);
979 QUrl
RbUtilQt::proxy()
981 if(settings
->proxyType() == "manual")
982 return QUrl(settings
->proxy());
983 else if(settings
->proxy() == "system")
985 return systemProxy();
991 bool RbUtilQt::chkConfig(bool warn
)
994 if(settings
->curPlatform().isEmpty()
995 || settings
->mountpoint().isEmpty()
996 || !QFileInfo(settings
->mountpoint()).isWritable()) {
999 if(warn
) QMessageBox::critical(this, tr("Configuration error"),
1000 tr("Your configuration is invalid. Please go to the configuration "
1001 "dialog and make sure the selected values are correct."));