summaryrefslogtreecommitdiff
path: root/rbutil/rbutilqt
diff options
context:
space:
mode:
Diffstat (limited to 'rbutil/rbutilqt')
-rw-r--r--rbutil/rbutilqt/base/rockboxinfo.cpp52
-rwxr-xr-xrbutil/rbutilqt/test/test-rockboxinfobin568151 -> 0 bytes
-rw-r--r--rbutil/rbutilqt/test/test-rockboxinfo.cpp18
3 files changed, 38 insertions, 32 deletions
diff --git a/rbutil/rbutilqt/base/rockboxinfo.cpp b/rbutil/rbutilqt/base/rockboxinfo.cpp
index 2f56a291c5..9d8aba65f9 100644
--- a/rbutil/rbutilqt/base/rockboxinfo.cpp
+++ b/rbutil/rbutilqt/base/rockboxinfo.cpp
@@ -33,38 +33,40 @@ RockboxInfo::RockboxInfo(QString mountpoint, QString fname)
33 return; 33 return;
34 34
35 // read file contents 35 // read file contents
36 QRegExp hash("^Version:\\s+(r?)([0-9a-fM]+)");
37 QRegExp version("^Version:\\s+(\\S.*)");
38 QRegExp release("^Version:\\s+([0-9\\.]+)");
39 QRegExp target("^Target:\\s+(\\S.*)");
40 QRegExp features("^Features:\\s+(\\S.*)");
41 QRegExp targetid("^Target id:\\s+(\\S.*)");
42 QRegExp memory("^Memory:\\s+(\\S.*)");
36 while (!file.atEnd()) 43 while (!file.atEnd())
37 { 44 {
38 QString line = file.readLine(); 45 QString line = file.readLine().trimmed();
39 46
40 if(line.contains("Version:")) 47 if(version.indexIn(line) >= 0) {
41 { 48 m_version = version.cap(1);
42 m_version = line.remove("Version:").trimmed();
43 if(m_version.startsWith("r")) {
44 m_revision = m_version;
45 m_revision.remove("r").replace(QRegExp("-.+$"), "");
46 m_release = "";
47 }
48 else {
49 m_release = m_version;
50 m_revision = "";
51 }
52 } 49 }
53 else if(line.contains("Target: ")) 50 if(release.indexIn(line) >= 0) {
54 { 51 m_release = release.cap(1);
55 m_target = line.remove("Target: ").trimmed();
56 } 52 }
57 else if(line.contains("Features:")) 53 if(hash.indexIn(line) >= 0) {
58 { 54 // git hashes are usually at least 7 characters.
59 m_features = line.remove("Features:").trimmed(); 55 // svn revisions are expected to be at least 4 digits.
56 if(hash.cap(2).size() > 3)
57 m_revision = hash.cap(2);
60 } 58 }
61 else if(line.contains("Target id:")) 59 else if(target.indexIn(line) >= 0) {
62 { 60 m_target = target.cap(1);
63 m_targetid = line.remove("Target id:").trimmed();
64 } 61 }
65 else if(line.contains("Memory:")) 62 else if(features.indexIn(line) >= 0) {
66 { 63 m_features = features.cap(1);
67 m_ram = line.remove("Memory:").trimmed().toInt(); 64 }
65 else if(targetid.indexIn(line) >= 0) {
66 m_targetid = targetid.cap(1);
67 }
68 else if(memory.indexIn(line) >= 0) {
69 m_ram = memory.cap(1).toInt();
68 } 70 }
69 } 71 }
70 72
diff --git a/rbutil/rbutilqt/test/test-rockboxinfo b/rbutil/rbutilqt/test/test-rockboxinfo
deleted file mode 100755
index f881e68015..0000000000
--- a/rbutil/rbutilqt/test/test-rockboxinfo
+++ /dev/null
Binary files differ
diff --git a/rbutil/rbutilqt/test/test-rockboxinfo.cpp b/rbutil/rbutilqt/test/test-rockboxinfo.cpp
index 541d1c18ee..6fb45fd028 100644
--- a/rbutil/rbutilqt/test/test-rockboxinfo.cpp
+++ b/rbutil/rbutilqt/test/test-rockboxinfo.cpp
@@ -45,10 +45,14 @@ void TestRockboxInfo::testVersion()
45 45
46 const struct testvector testdata[] = 46 const struct testvector testdata[] =
47 { 47 {
48 { "Version: r29629-110321", "29629", "r29629-110321", "" }, 48 { "Version: r29629-110321", "29629", "r29629-110321", "" },
49 { "Version: r29629M-110321", "29629M", "r29629M-110321", "" }, 49 { "Version: r29629M-110321", "29629M", "r29629M-110321", "" },
50 { "Version: 3.10", "", "3.10", "3.10" }, 50 { "Version: 3.10", "", "3.10", "3.10" },
51 { "Version:\t3.10", "", "3.10", "3.10" }, 51 { "Version:\t3.10", "", "3.10", "3.10" },
52 { "#Version: r29629-110321", "", "", "" },
53 { "Version: e5b1b0f-120218", "e5b1b0f", "e5b1b0f-120218", "" },
54 { "Version: e5b1b0fM-120218", "e5b1b0fM", "e5b1b0fM-120218", "" },
55 { "#Version: e5b1b0f-120218", "", "", "" },
52 }; 56 };
53 57
54 58
@@ -70,7 +74,7 @@ void TestRockboxInfo::testVersion()
70 74
71void TestRockboxInfo::testTarget() 75void TestRockboxInfo::testTarget()
72{ 76{
73 unsigned int i, j; 77 int i, j;
74 QStringList targets; 78 QStringList targets;
75 targets << "sansae200" << "gigabeats" << "iriverh100" << "unknown"; 79 targets << "sansae200" << "gigabeats" << "iriverh100" << "unknown";
76 QStringList prefix; 80 QStringList prefix;
@@ -94,7 +98,7 @@ void TestRockboxInfo::testTarget()
94 98
95void TestRockboxInfo::testMemory() 99void TestRockboxInfo::testMemory()
96{ 100{
97 unsigned int i, j; 101 int i, j;
98 QStringList memsizes; 102 QStringList memsizes;
99 memsizes << "8" << "16" << "32" << "64"; 103 memsizes << "8" << "16" << "32" << "64";
100 QStringList prefix; 104 QStringList prefix;
@@ -118,7 +122,7 @@ void TestRockboxInfo::testMemory()
118 122
119void TestRockboxInfo::testFeatures() 123void TestRockboxInfo::testFeatures()
120{ 124{
121 unsigned int i, j; 125 int i, j;
122 QStringList features; 126 QStringList features;
123 features << "backlight_brightness:button_light:dircache:flash_storage" 127 features << "backlight_brightness:button_light:dircache:flash_storage"
124 << "pitchscreen:multivolume:multidrive_usb:quickscreen"; 128 << "pitchscreen:multivolume:multidrive_usb:quickscreen";