+2003-11-05 João Luis M. Assirati <assirati@fma.if.usp.br>
+
+ * socket_callback.[Ch] ({set,remove}_{server,data}socket_callback()):
+ new files with a class to connect sockets.
+
+ * Makefile.am: add the above
2003-11-04 Alfredo Braunstein <abraunst@libero.it>
lyx_gui.C \
lcolorcache.h lcolorcache.C \
panelstack.h panelstack.C \
+ socket_callback.C socket_callback.h \
qcoloritem.h qcoloritem.C \
qfontexample.h qfontexample.C \
qfont_loader.h qfont_loader.C \
--- /dev/null
+/**
+ * \file io_callback.C
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
+ *
+ * \author unknown
+ * \author John Levon
+ * \author João Luis M. Assirati
+ *
+ * Full author contact details are available in file CREDITS.
+ */
+
+#include <config.h>
+
+
+#include "lyxsocket.h"
+#include "socket_callback.h"
+
+
+socket_callback::socket_callback(LyXServerSocket * server)
+ : server_(server)
+{
+ sn_.reset(new QSocketNotifier(server->fd(), QSocketNotifier::Read, this));
+ connect(sn_.get(), SIGNAL(activated(int)), this, SLOT(server_received()));
+}
+
+socket_callback::socket_callback(LyXDataSocket * data)
+ : data_(data)
+{
+ sn_.reset(new QSocketNotifier(data->fd(), QSocketNotifier::Read, this));
+ connect(sn_.get(), SIGNAL(activated(int)), this, SLOT(data_received()));
+}
+
+
+void socket_callback::server_received()
+{
+ server_->serverCallback();
+}
+
+void socket_callback::data_received()
+{
+ data_->server()->dataCallback(data_);
+}
--- /dev/null
+// -*- C++ -*-
+/**
+ * \file io_callback.h
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
+ *
+ * \author unknown
+ * \author John Levon
+ * \author João Luis M. Assirati
+ *
+ * Full author contact details are available in file CREDITS.
+ */
+
+#ifndef SOCKET_CALLBACK_H
+#define SOCKET_CALLBACK_H
+
+
+#include <qobject.h>
+#include <qsocketnotifier.h>
+#include <boost/scoped_ptr.hpp>
+
+class LyXServerSocket;
+class LyXDataSocket;
+
+/**
+ * socket_callback - a simple wrapper for asynchronous socket notification
+ *
+ * This is used by the lyxsocket to notice the socket is ready to be
+ * connected/read.
+ *
+ * FIXME: this code apparently will not work on Windows.
+ */
+class socket_callback : public QObject {
+ Q_OBJECT
+public:
+ /// connect a connection notification from the LyXServerSocket
+ socket_callback(LyXServerSocket * server);
+ socket_callback(LyXDataSocket * data);
+public slots:
+ void server_received();
+ void data_received();
+private:
+ /// our notifier
+ boost::scoped_ptr<QSocketNotifier> sn_;
+
+ LyXServerSocket * server_;
+ LyXDataSocket * data_;
+};
+
+#endif // SOCKET_CALLBACK_H