diff --git a/shell_integration/windows/CMakeLists.txt b/shell_integration/windows/CMakeLists.txt index 068c8b1d1..a350b09d6 100644 --- a/shell_integration/windows/CMakeLists.txt +++ b/shell_integration/windows/CMakeLists.txt @@ -9,7 +9,7 @@ include_directories( configure_file(WinShellExtConstants.h.in ${CMAKE_CURRENT_BINARY_DIR}/WinShellExtConstants.h) configure_file(WinShellExtConstants.wxi.in ${CMAKE_CURRENT_BINARY_DIR}/WinShellExtConstants.wxi) -add_subdirectory(OCContextMenu) -add_subdirectory(OCOverlays) -add_subdirectory(OCUtil) +add_subdirectory(NCContextMenu) +add_subdirectory(NCOverlays) +add_subdirectory(NCUtil) diff --git a/shell_integration/windows/NCContextMenu/CMakeLists.txt b/shell_integration/windows/NCContextMenu/CMakeLists.txt new file mode 100644 index 000000000..f8f9dc324 --- /dev/null +++ b/shell_integration/windows/NCContextMenu/CMakeLists.txt @@ -0,0 +1,17 @@ +add_library(NCContextMenu MODULE + dllmain.cpp + NCClientInterface.cpp + NCContextMenu.cpp + NCContextMenuFactory.cpp + NCContextMenuRegHandler.cpp + NCContextMenu.rc + NCContextMenu.def +) + +target_link_libraries(NCContextMenu + NCUtil) + +install(TARGETS NCContextMenu + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} + LIBRARY DESTINATION ${CMAKE_INSTALL_BINDIR} +) diff --git a/shell_integration/windows/OCContextMenu/OCClientInterface.cpp b/shell_integration/windows/NCContextMenu/NCClientInterface.cpp similarity index 94% rename from shell_integration/windows/OCContextMenu/OCClientInterface.cpp rename to shell_integration/windows/NCContextMenu/NCClientInterface.cpp index ad7a35564..6db4a27c9 100644 --- a/shell_integration/windows/OCContextMenu/OCClientInterface.cpp +++ b/shell_integration/windows/NCContextMenu/NCClientInterface.cpp @@ -12,7 +12,7 @@ * details. */ -#include "OCClientInterface.h" +#include "NCClientInterface.h" #include "CommunicationSocket.h" #include "StringUtil.h" @@ -31,7 +31,7 @@ using namespace std; #define PIPE_TIMEOUT 5*1000 //ms -OCClientInterface::ContextMenuInfo OCClientInterface::FetchInfo(const std::wstring &files) +NCClientInterface::ContextMenuInfo NCClientInterface::FetchInfo(const std::wstring &files) { auto pipename = CommunicationSocket::DefaultPipePath(); @@ -77,7 +77,7 @@ OCClientInterface::ContextMenuInfo OCClientInterface::FetchInfo(const std::wstri return info; } -void OCClientInterface::SendRequest(const wchar_t *verb, const std::wstring &path) +void NCClientInterface::SendRequest(const wchar_t *verb, const std::wstring &path) { auto pipename = CommunicationSocket::DefaultPipePath(); diff --git a/shell_integration/windows/OCContextMenu/OCClientInterface.h b/shell_integration/windows/NCContextMenu/NCClientInterface.h similarity index 98% rename from shell_integration/windows/OCContextMenu/OCClientInterface.h rename to shell_integration/windows/NCContextMenu/NCClientInterface.h index 586a03f2f..a76cab5af 100644 --- a/shell_integration/windows/OCContextMenu/OCClientInterface.h +++ b/shell_integration/windows/NCContextMenu/NCClientInterface.h @@ -40,7 +40,7 @@ class CommunicationSocket; -class OCClientInterface +class NCClientInterface { public: struct ContextMenuInfo { diff --git a/shell_integration/windows/OCContextMenu/OCContextMenu.cpp b/shell_integration/windows/NCContextMenu/NCContextMenu.cpp similarity index 89% rename from shell_integration/windows/OCContextMenu/OCContextMenu.cpp rename to shell_integration/windows/NCContextMenu/NCContextMenu.cpp index 1e9168af5..683376d2c 100644 --- a/shell_integration/windows/OCContextMenu/OCContextMenu.cpp +++ b/shell_integration/windows/NCContextMenu/NCContextMenu.cpp @@ -12,8 +12,8 @@ * details. */ -#include "OCContextMenu.h" -#include "OCClientInterface.h" +#include "NCContextMenu.h" +#include "NCClientInterface.h" #include #include @@ -23,13 +23,13 @@ extern long g_cDllRef; -OCContextMenu::OCContextMenu(void) +NCContextMenu::NCContextMenu(void) : m_cRef(1) { InterlockedIncrement(&g_cDllRef); } -OCContextMenu::~OCContextMenu(void) +NCContextMenu::~NCContextMenu(void) { InterlockedDecrement(&g_cDllRef); } @@ -37,25 +37,25 @@ OCContextMenu::~OCContextMenu(void) #pragma region IUnknown // Query to the interface the component supported. -IFACEMETHODIMP OCContextMenu::QueryInterface(REFIID riid, void **ppv) +IFACEMETHODIMP NCContextMenu::QueryInterface(REFIID riid, void **ppv) { static const QITAB qit[] = { - QITABENT(OCContextMenu, IContextMenu), - QITABENT(OCContextMenu, IShellExtInit), + QITABENT(NCContextMenu, IContextMenu), + QITABENT(NCContextMenu, IShellExtInit), { 0 }, }; return QISearch(this, qit, riid, ppv); } // Increase the reference count for an interface on an object. -IFACEMETHODIMP_(ULONG) OCContextMenu::AddRef() +IFACEMETHODIMP_(ULONG) NCContextMenu::AddRef() { return InterlockedIncrement(&m_cRef); } // Decrease the reference count for an interface on an object. -IFACEMETHODIMP_(ULONG) OCContextMenu::Release() +IFACEMETHODIMP_(ULONG) NCContextMenu::Release() { ULONG cRef = InterlockedDecrement(&m_cRef); if (0 == cRef) { @@ -71,7 +71,7 @@ IFACEMETHODIMP_(ULONG) OCContextMenu::Release() #pragma region IShellExtInit // Initialize the context menu handler. -IFACEMETHODIMP OCContextMenu::Initialize( +IFACEMETHODIMP NCContextMenu::Initialize( LPCITEMIDLIST pidlFolder, LPDATAOBJECT pDataObj, HKEY hKeyProgID) { m_selectedFiles.clear(); @@ -127,7 +127,7 @@ void InsertSeperator(HMENU hMenu, UINT indexMenu) InsertMenuItem(hMenu, indexMenu, TRUE, &sep); } -IFACEMETHODIMP OCContextMenu::QueryContextMenu(HMENU hMenu, UINT indexMenu, UINT idCmdFirst, UINT idCmdLast, UINT uFlags) +IFACEMETHODIMP NCContextMenu::QueryContextMenu(HMENU hMenu, UINT indexMenu, UINT idCmdFirst, UINT idCmdLast, UINT uFlags) { // If uFlags include CMF_DEFAULTONLY then we should not do anything. if (CMF_DEFAULTONLY & uFlags) @@ -135,7 +135,7 @@ IFACEMETHODIMP OCContextMenu::QueryContextMenu(HMENU hMenu, UINT indexMenu, UINT return MAKE_HRESULT(SEVERITY_SUCCESS, 0, USHORT(0)); } - m_info = OCClientInterface::FetchInfo(m_selectedFiles); + m_info = NCClientInterface::FetchInfo(m_selectedFiles); if (m_info.menuItems.empty()) { return MAKE_HRESULT(SEVERITY_SUCCESS, 0, USHORT(0)); } @@ -177,7 +177,7 @@ IFACEMETHODIMP OCContextMenu::QueryContextMenu(HMENU hMenu, UINT indexMenu, UINT return MAKE_HRESULT(SEVERITY_SUCCESS, 0, USHORT(indexSubMenu)); } -IFACEMETHODIMP OCContextMenu::InvokeCommand(LPCMINVOKECOMMANDINFO pici) +IFACEMETHODIMP NCContextMenu::InvokeCommand(LPCMINVOKECOMMANDINFO pici) { std::wstring command; @@ -215,11 +215,11 @@ IFACEMETHODIMP OCContextMenu::InvokeCommand(LPCMINVOKECOMMANDINFO pici) return E_FAIL; } - OCClientInterface::SendRequest(command.data(), m_selectedFiles); + NCClientInterface::SendRequest(command.data(), m_selectedFiles); return S_OK; } -IFACEMETHODIMP OCContextMenu::GetCommandString(UINT_PTR idCommand, +IFACEMETHODIMP NCContextMenu::GetCommandString(UINT_PTR idCommand, UINT uFlags, UINT *pwReserved, LPSTR pszName, UINT cchMax) { if (idCommand < m_info.menuItems.size() && uFlags == GCS_VERBW) { diff --git a/shell_integration/windows/OCContextMenu/OCContextMenu.def b/shell_integration/windows/NCContextMenu/NCContextMenu.def similarity index 100% rename from shell_integration/windows/OCContextMenu/OCContextMenu.def rename to shell_integration/windows/NCContextMenu/NCContextMenu.def diff --git a/shell_integration/windows/OCContextMenu/OCContextMenu.h b/shell_integration/windows/NCContextMenu/NCContextMenu.h similarity index 85% rename from shell_integration/windows/OCContextMenu/OCContextMenu.h rename to shell_integration/windows/NCContextMenu/NCContextMenu.h index e8836d6fe..b5b2a3eb7 100644 --- a/shell_integration/windows/OCContextMenu/OCContextMenu.h +++ b/shell_integration/windows/NCContextMenu/NCContextMenu.h @@ -12,15 +12,15 @@ * details. */ -#ifndef OCCONTEXTMENU_H -#define OCCONTEXTMENU_H +#ifndef NCCONTEXTMENU_H +#define NCCONTEXTMENU_H #pragma once #include // For IShellExtInit and IContextMenu #include -#include "OCClientInterface.h" +#include "NCClientInterface.h" -class OCContextMenu : public IShellExtInit, public IContextMenu +class NCContextMenu : public IShellExtInit, public IContextMenu { public: // IUnknown @@ -36,10 +36,10 @@ public: IFACEMETHODIMP InvokeCommand(LPCMINVOKECOMMANDINFO pici); IFACEMETHODIMP GetCommandString(UINT_PTR idCommand, UINT uFlags, UINT *pwReserved, LPSTR pszName, UINT cchMax); - OCContextMenu(); + NCContextMenu(); protected: - ~OCContextMenu(); + ~NCContextMenu(); private: // Reference count of component. @@ -47,7 +47,7 @@ private: // The name of the selected files (separated by '\x1e') std::wstring m_selectedFiles; - OCClientInterface::ContextMenuInfo m_info; + NCClientInterface::ContextMenuInfo m_info; }; -#endif //OCCONTEXTMENU_H +#endif //NCCONTEXTMENU_H diff --git a/shell_integration/windows/OCContextMenu/OCContextMenu.rc b/shell_integration/windows/NCContextMenu/NCContextMenu.rc similarity index 88% rename from shell_integration/windows/OCContextMenu/OCContextMenu.rc rename to shell_integration/windows/NCContextMenu/NCContextMenu.rc index c09944f14..ea3f44b20 100644 Binary files a/shell_integration/windows/OCContextMenu/OCContextMenu.rc and b/shell_integration/windows/NCContextMenu/NCContextMenu.rc differ diff --git a/shell_integration/windows/OCContextMenu/OCContextMenuFactory.cpp b/shell_integration/windows/NCContextMenu/NCContextMenuFactory.cpp similarity index 73% rename from shell_integration/windows/OCContextMenu/OCContextMenuFactory.cpp rename to shell_integration/windows/NCContextMenu/NCContextMenuFactory.cpp index e3e6ff6b6..8d1e1b65d 100644 --- a/shell_integration/windows/OCContextMenu/OCContextMenuFactory.cpp +++ b/shell_integration/windows/NCContextMenu/NCContextMenuFactory.cpp @@ -12,8 +12,8 @@ * details. */ -#include "OCContextMenuFactory.h" -#include "OCContextMenu.h" +#include "NCContextMenuFactory.h" +#include "NCContextMenu.h" #include #include #pragma comment(lib, "shlwapi.lib") @@ -22,12 +22,12 @@ extern long g_cDllRef; -OCContextMenuFactory::OCContextMenuFactory() : m_cRef(1) +NCContextMenuFactory::NCContextMenuFactory() : m_cRef(1) { InterlockedIncrement(&g_cDllRef); } -OCContextMenuFactory::~OCContextMenuFactory() +NCContextMenuFactory::~NCContextMenuFactory() { InterlockedDecrement(&g_cDllRef); } @@ -35,18 +35,18 @@ OCContextMenuFactory::~OCContextMenuFactory() // IUnknown methods -IFACEMETHODIMP OCContextMenuFactory::QueryInterface(REFIID riid, void **ppv) +IFACEMETHODIMP NCContextMenuFactory::QueryInterface(REFIID riid, void **ppv) { - static const QITAB qit[] = { QITABENT(OCContextMenuFactory, IClassFactory), { 0 }, }; + static const QITAB qit[] = { QITABENT(NCContextMenuFactory, IClassFactory), { 0 }, }; return QISearch(this, qit, riid, ppv); } -IFACEMETHODIMP_(ULONG) OCContextMenuFactory::AddRef() +IFACEMETHODIMP_(ULONG) NCContextMenuFactory::AddRef() { return InterlockedIncrement(&m_cRef); } -IFACEMETHODIMP_(ULONG) OCContextMenuFactory::Release() +IFACEMETHODIMP_(ULONG) NCContextMenuFactory::Release() { ULONG cRef = InterlockedDecrement(&m_cRef); if (0 == cRef) { @@ -58,7 +58,7 @@ IFACEMETHODIMP_(ULONG) OCContextMenuFactory::Release() // IClassFactory methods -IFACEMETHODIMP OCContextMenuFactory::CreateInstance(IUnknown *pUnkOuter, REFIID riid, void **ppv) +IFACEMETHODIMP NCContextMenuFactory::CreateInstance(IUnknown *pUnkOuter, REFIID riid, void **ppv) { HRESULT hr = CLASS_E_NOAGGREGATION; @@ -67,7 +67,7 @@ IFACEMETHODIMP OCContextMenuFactory::CreateInstance(IUnknown *pUnkOuter, REFIID hr = E_OUTOFMEMORY; // Create the COM component. - OCContextMenu *pExt = new (std::nothrow) OCContextMenu(); + NCContextMenu *pExt = new (std::nothrow) NCContextMenu(); if (pExt) { // Query the specified interface. hr = pExt->QueryInterface(riid, ppv); @@ -78,7 +78,7 @@ IFACEMETHODIMP OCContextMenuFactory::CreateInstance(IUnknown *pUnkOuter, REFIID return hr; } -IFACEMETHODIMP OCContextMenuFactory::LockServer(BOOL fLock) +IFACEMETHODIMP NCContextMenuFactory::LockServer(BOOL fLock) { if (fLock) { InterlockedIncrement(&g_cDllRef); diff --git a/shell_integration/windows/OCContextMenu/OCContextMenuFactory.h b/shell_integration/windows/NCContextMenu/NCContextMenuFactory.h similarity index 83% rename from shell_integration/windows/OCContextMenu/OCContextMenuFactory.h rename to shell_integration/windows/NCContextMenu/NCContextMenuFactory.h index 13f4d6759..4f878ab46 100644 --- a/shell_integration/windows/OCContextMenu/OCContextMenuFactory.h +++ b/shell_integration/windows/NCContextMenu/NCContextMenuFactory.h @@ -13,14 +13,14 @@ */ -#ifndef OCCONTEXTMENUFACTORY_H -#define OCCONTEXTMENUFACTORY_H +#ifndef NCCONTEXTMENUFACTORY_H +#define NCCONTEXTMENUFACTORY_H #pragma once #include // For IClassFactory -class OCContextMenuFactory : public IClassFactory +class NCContextMenuFactory : public IClassFactory { public: // IUnknown @@ -32,11 +32,11 @@ public: IFACEMETHODIMP CreateInstance(IUnknown *pUnkOuter, REFIID riid, void **ppv); IFACEMETHODIMP LockServer(BOOL fLock); - OCContextMenuFactory(); + NCContextMenuFactory(); private: - ~OCContextMenuFactory(); + ~NCContextMenuFactory(); long m_cRef; }; -#endif //OCCONTEXTMENUFACTORY_H \ No newline at end of file +#endif //NCCONTEXTMENUFACTORY_H \ No newline at end of file diff --git a/shell_integration/windows/OCContextMenu/OCContextMenuRegHandler.cpp b/shell_integration/windows/NCContextMenu/NCContextMenuRegHandler.cpp similarity index 95% rename from shell_integration/windows/OCContextMenu/OCContextMenuRegHandler.cpp rename to shell_integration/windows/NCContextMenu/NCContextMenuRegHandler.cpp index 43fb46a3b..37865b89a 100644 --- a/shell_integration/windows/OCContextMenu/OCContextMenuRegHandler.cpp +++ b/shell_integration/windows/NCContextMenu/NCContextMenuRegHandler.cpp @@ -12,7 +12,7 @@ * details. */ -#include "OCContextMenuRegHandler.h" +#include "NCContextMenuRegHandler.h" #include "RegDelnode.h" #include #include @@ -68,7 +68,7 @@ HRESULT GetHKCRRegistryKeyAndValue(PCWSTR pszSubKey, PCWSTR pszValueName, PWSTR } -HRESULT OCContextMenuRegHandler::RegisterInprocServer(PCWSTR pszModule, const CLSID& clsid, PCWSTR pszFriendlyName, PCWSTR pszThreadModel) +HRESULT NCContextMenuRegHandler::RegisterInprocServer(PCWSTR pszModule, const CLSID& clsid, PCWSTR pszFriendlyName, PCWSTR pszThreadModel) { if (!pszModule || !pszThreadModel) { @@ -111,7 +111,7 @@ HRESULT OCContextMenuRegHandler::RegisterInprocServer(PCWSTR pszModule, const CL return hr; } -HRESULT OCContextMenuRegHandler::UnregisterInprocServer(const CLSID& clsid) +HRESULT NCContextMenuRegHandler::UnregisterInprocServer(const CLSID& clsid) { HRESULT hr = S_OK; @@ -131,7 +131,7 @@ HRESULT OCContextMenuRegHandler::UnregisterInprocServer(const CLSID& clsid) } -HRESULT OCContextMenuRegHandler::RegisterShellExtContextMenuHandler( +HRESULT NCContextMenuRegHandler::RegisterShellExtContextMenuHandler( PCWSTR pszFileType, const CLSID& clsid, PCWSTR pszFriendlyName) { if (!pszFileType) @@ -175,7 +175,7 @@ HRESULT OCContextMenuRegHandler::RegisterShellExtContextMenuHandler( return hr; } -HRESULT OCContextMenuRegHandler::UnregisterShellExtContextMenuHandler( +HRESULT NCContextMenuRegHandler::UnregisterShellExtContextMenuHandler( PCWSTR pszFileType, PCWSTR pszFriendlyName) { if (!pszFileType) diff --git a/shell_integration/windows/OCContextMenu/OCContextMenuRegHandler.h b/shell_integration/windows/NCContextMenu/NCContextMenuRegHandler.h similarity index 89% rename from shell_integration/windows/OCContextMenu/OCContextMenuRegHandler.h rename to shell_integration/windows/NCContextMenu/NCContextMenuRegHandler.h index 91c2c9e81..2dba0fd52 100644 --- a/shell_integration/windows/OCContextMenu/OCContextMenuRegHandler.h +++ b/shell_integration/windows/NCContextMenu/NCContextMenuRegHandler.h @@ -13,14 +13,14 @@ */ -#ifndef OCCONTEXTMENUREGHANDLER_H -#define OCCONTEXTMENUREGHANDLER_H +#ifndef NCCONTEXTMENUREGHANDLER_H +#define NCCONTEXTMENUREGHANDLER_H #pragma once #include -class __declspec(dllexport) OCContextMenuRegHandler +class __declspec(dllexport) NCContextMenuRegHandler { public: static HRESULT MakeRegistryEntries(const CLSID& clsid, PCWSTR fileType); @@ -35,4 +35,4 @@ public: static HRESULT UnregisterShellExtContextMenuHandler(PCWSTR pszFileType, PCWSTR pszFriendlyName); }; -#endif //OCCONTEXTMENUREGHANDLER_H \ No newline at end of file +#endif //NCCONTEXTMENUREGHANDLER_H \ No newline at end of file diff --git a/shell_integration/windows/OCContextMenu/RegDelnode.h b/shell_integration/windows/NCContextMenu/RegDelnode.h similarity index 100% rename from shell_integration/windows/OCContextMenu/RegDelnode.h rename to shell_integration/windows/NCContextMenu/RegDelnode.h diff --git a/shell_integration/windows/OCContextMenu/dllmain.cpp b/shell_integration/windows/NCContextMenu/dllmain.cpp similarity index 73% rename from shell_integration/windows/OCContextMenu/dllmain.cpp rename to shell_integration/windows/NCContextMenu/dllmain.cpp index b6f1a11db..a8c6b6ed6 100644 --- a/shell_integration/windows/OCContextMenu/dllmain.cpp +++ b/shell_integration/windows/NCContextMenu/dllmain.cpp @@ -14,8 +14,8 @@ #include #include -#include "OCContextMenuRegHandler.h" -#include "OCContextMenuFactory.h" +#include "NCContextMenuRegHandler.h" +#include "NCContextMenuFactory.h" #include "WinShellExtConstants.h" HINSTANCE g_hInst = nullptr; @@ -41,7 +41,7 @@ BOOL APIENTRY DllMain(HMODULE hModule, DWORD dwReason, LPVOID lpReserved) STDAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, void **ppv) { - HRESULT hr = CLASS_E_CLASSNOTAVAILABLE; + HRESULT hr; GUID guid; hr = CLSIDFromString(CONTEXT_MENU_GUID, (LPCLSID)&guid); @@ -49,10 +49,12 @@ STDAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, void **ppv) return hr; } + hr = CLASS_E_CLASSNOTAVAILABLE; + if (IsEqualCLSID(guid, rclsid)) { hr = E_OUTOFMEMORY; - OCContextMenuFactory *pClassFactory = new OCContextMenuFactory(); + NCContextMenuFactory *pClassFactory = new NCContextMenuFactory(); if (pClassFactory) { hr = pClassFactory->QueryInterface(riid, ppv); pClassFactory->Release(); @@ -70,6 +72,12 @@ STDAPI DllCanUnloadNow(void) STDAPI DllRegisterServer(void) { HRESULT hr; + GUID guid; + + hr = CLSIDFromString(CONTEXT_MENU_GUID, (LPCLSID)&guid); + if (!SUCCEEDED(hr)) { + return hr; + } wchar_t szModule[MAX_PATH]; if (GetModuleFileName(g_hInst, szModule, ARRAYSIZE(szModule)) == 0) { @@ -78,12 +86,12 @@ STDAPI DllRegisterServer(void) } // Register the component. - hr = OCContextMenuRegHandler::RegisterInprocServer(szModule, CLSID_FileContextMenuExt, - L"OCContextMenuHandler Class", L"Apartment"); + hr = NCContextMenuRegHandler::RegisterInprocServer(szModule, guid, + CONTEXT_MENU_DESCRIPTION, L"Apartment"); if (SUCCEEDED(hr)) { // Register the context menu handler. The context menu handler is // associated with the .cpp file class. - hr = OCContextMenuRegHandler::RegisterShellExtContextMenuHandler(L"AllFileSystemObjects", CLSID_FileContextMenuExt, L"OCContextMenuHandler"); + hr = NCContextMenuRegHandler::RegisterShellExtContextMenuHandler(L"AllFileSystemObjects", guid, CONTEXT_MENU_REGKEY_NAME); } return hr; @@ -92,6 +100,12 @@ STDAPI DllRegisterServer(void) STDAPI DllUnregisterServer(void) { HRESULT hr = S_OK; + GUID guid; + + hr = CLSIDFromString(CONTEXT_MENU_GUID, (LPCLSID)&guid); + if (!SUCCEEDED(hr)) { + return hr; + } wchar_t szModule[MAX_PATH]; if (GetModuleFileName(g_hInst, szModule, ARRAYSIZE(szModule)) == 0) { @@ -100,10 +114,10 @@ STDAPI DllUnregisterServer(void) } // Unregister the component. - hr = OCContextMenuRegHandler::UnregisterInprocServer(CLSID_FileContextMenuExt); + hr = NCContextMenuRegHandler::UnregisterInprocServer(guid); if (SUCCEEDED(hr)) { // Unregister the context menu handler. - hr = OCContextMenuRegHandler::UnregisterShellExtContextMenuHandler(L"AllFileSystemObjects", L"OCContextMenuHandler"); + hr = NCContextMenuRegHandler::UnregisterShellExtContextMenuHandler(L"AllFileSystemObjects", CONTEXT_MENU_REGKEY_NAME); } return hr; diff --git a/shell_integration/windows/OCUtil/resource.h b/shell_integration/windows/NCContextMenu/resource.h similarity index 92% rename from shell_integration/windows/OCUtil/resource.h rename to shell_integration/windows/NCContextMenu/resource.h index b9407b5bc..c80f97834 100644 --- a/shell_integration/windows/OCUtil/resource.h +++ b/shell_integration/windows/NCContextMenu/resource.h @@ -1,6 +1,6 @@ //{{NO_DEPENDENCIES}} // Microsoft Visual C++ generated include file. -// Used by OCContextMenu.rc +// Used by NCContextMenu.rc // Next default values for new objects // diff --git a/shell_integration/windows/NCOverlays/CMakeLists.txt b/shell_integration/windows/NCOverlays/CMakeLists.txt new file mode 100644 index 000000000..35bfc2ce5 --- /dev/null +++ b/shell_integration/windows/NCOverlays/CMakeLists.txt @@ -0,0 +1,16 @@ +add_library(NCOverlays MODULE + DllMain.cpp + NCOverlay.cpp + NCOverlayFactory.cpp + NCOverlayRegistrationHandler.cpp + NCOverlay.rc + NCOverlays.def +) + +target_link_libraries(NCOverlays + NCUtil) + +install(TARGETS NCOverlays + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} + LIBRARY DESTINATION ${CMAKE_INSTALL_BINDIR} +) diff --git a/shell_integration/windows/OCOverlays/DllMain.cpp b/shell_integration/windows/NCOverlays/DllMain.cpp similarity index 82% rename from shell_integration/windows/OCOverlays/DllMain.cpp rename to shell_integration/windows/NCOverlays/DllMain.cpp index 8f6cff497..1798225d1 100644 --- a/shell_integration/windows/OCOverlays/DllMain.cpp +++ b/shell_integration/windows/NCOverlays/DllMain.cpp @@ -12,8 +12,8 @@ * details. */ -#include "OCOverlayRegistrationHandler.h" -#include "OCOverlayFactory.h" +#include "NCOverlayRegistrationHandler.h" +#include "NCOverlayFactory.h" #include "WinShellExtConstants.h" HINSTANCE instanceHandle = nullptr; @@ -41,11 +41,11 @@ HRESULT CreateFactory(REFIID riid, void **ppv, int state) { HRESULT hResult = E_OUTOFMEMORY; - OCOverlayFactory* ocOverlayFactory = new OCOverlayFactory(state); + NCOverlayFactory* ncOverlayFactory = new NCOverlayFactory(state); - if (ocOverlayFactory) { - hResult = ocOverlayFactory->QueryInterface(riid, ppv); - ocOverlayFactory->Release(); + if (ncOverlayFactory) { + hResult = ncOverlayFactory->QueryInterface(riid, ppv); + ncOverlayFactory->Release(); } return hResult; } @@ -94,13 +94,13 @@ HRESULT RegisterCLSID(LPCOLESTR guidStr, PCWSTR overlayStr, PCWSTR szModule) return hResult; } - hResult = OCOverlayRegistrationHandler::RegisterCOMObject(szModule, OVERLAY_GENERIC_NAME, guid); + hResult = NCOverlayRegistrationHandler::RegisterCOMObject(szModule, OVERLAY_DESCRIPTION, guid); if (!SUCCEEDED(hResult)) { return hResult; } - hResult = OCOverlayRegistrationHandler::MakeRegistryEntries(guid, overlayStr); + hResult = NCOverlayRegistrationHandler::MakeRegistryEntries(guid, overlayStr); return hResult; } @@ -116,13 +116,13 @@ HRESULT UnregisterCLSID(LPCOLESTR guidStr, PCWSTR overlayStr) return hResult; } - hResult = OCOverlayRegistrationHandler::UnregisterCOMObject(guid); + hResult = NCOverlayRegistrationHandler::UnregisterCOMObject(guid); if (!SUCCEEDED(hResult)) { return hResult; } - hResult = OCOverlayRegistrationHandler::RemoveRegistryEntries(overlayStr); + hResult = NCOverlayRegistrationHandler::RemoveRegistryEntries(overlayStr); return hResult; } @@ -138,13 +138,6 @@ HRESULT _stdcall DllRegisterServer(void) return hResult; } - // Unregister any obsolete CLSID when we register here - // Those CLSID were removed in 2.1, but we need to make sure to prevent any previous version - // of the extension on the system from loading at the same time as a new version to avoid crashing explorer. - UnregisterCLSID(OVERLAY_GUID_ERROR_SHARED, OVERLAY_NAME_ERROR_SHARED); - UnregisterCLSID(OVERLAY_GUID_SYNC_SHARED, OVERLAY_NAME_SYNC_SHARED); - UnregisterCLSID(OVERLAY_GUID_WARNING_SHARED, OVERLAY_NAME_WARNING_SHARED); - hResult = RegisterCLSID(OVERLAY_GUID_ERROR, OVERLAY_NAME_ERROR, szModule); if (!SUCCEEDED(hResult)) { return hResult; } hResult = RegisterCLSID(OVERLAY_GUID_OK, OVERLAY_NAME_OK, szModule); diff --git a/shell_integration/windows/OCOverlays/OCOverlay.cpp b/shell_integration/windows/NCOverlays/NCOverlay.cpp similarity index 88% rename from shell_integration/windows/OCOverlays/OCOverlay.cpp rename to shell_integration/windows/NCOverlays/NCOverlay.cpp index 985faec54..de1098648 100644 --- a/shell_integration/windows/OCOverlays/OCOverlay.cpp +++ b/shell_integration/windows/NCOverlays/NCOverlay.cpp @@ -12,12 +12,9 @@ * details. */ -#include "OCOverlay.h" - -#include "OCOverlayFactory.h" +#include "NCOverlay.h" +#include "NCOverlayFactory.h" #include "StringUtil.h" - -#include "UtilConstants.h" #include "RemotePathChecker.h" #include @@ -50,23 +47,23 @@ RemotePathChecker *getGlobalChecker() } } -OCOverlay::OCOverlay(int state) +NCOverlay::NCOverlay(int state) : _referenceCount(1) , _state(state) { } -OCOverlay::~OCOverlay(void) +NCOverlay::~NCOverlay(void) { } -IFACEMETHODIMP_(ULONG) OCOverlay::AddRef() +IFACEMETHODIMP_(ULONG) NCOverlay::AddRef() { return InterlockedIncrement(&_referenceCount); } -IFACEMETHODIMP OCOverlay::QueryInterface(REFIID riid, void **ppv) +IFACEMETHODIMP NCOverlay::QueryInterface(REFIID riid, void **ppv) { HRESULT hr = S_OK; @@ -88,7 +85,7 @@ IFACEMETHODIMP OCOverlay::QueryInterface(REFIID riid, void **ppv) return hr; } -IFACEMETHODIMP_(ULONG) OCOverlay::Release() +IFACEMETHODIMP_(ULONG) NCOverlay::Release() { ULONG cRef = InterlockedDecrement(&_referenceCount); if (0 == cRef) @@ -99,7 +96,7 @@ IFACEMETHODIMP_(ULONG) OCOverlay::Release() return cRef; } -IFACEMETHODIMP OCOverlay::GetPriority(int *pPriority) +IFACEMETHODIMP NCOverlay::GetPriority(int *pPriority) { // this defines which handler has prededence, so // we order this in terms of likelyhood @@ -121,7 +118,7 @@ IFACEMETHODIMP OCOverlay::GetPriority(int *pPriority) return S_OK; } -IFACEMETHODIMP OCOverlay::IsMemberOf(PCWSTR pwszPath, DWORD dwAttrib) +IFACEMETHODIMP NCOverlay::IsMemberOf(PCWSTR pwszPath, DWORD dwAttrib) { RemotePathChecker* checker = getGlobalChecker(); std::shared_ptr> watchedDirectories = checker->WatchedDirectories(); @@ -149,7 +146,7 @@ IFACEMETHODIMP OCOverlay::IsMemberOf(PCWSTR pwszPath, DWORD dwAttrib) return MAKE_HRESULT(state == _state ? S_OK : S_FALSE, 0, 0); } -IFACEMETHODIMP OCOverlay::GetOverlayInfo(PWSTR pwszIconFile, int cchMax, int *pIndex, DWORD *pdwFlags) +IFACEMETHODIMP NCOverlay::GetOverlayInfo(PWSTR pwszIconFile, int cchMax, int *pIndex, DWORD *pdwFlags) { *pIndex = 0; *pdwFlags = ISIOI_ICONFILE | ISIOI_ICONINDEX; diff --git a/shell_integration/windows/OCOverlays/OCOverlay.h b/shell_integration/windows/NCOverlays/NCOverlay.h similarity index 88% rename from shell_integration/windows/OCOverlays/OCOverlay.h rename to shell_integration/windows/NCOverlays/NCOverlay.h index 80aaa7882..688a6b095 100644 --- a/shell_integration/windows/OCOverlays/OCOverlay.h +++ b/shell_integration/windows/NCOverlays/NCOverlay.h @@ -12,18 +12,18 @@ * details. */ -#ifndef OCOVERLAY_H -#define OCOVERLAY_H +#ifndef NCOVERLAY_H +#define NCOVERLAY_H #pragma once #include -class OCOverlay : public IShellIconOverlayIdentifier +class NCOverlay : public IShellIconOverlayIdentifier { public: - OCOverlay(int state); + NCOverlay(int state); IFACEMETHODIMP_(ULONG) AddRef(); IFACEMETHODIMP GetOverlayInfo(PWSTR pwszIconFile, int cchMax, int *pIndex, DWORD *pdwFlags); @@ -33,7 +33,7 @@ public: IFACEMETHODIMP_(ULONG) Release(); protected: - ~OCOverlay(); + ~NCOverlay(); private: long _referenceCount; diff --git a/shell_integration/windows/OCOverlays/OCOverlay.rc b/shell_integration/windows/NCOverlays/NCOverlay.rc similarity index 90% rename from shell_integration/windows/OCOverlays/OCOverlay.rc rename to shell_integration/windows/NCOverlays/NCOverlay.rc index c8f0ef988..69bf79b9f 100644 Binary files a/shell_integration/windows/OCOverlays/OCOverlay.rc and b/shell_integration/windows/NCOverlays/NCOverlay.rc differ diff --git a/shell_integration/windows/OCOverlays/OCOverlayFactory.cpp b/shell_integration/windows/NCOverlays/NCOverlayFactory.cpp similarity index 78% rename from shell_integration/windows/OCOverlays/OCOverlayFactory.cpp rename to shell_integration/windows/NCOverlays/NCOverlayFactory.cpp index 58b569e1c..2c063a866 100644 --- a/shell_integration/windows/OCOverlays/OCOverlayFactory.cpp +++ b/shell_integration/windows/NCOverlays/NCOverlayFactory.cpp @@ -15,23 +15,23 @@ #include #include -#include "OCOverlayFactory.h" -#include "OCOverlay.h" +#include "NCOverlayFactory.h" +#include "NCOverlay.h" extern long dllReferenceCount; -OCOverlayFactory::OCOverlayFactory(int state) +NCOverlayFactory::NCOverlayFactory(int state) : _referenceCount(1), _state(state) { InterlockedIncrement(&dllReferenceCount); } -OCOverlayFactory::~OCOverlayFactory() +NCOverlayFactory::~NCOverlayFactory() { InterlockedDecrement(&dllReferenceCount); } -IFACEMETHODIMP OCOverlayFactory::QueryInterface(REFIID riid, void **ppv) +IFACEMETHODIMP NCOverlayFactory::QueryInterface(REFIID riid, void **ppv) { HRESULT hResult = S_OK; @@ -50,12 +50,12 @@ IFACEMETHODIMP OCOverlayFactory::QueryInterface(REFIID riid, void **ppv) return hResult; } -IFACEMETHODIMP_(ULONG) OCOverlayFactory::AddRef() +IFACEMETHODIMP_(ULONG) NCOverlayFactory::AddRef() { return InterlockedIncrement(&_referenceCount); } -IFACEMETHODIMP_(ULONG) OCOverlayFactory::Release() +IFACEMETHODIMP_(ULONG) NCOverlayFactory::Release() { ULONG cRef = InterlockedDecrement(&_referenceCount); @@ -66,7 +66,7 @@ IFACEMETHODIMP_(ULONG) OCOverlayFactory::Release() return cRef; } -IFACEMETHODIMP OCOverlayFactory::CreateInstance( +IFACEMETHODIMP NCOverlayFactory::CreateInstance( IUnknown *pUnkOuter, REFIID riid, void **ppv) { HRESULT hResult = CLASS_E_NOAGGREGATION; @@ -74,7 +74,7 @@ IFACEMETHODIMP OCOverlayFactory::CreateInstance( if (pUnkOuter) { return hResult; } hResult = E_OUTOFMEMORY; - OCOverlay *lrOverlay = new (std::nothrow) OCOverlay(_state); + NCOverlay *lrOverlay = new (std::nothrow) NCOverlay(_state); if (!lrOverlay) { return hResult; } hResult = lrOverlay->QueryInterface(riid, ppv); @@ -83,7 +83,7 @@ IFACEMETHODIMP OCOverlayFactory::CreateInstance( return hResult; } -IFACEMETHODIMP OCOverlayFactory::LockServer(BOOL fLock) +IFACEMETHODIMP NCOverlayFactory::LockServer(BOOL fLock) { if (fLock) { InterlockedIncrement(&dllReferenceCount); diff --git a/shell_integration/windows/OCOverlays/OCOverlayFactory.h b/shell_integration/windows/NCOverlays/NCOverlayFactory.h similarity index 86% rename from shell_integration/windows/OCOverlays/OCOverlayFactory.h rename to shell_integration/windows/NCOverlays/NCOverlayFactory.h index 5ce881d24..74962cc02 100644 --- a/shell_integration/windows/OCOverlays/OCOverlayFactory.h +++ b/shell_integration/windows/NCOverlays/NCOverlayFactory.h @@ -12,8 +12,8 @@ * details. */ -#ifndef OCOVERLAYFACTORY_H -#define OCOVERLAYFACTORY_H +#ifndef NCOVERLAYFACTORY_H +#define NCOVERLAYFACTORY_H #pragma once @@ -26,10 +26,10 @@ enum State { State_Warning }; -class OCOverlayFactory : public IClassFactory +class NCOverlayFactory : public IClassFactory { public: - OCOverlayFactory(int state); + NCOverlayFactory(int state); IFACEMETHODIMP_(ULONG) AddRef(); IFACEMETHODIMP CreateInstance(IUnknown *pUnkOuter, REFIID riid, void **ppv); @@ -38,7 +38,7 @@ public: IFACEMETHODIMP_(ULONG) Release(); protected: - ~OCOverlayFactory(); + ~NCOverlayFactory(); private: long _referenceCount; diff --git a/shell_integration/windows/OCOverlays/OCOverlayRegistrationHandler.cpp b/shell_integration/windows/NCOverlays/NCOverlayRegistrationHandler.cpp similarity index 74% rename from shell_integration/windows/OCOverlays/OCOverlayRegistrationHandler.cpp rename to shell_integration/windows/NCOverlays/NCOverlayRegistrationHandler.cpp index ffb2d4507..08586f1d9 100644 --- a/shell_integration/windows/OCOverlays/OCOverlayRegistrationHandler.cpp +++ b/shell_integration/windows/NCOverlays/NCOverlayRegistrationHandler.cpp @@ -12,17 +12,24 @@ * details. */ -#include "OCOverlayRegistrationHandler.h" -#include "OverlayConstants.h" +#include "NCOverlayRegistrationHandler.h" #include #include #include #include +#define REGISTRY_OVERLAY_KEY LR"(SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\ShellIconOverlayIdentifiers)" +#define REGISTRY_CLSID L"CLSID" +#define REGISTRY_IN_PROCESS L"InprocServer32" +#define REGISTRY_THREADING L"ThreadingModel" +#define REGISTRY_APARTMENT L"Apartment" +#define REGISTRY_VERSION L"Version" +#define REGISTRY_VERSION_NUMBER L"1.0" + using namespace std; -HRESULT OCOverlayRegistrationHandler::MakeRegistryEntries(const CLSID& clsid, PCWSTR friendlyName) +HRESULT NCOverlayRegistrationHandler::MakeRegistryEntries(const CLSID& clsid, PCWSTR friendlyName) { HRESULT hResult; HKEY shellOverlayKey = nullptr; @@ -53,7 +60,7 @@ HRESULT OCOverlayRegistrationHandler::MakeRegistryEntries(const CLSID& clsid, PC return hResult; } -HRESULT OCOverlayRegistrationHandler::RemoveRegistryEntries(PCWSTR friendlyName) +HRESULT NCOverlayRegistrationHandler::RemoveRegistryEntries(PCWSTR friendlyName) { HRESULT hResult; HKEY shellOverlayKey = nullptr; @@ -72,7 +79,7 @@ HRESULT OCOverlayRegistrationHandler::RemoveRegistryEntries(PCWSTR friendlyName) return hResult; } -HRESULT OCOverlayRegistrationHandler::RegisterCOMObject(PCWSTR modulePath, PCWSTR friendlyName, const CLSID& clsid) +HRESULT NCOverlayRegistrationHandler::RegisterCOMObject(PCWSTR modulePath, PCWSTR friendlyName, const CLSID& clsid) { if (!modulePath) { return E_FAIL; @@ -90,7 +97,7 @@ HRESULT OCOverlayRegistrationHandler::RegisterCOMObject(PCWSTR modulePath, PCWST HKEY clsidKey = nullptr; hResult = HRESULT_FROM_WIN32(RegCreateKeyEx(hKey, stringCLSID, 0, nullptr, REG_OPTION_NON_VOLATILE, KEY_WRITE, nullptr, &clsidKey, nullptr)); - if(!SUCCEEDED(hResult)) { + if (!SUCCEEDED(hResult)) { return hResult; } @@ -98,30 +105,36 @@ HRESULT OCOverlayRegistrationHandler::RegisterCOMObject(PCWSTR modulePath, PCWST HKEY inprocessKey = nullptr; hResult = HRESULT_FROM_WIN32(RegCreateKeyEx(clsidKey, REGISTRY_IN_PROCESS, 0, nullptr, REG_OPTION_NON_VOLATILE, KEY_WRITE, nullptr, &inprocessKey, nullptr)); - if(!SUCCEEDED(hResult)) { + if (!SUCCEEDED(hResult)) { return hResult; } hResult = HRESULT_FROM_WIN32(RegSetValue(inprocessKey, nullptr, REG_SZ, modulePath, (DWORD) wcslen(modulePath))); - if(!SUCCEEDED(hResult)) { + if (!SUCCEEDED(hResult)) { return hResult; } hResult = HRESULT_FROM_WIN32(RegSetValueEx(inprocessKey, REGISTRY_THREADING, 0, REG_SZ, (LPBYTE)REGISTRY_APARTMENT, (DWORD)((wcslen(REGISTRY_APARTMENT)+1) * sizeof(TCHAR)))); - if(!SUCCEEDED(hResult)) { + if (!SUCCEEDED(hResult)) { return hResult; } - hResult = HRESULT_FROM_WIN32(RegSetValueEx(inprocessKey, REGISTRY_VERSION, 0, REG_SZ, (LPBYTE)REGISTRY_VERSION_NUMBER, (DWORD)(wcslen(REGISTRY_VERSION_NUMBER)+1) * sizeof(TCHAR))); - if(!SUCCEEDED(hResult)) { + HKEY versionKey = nullptr; + hResult = HRESULT_FROM_WIN32(RegCreateKeyEx(clsidKey, REGISTRY_VERSION, 0, nullptr, REG_OPTION_NON_VOLATILE, KEY_WRITE, nullptr, &versionKey, nullptr)); + if (!SUCCEEDED(hResult)) { + return hResult; + } + + hResult = HRESULT_FROM_WIN32(RegSetValueEx(versionKey, nullptr, 0, REG_SZ, (LPBYTE)REGISTRY_VERSION_NUMBER, (DWORD)(wcslen(REGISTRY_VERSION_NUMBER)+1) * sizeof(TCHAR))); + if (!SUCCEEDED(hResult)) { return hResult; } return S_OK; } -HRESULT OCOverlayRegistrationHandler::UnregisterCOMObject(const CLSID& clsid) +HRESULT NCOverlayRegistrationHandler::UnregisterCOMObject(const CLSID& clsid) { wchar_t stringCLSID[MAX_PATH]; @@ -135,17 +148,22 @@ HRESULT OCOverlayRegistrationHandler::UnregisterCOMObject(const CLSID& clsid) HKEY clsidKey = nullptr; hResult = HRESULT_FROM_WIN32(RegOpenKeyEx(hKey, stringCLSID, 0, DELETE, &clsidKey)); - if(!SUCCEEDED(hResult)) { + if (!SUCCEEDED(hResult)) { return hResult; } hResult = HRESULT_FROM_WIN32(RegDeleteKey(clsidKey, REGISTRY_IN_PROCESS)); - if(!SUCCEEDED(hResult)) { + if (!SUCCEEDED(hResult)) { + return hResult; + } + + hResult = HRESULT_FROM_WIN32(RegDeleteKey(clsidKey, REGISTRY_VERSION)); + if (!SUCCEEDED(hResult)) { return hResult; } hResult = HRESULT_FROM_WIN32(RegDeleteKey(hKey, stringCLSID)); - if(!SUCCEEDED(hResult)) { + if (!SUCCEEDED(hResult)) { return hResult; } diff --git a/shell_integration/windows/OCOverlays/OCOverlayRegistrationHandler.h b/shell_integration/windows/NCOverlays/NCOverlayRegistrationHandler.h similarity index 87% rename from shell_integration/windows/OCOverlays/OCOverlayRegistrationHandler.h rename to shell_integration/windows/NCOverlays/NCOverlayRegistrationHandler.h index 2ab8f702f..473d4217d 100644 --- a/shell_integration/windows/OCOverlays/OCOverlayRegistrationHandler.h +++ b/shell_integration/windows/NCOverlays/NCOverlayRegistrationHandler.h @@ -12,14 +12,14 @@ * details. */ -#ifndef OCOVERLAYREGISTRATIONHANDLER_H -#define OCOVERLAYREGISTRATIONHANDLER_H +#ifndef NCOVERLAYREGISTRATIONHANDLER_H +#define NCOVERLAYREGISTRATIONHANDLER_H #pragma once #include -class __declspec(dllexport) OCOverlayRegistrationHandler +class __declspec(dllexport) NCOverlayRegistrationHandler { public: static HRESULT MakeRegistryEntries(const CLSID& clsid, PCWSTR fileType); diff --git a/shell_integration/windows/OCOverlays/OCOverlays.def b/shell_integration/windows/NCOverlays/NCOverlays.def similarity index 100% rename from shell_integration/windows/OCOverlays/OCOverlays.def rename to shell_integration/windows/NCOverlays/NCOverlays.def diff --git a/shell_integration/windows/OCOverlays/ico/Error.ico b/shell_integration/windows/NCOverlays/ico/Error.ico similarity index 100% rename from shell_integration/windows/OCOverlays/ico/Error.ico rename to shell_integration/windows/NCOverlays/ico/Error.ico diff --git a/shell_integration/windows/OCOverlays/ico/OK.ico b/shell_integration/windows/NCOverlays/ico/OK.ico similarity index 100% rename from shell_integration/windows/OCOverlays/ico/OK.ico rename to shell_integration/windows/NCOverlays/ico/OK.ico diff --git a/shell_integration/windows/OCOverlays/ico/OK_Shared.ico b/shell_integration/windows/NCOverlays/ico/OK_Shared.ico similarity index 100% rename from shell_integration/windows/OCOverlays/ico/OK_Shared.ico rename to shell_integration/windows/NCOverlays/ico/OK_Shared.ico diff --git a/shell_integration/windows/OCOverlays/ico/Sync.ico b/shell_integration/windows/NCOverlays/ico/Sync.ico similarity index 100% rename from shell_integration/windows/OCOverlays/ico/Sync.ico rename to shell_integration/windows/NCOverlays/ico/Sync.ico diff --git a/shell_integration/windows/OCOverlays/ico/Warning.ico b/shell_integration/windows/NCOverlays/ico/Warning.ico similarity index 100% rename from shell_integration/windows/OCOverlays/ico/Warning.ico rename to shell_integration/windows/NCOverlays/ico/Warning.ico diff --git a/shell_integration/windows/OCOverlays/resource.h b/shell_integration/windows/NCOverlays/resource.h similarity index 96% rename from shell_integration/windows/OCOverlays/resource.h rename to shell_integration/windows/NCOverlays/resource.h index 3a3dab356..b092fe27c 100644 Binary files a/shell_integration/windows/OCOverlays/resource.h and b/shell_integration/windows/NCOverlays/resource.h differ diff --git a/shell_integration/windows/OCUtil/CMakeLists.txt b/shell_integration/windows/NCUtil/CMakeLists.txt similarity index 63% rename from shell_integration/windows/OCUtil/CMakeLists.txt rename to shell_integration/windows/NCUtil/CMakeLists.txt index 13a9f6f53..fa75e1593 100644 --- a/shell_integration/windows/OCUtil/CMakeLists.txt +++ b/shell_integration/windows/NCUtil/CMakeLists.txt @@ -1,11 +1,11 @@ -add_library(OCUtil STATIC +add_library(NCUtil STATIC CommunicationSocket.cpp RemotePathChecker.cpp StringUtil.cpp - OCUtil.rc + NCUtil.rc ) -target_include_directories(OCUtil +target_include_directories(NCUtil PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}" ) diff --git a/shell_integration/windows/OCUtil/CommunicationSocket.cpp b/shell_integration/windows/NCUtil/CommunicationSocket.cpp similarity index 99% rename from shell_integration/windows/OCUtil/CommunicationSocket.cpp rename to shell_integration/windows/NCUtil/CommunicationSocket.cpp index 10f95159e..cda36c1b8 100644 --- a/shell_integration/windows/OCUtil/CommunicationSocket.cpp +++ b/shell_integration/windows/NCUtil/CommunicationSocket.cpp @@ -13,7 +13,6 @@ */ #include "CommunicationSocket.h" -#include "UtilConstants.h" #include "StringUtil.h" #include diff --git a/shell_integration/windows/OCUtil/CommunicationSocket.h b/shell_integration/windows/NCUtil/CommunicationSocket.h similarity index 100% rename from shell_integration/windows/OCUtil/CommunicationSocket.h rename to shell_integration/windows/NCUtil/CommunicationSocket.h diff --git a/shell_integration/windows/OCUtil/OCUtil.rc b/shell_integration/windows/NCUtil/NCUtil.rc similarity index 87% rename from shell_integration/windows/OCUtil/OCUtil.rc rename to shell_integration/windows/NCUtil/NCUtil.rc index 4fa556679..fc3700847 100644 Binary files a/shell_integration/windows/OCUtil/OCUtil.rc and b/shell_integration/windows/NCUtil/NCUtil.rc differ diff --git a/shell_integration/windows/OCUtil/RemotePathChecker.cpp b/shell_integration/windows/NCUtil/RemotePathChecker.cpp similarity index 100% rename from shell_integration/windows/OCUtil/RemotePathChecker.cpp rename to shell_integration/windows/NCUtil/RemotePathChecker.cpp diff --git a/shell_integration/windows/OCUtil/RemotePathChecker.h b/shell_integration/windows/NCUtil/RemotePathChecker.h similarity index 95% rename from shell_integration/windows/OCUtil/RemotePathChecker.h rename to shell_integration/windows/NCUtil/RemotePathChecker.h index 36bcf1ae9..5758a9a5c 100644 --- a/shell_integration/windows/OCUtil/RemotePathChecker.h +++ b/shell_integration/windows/NCUtil/RemotePathChecker.h @@ -29,7 +29,7 @@ class __declspec(dllexport) RemotePathChecker { public: enum FileState { - // Order synced with OCOverlay + // Order synced with NCOverlay StateError = 0, StateOk, StateOkSWM, StateSync, @@ -53,7 +53,7 @@ private: std::queue _pending; std::unordered_map _cache; - // The vector is const since it will be accessed from multiple threads through OCOverlay::IsMemberOf. + // The vector is const since it will be accessed from multiple threads through NCOverlay::IsMemberOf. // Each modification needs to be made onto a copy and then atomically replaced in the shared_ptr. std::shared_ptr> _watchedDirectories; bool _connected; diff --git a/shell_integration/windows/OCUtil/StringUtil.cpp b/shell_integration/windows/NCUtil/StringUtil.cpp similarity index 100% rename from shell_integration/windows/OCUtil/StringUtil.cpp rename to shell_integration/windows/NCUtil/StringUtil.cpp diff --git a/shell_integration/windows/OCUtil/StringUtil.h b/shell_integration/windows/NCUtil/StringUtil.h similarity index 100% rename from shell_integration/windows/OCUtil/StringUtil.h rename to shell_integration/windows/NCUtil/StringUtil.h diff --git a/shell_integration/windows/OCUtil/Version.h b/shell_integration/windows/NCUtil/Version.h similarity index 67% rename from shell_integration/windows/OCUtil/Version.h rename to shell_integration/windows/NCUtil/Version.h index d2c83b060..365156919 100644 --- a/shell_integration/windows/OCUtil/Version.h +++ b/shell_integration/windows/NCUtil/Version.h @@ -2,10 +2,10 @@ // This is the number that will end up in the version window of the DLLs. // Increment this version before committing a new build if you are today's shell_integration build master. -#define OCEXT_BUILD_NUM 46 +#define NCEXT_BUILD_NUM 47 #define STRINGIZE2(s) #s #define STRINGIZE(s) STRINGIZE2(s) -#define OCEXT_VERSION 1,0,0,OCEXT_BUILD_NUM -#define OCEXT_VERSION_STRING STRINGIZE(OCEXT_VERSION) +#define NCEXT_VERSION 3,0,0,NCEXT_BUILD_NUM +#define NCEXT_VERSION_STRING STRINGIZE(NCEXT_VERSION) diff --git a/shell_integration/windows/OCContextMenu/resource.h b/shell_integration/windows/NCUtil/resource.h similarity index 92% rename from shell_integration/windows/OCContextMenu/resource.h rename to shell_integration/windows/NCUtil/resource.h index b9407b5bc..c80f97834 100644 --- a/shell_integration/windows/OCContextMenu/resource.h +++ b/shell_integration/windows/NCUtil/resource.h @@ -1,6 +1,6 @@ //{{NO_DEPENDENCIES}} // Microsoft Visual C++ generated include file. -// Used by OCContextMenu.rc +// Used by NCContextMenu.rc // Next default values for new objects // diff --git a/shell_integration/windows/OCContextMenu/CMakeLists.txt b/shell_integration/windows/OCContextMenu/CMakeLists.txt deleted file mode 100644 index 74c12621b..000000000 --- a/shell_integration/windows/OCContextMenu/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -add_library(OCContextMenu MODULE - dllmain.cpp - OCClientInterface.cpp - OCContextMenu.cpp - OCContextMenuFactory.cpp - OCContextMenuRegHandler.cpp - OCContextMenu.rc - OCContextMenu.def -) - -target_link_libraries(OCContextMenu - OCUtil) - -install(TARGETS OCContextMenu - RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} - LIBRARY DESTINATION ${CMAKE_INSTALL_BINDIR} -) diff --git a/shell_integration/windows/OCOverlays/CMakeLists.txt b/shell_integration/windows/OCOverlays/CMakeLists.txt deleted file mode 100644 index 60d4a3748..000000000 --- a/shell_integration/windows/OCOverlays/CMakeLists.txt +++ /dev/null @@ -1,16 +0,0 @@ -add_library(OCOverlays MODULE - DllMain.cpp - OCOverlay.cpp - OCOverlayFactory.cpp - OCOverlayRegistrationHandler.cpp - OCOverlay.rc - OCOverlays.def -) - -target_link_libraries(OCOverlays - OCUtil) - -install(TARGETS OCOverlays - RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} - LIBRARY DESTINATION ${CMAKE_INSTALL_BINDIR} -) diff --git a/shell_integration/windows/OCUtil/UtilConstants.h b/shell_integration/windows/OCUtil/UtilConstants.h deleted file mode 100644 index 04ca7d3ba..000000000 --- a/shell_integration/windows/OCUtil/UtilConstants.h +++ /dev/null @@ -1,30 +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. - */ - -#define PLUG_IN_SOCKET_ADDRESS "127.0.0.1" - -#define BACK_SLASH L"\\" -#define CLOSE_BRACE L"]" -#define CLOSE_CURLY_BRACE L"}" -#define COLON L":" -#define COMMAND L"command" -#define COMMA L"," -#define OPEN_BRACE L"[" -#define OPEN_CURLY_BRACE L"{" -#define QUOTE L"\"" -#define VALUE L"value" - -#define REGISTRY_ROOT_KEY L"SOFTWARE\\ownCloud Inc\\ownCloud" -#define REGISTRY_ENABLE_OVERLAY L"EnableOverlay" -#define REGISTRY_FILTER_FOLDER L"FilterFolder" diff --git a/shell_integration/windows/WinShellExtConstants.h.in b/shell_integration/windows/WinShellExtConstants.h.in index 4c8a16597..cc0b4e32f 100644 --- a/shell_integration/windows/WinShellExtConstants.h.in +++ b/shell_integration/windows/WinShellExtConstants.h.in @@ -14,8 +14,13 @@ #pragma once +// IMPORTANT: Keep this file in sync with WinShellExtConstants.wxi.in + // Context Menu #define CONTEXT_MENU_GUID L"@WIN_SHELLEXT_CONTEXT_MENU_GUID@" +#define CONTEXT_MENU_REGKEY_NAME L"@APPLICATION_SHORTNAME@ContextMenuHandler" + +#define CONTEXT_MENU_DESCRIPTION L"@APPLICATION_SHORTNAME@ context menu handler" // Overlays #define OVERLAY_GUID_ERROR L"@WIN_SHELLEXT_OVERLAY_GUID_ERROR@" @@ -23,3 +28,17 @@ #define OVERLAY_GUID_OK_SHARED L"@WIN_SHELLEXT_OVERLAY_GUID_OK_SHARED@" #define OVERLAY_GUID_SYNC L"@WIN_SHELLEXT_OVERLAY_GUID_SYNC@" #define OVERLAY_GUID_WARNING L"@WIN_SHELLEXT_OVERLAY_GUID_WARNING@" + +// +// Preceeding spaces are intended, two spaces to put us ahead of the competition :/ +// +// There is a limit in Windows (oh wonder^^) so that only the first 15 extensions get invoked, this is why to use that dirty little trick to get ahead ;) +// See: https://docs.microsoft.com/en-us/windows/win32/shell/context-menu-handlers?redirectedfrom=MSDN#employing-the-verb-selection-model +// +#define OVERLAY_NAME_ERROR L" @APPLICATION_SHORTNAME@Error" +#define OVERLAY_NAME_OK L" @APPLICATION_SHORTNAME@OK" +#define OVERLAY_NAME_OK_SHARED L" @APPLICATION_SHORTNAME@OKShared" +#define OVERLAY_NAME_SYNC L" @APPLICATION_SHORTNAME@Sync" +#define OVERLAY_NAME_WARNING L" @APPLICATION_SHORTNAME@Warning" + +#define OVERLAY_DESCRIPTION L"@APPLICATION_SHORTNAME@ overlay handler" diff --git a/shell_integration/windows/WinShellExtConstants.wxi.in b/shell_integration/windows/WinShellExtConstants.wxi.in index 788ca3239..9e65fd0e7 100644 --- a/shell_integration/windows/WinShellExtConstants.wxi.in +++ b/shell_integration/windows/WinShellExtConstants.wxi.in @@ -16,6 +16,10 @@ --> + + @@ -29,7 +33,12 @@ - +