[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: KDE/kdeaccessibility
From: Jaison Lee <lee.jaison () gmail ! com>
Date: 2006-09-24 23:14:47
Message-ID: 1159139687.335957.21108.nullmailer () svn ! kde ! org
[Download RAW message or body]
SVN commit 588100 by jlee:
KTempFile->KTemporaryFile
M +4 -6 kmag/kmag.cpp
M +10 -10 kmouth/speech.cpp
M +2 -2 kmouth/speech.h
M +17 -19 kttsd/filters/xmltransformer/xmltransformerproc.cpp
M +7 -10 kttsd/kttsd/speaker.cpp
M +16 -18 kttsd/kttsd/ssmlconvert.cpp
M +7 -5 kttsd/libkttsd/testplayer.cpp
M +7 -4 kttsd/plugins/command/commandconf.cpp
M +11 -8 kttsd/plugins/command/commandproc.cpp
M +7 -4 kttsd/plugins/epos/eposconf.cpp
M +7 -7 kttsd/plugins/festivalint/festivalintconf.cpp
M +7 -4 kttsd/plugins/flite/fliteconf.cpp
M +7 -4 kttsd/plugins/freetts/freettsconf.cpp
M +7 -4 kttsd/plugins/hadifix/hadifixconf.cpp
--- trunk/KDE/kdeaccessibility/kmag/kmag.cpp #588099:588100
@@ -55,7 +55,7 @@
#include <kimageio.h>
#include <kio/job.h>
#include <kio/netaccess.h>
-#include <ktempfile.h>
+#include <ktemporaryfile.h>
#include <kmenu.h>
#include <kedittoolbar.h>
@@ -529,13 +529,13 @@
if(!url.fileName().isEmpty()) {
if(!url.isLocalFile()) {
// create a temp file.. save image to it.. copy over the n/w and then delete \
the temp file.
- KTempFile tempFile;
+ KTemporaryFile tempFile;
#warning "kde4: port KImageIO::type \n";
- if(!m_zoomView->getPixmap().save(tempFile.name(),"png"/*, \
KImageIO::type(url.fileName()).latin1()*/)) { + if(!tempFile.open() || \
!m_zoomView->getPixmap().save(tempFile.fileName(),"png"/*, \
KImageIO::type(url.fileName()).latin1()*/)) {
KMessageBox::error(0, i18n("Unable to save temporary file (before uploading \
to the network file you specified)."), i18n("Error Writing File"));
} else {
- if(!KIO::NetAccess::upload(tempFile.name(), url, this)) {
+ if(!KIO::NetAccess::upload(tempFile.fileName(), url, this)) {
KMessageBox::error(0, i18n("Unable to upload file over the network."),
i18n("Error Writing File"));
} else {
@@ -543,8 +543,6 @@
i18n("Information"), "save_confirm");
}
}
- // remove the temporary file
- tempFile.unlink();
} else {
#warning "kde4 : port KImageIO::type(...) \n";
--- trunk/KDE/kdeaccessibility/kmouth/speech.cpp #588099:588100
@@ -183,20 +183,20 @@
ts << text;
// 1.b) create a temporary file for the text
- tempFile.setAutoDelete(true);
- QTextStream* fs = tempFile.textStream();
+ tempFile.open();
+ QTextStream fs ( &tempFile );
if (encoding == Local)
- fs->setEncoding (QTextStream::Locale);
+ fs.setEncoding (QTextStream::Locale);
else if (encoding == Latin1)
- fs->setEncoding (QTextStream::Latin1);
+ fs.setEncoding (QTextStream::Latin1);
else if (encoding == Unicode)
- fs->setEncoding (QTextStream::Unicode);
+ fs.setEncoding (QTextStream::Unicode);
else
- fs->setCodec (codec);
- *fs << text;
- *fs << endl;
- QString filename = tempFile.file()->fileName();
- tempFile.close();
+ fs.setCodec (codec);
+ fs << text;
+ fs << endl;
+ QString filename = tempFile.fileName();
+ tempFile.flush();
// 2. prepare the command:
command = prepareCommand (command, encText, filename, language);
--- trunk/KDE/kdeaccessibility/kmouth/speech.h #588099:588100
@@ -21,7 +21,7 @@
#include <QObject>
#include <QString>
#include <kprocess.h>
-#include <ktempfile.h>
+#include <ktemporaryfile.h>
/**This class is used internally by TextToSpeechSystem in order to do the actual \
speaking.
*@author Gunnar Schmi Dt
@@ -66,7 +66,7 @@
private:
KShellProcess process;
QByteArray encText;
- KTempFile tempFile;
+ KTemporaryFile tempFile;
};
#endif
--- trunk/KDE/kdeaccessibility/kttsd/filters/xmltransformer/xmltransformerproc.cpp \
#588099:588100 @@ -29,7 +29,7 @@
// KDE includes.
#include <kdeversion.h>
#include <kconfig.h>
-#include <ktempfile.h>
+#include <ktemporaryfile.h>
#include <kstandarddirs.h>
#include <kprocess.h>
#include <kdebug.h>
@@ -213,33 +213,31 @@
}
/// Write @param text to a temporary file.
- KTempFile inFile(KStandardDirs::locateLocal("tmp", "kttsd-"), ".xml");
- m_inFilename = inFile.file()->fileName();
- QTextStream* wstream = inFile.textStream();
- if (wstream == 0) {
- /// wtf...
- kDebug() << "XmlTransformerProc::convert: Can't write to " << m_inFilename \
<< endl;;
- return false;
- }
+ KTemporaryFile inFile;
+ inFile.setPrefix("kttsd-");
+ inFile.setSuffix(".xml");
+ inFile.setAutoRemove(false);
+ inFile.open();
+ m_inFilename = inFile.fileName();
+ QTextStream wstream (&inFile);
// TODO: Is encoding an issue here?
// If input does not have xml processing instruction, add it.
- if (!inputText.startsWith("<?xml")) *wstream << "<?xml version=\"1.0\" \
encoding=\"UTF-8\"?>"; + if (!inputText.startsWith("<?xml")) wstream << "<?xml \
version=\"1.0\" encoding=\"UTF-8\"?>";
// FIXME: Temporary Fix until Konqi returns properly formatted xhtml with & \
coded as &
// This will change & inside a CDATA section, which is not good, and also within \
comments and
// processing instructions, which is OK because we don't speak those anyway.
QString text = inputText;
text.replace(QRegExp("&(?!amp;)"),"&");
- *wstream << text;
- inFile.close();
-#if KDE_VERSION >= KDE_MAKE_VERSION (3,3,0)
- inFile.sync();
-#endif
+ wstream << text;
+ inFile.flush();
// Get a temporary output file name.
- KTempFile outFile(KStandardDirs::locateLocal("tmp", "kttsd-"), ".output");
- m_outFilename = outFile.file()->fileName();
- outFile.close();
- // outFile.unlink(); // only activate this if necessary.
+ KTemporaryFile outFile;
+ outFile.setPrefix("kttsd-");
+ outFile.setSuffix(".output");
+ outFile.setAutoRemove(false);
+ outFile.open();
+ m_outFilename = outFile.fileName();
/// Spawn an xsltproc process to apply our stylesheet to input file.
m_xsltProc = new KProcess;
--- trunk/KDE/kdeaccessibility/kttsd/kttsd/speaker.cpp #588099:588100
@@ -38,7 +38,7 @@
#include <kparts/componentfactory.h>
#include <kapplication.h>
#include <kstandarddirs.h>
-#include <ktempfile.h>
+#include <ktemporaryfile.h>
#include <kservicetypetrader.h>
#include <kspeech.h>
//#include <kio/job.h>
@@ -992,15 +992,12 @@
QString Speaker::makeSuggestedFilename()
{
- QString tmpDir = KStandardDirs::locateLocal("tmp", "kttsd-");
- kDebug() << "Speaker::makeSuggestedFilename: tmpDir = " << tmpDir << endl;
- KTempFile tempFile (tmpDir, ".wav");
- // TODO: This not working. Why?
- // QString waveFile = tempFile.file()->name();
- // QString waveFile = mFile.name();
- // tempFile.close();
- QString waveFile = tempFile.name();
- QFile::remove(waveFile);
+ KTemporaryFile *tempFile = new KTemporaryFile();
+ tempFile->setPrefix("kttsd-");
+ tempFile->setSuffix(".wav");
+ tempFile->open();
+ QString waveFile = tempFile->fileName();
+ delete tempFile;
kDebug() << "Speaker::makeSuggestedFilename: Suggesting filename: " << waveFile \
<< endl; return KStandardDirs::realFilePath(waveFile);
}
--- trunk/KDE/kdeaccessibility/kttsd/kttsd/ssmlconvert.cpp #588099:588100
@@ -30,7 +30,7 @@
#include <kdeversion.h>
#include <kstandarddirs.h>
#include <kprocess.h>
-#include <ktempfile.h>
+#include <ktemporaryfile.h>
#include <kdebug.h>
// SSMLConvert includes.
@@ -206,29 +206,27 @@
bool SSMLConvert::transform(const QString &text, const QString &xsltFilename) {
m_xsltFilename = xsltFilename;
/// Write @param text to a temporary file.
- KTempFile inFile(KStandardDirs::locateLocal("tmp", "kttsd-"), ".ssml");
- m_inFilename = inFile.file()->fileName();
- QTextStream* wstream = inFile.textStream();
- if (wstream == 0) {
- /// wtf...
- kDebug() << "SSMLConvert::transform: Can't write to " << m_inFilename << \
endl;;
- return false;
- }
+ KTemporaryFile inFile;
+ inFile.setPrefix("kttsd-");
+ inFile.setSuffix(".ssml");
+ inFile.setAutoRemove(false);
+ inFile.open();
+ m_inFilename = inFile.fileName();
+ QTextStream wstream (&inFile);
// TODO: Is encoding an issue here?
// TODO: It would be nice if we detected whether the XML is properly formed
// with the required xml processing instruction and encoding attribute. If
// not wrap it in such. But maybe this should be handled by \
SpeechData::setText()?
- *wstream << text;
- inFile.close();
-#if KDE_VERSION >= KDE_MAKE_VERSION (3,3,0)
- inFile.sync();
-#endif
+ wstream << text;
+ inFile.flush();
// Get a temporary output file name.
- KTempFile outFile(KStandardDirs::locateLocal("tmp", "kttsd-"), ".output");
- m_outFilename = outFile.file()->fileName();
- outFile.close();
- // outFile.unlink(); // only activate this if necessary.
+ KTemporaryFile outFile;
+ outFile.setPrefix("kttsd-");
+ outFile.setSuffix(".output");
+ outFile.setAutoRemove(false);
+ outFile.open();
+ m_outFilename = outFile.fileName();
/// Spawn an xsltproc process to apply our stylesheet to our SSML file.
m_xsltProc = new KProcess;
--- trunk/KDE/kdeaccessibility/kttsd/libkttsd/testplayer.cpp #588099:588100
@@ -27,7 +27,7 @@
// KDE includes.
#include <kapplication.h>
-#include <ktempfile.h>
+#include <ktemporaryfile.h>
#include <kstandarddirs.h>
#include <kparts/componentfactory.h>
#include <kdebug.h>
@@ -183,10 +183,12 @@
*/
QString TestPlayer::makeSuggestedFilename()
{
- KTempFile tempFile (KStandardDirs::locateLocal("tmp", "kttsmgr-"), ".wav");
- QString waveFile = tempFile.file()->fileName();
- tempFile.close();
- QFile::remove(waveFile);
+ KTemporaryFile *tempFile = new KTemporaryFile();
+ tempFile->setPrefix("kttsmgr-");
+ tempFile->setSuffix(".wav");
+ tempFile->open();
+ QString waveFile = tempFile->fileName();
+ delete tempFile;
// kDebug() << "TestPlayer::makeSuggestedFilename: Suggesting filename: " << \
waveFile << endl; return PlugInConf::realFilePath(waveFile);
}
--- trunk/KDE/kdeaccessibility/kttsd/plugins/command/commandconf.cpp #588099:588100
@@ -25,7 +25,7 @@
#include <kdebug.h>
#include <klocale.h>
#include <kcombobox.h>
-#include <ktempfile.h>
+#include <ktemporaryfile.h>
#include <kstandarddirs.h>
#include <kprogressdialog.h>
// KTTS includes.
@@ -142,9 +142,12 @@
}
// Create a temp file name for the wave file.
- KTempFile tempFile (KStandardDirs::locateLocal("tmp", "commandplugin-"), \
".wav");
- QString tmpWaveFile = tempFile.file()->fileName();
- tempFile.close();
+ KTemporaryFile tempFile;
+ tempFile.setPrefix("commandplugin-");
+ tempFile.setSuffix(".wav");
+ tempFile.setAutoRemove(false);
+ tempFile.open();
+ QString tmpWaveFile = tempFile.fileName();
// Get test message in the language of the voice.
QString testMsg = testMessage(m_languageCode);
--- trunk/KDE/kdeaccessibility/kttsd/plugins/command/commandproc.cpp #588099:588100
@@ -28,7 +28,7 @@
#include <kdebug.h>
#include <kconfig.h>
#include <kprocess.h>
-#include <ktempfile.h>
+#include <ktemporaryfile.h>
#include <kstandarddirs.h>
// KTTS includes.
@@ -148,13 +148,16 @@
// 1.c) create a temporary file for the text, if %f macro is used.
if (command.contains("%f"))
{
- KTempFile tempFile(KStandardDirs::locateLocal("tmp", "commandplugin-"), \
".txt");
- QTextStream* fs = tempFile.textStream();
- fs->setCodec(codec);
- *fs << text;
- *fs << endl;
- m_textFilename = tempFile.file()->fileName();
- tempFile.close();
+ KTemporaryFile tempFile;
+ tempFile.setPrefix("commandplugin-");
+ tempFile.setSuffix(".txt");
+ tempFile.setAutoRemove(false);
+ tempFile.open();
+ QTextStream fs (&tempFile);
+ fs.setCodec(codec);
+ fs << text;
+ fs << endl;
+ m_textFilename = tempFile.fileName();
} else m_textFilename.clear();
// 2. replace variables with values
--- trunk/KDE/kdeaccessibility/kttsd/plugins/epos/eposconf.cpp #588099:588100
@@ -32,7 +32,7 @@
// KDE includes.
#include <kdialog.h>
-#include <ktempfile.h>
+#include <ktemporaryfile.h>
#include <kstandarddirs.h>
#include <kcombobox.h>
#include <klocale.h>
@@ -202,9 +202,12 @@
connect (m_eposProc, SIGNAL(stopped()), this, SLOT(slotSynthStopped()));
}
// Create a temp file name for the wave file.
- KTempFile tempFile (KStandardDirs::locateLocal("tmp", "eposplugin-"), ".wav");
- QString tmpWaveFile = tempFile.file()->fileName();
- tempFile.close();
+ KTemporaryFile tempFile;
+ tempFile.setPrefix("eposplugin-");
+ tempFile.setSuffix(".wav");
+ tempFile.setAutoRemove(false);
+ tempFile.open();
+ QString tmpWaveFile = tempFile.fileName();
// Get test message in the language of the voice.
QString testMsg = testMessage(m_languageCode);
--- trunk/KDE/kdeaccessibility/kttsd/plugins/festivalint/festivalintconf.cpp \
#588099:588100 @@ -40,7 +40,7 @@
#include <klocale.h>
#include <kcombobox.h>
#include <kglobal.h>
-#include <ktempfile.h>
+#include <ktemporaryfile.h>
#include <kstandarddirs.h>
#include <knuminput.h>
#include <kprocio.h>
@@ -548,12 +548,12 @@
connect (m_festProc, SIGNAL(stopped()), this, SLOT(slotSynthStopped()));
}
// Create a temp file name for the wave file.
- KTempFile tempFile (KStandardDirs::locateLocal("tmp", "festivalintplugin-"), \
".wav");
- // FIXME: Temporary workaround for KTempFile problem.
- // QString tmpWaveFile = tempFile.file()->name();
- // tempFile.close();
- QString tmpWaveFile = tempFile.name();
- QFile::remove(tmpWaveFile);
+ KTemporaryFile *tempFile = new KTemporaryFile();
+ tempFile->setPrefix("festivalintplugin-");
+ tempFile->setSuffix(".wav");
+ tempFile->open();
+ QString tmpWaveFile = tempFile->fileName();
+ delete tempFile;
kDebug() << "FestivalIntConf::slotTest_clicked: tmpWaveFile = " << tmpWaveFile \
<< endl;
--- trunk/KDE/kdeaccessibility/kttsd/plugins/flite/fliteconf.cpp #588099:588100
@@ -29,7 +29,7 @@
// KDE includes.
#include <klocale.h>
#include <kdialog.h>
-#include <ktempfile.h>
+#include <ktemporaryfile.h>
#include <kstandarddirs.h>
#include <kprogressdialog.h>
@@ -134,9 +134,12 @@
connect (m_fliteProc, SIGNAL(stopped()), this, SLOT(slotSynthStopped()));
}
// Create a temp file name for the wave file.
- KTempFile tempFile (KStandardDirs::locateLocal("tmp", "fliteplugin-"), ".wav");
- QString tmpWaveFile = tempFile.file()->fileName();
- tempFile.close();
+ KTemporaryFile tempFile;
+ tempFile.setPrefix("fliteplugin-");
+ tempFile.setSuffix(".wav");
+ tempFile.setAutoRemove(false);
+ tempFile.open();
+ QString tmpWaveFile = tempFile.fileName();
// Get test message in the language of the voice.
QString testMsg = testMessage(m_languageCode);
--- trunk/KDE/kdeaccessibility/kttsd/plugins/freetts/freettsconf.cpp #588099:588100
@@ -24,7 +24,7 @@
// KDE includes.
#include <kdialog.h>
-#include <ktempfile.h>
+#include <ktemporaryfile.h>
#include <kstandarddirs.h>
#include <kmessagebox.h>
#include <klocale.h>
@@ -160,9 +160,12 @@
connect (m_freettsProc, SIGNAL(stopped()), this, \
SLOT(slotSynthStopped())); }
// Create a temp file name for the wave file.
- KTempFile tempFile (KStandardDirs::locateLocal("tmp", "freettsplugin-"), \
".wav");
- QString tmpWaveFile = tempFile.file()->fileName();
- tempFile.close();
+ KTemporaryFile tempFile;
+ tempFile.setPrefix("freettsplugin-");
+ tempFile.setSuffix(".wav");
+ tempFile.setAutoRemove(false);
+ tempFile.open();
+ QString tmpWaveFile = tempFile.fileName();
// Get test message in the language of the voice.
QString testMsg = testMessage(m_languageCode);
--- trunk/KDE/kdeaccessibility/kttsd/plugins/hadifix/hadifixconf.cpp #588099:588100
@@ -30,7 +30,7 @@
#include <QTextStream>
// KDE includes.
-#include <ktempfile.h>
+#include <ktemporaryfile.h>
#include <kaboutdata.h>
#include <kaboutapplication.h>
#include <kdebug.h>
@@ -605,9 +605,12 @@
connect (d->hadifixProc, SIGNAL(stopped()), this, SLOT(slotSynthStopped()));
}
// Create a temp file name for the wave file.
- KTempFile tempFile (KStandardDirs::locateLocal("tmp", "hadifixplugin-"), \
".wav");
- QString tmpWaveFile = tempFile.file()->fileName();
- tempFile.close();
+ KTemporaryFile tempFile;
+ tempFile.setPrefix("hadifixplugin-");
+ tempFile.setSuffix(".wav");
+ tempFile.setAutoRemove(false);
+ tempFile.open();
+ QString tmpWaveFile = tempFile.fileName();
// Tell user to wait.
d->progressDlg = new KProgressDialog(d,
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic