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

View File

@ -737,11 +737,15 @@ CClient::onFileRecieveCompleted()
void
CClient::writeToDropDirThread(void*)
{
LOG((CLOG_DEBUG "starting write to drop dir thread"));
while (m_screen->getFakeDraggingStarted()) {
ARCH->sleep(.1f);
}
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) {
std::fstream file;
CString dropTarget = m_fileTransferDes;

View File

@ -43,6 +43,7 @@
#include <string.h>
#include <pbt.h>
#include <Shlobj.h>
#include <comutil.h>
//
// 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 "window is 0x%08x", m_window));
char desktopPath[MAX_PATH];
SHGetFolderPath(NULL, CSIDL_DESKTOP, NULL, 0, desktopPath);
m_desktopPath = CString(desktopPath);
LOG((CLOG_DEBUG "temporarily use desktop directory for drop target: %s", m_desktopPath.c_str()));
wchar_t* desktopPath = 0;
SHGetKnownFolderPath(FOLDERID_Desktop, 0, NULL, &desktopPath);
m_desktopPath = _bstr_t(desktopPath);
CoTaskMemFree(static_cast<void*>(desktopPath));
LOG((CLOG_DEBUG "using desktop for drop target: %s", m_desktopPath.c_str()));
}
catch (...) {
delete m_keyState;

View File

@ -1988,11 +1988,15 @@ CServer::onFileRecieveCompleted()
void
CServer::writeToDropDirThread(void*)
{
LOG((CLOG_DEBUG "starting write to drop dir thread"));
while (m_screen->getFakeDraggingStarted()) {
ARCH->sleep(.1f);
}
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) {
std::fstream file;
CString dropTarget = m_fileTransferDes;

View File

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

View File

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

View File

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