[client] close message boxes if the client connects

This commit is contained in:
Geoffrey McRae 2022-01-12 10:04:16 +11:00
parent 4122841b09
commit ca0bc7c514

View File

@ -974,14 +974,14 @@ static void reportBadVersion()
DEBUG_ERROR("Please install the matching host application for this client"); DEBUG_ERROR("Please install the matching host application for this client");
} }
static void showSpiceInputHelp(void) static MsgBoxHandle showSpiceInputHelp(void)
{ {
static bool done = false; static bool done = false;
if (!g_params.useSpiceInput || done) if (!g_params.useSpiceInput || done)
return; return NULL;
done = true; done = true;
app_msgBox( return app_msgBox(
"Information", "Information",
"Please note you can still control your guest\n" "Please note you can still control your guest\n"
"through SPICE if you press the capture key."); "through SPICE if you press the capture key.");
@ -1227,16 +1227,24 @@ static int lg_run(void)
KVMFR *udata; KVMFR *udata;
int waitCount = 0; int waitCount = 0;
MsgBoxHandle msgs[10];
int msgsCount;
restart: restart:
msgsCount = 0;
memset(msgs, 0, sizeof(msgs));
while(g_state.state == APP_STATE_RUNNING) while(g_state.state == APP_STATE_RUNNING)
{ {
if ((status = lgmpClientSessionInit(g_state.lgmp, &udataSize, (uint8_t **)&udata)) == LGMP_OK) if ((status = lgmpClientSessionInit(g_state.lgmp, &udataSize, (uint8_t **)&udata)) == LGMP_OK)
break; break;
if (status == LGMP_ERR_INVALID_VERSION) switch(status)
{
case LGMP_ERR_INVALID_VERSION:
{ {
reportBadVersion(); reportBadVersion();
app_msgBox( msgs[msgsCount++] = app_msgBox(
"Incompatible LGMP Version", "Incompatible LGMP Version",
"The host application is not compatible with this client.\n" "The host application is not compatible with this client.\n"
"Please download and install the matching version." "Please download and install the matching version."
@ -1250,15 +1258,12 @@ restart:
if (g_state.state != APP_STATE_RUNNING) if (g_state.state != APP_STATE_RUNNING)
return -1; return -1;
break; continue;
} }
if (status != LGMP_ERR_INVALID_SESSION && status != LGMP_ERR_INVALID_MAGIC) case LGMP_ERR_INVALID_SESSION:
case LGMP_ERR_INVALID_MAGIC:
{ {
DEBUG_ERROR("lgmpClientSessionInit Failed: %s", lgmpStatusString(status));
return -1;
}
if (waitCount++ == 0) if (waitCount++ == 0)
{ {
DEBUG_BREAK(); DEBUG_BREAK();
@ -1269,7 +1274,7 @@ restart:
if (waitCount == 30) if (waitCount == 30)
{ {
DEBUG_BREAK(); DEBUG_BREAK();
app_msgBox( msgs[msgsCount++] = app_msgBox(
"Host Application Not Running", "Host Application Not Running",
"It seems the host application is not running or your\n" "It seems the host application is not running or your\n"
"virtual machine is still starting up\n" "virtual machine is still starting up\n"
@ -1280,19 +1285,25 @@ restart:
"\n" "\n"
"Continuing to wait..."); "Continuing to wait...");
showSpiceInputHelp(); msgs[msgsCount++] = showSpiceInputHelp();
DEBUG_INFO("Check the host log in your guest at %%ProgramData%%\\Looking Glass (host)\\looking-glass-host.txt"); DEBUG_INFO("Check the host log in your guest at %%ProgramData%%\\Looking Glass (host)\\looking-glass-host.txt");
DEBUG_INFO("Continuing to wait..."); DEBUG_INFO("Continuing to wait...");
} }
g_state.ds->wait(1000); g_state.ds->wait(1000);
continue;
}
default:
DEBUG_ERROR("lgmpClientSessionInit Failed: %s", lgmpStatusString(status));
return -1;
} }
if (g_state.state != APP_STATE_RUNNING) if (g_state.state != APP_STATE_RUNNING)
return -1; return -1;
// dont show warnings again after the first startup // dont show warnings again after the first successful startup
waitCount = 100; waitCount = 100;
const bool magicMatches = memcmp(udata->magic, KVMFR_MAGIC, sizeof(udata->magic)) == 0; const bool magicMatches = memcmp(udata->magic, KVMFR_MAGIC, sizeof(udata->magic)) == 0;
@ -1303,14 +1314,13 @@ restart:
{ {
if(g_state.state == APP_STATE_RUNNING) if(g_state.state == APP_STATE_RUNNING)
g_state.ds->wait(1000); g_state.ds->wait(1000);
continue;
goto restart;
} }
reportBadVersion(); reportBadVersion();
if (magicMatches) if (magicMatches)
{ {
app_msgBox( msgs[msgsCount++] = app_msgBox(
"Incompatible KVMFR Version", "Incompatible KVMFR Version",
"The host application is not compatible with this client.\n" "The host application is not compatible with this client.\n"
"Please download and install the matching version.\n" "Please download and install the matching version.\n"
@ -1331,7 +1341,7 @@ restart:
DEBUG_BREAK(); DEBUG_BREAK();
showSpiceInputHelp(); msgs[msgsCount++] = showSpiceInputHelp();
DEBUG_INFO("Waiting for you to upgrade the host application"); DEBUG_INFO("Waiting for you to upgrade the host application");
@ -1339,9 +1349,22 @@ restart:
if(g_state.state == APP_STATE_RUNNING) if(g_state.state == APP_STATE_RUNNING)
g_state.ds->wait(1000); g_state.ds->wait(1000);
goto restart; continue;
} }
break;
}
if(g_state.state != APP_STATE_RUNNING)
return -1;
/* close any informational message boxes from above as we now connected
* successfully */
for(int i = 0; i < msgsCount; ++i)
if (msgs[i])
app_msgBoxClose(msgs[i]);
DEBUG_INFO("Guest Information:"); DEBUG_INFO("Guest Information:");
DEBUG_INFO("Version : %s", udata->hostver); DEBUG_INFO("Version : %s", udata->hostver);