diff --git a/kmcomposewin.cpp b/kmcomposewin.cpp index e357f25ee..9690aa552 100644 --- a/kmcomposewin.cpp +++ b/kmcomposewin.cpp @@ -22,7 +22,7 @@ #ifndef KRN #include "kmmainwin.h" #include "kmsettings.h" -#include +#include "kfileio.h" #endif #include @@ -59,6 +59,7 @@ #include #include #include +#include #if defined CHARSETS #include @@ -2218,39 +2219,36 @@ bool KMEdit::eventFilter(QObject*, QEvent* e) QRegExp repFn("\\%f"); QString sysLine = mExtEditor; - char tmpFile[20] = "/tmp/kmailXXXXXX"; - // make temporary file - mkstemp(tmpFile); + KTempFile tmpFile; + QString tmpName = tmpFile.name(); - // write the data out to the file - fstream mailFile(tmpFile, ios::out); + tmpFile.setAutoDelete(true); - mailFile << text(); + fprintf(tmpFile.fstream(), "%s", (const char *)text()); - mailFile.close(); + tmpFile.close(); // replace %f in the system line - sysLine.replace(repFn, QString(tmpFile)); + sysLine.replace(repFn, tmpName); system((const char *)sysLine); setAutoUpdate(false); clear(); // read data back in from file - mailFile.open(tmpFile, ios::in); - - while (!mailFile.eof()) { - char tmpbuf[1025]; - mailFile.getline(tmpbuf, 1024, '\n'); - insertLine(tmpbuf, -1); - } + insertLine(kFileToString(tmpName, TRUE, FALSE), -1); +// QFile mailFile(tmpName); + +// while (!mailFile.atEnd()) { +// QString oneLine; +// mailFile.readLine(oneLine, 1024); +// insertLine(oneLine, -1); +// } - setModified(true); - mailFile.close(); +// setModified(true); +// mailFile.close(); setAutoUpdate(true); repaint(); - - unlink(tmpFile); return TRUE; } else { #endif diff --git a/kmidentity.cpp b/kmidentity.cpp index 6ff9bdb9b..6a41c4528 100644 --- a/kmidentity.cpp +++ b/kmidentity.cpp @@ -13,6 +13,7 @@ #include #include #include +#include //----------------------------------------------------------------------------- @@ -144,34 +145,35 @@ void KMIdentity::setSignatureFile(const QString str) const QString KMIdentity::signature(void) const { QString result, sigcmd; - char tmpf[30] = "/tmp/kmailXXXXXX"; - int fd; if (mSignatureFile.isEmpty()) return QString::null; if (mSignatureFile.right(1)=="|") { + KTempFile tmpf; + int rc; + + tmpf.setAutoDelete(true); // signature file is a shell script that returns the signature - fd = mkstemp(tmpf); - if (fd == -1) { + if (tmpf.status() != 0) { warning(i18n("Failed to create temporary file\n%s\n%s"), - tmpf, strerror(errno)); + (const char *)tmpf.name(), strerror(errno)); return QString::null; } - close(fd); + tmpf.close(); + sigcmd = mSignatureFile.left(mSignatureFile.length()-1); sigcmd += " >"; - sigcmd += tmpf; - system(sigcmd); + sigcmd += tmpf.name(); + rc = system(sigcmd); - if (errno) + if (rc != 0) { warning(i18n("Failed to execute signature script\n%s\n%s"), sigcmd.data(), strerror(errno)); return QString::null; } - result = kFileToString(tmpf, TRUE, FALSE); - unlink(tmpf); + result = kFileToString(tmpf.name(), TRUE, FALSE); } else { diff --git a/kmsettings.cpp b/kmsettings.cpp index 7ef86f3d4..fb3a48443 100644 --- a/kmsettings.cpp +++ b/kmsettings.cpp @@ -286,7 +286,7 @@ void KMSettings::createTabIdentity(QWidget* parent) connect(sigModify, SIGNAL(clicked()), this, SLOT(slotSigModify())); label = new QLabel(tab); - label->setText(i18n("(Prepend the signature file with a \"|\" to specify a program.)")); + label->setText(i18n("(Append a \"|\" to the signature file to specify a program.)")); label->setMinimumSize(label->size()); grid->addMultiCellWidget(label, 5, 5, 1, 1);