summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDominik Riebeling <Dominik.Riebeling@gmail.com>2007-08-09 16:06:27 +0000
committerDominik Riebeling <Dominik.Riebeling@gmail.com>2007-08-09 16:06:27 +0000
commit8dbc7e350b9ec9a5461eefe0437d5d484b8bd534 (patch)
treea940107410715a35dc4bcafb9bb9f012ccde42b6
parent965881fd8559101d6782ebf37a03687ef98b0558 (diff)
downloadrockbox-8dbc7e350b9ec9a5461eefe0437d5d484b8bd534.zip
rockbox-8dbc7e350b9ec9a5461eefe0437d5d484b8bd534.tar.gz
rockbox-8dbc7e350b9ec9a5461eefe0437d5d484b8bd534.tar.bz2
rockbox-8dbc7e350b9ec9a5461eefe0437d5d484b8bd534.tar.xz
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
-rw-r--r--rbutil/rbutilqt/installzip.cpp88
-rw-r--r--rbutil/rbutilqt/installzip.h6
-rw-r--r--rbutil/rbutilqt/rbutilqt.cpp39
-rw-r--r--rbutil/rbutilqt/rbutilqt.h1
4 files changed, 102 insertions, 32 deletions
diff --git a/rbutil/rbutilqt/installzip.cpp b/rbutil/rbutilqt/installzip.cpp
index 4f99d7b..4e2ab51 100644
--- a/rbutil/rbutilqt/installzip.cpp
+++ b/rbutil/rbutilqt/installzip.cpp
@@ -24,7 +24,7 @@
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)
{
qDebug() << "Install::downloadDone, error:" << error;
-
+ QStringList zipContents; // needed later
// update progress bar
int max = m_dp->getProgressMax();
@@ -85,37 +85,63 @@ void ZipInstaller::downloadDone(bool error)
}
else m_dp->addItem(tr("Download finished."),LOGOK);
- // unzip downloaded file
- qDebug() << "about to unzip the downloaded file" << m_file << "to" << m_mountpoint;
-
- m_dp->addItem(tr("Extracting file."),LOGINFO);
-
- qDebug() << "file to unzip: " << m_file;
- UnZip::ErrorCode ec;
- UnZip uz;
- ec = uz.openArchive(m_file);
- if(ec != UnZip::Ok) {
- m_dp->addItem(tr("Opening archive failed: %1.")
- .arg(uz.formatError(ec)),LOGERROR);
- m_dp->abort();
- emit done(false);
- return;
+ if(m_unzip) {
+ // unzip downloaded file
+ qDebug() << "about to unzip the downloaded file" << m_file << "to" << m_mountpoint;
+
+ m_dp->addItem(tr("Extracting file."),LOGINFO);
+
+ qDebug() << "file to unzip: " << m_file;
+ UnZip::ErrorCode ec;
+ UnZip uz;
+ ec = uz.openArchive(m_file);
+ if(ec != UnZip::Ok) {
+ m_dp->addItem(tr("Opening archive failed: %1.")
+ .arg(uz.formatError(ec)),LOGERROR);
+ m_dp->abort();
+ downloadFile.remove();
+ 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();
}
-
- ec = uz.extractAll(m_mountpoint);
- if(ec != UnZip::Ok) {
- m_dp->addItem(tr("Extracting failed: %1.")
- .arg(uz.formatError(ec)),LOGERROR);
- m_dp->abort();
- emit done(false);
- return;
+ else {
+ // only copy the downloaded file to the output location / name
+ m_dp->addItem(tr("Installing file."), LOGINFO);
+ qDebug() << "saving downloaded file (no extraction)";
+
+ downloadFile.open(); // copy fails if file is not opened (filename issue?)
+ // make sure the required path is existing
+ 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);
-
- QStringList zipContents = uz.fileList();
-
- QSettings installlog(m_mountpoint + "/.rockbox/rbutil.log", QSettings::IniFormat, 0);
+ m_dp->addItem(tr("Creating installation log"),LOGINFO);
+ QSettings installlog(m_mountpoint + "/.rockbox/rbutil.log", QSettings::IniFormat, 0);
installlog.beginGroup(m_logsection);
for(int i = 0; i < zipContents.size(); i++)
@@ -127,7 +153,7 @@ void ZipInstaller::downloadDone(bool error)
// remove temporary file
downloadFile.remove();
- m_dp->addItem(tr("Extraction finished successfully."),LOGOK);
+ m_dp->addItem(tr("Installation finished successfully."),LOGOK);
m_dp->abort();
emit done(false);
}
diff --git a/rbutil/rbutilqt/installzip.h b/rbutil/rbutilqt/installzip.h
index f70ec70..a3d14d9 100644
--- a/rbutil/rbutilqt/installzip.h
+++ b/rbutil/rbutilqt/installzip.h
@@ -41,6 +41,8 @@ public:
void setUrl(QString url){m_url = url;}
void setProxy(QUrl proxy) {m_proxy= proxy;}
void setLogSection(QString name) {m_logsection = name;}
+ void setUnzip(bool i) { m_unzip = i; }
+ void setTarget(QString t) { m_target = t; }
signals:
void done(bool error);
@@ -50,9 +52,11 @@ private slots:
void downloadDone(bool);
void downloadRequestFinished(int, bool);
-private:
+private:
QString m_url,m_file,m_mountpoint,m_logsection;
QUrl m_proxy;
+ bool m_unzip;
+ QString m_target;
HttpGet *getter;
QTemporaryFile downloadFile;
diff --git a/rbutil/rbutilqt/rbutilqt.cpp b/rbutil/rbutilqt/rbutilqt.cpp
index bda2958..281fee7 100644
--- a/rbutil/rbutilqt/rbutilqt.cpp
+++ b/rbutil/rbutilqt/rbutilqt.cpp
@@ -80,6 +80,7 @@ RbUtilQt::RbUtilQt(QWidget *parent) : QMainWindow(parent)
connect(ui.buttonFonts, SIGNAL(clicked()), this, SLOT(installFonts()));
connect(ui.buttonGames, SIGNAL(clicked()), this, SLOT(installDoom()));
connect(ui.buttonTalk, SIGNAL(clicked()), this, SLOT(createTalkFiles()));
+ connect(ui.buttonVoice, SIGNAL(clicked()), this, SLOT(installVoice()));
// 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()
{
if(QMessageBox::question(this, tr("Confirm Installation"),
diff --git a/rbutil/rbutilqt/rbutilqt.h b/rbutil/rbutilqt/rbutilqt.h
index e23188a..7451235 100644
--- a/rbutil/rbutilqt/rbutilqt.h
+++ b/rbutil/rbutilqt/rbutilqt.h
@@ -63,6 +63,7 @@ class RbUtilQt : public QMainWindow
void downloadDone(bool);
void downloadDone(int, bool);
void downloadInfo(void);
+ void installVoice(void);
};
#endif