Show status about downloading build information in the status bar.
[kugel-rb.git] / rbutil / rbutilqt / rbutilqt.cpp
blobdf8b4d878d81669df7f5087859a9686c1bd1d5eb
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 "install.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"
40 #include "progressloggerinterface.h"
42 #include "bootloaderinstallbase.h"
43 #include "bootloaderinstallmi4.h"
44 #include "bootloaderinstallhex.h"
45 #include "bootloaderinstallipod.h"
46 #include "bootloaderinstallsansa.h"
47 #include "bootloaderinstallfile.h"
48 #include "bootloaderinstallchinachip.h"
49 #include "bootloaderinstallams.h"
52 #if defined(Q_OS_LINUX)
53 #include <stdio.h>
54 #endif
55 #if defined(Q_OS_WIN32)
56 #if defined(UNICODE)
57 #define _UNICODE
58 #endif
59 #include <stdio.h>
60 #include <tchar.h>
61 #include <windows.h>
62 #endif
64 RbUtilQt::RbUtilQt(QWidget *parent) : QMainWindow(parent)
66 // startup log
67 qDebug() << "======================================";
68 qDebug() << "[System] Rockbox Utility " VERSION;
69 qDebug() << "[System] Qt version:" << qVersion();
70 qDebug() << "======================================";
72 absolutePath = qApp->applicationDirPath();
74 HttpGet::setGlobalUserAgent("rbutil/"VERSION);
75 // init startup & autodetection
76 ui.setupUi(this);
77 updateSettings();
78 downloadInfo();
80 m_gotInfo = false;
81 m_auto = false;
83 // manual tab
84 ui.radioPdf->setChecked(true);
86 // info tab
87 ui.treeInfo->setAlternatingRowColors(true);
88 ui.treeInfo->setHeaderLabels(QStringList() << tr("File") << tr("Version"));
89 ui.treeInfo->expandAll();
90 ui.treeInfo->setColumnCount(2);
91 // disable quick install until version info is available
92 ui.buttonSmall->setEnabled(false);
93 ui.buttonComplete->setEnabled(false);
95 connect(ui.tabWidget, SIGNAL(currentChanged(int)), this, SLOT(updateTabs(int)));
96 connect(ui.actionAbout_Qt, SIGNAL(triggered()), qApp, SLOT(aboutQt()));
97 connect(ui.action_About, SIGNAL(triggered()), this, SLOT(about()));
98 connect(ui.action_Help, SIGNAL(triggered()), this, SLOT(help()));
99 connect(ui.action_Configure, SIGNAL(triggered()), this, SLOT(configDialog()));
100 connect(ui.buttonChangeDevice, SIGNAL(clicked()), this, SLOT(configDialog()));
101 connect(ui.buttonRockbox, SIGNAL(clicked()), this, SLOT(installBtn()));
102 connect(ui.buttonBootloader, SIGNAL(clicked()), this, SLOT(installBootloaderBtn()));
103 connect(ui.buttonFonts, SIGNAL(clicked()), this, SLOT(installFontsBtn()));
104 connect(ui.buttonGames, SIGNAL(clicked()), this, SLOT(installDoomBtn()));
105 connect(ui.buttonTalk, SIGNAL(clicked()), this, SLOT(createTalkFiles()));
106 connect(ui.buttonCreateVoice, SIGNAL(clicked()), this, SLOT(createVoiceFile()));
107 connect(ui.buttonVoice, SIGNAL(clicked()), this, SLOT(installVoice()));
108 connect(ui.buttonThemes, SIGNAL(clicked()), this, SLOT(installThemes()));
109 connect(ui.buttonRemoveRockbox, SIGNAL(clicked()), this, SLOT(uninstall()));
110 connect(ui.buttonRemoveBootloader, SIGNAL(clicked()), this, SLOT(uninstallBootloader()));
111 connect(ui.buttonDownloadManual, SIGNAL(clicked()), this, SLOT(downloadManual()));
112 connect(ui.buttonSmall, SIGNAL(clicked()), this, SLOT(smallInstall()));
113 connect(ui.buttonComplete, SIGNAL(clicked()), this, SLOT(completeInstall()));
115 // actions accessible from the menu
116 connect(ui.actionComplete_Installation, SIGNAL(triggered()), this, SLOT(completeInstall()));
117 connect(ui.actionSmall_Installation, SIGNAL(triggered()), this, SLOT(smallInstall()));
118 connect(ui.actionInstall_Bootloader, SIGNAL(triggered()), this, SLOT(installBootloaderBtn()));
119 connect(ui.actionInstall_Rockbox, SIGNAL(triggered()), this, SLOT(installBtn()));
120 connect(ui.actionFonts_Package, SIGNAL(triggered()), this, SLOT(installFontsBtn()));
121 connect(ui.actionInstall_Themes, SIGNAL(triggered()), this, SLOT(installThemes()));
122 connect(ui.actionInstall_Game_Files, SIGNAL(triggered()), this, SLOT(installDoomBtn()));
123 connect(ui.actionInstall_Voice_File, SIGNAL(triggered()), this, SLOT(installVoice()));
124 connect(ui.actionCreate_Voice_File, SIGNAL(triggered()), this, SLOT(createVoiceFile()));
125 connect(ui.actionCreate_Talk_Files, SIGNAL(triggered()), this, SLOT(createTalkFiles()));
126 connect(ui.actionRemove_bootloader, SIGNAL(triggered()), this, SLOT(uninstallBootloader()));
127 connect(ui.actionUninstall_Rockbox, SIGNAL(triggered()), this, SLOT(uninstall()));
128 connect(ui.action_System_Info, SIGNAL(triggered()), this, SLOT(sysinfo()));
129 connect(ui.action_Trace, SIGNAL(triggered()), this, SLOT(trace()));
131 #if !defined(STATIC)
132 ui.actionInstall_Rockbox_Utility_on_player->setEnabled(false);
133 #else
134 connect(ui.actionInstall_Rockbox_Utility_on_player, SIGNAL(triggered()), this, SLOT(installPortable()));
135 #endif
140 void RbUtilQt::trace(void)
142 SysTrace wnd(this);
143 wnd.exec();
146 void RbUtilQt::sysinfo(void)
148 Sysinfo info(this);
149 info.exec();
152 void RbUtilQt::updateTabs(int count)
154 switch(count) {
155 case 6:
156 updateInfo();
157 break;
158 default:
159 break;
164 void RbUtilQt::downloadInfo()
166 // make sure the version map is repopulated correctly later.
167 versmap.clear();
168 // try to get the current build information
169 daily = new HttpGet(this);
170 connect(daily, SIGNAL(done(bool)), this, SLOT(downloadDone(bool)));
171 connect(daily, SIGNAL(requestFinished(int, bool)), this, SLOT(downloadDone(int, bool)));
172 connect(qApp, SIGNAL(lastWindowClosed()), daily, SLOT(abort()));
173 if(RbSettings::value(RbSettings::CacheOffline).toBool())
174 daily->setCache(true);
175 else
176 daily->setCache(false);
177 ui.statusbar->showMessage(tr("Downloading build information, please wait ..."));
178 qDebug() << "[RbUtil] downloading build info";
179 daily->setFile(&buildInfo);
180 daily->getFile(QUrl(RbSettings::value(RbSettings::ServerConfUrl).toString()));
184 void RbUtilQt::downloadDone(bool error)
186 if(error) {
187 qDebug() << "[RbUtil] network error:" << daily->error();
188 ui.statusbar->showMessage(tr("Can't get version information!"));
189 QMessageBox::critical(this, tr("Network error"),
190 tr("Can't get version information."));
191 return;
193 qDebug() << "[RbUtil] network status:" << daily->error();
195 buildInfo.open();
196 QSettings info(buildInfo.fileName(), QSettings::IniFormat, this);
197 buildInfo.close();
198 versmap.insert("arch_rev", info.value("dailies/rev").toString());
199 versmap.insert("arch_date", info.value("dailies/date").toString());
201 info.beginGroup("release");
202 versmap.insert("rel_rev", info.value(RbSettings::value(RbSettings::CurBuildserverModel).toString()).toString());
203 info.endGroup();
205 if(versmap.value("rel_rev").isEmpty()) {
206 ui.buttonSmall->setEnabled(false);
207 ui.buttonComplete->setEnabled(false);
209 else {
210 ui.buttonSmall->setEnabled(true);
211 ui.buttonComplete->setEnabled(true);
214 bleeding = new HttpGet(this);
215 connect(bleeding, SIGNAL(done(bool)), this, SLOT(downloadBleedingDone(bool)));
216 connect(bleeding, SIGNAL(requestFinished(int, bool)), this, SLOT(downloadDone(int, bool)));
217 connect(qApp, SIGNAL(lastWindowClosed()), bleeding, SLOT(abort()));
218 if(RbSettings::value(RbSettings::CacheOffline).toBool())
219 bleeding->setCache(true);
220 bleeding->setFile(&bleedingInfo);
221 bleeding->getFile(QUrl(RbSettings::value(RbSettings::BleedingInfo).toString()));
222 ui.statusbar->showMessage(tr("Downloading build information, please wait ..."));
224 if(RbSettings::value(RbSettings::RbutilVersion) != PUREVERSION) {
225 QApplication::processEvents();
226 QMessageBox::information(this, tr("New installation"),
227 tr("This is a new installation of Rockbox Utility, or a new version. "
228 "The configuration dialog will now open to allow you to setup the program, "
229 " or review your settings."));
230 configDialog();
232 else if(chkConfig(false)) {
233 QApplication::processEvents();
234 QMessageBox::critical(this, tr("Configuration error"),
235 tr("Your configuration is invalid. This is most likely due "
236 "to a changed device path. The configuration dialog will "
237 "now open to allow you to correct the problem."));
238 configDialog();
243 void RbUtilQt::downloadBleedingDone(bool error)
245 if(error) {
246 qDebug() << "[RbUtil] network error:" << bleeding->error();
248 else {
249 bleedingInfo.open();
250 QSettings info(bleedingInfo.fileName(), QSettings::IniFormat, this);
251 bleedingInfo.close();
252 versmap.insert("bleed_rev", info.value("bleeding/rev").toString());
253 versmap.insert("bleed_date", info.value("bleeding/timestamp").toString());
254 qDebug() << "[RbUtil] version map:" << versmap;
255 ui.statusbar->showMessage(tr("Download build information finished."), 5000);
257 m_gotInfo = true;
259 //start check for updates
260 checkUpdate();
265 void RbUtilQt::downloadDone(int id, bool error)
267 QString errorString;
268 errorString = tr("Network error: %1. Please check your network and proxy settings.")
269 .arg(daily->errorString());
270 if(error) {
271 QMessageBox::about(this, "Network Error", errorString);
272 m_networkerror = daily->errorString();
274 qDebug() << "[RbUtil] downloadDone:" << id << "error:" << error;
278 void RbUtilQt::about()
280 QDialog *window = new QDialog(this);
281 Ui::aboutBox about;
282 about.setupUi(window);
283 window->setModal(true);
285 QFile licence(":/docs/gpl-2.0.html");
286 licence.open(QIODevice::ReadOnly);
287 QTextStream c(&licence);
288 QString cline = c.readAll();
289 about.browserLicense->insertHtml(cline);
290 about.browserLicense->moveCursor(QTextCursor::Start, QTextCursor::MoveAnchor);
291 QFile credits(":/docs/CREDITS");
292 credits.open(QIODevice::ReadOnly);
293 QTextStream r(&credits);
294 r.setCodec(QTextCodec::codecForName("UTF-8"));
295 QString rline = r.readAll();
296 about.browserCredits->insertPlainText(rline);
297 about.browserCredits->moveCursor(QTextCursor::Start, QTextCursor::MoveAnchor);
298 QString title = QString("<b>The Rockbox Utility</b><br/>Version %1").arg(FULLVERSION);
299 about.labelTitle->setText(title);
301 window->show();
306 void RbUtilQt::help()
308 QUrl helpurl("http://www.rockbox.org/wiki/RockboxUtility");
309 QDesktopServices::openUrl(helpurl);
313 void RbUtilQt::configDialog()
315 Config *cw = new Config(this);
316 connect(cw, SIGNAL(settingsUpdated()), this, SLOT(updateSettings()));
317 connect(cw, SIGNAL(settingsUpdated()), this, SLOT(downloadInfo()));
318 cw->show();
322 void RbUtilQt::updateSettings()
324 qDebug() << "[RbUtil] updating current settings";
325 updateDevice();
326 updateManual();
327 if(RbSettings::value(RbSettings::ProxyType) == "system") {
328 HttpGet::setGlobalProxy(System::systemProxy());
330 else if(RbSettings::value(RbSettings::ProxyType) == "manual") {
331 HttpGet::setGlobalProxy(RbSettings::value(RbSettings::Proxy).toString());
333 else {
334 HttpGet::setGlobalProxy(QUrl(""));
336 HttpGet::setGlobalCache(RbSettings::value(RbSettings::CachePath).toString());
337 HttpGet::setGlobalDumbCache(RbSettings::value(RbSettings::CacheOffline).toBool());
341 void RbUtilQt::updateDevice()
343 if(RbSettings::value(RbSettings::CurBootloaderMethod) == "none" ) {
344 ui.buttonBootloader->setEnabled(false);
345 ui.buttonRemoveBootloader->setEnabled(false);
346 ui.labelBootloader->setEnabled(false);
347 ui.labelRemoveBootloader->setEnabled(false);
349 else {
350 ui.buttonBootloader->setEnabled(true);
351 ui.labelBootloader->setEnabled(true);
352 if(RbSettings::value(RbSettings::CurBootloaderMethod) == "fwpatcher") {
353 ui.labelRemoveBootloader->setEnabled(false);
354 ui.buttonRemoveBootloader->setEnabled(false);
356 else {
357 ui.labelRemoveBootloader->setEnabled(true);
358 ui.buttonRemoveBootloader->setEnabled(true);
362 // displayed device info
363 QString mountpoint = RbSettings::value(RbSettings::Mountpoint).toString();
364 QString brand = RbSettings::value(RbSettings::CurBrand).toString();
365 QString name = RbSettings::value(RbSettings::CurName).toString();
366 if(name.isEmpty()) name = "&lt;none&gt;";
367 if(mountpoint.isEmpty()) mountpoint = "&lt;invalid&gt;";
368 ui.labelDevice->setText(tr("<b>%1 %2</b> at <b>%3</b>")
369 .arg(brand, name, QDir::toNativeSeparators(mountpoint)));
373 void RbUtilQt::updateManual()
375 if(RbSettings::value(RbSettings::Platform) != "")
377 QString manual= RbSettings::value(RbSettings::CurManual).toString();
379 if(manual == "")
380 manual = "rockbox-" + RbSettings::value(RbSettings::Platform).toString();
381 QString pdfmanual;
382 pdfmanual = RbSettings::value(RbSettings::ManualUrl).toString()
383 + "/" + manual + ".pdf";
384 QString htmlmanual;
385 htmlmanual = RbSettings::value(RbSettings::ManualUrl).toString()
386 + "/" + manual + "/rockbox-build.html";
387 ui.labelPdfManual->setText(tr("<a href='%1'>PDF Manual</a>")
388 .arg(pdfmanual));
389 ui.labelHtmlManual->setText(tr("<a href='%1'>HTML Manual (opens in browser)</a>")
390 .arg(htmlmanual));
392 else {
393 ui.labelPdfManual->setText(tr("Select a device for a link to the correct manual"));
394 ui.labelHtmlManual->setText(tr("<a href='%1'>Manual Overview</a>")
395 .arg("http://www.rockbox.org/manual.shtml"));
400 void RbUtilQt::completeInstall()
402 if(chkConfig(true)) return;
403 if(QMessageBox::question(this, tr("Confirm Installation"),
404 tr("Do you really want to perform a complete installation?\n\n"
405 "This will install Rockbox %1. To install the most recent "
406 "development build available press \"Cancel\" and "
407 "use the \"Installation\" tab.")
408 .arg(versmap.value("rel_rev")),
409 QMessageBox::Ok | QMessageBox::Cancel) != QMessageBox::Ok)
410 return;
411 // create logger
412 logger = new ProgressLoggerGui(this);
413 logger->show();
415 if(smallInstallInner())
416 return;
417 logger->setRunning();
418 // Fonts
419 m_error = false;
420 m_installed = false;
421 if(!installFontsAuto())
422 return;
423 else
425 // wait for installation finished
426 while(!m_installed)
427 QApplication::processEvents();
429 if(m_error) return;
430 logger->setRunning();
432 // Doom
433 if(hasDoom())
435 m_error = false;
436 m_installed = false;
437 if(!installDoomAuto())
438 return;
439 else
441 // wait for installation finished
442 while(!m_installed)
443 QApplication::processEvents();
445 if(m_error) return;
448 // theme
449 // this is a window
450 // it has its own logger window,so close our.
451 logger->close();
452 installThemes();
456 void RbUtilQt::smallInstall()
458 if(chkConfig(true)) return;
459 if(QMessageBox::question(this, tr("Confirm Installation"),
460 tr("Do you really want to perform a minimal installation? "
461 "A minimal installation will contain only the absolutely "
462 "necessary parts to run Rockbox.\n\n"
463 "This will install Rockbox %1. To install the most recent "
464 "development build available press \"Cancel\" and "
465 "use the \"Installation\" tab.")
466 .arg(versmap.value("rel_rev")),
467 QMessageBox::Ok | QMessageBox::Cancel) != QMessageBox::Ok)
468 return;
470 // create logger
471 logger = new ProgressLoggerGui(this);
472 logger->show();
474 smallInstallInner();
477 bool RbUtilQt::smallInstallInner()
479 QString mountpoint = RbSettings::value(RbSettings::Mountpoint).toString();
480 // show dialog with error if mount point is wrong
481 if(!QFileInfo(mountpoint).isDir()) {
482 logger->addItem(tr("Mount point is wrong!"),LOGERROR);
483 logger->setFinished();
484 return true;
486 // Bootloader
487 if(RbSettings::value(RbSettings::CurBootloaderMethod) != "none")
489 m_error = false;
490 m_installed = false;
491 m_auto = true;
492 if(!installBootloaderAuto()) {
493 logger->setFinished();
494 return true;
496 else
498 // wait for boot loader installation finished
499 while(!m_installed)
500 QApplication::processEvents();
502 m_auto = false;
503 if(m_error) return true;
504 logger->setRunning();
507 // Rockbox
508 m_error = false;
509 m_installed = false;
510 if(!installAuto())
511 return true;
512 else
514 // wait for installation finished
515 while(!m_installed)
516 QApplication::processEvents();
519 installBootloaderPost(false);
520 return false;
523 void RbUtilQt::installdone(bool error)
525 qDebug() << "[RbUtil] install done";
526 m_installed = true;
527 m_error = error;
530 void RbUtilQt::installBtn()
532 if(chkConfig(true)) return;
533 install();
536 bool RbUtilQt::installAuto()
538 QString file = RbSettings::value(RbSettings::ReleaseUrl).toString();
539 file.replace("%MODEL%", RbSettings::value(RbSettings::CurBuildserverModel).toString());
540 file.replace("%RELVERSION%", versmap.value("rel_rev"));
541 buildInfo.open();
542 QSettings info(buildInfo.fileName(), QSettings::IniFormat, this);
543 buildInfo.close();
545 // check installed Version and Target
546 QString warning = check(false);
547 if(!warning.isEmpty())
549 if(QMessageBox::warning(this, tr("Really continue?"), warning,
550 QMessageBox::Ok | QMessageBox::Abort, QMessageBox::Abort)
551 == QMessageBox::Abort)
553 logger->addItem(tr("Aborted!"), LOGERROR);
554 logger->setFinished();
555 return false;
559 // check version
560 RockboxInfo rbinfo(RbSettings::value(RbSettings::Mountpoint).toString());
561 if(rbinfo.version() != "")
563 if(QMessageBox::question(this, tr("Installed Rockbox detected"),
564 tr("Rockbox installation detected. Do you want to backup first?"),
565 QMessageBox::Yes | QMessageBox::No) == QMessageBox::Yes)
567 logger->addItem(tr("Starting backup..."),LOGINFO);
568 QString backupName = RbSettings::value(RbSettings::Mountpoint).toString()
569 + "/.backup/rockbox-backup-" + rbinfo.version() + ".zip";
571 //! create dir, if it doesnt exist
572 QFileInfo backupFile(backupName);
573 if(!QDir(backupFile.path()).exists())
575 QDir a;
576 a.mkpath(backupFile.path());
579 //! create backup
580 RbZip backup;
581 connect(&backup,SIGNAL(zipProgress(int,int)),logger, SLOT(setProgress(int,int)));
582 if(backup.createZip(backupName,
583 RbSettings::value(RbSettings::Mountpoint).toString() + "/.rockbox") == Zip::Ok)
585 logger->addItem(tr("Backup successful"),LOGOK);
587 else
589 logger->addItem(tr("Backup failed!"),LOGERROR);
590 logger->setFinished();
591 return false;
596 //! install current build
597 ZipInstaller* installer = new ZipInstaller(this);
598 installer->setUrl(file);
599 installer->setLogSection("Rockbox (Base)");
600 installer->setLogVersion(versmap.value("rel_rev"));
601 if(!RbSettings::value(RbSettings::CacheDisabled).toBool())
602 installer->setCache(true);
603 installer->setMountPoint(RbSettings::value(RbSettings::Mountpoint).toString());
605 connect(installer, SIGNAL(done(bool)), this, SLOT(installdone(bool)));
606 connect(installer, SIGNAL(logItem(QString, int)), logger, SLOT(addItem(QString, int)));
607 connect(installer, SIGNAL(logProgress(int, int)), logger, SLOT(setProgress(int, int)));
608 connect(installer, SIGNAL(done(bool)), logger, SLOT(setFinished()));
609 connect(logger, SIGNAL(aborted()), installer, SLOT(abort()));
610 installer->install();
611 return true;
615 void RbUtilQt::install()
617 Install *installWindow = new Install(this);
619 buildInfo.open();
620 QSettings info(buildInfo.fileName(), QSettings::IniFormat, this);
621 buildInfo.close();
622 installWindow->setVersionStrings(versmap);
624 installWindow->show();
627 bool RbUtilQt::installBootloaderAuto()
629 installBootloader();
630 return !m_error;
633 void RbUtilQt::installBootloaderBtn()
635 if(chkConfig(true)) return;
636 if(QMessageBox::question(this, tr("Confirm Installation"),
637 tr("Do you really want to install the Bootloader?"),
638 QMessageBox::Yes | QMessageBox::No) != QMessageBox::Yes) return;
640 // create logger
641 logger = new ProgressLoggerGui(this);
642 logger->show();
643 installBootloader();
646 void RbUtilQt::installBootloader()
648 QString platform = RbSettings::value(RbSettings::Platform).toString();
649 QString backupDestination = "";
650 m_error = false;
652 // create installer
653 BootloaderInstallBase *bl;
654 QString type = RbSettings::value(RbSettings::CurBootloaderMethod).toString();
655 if(type == "mi4") {
656 bl = new BootloaderInstallMi4(this);
658 else if(type == "hex") {
659 bl = new BootloaderInstallHex(this);
661 else if(type == "sansa") {
662 bl = new BootloaderInstallSansa(this);
664 else if(type == "ipod") {
665 bl = new BootloaderInstallIpod(this);
667 else if(type == "file") {
668 bl = new BootloaderInstallFile(this);
670 else if(type == "chinachip") {
671 bl = new BootloaderInstallChinaChip(this);
673 else if(type == "ams") {
674 bl = new BootloaderInstallAms(this);
676 else {
677 logger->addItem(tr("No install method known."), LOGERROR);
678 logger->setFinished();
679 return;
682 // set bootloader filename. Do this now as installed() needs it.
683 QStringList blfile = RbSettings::value(RbSettings::CurBootloaderFile).toStringList();
684 QStringList blfilepath;
685 for(int a = 0; a < blfile.size(); a++) {
686 blfilepath.append(RbSettings::value(RbSettings::Mountpoint).toString()
687 + blfile.at(a));
689 bl->setBlFile(blfilepath);
690 QUrl url(RbSettings::value(RbSettings::BootloaderUrl).toString()
691 + RbSettings::value(RbSettings::CurBootloaderName).toString());
692 bl->setBlUrl(url);
693 bl->setLogfile(RbSettings::value(RbSettings::Mountpoint).toString()
694 + "/.rockbox/rbutil.log");
696 if(bl->installed() == BootloaderInstallBase::BootloaderRockbox) {
697 if(QMessageBox::question(this, tr("Bootloader detected"),
698 tr("Bootloader already installed. Do you want to reinstall the bootloader?"),
699 QMessageBox::Yes | QMessageBox::No) == QMessageBox::No) {
700 if(m_auto) {
701 // keep logger open for auto installs.
702 // don't consider abort as error in auto-mode.
703 logger->addItem(tr("Bootloader installation skipped"), LOGINFO);
704 installBootloaderPost(false);
706 else {
707 logger->close();
708 installBootloaderPost(true);
710 delete bl;
711 return;
714 else if(bl->installed() == BootloaderInstallBase::BootloaderOther
715 && bl->capabilities() & BootloaderInstallBase::Backup)
717 QString targetFolder = RbSettings::value(RbSettings::CurPlatformName).toString()
718 + " Firmware Backup";
719 // remove invalid character(s)
720 targetFolder.remove(QRegExp("[:/]"));
721 if(QMessageBox::question(this, tr("Create Bootloader backup"),
722 tr("You can create a backup of the original bootloader "
723 "file. Press \"Yes\" to select an output folder on your "
724 "computer to save the file to. The file will get placed "
725 "in a new folder \"%1\" created below the selected folder.\n"
726 "Press \"No\" to skip this step.").arg(targetFolder),
727 QMessageBox::Yes | QMessageBox::No) == QMessageBox::Yes) {
728 BrowseDirtree tree(this, tr("Browse backup folder"));
729 tree.setDir(QDir::home());
730 tree.exec();
732 backupDestination = tree.getSelected() + "/" + targetFolder;
733 qDebug() << "[RbUtil] backing up to" << backupDestination;
734 // backup needs to be done after the logger has been set up.
738 if(bl->capabilities() & BootloaderInstallBase::NeedsOf)
740 int ret;
741 ret = QMessageBox::information(this, tr("Prerequisites"),
742 bl->ofHint(),QMessageBox::Ok | QMessageBox::Abort);
743 if(ret != QMessageBox::Ok) {
744 // consider aborting an error to close window / abort automatic
745 // installation.
746 m_error = true;
747 logger->addItem(tr("Bootloader installation aborted"), LOGINFO);
748 logger->setFinished();
749 return;
751 // open dialog to browse to of file
752 QString offile;
753 offile = QFileDialog::getOpenFileName(this,
754 tr("Select firmware file"), QDir::homePath());
755 if(!QFileInfo(offile).isReadable()) {
756 logger->addItem(tr("Error opening firmware file"), LOGERROR);
757 logger->setFinished();
758 m_error = true;
759 return;
761 bl->setOfFile(offile);
764 // the bootloader install class does NOT use any GUI stuff.
765 // All messages are passed via signals.
766 connect(bl, SIGNAL(done(bool)), logger, SLOT(setFinished()));
767 connect(bl, SIGNAL(done(bool)), this, SLOT(installBootloaderPost(bool)));
768 connect(bl, SIGNAL(logItem(QString, int)), logger, SLOT(addItem(QString, int)));
769 connect(bl, SIGNAL(logProgress(int, int)), logger, SLOT(setProgress(int, int)));
771 // start install.
772 if(!backupDestination.isEmpty()) {
773 if(!bl->backup(backupDestination)) {
774 if(QMessageBox::warning(this, tr("Backup error"),
775 tr("Could not create backup file. Continue?"),
776 QMessageBox::No | QMessageBox::Yes)
777 == QMessageBox::No) {
778 logger->setFinished();
779 return;
783 bl->install();
786 void RbUtilQt::installBootloaderPost(bool error)
788 qDebug() << "[RbUtil] Bootloader Post-Installation, error state:" << error;
789 // if an error occured don't perform post install steps.
790 if(error) {
791 m_error = true;
792 return;
794 else
795 m_error = false;
797 m_installed = true;
798 // end here if automated install
799 if(m_auto)
800 return;
802 QString msg = BootloaderInstallBase::postinstallHints(
803 RbSettings::value(RbSettings::Platform).toString());
804 if(!msg.isEmpty()) {
805 QMessageBox::information(this, tr("Manual steps required"), msg);
806 logger->close();
811 void RbUtilQt::installFontsBtn()
813 if(chkConfig(true)) return;
814 if(QMessageBox::question(this, tr("Confirm Installation"),
815 tr("Do you really want to install the fonts package?"),
816 QMessageBox::Yes | QMessageBox::No) != QMessageBox::Yes) return;
817 // create logger
818 logger = new ProgressLoggerGui(this);
819 logger->show();
820 installFonts();
823 bool RbUtilQt::installFontsAuto()
825 installFonts();
827 return !m_error;
830 void RbUtilQt::installFonts()
832 // create zip installer
833 installer = new ZipInstaller(this);
835 installer->setUrl(RbSettings::value(RbSettings::FontUrl).toString());
836 installer->setLogSection("Fonts");
837 installer->setLogVersion(versmap.value("arch_date"));
838 installer->setMountPoint(RbSettings::value(RbSettings::Mountpoint).toString());
839 if(!RbSettings::value(RbSettings::CacheDisabled).toBool())
840 installer->setCache(true);
842 connect(installer, SIGNAL(done(bool)), this, SLOT(installdone(bool)));
843 connect(installer, SIGNAL(logItem(QString, int)), logger, SLOT(addItem(QString, int)));
844 connect(installer, SIGNAL(logProgress(int, int)), logger, SLOT(setProgress(int, int)));
845 connect(installer, SIGNAL(done(bool)), logger, SLOT(setFinished()));
846 connect(logger, SIGNAL(aborted()), installer, SLOT(abort()));
847 installer->install();
851 void RbUtilQt::installVoice()
853 if(chkConfig(true)) return;
855 if(m_gotInfo == false)
857 QMessageBox::warning(this, tr("Warning"),
858 tr("The Application is still downloading Information about new Builds."
859 " Please try again shortly."));
860 return;
863 if(QMessageBox::question(this, tr("Confirm Installation"),
864 tr("Do you really want to install the voice file?"),
865 QMessageBox::Yes | QMessageBox::No) != QMessageBox::Yes) return;
866 // create logger
867 logger = new ProgressLoggerGui(this);
868 logger->show();
870 // create zip installer
871 installer = new ZipInstaller(this);
873 QString voiceurl = RbSettings::value(RbSettings::VoiceUrl).toString();
875 voiceurl += RbSettings::value(RbSettings::CurBuildserverModel).toString() + "-" +
876 versmap.value("arch_date") + "-english.zip";
877 qDebug() << "[RbUtil] voicefile URL:" << voiceurl;
879 installer->setUrl(voiceurl);
880 installer->setLogSection("Voice");
881 installer->setLogVersion(versmap.value("arch_date"));
882 installer->setMountPoint(RbSettings::value(RbSettings::Mountpoint).toString());
883 if(!RbSettings::value(RbSettings::CacheDisabled).toBool())
884 installer->setCache(true);
885 connect(installer, SIGNAL(logItem(QString, int)), logger, SLOT(addItem(QString, int)));
886 connect(installer, SIGNAL(logProgress(int, int)), logger, SLOT(setProgress(int, int)));
887 connect(installer, SIGNAL(done(bool)), logger, SLOT(setFinished()));
888 connect(logger, SIGNAL(aborted()), installer, SLOT(abort()));
889 installer->install();
893 void RbUtilQt::installDoomBtn()
895 if(chkConfig(true)) return;
896 if(!hasDoom()){
897 QMessageBox::critical(this, tr("Error"),
898 tr("Your device doesn't have a doom plugin. Aborting."));
899 return;
902 if(QMessageBox::question(this, tr("Confirm Installation"),
903 tr("Do you really want to install the game addon files?"),
904 QMessageBox::Yes | QMessageBox::No) != QMessageBox::Yes) return;
905 // create logger
906 logger = new ProgressLoggerGui(this);
907 logger->show();
909 installDoom();
911 bool RbUtilQt::installDoomAuto()
913 installDoom();
914 return !m_error;
917 bool RbUtilQt::hasDoom()
919 QFile doomrock(RbSettings::value(RbSettings::Mountpoint).toString()
920 +"/.rockbox/rocks/games/doom.rock");
921 return doomrock.exists();
924 void RbUtilQt::installDoom()
926 // create zip installer
927 installer = new ZipInstaller(this);
929 installer->setUrl(RbSettings::value(RbSettings::DoomUrl).toString());
930 installer->setLogSection("Game Addons");
931 installer->setLogVersion(versmap.value("arch_date"));
932 installer->setMountPoint(RbSettings::value(RbSettings::Mountpoint).toString());
933 if(!RbSettings::value(RbSettings::CacheDisabled).toBool())
934 installer->setCache(true);
935 connect(installer, SIGNAL(done(bool)), this, SLOT(installdone(bool)));
936 connect(installer, SIGNAL(logItem(QString, int)), logger, SLOT(addItem(QString, int)));
937 connect(installer, SIGNAL(logProgress(int, int)), logger, SLOT(setProgress(int, int)));
938 connect(installer, SIGNAL(done(bool)), logger, SLOT(setFinished()));
939 connect(logger, SIGNAL(aborted()), installer, SLOT(abort()));
940 installer->install();
944 void RbUtilQt::installThemes()
946 if(chkConfig(true)) return;
947 ThemesInstallWindow* tw = new ThemesInstallWindow(this);
948 tw->setModal(true);
949 tw->show();
952 void RbUtilQt::createTalkFiles(void)
954 if(chkConfig(true)) return;
955 InstallTalkWindow *installWindow = new InstallTalkWindow(this);
957 connect(installWindow, SIGNAL(settingsUpdated()), this, SLOT(downloadInfo()));
958 connect(installWindow, SIGNAL(settingsUpdated()), this, SLOT(updateSettings()));
959 installWindow->show();
963 void RbUtilQt::createVoiceFile(void)
965 if(chkConfig(true)) return;
966 CreateVoiceWindow *installWindow = new CreateVoiceWindow(this);
968 connect(installWindow, SIGNAL(settingsUpdated()), this, SLOT(downloadInfo()));
969 connect(installWindow, SIGNAL(settingsUpdated()), this, SLOT(updateSettings()));
970 installWindow->show();
973 void RbUtilQt::uninstall(void)
975 if(chkConfig(true)) return;
976 UninstallWindow *uninstallWindow = new UninstallWindow(this);
977 uninstallWindow->show();
981 void RbUtilQt::uninstallBootloader(void)
983 if(chkConfig(true)) return;
984 if(QMessageBox::question(this, tr("Confirm Uninstallation"),
985 tr("Do you really want to uninstall the Bootloader?"),
986 QMessageBox::Yes | QMessageBox::No) != QMessageBox::Yes) return;
987 // create logger
988 ProgressLoggerGui* logger = new ProgressLoggerGui(this);
989 logger->setProgressVisible(false);
990 logger->show();
992 QString platform = RbSettings::value(RbSettings::Platform).toString();
994 // create installer
995 BootloaderInstallBase *bl;
996 QString type = RbSettings::value(RbSettings::CurBootloaderMethod).toString();
997 if(type == "mi4") {
998 bl = new BootloaderInstallMi4(this);
1000 else if(type == "hex") {
1001 bl = new BootloaderInstallHex(this);
1003 else if(type == "sansa") {
1004 bl = new BootloaderInstallSansa(this);
1006 else if(type == "ipod") {
1007 bl = new BootloaderInstallIpod(this);
1009 else if(type == "file") {
1010 bl = new BootloaderInstallFile(this);
1012 else {
1013 logger->addItem(tr("No uninstall method known."), LOGERROR);
1014 logger->setFinished();
1015 return;
1018 QStringList blfile = RbSettings::value(RbSettings::CurBootloaderFile).toStringList();
1019 QStringList blfilepath;
1020 for(int a = 0; a < blfile.size(); a++) {
1021 blfilepath.append(RbSettings::value(RbSettings::Mountpoint).toString()
1022 + blfile.at(a));
1024 bl->setBlFile(blfilepath);
1026 connect(bl, SIGNAL(logItem(QString, int)), logger, SLOT(addItem(QString, int)));
1027 connect(bl, SIGNAL(logProgress(int, int)), logger, SLOT(setProgress(int, int)));
1029 int result;
1030 result = bl->uninstall();
1032 logger->setFinished();
1037 void RbUtilQt::downloadManual(void)
1039 if(chkConfig(true)) return;
1040 if(QMessageBox::question(this, tr("Confirm download"),
1041 tr("Do you really want to download the manual? The manual will be saved "
1042 "to the root folder of your player."),
1043 QMessageBox::Yes | QMessageBox::No) != QMessageBox::Yes)
1044 return;
1046 buildInfo.open();
1047 QSettings info(buildInfo.fileName(), QSettings::IniFormat, this);
1048 buildInfo.close();
1050 QString manual = RbSettings::value(RbSettings::CurManual).toString();
1051 if(manual.isEmpty())
1052 manual = "rockbox-" + RbSettings::value(RbSettings::Platform).toString();
1054 QString date = (info.value("dailies/date").toString());
1056 QString manualurl;
1057 QString target;
1058 QString section;
1059 if(ui.radioPdf->isChecked()) {
1060 target = "/" + manual + ".pdf";
1061 section = "Manual (PDF)";
1063 else {
1064 target = "/" + manual + "-" + date + "-html.zip";
1065 section = "Manual (HTML)";
1067 manualurl = RbSettings::value(RbSettings::ManualUrl).toString() + "/" + target;
1068 qDebug() << "[RbUtil] Manual URL:" << manualurl;
1070 ProgressLoggerGui* logger = new ProgressLoggerGui(this);
1071 logger->show();
1072 installer = new ZipInstaller(this);
1073 installer->setMountPoint(RbSettings::value(RbSettings::Mountpoint).toString());
1074 if(!RbSettings::value(RbSettings::CacheDisabled).toBool())
1075 installer->setCache(true);
1076 installer->setLogSection(section);
1077 installer->setLogVersion(date);
1078 installer->setUrl(manualurl);
1079 installer->setUnzip(false);
1080 installer->setTarget(target);
1081 connect(installer, SIGNAL(logItem(QString, int)), logger, SLOT(addItem(QString, int)));
1082 connect(installer, SIGNAL(logProgress(int, int)), logger, SLOT(setProgress(int, int)));
1083 connect(installer, SIGNAL(done(bool)), logger, SLOT(setFinished()));
1084 connect(logger, SIGNAL(aborted()), installer, SLOT(abort()));
1085 installer->install();
1089 void RbUtilQt::installPortable(void)
1091 if(QMessageBox::question(this, tr("Confirm installation"),
1092 tr("Do you really want to install Rockbox Utility to your player? "
1093 "After installation you can run it from the players hard drive."),
1094 QMessageBox::Yes | QMessageBox::No) != QMessageBox::Yes)
1095 return;
1097 ProgressLoggerGui* logger = new ProgressLoggerGui(this);
1098 logger->setProgressMax(0);
1099 logger->setProgressValue(0);
1100 logger->show();
1101 logger->addItem(tr("Installing Rockbox Utility"), LOGINFO);
1103 // check mountpoint
1104 if(!QFileInfo(RbSettings::value(RbSettings::Mountpoint).toString()).isDir()) {
1105 logger->addItem(tr("Mount point is wrong!"),LOGERROR);
1106 logger->setFinished();
1107 return;
1110 // remove old files first.
1111 QFile::remove(RbSettings::value(RbSettings::Mountpoint).toString()
1112 + "/RockboxUtility.exe");
1113 QFile::remove(RbSettings::value(RbSettings::Mountpoint).toString()
1114 + "/RockboxUtility.ini");
1115 // copy currently running binary and currently used settings file
1116 if(!QFile::copy(qApp->applicationFilePath(),
1117 RbSettings::value(RbSettings::Mountpoint).toString()
1118 + "/RockboxUtility.exe")) {
1119 logger->addItem(tr("Error installing Rockbox Utility"), LOGERROR);
1120 logger->setFinished();
1121 return;
1123 logger->addItem(tr("Installing user configuration"), LOGINFO);
1124 if(!QFile::copy(RbSettings::userSettingFilename(),
1125 RbSettings::value(RbSettings::Mountpoint).toString()
1126 + "/RockboxUtility.ini")) {
1127 logger->addItem(tr("Error installing user configuration"), LOGERROR);
1128 logger->setFinished();
1129 return;
1131 logger->addItem(tr("Successfully installed Rockbox Utility."), LOGOK);
1132 logger->setFinished();
1133 logger->setProgressMax(1);
1134 logger->setProgressValue(1);
1139 void RbUtilQt::updateInfo()
1141 qDebug() << "[RbUtil] updating server info";
1143 QSettings log(RbSettings::value(RbSettings::Mountpoint).toString()
1144 + "/.rockbox/rbutil.log", QSettings::IniFormat, this);
1145 QStringList groups = log.childGroups();
1146 QList<QTreeWidgetItem *> items;
1147 QTreeWidgetItem *w, *w2;
1148 QString min, max;
1149 int olditems = 0;
1151 // remove old list entries (if any)
1152 int l = ui.treeInfo->topLevelItemCount();
1153 while(l--) {
1154 QTreeWidgetItem *m;
1155 m = ui.treeInfo->takeTopLevelItem(l);
1156 // delete childs (single level deep, no recursion here)
1157 int n = m->childCount();
1158 while(n--)
1159 delete m->child(n);
1161 // get and populate new items
1162 for(int a = 0; a < groups.size(); a++) {
1163 log.beginGroup(groups.at(a));
1164 QStringList keys = log.allKeys();
1165 w = new QTreeWidgetItem;
1166 w->setFlags(Qt::ItemIsEnabled);
1167 w->setText(0, groups.at(a));
1168 items.append(w);
1169 // get minimum and maximum version information so we can hilight old files
1170 min = max = log.value(keys.at(0)).toString();
1171 for(int b = 0; b < keys.size(); b++) {
1172 if(log.value(keys.at(b)).toString() > max)
1173 max = log.value(keys.at(b)).toString();
1174 if(log.value(keys.at(b)).toString() < min)
1175 min = log.value(keys.at(b)).toString();
1178 for(int b = 0; b < keys.size(); b++) {
1179 QString file;
1180 file = RbSettings::value(RbSettings::Mountpoint).toString() + "/" + keys.at(b);
1181 if(QFileInfo(file).isDir())
1182 continue;
1183 w2 = new QTreeWidgetItem(w, QStringList() << "/"
1184 + keys.at(b) << log.value(keys.at(b)).toString());
1185 if(log.value(keys.at(b)).toString() != max) {
1186 w2->setForeground(0, QBrush(QColor(255, 0, 0)));
1187 w2->setForeground(1, QBrush(QColor(255, 0, 0)));
1188 olditems++;
1190 items.append(w2);
1192 log.endGroup();
1193 if(min != max)
1194 w->setData(1, Qt::DisplayRole, QString("%1 / %2").arg(min, max));
1195 else
1196 w->setData(1, Qt::DisplayRole, max);
1198 ui.treeInfo->insertTopLevelItems(0, items);
1199 ui.treeInfo->resizeColumnToContents(0);
1203 QUrl RbUtilQt::proxy()
1205 if(RbSettings::value(RbSettings::ProxyType) == "manual")
1206 return QUrl(RbSettings::value(RbSettings::Proxy).toString());
1207 else if(RbSettings::value(RbSettings::ProxyType) == "system")
1208 return System::systemProxy();
1209 return QUrl("");
1213 bool RbUtilQt::chkConfig(bool warn)
1215 bool error = false;
1216 if(RbSettings::value(RbSettings::Platform).toString().isEmpty()
1217 || RbSettings::value(RbSettings::Mountpoint).toString().isEmpty()
1218 || !QFileInfo(RbSettings::value(RbSettings::Mountpoint).toString()).isWritable()) {
1219 error = true;
1221 if(warn) QMessageBox::critical(this, tr("Configuration error"),
1222 tr("Your configuration is invalid. Please go to the configuration "
1223 "dialog and make sure the selected values are correct."));
1225 return error;
1228 void RbUtilQt::checkUpdate(void)
1230 QString url = RbSettings::value(RbSettings::RbutilUrl).toString();
1231 #if defined(Q_OS_WIN32)
1232 url += "win32/";
1233 #elif defined(Q_OS_LINUX)
1234 url += "linux/";
1235 #elif defined(Q_OS_MACX)
1236 url += "macosx/";
1237 #endif
1239 update = new HttpGet(this);
1240 connect(update, SIGNAL(done(bool)), this, SLOT(downloadUpdateDone(bool)));
1241 connect(update, SIGNAL(requestFinished(int, bool)), this, SLOT(downloadDone(int, bool)));
1242 connect(qApp, SIGNAL(lastWindowClosed()), update, SLOT(abort()));
1243 if(RbSettings::value(RbSettings::CacheOffline).toBool())
1244 update->setCache(true);
1246 update->getFile(QUrl(url));
1249 void RbUtilQt::downloadUpdateDone(bool error)
1251 if(error) {
1252 qDebug() << "[RbUtil] network error:" << update->error();
1254 else {
1255 QString toParse(update->readAll());
1257 QRegExp searchString("<a[^>]*>(rbutilqt[^<]*)</a>");
1258 QStringList rbutilList;
1259 int pos = 0;
1260 while ((pos = searchString.indexIn(toParse, pos)) != -1)
1262 rbutilList << searchString.cap(1);
1263 pos += searchString.matchedLength();
1265 qDebug() << "[Checkupdate] " << rbutilList;
1267 QString newVersion ="";
1268 //check if there is a binary with higher version in this list
1269 for(int i=0; i < rbutilList.size(); i++)
1271 #if defined(Q_OS_LINUX)
1272 #if defined(__amd64__)
1273 //skip if it isnt a 64bit build
1274 if( !rbutilList.at(i).contains("64bit"))
1275 continue;
1276 #else
1277 //skip if it is a 64bit build
1278 if(rbutilList.at(i).contains("64bit"))
1279 continue;
1280 #endif
1281 #endif
1282 //check if it is newer, and remember newest
1283 if(newerVersion(VERSION,rbutilList.at(i)))
1285 if(newVersion == "" || newerVersion(newVersion,rbutilList.at(i)))
1287 newVersion = rbutilList.at(i);
1292 // if we found something newer, display info
1293 if(newVersion != "")
1295 QString url = RbSettings::value(RbSettings::RbutilUrl).toString();
1296 #if defined(Q_OS_WIN32)
1297 url += "win32/";
1298 #elif defined(Q_OS_LINUX)
1299 url += "linux/";
1300 #elif defined(Q_OS_MACX)
1301 url += "macosx/";
1302 #endif
1303 url += newVersion;
1305 QMessageBox::information(this,tr("RockboxUtility Update available"),
1306 tr("<b>New RockboxUtility Version available.</b> <br><br>"
1307 "Download it from here: <a href='%1'>%2</a>").arg(url).arg(newVersion) );
1312 bool RbUtilQt::newerVersion(QString versionOld,QString versionNew)
1314 QRegExp chars("\\d*(\\D)");
1316 //strip non-number from beginning
1317 versionOld = versionOld.remove(0,versionOld.indexOf(QRegExp("\\d")));
1318 versionNew = versionNew.remove(0,versionNew.indexOf(QRegExp("\\d")));
1320 // split versions by "."
1321 QStringList versionListOld = versionOld.split(".");
1322 QStringList versionListNew = versionNew.split(".");
1324 QStringListIterator iteratorOld(versionListOld);
1325 QStringListIterator iteratorNew(versionListNew);
1327 //check every section
1328 while(iteratorOld.hasNext() && iteratorNew.hasNext())
1330 QString newPart = iteratorNew.next();
1331 QString oldPart = iteratorOld.next();
1332 QString newPartChar = "", oldPartChar = "";
1333 int newPartInt = 0, oldPartInt =0;
1335 //convert to int, if it contains chars, put into seperated variable
1336 if(newPart.contains(chars))
1338 newPartChar = chars.cap(1);
1339 newPart = newPart.remove(newPartChar);
1341 newPartInt = newPart.toInt();
1342 //convert to int, if it contains chars, put into seperated variable
1343 if(oldPart.contains(chars))
1345 oldPartChar = chars.cap(1);
1346 oldPart = oldPart.remove(oldPartChar);
1348 oldPartInt = oldPart.toInt();
1350 if(newPartInt > oldPartInt) // this section int is higher -> true
1351 return true;
1352 else if(newPartInt < oldPartInt) //this section int is lower -> false
1353 return false;
1354 else if(newPartChar > oldPartChar) //ints are the same, chars is higher -> true
1355 return true;
1356 else if(newPartChar < oldPartChar) //ints are the same, chars is lower -> false
1357 return false;
1358 //all the same, next section
1360 // all the same -> false
1361 return false;