Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[stable-3.12] if desktop client sent a first reply: wait for the menu data #6560

Merged
merged 1 commit into from
Mar 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,10 @@ NCClientInterface::ContextMenuInfo NCClientInterface::FetchInfo(const std::wstri
ContextMenuInfo info;
std::wstring response;
int sleptCount = 0;
while (sleptCount < 20) {
constexpr auto noReplyTimeout = 20;
constexpr auto replyTimeout = 200;
bool receivedReplyFromDesktopClient = false;
while ((!receivedReplyFromDesktopClient && sleptCount < noReplyTimeout) || (receivedReplyFromDesktopClient && sleptCount < replyTimeout)) {
if (socket.ReadLine(&response)) {
if (StringUtil::begins_with(response, wstring(L"REGISTER_PATH:"))) {
wstring responsePath = response.substr(14); // length of REGISTER_PATH
Expand All @@ -65,6 +68,9 @@ NCClientInterface::ContextMenuInfo NCClientInterface::FetchInfo(const std::wstri
if (!StringUtil::extractChunks(response, commandName, flags, title))
continue;
info.menuItems.push_back({ commandName, flags, title });
} else if (StringUtil::begins_with(response, wstring(L"GET_MENU_ITEMS:BEGIN"))) {
receivedReplyFromDesktopClient = true;
continue;
} else if (StringUtil::begins_with(response, wstring(L"GET_MENU_ITEMS:END"))) {
break; // Stop once we completely received the last sent request
}
Expand Down
2 changes: 1 addition & 1 deletion src/gui/socketapi/socketapi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1330,7 +1330,7 @@ SocketApi::FileData SocketApi::FileData::parentFolder() const

void SocketApi::command_GET_MENU_ITEMS(const QString &argument, OCC::SocketListener *listener)
{
listener->sendMessage(QString("GET_MENU_ITEMS:BEGIN"));
listener->sendMessage(QString("GET_MENU_ITEMS:BEGIN"), true);
const QStringList files = split(argument);

// Find the common sync folder.
Expand Down
Loading