mirror of
https://github.com/Rockbox/rockbox.git
synced 2025-12-08 20:55:17 -05:00
add voice file installation. This also extends the ZipInstaller class a bit to handle copying the downloaded file instead of unzipping.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@14256 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
965881fd85
commit
8dbc7e350b
4 changed files with 101 additions and 31 deletions
|
|
@ -24,7 +24,7 @@
|
||||||
|
|
||||||
ZipInstaller::ZipInstaller(QObject* parent): QObject(parent)
|
ZipInstaller::ZipInstaller(QObject* parent): QObject(parent)
|
||||||
{
|
{
|
||||||
|
m_unzip = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -62,7 +62,7 @@ void ZipInstaller::downloadRequestFinished(int id, bool error)
|
||||||
void ZipInstaller::downloadDone(bool error)
|
void ZipInstaller::downloadDone(bool error)
|
||||||
{
|
{
|
||||||
qDebug() << "Install::downloadDone, error:" << error;
|
qDebug() << "Install::downloadDone, error:" << error;
|
||||||
|
QStringList zipContents; // needed later
|
||||||
// update progress bar
|
// update progress bar
|
||||||
|
|
||||||
int max = m_dp->getProgressMax();
|
int max = m_dp->getProgressMax();
|
||||||
|
|
@ -85,37 +85,63 @@ void ZipInstaller::downloadDone(bool error)
|
||||||
}
|
}
|
||||||
else m_dp->addItem(tr("Download finished."),LOGOK);
|
else m_dp->addItem(tr("Download finished."),LOGOK);
|
||||||
|
|
||||||
// unzip downloaded file
|
if(m_unzip) {
|
||||||
qDebug() << "about to unzip the downloaded file" << m_file << "to" << m_mountpoint;
|
// unzip downloaded file
|
||||||
|
qDebug() << "about to unzip the downloaded file" << m_file << "to" << m_mountpoint;
|
||||||
|
|
||||||
m_dp->addItem(tr("Extracting file."),LOGINFO);
|
m_dp->addItem(tr("Extracting file."),LOGINFO);
|
||||||
|
|
||||||
qDebug() << "file to unzip: " << m_file;
|
qDebug() << "file to unzip: " << m_file;
|
||||||
UnZip::ErrorCode ec;
|
UnZip::ErrorCode ec;
|
||||||
UnZip uz;
|
UnZip uz;
|
||||||
ec = uz.openArchive(m_file);
|
ec = uz.openArchive(m_file);
|
||||||
if(ec != UnZip::Ok) {
|
if(ec != UnZip::Ok) {
|
||||||
m_dp->addItem(tr("Opening archive failed: %1.")
|
m_dp->addItem(tr("Opening archive failed: %1.")
|
||||||
.arg(uz.formatError(ec)),LOGERROR);
|
.arg(uz.formatError(ec)),LOGERROR);
|
||||||
m_dp->abort();
|
m_dp->abort();
|
||||||
emit done(false);
|
downloadFile.remove();
|
||||||
return;
|
emit done(false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
ec = uz.extractAll(m_mountpoint);
|
||||||
|
if(ec != UnZip::Ok) {
|
||||||
|
m_dp->addItem(tr("Extracting failed: %1.")
|
||||||
|
.arg(uz.formatError(ec)),LOGERROR);
|
||||||
|
m_dp->abort();
|
||||||
|
downloadFile.remove();
|
||||||
|
emit done(false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// prepare file list for log
|
||||||
|
zipContents = uz.fileList();
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
ec = uz.extractAll(m_mountpoint);
|
// only copy the downloaded file to the output location / name
|
||||||
if(ec != UnZip::Ok) {
|
m_dp->addItem(tr("Installing file."), LOGINFO);
|
||||||
m_dp->addItem(tr("Extracting failed: %1.")
|
qDebug() << "saving downloaded file (no extraction)";
|
||||||
.arg(uz.formatError(ec)),LOGERROR);
|
|
||||||
m_dp->abort();
|
downloadFile.open(); // copy fails if file is not opened (filename issue?)
|
||||||
emit done(false);
|
// make sure the required path is existing
|
||||||
return;
|
QString path = QFileInfo(m_mountpoint + m_target).absolutePath();
|
||||||
|
QDir p;
|
||||||
|
p.mkpath(path);
|
||||||
|
// QFile::copy() doesn't overwrite files, so remove old one first
|
||||||
|
QFile(m_mountpoint + m_target).remove();
|
||||||
|
if(!downloadFile.copy(m_mountpoint + m_target)) {
|
||||||
|
m_dp->addItem(tr("Installing file failed."), LOGERROR);
|
||||||
|
m_dp->abort();
|
||||||
|
downloadFile.remove();
|
||||||
|
emit done(false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// add file to log
|
||||||
|
zipContents.append(m_mountpoint + m_target);
|
||||||
}
|
}
|
||||||
|
|
||||||
m_dp->addItem(tr("creating installation log"),LOGINFO);
|
m_dp->addItem(tr("Creating installation log"),LOGINFO);
|
||||||
|
QSettings installlog(m_mountpoint + "/.rockbox/rbutil.log", QSettings::IniFormat, 0);
|
||||||
QStringList zipContents = uz.fileList();
|
|
||||||
|
|
||||||
QSettings installlog(m_mountpoint + "/.rockbox/rbutil.log", QSettings::IniFormat, 0);
|
|
||||||
|
|
||||||
installlog.beginGroup(m_logsection);
|
installlog.beginGroup(m_logsection);
|
||||||
for(int i = 0; i < zipContents.size(); i++)
|
for(int i = 0; i < zipContents.size(); i++)
|
||||||
|
|
@ -127,7 +153,7 @@ void ZipInstaller::downloadDone(bool error)
|
||||||
// remove temporary file
|
// remove temporary file
|
||||||
downloadFile.remove();
|
downloadFile.remove();
|
||||||
|
|
||||||
m_dp->addItem(tr("Extraction finished successfully."),LOGOK);
|
m_dp->addItem(tr("Installation finished successfully."),LOGOK);
|
||||||
m_dp->abort();
|
m_dp->abort();
|
||||||
emit done(false);
|
emit done(false);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -41,6 +41,8 @@ public:
|
||||||
void setUrl(QString url){m_url = url;}
|
void setUrl(QString url){m_url = url;}
|
||||||
void setProxy(QUrl proxy) {m_proxy= proxy;}
|
void setProxy(QUrl proxy) {m_proxy= proxy;}
|
||||||
void setLogSection(QString name) {m_logsection = name;}
|
void setLogSection(QString name) {m_logsection = name;}
|
||||||
|
void setUnzip(bool i) { m_unzip = i; }
|
||||||
|
void setTarget(QString t) { m_target = t; }
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void done(bool error);
|
void done(bool error);
|
||||||
|
|
@ -50,9 +52,11 @@ private slots:
|
||||||
void downloadDone(bool);
|
void downloadDone(bool);
|
||||||
void downloadRequestFinished(int, bool);
|
void downloadRequestFinished(int, bool);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QString m_url,m_file,m_mountpoint,m_logsection;
|
QString m_url,m_file,m_mountpoint,m_logsection;
|
||||||
QUrl m_proxy;
|
QUrl m_proxy;
|
||||||
|
bool m_unzip;
|
||||||
|
QString m_target;
|
||||||
|
|
||||||
HttpGet *getter;
|
HttpGet *getter;
|
||||||
QTemporaryFile downloadFile;
|
QTemporaryFile downloadFile;
|
||||||
|
|
|
||||||
|
|
@ -80,6 +80,7 @@ RbUtilQt::RbUtilQt(QWidget *parent) : QMainWindow(parent)
|
||||||
connect(ui.buttonFonts, SIGNAL(clicked()), this, SLOT(installFonts()));
|
connect(ui.buttonFonts, SIGNAL(clicked()), this, SLOT(installFonts()));
|
||||||
connect(ui.buttonGames, SIGNAL(clicked()), this, SLOT(installDoom()));
|
connect(ui.buttonGames, SIGNAL(clicked()), this, SLOT(installDoom()));
|
||||||
connect(ui.buttonTalk, SIGNAL(clicked()), this, SLOT(createTalkFiles()));
|
connect(ui.buttonTalk, SIGNAL(clicked()), this, SLOT(createTalkFiles()));
|
||||||
|
connect(ui.buttonVoice, SIGNAL(clicked()), this, SLOT(installVoice()));
|
||||||
|
|
||||||
|
|
||||||
// disable unimplemented stuff
|
// disable unimplemented stuff
|
||||||
|
|
@ -321,6 +322,44 @@ void RbUtilQt::installFonts()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void RbUtilQt::installVoice()
|
||||||
|
{
|
||||||
|
if(QMessageBox::question(this, tr("Confirm Installation"),
|
||||||
|
tr("Do you really want to install the voice file?"),
|
||||||
|
QMessageBox::Yes | QMessageBox::No) != QMessageBox::Yes) return;
|
||||||
|
// create logger
|
||||||
|
logger = new ProgressLoggerGui(this);
|
||||||
|
logger->show();
|
||||||
|
|
||||||
|
// create zip installer
|
||||||
|
installer = new ZipInstaller(this);
|
||||||
|
installer->setUnzip(false);
|
||||||
|
buildInfo.open();
|
||||||
|
QSettings info(buildInfo.fileName(), QSettings::IniFormat, this);
|
||||||
|
buildInfo.close();
|
||||||
|
QString datestring = info.value("dailies/date").toString();
|
||||||
|
|
||||||
|
QString voiceurl = devices->value("voice_url").toString() + "/" +
|
||||||
|
userSettings->value("defaults/platform").toString() + "-" +
|
||||||
|
datestring + "-english.voice";
|
||||||
|
qDebug() << voiceurl;
|
||||||
|
if(userSettings->value("defaults/proxytype") == "manual")
|
||||||
|
installer->setProxy(QUrl(userSettings->value("defaults/proxy").toString()));
|
||||||
|
#ifdef __linux
|
||||||
|
else if(userSettings->value("defaults/proxytype") == "system")
|
||||||
|
installer->setProxy(QUrl(getenv("http_proxy")));
|
||||||
|
#endif
|
||||||
|
|
||||||
|
installer->setUrl(voiceurl);
|
||||||
|
installer->setLogSection("Voice");
|
||||||
|
installer->setMountPoint(userSettings->value("defaults/mountpoint").toString());
|
||||||
|
installer->setTarget("/.rockbox/langs/english.lang");
|
||||||
|
installer->install(logger);
|
||||||
|
|
||||||
|
connect(installer, SIGNAL(done(bool)), this, SLOT(done(bool)));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void RbUtilQt::installDoom()
|
void RbUtilQt::installDoom()
|
||||||
{
|
{
|
||||||
if(QMessageBox::question(this, tr("Confirm Installation"),
|
if(QMessageBox::question(this, tr("Confirm Installation"),
|
||||||
|
|
|
||||||
|
|
@ -63,6 +63,7 @@ class RbUtilQt : public QMainWindow
|
||||||
void downloadDone(bool);
|
void downloadDone(bool);
|
||||||
void downloadDone(int, bool);
|
void downloadDone(int, bool);
|
||||||
void downloadInfo(void);
|
void downloadInfo(void);
|
||||||
|
void installVoice(void);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue