Check whether the dir that is to be used as the local mail store (~/Mail)

exists, is a dir, is readable and writeable, if it needs to be created
that creation succeeded and bail out otherwise. It would be nice, I guess,
to ask the user for an alternative dir to use, but this fixes the reported
crashes, at least.

The change to main.cpp is necessary to prevent kmail from acting like the
KUniqueApplication it is and try to bring up a new instance while we are
engaged in our somewhat onesided discussion with the user.

CC: 59244-done@bugs.kde.org
CC: 56278-done@bugs.kde.org

svn path=/trunk/kdepim/; revision=229374
wilder-work
Till Adam 23 years ago
parent 5829abeba8
commit dce4493590
  1. 30
      kmfoldermgr.cpp
  2. 8
      main.cpp

@ -121,8 +121,6 @@ void KMFolderMgr::compactAllAux(KMFolderDir* dir)
//-----------------------------------------------------------------------------
void KMFolderMgr::setBasePath(const QString& aBasePath)
{
QDir dir;
assert(!aBasePath.isNull());
if (aBasePath[0] == '~')
@ -134,14 +132,30 @@ void KMFolderMgr::setBasePath(const QString& aBasePath)
else
mBasePath = aBasePath;
QFileInfo info( mBasePath );
dir.setPath(mBasePath);
if (!dir.exists())
{
// FIXME: mkdir can fail!
mkdir(QFile::encodeName(mBasePath), 0700);
// FIXME We should ask for an alternative dir, rather than bailing out,
// I guess - till
if ( info.exists() ) {
if ( !info.isDir() ) {
KMessageBox::sorry(0, i18n("%1 does not appear to be a directory.\n"
"Please move the file out of the way.\n").arg( mBasePath ) );
::exit(-1);
}
if ( !info.isReadable() || !info.isWritable() ) {
KMessageBox::sorry(0, i18n("Permissions on the %1 directory are incorrect!\n"
"Please set them to 0700.\n").arg( mBasePath ) );
::exit(-1);
}
} else {
// ~/Mail (or whatever the user specified) doesn't exist, create it
if ( ::mkdir( QFile::encodeName( mBasePath ) , S_IRWXU ) == -1 ) {
KMessageBox::sorry(0, i18n("KMail couldn't create %1 directory !\n"
"Make sure you have write permissions in %2 directory.\n")
.arg( mBasePath ).arg( QDir::homeDirPath() ) );
::exit(-1);
}
}
mDir.setPath(mBasePath);
mDir.reload();
contentsChanged();

@ -9,6 +9,7 @@
#include <dcopclient.h>
#include "kmkernel.h" //control center
#include <kcmdlineargs.h>
#include <qtimer.h>
#undef Status // stupid X headers
@ -73,6 +74,13 @@ int KMailApplication::newInstance()
bool checkMail = false;
//bool viewOnly = false;
if (dcopClient()->isSuspended())
{
// Try again later.
QTimer::singleShot( 100, this, SLOT(newInstance()) );
return;
}
// process args:
KCmdLineArgs *args = KCmdLineArgs::parsedArgs();
if (args->getOption("subject"))

Loading…
Cancel
Save