- removed --filetransfer-src and --filetransfer-des args.

- on Window, temporarily use user desktop directory as drop target.
This commit is contained in:
jerry 2013-09-17 18:13:58 +00:00
parent 760e38eeba
commit 340e31298e
9 changed files with 34 additions and 27 deletions

View File

@ -725,7 +725,12 @@ CClient::onFileRecieveCompleted()
m_fileTransferDes = m_screen->getDropTarget();
if (!m_fileTransferDes.empty()) {
std::fstream file;
m_fileTransferDes.append("/").append(m_dragFileList.at(0));
#ifdef SYSAPI_WIN32
m_fileTransferDes.append("\\");
#else
m_fileTransferDes.append("/");
#endif
m_fileTransferDes.append(m_dragFileList.at(0));
file.open(m_fileTransferDes.c_str(), std::ios::out | std::ios::binary);
if (!file.is_open()) {
// TODO: file open failed

View File

@ -38,6 +38,7 @@
#include "CArchMiscWindows.h"
#include <string.h>
#include <pbt.h>
#include <Shlobj.h>
//
// add backwards compatible multihead support (and suppress bogus warning).
@ -140,6 +141,11 @@ CMSWindowsScreen::CMSWindowsScreen(
forceShowCursor();
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()));
}
catch (...) {
delete m_keyState;
@ -1849,3 +1855,9 @@ CMSWindowsScreen::getDraggingFileDir()
return m_draggingFileDir;
}
const CString&
CMSWindowsScreen::getDropTarget() const
{
return m_desktopPath;
}

View File

@ -117,6 +117,8 @@ public:
virtual bool isPrimary() const;
virtual void fakeDraggingFiles(CString str);
virtual CString& getDraggingFileDir();
virtual const CString&
getDropTarget() const;
protected:
// IPlatformScreen overrides
@ -327,6 +329,8 @@ private:
s_screen;
IEventQueue* m_events;
CString m_desktopPath;
};
#endif

View File

@ -1662,7 +1662,7 @@ CServer::onMouseUp(ButtonID id)
if (!m_screen->isOnScreen()) {
CString& dir = m_screen->getDraggingFileDir();
if (!dir.empty()) {
LOG((CLOG_DEBUG "drop file to client: %s", dir.c_str()));
LOG((CLOG_DEBUG "send file to client: %s", dir.c_str()));
sendFileToClient(dir.c_str());
}
}
@ -1952,10 +1952,16 @@ void
CServer::onFileRecieveCompleted()
{
if (isReceivedFileSizeValid()) {
m_fileTransferDes = m_screen->getDropTarget();
if (!m_fileTransferDes.empty() && m_dragFileList.size() > 0) {
std::fstream file;
CString dropTarget = m_fileTransferDes;
dropTarget.append("/").append(m_dragFileList.at(0));
#ifdef SYSAPI_WIN32
dropTarget.append("\\");
#else
dropTarget.append("/");
#endif
dropTarget.append(m_dragFileList.at(0));
file.open(dropTarget.c_str(), std::ios::out | std::ios::binary);
if (!file.is_open()) {
// TODO: file open failed
@ -2280,7 +2286,6 @@ CServer::sendFileThread(void* filename)
{
try {
char* name = reinterpret_cast<char*>(filename);
LOG((CLOG_DEBUG "sendFileChunks: %s", name));
CFileChunker::sendFileChunks(name, m_events, this);
}
catch (std::runtime_error error) {
@ -2295,14 +2300,10 @@ void
CServer::dragInfoReceived(UInt32 fileNum, CString content)
{
CDragInformation::parseDragInfo(m_dragFileList, fileNum, content);
LOG((CLOG_INFO "drag information received"));
LOG((CLOG_INFO "total drag file number: %i", m_dragFileList.size()));
LOG((CLOG_DEBUG "drag information received"));
LOG((CLOG_DEBUG "total drag file number: %i", m_dragFileList.size()));
for(int i = 0; i < m_dragFileList.size(); ++i) {
LOG((CLOG_INFO "dragging file %i name: %s", i + 1, m_dragFileList.at(i).c_str()));
}
if (m_dragFileList.size() != 0) {
//TODO: fake a dragging operation
LOG((CLOG_DEBUG2 "dragging file %i name: %s", i + 1, m_dragFileList.at(i).c_str()));
}
}

View File

@ -168,14 +168,6 @@ CApp::parseArg(const int& argc, const char* const* argv, int& i)
argsBase().m_crypto.setMode("cfb");
}
else if (isArg(i, argc, argv, NULL, "--filetransfer-src")) {
m_fileTransferSrc = argv[++i];
}
else if (isArg(i, argc, argv, NULL, "--filetransfer-des")) {
m_fileTransferDes = argv[++i];
}
else {
// option not supported here
return false;

View File

@ -101,9 +101,6 @@ public:
void setSocketMultiplexer(CSocketMultiplexer* sm) { m_socketMultiplexer = sm; }
CSocketMultiplexer* getSocketMultiplexer() const { return m_socketMultiplexer; }
CString& getFileTransferSrc() { return m_fileTransferSrc; }
CString& getFileTransferDes() { return m_fileTransferDes; }
private:
void handleIpcMessage(const CEvent&, void*);
@ -126,8 +123,6 @@ private:
ARCH_APP_UTIL m_appUtil;
CIpcClient* m_ipcClient;
CSocketMultiplexer* m_socketMultiplexer;
CString m_fileTransferSrc;
CString m_fileTransferDes;
};
#define BYE "\nTry `%s --help' for more information."

View File

@ -468,7 +468,6 @@ CClientApp::startClient()
s_client->connect();
s_client->setFileTransferDes(getFileTransferDes());
updateStatus();
return true;
}

View File

@ -375,7 +375,7 @@ CScreen::isLockedToScreen() const
if (m_screen->isAnyMouseButtonDown(buttonID)) {
LOG((CLOG_DEBUG "locked by mouse buttonID: %d", buttonID));
if (buttonID == kButtonLeft) {
// this should fake an esc pressed
// TODO: fake esc key down and up
m_screen->fakeMouseButton(buttonID, false);
}

View File

@ -691,7 +691,6 @@ CServer*
CServerApp::openServer(CConfig& config, CPrimaryClient* primaryClient)
{
CServer* server = new CServer(config, primaryClient, s_serverScreen, m_events);
server->setFileTransferDes(getFileTransferDes());
try {
m_events->adoptHandler(
m_events->forCServer().disconnected(), server,