Submit FS#9746 by Boris Gjenero. Set PP502x IDE pins low for iPod Video when IDE...
[kugel-rb.git] / rbutil / rbutilqt / rbutilqt.cpp
blob292a0026b14fa2d19fd2162c5334ff53b19e06c0
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 "rbzip.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"
42 #include "progressloggerinterface.h"
44 #include "bootloaderinstallbase.h"
45 #include "bootloaderinstallmi4.h"
46 #include "bootloaderinstallhex.h"
47 #include "bootloaderinstallipod.h"
48 #include "bootloaderinstallsansa.h"
49 #include "bootloaderinstallfile.h"
50 #include "bootloaderinstallchinachip.h"
51 #include "bootloaderinstallams.h"
52 #include "bootloaderinstalltcc.h"
55 #if defined(Q_OS_LINUX)
56 #include <stdio.h>
57 #endif
58 #if defined(Q_OS_WIN32)
59 #if defined(UNICODE)
60 #define _UNICODE
61 #endif
62 #include <stdio.h>
63 #include <tchar.h>
64 #include <windows.h>
65 #endif
67 RbUtilQt::RbUtilQt(QWidget *parent) : QMainWindow(parent)
69 // startup log
70 qDebug() << "======================================";
71 qDebug() << "[System] Rockbox Utility " VERSION;
72 qDebug() << "[System] Qt version:" << qVersion();
73 qDebug() << "======================================";
75 absolutePath = qApp->applicationDirPath();
77 HttpGet::setGlobalUserAgent("rbutil/"VERSION);
78 // init startup & autodetection
79 ui.setupUi(this);
80 downloadInfo();
82 m_gotInfo = false;
83 m_auto = false;
85 // manual tab
86 ui.radioPdf->setChecked(true);
88 // info tab
89 ui.treeInfo->setAlternatingRowColors(true);
90 ui.treeInfo->setHeaderLabels(QStringList() << tr("File") << tr("Version"));
91 ui.treeInfo->expandAll();
92 ui.treeInfo->setColumnCount(2);
93 ui.treeInfo->setLayoutDirection(Qt::LeftToRight);
94 // disable quick install until version info is available
95 ui.buttonSmall->setEnabled(false);
96 ui.buttonComplete->setEnabled(false);
97 ui.actionSmall_Installation->setEnabled(false);
98 ui.actionComplete_Installation->setEnabled(false);
100 connect(ui.tabWidget, SIGNAL(currentChanged(int)), this, SLOT(updateTabs(int)));
101 connect(ui.actionAbout_Qt, SIGNAL(triggered()), qApp, SLOT(aboutQt()));
102 connect(ui.action_About, SIGNAL(triggered()), this, SLOT(about()));
103 connect(ui.action_Help, SIGNAL(triggered()), this, SLOT(help()));
104 connect(ui.action_Configure, SIGNAL(triggered()), this, SLOT(configDialog()));
105 connect(ui.actionE_xit, SIGNAL(triggered()), this, SLOT(shutdown()));
106 connect(ui.buttonChangeDevice, SIGNAL(clicked()), this, SLOT(configDialog()));
107 connect(ui.buttonRockbox, SIGNAL(clicked()), this, SLOT(installBtn()));
108 connect(ui.buttonBootloader, SIGNAL(clicked()), this, SLOT(installBootloaderBtn()));
109 connect(ui.buttonFonts, SIGNAL(clicked()), this, SLOT(installFontsBtn()));
110 connect(ui.buttonGames, SIGNAL(clicked()), this, SLOT(installDoomBtn()));
111 connect(ui.buttonTalk, SIGNAL(clicked()), this, SLOT(createTalkFiles()));
112 connect(ui.buttonCreateVoice, SIGNAL(clicked()), this, SLOT(createVoiceFile()));
113 connect(ui.buttonVoice, SIGNAL(clicked()), this, SLOT(installVoice()));
114 connect(ui.buttonThemes, SIGNAL(clicked()), this, SLOT(installThemes()));
115 connect(ui.buttonRemoveRockbox, SIGNAL(clicked()), this, SLOT(uninstall()));
116 connect(ui.buttonRemoveBootloader, SIGNAL(clicked()), this, SLOT(uninstallBootloader()));
117 connect(ui.buttonDownloadManual, SIGNAL(clicked()), this, SLOT(downloadManual()));
118 connect(ui.buttonSmall, SIGNAL(clicked()), this, SLOT(smallInstall()));
119 connect(ui.buttonComplete, SIGNAL(clicked()), this, SLOT(completeInstall()));
121 // actions accessible from the menu
122 connect(ui.actionComplete_Installation, SIGNAL(triggered()), this, SLOT(completeInstall()));
123 connect(ui.actionSmall_Installation, SIGNAL(triggered()), this, SLOT(smallInstall()));
124 connect(ui.actionInstall_Bootloader, SIGNAL(triggered()), this, SLOT(installBootloaderBtn()));
125 connect(ui.actionInstall_Rockbox, SIGNAL(triggered()), this, SLOT(installBtn()));
126 connect(ui.actionFonts_Package, SIGNAL(triggered()), this, SLOT(installFontsBtn()));
127 connect(ui.actionInstall_Themes, SIGNAL(triggered()), this, SLOT(installThemes()));
128 connect(ui.actionInstall_Game_Files, SIGNAL(triggered()), this, SLOT(installDoomBtn()));
129 connect(ui.actionInstall_Voice_File, SIGNAL(triggered()), this, SLOT(installVoice()));
130 connect(ui.actionCreate_Voice_File, SIGNAL(triggered()), this, SLOT(createVoiceFile()));
131 connect(ui.actionCreate_Talk_Files, SIGNAL(triggered()), this, SLOT(createTalkFiles()));
132 connect(ui.actionRemove_bootloader, SIGNAL(triggered()), this, SLOT(uninstallBootloader()));
133 connect(ui.actionUninstall_Rockbox, SIGNAL(triggered()), this, SLOT(uninstall()));
134 connect(ui.action_System_Info, SIGNAL(triggered()), this, SLOT(sysinfo()));
135 connect(ui.action_Trace, SIGNAL(triggered()), this, SLOT(trace()));
137 #if !defined(STATIC)
138 ui.actionInstall_Rockbox_Utility_on_player->setEnabled(false);
139 #else
140 connect(ui.actionInstall_Rockbox_Utility_on_player, SIGNAL(triggered()), this, SLOT(installPortable()));
141 #endif
146 void RbUtilQt::shutdown(void)
148 // restore default message handler to prevent trace accesses during
149 // object destruction -- the trace object could already be destroyed.
150 // Fixes segfaults on exit.
151 qInstallMsgHandler(0);
152 this->close();
156 void RbUtilQt::trace(void)
158 SysTrace wnd(this);
159 wnd.exec();
162 void RbUtilQt::sysinfo(void)
164 Sysinfo info(this);
165 info.exec();
168 void RbUtilQt::updateTabs(int count)
170 switch(count) {
171 case 6:
172 updateInfo();
173 break;
174 default:
175 break;
180 void RbUtilQt::downloadInfo()
182 // try to get the current build information
183 daily = new HttpGet(this);
184 connect(daily, SIGNAL(done(bool)), this, SLOT(downloadDone(bool)));
185 connect(daily, SIGNAL(requestFinished(int, bool)), this, SLOT(downloadDone(int, bool)));
186 connect(qApp, SIGNAL(lastWindowClosed()), daily, SLOT(abort()));
187 if(RbSettings::value(RbSettings::CacheOffline).toBool())
188 daily->setCache(true);
189 else
190 daily->setCache(false);
191 ui.statusbar->showMessage(tr("Downloading build information, please wait ..."));
192 qDebug() << "[RbUtil] downloading build info";
193 daily->setFile(&buildInfo);
194 daily->getFile(QUrl(SystemInfo::value(SystemInfo::ServerConfUrl).toString()));
198 void RbUtilQt::downloadDone(bool error)
200 if(error) {
201 qDebug() << "[RbUtil] network error:" << daily->error();
202 ui.statusbar->showMessage(tr("Can't get version information!"));
203 QMessageBox::critical(this, tr("Network error"),
204 tr("Can't get version information."));
205 return;
207 qDebug() << "[RbUtil] network status:" << daily->error();
209 // read info into ServerInfo object
210 buildInfo.open();
211 ServerInfo::readBuildInfo(buildInfo.fileName());
212 buildInfo.close();
214 //start bleeding info download
215 bleeding = new HttpGet(this);
216 connect(bleeding, SIGNAL(done(bool)), this, SLOT(downloadBleedingDone(bool)));
217 connect(bleeding, SIGNAL(requestFinished(int, bool)), this, SLOT(downloadDone(int, bool)));
218 connect(qApp, SIGNAL(lastWindowClosed()), bleeding, SLOT(abort()));
219 if(RbSettings::value(RbSettings::CacheOffline).toBool())
220 bleeding->setCache(true);
221 bleeding->setFile(&bleedingInfo);
222 bleeding->getFile(QUrl(SystemInfo::value(SystemInfo::BleedingInfo).toString()));
223 ui.statusbar->showMessage(tr("Downloading build information, please wait ..."));
228 void RbUtilQt::downloadBleedingDone(bool error)
230 if(error) {
231 qDebug() << "[RbUtil] network error:" << bleeding->error();
233 else {
234 bleedingInfo.open();
235 ServerInfo::readBleedingInfo(bleedingInfo.fileName());
236 bleedingInfo.close();
238 ui.statusbar->showMessage(tr("Download build information finished."), 5000);
239 updateSettings();
240 m_gotInfo = true;
242 //start check for updates
243 checkUpdate();
248 void RbUtilQt::downloadDone(int id, bool error)
250 QString errorString;
251 errorString = tr("Network error: %1. Please check your network and proxy settings.")
252 .arg(daily->errorString());
253 if(error) {
254 QMessageBox::about(this, "Network Error", errorString);
255 m_networkerror = daily->errorString();
257 qDebug() << "[RbUtil] downloadDone:" << id << "error:" << error;
261 void RbUtilQt::about()
263 QDialog *window = new QDialog(this);
264 Ui::aboutBox about;
265 about.setupUi(window);
266 window->setLayoutDirection(Qt::LeftToRight);
267 window->setModal(true);
269 QFile licence(":/docs/gpl-2.0.html");
270 licence.open(QIODevice::ReadOnly);
271 QTextStream c(&licence);
272 QString cline = c.readAll();
273 about.browserLicense->insertHtml(cline);
274 about.browserLicense->moveCursor(QTextCursor::Start, QTextCursor::MoveAnchor);
275 QFile credits(":/docs/CREDITS");
276 credits.open(QIODevice::ReadOnly);
277 QTextStream r(&credits);
278 r.setCodec(QTextCodec::codecForName("UTF-8"));
279 while(!r.atEnd()) {
280 QString line = r.readLine();
281 // filter out header.
282 line.remove(QRegExp("^[^A-Z]+.*"));
283 line.remove(QRegExp("^People.*"));
284 about.browserCredits->append(line);
286 about.browserCredits->moveCursor(QTextCursor::Start, QTextCursor::MoveAnchor);
287 QString title = QString("<b>The Rockbox Utility</b><br/>Version %1").arg(FULLVERSION);
288 about.labelTitle->setText(title);
290 window->show();
295 void RbUtilQt::help()
297 QUrl helpurl("http://www.rockbox.org/wiki/RockboxUtility");
298 QDesktopServices::openUrl(helpurl);
302 void RbUtilQt::configDialog()
304 Config *cw = new Config(this);
305 connect(cw, SIGNAL(settingsUpdated()), this, SLOT(updateSettings()));
306 cw->show();
310 void RbUtilQt::updateSettings()
312 qDebug() << "[RbUtil] updating current settings";
313 updateDevice();
314 updateManual();
315 if(RbSettings::value(RbSettings::ProxyType) == "system") {
316 HttpGet::setGlobalProxy(System::systemProxy());
318 else if(RbSettings::value(RbSettings::ProxyType) == "manual") {
319 HttpGet::setGlobalProxy(RbSettings::value(RbSettings::Proxy).toString());
321 else {
322 HttpGet::setGlobalProxy(QUrl(""));
324 HttpGet::setGlobalCache(RbSettings::value(RbSettings::CachePath).toString());
325 HttpGet::setGlobalDumbCache(RbSettings::value(RbSettings::CacheOffline).toBool());
327 if(RbSettings::value(RbSettings::RbutilVersion) != PUREVERSION) {
328 QApplication::processEvents();
329 QMessageBox::information(this, tr("New installation"),
330 tr("This is a new installation of Rockbox Utility, or a new version. "
331 "The configuration dialog will now open to allow you to setup the program, "
332 " or review your settings."));
333 configDialog();
335 else if(chkConfig(false)) {
336 QApplication::processEvents();
337 QMessageBox::critical(this, tr("Configuration error"),
338 tr("Your configuration is invalid. This is most likely due "
339 "to a changed device path. The configuration dialog will "
340 "now open to allow you to correct the problem."));
341 configDialog();
346 void RbUtilQt::updateDevice()
348 /* TODO: We should check the flags of the bootloaderinstall classes, and not
349 * just check if its != none or != "fwpatcher" */
351 /* Enable bootloader installation, if possible */
352 bool bootloaderInstallable =
353 SystemInfo::value(SystemInfo::CurBootloaderMethod) != "none";
354 ui.buttonBootloader->setEnabled(bootloaderInstallable);
355 ui.labelBootloader->setEnabled(bootloaderInstallable);
356 ui.actionInstall_Bootloader->setEnabled(bootloaderInstallable);
358 /* Enable bootloader uninstallation, if possible */
359 bool bootloaderUninstallable = bootloaderInstallable &&
360 SystemInfo::value(SystemInfo::CurBootloaderMethod) != "fwpatcher";
361 ui.labelRemoveBootloader->setEnabled(bootloaderUninstallable);
362 ui.buttonRemoveBootloader->setEnabled(bootloaderUninstallable);
363 ui.actionRemove_bootloader->setEnabled(bootloaderUninstallable);
365 /* Disable the whole tab widget if configuration is invalid */
366 bool configurationValid = !chkConfig(false);
367 ui.tabWidget->setEnabled(configurationValid);
368 ui.menuA_ctions->setEnabled(configurationValid);
370 // displayed device info
371 QString mountpoint = RbSettings::value(RbSettings::Mountpoint).toString();
372 QString brand = SystemInfo::value(SystemInfo::CurBrand).toString();
373 QString name = SystemInfo::value(SystemInfo::CurName).toString() +
374 " (" + ServerInfo::value(ServerInfo::CurStatus).toString() + ")";
375 if(name.isEmpty()) name = "&lt;none&gt;";
376 if(mountpoint.isEmpty()) mountpoint = "&lt;invalid&gt;";
377 ui.labelDevice->setText(tr("<b>%1 %2</b> at <b>%3</b>")
378 .arg(brand, name, QDir::toNativeSeparators(mountpoint)));
380 // hide quickstart buttons if no release available
381 bool installable = !ServerInfo::value(ServerInfo::CurReleaseVersion).toString().isEmpty();
382 ui.buttonSmall->setEnabled(installable);
383 ui.buttonComplete->setEnabled(installable);
384 ui.actionSmall_Installation->setEnabled(installable);
385 ui.actionComplete_Installation->setEnabled(installable);
389 void RbUtilQt::updateManual()
391 if(RbSettings::value(RbSettings::Platform) != "")
393 QString manual= SystemInfo::value(SystemInfo::CurManual).toString();
395 if(manual == "")
396 manual = "rockbox-"
397 + SystemInfo::value(SystemInfo::CurBuildserverModel).toString();
398 QString pdfmanual;
399 pdfmanual = SystemInfo::value(SystemInfo::ManualUrl).toString()
400 + "/" + manual + ".pdf";
401 QString htmlmanual;
402 htmlmanual = SystemInfo::value(SystemInfo::ManualUrl).toString()
403 + "/" + manual + "/rockbox-build.html";
404 ui.labelPdfManual->setText(tr("<a href='%1'>PDF Manual</a>")
405 .arg(pdfmanual));
406 ui.labelHtmlManual->setText(tr("<a href='%1'>HTML Manual (opens in browser)</a>")
407 .arg(htmlmanual));
409 else {
410 ui.labelPdfManual->setText(tr("Select a device for a link to the correct manual"));
411 ui.labelHtmlManual->setText(tr("<a href='%1'>Manual Overview</a>")
412 .arg("http://www.rockbox.org/manual.shtml"));
417 void RbUtilQt::completeInstall()
419 if(chkConfig(true)) return;
420 if(QMessageBox::question(this, tr("Confirm Installation"),
421 tr("Do you really want to perform a complete installation?\n\n"
422 "This will install Rockbox %1. To install the most recent "
423 "development build available press \"Cancel\" and "
424 "use the \"Installation\" tab.")
425 .arg(ServerInfo::value(ServerInfo::CurReleaseVersion).toString()),
426 QMessageBox::Ok | QMessageBox::Cancel) != QMessageBox::Ok)
427 return;
428 // create logger
429 logger = new ProgressLoggerGui(this);
430 logger->show();
432 if(smallInstallInner())
433 return;
434 logger->setRunning();
435 // Fonts
436 m_error = false;
437 m_installed = false;
438 if(!installFontsAuto())
439 return;
440 else
442 // wait for installation finished
443 while(!m_installed)
444 QApplication::processEvents();
446 if(m_error) return;
447 logger->setRunning();
449 // Doom
450 if(hasDoom())
452 m_error = false;
453 m_installed = false;
454 if(!installDoomAuto())
455 return;
456 else
458 // wait for installation finished
459 while(!m_installed)
460 QApplication::processEvents();
462 if(m_error) return;
465 // theme
466 // this is a window
467 // it has its own logger window,so close our.
468 logger->close();
469 installThemes();
473 void RbUtilQt::smallInstall()
475 if(chkConfig(true)) return;
476 if(QMessageBox::question(this, tr("Confirm Installation"),
477 tr("Do you really want to perform a minimal installation? "
478 "A minimal installation will contain only the absolutely "
479 "necessary parts to run Rockbox.\n\n"
480 "This will install Rockbox %1. To install the most recent "
481 "development build available press \"Cancel\" and "
482 "use the \"Installation\" tab.")
483 .arg(ServerInfo::value(ServerInfo::CurReleaseVersion).toString()),
484 QMessageBox::Ok | QMessageBox::Cancel) != QMessageBox::Ok)
485 return;
487 // create logger
488 logger = new ProgressLoggerGui(this);
489 logger->show();
491 smallInstallInner();
494 bool RbUtilQt::smallInstallInner()
496 QString mountpoint = RbSettings::value(RbSettings::Mountpoint).toString();
497 // show dialog with error if mount point is wrong
498 if(!QFileInfo(mountpoint).isDir()) {
499 logger->addItem(tr("Mount point is wrong!"),LOGERROR);
500 logger->setFinished();
501 return true;
503 // Bootloader
504 if(SystemInfo::value(SystemInfo::CurBootloaderMethod) != "none")
506 m_error = false;
507 m_installed = false;
508 m_auto = true;
509 if(!installBootloaderAuto()) {
510 logger->setFinished();
511 return true;
513 else
515 // wait for boot loader installation finished
516 while(!m_installed)
517 QApplication::processEvents();
519 m_auto = false;
520 if(m_error) return true;
521 logger->setRunning();
524 // Rockbox
525 m_error = false;
526 m_installed = false;
527 if(!installAuto())
528 return true;
529 else
531 // wait for installation finished
532 while(!m_installed)
533 QApplication::processEvents();
536 installBootloaderPost(false);
537 return false;
540 void RbUtilQt::installdone(bool error)
542 qDebug() << "[RbUtil] install done";
543 m_installed = true;
544 m_error = error;
547 void RbUtilQt::installBtn()
549 if(chkConfig(true)) return;
550 install();
553 bool RbUtilQt::installAuto()
555 QString file = SystemInfo::value(SystemInfo::ReleaseUrl).toString();
556 file.replace("%MODEL%", SystemInfo::value(SystemInfo::CurBuildserverModel).toString());
557 file.replace("%RELVERSION%", ServerInfo::value(ServerInfo::CurReleaseVersion).toString());
559 // check installed Version and Target
560 QString warning = check(false);
561 if(!warning.isEmpty())
563 if(QMessageBox::warning(this, tr("Really continue?"), warning,
564 QMessageBox::Ok | QMessageBox::Abort, QMessageBox::Abort)
565 == QMessageBox::Abort)
567 logger->addItem(tr("Aborted!"), LOGERROR);
568 logger->setFinished();
569 return false;
573 // check version
574 RockboxInfo rbinfo(RbSettings::value(RbSettings::Mountpoint).toString());
575 if(rbinfo.version() != "")
577 if(QMessageBox::question(this, tr("Installed Rockbox detected"),
578 tr("Rockbox installation detected. Do you want to backup first?"),
579 QMessageBox::Yes | QMessageBox::No) == QMessageBox::Yes)
581 logger->addItem(tr("Starting backup..."),LOGINFO);
582 QString backupName = RbSettings::value(RbSettings::Mountpoint).toString()
583 + "/.backup/rockbox-backup-" + rbinfo.version() + ".zip";
585 //! create dir, if it doesnt exist
586 QFileInfo backupFile(backupName);
587 if(!QDir(backupFile.path()).exists())
589 QDir a;
590 a.mkpath(backupFile.path());
593 //! create backup
594 RbZip backup;
595 connect(&backup,SIGNAL(zipProgress(int,int)),logger, SLOT(setProgress(int,int)));
596 if(backup.createZip(backupName,
597 RbSettings::value(RbSettings::Mountpoint).toString() + "/.rockbox") == Zip::Ok)
599 logger->addItem(tr("Backup successful"),LOGOK);
601 else
603 logger->addItem(tr("Backup failed!"),LOGERROR);
604 logger->setFinished();
605 return false;
610 //! install current build
611 ZipInstaller* installer = new ZipInstaller(this);
612 installer->setUrl(file);
613 installer->setLogSection("Rockbox (Base)");
614 installer->setLogVersion(ServerInfo::value(ServerInfo::CurReleaseVersion).toString());
615 if(!RbSettings::value(RbSettings::CacheDisabled).toBool())
616 installer->setCache(true);
617 installer->setMountPoint(RbSettings::value(RbSettings::Mountpoint).toString());
619 connect(installer, SIGNAL(done(bool)), this, SLOT(installdone(bool)));
620 connect(installer, SIGNAL(logItem(QString, int)), logger, SLOT(addItem(QString, int)));
621 connect(installer, SIGNAL(logProgress(int, int)), logger, SLOT(setProgress(int, int)));
622 connect(installer, SIGNAL(done(bool)), logger, SLOT(setFinished()));
623 connect(logger, SIGNAL(aborted()), installer, SLOT(abort()));
624 installer->install();
625 return true;
629 void RbUtilQt::install()
631 InstallWindow *installWindow = new InstallWindow(this);
632 installWindow->show();
635 bool RbUtilQt::installBootloaderAuto()
637 installBootloader();
638 return !m_error;
641 void RbUtilQt::installBootloaderBtn()
643 if(chkConfig(true)) return;
644 if(QMessageBox::question(this, tr("Confirm Installation"),
645 tr("Do you really want to install the Bootloader?"),
646 QMessageBox::Yes | QMessageBox::No) != QMessageBox::Yes) return;
648 // create logger
649 logger = new ProgressLoggerGui(this);
650 logger->show();
651 installBootloader();
654 void RbUtilQt::installBootloader()
656 QString platform = RbSettings::value(RbSettings::Platform).toString();
657 QString backupDestination = "";
658 m_error = false;
660 // create installer
661 BootloaderInstallBase *bl;
662 QString type = SystemInfo::value(SystemInfo::CurBootloaderMethod).toString();
663 if(type == "mi4") {
664 bl = new BootloaderInstallMi4(this);
666 else if(type == "hex") {
667 bl = new BootloaderInstallHex(this);
669 else if(type == "sansa") {
670 bl = new BootloaderInstallSansa(this);
672 else if(type == "ipod") {
673 bl = new BootloaderInstallIpod(this);
675 else if(type == "file") {
676 bl = new BootloaderInstallFile(this);
678 else if(type == "chinachip") {
679 bl = new BootloaderInstallChinaChip(this);
681 else if(type == "ams") {
682 bl = new BootloaderInstallAms(this);
684 else if(type == "tcc") {
685 bl = new BootloaderInstallTcc(this);
687 else {
688 logger->addItem(tr("No install method known."), LOGERROR);
689 logger->setFinished();
690 return;
693 // set bootloader filename. Do this now as installed() needs it.
694 QStringList blfile = SystemInfo::value(SystemInfo::CurBootloaderFile).toStringList();
695 QStringList blfilepath;
696 for(int a = 0; a < blfile.size(); a++) {
697 blfilepath.append(RbSettings::value(RbSettings::Mountpoint).toString()
698 + blfile.at(a));
700 bl->setBlFile(blfilepath);
701 QUrl url(SystemInfo::value(SystemInfo::BootloaderUrl).toString()
702 + SystemInfo::value(SystemInfo::CurBootloaderName).toString());
703 bl->setBlUrl(url);
704 bl->setLogfile(RbSettings::value(RbSettings::Mountpoint).toString()
705 + "/.rockbox/rbutil.log");
707 if(bl->installed() == BootloaderInstallBase::BootloaderRockbox) {
708 if(QMessageBox::question(this, tr("Bootloader detected"),
709 tr("Bootloader already installed. Do you want to reinstall the bootloader?"),
710 QMessageBox::Yes | QMessageBox::No) == QMessageBox::No) {
711 if(m_auto) {
712 // keep logger open for auto installs.
713 // don't consider abort as error in auto-mode.
714 logger->addItem(tr("Bootloader installation skipped"), LOGINFO);
715 installBootloaderPost(false);
717 else {
718 logger->close();
719 installBootloaderPost(true);
721 delete bl;
722 return;
725 else if(bl->installed() == BootloaderInstallBase::BootloaderOther
726 && bl->capabilities() & BootloaderInstallBase::Backup)
728 QString targetFolder = SystemInfo::value(SystemInfo::CurPlatformName).toString()
729 + " Firmware Backup";
730 // remove invalid character(s)
731 targetFolder.remove(QRegExp("[:/]"));
732 if(QMessageBox::question(this, tr("Create Bootloader backup"),
733 tr("You can create a backup of the original bootloader "
734 "file. Press \"Yes\" to select an output folder on your "
735 "computer to save the file to. The file will get placed "
736 "in a new folder \"%1\" created below the selected folder.\n"
737 "Press \"No\" to skip this step.").arg(targetFolder),
738 QMessageBox::Yes | QMessageBox::No) == QMessageBox::Yes) {
739 backupDestination = QFileDialog::getExistingDirectory(this,
740 tr("Browse backup folder"), QDir::homePath());
741 if(!backupDestination.isEmpty())
742 backupDestination += "/" + targetFolder;
744 qDebug() << "[RbUtil] backing up to" << backupDestination;
745 // backup needs to be done after the logger has been set up.
749 if(bl->capabilities() & BootloaderInstallBase::NeedsOf)
751 int ret;
752 ret = QMessageBox::information(this, tr("Prerequisites"),
753 bl->ofHint(),QMessageBox::Ok | QMessageBox::Abort);
754 if(ret != QMessageBox::Ok) {
755 // consider aborting an error to close window / abort automatic
756 // installation.
757 m_error = true;
758 logger->addItem(tr("Bootloader installation aborted"), LOGINFO);
759 logger->setFinished();
760 return;
762 // open dialog to browse to of file
763 QString offile;
764 offile = QFileDialog::getOpenFileName(this,
765 tr("Select firmware file"), QDir::homePath());
766 if(!QFileInfo(offile).isReadable()) {
767 logger->addItem(tr("Error opening firmware file"), LOGERROR);
768 logger->setFinished();
769 m_error = true;
770 return;
772 bl->setOfFile(offile);
775 // the bootloader install class does NOT use any GUI stuff.
776 // All messages are passed via signals.
777 connect(bl, SIGNAL(done(bool)), logger, SLOT(setFinished()));
778 connect(bl, SIGNAL(done(bool)), this, SLOT(installBootloaderPost(bool)));
779 connect(bl, SIGNAL(logItem(QString, int)), logger, SLOT(addItem(QString, int)));
780 connect(bl, SIGNAL(logProgress(int, int)), logger, SLOT(setProgress(int, int)));
782 // start install.
783 if(!backupDestination.isEmpty()) {
784 if(!bl->backup(backupDestination)) {
785 if(QMessageBox::warning(this, tr("Backup error"),
786 tr("Could not create backup file. Continue?"),
787 QMessageBox::No | QMessageBox::Yes)
788 == QMessageBox::No) {
789 logger->setFinished();
790 return;
794 bl->install();
797 void RbUtilQt::installBootloaderPost(bool error)
799 qDebug() << "[RbUtil] Bootloader Post-Installation, error state:" << error;
800 // if an error occured don't perform post install steps.
801 if(error) {
802 m_error = true;
803 return;
805 else
806 m_error = false;
808 m_installed = true;
809 // end here if automated install
810 if(m_auto)
811 return;
813 QString msg = BootloaderInstallBase::postinstallHints(
814 RbSettings::value(RbSettings::Platform).toString());
815 if(!msg.isEmpty()) {
816 QMessageBox::information(this, tr("Manual steps required"), msg);
817 logger->close();
822 void RbUtilQt::installFontsBtn()
824 if(chkConfig(true)) return;
825 if(QMessageBox::question(this, tr("Confirm Installation"),
826 tr("Do you really want to install the fonts package?"),
827 QMessageBox::Yes | QMessageBox::No) != QMessageBox::Yes) return;
828 // create logger
829 logger = new ProgressLoggerGui(this);
830 logger->show();
831 installFonts();
834 bool RbUtilQt::installFontsAuto()
836 installFonts();
838 return !m_error;
841 void RbUtilQt::installFonts()
843 // create zip installer
844 installer = new ZipInstaller(this);
846 installer->setUrl(SystemInfo::value(SystemInfo::FontUrl).toString());
847 installer->setLogSection("Fonts");
848 installer->setLogVersion(ServerInfo::value(ServerInfo::DailyDate).toString());
849 installer->setMountPoint(RbSettings::value(RbSettings::Mountpoint).toString());
850 if(!RbSettings::value(RbSettings::CacheDisabled).toBool())
851 installer->setCache(true);
853 connect(installer, SIGNAL(done(bool)), this, SLOT(installdone(bool)));
854 connect(installer, SIGNAL(logItem(QString, int)), logger, SLOT(addItem(QString, int)));
855 connect(installer, SIGNAL(logProgress(int, int)), logger, SLOT(setProgress(int, int)));
856 connect(installer, SIGNAL(done(bool)), logger, SLOT(setFinished()));
857 connect(logger, SIGNAL(aborted()), installer, SLOT(abort()));
858 installer->install();
862 void RbUtilQt::installVoice()
864 if(chkConfig(true)) return;
866 if(m_gotInfo == false)
868 QMessageBox::warning(this, tr("Warning"),
869 tr("The Application is still downloading Information about new Builds."
870 " Please try again shortly."));
871 return;
874 if(QMessageBox::question(this, tr("Confirm Installation"),
875 tr("Do you really want to install the voice file?"),
876 QMessageBox::Yes | QMessageBox::No) != QMessageBox::Yes) return;
877 // create logger
878 logger = new ProgressLoggerGui(this);
879 logger->show();
881 // create zip installer
882 installer = new ZipInstaller(this);
884 QString voiceurl = SystemInfo::value(SystemInfo::VoiceUrl).toString();
885 QDate date = QDate::fromString(ServerInfo::value(ServerInfo::DailyDate).toString(),Qt::ISODate);
886 voiceurl += SystemInfo::value(SystemInfo::CurBuildserverModel).toString() + "-" +
887 date.toString("yyyyMMdd") + "-english.zip";
888 qDebug() << "[RbUtil] voicefile URL:" << voiceurl;
890 installer->setUrl(voiceurl);
891 installer->setLogSection("Voice");
892 installer->setLogVersion(ServerInfo::value(ServerInfo::DailyDate).toString());
893 installer->setMountPoint(RbSettings::value(RbSettings::Mountpoint).toString());
894 if(!RbSettings::value(RbSettings::CacheDisabled).toBool())
895 installer->setCache(true);
896 connect(installer, SIGNAL(logItem(QString, int)), logger, SLOT(addItem(QString, int)));
897 connect(installer, SIGNAL(logProgress(int, int)), logger, SLOT(setProgress(int, int)));
898 connect(installer, SIGNAL(done(bool)), logger, SLOT(setFinished()));
899 connect(logger, SIGNAL(aborted()), installer, SLOT(abort()));
900 installer->install();
904 void RbUtilQt::installDoomBtn()
906 if(chkConfig(true)) return;
907 if(!hasDoom()){
908 QMessageBox::critical(this, tr("Error"),
909 tr("Your device doesn't have a doom plugin. Aborting."));
910 return;
913 if(QMessageBox::question(this, tr("Confirm Installation"),
914 tr("Do you really want to install the game addon files?"),
915 QMessageBox::Yes | QMessageBox::No) != QMessageBox::Yes) return;
916 // create logger
917 logger = new ProgressLoggerGui(this);
918 logger->show();
920 installDoom();
922 bool RbUtilQt::installDoomAuto()
924 installDoom();
925 return !m_error;
928 bool RbUtilQt::hasDoom()
930 QFile doomrock(RbSettings::value(RbSettings::Mountpoint).toString()
931 +"/.rockbox/rocks/games/doom.rock");
932 return doomrock.exists();
935 void RbUtilQt::installDoom()
937 // create zip installer
938 installer = new ZipInstaller(this);
940 installer->setUrl(SystemInfo::value(SystemInfo::DoomUrl).toString());
941 installer->setLogSection("Game Addons");
942 installer->setLogVersion(ServerInfo::value(ServerInfo::DailyDate).toString());
943 installer->setMountPoint(RbSettings::value(RbSettings::Mountpoint).toString());
944 if(!RbSettings::value(RbSettings::CacheDisabled).toBool())
945 installer->setCache(true);
946 connect(installer, SIGNAL(done(bool)), this, SLOT(installdone(bool)));
947 connect(installer, SIGNAL(logItem(QString, int)), logger, SLOT(addItem(QString, int)));
948 connect(installer, SIGNAL(logProgress(int, int)), logger, SLOT(setProgress(int, int)));
949 connect(installer, SIGNAL(done(bool)), logger, SLOT(setFinished()));
950 connect(logger, SIGNAL(aborted()), installer, SLOT(abort()));
951 installer->install();
955 void RbUtilQt::installThemes()
957 if(chkConfig(true)) return;
958 ThemesInstallWindow* tw = new ThemesInstallWindow(this);
959 tw->setModal(true);
960 tw->show();
963 void RbUtilQt::createTalkFiles(void)
965 if(chkConfig(true)) return;
966 InstallTalkWindow *installWindow = new InstallTalkWindow(this);
967 connect(installWindow, SIGNAL(settingsUpdated()), this, SLOT(updateSettings()));
968 installWindow->show();
972 void RbUtilQt::createVoiceFile(void)
974 if(chkConfig(true)) return;
975 CreateVoiceWindow *installWindow = new CreateVoiceWindow(this);
977 connect(installWindow, SIGNAL(settingsUpdated()), this, SLOT(updateSettings()));
978 installWindow->show();
981 void RbUtilQt::uninstall(void)
983 if(chkConfig(true)) return;
984 UninstallWindow *uninstallWindow = new UninstallWindow(this);
985 uninstallWindow->show();
989 void RbUtilQt::uninstallBootloader(void)
991 if(chkConfig(true)) return;
992 if(QMessageBox::question(this, tr("Confirm Uninstallation"),
993 tr("Do you really want to uninstall the Bootloader?"),
994 QMessageBox::Yes | QMessageBox::No) != QMessageBox::Yes) return;
995 // create logger
996 ProgressLoggerGui* logger = new ProgressLoggerGui(this);
997 logger->setProgressVisible(false);
998 logger->show();
1000 QString platform = RbSettings::value(RbSettings::Platform).toString();
1002 // create installer
1003 BootloaderInstallBase *bl;
1004 QString type = SystemInfo::value(SystemInfo::CurBootloaderMethod).toString();
1005 if(type == "mi4") {
1006 bl = new BootloaderInstallMi4(this);
1008 else if(type == "hex") {
1009 bl = new BootloaderInstallHex(this);
1011 else if(type == "sansa") {
1012 bl = new BootloaderInstallSansa(this);
1014 else if(type == "ipod") {
1015 bl = new BootloaderInstallIpod(this);
1017 else if(type == "file") {
1018 bl = new BootloaderInstallFile(this);
1020 else {
1021 logger->addItem(tr("No uninstall method known."), LOGERROR);
1022 logger->setFinished();
1023 return;
1026 QStringList blfile = SystemInfo::value(SystemInfo::CurBootloaderFile).toStringList();
1027 QStringList blfilepath;
1028 for(int a = 0; a < blfile.size(); a++) {
1029 blfilepath.append(RbSettings::value(RbSettings::Mountpoint).toString()
1030 + blfile.at(a));
1032 bl->setBlFile(blfilepath);
1034 connect(bl, SIGNAL(logItem(QString, int)), logger, SLOT(addItem(QString, int)));
1035 connect(bl, SIGNAL(logProgress(int, int)), logger, SLOT(setProgress(int, int)));
1037 int result;
1038 result = bl->uninstall();
1040 logger->setFinished();
1045 void RbUtilQt::downloadManual(void)
1047 if(chkConfig(true)) return;
1048 if(QMessageBox::question(this, tr("Confirm download"),
1049 tr("Do you really want to download the manual? The manual will be saved "
1050 "to the root folder of your player."),
1051 QMessageBox::Yes | QMessageBox::No) != QMessageBox::Yes)
1052 return;
1054 QString manual = SystemInfo::value(SystemInfo::CurManual).toString();
1055 if(manual.isEmpty())
1056 manual = "rockbox-"
1057 + SystemInfo::value(SystemInfo::CurBuildserverModel).toString();
1059 QString date = ServerInfo::value(ServerInfo::DailyDate).toString();
1061 QString manualurl;
1062 QString target;
1063 QString section;
1064 if(ui.radioPdf->isChecked()) {
1065 target = "/" + manual + ".pdf";
1066 section = "Manual (PDF)";
1068 else {
1069 target = "/" + manual + "-" + date + "-html.zip";
1070 section = "Manual (HTML)";
1072 manualurl = SystemInfo::value(SystemInfo::ManualUrl).toString() + "/" + target;
1073 qDebug() << "[RbUtil] Manual URL:" << manualurl;
1075 ProgressLoggerGui* logger = new ProgressLoggerGui(this);
1076 logger->show();
1077 installer = new ZipInstaller(this);
1078 installer->setMountPoint(RbSettings::value(RbSettings::Mountpoint).toString());
1079 if(!RbSettings::value(RbSettings::CacheDisabled).toBool())
1080 installer->setCache(true);
1081 installer->setLogSection(section);
1082 installer->setLogVersion(date);
1083 installer->setUrl(manualurl);
1084 installer->setUnzip(false);
1085 installer->setTarget(target);
1086 connect(installer, SIGNAL(logItem(QString, int)), logger, SLOT(addItem(QString, int)));
1087 connect(installer, SIGNAL(logProgress(int, int)), logger, SLOT(setProgress(int, int)));
1088 connect(installer, SIGNAL(done(bool)), logger, SLOT(setFinished()));
1089 connect(logger, SIGNAL(aborted()), installer, SLOT(abort()));
1090 installer->install();
1094 void RbUtilQt::installPortable(void)
1096 if(QMessageBox::question(this, tr("Confirm installation"),
1097 tr("Do you really want to install Rockbox Utility to your player? "
1098 "After installation you can run it from the players hard drive."),
1099 QMessageBox::Yes | QMessageBox::No) != QMessageBox::Yes)
1100 return;
1102 ProgressLoggerGui* logger = new ProgressLoggerGui(this);
1103 logger->setProgressMax(0);
1104 logger->setProgressValue(0);
1105 logger->show();
1106 logger->addItem(tr("Installing Rockbox Utility"), LOGINFO);
1108 // check mountpoint
1109 if(!QFileInfo(RbSettings::value(RbSettings::Mountpoint).toString()).isDir()) {
1110 logger->addItem(tr("Mount point is wrong!"),LOGERROR);
1111 logger->setFinished();
1112 return;
1115 // remove old files first.
1116 QFile::remove(RbSettings::value(RbSettings::Mountpoint).toString()
1117 + "/RockboxUtility.exe");
1118 QFile::remove(RbSettings::value(RbSettings::Mountpoint).toString()
1119 + "/RockboxUtility.ini");
1120 // copy currently running binary and currently used settings file
1121 if(!QFile::copy(qApp->applicationFilePath(),
1122 RbSettings::value(RbSettings::Mountpoint).toString()
1123 + "/RockboxUtility.exe")) {
1124 logger->addItem(tr("Error installing Rockbox Utility"), LOGERROR);
1125 logger->setFinished();
1126 return;
1128 logger->addItem(tr("Installing user configuration"), LOGINFO);
1129 if(!QFile::copy(RbSettings::userSettingFilename(),
1130 RbSettings::value(RbSettings::Mountpoint).toString()
1131 + "/RockboxUtility.ini")) {
1132 logger->addItem(tr("Error installing user configuration"), LOGERROR);
1133 logger->setFinished();
1134 return;
1136 logger->addItem(tr("Successfully installed Rockbox Utility."), LOGOK);
1137 logger->setFinished();
1138 logger->setProgressMax(1);
1139 logger->setProgressValue(1);
1144 void RbUtilQt::updateInfo()
1146 qDebug() << "[RbUtil] updating server info";
1148 QSettings log(RbSettings::value(RbSettings::Mountpoint).toString()
1149 + "/.rockbox/rbutil.log", QSettings::IniFormat, this);
1150 QStringList groups = log.childGroups();
1151 QList<QTreeWidgetItem *> items;
1152 QTreeWidgetItem *w, *w2;
1153 QString min, max;
1154 int olditems = 0;
1156 // remove old list entries (if any)
1157 int l = ui.treeInfo->topLevelItemCount();
1158 while(l--) {
1159 QTreeWidgetItem *m;
1160 m = ui.treeInfo->takeTopLevelItem(l);
1161 // delete childs (single level deep, no recursion here)
1162 int n = m->childCount();
1163 while(n--)
1164 delete m->child(n);
1166 // get and populate new items
1167 for(int a = 0; a < groups.size(); a++) {
1168 log.beginGroup(groups.at(a));
1169 QStringList keys = log.allKeys();
1170 w = new QTreeWidgetItem;
1171 w->setFlags(Qt::ItemIsEnabled);
1172 w->setText(0, groups.at(a));
1173 items.append(w);
1174 // get minimum and maximum version information so we can hilight old files
1175 min = max = log.value(keys.at(0)).toString();
1176 for(int b = 0; b < keys.size(); b++) {
1177 if(log.value(keys.at(b)).toString() > max)
1178 max = log.value(keys.at(b)).toString();
1179 if(log.value(keys.at(b)).toString() < min)
1180 min = log.value(keys.at(b)).toString();
1183 for(int b = 0; b < keys.size(); b++) {
1184 QString file;
1185 file = RbSettings::value(RbSettings::Mountpoint).toString() + "/" + keys.at(b);
1186 if(QFileInfo(file).isDir())
1187 continue;
1188 w2 = new QTreeWidgetItem(w, QStringList() << "/"
1189 + keys.at(b) << log.value(keys.at(b)).toString());
1190 if(log.value(keys.at(b)).toString() != max) {
1191 w2->setForeground(0, QBrush(QColor(255, 0, 0)));
1192 w2->setForeground(1, QBrush(QColor(255, 0, 0)));
1193 olditems++;
1195 items.append(w2);
1197 log.endGroup();
1198 if(min != max)
1199 w->setData(1, Qt::DisplayRole, QString("%1 / %2").arg(min, max));
1200 else
1201 w->setData(1, Qt::DisplayRole, max);
1203 ui.treeInfo->insertTopLevelItems(0, items);
1204 ui.treeInfo->resizeColumnToContents(0);
1208 QUrl RbUtilQt::proxy()
1210 if(RbSettings::value(RbSettings::ProxyType) == "manual")
1211 return QUrl(RbSettings::value(RbSettings::Proxy).toString());
1212 else if(RbSettings::value(RbSettings::ProxyType) == "system")
1213 return System::systemProxy();
1214 return QUrl("");
1218 bool RbUtilQt::chkConfig(bool warn)
1220 bool error = false;
1221 if(RbSettings::value(RbSettings::Platform).toString().isEmpty()
1222 || RbSettings::value(RbSettings::Mountpoint).toString().isEmpty()
1223 || !QFileInfo(RbSettings::value(RbSettings::Mountpoint).toString()).isWritable()) {
1224 error = true;
1226 if(warn) QMessageBox::critical(this, tr("Configuration error"),
1227 tr("Your configuration is invalid. Please go to the configuration "
1228 "dialog and make sure the selected values are correct."));
1230 return error;
1233 void RbUtilQt::checkUpdate(void)
1235 QString url = SystemInfo::value(SystemInfo::RbutilUrl).toString();
1236 #if defined(Q_OS_WIN32)
1237 url += "win32/";
1238 #elif defined(Q_OS_LINUX)
1239 url += "linux/";
1240 #elif defined(Q_OS_MACX)
1241 url += "macosx/";
1242 #endif
1244 update = new HttpGet(this);
1245 connect(update, SIGNAL(done(bool)), this, SLOT(downloadUpdateDone(bool)));
1246 connect(update, SIGNAL(requestFinished(int, bool)), this, SLOT(downloadDone(int, bool)));
1247 connect(qApp, SIGNAL(lastWindowClosed()), update, SLOT(abort()));
1248 if(RbSettings::value(RbSettings::CacheOffline).toBool())
1249 update->setCache(true);
1251 update->getFile(QUrl(url));
1254 void RbUtilQt::downloadUpdateDone(bool error)
1256 if(error) {
1257 qDebug() << "[RbUtil] network error:" << update->error();
1259 else {
1260 QString toParse(update->readAll());
1262 QRegExp searchString("<a[^>]*>([a-zA-Z]+[^<]*)</a>");
1263 QStringList rbutilList;
1264 int pos = 0;
1265 while ((pos = searchString.indexIn(toParse, pos)) != -1)
1267 rbutilList << searchString.cap(1);
1268 pos += searchString.matchedLength();
1270 qDebug() << "[Checkupdate] " << rbutilList;
1272 QString newVersion ="";
1273 //check if there is a binary with higher version in this list
1274 for(int i=0; i < rbutilList.size(); i++)
1276 #if defined(Q_OS_LINUX)
1277 #if defined(__amd64__)
1278 //skip if it isnt a 64bit build
1279 if( !rbutilList.at(i).contains("64bit"))
1280 continue;
1281 #else
1282 //skip if it is a 64bit build
1283 if(rbutilList.at(i).contains("64bit"))
1284 continue;
1285 #endif
1286 #endif
1287 //check if it is newer, and remember newest
1288 if(newerVersion(VERSION,rbutilList.at(i)))
1290 if(newVersion == "" || newerVersion(newVersion,rbutilList.at(i)))
1292 newVersion = rbutilList.at(i);
1297 // if we found something newer, display info
1298 if(newVersion != "")
1300 QString url = SystemInfo::value(SystemInfo::RbutilUrl).toString();
1301 #if defined(Q_OS_WIN32)
1302 url += "win32/";
1303 #elif defined(Q_OS_LINUX)
1304 url += "linux/";
1305 #elif defined(Q_OS_MACX)
1306 url += "macosx/";
1307 #endif
1308 url += newVersion;
1310 QMessageBox::information(this,tr("RockboxUtility Update available"),
1311 tr("<b>New RockboxUtility Version available.</b> <br><br>"
1312 "Download it from here: <a href='%1'>%2</a>").arg(url).arg(newVersion) );
1317 bool RbUtilQt::newerVersion(QString versionOld,QString versionNew)
1319 QRegExp chars("\\d*(\\D)");
1321 //strip non-number from beginning
1322 versionOld = versionOld.remove(0,versionOld.indexOf(QRegExp("\\d")));
1323 versionNew = versionNew.remove(0,versionNew.indexOf(QRegExp("\\d")));
1325 // split versions by "."
1326 QStringList versionListOld = versionOld.split(".");
1327 QStringList versionListNew = versionNew.split(".");
1329 QStringListIterator iteratorOld(versionListOld);
1330 QStringListIterator iteratorNew(versionListNew);
1332 //check every section
1333 while(iteratorOld.hasNext() && iteratorNew.hasNext())
1335 QString newPart = iteratorNew.next();
1336 QString oldPart = iteratorOld.next();
1337 QString newPartChar = "", oldPartChar = "";
1338 int newPartInt = 0, oldPartInt =0;
1340 //convert to int, if it contains chars, put into seperated variable
1341 if(newPart.contains(chars))
1343 newPartChar = chars.cap(1);
1344 newPart = newPart.remove(newPartChar);
1346 newPartInt = newPart.toInt();
1347 //convert to int, if it contains chars, put into seperated variable
1348 if(oldPart.contains(chars))
1350 oldPartChar = chars.cap(1);
1351 oldPart = oldPart.remove(oldPartChar);
1353 oldPartInt = oldPart.toInt();
1355 if(newPartInt > oldPartInt) // this section int is higher -> true
1356 return true;
1357 else if(newPartInt < oldPartInt) //this section int is lower -> false
1358 return false;
1359 else if(newPartChar > oldPartChar) //ints are the same, chars is higher -> true
1360 return true;
1361 else if(newPartChar < oldPartChar) //ints are the same, chars is lower -> false
1362 return false;
1363 //all the same, next section
1365 // all the same -> false
1366 return false;