int reset_test(void) { int test_item, ret_val ; test_item = InsertTestItem("RESET test", NULL, NULL, NULL, NULL); ret_val = ConfirmMessage ("RESET test", "Press the RESET button. Did the three LEDs flash?"); if (ret_val == YES) UpdateTestItem(test_item, "RESET test", NULL, NULL, NULL, "PASS") ; else UpdateTestItem(test_item, "RESET test", NULL, NULL, NULL, "FAIL"); return SUCCESS ; }
int main_on_sig_test(void) { int ret_val ; int test_item ; test_item = InsertTestItem("MAIN_ON Signal test", NULL, NULL, NULL, NULL); ret_val = ConfirmMessage ("MAIN_ON Signal test", "Press the POWER button and wait for at least 10 seconds. Are the LED OFF ?"); if (ret_val == YES) UpdateTestItem(test_item, "MAIN_ON Signal test", NULL, NULL, NULL, "PASS") ; else UpdateTestItem(test_item, "MAIN_ON Signal test", NULL, NULL, NULL, "FAIL"); return SUCCESS ; }
int pwr_btn_test(void) { int ret_val ; int test_item ; test_item = InsertTestItem("Pwr button test", NULL, NULL, NULL, NULL); ret_val = ConfirmMessage ("Pwr Button test", "Press the POWER button. Are the LED OFF ?"); if (ret_val == YES) UpdateTestItem(test_item, "Pwr Button test", NULL, NULL, NULL, "PASS") ; else UpdateTestItem(test_item, "Pwr Button test", NULL, NULL, NULL, "FAIL"); return SUCCESS ; }
void RunScript(FILE * script, const char * path) { ErrFunc_f old = InstallErrFunc(ScriptError, NULL); char * mem; int len, ok; char strbuf[1024]; strcpy(strbuf, path); strcat(strbuf, DIR_STR); MakeDirExist(strbuf); strcat(strbuf, "Installer Log.txt"); scriptLog = fopen(strbuf, "w"); if (scriptLog) fprintf(scriptLog, "Installing X-Plane to %s.\n", path); char from_buf[1024], to_buf[1024], partial[1024]; const char * app_path = GetApplicationPath(); if (app_path == NULL) { return; } bool condition = true; while (get_line(script, strbuf, sizeof(strbuf)-1)) { char * t; char * p = strbuf; t = next_token(&p); if (t == NULL) continue; if (!strcmp(t, "NOCONDITION")) { condition = true; } if (!strcmp(t, "ELSE")) { condition = !condition; } if (!strcmp(t, "MESSAGE")) { if (scriptLog) fprintf(scriptLog, "Note: %s\n", p); DoUserAlert(p); } if (!strcmp(t, "CONDITION")) { if (scriptLog) fprintf(scriptLog, "Checking: %s\n", p); condition = ConfirmMessage(p, "Yes", "No"); if (scriptLog) fprintf(scriptLog, "Answer: %s\n", condition ? "yes" : "no"); } if (!strcmp(t, "UPDATE")) { if (scriptLog) fprintf(scriptLog, "Running update.\n"); if (condition) RunInstaller(path); } if (!strcmp(t, "COPY")) { t = next_token(&p); float indi = -1.0; sprintf(msgBuf, "Installing %s...", t); ShowProgressMessage(msgBuf, &indi); strcpy(from_buf, app_path); strip_to_delim(from_buf,DIR_CHAR); strcat(from_buf, t); strcpy(to_buf, path); strcat(to_buf, DIR_STR); strcat(to_buf, p); normalize_dir_chars(to_buf); normalize_dir_chars(from_buf); if (condition) { if (scriptLog) fprintf(scriptLog, "Copying %s to %s\n", from_buf, to_buf); ok = FileToBlock(from_buf, &mem, &len); if (!ok) return; ok = BlockToFile(to_buf, mem); if (!ok) return; free(mem); } else { if (scriptLog) fprintf(scriptLog, "Not copying %s to %s\n", from_buf, to_buf); } } if (!strcmp(t, "UNZIP")) { t = next_token(&p); sprintf(msgBuf, "Installing %s...", t); strcpy(from_buf, app_path); strip_to_delim(from_buf,DIR_CHAR); strcat(from_buf, t); if (!strcmp(p, "/")) { strcpy(partial, path); strcat(partial, DIR_STR); } else { strcpy(partial, path); strcat(partial, DIR_STR); strcat(partial, p); } normalize_dir_chars(partial); normalize_dir_chars(from_buf); if (condition) { if (scriptLog) fprintf(scriptLog, "Unzipping %s to %s\n", from_buf, partial); unzFile unz = unzOpen(from_buf); if (unz == NULL) { ReportError("Unable to open zip file.", EUNKNOWN, from_buf); return; } unz_global_info global; unzGetGlobalInfo(unz, &global); unzGoToFirstFile(unz); int counter = 0; do { char zip_path[1024]; unz_file_info info; unzGetCurrentFileInfo(unz, &info, zip_path, sizeof(zip_path), NULL, 0, NULL, 0); sprintf(msgBuf, "Installing %s...", zip_path); float prog = (global.number_entry > 0) ? ((float) counter / (float) global.number_entry) : -1.0; ShowProgressMessage(msgBuf, &prog); ++counter; strcpy(to_buf, partial); strcat(to_buf, zip_path); normalize_dir_chars(to_buf); strip_to_delim(to_buf, DIR_CHAR); MakeDirExist(to_buf); if (info.uncompressed_size == 0) continue; char * mem = (char *) malloc(info.uncompressed_size); if (!mem) { ReportError("Out of memory", ENOMEM, NULL); return; } unzOpenCurrentFile(unz); int result = unzReadCurrentFile(unz,mem, info.uncompressed_size); if (result != info.uncompressed_size) { ReportError("Could not read installer archive.", EUNKNOWN, zip_path); } unzCloseCurrentFile(unz); strcpy(to_buf, partial); strcat(to_buf, zip_path); normalize_dir_chars(to_buf); FILE * fi = fopen(to_buf, "wb"); if (fi == NULL) { ReportError("Could not create file", errno, to_buf); return; } result = fwrite(mem, 1, info.uncompressed_size, fi); if (result != info.uncompressed_size) { ReportError("Could not read installer archive.", errno, to_buf); } fclose(fi); free(mem); } while(unzGoToNextFile(unz) == UNZ_OK); unzClose(unz); } else { if (scriptLog) fprintf(scriptLog, "Not unzipping %s to %s\n", from_buf, partial); } } } InstallErrFunc(old, NULL); if (scriptLog) fprintf(scriptLog, "Installer completed successfully.\n"); if (scriptLog) fclose(scriptLog); DoUserAlert("Installation was successful!"); }
int post(int run) { int ret_val; int test_item, index; int byte_in_queue ; // old: int byte_in_queue ; char portname[6]; //char hwID_limit[5] = {" "} ; char pos_capture[3000]; //char char_read ; double begin, end ; float testtime ; FillBytes(portname, 0, 5, 32) ; portname[5] = '\0' ; sprintf(portname,"COM%d",g_dev_serial_port) ; //test_item = InsertTestItem("RESET test", NULL, NULL, NULL, NULL); ret_val = ConfirmMessage ("Turn unit back on", "Press the Power button and the Reset button. Did the three LEDs flash?"); /******************************************************************************** if (ret_val == YES) UpdateTestItem(test_item, "RESET test", NULL, NULL, NULL, "PASS") ; else UpdateTestItem(test_item, "RESET test", NULL, NULL, NULL, "FAIL"); ****************************************************************************/ Delay(1.0) ; //test_item = InsertTestItem("Power On Self Test",NULL,NULL,NULL,NULL); begin = Timer() ; FillBytes(pos_capture, 0, 2999, 32); pos_capture[2999] = '\0' ; test_item = InsertTestItem("Opening device port",NULL,NULL,NULL,NULL); ret_val = OpenComConfig (g_dev_serial_port, portname, 115200, 0, 8, 1, 512, 512); if (ret_val < 0) { UpdateTestItem(test_item, "Opening UUT port", "ERROR", NULL, NULL, "FAIL") ; return FAILURE ; } else UpdateTestItem(test_item, "Opening UUT port", NULL, NULL, NULL, "PASS") ; if (!run) { ComWrtByte (1, 'n'); } else { ComWrtByte (1, 'Y'); test_item = InsertTestItem("Power On Self Test",NULL,NULL,NULL,NULL); SetComTime(g_dev_serial_port, 5.0) ; FlushInQ(g_dev_serial_port) ; FlushOutQ(g_dev_serial_port) ; //ComRd(g_dev_serial_port, pos_capture, 3000) ; for (index = 0; index < 2999; index++) { byte_in_queue = ComRdByte(g_dev_serial_port) ; if (byte_in_queue < 0) break ; // no more byte to read if ( (byte_in_queue == CR) || (byte_in_queue == LF) ) pos_capture[index] = 32 ; else pos_capture[index] = (char) byte_in_queue; } // for all chars in COM buffer index = FindPattern(pos_capture, 0, -1, "failed", 0, 0) ; if (index > 0) { //test_item = InsertTestItem("Power On Self Test",NULL,NULL,NULL,"FAILED"); UpdateTestItem(test_item,NULL,NULL,NULL,NULL,"FAIL"); return FAILURE ; } else //test_item = InsertTestItem("Power On Self Test",NULL,NULL,NULL,"PASS"); UpdateTestItem(test_item,NULL,NULL,NULL,NULL,"PASS"); } // else, perform post test return SUCCESS ; }
int APIENTRY wWinMain(HINSTANCE, HINSTANCE, LPWSTR, int) { #else // _DEBUG void APIENTRY _myWinMain() { #endif // _DEBUG g_hinstExe = GetModuleHandle(NULL); int nExitCode = 1; //HANDLE hmtx = NULL; __try { ParseCommandLine(); if (!CheckVersion() && !(g_dwCmdLine & CCLF_NOCHECKVER)) { MessageBoxA(NULL, "This program requires features present in Windows XP/2003.", "Error", MB_OK | MB_ICONERROR | MB_TOPMOST | MB_SETFOREGROUND); __leave; } /*hmtx = CreateMutex(NULL, FALSE, g_szTaskSwitch); if (GetLastError() == ERROR_ALREADY_EXISTS) { ReportError(IDS_ERR_EXISTS); __leave; }*/ InitThreadLang2(); InitLanguage(); HWND hwndTs = FindWindowEx(NULL/*HWND_MESSAGE*/, NULL, g_szMainWnd, g_szWindowName); if (IsWindow(hwndTs)) { if (g_dwCmdLine != 0) { SetForegroundWindow(hwndTs); PostMessage(hwndTs, WM_REMOTECMD, g_dwCmdLine, 0); } else { if (ConfirmMessage(IDS_CONFIRM_RUNNING, MB_ICONEXCLAMATION | MB_DEFBUTTON2)) PostMessage(hwndTs, WM_DESTROY, 0, 0); //PostMessage(hwndTs, WM_RELOADSETTINGS, 0, 0); } __leave; } HINSTANCE hinstUser32 = LoadLibrary(L"user32.dll"); g_pfnIsHungAppWindow = (ISHUNGAPPWINDOW)GetProcAddress(hinstUser32, "IsHungAppWindow"); //g_pfnEndTask = (ENDTASK)GetProcAddress(hinstUser32, "EndTask"); WNDCLASSEX wcex; wcex.cbSize = sizeof(WNDCLASSEX); wcex.style = 0; wcex.lpfnWndProc = (WNDPROC)MainWndProc; wcex.cbClsExtra = 0; wcex.cbWndExtra = 0; wcex.hInstance = g_hinstExe; wcex.hIcon = NULL; wcex.hCursor = NULL; wcex.hbrBackground = NULL; wcex.lpszMenuName = NULL; wcex.lpszClassName = g_szMainWnd; wcex.hIconSm = NULL; if (!RegisterClassEx(&wcex)) __leave; if (!CreateWindowEx(WS_EX_TOOLWINDOW, g_szMainWnd, g_szWindowName, 0, 0, 0, 0, 0, NULL/*HWND_MESSAGE*/, NULL, g_hinstExe, NULL)) __leave; MSG msg; while (GetMessage(&msg, NULL, 0, 0)) { TranslateMessage(&msg); DispatchMessage(&msg); } nExitCode = (int)msg.wParam; } __finally { DestroyThreadLang2(); //if (hmtx) CloseHandle(hmtx); } #ifdef _DEBUG return(nExitCode); #else // _DEBUG ExitProcess((UINT)nExitCode); #endif }
LRESULT CALLBACK MainWndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { static BOOL s_fConfirmActive = FALSE; static UINT s_uTaskbarCreated = 0; switch (uMsg) { case WM_HOTKEY: { switch (wParam) { case IDH_NEXTTASK: case IDH_PREVTASK: case IDH_WINNEXTTASK: case IDH_WINPREVTASK: case IDH_INSTNEXT: case IDH_INSTPREV: case IDH_STNEXTTASK: case IDH_STINEXTTASK: ShowTaskSwitchWnd((UINT)wParam); break; case IDH_MINIMIZETRAY: FlipToTray(GetForegroundWindow()); break; case IDH_RESTORETRAY: if (g_cWti > 0) _UnflipFromTray(g_cWti - 1); break; case IDH_SHOWHIDE: ShowTrayIcon(!(g_dwFlags & TSF_SHOWTRAYICON)); break; case IDH_CONFIG: ConfigTaskSwitchXP(); break; case IDH_ALTAPPLIST: //MessageBox (0, L"This must display alternative task switching window\r\n" // L"(or the same window but in alternative mode)", L"klvov says:", MB_OK); //ShowAltTSWindow(); //OutputDebugString(L"IDH_ALTAPPLIST message received\n"); ShowTaskSwitchWnd((UINT)wParam); break; case IDH_EXIT: if (!(g_dwFlags & TSF_NOCONFIRMEXIT)) { if (s_fConfirmActive) { // activate confirm dialog #pragma FIX_LATER(multiple exit confirmations) break; /*HWND hwndMsg = FindWindowEx(NULL, NULL, L"#32770", L"TaskSwitchXP confirmation"); if (hwndMsg) { SetForegroundWindow(hwndMsg); break; }*/ } s_fConfirmActive = TRUE; if (ConfirmMessage(IDS_CONFIRM_EXIT)) DestroyWindow(hwnd); s_fConfirmActive = FALSE; } else DestroyWindow(hwnd); break; } break; } case WM_TIMER: if (wParam == TIMER_RIGHTUP) { KillTimer(hwnd, TIMER_RIGHTUP); mouse_event(MOUSEEVENTF_ABSOLUTE | MOUSEEVENTF_RIGHTUP, _ptRClick.x, _ptRClick.y, _dwRData, _dwRExtraInfo); } else if (wParam == TIMER_SETANIMATION) { KillTimer(hwnd, TIMER_SETANIMATION); ANIMATIONINFO ai; ai.cbSize = sizeof(ANIMATIONINFO); ai.iMinAnimate = TRUE; SystemParametersInfo(SPI_SETANIMATION, sizeof(ANIMATIONINFO), &ai, FALSE); } else if (wParam == TIMER_CHECKTRAYWND) { for (UINT i = 0; i < g_cWti; i++) { if (!IsWindow(g_pWti[i].hwnd) || IsWindowVisible(g_pWti[i].hwnd)) _UnflipFromTray(i, SC_MINIMIZE); } } else if (wParam == TIMER_RELOADICONS) { if (!(g_dwFlags & TSF_RELOADICONS)) KillTimer(hwnd, TIMER_RELOADICONS); ReloadTsTrayIcons(); } else if (wParam == TIMER_CHECKCOLORS) { KillTimer(hwnd, TIMER_CHECKCOLORS); if (CheckColorTheme()) CheckDefaultColors(); } else if (wParam == TIMER_CLOSEDESK) { if (WaitForSingleObject(g_hThreadTs, 0) == WAIT_OBJECT_0) { KillTimer(hwnd, TIMER_CLOSEDESK); //_RPT0(_CRT_WARN, "close desk\n"); if (g_hThreadTs) { CloseHandle(g_hThreadTs); g_hThreadTs = NULL; } if (g_hDesk) { CloseDesktop(g_hDesk); g_hDesk = NULL; } } } break; case WM_REMOTECMD: SwitchToThisWindow(hwnd, TRUE); if (wParam & CCLF_ESCAPE) { if (g_hwndTs) PostMessage(g_hwndTs, WM_TASKSWITCH, IDH_ESCAPE, 0); } else if (wParam & CCLF_STINEXTTASK) { ShowTaskSwitchWnd(IDH_STINEXTTASK); } else if (wParam & CCLF_STNEXTTASK) { ShowTaskSwitchWnd(IDH_STNEXTTASK); } break; case WM_MYTRAYMSG: if (wParam == IDI_TASKSWITCHXP) { if ((UINT)lParam == g_uTrayMenu) { ShowTrayMenu(); } else if ((UINT)lParam == g_uTrayConfig) { ConfigTaskSwitchXP(); } else if ((UINT)lParam == g_uTrayNext) { ShowTaskSwitchWnd(IDH_STTRAYNEXT); } else if ((UINT)lParam == g_uTrayPrev) { ShowTaskSwitchWnd(IDH_STITRAYNEXT); } } else { if (lParam == WM_LBUTTONUP) { UnflipFromTrayID((UINT)wParam); } else if (lParam == WM_RBUTTONUP) { ShowFlippedSystemMenu((UINT)wParam); } else if (lParam == WM_MBUTTONUP) UnflipFromTrayID((UINT)wParam, 0); } break; case WM_EXTMOUSE: if (wParam == HTMINBUTTON) { FlipToTray((HWND)lParam); } else if (wParam == HTMAXBUTTON) { HWND h = (HWND)lParam; DWORD dwExStyle = GetWindowLongPtr(h, GWL_EXSTYLE); SetWindowPos(h, ((dwExStyle & WS_EX_TOPMOST) ? HWND_NOTOPMOST : HWND_TOPMOST), 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE); } break; case WM_FLIPTOTRAY: return(FlipToTray((HWND)wParam)); //break; case WM_UNFLIPFROMTRAY: UnflipFromTray((HWND)wParam, (UINT)lParam); break; case WM_GETTRAYWINDOWS: if (wParam) { HWND *phWnd = (HWND*)wParam; int cWti = 0; while (cWti < MIN((int)lParam, (int)g_cWti)) { phWnd[cWti] = g_pWti[cWti].hwnd; cWti++; } return(cWti); } else return(g_cWti); break; case WM_RELOADSETTINGS: if (!LoadSettings()) { ReportError(IDS_ERR_LOADSETTINGS); DestroyWindow(hwnd); } break; case WM_THEMECHANGED: if (CheckColorTheme()) CheckDefaultColors(); SetTimer(hwnd, TIMER_CHECKCOLORS, 1000, NULL); break; case WM_CREATE: { s_uTaskbarCreated = RegisterWindowMessage(L"TaskbarCreated"); g_hwndMain = hwnd; SendMessage(hwnd, WM_SETICON, ICON_BIG, (LONG)(LONG_PTR)LoadImage(g_hinstExe, MAKEINTRESOURCE(IDI_TASKSWITCHXP), IMAGE_ICON, GetSystemMetrics(SM_CXICON), GetSystemMetrics(SM_CYICON), LR_DEFAULTCOLOR)); SendMessage(hwnd, WM_SETICON, ICON_SMALL, (LONG)(LONG_PTR)LoadImage(g_hinstExe, MAKEINTRESOURCE(IDI_TASKSWITCHXP), IMAGE_ICON, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), LR_DEFAULTCOLOR)); if (!LoadSettings()) { ReportError(IDS_ERR_LOADSETTINGS); return(-1); } if (!InitPreviewThread()) return(-1); // Weird huh? I cannot understand this... if (g_dwShowDelay && g_dwFlagsPv & TSFPV_DESKTOP && g_dwFlagsPv & TSFPV_TASKBAR) { RECT rcPvEx; rcPvEx.left = rcPvEx.top = 0; rcPvEx.right = 102; rcPvEx.bottom = 76; HDC hdcScreen = GetDC(NULL); HDC hdcMem = CreateCompatibleDC(hdcScreen); HBITMAP hbitmapMem = CreateCompatibleBitmap(hdcScreen, rcPvEx.right - rcPvEx.left, rcPvEx.bottom - rcPvEx.top); ReleaseDC(NULL, hdcScreen); if (hbitmapMem) { HBITMAP hbitmapOld = (HBITMAP)SelectObject(hdcMem, hbitmapMem); SetForegroundWindow(g_hwndMain); MyPrintWindow(FindWindow(L"Shell_TrayWnd", L""), hdcMem, &rcPvEx, &rcPvEx, MPW_NOCHECKPOS); SelectObject(hdcMem, hbitmapOld); DeleteObject(hbitmapMem); } DeleteDC(hdcMem); } SetTimer(hwnd, TIMER_CHECKTRAYWND, 1000, NULL); if (g_dwCmdLine & CCLF_STINEXTTASK) { ShowTaskSwitchWnd(IDH_STINEXTTASK); } else if (g_dwCmdLine & CCLF_STNEXTTASK) { ShowTaskSwitchWnd(IDH_STNEXTTASK); } break; } case WM_CLOSE: break; case WM_DESTROY: KillTimer(hwnd, TIMER_CHECKTRAYWND); DestroySettings(); DestroyPreviewThread(); for (int i = (int)g_cWti - 1; i >= 0; i--) _UnflipFromTray((UINT)i, 0); PostQuitMessage(0); break; default: if (uMsg == s_uTaskbarCreated) { ReloadTsTrayIcons(); } else return(DefWindowProc(hwnd, uMsg, wParam, lParam)); break; } return(0); }