1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
|
/***************************************************************************
* __________ __ ___.
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
* \/ \/ \/ \/ \/
*
* Copyright (C) 2007 by Dominik Riebeling
* $Id$
*
* All files in this archive are subject to the GNU General Public License.
* See the file COPYING in the source tree root for full license agreement.
*
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied.
*
****************************************************************************/
#include <QtGui>
#include "version.h"
#include "rbutilqt.h"
#include "ui_rbutilqtfrm.h"
#include "ui_aboutbox.h"
#include "configure.h"
#include "install.h"
#include "installtalkwindow.h"
#include "httpget.h"
#include "installbootloader.h"
#include "installthemes.h"
#include "uninstallwindow.h"
#include "browseof.h"
#ifdef __linux
#include <stdio.h>
#endif
RbUtilQt::RbUtilQt(QWidget *parent) : QMainWindow(parent)
{
absolutePath = qApp->applicationDirPath();
// use built-in rbutil.ini if no external file in binary folder
QString iniFile = absolutePath + "/rbutil.ini";
if(QFileInfo(iniFile).isFile()) {
qDebug() << "using external rbutil.ini";
devices = new QSettings(iniFile, QSettings::IniFormat, 0);
}
else {
qDebug() << "using built-in rbutil.ini";
devices = new QSettings(":/ini/rbutil.ini", QSettings::IniFormat, 0);
}
ui.setupUi(this);
// portable installation:
// check for a configuration file in the program folder.
QFileInfo config;
config.setFile(absolutePath + "/RockboxUtility.ini");
if(config.isFile()) {
userSettings = new QSettings(absolutePath + "/RockboxUtility.ini",
QSettings::IniFormat, 0);
qDebug() << "config: portable";
}
else {
userSettings = new QSettings(QSettings::IniFormat,
QSettings::UserScope, "rockbox.org", "RockboxUtility");
qDebug() << "config: system";
}
// manual tab
updateManual();
updateDevice();
ui.radioPdf->setChecked(true);
// info tab
ui.treeInfo->setAlternatingRowColors(true);
ui.treeInfo->setHeaderLabels(QStringList() << tr("File") << tr("Version"));
ui.treeInfo->expandAll();
ui.treeInfo->setColumnCount(2);
connect(ui.tabWidget, SIGNAL(currentChanged(int)), this, SLOT(updateTabs(int)));
connect(ui.actionAbout_Qt, SIGNAL(triggered()), qApp, SLOT(aboutQt()));
connect(ui.action_About, SIGNAL(triggered()), this, SLOT(about()));
connect(ui.action_Help, SIGNAL(triggered()), this, SLOT(help()));
connect(ui.action_Configure, SIGNAL(triggered()), this, SLOT(configDialog()));
connect(ui.buttonChangeDevice, SIGNAL(clicked()), this, SLOT(configDialog()));
connect(ui.buttonRockbox, SIGNAL(clicked()), this, SLOT(installBtn()));
connect(ui.buttonBootloader, SIGNAL(clicked()), this, SLOT(installBootloaderBtn()));
connect(ui.buttonFonts, SIGNAL(clicked()), this, SLOT(installFontsBtn()));
connect(ui.buttonGames, SIGNAL(clicked()), this, SLOT(installDoomBtn()));
connect(ui.buttonTalk, SIGNAL(clicked()), this, SLOT(createTalkFiles()));
connect(ui.buttonVoice, SIGNAL(clicked()), this, SLOT(installVoice()));
connect(ui.buttonThemes, SIGNAL(clicked()), this, SLOT(installThemes()));
connect(ui.buttonRemoveRockbox, SIGNAL(clicked()), this, SLOT(uninstall()));
connect(ui.buttonRemoveBootloader, SIGNAL(clicked()), this, SLOT(uninstallBootloader()));
connect(ui.buttonDownloadManual, SIGNAL(clicked()), this, SLOT(downloadManual()));
connect(ui.buttonSmall, SIGNAL(clicked()), this, SLOT(smallInstall()));
connect(ui.buttonComplete, SIGNAL(clicked()), this, SLOT(completeInstall()));
#if !defined(STATIC)
ui.actionInstall_Rockbox_Utility_on_player->setEnabled(false);
#else
connect(ui.actionInstall_Rockbox_Utility_on_player, SIGNAL(triggered()), this, SLOT(installPortable()));
#endif
initIpodpatcher();
initSansapatcher();
downloadInfo();
}
void RbUtilQt::updateTabs(int count)
{
switch(count) {
case 6:
updateInfo();
break;
default:
break;
}
}
void RbUtilQt::downloadInfo()
{
// try to get the current build information
daily = new HttpGet(this);
connect(daily, SIGNAL(done(bool)), this, SLOT(downloadDone(bool)));
connect(daily, SIGNAL(requestFinished(int, bool)), this, SLOT(downloadDone(int, bool)));
connect(qApp, SIGNAL(lastWindowClosed()), daily, SLOT(abort()));
daily->setProxy(proxy());
if(userSettings->value("offline").toBool())
daily->setCache(userSettings->value("cachepath", QDir::tempPath()).toString());
qDebug() << "downloading build info";
daily->setFile(&buildInfo);
daily->getFile(QUrl(devices->value("server_conf_url").toString()));
}
void RbUtilQt::downloadDone(bool error)
{
if(error) {
qDebug() << "network error:" << daily->error();
return;
}
qDebug() << "network status:" << daily->error();
buildInfo.open();
QSettings info(buildInfo.fileName(), QSettings::IniFormat, this);
buildInfo.close();
versmap.insert("arch_rev", info.value("dailies/rev").toString());
versmap.insert("arch_date", info.value("dailies/date").toString());
bleeding = new HttpGet(this);
connect(bleeding, SIGNAL(done(bool)), this, SLOT(downloadBleedingDone(bool)));
connect(bleeding, SIGNAL(requestFinished(int, bool)), this, SLOT(downloadDone(int, bool)));
connect(qApp, SIGNAL(lastWindowClosed()), daily, SLOT(abort()));
bleeding->setProxy(proxy());
if(userSettings->value("offline").toBool())
bleeding->setCache(userSettings->value("cachepath", QDir::tempPath()).toString());
bleeding->setFile(&bleedingInfo);
bleeding->getFile(QUrl(devices->value("bleeding_info").toString()));
}
void RbUtilQt::downloadBleedingDone(bool error)
{
if(error) qDebug() << "network error:" << bleeding->error();
bleedingInfo.open();
QSettings info(bleedingInfo.fileName(), QSettings::IniFormat, this);
bleedingInfo.close();
versmap.insert("bleed_rev", info.value("bleeding/rev").toString());
versmap.insert("bleed_date", info.value("bleeding/timestamp").toString());
qDebug() << "versmap =" << versmap;
}
void RbUtilQt::downloadDone(int id, bool error)
{
QString errorString;
errorString = tr("Network error: %1. Please check your network and proxy settings.")
.arg(daily->errorString());
if(error) {
QMessageBox::about(this, "Network Error", errorString);
}
qDebug() << "downloadDone:" << id << error;
}
void RbUtilQt::about()
{
QDialog *window = new QDialog(this);
Ui::aboutBox about;
about.setupUi(window);
window->setModal(true);
QFile licence(":/docs/gpl-2.0.html");
licence.open(QIODevice::ReadOnly);
QTextStream c(&licence);
QString cline = c.readAll();
about.browserLicense->insertHtml(cline);
about.browserLicense->moveCursor(QTextCursor::Start, QTextCursor::MoveAnchor);
QFile credits(":/docs/CREDITS");
credits.open(QIODevice::ReadOnly);
QTextStream r(&credits);
QString rline = r.readAll();
about.browserCredits->insertPlainText(rline);
about.browserCredits->moveCursor(QTextCursor::Start, QTextCursor::MoveAnchor);
QString title = QString("<b>The Rockbox Utility</b><br/>Version %1").arg(VERSION);
about.labelTitle->setText(title);
about.labelHomepage->setText("<a href='http://www.rockbox.org'>http://www.rockbox.org</a>");
window->show();
}
void RbUtilQt::help()
{
QUrl helpurl("http://www.rockbox.org/wiki/RockboxUtilityQt");
QDesktopServices::openUrl(helpurl);
}
void RbUtilQt::configDialog()
{
Config *cw = new Config(this);
cw->setUserSettings(userSettings);
cw->setDevices(devices);
cw->show();
connect(cw, SIGNAL(settingsUpdated()), this, SLOT(downloadInfo()));
connect(cw, SIGNAL(settingsUpdated()), this, SLOT(updateSettings()));
}
void RbUtilQt::updateSettings()
{
qDebug() << "updateSettings()";
updateDevice();
updateManual();
}
void RbUtilQt::updateDevice()
{
platform = userSettings->value("platform").toString();
// buttons
devices->beginGroup(platform);
if(devices->value("needsbootloader", "") == "no") {
ui.buttonBootloader->setEnabled(false);
ui.buttonRemoveBootloader->setEnabled(false);
ui.labelBootloader->setEnabled(false);
ui.labelRemoveBootloader->setEnabled(false);
}
else {
ui.buttonBootloader->setEnabled(true);
ui.labelBootloader->setEnabled(true);
if(devices->value("bootloadermethod") == "fwpatcher") {
ui.labelRemoveBootloader->setEnabled(false);
ui.buttonRemoveBootloader->setEnabled(false);
}
else {
ui.labelRemoveBootloader->setEnabled(true);
ui.buttonRemoveBootloader->setEnabled(true);
}
}
devices->endGroup();
// displayed device info
platform = userSettings->value("platform").toString();
QString mountpoint = userSettings->value("mountpoint").toString();
devices->beginGroup(platform);
QString brand = devices->value("brand").toString();
QString name = devices->value("name").toString();
devices->endGroup();
if(name.isEmpty()) name = "<none>";
if(mountpoint.isEmpty()) mountpoint = "<invalid>";
ui.labelDevice->setText(tr("<b>%1 %2</b> at <b>%3</b>")
.arg(brand, name, mountpoint));
}
void RbUtilQt::updateManual()
{
if(userSettings->value("platform").toString() != "")
{
devices->beginGroup(userSettings->value("platform").toString());
QString manual;
manual = devices->value("manualname", "").toString();
if(manual == "")
manual = "rockbox-" + devices->value("platform").toString();
devices->endGroup();
QString pdfmanual;
pdfmanual = devices->value("manual_url").toString() + "/" + manual + ".pdf";
QString htmlmanual;
htmlmanual = devices->value("manual_url").toString() + "/" + manual + "/rockbox-build.html";
ui.labelPdfManual->setText(tr("<a href='%1'>PDF Manual</a>")
.arg(pdfmanual));
ui.labelHtmlManual->setText(tr("<a href='%1'>HTML Manual (opens in browser)</a>")
.arg(htmlmanual));
}
else {
ui.labelPdfManual->setText(tr("Select a device for a link to the correct manual"));
ui.labelHtmlManual->setText(tr("<a href='%1'>Manual Overview</a>")
.arg("http://www.rockbox.org/manual.shtml"));
}
}
void RbUtilQt::completeInstall()
{
if(QMessageBox::question(this, tr("Confirm Installation"),
tr("Do you really want to make a complete Installation?"),
QMessageBox::Yes | QMessageBox::No) != QMessageBox::Yes) return;
// create logger
logger = new ProgressLoggerGui(this);
logger->show();
QString mountpoint = userSettings->value("mountpoint").toString();
// show dialog with error if mount point is wrong
if(!QFileInfo(mountpoint).isDir()) {
logger->addItem(tr("Mount point is wrong!"),LOGERROR);
logger->abort();
return;
}
// Bootloader
m_error = false;
m_installed = false;
if(!installBootloaderAuto())
return;
else
{
// wait for boot loader installation finished
while(!m_installed)
QApplication::processEvents();
}
if(m_error) return;
logger->undoAbort();
// Rockbox
m_error = false;
m_installed = false;
if(!installAuto())
return;
else
{
// wait for boot loader installation finished
while(!m_installed)
QApplication::processEvents();
}
if(m_error) return;
logger->undoAbort();
// Fonts
m_error = false;
m_installed = false;
if(!installFontsAuto())
return;
else
{
// wait for boot loader installation finished
while(!m_installed)
QApplication::processEvents();
}
if(m_error) return;
logger->undoAbort();
// Doom
m_error = false;
m_installed = false;
if(!installDoomAuto())
return;
else
{
// wait for boot loader installation finished
while(!m_installed)
QApplication::processEvents();
}
if(m_error) return;
// theme
// this is a window
// it has its own logger window,so close our.
logger->close();
installThemes();
}
void RbUtilQt::smallInstall()
{
if(QMessageBox::question(this, tr("Confirm Installation"),
tr("Do you really want to make a small Installation?"),
QMessageBox::Yes | QMessageBox::No) != QMessageBox::Yes) return;
// create logger
logger = new ProgressLoggerGui(this);
logger->show();
QString mountpoint = userSettings->value("mountpoint").toString();
// show dialog with error if mount point is wrong
if(!QFileInfo(mountpoint).isDir()) {
logger->addItem(tr("Mount point is wrong!"),LOGERROR);
logger->abort();
return;
}
// Bootloader
m_error = false;
m_installed = false;
if(!installBootloaderAuto())
return;
else
{
// wait for boot loader installation finished
while(!m_installed)
QApplication::processEvents();
}
if(m_error) return;
logger->undoAbort();
// Rockbox
m_error = false;
m_installed = false;
if(!installAuto())
return;
else
{
// wait for boot loader installation finished
while(!m_installed)
QApplication::processEvents();
}
}
void RbUtilQt::installdone(bool error)
{
qDebug() << "install done";
m_installed = true;
m_error = error;
}
void RbUtilQt::installBtn()
{
install();
}
bool RbUtilQt::installAuto()
{
QString file = QString("%1%2/rockbox.zip")
.arg(devices->value("bleeding_url").toString(),
userSettings->value("platform").toString());
buildInfo.open();
QSettings info(buildInfo.fileName(), QSettings::IniFormat, this);
buildInfo.close();
devices->beginGroup(platform);
QString released = devices->value("released").toString();
devices->endGroup();
if(released == "yes") {
// only set the keys if needed -- querying will yield an empty string
// if not set.
versmap.insert("rel_rev", devices->value("last_release").toString());
versmap.insert("rel_date", ""); // FIXME: provide the release timestamp
}
QString myversion = "r" + versmap.value("bleed_rev");
ZipInstaller* installer = new ZipInstaller(this);
installer->setUrl(file);
installer->setProxy(proxy());
installer->setLogSection("Rockbox (Base)");
installer->setLogVersion(myversion);
if(!userSettings->value("cachedisable").toBool())
installer->setCache(userSettings->value("cachepath", QDir::tempPath()).toString());
installer->setMountPoint(userSettings->value("mountpoint").toString());
installer->install(logger);
connect(installer, SIGNAL(done(bool)), this, SLOT(installdone(bool)));
return true;
}
void RbUtilQt::install()
{
Install *installWindow = new Install(this);
installWindow->setUserSettings(userSettings);
installWindow->setDeviceSettings(devices);
installWindow->setProxy(proxy());
buildInfo.open();
QSettings info(buildInfo.fileName(), QSettings::IniFormat, this);
buildInfo.close();
devices->beginGroup(platform);
QString released = devices->value("released").toString();
devices->endGroup();
if(released == "yes") {
// only set the keys if needed -- querying will yield an empty string
// if not set.
versmap.insert("rel_rev", devices->value("last_release").toString());
versmap.insert("rel_date", ""); // FIXME: provide the release timestamp
}
installWindow->setVersionStrings(versmap);
installWindow->show();
}
bool RbUtilQt::installBootloaderAuto()
{
installBootloader();
connect(blinstaller,SIGNAL(done(bool)),this,SLOT(installdone(bool)));
return !m_error;
}
void RbUtilQt::installBootloaderBtn()
{
if(QMessageBox::question(this, tr("Confirm Installation"),
tr("Do you really want to install the Bootloader?"),
QMessageBox::Yes | QMessageBox::No) != QMessageBox::Yes) return;
// create logger
logger = new ProgressLoggerGui(this);
logger->show();
installBootloader();
}
void RbUtilQt::installBootloader()
{
QString platform = userSettings->value("platform").toString();
// create installer
blinstaller = new BootloaderInstaller(this);
blinstaller->setMountPoint(userSettings->value("mountpoint").toString());
blinstaller->setProxy(proxy());
blinstaller->setDevice(platform);
blinstaller->setBootloaderMethod(devices->value(platform + "/bootloadermethod").toString());
blinstaller->setBootloaderName(devices->value(platform + "/bootloadername").toString());
blinstaller->setBootloaderBaseUrl(devices->value("bootloader_url").toString());
blinstaller->setBootloaderInfoUrl(devices->value("bootloader_info_url").toString());
if(!blinstaller->downloadInfo())
{
logger->addItem(tr("Could not get the bootloader info file!"),LOGERROR);
logger->abort();
m_error = true;
return;
}
if(blinstaller->uptodate())
{
int ret = QMessageBox::question(this, tr("Bootloader Installation"),
tr("It seem your Bootloader is already uptodate.\n"
"Do really want to install it?"),
QMessageBox::Ok | QMessageBox::Ignore |QMessageBox::Cancel,
QMessageBox::Cancel);
if(ret == QMessageBox::Cancel)
{
logger->addItem(tr("Bootloader installation Canceled!"),LOGERROR);
logger->abort();
m_error = true;
return;
}
else if(ret == QMessageBox::Ignore)
{
logger->addItem(tr("Bootloader installation Skipped!"),LOGERROR);
logger->abort();
m_installed = true;
return;
}
}
// if fwpatcher , ask for extra file
QString offirmware;
if(devices->value(platform + "/bootloadermethod").toString() == "fwpatcher")
{
BrowseOF ofbrowser(this);
ofbrowser.setFile(userSettings->value("ofpath").toString());
if(ofbrowser.exec() == QDialog::Accepted)
{
offirmware = ofbrowser.getFile();
qDebug() << offirmware;
if(!QFileInfo(offirmware).exists())
{
logger->addItem(tr("Original Firmware Path is wrong!"),LOGERROR);
logger->abort();
m_error = true;
return;
}
else
{
userSettings->setValue("ofpath",offirmware);
userSettings->sync();
}
}
else
{
logger->addItem(tr("Original Firmware selection Canceled!"),LOGERROR);
logger->abort();
m_error = true;
return;
}
}
blinstaller->setOrigFirmwarePath(offirmware);
blinstaller->install(logger);
}
void RbUtilQt::installFontsBtn()
{
if(QMessageBox::question(this, tr("Confirm Installation"),
tr("Do you really want to install the fonts package?"),
QMessageBox::Yes | QMessageBox::No) != QMessageBox::Yes) return;
// create logger
logger = new ProgressLoggerGui(this);
logger->show();
installFonts();
}
bool RbUtilQt::installFontsAuto()
{
installFonts();
connect(installer, SIGNAL(done(bool)), this, SLOT(installdone(bool)));
return !m_error;
}
void RbUtilQt::installFonts()
{
// create zip installer
installer = new ZipInstaller(this);
installer->setUrl(devices->value("font_url").toString());
installer->setProxy(proxy());
installer->setLogSection("Fonts");
installer->setLogVersion(versmap.value("arch_date"));
installer->setMountPoint(userSettings->value("mountpoint").toString());
if(!userSettings->value("cachedisable").toBool())
installer->setCache(userSettings->value("cachepath", QDir::tempPath()).toString());
installer->install(logger);
}
void RbUtilQt::installVoice()
{
if(QMessageBox::question(this, tr("Confirm Installation"),
tr("Do you really want to install the voice file?"),
QMessageBox::Yes | QMessageBox::No) != QMessageBox::Yes) return;
// create logger
logger = new ProgressLoggerGui(this);
logger->show();
// create zip installer
installer = new ZipInstaller(this);
installer->setUnzip(false);
QString voiceurl = devices->value("voice_url").toString() + "/" +
userSettings->value("platform").toString() + "-" +
versmap.value("arch_date") + "-english.voice";
qDebug() << voiceurl;
installer->setProxy(proxy());
installer->setUrl(voiceurl);
installer->setLogSection("Voice");
installer->setLogVersion(versmap.value("arch_date"));
installer->setMountPoint(userSettings->value("mountpoint").toString());
installer->setTarget("/.rockbox/langs/english.voice");
if(!userSettings->value("cachedisable").toBool())
installer->setCache(userSettings->value("cachepath", QDir::tempPath()).toString());
installer->install(logger);
//connect(installer, SIGNAL(done(bool)), this, SLOT(done(bool)));
}
void RbUtilQt::installDoomBtn()
{
QFile doomrock(userSettings->value("mountpoint").toString()+"/.rockbox/rocks/games/doom.rock");
if(!doomrock.exists()){
QMessageBox::critical(this, tr("Error"), tr("Your device doesn't have a doom plugin. Aborting."));
return;
}
if(QMessageBox::question(this, tr("Confirm Installation"),
tr("Do you really want to install the game addon files?"),
QMessageBox::Yes | QMessageBox::No) != QMessageBox::Yes) return;
// create logger
logger = new ProgressLoggerGui(this);
logger->show();
installDoom();
}
bool RbUtilQt::installDoomAuto()
{
installDoom();
connect(installer, SIGNAL(done(bool)), this, SLOT(installdone(bool)));
return !m_error;
}
void RbUtilQt::installDoom()
{
// create zip installer
installer = new ZipInstaller(this);
installer->setUrl(devices->value("doom_url").toString());
installer->setProxy(proxy());
installer->setLogSection("Game Addons");
installer->setLogVersion(versmap.value("arch_date"));
installer->setMountPoint(userSettings->value("mountpoint").toString());
if(!userSettings->value("cachedisable").toBool())
installer->setCache(userSettings->value("cachepath", QDir::tempPath()).toString());
installer->install(logger);
}
void RbUtilQt::installThemes()
{
ThemesInstallWindow* tw = new ThemesInstallWindow(this);
tw->setDeviceSettings(devices);
tw->setUserSettings(userSettings);
tw->setProxy(proxy());
tw->setModal(true);
tw->show();
}
void RbUtilQt::createTalkFiles(void)
{
InstallTalkWindow *installWindow = new InstallTalkWindow(this);
installWindow->setUserSettings(userSettings);
installWindow->setDeviceSettings(devices);
installWindow->show();
}
void RbUtilQt::uninstall(void)
{
UninstallWindow *uninstallWindow = new UninstallWindow(this);
uninstallWindow->setUserSettings(userSettings);
uninstallWindow->setDeviceSettings(devices);
uninstallWindow->show();
}
void RbUtilQt::uninstallBootloader(void)
{
if(QMessageBox::question(this, tr("Confirm Uninstallation"),
tr("Do you really want to uninstall the Bootloader?"),
QMessageBox::Yes | QMessageBox::No) != QMessageBox::Yes) return;
// create logger
ProgressLoggerGui* logger = new ProgressLoggerGui(this);
logger->show();
QString plattform = userSettings->value("platform").toString();
BootloaderInstaller blinstaller(this);
blinstaller.setMountPoint(userSettings->value("mountpoint").toString());
blinstaller.setDevice(userSettings->value("platform").toString());
blinstaller.setBootloaderMethod(devices->value(plattform + "/bootloadermethod").toString());
blinstaller.setBootloaderName(devices->value(plattform + "/bootloadername").toString());
blinstaller.setBootloaderBaseUrl(devices->value("bootloader_url").toString());
blinstaller.setBootloaderInfoUrl(devices->value("bootloader_info_url").toString());
if(!blinstaller.downloadInfo())
{
logger->addItem(tr("Could not get the bootloader info file!"),LOGERROR);
logger->abort();
return;
}
blinstaller.uninstall(logger);
}
void RbUtilQt::downloadManual(void)
{
if(QMessageBox::question(this, tr("Confirm download"),
tr("Do you really want to download the manual? The manual will be saved "
"to the root folder of your player."),
QMessageBox::Yes | QMessageBox::No) != QMessageBox::Yes)
return;
buildInfo.open();
QSettings info(buildInfo.fileName(), QSettings::IniFormat, this);
buildInfo.close();
devices->beginGroup(userSettings->value("platform").toString());
QString manual;
manual = devices->value("manualname", "rockbox-" + devices->value("platform").toString()).toString();
devices->endGroup();
QString date = (info.value("dailies/date").toString());
QString manualurl;
QString target;
QString section;
if(ui.radioPdf->isChecked()) {
target = "/" + manual + ".pdf";
section = "Manual (PDF)";
}
else {
target = "/" + manual + "-" + date + "-html.zip";
section = "Manual (HTML)";
}
manualurl = devices->value("manual_url").toString() + "/" + target;
qDebug() << "manualurl =" << manualurl;
ProgressLoggerGui* logger = new ProgressLoggerGui(this);
logger->show();
installer = new ZipInstaller(this);
installer->setMountPoint(userSettings->value("mountpoint").toString());
if(!userSettings->value("cachedisable").toBool())
installer->setCache(userSettings->value("cachepath", QDir::tempPath()).toString());
installer->setProxy(proxy());
installer->setLogSection(section);
installer->setUrl(manualurl);
installer->setUnzip(false);
installer->setTarget(target);
installer->install(logger);
}
void RbUtilQt::installPortable(void)
{
if(QMessageBox::question(this, tr("Confirm installation"),
tr("Do you really want to install Rockbox Utility to your player? "
"After installation you can run it from the players hard drive."),
QMessageBox::Yes | QMessageBox::No) != QMessageBox::Yes)
return;
ProgressLoggerGui* logger = new ProgressLoggerGui(this);
logger->show();
logger->addItem(tr("Installing Rockbox Utility"), LOGINFO);
// check mountpoint
if(!QFileInfo(userSettings->value("mountpoint").toString()).isDir()) {
logger->addItem(tr("Mount point is wrong!"),LOGERROR);
logger->abort();
return;
}
// remove old files first.
QFile::remove(userSettings->value("mountpoint").toString() + "/RockboxUtility.exe");
QFile::remove(userSettings->value("mountpoint").toString() + "/RockboxUtility.ini");
// copy currently running binary and currently used settings file
if(!QFile::copy(qApp->applicationFilePath(), userSettings->value("mountpoint").toString() + "/RockboxUtility.exe")) {
logger->addItem(tr("Error installing Rockbox Utility"), LOGERROR);
logger->abort();
return;
}
logger->addItem(tr("Installing user configuration"), LOGINFO);
if(!QFile::copy(userSettings->fileName(), userSettings->value("mountpoint").toString() + "/RockboxUtility.ini")) {
logger->addItem(tr("Error installing user configuration"), LOGERROR);
logger->abort();
return;
}
logger->addItem(tr("Successfully installed Rockbox Utility."), LOGOK);
logger->abort();
}
void RbUtilQt::updateInfo()
{
qDebug() << "RbUtilQt::updateInfo()";
QSettings log(userSettings->value("mountpoint").toString() + "/.rockbox/rbutil.log", QSettings::IniFormat, this);
QStringList groups = log.childGroups();
QList<QTreeWidgetItem *> items;
QTreeWidgetItem *w, *w2;
QString min, max;
int olditems = 0;
// remove old list entries (if any)
int l = ui.treeInfo->topLevelItemCount();
while(l--) {
QTreeWidgetItem *m;
m = ui.treeInfo->takeTopLevelItem(l);
// delete childs (single level deep, no recursion here)
int n = m->childCount();
while(n--)
delete m->child(n);
}
// get and populate new items
for(int a = 0; a < groups.size(); a++) {
log.beginGroup(groups.at(a));
QStringList keys = log.allKeys();
w = new QTreeWidgetItem;
w->setFlags(Qt::ItemIsEnabled);
w->setText(0, groups.at(a));
items.append(w);
// get minimum and maximum version information so we can hilight old files
min = max = log.value(keys.at(0)).toString();
for(int b = 0; b < keys.size(); b++) {
if(log.value(keys.at(b)).toString() > max)
max = log.value(keys.at(b)).toString();
if(log.value(keys.at(b)).toString() < min)
min = log.value(keys.at(b)).toString();
}
for(int b = 0; b < keys.size(); b++) {
QString file;
file = userSettings->value("mountpoint").toString() + "/" + keys.at(b);
if(QFileInfo(file).isDir())
continue;
w2 = new QTreeWidgetItem(w, QStringList() << "/"
+ keys.at(b) << log.value(keys.at(b)).toString());
if(log.value(keys.at(b)).toString() != max) {
w2->setForeground(0, QBrush(QColor(255, 0, 0)));
w2->setForeground(1, QBrush(QColor(255, 0, 0)));
olditems++;
}
items.append(w2);
}
log.endGroup();
if(min != max)
w->setData(1, Qt::DisplayRole, QString("%1 / %2").arg(min, max));
else
w->setData(1, Qt::DisplayRole, max);
}
ui.treeInfo->insertTopLevelItems(0, items);
ui.treeInfo->resizeColumnToContents(0);
}
QUrl RbUtilQt::proxy()
{
if(userSettings->value("proxytype") == "manual")
return QUrl(userSettings->value("proxy").toString());
#ifdef __linux
else if(userSettings->value("proxytype") == "system")
return QUrl(getenv("http_proxy"));
#endif
return QUrl("");
}
|