X-Git-Url: http://git.iain.cx/?a=blobdiff_plain;ds=sidebyside;f=gui.cpp;h=a69bf3baeda5c6307621c13024fb4804f5e825b2;hb=0dfa0fdb3a851b1ff69a0f0b308a3e1371286a57;hp=ce4d6bf1c129c05973b78a940688b849686a689d;hpb=14d5a10605085a499136744b66936c75b6f0ccd4;p=nssm.git diff --git a/gui.cpp b/gui.cpp index ce4d6bf..a69bf3b 100644 --- a/gui.cpp +++ b/gui.cpp @@ -1,6 +1,6 @@ #include "nssm.h" -static enum { NSSM_TAB_APPLICATION, NSSM_TAB_DETAILS, NSSM_TAB_LOGON, NSSM_TAB_PROCESS, NSSM_TAB_SHUTDOWN, NSSM_TAB_EXIT, NSSM_TAB_IO, NSSM_TAB_ROTATION, NSSM_TAB_ENVIRONMENT, NSSM_NUM_TABS }; +static enum { NSSM_TAB_APPLICATION, NSSM_TAB_DETAILS, NSSM_TAB_LOGON, NSSM_TAB_DEPENDENCIES, NSSM_TAB_PROCESS, NSSM_TAB_SHUTDOWN, NSSM_TAB_EXIT, NSSM_TAB_IO, NSSM_TAB_ROTATION, NSSM_TAB_ENVIRONMENT, NSSM_NUM_TABS }; static HWND tablist[NSSM_NUM_TABS]; static int selected_tab; @@ -95,6 +95,19 @@ int nssm_gui(int resource, nssm_service_t *service) { if (service->type & SERVICE_INTERACTIVE_PROCESS) SendDlgItemMessage(tablist[NSSM_TAB_LOGON], IDC_INTERACT, BM_SETCHECK, BST_CHECKED, 0); } + /* Dependencies tab. */ + if (service->dependencieslen) { + TCHAR *formatted; + unsigned long newlen; + if (format_double_null(service->dependencies, service->dependencieslen, &formatted, &newlen)) { + popup_message(dlg, MB_OK | MB_ICONEXCLAMATION, NSSM_EVENT_OUT_OF_MEMORY, _T("dependencies"), _T("nssm_dlg()")); + } + else { + SetDlgItemText(tablist[NSSM_TAB_DEPENDENCIES], IDC_DEPENDENCIES, formatted); + HeapFree(GetProcessHeap(), 0, formatted); + } + } + /* Process tab. */ if (service->priority) { int priority = priority_constant_to_index(service->priority); @@ -471,6 +484,33 @@ int configure(HWND window, nssm_service_t *service, nssm_service_t *orig_service } } + /* Get dependencies. */ + unsigned long dependencieslen = (unsigned long) SendMessage(GetDlgItem(tablist[NSSM_TAB_DEPENDENCIES], IDC_DEPENDENCIES), WM_GETTEXTLENGTH, 0, 0); + if (dependencieslen) { + TCHAR *dependencies = (TCHAR *) HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, (dependencieslen + 2) * sizeof(TCHAR)); + if (! dependencies) { + popup_message(window, MB_OK | MB_ICONEXCLAMATION, NSSM_EVENT_OUT_OF_MEMORY, _T("dependencies"), _T("install()")); + cleanup_nssm_service(service); + return 6; + } + + if (! GetDlgItemText(tablist[NSSM_TAB_DEPENDENCIES], IDC_DEPENDENCIES, dependencies, dependencieslen + 1)) { + popup_message(window, MB_OK | MB_ICONEXCLAMATION, NSSM_GUI_INVALID_DEPENDENCIES); + HeapFree(GetProcessHeap(), 0, dependencies); + cleanup_nssm_service(service); + return 6; + } + + if (unformat_double_null(dependencies, dependencieslen, &service->dependencies, &service->dependencieslen)) { + HeapFree(GetProcessHeap(), 0, dependencies); + popup_message(window, MB_OK | MB_ICONEXCLAMATION, NSSM_EVENT_OUT_OF_MEMORY, _T("dependencies"), _T("install()")); + cleanup_nssm_service(service); + return 6; + } + + HeapFree(GetProcessHeap(), 0, dependencies); + } + /* Remaining tabs are only for services we manage. */ if (service->native) return 0; @@ -955,6 +995,13 @@ INT_PTR CALLBACK nssm_dlg(HWND window, UINT message, WPARAM w, LPARAM l) { CheckRadioButton(tablist[NSSM_TAB_LOGON], IDC_LOCALSYSTEM, IDC_ACCOUNT, IDC_LOCALSYSTEM); set_logon_enabled(0); + /* Dependencies tab. */ + tab.pszText = message_string(NSSM_GUI_TAB_DEPENDENCIES); + tab.cchTextMax = (int) _tcslen(tab.pszText); + SendMessage(tabs, TCM_INSERTITEM, NSSM_TAB_DEPENDENCIES, (LPARAM) &tab); + tablist[NSSM_TAB_DEPENDENCIES] = dialog(MAKEINTRESOURCE(IDD_DEPENDENCIES), window, tab_dlg); + ShowWindow(tablist[NSSM_TAB_DEPENDENCIES], SW_HIDE); + /* Remaining tabs are only for services we manage. */ if (service->native) return 1;