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"
30 #include "installbootloader.h"
31 #include "installthemes.h"
32 #include "uninstallwindow.h"
35 #if defined(Q_OS_LINUX)
38 #if defined(Q_OS_WIN32)
47 RbUtilQt::RbUtilQt(QWidget
*parent
) : QMainWindow(parent
)
49 absolutePath
= qApp
->applicationDirPath();
50 // use built-in rbutil.ini if no external file in binary folder
51 QString iniFile
= absolutePath
+ "/rbutil.ini";
52 if(QFileInfo(iniFile
).isFile()) {
53 qDebug() << "using external rbutil.ini";
54 devices
= new QSettings(iniFile
, QSettings::IniFormat
, 0);
57 qDebug() << "using built-in rbutil.ini";
58 devices
= new QSettings(":/ini/rbutil.ini", QSettings::IniFormat
, 0);
63 // portable installation:
64 // check for a configuration file in the program folder.
66 config
.setFile(absolutePath
+ "/RockboxUtility.ini");
68 userSettings
= new QSettings(absolutePath
+ "/RockboxUtility.ini",
69 QSettings::IniFormat
, 0);
70 qDebug() << "config: portable";
73 userSettings
= new QSettings(QSettings::IniFormat
,
74 QSettings::UserScope
, "rockbox.org", "RockboxUtility");
75 qDebug() << "config: system";
81 ui
.radioPdf
->setChecked(true);
84 ui
.treeInfo
->setAlternatingRowColors(true);
85 ui
.treeInfo
->setHeaderLabels(QStringList() << tr("File") << tr("Version"));
86 ui
.treeInfo
->expandAll();
87 ui
.treeInfo
->setColumnCount(2);
89 connect(ui
.tabWidget
, SIGNAL(currentChanged(int)), this, SLOT(updateTabs(int)));
90 connect(ui
.actionAbout_Qt
, SIGNAL(triggered()), qApp
, SLOT(aboutQt()));
91 connect(ui
.action_About
, SIGNAL(triggered()), this, SLOT(about()));
92 connect(ui
.action_Help
, SIGNAL(triggered()), this, SLOT(help()));
93 connect(ui
.action_Configure
, SIGNAL(triggered()), this, SLOT(configDialog()));
94 connect(ui
.buttonChangeDevice
, SIGNAL(clicked()), this, SLOT(configDialog()));
95 connect(ui
.buttonRockbox
, SIGNAL(clicked()), this, SLOT(installBtn()));
96 connect(ui
.buttonBootloader
, SIGNAL(clicked()), this, SLOT(installBootloaderBtn()));
97 connect(ui
.buttonFonts
, SIGNAL(clicked()), this, SLOT(installFontsBtn()));
98 connect(ui
.buttonGames
, SIGNAL(clicked()), this, SLOT(installDoomBtn()));
99 connect(ui
.buttonTalk
, SIGNAL(clicked()), this, SLOT(createTalkFiles()));
100 connect(ui
.buttonVoice
, SIGNAL(clicked()), this, SLOT(installVoice()));
101 connect(ui
.buttonThemes
, SIGNAL(clicked()), this, SLOT(installThemes()));
102 connect(ui
.buttonRemoveRockbox
, SIGNAL(clicked()), this, SLOT(uninstall()));
103 connect(ui
.buttonRemoveBootloader
, SIGNAL(clicked()), this, SLOT(uninstallBootloader()));
104 connect(ui
.buttonDownloadManual
, SIGNAL(clicked()), this, SLOT(downloadManual()));
105 connect(ui
.buttonSmall
, SIGNAL(clicked()), this, SLOT(smallInstall()));
106 connect(ui
.buttonComplete
, SIGNAL(clicked()), this, SLOT(completeInstall()));
108 // actions accessible from the menu
109 connect(ui
.actionComplete_Installation
, SIGNAL(triggered()), this, SLOT(completeInstall()));
110 connect(ui
.actionSmall_Installation
, SIGNAL(triggered()), this, SLOT(smallInstall()));
111 connect(ui
.actionInstall_Bootloader
, SIGNAL(triggered()), this, SLOT(installBootloaderBtn()));
112 connect(ui
.actionInstall_Rockbox
, SIGNAL(triggered()), this, SLOT(installBtn()));
113 connect(ui
.actionFonts_Package
, SIGNAL(triggered()), this, SLOT(installFontsBtn()));
114 connect(ui
.actionInstall_Themes
, SIGNAL(triggered()), this, SLOT(installThemes()));
115 connect(ui
.actionInstall_Game_Files
, SIGNAL(triggered()), this, SLOT(installDoomBtn()));
116 connect(ui
.actionInstall_Voice_File
, SIGNAL(triggered()), this, SLOT(installVoice()));
117 connect(ui
.actionCreate_Talk_Files
, SIGNAL(triggered()), this, SLOT(createTalkFiles()));
118 connect(ui
.actionRemove_bootloader
, SIGNAL(triggered()), this, SLOT(uninstallBootloader()));
119 connect(ui
.actionUninstall_Rockbox
, SIGNAL(triggered()), this, SLOT(uninstall()));
122 ui
.actionInstall_Rockbox_Utility_on_player
->setEnabled(false);
124 connect(ui
.actionInstall_Rockbox_Utility_on_player
, SIGNAL(triggered()), this, SLOT(installPortable()));
134 void RbUtilQt::updateTabs(int count
)
146 void RbUtilQt::downloadInfo()
148 // try to get the current build information
149 daily
= new HttpGet(this);
150 connect(daily
, SIGNAL(done(bool)), this, SLOT(downloadDone(bool)));
151 connect(daily
, SIGNAL(requestFinished(int, bool)), this, SLOT(downloadDone(int, bool)));
152 connect(qApp
, SIGNAL(lastWindowClosed()), daily
, SLOT(abort()));
153 daily
->setProxy(proxy());
154 if(userSettings
->value("offline").toBool())
155 daily
->setCache(userSettings
->value("cachepath", QDir::tempPath()).toString());
156 qDebug() << "downloading build info";
157 daily
->setFile(&buildInfo
);
158 daily
->getFile(QUrl(devices
->value("server_conf_url").toString()));
162 void RbUtilQt::downloadDone(bool error
)
165 qDebug() << "network error:" << daily
->error();
168 qDebug() << "network status:" << daily
->error();
171 QSettings
info(buildInfo
.fileName(), QSettings::IniFormat
, this);
173 versmap
.insert("arch_rev", info
.value("dailies/rev").toString());
174 versmap
.insert("arch_date", info
.value("dailies/date").toString());
176 bleeding
= new HttpGet(this);
177 connect(bleeding
, SIGNAL(done(bool)), this, SLOT(downloadBleedingDone(bool)));
178 connect(bleeding
, SIGNAL(requestFinished(int, bool)), this, SLOT(downloadDone(int, bool)));
179 connect(qApp
, SIGNAL(lastWindowClosed()), daily
, SLOT(abort()));
180 bleeding
->setProxy(proxy());
181 if(userSettings
->value("offline").toBool())
182 bleeding
->setCache(userSettings
->value("cachepath", QDir::tempPath()).toString());
183 bleeding
->setFile(&bleedingInfo
);
184 bleeding
->getFile(QUrl(devices
->value("bleeding_info").toString()));
186 if(chkConfig(false)) {
187 QApplication::processEvents();
188 QMessageBox::critical(this, tr("Configuration error"),
189 tr("Your configuration is invalid. This is most likely due "
190 "to a new installation of Rockbox Utility or a changed device "
191 "path. The configuation dialog will now open to allow you "
192 "correcting 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
;
211 void RbUtilQt::downloadDone(int id
, bool error
)
214 errorString
= tr("Network error: %1. Please check your network and proxy settings.")
215 .arg(daily
->errorString());
217 QMessageBox::about(this, "Network Error", errorString
);
219 qDebug() << "downloadDone:" << id
<< error
;
223 void RbUtilQt::about()
225 QDialog
*window
= new QDialog(this);
227 about
.setupUi(window
);
228 window
->setModal(true);
230 QFile
licence(":/docs/gpl-2.0.html");
231 licence
.open(QIODevice::ReadOnly
);
232 QTextStream
c(&licence
);
233 QString cline
= c
.readAll();
234 about
.browserLicense
->insertHtml(cline
);
235 about
.browserLicense
->moveCursor(QTextCursor::Start
, QTextCursor::MoveAnchor
);
236 QFile
credits(":/docs/CREDITS");
237 credits
.open(QIODevice::ReadOnly
);
238 QTextStream
r(&credits
);
239 QString rline
= r
.readAll();
240 about
.browserCredits
->insertPlainText(rline
);
241 about
.browserCredits
->moveCursor(QTextCursor::Start
, QTextCursor::MoveAnchor
);
242 QString title
= QString("<b>The Rockbox Utility</b><br/>Version %1").arg(VERSION
);
243 about
.labelTitle
->setText(title
);
244 about
.labelHomepage
->setText("<a href='http://www.rockbox.org'>http://www.rockbox.org</a>");
251 void RbUtilQt::help()
253 QUrl
helpurl("http://www.rockbox.org/wiki/RockboxUtilityQt");
254 QDesktopServices::openUrl(helpurl
);
258 void RbUtilQt::configDialog()
260 Config
*cw
= new Config(this);
261 cw
->setUserSettings(userSettings
);
262 cw
->setDevices(devices
);
264 connect(cw
, SIGNAL(settingsUpdated()), this, SLOT(downloadInfo()));
265 connect(cw
, SIGNAL(settingsUpdated()), this, SLOT(updateSettings()));
269 void RbUtilQt::updateSettings()
271 qDebug() << "updateSettings()";
277 void RbUtilQt::updateDevice()
279 platform
= userSettings
->value("platform").toString();
281 devices
->beginGroup(platform
);
282 if(devices
->value("needsbootloader", "") == "no") {
283 ui
.buttonBootloader
->setEnabled(false);
284 ui
.buttonRemoveBootloader
->setEnabled(false);
285 ui
.labelBootloader
->setEnabled(false);
286 ui
.labelRemoveBootloader
->setEnabled(false);
289 ui
.buttonBootloader
->setEnabled(true);
290 ui
.labelBootloader
->setEnabled(true);
291 if(devices
->value("bootloadermethod") == "fwpatcher") {
292 ui
.labelRemoveBootloader
->setEnabled(false);
293 ui
.buttonRemoveBootloader
->setEnabled(false);
296 ui
.labelRemoveBootloader
->setEnabled(true);
297 ui
.buttonRemoveBootloader
->setEnabled(true);
301 // displayed device info
302 platform
= userSettings
->value("platform").toString();
303 QString mountpoint
= userSettings
->value("mountpoint").toString();
304 devices
->beginGroup(platform
);
305 QString brand
= devices
->value("brand").toString();
306 QString name
= devices
->value("name").toString();
308 if(name
.isEmpty()) name
= "<none>";
309 if(mountpoint
.isEmpty()) mountpoint
= "<invalid>";
310 ui
.labelDevice
->setText(tr("<b>%1 %2</b> at <b>%3</b>")
311 .arg(brand
, name
, mountpoint
));
315 void RbUtilQt::updateManual()
317 if(userSettings
->value("platform").toString() != "")
319 devices
->beginGroup(userSettings
->value("platform").toString());
321 manual
= devices
->value("manualname", "").toString();
324 manual
= "rockbox-" + devices
->value("platform").toString();
327 pdfmanual
= devices
->value("manual_url").toString() + "/" + manual
+ ".pdf";
329 htmlmanual
= devices
->value("manual_url").toString() + "/" + manual
+ "/rockbox-build.html";
330 ui
.labelPdfManual
->setText(tr("<a href='%1'>PDF Manual</a>")
332 ui
.labelHtmlManual
->setText(tr("<a href='%1'>HTML Manual (opens in browser)</a>")
336 ui
.labelPdfManual
->setText(tr("Select a device for a link to the correct manual"));
337 ui
.labelHtmlManual
->setText(tr("<a href='%1'>Manual Overview</a>")
338 .arg("http://www.rockbox.org/manual.shtml"));
343 void RbUtilQt::completeInstall()
345 if(chkConfig(true)) return;
346 if(QMessageBox::question(this, tr("Confirm Installation"),
347 tr("Do you really want to make a complete Installation?"),
348 QMessageBox::Yes
| QMessageBox::No
) != QMessageBox::Yes
) return;
351 logger
= new ProgressLoggerGui(this);
354 if(smallInstallInner())
360 if(!installFontsAuto())
364 // wait for installation finished
366 QApplication::processEvents();
376 if(!installDoomAuto())
380 // wait for installation finished
382 QApplication::processEvents();
389 // it has its own logger window,so close our.
395 void RbUtilQt::smallInstall()
397 if(chkConfig(true)) return;
398 if(QMessageBox::question(this, tr("Confirm Installation"),
399 tr("Do you really want to make a small Installation?"),
400 QMessageBox::Yes
| QMessageBox::No
) != QMessageBox::Yes
) return;
403 logger
= new ProgressLoggerGui(this);
409 bool RbUtilQt::smallInstallInner()
411 QString mountpoint
= userSettings
->value("mountpoint").toString();
412 // show dialog with error if mount point is wrong
413 if(!QFileInfo(mountpoint
).isDir()) {
414 logger
->addItem(tr("Mount point is wrong!"),LOGERROR
);
419 devices
->beginGroup(userSettings
->value("platform").toString());
420 if(devices
->value("needsbootloader", "") == "yes") {
423 if(!installBootloaderAuto())
427 // wait for boot loader installation finished
429 QApplication::processEvents();
431 if(m_error
) return true;
443 // wait for installation finished
445 QApplication::processEvents();
451 void RbUtilQt::installdone(bool error
)
453 qDebug() << "install done";
458 void RbUtilQt::installBtn()
460 if(chkConfig(true)) return;
464 bool RbUtilQt::installAuto()
466 QString file
= QString("%1%2/rockbox.zip")
467 .arg(devices
->value("bleeding_url").toString(),
468 userSettings
->value("platform").toString());
471 QSettings
info(buildInfo
.fileName(), QSettings::IniFormat
, this);
474 devices
->beginGroup(platform
);
475 QString released
= devices
->value("released").toString();
477 if(released
== "yes") {
478 // only set the keys if needed -- querying will yield an empty string
480 versmap
.insert("rel_rev", devices
->value("last_release").toString());
481 versmap
.insert("rel_date", ""); // FIXME: provide the release timestamp
484 QString myversion
= "r" + versmap
.value("bleed_rev");
486 ZipInstaller
* installer
= new ZipInstaller(this);
487 installer
->setUrl(file
);
488 installer
->setProxy(proxy());
489 installer
->setLogSection("Rockbox (Base)");
490 installer
->setLogVersion(myversion
);
491 if(!userSettings
->value("cachedisable").toBool())
492 installer
->setCache(userSettings
->value("cachepath", QDir::tempPath()).toString());
493 installer
->setMountPoint(userSettings
->value("mountpoint").toString());
494 installer
->install(logger
);
496 connect(installer
, SIGNAL(done(bool)), this, SLOT(installdone(bool)));
501 void RbUtilQt::install()
503 Install
*installWindow
= new Install(this);
504 installWindow
->setUserSettings(userSettings
);
505 installWindow
->setDeviceSettings(devices
);
506 installWindow
->setProxy(proxy());
509 QSettings
info(buildInfo
.fileName(), QSettings::IniFormat
, this);
512 devices
->beginGroup(platform
);
513 QString released
= devices
->value("released").toString();
515 if(released
== "yes") {
516 // only set the keys if needed -- querying will yield an empty string
518 versmap
.insert("rel_rev", devices
->value("last_release").toString());
519 versmap
.insert("rel_date", ""); // FIXME: provide the release timestamp
521 installWindow
->setVersionStrings(versmap
);
523 installWindow
->show();
526 bool RbUtilQt::installBootloaderAuto()
529 connect(blinstaller
,SIGNAL(done(bool)),this,SLOT(installdone(bool)));
533 void RbUtilQt::installBootloaderBtn()
535 if(chkConfig(true)) return;
536 if(QMessageBox::question(this, tr("Confirm Installation"),
537 tr("Do you really want to install the Bootloader?"),
538 QMessageBox::Yes
| QMessageBox::No
) != QMessageBox::Yes
) return;
541 logger
= new ProgressLoggerGui(this);
547 void RbUtilQt::installBootloader()
549 QString platform
= userSettings
->value("platform").toString();
552 blinstaller
= new BootloaderInstaller(this);
554 blinstaller
->setMountPoint(userSettings
->value("mountpoint").toString());
556 blinstaller
->setProxy(proxy());
557 blinstaller
->setDevice(platform
);
558 blinstaller
->setBootloaderMethod(devices
->value(platform
+ "/bootloadermethod").toString());
559 blinstaller
->setBootloaderName(devices
->value(platform
+ "/bootloadername").toString());
560 blinstaller
->setBootloaderBaseUrl(devices
->value("bootloader_url").toString());
561 blinstaller
->setBootloaderInfoUrl(devices
->value("bootloader_info_url").toString());
562 if(!blinstaller
->downloadInfo())
564 logger
->addItem(tr("Could not get the bootloader info file!"),LOGERROR
);
570 if(blinstaller
->uptodate())
572 int ret
= QMessageBox::question(this, tr("Bootloader Installation"),
573 tr("It seem your Bootloader is already up to date.\n"
574 "Do really want to install it?"),
575 QMessageBox::Ok
| QMessageBox::Ignore
|QMessageBox::Cancel
,
576 QMessageBox::Cancel
);
577 if(ret
== QMessageBox::Cancel
)
579 logger
->addItem(tr("Bootloader installation canceled!"),LOGERROR
);
584 else if(ret
== QMessageBox::Ignore
)
586 logger
->addItem(tr("Bootloader installation skipped!"),LOGERROR
);
593 // if fwpatcher , ask for extra file
595 if(devices
->value(platform
+ "/bootloadermethod").toString() == "fwpatcher")
597 BrowseOF
ofbrowser(this);
598 ofbrowser
.setFile(userSettings
->value("ofpath").toString());
599 if(ofbrowser
.exec() == QDialog::Accepted
)
601 offirmware
= ofbrowser
.getFile();
602 qDebug() << offirmware
;
603 if(!QFileInfo(offirmware
).exists())
605 logger
->addItem(tr("Original Firmware Path is wrong!"),LOGERROR
);
612 userSettings
->setValue("ofpath",offirmware
);
613 userSettings
->sync();
618 logger
->addItem(tr("Original Firmware selection Canceled!"),LOGERROR
);
624 blinstaller
->setOrigFirmwarePath(offirmware
);
626 blinstaller
->install(logger
);
629 void RbUtilQt::installFontsBtn()
631 if(chkConfig(true)) return;
632 if(QMessageBox::question(this, tr("Confirm Installation"),
633 tr("Do you really want to install the fonts package?"),
634 QMessageBox::Yes
| QMessageBox::No
) != QMessageBox::Yes
) return;
636 logger
= new ProgressLoggerGui(this);
641 bool RbUtilQt::installFontsAuto()
644 connect(installer
, SIGNAL(done(bool)), this, SLOT(installdone(bool)));
648 void RbUtilQt::installFonts()
650 // create zip installer
651 installer
= new ZipInstaller(this);
653 installer
->setUrl(devices
->value("font_url").toString());
654 installer
->setProxy(proxy());
655 installer
->setLogSection("Fonts");
656 installer
->setLogVersion(versmap
.value("arch_date"));
657 installer
->setMountPoint(userSettings
->value("mountpoint").toString());
658 if(!userSettings
->value("cachedisable").toBool())
659 installer
->setCache(userSettings
->value("cachepath", QDir::tempPath()).toString());
660 installer
->install(logger
);
664 void RbUtilQt::installVoice()
666 if(chkConfig(true)) return;
667 if(QMessageBox::question(this, tr("Confirm Installation"),
668 tr("Do you really want to install the voice file?"),
669 QMessageBox::Yes
| QMessageBox::No
) != QMessageBox::Yes
) return;
671 logger
= new ProgressLoggerGui(this);
674 // create zip installer
675 installer
= new ZipInstaller(this);
676 installer
->setUnzip(false);
678 QString voiceurl
= devices
->value("voice_url").toString() + "/" +
679 userSettings
->value("platform").toString() + "-" +
680 versmap
.value("arch_date") + "-english.voice";
681 qDebug() << voiceurl
;
683 installer
->setProxy(proxy());
684 installer
->setUrl(voiceurl
);
685 installer
->setLogSection("Voice");
686 installer
->setLogVersion(versmap
.value("arch_date"));
687 installer
->setMountPoint(userSettings
->value("mountpoint").toString());
688 installer
->setTarget("/.rockbox/langs/english.voice");
689 if(!userSettings
->value("cachedisable").toBool())
690 installer
->setCache(userSettings
->value("cachepath", QDir::tempPath()).toString());
691 installer
->install(logger
);
693 //connect(installer, SIGNAL(done(bool)), this, SLOT(done(bool)));
696 void RbUtilQt::installDoomBtn()
698 if(chkConfig(true)) return;
700 QMessageBox::critical(this, tr("Error"), tr("Your device doesn't have a doom plugin. Aborting."));
704 if(QMessageBox::question(this, tr("Confirm Installation"),
705 tr("Do you really want to install the game addon files?"),
706 QMessageBox::Yes
| QMessageBox::No
) != QMessageBox::Yes
) return;
708 logger
= new ProgressLoggerGui(this);
713 bool RbUtilQt::installDoomAuto()
716 connect(installer
, SIGNAL(done(bool)), this, SLOT(installdone(bool)));
720 bool RbUtilQt::hasDoom()
722 QFile
doomrock(userSettings
->value("mountpoint").toString()+"/.rockbox/rocks/games/doom.rock");
723 return doomrock
.exists();
726 void RbUtilQt::installDoom()
728 // create zip installer
729 installer
= new ZipInstaller(this);
731 installer
->setUrl(devices
->value("doom_url").toString());
732 installer
->setProxy(proxy());
733 installer
->setLogSection("Game Addons");
734 installer
->setLogVersion(versmap
.value("arch_date"));
735 installer
->setMountPoint(userSettings
->value("mountpoint").toString());
736 if(!userSettings
->value("cachedisable").toBool())
737 installer
->setCache(userSettings
->value("cachepath", QDir::tempPath()).toString());
738 installer
->install(logger
);
743 void RbUtilQt::installThemes()
745 if(chkConfig(true)) return;
746 ThemesInstallWindow
* tw
= new ThemesInstallWindow(this);
747 tw
->setDeviceSettings(devices
);
748 tw
->setUserSettings(userSettings
);
749 tw
->setProxy(proxy());
755 void RbUtilQt::createTalkFiles(void)
757 if(chkConfig(true)) return;
758 InstallTalkWindow
*installWindow
= new InstallTalkWindow(this);
759 installWindow
->setUserSettings(userSettings
);
760 installWindow
->setDeviceSettings(devices
);
761 installWindow
->show();
765 void RbUtilQt::uninstall(void)
767 if(chkConfig(true)) return;
768 UninstallWindow
*uninstallWindow
= new UninstallWindow(this);
769 uninstallWindow
->setUserSettings(userSettings
);
770 uninstallWindow
->setDeviceSettings(devices
);
771 uninstallWindow
->show();
774 void RbUtilQt::uninstallBootloader(void)
776 if(chkConfig(true)) return;
777 if(QMessageBox::question(this, tr("Confirm Uninstallation"),
778 tr("Do you really want to uninstall the Bootloader?"),
779 QMessageBox::Yes
| QMessageBox::No
) != QMessageBox::Yes
) return;
781 ProgressLoggerGui
* logger
= new ProgressLoggerGui(this);
784 QString plattform
= userSettings
->value("platform").toString();
785 BootloaderInstaller
blinstaller(this);
786 blinstaller
.setProxy(proxy());
787 blinstaller
.setMountPoint(userSettings
->value("mountpoint").toString());
788 blinstaller
.setDevice(userSettings
->value("platform").toString());
789 blinstaller
.setBootloaderMethod(devices
->value(plattform
+ "/bootloadermethod").toString());
790 blinstaller
.setBootloaderName(devices
->value(plattform
+ "/bootloadername").toString());
791 blinstaller
.setBootloaderBaseUrl(devices
->value("bootloader_url").toString());
792 blinstaller
.setBootloaderInfoUrl(devices
->value("bootloader_info_url").toString());
793 if(!blinstaller
.downloadInfo())
795 logger
->addItem(tr("Could not get the bootloader info file!"),LOGERROR
);
800 blinstaller
.uninstall(logger
);
805 void RbUtilQt::downloadManual(void)
807 if(chkConfig(true)) return;
808 if(QMessageBox::question(this, tr("Confirm download"),
809 tr("Do you really want to download the manual? The manual will be saved "
810 "to the root folder of your player."),
811 QMessageBox::Yes
| QMessageBox::No
) != QMessageBox::Yes
)
815 QSettings
info(buildInfo
.fileName(), QSettings::IniFormat
, this);
818 devices
->beginGroup(userSettings
->value("platform").toString());
820 manual
= devices
->value("manualname", "rockbox-" + devices
->value("platform").toString()).toString();
823 QString date
= (info
.value("dailies/date").toString());
828 if(ui
.radioPdf
->isChecked()) {
829 target
= "/" + manual
+ ".pdf";
830 section
= "Manual (PDF)";
833 target
= "/" + manual
+ "-" + date
+ "-html.zip";
834 section
= "Manual (HTML)";
836 manualurl
= devices
->value("manual_url").toString() + "/" + target
;
837 qDebug() << "manualurl =" << manualurl
;
839 ProgressLoggerGui
* logger
= new ProgressLoggerGui(this);
841 installer
= new ZipInstaller(this);
842 installer
->setMountPoint(userSettings
->value("mountpoint").toString());
843 if(!userSettings
->value("cachedisable").toBool())
844 installer
->setCache(userSettings
->value("cachepath", QDir::tempPath()).toString());
845 installer
->setProxy(proxy());
846 installer
->setLogSection(section
);
847 installer
->setLogVersion(date
);
848 installer
->setUrl(manualurl
);
849 installer
->setUnzip(false);
850 installer
->setTarget(target
);
851 installer
->install(logger
);
855 void RbUtilQt::installPortable(void)
857 if(QMessageBox::question(this, tr("Confirm installation"),
858 tr("Do you really want to install Rockbox Utility to your player? "
859 "After installation you can run it from the players hard drive."),
860 QMessageBox::Yes
| QMessageBox::No
) != QMessageBox::Yes
)
863 ProgressLoggerGui
* logger
= new ProgressLoggerGui(this);
864 logger
->setProgressMax(0);
865 logger
->setProgressValue(0);
867 logger
->addItem(tr("Installing Rockbox Utility"), LOGINFO
);
870 if(!QFileInfo(userSettings
->value("mountpoint").toString()).isDir()) {
871 logger
->addItem(tr("Mount point is wrong!"),LOGERROR
);
876 // remove old files first.
877 QFile::remove(userSettings
->value("mountpoint").toString() + "/RockboxUtility.exe");
878 QFile::remove(userSettings
->value("mountpoint").toString() + "/RockboxUtility.ini");
879 // copy currently running binary and currently used settings file
880 if(!QFile::copy(qApp
->applicationFilePath(), userSettings
->value("mountpoint").toString() + "/RockboxUtility.exe")) {
881 logger
->addItem(tr("Error installing Rockbox Utility"), LOGERROR
);
885 logger
->addItem(tr("Installing user configuration"), LOGINFO
);
886 if(!QFile::copy(userSettings
->fileName(), userSettings
->value("mountpoint").toString() + "/RockboxUtility.ini")) {
887 logger
->addItem(tr("Error installing user configuration"), LOGERROR
);
891 logger
->addItem(tr("Successfully installed Rockbox Utility."), LOGOK
);
893 logger
->setProgressMax(1);
894 logger
->setProgressValue(1);
899 void RbUtilQt::updateInfo()
901 qDebug() << "RbUtilQt::updateInfo()";
903 QSettings
log(userSettings
->value("mountpoint").toString() + "/.rockbox/rbutil.log", QSettings::IniFormat
, this);
904 QStringList groups
= log
.childGroups();
905 QList
<QTreeWidgetItem
*> items
;
906 QTreeWidgetItem
*w
, *w2
;
910 // remove old list entries (if any)
911 int l
= ui
.treeInfo
->topLevelItemCount();
914 m
= ui
.treeInfo
->takeTopLevelItem(l
);
915 // delete childs (single level deep, no recursion here)
916 int n
= m
->childCount();
920 // get and populate new items
921 for(int a
= 0; a
< groups
.size(); a
++) {
922 log
.beginGroup(groups
.at(a
));
923 QStringList keys
= log
.allKeys();
924 w
= new QTreeWidgetItem
;
925 w
->setFlags(Qt::ItemIsEnabled
);
926 w
->setText(0, groups
.at(a
));
928 // get minimum and maximum version information so we can hilight old files
929 min
= max
= log
.value(keys
.at(0)).toString();
930 for(int b
= 0; b
< keys
.size(); b
++) {
931 if(log
.value(keys
.at(b
)).toString() > max
)
932 max
= log
.value(keys
.at(b
)).toString();
933 if(log
.value(keys
.at(b
)).toString() < min
)
934 min
= log
.value(keys
.at(b
)).toString();
937 for(int b
= 0; b
< keys
.size(); b
++) {
939 file
= userSettings
->value("mountpoint").toString() + "/" + keys
.at(b
);
940 if(QFileInfo(file
).isDir())
942 w2
= new QTreeWidgetItem(w
, QStringList() << "/"
943 + keys
.at(b
) << log
.value(keys
.at(b
)).toString());
944 if(log
.value(keys
.at(b
)).toString() != max
) {
945 w2
->setForeground(0, QBrush(QColor(255, 0, 0)));
946 w2
->setForeground(1, QBrush(QColor(255, 0, 0)));
953 w
->setData(1, Qt::DisplayRole
, QString("%1 / %2").arg(min
, max
));
955 w
->setData(1, Qt::DisplayRole
, max
);
957 ui
.treeInfo
->insertTopLevelItems(0, items
);
958 ui
.treeInfo
->resizeColumnToContents(0);
962 QUrl
RbUtilQt::proxy()
964 if(userSettings
->value("proxytype", "system").toString() == "manual")
965 return QUrl(userSettings
->value("proxy").toString());
966 #if defined(Q_OS_LINUX)
967 else if(userSettings
->value("proxytype", "system").toString() == "system")
968 return QUrl(getenv("http_proxy"));
970 #if defined(Q_OS_WIN32)
972 wchar_t proxyval
[80];
976 ret
= RegOpenKeyEx(HKEY_CURRENT_USER
, _TEXT("Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings"),
977 0, KEY_QUERY_VALUE
, &hk
);
978 if(ret
!= ERROR_SUCCESS
) return QUrl("");
980 ret
= RegQueryValueEx(hk
, _TEXT("ProxyServer"), NULL
, NULL
, (LPBYTE
)proxyval
, &buflen
);
981 if(ret
!= ERROR_SUCCESS
) return QUrl("");
984 qDebug() << QString::fromWCharArray(proxyval
);
985 return QUrl("http://" + QString::fromWCharArray(proxyval
));
992 bool RbUtilQt::chkConfig(bool warn
)
995 if(userSettings
->value("platform").toString().isEmpty()
996 || userSettings
->value("mountpoint").toString().isEmpty()
997 || !QFileInfo(userSettings
->value("mountpoint").toString()).isWritable()) {
1000 if(warn
) QMessageBox::critical(this, tr("Configuration error"),
1001 tr("Your configuration is invalid. Please go to the configuration "
1002 "dialog and make sure the selected values are correct."));