diff options
author | Jocelyn Turcotte <jturcotte@woboq.com> | 2015-02-13 19:18:39 +0300 |
---|---|---|
committer | Jocelyn Turcotte <jturcotte@woboq.com> | 2015-02-13 19:18:39 +0300 |
commit | 4b674292345802ac28f2d511bba3de5e277f9ea6 (patch) | |
tree | 9fd17a56a2de8211883d5f46929c602b4167c4c6 /shell_integration | |
parent | 23e248b5d19ffddd4e836773044123ca977d09ef (diff) |
shell_integration: Wait longer for the Share menu title
50ms is sometimes not enough when the client is busy synchronizing.
Wait up to 500ms for the client to answer before we give up and show an
empty menu title.
Ideally we should request the title before the watched directory list, but
the list is currently sent implicitly on connect.
Diffstat (limited to 'shell_integration')
-rw-r--r-- | shell_integration/windows/OCContextMenu/OCClientInterface.cpp | 21 |
1 files changed, 14 insertions, 7 deletions
diff --git a/shell_integration/windows/OCContextMenu/OCClientInterface.cpp b/shell_integration/windows/OCContextMenu/OCClientInterface.cpp index ab6206f92..7d9783bfa 100644 --- a/shell_integration/windows/OCContextMenu/OCClientInterface.cpp +++ b/shell_integration/windows/OCContextMenu/OCClientInterface.cpp @@ -50,14 +50,21 @@ OCClientInterface::ContextMenuInfo OCClientInterface::FetchInfo() ContextMenuInfo info; std::wstring response; - Sleep(50); - while (socket.ReadLine(&response)) { - if (StringUtil::begins_with(response, wstring(L"REGISTER_PATH:"))) { - wstring responsePath = response.substr(14); // length of REGISTER_PATH - info.watchedDirectories.push_back(responsePath); + int sleptCount = 0; + while (sleptCount < 5) { + if (socket.ReadLine(&response)) { + if (StringUtil::begins_with(response, wstring(L"REGISTER_PATH:"))) { + wstring responsePath = response.substr(14); // length of REGISTER_PATH + info.watchedDirectories.push_back(responsePath); + } + else if (StringUtil::begins_with(response, wstring(L"SHARE_MENU_TITLE:"))) { + info.shareMenuTitle = response.substr(17); // length of SHARE_MENU_TITLE: + break; // Stop once we received the last sent request + } } - else if (StringUtil::begins_with(response, wstring(L"SHARE_MENU_TITLE:"))) { - info.shareMenuTitle = response.substr(17); // length of SHARE_MENU_TITLE: + else { + Sleep(50); + ++sleptCount; } } return info; |