File indexing completed on 2024-04-21 15:55:40

0001 /***************************************************************************
0002     begin                : Sat Sept 9 2003
0003     copyright            : (C) 2003 by Jeroen Wijnhout
0004     email                : Jeroen.Wijnhout@kdemail.net
0005  ***************************************************************************/
0006 
0007 /***************************************************************************
0008  *                                                                         *
0009  *   This program is free software; you can redistribute it and/or modify  *
0010  *   it under the terms of the GNU General Public License as published by  *
0011  *   the Free Software Foundation; either version 2 of the License, or     *
0012  *   (at your option) any later version.                                   *
0013  *                                                                         *
0014  ***************************************************************************/
0015 
0016 #ifndef _LYXSERVER_H_
0017 #define _LYXSERVER_H_
0018 
0019 #ifdef HAVE_CONFIG_H
0020 #include <config.h>
0021 #endif
0022 
0023 
0024 #include <QHash>
0025 #include <QList>
0026 #include <QObject>
0027 #include <QStringList>
0028 
0029 #include <QTemporaryDir>
0030 
0031 #include <sys/types.h>
0032 
0033 #ifdef _MSC_VER
0034 typedef int mode_t;
0035 #endif
0036 
0037 /**
0038  * @short Simple server that impersonates as LyX to work with gBib, pyBibliographer etc.
0039  * @author Jeroen Wijnhout <Jeroen.Wijnhout@kdemail.net>
0040  * @author Thomas Braun
0041  * @version 0.2
0042  */
0043 
0044 class QFile;
0045 class QSocketNotifier;
0046 namespace KileAction {
0047 class TagData;
0048 }
0049 
0050 class KileLyxServer : public QObject
0051 {
0052     Q_OBJECT
0053 
0054 public:
0055     explicit KileLyxServer(bool start = true);
0056     ~KileLyxServer();
0057 
0058     bool isRunning() {
0059         return m_running;
0060     }
0061 
0062 public Q_SLOTS:
0063     bool start();
0064     void stop();
0065 
0066 private Q_SLOTS:
0067     void receive(int);
0068 
0069 private:
0070     bool openPipes();
0071     void removePipes();
0072     void processLine(const QString &);
0073 
0074 Q_SIGNALS:
0075     void insert(const KileAction::TagData &);
0076 
0077 private:
0078     mode_t              m_perms;
0079     QTemporaryDir           *m_tempDir;
0080     QList<QFile*>           m_pipeIn;
0081     QList<QSocketNotifier*>     m_notifier;
0082     QHash<int, QFile*>      m_file;
0083     bool                m_running;
0084     QStringList             m_links,m_pipes;
0085 };
0086 
0087 #endif // _LYXSERVER_H_