Commit 6ea17376 authored by Harald Sitter's avatar Harald Sitter 🏳️‍🌈
Browse files

smb: port to workerbase

parent 49bd4ee4
Pipeline #199771 passed with stage
in 2 minutes and 5 seconds
......@@ -4,7 +4,7 @@
<!ENTITY % addindex "IGNORE">
<!ENTITY % English "INCLUDE" > <!-- change language only here -->
]>
<article lang="&language;" id="smb">
<title>SMB</title>
<articleinfo>
......@@ -16,7 +16,7 @@
<releaseinfo>Applications 16.12</releaseinfo>
</articleinfo>
<para>
The smb ioslave enables you to browse the shares of a &Windows; (or Samba)
The smb worker enables you to browse the shares of a &Windows; (or Samba)
network.
</para>
......@@ -42,16 +42,16 @@ or
</para>
<para>
The smb ioslave requires that you have libsmbclient to use this ioslave.
The smb worker requires that you have libsmbclient to use this worker.
</para>
<para>
You can set your default user name and password in the &systemsettings;
You can set your default user name and password in the &systemsettings;
category <guilabel>Network</guilabel> in
<menuchoice><guisubmenu>Connectivity</guisubmenu><guimenuitem>
Windows Shares</guimenuitem></menuchoice>. This is especially useful if you are a
member of a &Windows; <acronym>NT</acronym> domain. There you can also set your
workgroup name, but in most cases this is not required. The kioslave will ask for your username and password if a default is not set.
workgroup name, but in most cases this is not required. The worker will ask for your username and password if a default is not set.
</para>
</article>
......
......@@ -66,8 +66,8 @@ target_sources(kio_smb_static PRIVATE
ecm_qt_declare_logging_category(kio_smb_static
HEADER smb-logsettings.h
IDENTIFIER KIO_SMB_LOG
CATEGORY_NAME kf.kio.slaves.smb
OLD_CATEGORY_NAMES log_kio_smb
CATEGORY_NAME kf.kio.workers.smb
OLD_CATEGORY_NAMES log_kio_smb kf.kio.slaves.smb
DESCRIPTION "KIO smb"
EXPORT KIO_EXTRAS
)
......
......@@ -79,18 +79,19 @@ private Q_SLOTS:
auto url = tmpUrl("noResumeButPartial/thing");
auto partUrl = tmpUrl("noResumeButPartial/thing.part");
auto resume = Transfer::shouldResume<QFileResumeIO>(url, KIO::JobFlags(), &worker);
QVERIFY(resume.has_value());
QCOMPARE(resume->resuming, false);
QCOMPARE(resume->destination, partUrl);
QCOMPARE(resume->completeDestination, url);
QCOMPARE(resume->partDestination, partUrl);
auto resumeVariant = Transfer::shouldResume<QFileResumeIO>(url, KIO::JobFlags(), &worker);
QVERIFY(std::holds_alternative<TransferContext>(resumeVariant));
auto resume = std::get<TransferContext>(resumeVariant);
QCOMPARE(resume.resuming, false);
QCOMPARE(resume.destination, partUrl);
QCOMPARE(resume.completeDestination, url);
QCOMPARE(resume.partDestination, partUrl);
QDir().mkdir(tmpPath("noResumeButPartial"));
QFile part(partUrl.toLocalFile());
QVERIFY(part.open(QFile::WriteOnly));
part.write("");
QCOMPARE(Transfer::concludeResumeHasError<QFileResumeIO>(false, resume.value(), &worker), false);
QVERIFY(Transfer::concludeResumeHasError<QFileResumeIO>(WorkerResult::pass(), resume, &worker).success());
QVERIFY(QFileInfo::exists(url.toLocalFile()));
QVERIFY(!QFileInfo::exists(partUrl.toLocalFile()));
}
......@@ -103,14 +104,15 @@ private Q_SLOTS:
auto url = tmpUrl("noResumeAndNoPartial/thing");
auto resume = Transfer::shouldResume<QFileResumeIO>(url, KIO::JobFlags(), &worker);
auto resumeVariant = Transfer::shouldResume<QFileResumeIO>(url, KIO::JobFlags(), &worker);
worker.debugErrors();
QVERIFY(resume.has_value());
QCOMPARE(resume->resuming, false);
QCOMPARE(resume->destination, url);
QCOMPARE(resume->completeDestination, url);
QCOMPARE(resume->partDestination, QUrl());
QCOMPARE(Transfer::concludeResumeHasError<QFileResumeIO>(false, resume.value(), &worker), false);
QVERIFY(std::holds_alternative<TransferContext>(resumeVariant));
auto resume = std::get<TransferContext>(resumeVariant);
QCOMPARE(resume.resuming, false);
QCOMPARE(resume.destination, url);
QCOMPARE(resume.completeDestination, url);
QCOMPARE(resume.partDestination, QUrl());
QVERIFY(Transfer::concludeResumeHasError<QFileResumeIO>(WorkerResult::pass(), resume, &worker).success());
}
void resume()
......@@ -119,14 +121,15 @@ private Q_SLOTS:
auto url = tmpUrl("resume/thing");
auto partUrl = tmpUrl("resume/thing.part");
auto resume = Transfer::shouldResume<QFileResumeIO>(url, KIO::JobFlags(), &worker);
QVERIFY(resume.has_value());
QCOMPARE(resume->resuming, true);
QCOMPARE(resume->destination, partUrl);
QCOMPARE(resume->completeDestination, url);
QCOMPARE(resume->partDestination, partUrl);
QCOMPARE(Transfer::concludeResumeHasError<QFileResumeIO>(false, resume.value(), &worker), false);
auto resumeVariant = Transfer::shouldResume<QFileResumeIO>(url, KIO::JobFlags(), &worker);
QVERIFY(std::holds_alternative<TransferContext>(resumeVariant));
auto resume = std::get<TransferContext>(resumeVariant);
QCOMPARE(resume.resuming, true);
QCOMPARE(resume.destination, partUrl);
QCOMPARE(resume.completeDestination, url);
QCOMPARE(resume.partDestination, partUrl);
QVERIFY(Transfer::concludeResumeHasError<QFileResumeIO>(WorkerResult::pass(), resume, &worker).success());
QVERIFY(QFileInfo::exists(url.toLocalFile()));
QVERIFY(!QFileInfo::exists(partUrl.toLocalFile()));
}
......@@ -136,14 +139,15 @@ private Q_SLOTS:
FakeWorker worker;
auto url = tmpUrl("resumeInPlace/thing");
auto resume = Transfer::shouldResume<QFileResumeIO>(url, KIO::Resume, &worker);
QVERIFY(resume.has_value());
QCOMPARE(resume->resuming, true);
QCOMPARE(resume->destination, url);
QCOMPARE(resume->completeDestination, url);
QCOMPARE(resume->partDestination, url);
QCOMPARE(Transfer::concludeResumeHasError<QFileResumeIO>(false, resume.value(), &worker), false);
auto resumeVariant = Transfer::shouldResume<QFileResumeIO>(url, KIO::Resume, &worker);
QVERIFY(std::holds_alternative<TransferContext>(resumeVariant));
auto resume = std::get<TransferContext>(resumeVariant);
QCOMPARE(resume.resuming, true);
QCOMPARE(resume.destination, url);
QCOMPARE(resume.completeDestination, url);
QCOMPARE(resume.partDestination, url);
QVERIFY(Transfer::concludeResumeHasError<QFileResumeIO>(WorkerResult::pass(), resume, &worker).success());
QVERIFY(QFileInfo::exists(url.toLocalFile()));
}
......@@ -152,10 +156,10 @@ private Q_SLOTS:
FakeWorker worker;
auto url = tmpUrl("resumeInPlace/thing"); // intentionally the same path this scenario errors out
auto resume = Transfer::shouldResume<QFileResumeIO>(url, KIO::JobFlags(), &worker);
QVERIFY(!resume.has_value());
QCOMPARE(worker.m_errors.size(), 1);
QCOMPARE(worker.m_errors.at(0).id, KIO::ERR_FILE_ALREADY_EXIST);
auto resumeVariant = Transfer::shouldResume<QFileResumeIO>(url, KIO::JobFlags(), &worker);
QVERIFY(std::holds_alternative<WorkerResult>(resumeVariant));
auto result = std::get<WorkerResult>(resumeVariant);
QCOMPARE(result.error(), KIO::ERR_FILE_ALREADY_EXIST);
}
};
......
......@@ -2,10 +2,10 @@
Type=Service
X-KDE-ServiceTypes=KDEDModule
X-KDE-Kded-autoload=true
# We need this module loaded all the time, lazy loading on slave use wouldn't
# be sufficient as the kdirnotify signal is already out by the time the slave
# We need this module loaded all the time, lazy loading on worker use wouldn't
# be sufficient as the kdirnotify signal is already out by the time the worker
# is initalized so the first opened dir wouldn't be watched then.
# It'd be better if we had a general monitor module that slaves can register
# It'd be better if we had a general monitor module that workers can register
# with. The monitor would then listen to kdirnotify and check the schemes
# to decide which watcher to load, and then simply forward the call to the watcher
# in-process. Would also save us from having to connect to dbus in every watcher.
......@@ -66,7 +66,7 @@ Comment[es]=Monitoriza cambios en directorios del protocolo smb:/
Comment[et]=smb:/ protokolli kaudu ühendatud kataloogide muutuste jälgimine
Comment[eu]=«smb:/» protokoloko direktorioak zelatatzen ditu aldaketa bila
Comment[fi]=Tarkkailee smb:/-yhteyskäytännön kansioiden muutoksia
Comment[fr]=Surveille les modifications pour les dossiers gérés par le protocole « smb:/ »
Comment[fr]=Surveille les modifications pour les dossiers gérés par le protocole « smb:/ »
Comment[hu]=Könyvtárak változásainak monitorozása az smb:/ protokollon
Comment[ia]=Il monitora le directorios pro variationes sur le protocollo smb:/
Comment[id]=Memantau direktori di protokol smb:/ terhadap perubahan
......
......@@ -21,7 +21,7 @@
#include <errno.h>
// Frontend implementation in place of slavebase
// Frontend implementation in place of workerbase
class Frontend : public SMBAbstractFrontend
{
KPasswdServerClient m_passwd;
......
......@@ -12,7 +12,7 @@
class KIOPluginForMetaData : public QObject
{
Q_OBJECT
Q_PLUGIN_METADATA(IID "org.kde.kio.slave.smb" FILE "smb.json")
Q_PLUGIN_METADATA(IID "org.kde.kio.worker.smb" FILE "smb.json")
};
bool needsEEXISTWorkaround()
......@@ -40,43 +40,21 @@ bool needsEEXISTWorkaround()
return false;
}
SMBSlave::SMBSlave(const QByteArray &pool, const QByteArray &app)
: SlaveBase("smb", pool, app)
SMBWorker::SMBWorker(const QByteArray &pool, const QByteArray &app)
: WorkerBase("smb", pool, app)
, m_openFd(-1)
, m_enableEEXISTWorkaround(needsEEXISTWorkaround())
{
}
SMBSlave::~SMBSlave() = default;
void SMBSlave::virtual_hook(int id, void *data)
{
switch (id) {
case SlaveBase::GetFileSystemFreeSpace: {
QUrl *url = static_cast<QUrl *>(data);
fileSystemFreeSpace(*url);
}
break;
case SlaveBase::Truncate: {
auto length = static_cast<KIO::filesize_t *>(data);
truncate(*length);
}
break;
default: {
SlaveBase::virtual_hook(id, data);
}
break;
}
}
SlaveFrontend::SlaveFrontend(SMBSlave &slave)
: m_slave(slave)
WorkerFrontend::WorkerFrontend(SMBWorker &worker)
: m_worker(worker)
{
}
bool SlaveFrontend::checkCachedAuthentication(AuthInfo &info)
bool WorkerFrontend::checkCachedAuthentication(AuthInfo &info)
{
return m_slave.checkCachedAuthentication(info);
return m_worker.checkCachedAuthentication(info);
}
#include "kio_smb.moc"
......@@ -16,7 +16,7 @@
// KF includes
//--------------
#include <KIO/Global>
#include <KIO/SlaveBase>
#include <KIO/WorkerBase>
//-----------------------------
// Standard C library includes
......@@ -56,24 +56,25 @@ extern "C" {
#include "smbcontext.h"
using namespace KIO;
class SMBSlave;
class SMBWorker;
class SlaveFrontend : public SMBAbstractFrontend
class WorkerFrontend : public SMBAbstractFrontend
{
public:
SlaveFrontend(SMBSlave &slave);
explicit WorkerFrontend(SMBWorker &worker);
bool checkCachedAuthentication(AuthInfo &info) override;
private:
SMBSlave &m_slave;
SMBWorker &m_worker;
};
class SMBSlave : public QObject, public KIO::SlaveBase
class SMBWorker : public QObject, public KIO::WorkerBase
{
Q_OBJECT
friend class SMBCDiscoverer;
friend class SMBResumeIO;
SlaveFrontend m_frontend { *this };
SMBContext m_context { new SMBAuthenticator(m_frontend) };
WorkerFrontend m_frontend { *this };
SMBContext m_context{new SMBAuthenticator(m_frontend)};
Q_DISABLE_COPY(SMBWorker)
private:
......@@ -184,66 +185,51 @@ protected:
*/
QUrl checkURL(const QUrl &kurl) const;
void reportError(const SMBUrl &url, const int errNum);
Q_REQUIRED_RESULT WorkerResult reportError(const SMBUrl &url, const int errNum);
void reportWarning(const SMBUrl &url, const int errNum);
public:
//-----------------------------------------------------------------------
// Overwritten functions from the base class that define the operation of
// this slave. (See the base class headerfile slavebase.h for more
// details)
//-----------------------------------------------------------------------
// Functions overwritten in kio_smb.cpp
SMBSlave(const QByteArray &pool, const QByteArray &app);
~SMBSlave() override;
SMBWorker(const QByteArray &pool, const QByteArray &app);
~SMBWorker() override = default;
// Functions overwritten in kio_smb_browse.cpp
void listDir(const QUrl &url) override;
void stat(const QUrl &url) override;
Q_REQUIRED_RESULT WorkerResult listDir(const QUrl &url) override;
Q_REQUIRED_RESULT WorkerResult stat(const QUrl &url) override;
// Functions overwritten in kio_smb_config.cpp
void reparseConfiguration() override;
// Functions overwritten in kio_smb_dir.cpp
void copy(const QUrl &src, const QUrl &dst, int permissions, KIO::JobFlags flags) override;
void del(const QUrl &kurl, bool isfile) override;
void mkdir(const QUrl &kurl, int permissions) override;
void rename(const QUrl &src, const QUrl &dest, KIO::JobFlags flags) override;
Q_REQUIRED_RESULT WorkerResult copy(const QUrl &src, const QUrl &dst, int permissions, KIO::JobFlags flags) override;
Q_REQUIRED_RESULT WorkerResult del(const QUrl &kurl, bool isfile) override;
Q_REQUIRED_RESULT WorkerResult mkdir(const QUrl &kurl, int permissions) override;
Q_REQUIRED_RESULT WorkerResult rename(const QUrl &src, const QUrl &dest, KIO::JobFlags flags) override;
// Functions overwritten in kio_smb_file.cpp
void get(const QUrl &kurl) override;
void put(const QUrl &kurl, int permissions, KIO::JobFlags flags) override;
void open(const QUrl &kurl, QIODevice::OpenMode mode) override;
void read(KIO::filesize_t bytesRequested) override;
void write(const QByteArray &fileData) override;
void seek(KIO::filesize_t offset) override;
void truncate(KIO::filesize_t length);
void close() override;
// Functions not implemented (yet)
// virtual void setHost(const QString& host, int port, const QString& user, const QString& pass);
// virtual void openConnection();
// virtual void closeConnection();
// virtual void slave_status();
void special(const QByteArray &) override;
protected:
void virtual_hook(int id, void *data) override;
Q_REQUIRED_RESULT WorkerResult get(const QUrl &kurl) override;
Q_REQUIRED_RESULT WorkerResult put(const QUrl &kurl, int permissions, KIO::JobFlags flags) override;
Q_REQUIRED_RESULT WorkerResult open(const QUrl &kurl, QIODevice::OpenMode mode) override;
Q_REQUIRED_RESULT WorkerResult read(KIO::filesize_t bytesRequested) override;
Q_REQUIRED_RESULT WorkerResult write(const QByteArray &fileData) override;
Q_REQUIRED_RESULT WorkerResult seek(KIO::filesize_t offset) override;
Q_REQUIRED_RESULT WorkerResult truncate(KIO::filesize_t size) override;
Q_REQUIRED_RESULT WorkerResult close() override;
Q_REQUIRED_RESULT WorkerResult fileSystemFreeSpace(const QUrl &url) override;
Q_REQUIRED_RESULT WorkerResult special(const QByteArray &) override;
private:
SMBError errnumToKioError(const SMBUrl &url, const int errNum);
void smbCopy(const QUrl &src, const QUrl &dst, int permissions, KIO::JobFlags flags);
void smbCopyGet(const QUrl &ksrc, const QUrl &kdst, int permissions, KIO::JobFlags flags);
void smbCopyPut(const QUrl &ksrc, const QUrl &kdst, int permissions, KIO::JobFlags flags);
Q_REQUIRED_RESULT WorkerResult smbCopy(const QUrl &src, const QUrl &dst, int permissions, KIO::JobFlags flags);
Q_REQUIRED_RESULT WorkerResult smbCopyGet(const QUrl &ksrc, const QUrl &kdst, int permissions, KIO::JobFlags flags);
Q_REQUIRED_RESULT WorkerResult smbCopyPut(const QUrl &ksrc, const QUrl &kdst, int permissions, KIO::JobFlags flags);
bool workaroundEEXIST(const int errNum) const;
int statToUDSEntry(const QUrl &url, const struct stat &st, KIO::UDSEntry &udsentry);
void fileSystemFreeSpace(const QUrl &url);
/**
* Used in open(), read(), write(), and close()
* FIXME Placing these in the private section above causes m_openUrl = kurl
* to fail in SMBSlave::open. Need to find out why this is.
* to fail in SMBWorker::open. Need to find out why this is.
*/
int m_openFd;
SMBUrl m_openUrl;
......@@ -288,7 +274,7 @@ private:
};
//===========================================================================
// Main slave entrypoint (see kio_smb.cpp)
// Main worker entrypoint (see kio_smb.cpp)
extern "C" {
int kdemain(int argc, char **argv);
}
......
......@@ -13,7 +13,7 @@
#include <KConfigGroup>
#include <KLocalizedString>
int SMBSlave::checkPassword(SMBUrl &url)
int SMBWorker::checkPassword(SMBUrl &url)
{
qCDebug(KIO_SMB_LOG) << "checkPassword for " << url;
......@@ -23,10 +23,12 @@ int SMBSlave::checkPassword(SMBUrl &url)
QString share = url.path();
int index = share.indexOf('/', 1);
if (index > 1)
if (index > 1) {
share = share.left(index);
if (share.at(0) == '/')
}
if (share.at(0) == '/') {
share = share.mid(1);
}
info.url.setPath('/' + share);
info.verifyPath = true;
info.keepPassword = true;
......@@ -44,20 +46,21 @@ int SMBSlave::checkPassword(SMBUrl &url)
"<para><placeholder>anonymous</placeholder>: Anonymous logins can be attempted using empty username and password. Depending on server configuration non-empty usernames may be required</para>"
));
if (share.isEmpty())
if (share.isEmpty()) {
info.prompt = i18n("<qt>Please enter authentication information for <b>%1</b></qt>", url.host());
else
} else {
info.prompt = i18n(
"Please enter authentication information for:\n"
"Server = %1\n"
"Share = %2",
url.host(),
share);
"Please enter authentication information for:\n"
"Server = %1\n"
"Share = %2",
url.host(),
share);
}
info.username = url.userName();
qCDebug(KIO_SMB_LOG) << "call openPasswordDialog for " << info.url;
const int passwordDialogErrorCode = openPasswordDialogV2(info);
const int passwordDialogErrorCode = openPasswordDialog(info);
if (passwordDialogErrorCode == KJob::NoError) {
qCDebug(KIO_SMB_LOG) << "openPasswordDialog returned " << info.username;
url.setUser(info.username);
......
/*
SPDX-License-Identifier: GPL-2.0-or-later
SPDX-FileCopyrightText: 2000 Caldera Systems Inc.
SPDX-FileCopyrightText: 2018-2021 Harald Sitter <sitter@kde.org>
SPDX-FileCopyrightText: 2018-2022 Harald Sitter <sitter@kde.org>
SPDX-FileContributor: Matthew Peterson <mpeterson@caldera.com>
*/
#include "kio_smb.h"
#include "smburl.h"
#include <utility>
#include <KDNSSD/RemoteService>
#include <KDNSSD/ServiceBrowser>
#include <KIO/Job>
......@@ -26,7 +28,7 @@
using namespace KIO;
int SMBSlave::cache_stat(const SMBUrl &url, struct stat *st)
int SMBWorker::cache_stat(const SMBUrl &url, struct stat *st)
{
int cacheStatErr = 0;
int result = smbc_stat(url.toSmbcUrl(), st);
......@@ -39,7 +41,7 @@ int SMBSlave::cache_stat(const SMBUrl &url, struct stat *st)
return cacheStatErr;
}
int SMBSlave::browse_stat_path(const SMBUrl &url, UDSEntry &udsentry)
int SMBWorker::browse_stat_path(const SMBUrl &url, UDSEntry &udsentry)
{
int cacheStatErr = cache_stat(url, &st);
if (cacheStatErr == 0) {
......@@ -49,7 +51,7 @@ int SMBSlave::browse_stat_path(const SMBUrl &url, UDSEntry &udsentry)
return cacheStatErr;
}
int SMBSlave::statToUDSEntry(const QUrl &url, const struct stat &st, KIO::UDSEntry &udsentry)
int SMBWorker::statToUDSEntry(const QUrl &url, const struct stat &st, KIO::UDSEntry &udsentry)
{
if (!S_ISDIR(st.st_mode) && !S_ISREG(st.st_mode)) {
qCDebug(KIO_SMB_LOG) << "mode: "<< st.st_mode;
......@@ -110,7 +112,7 @@ int SMBSlave::statToUDSEntry(const QUrl &url, const struct stat &st, KIO::UDSEnt
return 0;
}
void SMBSlave::stat(const QUrl &kurl)
WorkerResult SMBWorker::stat(const QUrl &kurl)
{
qCDebug(KIO_SMB_LOG) << kurl;
// make a valid URL
......@@ -120,8 +122,7 @@ void SMBSlave::stat(const QUrl &kurl)
if (url != kurl) {
qCDebug(KIO_SMB_LOG) << "redirection " << url;
redirection(url);
finished();
return;
return WorkerResult::pass();
}
m_current_url = url;
......@@ -132,20 +133,14 @@ void SMBSlave::stat(const QUrl &kurl)
switch (m_current_url.getType()) {
case SMBURLTYPE_UNKNOWN:
error(ERR_MALFORMED_URL, url.toDisplayString());
return;
return WorkerResult::fail(ERR_MALFORMED_URL, url.toDisplayString());
case SMBURLTYPE_PRINTER:
error(ERR_UNSUPPORTED_ACTION, url.toDisplayString());
return;
return WorkerResult::fail(ERR_UNSUPPORTED_ACTION, url.toDisplayString());
case SMBURLTYPE_ENTIRE_NETWORK:
case SMBURLTYPE_WORKGROUP_OR_SERVER:
udsentry.fastInsert(KIO::UDSEntry::UDS_FILE_TYPE, S_IFDIR);
statEntry(udsentry);
finished();
return;
return WorkerResult::pass();
case SMBURLTYPE_SHARE_OR_PATH: {
int ret = browse_stat_path(m_current_url, udsentry);
......@@ -155,35 +150,32 @@ void SMBSlave::stat(const QUrl &kurl)
const int passwordError = checkPassword(smbUrl);
if (passwordError == KJob::NoError) {
redirection(smbUrl);
finished();
} else if (passwordError == KIO::ERR_USER_CANCELED) {
reportError(url, ret);
} else {
error(passwordError, url.toString());
return WorkerResult::pass();
}
return;
} else if (ret != 0) {
if (passwordError == KIO::ERR_USER_CANCELED) {
return reportError(url, ret);
}
return WorkerResult::fail(passwordError, url.toString());
}
if (ret != 0) {
qCDebug(KIO_SMB_LOG) << "stat() error" << ret << url;
reportError(url, ret);
return;
return reportError(url, ret);
}
statEntry(udsentry);
finished();
return;
return WorkerResult::pass();
}
}
qCDebug(KIO_SMB_LOG) << "UNKNOWN " << url;
finished();
return WorkerResult::pass();
}
// TODO: complete checking <-- what does that even mean?
// TODO: why is this not part of SMBUrl or at the very least URL validation should
// be 100% shared between this and SMBUrl. Notably SMBUrl has code that looks
// to do a similar thing but is much less complete.
QUrl SMBSlave::checkURL(const QUrl &kurl_) const
QUrl SMBWorker::checkURL(const QUrl &kurl_) const
{
qCDebug(KIO_SMB_LOG) << "checkURL " << kurl_;
......@@ -262,23 +254,24 @@ QUrl SMBSlave::checkURL(const QUrl &kurl_) const
// if there's a valid host, don't have an empty path
QUrl url(kurl);
if (url.path().isEmpty())
if (url.path().isEmpty()) {
url.setPath("/");
}
qCDebug(KIO_SMB_LOG) << "checkURL return3 " << url;
return url;
}
SMBSlave::SMBError SMBSlave::errnumToKioError(const SMBUrl &url, const int errNum)
SMBWorker::SMBError SMBWorker::errnumToKioError(const SMBUrl &url, const int errNum)
{
qCDebug(KIO_SMB_LOG) << "errNum" << errNum;
switch (errNum) {
case ENOENT:
if (url.getType() == SMBURLTYPE_ENTIRE_NETWORK)
if (url.getType() == SMBURLTYPE_ENTIRE_NETWORK) {
return SMBError {ERR_WORKER_DEFINED, i18n("Unable to find any workgroups in your local network. This might be caused by an enabled firewall.")};
else
return SMBError {ERR_DOES_NOT_EXIST, url.toDisplayString()};
}
return SMBError {ERR_DOES_NOT_EXIST, url.toDisplayString()};
#ifdef ENOMEDIUM