]> git.lyx.org Git - features.git/commitdiff
bring lyxsocket to qt
authorAlfredo Braunstein <abraunst@lyx.org>
Wed, 5 Nov 2003 08:40:45 +0000 (08:40 +0000)
committerAlfredo Braunstein <abraunst@lyx.org>
Wed, 5 Nov 2003 08:40:45 +0000 (08:40 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@8038 a592a061-630c-0410-9148-cb99ea01b6c8

src/frontends/qt2/ChangeLog
src/frontends/qt2/Makefile.am
src/frontends/qt2/socket_callback.C [new file with mode: 0644]
src/frontends/qt2/socket_callback.h [new file with mode: 0644]

index 94a01dc9b6472e3c5aaf496b1b764d46f35743d9..71d7853c7bda4d6d8488fb2f84d53ad970796eae 100644 (file)
@@ -1,3 +1,9 @@
+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>
 
index 09c8d11eabe49611884799d0d9d06de0bf3d5887..f765ab638fc66975de7adbb7057f5b570d35d068 100644 (file)
@@ -72,6 +72,7 @@ libqt2_la_SOURCES = \
        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 \
diff --git a/src/frontends/qt2/socket_callback.C b/src/frontends/qt2/socket_callback.C
new file mode 100644 (file)
index 0000000..ab3f161
--- /dev/null
@@ -0,0 +1,43 @@
+/**
+ * \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_);
+}
diff --git a/src/frontends/qt2/socket_callback.h b/src/frontends/qt2/socket_callback.h
new file mode 100644 (file)
index 0000000..3821033
--- /dev/null
@@ -0,0 +1,50 @@
+// -*- 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