mirror of
https://github.com/Rockbox/rockbox.git
synced 2025-11-14 15:42:28 -05:00
rbutil: create a RockboxInfo class so all rockbox-info.txt handling is in one place.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@20429 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
7aaffa51d6
commit
6c73482d00
5 changed files with 83 additions and 62 deletions
|
|
@ -90,21 +90,18 @@ bool Autodetection::detect()
|
||||||
}
|
}
|
||||||
|
|
||||||
// check rockbox-info.txt afterwards.
|
// check rockbox-info.txt afterwards.
|
||||||
QFile file(mounts.at(i) + "/.rockbox/rockbox-info.txt");
|
RockboxInfo info(mounts.at(i));
|
||||||
if(file.exists())
|
if(info.open())
|
||||||
{
|
{
|
||||||
file.open(QIODevice::ReadOnly | QIODevice::Text);
|
|
||||||
QString line = file.readLine();
|
|
||||||
if(line.startsWith("Target: "))
|
|
||||||
{
|
|
||||||
line.remove("Target: ");
|
|
||||||
if(m_device.isEmpty())
|
if(m_device.isEmpty())
|
||||||
m_device = line.trimmed(); // trim whitespaces
|
{
|
||||||
|
m_device = info.target();
|
||||||
|
}
|
||||||
m_mountpoint = mounts.at(i);
|
m_mountpoint = mounts.at(i);
|
||||||
qDebug() << "rockbox-info.txt detected:" << m_device << m_mountpoint;
|
qDebug() << "rockbox-info.txt detected:" << m_device << m_mountpoint;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
// check for some specific files in root folder
|
// check for some specific files in root folder
|
||||||
QDir root(mounts.at(i));
|
QDir root(mounts.at(i));
|
||||||
QStringList rootentries = root.entryList(QDir::Files);
|
QStringList rootentries = root.entryList(QDir::Files);
|
||||||
|
|
|
||||||
|
|
@ -58,6 +58,7 @@
|
||||||
#include <sys/mount.h>
|
#include <sys/mount.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include "utils.h"
|
||||||
|
|
||||||
/** @brief detect permission of user (only Windows at moment).
|
/** @brief detect permission of user (only Windows at moment).
|
||||||
* @return enum userlevel.
|
* @return enum userlevel.
|
||||||
|
|
@ -352,23 +353,13 @@ QUrl Detect::systemProxy(void)
|
||||||
*/
|
*/
|
||||||
QString Detect::installedVersion(QString mountpoint)
|
QString Detect::installedVersion(QString mountpoint)
|
||||||
{
|
{
|
||||||
// read rockbox-info.txt
|
RockboxInfo info(mountpoint);
|
||||||
QFile info(mountpoint +"/.rockbox/rockbox-info.txt");
|
if(!info.open())
|
||||||
if(!info.open(QIODevice::ReadOnly))
|
|
||||||
{
|
{
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
while (!info.atEnd()) {
|
return info.version();
|
||||||
QString line = info.readLine();
|
|
||||||
|
|
||||||
if(line.contains("Version:"))
|
|
||||||
{
|
|
||||||
return line.remove("Version:").trimmed();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
info.close();
|
|
||||||
return "";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -377,24 +368,13 @@ QString Detect::installedVersion(QString mountpoint)
|
||||||
*/
|
*/
|
||||||
QString Detect::installedTarget(QString mountpoint)
|
QString Detect::installedTarget(QString mountpoint)
|
||||||
{
|
{
|
||||||
// read rockbox-info.txt
|
RockboxInfo info(mountpoint);
|
||||||
QFile info(mountpoint +"/.rockbox/rockbox-info.txt");
|
if(!info.open())
|
||||||
if(!info.open(QIODevice::ReadOnly))
|
|
||||||
{
|
{
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
while (!info.atEnd())
|
return info.target();
|
||||||
{
|
|
||||||
QString line = info.readLine();
|
|
||||||
if(line.contains("Target:"))
|
|
||||||
{
|
|
||||||
qDebug() << line;
|
|
||||||
return line.remove("Target:").trimmed();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
info.close();
|
|
||||||
return "";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -130,3 +130,43 @@ qulonglong filesystemFree(QString path)
|
||||||
return size;
|
return size;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
RockboxInfo::RockboxInfo(QString mountpoint)
|
||||||
|
{
|
||||||
|
m_path = mountpoint +"/.rockbox/rockbox-info.txt";
|
||||||
|
}
|
||||||
|
|
||||||
|
bool RockboxInfo::open()
|
||||||
|
{
|
||||||
|
QFile file(m_path);
|
||||||
|
if(!file.exists())
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if(!file.open(QIODevice::ReadOnly | QIODevice::Text))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
// read file contents
|
||||||
|
while (!file.atEnd())
|
||||||
|
{
|
||||||
|
QString line = file.readLine();
|
||||||
|
|
||||||
|
if(line.contains("Version:"))
|
||||||
|
{
|
||||||
|
m_version = line.remove("Version:").trimmed();
|
||||||
|
}
|
||||||
|
else if(line.contains("Target: "))
|
||||||
|
{
|
||||||
|
m_target = line.remove("Target: ").trimmed();
|
||||||
|
}
|
||||||
|
else if(line.contains("Features:"))
|
||||||
|
{
|
||||||
|
m_features = line.remove("Features:").trimmed();
|
||||||
|
}
|
||||||
|
else if(line.contains("Target id:"))
|
||||||
|
{
|
||||||
|
m_targetid = line.remove("Target id:").trimmed();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
file.close();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -30,5 +30,23 @@ bool recRmdir( const QString &dirName );
|
||||||
QString resolvePathCase(QString path);
|
QString resolvePathCase(QString path);
|
||||||
qulonglong filesystemFree(QString path);
|
qulonglong filesystemFree(QString path);
|
||||||
|
|
||||||
|
class RockboxInfo
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
RockboxInfo(QString mountpoint);
|
||||||
|
bool open();
|
||||||
|
|
||||||
|
QString version() {return m_version;}
|
||||||
|
QString features(){return m_features;}
|
||||||
|
QString targetID() {return m_targetid;}
|
||||||
|
QString target() {return m_target;}
|
||||||
|
private:
|
||||||
|
QString m_path;
|
||||||
|
QString m_version;
|
||||||
|
QString m_features;
|
||||||
|
QString m_targetid;
|
||||||
|
QString m_target;
|
||||||
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,7 @@
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#include "voicefile.h"
|
#include "voicefile.h"
|
||||||
|
#include "utils.h"
|
||||||
|
|
||||||
#define STATE_INVALID 0
|
#define STATE_INVALID 0
|
||||||
#define STATE_PHRASE 1
|
#define STATE_PHRASE 1
|
||||||
|
|
@ -49,34 +50,19 @@ bool VoiceFileCreator::createVoiceFile(ProgressloggerInterface* logger)
|
||||||
m_path = QDir::tempPath() + "/rbvoice/";
|
m_path = QDir::tempPath() + "/rbvoice/";
|
||||||
|
|
||||||
// read rockbox-info.txt
|
// read rockbox-info.txt
|
||||||
QFile info(m_mountpoint+"/.rockbox/rockbox-info.txt");
|
RockboxInfo info(m_mountpoint);
|
||||||
if(!info.open(QIODevice::ReadOnly))
|
if(!info.open())
|
||||||
{
|
{
|
||||||
m_logger->addItem(tr("failed to open rockbox-info.txt"),LOGERROR);
|
m_logger->addItem(tr("could not find rockbox-info.txt"),LOGERROR);
|
||||||
m_logger->abort();
|
m_logger->abort();
|
||||||
emit done(false);
|
emit done(false);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString target, features,version;
|
QString target = info.target();
|
||||||
while (!info.atEnd()) {
|
QString features = info.features();
|
||||||
QString line = info.readLine();
|
QString version = info.version();
|
||||||
|
|
||||||
if(line.contains("Target:"))
|
|
||||||
{
|
|
||||||
target = line.remove("Target:").trimmed();
|
|
||||||
}
|
|
||||||
else if(line.contains("Features:"))
|
|
||||||
{
|
|
||||||
features = line.remove("Features:").trimmed();
|
|
||||||
}
|
|
||||||
else if(line.contains("Version:"))
|
|
||||||
{
|
|
||||||
version = line.remove("Version:").trimmed();
|
|
||||||
version = version.left(version.indexOf("-")).remove(0,1);
|
version = version.left(version.indexOf("-")).remove(0,1);
|
||||||
}
|
|
||||||
}
|
|
||||||
info.close();
|
|
||||||
|
|
||||||
//prepare download url
|
//prepare download url
|
||||||
QUrl genlangUrl = settings->genlangUrl() +"?lang=" +m_lang+"&t="+target+"&rev="+version+"&f="+features;
|
QUrl genlangUrl = settings->genlangUrl() +"?lang=" +m_lang+"&t="+target+"&rev="+version+"&f="+features;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue