From 4e52ee9ebd6672bb3f1099e27f3cd2cf9a0635d4 Mon Sep 17 00:00:00 2001 From: Dominik Schmidt Date: Thu, 4 Jan 2018 20:51:12 +0100 Subject: [PATCH] Build Explorer extension if building with MSVC --- shell_integration/CMakeLists.txt | 4 + shell_integration/windows/CMakeLists.txt | 4 + .../windows/OCContextMenu/CMakeLists.txt | 16 + .../windows/OCOverlays/CMakeLists.txt | 15 + .../windows/OCUtil/CMakeLists.txt | 17 + .../windows/OCUtil/OCMessage.cpp | 74 ---- shell_integration/windows/OCUtil/OCMessage.h | 42 -- .../windows/OCUtil/ParserUtil.cpp | 389 ------------------ 8 files changed, 56 insertions(+), 505 deletions(-) create mode 100644 shell_integration/windows/CMakeLists.txt create mode 100644 shell_integration/windows/OCContextMenu/CMakeLists.txt create mode 100644 shell_integration/windows/OCOverlays/CMakeLists.txt create mode 100644 shell_integration/windows/OCUtil/CMakeLists.txt delete mode 100644 shell_integration/windows/OCUtil/OCMessage.cpp delete mode 100644 shell_integration/windows/OCUtil/OCMessage.h delete mode 100644 shell_integration/windows/OCUtil/ParserUtil.cpp diff --git a/shell_integration/CMakeLists.txt b/shell_integration/CMakeLists.txt index 87c453bf2..959d94b7e 100644 --- a/shell_integration/CMakeLists.txt +++ b/shell_integration/CMakeLists.txt @@ -21,3 +21,7 @@ if( UNIX AND NOT APPLE ) endif() endif() endif() + +if(MSVC) + add_subdirectory(windows) +endif() diff --git a/shell_integration/windows/CMakeLists.txt b/shell_integration/windows/CMakeLists.txt new file mode 100644 index 000000000..b9c080b6e --- /dev/null +++ b/shell_integration/windows/CMakeLists.txt @@ -0,0 +1,4 @@ +add_subdirectory(OCContextMenu) +add_subdirectory(OCOverlays) +add_subdirectory(OCUtil) + diff --git a/shell_integration/windows/OCContextMenu/CMakeLists.txt b/shell_integration/windows/OCContextMenu/CMakeLists.txt new file mode 100644 index 000000000..27f45f582 --- /dev/null +++ b/shell_integration/windows/OCContextMenu/CMakeLists.txt @@ -0,0 +1,16 @@ +add_library(OCContextMenu MODULE + dllmain.cpp + OCClientInterface.cpp + OCContextMenu.cpp + OCContextMenuFactory.cpp + OCContextMenuRegHandler.cpp + stdafx.cpp +) + +target_link_libraries(OCContextMenu + OCUtil) + +install(TARGETS OCContextMenu + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} +) diff --git a/shell_integration/windows/OCOverlays/CMakeLists.txt b/shell_integration/windows/OCOverlays/CMakeLists.txt new file mode 100644 index 000000000..5e3cb7dff --- /dev/null +++ b/shell_integration/windows/OCOverlays/CMakeLists.txt @@ -0,0 +1,15 @@ +add_library(OCOverlays MODULE + DllMain.cpp + OCOverlay.cpp + OCOverlayFactory.cpp + OCOverlayRegistrationHandler.cpp + stdafx.cpp +) + +target_link_libraries(OCOverlays + OCUtil) + +install(TARGETS OCOverlays + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} +) diff --git a/shell_integration/windows/OCUtil/CMakeLists.txt b/shell_integration/windows/OCUtil/CMakeLists.txt new file mode 100644 index 000000000..718a6c327 --- /dev/null +++ b/shell_integration/windows/OCUtil/CMakeLists.txt @@ -0,0 +1,17 @@ +add_library(OCUtil SHARED + CommunicationSocket.cpp + FileUtil.cpp + RegistryUtil.cpp + RemotePathChecker.cpp + stdafx.cpp + StringUtil.cpp +) + +target_include_directories(OCUtil + PUBLIC + "${CMAKE_CURRENT_SOURCE_DIR}" +) + +install(TARGETS OCUtil + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} +) diff --git a/shell_integration/windows/OCUtil/OCMessage.cpp b/shell_integration/windows/OCUtil/OCMessage.cpp deleted file mode 100644 index 31da93180..000000000 --- a/shell_integration/windows/OCUtil/OCMessage.cpp +++ /dev/null @@ -1,74 +0,0 @@ -/** - * Copyright (c) 2000-2013 Liferay, Inc. All rights reserved. - * - * This library is free software; you can redistribute it and/or modify it under - * the terms of the GNU Lesser General Public License as published by the Free - * Software Foundation; either version 2.1 of the License, or (at your option) - * any later version. - * - * This library is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more - * details. - */ - -#include "OCMessage.h" -#include "ParserUtil.h" -#include "UtilConstants.h" - -#include - -#include -#include - -using namespace std; - -OCMessage::OCMessage(void) -{ - _command = new wstring(); - _value = new wstring(); -} - -OCMessage::~OCMessage(void) -{ -} - -bool OCMessage::InitFromMessage(const wstring* message) -{ - if(message->length() == 0) - { - return false; - } - - if(!ParserUtil::GetItem(COMMAND, message, _command)) - { - return false; - } - - if(!ParserUtil::GetItem(VALUE, message, _value)) - { - return false; - } - - return true; -} - -std::wstring* OCMessage::GetCommand() -{ - return _command; -} - -std::wstring* OCMessage::GetValue() -{ - return _value; -} - -void OCMessage::SetCommand(std::wstring* command) -{ - _command = command; -} - -void OCMessage::SetValue(std::wstring* value) -{ - _value = value; -} diff --git a/shell_integration/windows/OCUtil/OCMessage.h b/shell_integration/windows/OCUtil/OCMessage.h deleted file mode 100644 index 7b0eefca3..000000000 --- a/shell_integration/windows/OCUtil/OCMessage.h +++ /dev/null @@ -1,42 +0,0 @@ -/** - * Copyright (c) 2000-2013 Liferay, Inc. All rights reserved. - * - * This library is free software; you can redistribute it and/or modify it under - * the terms of the GNU Lesser General Public License as published by the Free - * Software Foundation; either version 2.1 of the License, or (at your option) - * any later version. - * - * This library is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more - * details. - */ - -#ifndef OCMESSAGE_H -#define OCMESSAGE_H - -#include - -#pragma once - -class __declspec(dllexport) OCMessage -{ -public: - OCMessage(void); - ~OCMessage(void); - - bool InitFromMessage(const std::wstring*); - - std::wstring* GetCommand(); - std::wstring* GetValue(); - - void SetCommand(std::wstring*); - void SetValue(std::wstring*); - -private: - - std::wstring* _command; - std::wstring* _value; -}; - -#endif \ No newline at end of file diff --git a/shell_integration/windows/OCUtil/ParserUtil.cpp b/shell_integration/windows/OCUtil/ParserUtil.cpp deleted file mode 100644 index 5ca05f670..000000000 --- a/shell_integration/windows/OCUtil/ParserUtil.cpp +++ /dev/null @@ -1,389 +0,0 @@ -/** - * Copyright (c) 2000-2013 Liferay, Inc. All rights reserved. - * - * This library is free software; you can redistribute it and/or modify it under - * the terms of the GNU Lesser General Public License as published by the Free - * Software Foundation; either version 2.1 of the License, or (at your option) - * any later version. - * - * This library is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more - * details. - */ - -#include "ParserUtil.h" -#include "UtilConstants.h" - -#include - -using namespace std; - -bool ParserUtil::GetItem(const wchar_t* item, const wstring* message, wstring* result) -{ - size_t start = message->find(item, 0); - - if(start == string::npos) - { - return false; - } - - size_t end = message->find(COLON, start); - - if(end == string::npos) - { - return false; - } - - //Move to next character after : - end += 1; - - wchar_t c = message->at(end); - - //Move to the next character, which is the start of the value - end += 1; - - if(c == '[') - { - return GetList(end - 1, message, result); - } - else - { - return GetValue(end, message, result); - } -} - -bool ParserUtil::GetList(size_t start, const wstring* message, wstring* result) -{ - size_t end = start + 1; - - int openBraceCount = 1; - - while(openBraceCount > 0) - { - size_t closeBraceLocation = message->find(CLOSE_BRACE, end); - size_t openBraceLocation = message->find(OPEN_BRACE, end); - - if(closeBraceLocation < openBraceLocation) - { - openBraceCount--; - end = closeBraceLocation + 1; - } - else if(openBraceLocation < closeBraceLocation) - { - openBraceCount++; - end = openBraceLocation + 1; - } - - } - - size_t length = end - start; - - return GetString(start, end, message, result); -} - -size_t ParserUtil::GetNextStringItemInList(const wstring* message, size_t start, wstring* result) -{ - size_t end = string::npos; - size_t commaLocation = message->find(COMMA, start); - - if(commaLocation == string::npos) - { - end = message->find(CLOSE_BRACE, start); - if(end == string::npos) - { - end = message->length(); - } - else - { - end = end - 1; - } - } - else - { - end = commaLocation - 1; - } - - if(!GetString(start + 2, end, message, result)) - { - return string::npos; - } - - return end + 2; -} - -size_t ParserUtil::GetNextOCItemInList(const wstring* message, size_t start, wstring* result) -{ - size_t end = message->find(OPEN_CURLY_BRACE, start) + 1; - - int openBraceCount = 1; - - while(openBraceCount > 0) - { - size_t closeBraceLocation = message->find(CLOSE_CURLY_BRACE, end); - size_t openBraceLocation = message->find(OPEN_CURLY_BRACE, end); - - if(closeBraceLocation < openBraceLocation) - { - openBraceCount--; - end = closeBraceLocation + 1; - } - else if(openBraceLocation < closeBraceLocation) - { - openBraceCount++; - end = openBraceLocation + 1; - } - } - - size_t length = end - start; - - if(!GetString(start, end, message, result)) - { - return string::npos; - } - - return end; -} - -bool ParserUtil::GetValue(size_t start, const wstring* message, wstring* result) -{ - if(message->at(start - 1) == '\"') - { - size_t end = message->find(QUOTE, start); - return GetString(start, end, message, result); - } - else - { - start = start - 1; - - size_t end = message->find(COMMA, start); - - result->append(message->substr(start, end-start)); - } - - return true; -} - -bool ParserUtil::GetString(size_t start, size_t end, const wstring* message, wstring* result) -{ - if(end == string::npos) - { - return false; - } - - size_t length = end - start; - - if(length > 0) - { - result->append(message->substr(start, length)); - } - else - { - result->append(L""); - } - - - return true; -} - -bool ParserUtil::IsList(wstring* message) -{ - wchar_t c = message->at(0); - - if(c == '[') - { - return true; - } - - return false; -} - -bool ParserUtil::ParseJsonList(wstring* message, vector* items) -{ - - size_t currentLocation = message->find(OPEN_BRACE, 0); - - while(currentLocation < message->size()) - { - wstring* item = new wstring(); - - currentLocation = ParserUtil::GetNextStringItemInList(message, currentLocation, item); - - if(currentLocation == string::npos) - { - return false; - } - - items->push_back(item); - } - - return true; -} - -bool ParserUtil::ParseOCList(wstring* message, vector* items) -{ - - size_t currentLocation = message->find(OPEN_CURLY_BRACE, 0); - - while(currentLocation < message->size()) - { - wstring* item = new wstring(); - - currentLocation = ParserUtil::GetNextOCItemInList(message, currentLocation, item); - - if(currentLocation == string::npos) - { - return false; - } - - items->push_back(item); - } - - return true; -} - -bool ParserUtil::ParseOCMessageList(wstring* message, vector* messages) -{ - vector* items = new vector(); - - if(!ParseOCList(message, items)) - { - return false; - } - - for(vector::iterator it = items->begin(); it != items->end(); it++) - { - wstring* temp = *it; - - OCMessage* message = new OCMessage(); - message->InitFromMessage(temp); - - messages->push_back(message); - } - - return true; -} - -bool ParserUtil::SerializeList(std::vector* list, std::wstring* result, bool escapeQuotes) -{ - if(result == 0) - { - return false; - } - - result->append(OPEN_BRACE); - - for(vector::iterator it = list->begin(); it != list->end(); it++) - { - wstring value = *it; - - if(escapeQuotes) - { - result->append(BACK_SLASH); - } - - result->append(QUOTE); - result->append(value.c_str()); - - if(escapeQuotes) - { - result->append(BACK_SLASH); - } - - result->append(QUOTE); - result->append(COMMA); - } - - //Erase last comma - result->erase(result->size() - 1, 1); - - result->append(CLOSE_BRACE); - - return true; -} - -bool ParserUtil::SerializeMessage(std::map* arguments, std::wstring* result, bool escapeQuotes) -{ - if(result == 0) - { - return false; - } - - result->append(OPEN_CURLY_BRACE); - - for(map::iterator it = arguments->begin(); it != arguments->end(); it++) - { - wstring key = *it->first; - wstring value = *it->second; - - if(escapeQuotes) - { - result->append(BACK_SLASH); - } - - result->append(QUOTE); - result->append(key.c_str()); - - if(escapeQuotes) - { - result->append(BACK_SLASH); - } - - result->append(QUOTE); - result->append(COLON); - result->append(value.c_str()); - result->append(COMMA); - } - - //Erase last comma - result->erase(result->size() - 1, 1); - - result->append(CLOSE_CURLY_BRACE); - - return true; -} - -bool ParserUtil::SerializeMessage(OCMessage* OCMessage, std::wstring* result) -{ - if(result == 0) - { - return false; - } - - result->append(OPEN_CURLY_BRACE); - - result->append(QUOTE); - result->append(COMMAND); - result->append(QUOTE); - - result->append(COLON); - - result->append(QUOTE); - result->append(OCMessage->GetCommand()->c_str()); - result->append(QUOTE); - - result->append(COMMA); - - result->append(QUOTE); - result->append(VALUE); - result->append(QUOTE); - - result->append(COLON); - - if(!IsList(OCMessage->GetValue())) - { - result->append(QUOTE); - } - - result->append(OCMessage->GetValue()->c_str()); - - if(!IsList(OCMessage->GetValue())) - { - result->append(QUOTE); - } - - result->append(CLOSE_CURLY_BRACE); - - return true; -} -