8
0
mirror of https://github.com/FirebirdSQL/firebird.git synced 2025-01-23 10:03:03 +01:00

Fixed the CPL applet.

This commit is contained in:
dimitr 2006-05-31 16:57:50 +00:00
parent f0d683d9c8
commit 33db7e2f6a
2 changed files with 68 additions and 36 deletions

View File

@ -273,8 +273,10 @@ bool CFBDialog::ValidateInstalledServices()
// If Guardian installed but not Server service
// then return false;
{
fb_status.UseService = CheckServiceInstalled(REMOTE_SERVICE);
fb_status.UseGuardian = CheckServiceInstalled(ISCGUARD_SERVICE);
fb_status.UseService =
CheckServiceInstalled(GetServiceName(REMOTE_SERVICE));
fb_status.UseGuardian =
CheckServiceInstalled(GetServiceName(ISCGUARD_SERVICE));
if (!fb_status.UseService && fb_status.UseGuardian)
return false;
@ -282,6 +284,12 @@ bool CFBDialog::ValidateInstalledServices()
return true;
}
CString CFBDialog::GetServiceName(const char* name) const
{
CString serviceName;
serviceName.Format(name, DEFAULT_INSTANCE);
return serviceName;
}
int CFBDialog::GetServerStatus()
// This is called by UpdateServerStatus,
@ -296,12 +304,13 @@ int CFBDialog::GetServerStatus()
{
int result = IDS_APPLICATION_STOPPED;
fb_status.UseService = CheckServiceInstalled(REMOTE_SERVICE);
const CString serviceName = GetServiceName(REMOTE_SERVICE);
fb_status.UseService = CheckServiceInstalled(serviceName);
if ( fb_status.UseService )
{
OpenServiceManager( GENERIC_READ );
SC_HANDLE hService = OpenService (hScManager, REMOTE_SERVICE, GENERIC_READ );
SC_HANDLE hService = OpenService (hScManager, serviceName, GENERIC_READ );
QueryServiceStatus( hService, &service_status );
CloseServiceHandle ( hService );
CloseServiceManager();
@ -371,13 +380,15 @@ void CFBDialog::ViewRegistryEntries()
fb_status.AutoStart = false;
fb_status.UseService = CheckServiceInstalled(REMOTE_SERVICE);
fb_status.UseService =
CheckServiceInstalled(GetServiceName(REMOTE_SERVICE));
if ( fb_status.UseService )
{
OpenServiceManager( GENERIC_READ );
const char* service = ISCGUARD_SERVICE;
const char* display_name = ISCGUARD_DISPLAY_NAME;
CString service = GetServiceName(ISCGUARD_SERVICE);
CString display_name = GetServiceName(ISCGUARD_DISPLAY_NAME);
SC_HANDLE hService = OpenService (hScManager, service, SERVICE_QUERY_CONFIG);
fb_status.UseGuardian = hService;
if (hService != NULL) // then we are running as a Service
@ -402,8 +413,8 @@ void CFBDialog::ViewRegistryEntries()
}
//Now do the same again, but this time only look at the server itself
service = REMOTE_SERVICE;
display_name = REMOTE_DISPLAY_NAME;
service = GetServiceName(REMOTE_SERVICE);
display_name = GetServiceName(REMOTE_DISPLAY_NAME);
hService = OpenService (hScManager, service, SERVICE_QUERY_CONFIG);
CloseServiceManager();
if (hService != NULL) // then we are running as a Service
@ -739,17 +750,17 @@ bool CFBDialog::ServerStart( CFBDialog::STATUS status )
if ( status.UseService )
{
const char * service = "";
const char * display_name = "";
CString service;
CString display_name;
if (status.UseGuardian)
{
service = ISCGUARD_SERVICE;
display_name = ISCGUARD_DISPLAY_NAME;
service = GetServiceName(ISCGUARD_SERVICE);
display_name = GetServiceName(ISCGUARD_DISPLAY_NAME);
}
else
{
service = REMOTE_SERVICE;
display_name = REMOTE_DISPLAY_NAME;
service = GetServiceName(REMOTE_SERVICE);
display_name = GetServiceName(REMOTE_DISPLAY_NAME);
}
OpenServiceManager(GENERIC_READ | GENERIC_EXECUTE | GENERIC_WRITE);
@ -820,10 +831,19 @@ bool CFBDialog::ServerStop()
#endif
OpenServiceManager( GENERIC_READ | GENERIC_EXECUTE | GENERIC_WRITE );
CString service;
CString display_name;
if (fb_status.UseGuardian)
m_Error_Status = SERVICES_stop(hScManager, ISCGUARD_SERVICE, ISCGUARD_DISPLAY_NAME, svc_error);
{
service = GetServiceName(ISCGUARD_SERVICE);
display_name = GetServiceName(ISCGUARD_DISPLAY_NAME);
}
else
m_Error_Status = SERVICES_stop(hScManager, REMOTE_SERVICE, REMOTE_DISPLAY_NAME, svc_error);
{
service = GetServiceName(REMOTE_SERVICE);
display_name = GetServiceName(REMOTE_DISPLAY_NAME);
}
m_Error_Status = SERVICES_stop(hScManager, service, display_name, svc_error);
result = !m_Error_Status;
@ -893,11 +913,18 @@ bool CFBDialog::ServiceInstall( CFBDialog::STATUS status )
if (hScManager)
{
const char* ServerPath = m_Root_Path;
CString guard_service = GetServiceName(ISCGUARD_SERVICE);
CString guard_display_name = GetServiceName(ISCGUARD_DISPLAY_NAME);
CString remote_service = GetServiceName(REMOTE_SERVICE);
CString remote_display_name = GetServiceName(REMOTE_DISPLAY_NAME);
if (new_settings.UseGuardian)
{
m_Error_Status = SERVICES_install (hScManager, ISCGUARD_SERVICE,
ISCGUARD_DISPLAY_NAME, ISCGUARD_DISPLAY_DESCR,
ISCGUARD_EXECUTABLE, ServerPath, NULL, status.AutoStart,
m_Error_Status = SERVICES_install (hScManager,
guard_service, guard_display_name,
ISCGUARD_DISPLAY_DESCR, ISCGUARD_EXECUTABLE,
ServerPath, NULL, NULL, status.AutoStart,
NULL, NULL, false, svc_error);
if (m_Error_Status != FB_SUCCESS)
{
@ -910,10 +937,10 @@ bool CFBDialog::ServiceInstall( CFBDialog::STATUS status )
}
/* do the install of server */
m_Error_Status = SERVICES_install (hScManager, REMOTE_SERVICE,
REMOTE_DISPLAY_NAME, REMOTE_DISPLAY_DESCR,
(LPCTSTR) status.ServiceExecutable,
ServerPath, NULL, status.AutoStart,
m_Error_Status = SERVICES_install (hScManager,
remote_service, remote_display_name,
REMOTE_DISPLAY_DESCR, (LPCTSTR) status.ServiceExecutable,
ServerPath, NULL, NULL, status.AutoStart,
NULL, NULL, false, svc_error);
if (m_Error_Status != FB_SUCCESS)
{
@ -944,16 +971,21 @@ bool CFBDialog::ServiceRemove()
OpenServiceManager( GENERIC_READ | GENERIC_EXECUTE | GENERIC_WRITE );
if (hScManager)
{
m_Error_Status = SERVICES_remove (hScManager, ISCGUARD_SERVICE,
ISCGUARD_DISPLAY_NAME, svc_error);
CString guard_service = GetServiceName(ISCGUARD_SERVICE);
CString guard_display_name = GetServiceName(ISCGUARD_DISPLAY_NAME);
CString remote_service = GetServiceName(REMOTE_SERVICE);
CString remote_display_name = GetServiceName(REMOTE_DISPLAY_NAME);
m_Error_Status = SERVICES_remove (hScManager, guard_service,
guard_display_name, svc_error);
if (m_Error_Status == IB_SERVICE_RUNNING)
{
CloseServiceManager();
return false;
}
m_Error_Status = SERVICES_remove (hScManager, REMOTE_SERVICE,
REMOTE_DISPLAY_NAME, svc_error);
m_Error_Status = SERVICES_remove (hScManager, remote_service,
remote_display_name, svc_error);
if (m_Error_Status == IB_SERVICE_RUNNING)
{
CloseServiceManager();
@ -1415,18 +1447,17 @@ void CFBDialog::SetAutoStart( CFBDialog::STATUS status )
// The database is locked, so it is safe to make changes.
const char* service = "";
const char* display_name = "";
CString service;
CString display_name;
if (status.UseGuardian)
{
service = ISCGUARD_SERVICE;
display_name = ISCGUARD_DISPLAY_NAME;
service = GetServiceName(ISCGUARD_SERVICE);
display_name = GetServiceName(ISCGUARD_DISPLAY_NAME);
}
else
{
service = REMOTE_SERVICE;
display_name = REMOTE_DISPLAY_NAME;
service = GetServiceName(REMOTE_SERVICE);
display_name = GetServiceName(REMOTE_DISPLAY_NAME);
}
// Open a handle to the service.

View File

@ -172,6 +172,7 @@ public:
//Get Stuff
CString GetServiceName(const char* name) const;
HWND GetSuperServerHandle() const;
#ifdef MANAGE_CLASSIC
HWND GetClassicServerHandle() const;