common/Png.hpp | 8 +-- common/Protocol.cpp | 33 ------------ common/Protocol.hpp | 3 - common/Unit.cpp | 8 +-- common/Unit.hpp | 2 common/UnitHTTP.hpp | 2 common/Util.cpp | 6 +- common/Util.hpp | 2 kit/ChildSession.cpp | 136 +++++++++++++++++++++++++-------------------------- kit/ChildSession.hpp | 4 - kit/Kit.cpp | 70 +++++++++++++------------- kit/Kit.hpp | 2 kit/KitHelper.hpp | 6 +- tools/KitClient.cpp | 6 +- wsd/Admin.hpp | 2 wsd/AdminModel.cpp | 18 +++--- wsd/LOOLWSD.cpp | 20 +++---- wsd/LOOLWSD.hpp | 6 +- wsd/TraceFile.hpp | 18 +++--- 19 files changed, 158 insertions(+), 194 deletions(-)
New commits: commit 11ae90cfcbda1ab24d82a3d2cdf264bbbaffd39d Author: Tor Lillqvist <t...@collabora.com> Date: Fri Jan 13 14:52:08 2017 +0200 No Hungarian notation please Change-Id: Ia624de45a792db7e39f2245aaea7d940b30b0db2 diff --git a/common/Png.hpp b/common/Png.hpp index b3c0863..f682772 100644 --- a/common/Png.hpp +++ b/common/Png.hpp @@ -181,10 +181,10 @@ uint64_t hashSubBuffer(unsigned char* pixmap, size_t startX, size_t startY, hash.Update(pixmap + position, width * 4); } - uint64_t nHash1; - uint64_t nHash2; - hash.Final(&nHash1, &nHash2); - return nHash1; + uint64_t hash1; + uint64_t hash2; + hash.Final(&hash1, &hash2); + return hash1; } static diff --git a/common/Unit.cpp b/common/Unit.cpp index 5be5f5a..41469be 100644 --- a/common/Unit.cpp +++ b/common/Unit.cpp @@ -54,12 +54,12 @@ UnitBase *UnitBase::linkAndCreateUnit(UnitType type, const std::string &unitLibP LOG_ERR("No " << symbol << " symbol in " << unitLibPath); return nullptr; } - UnitBase *pHooks = createHooks(); + UnitBase *hooks = createHooks(); - if (pHooks) - pHooks->setHandle(dlHandle); + if (hooks) + hooks->setHandle(dlHandle); - return pHooks; + return hooks; } bool UnitBase::init(UnitType type, const std::string &unitLibPath) diff --git a/common/Unit.hpp b/common/Unit.hpp index 84b99a8..6e8ea28 100644 --- a/common/Unit.hpp +++ b/common/Unit.hpp @@ -159,7 +159,7 @@ public: virtual bool createStorage(const Poco::URI& /* uri */, const std::string& /* jailRoot */, const std::string& /* jailPath */, - std::unique_ptr<StorageBase>& /*rStorage */) + std::unique_ptr<StorageBase>& /* storage */) { return false; } diff --git a/common/UnitHTTP.hpp b/common/UnitHTTP.hpp index ec3882a..0343036 100644 --- a/common/UnitHTTP.hpp +++ b/common/UnitHTTP.hpp @@ -45,7 +45,7 @@ public: } virtual void sendFile(const std::string& /* path */, const std::string& /* mediaType */) override {} - virtual void sendBuffer(const void* /* pBuffer */, + virtual void sendBuffer(const void* /* buffer */, std::size_t /* length */) override {} virtual void redirect(const std::string& /* uri */, HTTPStatus /* status = HTTP_FOUND */) override {} diff --git a/common/Util.cpp b/common/Util.cpp index ef578b8..0b5f991 100644 --- a/common/Util.cpp +++ b/common/Util.cpp @@ -132,12 +132,12 @@ namespace Util namespace Util { - int getMemoryUsage(const Poco::Process::PID nPid) + int getMemoryUsage(const Poco::Process::PID pid) { try { //TODO: Instead of RSS, return PSS - const auto cmd = "ps o rss= -p " + std::to_string(nPid); + const auto cmd = "ps o rss= -p " + std::to_string(pid); FILE* fp = popen(cmd.c_str(), "r"); if (fp == nullptr) { @@ -156,7 +156,7 @@ namespace Util } catch (const std::exception&) { - LOG_WRN("Trying to find memory of invalid/dead PID " << nPid); + LOG_WRN("Trying to find memory of invalid/dead PID " << pid); } return -1; diff --git a/common/Util.hpp b/common/Util.hpp index c439203..3e3d706 100644 --- a/common/Util.hpp +++ b/common/Util.hpp @@ -82,7 +82,7 @@ namespace Util assert(!mtx.try_lock()); } - int getMemoryUsage(const Poco::Process::PID nPid); + int getMemoryUsage(const Poco::Process::PID pid); std::string replace(const std::string& s, const std::string& a, const std::string& b); diff --git a/kit/ChildSession.cpp b/kit/ChildSession.cpp index cb08f0a..0f984ab 100644 --- a/kit/ChildSession.cpp +++ b/kit/ChildSession.cpp @@ -491,7 +491,7 @@ void insertUserNames(const std::map<int, UserInfo>& viewInfo, std::string& json) bool ChildSession::getCommandValues(const char* /*buffer*/, int /*length*/, StringTokenizer& tokens) { bool success; - char* pValues; + char* values; std::string command; if (tokens.count() != 2 || !getTokenString(tokens[1], "command", command)) { @@ -505,25 +505,25 @@ bool ChildSession::getCommandValues(const char* /*buffer*/, int /*length*/, Stri if (command == ".uno:DocumentRepair") { - char* pUndo; + char* undo; const std::string jsonTemplate("{\"commandName\":\".uno:DocumentRepair\",\"Redo\":%s,\"Undo\":%s}"); - pValues = getLOKitDocument()->getCommandValues(".uno:Redo"); - pUndo = getLOKitDocument()->getCommandValues(".uno:Undo"); + values = getLOKitDocument()->getCommandValues(".uno:Redo"); + undo = getLOKitDocument()->getCommandValues(".uno:Undo"); std::string json = Poco::format(jsonTemplate, - std::string(pValues == nullptr ? "" : pValues), - std::string(pUndo == nullptr ? "" : pUndo)); + std::string(values == nullptr ? "" : values), + std::string(undo == nullptr ? "" : undo)); // json only contains view IDs, insert matching user names. std::map<int, UserInfo> viewInfo = _docManager.getViewInfo(); insertUserNames(viewInfo, json); success = sendTextFrame("commandvalues: " + json); - std::free(pValues); - std::free(pUndo); + std::free(values); + std::free(undo); } else { - pValues = getLOKitDocument()->getCommandValues(command.c_str()); - success = sendTextFrame("commandvalues: " + std::string(pValues == nullptr ? "" : pValues)); - std::free(pValues); + values = getLOKitDocument()->getCommandValues(command.c_str()); + success = sendTextFrame("commandvalues: " + std::string(values == nullptr ? "" : values)); + std::free(values); } return success; @@ -985,40 +985,40 @@ bool ChildSession::setPage(const char* /*buffer*/, int /*length*/, StringTokeniz /* If the user is inactive we have to remember important events so that when * the user becomes active again, we can replay the events. */ -void ChildSession::rememberEventsForInactiveUser(const int nType, const std::string& rPayload) +void ChildSession::rememberEventsForInactiveUser(const int type, const std::string& payload) { - if (nType == LOK_CALLBACK_INVALIDATE_VISIBLE_CURSOR || - nType == LOK_CALLBACK_CURSOR_VISIBLE || - nType == LOK_CALLBACK_TEXT_SELECTION || - nType == LOK_CALLBACK_TEXT_SELECTION_START || - nType == LOK_CALLBACK_TEXT_SELECTION_END || - nType == LOK_CALLBACK_CELL_FORMULA || - nType == LOK_CALLBACK_CELL_CURSOR || - nType == LOK_CALLBACK_GRAPHIC_SELECTION || - nType == LOK_CALLBACK_DOCUMENT_SIZE_CHANGED) + if (type == LOK_CALLBACK_INVALIDATE_VISIBLE_CURSOR || + type == LOK_CALLBACK_CURSOR_VISIBLE || + type == LOK_CALLBACK_TEXT_SELECTION || + type == LOK_CALLBACK_TEXT_SELECTION_START || + type == LOK_CALLBACK_TEXT_SELECTION_END || + type == LOK_CALLBACK_CELL_FORMULA || + type == LOK_CALLBACK_CELL_CURSOR || + type == LOK_CALLBACK_GRAPHIC_SELECTION || + type == LOK_CALLBACK_DOCUMENT_SIZE_CHANGED) { auto lock(getLock()); - _stateRecorder.recordEvent(nType, rPayload); + _stateRecorder.recordEvent(type, payload); } - else if (nType == LOK_CALLBACK_INVALIDATE_VIEW_CURSOR || - nType == LOK_CALLBACK_TEXT_VIEW_SELECTION || - nType == LOK_CALLBACK_CELL_VIEW_CURSOR || - nType == LOK_CALLBACK_GRAPHIC_VIEW_SELECTION || - nType == LOK_CALLBACK_VIEW_CURSOR_VISIBLE || - nType == LOK_CALLBACK_VIEW_LOCK) + else if (type == LOK_CALLBACK_INVALIDATE_VIEW_CURSOR || + type == LOK_CALLBACK_TEXT_VIEW_SELECTION || + type == LOK_CALLBACK_CELL_VIEW_CURSOR || + type == LOK_CALLBACK_GRAPHIC_VIEW_SELECTION || + type == LOK_CALLBACK_VIEW_CURSOR_VISIBLE || + type == LOK_CALLBACK_VIEW_LOCK) { auto lock(getLock()); Poco::JSON::Parser parser; - auto root = parser.parse(rPayload).extract<Poco::JSON::Object::Ptr>(); + auto root = parser.parse(payload).extract<Poco::JSON::Object::Ptr>(); int viewId = root->getValue<int>("viewId"); - _stateRecorder.recordViewEvent(viewId, nType, rPayload); + _stateRecorder.recordViewEvent(viewId, type, payload); } - else if (nType == LOK_CALLBACK_STATE_CHANGED) + else if (type == LOK_CALLBACK_STATE_CHANGED) { std::string name; std::string value; - if (LOOLProtocol::parseNameValuePair(rPayload, name, value, '=')) + if (LOOLProtocol::parseNameValuePair(payload, name, value, '=')) { auto lock(getLock()); _stateRecorder.recordState(name, value); @@ -1026,11 +1026,11 @@ void ChildSession::rememberEventsForInactiveUser(const int nType, const std::str } } -void ChildSession::loKitCallback(const int nType, const std::string& rPayload) +void ChildSession::loKitCallback(const int type, const std::string& payload) { - const auto typeName = LOKitHelper::kitCallbackTypeToString(nType); + const auto typeName = LOKitHelper::kitCallbackTypeToString(type); LOG_TRC("CallbackWorker::callback [" << getName() << "]: " << - typeName << " [" << rPayload << "]."); + typeName << " [" << payload << "]."); if (isCloseFrame()) { @@ -1044,21 +1044,21 @@ void ChildSession::loKitCallback(const int nType, const std::string& rPayload) } else if (!isActive()) { - rememberEventsForInactiveUser(nType, rPayload); + rememberEventsForInactiveUser(type, payload); // Pass save notifications through. - if (nType != LOK_CALLBACK_UNO_COMMAND_RESULT || rPayload.find(".uno:Save") == std::string::npos) + if (type != LOK_CALLBACK_UNO_COMMAND_RESULT || payload.find(".uno:Save") == std::string::npos) { LOG_TRC("Skipping callback [" << typeName << "] on inactive session " << getName()); return; } } - switch (nType) + switch (type) { case LOK_CALLBACK_INVALIDATE_TILES: { - StringTokenizer tokens(rPayload, ",", StringTokenizer::TOK_IGNORE_EMPTY | StringTokenizer::TOK_TRIM); + StringTokenizer tokens(payload, ",", StringTokenizer::TOK_IGNORE_EMPTY | StringTokenizer::TOK_TRIM); if (tokens.count() == 5) { int part, x, y, width, height; @@ -1095,48 +1095,48 @@ void ChildSession::loKitCallback(const int nType, const std::string& rPayload) } else { - sendTextFrame("invalidatetiles: " + rPayload); + sendTextFrame("invalidatetiles: " + payload); } } break; case LOK_CALLBACK_INVALIDATE_VISIBLE_CURSOR: - sendTextFrame("invalidatecursor: " + rPayload); + sendTextFrame("invalidatecursor: " + payload); break; case LOK_CALLBACK_TEXT_SELECTION: - sendTextFrame("textselection: " + rPayload); + sendTextFrame("textselection: " + payload); break; case LOK_CALLBACK_TEXT_SELECTION_START: - sendTextFrame("textselectionstart: " + rPayload); + sendTextFrame("textselectionstart: " + payload); break; case LOK_CALLBACK_TEXT_SELECTION_END: - sendTextFrame("textselectionend: " + rPayload); + sendTextFrame("textselectionend: " + payload); break; case LOK_CALLBACK_CURSOR_VISIBLE: - sendTextFrame("cursorvisible: " + rPayload); + sendTextFrame("cursorvisible: " + payload); break; case LOK_CALLBACK_GRAPHIC_SELECTION: - sendTextFrame("graphicselection: " + rPayload); + sendTextFrame("graphicselection: " + payload); break; case LOK_CALLBACK_CELL_CURSOR: - sendTextFrame("cellcursor: " + rPayload); + sendTextFrame("cellcursor: " + payload); break; case LOK_CALLBACK_CELL_FORMULA: - sendTextFrame("cellformula: " + rPayload); + sendTextFrame("cellformula: " + payload); break; case LOK_CALLBACK_MOUSE_POINTER: - sendTextFrame("mousepointer: " + rPayload); + sendTextFrame("mousepointer: " + payload); break; case LOK_CALLBACK_HYPERLINK_CLICKED: - sendTextFrame("hyperlinkclicked: " + rPayload); + sendTextFrame("hyperlinkclicked: " + payload); break; case LOK_CALLBACK_STATE_CHANGED: - sendTextFrame("statechanged: " + rPayload); + sendTextFrame("statechanged: " + payload); break; case LOK_CALLBACK_SEARCH_NOT_FOUND: - sendTextFrame("searchnotfound: " + rPayload); + sendTextFrame("searchnotfound: " + payload); break; case LOK_CALLBACK_SEARCH_RESULT_SELECTION: - sendTextFrame("searchresultselection: " + rPayload); + sendTextFrame("searchresultselection: " + payload); break; case LOK_CALLBACK_DOCUMENT_SIZE_CHANGED: { @@ -1161,16 +1161,16 @@ void ChildSession::loKitCallback(const int nType, const std::string& rPayload) } break; case LOK_CALLBACK_SET_PART: - sendTextFrame("setpart: " + rPayload); + sendTextFrame("setpart: " + payload); break; case LOK_CALLBACK_UNO_COMMAND_RESULT: - sendTextFrame("unocommandresult: " + rPayload); + sendTextFrame("unocommandresult: " + payload); break; case LOK_CALLBACK_ERROR: { - LOG_ERR("CALLBACK_ERROR: " << rPayload); + LOG_ERR("CALLBACK_ERROR: " << payload); Parser parser; - Poco::Dynamic::Var var = parser.parse(rPayload); + Poco::Dynamic::Var var = parser.parse(payload); Object::Ptr object = var.extract<Object::Ptr>(); sendTextFrame("error: cmd=" + object->get("cmd").toString() + @@ -1178,43 +1178,43 @@ void ChildSession::loKitCallback(const int nType, const std::string& rPayload) } break; case LOK_CALLBACK_CONTEXT_MENU: - sendTextFrame("contextmenu: " + rPayload); + sendTextFrame("contextmenu: " + payload); break; case LOK_CALLBACK_STATUS_INDICATOR_START: sendTextFrame("statusindicatorstart:"); break; case LOK_CALLBACK_STATUS_INDICATOR_SET_VALUE: - sendTextFrame("statusindicatorsetvalue: " + rPayload); + sendTextFrame("statusindicatorsetvalue: " + payload); break; case LOK_CALLBACK_STATUS_INDICATOR_FINISH: sendTextFrame("statusindicatorfinish:"); break; case LOK_CALLBACK_INVALIDATE_VIEW_CURSOR: - sendTextFrame("invalidateviewcursor: " + rPayload); + sendTextFrame("invalidateviewcursor: " + payload); break; case LOK_CALLBACK_TEXT_VIEW_SELECTION: - sendTextFrame("textviewselection: " + rPayload); + sendTextFrame("textviewselection: " + payload); break; case LOK_CALLBACK_CELL_VIEW_CURSOR: - sendTextFrame("cellviewcursor: " + rPayload); + sendTextFrame("cellviewcursor: " + payload); break; case LOK_CALLBACK_GRAPHIC_VIEW_SELECTION: - sendTextFrame("graphicviewselection: " + rPayload); + sendTextFrame("graphicviewselection: " + payload); break; case LOK_CALLBACK_VIEW_CURSOR_VISIBLE: - sendTextFrame("viewcursorvisible: " + rPayload); + sendTextFrame("viewcursorvisible: " + payload); break; case LOK_CALLBACK_VIEW_LOCK: - sendTextFrame("viewlock: " + rPayload); + sendTextFrame("viewlock: " + payload); break; case LOK_CALLBACK_REDLINE_TABLE_SIZE_CHANGED: - sendTextFrame("redlinetablechanged: " + rPayload); + sendTextFrame("redlinetablechanged: " + payload); break; case LOK_CALLBACK_REDLINE_TABLE_ENTRY_MODIFIED: - sendTextFrame("redlinetablemodified: " + rPayload); + sendTextFrame("redlinetablemodified: " + payload); break; default: - LOG_ERR("Unknown callback event (" << nType << "): " << rPayload); + LOG_ERR("Unknown callback event (" << type << "): " << payload); } } diff --git a/kit/ChildSession.hpp b/kit/ChildSession.hpp index d88ba8b..b1c0fb9 100644 --- a/kit/ChildSession.hpp +++ b/kit/ChildSession.hpp @@ -118,7 +118,7 @@ public: const std::string& getViewUserId() const { return _userId; } const std::string& getViewUserName() const { return _userName; } - void loKitCallback(const int nType, const std::string& rPayload); + void loKitCallback(const int type, const std::string& payload); bool sendTextFrame(const char* buffer, const int length) override { @@ -154,7 +154,7 @@ private: bool setClientPart(const char* buffer, int length, Poco::StringTokenizer& tokens); bool setPage(const char* buffer, int length, Poco::StringTokenizer& tokens); - void rememberEventsForInactiveUser(const int nType, const std::string& rPayload); + void rememberEventsForInactiveUser(const int type, const std::string& payload); virtual void disconnect() override; virtual bool _handleInput(const char* buffer, int length) override; diff --git a/kit/Kit.cpp b/kit/Kit.cpp index c2e2281..4aa58ed 100644 --- a/kit/Kit.cpp +++ b/kit/Kit.cpp @@ -95,7 +95,7 @@ using namespace LOOLProtocol; // We only host a single document in our lifetime. class Document; static std::shared_ptr<Document> document; -static LokHookFunction2* pInit = nullptr; +static LokHookFunction2* initFunction = nullptr; namespace { @@ -543,7 +543,7 @@ public: } /// Set Document password for given URL - void setDocumentPassword(int nPasswordType) + void setDocumentPassword(int passwordType) { LOG_INF("setDocumentPassword: passwordProtected=" << _isDocPasswordProtected << " passwordProvided=" << _haveDocPassword << @@ -560,9 +560,9 @@ public: // One thing for sure, this is a password protected document _isDocPasswordProtected = true; - if (nPasswordType == LOK_CALLBACK_DOCUMENT_PASSWORD) + if (passwordType == LOK_CALLBACK_DOCUMENT_PASSWORD) _docPasswordType = PasswordType::ToView; - else if (nPasswordType == LOK_CALLBACK_DOCUMENT_PASSWORD_TO_MODIFY) + else if (passwordType == LOK_CALLBACK_DOCUMENT_PASSWORD_TO_MODIFY) _docPasswordType = PasswordType::ToModify; LOG_INF("Calling _loKit->setDocumentPassword"); @@ -779,50 +779,50 @@ public: return false; } - static void GlobalCallback(const int nType, const char* pPayload, void* pData) + static void GlobalCallback(const int type, const char* p, void* data) { if (TerminationFlag) { return; } - const std::string payload = pPayload ? pPayload : "(nil)"; - LOG_TRC("Document::GlobalCallback " << LOKitHelper::kitCallbackTypeToString(nType) << + const std::string payload = p ? p : "(nil)"; + LOG_TRC("Document::GlobalCallback " << LOKitHelper::kitCallbackTypeToString(type) << " [" << payload << "]."); - Document* self = static_cast<Document*>(pData); - if (nType == LOK_CALLBACK_DOCUMENT_PASSWORD_TO_MODIFY || - nType == LOK_CALLBACK_DOCUMENT_PASSWORD) + Document* self = static_cast<Document*>(data); + if (type == LOK_CALLBACK_DOCUMENT_PASSWORD_TO_MODIFY || + type == LOK_CALLBACK_DOCUMENT_PASSWORD) { // Mark the document password type. - self->setDocumentPassword(nType); + self->setDocumentPassword(type); return; } // Broadcast leftover status indicator callbacks to all clients - self->broadcastCallbackToClients(nType, payload); + self->broadcastCallbackToClients(type, payload); } - static void ViewCallback(const int nType, const char* pPayload, void* pData) + static void ViewCallback(const int type, const char* p, void* data) { if (TerminationFlag) { return; } - CallbackDescriptor* pDescr = static_cast<CallbackDescriptor*>(pData); - assert(pDescr && "Null callback data."); - assert(pDescr->Doc && "Null Document instance."); + CallbackDescriptor* descriptor = static_cast<CallbackDescriptor*>(data); + assert(descriptor && "Null callback data."); + assert(descriptor->Doc && "Null Document instance."); - auto tileQueue = pDescr->Doc->getTileQueue(); + auto tileQueue = descriptor->Doc->getTileQueue(); assert(tileQueue && "Null TileQueue."); - const std::string payload = pPayload ? pPayload : "(nil)"; - LOG_TRC("Document::ViewCallback [" << pDescr->ViewId << - "] [" << LOKitHelper::kitCallbackTypeToString(nType) << + const std::string payload = p ? p : "(nil)"; + LOG_TRC("Document::ViewCallback [" << descriptor->ViewId << + "] [" << LOKitHelper::kitCallbackTypeToString(type) << "] [" << payload << "]."); - if (nType == LOK_CALLBACK_INVALIDATE_VISIBLE_CURSOR || - nType == LOK_CALLBACK_CELL_CURSOR) + if (type == LOK_CALLBACK_INVALIDATE_VISIBLE_CURSOR || + type == LOK_CALLBACK_CELL_CURSOR) { Poco::StringTokenizer tokens(payload, ",", Poco::StringTokenizer::TOK_IGNORE_EMPTY | Poco::StringTokenizer::TOK_TRIM); // Payload may be 'EMPTY'. @@ -836,8 +836,8 @@ public: tileQueue->updateCursorPosition(0, 0, cursorX, cursorY, cursorWidth, cursorHeight); } } - else if (nType == LOK_CALLBACK_INVALIDATE_VIEW_CURSOR || - nType == LOK_CALLBACK_CELL_VIEW_CURSOR) + else if (type == LOK_CALLBACK_INVALIDATE_VIEW_CURSOR || + type == LOK_CALLBACK_CELL_VIEW_CURSOR) { Poco::JSON::Parser parser; const auto result = parser.parse(payload); @@ -858,16 +858,16 @@ public: } } - tileQueue->put("callback " + std::to_string(pDescr->ViewId) + ' ' + std::to_string(nType) + ' ' + payload); + tileQueue->put("callback " + std::to_string(descriptor->ViewId) + ' ' + std::to_string(type) + ' ' + payload); } private: /// Helper method to broadcast callback and its payload to all clients - void broadcastCallbackToClients(const int nType, const std::string& payload) + void broadcastCallbackToClients(const int type, const std::string& payload) { // "-1" means broadcast - _tileQueue->put("callback -1 " + std::to_string(nType) + ' ' + payload); + _tileQueue->put("callback -1 " + std::to_string(type) + ' ' + payload); } /// Load a document (or view) and register callbacks. @@ -1058,9 +1058,9 @@ private: { std::unique_lock<std::mutex> lock(_documentMutex); - char* pValues = _loKitDocument->getCommandValues(".uno:TrackedChangeAuthors"); - colorValues = std::string(pValues == nullptr ? "" : pValues); - std::free(pValues); + char* values = _loKitDocument->getCommandValues(".uno:TrackedChangeAuthors"); + colorValues = std::string(values == nullptr ? "" : values); + std::free(values); } try @@ -1455,9 +1455,9 @@ private: Poco::Thread _callbackThread; }; -void documentViewCallback(const int nType, const char* pPayload, void* pData) +void documentViewCallback(const int type, const char* payload, void* data) { - Document::ViewCallback(nType, pPayload, pData); + Document::ViewCallback(type, payload, data); } #ifndef BUILDING_TESTS @@ -1619,7 +1619,7 @@ void lokit_main(const std::string& childRoot, auto kit = UnitKit::get().lok_init(instdir, userdir); if (!kit) { - kit = (pInit ? pInit(instdir, userdir) : lok_init_2(instdir, userdir)); + kit = (initFunction ? initFunction(instdir, userdir) : lok_init_2(instdir, userdir)); } loKit = std::make_shared<lok::Office>(kit); @@ -1817,8 +1817,8 @@ bool globalPreinit(const std::string &loTemplate) return false; } - pInit = reinterpret_cast<LokHookFunction2 *>(dlsym(handle, "libreofficekit_hook_2")); - if (!pInit) + initFunction = reinterpret_cast<LokHookFunction2 *>(dlsym(handle, "libreofficekit_hook_2")); + if (!initFunction) { LOG_FTL("No libreofficekit_hook_2 symbol in " << loadedLibrary << ": " << dlerror()); } diff --git a/kit/Kit.hpp b/kit/Kit.hpp index b60ebe2..8431d76 100644 --- a/kit/Kit.hpp +++ b/kit/Kit.hpp @@ -19,7 +19,7 @@ void lokit_main(const std::string& childRoot, bool globalPreinit(const std::string& loTemplate); /// Wrapper around private Document::ViewCallback(). -void documentViewCallback(const int nType, const char* pPayload, void* pData); +void documentViewCallback(const int type, const char* p, void* data); class IDocumentManager; diff --git a/kit/KitHelper.hpp b/kit/KitHelper.hpp index f029450..7afa22a 100644 --- a/kit/KitHelper.hpp +++ b/kit/KitHelper.hpp @@ -43,10 +43,10 @@ namespace LOKitHelper return documentTypeToString(type); } - inline std::string kitCallbackTypeToString(const int nType) + inline std::string kitCallbackTypeToString(const int type) { // Keep in the same order as in LibreOfficeKitEnums.h - switch (nType) + switch (type) { case LOK_CALLBACK_INVALIDATE_TILES: return "INVALIDATE_TILES"; @@ -110,7 +110,7 @@ namespace LOKitHelper return "VIEW_LOCK"; } - return std::to_string(nType); + return std::to_string(type); } inline std::string documentStatus(LibreOfficeKitDocument *loKitDocument) diff --git a/tools/KitClient.cpp b/tools/KitClient.cpp index 30cffbe..dcc2ed3 100644 --- a/tools/KitClient.cpp +++ b/tools/KitClient.cpp @@ -36,10 +36,10 @@ using Poco::Util::Application; extern "C" { - static void myCallback(int nType, const char* pPayload, void*) + static void myCallback(int type, const char* payload, void*) { std::cout << "Callback: "; - switch ((LibreOfficeKitCallbackType) nType) + switch ((LibreOfficeKitCallbackType) type) { #define CASE(x) case LOK_CALLBACK_##x: std::cout << #x; break CASE(INVALIDATE_TILES); @@ -76,7 +76,7 @@ extern "C" CASE(REDLINE_TABLE_ENTRY_MODIFIED); #undef CASE } - std::cout << " payload: " << pPayload << std::endl; + std::cout << " payload: " << payload << std::endl; } } diff --git a/wsd/Admin.hpp b/wsd/Admin.hpp index 2c88cd2..52f0bd8 100644 --- a/wsd/Admin.hpp +++ b/wsd/Admin.hpp @@ -35,7 +35,7 @@ public: void handleRequest(Poco::Net::HTTPServerRequest& request, Poco::Net::HTTPServerResponse& response) override; private: - void handleWSRequests(Poco::Net::HTTPServerRequest& request, Poco::Net::HTTPServerResponse& response, int nSessionId); + void handleWSRequests(Poco::Net::HTTPServerRequest& request, Poco::Net::HTTPServerResponse& response, int sessionId); void sendTextFrame(const std::string& message); diff --git a/wsd/AdminModel.cpp b/wsd/AdminModel.cpp index 2f71486..680c647 100644 --- a/wsd/AdminModel.cpp +++ b/wsd/AdminModel.cpp @@ -147,27 +147,27 @@ unsigned AdminModel::getTotalMemoryUsage() return totalMem; } -void AdminModel::subscribe(int nSessionId, std::shared_ptr<LOOLWebSocket>& ws) +void AdminModel::subscribe(int sessionId, std::shared_ptr<LOOLWebSocket>& ws) { - const auto ret = _subscribers.emplace(nSessionId, Subscriber(nSessionId, ws)); + const auto ret = _subscribers.emplace(sessionId, Subscriber(sessionId, ws)); if (!ret.second) { Log::warn() << "Subscriber already exists" << Log::end; } } -void AdminModel::subscribe(int nSessionId, const std::string& command) +void AdminModel::subscribe(int sessionId, const std::string& command) { - auto subscriber = _subscribers.find(nSessionId); + auto subscriber = _subscribers.find(sessionId); if (subscriber != _subscribers.end()) { subscriber->second.subscribe(command); } } -void AdminModel::unsubscribe(int nSessionId, const std::string& command) +void AdminModel::unsubscribe(int sessionId, const std::string& command) { - auto subscriber = _subscribers.find(nSessionId); + auto subscriber = _subscribers.find(sessionId); if (subscriber != _subscribers.end()) { subscriber->second.unsubscribe(command); @@ -326,16 +326,16 @@ std::string AdminModel::getCpuStats() unsigned AdminModel::getTotalActiveViews() { - unsigned nTotalViews = 0; + unsigned numTotalViews = 0; for (const auto& it: _documents) { if (!it.second.isExpired()) { - nTotalViews += it.second.getActiveViews(); + numTotalViews += it.second.getActiveViews(); } } - return nTotalViews; + return numTotalViews; } std::string AdminModel::getDocuments() const diff --git a/wsd/LOOLWSD.cpp b/wsd/LOOLWSD.cpp index 65452fa..7976b97 100644 --- a/wsd/LOOLWSD.cpp +++ b/wsd/LOOLWSD.cpp @@ -1699,8 +1699,8 @@ void LOOLWSD::initialize(Application& self) { "trace[@enable]", "false" } }; // Set default values, in case they are missing from the config file. - AutoPtr<AppConfigMap> pDefConfig(new AppConfigMap(DefAppConfig)); - conf.addWriteable(pDefConfig, PRIO_SYSTEM); // Lowest priority + AutoPtr<AppConfigMap> defConfig(new AppConfigMap(DefAppConfig)); + conf.addWriteable(defConfig, PRIO_SYSTEM); // Lowest priority // Load default configuration files, if present. if (loadConfiguration(PRIO_DEFAULT) == 0) @@ -1711,8 +1711,8 @@ void LOOLWSD::initialize(Application& self) } // Override any settings passed on the command-line. - AutoPtr<AppConfigMap> pOverrideConfig(new AppConfigMap(_overrideSettings)); - conf.addWriteable(pOverrideConfig, PRIO_APPLICATION); // Highest priority + AutoPtr<AppConfigMap> overrideConfig(new AppConfigMap(_overrideSettings)); + conf.addWriteable(overrideConfig, PRIO_APPLICATION); // Highest priority // Allow UT to manipulate before using configuration values. UnitWSD::get().configure(config()); @@ -1887,27 +1887,27 @@ void LOOLWSD::initializeSSL() Poco::Net::SSLManager::instance().initializeClient(consoleClientHandler, invalidClientCertHandler, sslClientContext); } -void LOOLWSD::dumpEventTrace(const std::string& pId, const std::string& sessionId, const std::string& data) +void LOOLWSD::dumpEventTrace(const std::string& id, const std::string& sessionId, const std::string& data) { if (TraceDumper) { - TraceDumper->writeEvent(pId, sessionId, data); + TraceDumper->writeEvent(id, sessionId, data); } } -void LOOLWSD::dumpIncomingTrace(const std::string& pId, const std::string& sessionId, const std::string& data) +void LOOLWSD::dumpIncomingTrace(const std::string& id, const std::string& sessionId, const std::string& data) { if (TraceDumper) { - TraceDumper->writeIncoming(pId, sessionId, data); + TraceDumper->writeIncoming(id, sessionId, data); } } -void LOOLWSD::dumpOutgoingTrace(const std::string& pId, const std::string& sessionId, const std::string& data) +void LOOLWSD::dumpOutgoingTrace(const std::string& id, const std::string& sessionId, const std::string& data) { if (TraceDumper) { - TraceDumper->writeOutgoing(pId, sessionId, data); + TraceDumper->writeOutgoing(id, sessionId, data); } } diff --git a/wsd/LOOLWSD.hpp b/wsd/LOOLWSD.hpp index 0f7ecd3..a8d364e 100644 --- a/wsd/LOOLWSD.hpp +++ b/wsd/LOOLWSD.hpp @@ -62,11 +62,11 @@ public: return LOOLWSD::SSLTermination.get(); } - static void dumpEventTrace(const std::string& pId, const std::string& sessionId, const std::string& data); + static void dumpEventTrace(const std::string& id, const std::string& sessionId, const std::string& data); - static void dumpIncomingTrace(const std::string& pId, const std::string& sessionId, const std::string& data); + static void dumpIncomingTrace(const std::string& id, const std::string& sessionId, const std::string& data); - static void dumpOutgoingTrace(const std::string& pId, const std::string& sessionId, const std::string& data); + static void dumpOutgoingTrace(const std::string& id, const std::string& sessionId, const std::string& data); protected: void initialize(Poco::Util::Application& self) override; diff --git a/wsd/TraceFile.hpp b/wsd/TraceFile.hpp index f6c87b7..62616ac 100644 --- a/wsd/TraceFile.hpp +++ b/wsd/TraceFile.hpp @@ -72,31 +72,31 @@ public: _stream.close(); } - void writeEvent(const std::string& pId, const std::string& sessionId, const std::string& data) + void writeEvent(const std::string& id, const std::string& sessionId, const std::string& data) { std::unique_lock<std::mutex> lock(_mutex); - writeLocked(pId, sessionId, data, static_cast<char>(TraceFileRecord::Direction::Event)); + writeLocked(id, sessionId, data, static_cast<char>(TraceFileRecord::Direction::Event)); flushLocked(); } - void writeIncoming(const std::string& pId, const std::string& sessionId, const std::string& data) + void writeIncoming(const std::string& id, const std::string& sessionId, const std::string& data) { std::unique_lock<std::mutex> lock(_mutex); if (_filter.match(data)) { - writeLocked(pId, sessionId, data, static_cast<char>(TraceFileRecord::Direction::Incoming)); + writeLocked(id, sessionId, data, static_cast<char>(TraceFileRecord::Direction::Incoming)); } } - void writeOutgoing(const std::string& pId, const std::string& sessionId, const std::string& data) + void writeOutgoing(const std::string& id, const std::string& sessionId, const std::string& data) { std::unique_lock<std::mutex> lock(_mutex); if (_recordOutgoing && _filter.match(data)) { - writeLocked(pId, sessionId, data, static_cast<char>(TraceFileRecord::Direction::Outgoing)); + writeLocked(id, sessionId, data, static_cast<char>(TraceFileRecord::Direction::Outgoing)); } } @@ -109,7 +109,7 @@ private: _stream.flush(); } - void writeLocked(const std::string& pId, const std::string& sessionId, const std::string& data, const char delim) + void writeLocked(const std::string& id, const std::string& sessionId, const std::string& data, const char delim) { Util::assertIsLocked(_mutex); @@ -119,7 +119,7 @@ private: _deflater.write(&delim, 1); _deflater << usec; _deflater.write(&delim, 1); - _deflater << pId; + _deflater << id; _deflater.write(&delim, 1); _deflater << sessionId; _deflater.write(&delim, 1); @@ -131,7 +131,7 @@ private: _stream.write(&delim, 1); _stream << usec; _stream.write(&delim, 1); - _stream << pId; + _stream << id; _stream.write(&delim, 1); _stream << sessionId; _stream.write(&delim, 1); commit 04bdf8d623c4488e13b85e21448cb44916eb5401 Author: Tor Lillqvist <t...@collabora.com> Date: Fri Jan 13 14:14:36 2017 +0200 Bin unused code Change-Id: I71b7a5f8d769e033b489ae5ea0fbd4425db2184e diff --git a/common/Protocol.cpp b/common/Protocol.cpp index f2e6fc3..a6a24b9 100644 --- a/common/Protocol.cpp +++ b/common/Protocol.cpp @@ -218,39 +218,6 @@ namespace LOOLProtocol Poco::StringTokenizer tokens(message, " \n", StringTokenizer::TOK_IGNORE_EMPTY | StringTokenizer::TOK_TRIM); return getTokenKeyword(tokens, name, map, value); } - - bool parseStatus(const std::string& message, LibreOfficeKitDocumentType& type, int& nParts, int& currentPart, int& width, int& height) - { - StringTokenizer tokens(message, " ", StringTokenizer::TOK_IGNORE_EMPTY | StringTokenizer::TOK_TRIM); - - assert(tokens.count() == 6); - assert(tokens[0] == "status:"); - - std::string typeString; - if (!getTokenString(tokens[1], "type", typeString)) - return false; - - if (typeString == "text") - type = LOK_DOCTYPE_TEXT; - else if (typeString == "spreadsheet") - type = LOK_DOCTYPE_SPREADSHEET; - else if (typeString == "presentation") - type = LOK_DOCTYPE_PRESENTATION; - else if (typeString == "drawing") - type = LOK_DOCTYPE_PRESENTATION; - else if (typeString == "other") - type = LOK_DOCTYPE_OTHER; - else - return false; - - if (!getTokenInteger(tokens[2], "parts", nParts) || - !getTokenInteger(tokens[3], "current", currentPart) || - !getTokenInteger(tokens[4], "width", width) || - !getTokenInteger(tokens[5], "height", height)) - return false; - - return true; - } }; /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/common/Protocol.hpp b/common/Protocol.hpp index 0e544b0..6d4e5cb 100644 --- a/common/Protocol.hpp +++ b/common/Protocol.hpp @@ -78,9 +78,6 @@ namespace LOOLProtocol bool getTokenStringFromMessage(const std::string& message, const std::string& name, std::string& value); bool getTokenKeywordFromMessage(const std::string& message, const std::string& name, const std::map<std::string, int>& map, int& value); - // Functions that parse messages. All return false if parsing fails - bool parseStatus(const std::string& message, LibreOfficeKitDocumentType& type, int& nParts, int& currentPart, int& width, int& height); - /// Tokenize space-delimited values until we hit new-line or the end. inline std::vector<std::string> tokenize(const char* data, const size_t size) _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits