removed mkstemp references and replaced them with KTempFile

fixed a text error: "Append" instead of "Prepend"
changed fstream I/O to use QFile instead

svn path=/trunk/kdenetwork/kmail/; revision=39876
wilder-work
George Staikos 27 years ago
parent 35b320e7ea
commit 287f271ddb
  1. 38
      kmcomposewin.cpp
  2. 24
      kmidentity.cpp
  3. 2
      kmsettings.cpp

@ -22,7 +22,7 @@
#ifndef KRN
#include "kmmainwin.h"
#include "kmsettings.h"
#include <fstream.h>
#include "kfileio.h"
#endif
#include <assert.h>
@ -59,6 +59,7 @@
#include <unistd.h>
#include <errno.h>
#include <klocale.h>
#include <ktempfile.h>
#if defined CHARSETS
#include <kcharsets.h>
@ -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

@ -13,6 +13,7 @@
#include <stdio.h>
#include <errno.h>
#include <klocale.h>
#include <ktempfile.h>
//-----------------------------------------------------------------------------
@ -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
{

@ -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);

Loading…
Cancel
Save