summaryrefslogtreecommitdiff
path: root/rbutil/rbutilqt/installbootloader.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'rbutil/rbutilqt/installbootloader.cpp')
-rw-r--r--rbutil/rbutilqt/installbootloader.cpp125
1 files changed, 123 insertions, 2 deletions
diff --git a/rbutil/rbutilqt/installbootloader.cpp b/rbutil/rbutilqt/installbootloader.cpp
index c124c71150..11798c1232 100644
--- a/rbutil/rbutilqt/installbootloader.cpp
+++ b/rbutil/rbutilqt/installbootloader.cpp
@@ -22,7 +22,7 @@
22 22
23BootloaderInstaller::BootloaderInstaller(QObject* parent): QObject(parent) 23BootloaderInstaller::BootloaderInstaller(QObject* parent): QObject(parent)
24{ 24{
25 25
26} 26}
27 27
28void BootloaderInstaller::install(ProgressloggerInterface* dp) 28void BootloaderInstaller::install(ProgressloggerInterface* dp)
@@ -179,6 +179,108 @@ void BootloaderInstaller::installEnded(bool error)
179 m_dp->abort(); 179 m_dp->abort();
180} 180}
181 181
182bool BootloaderInstaller::downloadInfo()
183{
184 // try to get the current build information
185 infodownloader = new HttpGet(this);
186
187 connect(infodownloader, SIGNAL(done(bool)), this, SLOT(infoDownloadDone(bool)));
188 connect(infodownloader, SIGNAL(requestFinished(int, bool)), this, SLOT(infoRequestFinished(int, bool)));
189
190 infodownloader->setProxy(m_proxy);
191
192 qDebug() << "downloading bootloader info";
193 infodownloader->setFile(&bootloaderInfo);
194 infodownloader->getFile(QUrl(m_bootloaderinfoUrl));
195
196 // block until its downloaded
197 qDebug() << "Waiting for Download finished";
198 infoDownloaded=false;
199 infoError = false;
200 while(!infoDownloaded )
201 QApplication::processEvents();
202 return !infoError;
203}
204
205void BootloaderInstaller::infoDownloadDone(bool error)
206{
207 if(error)
208 {
209 qDebug() << "network error:" << infodownloader->error();
210 return;
211 }
212 qDebug() << "network status:" << infodownloader->error();
213
214 infoDownloaded = true;
215}
216
217void BootloaderInstaller::infoRequestFinished(int id, bool error)
218{
219
220 if(error)
221 {
222 QString errorString;
223 errorString = tr("Network error: %1. Please check your network and proxy settings.")
224 .arg(infodownloader->errorString());
225 if(error) QMessageBox::about(NULL, "Network Error", errorString);
226 qDebug() << "downloadDone:" << id << error;
227
228 infoError = true;
229 infoDownloaded = true;
230 }
231 qDebug() << "infoRequestFinished:" << id << error;
232}
233
234
235void BootloaderInstaller::createInstallLog()
236{
237 m_dp->addItem(tr("Creating installation log"),LOGINFO);
238 QSettings installlog(m_mountpoint + "/.rockbox/rbutil.log", QSettings::IniFormat, 0);
239
240 bootloaderInfo.open();
241 QSettings info(bootloaderInfo.fileName(), QSettings::IniFormat, this);
242 bootloaderInfo.close();
243 info.beginGroup(m_device);
244
245 installlog.beginGroup("Bootloader");
246 installlog.setValue("md5sum",info.value("md5sum").toString());
247 installlog.endGroup();
248 installlog.sync();
249}
250
251void BootloaderInstaller::removeInstallLog()
252{
253 m_dp->addItem(tr("Editing installation log"),LOGINFO);
254 QSettings installlog(m_mountpoint + "/.rockbox/rbutil.log", QSettings::IniFormat, 0);
255 installlog.beginGroup("Bootloader");
256 installlog.remove("md5sum");
257 installlog.endGroup();
258 installlog.sync();
259}
260
261
262bool BootloaderInstaller::uptodate()
263{
264 QString installedMd5;
265 QString serverMd5;
266
267 QSettings installlog(m_mountpoint + "/.rockbox/rbutil.log", QSettings::IniFormat, 0);
268 installlog.beginGroup("Bootloader");
269 installedMd5 = installlog.value("md5sum").toString();
270 installlog.endGroup();
271
272 bootloaderInfo.open();
273 QSettings info(bootloaderInfo.fileName(), QSettings::IniFormat, this);
274 bootloaderInfo.close();
275 info.beginGroup(m_device);
276 serverMd5 = info.value("md5sum").toString();
277 info.endGroup();
278
279 if(installedMd5 != serverMd5)
280 return false;
281 else
282 return true;
283}
182 284
183/************************************************** 285/**************************************************
184*** gigabeat secific code 286*** gigabeat secific code
@@ -244,6 +346,8 @@ void BootloaderInstaller::gigabeatPrepare()
244 return; 346 return;
245 } 347 }
246 348
349 removeInstallLog();
350
247 emit done(false); //success 351 emit done(false); //success
248 } 352 }
249 353
@@ -301,6 +405,8 @@ void BootloaderInstaller::gigabeatFinish()
301 405
302 downloadFile.remove(); 406 downloadFile.remove();
303 407
408 createInstallLog();
409
304 m_dp->addItem(tr("Bootloader install finished successfully."),LOGOK); 410 m_dp->addItem(tr("Bootloader install finished successfully."),LOGOK);
305 m_dp->addItem(tr("To finish the Bootloader installation, follow the steps below."),LOGINFO); 411 m_dp->addItem(tr("To finish the Bootloader installation, follow the steps below."),LOGINFO);
306 m_dp->addItem(tr("1. Eject/Unmount your Device."),LOGINFO); 412 m_dp->addItem(tr("1. Eject/Unmount your Device."),LOGINFO);
@@ -357,6 +463,8 @@ void BootloaderInstaller::iaudioFinish()
357 463
358 downloadFile.remove(); 464 downloadFile.remove();
359 465
466 createInstallLog();
467
360 m_dp->addItem(tr("Bootloader install finished successfully."),LOGOK); 468 m_dp->addItem(tr("Bootloader install finished successfully."),LOGOK);
361 m_dp->addItem(tr("To finish the Bootloader installation, follow the steps below."),LOGINFO); 469 m_dp->addItem(tr("To finish the Bootloader installation, follow the steps below."),LOGINFO);
362 m_dp->addItem(tr("1. Eject/Unmount your Device."),LOGINFO); 470 m_dp->addItem(tr("1. Eject/Unmount your Device."),LOGINFO);
@@ -448,6 +556,8 @@ void BootloaderInstaller::h10Prepare()
448 return; 556 return;
449 } 557 }
450 558
559 removeInstallLog();
560
451 emit done(false); //success 561 emit done(false); //success
452 562
453 } 563 }
@@ -503,7 +613,9 @@ void BootloaderInstaller::h10Finish()
503 } 613 }
504 614
505 downloadFile.remove(); 615 downloadFile.remove();
506 616
617 createInstallLog();
618
507 m_dp->addItem(tr("Bootloader install finished successfully."),LOGOK); 619 m_dp->addItem(tr("Bootloader install finished successfully."),LOGOK);
508 m_dp->abort(); 620 m_dp->abort();
509 621
@@ -639,6 +751,7 @@ void BootloaderInstaller::ipodPrepare()
639 if (delete_bootloader(&ipod)==0) 751 if (delete_bootloader(&ipod)==0)
640 { 752 {
641 m_dp->addItem(tr("Successfully removed Bootloader"),LOGOK); 753 m_dp->addItem(tr("Successfully removed Bootloader"),LOGOK);
754 removeInstallLog();
642 emit done(false); 755 emit done(false);
643 ipod_close(&ipod); 756 ipod_close(&ipod);
644 return; 757 return;
@@ -729,6 +842,7 @@ void BootloaderInstaller::ipodFinish()
729 if (add_bootloader(&ipod, m_tempfilename.toLatin1().data(), FILETYPE_DOT_IPOD)==0) 842 if (add_bootloader(&ipod, m_tempfilename.toLatin1().data(), FILETYPE_DOT_IPOD)==0)
730 { 843 {
731 m_dp->addItem(tr("Successfully added Bootloader"),LOGOK); 844 m_dp->addItem(tr("Successfully added Bootloader"),LOGOK);
845 createInstallLog();
732 emit done(false); 846 emit done(false);
733 ipod_close(&ipod); 847 ipod_close(&ipod);
734 return; 848 return;
@@ -839,6 +953,7 @@ void BootloaderInstaller::sansaPrepare()
839 if (sansa_delete_bootloader(&sansa)==0) 953 if (sansa_delete_bootloader(&sansa)==0)
840 { 954 {
841 m_dp->addItem(tr("Successfully removed Bootloader"),LOGOK); 955 m_dp->addItem(tr("Successfully removed Bootloader"),LOGOK);
956 removeInstallLog();
842 emit done(false); 957 emit done(false);
843 sansa_close(&sansa); 958 sansa_close(&sansa);
844 return; 959 return;
@@ -903,6 +1018,7 @@ void BootloaderInstaller::sansaFinish()
903 if (sansa_add_bootloader(&sansa, m_tempfilename.toLatin1().data(), FILETYPE_MI4)==0) 1018 if (sansa_add_bootloader(&sansa, m_tempfilename.toLatin1().data(), FILETYPE_MI4)==0)
904 { 1019 {
905 m_dp->addItem(tr("Successfully added Bootloader"),LOGOK); 1020 m_dp->addItem(tr("Successfully added Bootloader"),LOGOK);
1021 createInstallLog();
906 emit done(false); 1022 emit done(false);
907 sansa_close(&sansa); 1023 sansa_close(&sansa);
908 return; 1024 return;
@@ -1070,7 +1186,10 @@ void BootloaderInstaller::iriverFinish()
1070 dest = m_mountpoint + "/ihp_120.hex"; 1186 dest = m_mountpoint + "/ihp_120.hex";
1071 else if(series == 300) 1187 else if(series == 300)
1072 dest = m_mountpoint + "/H300.hex"; 1188 dest = m_mountpoint + "/H300.hex";
1189
1073 // copy file 1190 // copy file
1191 QFile destfile(dest);
1192 if(destfile.exists()) destfile.remove();
1074 if(!newHex.copy(dest)) 1193 if(!newHex.copy(dest))
1075 { 1194 {
1076 m_dp->addItem(tr("Could not copy: %1 to %2") 1195 m_dp->addItem(tr("Could not copy: %1 to %2")
@@ -1082,6 +1201,8 @@ void BootloaderInstaller::iriverFinish()
1082 downloadFile.remove(); 1201 downloadFile.remove();
1083 newHex.remove(); 1202 newHex.remove();
1084 1203
1204 createInstallLog();
1205
1085 m_dp->addItem(tr("Bootloader install finished successfully."),LOGOK); 1206 m_dp->addItem(tr("Bootloader install finished successfully."),LOGOK);
1086 m_dp->addItem(tr("To finish the Bootloader installation, follow the steps below."),LOGINFO); 1207 m_dp->addItem(tr("To finish the Bootloader installation, follow the steps below."),LOGINFO);
1087 m_dp->addItem(tr("1. Eject/Unmount your Device."),LOGINFO); 1208 m_dp->addItem(tr("1. Eject/Unmount your Device."),LOGINFO);