From 79103e2e17254d7b08b7b91f94fb5e05f198e9ee Mon Sep 17 00:00:00 2001 From: Michael Haeckel Date: Mon, 11 Jun 2001 13:09:54 +0000 Subject: [PATCH] Again QT_NO_ASCII_CAST fixes and two charset related fixes for bugs I found on the way. svn path=/trunk/kdenetwork/kmail/; revision=101586 --- kfileio.cpp | 14 +++++++------- kfileio.h | 2 +- kmfldsearch.cpp | 11 +++++------ kmidentity.cpp | 3 +-- kmkernel.cpp | 18 +++++++++--------- 5 files changed, 23 insertions(+), 25 deletions(-) diff --git a/kfileio.cpp b/kfileio.cpp index fc5ef8768..f0086a28e 100644 --- a/kfileio.cpp +++ b/kfileio.cpp @@ -22,7 +22,7 @@ static void msgDialog(const QString &msg) //----------------------------------------------------------------------------- -QString kFileToString(const QString &aFileName, bool aEnsureNL, bool aVerbose) +QCString kFileToString(const QString &aFileName, bool aEnsureNL, bool aVerbose) { QCString result; QFileInfo info(aFileName); @@ -38,22 +38,22 @@ QString kFileToString(const QString &aFileName, bool aEnsureNL, bool aVerbose) { if (aVerbose) msgDialog(i18n("The specified file does not exist:\n%1").arg(aFileName)); - return QString::null; + return QCString(); } if (info.isDir()) { if (aVerbose) msgDialog(i18n("This is a directory and not a file:\n%1").arg(aFileName)); - return QString::null; + return QCString(); } if (!info.isReadable()) { if (aVerbose) msgDialog(i18n("You do not have read permissions " "to the file:\n%1").arg(aFileName)); - return QString::null; + return QCString(); } - if (len <= 0) return QString::null; + if (len <= 0) return QCString(); if (!file.open(IO_Raw|IO_ReadOnly)) { @@ -68,7 +68,7 @@ QString kFileToString(const QString &aFileName, bool aEnsureNL, bool aVerbose) default: msgDialog(i18n("Error while reading file:\n%1").arg(aFileName)); } - return QString::null; + return QCString(); } result.resize(len + (int)aEnsureNL + 1); @@ -85,7 +85,7 @@ QString kFileToString(const QString &aFileName, bool aEnsureNL, bool aVerbose) QString msg = i18n("Could only read %1 bytes of %2.") .arg(readLen).arg(len); msgDialog(msg); - return QString::null; + return QCString(); } return result; diff --git a/kfileio.h b/kfileio.h index 4838fc631..1f6f08076 100644 --- a/kfileio.h +++ b/kfileio.h @@ -16,7 +16,7 @@ * byte longer than the file itself. * If ensureNewline is TRUE the string will always have a trailing newline. */ -QString kFileToString(const QString &fileName, bool ensureNewline=TRUE, +QCString kFileToString(const QString &fileName, bool ensureNewline=TRUE, bool withDialogs=TRUE); QByteArray kFileToBytes(const QString &fileName, bool withDialogs=TRUE); diff --git a/kmfldsearch.cpp b/kmfldsearch.cpp index d5676e32f..011219007 100644 --- a/kmfldsearch.cpp +++ b/kmfldsearch.cpp @@ -1,4 +1,3 @@ -#undef QT_NO_ASCII_CAST // kmfldsearch.cpp // TODO: Add search in subfolder checkbox // TODO: Use msgIdMD5 in MSGID_COLUMN @@ -250,12 +249,12 @@ void KMFldSearch::searchInFolder(QGuardedPtr aFld, int fldNum) assert(!aFld.isNull()); - if (aFld->isSystemFolder()) mSearchFolder = i18n(aFld->name()); + if (aFld->isSystemFolder()) mSearchFolder = i18n(aFld->name().utf8()); else mSearchFolder = aFld->name(); kapp->processEvents(); if (aFld->open() != 0) { - kdDebug() << "Cannot open folder '" << (const char*)aFld->name() << "'" << endl; + kdDebug() << "Cannot open folder '" << aFld->name() << "'" << endl; return; } @@ -553,7 +552,7 @@ void KMFldSearchRule::prepare(void) { mFieldIdx = mCbxField->currentItem(); mField = mCbxField->currentText(); - mHeaderField = "\n" + mField + ": "; + mHeaderField = QString("\n" + mField + ": ").latin1(); mFieldLength = mField.length() + 3; mFunc = mCbxFunc->currentItem(); mValue = mEdtValue->text(); @@ -613,9 +612,9 @@ bool KMFldSearchRule::matches(const KMMessage* aMsg, const QCString& aMsgStr) switch(mFunc) { case Equal: - return (qstricmp(value, mValue) == 0); + return (value == mValue); case NotEqual: - return (qstricmp(value, mValue) != 0); + return (value != mValue); case Contains: return value.contains(mValue, FALSE); case NotContains: diff --git a/kmidentity.cpp b/kmidentity.cpp index 94b351850..0375de7c6 100644 --- a/kmidentity.cpp +++ b/kmidentity.cpp @@ -1,4 +1,3 @@ -#undef QT_NO_ASCII_CAST #undef QT_NO_COMPAT // kmidentity.cpp @@ -245,7 +244,7 @@ QString KMIdentity::signature(void) const sigcmd = mSignatureFile.left(mSignatureFile.length()-1); sigcmd += " >"; sigcmd += tmpf.name(); - rc = system(sigcmd); + rc = system(sigcmd.local8Bit()); if (rc != 0) { diff --git a/kmkernel.cpp b/kmkernel.cpp index b228bd68f..d97c45611 100644 --- a/kmkernel.cpp +++ b/kmkernel.cpp @@ -1,4 +1,3 @@ -#undef QT_NO_ASCII_CAST #undef QT_NO_COMPAT #include #include @@ -131,7 +130,7 @@ int KMKernel::openComposer (const QString &to, const QString &cc, if (!to.isEmpty()) msg->setTo(to); if (!messageFile.isEmpty() && messageFile.isLocalFile()) - msg->setBody( kFileToString( messageFile.path(), true, false ).local8Bit() ); + msg->setBody( kFileToString( messageFile.path(), true, false ) ); if (!body.isEmpty()) msg->setBody(body.local8Bit() ); @@ -376,7 +375,7 @@ void KMKernel::recoverDeadLetters(void) rc = folder.open(); if (rc) { - perror("cannot open file "+fname); + perror(QString("cannot open file "+fname).latin1()); return; } @@ -395,7 +394,7 @@ void KMKernel::recoverDeadLetters(void) } } folder.close(); - unlink(fname); + QFile::remove(fname); } void KMKernel::initFolders(KConfig* cfg) @@ -461,12 +460,13 @@ void KMKernel::init() the_firstStart = cfg->readBoolEntry("first-start", true); the_previousVersion = cfg->readEntry("previous-version", ""); cfg->writeEntry("previous-version", KMAIL_VERSION); - foldersPath = cfg->readEntry("folders", ""); - acctPath = cfg->readEntry("accounts", foldersPath + "/.kmail-accounts"); + foldersPath = cfg->readEntry("folders", "").local8Bit(); + acctPath = cfg->readEntry("accounts", foldersPath + "/.kmail-accounts") + .local8Bit(); if (foldersPath.isEmpty()) { - foldersPath = QDir::homeDirPath() + QString("/Mail"); + foldersPath = QString(QDir::homeDirPath() + QString("/Mail")).local8Bit(); transferMail(); } @@ -599,7 +599,7 @@ void KMKernel::cleanup(void) // left behind. if (!KMReaderWin::attachDir().isEmpty()) { - cmd.sprintf("rm -rf '%s'", (const char*)KMReaderWin::attachDir()); + cmd.sprintf("rm -rf '%s'", KMReaderWin::attachDir().local8Bit()); system (cmd.data()); // delete your owns only } //--- Sven's save attachments to /tmp end --- @@ -671,7 +671,7 @@ void KMKernel::kmailMsgHandler(QtMsgType aType, const char* aMsg) case QtFatalMsg: ungrabPtrKb(); - fprintf(stderr, appName+" "+i18n("fatal error")+": %s\n", msg.data()); + kdDebug() << appName << " " << i18n("fatal error") << " " << msg.data() << endl; KMessageBox::error(0, aMsg); abort(); }