fixed: file is dragged twice by accident.
fixed: exe and lnk files dragged by accident. fixed: "dir" used instead of "filename".
This commit is contained in:
parent
98f8a12425
commit
cfc1aa2569
|
@ -1669,10 +1669,10 @@ CServer::onMouseUp(ButtonID id)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_enableDragDrop && !m_screen->isOnScreen()) {
|
if (m_enableDragDrop && !m_screen->isOnScreen()) {
|
||||||
CString& dir = m_screen->getDraggingFilename();
|
CString& file = m_screen->getDraggingFilename();
|
||||||
if (!dir.empty()) {
|
if (!file.empty()) {
|
||||||
LOG((CLOG_DEBUG "send file to client: %s", dir.c_str()));
|
LOG((CLOG_DEBUG "send file to client: %s", file.c_str()));
|
||||||
sendFileToClient(dir.c_str());
|
sendFileToClient(file.c_str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -86,10 +86,8 @@ 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");
|
||||||
|
|
||||||
std::string fileName = _bstr_t(pszFileName);
|
std::string fileName = _bstr_t(pszFileName);
|
||||||
setDraggingFilename(fileName.c_str());
|
setDraggingFilename(fileName.c_str());
|
||||||
|
|
||||||
outputDebugStringF("synwinxt: < CDataHandlerExtension::Load\n");
|
outputDebugStringF("synwinxt: < CDataHandlerExtension::Load\n");
|
||||||
return S_OK;
|
return S_OK;
|
||||||
}
|
}
|
||||||
|
|
|
@ -281,11 +281,37 @@ unregisterShellExtDataHandler(CHAR* fileType, const CLSID& clsid)
|
||||||
return hr;
|
return hr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string
|
||||||
|
getFileExt(const char* filenameCStr)
|
||||||
|
{
|
||||||
|
std::string filename = filenameCStr;
|
||||||
|
size_t findExt = filename.find_last_of(".", filename.size());
|
||||||
|
if (findExt != std::string::npos) {
|
||||||
|
return filename.substr(findExt + 1, filename.size() - findExt - 1);
|
||||||
|
}
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
setDraggingFilename(const char* filename)
|
setDraggingFilename(const char* filename)
|
||||||
{
|
{
|
||||||
outputDebugStringF("synwinxt: > setDraggingFilename, filename=%s\n", filename);
|
outputDebugStringF("synwinxt: > setDraggingFilename, filename=%s\n", filename);
|
||||||
|
|
||||||
|
// HACK: only handle files that are not .exe or .lnk
|
||||||
|
// dragging anything, including a selection marquee, from a program
|
||||||
|
// (e.g. explorer.exe) will cause this function to be called with the
|
||||||
|
// path of that program. currently we don't know how to test for this
|
||||||
|
// situation, so just ignore exe and lnk files.
|
||||||
|
std::string ext = getFileExt(filename);
|
||||||
|
if ((ext != "exe") && (ext != "lnk")) {
|
||||||
memcpy(g_draggingFilename, filename, MAX_PATH);
|
memcpy(g_draggingFilename, filename, MAX_PATH);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
outputDebugStringF(
|
||||||
|
"synwinxt: ignoring filename=%s, ext=%s\n",
|
||||||
|
filename, ext.c_str());
|
||||||
|
}
|
||||||
|
|
||||||
outputDebugStringF("synwinxt: < setDraggingFilename, g_draggingFilename=%s\n", g_draggingFilename);
|
outputDebugStringF("synwinxt: < setDraggingFilename, g_draggingFilename=%s\n", g_draggingFilename);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -294,5 +320,10 @@ getDraggingFilename(char* filename)
|
||||||
{
|
{
|
||||||
outputDebugStringF("synwinxt: > getDraggingFilename\n");
|
outputDebugStringF("synwinxt: > getDraggingFilename\n");
|
||||||
memcpy(filename, g_draggingFilename, MAX_PATH);
|
memcpy(filename, g_draggingFilename, MAX_PATH);
|
||||||
|
|
||||||
|
// mark string as empty once used, so we can't accidentally copy
|
||||||
|
// the same file more than once unless the user does this on purpose.
|
||||||
|
g_draggingFilename[0] = NULL;
|
||||||
|
|
||||||
outputDebugStringF("synwinxt: < getDraggingFilename, filename=%s\n", filename);
|
outputDebugStringF("synwinxt: < getDraggingFilename, filename=%s\n", filename);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue