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()));
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::updateTabs(int count
)
133 void RbUtilQt::downloadInfo()
135 // try to get the current build information
136 daily
= new HttpGet(this);
137 connect(daily
, SIGNAL(done(bool)), this, SLOT(downloadDone(bool)));
138 connect(daily
, SIGNAL(requestFinished(int, bool)), this, SLOT(downloadDone(int, bool)));
139 connect(qApp
, SIGNAL(lastWindowClosed()), daily
, SLOT(abort()));
140 daily
->setProxy(proxy());
141 if(userSettings
->value("offline").toBool())
142 daily
->setCache(userSettings
->value("cachepath", QDir::tempPath()).toString());
143 qDebug() << "downloading build info";
144 daily
->setFile(&buildInfo
);
145 daily
->getFile(QUrl(devices
->value("server_conf_url").toString()));
149 void RbUtilQt::downloadDone(bool error
)
152 qDebug() << "network error:" << daily
->error();
155 qDebug() << "network status:" << daily
->error();
158 QSettings
info(buildInfo
.fileName(), QSettings::IniFormat
, this);
160 versmap
.insert("arch_rev", info
.value("dailies/rev").toString());
161 versmap
.insert("arch_date", info
.value("dailies/date").toString());
163 bleeding
= new HttpGet(this);
164 connect(bleeding
, SIGNAL(done(bool)), this, SLOT(downloadBleedingDone(bool)));
165 connect(bleeding
, SIGNAL(requestFinished(int, bool)), this, SLOT(downloadDone(int, bool)));
166 connect(qApp
, SIGNAL(lastWindowClosed()), daily
, SLOT(abort()));
167 bleeding
->setProxy(proxy());
168 if(userSettings
->value("offline").toBool())
169 bleeding
->setCache(userSettings
->value("cachepath", QDir::tempPath()).toString());
170 bleeding
->setFile(&bleedingInfo
);
171 bleeding
->getFile(QUrl(devices
->value("bleeding_info").toString()));
173 if(chkConfig(false)) {
174 QApplication::processEvents();
175 QMessageBox::critical(this, tr("Configuration error"),
176 tr("Your configuration is invalid. This is most likely due "
177 "to a new installation of Rockbox Utility or a changed device "
178 "path. The configuation dialog will now open to allow you "
179 "correcting the problem."));
185 void RbUtilQt::downloadBleedingDone(bool error
)
187 if(error
) qDebug() << "network error:" << bleeding
->error();
190 QSettings
info(bleedingInfo
.fileName(), QSettings::IniFormat
, this);
191 bleedingInfo
.close();
192 versmap
.insert("bleed_rev", info
.value("bleeding/rev").toString());
193 versmap
.insert("bleed_date", info
.value("bleeding/timestamp").toString());
194 qDebug() << "versmap =" << versmap
;
198 void RbUtilQt::downloadDone(int id
, bool error
)
201 errorString
= tr("Network error: %1. Please check your network and proxy settings.")
202 .arg(daily
->errorString());
204 QMessageBox::about(this, "Network Error", errorString
);
206 qDebug() << "downloadDone:" << id
<< error
;
210 void RbUtilQt::about()
212 QDialog
*window
= new QDialog(this);
214 about
.setupUi(window
);
215 window
->setModal(true);
217 QFile
licence(":/docs/gpl-2.0.html");
218 licence
.open(QIODevice::ReadOnly
);
219 QTextStream
c(&licence
);
220 QString cline
= c
.readAll();
221 about
.browserLicense
->insertHtml(cline
);
222 about
.browserLicense
->moveCursor(QTextCursor::Start
, QTextCursor::MoveAnchor
);
223 QFile
credits(":/docs/CREDITS");
224 credits
.open(QIODevice::ReadOnly
);
225 QTextStream
r(&credits
);
226 QString rline
= r
.readAll();
227 about
.browserCredits
->insertPlainText(rline
);
228 about
.browserCredits
->moveCursor(QTextCursor::Start
, QTextCursor::MoveAnchor
);
229 QString title
= QString("<b>The Rockbox Utility</b><br/>Version %1").arg(VERSION
);
230 about
.labelTitle
->setText(title
);
231 about
.labelHomepage
->setText("<a href='http://www.rockbox.org'>http://www.rockbox.org</a>");
238 void RbUtilQt::help()
240 QUrl
helpurl("http://www.rockbox.org/wiki/RockboxUtilityQt");
241 QDesktopServices::openUrl(helpurl
);
245 void RbUtilQt::configDialog()
247 Config
*cw
= new Config(this);
248 cw
->setUserSettings(userSettings
);
249 cw
->setDevices(devices
);
251 connect(cw
, SIGNAL(settingsUpdated()), this, SLOT(downloadInfo()));
252 connect(cw
, SIGNAL(settingsUpdated()), this, SLOT(updateSettings()));
256 void RbUtilQt::updateSettings()
258 qDebug() << "updateSettings()";
264 void RbUtilQt::updateDevice()
266 platform
= userSettings
->value("platform").toString();
268 devices
->beginGroup(platform
);
269 if(devices
->value("needsbootloader", "") == "no") {
270 ui
.buttonBootloader
->setEnabled(false);
271 ui
.buttonRemoveBootloader
->setEnabled(false);
272 ui
.labelBootloader
->setEnabled(false);
273 ui
.labelRemoveBootloader
->setEnabled(false);
276 ui
.buttonBootloader
->setEnabled(true);
277 ui
.labelBootloader
->setEnabled(true);
278 if(devices
->value("bootloadermethod") == "fwpatcher") {
279 ui
.labelRemoveBootloader
->setEnabled(false);
280 ui
.buttonRemoveBootloader
->setEnabled(false);
283 ui
.labelRemoveBootloader
->setEnabled(true);
284 ui
.buttonRemoveBootloader
->setEnabled(true);
288 // displayed device info
289 platform
= userSettings
->value("platform").toString();
290 QString mountpoint
= userSettings
->value("mountpoint").toString();
291 devices
->beginGroup(platform
);
292 QString brand
= devices
->value("brand").toString();
293 QString name
= devices
->value("name").toString();
295 if(name
.isEmpty()) name
= "<none>";
296 if(mountpoint
.isEmpty()) mountpoint
= "<invalid>";
297 ui
.labelDevice
->setText(tr("<b>%1 %2</b> at <b>%3</b>")
298 .arg(brand
, name
, mountpoint
));
302 void RbUtilQt::updateManual()
304 if(userSettings
->value("platform").toString() != "")
306 devices
->beginGroup(userSettings
->value("platform").toString());
308 manual
= devices
->value("manualname", "").toString();
311 manual
= "rockbox-" + devices
->value("platform").toString();
314 pdfmanual
= devices
->value("manual_url").toString() + "/" + manual
+ ".pdf";
316 htmlmanual
= devices
->value("manual_url").toString() + "/" + 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
= userSettings
->value("mountpoint").toString();
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 devices
->beginGroup(userSettings
->value("platform").toString());
407 if(devices
->value("needsbootloader", "") == "yes") {
410 if(!installBootloaderAuto())
414 // wait for boot loader installation finished
416 QApplication::processEvents();
418 if(m_error
) return true;
430 // wait for installation finished
432 QApplication::processEvents();
438 void RbUtilQt::installdone(bool error
)
440 qDebug() << "install done";
445 void RbUtilQt::installBtn()
447 if(chkConfig(true)) return;
451 bool RbUtilQt::installAuto()
453 QString file
= QString("%1%2/rockbox.zip")
454 .arg(devices
->value("bleeding_url").toString(),
455 userSettings
->value("platform").toString());
458 QSettings
info(buildInfo
.fileName(), QSettings::IniFormat
, this);
461 devices
->beginGroup(platform
);
462 QString released
= devices
->value("released").toString();
464 if(released
== "yes") {
465 // only set the keys if needed -- querying will yield an empty string
467 versmap
.insert("rel_rev", devices
->value("last_release").toString());
468 versmap
.insert("rel_date", ""); // FIXME: provide the release timestamp
471 QString myversion
= "r" + versmap
.value("bleed_rev");
473 ZipInstaller
* installer
= new ZipInstaller(this);
474 installer
->setUrl(file
);
475 installer
->setProxy(proxy());
476 installer
->setLogSection("Rockbox (Base)");
477 installer
->setLogVersion(myversion
);
478 if(!userSettings
->value("cachedisable").toBool())
479 installer
->setCache(userSettings
->value("cachepath", QDir::tempPath()).toString());
480 installer
->setMountPoint(userSettings
->value("mountpoint").toString());
481 installer
->install(logger
);
483 connect(installer
, SIGNAL(done(bool)), this, SLOT(installdone(bool)));
488 void RbUtilQt::install()
490 Install
*installWindow
= new Install(this);
491 installWindow
->setUserSettings(userSettings
);
492 installWindow
->setDeviceSettings(devices
);
493 installWindow
->setProxy(proxy());
496 QSettings
info(buildInfo
.fileName(), QSettings::IniFormat
, this);
499 devices
->beginGroup(platform
);
500 QString released
= devices
->value("released").toString();
502 if(released
== "yes") {
503 // only set the keys if needed -- querying will yield an empty string
505 versmap
.insert("rel_rev", devices
->value("last_release").toString());
506 versmap
.insert("rel_date", ""); // FIXME: provide the release timestamp
508 installWindow
->setVersionStrings(versmap
);
510 installWindow
->show();
513 bool RbUtilQt::installBootloaderAuto()
516 connect(blinstaller
,SIGNAL(done(bool)),this,SLOT(installdone(bool)));
520 void RbUtilQt::installBootloaderBtn()
522 if(chkConfig(true)) return;
523 if(QMessageBox::question(this, tr("Confirm Installation"),
524 tr("Do you really want to install the Bootloader?"),
525 QMessageBox::Yes
| QMessageBox::No
) != QMessageBox::Yes
) return;
528 logger
= new ProgressLoggerGui(this);
534 void RbUtilQt::installBootloader()
536 QString platform
= userSettings
->value("platform").toString();
539 blinstaller
= new BootloaderInstaller(this);
541 blinstaller
->setMountPoint(userSettings
->value("mountpoint").toString());
543 blinstaller
->setProxy(proxy());
544 blinstaller
->setDevice(platform
);
545 blinstaller
->setBootloaderMethod(devices
->value(platform
+ "/bootloadermethod").toString());
546 blinstaller
->setBootloaderName(devices
->value(platform
+ "/bootloadername").toString());
547 blinstaller
->setBootloaderBaseUrl(devices
->value("bootloader_url").toString());
548 blinstaller
->setBootloaderInfoUrl(devices
->value("bootloader_info_url").toString());
549 if(!blinstaller
->downloadInfo())
551 logger
->addItem(tr("Could not get the bootloader info file!"),LOGERROR
);
557 if(blinstaller
->uptodate())
559 int ret
= QMessageBox::question(this, tr("Bootloader Installation"),
560 tr("It seem your Bootloader is already up to date.\n"
561 "Do really want to install it?"),
562 QMessageBox::Ok
| QMessageBox::Ignore
|QMessageBox::Cancel
,
563 QMessageBox::Cancel
);
564 if(ret
== QMessageBox::Cancel
)
566 logger
->addItem(tr("Bootloader installation canceled!"),LOGERROR
);
571 else if(ret
== QMessageBox::Ignore
)
573 logger
->addItem(tr("Bootloader installation skipped!"),LOGERROR
);
580 // if fwpatcher , ask for extra file
582 if(devices
->value(platform
+ "/bootloadermethod").toString() == "fwpatcher")
584 BrowseOF
ofbrowser(this);
585 ofbrowser
.setFile(userSettings
->value("ofpath").toString());
586 if(ofbrowser
.exec() == QDialog::Accepted
)
588 offirmware
= ofbrowser
.getFile();
589 qDebug() << offirmware
;
590 if(!QFileInfo(offirmware
).exists())
592 logger
->addItem(tr("Original Firmware Path is wrong!"),LOGERROR
);
599 userSettings
->setValue("ofpath",offirmware
);
600 userSettings
->sync();
605 logger
->addItem(tr("Original Firmware selection Canceled!"),LOGERROR
);
611 blinstaller
->setOrigFirmwarePath(offirmware
);
613 blinstaller
->install(logger
);
616 void RbUtilQt::installFontsBtn()
618 if(chkConfig(true)) return;
619 if(QMessageBox::question(this, tr("Confirm Installation"),
620 tr("Do you really want to install the fonts package?"),
621 QMessageBox::Yes
| QMessageBox::No
) != QMessageBox::Yes
) return;
623 logger
= new ProgressLoggerGui(this);
628 bool RbUtilQt::installFontsAuto()
631 connect(installer
, SIGNAL(done(bool)), this, SLOT(installdone(bool)));
635 void RbUtilQt::installFonts()
637 // create zip installer
638 installer
= new ZipInstaller(this);
640 installer
->setUrl(devices
->value("font_url").toString());
641 installer
->setProxy(proxy());
642 installer
->setLogSection("Fonts");
643 installer
->setLogVersion(versmap
.value("arch_date"));
644 installer
->setMountPoint(userSettings
->value("mountpoint").toString());
645 if(!userSettings
->value("cachedisable").toBool())
646 installer
->setCache(userSettings
->value("cachepath", QDir::tempPath()).toString());
647 installer
->install(logger
);
651 void RbUtilQt::installVoice()
653 if(chkConfig(true)) return;
654 if(QMessageBox::question(this, tr("Confirm Installation"),
655 tr("Do you really want to install the voice file?"),
656 QMessageBox::Yes
| QMessageBox::No
) != QMessageBox::Yes
) return;
658 logger
= new ProgressLoggerGui(this);
661 // create zip installer
662 installer
= new ZipInstaller(this);
663 installer
->setUnzip(false);
665 QString voiceurl
= devices
->value("voice_url").toString() + "/" +
666 userSettings
->value("platform").toString() + "-" +
667 versmap
.value("arch_date") + "-english.voice";
668 qDebug() << voiceurl
;
670 installer
->setProxy(proxy());
671 installer
->setUrl(voiceurl
);
672 installer
->setLogSection("Voice");
673 installer
->setLogVersion(versmap
.value("arch_date"));
674 installer
->setMountPoint(userSettings
->value("mountpoint").toString());
675 installer
->setTarget("/.rockbox/langs/english.voice");
676 if(!userSettings
->value("cachedisable").toBool())
677 installer
->setCache(userSettings
->value("cachepath", QDir::tempPath()).toString());
678 installer
->install(logger
);
680 //connect(installer, SIGNAL(done(bool)), this, SLOT(done(bool)));
683 void RbUtilQt::installDoomBtn()
685 if(chkConfig(true)) return;
687 QMessageBox::critical(this, tr("Error"), tr("Your device doesn't have a doom plugin. Aborting."));
691 if(QMessageBox::question(this, tr("Confirm Installation"),
692 tr("Do you really want to install the game addon files?"),
693 QMessageBox::Yes
| QMessageBox::No
) != QMessageBox::Yes
) return;
695 logger
= new ProgressLoggerGui(this);
700 bool RbUtilQt::installDoomAuto()
703 connect(installer
, SIGNAL(done(bool)), this, SLOT(installdone(bool)));
707 bool RbUtilQt::hasDoom()
709 QFile
doomrock(userSettings
->value("mountpoint").toString()+"/.rockbox/rocks/games/doom.rock");
710 return doomrock
.exists();
713 void RbUtilQt::installDoom()
715 // create zip installer
716 installer
= new ZipInstaller(this);
718 installer
->setUrl(devices
->value("doom_url").toString());
719 installer
->setProxy(proxy());
720 installer
->setLogSection("Game Addons");
721 installer
->setLogVersion(versmap
.value("arch_date"));
722 installer
->setMountPoint(userSettings
->value("mountpoint").toString());
723 if(!userSettings
->value("cachedisable").toBool())
724 installer
->setCache(userSettings
->value("cachepath", QDir::tempPath()).toString());
725 installer
->install(logger
);
730 void RbUtilQt::installThemes()
732 if(chkConfig(true)) return;
733 ThemesInstallWindow
* tw
= new ThemesInstallWindow(this);
734 tw
->setDeviceSettings(devices
);
735 tw
->setUserSettings(userSettings
);
736 tw
->setProxy(proxy());
742 void RbUtilQt::createTalkFiles(void)
744 if(chkConfig(true)) return;
745 InstallTalkWindow
*installWindow
= new InstallTalkWindow(this);
746 installWindow
->setUserSettings(userSettings
);
747 installWindow
->setDeviceSettings(devices
);
748 installWindow
->show();
752 void RbUtilQt::uninstall(void)
754 if(chkConfig(true)) return;
755 UninstallWindow
*uninstallWindow
= new UninstallWindow(this);
756 uninstallWindow
->setUserSettings(userSettings
);
757 uninstallWindow
->setDeviceSettings(devices
);
758 uninstallWindow
->show();
761 void RbUtilQt::uninstallBootloader(void)
763 if(chkConfig(true)) return;
764 if(QMessageBox::question(this, tr("Confirm Uninstallation"),
765 tr("Do you really want to uninstall the Bootloader?"),
766 QMessageBox::Yes
| QMessageBox::No
) != QMessageBox::Yes
) return;
768 ProgressLoggerGui
* logger
= new ProgressLoggerGui(this);
771 QString plattform
= userSettings
->value("platform").toString();
772 BootloaderInstaller
blinstaller(this);
773 blinstaller
.setProxy(proxy());
774 blinstaller
.setMountPoint(userSettings
->value("mountpoint").toString());
775 blinstaller
.setDevice(userSettings
->value("platform").toString());
776 blinstaller
.setBootloaderMethod(devices
->value(plattform
+ "/bootloadermethod").toString());
777 blinstaller
.setBootloaderName(devices
->value(plattform
+ "/bootloadername").toString());
778 blinstaller
.setBootloaderBaseUrl(devices
->value("bootloader_url").toString());
779 blinstaller
.setBootloaderInfoUrl(devices
->value("bootloader_info_url").toString());
780 if(!blinstaller
.downloadInfo())
782 logger
->addItem(tr("Could not get the bootloader info file!"),LOGERROR
);
787 blinstaller
.uninstall(logger
);
792 void RbUtilQt::downloadManual(void)
794 if(chkConfig(true)) return;
795 if(QMessageBox::question(this, tr("Confirm download"),
796 tr("Do you really want to download the manual? The manual will be saved "
797 "to the root folder of your player."),
798 QMessageBox::Yes
| QMessageBox::No
) != QMessageBox::Yes
)
802 QSettings
info(buildInfo
.fileName(), QSettings::IniFormat
, this);
805 devices
->beginGroup(userSettings
->value("platform").toString());
807 manual
= devices
->value("manualname", "rockbox-" + devices
->value("platform").toString()).toString();
810 QString date
= (info
.value("dailies/date").toString());
815 if(ui
.radioPdf
->isChecked()) {
816 target
= "/" + manual
+ ".pdf";
817 section
= "Manual (PDF)";
820 target
= "/" + manual
+ "-" + date
+ "-html.zip";
821 section
= "Manual (HTML)";
823 manualurl
= devices
->value("manual_url").toString() + "/" + target
;
824 qDebug() << "manualurl =" << manualurl
;
826 ProgressLoggerGui
* logger
= new ProgressLoggerGui(this);
828 installer
= new ZipInstaller(this);
829 installer
->setMountPoint(userSettings
->value("mountpoint").toString());
830 if(!userSettings
->value("cachedisable").toBool())
831 installer
->setCache(userSettings
->value("cachepath", QDir::tempPath()).toString());
832 installer
->setProxy(proxy());
833 installer
->setLogSection(section
);
834 installer
->setUrl(manualurl
);
835 installer
->setUnzip(false);
836 installer
->setTarget(target
);
837 installer
->install(logger
);
841 void RbUtilQt::installPortable(void)
843 if(QMessageBox::question(this, tr("Confirm installation"),
844 tr("Do you really want to install Rockbox Utility to your player? "
845 "After installation you can run it from the players hard drive."),
846 QMessageBox::Yes
| QMessageBox::No
) != QMessageBox::Yes
)
849 ProgressLoggerGui
* logger
= new ProgressLoggerGui(this);
851 logger
->addItem(tr("Installing Rockbox Utility"), LOGINFO
);
854 if(!QFileInfo(userSettings
->value("mountpoint").toString()).isDir()) {
855 logger
->addItem(tr("Mount point is wrong!"),LOGERROR
);
860 // remove old files first.
861 QFile::remove(userSettings
->value("mountpoint").toString() + "/RockboxUtility.exe");
862 QFile::remove(userSettings
->value("mountpoint").toString() + "/RockboxUtility.ini");
863 // copy currently running binary and currently used settings file
864 if(!QFile::copy(qApp
->applicationFilePath(), userSettings
->value("mountpoint").toString() + "/RockboxUtility.exe")) {
865 logger
->addItem(tr("Error installing Rockbox Utility"), LOGERROR
);
869 logger
->addItem(tr("Installing user configuration"), LOGINFO
);
870 if(!QFile::copy(userSettings
->fileName(), userSettings
->value("mountpoint").toString() + "/RockboxUtility.ini")) {
871 logger
->addItem(tr("Error installing user configuration"), LOGERROR
);
875 logger
->addItem(tr("Successfully installed Rockbox Utility."), LOGOK
);
881 void RbUtilQt::updateInfo()
883 qDebug() << "RbUtilQt::updateInfo()";
885 QSettings
log(userSettings
->value("mountpoint").toString() + "/.rockbox/rbutil.log", QSettings::IniFormat
, this);
886 QStringList groups
= log
.childGroups();
887 QList
<QTreeWidgetItem
*> items
;
888 QTreeWidgetItem
*w
, *w2
;
892 // remove old list entries (if any)
893 int l
= ui
.treeInfo
->topLevelItemCount();
896 m
= ui
.treeInfo
->takeTopLevelItem(l
);
897 // delete childs (single level deep, no recursion here)
898 int n
= m
->childCount();
902 // get and populate new items
903 for(int a
= 0; a
< groups
.size(); a
++) {
904 log
.beginGroup(groups
.at(a
));
905 QStringList keys
= log
.allKeys();
906 w
= new QTreeWidgetItem
;
907 w
->setFlags(Qt::ItemIsEnabled
);
908 w
->setText(0, groups
.at(a
));
910 // get minimum and maximum version information so we can hilight old files
911 min
= max
= log
.value(keys
.at(0)).toString();
912 for(int b
= 0; b
< keys
.size(); b
++) {
913 if(log
.value(keys
.at(b
)).toString() > max
)
914 max
= log
.value(keys
.at(b
)).toString();
915 if(log
.value(keys
.at(b
)).toString() < min
)
916 min
= log
.value(keys
.at(b
)).toString();
919 for(int b
= 0; b
< keys
.size(); b
++) {
921 file
= userSettings
->value("mountpoint").toString() + "/" + keys
.at(b
);
922 if(QFileInfo(file
).isDir())
924 w2
= new QTreeWidgetItem(w
, QStringList() << "/"
925 + keys
.at(b
) << log
.value(keys
.at(b
)).toString());
926 if(log
.value(keys
.at(b
)).toString() != max
) {
927 w2
->setForeground(0, QBrush(QColor(255, 0, 0)));
928 w2
->setForeground(1, QBrush(QColor(255, 0, 0)));
935 w
->setData(1, Qt::DisplayRole
, QString("%1 / %2").arg(min
, max
));
937 w
->setData(1, Qt::DisplayRole
, max
);
939 ui
.treeInfo
->insertTopLevelItems(0, items
);
940 ui
.treeInfo
->resizeColumnToContents(0);
944 QUrl
RbUtilQt::proxy()
946 if(userSettings
->value("proxytype", "system").toString() == "manual")
947 return QUrl(userSettings
->value("proxy").toString());
948 #if defined(Q_OS_LINUX)
949 else if(userSettings
->value("proxytype", "system").toString() == "system")
950 return QUrl(getenv("http_proxy"));
952 #if defined(Q_OS_WIN32)
954 wchar_t proxyval
[80];
958 ret
= RegOpenKeyEx(HKEY_CURRENT_USER
, _TEXT("Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings"),
959 0, KEY_QUERY_VALUE
, &hk
);
960 if(ret
!= ERROR_SUCCESS
) return QUrl("");
962 ret
= RegQueryValueEx(hk
, _TEXT("ProxyServer"), NULL
, NULL
, (LPBYTE
)proxyval
, &buflen
);
963 if(ret
!= ERROR_SUCCESS
) return QUrl("");
966 qDebug() << QString::fromWCharArray(proxyval
);
967 return QUrl("http://" + QString::fromWCharArray(proxyval
));
974 bool RbUtilQt::chkConfig(bool warn
)
977 if(userSettings
->value("platform").toString().isEmpty()
978 || userSettings
->value("mountpoint").toString().isEmpty()
979 || !QFileInfo(userSettings
->value("mountpoint").toString()).isWritable()) {
982 if(warn
) QMessageBox::critical(this, tr("Configuration error"),
983 tr("Your configuration is invalid. Please go to the configuration "
984 "dialog and make sure the selected values are correct."));