[EMAIL PROTECTED] (Lars Gullik Bjønnes) writes:

| The changes I did with lyxsocket, can very well be used by the
| lyxserver as well.
>
| This patch does that.
>
| So far only compiled on xforms, will test qt as well before
| committing... I might skip on gtk.

Updated a bit.

? Config
? counter-2.diff
? counter-3.diff
? counter.diff
? deptherror.diff
? deptherror.lyx
? dispatch-2.diff
? dispatch-3.diff
? dispatch-4.diff
? distcheck-2.diff
? distcheck.diff
? end.lyx
? kystskipper-a-1.lyx
? lyxserver-1.diff
? lyxserver-2.diff
? morectrs.lyx
? refenum.lyx
? unneeded.diff
Index: src/lyxserver.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/lyxserver.C,v
retrieving revision 1.56
diff -u -p -r1.56 lyxserver.C
--- src/lyxserver.C	13 Oct 2003 00:38:07 -0000	1.56
+++ src/lyxserver.C	21 Jul 2004 19:58:06 -0000
@@ -48,6 +48,8 @@
 #include "support/lyxlib.h"
 #include "frontends/lyx_gui.h"
 
+#include <boost/bind.hpp>
+
 #include <cerrno>
 #include <sys/stat.h>
 #include <fcntl.h>
@@ -205,7 +207,7 @@ int LyXComm::startPipe(string const & fi
 	}
 
 	if (!write) {
-		lyx_gui::set_read_callback(fd, this);
+		lyx_gui::register_socket_callback(fd, boost::bind(&LyXComm::read_ready, *this));
 	}
 
 	return fd;
@@ -218,7 +220,7 @@ void LyXComm::endPipe(int & fd, string c
 		return;
 
 	if (!write) {
-		lyx_gui::remove_read_callback(fd);
+		lyx_gui::unregister_socket_callback(fd);
 	}
 
 #ifdef __EMX__
Index: src/frontends/lyx_gui.h
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/lyx_gui.h,v
retrieving revision 1.25
diff -u -p -r1.25 lyx_gui.h
--- src/frontends/lyx_gui.h	21 Jul 2004 19:03:20 -0000	1.25
+++ src/frontends/lyx_gui.h	21 Jul 2004 19:58:06 -0000
@@ -95,16 +95,15 @@ void update_fonts();
 bool font_available(LyXFont const & font);
 
 /**
- * add a callback for I/O read notification
+ * add a callback for socket read notification
+ * @param fd socket descriptor (file/socket/etc)
  */
-void set_read_callback(int fd, LyXComm * comm);
 void register_socket_callback(int fd, boost::function<void()> func);
 
 /**
  * remove a I/O read callback
- * @param fd file descriptor
+ * @param fd socket descriptor (file/socket/etc)
  */
-void remove_read_callback(int fd);
 void unregister_socket_callback(int fd);
 
 } // namespace lyx_gui
Index: src/frontends/gtk/lyx_gui.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/gtk/lyx_gui.C,v
retrieving revision 1.16
diff -u -p -r1.16 lyx_gui.C
--- src/frontends/gtk/lyx_gui.C	21 Jul 2004 19:03:20 -0000	1.16
+++ src/frontends/gtk/lyx_gui.C	21 Jul 2004 19:58:06 -0000
@@ -415,41 +415,26 @@ bool lyx_gui::font_available(LyXFont con
 namespace {
 
 
-bool readCallback(Glib::IOCondition /*condition*/, LyXComm * comm)
-{
-	comm->read_ready();
-	return true;
-}
-
+std::map<int, SigC::Connection> gSocketCallbackMap;
 
-std::map<int, SigC::Connection> gReadCallbackMap;
-
-}
+} // NS anon
 
 
-void lyx_gui::set_read_callback(int fd, LyXComm * comm)
+void lyx_gui::register_socket_callback(int fd,
+				       boost::function<void()> func)
 {
-	gReadCallbackMap[fd] = Glib::signal_io().connect(
-		SigC::bind(SigC::slot(readCallback), comm),
+	gSocketCallbackMap[fd] = Glib::signal_io().connect(
+		SigC::bind(SigC::slot(func)),
 		fd,
 		Glib::IO_IN);
 }
 
 
-void lyx_gui::remove_read_callback(int fd)
+void lyx_gui::unregister_socket_callback(int fd)
 {
-	gReadCallbackMap[fd].disconnect();
-	gReadCallbackMap.erase(fd);
+	gSocketCallbackMap[fd].disconnect();
+	gSocketCallbackMap.erase(fd);
 }
-
-
-void lyx_gui::register_socket_callback(int /*fd*/,
-				       boost::function<void()> /*func*/)
-{}
-
-
-void lyx_gui::unregister_socket_callback(int /*fd*/)
-{}
 
 
 string const lyx_gui::roman_font_name()
Index: src/frontends/qt2/Makefile.dialogs
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/qt2/Makefile.dialogs,v
retrieving revision 1.52
diff -u -p -r1.52 Makefile.dialogs
--- src/frontends/qt2/Makefile.dialogs	31 Mar 2004 22:09:51 -0000	1.52
+++ src/frontends/qt2/Makefile.dialogs	21 Jul 2004 19:58:06 -0000
@@ -74,7 +74,6 @@ MOCFILES = \
 	FileDialog_private.C FileDialog_private.h \
 	floatplacement.C floatplacement.h \
 	iconpalette.C iconpalette.h \
-	io_callback.C io_callback.h \
 	lengthcombo.C lengthcombo.h \
 	panelstack.C panelstack.h \
 	QAboutDialog.C QAboutDialog.h \
Index: src/frontends/qt2/io_callback.C
===================================================================
RCS file: src/frontends/qt2/io_callback.C
diff -N src/frontends/qt2/io_callback.C
--- src/frontends/qt2/io_callback.C	20 May 2004 09:36:28 -0000	1.5
+++ /dev/null	1 Jan 1970 00:00:00 -0000
@@ -1,30 +0,0 @@
-/**
- * \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
- *
- * Full author contact details are available in file CREDITS.
- */
-
-#include <config.h>
-
-// Qt defines a macro 'signals' that clashes with a boost namespace.
-#include "lyxserver.h"
-
-#include "io_callback.h"
-
-io_callback::io_callback(int fd, LyXComm * comm)
-	: comm_(comm)
-{
-	sn_.reset(new QSocketNotifier(fd, QSocketNotifier::Read, this));
-	connect(sn_.get(), SIGNAL(activated(int)), this, SLOT(data_received()));
-}
-
-
-void io_callback::data_received()
-{
-	comm_->read_ready();
-}
Index: src/frontends/qt2/io_callback.h
===================================================================
RCS file: src/frontends/qt2/io_callback.h
diff -N src/frontends/qt2/io_callback.h
--- src/frontends/qt2/io_callback.h	23 Aug 2003 00:16:39 -0000	1.7
+++ /dev/null	1 Jan 1970 00:00:00 -0000
@@ -1,45 +0,0 @@
-// -*- 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
- *
- * Full author contact details are available in file CREDITS.
- */
-
-#ifndef IO_CALLBACK_H
-#define IO_CALLBACK_H
-
-
-#include <qobject.h>
-#include <qsocketnotifier.h>
-#include <boost/scoped_ptr.hpp>
-
-class LyXComm;
-
-/**
- * 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.
- */
-class io_callback : public QObject {
-	Q_OBJECT
-public:
-	/// connect a read ready notification for fd to the LyXComm
-	io_callback(int fd, LyXComm * comm);
-public slots:
-	void data_received();
-private:
-	/// our notifier
-	boost::scoped_ptr<QSocketNotifier> sn_;
-
-	LyXComm * comm_;
-};
-
-#endif // IO_CALLBACK_H
Index: src/frontends/qt2/lyx_gui.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/qt2/lyx_gui.C,v
retrieving revision 1.67
diff -u -p -r1.67 lyx_gui.C
--- src/frontends/qt2/lyx_gui.C	21 Jul 2004 19:03:20 -0000	1.67
+++ src/frontends/qt2/lyx_gui.C	21 Jul 2004 19:58:06 -0000
@@ -38,7 +38,6 @@
 #include <boost/shared_ptr.hpp>
 
 #include "QtView.h"
-#include "io_callback.h"
 #include "lcolorcache.h"
 #include "qfont_loader.h"
 #include "QLImage.h"
@@ -80,7 +79,6 @@ float getDPI()
 	return 0.5 * (pdm.logicalDpiX() + pdm.logicalDpiY());
 }
 
-map<int, io_callback *> io_callbacks;
 map<int, shared_ptr<socket_callback> > socket_callbacks;
 
 } // namespace anon
@@ -285,22 +283,6 @@ void update_fonts()
 bool font_available(LyXFont const & font)
 {
 	return fontloader.available(font);
-}
-
-
-void set_read_callback(int fd, LyXComm * comm)
-{
-	io_callbacks[fd] = new io_callback(fd, comm);
-}
-
-
-void remove_read_callback(int fd)
-{
-	map<int, io_callback *>::iterator it = io_callbacks.find(fd);
-	if (it != io_callbacks.end()) {
-		delete it->second;
-		io_callbacks.erase(it);
-	}
 }
 
 
Index: src/frontends/xforms/lyx_gui.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/xforms/lyx_gui.C,v
retrieving revision 1.60
diff -u -p -r1.60 lyx_gui.C
--- src/frontends/xforms/lyx_gui.C	21 Jul 2004 19:03:21 -0000	1.60
+++ src/frontends/xforms/lyx_gui.C	21 Jul 2004 19:58:06 -0000
@@ -388,28 +388,6 @@ bool font_available(LyXFont const & font
 	return fontloader.available(font);
 }
 
-namespace {
-
-extern "C"
-void C_read_callback(int, void * data)
-{
-	LyXComm * comm = static_cast<LyXComm *>(data);
-	comm->read_ready();
-}
-
-}
-
-
-void set_read_callback(int fd, LyXComm * comm)
-{
-	fl_add_io_callback(fd, FL_READ, C_read_callback, comm);
-}
-
-void remove_read_callback(int fd)
-{
-	fl_remove_io_callback(fd, FL_READ, C_read_callback);
-}
-
 
 namespace {
 
-- 
        Lgb

Reply via email to