diff options
author | Daniel Molkentin <danimo@owncloud.com> | 2015-01-29 18:37:51 +0300 |
---|---|---|
committer | Daniel Molkentin <danimo@owncloud.com> | 2015-01-29 18:37:51 +0300 |
commit | f84758eaac5d2afd2eb2b6c57a02f3b6c411c040 (patch) | |
tree | 651728b687db26faa99179987698b8196066acd9 /shell_integration | |
parent | 8c58236e7c886c315b5a08a7f4263713ee57a210 (diff) |
Add Resource File for OCContextMenu, adjust (c) dates.
Diffstat (limited to 'shell_integration')
-rw-r--r-- | shell_integration/windows/OCContextMenu/OCContextMenu.rc | bin | 0 -> 4660 bytes | |||
-rw-r--r-- | shell_integration/windows/OCContextMenu/OCContextMenu.vcxproj | 4 | ||||
-rw-r--r-- | shell_integration/windows/OCContextMenu/resource.h | 14 | ||||
-rw-r--r-- | shell_integration/windows/OCOverlays/OCContextMenu.cpp | 131 | ||||
-rw-r--r-- | shell_integration/windows/OCOverlays/OCContextMenu.h | 43 | ||||
-rw-r--r-- | shell_integration/windows/OCOverlays/OCOverlay.rc | bin | 6122 -> 6110 bytes |
6 files changed, 192 insertions, 0 deletions
diff --git a/shell_integration/windows/OCContextMenu/OCContextMenu.rc b/shell_integration/windows/OCContextMenu/OCContextMenu.rc Binary files differnew file mode 100644 index 000000000..9ad518061 --- /dev/null +++ b/shell_integration/windows/OCContextMenu/OCContextMenu.rc diff --git a/shell_integration/windows/OCContextMenu/OCContextMenu.vcxproj b/shell_integration/windows/OCContextMenu/OCContextMenu.vcxproj index f01393576..535ae5282 100644 --- a/shell_integration/windows/OCContextMenu/OCContextMenu.vcxproj +++ b/shell_integration/windows/OCContextMenu/OCContextMenu.vcxproj @@ -146,6 +146,7 @@ <ClInclude Include="OCContextMenuFactory.h" /> <ClInclude Include="OCContextMenuRegHandler.h" /> <ClInclude Include="OCContextMenu.h" /> + <ClInclude Include="resource.h" /> <ClInclude Include="stdafx.h" /> <ClInclude Include="targetver.h" /> </ItemGroup> @@ -170,6 +171,9 @@ <ItemGroup> <None Include="OCContextMenu.def" /> </ItemGroup> + <ItemGroup> + <ResourceCompile Include="OCContextMenu.rc" /> + </ItemGroup> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> <ImportGroup Label="ExtensionTargets"> </ImportGroup> 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 <danimo@owncloud.com>. 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<IContextMenu *>(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<PWSTR>(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<PWSTR>(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 <danimo@owncloud.com>. 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 Binary files differindex fc261e81d..653468b44 100644 --- a/shell_integration/windows/OCOverlays/OCOverlay.rc +++ b/shell_integration/windows/OCOverlays/OCOverlay.rc |