Packard Bell Vibe 500: correct the path to a proper one in rbutil (proper directory...
[kugel-rb.git] / rbutil / rbutilqt / rbutilqt.cpp
blobececb782d4481c577d32ff435ce772d44d551f99
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 SysTrace::save();
153 this->close();
157 void RbUtilQt::trace(void)
159 SysTrace wnd(this);
160 wnd.exec();
163 void RbUtilQt::sysinfo(void)
165 Sysinfo info(this);
166 info.exec();
169 void RbUtilQt::updateTabs(int count)
171 switch(count) {
172 case 6:
173 updateInfo();
174 break;
175 default:
176 break;
181 void RbUtilQt::downloadInfo()
183 // try to get the current build information
184 daily = new HttpGet(this);
185 connect(daily, SIGNAL(done(bool)), this, SLOT(downloadDone(bool)));
186 connect(daily, SIGNAL(requestFinished(int, bool)), this, SLOT(downloadDone(int, bool)));
187 connect(qApp, SIGNAL(lastWindowClosed()), daily, SLOT(abort()));
188 if(RbSettings::value(RbSettings::CacheOffline).toBool())
189 daily->setCache(true);
190 else
191 daily->setCache(false);
192 ui.statusbar->showMessage(tr("Downloading build information, please wait ..."));
193 qDebug() << "[RbUtil] downloading build info";
194 daily->setFile(&buildInfo);
195 daily->getFile(QUrl(SystemInfo::value(SystemInfo::ServerConfUrl).toString()));
199 void RbUtilQt::downloadDone(bool error)
201 if(error) {
202 qDebug() << "[RbUtil] network error:" << daily->error();
203 ui.statusbar->showMessage(tr("Can't get version information!"));
204 QMessageBox::critical(this, tr("Network error"),
205 tr("Can't get version information."));
206 return;
208 qDebug() << "[RbUtil] network status:" << daily->error();
210 // read info into ServerInfo object
211 buildInfo.open();
212 ServerInfo::readBuildInfo(buildInfo.fileName());
213 buildInfo.close();
215 //start bleeding info download
216 bleeding = new HttpGet(this);
217 connect(bleeding, SIGNAL(done(bool)), this, SLOT(downloadBleedingDone(bool)));
218 connect(bleeding, SIGNAL(requestFinished(int, bool)), this, SLOT(downloadDone(int, bool)));
219 connect(qApp, SIGNAL(lastWindowClosed()), bleeding, SLOT(abort()));
220 if(RbSettings::value(RbSettings::CacheOffline).toBool())
221 bleeding->setCache(true);
222 bleeding->setFile(&bleedingInfo);
223 bleeding->getFile(QUrl(SystemInfo::value(SystemInfo::BleedingInfo).toString()));
224 ui.statusbar->showMessage(tr("Downloading build information, please wait ..."));
229 void RbUtilQt::downloadBleedingDone(bool error)
231 if(error) {
232 qDebug() << "[RbUtil] network error:" << bleeding->error();
234 else {
235 bleedingInfo.open();
236 ServerInfo::readBleedingInfo(bleedingInfo.fileName());
237 bleedingInfo.close();
239 ui.statusbar->showMessage(tr("Download build information finished."), 5000);
240 updateSettings();
241 m_gotInfo = true;
243 //start check for updates
244 checkUpdate();
249 void RbUtilQt::downloadDone(int id, bool error)
251 QString errorString;
252 errorString = tr("Network error: %1. Please check your network and proxy settings.")
253 .arg(daily->errorString());
254 if(error) {
255 QMessageBox::about(this, "Network Error", errorString);
256 m_networkerror = daily->errorString();
258 qDebug() << "[RbUtil] downloadDone:" << id << "error:" << error;
262 void RbUtilQt::about()
264 QDialog *window = new QDialog(this);
265 Ui::aboutBox about;
266 about.setupUi(window);
267 window->setLayoutDirection(Qt::LeftToRight);
268 window->setModal(true);
270 QFile licence(":/docs/gpl-2.0.html");
271 licence.open(QIODevice::ReadOnly);
272 QTextStream c(&licence);
273 QString cline = c.readAll();
274 about.browserLicense->insertHtml(cline);
275 about.browserLicense->moveCursor(QTextCursor::Start, QTextCursor::MoveAnchor);
276 QFile credits(":/docs/CREDITS");
277 credits.open(QIODevice::ReadOnly);
278 QTextStream r(&credits);
279 r.setCodec(QTextCodec::codecForName("UTF-8"));
280 while(!r.atEnd()) {
281 QString line = r.readLine();
282 // filter out header.
283 line.remove(QRegExp("^[^A-Z]+.*"));
284 line.remove(QRegExp("^People.*"));
285 about.browserCredits->append(line);
287 about.browserCredits->moveCursor(QTextCursor::Start, QTextCursor::MoveAnchor);
288 QString title = QString("<b>The Rockbox Utility</b><br/>Version %1").arg(FULLVERSION);
289 about.labelTitle->setText(title);
291 window->show();
296 void RbUtilQt::help()
298 QUrl helpurl("http://www.rockbox.org/wiki/RockboxUtility");
299 QDesktopServices::openUrl(helpurl);
303 void RbUtilQt::configDialog()
305 Config *cw = new Config(this);
306 connect(cw, SIGNAL(settingsUpdated()), this, SLOT(updateSettings()));
307 cw->show();
311 void RbUtilQt::updateSettings()
313 qDebug() << "[RbUtil] updating current settings";
314 updateDevice();
315 updateManual();
316 if(RbSettings::value(RbSettings::ProxyType) == "system") {
317 HttpGet::setGlobalProxy(System::systemProxy());
319 else if(RbSettings::value(RbSettings::ProxyType) == "manual") {
320 HttpGet::setGlobalProxy(RbSettings::value(RbSettings::Proxy).toString());
322 else {
323 HttpGet::setGlobalProxy(QUrl(""));
325 HttpGet::setGlobalCache(RbSettings::value(RbSettings::CachePath).toString());
326 HttpGet::setGlobalDumbCache(RbSettings::value(RbSettings::CacheOffline).toBool());
328 if(RbSettings::value(RbSettings::RbutilVersion) != PUREVERSION) {
329 QApplication::processEvents();
330 QMessageBox::information(this, tr("New installation"),
331 tr("This is a new installation of Rockbox Utility, or a new version. "
332 "The configuration dialog will now open to allow you to setup the program, "
333 " or review your settings."));
334 configDialog();
336 else if(chkConfig(false)) {
337 QApplication::processEvents();
338 QMessageBox::critical(this, tr("Configuration error"),
339 tr("Your configuration is invalid. This is most likely due "
340 "to a changed device path. The configuration dialog will "
341 "now open to allow you to correct the problem."));
342 configDialog();
347 void RbUtilQt::updateDevice()
349 /* TODO: We should check the flags of the bootloaderinstall classes, and not
350 * just check if its != none or != "fwpatcher" */
352 /* Enable bootloader installation, if possible */
353 bool bootloaderInstallable =
354 SystemInfo::value(SystemInfo::CurBootloaderMethod) != "none";
355 ui.buttonBootloader->setEnabled(bootloaderInstallable);
356 ui.labelBootloader->setEnabled(bootloaderInstallable);
357 ui.actionInstall_Bootloader->setEnabled(bootloaderInstallable);
359 /* Enable bootloader uninstallation, if possible */
360 bool bootloaderUninstallable = bootloaderInstallable &&
361 SystemInfo::value(SystemInfo::CurBootloaderMethod) != "fwpatcher";
362 ui.labelRemoveBootloader->setEnabled(bootloaderUninstallable);
363 ui.buttonRemoveBootloader->setEnabled(bootloaderUninstallable);
364 ui.actionRemove_bootloader->setEnabled(bootloaderUninstallable);
366 /* Disable the whole tab widget if configuration is invalid */
367 bool configurationValid = !chkConfig(false);
368 ui.tabWidget->setEnabled(configurationValid);
369 ui.menuA_ctions->setEnabled(configurationValid);
371 // displayed device info
372 QString mountpoint = RbSettings::value(RbSettings::Mountpoint).toString();
373 QString brand = SystemInfo::value(SystemInfo::CurBrand).toString();
374 QString name = SystemInfo::value(SystemInfo::CurName).toString() +
375 " (" + ServerInfo::value(ServerInfo::CurStatus).toString() + ")";
376 if(name.isEmpty()) name = "&lt;none&gt;";
377 if(mountpoint.isEmpty()) mountpoint = "&lt;invalid&gt;";
378 ui.labelDevice->setText(tr("<b>%1 %2</b> at <b>%3</b>")
379 .arg(brand, name, QDir::toNativeSeparators(mountpoint)));
381 // hide quickstart buttons if no release available
382 bool installable = !ServerInfo::value(ServerInfo::CurReleaseVersion).toString().isEmpty();
383 ui.buttonSmall->setEnabled(installable);
384 ui.buttonComplete->setEnabled(installable);
385 ui.actionSmall_Installation->setEnabled(installable);
386 ui.actionComplete_Installation->setEnabled(installable);
390 void RbUtilQt::updateManual()
392 if(RbSettings::value(RbSettings::Platform) != "")
394 QString manual= SystemInfo::value(SystemInfo::CurManual).toString();
396 if(manual == "")
397 manual = "rockbox-"
398 + SystemInfo::value(SystemInfo::CurBuildserverModel).toString();
399 QString pdfmanual;
400 pdfmanual = SystemInfo::value(SystemInfo::ManualUrl).toString()
401 + "/" + manual + ".pdf";
402 QString htmlmanual;
403 htmlmanual = SystemInfo::value(SystemInfo::ManualUrl).toString()
404 + "/" + manual + "/rockbox-build.html";
405 ui.labelPdfManual->setText(tr("<a href='%1'>PDF Manual</a>")
406 .arg(pdfmanual));
407 ui.labelHtmlManual->setText(tr("<a href='%1'>HTML Manual (opens in browser)</a>")
408 .arg(htmlmanual));
410 else {
411 ui.labelPdfManual->setText(tr("Select a device for a link to the correct manual"));
412 ui.labelHtmlManual->setText(tr("<a href='%1'>Manual Overview</a>")
413 .arg("http://www.rockbox.org/manual.shtml"));
418 void RbUtilQt::completeInstall()
420 if(chkConfig(true)) return;
421 if(QMessageBox::question(this, tr("Confirm Installation"),
422 tr("Do you really want to perform a complete installation?\n\n"
423 "This will install Rockbox %1. To install the most recent "
424 "development build available press \"Cancel\" and "
425 "use the \"Installation\" tab.")
426 .arg(ServerInfo::value(ServerInfo::CurReleaseVersion).toString()),
427 QMessageBox::Ok | QMessageBox::Cancel) != QMessageBox::Ok)
428 return;
429 // create logger
430 logger = new ProgressLoggerGui(this);
431 logger->show();
433 if(smallInstallInner())
434 return;
435 logger->setRunning();
436 // Fonts
437 m_error = false;
438 m_installed = false;
439 if(!installFontsAuto())
440 return;
441 else
443 // wait for installation finished
444 while(!m_installed)
445 QApplication::processEvents();
447 if(m_error) return;
448 logger->setRunning();
450 // Doom
451 if(hasDoom())
453 m_error = false;
454 m_installed = false;
455 if(!installDoomAuto())
456 return;
457 else
459 // wait for installation finished
460 while(!m_installed)
461 QApplication::processEvents();
463 if(m_error) return;
466 // theme
467 // this is a window
468 // it has its own logger window,so close our.
469 logger->close();
470 installThemes();
474 void RbUtilQt::smallInstall()
476 if(chkConfig(true)) return;
477 if(QMessageBox::question(this, tr("Confirm Installation"),
478 tr("Do you really want to perform a minimal installation? "
479 "A minimal installation will contain only the absolutely "
480 "necessary parts to run Rockbox.\n\n"
481 "This will install Rockbox %1. To install the most recent "
482 "development build available press \"Cancel\" and "
483 "use the \"Installation\" tab.")
484 .arg(ServerInfo::value(ServerInfo::CurReleaseVersion).toString()),
485 QMessageBox::Ok | QMessageBox::Cancel) != QMessageBox::Ok)
486 return;
488 // create logger
489 logger = new ProgressLoggerGui(this);
490 logger->show();
492 smallInstallInner();
495 bool RbUtilQt::smallInstallInner()
497 QString mountpoint = RbSettings::value(RbSettings::Mountpoint).toString();
498 // show dialog with error if mount point is wrong
499 if(!QFileInfo(mountpoint).isDir()) {
500 logger->addItem(tr("Mount point is wrong!"),LOGERROR);
501 logger->setFinished();
502 return true;
504 // Bootloader
505 if(SystemInfo::value(SystemInfo::CurBootloaderMethod) != "none")
507 m_error = false;
508 m_installed = false;
509 m_auto = true;
510 if(!installBootloaderAuto()) {
511 logger->setFinished();
512 return true;
514 else
516 // wait for boot loader installation finished
517 while(!m_installed)
518 QApplication::processEvents();
520 m_auto = false;
521 if(m_error) return true;
522 logger->setRunning();
525 // Rockbox
526 m_error = false;
527 m_installed = false;
528 if(!installAuto())
529 return true;
530 else
532 // wait for installation finished
533 while(!m_installed)
534 QApplication::processEvents();
537 installBootloaderPost(false);
538 return false;
541 void RbUtilQt::installdone(bool error)
543 qDebug() << "[RbUtil] install done";
544 m_installed = true;
545 m_error = error;
548 void RbUtilQt::installBtn()
550 if(chkConfig(true)) return;
551 install();
554 bool RbUtilQt::installAuto()
556 QString file = SystemInfo::value(SystemInfo::ReleaseUrl).toString();
557 file.replace("%MODEL%", SystemInfo::value(SystemInfo::CurBuildserverModel).toString());
558 file.replace("%RELVERSION%", ServerInfo::value(ServerInfo::CurReleaseVersion).toString());
560 // check installed Version and Target
561 QString warning = check(false);
562 if(!warning.isEmpty())
564 if(QMessageBox::warning(this, tr("Really continue?"), warning,
565 QMessageBox::Ok | QMessageBox::Abort, QMessageBox::Abort)
566 == QMessageBox::Abort)
568 logger->addItem(tr("Aborted!"), LOGERROR);
569 logger->setFinished();
570 return false;
574 // check version
575 RockboxInfo rbinfo(RbSettings::value(RbSettings::Mountpoint).toString());
576 if(rbinfo.version() != "")
578 if(QMessageBox::question(this, tr("Installed Rockbox detected"),
579 tr("Rockbox installation detected. Do you want to backup first?"),
580 QMessageBox::Yes | QMessageBox::No) == QMessageBox::Yes)
582 logger->addItem(tr("Starting backup..."),LOGINFO);
583 QString backupName = RbSettings::value(RbSettings::Mountpoint).toString()
584 + "/.backup/rockbox-backup-" + rbinfo.version() + ".zip";
586 //! create dir, if it doesnt exist
587 QFileInfo backupFile(backupName);
588 if(!QDir(backupFile.path()).exists())
590 QDir a;
591 a.mkpath(backupFile.path());
594 //! create backup
595 RbZip backup;
596 connect(&backup,SIGNAL(zipProgress(int,int)),logger, SLOT(setProgress(int,int)));
597 if(backup.createZip(backupName,
598 RbSettings::value(RbSettings::Mountpoint).toString() + "/.rockbox") == Zip::Ok)
600 logger->addItem(tr("Backup successful"),LOGOK);
602 else
604 logger->addItem(tr("Backup failed!"),LOGERROR);
605 logger->setFinished();
606 return false;
611 //! install current build
612 ZipInstaller* installer = new ZipInstaller(this);
613 installer->setUrl(file);
614 installer->setLogSection("Rockbox (Base)");
615 installer->setLogVersion(ServerInfo::value(ServerInfo::CurReleaseVersion).toString());
616 if(!RbSettings::value(RbSettings::CacheDisabled).toBool())
617 installer->setCache(true);
618 installer->setMountPoint(RbSettings::value(RbSettings::Mountpoint).toString());
620 connect(installer, SIGNAL(done(bool)), this, SLOT(installdone(bool)));
621 connect(installer, SIGNAL(logItem(QString, int)), logger, SLOT(addItem(QString, int)));
622 connect(installer, SIGNAL(logProgress(int, int)), logger, SLOT(setProgress(int, int)));
623 connect(installer, SIGNAL(done(bool)), logger, SLOT(setFinished()));
624 connect(logger, SIGNAL(aborted()), installer, SLOT(abort()));
625 installer->install();
626 return true;
630 void RbUtilQt::install()
632 InstallWindow *installWindow = new InstallWindow(this);
633 installWindow->show();
636 bool RbUtilQt::installBootloaderAuto()
638 installBootloader();
639 return !m_error;
642 void RbUtilQt::installBootloaderBtn()
644 if(chkConfig(true)) return;
645 if(QMessageBox::question(this, tr("Confirm Installation"),
646 tr("Do you really want to install the Bootloader?"),
647 QMessageBox::Yes | QMessageBox::No) != QMessageBox::Yes) return;
649 // create logger
650 logger = new ProgressLoggerGui(this);
651 logger->show();
652 installBootloader();
655 void RbUtilQt::installBootloader()
657 QString platform = RbSettings::value(RbSettings::Platform).toString();
658 QString backupDestination = "";
659 m_error = false;
661 // create installer
662 BootloaderInstallBase *bl;
663 QString type = SystemInfo::value(SystemInfo::CurBootloaderMethod).toString();
664 if(type == "mi4") {
665 bl = new BootloaderInstallMi4(this);
667 else if(type == "hex") {
668 bl = new BootloaderInstallHex(this);
670 else if(type == "sansa") {
671 bl = new BootloaderInstallSansa(this);
673 else if(type == "ipod") {
674 bl = new BootloaderInstallIpod(this);
676 else if(type == "file") {
677 bl = new BootloaderInstallFile(this);
679 else if(type == "chinachip") {
680 bl = new BootloaderInstallChinaChip(this);
682 else if(type == "ams") {
683 bl = new BootloaderInstallAms(this);
685 else if(type == "tcc") {
686 bl = new BootloaderInstallTcc(this);
688 else {
689 logger->addItem(tr("No install method known."), LOGERROR);
690 logger->setFinished();
691 return;
694 // set bootloader filename. Do this now as installed() needs it.
695 QStringList blfile = SystemInfo::value(SystemInfo::CurBootloaderFile).toStringList();
696 QStringList blfilepath;
697 for(int a = 0; a < blfile.size(); a++) {
698 blfilepath.append(RbSettings::value(RbSettings::Mountpoint).toString()
699 + blfile.at(a));
701 bl->setBlFile(blfilepath);
702 QUrl url(SystemInfo::value(SystemInfo::BootloaderUrl).toString()
703 + SystemInfo::value(SystemInfo::CurBootloaderName).toString());
704 bl->setBlUrl(url);
705 bl->setLogfile(RbSettings::value(RbSettings::Mountpoint).toString()
706 + "/.rockbox/rbutil.log");
708 if(bl->installed() == BootloaderInstallBase::BootloaderRockbox) {
709 if(QMessageBox::question(this, tr("Bootloader detected"),
710 tr("Bootloader already installed. Do you want to reinstall the bootloader?"),
711 QMessageBox::Yes | QMessageBox::No) == QMessageBox::No) {
712 if(m_auto) {
713 // keep logger open for auto installs.
714 // don't consider abort as error in auto-mode.
715 logger->addItem(tr("Bootloader installation skipped"), LOGINFO);
716 installBootloaderPost(false);
718 else {
719 logger->close();
720 installBootloaderPost(true);
722 delete bl;
723 return;
726 else if(bl->installed() == BootloaderInstallBase::BootloaderOther
727 && bl->capabilities() & BootloaderInstallBase::Backup)
729 QString targetFolder = SystemInfo::value(SystemInfo::CurPlatformName).toString()
730 + " Firmware Backup";
731 // remove invalid character(s)
732 targetFolder.remove(QRegExp("[:/]"));
733 if(QMessageBox::question(this, tr("Create Bootloader backup"),
734 tr("You can create a backup of the original bootloader "
735 "file. Press \"Yes\" to select an output folder on your "
736 "computer to save the file to. The file will get placed "
737 "in a new folder \"%1\" created below the selected folder.\n"
738 "Press \"No\" to skip this step.").arg(targetFolder),
739 QMessageBox::Yes | QMessageBox::No) == QMessageBox::Yes) {
740 backupDestination = QFileDialog::getExistingDirectory(this,
741 tr("Browse backup folder"), QDir::homePath());
742 if(!backupDestination.isEmpty())
743 backupDestination += "/" + targetFolder;
745 qDebug() << "[RbUtil] backing up to" << backupDestination;
746 // backup needs to be done after the logger has been set up.
750 if(bl->capabilities() & BootloaderInstallBase::NeedsOf)
752 int ret;
753 ret = QMessageBox::information(this, tr("Prerequisites"),
754 bl->ofHint(),QMessageBox::Ok | QMessageBox::Abort);
755 if(ret != QMessageBox::Ok) {
756 // consider aborting an error to close window / abort automatic
757 // installation.
758 m_error = true;
759 logger->addItem(tr("Bootloader installation aborted"), LOGINFO);
760 logger->setFinished();
761 return;
763 // open dialog to browse to of file
764 QString offile;
765 offile = QFileDialog::getOpenFileName(this,
766 tr("Select firmware file"), QDir::homePath());
767 if(!QFileInfo(offile).isReadable()) {
768 logger->addItem(tr("Error opening firmware file"), LOGERROR);
769 logger->setFinished();
770 m_error = true;
771 return;
773 bl->setOfFile(offile);
776 // the bootloader install class does NOT use any GUI stuff.
777 // All messages are passed via signals.
778 connect(bl, SIGNAL(done(bool)), logger, SLOT(setFinished()));
779 connect(bl, SIGNAL(done(bool)), this, SLOT(installBootloaderPost(bool)));
780 connect(bl, SIGNAL(logItem(QString, int)), logger, SLOT(addItem(QString, int)));
781 connect(bl, SIGNAL(logProgress(int, int)), logger, SLOT(setProgress(int, int)));
783 // start install.
784 if(!backupDestination.isEmpty()) {
785 if(!bl->backup(backupDestination)) {
786 if(QMessageBox::warning(this, tr("Backup error"),
787 tr("Could not create backup file. Continue?"),
788 QMessageBox::No | QMessageBox::Yes)
789 == QMessageBox::No) {
790 logger->setFinished();
791 return;
795 bl->install();
798 void RbUtilQt::installBootloaderPost(bool error)
800 qDebug() << "[RbUtil] Bootloader Post-Installation, error state:" << error;
801 // if an error occured don't perform post install steps.
802 if(error) {
803 m_error = true;
804 return;
806 else
807 m_error = false;
809 m_installed = true;
810 // end here if automated install
811 if(m_auto)
812 return;
814 QString msg = BootloaderInstallBase::postinstallHints(
815 RbSettings::value(RbSettings::Platform).toString());
816 if(!msg.isEmpty()) {
817 QMessageBox::information(this, tr("Manual steps required"), msg);
818 logger->close();
823 void RbUtilQt::installFontsBtn()
825 if(chkConfig(true)) return;
826 if(QMessageBox::question(this, tr("Confirm Installation"),
827 tr("Do you really want to install the fonts package?"),
828 QMessageBox::Yes | QMessageBox::No) != QMessageBox::Yes) return;
829 // create logger
830 logger = new ProgressLoggerGui(this);
831 logger->show();
832 installFonts();
835 bool RbUtilQt::installFontsAuto()
837 installFonts();
839 return !m_error;
842 void RbUtilQt::installFonts()
844 // create zip installer
845 installer = new ZipInstaller(this);
847 installer->setUrl(SystemInfo::value(SystemInfo::FontUrl).toString());
848 installer->setLogSection("Fonts");
849 installer->setLogVersion(ServerInfo::value(ServerInfo::DailyDate).toString());
850 installer->setMountPoint(RbSettings::value(RbSettings::Mountpoint).toString());
851 if(!RbSettings::value(RbSettings::CacheDisabled).toBool())
852 installer->setCache(true);
854 connect(installer, SIGNAL(done(bool)), this, SLOT(installdone(bool)));
855 connect(installer, SIGNAL(logItem(QString, int)), logger, SLOT(addItem(QString, int)));
856 connect(installer, SIGNAL(logProgress(int, int)), logger, SLOT(setProgress(int, int)));
857 connect(installer, SIGNAL(done(bool)), logger, SLOT(setFinished()));
858 connect(logger, SIGNAL(aborted()), installer, SLOT(abort()));
859 installer->install();
863 void RbUtilQt::installVoice()
865 if(chkConfig(true)) return;
867 if(m_gotInfo == false)
869 QMessageBox::warning(this, tr("Warning"),
870 tr("The Application is still downloading Information about new Builds."
871 " Please try again shortly."));
872 return;
875 if(QMessageBox::question(this, tr("Confirm Installation"),
876 tr("Do you really want to install the voice file?"),
877 QMessageBox::Yes | QMessageBox::No) != QMessageBox::Yes) return;
878 // create logger
879 logger = new ProgressLoggerGui(this);
880 logger->show();
882 // create zip installer
883 installer = new ZipInstaller(this);
885 QString voiceurl = SystemInfo::value(SystemInfo::VoiceUrl).toString();
886 QDate date = QDate::fromString(ServerInfo::value(ServerInfo::DailyDate).toString(),Qt::ISODate);
887 voiceurl += SystemInfo::value(SystemInfo::CurBuildserverModel).toString() + "-" +
888 date.toString("yyyyMMdd") + "-english.zip";
889 qDebug() << "[RbUtil] voicefile URL:" << voiceurl;
891 installer->setUrl(voiceurl);
892 installer->setLogSection("Voice");
893 installer->setLogVersion(ServerInfo::value(ServerInfo::DailyDate).toString());
894 installer->setMountPoint(RbSettings::value(RbSettings::Mountpoint).toString());
895 if(!RbSettings::value(RbSettings::CacheDisabled).toBool())
896 installer->setCache(true);
897 connect(installer, SIGNAL(logItem(QString, int)), logger, SLOT(addItem(QString, int)));
898 connect(installer, SIGNAL(logProgress(int, int)), logger, SLOT(setProgress(int, int)));
899 connect(installer, SIGNAL(done(bool)), logger, SLOT(setFinished()));
900 connect(logger, SIGNAL(aborted()), installer, SLOT(abort()));
901 installer->install();
905 void RbUtilQt::installDoomBtn()
907 if(chkConfig(true)) return;
908 if(!hasDoom()){
909 QMessageBox::critical(this, tr("Error"),
910 tr("Your device doesn't have a doom plugin. Aborting."));
911 return;
914 if(QMessageBox::question(this, tr("Confirm Installation"),
915 tr("Do you really want to install the game addon files?"),
916 QMessageBox::Yes | QMessageBox::No) != QMessageBox::Yes) return;
917 // create logger
918 logger = new ProgressLoggerGui(this);
919 logger->show();
921 installDoom();
923 bool RbUtilQt::installDoomAuto()
925 installDoom();
926 return !m_error;
929 bool RbUtilQt::hasDoom()
931 QFile doomrock(RbSettings::value(RbSettings::Mountpoint).toString()
932 +"/.rockbox/rocks/games/doom.rock");
933 return doomrock.exists();
936 void RbUtilQt::installDoom()
938 // create zip installer
939 installer = new ZipInstaller(this);
941 installer->setUrl(SystemInfo::value(SystemInfo::DoomUrl).toString());
942 installer->setLogSection("Game Addons");
943 installer->setLogVersion(ServerInfo::value(ServerInfo::DailyDate).toString());
944 installer->setMountPoint(RbSettings::value(RbSettings::Mountpoint).toString());
945 if(!RbSettings::value(RbSettings::CacheDisabled).toBool())
946 installer->setCache(true);
947 connect(installer, SIGNAL(done(bool)), this, SLOT(installdone(bool)));
948 connect(installer, SIGNAL(logItem(QString, int)), logger, SLOT(addItem(QString, int)));
949 connect(installer, SIGNAL(logProgress(int, int)), logger, SLOT(setProgress(int, int)));
950 connect(installer, SIGNAL(done(bool)), logger, SLOT(setFinished()));
951 connect(logger, SIGNAL(aborted()), installer, SLOT(abort()));
952 installer->install();
956 void RbUtilQt::installThemes()
958 if(chkConfig(true)) return;
959 ThemesInstallWindow* tw = new ThemesInstallWindow(this);
960 tw->setModal(true);
961 tw->show();
964 void RbUtilQt::createTalkFiles(void)
966 if(chkConfig(true)) return;
967 InstallTalkWindow *installWindow = new InstallTalkWindow(this);
968 connect(installWindow, SIGNAL(settingsUpdated()), this, SLOT(updateSettings()));
969 installWindow->show();
973 void RbUtilQt::createVoiceFile(void)
975 if(chkConfig(true)) return;
976 CreateVoiceWindow *installWindow = new CreateVoiceWindow(this);
978 connect(installWindow, SIGNAL(settingsUpdated()), this, SLOT(updateSettings()));
979 installWindow->show();
982 void RbUtilQt::uninstall(void)
984 if(chkConfig(true)) return;
985 UninstallWindow *uninstallWindow = new UninstallWindow(this);
986 uninstallWindow->show();
990 void RbUtilQt::uninstallBootloader(void)
992 if(chkConfig(true)) return;
993 if(QMessageBox::question(this, tr("Confirm Uninstallation"),
994 tr("Do you really want to uninstall the Bootloader?"),
995 QMessageBox::Yes | QMessageBox::No) != QMessageBox::Yes) return;
996 // create logger
997 ProgressLoggerGui* logger = new ProgressLoggerGui(this);
998 logger->setProgressVisible(false);
999 logger->show();
1001 QString platform = RbSettings::value(RbSettings::Platform).toString();
1003 // create installer
1004 BootloaderInstallBase *bl;
1005 QString type = SystemInfo::value(SystemInfo::CurBootloaderMethod).toString();
1006 if(type == "mi4") {
1007 bl = new BootloaderInstallMi4(this);
1009 else if(type == "hex") {
1010 bl = new BootloaderInstallHex(this);
1012 else if(type == "sansa") {
1013 bl = new BootloaderInstallSansa(this);
1015 else if(type == "ipod") {
1016 bl = new BootloaderInstallIpod(this);
1018 else if(type == "file") {
1019 bl = new BootloaderInstallFile(this);
1021 else {
1022 logger->addItem(tr("No uninstall method known."), LOGERROR);
1023 logger->setFinished();
1024 return;
1027 QStringList blfile = SystemInfo::value(SystemInfo::CurBootloaderFile).toStringList();
1028 QStringList blfilepath;
1029 for(int a = 0; a < blfile.size(); a++) {
1030 blfilepath.append(RbSettings::value(RbSettings::Mountpoint).toString()
1031 + blfile.at(a));
1033 bl->setBlFile(blfilepath);
1035 connect(bl, SIGNAL(logItem(QString, int)), logger, SLOT(addItem(QString, int)));
1036 connect(bl, SIGNAL(logProgress(int, int)), logger, SLOT(setProgress(int, int)));
1038 int result;
1039 result = bl->uninstall();
1041 logger->setFinished();
1046 void RbUtilQt::downloadManual(void)
1048 if(chkConfig(true)) return;
1049 if(QMessageBox::question(this, tr("Confirm download"),
1050 tr("Do you really want to download the manual? The manual will be saved "
1051 "to the root folder of your player."),
1052 QMessageBox::Yes | QMessageBox::No) != QMessageBox::Yes)
1053 return;
1055 QString manual = SystemInfo::value(SystemInfo::CurManual).toString();
1056 if(manual.isEmpty())
1057 manual = "rockbox-"
1058 + SystemInfo::value(SystemInfo::CurBuildserverModel).toString();
1060 QString date = ServerInfo::value(ServerInfo::DailyDate).toString();
1062 QString manualurl;
1063 QString target;
1064 QString section;
1065 if(ui.radioPdf->isChecked()) {
1066 target = "/" + manual + ".pdf";
1067 section = "Manual (PDF)";
1069 else {
1070 target = "/" + manual + "-" + date + "-html.zip";
1071 section = "Manual (HTML)";
1073 manualurl = SystemInfo::value(SystemInfo::ManualUrl).toString() + "/" + target;
1074 qDebug() << "[RbUtil] Manual URL:" << manualurl;
1076 ProgressLoggerGui* logger = new ProgressLoggerGui(this);
1077 logger->show();
1078 installer = new ZipInstaller(this);
1079 installer->setMountPoint(RbSettings::value(RbSettings::Mountpoint).toString());
1080 if(!RbSettings::value(RbSettings::CacheDisabled).toBool())
1081 installer->setCache(true);
1082 installer->setLogSection(section);
1083 installer->setLogVersion(date);
1084 installer->setUrl(manualurl);
1085 installer->setUnzip(false);
1086 installer->setTarget(target);
1087 connect(installer, SIGNAL(logItem(QString, int)), logger, SLOT(addItem(QString, int)));
1088 connect(installer, SIGNAL(logProgress(int, int)), logger, SLOT(setProgress(int, int)));
1089 connect(installer, SIGNAL(done(bool)), logger, SLOT(setFinished()));
1090 connect(logger, SIGNAL(aborted()), installer, SLOT(abort()));
1091 installer->install();
1095 void RbUtilQt::installPortable(void)
1097 if(QMessageBox::question(this, tr("Confirm installation"),
1098 tr("Do you really want to install Rockbox Utility to your player? "
1099 "After installation you can run it from the players hard drive."),
1100 QMessageBox::Yes | QMessageBox::No) != QMessageBox::Yes)
1101 return;
1103 ProgressLoggerGui* logger = new ProgressLoggerGui(this);
1104 logger->setProgressMax(0);
1105 logger->setProgressValue(0);
1106 logger->show();
1107 logger->addItem(tr("Installing Rockbox Utility"), LOGINFO);
1109 // check mountpoint
1110 if(!QFileInfo(RbSettings::value(RbSettings::Mountpoint).toString()).isDir()) {
1111 logger->addItem(tr("Mount point is wrong!"),LOGERROR);
1112 logger->setFinished();
1113 return;
1116 // remove old files first.
1117 QFile::remove(RbSettings::value(RbSettings::Mountpoint).toString()
1118 + "/RockboxUtility.exe");
1119 QFile::remove(RbSettings::value(RbSettings::Mountpoint).toString()
1120 + "/RockboxUtility.ini");
1121 // copy currently running binary and currently used settings file
1122 if(!QFile::copy(qApp->applicationFilePath(),
1123 RbSettings::value(RbSettings::Mountpoint).toString()
1124 + "/RockboxUtility.exe")) {
1125 logger->addItem(tr("Error installing Rockbox Utility"), LOGERROR);
1126 logger->setFinished();
1127 return;
1129 logger->addItem(tr("Installing user configuration"), LOGINFO);
1130 if(!QFile::copy(RbSettings::userSettingFilename(),
1131 RbSettings::value(RbSettings::Mountpoint).toString()
1132 + "/RockboxUtility.ini")) {
1133 logger->addItem(tr("Error installing user configuration"), LOGERROR);
1134 logger->setFinished();
1135 return;
1137 logger->addItem(tr("Successfully installed Rockbox Utility."), LOGOK);
1138 logger->setFinished();
1139 logger->setProgressMax(1);
1140 logger->setProgressValue(1);
1145 void RbUtilQt::updateInfo()
1147 qDebug() << "[RbUtil] updating server info";
1149 QSettings log(RbSettings::value(RbSettings::Mountpoint).toString()
1150 + "/.rockbox/rbutil.log", QSettings::IniFormat, this);
1151 QStringList groups = log.childGroups();
1152 QList<QTreeWidgetItem *> items;
1153 QTreeWidgetItem *w, *w2;
1154 QString min, max;
1155 int olditems = 0;
1157 // remove old list entries (if any)
1158 int l = ui.treeInfo->topLevelItemCount();
1159 while(l--) {
1160 QTreeWidgetItem *m;
1161 m = ui.treeInfo->takeTopLevelItem(l);
1162 // delete childs (single level deep, no recursion here)
1163 int n = m->childCount();
1164 while(n--)
1165 delete m->child(n);
1167 // get and populate new items
1168 for(int a = 0; a < groups.size(); a++) {
1169 log.beginGroup(groups.at(a));
1170 QStringList keys = log.allKeys();
1171 w = new QTreeWidgetItem;
1172 w->setFlags(Qt::ItemIsEnabled);
1173 w->setText(0, groups.at(a));
1174 items.append(w);
1175 // get minimum and maximum version information so we can hilight old files
1176 min = max = log.value(keys.at(0)).toString();
1177 for(int b = 0; b < keys.size(); b++) {
1178 if(log.value(keys.at(b)).toString() > max)
1179 max = log.value(keys.at(b)).toString();
1180 if(log.value(keys.at(b)).toString() < min)
1181 min = log.value(keys.at(b)).toString();
1184 for(int b = 0; b < keys.size(); b++) {
1185 QString file;
1186 file = RbSettings::value(RbSettings::Mountpoint).toString() + "/" + keys.at(b);
1187 if(QFileInfo(file).isDir())
1188 continue;
1189 w2 = new QTreeWidgetItem(w, QStringList() << "/"
1190 + keys.at(b) << log.value(keys.at(b)).toString());
1191 if(log.value(keys.at(b)).toString() != max) {
1192 w2->setForeground(0, QBrush(QColor(255, 0, 0)));
1193 w2->setForeground(1, QBrush(QColor(255, 0, 0)));
1194 olditems++;
1196 items.append(w2);
1198 log.endGroup();
1199 if(min != max)
1200 w->setData(1, Qt::DisplayRole, QString("%1 / %2").arg(min, max));
1201 else
1202 w->setData(1, Qt::DisplayRole, max);
1204 ui.treeInfo->insertTopLevelItems(0, items);
1205 ui.treeInfo->resizeColumnToContents(0);
1209 QUrl RbUtilQt::proxy()
1211 if(RbSettings::value(RbSettings::ProxyType) == "manual")
1212 return QUrl(RbSettings::value(RbSettings::Proxy).toString());
1213 else if(RbSettings::value(RbSettings::ProxyType) == "system")
1214 return System::systemProxy();
1215 return QUrl("");
1219 bool RbUtilQt::chkConfig(bool warn)
1221 bool error = false;
1222 if(RbSettings::value(RbSettings::Platform).toString().isEmpty()
1223 || RbSettings::value(RbSettings::Mountpoint).toString().isEmpty()
1224 || !QFileInfo(RbSettings::value(RbSettings::Mountpoint).toString()).isWritable()) {
1225 error = true;
1227 if(warn) QMessageBox::critical(this, tr("Configuration error"),
1228 tr("Your configuration is invalid. Please go to the configuration "
1229 "dialog and make sure the selected values are correct."));
1231 return error;
1234 void RbUtilQt::checkUpdate(void)
1236 QString url = SystemInfo::value(SystemInfo::RbutilUrl).toString();
1237 #if defined(Q_OS_WIN32)
1238 url += "win32/";
1239 #elif defined(Q_OS_LINUX)
1240 url += "linux/";
1241 #elif defined(Q_OS_MACX)
1242 url += "macosx/";
1243 #endif
1245 update = new HttpGet(this);
1246 connect(update, SIGNAL(done(bool)), this, SLOT(downloadUpdateDone(bool)));
1247 connect(update, SIGNAL(requestFinished(int, bool)), this, SLOT(downloadDone(int, bool)));
1248 connect(qApp, SIGNAL(lastWindowClosed()), update, SLOT(abort()));
1249 if(RbSettings::value(RbSettings::CacheOffline).toBool())
1250 update->setCache(true);
1252 update->getFile(QUrl(url));
1255 void RbUtilQt::downloadUpdateDone(bool error)
1257 if(error) {
1258 qDebug() << "[RbUtil] network error:" << update->error();
1260 else {
1261 QString toParse(update->readAll());
1263 QRegExp searchString("<a[^>]*>([a-zA-Z]+[^<]*)</a>");
1264 QStringList rbutilList;
1265 int pos = 0;
1266 while ((pos = searchString.indexIn(toParse, pos)) != -1)
1268 rbutilList << searchString.cap(1);
1269 pos += searchString.matchedLength();
1271 qDebug() << "[Checkupdate] " << rbutilList;
1273 QString newVersion ="";
1274 //check if there is a binary with higher version in this list
1275 for(int i=0; i < rbutilList.size(); i++)
1277 #if defined(Q_OS_LINUX)
1278 #if defined(__amd64__)
1279 //skip if it isnt a 64bit build
1280 if( !rbutilList.at(i).contains("64bit"))
1281 continue;
1282 #else
1283 //skip if it is a 64bit build
1284 if(rbutilList.at(i).contains("64bit"))
1285 continue;
1286 #endif
1287 #endif
1288 //check if it is newer, and remember newest
1289 if(newerVersion(VERSION,rbutilList.at(i)))
1291 if(newVersion == "" || newerVersion(newVersion,rbutilList.at(i)))
1293 newVersion = rbutilList.at(i);
1298 // if we found something newer, display info
1299 if(newVersion != "")
1301 QString url = SystemInfo::value(SystemInfo::RbutilUrl).toString();
1302 #if defined(Q_OS_WIN32)
1303 url += "win32/";
1304 #elif defined(Q_OS_LINUX)
1305 url += "linux/";
1306 #elif defined(Q_OS_MACX)
1307 url += "macosx/";
1308 #endif
1309 url += newVersion;
1311 QMessageBox::information(this,tr("RockboxUtility Update available"),
1312 tr("<b>New RockboxUtility Version available.</b> <br><br>"
1313 "Download it from here: <a href='%1'>%2</a>").arg(url).arg(newVersion) );
1318 bool RbUtilQt::newerVersion(QString versionOld,QString versionNew)
1320 QRegExp chars("\\d*(\\D)");
1322 //strip non-number from beginning
1323 versionOld = versionOld.remove(0,versionOld.indexOf(QRegExp("\\d")));
1324 versionNew = versionNew.remove(0,versionNew.indexOf(QRegExp("\\d")));
1326 // split versions by "."
1327 QStringList versionListOld = versionOld.split(".");
1328 QStringList versionListNew = versionNew.split(".");
1330 QStringListIterator iteratorOld(versionListOld);
1331 QStringListIterator iteratorNew(versionListNew);
1333 //check every section
1334 while(iteratorOld.hasNext() && iteratorNew.hasNext())
1336 QString newPart = iteratorNew.next();
1337 QString oldPart = iteratorOld.next();
1338 QString newPartChar = "", oldPartChar = "";
1339 int newPartInt = 0, oldPartInt =0;
1341 //convert to int, if it contains chars, put into seperated variable
1342 if(newPart.contains(chars))
1344 newPartChar = chars.cap(1);
1345 newPart = newPart.remove(newPartChar);
1347 newPartInt = newPart.toInt();
1348 //convert to int, if it contains chars, put into seperated variable
1349 if(oldPart.contains(chars))
1351 oldPartChar = chars.cap(1);
1352 oldPart = oldPart.remove(oldPartChar);
1354 oldPartInt = oldPart.toInt();
1356 if(newPartInt > oldPartInt) // this section int is higher -> true
1357 return true;
1358 else if(newPartInt < oldPartInt) //this section int is lower -> false
1359 return false;
1360 else if(newPartChar > oldPartChar) //ints are the same, chars is higher -> true
1361 return true;
1362 else if(newPartChar < oldPartChar) //ints are the same, chars is lower -> false
1363 return false;
1364 //all the same, next section
1366 // all the same -> false
1367 return false;