1 /***************************************************************************
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
9 * Copyright (C) 2010 by Dominik Wenger
12 * All files in this archive are subject to the GNU General Public License.
13 * See the file COPYING in the source tree root for full license agreement.
15 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
16 * KIND, either express or implied.
18 ****************************************************************************/
20 #include "systeminfo.h"
21 #include "rbsettings.h"
25 #if defined(Q_OS_LINUX)
32 SystemInfo::SystemInfos info
;
35 } SystemInfosList
[] = {
36 { SystemInfo::ManualUrl
, "manual_url", "" },
37 { SystemInfo::BleedingUrl
, "bleeding_url", "" },
38 { SystemInfo::BootloaderUrl
, "bootloader_url", "" },
39 { SystemInfo::BootloaderInfoUrl
, "bootloader_info_url", "" },
40 { SystemInfo::FontUrl
, "font_url", "" },
41 { SystemInfo::VoiceUrl
, "voice_url", "" },
42 { SystemInfo::DoomUrl
, "doom_url", "" },
43 { SystemInfo::ReleaseUrl
, "release_url", "" },
44 { SystemInfo::DailyUrl
, "daily_url", "" },
45 { SystemInfo::ServerConfUrl
, "server_conf_url", "" },
46 { SystemInfo::GenlangUrl
, "genlang_url", "" },
47 { SystemInfo::ThemesUrl
, "themes_url", "" },
48 { SystemInfo::RbutilUrl
, "rbutil_url", "" },
49 { SystemInfo::BleedingInfo
, "bleeding_info", "" },
50 { SystemInfo::CurPlatformName
, ":platform:/name", "" },
51 { SystemInfo::CurManual
, ":platform:/manualname","rockbox-:platform:" },
52 { SystemInfo::CurBootloaderMethod
, ":platform:/bootloadermethod", "none" },
53 { SystemInfo::CurBootloaderName
, ":platform:/bootloadername", "" },
54 { SystemInfo::CurBootloaderFile
, ":platform:/bootloaderfile", "" },
55 { SystemInfo::CurEncoder
, ":platform:/encoder", "" },
56 { SystemInfo::CurBrand
, ":platform:/brand", "" },
57 { SystemInfo::CurName
, ":platform:/name", "" },
58 { SystemInfo::CurBuildserverModel
, ":platform:/buildserver_modelname", "" },
59 { SystemInfo::CurConfigureModel
, ":platform:/configure_modelname", "" },
62 //! pointer to setting object to NULL
63 QSettings
* SystemInfo::systemInfos
= NULL
;
65 void SystemInfo::ensureSystemInfoExists()
67 //check and create settings object
68 if(systemInfos
== NULL
)
70 // only use built-in rbutil.ini
71 systemInfos
= new QSettings(":/ini/rbutil.ini", QSettings::IniFormat
, 0);
76 QVariant
SystemInfo::value(enum SystemInfos info
)
78 ensureSystemInfoExists();
80 // locate setting item
82 while(SystemInfosList
[i
].info
!= info
)
84 QString platform
= RbSettings::value(RbSettings::CurrentPlatform
).toString();
85 QString s
= SystemInfosList
[i
].name
;
86 s
.replace(":platform:", platform
);
87 QString d
= SystemInfosList
[i
].def
;
88 d
.replace(":platform:", platform
);
89 qDebug() << "[SystemInfo] GET:" << s
<< systemInfos
->value(s
, d
).toString();
90 return systemInfos
->value(s
, d
);
93 QVariant
SystemInfo::platformValue(QString platform
, enum SystemInfos info
)
95 ensureSystemInfoExists();
97 // locate setting item
99 while(SystemInfosList
[i
].info
!= info
)
102 QString s
= SystemInfosList
[i
].name
;
103 s
.replace(":platform:", platform
);
104 QString d
= SystemInfosList
[i
].def
;
105 d
.replace(":platform:", platform
);
106 qDebug() << "[SystemInfo] GET P:" << s
<< systemInfos
->value(s
, d
).toString();
107 return systemInfos
->value(s
, d
);
110 QStringList
SystemInfo::platforms(enum SystemInfo::PlatformType type
, QString variant
)
112 ensureSystemInfoExists();
115 systemInfos
->beginGroup("platforms");
116 QStringList a
= systemInfos
->childKeys();
117 systemInfos
->endGroup();
118 for(int i
= 0; i
< a
.size(); i
++)
120 QString target
= systemInfos
->value("platforms/"+a
.at(i
), "null").toString();
121 QRegExp
regex("\\..*$");
122 QString targetbase
= target
;
123 targetbase
.remove(regex
);
124 // only add target if its not disabled unless Platform*Disabled requested
125 if(type
!= PlatformAllDisabled
&& type
!= PlatformBaseDisabled
126 && type
!= PlatformVariantDisabled
127 && systemInfos
->value(target
+"/status").toString() == "disabled")
129 // report only matching target if PlatformVariant* is requested
130 if((type
== PlatformVariant
|| type
== PlatformVariantDisabled
)
131 && (targetbase
!= variant
))
133 // report only base targets when PlatformBase* is requested
134 if((type
== PlatformBase
|| type
== PlatformBaseDisabled
))
135 result
.append(targetbase
);
137 result
.append(target
);
139 result
.removeDuplicates();
143 QStringList
SystemInfo::languages()
145 ensureSystemInfoExists();
148 systemInfos
->beginGroup("languages");
149 QStringList a
= systemInfos
->childKeys();
150 for(int i
= 0; i
< a
.size(); i
++)
152 result
.append(systemInfos
->value(a
.at(i
), "null").toString());
154 systemInfos
->endGroup();
159 QMap
<int, QString
> SystemInfo::usbIdMap(enum MapType type
)
161 ensureSystemInfoExists();
163 QMap
<int, QString
> map
;
164 // get a list of ID -> target name
165 QStringList platforms
;
166 systemInfos
->beginGroup("platforms");
167 platforms
= systemInfos
->childKeys();
168 systemInfos
->endGroup();
178 case MapIncompatible
:
183 for(int i
= 0; i
< platforms
.size(); i
++)
185 systemInfos
->beginGroup("platforms");
186 QString target
= systemInfos
->value(platforms
.at(i
)).toString();
187 systemInfos
->endGroup();
188 systemInfos
->beginGroup(target
);
189 QStringList ids
= systemInfos
->value(t
).toStringList();
192 map
.insert(ids
.at(j
).toInt(0, 16), target
);
194 systemInfos
->endGroup();