File: smbcdiscoverer.h

package info (click to toggle)
kio-extras 4%3A25.04.2-1
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 31,928 kB
  • sloc: cpp: 28,852; ansic: 3,084; perl: 1,048; xml: 116; sh: 92; python: 28; makefile: 9
file content (82 lines) | stat: -rw-r--r-- 1,674 bytes parent folder | download | duplicates (2)
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