From f84758eaac5d2afd2eb2b6c57a02f3b6c411c040 Mon Sep 17 00:00:00 2001 From: Daniel Molkentin Date: Thu, 29 Jan 2015 16:37:51 +0100 Subject: [PATCH] Add Resource File for OCContextMenu, adjust (c) dates. --- .../windows/OCContextMenu/OCContextMenu.rc | Bin 0 -> 4660 bytes .../OCContextMenu/OCContextMenu.vcxproj | 4 + .../windows/OCContextMenu/resource.h | 14 ++ .../windows/OCOverlays/OCContextMenu.cpp | 131 ++++++++++++++++++ .../windows/OCOverlays/OCContextMenu.h | 43 ++++++ .../windows/OCOverlays/OCOverlay.rc | Bin 6122 -> 6110 bytes 6 files changed, 192 insertions(+) create mode 100644 shell_integration/windows/OCContextMenu/OCContextMenu.rc create mode 100644 shell_integration/windows/OCContextMenu/resource.h create mode 100644 shell_integration/windows/OCOverlays/OCContextMenu.cpp create mode 100644 shell_integration/windows/OCOverlays/OCContextMenu.h diff --git a/shell_integration/windows/OCContextMenu/OCContextMenu.rc b/shell_integration/windows/OCContextMenu/OCContextMenu.rc new file mode 100644 index 0000000000000000000000000000000000000000..9ad518061424fe2665118758f57bd8f0ee15ec8f GIT binary patch literal 4660 zcmdUyTTdE66vxkVlYWOSzSPvHsD0?80-`C3kxSdegtP+I#DZZV+N7Vo?e9Os$S%9s zNNqy1S!VXkx!>mS>*tnjS!5@6ZI?E(p~bv?8v|4jb%zRmQfSlLc|2rmmg8UZrZQ3&(vsB&&Q)HK?B! z)m1`rhwQ5Hi0==cXdz`29_Qq62dY!(*PYZF&{Lo-)~d_X0P%QLcpp=%N45d)26zWR zJk2~thf`nGJ_BUS;tWuIw6WwpQp^8cFUYU*kP}+<7V%j=X5`Kfu)XR!g|MUPliztS zY$6+iDWQK_#iBO|Zl7cARv3U)!?x*(%{@1JS8NTb~)HF~O?HP?^3RGNB>f7B!L z`b{?5LX1|ct0c9NhWZYx?tb0yF%}PrM}P-Q+EiZ$oC%(Xvp1!gd8^4h zbB2ZjnURe zFMFa%r{pG&9jq(bTRiwYF|JSLEAwS_h`GL!8MWB@P4Y|8eu@{)kUE5JLQanVk*Cu# zmd}>i3=pa$3rSaf8{dr{Jh@C4N!NN4ZmRPbFKfC@)}MO1?=i}qA~TBmr|+*`-CZD|C-2wQ+ROUn>usf{etcUb@S-?V1T$Nx + @@ -170,6 +171,9 @@ + + + diff --git a/shell_integration/windows/OCContextMenu/resource.h b/shell_integration/windows/OCContextMenu/resource.h new file mode 100644 index 000000000..b9407b5bc --- /dev/null +++ b/shell_integration/windows/OCContextMenu/resource.h @@ -0,0 +1,14 @@ +//{{NO_DEPENDENCIES}} +// Microsoft Visual C++ generated include file. +// Used by OCContextMenu.rc + +// Next default values for new objects +// +#ifdef APSTUDIO_INVOKED +#ifndef APSTUDIO_READONLY_SYMBOLS +#define _APS_NEXT_RESOURCE_VALUE 101 +#define _APS_NEXT_COMMAND_VALUE 40001 +#define _APS_NEXT_CONTROL_VALUE 1001 +#define _APS_NEXT_SYMED_VALUE 101 +#endif +#endif diff --git a/shell_integration/windows/OCOverlays/OCContextMenu.cpp b/shell_integration/windows/OCOverlays/OCContextMenu.cpp new file mode 100644 index 000000000..cac5125a8 --- /dev/null +++ b/shell_integration/windows/OCOverlays/OCContextMenu.cpp @@ -0,0 +1,131 @@ +/** +* Copyright (c) 2015 Daniel Molkentin . 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 "OCContextMenu.h" +#include "stdafx.h" + +#define IDM_SHARE 0 + +OCContextMenu::OCContextMenu() + : m_pwszVerb(0) + , m_referenceCount(0) +{ +} + + +OCContextMenu::~OCContextMenu() +{ +} + +IFACEMETHODIMP_(ULONG) OCContextMenu::AddRef() +{ + return InterlockedIncrement(&m_referenceCount); +} + +IFACEMETHODIMP_(ULONG) OCContextMenu::Release() +{ + ULONG cRef = InterlockedDecrement(&m_referenceCount); + if (0 == cRef) + { + delete this; + } + + return cRef; +} + +IFACEMETHODIMP OCContextMenu::QueryInterface(REFIID riid, void **ppv) +{ + HRESULT hr = S_OK; + + if (IsEqualIID(IID_IUnknown, riid) || IsEqualIID(IID_IContextMenu, riid)) + { + *ppv = static_cast(this); + } + else + { + hr = E_NOINTERFACE; + *ppv = NULL; + } + + if (*ppv) + { + AddRef(); + } + + return hr; +} + +IFACEMETHODIMP OCContextMenu::GetCommandString(UINT_PTR idCmd, UINT uFlags, UINT *pwReserved, LPSTR pszName, UINT cchMax) +{ + HRESULT hr = E_INVALIDARG; + + if (idCmd == IDM_SHARE) + { + switch (uFlags) + { + case GCS_HELPTEXTW: + hr = StringCchCopyW(reinterpret_cast(pszName), cchMax, L"Shares file or directory with ownCloud"); + break; + + case GCS_VERBW: + // GCS_VERBW is an optional feature that enables a caller + // to discover the canonical name for the verb that is passed in + // through idCommand. + hr = StringCchCopyW(reinterpret_cast(pszName), cchMax, L"ownCloudShare"); + break; + } + } + return hr; +} + +IFACEMETHODIMP OCContextMenu::InvokeCommand(LPCMINVOKECOMMANDINFO pici) +{ + if (pici->cbSize == sizeof(CMINVOKECOMMANDINFOEX) && + (pici->fMask & CMIC_MASK_UNICODE)) + { + return E_FAIL; + } + return MAKE_HRESULT(SEVERITY_SUCCESS, 0, USHORT(0)); + if (HIWORD(((CMINVOKECOMMANDINFOEX *)pici)->lpVerbW)) + { + if (StrCmpIW(((CMINVOKECOMMANDINFOEX *)pici)->lpVerbW, m_pwszVerb)) + { + return E_FAIL; + } + } + + if (LOWORD(pici->lpVerb) != IDM_SHARE) { + return E_FAIL; + } + + MessageBox(pici->hwnd, + L"ownCloud was here", + L"ownCloud was here", + MB_OK | MB_ICONINFORMATION); + +} + +IFACEMETHODIMP OCContextMenu::QueryContextMenu(HMENU hMenu, UINT indexMenu, UINT idCmdFirst, UINT idCmdLast, UINT uFlags) +{ + HRESULT hr; + + if (!(CMF_DEFAULTONLY & uFlags)) + { + InsertMenu(hMenu, indexMenu, MF_STRING | MF_BYPOSITION, idCmdFirst + IDM_SHARE, L"&Share with ownCloud"); + } + hr = StringCbCopyW(m_pwszVerb, sizeof(m_pwszVerb), L"ownCloudShare"); + + return MAKE_HRESULT(SEVERITY_SUCCESS, 0, USHORT(IDM_SHARE + 1)); +} + diff --git a/shell_integration/windows/OCOverlays/OCContextMenu.h b/shell_integration/windows/OCOverlays/OCContextMenu.h new file mode 100644 index 000000000..81cec6021 --- /dev/null +++ b/shell_integration/windows/OCOverlays/OCContextMenu.h @@ -0,0 +1,43 @@ +/** +* Copyright (c) 2015 Daniel Molkentin . 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 OCCONTEXTMENU_H +#define OCCONTEXTMENU_H + +#pragma once + +#include "ShObjIdl.h" +#include "memory" + +class OCContextMenu :public IContextMenu +{ +public: + OCContextMenu(); + ~OCContextMenu(); + + IFACEMETHODIMP QueryInterface(REFIID riid, void **ppv); + IFACEMETHODIMP_(ULONG) AddRef(); + IFACEMETHODIMP_(ULONG) Release(); + + + IFACEMETHODIMP GetCommandString(UINT_PTR idCmd, UINT uFlags, UINT *pwReserved, LPSTR pszName, UINT cchMax); + IFACEMETHODIMP InvokeCommand(LPCMINVOKECOMMANDINFO pici); + IFACEMETHODIMP QueryContextMenu(HMENU hmenu, UINT indexMenu, UINT idCmdFirst, UINT idCmdLast, UINT uFlags); +private: + TCHAR* m_pwszVerb; + long m_referenceCount; + +}; + +#endif //OCCONTEXTMENU_H \ No newline at end of file diff --git a/shell_integration/windows/OCOverlays/OCOverlay.rc b/shell_integration/windows/OCOverlays/OCOverlay.rc index fc261e81dfdacc581cfdef85c8b5043c520ee10e..653468b4400eeaa694966646e3a3331a684856cb 100644 GIT binary patch delta 50 zcmaE*e@}mdjF7NDgENCaLm5LVLlHv`Ln1>ZL-FK?0=konggiKP8H^YV7z`OqH}4cO GWCZ|V!wkUy delta 62 zcmcbo|4M&@jF4ssgFk}{5L+=QFxW77GUPFoFr+dR0qI1B9H1D8&IO9tO@1h#J2^(k KWAi#816BaafDYII