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 83 84 85 86 87 88
|
/* This file is part of the KDE libraries
Copyright (c) 2000 Matthias Hoelzer-Kluepfel <mhk@caldera.de>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#ifndef __kio_man_h__
#define __kio_man_h__
#include <QBuffer>
#include <QTextStream>
#include <kio/global.h>
#include <kio/slavebase.h>
class MANProtocol : public QObject, public KIO::SlaveBase
{
Q_OBJECT
public:
MANProtocol(const QByteArray &pool_socket, const QByteArray &app_socket);
virtual ~MANProtocol();
virtual void get(const QUrl& url);
virtual void stat(const QUrl& url);
virtual void mimetype(const QUrl &url);
virtual void listDir(const QUrl &url);
void outputError(const QString& errmsg);
void outputMatchingPages(const QStringList &matchingPages);
void showMainIndex();
void showIndex(const QString& section);
// the following two functions are the interface to man2html
void output(const char *insert);
char *readManPage(const char *filename);
static MANProtocol *self();
private:
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);
private:
static MANProtocol *_self;
QByteArray lastdir;
void findManPagesInSection(const QString &dir, const QString &title, bool full_path, QStringList &list);
QStringList m_manpath; ///< Path of man directories
QStringList m_mandbpath; ///< Path of catman directories
QStringList section_names;
QString mySgml2RoffPath;
void getProgramPath();
QByteArray m_cssPath; ///< Path to KDE resources, encoded for CSS
QBuffer m_outputBuffer; ///< Buffer for the output
QByteArray m_manCSSFile; ///< Path to kio_man.css
};
#endif
|