mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-27 14:29:21 +00:00
rename LyXServer into Server
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@18092 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
32f444d6d6
commit
d079c908b3
@ -16,7 +16,7 @@
|
|||||||
#include "LyXRC.h"
|
#include "LyXRC.h"
|
||||||
#include "debug.h"
|
#include "debug.h"
|
||||||
#include "gettext.h"
|
#include "gettext.h"
|
||||||
#include "LyXServerSocket.h"
|
#include "ServerSocket.h"
|
||||||
|
|
||||||
#include "frontends/Application.h"
|
#include "frontends/Application.h"
|
||||||
#include "frontends/alert.h" //to be removed?
|
#include "frontends/alert.h" //to be removed?
|
||||||
@ -314,7 +314,7 @@ bool Formats::view(Buffer const & buffer, FileName const & filename,
|
|||||||
|
|
||||||
command = subst(command, token_from_format, quoteName(filename.toFilesystemEncoding()));
|
command = subst(command, token_from_format, quoteName(filename.toFilesystemEncoding()));
|
||||||
command = subst(command, token_path_format, quoteName(onlyPath(filename.toFilesystemEncoding())));
|
command = subst(command, token_path_format, quoteName(onlyPath(filename.toFilesystemEncoding())));
|
||||||
command = subst(command, token_socket_format, quoteName(theLyXServerSocket().address()));
|
command = subst(command, token_socket_format, quoteName(theServerSocket().address()));
|
||||||
LYXERR(Debug::FILES) << "Executing command: " << command << std::endl;
|
LYXERR(Debug::FILES) << "Executing command: " << command << std::endl;
|
||||||
// FIXME UNICODE utf8 can be wrong for files
|
// FIXME UNICODE utf8 can be wrong for files
|
||||||
buffer.message(_("Executing command: ") + from_utf8(command));
|
buffer.message(_("Executing command: ") + from_utf8(command));
|
||||||
@ -373,7 +373,7 @@ bool Formats::edit(Buffer const & buffer, FileName const & filename,
|
|||||||
|
|
||||||
command = subst(command, token_from_format, quoteName(filename.toFilesystemEncoding()));
|
command = subst(command, token_from_format, quoteName(filename.toFilesystemEncoding()));
|
||||||
command = subst(command, token_path_format, quoteName(onlyPath(filename.toFilesystemEncoding())));
|
command = subst(command, token_path_format, quoteName(onlyPath(filename.toFilesystemEncoding())));
|
||||||
command = subst(command, token_socket_format, quoteName(theLyXServerSocket().address()));
|
command = subst(command, token_socket_format, quoteName(theServerSocket().address()));
|
||||||
LYXERR(Debug::FILES) << "Executing command: " << command << std::endl;
|
LYXERR(Debug::FILES) << "Executing command: " << command << std::endl;
|
||||||
// FIXME UNICODE utf8 can be wrong for files
|
// FIXME UNICODE utf8 can be wrong for files
|
||||||
buffer.message(_("Executing command: ") + from_utf8(command));
|
buffer.message(_("Executing command: ") + from_utf8(command));
|
||||||
|
24
src/LyX.cpp
24
src/LyX.cpp
@ -36,8 +36,8 @@
|
|||||||
#include "LyXFunc.h"
|
#include "LyXFunc.h"
|
||||||
#include "Lexer.h"
|
#include "Lexer.h"
|
||||||
#include "LyXRC.h"
|
#include "LyXRC.h"
|
||||||
#include "LyXServer.h"
|
#include "Server.h"
|
||||||
#include "LyXServerSocket.h"
|
#include "ServerSocket.h"
|
||||||
#include "LyXTextClassList.h"
|
#include "LyXTextClassList.h"
|
||||||
#include "MenuBackend.h"
|
#include "MenuBackend.h"
|
||||||
#include "Messages.h"
|
#include "Messages.h"
|
||||||
@ -163,9 +163,9 @@ struct LyX::Singletons
|
|||||||
///
|
///
|
||||||
boost::scoped_ptr<KeyMap> toplevel_keymap_;
|
boost::scoped_ptr<KeyMap> toplevel_keymap_;
|
||||||
///
|
///
|
||||||
boost::scoped_ptr<LyXServer> lyx_server_;
|
boost::scoped_ptr<Server> lyx_server_;
|
||||||
///
|
///
|
||||||
boost::scoped_ptr<LyXServerSocket> lyx_socket_;
|
boost::scoped_ptr<ServerSocket> lyx_socket_;
|
||||||
///
|
///
|
||||||
boost::scoped_ptr<frontend::Application> application_;
|
boost::scoped_ptr<frontend::Application> application_;
|
||||||
/// lyx session, containing lastfiles, lastfilepos, and lastopened
|
/// lyx session, containing lastfiles, lastfilepos, and lastopened
|
||||||
@ -265,28 +265,28 @@ LyXFunc const & LyX::lyxFunc() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
LyXServer & LyX::server()
|
Server & LyX::server()
|
||||||
{
|
{
|
||||||
BOOST_ASSERT(pimpl_->lyx_server_.get());
|
BOOST_ASSERT(pimpl_->lyx_server_.get());
|
||||||
return *pimpl_->lyx_server_.get();
|
return *pimpl_->lyx_server_.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
LyXServer const & LyX::server() const
|
Server const & LyX::server() const
|
||||||
{
|
{
|
||||||
BOOST_ASSERT(pimpl_->lyx_server_.get());
|
BOOST_ASSERT(pimpl_->lyx_server_.get());
|
||||||
return *pimpl_->lyx_server_.get();
|
return *pimpl_->lyx_server_.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
LyXServerSocket & LyX::socket()
|
ServerSocket & LyX::socket()
|
||||||
{
|
{
|
||||||
BOOST_ASSERT(pimpl_->lyx_socket_.get());
|
BOOST_ASSERT(pimpl_->lyx_socket_.get());
|
||||||
return *pimpl_->lyx_socket_.get();
|
return *pimpl_->lyx_socket_.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
LyXServerSocket const & LyX::socket() const
|
ServerSocket const & LyX::socket() const
|
||||||
{
|
{
|
||||||
BOOST_ASSERT(pimpl_->lyx_socket_.get());
|
BOOST_ASSERT(pimpl_->lyx_socket_.get());
|
||||||
return *pimpl_->lyx_socket_.get();
|
return *pimpl_->lyx_socket_.get();
|
||||||
@ -454,8 +454,8 @@ int LyX::exec(int & argc, char * argv[])
|
|||||||
*/
|
*/
|
||||||
// Note: socket callback must be registered after init(argc, argv)
|
// Note: socket callback must be registered after init(argc, argv)
|
||||||
// such that package().temp_dir() is properly initialized.
|
// such that package().temp_dir() is properly initialized.
|
||||||
pimpl_->lyx_server_.reset(new LyXServer(&pimpl_->lyxfunc_, lyxrc.lyxpipes));
|
pimpl_->lyx_server_.reset(new Server(&pimpl_->lyxfunc_, lyxrc.lyxpipes));
|
||||||
pimpl_->lyx_socket_.reset(new LyXServerSocket(&pimpl_->lyxfunc_,
|
pimpl_->lyx_socket_.reset(new ServerSocket(&pimpl_->lyxfunc_,
|
||||||
FileName(package().temp_dir().absFilename() + "/lyxsocket")));
|
FileName(package().temp_dir().absFilename() + "/lyxsocket")));
|
||||||
|
|
||||||
// Start the real execution loop.
|
// Start the real execution loop.
|
||||||
@ -1464,7 +1464,7 @@ LyXFunc & theLyXFunc()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
LyXServer & theLyXServer()
|
Server & theServer()
|
||||||
{
|
{
|
||||||
// FIXME: this should not be use_gui dependent
|
// FIXME: this should not be use_gui dependent
|
||||||
BOOST_ASSERT(use_gui);
|
BOOST_ASSERT(use_gui);
|
||||||
@ -1472,7 +1472,7 @@ LyXServer & theLyXServer()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
LyXServerSocket & theLyXServerSocket()
|
ServerSocket & theServerSocket()
|
||||||
{
|
{
|
||||||
// FIXME: this should not be use_gui dependent
|
// FIXME: this should not be use_gui dependent
|
||||||
BOOST_ASSERT(use_gui);
|
BOOST_ASSERT(use_gui);
|
||||||
|
12
src/LyX.h
12
src/LyX.h
@ -27,8 +27,8 @@ class Converters;
|
|||||||
class ErrorItem;
|
class ErrorItem;
|
||||||
class Inset;
|
class Inset;
|
||||||
class LyXFunc;
|
class LyXFunc;
|
||||||
class LyXServer;
|
class Server;
|
||||||
class LyXServerSocket;
|
class ServerSocket;
|
||||||
class LyXView;
|
class LyXView;
|
||||||
class Messages;
|
class Messages;
|
||||||
class Mover;
|
class Mover;
|
||||||
@ -66,11 +66,11 @@ public:
|
|||||||
LyXFunc & lyxFunc();
|
LyXFunc & lyxFunc();
|
||||||
LyXFunc const & lyxFunc() const;
|
LyXFunc const & lyxFunc() const;
|
||||||
///
|
///
|
||||||
LyXServer & server();
|
Server & server();
|
||||||
LyXServer const & server() const;
|
Server const & server() const;
|
||||||
///
|
///
|
||||||
LyXServerSocket & socket();
|
ServerSocket & socket();
|
||||||
LyXServerSocket const & socket() const;
|
ServerSocket const & socket() const;
|
||||||
|
|
||||||
///
|
///
|
||||||
frontend::Application & application();
|
frontend::Application & application();
|
||||||
|
@ -53,7 +53,7 @@
|
|||||||
#include "Lexer.h"
|
#include "Lexer.h"
|
||||||
#include "LyXRC.h"
|
#include "LyXRC.h"
|
||||||
#include "Row.h"
|
#include "Row.h"
|
||||||
#include "LyXServer.h"
|
#include "Server.h"
|
||||||
#include "LyXTextClassList.h"
|
#include "LyXTextClassList.h"
|
||||||
#include "LyXVC.h"
|
#include "LyXVC.h"
|
||||||
#include "Paragraph.h"
|
#include "Paragraph.h"
|
||||||
@ -1220,7 +1220,7 @@ void LyXFunc::dispatch(FuncRequest const & cmd)
|
|||||||
|
|
||||||
case LFUN_SERVER_NOTIFY:
|
case LFUN_SERVER_NOTIFY:
|
||||||
dispatch_buffer = keyseq->print(false);
|
dispatch_buffer = keyseq->print(false);
|
||||||
theLyXServer().notifyClient(to_utf8(dispatch_buffer));
|
theServer().notifyClient(to_utf8(dispatch_buffer));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case LFUN_SERVER_GOTO_FILE_ROW: {
|
case LFUN_SERVER_GOTO_FILE_ROW: {
|
||||||
|
@ -182,10 +182,10 @@ lyx_SOURCES = \
|
|||||||
lyxlayout_ptr_fwd.h \
|
lyxlayout_ptr_fwd.h \
|
||||||
LyXRC.cpp \
|
LyXRC.cpp \
|
||||||
LyXRC.h \
|
LyXRC.h \
|
||||||
LyXServer.cpp \
|
Server.cpp \
|
||||||
LyXServer.h \
|
Server.h \
|
||||||
LyXServerSocket.cpp \
|
ServerSocket.cpp \
|
||||||
LyXServerSocket.h \
|
ServerSocket.h \
|
||||||
lyx_sty.cpp \
|
lyx_sty.cpp \
|
||||||
lyx_sty.h \
|
lyx_sty.h \
|
||||||
LyXTextClass.cpp \
|
LyXTextClass.cpp \
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/**
|
/**
|
||||||
* \file LyXServer.cpp
|
* \file Server.cpp
|
||||||
* This file is part of LyX, the document processor.
|
* This file is part of LyX, the document processor.
|
||||||
* Licence details can be found in the file COPYING.
|
* Licence details can be found in the file COPYING.
|
||||||
*
|
*
|
||||||
@ -39,7 +39,7 @@
|
|||||||
|
|
||||||
#include <config.h>
|
#include <config.h>
|
||||||
|
|
||||||
#include "LyXServer.h"
|
#include "Server.h"
|
||||||
#include "debug.h"
|
#include "debug.h"
|
||||||
#include "FuncRequest.h"
|
#include "FuncRequest.h"
|
||||||
#include "LyXAction.h"
|
#include "LyXAction.h"
|
||||||
@ -331,9 +331,9 @@ string const LyXComm::outPipeName() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// LyXServer class
|
// Server class
|
||||||
|
|
||||||
LyXServer::~LyXServer()
|
Server::~Server()
|
||||||
{
|
{
|
||||||
// say goodbye to clients so they stop sending messages
|
// say goodbye to clients so they stop sending messages
|
||||||
// modified june 1999 by stefano@zool.su.se to send as many bye
|
// modified june 1999 by stefano@zool.su.se to send as many bye
|
||||||
@ -352,9 +352,9 @@ LyXServer::~LyXServer()
|
|||||||
Purpose : handle data gotten from communication
|
Purpose : handle data gotten from communication
|
||||||
\* ---F------------------------------------------------------------------- */
|
\* ---F------------------------------------------------------------------- */
|
||||||
|
|
||||||
void LyXServer::callback(LyXServer * serv, string const & msg)
|
void Server::callback(Server * serv, string const & msg)
|
||||||
{
|
{
|
||||||
LYXERR(Debug::LYXSERVER) << "LyXServer: Received: '"
|
LYXERR(Debug::LYXSERVER) << "Server: Received: '"
|
||||||
<< msg << '\'' << endl;
|
<< msg << '\'' << endl;
|
||||||
|
|
||||||
char const * p = msg.c_str();
|
char const * p = msg.c_str();
|
||||||
@ -370,7 +370,7 @@ void LyXServer::callback(LyXServer * serv, string const & msg)
|
|||||||
if (compare(p, "LYXSRV:", 7) == 0) {
|
if (compare(p, "LYXSRV:", 7) == 0) {
|
||||||
server_only = true;
|
server_only = true;
|
||||||
} else if (0 != compare(p, "LYXCMD:", 7)) {
|
} else if (0 != compare(p, "LYXCMD:", 7)) {
|
||||||
lyxerr << "LyXServer: Unknown request \""
|
lyxerr << "Server: Unknown request \""
|
||||||
<< p << '"' << endl;
|
<< p << '"' << endl;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -397,7 +397,7 @@ void LyXServer::callback(LyXServer * serv, string const & msg)
|
|||||||
}
|
}
|
||||||
|
|
||||||
LYXERR(Debug::LYXSERVER)
|
LYXERR(Debug::LYXSERVER)
|
||||||
<< "LyXServer: Client: '" << client
|
<< "Server: Client: '" << client
|
||||||
<< "' Command: '" << cmd
|
<< "' Command: '" << cmd
|
||||||
<< "' Argument: '" << arg << '\'' << endl;
|
<< "' Argument: '" << arg << '\'' << endl;
|
||||||
|
|
||||||
@ -411,7 +411,7 @@ void LyXServer::callback(LyXServer * serv, string const & msg)
|
|||||||
// One more client
|
// One more client
|
||||||
if (serv->numclients == MAX_CLIENTS) { //paranoid check
|
if (serv->numclients == MAX_CLIENTS) { //paranoid check
|
||||||
LYXERR(Debug::LYXSERVER)
|
LYXERR(Debug::LYXSERVER)
|
||||||
<< "LyXServer: too many clients..."
|
<< "Server: too many clients..."
|
||||||
<< endl;
|
<< endl;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -423,7 +423,7 @@ void LyXServer::callback(LyXServer * serv, string const & msg)
|
|||||||
serv->numclients++;
|
serv->numclients++;
|
||||||
buf = "LYXSRV:" + client + ":hello\n";
|
buf = "LYXSRV:" + client + ":hello\n";
|
||||||
LYXERR(Debug::LYXSERVER)
|
LYXERR(Debug::LYXSERVER)
|
||||||
<< "LyXServer: Greeting "
|
<< "Server: Greeting "
|
||||||
<< client << endl;
|
<< client << endl;
|
||||||
serv->pipes.send(buf);
|
serv->pipes.send(buf);
|
||||||
} else if (cmd == "bye") {
|
} else if (cmd == "bye") {
|
||||||
@ -437,16 +437,16 @@ void LyXServer::callback(LyXServer * serv, string const & msg)
|
|||||||
serv->numclients--;
|
serv->numclients--;
|
||||||
serv->clients[i].erase();
|
serv->clients[i].erase();
|
||||||
LYXERR(Debug::LYXSERVER)
|
LYXERR(Debug::LYXSERVER)
|
||||||
<< "LyXServer: Client "
|
<< "Server: Client "
|
||||||
<< client << " said goodbye"
|
<< client << " said goodbye"
|
||||||
<< endl;
|
<< endl;
|
||||||
} else {
|
} else {
|
||||||
LYXERR(Debug::LYXSERVER)
|
LYXERR(Debug::LYXSERVER)
|
||||||
<< "LyXServer: ignoring bye messge from unregistered client"
|
<< "Server: ignoring bye messge from unregistered client"
|
||||||
<< client << endl;
|
<< client << endl;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
lyxerr <<"LyXServer: Undefined server command "
|
lyxerr <<"Server: Undefined server command "
|
||||||
<< cmd << '.' << endl;
|
<< cmd << '.' << endl;
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
@ -496,7 +496,7 @@ void LyXServer::callback(LyXServer * serv, string const & msg)
|
|||||||
Returns : nothing
|
Returns : nothing
|
||||||
\* ---F------------------------------------------------------------------- */
|
\* ---F------------------------------------------------------------------- */
|
||||||
|
|
||||||
void LyXServer::notifyClient(string const & s)
|
void Server::notifyClient(string const & s)
|
||||||
{
|
{
|
||||||
string buf = string("NOTIFY:") + s + "\n";
|
string buf = string("NOTIFY:") + s + "\n";
|
||||||
pipes.send(buf);
|
pipes.send(buf);
|
@ -1,6 +1,6 @@
|
|||||||
// -*- C++ -*-
|
// -*- C++ -*-
|
||||||
/**
|
/**
|
||||||
* \file LyXServer.h
|
* \file Server.h
|
||||||
* This file is part of LyX, the document processor.
|
* This file is part of LyX, the document processor.
|
||||||
* Licence details can be found in the file COPYING.
|
* Licence details can be found in the file COPYING.
|
||||||
*
|
*
|
||||||
@ -10,8 +10,8 @@
|
|||||||
* Full author contact details are available in file CREDITS.
|
* Full author contact details are available in file CREDITS.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef LYXSERVER_H
|
#ifndef SERVER_H
|
||||||
#define LYXSERVER_H
|
#define SERVER_H
|
||||||
|
|
||||||
#include <boost/signals/trackable.hpp>
|
#include <boost/signals/trackable.hpp>
|
||||||
|
|
||||||
@ -19,9 +19,8 @@
|
|||||||
namespace lyx {
|
namespace lyx {
|
||||||
|
|
||||||
class LyXFunc;
|
class LyXFunc;
|
||||||
class LyXServer;
|
class Server;
|
||||||
|
|
||||||
/* --- i/o pipes --------------------------------------------------------- */
|
|
||||||
|
|
||||||
/** This class managed the pipes used for communicating with clients.
|
/** This class managed the pipes used for communicating with clients.
|
||||||
Usage: Initialize with pipe-filename-base, client class to receive
|
Usage: Initialize with pipe-filename-base, client class to receive
|
||||||
@ -36,19 +35,18 @@ public:
|
|||||||
This is one of the small things that would have been a lot
|
This is one of the small things that would have been a lot
|
||||||
cleaner with a Signal/Slot thing.
|
cleaner with a Signal/Slot thing.
|
||||||
*/
|
*/
|
||||||
typedef void (*ClientCallbackfct)(LyXServer *, std::string const &);
|
typedef void (*ClientCallbackfct)(Server *, std::string const &);
|
||||||
|
|
||||||
/// Construct with pipe-basename and callback to receive messages
|
/// Construct with pipe-basename and callback to receive messages
|
||||||
LyXComm(std::string const & pip, LyXServer * cli, ClientCallbackfct ccb = 0)
|
LyXComm(std::string const & pip, Server * cli, ClientCallbackfct ccb = 0)
|
||||||
: pipename(pip), client(cli), clientcb(ccb) {
|
: pipename(pip), client(cli), clientcb(ccb)
|
||||||
|
{
|
||||||
ready = false;
|
ready = false;
|
||||||
openConnection();
|
openConnection();
|
||||||
}
|
}
|
||||||
|
|
||||||
///
|
///
|
||||||
~LyXComm() {
|
~LyXComm() { closeConnection(); }
|
||||||
closeConnection();
|
|
||||||
}
|
|
||||||
|
|
||||||
/// clean up in emergency
|
/// clean up in emergency
|
||||||
void emergencyCleanup();
|
void emergencyCleanup();
|
||||||
@ -91,16 +89,16 @@ private:
|
|||||||
std::string pipename;
|
std::string pipename;
|
||||||
|
|
||||||
/// The client
|
/// The client
|
||||||
LyXServer * client;
|
Server * client;
|
||||||
|
|
||||||
/// The client callback function
|
/// The client callback function
|
||||||
ClientCallbackfct clientcb;
|
ClientCallbackfct clientcb;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/* --- prototypes -------------------------------------------------------- */
|
|
||||||
///
|
///
|
||||||
class LyXServer {
|
class Server {
|
||||||
public:
|
public:
|
||||||
// FIXME IN 0.13
|
// FIXME IN 0.13
|
||||||
// Hack! This should be changed in 0.13
|
// Hack! This should be changed in 0.13
|
||||||
@ -113,21 +111,19 @@ public:
|
|||||||
// lyxserver is using a buffer that is being edited with a bufferview.
|
// lyxserver is using a buffer that is being edited with a bufferview.
|
||||||
// With a common buffer list this is not a problem, maybe. (Alejandro)
|
// With a common buffer list this is not a problem, maybe. (Alejandro)
|
||||||
///
|
///
|
||||||
LyXServer(LyXFunc * f, std::string const & pip)
|
Server(LyXFunc * f, std::string const & pip)
|
||||||
: numclients(0), func(f), pipes(pip, (this), callback) {}
|
: numclients(0), func(f), pipes(pip, (this), callback) {}
|
||||||
///
|
///
|
||||||
~LyXServer();
|
~Server();
|
||||||
///
|
///
|
||||||
void notifyClient(std::string const &);
|
void notifyClient(std::string const &);
|
||||||
|
|
||||||
/// whilst crashing etc.
|
/// whilst crashing etc.
|
||||||
void emergencyCleanup() {
|
void emergencyCleanup() { pipes.emergencyCleanup(); }
|
||||||
pipes.emergencyCleanup();
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
///
|
///
|
||||||
static void callback(LyXServer *, std::string const & msg);
|
static void callback(Server *, std::string const & msg);
|
||||||
/// Names and number of current clients
|
/// Names and number of current clients
|
||||||
enum {
|
enum {
|
||||||
///
|
///
|
||||||
@ -144,11 +140,9 @@ private:
|
|||||||
};
|
};
|
||||||
|
|
||||||
/// Implementation is in LyX.cpp
|
/// Implementation is in LyX.cpp
|
||||||
extern LyXServer & theLyXServer();
|
extern Server & theServer();
|
||||||
|
|
||||||
|
|
||||||
} // namespace lyx
|
} // namespace lyx
|
||||||
|
|
||||||
#endif /* _LYXSERVER_H_ */
|
#endif // SERVER_H
|
||||||
|
|
||||||
/* === End of File: LyXServer.h ========================================== */
|
|
@ -1,5 +1,5 @@
|
|||||||
/**
|
/**
|
||||||
* \file LyXServerSocket.cpp
|
* \file ServerSocket.cpp
|
||||||
* This file is part of LyX, the document processor.
|
* This file is part of LyX, the document processor.
|
||||||
* Licence details can be found in the file COPYING.
|
* Licence details can be found in the file COPYING.
|
||||||
*
|
*
|
||||||
@ -14,7 +14,7 @@
|
|||||||
|
|
||||||
#include <config.h>
|
#include <config.h>
|
||||||
|
|
||||||
#include "LyXServerSocket.h"
|
#include "ServerSocket.h"
|
||||||
|
|
||||||
#include "debug.h"
|
#include "debug.h"
|
||||||
#include "FuncRequest.h"
|
#include "FuncRequest.h"
|
||||||
@ -48,7 +48,7 @@ namespace lyx {
|
|||||||
// Address is the unix address for the socket.
|
// Address is the unix address for the socket.
|
||||||
// MAX_CLIENTS is the maximum number of clients
|
// MAX_CLIENTS is the maximum number of clients
|
||||||
// that can connect at the same time.
|
// that can connect at the same time.
|
||||||
LyXServerSocket::LyXServerSocket(LyXFunc * f, support::FileName const & addr)
|
ServerSocket::ServerSocket(LyXFunc * f, support::FileName const & addr)
|
||||||
: func(f),
|
: func(f),
|
||||||
fd_(support::socktools::listen(addr, 3)),
|
fd_(support::socktools::listen(addr, 3)),
|
||||||
address_(addr)
|
address_(addr)
|
||||||
@ -66,7 +66,7 @@ LyXServerSocket::LyXServerSocket(LyXFunc * f, support::FileName const & addr)
|
|||||||
|
|
||||||
theApp()->registerSocketCallback(
|
theApp()->registerSocketCallback(
|
||||||
fd_,
|
fd_,
|
||||||
boost::bind(&LyXServerSocket::serverCallback, this)
|
boost::bind(&ServerSocket::serverCallback, this)
|
||||||
);
|
);
|
||||||
|
|
||||||
LYXERR(Debug::LYXSERVER) << "lyx: New server socket "
|
LYXERR(Debug::LYXSERVER) << "lyx: New server socket "
|
||||||
@ -75,7 +75,7 @@ LyXServerSocket::LyXServerSocket(LyXFunc * f, support::FileName const & addr)
|
|||||||
|
|
||||||
|
|
||||||
// Close the socket and remove the address of the filesystem.
|
// Close the socket and remove the address of the filesystem.
|
||||||
LyXServerSocket::~LyXServerSocket()
|
ServerSocket::~ServerSocket()
|
||||||
{
|
{
|
||||||
if (fd_ != -1) {
|
if (fd_ != -1) {
|
||||||
BOOST_ASSERT (theApp());
|
BOOST_ASSERT (theApp());
|
||||||
@ -89,7 +89,7 @@ LyXServerSocket::~LyXServerSocket()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
string const LyXServerSocket::address() const
|
string const ServerSocket::address() const
|
||||||
{
|
{
|
||||||
return address_.absFilename();
|
return address_.absFilename();
|
||||||
}
|
}
|
||||||
@ -97,7 +97,7 @@ string const LyXServerSocket::address() const
|
|||||||
|
|
||||||
// Creates a new LyXDataSocket and checks to see if the connection
|
// Creates a new LyXDataSocket and checks to see if the connection
|
||||||
// is OK and if the number of clients does not exceed MAX_CLIENTS
|
// is OK and if the number of clients does not exceed MAX_CLIENTS
|
||||||
void LyXServerSocket::serverCallback()
|
void ServerSocket::serverCallback()
|
||||||
{
|
{
|
||||||
int const client_fd = support::socktools::accept(fd_);
|
int const client_fd = support::socktools::accept(fd_);
|
||||||
|
|
||||||
@ -117,7 +117,7 @@ void LyXServerSocket::serverCallback()
|
|||||||
shared_ptr<LyXDataSocket>(new LyXDataSocket(client_fd));
|
shared_ptr<LyXDataSocket>(new LyXDataSocket(client_fd));
|
||||||
theApp()->registerSocketCallback(
|
theApp()->registerSocketCallback(
|
||||||
client_fd,
|
client_fd,
|
||||||
boost::bind(&LyXServerSocket::dataCallback,
|
boost::bind(&ServerSocket::dataCallback,
|
||||||
this, client_fd)
|
this, client_fd)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -125,14 +125,14 @@ void LyXServerSocket::serverCallback()
|
|||||||
|
|
||||||
// Reads and processes input from client and check
|
// Reads and processes input from client and check
|
||||||
// if the connection has been closed
|
// if the connection has been closed
|
||||||
void LyXServerSocket::dataCallback(int fd)
|
void ServerSocket::dataCallback(int fd)
|
||||||
{
|
{
|
||||||
shared_ptr<LyXDataSocket> client = clients[fd];
|
shared_ptr<LyXDataSocket> client = clients[fd];
|
||||||
|
|
||||||
string line;
|
string line;
|
||||||
string::size_type pos;
|
string::size_type pos;
|
||||||
bool saidbye = false;
|
bool saidbye = false;
|
||||||
while ((!saidbye) && client->readln(line)) {
|
while (!saidbye && client->readln(line)) {
|
||||||
// The protocol must be programmed here
|
// The protocol must be programmed here
|
||||||
// Split the key and the data
|
// Split the key and the data
|
||||||
if ((pos = line.find(':')) == string::npos) {
|
if ((pos = line.find(':')) == string::npos) {
|
||||||
@ -160,19 +160,19 @@ void LyXServerSocket::dataCallback(int fd)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (saidbye || (!client->connected())) {
|
if (saidbye || !client->connected()) {
|
||||||
clients.erase(fd);
|
clients.erase(fd);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void LyXServerSocket::writeln(string const & line)
|
void ServerSocket::writeln(string const & line)
|
||||||
{
|
{
|
||||||
string const linen(line + '\n');
|
string const linen = line + '\n';
|
||||||
int const size = linen.size();
|
int const size = linen.size();
|
||||||
int const written = ::write(fd_, linen.c_str(), size);
|
int const written = ::write(fd_, linen.c_str(), size);
|
||||||
if (written < size) { // Always mean end of connection.
|
if (written < size) { // Always mean end of connection.
|
||||||
if ((written == -1) && (errno == EPIPE)) {
|
if (written == -1 && errno == EPIPE) {
|
||||||
// The program will also receive a SIGPIPE
|
// The program will also receive a SIGPIPE
|
||||||
// that must be caught
|
// that must be caught
|
||||||
lyxerr << "lyx: Server socket " << fd_
|
lyxerr << "lyx: Server socket " << fd_
|
||||||
@ -188,9 +188,9 @@ void LyXServerSocket::writeln(string const & line)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Debug
|
// Debug
|
||||||
// void LyXServerSocket::dump() const
|
// void ServerSocket::dump() const
|
||||||
// {
|
// {
|
||||||
// lyxerr << "LyXServerSocket debug dump.\n"
|
// lyxerr << "ServerSocket debug dump.\n"
|
||||||
// << "fd = " << fd_ << ", address = " << address_.absFilename() << ".\n"
|
// << "fd = " << fd_ << ", address = " << address_.absFilename() << ".\n"
|
||||||
// << "Clients: " << clients.size() << ".\n";
|
// << "Clients: " << clients.size() << ".\n";
|
||||||
// std::map<int, shared_ptr<LyXDataSocket> >::const_iterator client = clients.begin();
|
// std::map<int, shared_ptr<LyXDataSocket> >::const_iterator client = clients.begin();
|
||||||
@ -265,11 +265,11 @@ bool LyXDataSocket::readln(string & line)
|
|||||||
// Write a line of the form <key>:<value> to the socket
|
// Write a line of the form <key>:<value> to the socket
|
||||||
void LyXDataSocket::writeln(string const & line)
|
void LyXDataSocket::writeln(string const & line)
|
||||||
{
|
{
|
||||||
string const linen(line + '\n');
|
string const linen = line + '\n';
|
||||||
int const size = linen.size();
|
int const size = linen.size();
|
||||||
int const written = ::write(fd_, linen.c_str(), size);
|
int const written = ::write(fd_, linen.c_str(), size);
|
||||||
if (written < size) { // Always mean end of connection.
|
if (written < size) { // Always mean end of connection.
|
||||||
if ((written == -1) && (errno == EPIPE)) {
|
if (written == -1 && errno == EPIPE) {
|
||||||
// The program will also receive a SIGPIPE
|
// The program will also receive a SIGPIPE
|
||||||
// that must be catched
|
// that must be catched
|
||||||
lyxerr << "lyx: Data socket " << fd_
|
lyxerr << "lyx: Data socket " << fd_
|
@ -1,6 +1,6 @@
|
|||||||
// -*- C++ -*-
|
// -*- C++ -*-
|
||||||
/**
|
/**
|
||||||
* \file LyXServerSocket.h
|
* \file ServerSocket.h
|
||||||
* This file is part of LyX, the document processor.
|
* This file is part of LyX, the document processor.
|
||||||
* Licence details can be found in the file COPYING.
|
* Licence details can be found in the file COPYING.
|
||||||
*
|
*
|
||||||
@ -26,7 +26,6 @@
|
|||||||
|
|
||||||
namespace lyx {
|
namespace lyx {
|
||||||
|
|
||||||
class LyXServerSocket;
|
|
||||||
class LyXDataSocket;
|
class LyXDataSocket;
|
||||||
|
|
||||||
|
|
||||||
@ -39,12 +38,12 @@ class LyXDataSocket;
|
|||||||
* This class encapsulates local (unix) server socket operations and
|
* This class encapsulates local (unix) server socket operations and
|
||||||
* manages LyXDataSockets objects that are created when clients connect.
|
* manages LyXDataSockets objects that are created when clients connect.
|
||||||
*/
|
*/
|
||||||
class LyXServerSocket {
|
class ServerSocket {
|
||||||
public:
|
public:
|
||||||
///
|
///
|
||||||
LyXServerSocket(LyXFunc *, support::FileName const &);
|
ServerSocket(LyXFunc *, support::FileName const &);
|
||||||
///
|
///
|
||||||
~LyXServerSocket();
|
~ServerSocket();
|
||||||
/// Address of the local socket
|
/// Address of the local socket
|
||||||
std::string const address() const;
|
std::string const address() const;
|
||||||
/// To be called when there is activity in the server socket
|
/// To be called when there is activity in the server socket
|
||||||
@ -94,7 +93,7 @@ private:
|
|||||||
};
|
};
|
||||||
|
|
||||||
/// Implementation is in LyX.cpp
|
/// Implementation is in LyX.cpp
|
||||||
extern LyXServerSocket & theLyXServerSocket();
|
extern ServerSocket & theServerSocket();
|
||||||
|
|
||||||
|
|
||||||
} // namespace lyx
|
} // namespace lyx
|
@ -18,31 +18,31 @@
|
|||||||
#include "InsetMathBrace.h"
|
#include "InsetMathBrace.h"
|
||||||
#include "InsetMathColor.h"
|
#include "InsetMathColor.h"
|
||||||
#include "InsetMathComment.h"
|
#include "InsetMathComment.h"
|
||||||
#include "MathData.h"
|
|
||||||
#include "InsetMathDelim.h"
|
#include "InsetMathDelim.h"
|
||||||
#include "MathFactory.h"
|
|
||||||
#include "InsetMathHull.h"
|
#include "InsetMathHull.h"
|
||||||
#include "MathStream.h"
|
|
||||||
#include "MathMacroArgument.h"
|
|
||||||
//#include "InsetMathMBox.h"
|
//#include "InsetMathMBox.h"
|
||||||
#include "MathParser.h"
|
#include "InsetMathRef.h"
|
||||||
#include "InsetMathScript.h"
|
#include "InsetMathScript.h"
|
||||||
#include "InsetMathSpace.h"
|
#include "InsetMathSpace.h"
|
||||||
#include "InsetMathSymbol.h"
|
#include "InsetMathSymbol.h"
|
||||||
#include "MathSupport.h"
|
|
||||||
#include "InsetMathUnknown.h"
|
#include "InsetMathUnknown.h"
|
||||||
#include "InsetMathRef.h"
|
#include "MathData.h"
|
||||||
|
#include "MathFactory.h"
|
||||||
|
#include "MathMacroArgument.h"
|
||||||
|
#include "MathParser.h"
|
||||||
|
#include "MathStream.h"
|
||||||
|
#include "MathSupport.h"
|
||||||
|
|
||||||
#include "BufferView.h"
|
|
||||||
#include "CutAndPaste.h"
|
|
||||||
#include "FuncStatus.h"
|
|
||||||
#include "Color.h"
|
|
||||||
#include "bufferview_funcs.h"
|
#include "bufferview_funcs.h"
|
||||||
|
#include "BufferView.h"
|
||||||
|
#include "Color.h"
|
||||||
#include "CoordCache.h"
|
#include "CoordCache.h"
|
||||||
#include "Cursor.h"
|
#include "Cursor.h"
|
||||||
|
#include "CutAndPaste.h"
|
||||||
#include "debug.h"
|
#include "debug.h"
|
||||||
#include "DispatchResult.h"
|
#include "DispatchResult.h"
|
||||||
#include "FuncRequest.h"
|
#include "FuncRequest.h"
|
||||||
|
#include "FuncStatus.h"
|
||||||
#include "gettext.h"
|
#include "gettext.h"
|
||||||
#include "LyXText.h"
|
#include "LyXText.h"
|
||||||
#include "OutputParams.h"
|
#include "OutputParams.h"
|
||||||
@ -56,8 +56,6 @@
|
|||||||
#include "frontends/Selection.h"
|
#include "frontends/Selection.h"
|
||||||
|
|
||||||
#include "FuncRequest.h"
|
#include "FuncRequest.h"
|
||||||
#include "LyXServer.h"
|
|
||||||
#include "LyXServerSocket.h"
|
|
||||||
|
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
|
||||||
|
@ -46,8 +46,8 @@
|
|||||||
#include "paragraph_funcs.h"
|
#include "paragraph_funcs.h"
|
||||||
#include "ParagraphParameters.h"
|
#include "ParagraphParameters.h"
|
||||||
#include "ParIterator.h"
|
#include "ParIterator.h"
|
||||||
#include "LyXServer.h"
|
#include "Server.h"
|
||||||
#include "LyXServerSocket.h"
|
#include "ServerSocket.h"
|
||||||
#include "Undo.h"
|
#include "Undo.h"
|
||||||
#include "VSpace.h"
|
#include "VSpace.h"
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user