summaryrefslogtreecommitdiff
path: root/rbutil/rbutilqt/base/bootloaderinstallipod.cpp
diff options
context:
space:
mode:
authorDominik Riebeling <Dominik.Riebeling@gmail.com>2009-12-17 21:54:07 +0000
committerDominik Riebeling <Dominik.Riebeling@gmail.com>2009-12-17 21:54:07 +0000
commit3e0e14b592200c2516eb03c6a3b1838cd971e0f4 (patch)
treec36b639250bc73bad258316eaca8b343fd8e3546 /rbutil/rbutilqt/base/bootloaderinstallipod.cpp
parent5a4ca2f04d21322a81a776ac823040e385158204 (diff)
downloadrockbox-3e0e14b592200c2516eb03c6a3b1838cd971e0f4.tar.gz
rockbox-3e0e14b592200c2516eb03c6a3b1838cd971e0f4.zip
Remove scanning for Ipod from Ipod bootloader installation and clean it up a bit. The Ipod is specified by its mountpoint, so there is no need to scan at all.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@24056 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'rbutil/rbutilqt/base/bootloaderinstallipod.cpp')
-rw-r--r--rbutil/rbutilqt/base/bootloaderinstallipod.cpp65
1 files changed, 22 insertions, 43 deletions
diff --git a/rbutil/rbutilqt/base/bootloaderinstallipod.cpp b/rbutil/rbutilqt/base/bootloaderinstallipod.cpp
index eaf69e4773..48b35f930f 100644
--- a/rbutil/rbutilqt/base/bootloaderinstallipod.cpp
+++ b/rbutil/rbutilqt/base/bootloaderinstallipod.cpp
@@ -55,23 +55,24 @@ bool BootloaderInstallIpod::install(void)
55 emit done(true); 55 emit done(true);
56 return false; 56 return false;
57 } 57 }
58 memset(&ipod, 0, sizeof(struct ipod_t));
58 59
59 struct ipod_t ipod; 60 if(!ipodInitialize(&ipod)) {
61 emit done(true);
62 return false;
63 }
60 64
61 int n = ipod_scan(&ipod); 65 if(ipod.nimages <= 0) {
62 if(n == -1) { 66 emit logItem(tr("Failed to read firmware directory"), LOGERROR);
63 emit logItem(tr("No Ipod detected\n"
64 "Permission for disc access denied!"),
65 LOGERROR);
66 emit done(true); 67 emit done(true);
67 return false; 68 return false;
68 } 69 }
69 if(n == 0) { 70 if(getmodel(&ipod,(ipod.ipod_directory[ipod.ososimage].vers>>8)) < 0) {
70 emit logItem(tr("No Ipod detected!"), LOGERROR); 71 emit logItem(tr("Unknown version number in firmware (%1)").arg(
72 ipod.ipod_directory[0].vers), LOGERROR);
71 emit done(true); 73 emit done(true);
72 return false; 74 return false;
73 } 75 }
74
75 if(ipod.macpod) { 76 if(ipod.macpod) {
76 emit logItem(tr("Warning: This is a MacPod, Rockbox only runs on WinPods. \n" 77 emit logItem(tr("Warning: This is a MacPod, Rockbox only runs on WinPods. \n"
77 "See http://www.rockbox.org/wiki/IpodConversionToFAT32"), LOGERROR); 78 "See http://www.rockbox.org/wiki/IpodConversionToFAT32"), LOGERROR);
@@ -88,41 +89,15 @@ bool BootloaderInstallIpod::install(void)
88 89
89void BootloaderInstallIpod::installStage2(void) 90void BootloaderInstallIpod::installStage2(void)
90{ 91{
91 struct ipod_t ipod;
92
93 emit logItem(tr("Installing Rockbox bootloader"), LOGINFO); 92 emit logItem(tr("Installing Rockbox bootloader"), LOGINFO);
94 QCoreApplication::processEvents(); 93 QCoreApplication::processEvents();
95 if(!ipodInitialize(&ipod)) {
96 emit done(true);
97 return;
98 }
99
100 read_directory(&ipod);
101
102 if(ipod.nimages <= 0) {
103 emit logItem(tr("Failed to read firmware directory"), LOGERROR);
104 emit done(true);
105 return;
106 }
107 if(getmodel(&ipod,(ipod.ipod_directory[ipod.ososimage].vers>>8)) < 0) {
108 emit logItem(tr("Unknown version number in firmware (%1)").arg(
109 ipod.ipod_directory[0].vers), LOGERROR);
110 emit done(true);
111 return;
112 }
113
114 if(ipod.macpod) {
115 emit logItem(tr("Warning: This is a MacPod, Rockbox only runs on WinPods. \n"
116 "See http://www.rockbox.org/wiki/IpodConversionToFAT32"), LOGERROR);
117 emit done(true);
118 return;
119 }
120 94
121 if(ipod_reopen_rw(&ipod) < 0) { 95 if(ipod_reopen_rw(&ipod) < 0) {
122 emit logItem(tr("Could not open Ipod in R/W mode"), LOGERROR); 96 emit logItem(tr("Could not open Ipod in R/W mode"), LOGERROR);
123 emit done(true); 97 emit done(true);
124 return; 98 return;
125 } 99 }
100 QCoreApplication::processEvents();
126 101
127 m_tempfile.open(); 102 m_tempfile.open();
128 QString blfile = m_tempfile.fileName(); 103 QString blfile = m_tempfile.fileName();
@@ -174,8 +149,6 @@ bool BootloaderInstallIpod::uninstall(void)
174 return false; 149 return false;
175 } 150 }
176 151
177 read_directory(&ipod);
178
179 if (ipod.nimages <= 0) { 152 if (ipod.nimages <= 0) {
180 emit logItem(tr("Failed to read firmware directory"),LOGERROR); 153 emit logItem(tr("Failed to read firmware directory"),LOGERROR);
181 emit done(true); 154 emit done(true);
@@ -266,16 +239,20 @@ bool BootloaderInstallIpod::ipodInitialize(struct ipod_t *ipod)
266 << ipod->diskname; 239 << ipod->diskname;
267 } 240 }
268 else { 241 else {
269 ipod_scan(ipod); 242 emit logItem(tr("Error: no mountpoint specified!"), LOGERROR);
270 qDebug() << "[BootloaderInstallIpod] ipodpatcher: scanning, found device" 243 qDebug() << "[BootloaderInstallIpod] no mountpoint specified!";
271 << ipod->diskname; 244 }
245 int result = ipod_open(ipod, 1);
246 if(result == -2) {
247 emit logItem(tr("Could not open Ipod: permission denied"), LOGERROR);
248 return false;
272 } 249 }
273 if(ipod_open(ipod, 0) < 0) { 250 else if(result < 0) {
274 emit logItem(tr("Could not open Ipod"), LOGERROR); 251 emit logItem(tr("Could not open Ipod"), LOGERROR);
275 return false; 252 return false;
276 } 253 }
277 254
278 if(read_partinfo(ipod, 0) < 0) { 255 if(read_partinfo(ipod, 1) < 0) {
279 emit logItem(tr("Error reading partition table - possibly not an Ipod"), LOGERROR); 256 emit logItem(tr("Error reading partition table - possibly not an Ipod"), LOGERROR);
280 ipod_close(ipod); 257 ipod_close(ipod);
281 return false; 258 return false;
@@ -286,6 +263,8 @@ bool BootloaderInstallIpod::ipodInitialize(struct ipod_t *ipod)
286 ipod_close(ipod); 263 ipod_close(ipod);
287 return false; 264 return false;
288 } 265 }
266 read_directory(ipod);
267 ipod_close(ipod);
289 return true; 268 return true;
290} 269}
291 270