loolwsd/ClientSession.cpp | 11 +++++++++-- loolwsd/LOOLForKit.cpp | 12 ++++++++---- loolwsd/LOOLKit.cpp | 15 +++++++++++++-- loolwsd/LOOLKit.hpp | 3 ++- loolwsd/LOOLWSD.cpp | 11 ++++++++++- loolwsd/LOOLWSD.hpp | 1 + loolwsd/LibreOfficeKit.hpp | 13 +++++++++++++ loolwsd/Util.cpp | 6 +++--- loolwsd/Util.hpp | 4 ++-- loolwsd/protocol.txt | 8 +++++++- 10 files changed, 68 insertions(+), 16 deletions(-)
New commits: commit b83ac269fa790f674cfe5b1bd90e9d6aadc28df4 Author: Pranav Kant <pran...@collabora.com> Date: Tue Jun 21 00:28:00 2016 +0530 loolwsd: Send LOKit version information to clients Send as a response to 'loolclient' message received from the client Change-Id: I3d33f9fd087489aa9bf5a94f591ab04e208cbf13 diff --git a/loolwsd/ClientSession.cpp b/loolwsd/ClientSession.cpp index 1fb1ec7..ad73943 100644 --- a/loolwsd/ClientSession.cpp +++ b/loolwsd/ClientSession.cpp @@ -74,11 +74,18 @@ bool ClientSession::_handleInput(const char *buffer, int length) if (std::get<0>(versionTuple) != ProtocolMajorVersionNumber || std::get<1>(versionTuple) != ProtocolMinorVersionNumber) { - sendTextFrame("error: cmd=loolclient kind=badversion"); + sendTextFrame("error: cmd=loolclient kind=badprotocolversion"); return false; } - return sendTextFrame("loolserver " + GetProtocolVersion()); + // Send LOOL version information + std::string version, hash; + Util::getVersionInfo(version, hash); + sendTextFrame("loolserver " + version + " " + hash + " " + GetProtocolVersion()); + // Send LOKit version information + sendTextFrame("lokitversion " + LOOLWSD::LOKitVersion); + + return true; } if (tokens[0] == "takeedit") diff --git a/loolwsd/LOOLForKit.cpp b/loolwsd/LOOLForKit.cpp index 9313adc..c29de0d 100644 --- a/loolwsd/LOOLForKit.cpp +++ b/loolwsd/LOOLForKit.cpp @@ -135,7 +135,8 @@ static void cleanupChildren() static int createLibreOfficeKit(const std::string& childRoot, const std::string& sysTemplate, const std::string& loTemplate, - const std::string& loSubPath) + const std::string& loSubPath, + bool queryVersion = false) { Log::debug("Forking a loolkit process."); @@ -157,7 +158,7 @@ static int createLibreOfficeKit(const std::string& childRoot, Thread::sleep(std::stoul(std::getenv("SLEEPKITFORDEBUGGER")) * 1000); } - lokit_main(childRoot, sysTemplate, loTemplate, loSubPath, NoCapsForKit); + lokit_main(childRoot, sysTemplate, loTemplate, loSubPath, NoCapsForKit, queryVersion); } else { @@ -308,7 +309,8 @@ int main(int argc, char** argv) Log::info("Preinit stage OK."); // We must have at least one child, more are created dynamically. - if (createLibreOfficeKit(childRoot, sysTemplate, loTemplate, loSubPath) < 0) + // Ask this first child to send version information to master process + if (createLibreOfficeKit(childRoot, sysTemplate, loTemplate, loSubPath, true) < 0) { Log::error("Failed to create a kit process."); std::_Exit(Application::EXIT_SOFTWARE); diff --git a/loolwsd/LOOLKit.cpp b/loolwsd/LOOLKit.cpp index f63f4cb..be7fb99 100644 --- a/loolwsd/LOOLKit.cpp +++ b/loolwsd/LOOLKit.cpp @@ -1000,7 +1000,8 @@ void lokit_main(const std::string& childRoot, const std::string& sysTemplate, const std::string& loTemplate, const std::string& loSubPath, - bool noCapabilities) + bool noCapabilities, + bool queryVersion) { // Reinitialize logging when forked. Log::initialize("kit"); @@ -1156,7 +1157,17 @@ void lokit_main(const std::string& childRoot, // Open websocket connection between the child process and WSD. HTTPClientSession cs("127.0.0.1", MasterPortNumber); cs.setTimeout(0); - HTTPRequest request(HTTPRequest::HTTP_GET, std::string(NEW_CHILD_URI) + "pid=" + pid); + + std::string requestUrl = std::string(NEW_CHILD_URI) + "pid=" + pid; + if (queryVersion) + { + char* versionInfo = loKit->getVersionInfo(); + std::string encodedVersionStr; + URI::encode(std::string(versionInfo), "", encodedVersionStr); + requestUrl += "&version=" + encodedVersionStr; + free(versionInfo); + } + HTTPRequest request(HTTPRequest::HTTP_GET, requestUrl); HTTPResponse response; auto ws = std::make_shared<WebSocket>(cs, request, response); ws->setReceiveTimeout(0); diff --git a/loolwsd/LOOLKit.hpp b/loolwsd/LOOLKit.hpp index 2f43022..4206133 100644 --- a/loolwsd/LOOLKit.hpp +++ b/loolwsd/LOOLKit.hpp @@ -13,7 +13,8 @@ void lokit_main(const std::string& childRoot, const std::string& sysTemplate, const std::string& loTemplate, const std::string& loSubPath, - bool noCapabilities); + bool noCapabilities, + bool queryVersionInfo); bool globalPreinit(const std::string &loTemplate); diff --git a/loolwsd/LOOLWSD.cpp b/loolwsd/LOOLWSD.cpp index 59575d6..0947548 100644 --- a/loolwsd/LOOLWSD.cpp +++ b/loolwsd/LOOLWSD.cpp @@ -924,6 +924,10 @@ public: { pid = std::stoi(param.second); } + else if (param.first == "version") + { + LOOLWSD::LOKitVersion = param.second; + } } if (pid <= 0) @@ -1168,6 +1172,7 @@ std::string LOOLWSD::LoSubPath = "lo"; std::string LOOLWSD::ServerName; std::string LOOLWSD::FileServerRoot; std::string LOOLWSD::AdminCreds; +std::string LOOLWSD::LOKitVersion; bool LOOLWSD::AllowLocalStorage = false; bool LOOLWSD::SSLEnabled = #if ENABLE_SSL diff --git a/loolwsd/LOOLWSD.hpp b/loolwsd/LOOLWSD.hpp index 1fcdac6..8de18e4 100644 --- a/loolwsd/LOOLWSD.hpp +++ b/loolwsd/LOOLWSD.hpp @@ -44,6 +44,7 @@ public: static std::string ServerName; static std::string FileServerRoot; static std::string AdminCreds; + static std::string LOKitVersion; static bool AllowLocalStorage; static bool SSLEnabled; diff --git a/loolwsd/LibreOfficeKit.hpp b/loolwsd/LibreOfficeKit.hpp index be23fab..91dea2d 100644 --- a/loolwsd/LibreOfficeKit.hpp +++ b/loolwsd/LibreOfficeKit.hpp @@ -607,6 +607,19 @@ public: { _pOffice->pClass->setDocumentPassword(_pOffice, pURL, pPassword); } + + /** + * Get version information of the LOKit process + * + * @returns string containing version information in format: + * PRODUCT_NAME PRODUCT_VERSION PRODUCT_EXTENSION BUILD_ID + * + * Eg: LibreOffice 5.3 .0.0 alpha0 <commit hash> + */ + inline char* getVersionInfo() + { + return _pOffice->pClass->getVersionInfo(_pOffice); + } #endif // defined LOK_USE_UNSTABLE_API || defined LIBO_INTERNAL_ONLY }; diff --git a/loolwsd/protocol.txt b/loolwsd/protocol.txt index 32008bc..7bcbd58 100644 --- a/loolwsd/protocol.txt +++ b/loolwsd/protocol.txt @@ -175,7 +175,7 @@ pong server -> client ================ -loolserver <major.minor[-patch]> +loolserver <loolwsd version> <loolwsd git hash> <major.minor[-patch]> Upon connection, the server must announce the version number it supports. Major: an integer that must always match between client and server, @@ -185,6 +185,12 @@ loolserver <major.minor[-patch]> Security fixes that do not alter the API would bump the minor version number. Patch: an optional string that is informational. +lokitversion <product_name> <product_version> <product_extension> <build_id> + + Version information of underlying LOKit process. + + Eg: LibreOfficeDev 5.3 .0.0.alpha0 <git hash> + contextmenu: <json description of the context menu> When the user right-clicks in the document, the content of the context commit e271995ed2a305942f394d35bda067dfb52d7022 Author: Pranav Kant <pran...@collabora.com> Date: Mon Jun 20 15:21:35 2016 +0530 loolwsd: Restructure version information functions ... so that version information can be sent to clients. Change-Id: Icc90f31fabb501f816ff1dca0c618a73660c88bc diff --git a/loolwsd/LOOLForKit.cpp b/loolwsd/LOOLForKit.cpp index 48ad394..9313adc 100644 --- a/loolwsd/LOOLForKit.cpp +++ b/loolwsd/LOOLForKit.cpp @@ -252,7 +252,9 @@ int main(int argc, char** argv) } else if (std::strstr(cmd, "--version") == cmd) { - Util::displayVersionInfo("loolforkit"); + std::string version, hash; + Util::getVersionInfo(version, hash); + std::cout << "loolforkit " << version << " - " << hash << std::endl; } #if ENABLE_DEBUG // this process has various privileges - don't run arbitrary code. diff --git a/loolwsd/LOOLWSD.cpp b/loolwsd/LOOLWSD.cpp index 052070e..59575d6 100644 --- a/loolwsd/LOOLWSD.cpp +++ b/loolwsd/LOOLWSD.cpp @@ -1498,7 +1498,11 @@ Process::PID LOOLWSD::createForKit() int LOOLWSD::main(const std::vector<std::string>& /*args*/) { if (DisplayVersion) - Util::displayVersionInfo("loolwsd"); + { + std::string version, hash; + Util::getVersionInfo(version, hash); + std::cout << "loolwsd " << version << " - " << hash << std::endl; + } #if ENABLE_SSL initializeSSL(); diff --git a/loolwsd/Util.cpp b/loolwsd/Util.cpp index 6224534..328957e 100644 --- a/loolwsd/Util.cpp +++ b/loolwsd/Util.cpp @@ -383,11 +383,11 @@ namespace Util Log::syserror("Cannot set thread name to " + s + "."); } - void displayVersionInfo(const char *app) + void getVersionInfo(std::string& version, std::string& hash) { - std::string hash(LOOLWSD_VERSION_HASH); + version = std::string(LOOLWSD_VERSION); + hash = std::string(LOOLWSD_VERSION_HASH); hash.resize(std::min(8, (int)hash.length())); - std::cout << app << " " << LOOLWSD_VERSION << " - " << hash << std::endl; } std::string UniqueId() diff --git a/loolwsd/Util.hpp b/loolwsd/Util.hpp index fd76c54..138d791 100644 --- a/loolwsd/Util.hpp +++ b/loolwsd/Util.hpp @@ -101,8 +101,8 @@ namespace Util void setThreadName(const std::string& s); - /// Display version information - void displayVersionInfo(const char *app); + /// Get version information + void getVersionInfo(std::string& version, std::string& hash); /// Return a string that is unique across processes and calls. std::string UniqueId(); _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits