bolar_2 backup
This commit is contained in:
69
main/core/remote_behavior.cc
Normal file
69
main/core/remote_behavior.cc
Normal file
@@ -0,0 +1,69 @@
|
||||
#include "core/remote_behavior.h"
|
||||
|
||||
#include <cstring>
|
||||
|
||||
namespace borla {
|
||||
|
||||
const char* ToString(ButtonAction action)
|
||||
{
|
||||
switch (action) {
|
||||
case ButtonAction::kUnspecified:
|
||||
return "";
|
||||
case ButtonAction::kFriendMode:
|
||||
return "friend_mode";
|
||||
case ButtonAction::kNetworkSwitch:
|
||||
return "network_switch";
|
||||
case ButtonAction::kNothing:
|
||||
return "nothing";
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
bool ParseButtonAction(const char* value, ButtonAction* action)
|
||||
{
|
||||
if (value == nullptr || action == nullptr) {
|
||||
return false;
|
||||
}
|
||||
if (std::strcmp(value, "friend_mode") == 0) {
|
||||
*action = ButtonAction::kFriendMode;
|
||||
return true;
|
||||
}
|
||||
if (std::strcmp(value, "network_switch") == 0) {
|
||||
*action = ButtonAction::kNetworkSwitch;
|
||||
return true;
|
||||
}
|
||||
if (std::strcmp(value, "nothing") == 0) {
|
||||
*action = ButtonAction::kNothing;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool IsAllowedConnectionPrompt(LocalPrompt prompt)
|
||||
{
|
||||
return prompt == LocalPrompt::kServerError ||
|
||||
prompt == LocalPrompt::kNoNetwork ||
|
||||
prompt == LocalPrompt::kError;
|
||||
}
|
||||
|
||||
bool ParseConnectionPrompt(const char* value, LocalPrompt* prompt)
|
||||
{
|
||||
if (value == nullptr || prompt == nullptr) {
|
||||
return false;
|
||||
}
|
||||
if (std::strcmp(value, "server_error") == 0) {
|
||||
*prompt = LocalPrompt::kServerError;
|
||||
return true;
|
||||
}
|
||||
if (std::strcmp(value, "no_network") == 0) {
|
||||
*prompt = LocalPrompt::kNoNetwork;
|
||||
return true;
|
||||
}
|
||||
if (std::strcmp(value, "error") == 0) {
|
||||
*prompt = LocalPrompt::kError;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
} // namespace borla
|
||||
Reference in New Issue
Block a user