diff options
Diffstat (limited to 'rbutil')
-rw-r--r-- | rbutil/rbutilqt/base/rbsettings.cpp | 1 | ||||
-rw-r--r-- | rbutil/rbutilqt/base/rbsettings.h | 1 | ||||
-rw-r--r-- | rbutil/rbutilqt/rbutil.ini | 1 | ||||
-rw-r--r-- | rbutil/rbutilqt/rbutilqt.cpp | 139 | ||||
-rw-r--r-- | rbutil/rbutilqt/rbutilqt.h | 5 |
5 files changed, 146 insertions, 1 deletions
diff --git a/rbutil/rbutilqt/base/rbsettings.cpp b/rbutil/rbutilqt/base/rbsettings.cpp index 116f321a4c..b1c6500ed2 100644 --- a/rbutil/rbutilqt/base/rbsettings.cpp +++ b/rbutil/rbutilqt/base/rbsettings.cpp | |||
@@ -44,6 +44,7 @@ const static struct { | |||
44 | { RbSettings::ServerConfUrl, "server_conf_url", "" }, | 44 | { RbSettings::ServerConfUrl, "server_conf_url", "" }, |
45 | { RbSettings::GenlangUrl, "genlang_url", "" }, | 45 | { RbSettings::GenlangUrl, "genlang_url", "" }, |
46 | { RbSettings::ThemesUrl, "themes_url", "" }, | 46 | { RbSettings::ThemesUrl, "themes_url", "" }, |
47 | { RbSettings::RbutilUrl, "rbutil_url", "" }, | ||
47 | { RbSettings::BleedingInfo, "bleeding_info", "" }, | 48 | { RbSettings::BleedingInfo, "bleeding_info", "" }, |
48 | { RbSettings::CurPlatformName, ":platform:/name", "" }, | 49 | { RbSettings::CurPlatformName, ":platform:/name", "" }, |
49 | { RbSettings::CurManual, ":platform:/manualname","rockbox-:platform:" }, | 50 | { RbSettings::CurManual, ":platform:/manualname","rockbox-:platform:" }, |
diff --git a/rbutil/rbutilqt/base/rbsettings.h b/rbutil/rbutilqt/base/rbsettings.h index e178be0e52..b3f0430208 100644 --- a/rbutil/rbutilqt/base/rbsettings.h +++ b/rbutil/rbutilqt/base/rbsettings.h | |||
@@ -83,6 +83,7 @@ class RbSettings : public QObject | |||
83 | ServerConfUrl, | 83 | ServerConfUrl, |
84 | GenlangUrl, | 84 | GenlangUrl, |
85 | ThemesUrl, | 85 | ThemesUrl, |
86 | RbutilUrl, | ||
86 | BleedingInfo, | 87 | BleedingInfo, |
87 | CurPlatformName, | 88 | CurPlatformName, |
88 | CurManual, | 89 | CurManual, |
diff --git a/rbutil/rbutilqt/rbutil.ini b/rbutil/rbutilqt/rbutil.ini index ca27dba437..f082163411 100644 --- a/rbutil/rbutilqt/rbutil.ini +++ b/rbutil/rbutilqt/rbutil.ini | |||
@@ -13,6 +13,7 @@ manual_url=http://download.rockbox.org/daily/manual | |||
13 | doom_url=http://download.rockbox.org/useful/rockdoom.zip | 13 | doom_url=http://download.rockbox.org/useful/rockdoom.zip |
14 | voice_url=http://download.rockbox.org/daily/voices/ | 14 | voice_url=http://download.rockbox.org/daily/voices/ |
15 | genlang_url=http://www.rockbox.org/genlang/ | 15 | genlang_url=http://www.rockbox.org/genlang/ |
16 | rbutil_url=http://download.rockbox.org/rbutil/ | ||
16 | 17 | ||
17 | [platforms] | 18 | [platforms] |
18 | platform01=player | 19 | platform01=player |
diff --git a/rbutil/rbutilqt/rbutilqt.cpp b/rbutil/rbutilqt/rbutilqt.cpp index ec06955eef..083d35d8d9 100644 --- a/rbutil/rbutilqt/rbutilqt.cpp +++ b/rbutil/rbutilqt/rbutilqt.cpp | |||
@@ -212,7 +212,7 @@ void RbUtilQt::downloadDone(bool error) | |||
212 | bleeding = new HttpGet(this); | 212 | bleeding = new HttpGet(this); |
213 | connect(bleeding, SIGNAL(done(bool)), this, SLOT(downloadBleedingDone(bool))); | 213 | connect(bleeding, SIGNAL(done(bool)), this, SLOT(downloadBleedingDone(bool))); |
214 | connect(bleeding, SIGNAL(requestFinished(int, bool)), this, SLOT(downloadDone(int, bool))); | 214 | connect(bleeding, SIGNAL(requestFinished(int, bool)), this, SLOT(downloadDone(int, bool))); |
215 | connect(qApp, SIGNAL(lastWindowClosed()), daily, SLOT(abort())); | 215 | connect(qApp, SIGNAL(lastWindowClosed()), bleeding, SLOT(abort())); |
216 | if(RbSettings::value(RbSettings::CacheOffline).toBool()) | 216 | if(RbSettings::value(RbSettings::CacheOffline).toBool()) |
217 | bleeding->setCache(true); | 217 | bleeding->setCache(true); |
218 | bleeding->setFile(&bleedingInfo); | 218 | bleeding->setFile(&bleedingInfo); |
@@ -251,6 +251,9 @@ void RbUtilQt::downloadBleedingDone(bool error) | |||
251 | qDebug() << "[RbUtil] version map:" << versmap; | 251 | qDebug() << "[RbUtil] version map:" << versmap; |
252 | 252 | ||
253 | m_gotInfo = true; | 253 | m_gotInfo = true; |
254 | |||
255 | //start check for updates | ||
256 | checkUpdate(); | ||
254 | } | 257 | } |
255 | } | 258 | } |
256 | 259 | ||
@@ -1217,4 +1220,138 @@ bool RbUtilQt::chkConfig(bool warn) | |||
1217 | return error; | 1220 | return error; |
1218 | } | 1221 | } |
1219 | 1222 | ||
1223 | void RbUtilQt::checkUpdate(void) | ||
1224 | { | ||
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 | ||
1233 | |||
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); | ||
1240 | |||
1241 | update->getFile(QUrl(url)); | ||
1242 | } | ||
1220 | 1243 | ||
1244 | void RbUtilQt::downloadUpdateDone(bool error) | ||
1245 | { | ||
1246 | if(error) { | ||
1247 | qDebug() << "[RbUtil] network error:" << update->error(); | ||
1248 | } | ||
1249 | else { | ||
1250 | QString toParse(update->readAll()); | ||
1251 | qDebug() << "[Checkupdate] " << toParse; | ||
1252 | |||
1253 | QRegExp searchString("<a[^>]*>(rbutilqt[^<]*)</a>"); | ||
1254 | QStringList rbutilList; | ||
1255 | int pos = 0; | ||
1256 | while ((pos = searchString.indexIn(toParse, pos)) != -1) | ||
1257 | { | ||
1258 | rbutilList << searchString.cap(1); | ||
1259 | pos += searchString.matchedLength(); | ||
1260 | } | ||
1261 | |||
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++) | ||
1265 | { | ||
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))) | ||
1279 | { | ||
1280 | if(newVersion == "" || newerVersion(newVersion,rbutilList.at(i))) | ||
1281 | { | ||
1282 | newVersion = rbutilList.at(i); | ||
1283 | } | ||
1284 | } | ||
1285 | } | ||
1286 | |||
1287 | // if we found something newer, display info | ||
1288 | if(newVersion != "") | ||
1289 | { | ||
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; | ||
1299 | |||
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) ); | ||
1303 | } | ||
1304 | } | ||
1305 | } | ||
1306 | |||
1307 | bool RbUtilQt::newerVersion(QString versionOld,QString versionNew) | ||
1308 | { | ||
1309 | QRegExp chars("\\d*(\\D)"); | ||
1310 | |||
1311 | //strip non-number from beginning | ||
1312 | versionOld = versionOld.remove(0,versionOld.indexOf(QRegExp("\\d"))); | ||
1313 | versionNew = versionNew.remove(0,versionNew.indexOf(QRegExp("\\d"))); | ||
1314 | |||
1315 | // split versions by "." | ||
1316 | QStringList versionListOld = versionOld.split("."); | ||
1317 | QStringList versionListNew = versionNew.split("."); | ||
1318 | |||
1319 | QStringListIterator iteratorOld(versionListOld); | ||
1320 | QStringListIterator iteratorNew(versionListNew); | ||
1321 | |||
1322 | //check every section | ||
1323 | while(iteratorOld.hasNext() && iteratorNew.hasNext()) | ||
1324 | { | ||
1325 | QString newPart = iteratorNew.next(); | ||
1326 | QString oldPart = iteratorOld.next(); | ||
1327 | QString newPartChar = "", oldPartChar = ""; | ||
1328 | int newPartInt = 0, oldPartInt =0; | ||
1329 | |||
1330 | //convert to int, if it contains chars, put into seperated variable | ||
1331 | if(newPart.contains(chars)) | ||
1332 | { | ||
1333 | newPartChar = chars.cap(1); | ||
1334 | newPart = newPart.remove(newPartChar); | ||
1335 | } | ||
1336 | newPartInt = newPart.toInt(); | ||
1337 | //convert to int, if it contains chars, put into seperated variable | ||
1338 | if(oldPart.contains(chars)) | ||
1339 | { | ||
1340 | oldPartChar = chars.cap(1); | ||
1341 | oldPart = oldPart.remove(oldPartChar); | ||
1342 | } | ||
1343 | oldPartInt = oldPart.toInt(); | ||
1344 | |||
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 | ||
1354 | } | ||
1355 | // all the same -> false | ||
1356 | return false; | ||
1357 | } | ||
diff --git a/rbutil/rbutilqt/rbutilqt.h b/rbutil/rbutilqt/rbutilqt.h index b5368c9ae3..31bae73630 100644 --- a/rbutil/rbutilqt/rbutilqt.h +++ b/rbutil/rbutilqt/rbutilqt.h | |||
@@ -47,6 +47,7 @@ class RbUtilQt : public QMainWindow | |||
47 | QString platform; | 47 | QString platform; |
48 | HttpGet *daily; | 48 | HttpGet *daily; |
49 | HttpGet *bleeding; | 49 | HttpGet *bleeding; |
50 | HttpGet *update; | ||
50 | QString absolutePath; | 51 | QString absolutePath; |
51 | QTemporaryFile buildInfo; | 52 | QTemporaryFile buildInfo; |
52 | QTemporaryFile bleedingInfo; | 53 | QTemporaryFile bleedingInfo; |
@@ -110,6 +111,10 @@ class RbUtilQt : public QMainWindow | |||
110 | void installPortable(void); | 111 | void installPortable(void); |
111 | void updateInfo(void); | 112 | void updateInfo(void); |
112 | void updateTabs(int); | 113 | void updateTabs(int); |
114 | |||
115 | void checkUpdate(void); | ||
116 | void downloadUpdateDone(bool errror); | ||
117 | bool newerVersion(QString versionOld,QString versionNew); | ||
113 | }; | 118 | }; |
114 | 119 | ||
115 | #endif | 120 | #endif |