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:
André Pönitz 2007-04-29 16:22:46 +00:00
parent 32f444d6d6
commit d079c908b3
11 changed files with 95 additions and 104 deletions

View File

@ -16,7 +16,7 @@
#include "LyXRC.h"
#include "debug.h"
#include "gettext.h"
#include "LyXServerSocket.h"
#include "ServerSocket.h"
#include "frontends/Application.h"
#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_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;
// FIXME UNICODE utf8 can be wrong for files
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_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;
// FIXME UNICODE utf8 can be wrong for files
buffer.message(_("Executing command: ") + from_utf8(command));

View File

@ -36,8 +36,8 @@
#include "LyXFunc.h"
#include "Lexer.h"
#include "LyXRC.h"
#include "LyXServer.h"
#include "LyXServerSocket.h"
#include "Server.h"
#include "ServerSocket.h"
#include "LyXTextClassList.h"
#include "MenuBackend.h"
#include "Messages.h"
@ -163,9 +163,9 @@ struct LyX::Singletons
///
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_;
/// 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());
return *pimpl_->lyx_server_.get();
}
LyXServer const & LyX::server() const
Server const & LyX::server() const
{
BOOST_ASSERT(pimpl_->lyx_server_.get());
return *pimpl_->lyx_server_.get();
}
LyXServerSocket & LyX::socket()
ServerSocket & LyX::socket()
{
BOOST_ASSERT(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());
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)
// such that package().temp_dir() is properly initialized.
pimpl_->lyx_server_.reset(new LyXServer(&pimpl_->lyxfunc_, lyxrc.lyxpipes));
pimpl_->lyx_socket_.reset(new LyXServerSocket(&pimpl_->lyxfunc_,
pimpl_->lyx_server_.reset(new Server(&pimpl_->lyxfunc_, lyxrc.lyxpipes));
pimpl_->lyx_socket_.reset(new ServerSocket(&pimpl_->lyxfunc_,
FileName(package().temp_dir().absFilename() + "/lyxsocket")));
// Start the real execution loop.
@ -1464,7 +1464,7 @@ LyXFunc & theLyXFunc()
}
LyXServer & theLyXServer()
Server & theServer()
{
// FIXME: this should not be use_gui dependent
BOOST_ASSERT(use_gui);
@ -1472,7 +1472,7 @@ LyXServer & theLyXServer()
}
LyXServerSocket & theLyXServerSocket()
ServerSocket & theServerSocket()
{
// FIXME: this should not be use_gui dependent
BOOST_ASSERT(use_gui);

View File

@ -27,8 +27,8 @@ class Converters;
class ErrorItem;
class Inset;
class LyXFunc;
class LyXServer;
class LyXServerSocket;
class Server;
class ServerSocket;
class LyXView;
class Messages;
class Mover;
@ -66,11 +66,11 @@ public:
LyXFunc & lyxFunc();
LyXFunc const & lyxFunc() const;
///
LyXServer & server();
LyXServer const & server() const;
Server & server();
Server const & server() const;
///
LyXServerSocket & socket();
LyXServerSocket const & socket() const;
ServerSocket & socket();
ServerSocket const & socket() const;
///
frontend::Application & application();

View File

@ -53,7 +53,7 @@
#include "Lexer.h"
#include "LyXRC.h"
#include "Row.h"
#include "LyXServer.h"
#include "Server.h"
#include "LyXTextClassList.h"
#include "LyXVC.h"
#include "Paragraph.h"
@ -1220,7 +1220,7 @@ void LyXFunc::dispatch(FuncRequest const & cmd)
case LFUN_SERVER_NOTIFY:
dispatch_buffer = keyseq->print(false);
theLyXServer().notifyClient(to_utf8(dispatch_buffer));
theServer().notifyClient(to_utf8(dispatch_buffer));
break;
case LFUN_SERVER_GOTO_FILE_ROW: {

View File

@ -182,10 +182,10 @@ lyx_SOURCES = \
lyxlayout_ptr_fwd.h \
LyXRC.cpp \
LyXRC.h \
LyXServer.cpp \
LyXServer.h \
LyXServerSocket.cpp \
LyXServerSocket.h \
Server.cpp \
Server.h \
ServerSocket.cpp \
ServerSocket.h \
lyx_sty.cpp \
lyx_sty.h \
LyXTextClass.cpp \

View File

@ -1,5 +1,5 @@
/**
* \file LyXServer.cpp
* \file Server.cpp
* This file is part of LyX, the document processor.
* Licence details can be found in the file COPYING.
*
@ -39,7 +39,7 @@
#include <config.h>
#include "LyXServer.h"
#include "Server.h"
#include "debug.h"
#include "FuncRequest.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
// 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
\* ---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;
char const * p = msg.c_str();
@ -370,7 +370,7 @@ void LyXServer::callback(LyXServer * serv, string const & msg)
if (compare(p, "LYXSRV:", 7) == 0) {
server_only = true;
} else if (0 != compare(p, "LYXCMD:", 7)) {
lyxerr << "LyXServer: Unknown request \""
lyxerr << "Server: Unknown request \""
<< p << '"' << endl;
return;
}
@ -397,7 +397,7 @@ void LyXServer::callback(LyXServer * serv, string const & msg)
}
LYXERR(Debug::LYXSERVER)
<< "LyXServer: Client: '" << client
<< "Server: Client: '" << client
<< "' Command: '" << cmd
<< "' Argument: '" << arg << '\'' << endl;
@ -411,7 +411,7 @@ void LyXServer::callback(LyXServer * serv, string const & msg)
// One more client
if (serv->numclients == MAX_CLIENTS) { //paranoid check
LYXERR(Debug::LYXSERVER)
<< "LyXServer: too many clients..."
<< "Server: too many clients..."
<< endl;
return;
}
@ -423,7 +423,7 @@ void LyXServer::callback(LyXServer * serv, string const & msg)
serv->numclients++;
buf = "LYXSRV:" + client + ":hello\n";
LYXERR(Debug::LYXSERVER)
<< "LyXServer: Greeting "
<< "Server: Greeting "
<< client << endl;
serv->pipes.send(buf);
} else if (cmd == "bye") {
@ -437,16 +437,16 @@ void LyXServer::callback(LyXServer * serv, string const & msg)
serv->numclients--;
serv->clients[i].erase();
LYXERR(Debug::LYXSERVER)
<< "LyXServer: Client "
<< "Server: Client "
<< client << " said goodbye"
<< endl;
} else {
LYXERR(Debug::LYXSERVER)
<< "LyXServer: ignoring bye messge from unregistered client"
<< "Server: ignoring bye messge from unregistered client"
<< client << endl;
}
} else {
lyxerr <<"LyXServer: Undefined server command "
lyxerr <<"Server: Undefined server command "
<< cmd << '.' << endl;
}
return;
@ -496,7 +496,7 @@ void LyXServer::callback(LyXServer * serv, string const & msg)
Returns : nothing
\* ---F------------------------------------------------------------------- */
void LyXServer::notifyClient(string const & s)
void Server::notifyClient(string const & s)
{
string buf = string("NOTIFY:") + s + "\n";
pipes.send(buf);

View File

@ -1,6 +1,6 @@
// -*- C++ -*-
/**
* \file LyXServer.h
* \file Server.h
* This file is part of LyX, the document processor.
* Licence details can be found in the file COPYING.
*
@ -10,8 +10,8 @@
* Full author contact details are available in file CREDITS.
*/
#ifndef LYXSERVER_H
#define LYXSERVER_H
#ifndef SERVER_H
#define SERVER_H
#include <boost/signals/trackable.hpp>
@ -19,9 +19,8 @@
namespace lyx {
class LyXFunc;
class LyXServer;
class Server;
/* --- i/o pipes --------------------------------------------------------- */
/** This class managed the pipes used for communicating with clients.
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
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
LyXComm(std::string const & pip, LyXServer * cli, ClientCallbackfct ccb = 0)
: pipename(pip), client(cli), clientcb(ccb) {
LyXComm(std::string const & pip, Server * cli, ClientCallbackfct ccb = 0)
: pipename(pip), client(cli), clientcb(ccb)
{
ready = false;
openConnection();
}
///
~LyXComm() {
closeConnection();
}
~LyXComm() { closeConnection(); }
/// clean up in emergency
void emergencyCleanup();
@ -91,16 +89,16 @@ private:
std::string pipename;
/// The client
LyXServer * client;
Server * client;
/// The client callback function
ClientCallbackfct clientcb;
};
/* --- prototypes -------------------------------------------------------- */
///
class LyXServer {
class Server {
public:
// FIXME 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.
// 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) {}
///
~LyXServer();
~Server();
///
void notifyClient(std::string const &);
/// whilst crashing etc.
void emergencyCleanup() {
pipes.emergencyCleanup();
}
void emergencyCleanup() { pipes.emergencyCleanup(); }
private:
///
static void callback(LyXServer *, std::string const & msg);
static void callback(Server *, std::string const & msg);
/// Names and number of current clients
enum {
///
@ -144,11 +140,9 @@ private:
};
/// Implementation is in LyX.cpp
extern LyXServer & theLyXServer();
extern Server & theServer();
} // namespace lyx
#endif /* _LYXSERVER_H_ */
/* === End of File: LyXServer.h ========================================== */
#endif // SERVER_H

View File

@ -1,5 +1,5 @@
/**
* \file LyXServerSocket.cpp
* \file ServerSocket.cpp
* This file is part of LyX, the document processor.
* Licence details can be found in the file COPYING.
*
@ -14,7 +14,7 @@
#include <config.h>
#include "LyXServerSocket.h"
#include "ServerSocket.h"
#include "debug.h"
#include "FuncRequest.h"
@ -48,7 +48,7 @@ namespace lyx {
// Address is the unix address for the socket.
// MAX_CLIENTS is the maximum number of clients
// 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),
fd_(support::socktools::listen(addr, 3)),
address_(addr)
@ -66,7 +66,7 @@ LyXServerSocket::LyXServerSocket(LyXFunc * f, support::FileName const & addr)
theApp()->registerSocketCallback(
fd_,
boost::bind(&LyXServerSocket::serverCallback, this)
boost::bind(&ServerSocket::serverCallback, this)
);
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.
LyXServerSocket::~LyXServerSocket()
ServerSocket::~ServerSocket()
{
if (fd_ != -1) {
BOOST_ASSERT (theApp());
@ -89,7 +89,7 @@ LyXServerSocket::~LyXServerSocket()
}
string const LyXServerSocket::address() const
string const ServerSocket::address() const
{
return address_.absFilename();
}
@ -97,7 +97,7 @@ string const LyXServerSocket::address() const
// Creates a new LyXDataSocket and checks to see if the connection
// 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_);
@ -117,7 +117,7 @@ void LyXServerSocket::serverCallback()
shared_ptr<LyXDataSocket>(new LyXDataSocket(client_fd));
theApp()->registerSocketCallback(
client_fd,
boost::bind(&LyXServerSocket::dataCallback,
boost::bind(&ServerSocket::dataCallback,
this, client_fd)
);
}
@ -125,14 +125,14 @@ void LyXServerSocket::serverCallback()
// Reads and processes input from client and check
// if the connection has been closed
void LyXServerSocket::dataCallback(int fd)
void ServerSocket::dataCallback(int fd)
{
shared_ptr<LyXDataSocket> client = clients[fd];
string line;
string::size_type pos;
bool saidbye = false;
while ((!saidbye) && client->readln(line)) {
while (!saidbye && client->readln(line)) {
// The protocol must be programmed here
// Split the key and the data
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);
}
}
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 written = ::write(fd_, linen.c_str(), size);
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
// that must be caught
lyxerr << "lyx: Server socket " << fd_
@ -188,9 +188,9 @@ void LyXServerSocket::writeln(string const & line)
}
// 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"
// << "Clients: " << clients.size() << ".\n";
// 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
void LyXDataSocket::writeln(string const & line)
{
string const linen(line + '\n');
string const linen = line + '\n';
int const size = linen.size();
int const written = ::write(fd_, linen.c_str(), size);
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
// that must be catched
lyxerr << "lyx: Data socket " << fd_

View File

@ -1,6 +1,6 @@
// -*- C++ -*-
/**
* \file LyXServerSocket.h
* \file ServerSocket.h
* This file is part of LyX, the document processor.
* Licence details can be found in the file COPYING.
*
@ -26,7 +26,6 @@
namespace lyx {
class LyXServerSocket;
class LyXDataSocket;
@ -39,12 +38,12 @@ class LyXDataSocket;
* This class encapsulates local (unix) server socket operations and
* manages LyXDataSockets objects that are created when clients connect.
*/
class LyXServerSocket {
class ServerSocket {
public:
///
LyXServerSocket(LyXFunc *, support::FileName const &);
ServerSocket(LyXFunc *, support::FileName const &);
///
~LyXServerSocket();
~ServerSocket();
/// Address of the local socket
std::string const address() const;
/// To be called when there is activity in the server socket
@ -94,7 +93,7 @@ private:
};
/// Implementation is in LyX.cpp
extern LyXServerSocket & theLyXServerSocket();
extern ServerSocket & theServerSocket();
} // namespace lyx

View File

@ -18,31 +18,31 @@
#include "InsetMathBrace.h"
#include "InsetMathColor.h"
#include "InsetMathComment.h"
#include "MathData.h"
#include "InsetMathDelim.h"
#include "MathFactory.h"
#include "InsetMathHull.h"
#include "MathStream.h"
#include "MathMacroArgument.h"
//#include "InsetMathMBox.h"
#include "MathParser.h"
#include "InsetMathRef.h"
#include "InsetMathScript.h"
#include "InsetMathSpace.h"
#include "InsetMathSymbol.h"
#include "MathSupport.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.h"
#include "Color.h"
#include "CoordCache.h"
#include "Cursor.h"
#include "CutAndPaste.h"
#include "debug.h"
#include "DispatchResult.h"
#include "FuncRequest.h"
#include "FuncStatus.h"
#include "gettext.h"
#include "LyXText.h"
#include "OutputParams.h"
@ -56,8 +56,6 @@
#include "frontends/Selection.h"
#include "FuncRequest.h"
#include "LyXServer.h"
#include "LyXServerSocket.h"
#include <sstream>

View File

@ -46,8 +46,8 @@
#include "paragraph_funcs.h"
#include "ParagraphParameters.h"
#include "ParIterator.h"
#include "LyXServer.h"
#include "LyXServerSocket.h"
#include "Server.h"
#include "ServerSocket.h"
#include "Undo.h"
#include "VSpace.h"