2002-07-14 02:04:19 +00:00
|
|
|
/**
|
|
|
|
* \file io_callback.h
|
|
|
|
* Copyright 2002 the LyX Team
|
|
|
|
* Read the file COPYING
|
|
|
|
*
|
|
|
|
* \author unknown
|
|
|
|
* \author John Levon <moz@compsoc.man.ac.uk>
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef IO_CALLBACK_H
|
|
|
|
#define IO_CALLBACK_H
|
|
|
|
|
|
|
|
#include <config.h>
|
|
|
|
|
|
|
|
#include "lyxserver.h"
|
2002-07-31 04:33:03 +00:00
|
|
|
#include "debug.h"
|
2002-07-14 02:04:19 +00:00
|
|
|
|
|
|
|
#include <qsocketnotifier.h>
|
|
|
|
|
2002-07-31 04:33:03 +00:00
|
|
|
#include <boost/scoped_ptr.hpp>
|
|
|
|
|
2002-07-30 00:53:57 +00:00
|
|
|
/**
|
|
|
|
* io_callback - a simple wrapper for asynchronous pipe notification
|
|
|
|
*
|
|
|
|
* This is used by the lyxserver to notice the pipe is ready to be
|
|
|
|
* read.
|
|
|
|
*
|
|
|
|
* FIXME: this code apparently will not work on Windows.
|
|
|
|
*/
|
2002-07-14 02:04:19 +00:00
|
|
|
class io_callback : public QObject {
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
2002-07-30 00:53:57 +00:00
|
|
|
/// connect a read ready notification for fd to the LyXComm
|
2002-07-14 02:04:19 +00:00
|
|
|
io_callback(int fd, LyXComm * comm)
|
|
|
|
: comm_(comm) {
|
2002-07-31 04:33:03 +00:00
|
|
|
sn_.reset(new QSocketNotifier(fd, QSocketNotifier::Read, this));
|
|
|
|
connect(sn_.get(), SIGNAL(activated(int)), this, SLOT(data_received()));
|
2002-07-14 02:04:19 +00:00
|
|
|
}
|
2002-07-31 04:33:03 +00:00
|
|
|
|
2002-07-14 02:04:19 +00:00
|
|
|
public slots:
|
|
|
|
void data_received() {
|
|
|
|
comm_->read_ready();
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
2002-07-31 04:33:03 +00:00
|
|
|
/// our notifier
|
|
|
|
boost::scoped_ptr<QSocketNotifier> sn_;
|
|
|
|
|
2002-07-14 02:04:19 +00:00
|
|
|
LyXComm * comm_;
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif // IO_CALLBACK_H
|