1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82
|
/*
SPDX-FileCopyrightText: 2020 Harald Sitter <sitter@kde.org>
SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
*/
#ifndef SMBCDISCOVERER_H
#define SMBCDISCOVERER_H
#include <QObject>
#include "discovery.h"
#include "kio_smb.h"
class QEventLoop;
class SMBCDiscovery : public Discovery
{
public:
SMBCDiscovery(const UDSEntry &entry);
QString udsName() const override;
KIO::UDSEntry toEntry() const override;
protected:
UDSEntry m_entry;
private:
const QString m_name;
};
class SMBCDiscoverer : public QObject, public Discoverer
{
Q_OBJECT
public:
SMBCDiscoverer(const SMBUrl &url, QEventLoop *discoverNext, SMBWorker *worker);
~SMBCDiscoverer() override;
void start() override;
bool isFinished() const override;
bool dirWasRoot() const;
int error() const;
Q_SIGNALS:
void newDiscovery(Discovery::Ptr discovery) override;
void finished() override;
private Q_SLOTS:
/**
* Process one dirent, queue a new loop event and return.
* @see customEvent
* @see queue
*/
void discoverNext();
protected:
void customEvent(QEvent *event) override;
private:
void stop() override;
/**
* readdirplus2 based file_info looping
* @returns whether a file info was looped on
*/
bool discoverNextFileInfo();
/// init discoverer (calls opendir)
void init();
/// queue new loop run
inline void queue();
SMBUrl m_url;
QEventLoop *m_loop = nullptr;
SMBWorker *m_worker = nullptr;
bool m_finished = false;
int m_error = 0;
bool m_dirWasRoot = true;
int m_dirFd = -1;
};
#endif // SMBCDISCOVERER_H
|