Improve error reporting in KMFolderMaildir::canAccess(). Based on patch by

Falco Hirschenberger (hirsch bigfoot de).
CCMAIL: 81342-done@bugs.kde.org

svn path=/trunk/kdepim/; revision=321881
wilder-work
David Faure 22 years ago
parent cc88abe4a2
commit fba1acf88b
  1. 41
      kmfoldermaildir.cpp

@ -66,17 +66,29 @@ int KMFolderMaildir::canAccess()
assert(!folder()->name().isEmpty());
if (access(QFile::encodeName(location()), R_OK | W_OK | X_OK) != 0)
return 1;
if (access(QFile::encodeName(location() + "/new"), R_OK | W_OK | X_OK) != 0)
return 1;
if (access(QFile::encodeName(location() + "/cur"), R_OK | W_OK | X_OK) != 0)
return 1;
QString sBadFolderName;
if (access(QFile::encodeName(location()), R_OK | W_OK | X_OK) != 0) {
sBadFolderName = location();
} else if (access(QFile::encodeName(location() + "/new"), R_OK | W_OK | X_OK) != 0) {
sBadFolderName = location() + "/new";
} else if (access(QFile::encodeName(location() + "/cur"), R_OK | W_OK | X_OK) != 0) {
sBadFolderName = location() + "/cur";
} else if (access(QFile::encodeName(location() + "/tmp"), R_OK | W_OK | X_OK) != 0) {
sBadFolderName = location() + "/tmp";
}
if (access(QFile::encodeName(location() + "/tmp"), R_OK | W_OK | X_OK) != 0)
return 1;
if ( !sBadFolderName.isEmpty() ) {
int nRetVal = QFile::exists(sBadFolderName) ? EPERM : ENOENT;
KCursorSaver idle(KBusyPtr::idle());
if ( nRetVal == ENOENT )
KMessageBox::sorry(0, i18n("Error opening %1; this folder is missing.")
.arg(sBadFolderName));
else
KMessageBox::sorry(0, i18n("Error opening %1; either this is not a valid "
"maildir folder, you do not have sufficient access permissions.")
.arg(sBadFolderName));
return nRetVal;
}
return 0;
}
@ -93,12 +105,9 @@ int KMFolderMaildir::open()
assert(!folder()->name().isEmpty());
if (canAccess() != 0) {
KCursorSaver idle(KBusyPtr::idle());
KMessageBox::sorry(0, i18n("Error opening %1; either this is not a valid "
"maildir folder or you do not have sufficient access permissions.")
.arg(name()));
return EPERM;
rc = canAccess();
if ( rc != 0 ) {
return rc;
}
if (!folder()->path().isEmpty())

Loading…
Cancel
Save