X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2FServer.cpp;h=9b9f6e0a75a76009cdc569df7a3e2f26a54a188a;hb=c0f4aa8c4b786dcfb3699b175dff63f109abba98;hp=cc47b23c74b70e51252a5d95ad553a8fc80147eb;hpb=50423d0e7c9a6514946c9cbfc02602bcaee0bedb;p=lyx.git diff --git a/src/Server.cpp b/src/Server.cpp index cc47b23c74..9b9f6e0a75 100644 --- a/src/Server.cpp +++ b/src/Server.cpp @@ -34,16 +34,18 @@ received LyX will inform the client that it's listening its messages, and 'bye' will inform that lyx is closing. - See development/server_monitor.c for an example client. + See development/lyxserver/server_monitor.cpp for an example client. Purpose: implement a client/server lib for LyX */ #include #include "Server.h" + +#include "DispatchResult.h" #include "FuncRequest.h" +#include "LyX.h" #include "LyXAction.h" -#include "LyXFunc.h" #include "frontends/Application.h" @@ -415,6 +417,8 @@ bool LyXComm::checkStopServer(DWORD timeout) bool LyXComm::startPipe(DWORD index) { pipe_[index].pending_io = false; + pipe_[index].overlap.Offset = 0; + pipe_[index].overlap.OffsetHigh = 0; // Overlapped ConnectNamedPipe should return zero. if (ConnectNamedPipe(pipe_[index].handle, &pipe_[index].overlap)) { @@ -664,8 +668,7 @@ void LyXComm::send(string const & msg) << "\nLyXComm: Resetting connection" << endl; ReleaseMutex(outbuf_mutex_); closeConnection(); - if (!checkStopServer()) - openConnection(); + openConnection(); } } @@ -985,8 +988,8 @@ void ServerCallback(Server * server, string const & msg) server->callback(msg); } -Server::Server(LyXFunc * f, string const & pipes) - : numclients_(0), func_(f), pipes_(pipes, this, &ServerCallback) +Server::Server(string const & pipes) + : numclients_(0), pipes_(pipes, this, &ServerCallback) {} @@ -1107,17 +1110,19 @@ void Server::callback(string const & msg) // The correct solution would be to have a // specialized (non-gui) BufferView. But how do // we do it now? Probably we should just let it - // connect to the lyxfunc in the single LyXView we + // connect to the lyxfunc in the single GuiView we // support currently. (Lgb) - func_->dispatch(FuncRequest(lyxaction.lookupFunc(cmd), arg)); - string const rval = to_utf8(func_->getMessage()); + FuncRequest const fr(lyxaction.lookupFunc(cmd), arg); + DispatchResult dr; + theApp()->dispatch(fr, dr); + string const rval = to_utf8(dr.message()); // all commands produce an INFO or ERROR message // in the output pipe, even if they do not return // anything. See chapter 4 of Customization doc. string buf; - if (func_->errorStat()) + if (dr.error()) buf = "ERROR:"; else buf = "INFO:";