nextcloud-desktop/shell_integration/windows/OCUtil/CommunicationSocket.cpp

129 lines
2.9 KiB
C++
Raw Normal View History

2014-07-30 19:20:55 +04:00
/**
* Copyright (c) 2000-2013 Liferay, Inc. All rights reserved.
*
* This library is free software; you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the Free
* Software Foundation; either version 2.1 of the License, or (at your option)
* any later version.
*
* This library 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 Lesser General Public License for more
* details.
*/
#include "stdafx.h"
2014-07-30 19:20:55 +04:00
#include "CommunicationSocket.h"
#include "UtilConstants.h"
#include "StringUtil.h"
#include <WinSock2.h>
#include <Ws2def.h>
#include <windows.h>
#include <iostream>
#include <vector>
Windows Shell Integration: Use the QLocalSocket on windo and do the request assynchroniously Squashed commit of the following: commit 4d9b072f560fa171a1390b7c74425614aa20e955 Author: Olivier Goffart <ogoffart@woboq.com> Date: Tue Oct 14 16:04:02 2014 +0200 Remove useless variable commit 8e85de0307ec5f31bf3f92a7de793fed7d41c2ea Author: Daniel Molkentin <danimo@owncloud.com> Date: Tue Oct 14 16:01:52 2014 +0200 Make Windows Explorer Extension build commit 8e2942cd9fd32e3af72d60cba0d06bd9d6222a45 Author: Daniel Molkentin <danimo@owncloud.com> Date: Tue Oct 14 11:39:37 2014 +0200 Fix compilation commit 0fc0c0e0e0c7e58ad97f62700256c7d1f8c0670b Author: Olivier Goffart <ogoffart@woboq.com> Date: Tue Oct 14 11:48:32 2014 +0200 Windows Shell Integration: Try to let the thread notify about changes when there are changes commit 4a1712b7c03269ca3007f167b8f313ea47655967 Author: Olivier Goffart <ogoffart@woboq.com> Date: Tue Oct 14 11:35:20 2014 +0200 Windows Shell Integration: Share the RemotePathChecker amongst all the OCOverlay instances commit 2d87408e9af5a4d7ab71c460ce606ba1f367c09f Author: Olivier Goffart <ogoffart@woboq.com> Date: Mon Oct 13 18:55:15 2014 +0200 Windows Shell Integration: Attempts to wait on multiple objects (WIP) commit e448e427b6d1561ad7a40d08fc6632f4d2b4ef44 Author: Daniel Molkentin <danimo@owncloud.com> Date: Mon Oct 13 17:58:02 2014 +0200 Introduce a worker thread commit 2344407ec0bc1ce173ebbacadcf3992d62d94078 Author: Olivier Goffart <ogoffart@woboq.com> Date: Mon Oct 13 17:03:47 2014 +0200 Windows Shell Integration: try to keep the socket open using a thread (WIP) commit ea6d5273ed60d8bc3f1c5d5c6936364d783a1c0f Author: Daniel Molkentin <danimo@owncloud.com> Date: Mon Oct 13 15:27:46 2014 +0200 Make Explorer plugin work again with named pipes This is a temporary hack, which needs more refactoring. commit 44a3437a44082379efa0078c9afd7b8bbde930de Author: Daniel Molkentin <danimo@owncloud.com> Date: Sat Oct 11 07:31:24 2014 +0200 Fix code commit 123390a0f3516c0078309d7048c6d2acb9293676 Author: Olivier Goffart <ogoffart@woboq.com> Date: Fri Oct 10 16:29:35 2014 +0200 Windows shell integration: Use named pipe (WIP) commit 9eea7e2321abeac6b8db0bd85bfce612dbf6bb20 Author: Olivier Goffart <ogoffart@woboq.com> Date: Wed Oct 1 12:04:13 2014 +0200 Windows Shell Integration: Simplify StringUtil This fixes a memory leak in CommunicationSocket::ReadLine
2014-10-14 18:05:48 +04:00
#include <array>
2014-07-30 19:20:55 +04:00
#include <fstream>
#define BUFSIZE 1024
using namespace std;
#define DEFAULT_BUFLEN 4096
Windows Shell Integration: Use the QLocalSocket on windo and do the request assynchroniously Squashed commit of the following: commit 4d9b072f560fa171a1390b7c74425614aa20e955 Author: Olivier Goffart <ogoffart@woboq.com> Date: Tue Oct 14 16:04:02 2014 +0200 Remove useless variable commit 8e85de0307ec5f31bf3f92a7de793fed7d41c2ea Author: Daniel Molkentin <danimo@owncloud.com> Date: Tue Oct 14 16:01:52 2014 +0200 Make Windows Explorer Extension build commit 8e2942cd9fd32e3af72d60cba0d06bd9d6222a45 Author: Daniel Molkentin <danimo@owncloud.com> Date: Tue Oct 14 11:39:37 2014 +0200 Fix compilation commit 0fc0c0e0e0c7e58ad97f62700256c7d1f8c0670b Author: Olivier Goffart <ogoffart@woboq.com> Date: Tue Oct 14 11:48:32 2014 +0200 Windows Shell Integration: Try to let the thread notify about changes when there are changes commit 4a1712b7c03269ca3007f167b8f313ea47655967 Author: Olivier Goffart <ogoffart@woboq.com> Date: Tue Oct 14 11:35:20 2014 +0200 Windows Shell Integration: Share the RemotePathChecker amongst all the OCOverlay instances commit 2d87408e9af5a4d7ab71c460ce606ba1f367c09f Author: Olivier Goffart <ogoffart@woboq.com> Date: Mon Oct 13 18:55:15 2014 +0200 Windows Shell Integration: Attempts to wait on multiple objects (WIP) commit e448e427b6d1561ad7a40d08fc6632f4d2b4ef44 Author: Daniel Molkentin <danimo@owncloud.com> Date: Mon Oct 13 17:58:02 2014 +0200 Introduce a worker thread commit 2344407ec0bc1ce173ebbacadcf3992d62d94078 Author: Olivier Goffart <ogoffart@woboq.com> Date: Mon Oct 13 17:03:47 2014 +0200 Windows Shell Integration: try to keep the socket open using a thread (WIP) commit ea6d5273ed60d8bc3f1c5d5c6936364d783a1c0f Author: Daniel Molkentin <danimo@owncloud.com> Date: Mon Oct 13 15:27:46 2014 +0200 Make Explorer plugin work again with named pipes This is a temporary hack, which needs more refactoring. commit 44a3437a44082379efa0078c9afd7b8bbde930de Author: Daniel Molkentin <danimo@owncloud.com> Date: Sat Oct 11 07:31:24 2014 +0200 Fix code commit 123390a0f3516c0078309d7048c6d2acb9293676 Author: Olivier Goffart <ogoffart@woboq.com> Date: Fri Oct 10 16:29:35 2014 +0200 Windows shell integration: Use named pipe (WIP) commit 9eea7e2321abeac6b8db0bd85bfce612dbf6bb20 Author: Olivier Goffart <ogoffart@woboq.com> Date: Wed Oct 1 12:04:13 2014 +0200 Windows Shell Integration: Simplify StringUtil This fixes a memory leak in CommunicationSocket::ReadLine
2014-10-14 18:05:48 +04:00
CommunicationSocket::CommunicationSocket()
: _pipe(INVALID_HANDLE_VALUE)
2014-07-30 19:20:55 +04:00
{
}
CommunicationSocket::~CommunicationSocket()
{
Close();
}
bool CommunicationSocket::Close()
{
WSACleanup();
Windows Shell Integration: Use the QLocalSocket on windo and do the request assynchroniously Squashed commit of the following: commit 4d9b072f560fa171a1390b7c74425614aa20e955 Author: Olivier Goffart <ogoffart@woboq.com> Date: Tue Oct 14 16:04:02 2014 +0200 Remove useless variable commit 8e85de0307ec5f31bf3f92a7de793fed7d41c2ea Author: Daniel Molkentin <danimo@owncloud.com> Date: Tue Oct 14 16:01:52 2014 +0200 Make Windows Explorer Extension build commit 8e2942cd9fd32e3af72d60cba0d06bd9d6222a45 Author: Daniel Molkentin <danimo@owncloud.com> Date: Tue Oct 14 11:39:37 2014 +0200 Fix compilation commit 0fc0c0e0e0c7e58ad97f62700256c7d1f8c0670b Author: Olivier Goffart <ogoffart@woboq.com> Date: Tue Oct 14 11:48:32 2014 +0200 Windows Shell Integration: Try to let the thread notify about changes when there are changes commit 4a1712b7c03269ca3007f167b8f313ea47655967 Author: Olivier Goffart <ogoffart@woboq.com> Date: Tue Oct 14 11:35:20 2014 +0200 Windows Shell Integration: Share the RemotePathChecker amongst all the OCOverlay instances commit 2d87408e9af5a4d7ab71c460ce606ba1f367c09f Author: Olivier Goffart <ogoffart@woboq.com> Date: Mon Oct 13 18:55:15 2014 +0200 Windows Shell Integration: Attempts to wait on multiple objects (WIP) commit e448e427b6d1561ad7a40d08fc6632f4d2b4ef44 Author: Daniel Molkentin <danimo@owncloud.com> Date: Mon Oct 13 17:58:02 2014 +0200 Introduce a worker thread commit 2344407ec0bc1ce173ebbacadcf3992d62d94078 Author: Olivier Goffart <ogoffart@woboq.com> Date: Mon Oct 13 17:03:47 2014 +0200 Windows Shell Integration: try to keep the socket open using a thread (WIP) commit ea6d5273ed60d8bc3f1c5d5c6936364d783a1c0f Author: Daniel Molkentin <danimo@owncloud.com> Date: Mon Oct 13 15:27:46 2014 +0200 Make Explorer plugin work again with named pipes This is a temporary hack, which needs more refactoring. commit 44a3437a44082379efa0078c9afd7b8bbde930de Author: Daniel Molkentin <danimo@owncloud.com> Date: Sat Oct 11 07:31:24 2014 +0200 Fix code commit 123390a0f3516c0078309d7048c6d2acb9293676 Author: Olivier Goffart <ogoffart@woboq.com> Date: Fri Oct 10 16:29:35 2014 +0200 Windows shell integration: Use named pipe (WIP) commit 9eea7e2321abeac6b8db0bd85bfce612dbf6bb20 Author: Olivier Goffart <ogoffart@woboq.com> Date: Wed Oct 1 12:04:13 2014 +0200 Windows Shell Integration: Simplify StringUtil This fixes a memory leak in CommunicationSocket::ReadLine
2014-10-14 18:05:48 +04:00
if (_pipe == INVALID_HANDLE_VALUE) {
return false;
}
CloseHandle(_pipe);
_pipe = INVALID_HANDLE_VALUE;
return true;
2014-07-30 19:20:55 +04:00
}
bool CommunicationSocket::Connect(const std::wstring &pipename)
2014-07-30 19:20:55 +04:00
{
Windows Shell Integration: Use the QLocalSocket on windo and do the request assynchroniously Squashed commit of the following: commit 4d9b072f560fa171a1390b7c74425614aa20e955 Author: Olivier Goffart <ogoffart@woboq.com> Date: Tue Oct 14 16:04:02 2014 +0200 Remove useless variable commit 8e85de0307ec5f31bf3f92a7de793fed7d41c2ea Author: Daniel Molkentin <danimo@owncloud.com> Date: Tue Oct 14 16:01:52 2014 +0200 Make Windows Explorer Extension build commit 8e2942cd9fd32e3af72d60cba0d06bd9d6222a45 Author: Daniel Molkentin <danimo@owncloud.com> Date: Tue Oct 14 11:39:37 2014 +0200 Fix compilation commit 0fc0c0e0e0c7e58ad97f62700256c7d1f8c0670b Author: Olivier Goffart <ogoffart@woboq.com> Date: Tue Oct 14 11:48:32 2014 +0200 Windows Shell Integration: Try to let the thread notify about changes when there are changes commit 4a1712b7c03269ca3007f167b8f313ea47655967 Author: Olivier Goffart <ogoffart@woboq.com> Date: Tue Oct 14 11:35:20 2014 +0200 Windows Shell Integration: Share the RemotePathChecker amongst all the OCOverlay instances commit 2d87408e9af5a4d7ab71c460ce606ba1f367c09f Author: Olivier Goffart <ogoffart@woboq.com> Date: Mon Oct 13 18:55:15 2014 +0200 Windows Shell Integration: Attempts to wait on multiple objects (WIP) commit e448e427b6d1561ad7a40d08fc6632f4d2b4ef44 Author: Daniel Molkentin <danimo@owncloud.com> Date: Mon Oct 13 17:58:02 2014 +0200 Introduce a worker thread commit 2344407ec0bc1ce173ebbacadcf3992d62d94078 Author: Olivier Goffart <ogoffart@woboq.com> Date: Mon Oct 13 17:03:47 2014 +0200 Windows Shell Integration: try to keep the socket open using a thread (WIP) commit ea6d5273ed60d8bc3f1c5d5c6936364d783a1c0f Author: Daniel Molkentin <danimo@owncloud.com> Date: Mon Oct 13 15:27:46 2014 +0200 Make Explorer plugin work again with named pipes This is a temporary hack, which needs more refactoring. commit 44a3437a44082379efa0078c9afd7b8bbde930de Author: Daniel Molkentin <danimo@owncloud.com> Date: Sat Oct 11 07:31:24 2014 +0200 Fix code commit 123390a0f3516c0078309d7048c6d2acb9293676 Author: Olivier Goffart <ogoffart@woboq.com> Date: Fri Oct 10 16:29:35 2014 +0200 Windows shell integration: Use named pipe (WIP) commit 9eea7e2321abeac6b8db0bd85bfce612dbf6bb20 Author: Olivier Goffart <ogoffart@woboq.com> Date: Wed Oct 1 12:04:13 2014 +0200 Windows Shell Integration: Simplify StringUtil This fixes a memory leak in CommunicationSocket::ReadLine
2014-10-14 18:05:48 +04:00
_pipe = CreateFile(pipename.data(), GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, NULL);
2014-07-30 19:20:55 +04:00
Windows Shell Integration: Use the QLocalSocket on windo and do the request assynchroniously Squashed commit of the following: commit 4d9b072f560fa171a1390b7c74425614aa20e955 Author: Olivier Goffart <ogoffart@woboq.com> Date: Tue Oct 14 16:04:02 2014 +0200 Remove useless variable commit 8e85de0307ec5f31bf3f92a7de793fed7d41c2ea Author: Daniel Molkentin <danimo@owncloud.com> Date: Tue Oct 14 16:01:52 2014 +0200 Make Windows Explorer Extension build commit 8e2942cd9fd32e3af72d60cba0d06bd9d6222a45 Author: Daniel Molkentin <danimo@owncloud.com> Date: Tue Oct 14 11:39:37 2014 +0200 Fix compilation commit 0fc0c0e0e0c7e58ad97f62700256c7d1f8c0670b Author: Olivier Goffart <ogoffart@woboq.com> Date: Tue Oct 14 11:48:32 2014 +0200 Windows Shell Integration: Try to let the thread notify about changes when there are changes commit 4a1712b7c03269ca3007f167b8f313ea47655967 Author: Olivier Goffart <ogoffart@woboq.com> Date: Tue Oct 14 11:35:20 2014 +0200 Windows Shell Integration: Share the RemotePathChecker amongst all the OCOverlay instances commit 2d87408e9af5a4d7ab71c460ce606ba1f367c09f Author: Olivier Goffart <ogoffart@woboq.com> Date: Mon Oct 13 18:55:15 2014 +0200 Windows Shell Integration: Attempts to wait on multiple objects (WIP) commit e448e427b6d1561ad7a40d08fc6632f4d2b4ef44 Author: Daniel Molkentin <danimo@owncloud.com> Date: Mon Oct 13 17:58:02 2014 +0200 Introduce a worker thread commit 2344407ec0bc1ce173ebbacadcf3992d62d94078 Author: Olivier Goffart <ogoffart@woboq.com> Date: Mon Oct 13 17:03:47 2014 +0200 Windows Shell Integration: try to keep the socket open using a thread (WIP) commit ea6d5273ed60d8bc3f1c5d5c6936364d783a1c0f Author: Daniel Molkentin <danimo@owncloud.com> Date: Mon Oct 13 15:27:46 2014 +0200 Make Explorer plugin work again with named pipes This is a temporary hack, which needs more refactoring. commit 44a3437a44082379efa0078c9afd7b8bbde930de Author: Daniel Molkentin <danimo@owncloud.com> Date: Sat Oct 11 07:31:24 2014 +0200 Fix code commit 123390a0f3516c0078309d7048c6d2acb9293676 Author: Olivier Goffart <ogoffart@woboq.com> Date: Fri Oct 10 16:29:35 2014 +0200 Windows shell integration: Use named pipe (WIP) commit 9eea7e2321abeac6b8db0bd85bfce612dbf6bb20 Author: Olivier Goffart <ogoffart@woboq.com> Date: Wed Oct 1 12:04:13 2014 +0200 Windows Shell Integration: Simplify StringUtil This fixes a memory leak in CommunicationSocket::ReadLine
2014-10-14 18:05:48 +04:00
if (_pipe == INVALID_HANDLE_VALUE) {
return false;
}
Windows Shell Integration: Use the QLocalSocket on windo and do the request assynchroniously Squashed commit of the following: commit 4d9b072f560fa171a1390b7c74425614aa20e955 Author: Olivier Goffart <ogoffart@woboq.com> Date: Tue Oct 14 16:04:02 2014 +0200 Remove useless variable commit 8e85de0307ec5f31bf3f92a7de793fed7d41c2ea Author: Daniel Molkentin <danimo@owncloud.com> Date: Tue Oct 14 16:01:52 2014 +0200 Make Windows Explorer Extension build commit 8e2942cd9fd32e3af72d60cba0d06bd9d6222a45 Author: Daniel Molkentin <danimo@owncloud.com> Date: Tue Oct 14 11:39:37 2014 +0200 Fix compilation commit 0fc0c0e0e0c7e58ad97f62700256c7d1f8c0670b Author: Olivier Goffart <ogoffart@woboq.com> Date: Tue Oct 14 11:48:32 2014 +0200 Windows Shell Integration: Try to let the thread notify about changes when there are changes commit 4a1712b7c03269ca3007f167b8f313ea47655967 Author: Olivier Goffart <ogoffart@woboq.com> Date: Tue Oct 14 11:35:20 2014 +0200 Windows Shell Integration: Share the RemotePathChecker amongst all the OCOverlay instances commit 2d87408e9af5a4d7ab71c460ce606ba1f367c09f Author: Olivier Goffart <ogoffart@woboq.com> Date: Mon Oct 13 18:55:15 2014 +0200 Windows Shell Integration: Attempts to wait on multiple objects (WIP) commit e448e427b6d1561ad7a40d08fc6632f4d2b4ef44 Author: Daniel Molkentin <danimo@owncloud.com> Date: Mon Oct 13 17:58:02 2014 +0200 Introduce a worker thread commit 2344407ec0bc1ce173ebbacadcf3992d62d94078 Author: Olivier Goffart <ogoffart@woboq.com> Date: Mon Oct 13 17:03:47 2014 +0200 Windows Shell Integration: try to keep the socket open using a thread (WIP) commit ea6d5273ed60d8bc3f1c5d5c6936364d783a1c0f Author: Daniel Molkentin <danimo@owncloud.com> Date: Mon Oct 13 15:27:46 2014 +0200 Make Explorer plugin work again with named pipes This is a temporary hack, which needs more refactoring. commit 44a3437a44082379efa0078c9afd7b8bbde930de Author: Daniel Molkentin <danimo@owncloud.com> Date: Sat Oct 11 07:31:24 2014 +0200 Fix code commit 123390a0f3516c0078309d7048c6d2acb9293676 Author: Olivier Goffart <ogoffart@woboq.com> Date: Fri Oct 10 16:29:35 2014 +0200 Windows shell integration: Use named pipe (WIP) commit 9eea7e2321abeac6b8db0bd85bfce612dbf6bb20 Author: Olivier Goffart <ogoffart@woboq.com> Date: Wed Oct 1 12:04:13 2014 +0200 Windows Shell Integration: Simplify StringUtil This fixes a memory leak in CommunicationSocket::ReadLine
2014-10-14 18:05:48 +04:00
return true;
2014-07-30 19:20:55 +04:00
}
bool CommunicationSocket::SendMsg(const wchar_t* message) const
2014-07-30 19:20:55 +04:00
{
Windows Shell Integration: Use the QLocalSocket on windo and do the request assynchroniously Squashed commit of the following: commit 4d9b072f560fa171a1390b7c74425614aa20e955 Author: Olivier Goffart <ogoffart@woboq.com> Date: Tue Oct 14 16:04:02 2014 +0200 Remove useless variable commit 8e85de0307ec5f31bf3f92a7de793fed7d41c2ea Author: Daniel Molkentin <danimo@owncloud.com> Date: Tue Oct 14 16:01:52 2014 +0200 Make Windows Explorer Extension build commit 8e2942cd9fd32e3af72d60cba0d06bd9d6222a45 Author: Daniel Molkentin <danimo@owncloud.com> Date: Tue Oct 14 11:39:37 2014 +0200 Fix compilation commit 0fc0c0e0e0c7e58ad97f62700256c7d1f8c0670b Author: Olivier Goffart <ogoffart@woboq.com> Date: Tue Oct 14 11:48:32 2014 +0200 Windows Shell Integration: Try to let the thread notify about changes when there are changes commit 4a1712b7c03269ca3007f167b8f313ea47655967 Author: Olivier Goffart <ogoffart@woboq.com> Date: Tue Oct 14 11:35:20 2014 +0200 Windows Shell Integration: Share the RemotePathChecker amongst all the OCOverlay instances commit 2d87408e9af5a4d7ab71c460ce606ba1f367c09f Author: Olivier Goffart <ogoffart@woboq.com> Date: Mon Oct 13 18:55:15 2014 +0200 Windows Shell Integration: Attempts to wait on multiple objects (WIP) commit e448e427b6d1561ad7a40d08fc6632f4d2b4ef44 Author: Daniel Molkentin <danimo@owncloud.com> Date: Mon Oct 13 17:58:02 2014 +0200 Introduce a worker thread commit 2344407ec0bc1ce173ebbacadcf3992d62d94078 Author: Olivier Goffart <ogoffart@woboq.com> Date: Mon Oct 13 17:03:47 2014 +0200 Windows Shell Integration: try to keep the socket open using a thread (WIP) commit ea6d5273ed60d8bc3f1c5d5c6936364d783a1c0f Author: Daniel Molkentin <danimo@owncloud.com> Date: Mon Oct 13 15:27:46 2014 +0200 Make Explorer plugin work again with named pipes This is a temporary hack, which needs more refactoring. commit 44a3437a44082379efa0078c9afd7b8bbde930de Author: Daniel Molkentin <danimo@owncloud.com> Date: Sat Oct 11 07:31:24 2014 +0200 Fix code commit 123390a0f3516c0078309d7048c6d2acb9293676 Author: Olivier Goffart <ogoffart@woboq.com> Date: Fri Oct 10 16:29:35 2014 +0200 Windows shell integration: Use named pipe (WIP) commit 9eea7e2321abeac6b8db0bd85bfce612dbf6bb20 Author: Olivier Goffart <ogoffart@woboq.com> Date: Wed Oct 1 12:04:13 2014 +0200 Windows Shell Integration: Simplify StringUtil This fixes a memory leak in CommunicationSocket::ReadLine
2014-10-14 18:05:48 +04:00
auto utf8_msg = StringUtil::toUtf8(message);
DWORD numBytesWritten = 0;
auto result = WriteFile( _pipe, utf8_msg.c_str(), DWORD(utf8_msg.size()), &numBytesWritten, NULL);
if (result) {
return true;
} else {
const_cast<CommunicationSocket*>(this)->Close();
Windows Shell Integration: Use the QLocalSocket on windo and do the request assynchroniously Squashed commit of the following: commit 4d9b072f560fa171a1390b7c74425614aa20e955 Author: Olivier Goffart <ogoffart@woboq.com> Date: Tue Oct 14 16:04:02 2014 +0200 Remove useless variable commit 8e85de0307ec5f31bf3f92a7de793fed7d41c2ea Author: Daniel Molkentin <danimo@owncloud.com> Date: Tue Oct 14 16:01:52 2014 +0200 Make Windows Explorer Extension build commit 8e2942cd9fd32e3af72d60cba0d06bd9d6222a45 Author: Daniel Molkentin <danimo@owncloud.com> Date: Tue Oct 14 11:39:37 2014 +0200 Fix compilation commit 0fc0c0e0e0c7e58ad97f62700256c7d1f8c0670b Author: Olivier Goffart <ogoffart@woboq.com> Date: Tue Oct 14 11:48:32 2014 +0200 Windows Shell Integration: Try to let the thread notify about changes when there are changes commit 4a1712b7c03269ca3007f167b8f313ea47655967 Author: Olivier Goffart <ogoffart@woboq.com> Date: Tue Oct 14 11:35:20 2014 +0200 Windows Shell Integration: Share the RemotePathChecker amongst all the OCOverlay instances commit 2d87408e9af5a4d7ab71c460ce606ba1f367c09f Author: Olivier Goffart <ogoffart@woboq.com> Date: Mon Oct 13 18:55:15 2014 +0200 Windows Shell Integration: Attempts to wait on multiple objects (WIP) commit e448e427b6d1561ad7a40d08fc6632f4d2b4ef44 Author: Daniel Molkentin <danimo@owncloud.com> Date: Mon Oct 13 17:58:02 2014 +0200 Introduce a worker thread commit 2344407ec0bc1ce173ebbacadcf3992d62d94078 Author: Olivier Goffart <ogoffart@woboq.com> Date: Mon Oct 13 17:03:47 2014 +0200 Windows Shell Integration: try to keep the socket open using a thread (WIP) commit ea6d5273ed60d8bc3f1c5d5c6936364d783a1c0f Author: Daniel Molkentin <danimo@owncloud.com> Date: Mon Oct 13 15:27:46 2014 +0200 Make Explorer plugin work again with named pipes This is a temporary hack, which needs more refactoring. commit 44a3437a44082379efa0078c9afd7b8bbde930de Author: Daniel Molkentin <danimo@owncloud.com> Date: Sat Oct 11 07:31:24 2014 +0200 Fix code commit 123390a0f3516c0078309d7048c6d2acb9293676 Author: Olivier Goffart <ogoffart@woboq.com> Date: Fri Oct 10 16:29:35 2014 +0200 Windows shell integration: Use named pipe (WIP) commit 9eea7e2321abeac6b8db0bd85bfce612dbf6bb20 Author: Olivier Goffart <ogoffart@woboq.com> Date: Wed Oct 1 12:04:13 2014 +0200 Windows Shell Integration: Simplify StringUtil This fixes a memory leak in CommunicationSocket::ReadLine
2014-10-14 18:05:48 +04:00
return false;
}
2014-07-30 19:20:55 +04:00
}
bool CommunicationSocket::ReadLine(wstring* response)
2014-07-30 19:20:55 +04:00
{
if (!response) {
return false;
}
Windows Shell Integration: Use the QLocalSocket on windo and do the request assynchroniously Squashed commit of the following: commit 4d9b072f560fa171a1390b7c74425614aa20e955 Author: Olivier Goffart <ogoffart@woboq.com> Date: Tue Oct 14 16:04:02 2014 +0200 Remove useless variable commit 8e85de0307ec5f31bf3f92a7de793fed7d41c2ea Author: Daniel Molkentin <danimo@owncloud.com> Date: Tue Oct 14 16:01:52 2014 +0200 Make Windows Explorer Extension build commit 8e2942cd9fd32e3af72d60cba0d06bd9d6222a45 Author: Daniel Molkentin <danimo@owncloud.com> Date: Tue Oct 14 11:39:37 2014 +0200 Fix compilation commit 0fc0c0e0e0c7e58ad97f62700256c7d1f8c0670b Author: Olivier Goffart <ogoffart@woboq.com> Date: Tue Oct 14 11:48:32 2014 +0200 Windows Shell Integration: Try to let the thread notify about changes when there are changes commit 4a1712b7c03269ca3007f167b8f313ea47655967 Author: Olivier Goffart <ogoffart@woboq.com> Date: Tue Oct 14 11:35:20 2014 +0200 Windows Shell Integration: Share the RemotePathChecker amongst all the OCOverlay instances commit 2d87408e9af5a4d7ab71c460ce606ba1f367c09f Author: Olivier Goffart <ogoffart@woboq.com> Date: Mon Oct 13 18:55:15 2014 +0200 Windows Shell Integration: Attempts to wait on multiple objects (WIP) commit e448e427b6d1561ad7a40d08fc6632f4d2b4ef44 Author: Daniel Molkentin <danimo@owncloud.com> Date: Mon Oct 13 17:58:02 2014 +0200 Introduce a worker thread commit 2344407ec0bc1ce173ebbacadcf3992d62d94078 Author: Olivier Goffart <ogoffart@woboq.com> Date: Mon Oct 13 17:03:47 2014 +0200 Windows Shell Integration: try to keep the socket open using a thread (WIP) commit ea6d5273ed60d8bc3f1c5d5c6936364d783a1c0f Author: Daniel Molkentin <danimo@owncloud.com> Date: Mon Oct 13 15:27:46 2014 +0200 Make Explorer plugin work again with named pipes This is a temporary hack, which needs more refactoring. commit 44a3437a44082379efa0078c9afd7b8bbde930de Author: Daniel Molkentin <danimo@owncloud.com> Date: Sat Oct 11 07:31:24 2014 +0200 Fix code commit 123390a0f3516c0078309d7048c6d2acb9293676 Author: Olivier Goffart <ogoffart@woboq.com> Date: Fri Oct 10 16:29:35 2014 +0200 Windows shell integration: Use named pipe (WIP) commit 9eea7e2321abeac6b8db0bd85bfce612dbf6bb20 Author: Olivier Goffart <ogoffart@woboq.com> Date: Wed Oct 1 12:04:13 2014 +0200 Windows Shell Integration: Simplify StringUtil This fixes a memory leak in CommunicationSocket::ReadLine
2014-10-14 18:05:48 +04:00
response->clear();
if (_pipe == INVALID_HANDLE_VALUE) {
return false;
}
2014-07-30 19:20:55 +04:00
while (true) {
Windows Shell Integration: Use the QLocalSocket on windo and do the request assynchroniously Squashed commit of the following: commit 4d9b072f560fa171a1390b7c74425614aa20e955 Author: Olivier Goffart <ogoffart@woboq.com> Date: Tue Oct 14 16:04:02 2014 +0200 Remove useless variable commit 8e85de0307ec5f31bf3f92a7de793fed7d41c2ea Author: Daniel Molkentin <danimo@owncloud.com> Date: Tue Oct 14 16:01:52 2014 +0200 Make Windows Explorer Extension build commit 8e2942cd9fd32e3af72d60cba0d06bd9d6222a45 Author: Daniel Molkentin <danimo@owncloud.com> Date: Tue Oct 14 11:39:37 2014 +0200 Fix compilation commit 0fc0c0e0e0c7e58ad97f62700256c7d1f8c0670b Author: Olivier Goffart <ogoffart@woboq.com> Date: Tue Oct 14 11:48:32 2014 +0200 Windows Shell Integration: Try to let the thread notify about changes when there are changes commit 4a1712b7c03269ca3007f167b8f313ea47655967 Author: Olivier Goffart <ogoffart@woboq.com> Date: Tue Oct 14 11:35:20 2014 +0200 Windows Shell Integration: Share the RemotePathChecker amongst all the OCOverlay instances commit 2d87408e9af5a4d7ab71c460ce606ba1f367c09f Author: Olivier Goffart <ogoffart@woboq.com> Date: Mon Oct 13 18:55:15 2014 +0200 Windows Shell Integration: Attempts to wait on multiple objects (WIP) commit e448e427b6d1561ad7a40d08fc6632f4d2b4ef44 Author: Daniel Molkentin <danimo@owncloud.com> Date: Mon Oct 13 17:58:02 2014 +0200 Introduce a worker thread commit 2344407ec0bc1ce173ebbacadcf3992d62d94078 Author: Olivier Goffart <ogoffart@woboq.com> Date: Mon Oct 13 17:03:47 2014 +0200 Windows Shell Integration: try to keep the socket open using a thread (WIP) commit ea6d5273ed60d8bc3f1c5d5c6936364d783a1c0f Author: Daniel Molkentin <danimo@owncloud.com> Date: Mon Oct 13 15:27:46 2014 +0200 Make Explorer plugin work again with named pipes This is a temporary hack, which needs more refactoring. commit 44a3437a44082379efa0078c9afd7b8bbde930de Author: Daniel Molkentin <danimo@owncloud.com> Date: Sat Oct 11 07:31:24 2014 +0200 Fix code commit 123390a0f3516c0078309d7048c6d2acb9293676 Author: Olivier Goffart <ogoffart@woboq.com> Date: Fri Oct 10 16:29:35 2014 +0200 Windows shell integration: Use named pipe (WIP) commit 9eea7e2321abeac6b8db0bd85bfce612dbf6bb20 Author: Olivier Goffart <ogoffart@woboq.com> Date: Wed Oct 1 12:04:13 2014 +0200 Windows Shell Integration: Simplify StringUtil This fixes a memory leak in CommunicationSocket::ReadLine
2014-10-14 18:05:48 +04:00
int lbPos = 0;
auto it = std::find(_buffer.begin() + lbPos, _buffer.end(), '\n');
if (it != _buffer.end()) {
*response = StringUtil::toUtf16(_buffer.data(), DWORD(it - _buffer.begin()));
_buffer.erase(_buffer.begin(), it + 1);
return true;
}
std::array<char, 128> resp_utf8;
DWORD numBytesRead = 0;
DWORD totalBytesAvailable = 0;
if (!PeekNamedPipe(_pipe, NULL, 0, 0, &totalBytesAvailable, 0)) {
Close();
return false;
}
if (totalBytesAvailable == 0) {
return false;
2014-07-30 19:20:55 +04:00
}
if (!ReadFile(_pipe, resp_utf8.data(), DWORD(resp_utf8.size()), &numBytesRead, NULL)) {
Close();
Windows Shell Integration: Use the QLocalSocket on windo and do the request assynchroniously Squashed commit of the following: commit 4d9b072f560fa171a1390b7c74425614aa20e955 Author: Olivier Goffart <ogoffart@woboq.com> Date: Tue Oct 14 16:04:02 2014 +0200 Remove useless variable commit 8e85de0307ec5f31bf3f92a7de793fed7d41c2ea Author: Daniel Molkentin <danimo@owncloud.com> Date: Tue Oct 14 16:01:52 2014 +0200 Make Windows Explorer Extension build commit 8e2942cd9fd32e3af72d60cba0d06bd9d6222a45 Author: Daniel Molkentin <danimo@owncloud.com> Date: Tue Oct 14 11:39:37 2014 +0200 Fix compilation commit 0fc0c0e0e0c7e58ad97f62700256c7d1f8c0670b Author: Olivier Goffart <ogoffart@woboq.com> Date: Tue Oct 14 11:48:32 2014 +0200 Windows Shell Integration: Try to let the thread notify about changes when there are changes commit 4a1712b7c03269ca3007f167b8f313ea47655967 Author: Olivier Goffart <ogoffart@woboq.com> Date: Tue Oct 14 11:35:20 2014 +0200 Windows Shell Integration: Share the RemotePathChecker amongst all the OCOverlay instances commit 2d87408e9af5a4d7ab71c460ce606ba1f367c09f Author: Olivier Goffart <ogoffart@woboq.com> Date: Mon Oct 13 18:55:15 2014 +0200 Windows Shell Integration: Attempts to wait on multiple objects (WIP) commit e448e427b6d1561ad7a40d08fc6632f4d2b4ef44 Author: Daniel Molkentin <danimo@owncloud.com> Date: Mon Oct 13 17:58:02 2014 +0200 Introduce a worker thread commit 2344407ec0bc1ce173ebbacadcf3992d62d94078 Author: Olivier Goffart <ogoffart@woboq.com> Date: Mon Oct 13 17:03:47 2014 +0200 Windows Shell Integration: try to keep the socket open using a thread (WIP) commit ea6d5273ed60d8bc3f1c5d5c6936364d783a1c0f Author: Daniel Molkentin <danimo@owncloud.com> Date: Mon Oct 13 15:27:46 2014 +0200 Make Explorer plugin work again with named pipes This is a temporary hack, which needs more refactoring. commit 44a3437a44082379efa0078c9afd7b8bbde930de Author: Daniel Molkentin <danimo@owncloud.com> Date: Sat Oct 11 07:31:24 2014 +0200 Fix code commit 123390a0f3516c0078309d7048c6d2acb9293676 Author: Olivier Goffart <ogoffart@woboq.com> Date: Fri Oct 10 16:29:35 2014 +0200 Windows shell integration: Use named pipe (WIP) commit 9eea7e2321abeac6b8db0bd85bfce612dbf6bb20 Author: Olivier Goffart <ogoffart@woboq.com> Date: Wed Oct 1 12:04:13 2014 +0200 Windows Shell Integration: Simplify StringUtil This fixes a memory leak in CommunicationSocket::ReadLine
2014-10-14 18:05:48 +04:00
return false;
}
if (numBytesRead <= 0) {
return false;
}
_buffer.insert(_buffer.end(), resp_utf8.begin(), resp_utf8.begin()+numBytesRead);
continue;
2014-07-30 19:20:55 +04:00
}
}