- improved string conversion by using ms comutil.

- removed dead member variable.
- extra logging to help debug file drop on windows.
This commit is contained in:
Nick Bolton 2014-02-07 17:06:26 +00:00
parent fe40c670a4
commit d03b398bc1
7 changed files with 26 additions and 18 deletions

View File

@ -180,7 +180,7 @@ if (UNIX)
${lib_Carbon} ${lib_Carbon}
) )
else() else() # not-apple
# add include dir for bsd (posix uses /usr/include/) # add include dir for bsd (posix uses /usr/include/)
set(CMAKE_INCLUDE_PATH "${CMAKE_INCLUDE_PATH}:/usr/local/include") set(CMAKE_INCLUDE_PATH "${CMAKE_INCLUDE_PATH}:/usr/local/include")
@ -284,9 +284,9 @@ if (UNIX)
add_definitions(-DWINAPI_XWINDOWS=1) add_definitions(-DWINAPI_XWINDOWS=1)
endif() endif()
else (UNIX) else() # not-unix
list(APPEND libs Wtsapi32 Userenv Wininet) list(APPEND libs Wtsapi32 Userenv Wininet comsuppw)
add_definitions( add_definitions(
/DWIN32 /DWIN32

View File

@ -737,11 +737,15 @@ CClient::onFileRecieveCompleted()
void void
CClient::writeToDropDirThread(void*) CClient::writeToDropDirThread(void*)
{ {
LOG((CLOG_DEBUG "starting write to drop dir thread"));
while (m_screen->getFakeDraggingStarted()) { while (m_screen->getFakeDraggingStarted()) {
ARCH->sleep(.1f); ARCH->sleep(.1f);
} }
m_fileTransferDes = m_screen->getDropTarget(); m_fileTransferDes = m_screen->getDropTarget();
LOG((CLOG_DEBUG "dropping file, files=%i target=%s", m_dragFileList.size(), m_fileTransferDes.c_str()));
if (!m_fileTransferDes.empty() && m_dragFileList.size() > 0) { if (!m_fileTransferDes.empty() && m_dragFileList.size() > 0) {
std::fstream file; std::fstream file;
CString dropTarget = m_fileTransferDes; CString dropTarget = m_fileTransferDes;

View File

@ -43,6 +43,7 @@
#include <string.h> #include <string.h>
#include <pbt.h> #include <pbt.h>
#include <Shlobj.h> #include <Shlobj.h>
#include <comutil.h>
// //
// add backwards compatible multihead support (and suppress bogus warning). // add backwards compatible multihead support (and suppress bogus warning).
@ -147,10 +148,11 @@ CMSWindowsScreen::CMSWindowsScreen(
LOG((CLOG_DEBUG "screen shape: %d,%d %dx%d %s", m_x, m_y, m_w, m_h, m_multimon ? "(multi-monitor)" : "")); LOG((CLOG_DEBUG "screen shape: %d,%d %dx%d %s", m_x, m_y, m_w, m_h, m_multimon ? "(multi-monitor)" : ""));
LOG((CLOG_DEBUG "window is 0x%08x", m_window)); LOG((CLOG_DEBUG "window is 0x%08x", m_window));
char desktopPath[MAX_PATH]; wchar_t* desktopPath = 0;
SHGetFolderPath(NULL, CSIDL_DESKTOP, NULL, 0, desktopPath); SHGetKnownFolderPath(FOLDERID_Desktop, 0, NULL, &desktopPath);
m_desktopPath = CString(desktopPath); m_desktopPath = _bstr_t(desktopPath);
LOG((CLOG_DEBUG "temporarily use desktop directory for drop target: %s", m_desktopPath.c_str())); CoTaskMemFree(static_cast<void*>(desktopPath));
LOG((CLOG_DEBUG "using desktop for drop target: %s", m_desktopPath.c_str()));
} }
catch (...) { catch (...) {
delete m_keyState; delete m_keyState;

View File

@ -1988,11 +1988,15 @@ CServer::onFileRecieveCompleted()
void void
CServer::writeToDropDirThread(void*) CServer::writeToDropDirThread(void*)
{ {
LOG((CLOG_DEBUG "starting write to drop dir thread"));
while (m_screen->getFakeDraggingStarted()) { while (m_screen->getFakeDraggingStarted()) {
ARCH->sleep(.1f); ARCH->sleep(.1f);
} }
m_fileTransferDes = m_screen->getDropTarget(); m_fileTransferDes = m_screen->getDropTarget();
LOG((CLOG_DEBUG "dropping file, files=%i target=%s", m_dragFileList.size(), m_fileTransferDes.c_str()));
if (!m_fileTransferDes.empty() && m_dragFileList.size() > 0) { if (!m_fileTransferDes.empty() && m_dragFileList.size() > 0) {
std::fstream file; std::fstream file;
CString dropTarget = m_fileTransferDes; CString dropTarget = m_fileTransferDes;

View File

@ -16,13 +16,14 @@
*/ */
#include "CDataHandlerExtension.h" #include "CDataHandlerExtension.h"
#include <Shlwapi.h> #include <Shlwapi.h>
#include <strsafe.h> #include <comutil.h>
#include <string>
extern LONG g_refCount; extern LONG g_refCount;
extern GUID g_CLSID; extern GUID g_CLSID;
extern void setDraggingFilename(char*); extern void setDraggingFilename(const char* str);
extern void outputDebugStringF(const char *str, ...); extern void outputDebugStringF(const char* str, ...);
CDataHandlerExtension::CDataHandlerExtension() : CDataHandlerExtension::CDataHandlerExtension() :
m_refCount(1) m_refCount(1)
@ -85,11 +86,9 @@ HRESULT STDMETHODCALLTYPE
CDataHandlerExtension::Load(__RPC__in LPCOLESTR pszFileName, DWORD dwMode) CDataHandlerExtension::Load(__RPC__in LPCOLESTR pszFileName, DWORD dwMode)
{ {
outputDebugStringF("synwinxt: > CDataHandlerExtension::Load\n"); outputDebugStringF("synwinxt: > CDataHandlerExtension::Load\n");
char selectedFilename[MAX_PATH]; std::string fileName = _bstr_t(pszFileName);
StringCchCopyW(m_selectedFilename, ARRAYSIZE(m_selectedFilename), pszFileName); setDraggingFilename(fileName.c_str());
WideCharToMultiByte(CP_ACP, 0, m_selectedFilename, -1, selectedFilename, MAX_PATH, NULL, NULL);
setDraggingFilename(selectedFilename);
outputDebugStringF("synwinxt: < CDataHandlerExtension::Load\n"); outputDebugStringF("synwinxt: < CDataHandlerExtension::Load\n");
return S_OK; return S_OK;

View File

@ -53,5 +53,4 @@ public:
private: private:
LONG m_refCount; LONG m_refCount;
WCHAR m_selectedFilename[MAX_PATH];
}; };

View File

@ -282,7 +282,7 @@ unregisterShellExtDataHandler(CHAR* fileType, const CLSID& clsid)
} }
void void
setDraggingFilename(char* filename) setDraggingFilename(const char* filename)
{ {
outputDebugStringF("synwinxt: > setDraggingFilename, filename=%s\n", filename); outputDebugStringF("synwinxt: > setDraggingFilename, filename=%s\n", filename);
memcpy(g_draggingFilename, filename, MAX_PATH); memcpy(g_draggingFilename, filename, MAX_PATH);