void ServerStart(HWND hWnd, HWND hCaller, UINT uMsg) { wchar_t qemu[256]; wchar_t path[256]; wchar_t hdb[256], hdc[256], hdd[256]; wchar_t net_name[256]; wchar_t qemu_args[2048]; STARTUPINFO si; HANDLE hStatusThread; memset(&si, 0, sizeof(STARTUPINFO)); ConfigGetString(L"qemu", qemu); ConfigGetString(L"path", path); if(wcslen(qemu) == 0 || wcslen(path) == 0) return; UpdateDrives(NULL); UpdateInterfaces(NULL); ConfigGetString(L"hdb", hdb); ConfigGetString(L"hdc", hdc); ConfigGetString(L"hdd", hdd); ConfigGetString(L"net_name", net_name); if(wcslen(net_name) == 0) { MessageBox(NULL, GetString(IDS_ERROR_NONET), GetString(IDS_CAPTION), MB_ICONEXCLAMATION | MB_OK); return; } if(wcslen(hdb) == 0 && wcslen(hdc) == 0 && wcslen(hdd) == 0) { MessageBox(NULL, GetString(IDS_ERROR_NODRIVE), GetString(IDS_CAPTION), MB_ICONEXCLAMATION | MB_OK); return; } wsprintf(qemu_args, L"\"%s\" -L . -m %d -net nic,model=%s -net tap,ifname=\"%s\" -hda %s", qemu, QEMU_MEM, QEMU_NIC, net_name, QEMU_SERVERIMG); if(wcslen(hdb) > 0) wsprintf(qemu_args, L"%s -hdb %s", qemu_args, hdb); if(wcslen(hdc) > 0) wsprintf(qemu_args, L"%s -hdc %s", qemu_args, hdc); if(wcslen(hdd) > 0) wsprintf(qemu_args, L"%s -hdd %s", qemu_args, hdd); wcscat_s(qemu_args, 2048, QEMU_ARGS); GetStartupInfo(&si); si.dwFlags = STARTF_USESHOWWINDOW; si.wShowWindow = SW_HIDE; if(!CreateProcess(qemu, qemu_args, NULL, NULL, FALSE, 0, NULL, path, &si, &gServer)) { MessageBox(NULL, GetString(IDS_ERROR_START), GetString(IDS_CAPTION), MB_ICONSTOP | MB_OK); return; } hStatusThread = CreateThread(NULL, 0, StatusThread, (LPVOID)hWnd, 0, NULL); CloseHandle(hStatusThread); }
void ShowSetupDialog(HWND hWnd, HWND hCaller, UINT uMsg) { wchar_t serverIP[256]; wchar_t checkAutoStart[256]; wchar_t checkWrite[256]; RECT desktopRect, dialogRect; POINT showPos; if(gSetupShown) { ShowWindow(hWnd, SW_HIDE); gSetupShown = FALSE; return; } UpdateDrives(hWnd); UpdateInterfaces(hWnd); SetDlgItemText(hWnd, IDC_STATUS, TranslateServerStatus()); wcscpy_s(serverIP, 256, GetString(IDS_SERVER_ETH0)); wcscat_s(serverIP, 256, QEMU_IP); SetDlgItemText(hWnd, IDC_ETH0, serverIP); ConfigGetString(L"autostart", checkAutoStart); ConfigGetString(L"rw", checkWrite); if(wcscmp(checkAutoStart, L"yes") == 0) SendMessage(GetDlgItem(hWnd, IDC_AUTOSERVER), BM_SETCHECK, (WPARAM)BST_CHECKED, 0); else SendMessage(GetDlgItem(hWnd, IDC_AUTOSERVER), BM_SETCHECK, (WPARAM)BST_UNCHECKED, 0); if(wcscmp(checkWrite, L"yes") == 0) SendMessage(GetDlgItem(hWnd, IDC_MOUNTRW), BM_SETCHECK, (WPARAM)BST_CHECKED, 0); else SendMessage(GetDlgItem(hWnd, IDC_MOUNTRW), BM_SETCHECK, (WPARAM)BST_UNCHECKED, 0); if(ConfigStartupQuery(GetString(IDS_NAME))) SendMessage(GetDlgItem(hWnd, IDC_AUTOSTART), BM_SETCHECK, (WPARAM)BST_CHECKED, 0); else SendMessage(GetDlgItem(hWnd, IDC_AUTOSTART), BM_SETCHECK, (WPARAM)BST_UNCHECKED, 0); GetClientRect(GetDesktopWindow(), &desktopRect); GetWindowRect(hWnd, &dialogRect); showPos.x = (desktopRect.right - (dialogRect.right - dialogRect.left)) / 2; showPos.y = (desktopRect.bottom - (dialogRect.bottom - dialogRect.top)) / 2; SetWindowPos(hWnd, HWND_TOPMOST, showPos.x, showPos.y, 0, 0, SWP_NOSIZE | SWP_SHOWWINDOW); gSetupShown = TRUE; }
void CaptureInterfacesDialog::updateLocalInterfaces() { UpdateInterfaces(); }
void CaptureInterfacesDialog::refreshInterfaceList() { UpdateInterfaces(); emit interfaceListChanged(); }