Don't put the complete HTML source in the trace when checking for a new version....
[kugel-rb.git] / rbutil / rbutilqt / rbutilqt.cpp
blob8fa1c82ad31689720b8aef1831e037348f0ba5e4
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 qDebug() << "[RbUtil] downloading build info";
178 daily->setFile(&buildInfo);
179 daily->getFile(QUrl(RbSettings::value(RbSettings::ServerConfUrl).toString()));
183 void RbUtilQt::downloadDone(bool error)
185 if(error) {
186 qDebug() << "[RbUtil] network error:" << daily->error();
187 QMessageBox::critical(this, tr("Network error"),
188 tr("Can't get version information."));
189 return;
191 qDebug() << "[RbUtil] network status:" << daily->error();
193 buildInfo.open();
194 QSettings info(buildInfo.fileName(), QSettings::IniFormat, this);
195 buildInfo.close();
196 versmap.insert("arch_rev", info.value("dailies/rev").toString());
197 versmap.insert("arch_date", info.value("dailies/date").toString());
199 info.beginGroup("release");
200 versmap.insert("rel_rev", info.value(RbSettings::value(RbSettings::CurBuildserverModel).toString()).toString());
201 info.endGroup();
203 if(versmap.value("rel_rev").isEmpty()) {
204 ui.buttonSmall->setEnabled(false);
205 ui.buttonComplete->setEnabled(false);
207 else {
208 ui.buttonSmall->setEnabled(true);
209 ui.buttonComplete->setEnabled(true);
212 bleeding = new HttpGet(this);
213 connect(bleeding, SIGNAL(done(bool)), this, SLOT(downloadBleedingDone(bool)));
214 connect(bleeding, SIGNAL(requestFinished(int, bool)), this, SLOT(downloadDone(int, bool)));
215 connect(qApp, SIGNAL(lastWindowClosed()), bleeding, SLOT(abort()));
216 if(RbSettings::value(RbSettings::CacheOffline).toBool())
217 bleeding->setCache(true);
218 bleeding->setFile(&bleedingInfo);
219 bleeding->getFile(QUrl(RbSettings::value(RbSettings::BleedingInfo).toString()));
221 if(RbSettings::value(RbSettings::RbutilVersion) != PUREVERSION) {
222 QApplication::processEvents();
223 QMessageBox::information(this, tr("New installation"),
224 tr("This is a new installation of Rockbox Utility, or a new version. "
225 "The configuration dialog will now open to allow you to setup the program, "
226 " or review your settings."));
227 configDialog();
229 else if(chkConfig(false)) {
230 QApplication::processEvents();
231 QMessageBox::critical(this, tr("Configuration error"),
232 tr("Your configuration is invalid. This is most likely due "
233 "to a changed device path. The configuration dialog will "
234 "now open to allow you to correct the problem."));
235 configDialog();
240 void RbUtilQt::downloadBleedingDone(bool error)
242 if(error) {
243 qDebug() << "[RbUtil] network error:" << bleeding->error();
245 else {
246 bleedingInfo.open();
247 QSettings info(bleedingInfo.fileName(), QSettings::IniFormat, this);
248 bleedingInfo.close();
249 versmap.insert("bleed_rev", info.value("bleeding/rev").toString());
250 versmap.insert("bleed_date", info.value("bleeding/timestamp").toString());
251 qDebug() << "[RbUtil] version map:" << versmap;
253 m_gotInfo = true;
255 //start check for updates
256 checkUpdate();
261 void RbUtilQt::downloadDone(int id, bool error)
263 QString errorString;
264 errorString = tr("Network error: %1. Please check your network and proxy settings.")
265 .arg(daily->errorString());
266 if(error) {
267 QMessageBox::about(this, "Network Error", errorString);
268 m_networkerror = daily->errorString();
270 qDebug() << "[RbUtil] downloadDone:" << id << "error:" << error;
274 void RbUtilQt::about()
276 QDialog *window = new QDialog(this);
277 Ui::aboutBox about;
278 about.setupUi(window);
279 window->setModal(true);
281 QFile licence(":/docs/gpl-2.0.html");
282 licence.open(QIODevice::ReadOnly);
283 QTextStream c(&licence);
284 QString cline = c.readAll();
285 about.browserLicense->insertHtml(cline);
286 about.browserLicense->moveCursor(QTextCursor::Start, QTextCursor::MoveAnchor);
287 QFile credits(":/docs/CREDITS");
288 credits.open(QIODevice::ReadOnly);
289 QTextStream r(&credits);
290 r.setCodec(QTextCodec::codecForName("UTF-8"));
291 QString rline = r.readAll();
292 about.browserCredits->insertPlainText(rline);
293 about.browserCredits->moveCursor(QTextCursor::Start, QTextCursor::MoveAnchor);
294 QString title = QString("<b>The Rockbox Utility</b><br/>Version %1").arg(FULLVERSION);
295 about.labelTitle->setText(title);
297 window->show();
302 void RbUtilQt::help()
304 QUrl helpurl("http://www.rockbox.org/wiki/RockboxUtility");
305 QDesktopServices::openUrl(helpurl);
309 void RbUtilQt::configDialog()
311 Config *cw = new Config(this);
312 connect(cw, SIGNAL(settingsUpdated()), this, SLOT(updateSettings()));
313 connect(cw, SIGNAL(settingsUpdated()), this, SLOT(downloadInfo()));
314 cw->show();
318 void RbUtilQt::updateSettings()
320 qDebug() << "[RbUtil] updating current settings";
321 updateDevice();
322 updateManual();
323 if(RbSettings::value(RbSettings::ProxyType) == "system") {
324 HttpGet::setGlobalProxy(System::systemProxy());
326 else if(RbSettings::value(RbSettings::ProxyType) == "manual") {
327 HttpGet::setGlobalProxy(RbSettings::value(RbSettings::Proxy).toString());
329 else {
330 HttpGet::setGlobalProxy(QUrl(""));
332 HttpGet::setGlobalCache(RbSettings::value(RbSettings::CachePath).toString());
333 HttpGet::setGlobalDumbCache(RbSettings::value(RbSettings::CacheOffline).toBool());
337 void RbUtilQt::updateDevice()
339 if(RbSettings::value(RbSettings::CurBootloaderMethod) == "none" ) {
340 ui.buttonBootloader->setEnabled(false);
341 ui.buttonRemoveBootloader->setEnabled(false);
342 ui.labelBootloader->setEnabled(false);
343 ui.labelRemoveBootloader->setEnabled(false);
345 else {
346 ui.buttonBootloader->setEnabled(true);
347 ui.labelBootloader->setEnabled(true);
348 if(RbSettings::value(RbSettings::CurBootloaderMethod) == "fwpatcher") {
349 ui.labelRemoveBootloader->setEnabled(false);
350 ui.buttonRemoveBootloader->setEnabled(false);
352 else {
353 ui.labelRemoveBootloader->setEnabled(true);
354 ui.buttonRemoveBootloader->setEnabled(true);
358 // displayed device info
359 QString mountpoint = RbSettings::value(RbSettings::Mountpoint).toString();
360 QString brand = RbSettings::value(RbSettings::CurBrand).toString();
361 QString name = RbSettings::value(RbSettings::CurName).toString();
362 if(name.isEmpty()) name = "&lt;none&gt;";
363 if(mountpoint.isEmpty()) mountpoint = "&lt;invalid&gt;";
364 ui.labelDevice->setText(tr("<b>%1 %2</b> at <b>%3</b>")
365 .arg(brand, name, QDir::toNativeSeparators(mountpoint)));
369 void RbUtilQt::updateManual()
371 if(RbSettings::value(RbSettings::Platform) != "")
373 QString manual= RbSettings::value(RbSettings::CurManual).toString();
375 if(manual == "")
376 manual = "rockbox-" + RbSettings::value(RbSettings::Platform).toString();
377 QString pdfmanual;
378 pdfmanual = RbSettings::value(RbSettings::ManualUrl).toString()
379 + "/" + manual + ".pdf";
380 QString htmlmanual;
381 htmlmanual = RbSettings::value(RbSettings::ManualUrl).toString()
382 + "/" + manual + "/rockbox-build.html";
383 ui.labelPdfManual->setText(tr("<a href='%1'>PDF Manual</a>")
384 .arg(pdfmanual));
385 ui.labelHtmlManual->setText(tr("<a href='%1'>HTML Manual (opens in browser)</a>")
386 .arg(htmlmanual));
388 else {
389 ui.labelPdfManual->setText(tr("Select a device for a link to the correct manual"));
390 ui.labelHtmlManual->setText(tr("<a href='%1'>Manual Overview</a>")
391 .arg("http://www.rockbox.org/manual.shtml"));
396 void RbUtilQt::completeInstall()
398 if(chkConfig(true)) return;
399 if(QMessageBox::question(this, tr("Confirm Installation"),
400 tr("Do you really want to perform a complete installation?\n\n"
401 "This will install Rockbox %1. To install the most recent "
402 "development build available press \"Cancel\" and "
403 "use the \"Installation\" tab.")
404 .arg(versmap.value("rel_rev")),
405 QMessageBox::Ok | QMessageBox::Cancel) != QMessageBox::Ok)
406 return;
407 // create logger
408 logger = new ProgressLoggerGui(this);
409 logger->show();
411 if(smallInstallInner())
412 return;
413 logger->setRunning();
414 // Fonts
415 m_error = false;
416 m_installed = false;
417 if(!installFontsAuto())
418 return;
419 else
421 // wait for installation finished
422 while(!m_installed)
423 QApplication::processEvents();
425 if(m_error) return;
426 logger->setRunning();
428 // Doom
429 if(hasDoom())
431 m_error = false;
432 m_installed = false;
433 if(!installDoomAuto())
434 return;
435 else
437 // wait for installation finished
438 while(!m_installed)
439 QApplication::processEvents();
441 if(m_error) return;
444 // theme
445 // this is a window
446 // it has its own logger window,so close our.
447 logger->close();
448 installThemes();
452 void RbUtilQt::smallInstall()
454 if(chkConfig(true)) return;
455 if(QMessageBox::question(this, tr("Confirm Installation"),
456 tr("Do you really want to perform a minimal installation? "
457 "A minimal installation will contain only the absolutely "
458 "necessary parts to run Rockbox.\n\n"
459 "This will install Rockbox %1. To install the most recent "
460 "development build available press \"Cancel\" and "
461 "use the \"Installation\" tab.")
462 .arg(versmap.value("rel_rev")),
463 QMessageBox::Ok | QMessageBox::Cancel) != QMessageBox::Ok)
464 return;
466 // create logger
467 logger = new ProgressLoggerGui(this);
468 logger->show();
470 smallInstallInner();
473 bool RbUtilQt::smallInstallInner()
475 QString mountpoint = RbSettings::value(RbSettings::Mountpoint).toString();
476 // show dialog with error if mount point is wrong
477 if(!QFileInfo(mountpoint).isDir()) {
478 logger->addItem(tr("Mount point is wrong!"),LOGERROR);
479 logger->setFinished();
480 return true;
482 // Bootloader
483 if(RbSettings::value(RbSettings::CurBootloaderMethod) != "none")
485 m_error = false;
486 m_installed = false;
487 m_auto = true;
488 if(!installBootloaderAuto()) {
489 logger->setFinished();
490 return true;
492 else
494 // wait for boot loader installation finished
495 while(!m_installed)
496 QApplication::processEvents();
498 m_auto = false;
499 if(m_error) return true;
500 logger->setRunning();
503 // Rockbox
504 m_error = false;
505 m_installed = false;
506 if(!installAuto())
507 return true;
508 else
510 // wait for installation finished
511 while(!m_installed)
512 QApplication::processEvents();
515 installBootloaderPost(false);
516 return false;
519 void RbUtilQt::installdone(bool error)
521 qDebug() << "[RbUtil] install done";
522 m_installed = true;
523 m_error = error;
526 void RbUtilQt::installBtn()
528 if(chkConfig(true)) return;
529 install();
532 bool RbUtilQt::installAuto()
534 QString file = RbSettings::value(RbSettings::ReleaseUrl).toString();
535 file.replace("%MODEL%", RbSettings::value(RbSettings::CurBuildserverModel).toString());
536 file.replace("%RELVERSION%", versmap.value("rel_rev"));
537 buildInfo.open();
538 QSettings info(buildInfo.fileName(), QSettings::IniFormat, this);
539 buildInfo.close();
541 // check installed Version and Target
542 QString warning = check(false);
543 if(!warning.isEmpty())
545 if(QMessageBox::warning(this, tr("Really continue?"), warning,
546 QMessageBox::Ok | QMessageBox::Abort, QMessageBox::Abort)
547 == QMessageBox::Abort)
549 logger->addItem(tr("Aborted!"), LOGERROR);
550 logger->setFinished();
551 return false;
555 // check version
556 RockboxInfo rbinfo(RbSettings::value(RbSettings::Mountpoint).toString());
557 if(rbinfo.version() != "")
559 if(QMessageBox::question(this, tr("Installed Rockbox detected"),
560 tr("Rockbox installation detected. Do you want to backup first?"),
561 QMessageBox::Yes | QMessageBox::No) == QMessageBox::Yes)
563 logger->addItem(tr("Starting backup..."),LOGINFO);
564 QString backupName = RbSettings::value(RbSettings::Mountpoint).toString()
565 + "/.backup/rockbox-backup-" + rbinfo.version() + ".zip";
567 //! create dir, if it doesnt exist
568 QFileInfo backupFile(backupName);
569 if(!QDir(backupFile.path()).exists())
571 QDir a;
572 a.mkpath(backupFile.path());
575 //! create backup
576 RbZip backup;
577 connect(&backup,SIGNAL(zipProgress(int,int)),logger, SLOT(setProgress(int,int)));
578 if(backup.createZip(backupName,
579 RbSettings::value(RbSettings::Mountpoint).toString() + "/.rockbox") == Zip::Ok)
581 logger->addItem(tr("Backup successful"),LOGOK);
583 else
585 logger->addItem(tr("Backup failed!"),LOGERROR);
586 logger->setFinished();
587 return false;
592 //! install current build
593 ZipInstaller* installer = new ZipInstaller(this);
594 installer->setUrl(file);
595 installer->setLogSection("Rockbox (Base)");
596 installer->setLogVersion(versmap.value("rel_rev"));
597 if(!RbSettings::value(RbSettings::CacheDisabled).toBool())
598 installer->setCache(true);
599 installer->setMountPoint(RbSettings::value(RbSettings::Mountpoint).toString());
601 connect(installer, SIGNAL(done(bool)), this, SLOT(installdone(bool)));
602 connect(installer, SIGNAL(logItem(QString, int)), logger, SLOT(addItem(QString, int)));
603 connect(installer, SIGNAL(logProgress(int, int)), logger, SLOT(setProgress(int, int)));
604 connect(installer, SIGNAL(done(bool)), logger, SLOT(setFinished()));
605 connect(logger, SIGNAL(aborted()), installer, SLOT(abort()));
606 installer->install();
607 return true;
611 void RbUtilQt::install()
613 Install *installWindow = new Install(this);
615 buildInfo.open();
616 QSettings info(buildInfo.fileName(), QSettings::IniFormat, this);
617 buildInfo.close();
618 installWindow->setVersionStrings(versmap);
620 installWindow->show();
623 bool RbUtilQt::installBootloaderAuto()
625 installBootloader();
626 return !m_error;
629 void RbUtilQt::installBootloaderBtn()
631 if(chkConfig(true)) return;
632 if(QMessageBox::question(this, tr("Confirm Installation"),
633 tr("Do you really want to install the Bootloader?"),
634 QMessageBox::Yes | QMessageBox::No) != QMessageBox::Yes) return;
636 // create logger
637 logger = new ProgressLoggerGui(this);
638 logger->show();
639 installBootloader();
642 void RbUtilQt::installBootloader()
644 QString platform = RbSettings::value(RbSettings::Platform).toString();
645 QString backupDestination = "";
646 m_error = false;
648 // create installer
649 BootloaderInstallBase *bl;
650 QString type = RbSettings::value(RbSettings::CurBootloaderMethod).toString();
651 if(type == "mi4") {
652 bl = new BootloaderInstallMi4(this);
654 else if(type == "hex") {
655 bl = new BootloaderInstallHex(this);
657 else if(type == "sansa") {
658 bl = new BootloaderInstallSansa(this);
660 else if(type == "ipod") {
661 bl = new BootloaderInstallIpod(this);
663 else if(type == "file") {
664 bl = new BootloaderInstallFile(this);
666 else if(type == "chinachip") {
667 bl = new BootloaderInstallChinaChip(this);
669 else if(type == "ams") {
670 bl = new BootloaderInstallAms(this);
672 else {
673 logger->addItem(tr("No install method known."), LOGERROR);
674 logger->setFinished();
675 return;
678 // set bootloader filename. Do this now as installed() needs it.
679 QStringList blfile = RbSettings::value(RbSettings::CurBootloaderFile).toStringList();
680 QStringList blfilepath;
681 for(int a = 0; a < blfile.size(); a++) {
682 blfilepath.append(RbSettings::value(RbSettings::Mountpoint).toString()
683 + blfile.at(a));
685 bl->setBlFile(blfilepath);
686 QUrl url(RbSettings::value(RbSettings::BootloaderUrl).toString()
687 + RbSettings::value(RbSettings::CurBootloaderName).toString());
688 bl->setBlUrl(url);
689 bl->setLogfile(RbSettings::value(RbSettings::Mountpoint).toString()
690 + "/.rockbox/rbutil.log");
692 if(bl->installed() == BootloaderInstallBase::BootloaderRockbox) {
693 if(QMessageBox::question(this, tr("Bootloader detected"),
694 tr("Bootloader already installed. Do you want to reinstall the bootloader?"),
695 QMessageBox::Yes | QMessageBox::No) == QMessageBox::No) {
696 if(m_auto) {
697 // keep logger open for auto installs.
698 // don't consider abort as error in auto-mode.
699 logger->addItem(tr("Bootloader installation skipped"), LOGINFO);
700 installBootloaderPost(false);
702 else {
703 logger->close();
704 installBootloaderPost(true);
706 return;
709 else if(bl->installed() == BootloaderInstallBase::BootloaderOther
710 && bl->capabilities() & BootloaderInstallBase::Backup)
712 QString targetFolder = RbSettings::value(RbSettings::CurPlatformName).toString()
713 + " Firmware Backup";
714 // remove invalid character(s)
715 targetFolder.remove(QRegExp("[:/]"));
716 if(QMessageBox::question(this, tr("Create Bootloader backup"),
717 tr("You can create a backup of the original bootloader "
718 "file. Press \"Yes\" to select an output folder on your "
719 "computer to save the file to. The file will get placed "
720 "in a new folder \"%1\" created below the selected folder.\n"
721 "Press \"No\" to skip this step.").arg(targetFolder),
722 QMessageBox::Yes | QMessageBox::No) == QMessageBox::Yes) {
723 BrowseDirtree tree(this, tr("Browse backup folder"));
724 tree.setDir(QDir::home());
725 tree.exec();
727 backupDestination = tree.getSelected() + "/" + targetFolder;
728 qDebug() << "[RbUtil] backing up to" << backupDestination;
729 // backup needs to be done after the logger has been set up.
733 if(bl->capabilities() & BootloaderInstallBase::NeedsOf)
735 int ret;
736 ret = QMessageBox::information(this, tr("Prerequisites"),
737 bl->ofHint(),QMessageBox::Ok | QMessageBox::Abort);
738 if(ret != QMessageBox::Ok) {
739 // consider aborting an error to close window / abort automatic
740 // installation.
741 m_error = true;
742 logger->addItem(tr("Bootloader installation aborted"), LOGINFO);
743 logger->setFinished();
744 return;
746 // open dialog to browse to of file
747 QString offile;
748 offile = QFileDialog::getOpenFileName(this,
749 tr("Select firmware file"), QDir::homePath());
750 if(!QFileInfo(offile).isReadable()) {
751 logger->addItem(tr("Error opening firmware file"), LOGERROR);
752 logger->setFinished();
753 m_error = true;
754 return;
756 bl->setOfFile(offile);
759 // the bootloader install class does NOT use any GUI stuff.
760 // All messages are passed via signals.
761 connect(bl, SIGNAL(done(bool)), logger, SLOT(setFinished()));
762 connect(bl, SIGNAL(done(bool)), this, SLOT(installBootloaderPost(bool)));
763 connect(bl, SIGNAL(logItem(QString, int)), logger, SLOT(addItem(QString, int)));
764 connect(bl, SIGNAL(logProgress(int, int)), logger, SLOT(setProgress(int, int)));
766 // start install.
767 if(!backupDestination.isEmpty()) {
768 if(!bl->backup(backupDestination)) {
769 if(QMessageBox::warning(this, tr("Backup error"),
770 tr("Could not create backup file. Continue?"),
771 QMessageBox::No | QMessageBox::Yes)
772 == QMessageBox::No) {
773 logger->setFinished();
774 return;
778 bl->install();
781 void RbUtilQt::installBootloaderPost(bool error)
783 qDebug() << "[RbUtil] Bootloader Post-Installation, error state:" << error;
784 // if an error occured don't perform post install steps.
785 if(error) {
786 m_error = true;
787 return;
789 else
790 m_error = false;
792 m_installed = true;
793 // end here if automated install
794 if(m_auto)
795 return;
797 QString msg = BootloaderInstallBase::postinstallHints(
798 RbSettings::value(RbSettings::Platform).toString());
799 if(!msg.isEmpty()) {
800 QMessageBox::information(this, tr("Manual steps required"), msg);
801 logger->close();
806 void RbUtilQt::installFontsBtn()
808 if(chkConfig(true)) return;
809 if(QMessageBox::question(this, tr("Confirm Installation"),
810 tr("Do you really want to install the fonts package?"),
811 QMessageBox::Yes | QMessageBox::No) != QMessageBox::Yes) return;
812 // create logger
813 logger = new ProgressLoggerGui(this);
814 logger->show();
815 installFonts();
818 bool RbUtilQt::installFontsAuto()
820 installFonts();
822 return !m_error;
825 void RbUtilQt::installFonts()
827 // create zip installer
828 installer = new ZipInstaller(this);
830 installer->setUrl(RbSettings::value(RbSettings::FontUrl).toString());
831 installer->setLogSection("Fonts");
832 installer->setLogVersion(versmap.value("arch_date"));
833 installer->setMountPoint(RbSettings::value(RbSettings::Mountpoint).toString());
834 if(!RbSettings::value(RbSettings::CacheDisabled).toBool())
835 installer->setCache(true);
837 connect(installer, SIGNAL(done(bool)), this, SLOT(installdone(bool)));
838 connect(installer, SIGNAL(logItem(QString, int)), logger, SLOT(addItem(QString, int)));
839 connect(installer, SIGNAL(logProgress(int, int)), logger, SLOT(setProgress(int, int)));
840 connect(installer, SIGNAL(done(bool)), logger, SLOT(setFinished()));
841 connect(logger, SIGNAL(aborted()), installer, SLOT(abort()));
842 installer->install();
846 void RbUtilQt::installVoice()
848 if(chkConfig(true)) return;
850 if(m_gotInfo == false)
852 QMessageBox::warning(this, tr("Warning"),
853 tr("The Application is still downloading Information about new Builds."
854 " Please try again shortly."));
855 return;
858 if(QMessageBox::question(this, tr("Confirm Installation"),
859 tr("Do you really want to install the voice file?"),
860 QMessageBox::Yes | QMessageBox::No) != QMessageBox::Yes) return;
861 // create logger
862 logger = new ProgressLoggerGui(this);
863 logger->show();
865 // create zip installer
866 installer = new ZipInstaller(this);
868 QString voiceurl = RbSettings::value(RbSettings::VoiceUrl).toString();
870 voiceurl += RbSettings::value(RbSettings::CurBuildserverModel).toString() + "-" +
871 versmap.value("arch_date") + "-english.zip";
872 qDebug() << "[RbUtil] voicefile URL:" << voiceurl;
874 installer->setUrl(voiceurl);
875 installer->setLogSection("Voice");
876 installer->setLogVersion(versmap.value("arch_date"));
877 installer->setMountPoint(RbSettings::value(RbSettings::Mountpoint).toString());
878 if(!RbSettings::value(RbSettings::CacheDisabled).toBool())
879 installer->setCache(true);
880 connect(installer, SIGNAL(logItem(QString, int)), logger, SLOT(addItem(QString, int)));
881 connect(installer, SIGNAL(logProgress(int, int)), logger, SLOT(setProgress(int, int)));
882 connect(installer, SIGNAL(done(bool)), logger, SLOT(setFinished()));
883 connect(logger, SIGNAL(aborted()), installer, SLOT(abort()));
884 installer->install();
888 void RbUtilQt::installDoomBtn()
890 if(chkConfig(true)) return;
891 if(!hasDoom()){
892 QMessageBox::critical(this, tr("Error"),
893 tr("Your device doesn't have a doom plugin. Aborting."));
894 return;
897 if(QMessageBox::question(this, tr("Confirm Installation"),
898 tr("Do you really want to install the game addon files?"),
899 QMessageBox::Yes | QMessageBox::No) != QMessageBox::Yes) return;
900 // create logger
901 logger = new ProgressLoggerGui(this);
902 logger->show();
904 installDoom();
906 bool RbUtilQt::installDoomAuto()
908 installDoom();
909 return !m_error;
912 bool RbUtilQt::hasDoom()
914 QFile doomrock(RbSettings::value(RbSettings::Mountpoint).toString()
915 +"/.rockbox/rocks/games/doom.rock");
916 return doomrock.exists();
919 void RbUtilQt::installDoom()
921 // create zip installer
922 installer = new ZipInstaller(this);
924 installer->setUrl(RbSettings::value(RbSettings::DoomUrl).toString());
925 installer->setLogSection("Game Addons");
926 installer->setLogVersion(versmap.value("arch_date"));
927 installer->setMountPoint(RbSettings::value(RbSettings::Mountpoint).toString());
928 if(!RbSettings::value(RbSettings::CacheDisabled).toBool())
929 installer->setCache(true);
930 connect(installer, SIGNAL(done(bool)), this, SLOT(installdone(bool)));
931 connect(installer, SIGNAL(logItem(QString, int)), logger, SLOT(addItem(QString, int)));
932 connect(installer, SIGNAL(logProgress(int, int)), logger, SLOT(setProgress(int, int)));
933 connect(installer, SIGNAL(done(bool)), logger, SLOT(setFinished()));
934 connect(logger, SIGNAL(aborted()), installer, SLOT(abort()));
935 installer->install();
939 void RbUtilQt::installThemes()
941 if(chkConfig(true)) return;
942 ThemesInstallWindow* tw = new ThemesInstallWindow(this);
943 tw->setModal(true);
944 tw->show();
947 void RbUtilQt::createTalkFiles(void)
949 if(chkConfig(true)) return;
950 InstallTalkWindow *installWindow = new InstallTalkWindow(this);
952 connect(installWindow, SIGNAL(settingsUpdated()), this, SLOT(downloadInfo()));
953 connect(installWindow, SIGNAL(settingsUpdated()), this, SLOT(updateSettings()));
954 installWindow->show();
958 void RbUtilQt::createVoiceFile(void)
960 if(chkConfig(true)) return;
961 CreateVoiceWindow *installWindow = new CreateVoiceWindow(this);
963 connect(installWindow, SIGNAL(settingsUpdated()), this, SLOT(downloadInfo()));
964 connect(installWindow, SIGNAL(settingsUpdated()), this, SLOT(updateSettings()));
965 installWindow->show();
968 void RbUtilQt::uninstall(void)
970 if(chkConfig(true)) return;
971 UninstallWindow *uninstallWindow = new UninstallWindow(this);
972 uninstallWindow->show();
976 void RbUtilQt::uninstallBootloader(void)
978 if(chkConfig(true)) return;
979 if(QMessageBox::question(this, tr("Confirm Uninstallation"),
980 tr("Do you really want to uninstall the Bootloader?"),
981 QMessageBox::Yes | QMessageBox::No) != QMessageBox::Yes) return;
982 // create logger
983 ProgressLoggerGui* logger = new ProgressLoggerGui(this);
984 logger->setProgressVisible(false);
985 logger->show();
987 QString platform = RbSettings::value(RbSettings::Platform).toString();
989 // create installer
990 BootloaderInstallBase *bl;
991 QString type = RbSettings::value(RbSettings::CurBootloaderMethod).toString();
992 if(type == "mi4") {
993 bl = new BootloaderInstallMi4(this);
995 else if(type == "hex") {
996 bl = new BootloaderInstallHex(this);
998 else if(type == "sansa") {
999 bl = new BootloaderInstallSansa(this);
1001 else if(type == "ipod") {
1002 bl = new BootloaderInstallIpod(this);
1004 else if(type == "file") {
1005 bl = new BootloaderInstallFile(this);
1007 else {
1008 logger->addItem(tr("No uninstall method known."), LOGERROR);
1009 logger->setFinished();
1010 return;
1013 QStringList blfile = RbSettings::value(RbSettings::CurBootloaderFile).toStringList();
1014 QStringList blfilepath;
1015 for(int a = 0; a < blfile.size(); a++) {
1016 blfilepath.append(RbSettings::value(RbSettings::Mountpoint).toString()
1017 + blfile.at(a));
1019 bl->setBlFile(blfilepath);
1021 connect(bl, SIGNAL(logItem(QString, int)), logger, SLOT(addItem(QString, int)));
1022 connect(bl, SIGNAL(logProgress(int, int)), logger, SLOT(setProgress(int, int)));
1024 int result;
1025 result = bl->uninstall();
1027 logger->setFinished();
1032 void RbUtilQt::downloadManual(void)
1034 if(chkConfig(true)) return;
1035 if(QMessageBox::question(this, tr("Confirm download"),
1036 tr("Do you really want to download the manual? The manual will be saved "
1037 "to the root folder of your player."),
1038 QMessageBox::Yes | QMessageBox::No) != QMessageBox::Yes)
1039 return;
1041 buildInfo.open();
1042 QSettings info(buildInfo.fileName(), QSettings::IniFormat, this);
1043 buildInfo.close();
1045 QString manual = RbSettings::value(RbSettings::CurManual).toString();
1046 if(manual.isEmpty())
1047 manual = "rockbox-" + RbSettings::value(RbSettings::Platform).toString();
1049 QString date = (info.value("dailies/date").toString());
1051 QString manualurl;
1052 QString target;
1053 QString section;
1054 if(ui.radioPdf->isChecked()) {
1055 target = "/" + manual + ".pdf";
1056 section = "Manual (PDF)";
1058 else {
1059 target = "/" + manual + "-" + date + "-html.zip";
1060 section = "Manual (HTML)";
1062 manualurl = RbSettings::value(RbSettings::ManualUrl).toString() + "/" + target;
1063 qDebug() << "[RbUtil] Manual URL:" << manualurl;
1065 ProgressLoggerGui* logger = new ProgressLoggerGui(this);
1066 logger->show();
1067 installer = new ZipInstaller(this);
1068 installer->setMountPoint(RbSettings::value(RbSettings::Mountpoint).toString());
1069 if(!RbSettings::value(RbSettings::CacheDisabled).toBool())
1070 installer->setCache(true);
1071 installer->setLogSection(section);
1072 installer->setLogVersion(date);
1073 installer->setUrl(manualurl);
1074 installer->setUnzip(false);
1075 installer->setTarget(target);
1076 connect(installer, SIGNAL(logItem(QString, int)), logger, SLOT(addItem(QString, int)));
1077 connect(installer, SIGNAL(logProgress(int, int)), logger, SLOT(setProgress(int, int)));
1078 connect(installer, SIGNAL(done(bool)), logger, SLOT(setFinished()));
1079 connect(logger, SIGNAL(aborted()), installer, SLOT(abort()));
1080 installer->install();
1084 void RbUtilQt::installPortable(void)
1086 if(QMessageBox::question(this, tr("Confirm installation"),
1087 tr("Do you really want to install Rockbox Utility to your player? "
1088 "After installation you can run it from the players hard drive."),
1089 QMessageBox::Yes | QMessageBox::No) != QMessageBox::Yes)
1090 return;
1092 ProgressLoggerGui* logger = new ProgressLoggerGui(this);
1093 logger->setProgressMax(0);
1094 logger->setProgressValue(0);
1095 logger->show();
1096 logger->addItem(tr("Installing Rockbox Utility"), LOGINFO);
1098 // check mountpoint
1099 if(!QFileInfo(RbSettings::value(RbSettings::Mountpoint).toString()).isDir()) {
1100 logger->addItem(tr("Mount point is wrong!"),LOGERROR);
1101 logger->setFinished();
1102 return;
1105 // remove old files first.
1106 QFile::remove(RbSettings::value(RbSettings::Mountpoint).toString()
1107 + "/RockboxUtility.exe");
1108 QFile::remove(RbSettings::value(RbSettings::Mountpoint).toString()
1109 + "/RockboxUtility.ini");
1110 // copy currently running binary and currently used settings file
1111 if(!QFile::copy(qApp->applicationFilePath(),
1112 RbSettings::value(RbSettings::Mountpoint).toString()
1113 + "/RockboxUtility.exe")) {
1114 logger->addItem(tr("Error installing Rockbox Utility"), LOGERROR);
1115 logger->setFinished();
1116 return;
1118 logger->addItem(tr("Installing user configuration"), LOGINFO);
1119 if(!QFile::copy(RbSettings::userSettingFilename(),
1120 RbSettings::value(RbSettings::Mountpoint).toString()
1121 + "/RockboxUtility.ini")) {
1122 logger->addItem(tr("Error installing user configuration"), LOGERROR);
1123 logger->setFinished();
1124 return;
1126 logger->addItem(tr("Successfully installed Rockbox Utility."), LOGOK);
1127 logger->setFinished();
1128 logger->setProgressMax(1);
1129 logger->setProgressValue(1);
1134 void RbUtilQt::updateInfo()
1136 qDebug() << "[RbUtil] updating server info";
1138 QSettings log(RbSettings::value(RbSettings::Mountpoint).toString()
1139 + "/.rockbox/rbutil.log", QSettings::IniFormat, this);
1140 QStringList groups = log.childGroups();
1141 QList<QTreeWidgetItem *> items;
1142 QTreeWidgetItem *w, *w2;
1143 QString min, max;
1144 int olditems = 0;
1146 // remove old list entries (if any)
1147 int l = ui.treeInfo->topLevelItemCount();
1148 while(l--) {
1149 QTreeWidgetItem *m;
1150 m = ui.treeInfo->takeTopLevelItem(l);
1151 // delete childs (single level deep, no recursion here)
1152 int n = m->childCount();
1153 while(n--)
1154 delete m->child(n);
1156 // get and populate new items
1157 for(int a = 0; a < groups.size(); a++) {
1158 log.beginGroup(groups.at(a));
1159 QStringList keys = log.allKeys();
1160 w = new QTreeWidgetItem;
1161 w->setFlags(Qt::ItemIsEnabled);
1162 w->setText(0, groups.at(a));
1163 items.append(w);
1164 // get minimum and maximum version information so we can hilight old files
1165 min = max = log.value(keys.at(0)).toString();
1166 for(int b = 0; b < keys.size(); b++) {
1167 if(log.value(keys.at(b)).toString() > max)
1168 max = log.value(keys.at(b)).toString();
1169 if(log.value(keys.at(b)).toString() < min)
1170 min = log.value(keys.at(b)).toString();
1173 for(int b = 0; b < keys.size(); b++) {
1174 QString file;
1175 file = RbSettings::value(RbSettings::Mountpoint).toString() + "/" + keys.at(b);
1176 if(QFileInfo(file).isDir())
1177 continue;
1178 w2 = new QTreeWidgetItem(w, QStringList() << "/"
1179 + keys.at(b) << log.value(keys.at(b)).toString());
1180 if(log.value(keys.at(b)).toString() != max) {
1181 w2->setForeground(0, QBrush(QColor(255, 0, 0)));
1182 w2->setForeground(1, QBrush(QColor(255, 0, 0)));
1183 olditems++;
1185 items.append(w2);
1187 log.endGroup();
1188 if(min != max)
1189 w->setData(1, Qt::DisplayRole, QString("%1 / %2").arg(min, max));
1190 else
1191 w->setData(1, Qt::DisplayRole, max);
1193 ui.treeInfo->insertTopLevelItems(0, items);
1194 ui.treeInfo->resizeColumnToContents(0);
1198 QUrl RbUtilQt::proxy()
1200 if(RbSettings::value(RbSettings::ProxyType) == "manual")
1201 return QUrl(RbSettings::value(RbSettings::Proxy).toString());
1202 else if(RbSettings::value(RbSettings::ProxyType) == "system")
1203 return System::systemProxy();
1204 return QUrl("");
1208 bool RbUtilQt::chkConfig(bool warn)
1210 bool error = false;
1211 if(RbSettings::value(RbSettings::Platform).toString().isEmpty()
1212 || RbSettings::value(RbSettings::Mountpoint).toString().isEmpty()
1213 || !QFileInfo(RbSettings::value(RbSettings::Mountpoint).toString()).isWritable()) {
1214 error = true;
1216 if(warn) QMessageBox::critical(this, tr("Configuration error"),
1217 tr("Your configuration is invalid. Please go to the configuration "
1218 "dialog and make sure the selected values are correct."));
1220 return error;
1223 void RbUtilQt::checkUpdate(void)
1225 QString url = RbSettings::value(RbSettings::RbutilUrl).toString();
1226 #if defined(Q_OS_WIN32)
1227 url += "win32/";
1228 #elif defined(Q_OS_LINUX)
1229 url += "linux/";
1230 #elif defined(Q_OS_MACX)
1231 url += "macosx/";
1232 #endif
1234 update = new HttpGet(this);
1235 connect(update, SIGNAL(done(bool)), this, SLOT(downloadUpdateDone(bool)));
1236 connect(update, SIGNAL(requestFinished(int, bool)), this, SLOT(downloadDone(int, bool)));
1237 connect(qApp, SIGNAL(lastWindowClosed()), update, SLOT(abort()));
1238 if(RbSettings::value(RbSettings::CacheOffline).toBool())
1239 update->setCache(true);
1241 update->getFile(QUrl(url));
1244 void RbUtilQt::downloadUpdateDone(bool error)
1246 if(error) {
1247 qDebug() << "[RbUtil] network error:" << update->error();
1249 else {
1250 QString toParse(update->readAll());
1252 QRegExp searchString("<a[^>]*>(rbutilqt[^<]*)</a>");
1253 QStringList rbutilList;
1254 int pos = 0;
1255 while ((pos = searchString.indexIn(toParse, pos)) != -1)
1257 rbutilList << searchString.cap(1);
1258 pos += searchString.matchedLength();
1260 qDebug() << "[Checkupdate] " << rbutilList;
1262 QString newVersion ="";
1263 //check if there is a binary with higher version in this list
1264 for(int i=0; i < rbutilList.size(); i++)
1266 #if defined(Q_OS_LINUX)
1267 #if defined(__amd64__)
1268 //skip if it isnt a 64bit build
1269 if( !rbutilList.at(i).contains("64bit"))
1270 continue;
1271 #else
1272 //skip if it is a 64bit build
1273 if(rbutilList.at(i).contains("64bit"))
1274 continue;
1275 #endif
1276 #endif
1277 //check if it is newer, and remember newest
1278 if(newerVersion(VERSION,rbutilList.at(i)))
1280 if(newVersion == "" || newerVersion(newVersion,rbutilList.at(i)))
1282 newVersion = rbutilList.at(i);
1287 // if we found something newer, display info
1288 if(newVersion != "")
1290 QString url = RbSettings::value(RbSettings::RbutilUrl).toString();
1291 #if defined(Q_OS_WIN32)
1292 url += "win32/";
1293 #elif defined(Q_OS_LINUX)
1294 url += "linux/";
1295 #elif defined(Q_OS_MACX)
1296 url += "macosx/";
1297 #endif
1298 url += newVersion;
1300 QMessageBox::information(this,tr("RockboxUtility Update available"),
1301 tr("<b>New RockboxUtility Version available.</b> <br><br>"
1302 "Download it from here: <a href='%1'>%2</a>").arg(url).arg(newVersion) );
1307 bool RbUtilQt::newerVersion(QString versionOld,QString versionNew)
1309 QRegExp chars("\\d*(\\D)");
1311 //strip non-number from beginning
1312 versionOld = versionOld.remove(0,versionOld.indexOf(QRegExp("\\d")));
1313 versionNew = versionNew.remove(0,versionNew.indexOf(QRegExp("\\d")));
1315 // split versions by "."
1316 QStringList versionListOld = versionOld.split(".");
1317 QStringList versionListNew = versionNew.split(".");
1319 QStringListIterator iteratorOld(versionListOld);
1320 QStringListIterator iteratorNew(versionListNew);
1322 //check every section
1323 while(iteratorOld.hasNext() && iteratorNew.hasNext())
1325 QString newPart = iteratorNew.next();
1326 QString oldPart = iteratorOld.next();
1327 QString newPartChar = "", oldPartChar = "";
1328 int newPartInt = 0, oldPartInt =0;
1330 //convert to int, if it contains chars, put into seperated variable
1331 if(newPart.contains(chars))
1333 newPartChar = chars.cap(1);
1334 newPart = newPart.remove(newPartChar);
1336 newPartInt = newPart.toInt();
1337 //convert to int, if it contains chars, put into seperated variable
1338 if(oldPart.contains(chars))
1340 oldPartChar = chars.cap(1);
1341 oldPart = oldPart.remove(oldPartChar);
1343 oldPartInt = oldPart.toInt();
1345 if(newPartInt > oldPartInt) // this section int is higher -> true
1346 return true;
1347 else if(newPartInt < oldPartInt) //this section int is lower -> false
1348 return false;
1349 else if(newPartChar > oldPartChar) //ints are the same, chars is higher -> true
1350 return true;
1351 else if(newPartChar < oldPartChar) //ints are the same, chars is lower -> false
1352 return false;
1353 //all the same, next section
1355 // all the same -> false
1356 return false;