コード例 #1
0
ファイル: Asset.cpp プロジェクト: scottp/xcsoar
void InitAsset() {
#ifdef GNAV
#ifdef FORCEPORTRAIT
  // JMW testing only for portrait mode of Altair
  RotateScreen();
#endif
#endif

// VENTA2- delete registries at startup, but not on PC!
#if defined(FIVV) && ( !defined(WINDOWSPC) || WINDOWSPC==0 )
#ifndef PNA
  RegDeleteKey(HKEY_CURRENT_USER, _T(REGKEYNAME));
#endif
#endif

#ifdef PNA // VENTA2-ADDON MODEL TYPE
/*
  LocalPath is called for the very first time by CreateDirectoryIfAbsent.
  In order to be able in the future to behave differently for each PNA device
  and maybe also for common PDAs, we need to know the PNA/PDA Model Type
  BEFORE calling LocalPath. This was critical.
*/

  SmartGlobalModelType(); // First we check the exec filename, which
			  // has priority over registry values

  if (!_tcscmp(GlobalModelName, _T("UNKNOWN"))) // Then if there is no smart name...
    SetModelType();                         // get the modeltype from
					    // the registry as usual
#endif

// VENTA2- TODO fix these directories are not used always!
  CreateDirectoryIfAbsent(TEXT(""));  // RLD make sure the LocalPath folder actually exists
  CreateDirectoryIfAbsent(TEXT("persist"));
  CreateDirectoryIfAbsent(TEXT("logs"));
  CreateDirectoryIfAbsent(TEXT("config"));

// VENTA2-ADDON install fonts on PDAs and check XCSoarData existance
#if defined(FIVV) && ( !defined(WINDOWSPC) || WINDOWSPC==0 )
//#ifndef PNA

  bool datadir=CheckDataDir();
  if (datadir) StartupStore(TEXT("XCSoarData directory found.\n"));
  else StartupStore(TEXT("ERROR: NO XCSOARDATA DIRECTORY FOUND!\n"));

  StartupStore(TEXT("Check for installing fonts\n"));
  short didfonts=InstallFonts();  // check if really did it, and maybe restart
  TCHAR nTmp[100];
  _stprintf(nTmp,TEXT("InstallFonts() result=%d (0=installed >0 not installed)\n"), didfonts);
  StartupStore(nTmp);

  //#endif
#endif

  StartupLogFreeRamAndStorage();

}
コード例 #2
0
short dlgStartupShowModal(void){
  WndProperty* wp;

  #if TESTBENCH
  StartupStore(TEXT(". Startup dialog, RUN_MODE=%d %s"),RUN_MODE,NEWLINE);
  #endif

  char filename[MAX_PATH];
  strcpy(filename,"");

  // FLY SIM PROFILE EXIT
  if (RUN_MODE==RUN_WELCOME) {
	if (!ScreenLandscape) {
		LocalPathS(filename, TEXT("dlgFlySim_L.xml"));
		wf = dlgLoadFromXML(CallBackTable, filename, hWndMainWindow, TEXT("IDR_XML_FLYSIM_L"));
	} else {
		LocalPathS(filename, TEXT("dlgFlySim.xml"));
		wf = dlgLoadFromXML(CallBackTable, filename, hWndMainWindow, TEXT("IDR_XML_FLYSIM"));
	}
	if (!wf) {
		return 0;
	}
  }

  //  PROFILE AIRCRAFT  CLOSE
  if (RUN_MODE==RUN_DUALPROF) {
	if (!ScreenLandscape) {
		LocalPathS(filename, TEXT("dlgDualProfile_L.xml"));
		wf = dlgLoadFromXML(CallBackTable, filename, hWndMainWindow, TEXT("IDR_XML_DUALPROFILE_L"));
	} else {
		LocalPathS(filename, TEXT("dlgDualProfile.xml"));
		wf = dlgLoadFromXML(CallBackTable, filename, hWndMainWindow, TEXT("IDR_XML_DUALPROFILE"));
	}
	if (!wf) return 0;
  }

  // CHOOSE PROFILE
  if (RUN_MODE==RUN_PROFILE || RUN_MODE==RUN_AIRCRAFT || RUN_MODE==RUN_PILOT) {
	if (!ScreenLandscape) {
		LocalPathS(filename, TEXT("dlgStartup_L.xml"));
		wf = dlgLoadFromXML(CallBackTable, filename, hWndMainWindow, TEXT("IDR_XML_STARTUP_L"));
	} else {
		LocalPathS(filename, TEXT("dlgStartup.xml"));
		wf = dlgLoadFromXML(CallBackTable, filename, hWndMainWindow, TEXT("IDR_XML_STARTUP"));
	}
	if (!wf) return 0;
  }

  wSplash = (WndOwnerDrawFrame*)wf->FindByName(TEXT("frmSplash")); 
  wSplash->SetWidth(ScreenSizeX);


  int  PROFWIDTH=0, PROFACCEPTWIDTH=0, PROFHEIGHT=0, PROFSEPARATOR=0;

  if (RUN_MODE==RUN_WELCOME) {
	((WndButton *)wf->FindByName(TEXT("cmdFLY"))) ->SetOnClickNotify(OnFLYClicked);
	((WndButton *)wf->FindByName(TEXT("cmdSIM"))) ->SetOnClickNotify(OnSIMClicked);
	((WndButton *)wf->FindByName(TEXT("cmdDUALPROFILE"))) ->SetOnClickNotify(OnDUALPROFILEClicked);
	((WndButton *)wf->FindByName(TEXT("cmdEXIT"))) ->SetOnClickNotify(OnEXITClicked);
	if (ScreenLandscape) {
		
		PROFWIDTH=(ScreenSizeX-IBLSCALE(320))/3; 


		switch(ScreenSize) {
			case ss800x480:
			case ss400x240:
				((WndButton *)wf->FindByName(TEXT("cmdFLY"))) ->SetWidth(IBLSCALE(110));
				((WndButton *)wf->FindByName(TEXT("cmdSIM"))) ->SetWidth(IBLSCALE(110));
				((WndButton *)wf->FindByName(TEXT("cmdSIM"))) ->SetLeft(IBLSCALE(208)+PROFWIDTH*3);
				((WndButton *)wf->FindByName(TEXT("cmdDUALPROFILE"))) ->SetLeft(IBLSCALE(88)+PROFWIDTH);
				((WndButton *)wf->FindByName(TEXT("cmdDUALPROFILE"))) ->SetWidth(IBLSCALE(92)+PROFWIDTH/6);
				((WndButton *)wf->FindByName(TEXT("cmdEXIT"))) ->SetLeft(IBLSCALE(161)+PROFWIDTH*2);
				((WndButton *)wf->FindByName(TEXT("cmdEXIT"))) ->SetWidth(IBLSCALE(65)+PROFWIDTH/5);
				break;
			case ss480x272:
				((WndButton *)wf->FindByName(TEXT("cmdFLY"))) ->SetWidth(IBLSCALE(117));
				((WndButton *)wf->FindByName(TEXT("cmdFLY"))) ->SetHeight(IBLSCALE(38));
				((WndButton *)wf->FindByName(TEXT("cmdFLY"))) ->SetTop(IBLSCALE(197));
				((WndButton *)wf->FindByName(TEXT("cmdSIM"))) ->SetWidth(IBLSCALE(117));
				((WndButton *)wf->FindByName(TEXT("cmdSIM"))) ->SetLeft(IBLSCALE(201)+PROFWIDTH*3);
				((WndButton *)wf->FindByName(TEXT("cmdSIM"))) ->SetHeight(IBLSCALE(38));
				((WndButton *)wf->FindByName(TEXT("cmdSIM"))) ->SetTop(IBLSCALE(197));
				((WndButton *)wf->FindByName(TEXT("cmdDUALPROFILE"))) ->SetLeft(IBLSCALE(88)+PROFWIDTH);
				((WndButton *)wf->FindByName(TEXT("cmdDUALPROFILE"))) ->SetWidth(IBLSCALE(99)+PROFWIDTH/6);
				((WndButton *)wf->FindByName(TEXT("cmdDUALPROFILE"))) ->SetHeight(IBLSCALE(38));
				((WndButton *)wf->FindByName(TEXT("cmdDUALPROFILE"))) ->SetTop(IBLSCALE(197));
				((WndButton *)wf->FindByName(TEXT("cmdEXIT"))) ->SetLeft(IBLSCALE(161)+PROFWIDTH*2);
				((WndButton *)wf->FindByName(TEXT("cmdEXIT"))) ->SetWidth(IBLSCALE(65)+PROFWIDTH/5);
				((WndButton *)wf->FindByName(TEXT("cmdEXIT"))) ->SetHeight(IBLSCALE(38));
				((WndButton *)wf->FindByName(TEXT("cmdEXIT"))) ->SetTop(IBLSCALE(197));
				break;
			case ss640x480:
			case ss320x240:
				((WndButton *)wf->FindByName(TEXT("cmdDUALPROFILE"))) ->SetLeft(IBLSCALE(93)+PROFWIDTH);
				((WndButton *)wf->FindByName(TEXT("cmdDUALPROFILE"))) ->SetWidth(IBLSCALE(73)+PROFWIDTH/6);
				((WndButton *)wf->FindByName(TEXT("cmdEXIT"))) ->SetLeft(IBLSCALE(166)+PROFWIDTH*2);
				((WndButton *)wf->FindByName(TEXT("cmdEXIT"))) ->SetWidth(IBLSCALE(60)+PROFWIDTH/5);
				((WndButton *)wf->FindByName(TEXT("cmdSIM"))) ->SetLeft(IBLSCALE(228)+PROFWIDTH*3);
				((WndButton *)wf->FindByName(TEXT("cmdSIM"))) ->SetWidth(IBLSCALE(88));
				break;
			default:
				((WndButton *)wf->FindByName(TEXT("cmdDUALPROFILE"))) ->SetLeft(IBLSCALE(93)+PROFWIDTH);
				((WndButton *)wf->FindByName(TEXT("cmdDUALPROFILE"))) ->SetWidth(IBLSCALE(73)+PROFWIDTH/6);
				((WndButton *)wf->FindByName(TEXT("cmdEXIT"))) ->SetLeft(IBLSCALE(166)+PROFWIDTH*2);
				((WndButton *)wf->FindByName(TEXT("cmdEXIT"))) ->SetWidth(IBLSCALE(60)+PROFWIDTH/5);
				((WndButton *)wf->FindByName(TEXT("cmdSIM"))) ->SetLeft(IBLSCALE(228)+PROFWIDTH*3);
				break;
		}	
	} else {
		PROFWIDTH=IBLSCALE(236);
		PROFACCEPTWIDTH=NIBLSCALE(45);
		PROFHEIGHT=NIBLSCALE(25);
		PROFSEPARATOR=NIBLSCALE(2);
	}
  }

  if (RUN_MODE==RUN_DUALPROF) {
	((WndButton *)wf->FindByName(TEXT("cmdAIRCRAFT"))) ->SetOnClickNotify(OnAIRCRAFTClicked);
	((WndButton *)wf->FindByName(TEXT("cmdPROFILE"))) ->SetOnClickNotify(OnPROFILEClicked);
	((WndButton *)wf->FindByName(TEXT("cmdPILOT"))) ->SetOnClickNotify(OnPILOTClicked);
	((WndButton *)wf->FindByName(TEXT("cmdCLOSE"))) ->SetOnClickNotify(OnCloseClicked);

	//((WndButton *)wf->FindByName(TEXT("cmdFLY"))) ->SetOnClickNotify(OnFLYClicked);
	//((WndButton *)wf->FindByName(TEXT("cmdSIM"))) ->SetOnClickNotify(OnSIMClicked);
	//((WndButton *)wf->FindByName(TEXT("cmdDUALPROFILE"))) ->SetOnClickNotify(OnDUALPROFILEClicked);
	//((WndButton *)wf->FindByName(TEXT("cmdEXIT"))) ->SetOnClickNotify(OnEXITClicked);
	if (ScreenLandscape) {
		
		PROFWIDTH=(ScreenSizeX-IBLSCALE(320))/3; 


		switch(ScreenSize) {
			case ss800x480:
			case ss400x240:
				((WndButton *)wf->FindByName(TEXT("cmdAIRCRAFT"))) ->SetWidth(IBLSCALE(110));
				((WndButton *)wf->FindByName(TEXT("cmdCLOSE"))) ->SetWidth(IBLSCALE(110));
				((WndButton *)wf->FindByName(TEXT("cmdCLOSE"))) ->SetLeft(IBLSCALE(208)+PROFWIDTH*3);
				((WndButton *)wf->FindByName(TEXT("cmdPROFILE"))) ->SetLeft(IBLSCALE(88)+PROFWIDTH);
				((WndButton *)wf->FindByName(TEXT("cmdPROFILE"))) ->SetWidth(IBLSCALE(92)+PROFWIDTH/6);
				((WndButton *)wf->FindByName(TEXT("cmdPILOT"))) ->SetLeft(IBLSCALE(161)+PROFWIDTH*2);
				((WndButton *)wf->FindByName(TEXT("cmdPILOT"))) ->SetWidth(IBLSCALE(65)+PROFWIDTH/5);
				break;
			case ss480x272:
				((WndButton *)wf->FindByName(TEXT("cmdAIRCRAFT"))) ->SetWidth(IBLSCALE(117));
				((WndButton *)wf->FindByName(TEXT("cmdAIRCRAFT"))) ->SetHeight(IBLSCALE(38));
				((WndButton *)wf->FindByName(TEXT("cmdAIRCRAFT"))) ->SetTop(IBLSCALE(197));
				((WndButton *)wf->FindByName(TEXT("cmdCLOSE"))) ->SetWidth(IBLSCALE(117));
				((WndButton *)wf->FindByName(TEXT("cmdCLOSE"))) ->SetLeft(IBLSCALE(201)+PROFWIDTH*3);
				((WndButton *)wf->FindByName(TEXT("cmdCLOSE"))) ->SetHeight(IBLSCALE(38));
				((WndButton *)wf->FindByName(TEXT("cmdCLOSE"))) ->SetTop(IBLSCALE(197));
				((WndButton *)wf->FindByName(TEXT("cmdPROFILE"))) ->SetLeft(IBLSCALE(88)+PROFWIDTH);
				((WndButton *)wf->FindByName(TEXT("cmdPROFILE"))) ->SetWidth(IBLSCALE(99)+PROFWIDTH/6);
				((WndButton *)wf->FindByName(TEXT("cmdPROFILE"))) ->SetHeight(IBLSCALE(38));
				((WndButton *)wf->FindByName(TEXT("cmdPROFILE"))) ->SetTop(IBLSCALE(197));
				((WndButton *)wf->FindByName(TEXT("cmdPILOT"))) ->SetLeft(IBLSCALE(161)+PROFWIDTH*2);
				((WndButton *)wf->FindByName(TEXT("cmdPILOT"))) ->SetWidth(IBLSCALE(65)+PROFWIDTH/5);
				((WndButton *)wf->FindByName(TEXT("cmdPILOT"))) ->SetHeight(IBLSCALE(38));
				((WndButton *)wf->FindByName(TEXT("cmdPILOT"))) ->SetTop(IBLSCALE(197));
				break;
			case ss640x480:
			case ss320x240:
				((WndButton *)wf->FindByName(TEXT("cmdPROFILE"))) ->SetLeft(IBLSCALE(93)+PROFWIDTH);
				((WndButton *)wf->FindByName(TEXT("cmdPROFILE"))) ->SetWidth(IBLSCALE(73)+PROFWIDTH/6);
				((WndButton *)wf->FindByName(TEXT("cmdPILOT"))) ->SetLeft(IBLSCALE(166)+PROFWIDTH*2);
				((WndButton *)wf->FindByName(TEXT("cmdPILOT"))) ->SetWidth(IBLSCALE(60)+PROFWIDTH/5);
				((WndButton *)wf->FindByName(TEXT("cmdCLOSE"))) ->SetLeft(IBLSCALE(228)+PROFWIDTH*3);
				((WndButton *)wf->FindByName(TEXT("cmdCLOSE"))) ->SetWidth(IBLSCALE(88));
				break;
			default:
				((WndButton *)wf->FindByName(TEXT("cmdPROFILE"))) ->SetLeft(IBLSCALE(93)+PROFWIDTH);
				((WndButton *)wf->FindByName(TEXT("cmdPROFILE"))) ->SetWidth(IBLSCALE(73)+PROFWIDTH/6);
				((WndButton *)wf->FindByName(TEXT("cmdPILOT"))) ->SetLeft(IBLSCALE(166)+PROFWIDTH*2);
				((WndButton *)wf->FindByName(TEXT("cmdPILOT"))) ->SetWidth(IBLSCALE(60)+PROFWIDTH/5);
				((WndButton *)wf->FindByName(TEXT("cmdCLOSE"))) ->SetLeft(IBLSCALE(228)+PROFWIDTH*3);
				break;
		}	
	} else {
		PROFWIDTH=IBLSCALE(236);
		PROFACCEPTWIDTH=NIBLSCALE(45);
		PROFHEIGHT=NIBLSCALE(25);
		PROFSEPARATOR=NIBLSCALE(2);
	}
  }



  if (RUN_MODE==RUN_PROFILE || RUN_MODE==RUN_AIRCRAFT || RUN_MODE==RUN_PILOT) {
	((WndButton *)wf->FindByName(TEXT("cmdClose"))) ->SetOnClickNotify(OnCloseClicked);
	if (ScreenLandscape) {
		PROFWIDTH=IBLSCALE(256);
		PROFACCEPTWIDTH=NIBLSCALE(60);
		PROFHEIGHT=NIBLSCALE(30);
		PROFSEPARATOR=NIBLSCALE(4);
		((WndButton *)wf->FindByName(TEXT("cmdClose"))) ->SetWidth(PROFACCEPTWIDTH);
		((WndButton *)wf->FindByName(TEXT("cmdClose"))) ->
			SetLeft((((ScreenSizeX-PROFWIDTH-PROFSEPARATOR-PROFACCEPTWIDTH)/2)+PROFSEPARATOR+PROFWIDTH)-NIBLSCALE(2));
		((WndButton *)wf->FindByName(TEXT("cmdClose"))) ->SetHeight(PROFHEIGHT-NIBLSCALE(4));
	} else {
		PROFWIDTH=IBLSCALE(236);
		PROFACCEPTWIDTH=NIBLSCALE(45);
		PROFHEIGHT=NIBLSCALE(25);
		PROFSEPARATOR=NIBLSCALE(2);
		((WndButton *)wf->FindByName(TEXT("cmdClose"))) ->SetWidth(ScreenSizeX-NIBLSCALE(6));
		((WndButton *)wf->FindByName(TEXT("cmdClose"))) -> SetLeft(NIBLSCALE(2));
	}
  }

  TCHAR temp[MAX_PATH];

  wf->SetHeight(ScreenSizeY);
  wf->SetWidth(ScreenSizeX);

  wp = ((WndProperty *)wf->FindByName(TEXT("prpProfile")));
  if (wp) {
    DataFieldFileReader* dfe;
    dfe = (DataFieldFileReader*)wp->GetDataField();

    if (RUN_MODE==RUN_PROFILE) {
	    _stprintf(temp,_T("*%S"),LKS_PRF); 
	    dfe->ScanDirectoryTop(_T(LKD_CONF),temp); 
	    dfe->addFile(gettext(_T("_@M1741_")),_T("PROFILE_RESET")); 
	    dfe->Lookup(startProfileFile);
    } 
    if (RUN_MODE==RUN_AIRCRAFT) {
	    _stprintf(temp,_T("*%S"),LKS_AIRCRAFT); 
	    dfe->ScanDirectoryTop(_T(LKD_CONF),temp); 
	    dfe->Lookup(startAircraftFile);
    }
    if (RUN_MODE==RUN_PILOT) {
	    _stprintf(temp,_T("*%S"),LKS_PILOT); 
	    dfe->ScanDirectoryTop(_T(LKD_CONF),temp); 
	    dfe->Lookup(startPilotFile);
    }

    wp->SetHeight(PROFHEIGHT);
    wp->SetWidth(PROFWIDTH);
    if (ScreenLandscape)
    	wp->SetLeft(((ScreenSizeX-PROFWIDTH-PROFSEPARATOR-PROFACCEPTWIDTH)/2)-NIBLSCALE(2));
    else
    	wp->SetLeft(0);

    wp->RefreshDisplay();
  }



  if  (!CheckRootDir()) {
	TCHAR mydir[MAX_PATH];
	TCHAR mes[MAX_PATH];

	LocalPath(mydir,_T(""));
	_stprintf(mes,_T("%s"),mydir);
	MessageBoxX(hWndMainWindow, _T("NO LK8000 DIRECTORY\nCheck Installation!"), _T("FATAL ERROR 000"), MB_OK|MB_ICONQUESTION);
	MessageBoxX(hWndMainWindow, mes, _T("NO LK8000 DIRECTORY"), MB_OK|MB_ICONQUESTION, true);
	RUN_MODE=RUN_EXIT;
	Shutdown();
	goto _exit;
  }

  if  (!CheckDataDir()) {
	TCHAR mydir[MAX_PATH];
	TCHAR mes[MAX_PATH];

	LocalPath(mydir,_T(LKD_SYSTEM));
	_stprintf(mes,_T("%s"),mydir);
	MessageBoxX(hWndMainWindow, _T("NO SYSTEM DIRECTORY\nCheck Installation!"), _T("FATAL ERROR 001"), MB_OK|MB_ICONQUESTION);
	MessageBoxX(hWndMainWindow, mes, _T("NO SYSTEM DIRECTORY"), MB_OK|MB_ICONQUESTION, true);
	RUN_MODE=RUN_EXIT;
	Shutdown();
	goto _exit;
  }

  if  (!CheckLanguageDir()) {
	TCHAR mydir[MAX_PATH];
	TCHAR mes[MAX_PATH];
	StartupStore(_T("... CHECK LANGUAGE DIRECTORY FAILED!%s"),NEWLINE);

	LocalPath(mydir,_T(LKD_LANGUAGE));
	_stprintf(mes,_T("%s"),mydir);
	MessageBoxX(hWndMainWindow, _T("LANGUAGE DIRECTORY CHECK FAIL\nCheck Language Install"), _T("FATAL ERROR 002"), MB_OK|MB_ICONQUESTION);
	MessageBoxX(hWndMainWindow, mes, _T("NO LANGUAGE DIRECTORY"), MB_OK|MB_ICONQUESTION, true);
	RUN_MODE=RUN_EXIT;
	Shutdown();
	goto _exit;
  }
  if  (!CheckLanguageEngMsg()) {
	TCHAR mydir[MAX_PATH];
	TCHAR mes[MAX_PATH];
	StartupStore(_T("... CHECK LANGUAGE ENG_MSG FAILED!%s"),NEWLINE);
	LocalPath(mydir,_T(LKD_LANGUAGE));
	_stprintf(mes,_T("%s/ENG_MSG.TXT"),mydir);
	MessageBoxX(hWndMainWindow, _T("ENG_MSG.TXT MISSING in LANGUAGE\nCheck Language Install"), _T("FATAL ERROR 012"), MB_OK|MB_ICONQUESTION);
	MessageBoxX(hWndMainWindow, mes, _T("MISSING FILE!"), MB_OK|MB_ICONQUESTION, true);
	RUN_MODE=RUN_EXIT;
	Shutdown();
	goto _exit;
  }
  if  (!CheckSystemDefaultMenu()) {
	TCHAR mydir[MAX_PATH];
	TCHAR mes[MAX_PATH];
	StartupStore(_T("... CHECK SYSTEM DEFAULT_MENU.TXT FAILED!%s"),NEWLINE);
	LocalPath(mydir,_T(LKD_SYSTEM));
	_stprintf(mes,_T("%s/DEFAULT_MENU.TXT"),mydir);
	MessageBoxX(hWndMainWindow, _T("DEFAULT_MENU.TXT MISSING in SYSTEM\nCheck System Install"), _T("FATAL ERROR 022"), MB_OK|MB_ICONQUESTION);
	MessageBoxX(hWndMainWindow, mes, _T("MISSING FILE!"), MB_OK|MB_ICONQUESTION, true);
	RUN_MODE=RUN_EXIT;
	Shutdown();
	goto _exit;
  }

  if  (!CheckSystemBitmaps()) {
	TCHAR mydir[MAX_PATH];
	TCHAR mes[MAX_PATH];
	StartupStore(_T("... CHECK SYSTEM _BITMAPSH FAILED!%s"),NEWLINE);
	LocalPath(mydir,_T(LKD_BITMAPS));
	_stprintf(mes,_T("%s/_BITMAPSH"),mydir);
	MessageBoxX(hWndMainWindow, _T("_BITMAPSH MISSING in SYSTEM Bitmaps\nCheck System Install"), _T("FATAL ERROR 032"), MB_OK|MB_ICONQUESTION);
	MessageBoxX(hWndMainWindow, mes, _T("MISSING FILE!"), MB_OK|MB_ICONQUESTION, true);
	RUN_MODE=RUN_EXIT;
	Shutdown();
	goto _exit;
  }

  if  (!CheckPolarsDir()) {
	TCHAR mydir[MAX_PATH];
	TCHAR mes[MAX_PATH];
	StartupStore(_T("... CHECK POLARS DIRECTORY FAILED!%s"),NEWLINE);

	LocalPath(mydir,_T(LKD_POLARS));
	_stprintf(mes,_T("%s"),mydir);
	MessageBoxX(hWndMainWindow, _T("NO POLARS DIRECTORY\nCheck Install"), _T("FATAL ERROR 003"), MB_OK|MB_ICONQUESTION);
	MessageBoxX(hWndMainWindow, mes, _T("NO POLARS DIRECTORY"), MB_OK|MB_ICONQUESTION, true);
	RUN_MODE=RUN_EXIT;
	Shutdown();
	goto _exit;
  }


  // Standby for a system request to close the application during this phase.
  wf->SetTimerNotify(OnTimerNotify);
  #if 0
  srand(GetTickCount());
  #endif

  wf->ShowModal();
  if (RUN_MODE==RUN_SHUTDOWN) goto _exit;

  wp = (WndProperty*)wf->FindByName(TEXT("prpProfile"));
  if (wp) {
	DataFieldFileReader* dfe;
	dfe = (DataFieldFileReader*)wp->GetDataField();

	if (RUN_MODE==RUN_PROFILE) {
		if (_tcslen(dfe->GetPathFile())>0) {
			if (_tcscmp(dfe->GetPathFile(),startProfileFile) ) { // if they are not the same
				_tcscpy(startProfileFile,dfe->GetPathFile());
				if (_tcscmp(startProfileFile,_T("PROFILE_RESET"))==0) {
					#if TESTBENCH
					StartupStore(_T("... Selected FULL RESET virtual profile\n"));
					#endif
					if (MessageBoxX(NULL, gettext(TEXT("_@M1758_")), 
						gettext(TEXT("_@M1757_")), MB_OK|MB_ICONQUESTION));
					fullresetasked=true;
				} else {
					#if TESTBENCH
					StartupStore(_T("... Selected new profile, preloading..\n"));
					#endif
					LKProfileLoad(startProfileFile);
					fullresetasked=false;
				}
			}
		}
	}
	if (RUN_MODE==RUN_AIRCRAFT) {
		if (_tcslen(dfe->GetPathFile())>0) {
			if (_tcscmp(dfe->GetPathFile(),startAircraftFile) ) { // if they are not the same
				_tcscpy(startAircraftFile,dfe->GetPathFile());
				#if TESTBENCH
				StartupStore(_T("... Selected new aircraft, preloading..\n"));
				#endif
				LKProfileLoad(startAircraftFile);
			}
		}
	}
	if (RUN_MODE==RUN_PILOT) {
		if (_tcslen(dfe->GetPathFile())>0) {
			if (_tcscmp(dfe->GetPathFile(),startPilotFile) ) { // if they are not the same
				_tcscpy(startPilotFile,dfe->GetPathFile());
				#if TESTBENCH
				StartupStore(_T("... Selected new pilot, preloading..\n"));
				#endif
				LKProfileLoad(startPilotFile);
			}
		}
	}
	RUN_MODE=RUN_DUALPROF;
  }
  if (RUN_MODE==RUN_EXIT) {
	if (EnableSoundModes) LKSound(_T("LK_SLIDE.WAV"));
	if (MessageBoxX(hWndMainWindow, 
	// LKTOKEN  _@M198_ = "Confirm Exit?" 
		gettext(TEXT("_@M198_")), 
		TEXT("LK8000"), MB_YESNO|MB_ICONQUESTION) == IDYES) {
		Shutdown();
	} else
		RUN_MODE=RUN_WELCOME;
  }


_exit:
  if (wf!=NULL) {
	delete wf;
	wf = NULL;
  }

  if (RUN_MODE==RUN_FLY || RUN_MODE==RUN_SIM) {
	if (EnableSoundModes) LKSound(_T("LK_SLIDE.WAV"));
	return 0;	// do not repeat dialog
  }

  if (RUN_MODE==RUN_EXIT || RUN_MODE==RUN_SHUTDOWN)
	return -1;	// terminate
  else
	return 1;	// repeat dialog

}
コード例 #3
0
ファイル: nfexpire.c プロジェクト: raceli/NetflowDB
int main( int argc, char **argv ) {
    struct stat fstat;
    int 		c, err, maxsize_set, maxlife_set;
    int			do_rescan, do_expire, do_list, print_stat, do_update_param, print_books, is_profile, nfsen_format;
    char		*maxsize_string, *lifetime_string, *datadir;
    uint64_t	maxsize, lifetime, low_water;
    uint32_t	runtime;
    channel_t	*channel, *current_channel;

    maxsize_string = lifetime_string = NULL;
    datadir = NULL;
    maxsize = lifetime = 0;
    do_rescan  		= 0;
    do_expire  		= 0;
    do_list	   		= 0;
    do_update_param = 0;
    is_profile		= 0;
    print_stat		= 0;
    print_books		= 0;
    maxsize_set 	= 0;
    maxlife_set 	= 0;
    low_water		= 0;
    nfsen_format	= 0;
    runtime			= 0;

    while ((c = getopt(argc, argv, "e:hl:L:T:Ypr:s:t:u:w:")) != EOF) {
        switch (c) {
        case 'h':
            usage(argv[0]);
            exit(0);
            break;
        case 'l':
            CheckDataDir(datadir);
            datadir = optarg;
            do_list = 1;
            print_stat = 1;
            break;
        case 'L':
            CheckDataDir(datadir);
            datadir = optarg;
            print_stat  = 1;
            print_books = 1;
            break;
        case 'p':
            is_profile = 1;
            break;
        case 'r':
            CheckDataDir(datadir);
            do_rescan = 1;
            print_stat = 1;
            datadir = optarg;
            break;
        case 'e':
            CheckDataDir(datadir);
            datadir = optarg;
            do_expire = 1;
            print_stat = 1;
            break;
        case 's':
            if ( ParseSizeDef(optarg, &maxsize ) == 0 )
                exit(250);
            maxsize_set = 1;
            break;
        case 't':
            if ( ParseTimeDef(optarg, &lifetime ) == 0 )
                exit(250);
            maxlife_set = 1;
            break;
        case 'u':
            CheckDataDir(datadir);
            datadir = optarg;
            do_update_param = 1;
            break;
        case 'w':
            low_water = strtoll(optarg, NULL, 10);
            if ( low_water > 100 ) {
                fprintf(stderr, "Water mark > 100%%\n");
                exit(250);
            }
            if ( low_water == 0 )
                low_water = 100;
            break;
        case 'T':
            runtime = strtoll(optarg, NULL, 10);
            if ( runtime > 3600 ) {
                fprintf(stderr, "Runtime > 3600 (1h)\n");
                exit(250);
            }
            break;
        case 'Y':
            nfsen_format = 1;
            break;
        default:
            usage(argv[0]);
            exit(250);
        }

    }

    datadir = AbsolutePath(datadir);

    if ( !datadir ) {
        fprintf(stderr, "Missing data directory\n");
        usage(argv[0]);
        exit(250);
    }

    err  = stat(datadir, &fstat);
    if ( !(fstat.st_mode & S_IFDIR) ) {
        fprintf(stderr, "No such directory: %s\n", datadir);
        exit(250);
    }

    channel = GetChannelList(datadir, is_profile, do_rescan);
    // GetChannelList(datadir, is_profile, do_rescan);
    if ( !channel ) {
        exit(250);
    }

// printf("Size: %llu, time: %llu\n", maxsize, lifetime);

    // update water mark only, when not listing
    if ( !is_profile && !do_list && low_water )
        channel->dirstat->low_water = low_water;

    /* process do_list first: if the UpdateBookStat results in a FORCE_REBUILD,
     * this will immediately done afterwards
     * do_expire will need accurate books as well, so update the books here as well
     */
    if ( do_list || do_expire ) {
        current_channel = channel;
        while ( current_channel ) {
            if ( current_channel->books_stat == BOOKKEEPER_OK ) {
                bookkeeper_t	tmp_books;
                printf("Include nfcapd bookeeping record in %s\n", current_channel->datadir);
                ClearBooks(current_channel->books, &tmp_books);
                UpdateBookStat(current_channel->dirstat, &tmp_books);
                if ( current_channel->dirstat->status == FORCE_REBUILD )
                    current_channel->do_rescan = 1;
            }
            current_channel = current_channel->next;
        }
    }

    // process do_rescan: make sure stats are up to date, if required
    current_channel = channel;
    while ( current_channel ) {
        if ( current_channel->do_rescan ) {
            int	 i;
            uint64_t last_sequence;

            /* detect new files: If nfcapd adds a new file while we are rescanning the directory
            * this results in inconsistent data for the rescan. Therefore check at the begin and end
            * of the rescan for the sequence number, which reflects the accesss/change to the bookkeeping record
            * It's assumed, that such an event does not occure more than once. However, loop 3 times max
            */
            for ( i=0; i<3; i++ ) {
                last_sequence = BookSequence(current_channel->books);
                printf("Scanning files in %s .. ", current_channel->datadir);
                RescanDir(current_channel->datadir, current_channel->dirstat);
                if ( current_channel->dirstat->numfiles == 0 ) { //nothing found
                    current_channel->status = NOFILES;
                }
                if ( BookSequence(current_channel->books) == last_sequence )
                    break;
                printf("Rescan again, due to file changes in directory!\n");
            }
            if ( BookSequence(current_channel->books) != last_sequence ) {
                fprintf(stderr, "Could not savely rescan the directory. Data is not consistent.\n");
                ReleaseBookkeeper(current_channel->books, DETACH_ONLY);
                if ( current_channel->status == OK )
                    WriteStatInfo(current_channel->dirstat);
                exit(250);
            }
            printf("done.\n");
            if ( current_channel->books_stat == BOOKKEEPER_OK ) {
                printf("Updating nfcapd bookeeping records\n");
                ClearBooks(channel->books, NULL);
            }
        }
        current_channel = current_channel->next;
    }

    // now process do_expire if required
    if ( do_expire ) {
        dirstat_t	old_stat, current_stat;

        if ( is_profile ) {
            current_stat.status = 0;
            current_stat.max_lifetime 	= lifetime;
            current_stat.max_size  		= maxsize;
            current_stat.low_water 		= low_water ? low_water : 98;

            // sum up all channels in the profile
            current_channel = channel;
            current_stat.numfiles = current_channel->dirstat->numfiles;
            current_stat.filesize = current_channel->dirstat->filesize;
            current_stat.first 	  = current_channel->dirstat->first;
            current_stat.last 	  = current_channel->dirstat->last;
            current_channel = current_channel->next;
            while ( current_channel ) {
                current_stat.numfiles += current_channel->dirstat->numfiles;
                current_stat.filesize += current_channel->dirstat->filesize;
                if ( current_channel->dirstat->first && (current_channel->dirstat->first < current_stat.first) )
                    current_stat.first = current_channel->dirstat->first;
                if ( current_channel->dirstat->last > current_stat.last )
                    current_stat.last = current_channel->dirstat->last;

                current_channel = current_channel->next;
            }
            old_stat = current_stat;
            ExpireProfile(channel, &current_stat, maxsize, lifetime, runtime);

        } else {
            // cmd args override dirstat values
            if ( maxsize_set )
                channel->dirstat->max_size     = maxsize;
            else
                maxsize = channel->dirstat->max_size;
            if ( maxlife_set )
                channel->dirstat->max_lifetime = lifetime;
            else
                lifetime = channel->dirstat->max_lifetime;


            old_stat = *(channel->dirstat);
            ExpireDir(channel->datadir, channel->dirstat, maxsize, lifetime, runtime);
            current_stat = *(channel->dirstat);

        }
        // Report, what we have done
        printf("Expired files:      %llu\n", (unsigned long long)(old_stat.numfiles - current_stat.numfiles));
        printf("Expired file size:  %s\n", ScaleValue(old_stat.filesize - current_stat.filesize));
        printf("Expired time range: %s\n\n", ScaleTime(current_stat.first - old_stat.first));
    }

    if ( !is_profile && do_update_param ) {
        switch (channel->books_stat) {
        case BOOKKEEPER_OK:
            if ( maxsize_set )
                channel->dirstat->max_size = maxsize;
            else
                maxsize = channel->dirstat->max_size;
            if ( maxlife_set )
                channel->dirstat->max_lifetime = lifetime;
            else
                lifetime = channel->dirstat->max_lifetime;
            printf("Update collector process running for directory: '%s'\n", datadir);
            UpdateBooksParam(channel->books, (time_t)lifetime, maxsize);
            print_stat = 1;
            break;
        case ERR_NOTEXISTS:
            if ( maxsize_set )
                channel->dirstat->max_size = maxsize;
            if ( maxlife_set )
                channel->dirstat->max_lifetime = lifetime;
            print_stat = 1;
            break;
        default:
            // should never be reached as already cought earlier
            printf("Error %i while connecting to collector\n", channel->books_stat);
        }
        if ( channel->status == OK || channel->status == NOFILES  )
            WriteStatInfo(channel->dirstat);
    }

    if ( !is_profile && print_books ) {
        switch (channel->books_stat) {
        case BOOKKEEPER_OK:
            PrintBooks(channel->books);
            break;
        case ERR_NOTEXISTS:
            printf("No collector process running for directory: '%s'\n", channel->datadir);
            break;
        default:
            // should never be reached as already cought earlier
            printf("Error %i while connecting to collector\n", channel->books_stat);
        }

    }

    if ( print_stat ) {
        if ( is_profile ) {
            dirstat_t	current_stat;

            current_stat.status = 0;
            current_stat.max_lifetime 	= lifetime;
            current_stat.max_size  		= maxsize;
            current_stat.low_water 		= low_water ? low_water : 98;

            // sum up all channels in the profile
            current_channel = channel;
            current_stat.numfiles = current_channel->dirstat->numfiles;
            current_stat.filesize = current_channel->dirstat->filesize;
            current_stat.first 	  = current_channel->dirstat->first;
            current_stat.last 	  = current_channel->dirstat->last;
            current_channel = current_channel->next;
            while ( current_channel ) {
                current_stat.numfiles += current_channel->dirstat->numfiles;
                current_stat.filesize += current_channel->dirstat->filesize;
                if ( current_channel->dirstat->first && (current_channel->dirstat->first < current_stat.first) )
                    current_stat.first = current_channel->dirstat->first;
                if ( current_channel->dirstat->last > current_stat.last )
                    current_stat.last = current_channel->dirstat->last;

                current_channel = current_channel->next;
            }
            if ( nfsen_format ) {
                printf("Stat|%llu|%llu|%llu\n",
                       (unsigned long long)current_stat.filesize,
                       (unsigned long long)current_stat.first, (unsigned long long)current_stat.last);
            } else
                PrintDirStat(&current_stat);
        } else if ( nfsen_format )
            printf("Stat|%llu|%llu|%llu\n",
                   (unsigned long long)channel->dirstat->filesize,
                   (unsigned long long)channel->dirstat->first, (unsigned long long)channel->dirstat->last );
        else
            PrintDirStat(channel->dirstat);

    }

    current_channel = channel;
    while ( current_channel ) {
        ReleaseBookkeeper(current_channel->books, DETACH_ONLY);
        if ( current_channel->status == OK )
            WriteStatInfo(current_channel->dirstat);

        current_channel = current_channel->next;
    }

    return 0;
}
コード例 #4
0
short dlgStartupShowModal(void) {
    WndProperty* wp = nullptr;

#if TESTBENCH
    StartupStore(TEXT(". Startup dialog, RUN_MODE=%d %s"), RUN_MODE, NEWLINE);
#endif

    switch(RUN_MODE) {
        case RUN_WELCOME: // FLY SIM PROFILE EXIT
            wf = InitFlySim();
            break;
        case RUN_DUALPROF: //  PROFILE AIRCRAFT  CLOSE
            wf = InitDualProfile();
            break;
        case RUN_PROFILE:
        case RUN_AIRCRAFT:
        case RUN_PILOT:
        case RUN_DEVICE:
            // CHOOSE PROFILE
            wf = InitStartup(RUN_MODE);
            break;
    }
    if (!wf) {
        return 0;
    }

    wf->SetHeight(ScreenSizeY);
    wf->SetWidth(ScreenSizeX);

    WindowControl* wSplash = wf->FindByName(TEXT("frmSplash"));
    if(wSplash) {
        wSplash->SetWidth(ScreenSizeX);
        // wSplash->SetHeight(ScreenSizeY);// - IBLSCALE(55));
    }




    if (!CheckRootDir()) {
        TCHAR mydir[MAX_PATH];
        TCHAR mes[MAX_PATH];

        LocalPath(mydir, _T(""));
        _stprintf(mes, _T("%s"), mydir);
        MessageBoxX(_T("NO LK8000 DIRECTORY\nCheck Installation!"), _T("FATAL ERROR 000"), mbOk);
        MessageBoxX(mes, _T("NO LK8000 DIRECTORY"), mbOk, true);
        RUN_MODE = RUN_EXIT;
        Shutdown();
        goto _exit;
    }

    if (!CheckDataDir()) {
        TCHAR mydir[MAX_PATH];
        TCHAR mes[MAX_PATH];

        SystemPath(mydir, _T(LKD_SYSTEM));
        _stprintf(mes, _T("%s"), mydir);
        MessageBoxX(_T("NO SYSTEM DIRECTORY\nCheck Installation!"), _T("FATAL ERROR 001"), mbOk);
        MessageBoxX(mes, _T("NO SYSTEM DIRECTORY"), mbOk, true);
        RUN_MODE = RUN_EXIT;
        Shutdown();
        goto _exit;
    }

    if (!CheckLanguageDir()) {
        TCHAR mydir[MAX_PATH];
        TCHAR mes[MAX_PATH];
        StartupStore(_T("... CHECK LANGUAGE DIRECTORY FAILED!%s"), NEWLINE);

        LocalPath(mydir, _T(LKD_LANGUAGE));
        _stprintf(mes, _T("%s"), mydir);
        MessageBoxX(_T("LANGUAGE DIRECTORY CHECK FAIL\nCheck Language Install"), _T("FATAL ERROR 002"), mbOk);
        MessageBoxX(mes, _T("NO LANGUAGE DIRECTORY"), mbOk, true);
        RUN_MODE = RUN_EXIT;
        Shutdown();
        goto _exit;
    }
    if (!CheckLanguageEngMsg()) {
        TCHAR mydir[MAX_PATH];
        TCHAR mes[MAX_PATH];
        StartupStore(_T("... CHECK LANGUAGE ENG_MSG FAILED!%s"), NEWLINE);
        LocalPath(mydir, _T(LKD_LANGUAGE));
        _stprintf(mes, _T("%s/ENG_MSG.TXT"), mydir);
        MessageBoxX(_T("ENG_MSG.TXT MISSING in LANGUAGE\nCheck Language Install"), _T("FATAL ERROR 012"), mbOk);
        MessageBoxX(mes, _T("MISSING FILE!"), mbOk, true);
        RUN_MODE = RUN_EXIT;
        Shutdown();
        goto _exit;
    }
    if (!CheckSystemDefaultMenu()) {
        TCHAR mydir[MAX_PATH];
        TCHAR mes[MAX_PATH];
        StartupStore(_T("... CHECK SYSTEM DEFAULT_MENU.TXT FAILED!%s"), NEWLINE);
        SystemPath(mydir, _T(LKD_SYSTEM));
        _stprintf(mes, _T("%s/DEFAULT_MENU.TXT"), mydir);
        MessageBoxX(_T("DEFAULT_MENU.TXT MISSING in SYSTEM\nCheck System Install"), _T("FATAL ERROR 022"), mbOk);
        MessageBoxX(mes, _T("MISSING FILE!"), mbOk, true);
        RUN_MODE = RUN_EXIT;
        Shutdown();
        goto _exit;
    }

    if (!CheckSystemBitmaps()) {
        TCHAR mydir[MAX_PATH];
        TCHAR mes[MAX_PATH];
        StartupStore(_T("... CHECK SYSTEM _BITMAPSH FAILED!%s"), NEWLINE);
        SystemPath(mydir, _T(LKD_BITMAPS));
        _stprintf(mes, _T("%s/_BITMAPSH"), mydir);
        MessageBoxX(_T("_BITMAPSH MISSING in SYSTEM Bitmaps\nCheck System Install"), _T("FATAL ERROR 032"), mbOk);
        MessageBoxX(mes, _T("MISSING FILE!"), mbOk, true);
        RUN_MODE = RUN_EXIT;
        Shutdown();
        goto _exit;
    }

    extern unsigned short Bitmaps_Errors;
    if (Bitmaps_Errors) {
        TCHAR mes[MAX_PATH];
        _stprintf(mes, _T("MISSING %d SYSTEM BITMAPS! CHECK INSTALLATION."), Bitmaps_Errors);
        MessageBoxX(mes, _T("MISSING FILES!"), mbOk, true);
    }

    if (!CheckPolarsDir()) {
        TCHAR mydir[MAX_PATH];
        TCHAR mes[MAX_PATH];
        StartupStore(_T("... CHECK POLARS DIRECTORY FAILED!%s"), NEWLINE);

        LocalPath(mydir, _T(LKD_POLARS));
        _stprintf(mes, _T("%s"), mydir);
        MessageBoxX(_T("NO POLARS DIRECTORY\nCheck Install"), _T("FATAL ERROR 003"), mbOk);
        MessageBoxX(mes, _T("NO POLARS DIRECTORY"), mbOk, true);
        RUN_MODE = RUN_EXIT;
        Shutdown();
        goto _exit;
    }

    extern bool CheckFilesystemWritable(void);
    if (!CheckFilesystemWritable()) {
        MessageBoxX(_T("LK8000 CANNOT WRITE IN MEMORY CARD!\nCARD IS LOCKED, OR DAMAGED, OR FULL."), _T("CRITICAL PROBLEM"), mbOk);
        RUN_MODE = RUN_EXIT;
        Shutdown();
        goto _exit;
    }



    // Standby for a system request to close the application during this phase.
    wf->SetTimerNotify(500, OnTimerNotify);
    if (wf->ShowModal() == mrCancel) {
        RUN_MODE = RUN_EXIT;
    }
    if (RUN_MODE == RUN_SHUTDOWN) goto _exit;

    wp = (WndProperty*) wf->FindByName(TEXT("prpProfile"));
    if (wp) {
        DataFieldFileReader* dfe = (DataFieldFileReader*) wp->GetDataField();

        if (RUN_MODE == RUN_PROFILE) {
            if (_tcslen(dfe->GetPathFile()) > 0) {
                if (_tcscmp(dfe->GetPathFile(), startProfileFile)) { // if they are not the same
                    _tcscpy(startProfileFile, dfe->GetPathFile());
                    if (_tcscmp(startProfileFile, _T("PROFILE_RESET")) == 0) {
#if TESTBENCH
                        StartupStore(_T("... Selected FULL RESET virtual profile\n"));
#endif
                        MessageBoxX(MsgToken(1758), MsgToken(1757), mbOk);
                        FullResetAsked = true;
                    } else {
#if TESTBENCH
                        StartupStore(_T("... Selected new profile, preloading..\n"));
#endif
                        FullResetAsked = false;
                    }
                }
            }
        }
        if (RUN_MODE == RUN_AIRCRAFT) {
            if (_tcslen(dfe->GetPathFile()) > 0) {
                if (_tcscmp(dfe->GetPathFile(), startAircraftFile)) { // if they are not the same
                    _tcscpy(startAircraftFile, dfe->GetPathFile());
#if TESTBENCH
                    StartupStore(_T("... Selected new aircraft, preloading..\n"));
#endif
                }
            }
        }
        if (RUN_MODE == RUN_DEVICE) {
            if (_tcslen(dfe->GetPathFile()) > 0) {
                if (_tcscmp(dfe->GetPathFile(), startDeviceFile)) { // if they are not the same
                    _tcscpy(startDeviceFile, dfe->GetPathFile());
#if TESTBENCH
                    StartupStore(_T("... Selected new device, preloading..\n"));
#endif
                }
            }
        }
        if (RUN_MODE == RUN_PILOT) {
            if (_tcslen(dfe->GetPathFile()) > 0) {
                if (_tcscmp(dfe->GetPathFile(), startPilotFile)) { // if they are not the same
                    _tcscpy(startPilotFile, dfe->GetPathFile());
#if TESTBENCH
                    StartupStore(_T("... Selected new pilot, preloading..\n"));
#endif
                }
            }
        }
        RUN_MODE = RUN_DUALPROF;
    }
    if (RUN_MODE == RUN_EXIT) {
#if __linux__
        RUN_MODE = RUN_WELCOME;
#endif
        LKSound(_T("LK_SLIDE.WAV"));
        if (MessageBoxX(
                // LKTOKEN  _@M198_ = "Confirm Exit?"
                MsgToken(198),
                TEXT("LK8000"), mbYesNo) == IdYes) {
            Shutdown();
        } else {
            RUN_MODE = RUN_WELCOME;
        }
    }


_exit:
    if (wf != NULL) {
        delete wf;
        wf = NULL;
    }

    StartBitmap.Release();
    ProfileBitmap.Release();


    if (RUN_MODE == RUN_FLY || RUN_MODE == RUN_SIM) {
        LKSound(_T("LK_SLIDE.WAV"));
        return 0; // do not repeat dialog
    }

    if (RUN_MODE == RUN_EXIT || RUN_MODE == RUN_SHUTDOWN)
        return -1; // terminate
    else
        return 1; // repeat dialog

}