From 4c5af28b12fe8b5518b3cbca2b4c1e9b60b6b118 Mon Sep 17 00:00:00 2001 From: Domonoky Date: Sat, 9 Feb 2008 18:58:14 +0000 Subject: [PATCH] rbutil: tts and encoders: preparation for cli interface. installers: make sure all installers correctly emit a done signal. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@16255 a1c6a512-1295-4272-9138-f99709370657 --- rbutil/rbutilqt/encoders.cpp | 26 +++++++++++++++++--------- rbutil/rbutilqt/encoders.h | 8 ++++---- rbutil/rbutilqt/installzip.cpp | 18 ++++-------------- rbutil/rbutilqt/installzip.h | 1 - rbutil/rbutilqt/talkfile.cpp | 10 ++++++---- rbutil/rbutilqt/talkfile.h | 2 +- rbutil/rbutilqt/tts.cpp | 8 ++++++++ rbutil/rbutilqt/tts.h | 2 ++ rbutil/rbutilqt/voicefile.cpp | 26 ++++++++++++++------------ rbutil/rbutilqt/voicefile.h | 4 +++- 10 files changed, 59 insertions(+), 46 deletions(-) diff --git a/rbutil/rbutilqt/encoders.cpp b/rbutil/rbutilqt/encoders.cpp index bb5474ce4..47e39e87e 100644 --- a/rbutil/rbutilqt/encoders.cpp +++ b/rbutil/rbutilqt/encoders.cpp @@ -22,6 +22,8 @@ #ifndef CONSOLE #include "encodersgui.h" +#else +#include "encodersguicli.h" #endif static QMap encoderList; @@ -53,20 +55,18 @@ EncBase* getEncoder(QString encoder) return encoderCache.value(encoder); EncBase* enc; - if(encoder == "rbspeex") + if(encoder == "lame") { - enc = new EncRbSpeex(); + enc = new EncExes(encoder); encoderCache[encoder] = enc; return enc; } - else if(encoder == "lame") + else // rbspeex is default { - enc = new EncExes(encoder); + enc = new EncRbSpeex(); encoderCache[encoder] = enc; return enc; } - else - return NULL; } @@ -81,7 +81,7 @@ QStringList getEncoderList() /********************************************************************* * Encoder Base **********************************************************************/ -EncBase::EncBase(QWidget *parent): QDialog(parent) +EncBase::EncBase(QObject *parent): QObject(parent) { } @@ -89,7 +89,7 @@ EncBase::EncBase(QWidget *parent): QDialog(parent) /********************************************************************* * GEneral Exe Encoder **********************************************************************/ -EncExes::EncExes(QString name,QWidget *parent) : EncBase(parent) +EncExes::EncExes(QString name,QObject *parent) : EncBase(parent) { m_name = name; @@ -132,7 +132,11 @@ bool EncExes::encode(QString input,QString output) void EncExes::showCfg() { +#ifndef CONSOLE EncExesGui gui; +#else + EncExesGuiCli gui; +#endif gui.setCfg(settings); gui.showCfg(m_name); } @@ -152,7 +156,7 @@ bool EncExes::configOk() /********************************************************************* * RB SPEEX ENCODER **********************************************************************/ -EncRbSpeex::EncRbSpeex(QWidget *parent) : EncBase(parent) +EncRbSpeex::EncRbSpeex(QObject *parent) : EncBase(parent) { defaultQuality = 8.f; @@ -208,7 +212,11 @@ bool EncRbSpeex::encode(QString input,QString output) void EncRbSpeex::showCfg() { +#ifndef CONSOLE EncRbSpeexGui gui; +#else + EncRbSpeexGuiCli gui; +#endif gui.setCfg(settings); gui.showCfg(defaultQuality,defaultVolume,defaultComplexity,defaultBand); } diff --git a/rbutil/rbutilqt/encoders.h b/rbutil/rbutilqt/encoders.h index 64d57b0ff..239ca3df7 100644 --- a/rbutil/rbutilqt/encoders.h +++ b/rbutil/rbutilqt/encoders.h @@ -40,11 +40,11 @@ QString getEncoderName(QString encoder); QStringList getEncoderList(void); -class EncBase : public QDialog +class EncBase : public QObject { Q_OBJECT public: - EncBase(QWidget *parent ); + EncBase(QObject *parent ); virtual bool encode(QString input,QString output) {(void)input; (void)output; return false;} @@ -71,7 +71,7 @@ class EncExes : public EncBase { Q_OBJECT public: - EncExes(QString name,QWidget *parent = NULL); + EncExes(QString name,QObject *parent = NULL); virtual bool encode(QString input,QString output); virtual bool start(); virtual bool stop() {return true;} @@ -90,7 +90,7 @@ class EncRbSpeex : public EncBase { Q_OBJECT public: - EncRbSpeex(QWidget *parent = NULL); + EncRbSpeex(QObject *parent = NULL); virtual bool encode(QString input,QString output); virtual bool start(); virtual bool stop() {return true;} diff --git a/rbutil/rbutilqt/installzip.cpp b/rbutil/rbutilqt/installzip.cpp index 41f88171c..874417dc9 100644 --- a/rbutil/rbutilqt/installzip.cpp +++ b/rbutil/rbutilqt/installzip.cpp @@ -62,7 +62,7 @@ void ZipInstaller::installContinue() m_dp->addItem(tr("Installation finished successfully."),LOGOK); m_dp->abort(); - emit done(false); + emit done(true); return; } @@ -89,27 +89,17 @@ void ZipInstaller::installStart() getter->setProxy(m_proxy); if(m_cache.exists()) { getter->setCache(m_cache); - qDebug() << "installzip: setting cache to" << m_cache; + } getter->setFile(downloadFile); getter->getFile(QUrl(m_url)); connect(getter, SIGNAL(done(bool)), this, SLOT(downloadDone(bool))); - connect(getter, SIGNAL(downloadDone(int, bool)), this, SLOT(downloadRequestFinished(int, bool))); connect(getter, SIGNAL(dataReadProgress(int, int)), this, SLOT(updateDataReadProgress(int, int))); connect(m_dp, SIGNAL(aborted()), getter, SLOT(abort())); } -void ZipInstaller::downloadRequestFinished(int id, bool error) -{ - qDebug() << "Install::downloadRequestFinished" << id << error; - qDebug() << "error:" << getter->errorString(); - - downloadDone(error); -} - - void ZipInstaller::downloadDone(bool error) { qDebug() << "Install::downloadDone, error:" << error; @@ -125,14 +115,14 @@ void ZipInstaller::downloadDone(bool error) if(getter->httpResponse() != 200 && !getter->isCached()) { m_dp->addItem(tr("Download error: received HTTP error %1.").arg(getter->httpResponse()),LOGERROR); m_dp->abort(); - emit done(true); + emit done(false); return; } if(getter->isCached()) m_dp->addItem(tr("Cached file used."), LOGINFO); if(error) { m_dp->addItem(tr("Download error: %1").arg(getter->errorString()),LOGERROR); m_dp->abort(); - emit done(true); + emit done(false); return; } else m_dp->addItem(tr("Download finished."),LOGOK); diff --git a/rbutil/rbutilqt/installzip.h b/rbutil/rbutilqt/installzip.h index 9becbb1b8..8100dee2b 100644 --- a/rbutil/rbutilqt/installzip.h +++ b/rbutil/rbutilqt/installzip.h @@ -56,7 +56,6 @@ signals: private slots: void updateDataReadProgress(int, int); void downloadDone(bool); - void downloadRequestFinished(int, bool); void installStart(void); void installContinue(void); diff --git a/rbutil/rbutilqt/talkfile.cpp b/rbutil/rbutilqt/talkfile.cpp index 0df653b97..478e9ea19 100644 --- a/rbutil/rbutilqt/talkfile.cpp +++ b/rbutil/rbutilqt/talkfile.cpp @@ -60,10 +60,10 @@ bool TalkFileCreator::createTalkFiles(ProgressloggerInterface* logger) connect(logger,SIGNAL(aborted()),this,SLOT(abort())); m_logger->setProgressMax(0); - QDirIterator::IteratorFlags flags = QDirIterator::NoIteratorFlags; - if(m_recursive) - flags = QDirIterator::Subdirectories; - + QDirIterator::IteratorFlags flags = QDirIterator::NoIteratorFlags; + if(m_recursive) + flags = QDirIterator::Subdirectories; + QDirIterator it(m_dir,flags); QSettings installlog(m_mountpoint + "/.rockbox/rbutil.log", QSettings::IniFormat, 0); installlog.beginGroup("talkfiles"); @@ -141,6 +141,7 @@ bool TalkFileCreator::createTalkFiles(ProgressloggerInterface* logger) m_logger->abort(); m_tts->stop(); m_enc->stop(); + return false; } QApplication::processEvents(); @@ -152,6 +153,7 @@ bool TalkFileCreator::createTalkFiles(ProgressloggerInterface* logger) m_logger->abort(); m_tts->stop(); m_enc->stop(); + return false; } QApplication::processEvents(); diff --git a/rbutil/rbutilqt/talkfile.h b/rbutil/rbutilqt/talkfile.h index 6d3b01241..f3c0c54ce 100644 --- a/rbutil/rbutilqt/talkfile.h +++ b/rbutil/rbutilqt/talkfile.h @@ -48,7 +48,7 @@ public: void setStripExtensions(bool ov) {m_stripExtensions = ov;} void setTalkFolders(bool ov) {m_talkFolders = ov;} void setTalkFiles(bool ov) {m_talkFiles = ov;} - + private slots: void abort(); diff --git a/rbutil/rbutilqt/tts.cpp b/rbutil/rbutilqt/tts.cpp index eb78f3100..9bdbf6fe3 100644 --- a/rbutil/rbutilqt/tts.cpp +++ b/rbutil/rbutilqt/tts.cpp @@ -130,7 +130,11 @@ bool TTSExes::voice(QString text,QString wavfile) void TTSExes::showCfg() { +#ifndef CONSOLE TTSExesGui gui; +#else + TTSExesGuiCli gui; +#endif gui.setCfg(settings); gui.showCfg(m_name); } @@ -270,7 +274,11 @@ bool TTSSapi::stop() void TTSSapi::showCfg() { +#ifndef CONSOLE TTSSapiGui gui(this); +#else + TTSSapiGuiCli gui(this); +#endif gui.setCfg(settings); gui.showCfg(); } diff --git a/rbutil/rbutilqt/tts.h b/rbutil/rbutilqt/tts.h index 40fd4c727..eb5bbb731 100644 --- a/rbutil/rbutilqt/tts.h +++ b/rbutil/rbutilqt/tts.h @@ -27,6 +27,8 @@ #ifndef CONSOLE #include "ttsgui.h" +#else +#include "ttsguicli.h" #endif class TTSBase; diff --git a/rbutil/rbutilqt/voicefile.cpp b/rbutil/rbutilqt/voicefile.cpp index 54fd7a6ec..42902b93d 100644 --- a/rbutil/rbutilqt/voicefile.cpp +++ b/rbutil/rbutilqt/voicefile.cpp @@ -54,6 +54,7 @@ bool VoiceFileCreator::createVoiceFile(ProgressloggerInterface* logger) { m_logger->addItem(tr("failed to open rockbox-info.txt"),LOGERROR); m_logger->abort(); + emit done(false); return false; } @@ -94,22 +95,12 @@ bool VoiceFileCreator::createVoiceFile(ProgressloggerInterface* logger) getter->getFile(genlangUrl); connect(getter, SIGNAL(done(bool)), this, SLOT(downloadDone(bool))); - connect(getter, SIGNAL(downloadDone(int, bool)), this, SLOT(downloadRequestFinished(int, bool))); connect(getter, SIGNAL(dataReadProgress(int, int)), this, SLOT(updateDataReadProgress(int, int))); connect(m_logger, SIGNAL(aborted()), getter, SLOT(abort())); return true; } -void VoiceFileCreator::downloadRequestFinished(int id, bool error) -{ - qDebug() << "Install::downloadRequestFinished" << id << error; - qDebug() << "error:" << getter->errorString(); - - downloadDone(error); -} - - void VoiceFileCreator::downloadDone(bool error) { qDebug() << "Voice creator::downloadDone, error:" << error; @@ -124,12 +115,14 @@ void VoiceFileCreator::downloadDone(bool error) if(getter->httpResponse() != 200 && !getter->isCached()) { m_logger->addItem(tr("Download error: received HTTP error %1.").arg(getter->httpResponse()),LOGERROR); m_logger->abort(); + emit done(false); return; } if(getter->isCached()) m_logger->addItem(tr("Cached file used."), LOGINFO); if(error) { m_logger->addItem(tr("Download error: %1").arg(getter->errorString()),LOGERROR); m_logger->abort(); + emit done(false); return; } else m_logger->addItem(tr("Download finished."),LOGOK); @@ -143,6 +136,7 @@ void VoiceFileCreator::downloadDone(bool error) { m_logger->addItem(tr("failed to open downloaded file"),LOGERROR); m_logger->abort(); + emit done(false); return; } @@ -156,6 +150,7 @@ void VoiceFileCreator::downloadDone(bool error) m_logger->addItem(errStr,LOGERROR); m_logger->addItem(tr("Init of TTS engine failed"),LOGERROR); m_logger->abort(); + emit done(false); return; } @@ -168,6 +163,7 @@ void VoiceFileCreator::downloadDone(bool error) m_logger->addItem(tr("Init of Encoder engine failed"),LOGERROR); m_tts->stop(); m_logger->abort(); + emit done(false); return; } @@ -210,6 +206,7 @@ void VoiceFileCreator::downloadDone(bool error) m_logger->addItem(tr("The downloaded file was empty!"),LOGERROR); m_logger->abort(); m_tts->stop(); + emit done(false); return; } @@ -225,6 +222,7 @@ void VoiceFileCreator::downloadDone(bool error) m_logger->addItem("aborted.",LOGERROR); m_logger->abort(); m_tts->stop(); + emit done(false); return; } @@ -269,13 +267,15 @@ void VoiceFileCreator::downloadDone(bool error) { m_logger->addItem(tr("Error opening downloaded file"),LOGERROR); m_logger->abort(); + emit done(false); return; } FILE* output = fopen(QString(m_mountpoint + "/.rockbox/langs/" + m_lang + ".voice").toUtf8(), "wb"); if (output == NULL) { - m_logger->addItem(tr("Error opening output file"),LOGERROR); + m_logger->addItem(tr("Error opening output file"),LOGERROR); + emit done(false); return; } @@ -290,7 +290,9 @@ void VoiceFileCreator::downloadDone(bool error) m_logger->setProgressMax(100); m_logger->setProgressValue(100); m_logger->addItem(tr("successfully created."),LOGOK); - m_logger->abort(); + m_logger->abort(); + + emit done(true); } void VoiceFileCreator::updateDataReadProgress(int read, int total) diff --git a/rbutil/rbutilqt/voicefile.h b/rbutil/rbutilqt/voicefile.h index 43eb95a69..55b2184c3 100644 --- a/rbutil/rbutilqt/voicefile.h +++ b/rbutil/rbutilqt/voicefile.h @@ -53,9 +53,11 @@ public: void setWavtrimThreshold(int th){m_wavtrimThreshold = th;} void setProxy(QUrl proxy){m_proxy = proxy;} +signals: + void done(bool error); + private slots: void abort(); - void downloadRequestFinished(int id, bool error); void downloadDone(bool error); void updateDataReadProgress(int read, int total); -- 2.11.4.GIT