From: Giannis Adamopoulos Date: Fri, 12 Aug 2011 10:25:30 +0000 (+0000) Subject: [themesvc] X-Git-Tag: backups/icu4ros-bringup@60647~248^2~21 X-Git-Url: https://git.reactos.org/?p=reactos.git;a=commitdiff_plain;h=5cc3be39537f859bc1534974477e846637796022 [themesvc] - Add the themes service. For now it will only call ThemeHooksInstall and ThemeHooksRemove. From now on we do not need apihooksrv in order to have themes svn path=/branches/GSoC_2011/ThemesSupport/; revision=53195 --- diff --git a/base/services/CMakeLists.txt b/base/services/CMakeLists.txt index c49d77ba533..51c0d7df383 100644 --- a/base/services/CMakeLists.txt +++ b/base/services/CMakeLists.txt @@ -7,5 +7,6 @@ add_subdirectory(svchost) add_subdirectory(tcpsvcs) add_subdirectory(telnetd) #add_subdirectory(tftpd) +add_subdirectory(thmsvc) add_subdirectory(umpnpmgr) add_subdirectory(wlansvc) diff --git a/base/services/services.rbuild b/base/services/services.rbuild index 5125d9b2f79..e46bf8ff969 100644 --- a/base/services/services.rbuild +++ b/base/services/services.rbuild @@ -25,6 +25,9 @@ + + + diff --git a/base/services/thmsvc/CMakeLists.txt b/base/services/thmsvc/CMakeLists.txt new file mode 100644 index 00000000000..dfa56a91a71 --- /dev/null +++ b/base/services/thmsvc/CMakeLists.txt @@ -0,0 +1,10 @@ + +set_unicode() + +add_executable(thmsvc thmsvc.c thmsvc.rc) + +target_link_libraries(thmsvc wine) + +set_module_type(thmsvc win32cui) +add_importlibs(thmsvc uxtheme advapi32 msvcrt kernel32 ntdll) +add_cd_file(TARGET thmsvc DESTINATION reactos/system32 FOR all) diff --git a/base/services/thmsvc/thmsvc.c b/base/services/thmsvc/thmsvc.c new file mode 100644 index 00000000000..34b81653596 --- /dev/null +++ b/base/services/thmsvc/thmsvc.c @@ -0,0 +1,149 @@ +/* + * COPYRIGHT: See COPYING in the top level directory + * PROJECT: ReactOS kernel + * FILE: services/thmsvc/thmsvc.c + * PURPOSE: Themes service + * PROGRAMMER: Giannis Adamopoulos + */ + +/* INCLUDES *****************************************************************/ + +#define WIN32_NO_STATUS +#include + +#include "wine/debug.h" + +WINE_DEFAULT_DEBUG_CHANNEL(thmsvc); + + +/* GLOBALS ******************************************************************/ + +static VOID CALLBACK ServiceMain(DWORD argc, LPWSTR *argv); +static WCHAR ServiceName[] = L"Themes"; +static SERVICE_TABLE_ENTRYW ServiceTable[] = +{ + {ServiceName, ServiceMain}, + {NULL, NULL} +}; + +SERVICE_STATUS_HANDLE ServiceStatusHandle; +SERVICE_STATUS ServiceStatus; + +BOOL WINAPI ThemeHooksInstall(); + +BOOL WINAPI ThemeHooksRemove(); + +/* FUNCTIONS *****************************************************************/ + +static VOID +UpdateServiceStatus(DWORD dwState) +{ + ServiceStatus.dwServiceType = SERVICE_WIN32_OWN_PROCESS; + ServiceStatus.dwCurrentState = dwState; + + if (dwState == SERVICE_RUNNING) + ServiceStatus.dwControlsAccepted = SERVICE_ACCEPT_PAUSE_CONTINUE | SERVICE_ACCEPT_STOP | SERVICE_ACCEPT_SHUTDOWN; + else if (dwState == SERVICE_PAUSED) + ServiceStatus.dwControlsAccepted = SERVICE_ACCEPT_PAUSE_CONTINUE; + else + ServiceStatus.dwControlsAccepted = 0; + + ServiceStatus.dwWin32ExitCode = 0; + ServiceStatus.dwServiceSpecificExitCode = 0; + ServiceStatus.dwCheckPoint = 0; + + if (dwState == SERVICE_START_PENDING || + dwState == SERVICE_STOP_PENDING || + dwState == SERVICE_PAUSE_PENDING || + dwState == SERVICE_CONTINUE_PENDING) + ServiceStatus.dwWaitHint = 10000; + else + ServiceStatus.dwWaitHint = 0; + + SetServiceStatus(ServiceStatusHandle, + &ServiceStatus); +} + + +static DWORD WINAPI +ServiceControlHandler(DWORD dwControl, + DWORD dwEventType, + LPVOID lpEventData, + LPVOID lpContext) +{ + TRACE("ServiceControlHandler() called\n"); + + switch (dwControl) + { + case SERVICE_CONTROL_STOP: + TRACE(" SERVICE_CONTROL_STOP received\n"); + UpdateServiceStatus(SERVICE_STOPPED); + ThemeHooksRemove(); + return ERROR_SUCCESS; + + case SERVICE_CONTROL_PAUSE: + TRACE(" SERVICE_CONTROL_PAUSE received\n"); + UpdateServiceStatus(SERVICE_PAUSED); + return ERROR_SUCCESS; + + case SERVICE_CONTROL_CONTINUE: + TRACE(" SERVICE_CONTROL_CONTINUE received\n"); + UpdateServiceStatus(SERVICE_RUNNING); + return ERROR_SUCCESS; + + case SERVICE_CONTROL_INTERROGATE: + TRACE(" SERVICE_CONTROL_INTERROGATE received\n"); + SetServiceStatus(ServiceStatusHandle, + &ServiceStatus); + return ERROR_SUCCESS; + + case SERVICE_CONTROL_SHUTDOWN: + TRACE(" SERVICE_CONTROL_SHUTDOWN received\n"); + UpdateServiceStatus(SERVICE_STOPPED); + return ERROR_SUCCESS; + + default : + TRACE(" Control %lu received\n"); + return ERROR_CALL_NOT_IMPLEMENTED; + } +} + + +static VOID CALLBACK +ServiceMain(DWORD argc, LPWSTR *argv) +{ + UNREFERENCED_PARAMETER(argc); + UNREFERENCED_PARAMETER(argv); + + TRACE("ServiceMain() called\n"); + + ServiceStatusHandle = RegisterServiceCtrlHandlerExW(ServiceName, + ServiceControlHandler, + NULL); + + TRACE("Calling SetServiceStatus()\n"); + UpdateServiceStatus(SERVICE_RUNNING); + TRACE("SetServiceStatus() called\n"); + + ThemeHooksInstall(); + + TRACE("ServiceMain() done\n"); +} + + +int +wmain(int argc, WCHAR *argv[]) +{ + UNREFERENCED_PARAMETER(argc); + UNREFERENCED_PARAMETER(argv); + + TRACE("thmsvc: main() started\n"); + + StartServiceCtrlDispatcher(ServiceTable); + + TRACE("thmsvc: main() done\n"); + + return 0; +} + +/* EOF */ diff --git a/base/services/thmsvc/thmsvc.rbuild b/base/services/thmsvc/thmsvc.rbuild new file mode 100644 index 00000000000..fd18e9a6e4e --- /dev/null +++ b/base/services/thmsvc/thmsvc.rbuild @@ -0,0 +1,11 @@ + + + + . + uxtheme + wine + ntdll + advapi32 + thmsvc.c + thmsvc.rc + diff --git a/base/services/thmsvc/thmsvc.rc b/base/services/thmsvc/thmsvc.rc new file mode 100644 index 00000000000..c8d5843a60f --- /dev/null +++ b/base/services/thmsvc/thmsvc.rc @@ -0,0 +1,4 @@ +#define REACTOS_STR_FILE_DESCRIPTION "Themes-Service\0" +#define REACTOS_STR_INTERNAL_NAME "thmsvc\0" +#define REACTOS_STR_ORIGINAL_FILENAME "thmsvc.exe\0" +#include