summaryrefslogtreecommitdiff
path: root/rbutil
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 /rbutil
parent965881fd8559101d6782ebf37a03687ef98b0558 (diff)
downloadrockbox-8dbc7e350b9ec9a5461eefe0437d5d484b8bd534.tar.gz
rockbox-8dbc7e350b9ec9a5461eefe0437d5d484b8bd534.zip
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
Diffstat (limited to 'rbutil')
-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 4f99d7bc31..4e2ab518ba 100644
--- a/rbutil/rbutilqt/installzip.cpp
+++ b/rbutil/rbutilqt/installzip.cpp
@@ -24,7 +24,7 @@
24 24
25ZipInstaller::ZipInstaller(QObject* parent): QObject(parent) 25ZipInstaller::ZipInstaller(QObject* parent): QObject(parent)
26{ 26{
27 27 m_unzip = true;
28} 28}
29 29
30 30
@@ -62,7 +62,7 @@ void ZipInstaller::downloadRequestFinished(int id, bool error)
62void ZipInstaller::downloadDone(bool error) 62void ZipInstaller::downloadDone(bool error)
63{ 63{
64 qDebug() << "Install::downloadDone, error:" << error; 64 qDebug() << "Install::downloadDone, error:" << error;
65 65 QStringList zipContents; // needed later
66 // update progress bar 66 // update progress bar
67 67
68 int max = m_dp->getProgressMax(); 68 int max = m_dp->getProgressMax();
@@ -85,37 +85,63 @@ void ZipInstaller::downloadDone(bool error)
85 } 85 }
86 else m_dp->addItem(tr("Download finished."),LOGOK); 86 else m_dp->addItem(tr("Download finished."),LOGOK);
87 87
88 // unzip downloaded file 88 if(m_unzip) {
89 qDebug() << "about to unzip the downloaded file" << m_file << "to" << m_mountpoint; 89 // unzip downloaded file
90 90 qDebug() << "about to unzip the downloaded file" << m_file << "to" << m_mountpoint;
91 m_dp->addItem(tr("Extracting file."),LOGINFO); 91
92 92 m_dp->addItem(tr("Extracting file."),LOGINFO);
93 qDebug() << "file to unzip: " << m_file; 93
94 UnZip::ErrorCode ec; 94 qDebug() << "file to unzip: " << m_file;
95 UnZip uz; 95 UnZip::ErrorCode ec;
96 ec = uz.openArchive(m_file); 96 UnZip uz;
97 if(ec != UnZip::Ok) { 97 ec = uz.openArchive(m_file);
98 m_dp->addItem(tr("Opening archive failed: %1.") 98 if(ec != UnZip::Ok) {
99 .arg(uz.formatError(ec)),LOGERROR); 99 m_dp->addItem(tr("Opening archive failed: %1.")
100 m_dp->abort(); 100 .arg(uz.formatError(ec)),LOGERROR);
101 emit done(false); 101 m_dp->abort();
102 return; 102 downloadFile.remove();
103 emit done(false);
104 return;
105 }
106
107 ec = uz.extractAll(m_mountpoint);
108 if(ec != UnZip::Ok) {
109 m_dp->addItem(tr("Extracting failed: %1.")
110 .arg(uz.formatError(ec)),LOGERROR);
111 m_dp->abort();
112 downloadFile.remove();
113 emit done(false);
114 return;
115 }
116 // prepare file list for log
117 zipContents = uz.fileList();
103 } 118 }
104 119 else {
105 ec = uz.extractAll(m_mountpoint); 120 // only copy the downloaded file to the output location / name
106 if(ec != UnZip::Ok) { 121 m_dp->addItem(tr("Installing file."), LOGINFO);
107 m_dp->addItem(tr("Extracting failed: %1.") 122 qDebug() << "saving downloaded file (no extraction)";
108 .arg(uz.formatError(ec)),LOGERROR); 123
109 m_dp->abort(); 124 downloadFile.open(); // copy fails if file is not opened (filename issue?)
110 emit done(false); 125 // make sure the required path is existing
111 return; 126 QString path = QFileInfo(m_mountpoint + m_target).absolutePath();
127 QDir p;
128 p.mkpath(path);
129 // QFile::copy() doesn't overwrite files, so remove old one first
130 QFile(m_mountpoint + m_target).remove();
131 if(!downloadFile.copy(m_mountpoint + m_target)) {
132 m_dp->addItem(tr("Installing file failed."), LOGERROR);
133 m_dp->abort();
134 downloadFile.remove();
135 emit done(false);
136 return;
137 }
138
139 // add file to log
140 zipContents.append(m_mountpoint + m_target);
112 } 141 }
113 142
114 m_dp->addItem(tr("creating installation log"),LOGINFO); 143 m_dp->addItem(tr("Creating installation log"),LOGINFO);
115 144 QSettings installlog(m_mountpoint + "/.rockbox/rbutil.log", QSettings::IniFormat, 0);
116 QStringList zipContents = uz.fileList();
117
118 QSettings installlog(m_mountpoint + "/.rockbox/rbutil.log", QSettings::IniFormat, 0);
119 145
120 installlog.beginGroup(m_logsection); 146 installlog.beginGroup(m_logsection);
121 for(int i = 0; i < zipContents.size(); i++) 147 for(int i = 0; i < zipContents.size(); i++)
@@ -127,7 +153,7 @@ void ZipInstaller::downloadDone(bool error)
127 // remove temporary file 153 // remove temporary file
128 downloadFile.remove(); 154 downloadFile.remove();
129 155
130 m_dp->addItem(tr("Extraction finished successfully."),LOGOK); 156 m_dp->addItem(tr("Installation finished successfully."),LOGOK);
131 m_dp->abort(); 157 m_dp->abort();
132 emit done(false); 158 emit done(false);
133} 159}
diff --git a/rbutil/rbutilqt/installzip.h b/rbutil/rbutilqt/installzip.h
index f70ec70ccf..a3d14d9222 100644
--- a/rbutil/rbutilqt/installzip.h
+++ b/rbutil/rbutilqt/installzip.h
@@ -41,6 +41,8 @@ public:
41 void setUrl(QString url){m_url = url;} 41 void setUrl(QString url){m_url = url;}
42 void setProxy(QUrl proxy) {m_proxy= proxy;} 42 void setProxy(QUrl proxy) {m_proxy= proxy;}
43 void setLogSection(QString name) {m_logsection = name;} 43 void setLogSection(QString name) {m_logsection = name;}
44 void setUnzip(bool i) { m_unzip = i; }
45 void setTarget(QString t) { m_target = t; }
44 46
45signals: 47signals:
46 void done(bool error); 48 void done(bool error);
@@ -50,9 +52,11 @@ private slots:
50 void downloadDone(bool); 52 void downloadDone(bool);
51 void downloadRequestFinished(int, bool); 53 void downloadRequestFinished(int, bool);
52 54
53private: 55private:
54 QString m_url,m_file,m_mountpoint,m_logsection; 56 QString m_url,m_file,m_mountpoint,m_logsection;
55 QUrl m_proxy; 57 QUrl m_proxy;
58 bool m_unzip;
59 QString m_target;
56 60
57 HttpGet *getter; 61 HttpGet *getter;
58 QTemporaryFile downloadFile; 62 QTemporaryFile downloadFile;
diff --git a/rbutil/rbutilqt/rbutilqt.cpp b/rbutil/rbutilqt/rbutilqt.cpp
index bda2958c8b..281fee70ed 100644
--- a/rbutil/rbutilqt/rbutilqt.cpp
+++ b/rbutil/rbutilqt/rbutilqt.cpp
@@ -80,6 +80,7 @@ RbUtilQt::RbUtilQt(QWidget *parent) : QMainWindow(parent)
80 connect(ui.buttonFonts, SIGNAL(clicked()), this, SLOT(installFonts())); 80 connect(ui.buttonFonts, SIGNAL(clicked()), this, SLOT(installFonts()));
81 connect(ui.buttonGames, SIGNAL(clicked()), this, SLOT(installDoom())); 81 connect(ui.buttonGames, SIGNAL(clicked()), this, SLOT(installDoom()));
82 connect(ui.buttonTalk, SIGNAL(clicked()), this, SLOT(createTalkFiles())); 82 connect(ui.buttonTalk, SIGNAL(clicked()), this, SLOT(createTalkFiles()));
83 connect(ui.buttonVoice, SIGNAL(clicked()), this, SLOT(installVoice()));
83 84
84 85
85 // disable unimplemented stuff 86 // disable unimplemented stuff
@@ -321,6 +322,44 @@ void RbUtilQt::installFonts()
321} 322}
322 323
323 324
325void RbUtilQt::installVoice()
326{
327 if(QMessageBox::question(this, tr("Confirm Installation"),
328 tr("Do you really want to install the voice file?"),
329 QMessageBox::Yes | QMessageBox::No) != QMessageBox::Yes) return;
330 // create logger
331 logger = new ProgressLoggerGui(this);
332 logger->show();
333
334 // create zip installer
335 installer = new ZipInstaller(this);
336 installer->setUnzip(false);
337 buildInfo.open();
338 QSettings info(buildInfo.fileName(), QSettings::IniFormat, this);
339 buildInfo.close();
340 QString datestring = info.value("dailies/date").toString();
341
342 QString voiceurl = devices->value("voice_url").toString() + "/" +
343 userSettings->value("defaults/platform").toString() + "-" +
344 datestring + "-english.voice";
345 qDebug() << voiceurl;
346 if(userSettings->value("defaults/proxytype") == "manual")
347 installer->setProxy(QUrl(userSettings->value("defaults/proxy").toString()));
348 #ifdef __linux
349 else if(userSettings->value("defaults/proxytype") == "system")
350 installer->setProxy(QUrl(getenv("http_proxy")));
351 #endif
352
353 installer->setUrl(voiceurl);
354 installer->setLogSection("Voice");
355 installer->setMountPoint(userSettings->value("defaults/mountpoint").toString());
356 installer->setTarget("/.rockbox/langs/english.lang");
357 installer->install(logger);
358
359 connect(installer, SIGNAL(done(bool)), this, SLOT(done(bool)));
360}
361
362
324void RbUtilQt::installDoom() 363void RbUtilQt::installDoom()
325{ 364{
326 if(QMessageBox::question(this, tr("Confirm Installation"), 365 if(QMessageBox::question(this, tr("Confirm Installation"),
diff --git a/rbutil/rbutilqt/rbutilqt.h b/rbutil/rbutilqt/rbutilqt.h
index e23188a136..745123597e 100644
--- a/rbutil/rbutilqt/rbutilqt.h
+++ b/rbutil/rbutilqt/rbutilqt.h
@@ -63,6 +63,7 @@ class RbUtilQt : public QMainWindow
63 void downloadDone(bool); 63 void downloadDone(bool);
64 void downloadDone(int, bool); 64 void downloadDone(int, bool);
65 void downloadInfo(void); 65 void downloadInfo(void);
66 void installVoice(void);
66}; 67};
67 68
68#endif 69#endif