OS X: remove translation for menu entries handled separately.
[kugel-rb.git] / rbutil / rbutilqt / rbutilqt.cpp
blob4a3648618e59a0aaf7b73f4d4fbff2d67a3b0ddf
1 /***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
9 * Copyright (C) 2007 by Dominik Riebeling
10 * $Id$
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 ****************************************************************************/
20 #include <QtGui>
22 #include "version.h"
23 #include "rbutilqt.h"
24 #include "ui_rbutilqtfrm.h"
25 #include "ui_aboutbox.h"
26 #include "configure.h"
27 #include "installwindow.h"
28 #include "installtalkwindow.h"
29 #include "createvoicewindow.h"
30 #include "httpget.h"
31 #include "themesinstallwindow.h"
32 #include "uninstallwindow.h"
33 #include "utils.h"
34 #include "rockboxinfo.h"
35 #include "sysinfo.h"
36 #include "system.h"
37 #include "systrace.h"
38 #include "rbsettings.h"
39 #include "serverinfo.h"
40 #include "systeminfo.h"
41 #include "ziputil.h"
43 #include "progressloggerinterface.h"
45 #include "bootloaderinstallbase.h"
46 #include "bootloaderinstallmpio.h"
48 #if defined(Q_OS_LINUX)
49 #include <stdio.h>
50 #endif
51 #if defined(Q_OS_WIN32)
52 #if defined(UNICODE)
53 #define _UNICODE
54 #endif
55 #include <stdio.h>
56 #include <tchar.h>
57 #include <windows.h>
58 #endif
60 RbUtilQt::RbUtilQt(QWidget *parent) : QMainWindow(parent)
62 // startup log
63 qDebug() << "======================================";
64 qDebug() << "[System] Rockbox Utility " VERSION;
65 qDebug() << "[System] Qt version:" << qVersion();
66 qDebug() << "======================================";
68 absolutePath = qApp->applicationDirPath();
70 HttpGet::setGlobalUserAgent("rbutil/"VERSION);
71 HttpGet::setGlobalProxy(proxy());
72 // init startup & autodetection
73 ui.setupUi(this);
74 #if defined(Q_OS_LINUX)
75 QIcon windowIcon(":/icons/rockbox-clef.svg");
76 this->setWindowIcon(windowIcon);
77 #endif
78 #if defined(Q_OS_MACX)
79 // don't translate menu entries that are handled specially on OS X
80 // (Configure, Quit). Qt handles them for us if they use english string.
81 ui.action_Configure->setText("Configure");
82 ui.actionE_xit->setText("Quit");
83 #endif
84 #if defined(Q_OS_WIN32)
85 long ret;
86 HKEY hk;
87 ret = RegOpenKeyEx(HKEY_CURRENT_USER, _TEXT("Software\\Wine"),
88 0, KEY_QUERY_VALUE, &hk);
89 if(ret == ERROR_SUCCESS) {
90 QMessageBox::warning(this, tr("Wine detected!"),
91 tr("It seems you are trying to run this program under Wine. "
92 "Please don't do this, running under Wine will fail. "
93 "Use the native Linux binary instead."),
94 QMessageBox::Ok, QMessageBox::Ok);
95 qDebug() << "[RbUtil] WINE DETECTED!";
96 RegCloseKey(hk);
98 #endif
99 downloadInfo();
101 m_gotInfo = false;
102 m_auto = false;
104 // manual tab
105 ui.radioPdf->setChecked(true);
107 // info tab
108 ui.treeInfo->setAlternatingRowColors(true);
109 ui.treeInfo->setHeaderLabels(QStringList() << tr("File") << tr("Version"));
110 ui.treeInfo->expandAll();
111 ui.treeInfo->setColumnCount(2);
112 ui.treeInfo->setLayoutDirection(Qt::LeftToRight);
113 // disable quick install until version info is available
114 ui.buttonSmall->setEnabled(false);
115 ui.buttonComplete->setEnabled(false);
116 ui.actionSmall_Installation->setEnabled(false);
117 ui.actionComplete_Installation->setEnabled(false);
119 connect(ui.tabWidget, SIGNAL(currentChanged(int)), this, SLOT(updateTabs(int)));
120 connect(ui.actionAbout_Qt, SIGNAL(triggered()), qApp, SLOT(aboutQt()));
121 connect(ui.action_About, SIGNAL(triggered()), this, SLOT(about()));
122 connect(ui.action_Help, SIGNAL(triggered()), this, SLOT(help()));
123 connect(ui.action_Configure, SIGNAL(triggered()), this, SLOT(configDialog()));
124 connect(ui.actionE_xit, SIGNAL(triggered()), this, SLOT(shutdown()));
125 connect(ui.buttonChangeDevice, SIGNAL(clicked()), this, SLOT(configDialog()));
126 connect(ui.buttonRockbox, SIGNAL(clicked()), this, SLOT(installBtn()));
127 connect(ui.buttonBootloader, SIGNAL(clicked()), this, SLOT(installBootloaderBtn()));
128 connect(ui.buttonFonts, SIGNAL(clicked()), this, SLOT(installFontsBtn()));
129 connect(ui.buttonGames, SIGNAL(clicked()), this, SLOT(installDoomBtn()));
130 connect(ui.buttonTalk, SIGNAL(clicked()), this, SLOT(createTalkFiles()));
131 connect(ui.buttonCreateVoice, SIGNAL(clicked()), this, SLOT(createVoiceFile()));
132 connect(ui.buttonVoice, SIGNAL(clicked()), this, SLOT(installVoice()));
133 connect(ui.buttonThemes, SIGNAL(clicked()), this, SLOT(installThemes()));
134 connect(ui.buttonRemoveRockbox, SIGNAL(clicked()), this, SLOT(uninstall()));
135 connect(ui.buttonRemoveBootloader, SIGNAL(clicked()), this, SLOT(uninstallBootloader()));
136 connect(ui.buttonDownloadManual, SIGNAL(clicked()), this, SLOT(downloadManual()));
137 connect(ui.buttonSmall, SIGNAL(clicked()), this, SLOT(smallInstall()));
138 connect(ui.buttonComplete, SIGNAL(clicked()), this, SLOT(completeInstall()));
140 // actions accessible from the menu
141 connect(ui.actionComplete_Installation, SIGNAL(triggered()), this, SLOT(completeInstall()));
142 connect(ui.actionSmall_Installation, SIGNAL(triggered()), this, SLOT(smallInstall()));
143 connect(ui.actionInstall_Bootloader, SIGNAL(triggered()), this, SLOT(installBootloaderBtn()));
144 connect(ui.actionInstall_Rockbox, SIGNAL(triggered()), this, SLOT(installBtn()));
145 connect(ui.actionFonts_Package, SIGNAL(triggered()), this, SLOT(installFontsBtn()));
146 connect(ui.actionInstall_Themes, SIGNAL(triggered()), this, SLOT(installThemes()));
147 connect(ui.actionInstall_Game_Files, SIGNAL(triggered()), this, SLOT(installDoomBtn()));
148 connect(ui.actionInstall_Voice_File, SIGNAL(triggered()), this, SLOT(installVoice()));
149 connect(ui.actionCreate_Voice_File, SIGNAL(triggered()), this, SLOT(createVoiceFile()));
150 connect(ui.actionCreate_Talk_Files, SIGNAL(triggered()), this, SLOT(createTalkFiles()));
151 connect(ui.actionRemove_bootloader, SIGNAL(triggered()), this, SLOT(uninstallBootloader()));
152 connect(ui.actionUninstall_Rockbox, SIGNAL(triggered()), this, SLOT(uninstall()));
153 connect(ui.action_System_Info, SIGNAL(triggered()), this, SLOT(sysinfo()));
154 connect(ui.action_Trace, SIGNAL(triggered()), this, SLOT(trace()));
156 #if !defined(STATIC)
157 ui.actionInstall_Rockbox_Utility_on_player->setEnabled(false);
158 #else
159 connect(ui.actionInstall_Rockbox_Utility_on_player, SIGNAL(triggered()), this, SLOT(installPortable()));
160 #endif
165 void RbUtilQt::shutdown(void)
167 // restore default message handler to prevent trace accesses during
168 // object destruction -- the trace object could already be destroyed.
169 // Fixes segfaults on exit.
170 qInstallMsgHandler(0);
171 SysTrace::save();
172 this->close();
176 void RbUtilQt::trace(void)
178 SysTrace wnd(this);
179 wnd.exec();
182 void RbUtilQt::sysinfo(void)
184 Sysinfo info(this);
185 info.exec();
188 void RbUtilQt::updateTabs(int count)
190 switch(count) {
191 case 6:
192 updateInfo();
193 break;
194 default:
195 break;
200 void RbUtilQt::downloadInfo()
202 // try to get the current build information
203 daily = new HttpGet(this);
204 connect(daily, SIGNAL(done(bool)), this, SLOT(downloadDone(bool)));
205 connect(qApp, SIGNAL(lastWindowClosed()), daily, SLOT(abort()));
206 if(RbSettings::value(RbSettings::CacheOffline).toBool())
207 daily->setCache(true);
208 else
209 daily->setCache(false);
210 ui.statusbar->showMessage(tr("Downloading build information, please wait ..."));
211 qDebug() << "[RbUtil] downloading build info";
212 daily->setFile(&buildInfo);
213 daily->getFile(QUrl(SystemInfo::value(SystemInfo::ServerConfUrl).toString()));
217 void RbUtilQt::downloadDone(bool error)
219 if(error) {
220 qDebug() << "[RbUtil] network error:" << daily->error();
221 ui.statusbar->showMessage(tr("Can't get version information!"));
222 QMessageBox::critical(this, tr("Network error"),
223 tr("Can't get version information.\n"
224 "Network error: %1. Please check your network and proxy settings.")
225 .arg(daily->errorString()));
226 return;
228 qDebug() << "[RbUtil] network status:" << daily->error();
230 // read info into ServerInfo object
231 buildInfo.open();
232 ServerInfo::readBuildInfo(buildInfo.fileName());
233 buildInfo.close();
235 // start bleeding info download
236 bleeding = new HttpGet(this);
237 connect(bleeding, SIGNAL(done(bool)), this, SLOT(downloadBleedingDone(bool)));
238 connect(qApp, SIGNAL(lastWindowClosed()), bleeding, SLOT(abort()));
239 if(RbSettings::value(RbSettings::CacheOffline).toBool())
240 bleeding->setCache(true);
241 bleeding->setFile(&bleedingInfo);
242 bleeding->getFile(QUrl(SystemInfo::value(SystemInfo::BleedingInfo).toString()));
243 ui.statusbar->showMessage(tr("Downloading build information, please wait ..."));
248 void RbUtilQt::downloadBleedingDone(bool error)
250 if(error) {
251 qDebug() << "[RbUtil] network error:" << bleeding->error();
252 ui.statusbar->showMessage(tr("Can't get version information!"));
253 QMessageBox::critical(this, tr("Network error"),
254 tr("Can't get version information.\n"
255 "Network error: %1. Please check your network and proxy settings.")
256 .arg(bleeding->errorString()));
257 return;
259 else {
260 bleedingInfo.open();
261 ServerInfo::readBleedingInfo(bleedingInfo.fileName());
262 bleedingInfo.close();
264 ui.statusbar->showMessage(tr("Download build information finished."), 5000);
265 updateSettings();
266 m_gotInfo = true;
268 //start check for updates
269 checkUpdate();
274 void RbUtilQt::about()
276 QDialog *window = new QDialog(this);
277 Ui::aboutBox about;
278 about.setupUi(window);
279 window->setLayoutDirection(Qt::LeftToRight);
280 window->setModal(true);
282 QFile licence(":/docs/gpl-2.0.html");
283 licence.open(QIODevice::ReadOnly);
284 QTextStream c(&licence);
285 QString cline = c.readAll();
286 about.browserLicense->insertHtml(cline);
287 about.browserLicense->moveCursor(QTextCursor::Start, QTextCursor::MoveAnchor);
288 QFile credits(":/docs/CREDITS");
289 credits.open(QIODevice::ReadOnly);
290 QTextStream r(&credits);
291 r.setCodec(QTextCodec::codecForName("UTF-8"));
292 while(!r.atEnd()) {
293 QString line = r.readLine();
294 // filter out header.
295 line.remove(QRegExp("^ +.*"));
296 line.remove(QRegExp("^People.*"));
297 about.browserCredits->append(line);
299 about.browserCredits->moveCursor(QTextCursor::Start, QTextCursor::MoveAnchor);
300 QString title = QString("<b>The Rockbox Utility</b><br/>Version %1").arg(FULLVERSION);
301 about.labelTitle->setText(title);
303 window->show();
308 void RbUtilQt::help()
310 QUrl helpurl("http://www.rockbox.org/wiki/RockboxUtility");
311 QDesktopServices::openUrl(helpurl);
315 void RbUtilQt::configDialog()
317 Config *cw = new Config(this);
318 connect(cw, SIGNAL(settingsUpdated()), this, SLOT(updateSettings()));
319 cw->show();
323 void RbUtilQt::updateSettings()
325 qDebug() << "[RbUtil] updating current settings";
326 updateDevice();
327 updateManual();
328 HttpGet::setGlobalProxy(proxy());
329 HttpGet::setGlobalCache(RbSettings::value(RbSettings::CachePath).toString());
330 HttpGet::setGlobalDumbCache(RbSettings::value(RbSettings::CacheOffline).toBool());
332 if(RbSettings::value(RbSettings::RbutilVersion) != PUREVERSION) {
333 QApplication::processEvents();
334 QMessageBox::information(this, tr("New installation"),
335 tr("This is a new installation of Rockbox Utility, or a new version. "
336 "The configuration dialog will now open to allow you to setup the program, "
337 " or review your settings."));
338 configDialog();
340 else if(chkConfig(false)) {
341 QApplication::processEvents();
342 QMessageBox::critical(this, tr("Configuration error"),
343 tr("Your configuration is invalid. This is most likely due "
344 "to a changed device path. The configuration dialog will "
345 "now open to allow you to correct the problem."));
346 configDialog();
351 void RbUtilQt::updateDevice()
353 /* TODO: We should check the flags of the bootloaderinstall classes, and not
354 * just check if its != none or != "fwpatcher" */
356 /* Enable bootloader installation, if possible */
357 bool bootloaderInstallable =
358 SystemInfo::value(SystemInfo::CurBootloaderMethod) != "none";
359 ui.buttonBootloader->setEnabled(bootloaderInstallable);
360 ui.labelBootloader->setEnabled(bootloaderInstallable);
361 ui.actionInstall_Bootloader->setEnabled(bootloaderInstallable);
363 /* Enable bootloader uninstallation, if possible */
364 bool bootloaderUninstallable = bootloaderInstallable &&
365 SystemInfo::value(SystemInfo::CurBootloaderMethod) != "fwpatcher";
366 ui.labelRemoveBootloader->setEnabled(bootloaderUninstallable);
367 ui.buttonRemoveBootloader->setEnabled(bootloaderUninstallable);
368 ui.actionRemove_bootloader->setEnabled(bootloaderUninstallable);
370 /* Disable the whole tab widget if configuration is invalid */
371 bool configurationValid = !chkConfig(false);
372 ui.tabWidget->setEnabled(configurationValid);
373 ui.menuA_ctions->setEnabled(configurationValid);
375 // displayed device info
376 QString mountpoint = RbSettings::value(RbSettings::Mountpoint).toString();
377 QString brand = SystemInfo::value(SystemInfo::CurBrand).toString();
378 QString name = SystemInfo::value(SystemInfo::CurName).toString() +
379 " (" + ServerInfo::value(ServerInfo::CurStatus).toString() + ")";
380 QString mountdisplay = QDir::toNativeSeparators(mountpoint);
381 QString label = Utils::filesystemName(mountpoint);
382 if(!label.isEmpty())
383 mountdisplay += " (" + label + ")";
385 if(name.isEmpty()) name = "&lt;none&gt;";
386 if(mountpoint.isEmpty())
387 mountpoint = "&lt;invalid&gt;";
388 ui.labelDevice->setText(tr("<b>%1 %2</b> at <b>%3</b>")
389 .arg(brand, name, mountdisplay));
391 // hide quickstart buttons if no release available
392 bool installable = !ServerInfo::value(ServerInfo::CurReleaseVersion).toString().isEmpty();
393 ui.buttonSmall->setEnabled(installable);
394 ui.buttonComplete->setEnabled(installable);
395 ui.actionSmall_Installation->setEnabled(installable);
396 ui.actionComplete_Installation->setEnabled(installable);
400 void RbUtilQt::updateManual()
402 if(RbSettings::value(RbSettings::Platform) != "")
404 QString manual= SystemInfo::value(SystemInfo::CurManual).toString();
406 if(manual == "")
407 manual = "rockbox-"
408 + SystemInfo::value(SystemInfo::CurBuildserverModel).toString();
409 QString pdfmanual;
410 pdfmanual = SystemInfo::value(SystemInfo::ManualUrl).toString()
411 + "/" + manual + ".pdf";
412 QString htmlmanual;
413 htmlmanual = SystemInfo::value(SystemInfo::ManualUrl).toString()
414 + "/" + manual + "/rockbox-build.html";
415 ui.labelPdfManual->setText(tr("<a href='%1'>PDF Manual</a>")
416 .arg(pdfmanual));
417 ui.labelHtmlManual->setText(tr("<a href='%1'>HTML Manual (opens in browser)</a>")
418 .arg(htmlmanual));
420 else {
421 ui.labelPdfManual->setText(tr("Select a device for a link to the correct manual"));
422 ui.labelHtmlManual->setText(tr("<a href='%1'>Manual Overview</a>")
423 .arg("http://www.rockbox.org/manual.shtml"));
428 void RbUtilQt::completeInstall()
430 if(chkConfig(true)) return;
431 if(QMessageBox::question(this, tr("Confirm Installation"),
432 tr("Do you really want to perform a complete installation?\n\n"
433 "This will install Rockbox %1. To install the most recent "
434 "development build available press \"Cancel\" and "
435 "use the \"Installation\" tab.")
436 .arg(ServerInfo::value(ServerInfo::CurReleaseVersion).toString()),
437 QMessageBox::Ok | QMessageBox::Cancel) != QMessageBox::Ok)
438 return;
439 // create logger
440 logger = new ProgressLoggerGui(this);
441 logger->show();
443 if(smallInstallInner())
444 return;
445 logger->setRunning();
446 // Fonts
447 m_error = false;
448 m_installed = false;
449 if(!installFontsAuto())
450 return;
451 else
453 // wait for installation finished
454 while(!m_installed)
455 QApplication::processEvents();
457 if(m_error) return;
458 logger->setRunning();
460 // Doom
461 if(hasDoom())
463 m_error = false;
464 m_installed = false;
465 if(!installDoomAuto())
466 return;
467 else
469 // wait for installation finished
470 while(!m_installed)
471 QApplication::processEvents();
473 if(m_error) return;
476 // theme
477 // this is a window
478 // it has its own logger window,so close our.
479 logger->close();
480 installThemes();
484 void RbUtilQt::smallInstall()
486 if(chkConfig(true)) return;
487 if(QMessageBox::question(this, tr("Confirm Installation"),
488 tr("Do you really want to perform a minimal installation? "
489 "A minimal installation will contain only the absolutely "
490 "necessary parts to run Rockbox.\n\n"
491 "This will install Rockbox %1. To install the most recent "
492 "development build available press \"Cancel\" and "
493 "use the \"Installation\" tab.")
494 .arg(ServerInfo::value(ServerInfo::CurReleaseVersion).toString()),
495 QMessageBox::Ok | QMessageBox::Cancel) != QMessageBox::Ok)
496 return;
498 // create logger
499 logger = new ProgressLoggerGui(this);
500 logger->show();
502 smallInstallInner();
505 bool RbUtilQt::smallInstallInner()
507 QString mountpoint = RbSettings::value(RbSettings::Mountpoint).toString();
508 // show dialog with error if mount point is wrong
509 if(!QFileInfo(mountpoint).isDir()) {
510 logger->addItem(tr("Mount point is wrong!"),LOGERROR);
511 logger->setFinished();
512 return true;
514 // Bootloader
515 if(SystemInfo::value(SystemInfo::CurBootloaderMethod) != "none")
517 m_error = false;
518 m_installed = false;
519 m_auto = true;
520 if(!installBootloaderAuto()) {
521 logger->setFinished();
522 return true;
524 else
526 // wait for boot loader installation finished
527 while(!m_installed)
528 QApplication::processEvents();
530 m_auto = false;
531 if(m_error) return true;
532 logger->setRunning();
535 // Rockbox
536 m_error = false;
537 m_installed = false;
538 if(!installAuto())
539 return true;
540 else
542 // wait for installation finished
543 while(!m_installed)
544 QApplication::processEvents();
547 installBootloaderPost(false);
548 return false;
551 void RbUtilQt::installdone(bool error)
553 qDebug() << "[RbUtil] install done";
554 m_installed = true;
555 m_error = error;
558 void RbUtilQt::installBtn()
560 if(chkConfig(true)) return;
561 install();
564 bool RbUtilQt::installAuto()
566 QString file = SystemInfo::value(SystemInfo::ReleaseUrl).toString();
567 file.replace("%MODEL%", SystemInfo::value(SystemInfo::CurBuildserverModel).toString());
568 file.replace("%RELVERSION%", ServerInfo::value(ServerInfo::CurReleaseVersion).toString());
570 // check installed Version and Target
571 QString warning = Utils::checkEnvironment(false);
572 if(!warning.isEmpty())
574 if(QMessageBox::warning(this, tr("Really continue?"), warning,
575 QMessageBox::Ok | QMessageBox::Abort, QMessageBox::Abort)
576 == QMessageBox::Abort)
578 logger->addItem(tr("Aborted!"), LOGERROR);
579 logger->setFinished();
580 return false;
584 // check version
585 RockboxInfo rbinfo(RbSettings::value(RbSettings::Mountpoint).toString());
586 if(rbinfo.version() != "")
588 if(QMessageBox::question(this, tr("Installed Rockbox detected"),
589 tr("Rockbox installation detected. Do you want to backup first?"),
590 QMessageBox::Yes | QMessageBox::No) == QMessageBox::Yes)
592 bool result;
593 logger->addItem(tr("Starting backup..."),LOGINFO);
594 QString backupName = RbSettings::value(RbSettings::Mountpoint).toString()
595 + "/.backup/rockbox-backup-" + rbinfo.version() + ".zip";
597 //! create dir, if it doesnt exist
598 QFileInfo backupFile(backupName);
599 if(!QDir(backupFile.path()).exists())
601 QDir a;
602 a.mkpath(backupFile.path());
605 logger->addItem(tr("Beginning Backup..."),LOGINFO);
606 QCoreApplication::processEvents();
608 //! create backup
609 ZipUtil zip(this);
610 connect(&zip, SIGNAL(logProgress(int, int)), logger, SLOT(setProgress(int, int)));
611 connect(&zip, SIGNAL(logItem(QString, int)), logger, SLOT(addItem(QString, int)));
612 zip.open(backupName, QuaZip::mdCreate);
613 QString mp = RbSettings::value(RbSettings::Mountpoint).toString();
614 QString folder = mp + "/.rockbox";
615 result = zip.appendDirToArchive(folder, mp);
616 zip.close();
617 if(result)
619 logger->addItem(tr("Backup successful"),LOGOK);
621 else
623 logger->addItem(tr("Backup failed!"),LOGERROR);
624 logger->setFinished();
625 return false;
630 //! install current build
631 ZipInstaller* installer = new ZipInstaller(this);
632 installer->setUrl(file);
633 installer->setLogSection("Rockbox (Base)");
634 installer->setLogVersion(ServerInfo::value(ServerInfo::CurReleaseVersion).toString());
635 if(!RbSettings::value(RbSettings::CacheDisabled).toBool())
636 installer->setCache(true);
637 installer->setMountPoint(RbSettings::value(RbSettings::Mountpoint).toString());
639 connect(installer, SIGNAL(done(bool)), this, SLOT(installdone(bool)));
640 connect(installer, SIGNAL(logItem(QString, int)), logger, SLOT(addItem(QString, int)));
641 connect(installer, SIGNAL(logProgress(int, int)), logger, SLOT(setProgress(int, int)));
642 connect(installer, SIGNAL(done(bool)), logger, SLOT(setFinished()));
643 connect(logger, SIGNAL(aborted()), installer, SLOT(abort()));
644 installer->install();
645 return true;
649 void RbUtilQt::install()
651 InstallWindow *installWindow = new InstallWindow(this);
652 installWindow->show();
655 bool RbUtilQt::installBootloaderAuto()
657 installBootloader();
658 return !m_error;
661 void RbUtilQt::installBootloaderBtn()
663 if(chkConfig(true)) return;
664 if(QMessageBox::question(this, tr("Confirm Installation"),
665 tr("Do you really want to install the Bootloader?"),
666 QMessageBox::Yes | QMessageBox::No) != QMessageBox::Yes) return;
668 // create logger
669 logger = new ProgressLoggerGui(this);
670 logger->show();
671 installBootloader();
674 void RbUtilQt::installBootloader()
676 QString platform = RbSettings::value(RbSettings::Platform).toString();
677 QString backupDestination = "";
678 m_error = false;
680 // create installer
681 BootloaderInstallBase *bl = BootloaderInstallBase::createBootloaderInstaller(this,
682 SystemInfo::value(SystemInfo::CurBootloaderMethod).toString());
683 if(bl == NULL) {
684 logger->addItem(tr("No install method known."), LOGERROR);
685 logger->setFinished();
686 return;
689 // set bootloader filename. Do this now as installed() needs it.
690 QStringList blfile = SystemInfo::value(SystemInfo::CurBootloaderFile).toStringList();
691 QStringList blfilepath;
692 for(int a = 0; a < blfile.size(); a++) {
693 blfilepath.append(RbSettings::value(RbSettings::Mountpoint).toString()
694 + blfile.at(a));
696 bl->setBlFile(blfilepath);
697 QUrl url(SystemInfo::value(SystemInfo::BootloaderUrl).toString()
698 + SystemInfo::value(SystemInfo::CurBootloaderName).toString());
699 bl->setBlUrl(url);
700 bl->setLogfile(RbSettings::value(RbSettings::Mountpoint).toString()
701 + "/.rockbox/rbutil.log");
703 if(bl->installed() == BootloaderInstallBase::BootloaderRockbox) {
704 if(QMessageBox::question(this, tr("Bootloader detected"),
705 tr("Bootloader already installed. Do you want to reinstall the bootloader?"),
706 QMessageBox::Yes | QMessageBox::No) == QMessageBox::No) {
707 if(m_auto) {
708 // keep logger open for auto installs.
709 // don't consider abort as error in auto-mode.
710 logger->addItem(tr("Bootloader installation skipped"), LOGINFO);
711 installBootloaderPost(false);
713 else {
714 logger->close();
715 installBootloaderPost(true);
717 delete bl;
718 return;
721 else if(bl->installed() == BootloaderInstallBase::BootloaderOther
722 && bl->capabilities() & BootloaderInstallBase::Backup)
724 QString targetFolder = SystemInfo::value(SystemInfo::CurPlatformName).toString()
725 + " Firmware Backup";
726 // remove invalid character(s)
727 targetFolder.remove(QRegExp("[:/]"));
728 if(QMessageBox::question(this, tr("Create Bootloader backup"),
729 tr("You can create a backup of the original bootloader "
730 "file. Press \"Yes\" to select an output folder on your "
731 "computer to save the file to. The file will get placed "
732 "in a new folder \"%1\" created below the selected folder.\n"
733 "Press \"No\" to skip this step.").arg(targetFolder),
734 QMessageBox::Yes | QMessageBox::No) == QMessageBox::Yes) {
735 backupDestination = QFileDialog::getExistingDirectory(this,
736 tr("Browse backup folder"), QDir::homePath());
737 if(!backupDestination.isEmpty())
738 backupDestination += "/" + targetFolder;
740 qDebug() << "[RbUtil] backing up to" << backupDestination;
741 // backup needs to be done after the logger has been set up.
745 if(bl->capabilities() & BootloaderInstallBase::NeedsOf)
747 int ret;
748 ret = QMessageBox::information(this, tr("Prerequisites"),
749 bl->ofHint(),QMessageBox::Ok | QMessageBox::Abort);
750 if(ret != QMessageBox::Ok) {
751 // consider aborting an error to close window / abort automatic
752 // installation.
753 m_error = true;
754 logger->addItem(tr("Bootloader installation aborted"), LOGINFO);
755 logger->setFinished();
756 return;
758 // open dialog to browse to of file
759 QString offile;
760 offile = QFileDialog::getOpenFileName(this,
761 tr("Select firmware file"), QDir::homePath());
762 if(!QFileInfo(offile).isReadable()) {
763 logger->addItem(tr("Error opening firmware file"), LOGERROR);
764 logger->setFinished();
765 m_error = true;
766 return;
768 bl->setOfFile(offile);
771 // the bootloader install class does NOT use any GUI stuff.
772 // All messages are passed via signals.
773 connect(bl, SIGNAL(done(bool)), logger, SLOT(setFinished()));
774 connect(bl, SIGNAL(done(bool)), this, SLOT(installBootloaderPost(bool)));
775 connect(bl, SIGNAL(logItem(QString, int)), logger, SLOT(addItem(QString, int)));
776 connect(bl, SIGNAL(logProgress(int, int)), logger, SLOT(setProgress(int, int)));
778 // start install.
779 if(!backupDestination.isEmpty()) {
780 if(!bl->backup(backupDestination)) {
781 if(QMessageBox::warning(this, tr("Backup error"),
782 tr("Could not create backup file. Continue?"),
783 QMessageBox::No | QMessageBox::Yes)
784 == QMessageBox::No) {
785 logger->setFinished();
786 return;
790 bl->install();
793 void RbUtilQt::installBootloaderPost(bool error)
795 qDebug() << "[RbUtil] Bootloader Post-Installation, error state:" << error;
796 // if an error occured don't perform post install steps.
797 if(error) {
798 m_error = true;
799 return;
801 else
802 m_error = false;
804 m_installed = true;
805 // end here if automated install
806 if(m_auto)
807 return;
809 QString msg = BootloaderInstallBase::postinstallHints(
810 RbSettings::value(RbSettings::Platform).toString());
811 if(!msg.isEmpty()) {
812 QMessageBox::information(this, tr("Manual steps required"), msg);
813 logger->close();
818 void RbUtilQt::installFontsBtn()
820 if(chkConfig(true)) return;
821 QString mountpoint = RbSettings::value(RbSettings::Mountpoint).toString();
822 RockboxInfo installInfo(mountpoint);
823 if(installInfo.revision().isEmpty() && installInfo.release().isEmpty()) {
824 QMessageBox::critical(this, tr("No Rockbox installation found"),
825 tr("Could not determine the installed Rockbox version. "
826 "Please install a Rockbox build before installing "
827 "fonts."));
828 return;
830 if(QMessageBox::question(this, tr("Confirm Installation"),
831 tr("Do you really want to install the fonts package?"),
832 QMessageBox::Yes | QMessageBox::No) != QMessageBox::Yes) return;
833 // create logger
834 logger = new ProgressLoggerGui(this);
835 logger->show();
836 installFonts();
839 bool RbUtilQt::installFontsAuto()
841 installFonts();
843 return !m_error;
846 void RbUtilQt::installFonts()
848 QString mountpoint = RbSettings::value(RbSettings::Mountpoint).toString();
849 RockboxInfo installInfo(mountpoint);
850 QString fontsurl;
851 QString logversion;
852 QString relversion = installInfo.release();
853 if(relversion.isEmpty()) {
854 // release is empty for non-release versions (i.e. daily / current)
855 fontsurl = SystemInfo::value(SystemInfo::DailyFontUrl).toString();
856 logversion = installInfo.revision();
858 else {
859 fontsurl = SystemInfo::value(SystemInfo::ReleaseFontUrl).toString();
860 logversion = installInfo.release();
862 fontsurl.replace("%RELEASEVER%", relversion);
864 // create zip installer
865 installer = new ZipInstaller(this);
866 installer->setUrl(fontsurl);
867 installer->setLogSection("Fonts");
868 installer->setLogVersion(logversion);
869 installer->setMountPoint(mountpoint);
870 if(!RbSettings::value(RbSettings::CacheDisabled).toBool())
871 installer->setCache(true);
873 connect(installer, SIGNAL(done(bool)), this, SLOT(installdone(bool)));
874 connect(installer, SIGNAL(logItem(QString, int)), logger, SLOT(addItem(QString, int)));
875 connect(installer, SIGNAL(logProgress(int, int)), logger, SLOT(setProgress(int, int)));
876 connect(installer, SIGNAL(done(bool)), logger, SLOT(setFinished()));
877 connect(logger, SIGNAL(aborted()), installer, SLOT(abort()));
878 installer->install();
882 void RbUtilQt::installVoice()
884 if(chkConfig(true)) return;
886 if(m_gotInfo == false)
888 QMessageBox::warning(this, tr("Warning"),
889 tr("The Application is still downloading Information about new Builds."
890 " Please try again shortly."));
891 return;
894 QString mountpoint = RbSettings::value(RbSettings::Mountpoint).toString();
895 RockboxInfo installInfo(mountpoint);
897 QString voiceurl;
898 QString logversion;
899 QString relversion = installInfo.release();
900 // if no version is found abort.
901 if(installInfo.revision().isEmpty() && relversion.isEmpty()) {
902 QMessageBox::critical(this, tr("No Rockbox installation found"),
903 tr("Could not determine the installed Rockbox version. "
904 "Please install a Rockbox build before installing "
905 "voice files."));
906 return;
908 if(relversion.isEmpty()) {
909 // release is empty for non-release versions (i.e. daily / current)
910 voiceurl = SystemInfo::value(SystemInfo::DailyVoiceUrl).toString();
911 logversion = installInfo.revision();
913 else {
914 voiceurl = SystemInfo::value(SystemInfo::ReleaseVoiceUrl).toString();
915 logversion = installInfo.release();
917 if(QMessageBox::question(this, tr("Confirm Installation"),
918 tr("Do you really want to install the voice file?"),
919 QMessageBox::Yes | QMessageBox::No) != QMessageBox::Yes)
920 return;
922 QDate date = QDate::fromString(
923 ServerInfo::value(ServerInfo::DailyDate).toString(), Qt::ISODate);
924 QString model = SystemInfo::value(SystemInfo::CurBuildserverModel).toString();
925 // replace placeholder in voice url
926 voiceurl.replace("%DATE%", date.toString("yyyyMMdd"));
927 voiceurl.replace("%MODEL%", model);
928 voiceurl.replace("%RELVERSION%", relversion);
930 qDebug() << "[RbUtil] voicefile URL:" << voiceurl;
932 // create logger
933 logger = new ProgressLoggerGui(this);
934 logger->show();
935 // create zip installer
936 installer = new ZipInstaller(this);
938 installer->setUrl(voiceurl);
939 installer->setLogSection("Voice");
940 installer->setLogVersion(logversion);
941 installer->setMountPoint(mountpoint);
942 if(!RbSettings::value(RbSettings::CacheDisabled).toBool())
943 installer->setCache(true);
944 connect(installer, SIGNAL(logItem(QString, int)), logger, SLOT(addItem(QString, int)));
945 connect(installer, SIGNAL(logProgress(int, int)), logger, SLOT(setProgress(int, int)));
946 connect(installer, SIGNAL(done(bool)), logger, SLOT(setFinished()));
947 connect(logger, SIGNAL(aborted()), installer, SLOT(abort()));
948 installer->install();
952 void RbUtilQt::installDoomBtn()
954 if(chkConfig(true)) return;
955 if(!hasDoom()){
956 QMessageBox::critical(this, tr("Error"),
957 tr("Your device doesn't have a doom plugin. Aborting."));
958 return;
961 if(QMessageBox::question(this, tr("Confirm Installation"),
962 tr("Do you really want to install the game addon files?"),
963 QMessageBox::Yes | QMessageBox::No) != QMessageBox::Yes) return;
964 // create logger
965 logger = new ProgressLoggerGui(this);
966 logger->show();
968 installDoom();
970 bool RbUtilQt::installDoomAuto()
972 installDoom();
973 return !m_error;
976 bool RbUtilQt::hasDoom()
978 QFile doomrock(RbSettings::value(RbSettings::Mountpoint).toString()
979 +"/.rockbox/rocks/games/doom.rock");
980 return doomrock.exists();
983 void RbUtilQt::installDoom()
985 // create zip installer
986 installer = new ZipInstaller(this);
988 installer->setUrl(SystemInfo::value(SystemInfo::DoomUrl).toString());
989 installer->setLogSection("Game Addons");
990 installer->setLogVersion(ServerInfo::value(ServerInfo::DailyDate).toString());
991 installer->setMountPoint(RbSettings::value(RbSettings::Mountpoint).toString());
992 if(!RbSettings::value(RbSettings::CacheDisabled).toBool())
993 installer->setCache(true);
994 connect(installer, SIGNAL(done(bool)), this, SLOT(installdone(bool)));
995 connect(installer, SIGNAL(logItem(QString, int)), logger, SLOT(addItem(QString, int)));
996 connect(installer, SIGNAL(logProgress(int, int)), logger, SLOT(setProgress(int, int)));
997 connect(installer, SIGNAL(done(bool)), logger, SLOT(setFinished()));
998 connect(logger, SIGNAL(aborted()), installer, SLOT(abort()));
999 installer->install();
1003 void RbUtilQt::installThemes()
1005 if(chkConfig(true)) return;
1006 ThemesInstallWindow* tw = new ThemesInstallWindow(this);
1007 tw->setModal(true);
1008 tw->show();
1011 void RbUtilQt::createTalkFiles(void)
1013 if(chkConfig(true)) return;
1014 InstallTalkWindow *installWindow = new InstallTalkWindow(this);
1015 connect(installWindow, SIGNAL(settingsUpdated()), this, SLOT(updateSettings()));
1016 installWindow->show();
1020 void RbUtilQt::createVoiceFile(void)
1022 if(chkConfig(true)) return;
1023 CreateVoiceWindow *installWindow = new CreateVoiceWindow(this);
1025 connect(installWindow, SIGNAL(settingsUpdated()), this, SLOT(updateSettings()));
1026 installWindow->show();
1029 void RbUtilQt::uninstall(void)
1031 if(chkConfig(true)) return;
1032 UninstallWindow *uninstallWindow = new UninstallWindow(this);
1033 uninstallWindow->show();
1037 void RbUtilQt::uninstallBootloader(void)
1039 if(chkConfig(true)) return;
1040 if(QMessageBox::question(this, tr("Confirm Uninstallation"),
1041 tr("Do you really want to uninstall the Bootloader?"),
1042 QMessageBox::Yes | QMessageBox::No) != QMessageBox::Yes) return;
1043 // create logger
1044 ProgressLoggerGui* logger = new ProgressLoggerGui(this);
1045 logger->setProgressVisible(false);
1046 logger->show();
1048 QString platform = RbSettings::value(RbSettings::Platform).toString();
1050 // create installer
1051 BootloaderInstallBase *bl = BootloaderInstallBase::createBootloaderInstaller(this,
1052 SystemInfo::value(SystemInfo::CurBootloaderMethod).toString());
1054 if(bl == NULL ) {
1055 logger->addItem(tr("No uninstall method for this target known."), LOGERROR);
1056 logger->setFinished();
1057 return;
1059 QStringList blfile = SystemInfo::value(SystemInfo::CurBootloaderFile).toStringList();
1060 QStringList blfilepath;
1061 for(int a = 0; a < blfile.size(); a++) {
1062 blfilepath.append(RbSettings::value(RbSettings::Mountpoint).toString()
1063 + blfile.at(a));
1065 bl->setBlFile(blfilepath);
1067 BootloaderInstallBase::BootloaderType currentbl = bl->installed();
1068 if((bl->capabilities() & BootloaderInstallBase::Uninstall) == 0
1069 || currentbl == BootloaderInstallBase::BootloaderUnknown
1070 || currentbl == BootloaderInstallBase::BootloaderOther)
1072 logger->addItem(tr("Rockbox Utility can not uninstall the bootloader on this target. "
1073 "Try a normal firmware update to remove the booloader."), LOGERROR);
1074 logger->setFinished();
1075 delete bl;
1076 return;
1079 connect(bl, SIGNAL(logItem(QString, int)), logger, SLOT(addItem(QString, int)));
1080 connect(bl, SIGNAL(logProgress(int, int)), logger, SLOT(setProgress(int, int)));
1082 bl->uninstall();
1084 logger->setFinished();
1089 void RbUtilQt::downloadManual(void)
1091 if(chkConfig(true)) return;
1092 if(QMessageBox::question(this, tr("Confirm download"),
1093 tr("Do you really want to download the manual? The manual will be saved "
1094 "to the root folder of your player."),
1095 QMessageBox::Yes | QMessageBox::No) != QMessageBox::Yes)
1096 return;
1098 QString manual = SystemInfo::value(SystemInfo::CurManual).toString();
1099 if(manual.isEmpty())
1100 manual = "rockbox-"
1101 + SystemInfo::value(SystemInfo::CurBuildserverModel).toString();
1103 QDate date = QDate::fromString(ServerInfo::value(ServerInfo::DailyDate).toString(),Qt::ISODate);
1105 QString manualurl;
1106 QString target;
1107 QString section;
1108 if(ui.radioPdf->isChecked()) {
1109 target = "/" + manual + ".pdf";
1110 section = "Manual (PDF)";
1112 else {
1113 target = "/" + manual + "-" + date.toString("yyyyMMdd") + "-html.zip";
1114 section = "Manual (HTML)";
1116 manualurl = SystemInfo::value(SystemInfo::ManualUrl).toString() + "/" + target;
1117 qDebug() << "[RbUtil] Manual URL:" << manualurl;
1119 ProgressLoggerGui* logger = new ProgressLoggerGui(this);
1120 logger->show();
1121 installer = new ZipInstaller(this);
1122 installer->setMountPoint(RbSettings::value(RbSettings::Mountpoint).toString());
1123 if(!RbSettings::value(RbSettings::CacheDisabled).toBool())
1124 installer->setCache(true);
1125 installer->setLogSection(section);
1126 installer->setLogVersion(ServerInfo::value(ServerInfo::DailyDate).toString());
1127 installer->setUrl(manualurl);
1128 installer->setUnzip(false);
1129 installer->setTarget(target);
1130 connect(installer, SIGNAL(logItem(QString, int)), logger, SLOT(addItem(QString, int)));
1131 connect(installer, SIGNAL(logProgress(int, int)), logger, SLOT(setProgress(int, int)));
1132 connect(installer, SIGNAL(done(bool)), logger, SLOT(setFinished()));
1133 connect(logger, SIGNAL(aborted()), installer, SLOT(abort()));
1134 installer->install();
1138 void RbUtilQt::installPortable(void)
1140 if(QMessageBox::question(this, tr("Confirm installation"),
1141 tr("Do you really want to install Rockbox Utility to your player? "
1142 "After installation you can run it from the players hard drive."),
1143 QMessageBox::Yes | QMessageBox::No) != QMessageBox::Yes)
1144 return;
1146 ProgressLoggerGui* logger = new ProgressLoggerGui(this);
1147 logger->setProgressMax(0);
1148 logger->setProgressValue(0);
1149 logger->show();
1150 logger->addItem(tr("Installing Rockbox Utility"), LOGINFO);
1152 // check mountpoint
1153 if(!QFileInfo(RbSettings::value(RbSettings::Mountpoint).toString()).isDir()) {
1154 logger->addItem(tr("Mount point is wrong!"),LOGERROR);
1155 logger->setFinished();
1156 return;
1159 // remove old files first.
1160 QFile::remove(RbSettings::value(RbSettings::Mountpoint).toString()
1161 + "/RockboxUtility.exe");
1162 QFile::remove(RbSettings::value(RbSettings::Mountpoint).toString()
1163 + "/RockboxUtility.ini");
1164 // copy currently running binary and currently used settings file
1165 if(!QFile::copy(qApp->applicationFilePath(),
1166 RbSettings::value(RbSettings::Mountpoint).toString()
1167 + "/RockboxUtility.exe")) {
1168 logger->addItem(tr("Error installing Rockbox Utility"), LOGERROR);
1169 logger->setFinished();
1170 return;
1172 logger->addItem(tr("Installing user configuration"), LOGINFO);
1173 if(!QFile::copy(RbSettings::userSettingFilename(),
1174 RbSettings::value(RbSettings::Mountpoint).toString()
1175 + "/RockboxUtility.ini")) {
1176 logger->addItem(tr("Error installing user configuration"), LOGERROR);
1177 logger->setFinished();
1178 return;
1180 logger->addItem(tr("Successfully installed Rockbox Utility."), LOGOK);
1181 logger->setFinished();
1182 logger->setProgressMax(1);
1183 logger->setProgressValue(1);
1188 void RbUtilQt::updateInfo()
1190 qDebug() << "[RbUtil] updating server info";
1192 QString mp = RbSettings::value(RbSettings::Mountpoint).toString();
1193 QSettings log(mp + "/.rockbox/rbutil.log", QSettings::IniFormat, this);
1194 QStringList groups = log.childGroups();
1195 QList<QTreeWidgetItem *> items;
1196 QTreeWidgetItem *w, *w2;
1197 QString min, max;
1198 int olditems = 0;
1200 // remove old list entries (if any)
1201 int l = ui.treeInfo->topLevelItemCount();
1202 while(l--) {
1203 QTreeWidgetItem *m;
1204 m = ui.treeInfo->takeTopLevelItem(l);
1205 // delete childs (single level deep, no recursion here)
1206 int n = m->childCount();
1207 while(n--)
1208 delete m->child(n);
1210 // get and populate new items
1211 for(int a = 0; a < groups.size(); a++) {
1212 log.beginGroup(groups.at(a));
1213 QStringList keys = log.allKeys();
1214 w = new QTreeWidgetItem;
1215 w->setFlags(Qt::ItemIsEnabled);
1216 w->setText(0, groups.at(a));
1217 items.append(w);
1218 // get minimum and maximum version information so we can hilight old files
1219 min = max = log.value(keys.at(0)).toString();
1220 for(int b = 0; b < keys.size(); b++) {
1221 if(log.value(keys.at(b)).toString() > max)
1222 max = log.value(keys.at(b)).toString();
1223 if(log.value(keys.at(b)).toString() < min)
1224 min = log.value(keys.at(b)).toString();
1227 for(int b = 0; b < keys.size(); b++) {
1228 QString file;
1229 file = mp + "/" + keys.at(b);
1230 if(QFileInfo(file).isDir())
1231 continue;
1232 w2 = new QTreeWidgetItem(w, QStringList() << "/"
1233 + keys.at(b) << log.value(keys.at(b)).toString());
1234 if(log.value(keys.at(b)).toString() != max) {
1235 w2->setForeground(0, QBrush(QColor(255, 0, 0)));
1236 w2->setForeground(1, QBrush(QColor(255, 0, 0)));
1237 olditems++;
1239 items.append(w2);
1241 log.endGroup();
1242 if(min != max)
1243 w->setData(1, Qt::DisplayRole, QString("%1 / %2").arg(min, max));
1244 else
1245 w->setData(1, Qt::DisplayRole, max);
1247 ui.treeInfo->insertTopLevelItems(0, items);
1248 ui.treeInfo->resizeColumnToContents(0);
1252 QUrl RbUtilQt::proxy()
1254 QUrl proxy;
1255 if(RbSettings::value(RbSettings::ProxyType) == "manual")
1256 proxy.setEncodedUrl(RbSettings::value(RbSettings::Proxy).toByteArray());
1257 else if(RbSettings::value(RbSettings::ProxyType) == "system")
1258 proxy = System::systemProxy();
1259 qDebug() << proxy.userName() << proxy.password() << proxy.host() << proxy.port();
1260 return proxy;
1264 bool RbUtilQt::chkConfig(bool warn)
1266 bool error = false;
1267 if(RbSettings::value(RbSettings::Platform).toString().isEmpty()
1268 || RbSettings::value(RbSettings::Mountpoint).toString().isEmpty()
1269 || !QFileInfo(RbSettings::value(RbSettings::Mountpoint).toString()).isWritable()) {
1270 error = true;
1272 if(warn) QMessageBox::critical(this, tr("Configuration error"),
1273 tr("Your configuration is invalid. Please go to the configuration "
1274 "dialog and make sure the selected values are correct."));
1276 return error;
1279 void RbUtilQt::checkUpdate(void)
1281 QString url = SystemInfo::value(SystemInfo::RbutilUrl).toString();
1282 #if defined(Q_OS_WIN32)
1283 url += "win32/";
1284 #elif defined(Q_OS_LINUX)
1285 url += "linux/";
1286 #elif defined(Q_OS_MACX)
1287 url += "macosx/";
1288 #endif
1290 update = new HttpGet(this);
1291 connect(update, SIGNAL(done(bool)), this, SLOT(downloadUpdateDone(bool)));
1292 connect(qApp, SIGNAL(lastWindowClosed()), update, SLOT(abort()));
1293 if(RbSettings::value(RbSettings::CacheOffline).toBool())
1294 update->setCache(true);
1296 ui.statusbar->showMessage(tr("Checking for update ..."));
1297 update->getFile(QUrl(url));
1300 void RbUtilQt::downloadUpdateDone(bool error)
1302 if(error) {
1303 qDebug() << "[RbUtil] network error:" << update->error();
1305 else {
1306 QString toParse(update->readAll());
1308 QRegExp searchString("<a[^>]*>([a-zA-Z]+[^<]*)</a>");
1309 QStringList rbutilList;
1310 int pos = 0;
1311 while ((pos = searchString.indexIn(toParse, pos)) != -1)
1313 rbutilList << searchString.cap(1);
1314 pos += searchString.matchedLength();
1316 qDebug() << "[RbUtilQt] Checking for update";
1318 QString newVersion = "";
1319 QString foundVersion = "";
1320 // check if there is a binary with higher version in this list
1321 for(int i=0; i < rbutilList.size(); i++)
1323 QString item = rbutilList.at(i);
1324 #if defined(Q_OS_LINUX)
1325 #if defined(__amd64__)
1326 // skip if it isn't a 64 bit build
1327 if( !item.contains("64bit"))
1328 continue;
1329 // strip the "64bit" suffix for comparison
1330 item = item.remove("64bit");
1331 #else
1332 //skip if it is a 64bit build
1333 if(item.contains("64bit"))
1334 continue;
1335 #endif
1336 #endif
1337 // check if it is newer, and remember newest
1338 if(Utils::compareVersionStrings(VERSION, item) == 1)
1340 if(Utils::compareVersionStrings(newVersion, item) == 1)
1342 newVersion = item;
1343 foundVersion = rbutilList.at(i);
1348 // if we found something newer, display info
1349 if(foundVersion != "")
1351 QString url = SystemInfo::value(SystemInfo::RbutilUrl).toString();
1352 #if defined(Q_OS_WIN32)
1353 url += "win32/";
1354 #elif defined(Q_OS_LINUX)
1355 url += "linux/";
1356 #elif defined(Q_OS_MACX)
1357 url += "macosx/";
1358 #endif
1359 url += foundVersion;
1361 QMessageBox::information(this,tr("RockboxUtility Update available"),
1362 tr("<b>New RockboxUtility Version available.</b> <br><br>"
1363 "Download it from here: <a href='%1'>%2</a>")
1364 .arg(url).arg(foundVersion));
1365 ui.statusbar->showMessage(tr("New version of Rockbox Utility available."));
1367 else {
1368 ui.statusbar->showMessage(tr("Rockbox Utility is up to date."), 5000);