mirror of
https://github.com/nextcloud/desktop.git
synced 2024-10-23 21:05:44 +03:00
Windows shell integration: Make the share entry work by adding a Sleep
Timeouts don't work with named pipe, so wait for 50ms to let time for the client to answer
This commit is contained in:
parent
081cc0b9e8
commit
0af97156c9
5 changed files with 27 additions and 19 deletions
|
@ -49,7 +49,8 @@ std::vector<std::wstring> OCClientInterface::WatchedDirectories()
|
|||
}
|
||||
std::vector<std::wstring> watchedDirectories;
|
||||
std::wstring response;
|
||||
while (socket.ReadLine(&response, true)) {
|
||||
Sleep(50);
|
||||
while (socket.ReadLine(&response)) {
|
||||
if (StringUtil::begins_with(response, wstring(L"REGISTER_PATH:"))) {
|
||||
wstring responsePath = response.substr(14); // length of REGISTER_PATH
|
||||
watchedDirectories.push_back(responsePath);
|
||||
|
|
|
@ -27,6 +27,8 @@ extern long g_cDllRef;
|
|||
|
||||
#define IDM_SHARE 0
|
||||
|
||||
|
||||
|
||||
OCContextMenu::OCContextMenu(void)
|
||||
: m_cRef(1)
|
||||
, m_pszMenuText(L"&Share")
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio 2013
|
||||
VisualStudioVersion = 12.0.30501.0
|
||||
VisualStudioVersion = 12.0.31101.0
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "OCOverlays", "OCOverlays\OCOverlays.vcxproj", "{42EFEC79-5ACA-4F76-955F-15CE4340F6BC}"
|
||||
ProjectSection(ProjectDependencies) = postProject
|
||||
|
@ -10,6 +10,11 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "OCOverlays", "OCOverlays\OC
|
|||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "OCUtil", "OCUtil\OCUtil.vcxproj", "{E4F63E19-808D-4234-8DF0-69C5F47C9CD3}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "OCContextMenu", "OCContextMenu\OCContextMenu.vcxproj", "{FF34851F-1346-4809-A68A-B1188D7DFF32}"
|
||||
ProjectSection(ProjectDependencies) = postProject
|
||||
{E4F63E19-808D-4234-8DF0-69C5F47C9CD3} = {E4F63E19-808D-4234-8DF0-69C5F47C9CD3}
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Win32 = Debug|Win32
|
||||
|
@ -34,6 +39,14 @@ Global
|
|||
{E4F63E19-808D-4234-8DF0-69C5F47C9CD3}.Release|Win32.Build.0 = Release|Win32
|
||||
{E4F63E19-808D-4234-8DF0-69C5F47C9CD3}.Release|x64.ActiveCfg = Release|x64
|
||||
{E4F63E19-808D-4234-8DF0-69C5F47C9CD3}.Release|x64.Build.0 = Release|x64
|
||||
{FF34851F-1346-4809-A68A-B1188D7DFF32}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
{FF34851F-1346-4809-A68A-B1188D7DFF32}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{FF34851F-1346-4809-A68A-B1188D7DFF32}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{FF34851F-1346-4809-A68A-B1188D7DFF32}.Debug|x64.Build.0 = Debug|x64
|
||||
{FF34851F-1346-4809-A68A-B1188D7DFF32}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{FF34851F-1346-4809-A68A-B1188D7DFF32}.Release|Win32.Build.0 = Release|Win32
|
||||
{FF34851F-1346-4809-A68A-B1188D7DFF32}.Release|x64.ActiveCfg = Release|x64
|
||||
{FF34851F-1346-4809-A68A-B1188D7DFF32}.Release|x64.Build.0 = Release|x64
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
|
|
|
@ -60,6 +60,7 @@ bool CommunicationSocket::Connect(const std::wstring &pipename)
|
|||
if (_pipe == INVALID_HANDLE_VALUE) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -79,7 +80,7 @@ bool CommunicationSocket::SendMsg(const wchar_t* message) const
|
|||
}
|
||||
}
|
||||
|
||||
bool CommunicationSocket::ReadLine(wstring* response, bool block)
|
||||
bool CommunicationSocket::ReadLine(wstring* response)
|
||||
{
|
||||
if (!response) {
|
||||
return false;
|
||||
|
@ -91,13 +92,6 @@ bool CommunicationSocket::ReadLine(wstring* response, bool block)
|
|||
return false;
|
||||
}
|
||||
|
||||
COMMTIMEOUTS timeout = { };
|
||||
timeout.ReadIntervalTimeout = 10;
|
||||
timeout.ReadTotalTimeoutMultiplier = 0;
|
||||
timeout.WriteTotalTimeoutMultiplier = 0;
|
||||
|
||||
SetCommTimeouts(_pipe, &timeout);
|
||||
|
||||
while (true) {
|
||||
int lbPos = 0;
|
||||
auto it = std::find(_buffer.begin() + lbPos, _buffer.end(), '\n');
|
||||
|
@ -111,14 +105,12 @@ bool CommunicationSocket::ReadLine(wstring* response, bool block)
|
|||
DWORD numBytesRead = 0;
|
||||
DWORD totalBytesAvailable = 0;
|
||||
|
||||
if (/*!block*/ true) {
|
||||
if (!PeekNamedPipe(_pipe, NULL, 0, 0, &totalBytesAvailable, 0)) {
|
||||
Close();
|
||||
return false;
|
||||
}
|
||||
if (totalBytesAvailable == 0) {
|
||||
return false;
|
||||
}
|
||||
if (!PeekNamedPipe(_pipe, NULL, 0, 0, &totalBytesAvailable, 0)) {
|
||||
Close();
|
||||
return false;
|
||||
}
|
||||
if (totalBytesAvailable == 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!ReadFile(_pipe, resp_utf8.data(), DWORD(resp_utf8.size()), &numBytesRead, NULL)) {
|
||||
|
|
|
@ -33,7 +33,7 @@ public:
|
|||
bool Close();
|
||||
|
||||
bool SendMsg(const wchar_t*) const;
|
||||
bool ReadLine(std::wstring*, bool block = false);
|
||||
bool ReadLine(std::wstring*);
|
||||
|
||||
HANDLE Event() { return _pipe; }
|
||||
|
||||
|
|
Loading…
Reference in a new issue