- Log out dragging file's directory in Synergy (using COM shell extension)
- Change shell extension dll Main.cpp to synwinxt.cpp
This commit is contained in:
parent
587c320f61
commit
012fe6ddd8
|
@ -48,6 +48,7 @@ set(inc
|
||||||
../../lib/platform
|
../../lib/platform
|
||||||
../../lib/synergy
|
../../lib/synergy
|
||||||
../../lib/synwinhk
|
../../lib/synwinhk
|
||||||
|
../../lib/synwinxt
|
||||||
)
|
)
|
||||||
|
|
||||||
if (UNIX)
|
if (UNIX)
|
||||||
|
|
|
@ -48,6 +48,7 @@ set(inc
|
||||||
../../lib/synergy
|
../../lib/synergy
|
||||||
../../lib/server
|
../../lib/server
|
||||||
../../lib/synwinhk
|
../../lib/synwinhk
|
||||||
|
../../lib/synwinxt
|
||||||
)
|
)
|
||||||
|
|
||||||
if (UNIX)
|
if (UNIX)
|
||||||
|
|
|
@ -48,6 +48,7 @@ set(inc
|
||||||
../../lib/synergy
|
../../lib/synergy
|
||||||
../../lib/server
|
../../lib/server
|
||||||
../../lib/synwinhk
|
../../lib/synwinhk
|
||||||
|
../../lib/synwinxt
|
||||||
)
|
)
|
||||||
|
|
||||||
if (UNIX)
|
if (UNIX)
|
||||||
|
|
|
@ -25,7 +25,8 @@ CMSWindowsHookLibraryLoader::CMSWindowsHookLibraryLoader() :
|
||||||
m_cleanup(NULL),
|
m_cleanup(NULL),
|
||||||
m_setSides(NULL),
|
m_setSides(NULL),
|
||||||
m_setZone(NULL),
|
m_setZone(NULL),
|
||||||
m_setMode(NULL)
|
m_setMode(NULL),
|
||||||
|
m_getDraggingFileDir(NULL)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -67,4 +68,25 @@ CMSWindowsHookLibraryLoader::openHookLibrary(const char* name)
|
||||||
}
|
}
|
||||||
|
|
||||||
return hookLibrary;
|
return hookLibrary;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
HINSTANCE
|
||||||
|
CMSWindowsHookLibraryLoader::openShellLibrary(const char* name)
|
||||||
|
{
|
||||||
|
// load the hook library
|
||||||
|
HINSTANCE shellLibrary = LoadLibrary(name);
|
||||||
|
if (shellLibrary == NULL) {
|
||||||
|
LOG((CLOG_ERR "failed to load shell library, %s.dll is missing or invalid", name));
|
||||||
|
throw XScreenOpenFailure();
|
||||||
|
}
|
||||||
|
|
||||||
|
// look up functions
|
||||||
|
m_getDraggingFileDir = (GetDraggingFileDir)GetProcAddress(shellLibrary, "getDraggingFileDir");
|
||||||
|
|
||||||
|
if (m_getDraggingFileDir == NULL) {
|
||||||
|
LOG((CLOG_ERR "invalid shell library, use a newer %s.dll", name));
|
||||||
|
throw XScreenOpenFailure();
|
||||||
|
}
|
||||||
|
|
||||||
|
return shellLibrary;
|
||||||
|
}
|
||||||
|
|
|
@ -22,6 +22,7 @@
|
||||||
#define WIN32_LEAN_AND_MEAN
|
#define WIN32_LEAN_AND_MEAN
|
||||||
#include <Windows.h>
|
#include <Windows.h>
|
||||||
#include "synwinhk.h"
|
#include "synwinhk.h"
|
||||||
|
#include "synwinxt.h"
|
||||||
|
|
||||||
//! Loads Windows hook DLLs.
|
//! Loads Windows hook DLLs.
|
||||||
class CMSWindowsHookLibraryLoader
|
class CMSWindowsHookLibraryLoader
|
||||||
|
@ -31,6 +32,7 @@ public:
|
||||||
virtual ~CMSWindowsHookLibraryLoader();
|
virtual ~CMSWindowsHookLibraryLoader();
|
||||||
|
|
||||||
HINSTANCE openHookLibrary(const char* name);
|
HINSTANCE openHookLibrary(const char* name);
|
||||||
|
HINSTANCE openShellLibrary(const char* name);
|
||||||
|
|
||||||
// TODO: either make these private or expose properly
|
// TODO: either make these private or expose properly
|
||||||
InitFunc m_init;
|
InitFunc m_init;
|
||||||
|
@ -39,8 +41,7 @@ public:
|
||||||
SetZoneFunc m_setZone;
|
SetZoneFunc m_setZone;
|
||||||
SetModeFunc m_setMode;
|
SetModeFunc m_setMode;
|
||||||
|
|
||||||
private:
|
GetDraggingFileDir m_getDraggingFileDir;
|
||||||
HINSTANCE m_hookLibrary;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
|
@ -110,9 +110,11 @@ CMSWindowsScreen::CMSWindowsScreen(
|
||||||
m_ownClipboard(false),
|
m_ownClipboard(false),
|
||||||
m_desks(NULL),
|
m_desks(NULL),
|
||||||
m_hookLibrary(NULL),
|
m_hookLibrary(NULL),
|
||||||
|
m_shellLibrary(NULL),
|
||||||
m_keyState(NULL),
|
m_keyState(NULL),
|
||||||
m_hasMouse(GetSystemMetrics(SM_MOUSEPRESENT) != 0),
|
m_hasMouse(GetSystemMetrics(SM_MOUSEPRESENT) != 0),
|
||||||
m_showingMouse(false),
|
m_showingMouse(false),
|
||||||
|
m_startDragging(false),
|
||||||
m_events(events)
|
m_events(events)
|
||||||
{
|
{
|
||||||
assert(s_windowInstance != NULL);
|
assert(s_windowInstance != NULL);
|
||||||
|
@ -122,6 +124,7 @@ CMSWindowsScreen::CMSWindowsScreen(
|
||||||
try {
|
try {
|
||||||
if (m_isPrimary && !m_noHooks) {
|
if (m_isPrimary && !m_noHooks) {
|
||||||
m_hookLibrary = openHookLibrary("synwinhk");
|
m_hookLibrary = openHookLibrary("synwinhk");
|
||||||
|
m_shellLibrary = openShellLibrary("synwinxt");
|
||||||
}
|
}
|
||||||
m_screensaver = new CMSWindowsScreenSaver();
|
m_screensaver = new CMSWindowsScreenSaver();
|
||||||
m_desks = new CMSWindowsDesks(
|
m_desks = new CMSWindowsDesks(
|
||||||
|
@ -149,6 +152,9 @@ CMSWindowsScreen::CMSWindowsScreen(
|
||||||
if (m_hookLibrary != NULL)
|
if (m_hookLibrary != NULL)
|
||||||
closeHookLibrary(m_hookLibrary);
|
closeHookLibrary(m_hookLibrary);
|
||||||
|
|
||||||
|
if (m_shellLibrary != NULL)
|
||||||
|
closeHookLibrary(m_shellLibrary);
|
||||||
|
|
||||||
s_screen = NULL;
|
s_screen = NULL;
|
||||||
throw;
|
throw;
|
||||||
}
|
}
|
||||||
|
@ -178,6 +184,9 @@ CMSWindowsScreen::~CMSWindowsScreen()
|
||||||
if (m_hookLibrary != NULL)
|
if (m_hookLibrary != NULL)
|
||||||
closeHookLibrary(m_hookLibrary);
|
closeHookLibrary(m_hookLibrary);
|
||||||
|
|
||||||
|
if (m_shellLibrary != NULL)
|
||||||
|
closeHookLibrary(m_shellLibrary);
|
||||||
|
|
||||||
s_screen = NULL;
|
s_screen = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -751,6 +760,12 @@ CMSWindowsScreen::openHookLibrary(const char* name)
|
||||||
return m_hookLibraryLoader.openHookLibrary(name);
|
return m_hookLibraryLoader.openHookLibrary(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
HINSTANCE
|
||||||
|
CMSWindowsScreen::openShellLibrary(const char* name)
|
||||||
|
{
|
||||||
|
return m_hookLibraryLoader.openShellLibrary(name);
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
CMSWindowsScreen::closeHookLibrary(HINSTANCE hookLibrary) const
|
CMSWindowsScreen::closeHookLibrary(HINSTANCE hookLibrary) const
|
||||||
{
|
{
|
||||||
|
@ -1261,6 +1276,9 @@ CMSWindowsScreen::onMouseButton(WPARAM wParam, LPARAM lParam)
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
m_buttons[button] = false;
|
m_buttons[button] = false;
|
||||||
|
if (m_startDragging && button == kButtonLeft) {
|
||||||
|
m_startDragging = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1321,6 +1339,15 @@ CMSWindowsScreen::onMouseMove(SInt32 mx, SInt32 my)
|
||||||
sendEvent(
|
sendEvent(
|
||||||
m_events->forIPrimaryScreen().motionOnPrimary(),
|
m_events->forIPrimaryScreen().motionOnPrimary(),
|
||||||
CMotionInfo::alloc(m_xCursor, m_yCursor));
|
CMotionInfo::alloc(m_xCursor, m_yCursor));
|
||||||
|
|
||||||
|
if (m_buttons[kButtonLeft] == true && m_startDragging == false) {
|
||||||
|
// temporarily log out dragging file directory
|
||||||
|
char dir[MAX_PATH];
|
||||||
|
m_hookLibraryLoader.m_getDraggingFileDir(dir);
|
||||||
|
LOG((CLOG_DEBUG "dragging file: %s", dir));
|
||||||
|
|
||||||
|
m_startDragging = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -125,6 +125,7 @@ protected:
|
||||||
private:
|
private:
|
||||||
// initialization and shutdown operations
|
// initialization and shutdown operations
|
||||||
HINSTANCE openHookLibrary(const char* name);
|
HINSTANCE openHookLibrary(const char* name);
|
||||||
|
HINSTANCE openShellLibrary(const char* name);
|
||||||
void closeHookLibrary(HINSTANCE hookLibrary) const;
|
void closeHookLibrary(HINSTANCE hookLibrary) const;
|
||||||
HCURSOR createBlankCursor() const;
|
HCURSOR createBlankCursor() const;
|
||||||
void destroyCursor(HCURSOR cursor) const;
|
void destroyCursor(HCURSOR cursor) const;
|
||||||
|
@ -286,6 +287,7 @@ private:
|
||||||
|
|
||||||
// hook library stuff
|
// hook library stuff
|
||||||
HINSTANCE m_hookLibrary;
|
HINSTANCE m_hookLibrary;
|
||||||
|
HINSTANCE m_shellLibrary;
|
||||||
|
|
||||||
// keyboard stuff
|
// keyboard stuff
|
||||||
CMSWindowsKeyState* m_keyState;
|
CMSWindowsKeyState* m_keyState;
|
||||||
|
@ -323,6 +325,8 @@ private:
|
||||||
s_screen;
|
s_screen;
|
||||||
|
|
||||||
IEventQueue* m_events;
|
IEventQueue* m_events;
|
||||||
|
|
||||||
|
bool m_startDragging;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -101,6 +101,7 @@ set(inc
|
||||||
../net
|
../net
|
||||||
../io
|
../io
|
||||||
../synwinhk
|
../synwinhk
|
||||||
|
../synwinxt
|
||||||
)
|
)
|
||||||
|
|
||||||
if (UNIX)
|
if (UNIX)
|
||||||
|
|
|
@ -105,6 +105,7 @@ set(inc
|
||||||
../server
|
../server
|
||||||
../synergy
|
../synergy
|
||||||
../synwinhk
|
../synwinhk
|
||||||
|
../synwinxt
|
||||||
../..
|
../..
|
||||||
../../../tools
|
../../../tools
|
||||||
)
|
)
|
||||||
|
|
|
@ -21,6 +21,7 @@
|
||||||
|
|
||||||
extern LONG g_refCount;
|
extern LONG g_refCount;
|
||||||
extern GUID g_CLSID;
|
extern GUID g_CLSID;
|
||||||
|
extern void updateDraggingDir(char*);
|
||||||
extern void outputDebugStringF(const char *str, ...);
|
extern void outputDebugStringF(const char *str, ...);
|
||||||
|
|
||||||
CDataHandlerExtension::CDataHandlerExtension()
|
CDataHandlerExtension::CDataHandlerExtension()
|
||||||
|
@ -64,8 +65,11 @@ CDataHandlerExtension::Release()
|
||||||
HRESULT STDMETHODCALLTYPE
|
HRESULT STDMETHODCALLTYPE
|
||||||
CDataHandlerExtension::Load(__RPC__in LPCOLESTR pszFileName, DWORD dwMode)
|
CDataHandlerExtension::Load(__RPC__in LPCOLESTR pszFileName, DWORD dwMode)
|
||||||
{
|
{
|
||||||
StringCchCopyW(m_selectedFileName, ARRAYSIZE(m_selectedFileName), pszFileName);
|
char selectedFileDir[MAX_PATH];
|
||||||
outputDebugStringF("DataHandlerDemo: CDataHandlerExtension::Load: m_selectedFileName=%ls", m_selectedFileName);
|
StringCchCopyW(m_selectedFileDir, ARRAYSIZE(m_selectedFileDir), pszFileName);
|
||||||
|
WideCharToMultiByte(CP_ACP, 0, m_selectedFileDir, -1, selectedFileDir, MAX_PATH, NULL, NULL);
|
||||||
|
updateDraggingDir(selectedFileDir);
|
||||||
|
|
||||||
return S_OK;
|
return S_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -53,5 +53,5 @@ public:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
LONG m_refCount;
|
LONG m_refCount;
|
||||||
WCHAR m_selectedFileName[MAX_PATH];
|
WCHAR m_selectedFileDir[MAX_PATH];
|
||||||
};
|
};
|
||||||
|
|
|
@ -16,13 +16,14 @@
|
||||||
set(inc
|
set(inc
|
||||||
CClassFactory.h
|
CClassFactory.h
|
||||||
CDataHandlerExtension.h
|
CDataHandlerExtension.h
|
||||||
|
synwinxt.h
|
||||||
)
|
)
|
||||||
|
|
||||||
set(src
|
set(src
|
||||||
CClassFactory.cpp
|
CClassFactory.cpp
|
||||||
CDataHandlerExtension.cpp
|
CDataHandlerExtension.cpp
|
||||||
|
synwinxt.cpp
|
||||||
synwinxt.def
|
synwinxt.def
|
||||||
Main.cpp
|
|
||||||
)
|
)
|
||||||
|
|
||||||
list(APPEND src
|
list(APPEND src
|
||||||
|
|
|
@ -15,6 +15,7 @@
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include "synwinxt.h"
|
||||||
#include "CClassFactory.h"
|
#include "CClassFactory.h"
|
||||||
#include "CArchMiscWindows.h"
|
#include "CArchMiscWindows.h"
|
||||||
#include <strsafe.h>
|
#include <strsafe.h>
|
||||||
|
@ -22,6 +23,17 @@
|
||||||
|
|
||||||
#pragma comment(lib, "Shlwapi.lib")
|
#pragma comment(lib, "Shlwapi.lib")
|
||||||
|
|
||||||
|
#if defined(_MSC_VER)
|
||||||
|
#pragma comment(linker, "-section:sharedData,rws")
|
||||||
|
#pragma data_seg("sharedData")
|
||||||
|
#endif
|
||||||
|
|
||||||
|
static BYTE g_draggingFileDir[MAX_PATH] = { 0 };
|
||||||
|
|
||||||
|
#if defined(_MSC_VER)
|
||||||
|
#pragma data_seg()
|
||||||
|
#endif
|
||||||
|
|
||||||
// {1BE208B1-BC21-4E39-8BB6-A5DC3F51479E}
|
// {1BE208B1-BC21-4E39-8BB6-A5DC3F51479E}
|
||||||
GUID g_CLSID = {0x1be208b1, 0xbc21, 0x4e39, {0x8b, 0xb6, 0xa5, 0xdc, 0x3f, 0x51, 0x47, 0x9e}};
|
GUID g_CLSID = {0x1be208b1, 0xbc21, 0x4e39, {0x8b, 0xb6, 0xa5, 0xdc, 0x3f, 0x51, 0x47, 0x9e}};
|
||||||
LONG g_refCount = 0;
|
LONG g_refCount = 0;
|
||||||
|
@ -217,8 +229,7 @@ unregisterShellExtDataHandler(CHAR* fileType, const CLSID& clsid)
|
||||||
CHAR subkey[MAX_PATH];
|
CHAR subkey[MAX_PATH];
|
||||||
|
|
||||||
// Remove the HKCR\<File Type>\shellex\DataHandler key.
|
// Remove the HKCR\<File Type>\shellex\DataHandler key.
|
||||||
hr = StringCchPrintf(subkey, ARRAYSIZE(subkey),
|
hr = StringCchPrintf(subkey, ARRAYSIZE(subkey), "%s\\shellex\\DataHandler", fileType);
|
||||||
"%s\\shellex\\DataHandler", fileType);
|
|
||||||
if (SUCCEEDED(hr)) {
|
if (SUCCEEDED(hr)) {
|
||||||
hr = HRESULT_FROM_WIN32(RegDeleteTree(HKEY_CLASSES_ROOT, subkey));
|
hr = HRESULT_FROM_WIN32(RegDeleteTree(HKEY_CLASSES_ROOT, subkey));
|
||||||
}
|
}
|
||||||
|
@ -227,7 +238,7 @@ unregisterShellExtDataHandler(CHAR* fileType, const CLSID& clsid)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
outputDebugStringF(const char *str, ...)
|
outputDebugStringF(const char* str, ...)
|
||||||
{
|
{
|
||||||
char buf[2048];
|
char buf[2048];
|
||||||
|
|
||||||
|
@ -237,3 +248,16 @@ outputDebugStringF(const char *str, ...)
|
||||||
|
|
||||||
OutputDebugStringA(buf);
|
OutputDebugStringA(buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
updateDraggingDir(char* dir)
|
||||||
|
{
|
||||||
|
memcpy(g_draggingFileDir, dir, MAX_PATH);
|
||||||
|
outputDebugStringF("draggingFileDir: %s", g_draggingFileDir);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
getDraggingFileDir(char* dir)
|
||||||
|
{
|
||||||
|
memcpy(dir, g_draggingFileDir, MAX_PATH);
|
||||||
|
}
|
|
@ -4,3 +4,4 @@ EXPORTS
|
||||||
DllCanUnloadNow PRIVATE
|
DllCanUnloadNow PRIVATE
|
||||||
DllRegisterServer PRIVATE
|
DllRegisterServer PRIVATE
|
||||||
DllUnregisterServer PRIVATE
|
DllUnregisterServer PRIVATE
|
||||||
|
getDraggingFileDir
|
||||||
|
|
|
@ -0,0 +1,30 @@
|
||||||
|
/*
|
||||||
|
* synergy -- mouse and keyboard sharing utility
|
||||||
|
* Copyright (C) 2013 Bolton Software Ltd.
|
||||||
|
*
|
||||||
|
* This package is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU General Public License
|
||||||
|
* found in the file COPYING that should have accompanied this file.
|
||||||
|
*
|
||||||
|
* This package 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.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <Windows.h>
|
||||||
|
|
||||||
|
#if defined(synwinxt_EXPORTS)
|
||||||
|
#define CSYNERGYSHELLEXE_API __declspec(dllexport)
|
||||||
|
#else
|
||||||
|
#define CSYNERGYSHELLEXE_API __declspec(dllimport)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
typedef void (*GetDraggingFileDir)(CHAR*);
|
||||||
|
|
||||||
|
CSYNERGYSHELLEXE_API void getDraggingFileDir(char*);
|
|
@ -60,6 +60,7 @@ set(inc
|
||||||
../../lib/server
|
../../lib/server
|
||||||
../../lib/synergy
|
../../lib/synergy
|
||||||
../../lib/synwinhk
|
../../lib/synwinhk
|
||||||
|
../../lib/synwinxt
|
||||||
../../../tools/gtest-1.6.0/include
|
../../../tools/gtest-1.6.0/include
|
||||||
../../../tools/gmock-1.6.0/include
|
../../../tools/gmock-1.6.0/include
|
||||||
../unittests
|
../unittests
|
||||||
|
|
Loading…
Reference in New Issue