File: kio_man.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 (72 lines) | stat: -rw-r--r-- 2,198 bytes parent folder | download
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
/*  This file is part of the KDE libraries
    SPDX-FileCopyrightText: 2000 Matthias Hoelzer-Kluepfel <mhk@caldera.de>


    SPDX-License-Identifier: LGPL-2.0-or-later
*/
#ifndef __kio_man_h__
#define __kio_man_h__

#include <QBuffer>

#include <KIO/Global>
#include <KIO/WorkerBase>

class MANProtocol : public QObject, public KIO::WorkerBase
{
    Q_OBJECT

public:
    explicit MANProtocol(const QByteArray &pool_socket, const QByteArray &app_socket);
    ~MANProtocol() override;

    KIO::WorkerResult get(const QUrl &url) override;
    KIO::WorkerResult stat(const QUrl &url) override;

    KIO::WorkerResult mimetype(const QUrl &url) override;
    KIO::WorkerResult listDir(const QUrl &url) override;

    // the following two functions are the interface to man2html
    void output(const char *insert);
    char *readManPage(const char *filename);

    static MANProtocol *self();

    void showIndex(const QString &section);

private:
    void outputError(const QString &errmsg);
    void outputMatchingPages(const QStringList &matchingPages);

    void showMainIndex();

    void checkManPaths();
    QStringList manDirectories();
    QMap<QString, QString> buildIndexMap(const QString &section);
    bool addWhatIs(QMap<QString, QString> &i, const QString &f, const QString &mark);
    void parseWhatIs(QMap<QString, QString> &i, QTextStream &t, const QString &mark);
    QStringList findPages(const QString &section, const QString &title, bool full_path = true);

    QStringList buildSectionList(const QStringList &dirs) const;
    void constructPath(QStringList &constr_path, QStringList constr_catmanpath);
    QStringList findManPagesInSection(const QString &dir, const QString &title, bool full_path);

    void outputHeader(QTextStream &os, const QString &header, const QString &title = QString());
    void outputFooter(QTextStream &os);

    bool getProgramPath();

private:
    static MANProtocol *s_self;
    QByteArray lastdir;

    QStringList m_manpath; ///< Path of man directories
    QStringList m_mandbpath; ///< Path of catman directories
    QStringList m_sectionNames;

    QString mySgml2RoffPath;

    QBuffer m_outputBuffer; ///< Buffer for the output
};

#endif