Previously side by side installation with ownCloud or other NC custom builds would break the shell integration because the same GUIDs and registry keys were used.
Now we specify our custom GUIDs in NEXTCLOUD.cmake and use CMake to generate a header file and WiX (MSI) include file with these constants.
Note: Using generators like "guidgen" or "uuidgen" ensures that GUIDs are unique, as manual changes are not guaranteed to be.
Signed-off-by: Michael Schuster <michael@schuster.ms>
set( APPLICATION_WIZARD_HEADER_TITLE_COLOR "#ffffff" CACHE STRING "Hex color of the text in the wizard header")
option( APPLICATION_WIZARD_USE_CUSTOM_LOGO "Use the logo from ':/client/theme/colored/wizard_logo.png' else the default application icon is used" ON )
+
+#
+## Windows Shell Extensions - IMPORTANT: Generate new GUIDs for custom builds with "guidgen" or "uuidgen"
+#
+
+# Context Menu
+set( WIN_SHELLEXT_CONTEXT_MENU_GUID "{BC6988AB-ACE2-4B81-84DC-DC34F9B24401}" )
+
+# Overlays
+set( WIN_SHELLEXT_OVERLAY_GUID_ERROR "{E0342B74-7593-4C70-9D61-22F294AAFE05}" )
+set( WIN_SHELLEXT_OVERLAY_GUID_OK "{E1094E94-BE93-4EA2-9639-8475C68F3886}" )
+set( WIN_SHELLEXT_OVERLAY_GUID_OK_SHARED "{E243AD85-F71B-496B-B17E-B8091CBE93D2}" )
+set( WIN_SHELLEXT_OVERLAY_GUID_SYNC "{E3D6DB20-1D83-4829-B5C9-941B31C0C35A}" )
+set( WIN_SHELLEXT_OVERLAY_GUID_WARNING "{E4977F33-F93A-4A0A-9D3C-83DEA0EE8483}" )
string(REPLACE "/MD" "/MT" "CMAKE_CXX_FLAGS${buildType}" "${CMAKE_CXX_FLAGS${buildType}}")
endforeach()
+include_directories(
+ ${CMAKE_CURRENT_BINARY_DIR}
+)
+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)
#include <Guiddef.h>
#include "OCContextMenuRegHandler.h"
#include "OCContextMenuFactory.h"
-
-// {841A0AAD-AA11-4B50-84D9-7F8E727D77D7}
-static const GUID CLSID_FileContextMenuExt = { 0x841a0aad, 0xaa11, 0x4b50, { 0x84, 0xd9, 0x7f, 0x8e, 0x72, 0x7d, 0x77, 0xd7 } };
+#include "WinShellExtConstants.h"
HINSTANCE g_hInst = nullptr;
long g_cDllRef = 0;
STDAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, void **ppv)
{
HRESULT hr = CLASS_E_CLASSNOTAVAILABLE;
+ GUID guid;
+
+ hr = CLSIDFromString(CONTEXT_MENU_GUID, (LPCLSID)&guid);
+ if (!SUCCEEDED(hr)) {
+ return hr;
+ }
- if (IsEqualCLSID(CLSID_FileContextMenuExt, rclsid)) {
+ if (IsEqualCLSID(guid, rclsid)) {
hr = E_OUTOFMEMORY;
OCContextMenuFactory *pClassFactory = new OCContextMenuFactory();
#include "OCOverlayRegistrationHandler.h"
#include "OCOverlayFactory.h"
-#include "OverlayConstants.h"
+#include "WinShellExtConstants.h"
HINSTANCE instanceHandle = nullptr;
+++ /dev/null
-/**
-* 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 OVERLAY_GUID_ERROR L"{0960F090-F328-48A3-B746-276B1E3C3722}"
-#define OVERLAY_GUID_ERROR_SHARED L"{0960F091-F328-48A3-B746-276B1E3C3722}"
-#define OVERLAY_GUID_OK L"{0960F092-F328-48A3-B746-276B1E3C3722}"
-#define OVERLAY_GUID_OK_SHARED L"{0960F093-F328-48A3-B746-276B1E3C3722}"
-#define OVERLAY_GUID_SYNC L"{0960F094-F328-48A3-B746-276B1E3C3722}"
-#define OVERLAY_GUID_SYNC_SHARED L"{0960F095-F328-48A3-B746-276B1E3C3722}"
-#define OVERLAY_GUID_WARNING L"{0960F096-F328-48A3-B746-276B1E3C3722}"
-#define OVERLAY_GUID_WARNING_SHARED L"{0960F097-F328-48A3-B746-276B1E3C3722}"
-
-#define OVERLAY_GENERIC_NAME L"ownCloud overlay handler"
-
-// two spaces to put us ahead of the competition :/
-#define OVERLAY_NAME_ERROR L" OCError"
-#define OVERLAY_NAME_ERROR_SHARED L" OCErrorShared"
-#define OVERLAY_NAME_OK L" OCOK"
-#define OVERLAY_NAME_OK_SHARED L" OCOKShared"
-#define OVERLAY_NAME_SYNC L" OCSync"
-#define OVERLAY_NAME_SYNC_SHARED L" OCSyncShared"
-#define OVERLAY_NAME_WARNING L" OCWarning"
-#define OVERLAY_NAME_WARNING_SHARED L" OCWarningShared"
-
-#define REGISTRY_OVERLAY_KEY L"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"
-
-//Registry values for running
-#define REGISTRY_ENABLE_OVERLAY L"EnableOverlay"
-
-#define GET_FILE_OVERLAY_ID L"getFileIconId"
-
-#define PORT 34001
--- /dev/null
+/*
+ * Copyright (C) by Michael Schuster <michael.schuster@nextcloud.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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 General Public License
+ * for more details.
+ */
+
+#pragma once
+
+// Context Menu
+#define CONTEXT_MENU_GUID L"@WIN_SHELLEXT_CONTEXT_MENU_GUID@"
+
+// Overlays
+#define OVERLAY_GUID_ERROR L"@WIN_SHELLEXT_OVERLAY_GUID_ERROR@"
+#define OVERLAY_GUID_OK L"@WIN_SHELLEXT_OVERLAY_GUID_OK@"
+#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@"
--- /dev/null
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ *
+ * Copyright (C) by Michael Schuster <michael.schuster@nextcloud.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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 General Public License
+ * for more details.
+ *
+-->
+<Include>
+
+ <!-- Context Menu -->
+ <?define ContextMenuGuid = "@WIN_SHELLEXT_CONTEXT_MENU_GUID@" ?>
+ <?define ContextMenuRegKeyName = "@APPLICATION_SHORTNAME@ContextMenuHandler" ?>
+
+ <?define ContextMenuDescription = "@APPLICATION_SHORTNAME@ context menu handler" ?>
+
+ <!-- Overlays -->
+ <?define OverlayGuidError = "@WIN_SHELLEXT_OVERLAY_GUID_ERROR@" ?>
+ <?define OverlayGuidOK = "@WIN_SHELLEXT_OVERLAY_GUID_OK@" ?>
+ <?define OverlayGuidOKShared = "@WIN_SHELLEXT_OVERLAY_GUID_OK_SHARED@" ?>
+ <?define OverlayGuidSync = "@WIN_SHELLEXT_OVERLAY_GUID_SYNC@" ?>
+ <?define OverlayGuidWarning = "@WIN_SHELLEXT_OVERLAY_GUID_WARNING@" ?>
+
+ <!-- Preceeding spaces are intended, two spaces to put us ahead of the competition :/ -->
+ <?define OverlayNameError = " @APPLICATION_SHORTNAME@Error" ?>
+ <?define OverlayNameOK = " @APPLICATION_SHORTNAME@OK" ?>
+ <?define OverlayNameOKShared = " @APPLICATION_SHORTNAME@OKShared" ?>
+ <?define OverlayNameSync = " @APPLICATION_SHORTNAME@Sync" ?>
+ <?define OverlayNameWarning = " @APPLICATION_SHORTNAME@Warning" ?>
+
+ <?define OverlayDescription = "@APPLICATION_SHORTNAME@ overlay handler" ?>
+
+</Include>