Other: fix gRPC enum value clash on Windows.

This commit is contained in:
Xavier Michelon
2022-08-16 18:33:05 +02:00
committed by Jakub
parent ed904c2bdd
commit af51018e02
6 changed files with 420 additions and 423 deletions

View File

@ -21,13 +21,6 @@
#include "../BridgeUtils.h"
#if defined(Q_OS_WIN32) && defined(ERROR)
// The folks at Microsoft have decided that it was OK to `#define ERROR 0` in wingdi.h. It is not OK, because
// any occurrence of ERROR, even scoped, will be substituted. For instance Log::Level::ERROR (case imposed by gRPC).
#undef ERROR
#endif
namespace bridgepp
{
@ -85,19 +78,19 @@ grpc::LogLevel logLevelToGRPC(Log::Level level)
switch (level)
{
case Log::Level::Panic:
return grpc::LogLevel::PANIC;
return grpc::LogLevel::LOG_PANIC;
case Log::Level::Fatal:
return grpc::LogLevel::FATAL;
return grpc::LogLevel::LOG_FATAL;
case Log::Level::Error:
return grpc::LogLevel::ERROR;
return grpc::LogLevel::LOG_ERROR;
case Log::Level::Warn:
return grpc::LogLevel::WARN;
return grpc::LogLevel::LOG_WARN;
case Log::Level::Info:
return grpc::LogLevel::INFO;
return grpc::LogLevel::LOG_INFO;
case Log::Level::Debug:
return grpc::LogLevel::DEBUG;
return grpc::LogLevel::LOG_DEBUG;
case Log::Level::Trace:
return grpc::LogLevel::TRACE;
return grpc::LogLevel::LOG_TRACE;
default:
throw Exception(QString("unknown log level %1.").arg(qint32(level)));
}
@ -112,19 +105,19 @@ Log::Level logLevelFromGRPC(grpc::LogLevel level)
{
switch (level)
{
case grpc::PANIC:
case grpc::LOG_PANIC:
return Log::Level::Panic;
case grpc::FATAL:
case grpc::LOG_FATAL:
return Log::Level::Fatal;
case grpc::ERROR:
case grpc::LOG_ERROR:
return Log::Level::Error;
case grpc::WARN:
case grpc::LOG_WARN:
return Log::Level::Warn;
case grpc::INFO:
case grpc::LOG_INFO:
return Log::Level::Info;
case grpc::DEBUG:
case grpc::LOG_DEBUG:
return Log::Level::Debug;
case grpc::TRACE:
case grpc::LOG_TRACE:
return Log::Level::Trace;
default:
throw Exception(QString("unknown log level %1.").arg(qint32(level)));
@ -174,8 +167,8 @@ void userToGRPC(User const &user, grpc::User &outGRPCUser)
outGRPCUser.set_loggedin(user.loggedIn());
outGRPCUser.set_splitmode(user.splitMode());
outGRPCUser.set_setupguideseen(user.setupGuideSeen());
outGRPCUser.set_usedbytes(user.usedBytes());
outGRPCUser.set_totalbytes(user.totalBytes());
outGRPCUser.set_usedbytes(qint64(user.usedBytes()));
outGRPCUser.set_totalbytes(qint64(user.totalBytes()));
}

View File

@ -1453,116 +1453,117 @@ const char descriptor_table_protodef_bridge_2eproto[] PROTOBUF_SECTION_VARIABLE(
"serChangedEventH\000B\007\n\005event\".\n\034ToggleSpli"
"tModeFinishedEvent\022\016\n\006userID\030\001 \001(\t\")\n\025Us"
"erDisconnectedEvent\022\020\n\010username\030\001 \001(\t\"\"\n"
"\020UserChangedEvent\022\016\n\006userID\030\001 \001(\t*U\n\010Log"
"Level\022\t\n\005PANIC\020\000\022\t\n\005FATAL\020\001\022\t\n\005ERROR\020\002\022\010"
"\n\004WARN\020\003\022\010\n\004INFO\020\004\022\t\n\005DEBUG\020\005\022\t\n\005TRACE\020\006"
"*\242\001\n\016LoginErrorType\022\033\n\027USERNAME_PASSWORD"
"_ERROR\020\000\022\r\n\tFREE_USER\020\001\022\024\n\020CONNECTION_ER"
"ROR\020\002\022\r\n\tTFA_ERROR\020\003\022\r\n\tTFA_ABORT\020\004\022\027\n\023T"
"WO_PASSWORDS_ERROR\020\005\022\027\n\023TWO_PASSWORDS_AB"
"ORT\020\006*[\n\017UpdateErrorType\022\027\n\023UPDATE_MANUA"
"L_ERROR\020\000\022\026\n\022UPDATE_FORCE_ERROR\020\001\022\027\n\023UPD"
"ATE_SILENT_ERROR\020\002*W\n\016CacheErrorType\022\033\n\027"
"CACHE_UNAVAILABLE_ERROR\020\000\022\031\n\025CACHE_CANT_"
"MOVE_ERROR\020\001\022\r\n\tDISK_FULL\020\002*A\n\025MailSetti"
"ngsErrorType\022\023\n\017IMAP_PORT_ISSUE\020\000\022\023\n\017SMT"
"P_PORT_ISSUE\020\0012\300\035\n\006Bridge\022\?\n\013AddLogEntry"
"\022\030.grpc.AddLogEntryRequest\032\026.google.prot"
"obuf.Empty\022:\n\010GuiReady\022\026.google.protobuf"
".Empty\032\026.google.protobuf.Empty\0226\n\004Quit\022\026"
".google.protobuf.Empty\032\026.google.protobuf"
".Empty\0229\n\007Restart\022\026.google.protobuf.Empt"
"y\032\026.google.protobuf.Empty\022C\n\rShowOnStart"
"up\022\026.google.protobuf.Empty\032\032.google.prot"
"obuf.BoolValue\022F\n\020ShowSplashScreen\022\026.goo"
"\020UserChangedEvent\022\016\n\006userID\030\001 \001(\t*q\n\010Log"
"Level\022\r\n\tLOG_PANIC\020\000\022\r\n\tLOG_FATAL\020\001\022\r\n\tL"
"OG_ERROR\020\002\022\014\n\010LOG_WARN\020\003\022\014\n\010LOG_INFO\020\004\022\r"
"\n\tLOG_DEBUG\020\005\022\r\n\tLOG_TRACE\020\006*\242\001\n\016LoginEr"
"rorType\022\033\n\027USERNAME_PASSWORD_ERROR\020\000\022\r\n\t"
"FREE_USER\020\001\022\024\n\020CONNECTION_ERROR\020\002\022\r\n\tTFA"
"_ERROR\020\003\022\r\n\tTFA_ABORT\020\004\022\027\n\023TWO_PASSWORDS"
"_ERROR\020\005\022\027\n\023TWO_PASSWORDS_ABORT\020\006*[\n\017Upd"
"ateErrorType\022\027\n\023UPDATE_MANUAL_ERROR\020\000\022\026\n"
"\022UPDATE_FORCE_ERROR\020\001\022\027\n\023UPDATE_SILENT_E"
"RROR\020\002*W\n\016CacheErrorType\022\033\n\027CACHE_UNAVAI"
"LABLE_ERROR\020\000\022\031\n\025CACHE_CANT_MOVE_ERROR\020\001"
"\022\r\n\tDISK_FULL\020\002*A\n\025MailSettingsErrorType"
"\022\023\n\017IMAP_PORT_ISSUE\020\000\022\023\n\017SMTP_PORT_ISSUE"
"\020\0012\300\035\n\006Bridge\022\?\n\013AddLogEntry\022\030.grpc.AddL"
"ogEntryRequest\032\026.google.protobuf.Empty\022:"
"\n\010GuiReady\022\026.google.protobuf.Empty\032\026.goo"
"gle.protobuf.Empty\0226\n\004Quit\022\026.google.prot"
"obuf.Empty\032\026.google.protobuf.Empty\0229\n\007Re"
"start\022\026.google.protobuf.Empty\032\026.google.p"
"rotobuf.Empty\022C\n\rShowOnStartup\022\026.google."
"protobuf.Empty\032\032.google.protobuf.BoolVal"
"ue\022F\n\020ShowSplashScreen\022\026.google.protobuf"
".Empty\032\032.google.protobuf.BoolValue\022E\n\017Is"
"FirstGuiStart\022\026.google.protobuf.Empty\032\032."
"google.protobuf.BoolValue\022F\n\020SetIsAutost"
"artOn\022\032.google.protobuf.BoolValue\032\026.goog"
"le.protobuf.Empty\022C\n\rIsAutostartOn\022\026.goo"
"gle.protobuf.Empty\032\032.google.protobuf.Boo"
"lValue\022E\n\017IsFirstGuiStart\022\026.google.proto"
"buf.Empty\032\032.google.protobuf.BoolValue\022F\n"
"\020SetIsAutostartOn\022\032.google.protobuf.Bool"
"Value\032\026.google.protobuf.Empty\022C\n\rIsAutos"
"tartOn\022\026.google.protobuf.Empty\032\032.google."
"protobuf.BoolValue\022F\n\020SetIsBetaEnabled\022\032"
"lValue\022F\n\020SetIsBetaEnabled\022\032.google.prot"
"obuf.BoolValue\032\026.google.protobuf.Empty\022C"
"\n\rIsBetaEnabled\022\026.google.protobuf.Empty\032"
"\032.google.protobuf.BoolValue\022<\n\004GoOs\022\026.go"
"ogle.protobuf.Empty\032\034.google.protobuf.St"
"ringValue\022>\n\014TriggerReset\022\026.google.proto"
"buf.Empty\032\026.google.protobuf.Empty\022\?\n\007Ver"
"sion\022\026.google.protobuf.Empty\032\034.google.pr"
"otobuf.StringValue\022@\n\010LogsPath\022\026.google."
"protobuf.Empty\032\034.google.protobuf.StringV"
"alue\022C\n\013LicensePath\022\026.google.protobuf.Em"
"pty\032\034.google.protobuf.StringValue\022L\n\024Rel"
"easeNotesPageLink\022\026.google.protobuf.Empt"
"y\032\034.google.protobuf.StringValue\022N\n\026Depen"
"dencyLicensesLink\022\026.google.protobuf.Empt"
"y\032\034.google.protobuf.StringValue\022G\n\017Landi"
"ngPageLink\022\026.google.protobuf.Empty\032\034.goo"
"gle.protobuf.StringValue\022J\n\022SetColorSche"
"meName\022\034.google.protobuf.StringValue\032\026.g"
"oogle.protobuf.Empty\022G\n\017ColorSchemeName\022"
"\026.google.protobuf.Empty\032\034.google.protobu"
"f.StringValue\022J\n\022CurrentEmailClient\022\026.go"
"ogle.protobuf.Empty\032\034.google.protobuf.St"
"ringValue\022;\n\tReportBug\022\026.grpc.ReportBugR"
"equest\032\026.google.protobuf.Empty\022E\n\rForceL"
"auncher\022\034.google.protobuf.StringValue\032\026."
"google.protobuf.Empty\0223\n\005Login\022\022.grpc.Lo"
"ginRequest\032\026.google.protobuf.Empty\0226\n\010Lo"
"gin2FA\022\022.grpc.LoginRequest\032\026.google.prot"
"obuf.Empty\022=\n\017Login2Passwords\022\022.grpc.Log"
"inRequest\032\026.google.protobuf.Empty\022=\n\nLog"
"inAbort\022\027.grpc.LoginAbortRequest\032\026.googl"
"e.protobuf.Empty\022=\n\013CheckUpdate\022\026.google"
".protobuf.Empty\032\026.google.protobuf.Empty\022"
"\?\n\rInstallUpdate\022\026.google.protobuf.Empty"
"\032\026.google.protobuf.Empty\022L\n\026SetIsAutomat"
"icUpdateOn\022\032.google.protobuf.BoolValue\032\026"
".google.protobuf.Empty\022I\n\023IsAutomaticUpd"
"ateOn\022\026.google.protobuf.Empty\032\032.google.p"
"rotobuf.BoolValue\022J\n\024IsCacheOnDiskEnable"
"d\022\026.google.protobuf.Empty\032\032.google.proto"
"buf.BoolValue\022E\n\rDiskCachePath\022\026.google."
"protobuf.Empty\032\034.google.protobuf.StringV"
"alue\022I\n\020ChangeLocalCache\022\035.grpc.ChangeLo"
"calCacheRequest\032\026.google.protobuf.Empty\022"
"E\n\017SetIsDoHEnabled\022\032.google.protobuf.Boo"
"lValue\032\026.google.protobuf.Empty\022B\n\014IsDoHE"
"nabled\022\026.google.protobuf.Empty\032\032.google."
"protobuf.BoolValue\022F\n\020SetUseSslForSmtp\022\032"
".google.protobuf.BoolValue\032\026.google.prot"
"obuf.Empty\022C\n\rIsBetaEnabled\022\026.google.pro"
"obuf.Empty\022C\n\rUseSslForSmtp\022\026.google.pro"
"tobuf.Empty\032\032.google.protobuf.BoolValue\022"
"<\n\004GoOs\022\026.google.protobuf.Empty\032\034.google"
".protobuf.StringValue\022>\n\014TriggerReset\022\026."
"google.protobuf.Empty\032\026.google.protobuf."
"Empty\022\?\n\007Version\022\026.google.protobuf.Empty"
"\032\034.google.protobuf.StringValue\022@\n\010LogsPa"
"th\022\026.google.protobuf.Empty\032\034.google.prot"
"obuf.StringValue\022C\n\013LicensePath\022\026.google"
".protobuf.Empty\032\034.google.protobuf.String"
"Value\022L\n\024ReleaseNotesPageLink\022\026.google.p"
"rotobuf.Empty\032\034.google.protobuf.StringVa"
"lue\022N\n\026DependencyLicensesLink\022\026.google.p"
"rotobuf.Empty\032\034.google.protobuf.StringVa"
"lue\022G\n\017LandingPageLink\022\026.google.protobuf"
".Empty\032\034.google.protobuf.StringValue\022J\n\022"
"SetColorSchemeName\022\034.google.protobuf.Str"
"ingValue\032\026.google.protobuf.Empty\022G\n\017Colo"
"rSchemeName\022\026.google.protobuf.Empty\032\034.go"
"ogle.protobuf.StringValue\022J\n\022CurrentEmai"
"lClient\022\026.google.protobuf.Empty\032\034.google"
".protobuf.StringValue\022;\n\tReportBug\022\026.grp"
"c.ReportBugRequest\032\026.google.protobuf.Emp"
"ty\022E\n\rForceLauncher\022\034.google.protobuf.St"
"ringValue\032\026.google.protobuf.Empty\0223\n\005Log"
"in\022\022.grpc.LoginRequest\032\026.google.protobuf"
".Empty\0226\n\010Login2FA\022\022.grpc.LoginRequest\032\026"
".google.protobuf.Empty\022=\n\017Login2Password"
"s\022\022.grpc.LoginRequest\032\026.google.protobuf."
"Empty\022=\n\nLoginAbort\022\027.grpc.LoginAbortReq"
"uest\032\026.google.protobuf.Empty\022=\n\013CheckUpd"
"ate\022\026.google.protobuf.Empty\032\026.google.pro"
"tobuf.Empty\022\?\n\rInstallUpdate\022\026.google.pr"
"otobuf.Empty\032\026.google.protobuf.Empty\022L\n\026"
"SetIsAutomaticUpdateOn\022\032.google.protobuf"
".BoolValue\032\026.google.protobuf.Empty\022I\n\023Is"
"AutomaticUpdateOn\022\026.google.protobuf.Empt"
"y\032\032.google.protobuf.BoolValue\022J\n\024IsCache"
"OnDiskEnabled\022\026.google.protobuf.Empty\032\032."
"google.protobuf.BoolValue\022E\n\rDiskCachePa"
"th\022\026.google.protobuf.Empty\032\034.google.prot"
"obuf.StringValue\022I\n\020ChangeLocalCache\022\035.g"
"rpc.ChangeLocalCacheRequest\032\026.google.pro"
"tobuf.Empty\022E\n\017SetIsDoHEnabled\022\032.google."
"protobuf.BoolValue\032\026.google.protobuf.Emp"
"ty\022B\n\014IsDoHEnabled\022\026.google.protobuf.Emp"
"ty\032\032.google.protobuf.BoolValue\022F\n\020SetUse"
"SslForSmtp\022\032.google.protobuf.BoolValue\032\026"
".google.protobuf.Empty\022C\n\rUseSslForSmtp\022"
"\026.google.protobuf.Empty\032\032.google.protobu"
"f.BoolValue\022@\n\010Hostname\022\026.google.protobu"
"f.Empty\032\034.google.protobuf.StringValue\022\?\n"
"\010ImapPort\022\026.google.protobuf.Empty\032\033.goog"
"le.protobuf.Int32Value\022\?\n\010SmtpPort\022\026.goo"
"gle.protobuf.Empty\032\033.google.protobuf.Int"
"32Value\022\?\n\013ChangePorts\022\030.grpc.ChangePort"
"sRequest\032\026.google.protobuf.Empty\022E\n\nIsPo"
"rtFree\022\033.google.protobuf.Int32Value\032\032.go"
"ogle.protobuf.BoolValue\022N\n\022AvailableKeyc"
"hains\022\026.google.protobuf.Empty\032 .grpc.Ava"
"ilableKeychainsResponse\022J\n\022SetCurrentKey"
"chain\022\034.google.protobuf.StringValue\032\026.go"
"ogle.protobuf.Empty\022G\n\017CurrentKeychain\022\026"
".google.protobuf.Empty\032\034.google.protobuf"
".StringValue\022=\n\013GetUserList\022\026.google.pro"
"tobuf.Empty\032\026.grpc.UserListResponse\0223\n\007G"
"etUser\022\034.google.protobuf.StringValue\032\n.g"
"rpc.User\022F\n\020SetUserSplitMode\022\032.grpc.User"
"SplitModeRequest\032\026.google.protobuf.Empty"
"\022B\n\nLogoutUser\022\034.google.protobuf.StringV"
"alue\032\026.google.protobuf.Empty\022B\n\nRemoveUs"
"@\n\010Hostname\022\026.google.protobuf.Empty\032\034.go"
"ogle.protobuf.StringValue\022\?\n\010ImapPort\022\026."
"google.protobuf.Empty\032\033.google.protobuf."
"Int32Value\022\?\n\010SmtpPort\022\026.google.protobuf"
".Empty\032\033.google.protobuf.Int32Value\022\?\n\013C"
"hangePorts\022\030.grpc.ChangePortsRequest\032\026.g"
"oogle.protobuf.Empty\022E\n\nIsPortFree\022\033.goo"
"gle.protobuf.Int32Value\032\032.google.protobu"
"f.BoolValue\022N\n\022AvailableKeychains\022\026.goog"
"le.protobuf.Empty\032 .grpc.AvailableKeycha"
"insResponse\022J\n\022SetCurrentKeychain\022\034.goog"
"le.protobuf.StringValue\032\026.google.protobu"
"f.Empty\022G\n\017CurrentKeychain\022\026.google.prot"
"obuf.Empty\032\034.google.protobuf.StringValue"
"\022=\n\013GetUserList\022\026.google.protobuf.Empty\032"
"\026.grpc.UserListResponse\0223\n\007GetUser\022\034.goo"
"gle.protobuf.StringValue\032\n.grpc.User\022F\n\020"
"SetUserSplitMode\022\032.grpc.UserSplitModeReq"
"uest\032\026.google.protobuf.Empty\022B\n\nLogoutUs"
"er\022\034.google.protobuf.StringValue\032\026.googl"
"e.protobuf.Empty\022Q\n\026ConfigureUserAppleMa"
"il\022\037.grpc.ConfigureAppleMailRequest\032\026.go"
"ogle.protobuf.Empty\022A\n\020StartEventStream\022"
"\030.grpc.EventStreamRequest\032\021.grpc.StreamE"
"vent0\001\022A\n\017StopEventStream\022\026.google.proto"
"buf.Empty\032\026.google.protobuf.EmptyB6Z4git"
"hub.com/ProtonMail/proton-bridge/v2/inte"
"rnal/grpcb\006proto3"
"e.protobuf.Empty\022B\n\nRemoveUser\022\034.google."
"protobuf.StringValue\032\026.google.protobuf.E"
"mpty\022Q\n\026ConfigureUserAppleMail\022\037.grpc.Co"
"nfigureAppleMailRequest\032\026.google.protobu"
"f.Empty\022A\n\020StartEventStream\022\030.grpc.Event"
"StreamRequest\032\021.grpc.StreamEvent0\001\022A\n\017St"
"opEventStream\022\026.google.protobuf.Empty\032\026."
"google.protobuf.EmptyB6Z4github.com/Prot"
"onMail/proton-bridge/v2/internal/grpcb\006p"
"roto3"
;
static const ::_pbi::DescriptorTable* const descriptor_table_bridge_2eproto_deps[2] = {
&::descriptor_table_google_2fprotobuf_2fempty_2eproto,
@ -1570,7 +1571,7 @@ static const ::_pbi::DescriptorTable* const descriptor_table_bridge_2eproto_deps
};
static ::_pbi::once_flag descriptor_table_bridge_2eproto_once;
const ::_pbi::DescriptorTable descriptor_table_bridge_2eproto = {
false, false, 9297, descriptor_table_protodef_bridge_2eproto,
false, false, 9325, descriptor_table_protodef_bridge_2eproto,
"bridge.proto",
&descriptor_table_bridge_2eproto_once, descriptor_table_bridge_2eproto_deps, 2, 57,
schemas, file_default_instances, TableStruct_bridge_2eproto::offsets,

View File

@ -283,19 +283,19 @@ PROTOBUF_NAMESPACE_CLOSE
namespace grpc {
enum LogLevel : int {
PANIC = 0,
FATAL = 1,
ERROR = 2,
WARN = 3,
INFO = 4,
DEBUG = 5,
TRACE = 6,
LOG_PANIC = 0,
LOG_FATAL = 1,
LOG_ERROR = 2,
LOG_WARN = 3,
LOG_INFO = 4,
LOG_DEBUG = 5,
LOG_TRACE = 6,
LogLevel_INT_MIN_SENTINEL_DO_NOT_USE_ = std::numeric_limits<int32_t>::min(),
LogLevel_INT_MAX_SENTINEL_DO_NOT_USE_ = std::numeric_limits<int32_t>::max()
};
bool LogLevel_IsValid(int value);
constexpr LogLevel LogLevel_MIN = PANIC;
constexpr LogLevel LogLevel_MAX = TRACE;
constexpr LogLevel LogLevel_MIN = LOG_PANIC;
constexpr LogLevel LogLevel_MAX = LOG_TRACE;
constexpr int LogLevel_ARRAYSIZE = LogLevel_MAX + 1;
const ::PROTOBUF_NAMESPACE_ID::EnumDescriptor* LogLevel_descriptor();