From dd98e0dfe644a3a46cfc974551f3e2b312be4109 Mon Sep 17 00:00:00 2001 From: Ivailo Monev Date: Sat, 6 Dec 2014 20:43:49 +0000 Subject: [PATCH] imrpve (somewhat) shareplugin error reporting and use (somewhat) standard path with /sbin to find smbd (dirty) --- .../filepropertiesplugin/sambausershareplugin.cpp | 60 ++++++++++++++++++++-- 1 file changed, 56 insertions(+), 4 deletions(-) diff --git a/kdenetwork-filesharing/samba/filepropertiesplugin/sambausershareplugin.cpp b/kdenetwork-filesharing/samba/filepropertiesplugin/sambausershareplugin.cpp index 97b756db..b4c4a703 100644 --- a/kdenetwork-filesharing/samba/filepropertiesplugin/sambausershareplugin.cpp +++ b/kdenetwork-filesharing/samba/filepropertiesplugin/sambausershareplugin.cpp @@ -63,7 +63,9 @@ SambaUserSharePlugin::SambaUserSharePlugin(QObject *parent, const QListaddPage(vbox, i18n("&Share")); properties->setFileSharingPage(vbox); - if (KStandardDirs::findExe("smbd").isEmpty()) { + // smbd is usually found as /usr/sbin/smbd + QString exePath = "/usr/sbin:/usr/bin:/sbin:/bin"; + if (KStandardDirs::findExe("smbd", exePath).isEmpty()) { QWidget *widget = new QWidget(vbox); QVBoxLayout *vLayout = new QVBoxLayout(widget); @@ -160,10 +162,60 @@ void SambaUserSharePlugin::applyChanges() result = shareData.remove(); } -#warning "Improve error reporting" - if (!result == KSambaShareData::UserShareOk) { +#warning "the error reporting could use some love" + // Some error types that do not apply but may in the future: + // UserSharePathNotDirectory + if (result == KSambaShareData::UserShareExceedMaxShares) { KMessageBox::sorry(qobject_cast(this), - i18n("The action did not successed.")); + i18n("Maximum shared exceeded.")); + } else if (result == KSambaShareData::UserShareNameInvalid) { + // Is that even supposed to happend? + KMessageBox::sorry(qobject_cast(this), + i18n("The username for sharing is invalid.")); + } else if (result == KSambaShareData::UserShareNameInUse) { + // Is that even supposed to happend? + KMessageBox::sorry(qobject_cast(this), + i18n("The username for sharing is already in use.")); + } else if (result == KSambaShareData::UserSharePathInvalid) { + // Is that even supposed to happend? + KMessageBox::sorry(qobject_cast(this), + i18n("The path chosen is invalid.")); + } else if (result == KSambaShareData::UserSharePathNotExists) { + // The path can be gone all of a sudden + KMessageBox::sorry(qobject_cast(this), + i18n("The path chosen does not exists.")); + } else if (result == KSambaShareData::UserSharePathNotAbsolute) { + // Is that even supposed to happend? + KMessageBox::sorry(qobject_cast(this), + i18n("The path chosen is not absolute.")); + } else if (result == KSambaShareData::UserSharePathNotAllowed) { + // Not allowed, ok + KMessageBox::sorry(qobject_cast(this), + i18n("The path chosen is not allowed.")); + } else if (result == KSambaShareData::UserShareAclInvalid) { + // Invalid ACL? + KMessageBox::sorry(qobject_cast(this), + i18n("Invalid Advanced Control List (ACL).")); + } else if (result == KSambaShareData::UserShareAclUserNotValid) { + // Invalid ACL? + KMessageBox::sorry(qobject_cast(this), + i18n("Invalid user in Advanced Control List (ACL).")); + } else if (result == KSambaShareData::UserShareGuestsInvalid) { + // Invalid ACL? + KMessageBox::sorry(qobject_cast(this), + i18n("Invalid guest user.")); + } else if (result == KSambaShareData::UserShareGuestsNotAllowed) { + // Guest not allowed, ok + KMessageBox::sorry(qobject_cast(this), + i18n("Guest user not allowed.")); + } else if (result == KSambaShareData::UserShareSystemError) { + // Something strange happened, Bob + KMessageBox::sorry(qobject_cast(this), + i18n("System error.")); + } else if (!result == KSambaShareData::UserShareOk) { + // Something strange happened, Bob + KMessageBox::sorry(qobject_cast(this), + i18n("Unexpected error occurred.")); } } -- 2.11.0