mirror of
https://github.com/reactos/reactos.git
synced 2024-07-29 23:58:44 +00:00
[SERVMAN]
- Fully implement stopping all dependent services - When stopping a service, only list other running services which require stopping - Use the same progress dialog for stopping multiple services and make it smoother svn path=/trunk/; revision=44961
This commit is contained in:
parent
ef88ea7724
commit
d5bc8625fb
|
@ -121,10 +121,11 @@ BOOL DoPause(PMAIN_WND_INFO Info)
|
||||||
HWND hProgDlg;
|
HWND hProgDlg;
|
||||||
|
|
||||||
hProgDlg = CreateProgressDialog(Info->hMainWnd,
|
hProgDlg = CreateProgressDialog(Info->hMainWnd,
|
||||||
Info->pCurrentService->lpServiceName,
|
|
||||||
IDS_PROGRESS_INFO_PAUSE);
|
IDS_PROGRESS_INFO_PAUSE);
|
||||||
if (hProgDlg)
|
if (hProgDlg)
|
||||||
{
|
{
|
||||||
|
InitializeProgressDialog(hProgDlg, Info->pCurrentService->lpServiceName);
|
||||||
|
|
||||||
ret = Control(Info,
|
ret = Control(Info,
|
||||||
hProgDlg,
|
hProgDlg,
|
||||||
SERVICE_CONTROL_PAUSE);
|
SERVICE_CONTROL_PAUSE);
|
||||||
|
@ -142,10 +143,11 @@ BOOL DoResume(PMAIN_WND_INFO Info)
|
||||||
HWND hProgDlg;
|
HWND hProgDlg;
|
||||||
|
|
||||||
hProgDlg = CreateProgressDialog(Info->hMainWnd,
|
hProgDlg = CreateProgressDialog(Info->hMainWnd,
|
||||||
Info->pCurrentService->lpServiceName,
|
|
||||||
IDS_PROGRESS_INFO_RESUME);
|
IDS_PROGRESS_INFO_RESUME);
|
||||||
if (hProgDlg)
|
if (hProgDlg)
|
||||||
{
|
{
|
||||||
|
InitializeProgressDialog(hProgDlg, Info->pCurrentService->lpServiceName);
|
||||||
|
|
||||||
ret = Control(Info,
|
ret = Control(Info,
|
||||||
hProgDlg,
|
hProgDlg,
|
||||||
SERVICE_CONTROL_CONTINUE);
|
SERVICE_CONTROL_CONTINUE);
|
||||||
|
|
|
@ -97,8 +97,9 @@ BOOL DoResume(PMAIN_WND_INFO Info);
|
||||||
|
|
||||||
/* progress.c */
|
/* progress.c */
|
||||||
#define DEFAULT_STEP 0
|
#define DEFAULT_STEP 0
|
||||||
HWND CreateProgressDialog(HWND hParent, LPTSTR lpServiceName, UINT LabelId);
|
HWND CreateProgressDialog(HWND hParent, UINT LabelId);
|
||||||
BOOL DestroyProgressDialog(HWND hProgDlg, BOOL bComplete);
|
BOOL DestroyProgressDialog(HWND hProgDlg, BOOL bComplete);
|
||||||
|
VOID InitializeProgressDialog(HWND hProgDlg, LPWSTR lpServiceName);
|
||||||
VOID IncrementProgressBar(HWND hProgDlg, UINT NewPos);
|
VOID IncrementProgressBar(HWND hProgDlg, UINT NewPos);
|
||||||
VOID CompleteProgressBar(HWND hProgDlg);
|
VOID CompleteProgressBar(HWND hProgDlg);
|
||||||
|
|
||||||
|
|
|
@ -75,6 +75,25 @@ IncrementProgressBar(HWND hProgDlg,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
VOID
|
||||||
|
InitializeProgressDialog(HWND hProgDlg,
|
||||||
|
LPWSTR lpServiceName)
|
||||||
|
{
|
||||||
|
/* Write the service name to the dialog */
|
||||||
|
SendDlgItemMessageW(hProgDlg,
|
||||||
|
IDC_SERVCON_NAME,
|
||||||
|
WM_SETTEXT,
|
||||||
|
0,
|
||||||
|
(LPARAM)lpServiceName);
|
||||||
|
|
||||||
|
/* Set the progress bar to the start */
|
||||||
|
SendDlgItemMessageW(hProgDlg,
|
||||||
|
IDC_SERVCON_PROGRESS,
|
||||||
|
PBM_SETPOS,
|
||||||
|
0,
|
||||||
|
0);
|
||||||
|
}
|
||||||
|
|
||||||
INT_PTR CALLBACK
|
INT_PTR CALLBACK
|
||||||
ProgressDialogProc(HWND hDlg,
|
ProgressDialogProc(HWND hDlg,
|
||||||
UINT Message,
|
UINT Message,
|
||||||
|
@ -124,7 +143,6 @@ ProgressDialogProc(HWND hDlg,
|
||||||
|
|
||||||
HWND
|
HWND
|
||||||
CreateProgressDialog(HWND hParent,
|
CreateProgressDialog(HWND hParent,
|
||||||
LPTSTR lpServiceName,
|
|
||||||
UINT LabelId)
|
UINT LabelId)
|
||||||
{
|
{
|
||||||
HWND hProgDlg;
|
HWND hProgDlg;
|
||||||
|
@ -153,13 +171,6 @@ CreateProgressDialog(HWND hParent,
|
||||||
0,
|
0,
|
||||||
lpProgStr);
|
lpProgStr);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Write the service name to the dialog */
|
|
||||||
SendDlgItemMessageW(hProgDlg,
|
|
||||||
IDC_SERVCON_NAME,
|
|
||||||
WM_SETTEXT,
|
|
||||||
0,
|
|
||||||
(LPARAM)lpServiceName);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return hProgDlg;
|
return hProgDlg;
|
||||||
|
|
|
@ -116,12 +116,11 @@ DoStart(PMAIN_WND_INFO Info)
|
||||||
BOOL bRet = FALSE;
|
BOOL bRet = FALSE;
|
||||||
|
|
||||||
hProgDlg = CreateProgressDialog(Info->hMainWnd,
|
hProgDlg = CreateProgressDialog(Info->hMainWnd,
|
||||||
Info->pCurrentService->lpServiceName,
|
|
||||||
IDS_PROGRESS_INFO_START);
|
IDS_PROGRESS_INFO_START);
|
||||||
|
|
||||||
if (hProgDlg)
|
if (hProgDlg)
|
||||||
{
|
{
|
||||||
IncrementProgressBar(hProgDlg, DEFAULT_STEP);
|
InitializeProgressDialog(hProgDlg, Info->pCurrentService->lpServiceName);
|
||||||
|
|
||||||
bRet = DoStartService(Info,
|
bRet = DoStartService(Info,
|
||||||
hProgDlg);
|
hProgDlg);
|
||||||
|
|
|
@ -25,8 +25,8 @@ StopService(PMAIN_WND_INFO pInfo,
|
||||||
|
|
||||||
if (hProgress)
|
if (hProgress)
|
||||||
{
|
{
|
||||||
/* Increment the progress bar */
|
/* Set the service name and reset the progress bag */
|
||||||
IncrementProgressBar(hProgress, DEFAULT_STEP);
|
InitializeProgressDialog(hProgress, lpServiceName);
|
||||||
}
|
}
|
||||||
|
|
||||||
hSCManager = OpenSCManager(NULL,
|
hSCManager = OpenSCManager(NULL,
|
||||||
|
@ -62,6 +62,10 @@ StopService(PMAIN_WND_INFO pInfo,
|
||||||
|
|
||||||
while (ServiceStatus.dwCurrentState != SERVICE_STOPPED)
|
while (ServiceStatus.dwCurrentState != SERVICE_STOPPED)
|
||||||
{
|
{
|
||||||
|
/* Don't sleep for more than 3 seconds */
|
||||||
|
if (ServiceStatus.dwWaitHint > 3000)
|
||||||
|
ServiceStatus.dwWaitHint = 3000;
|
||||||
|
|
||||||
Sleep(ServiceStatus.dwWaitHint);
|
Sleep(ServiceStatus.dwWaitHint);
|
||||||
|
|
||||||
if (hProgress)
|
if (hProgress)
|
||||||
|
@ -103,11 +107,41 @@ StopService(PMAIN_WND_INFO pInfo,
|
||||||
|
|
||||||
static BOOL
|
static BOOL
|
||||||
StopDependantServices(PMAIN_WND_INFO pInfo,
|
StopDependantServices(PMAIN_WND_INFO pInfo,
|
||||||
LPWSTR lpServiceName)
|
LPWSTR lpServiceList,
|
||||||
|
HWND hProgress OPTIONAL)
|
||||||
{
|
{
|
||||||
|
LPWSTR lpStr;
|
||||||
BOOL bRet = FALSE;
|
BOOL bRet = FALSE;
|
||||||
|
|
||||||
MessageBox(NULL, L"Rewrite StopDependentServices", NULL, 0);
|
lpStr = lpServiceList;
|
||||||
|
|
||||||
|
/* Loop through all the services in the list */
|
||||||
|
while (TRUE)
|
||||||
|
{
|
||||||
|
/* Break when we hit the double null */
|
||||||
|
if (*lpStr == L'\0' && *(lpStr + 1) == L'\0')
|
||||||
|
break;
|
||||||
|
|
||||||
|
/* If this isn't our first time in the loop we'll
|
||||||
|
have been left on a null char */
|
||||||
|
if (*lpStr == L'\0')
|
||||||
|
lpStr++;
|
||||||
|
|
||||||
|
/* Stop the requested service */
|
||||||
|
bRet = StopService(pInfo,
|
||||||
|
lpStr,
|
||||||
|
hProgress);
|
||||||
|
|
||||||
|
/* Complete the progress bar if we succeeded */
|
||||||
|
if (bRet)
|
||||||
|
{
|
||||||
|
CompleteProgressBar(hProgress);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Move onto the next string */
|
||||||
|
while (*lpStr != L'\0')
|
||||||
|
lpStr++;
|
||||||
|
}
|
||||||
|
|
||||||
return bRet;
|
return bRet;
|
||||||
}
|
}
|
||||||
|
@ -119,43 +153,57 @@ DoStop(PMAIN_WND_INFO pInfo)
|
||||||
HWND hProgress;
|
HWND hProgress;
|
||||||
LPWSTR lpServiceList;
|
LPWSTR lpServiceList;
|
||||||
BOOL bRet = FALSE;
|
BOOL bRet = FALSE;
|
||||||
BOOL bStop = TRUE;
|
BOOL bStopMainService = TRUE;
|
||||||
|
|
||||||
if (pInfo)
|
if (pInfo)
|
||||||
{
|
{
|
||||||
/* Does this service have anything which depends on it? */
|
/* Does the service have any dependent services which need stopping first */
|
||||||
if (TV2_HasDependantServices(pInfo->pCurrentService->lpServiceName))
|
lpServiceList = GetListOfServicesToStop(pInfo->pCurrentService->lpServiceName);
|
||||||
|
if (lpServiceList)
|
||||||
{
|
{
|
||||||
/* It does, get a list of all the services which need stopping */
|
/* Tag the service list to the main wnd info */
|
||||||
lpServiceList = GetListOfServicesToStop(pInfo->pCurrentService->lpServiceName);
|
pInfo->pTag = (PVOID)lpServiceList;
|
||||||
if (lpServiceList)
|
|
||||||
{
|
|
||||||
/* Tag the service list to the main wnd info */
|
|
||||||
pInfo->pTag = (PVOID)lpServiceList;
|
|
||||||
|
|
||||||
/* List them and ask the user if they want to stop them */
|
/* List them and ask the user if they want to stop them */
|
||||||
if (DialogBoxParamW(hInstance,
|
if (DialogBoxParamW(hInstance,
|
||||||
MAKEINTRESOURCEW(IDD_DLG_DEPEND_STOP),
|
MAKEINTRESOURCEW(IDD_DLG_DEPEND_STOP),
|
||||||
pInfo->hMainWnd,
|
pInfo->hMainWnd,
|
||||||
StopDependsDialogProc,
|
StopDependsDialogProc,
|
||||||
(LPARAM)pInfo) == IDOK)
|
(LPARAM)pInfo) == IDOK)
|
||||||
|
{
|
||||||
|
/* Create a progress window to track the progress of the stopping services */
|
||||||
|
hProgress = CreateProgressDialog(pInfo->hMainWnd,
|
||||||
|
IDS_PROGRESS_INFO_STOP);
|
||||||
|
|
||||||
|
/* Stop all the dependant services */
|
||||||
|
StopDependantServices(pInfo, lpServiceList, hProgress);
|
||||||
|
|
||||||
|
/* Now stop the requested one */
|
||||||
|
bRet = StopService(pInfo,
|
||||||
|
pInfo->pCurrentService->lpServiceName,
|
||||||
|
hProgress);
|
||||||
|
|
||||||
|
/* We've already stopped the main service, don't try to stop it again */
|
||||||
|
bStopMainService = FALSE;
|
||||||
|
|
||||||
|
if (hProgress)
|
||||||
{
|
{
|
||||||
/* Stop all the dependant services */
|
/* Complete and destroy the progress bar */
|
||||||
StopDependantServices(pInfo, pInfo->pCurrentService->lpServiceName);
|
DestroyProgressDialog(hProgress, TRUE);
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
/* Don't stop the main service if the user selected not to */
|
|
||||||
bStop = FALSE;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* Don't stop the main service if the user selected not to */
|
||||||
|
bStopMainService = FALSE;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (bStop)
|
/* If the service has no running dependents, then we stop it here */
|
||||||
|
if (bStopMainService)
|
||||||
{
|
{
|
||||||
/* Create a progress window to track the progress of the stopping service */
|
/* Create a progress window to track the progress of the stopping service */
|
||||||
hProgress = CreateProgressDialog(pInfo->hMainWnd,
|
hProgress = CreateProgressDialog(pInfo->hMainWnd,
|
||||||
pInfo->pCurrentService->lpServiceName,
|
|
||||||
IDS_PROGRESS_INFO_STOP);
|
IDS_PROGRESS_INFO_STOP);
|
||||||
|
|
||||||
/* Stop the requested service */
|
/* Stop the requested service */
|
||||||
|
|
|
@ -95,19 +95,25 @@ BuildListOfServicesToStop(LPWSTR *lpServiceList,
|
||||||
{
|
{
|
||||||
for (i = 0; i < dwCount; i++)
|
for (i = 0; i < dwCount; i++)
|
||||||
{
|
{
|
||||||
/* Does this service have any dependents? */
|
/* Does this service need stopping? */
|
||||||
if (TV2_HasDependantServices(lpServiceStatus[i].lpServiceName))
|
if (lpServiceStatus[i].ServiceStatus.dwCurrentState != SERVICE_STOPPED &&
|
||||||
|
lpServiceStatus[i].ServiceStatus.dwCurrentState != SERVICE_STOP_PENDING)
|
||||||
{
|
{
|
||||||
/* recall this function with the dependent */
|
/* Does this service have any dependents? */
|
||||||
BuildListOfServicesToStop(lpServiceList, lpServiceStatus[i].lpServiceName);
|
if (TV2_HasDependantServices(lpServiceStatus[i].lpServiceName))
|
||||||
|
{
|
||||||
|
/* recall this function with the dependent */
|
||||||
|
BuildListOfServicesToStop(lpServiceList, lpServiceStatus[i].lpServiceName);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Add the service to the list */
|
||||||
|
*lpServiceList = AddServiceToList(lpServiceList, lpServiceStatus[i].lpServiceName);
|
||||||
|
|
||||||
|
/* We've got one */
|
||||||
|
bRet = TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Add the service to the list */
|
|
||||||
*lpServiceList = AddServiceToList(lpServiceList, lpServiceStatus[i].lpServiceName);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bRet = TRUE;
|
|
||||||
|
|
||||||
HeapFree(GetProcessHeap(),
|
HeapFree(GetProcessHeap(),
|
||||||
0,
|
0,
|
||||||
lpServiceStatus);
|
lpServiceStatus);
|
||||||
|
|
Loading…
Reference in a new issue