[wing/wip/service-fixes] service: allow to choose whether the service is interactive



commit 761363e12b0966d1e1bbd19e608fd409ca183f34
Author: Ignacio Casal Quinteiro <icq gnome org>
Date:   Thu Aug 18 13:33:33 2016 +0200

    service: allow to choose whether the service is interactive
    
    See that this changes the default behavior where it would
    install an interactive service by default.

 wing/wingservice.c        |   12 ++++++++++++
 wing/wingservice.h        |   16 +++++++++++++++-
 wing/wingservicemanager.c |    9 ++++++++-
 3 files changed, 35 insertions(+), 2 deletions(-)
---
diff --git a/wing/wingservice.c b/wing/wingservice.c
index cb74b88..14fa41b 100644
--- a/wing/wingservice.c
+++ b/wing/wingservice.c
@@ -429,6 +429,18 @@ _wing_service_get_namew (WingService *service)
   return priv->namew;
 }
 
+WingServiceFlags
+wing_service_get_flags (WingService *service)
+{
+  WingServicePrivate *priv;
+
+  g_return_val_if_fail (WING_IS_SERVICE (service), WING_SERVICE_NONE);
+
+  priv = wing_service_get_instance_private (service);
+
+  return priv->flags;
+}
+
 static void
 set_service_status (WingService *service,
                     DWORD        state)
diff --git a/wing/wingservice.h b/wing/wingservice.h
index 6c7710a..d63c353 100644
--- a/wing/wingservice.h
+++ b/wing/wingservice.h
@@ -51,12 +51,23 @@ struct _WingServiceClass
   gpointer reserved[12];
 };
 
+/**
+ * WingServiceFlags:
+ * @WING_SERVICE_NONE: no flags.
+ * @WING_SERVICE_CAN_BE_SUSPENDED: whether the service can be suspended.
+ * @WING_SERVICE_CAN_BE_STOPPED: whether the service can be stopped.
+ * @WING_SERVICE_STOP_ON_SHUTDOWN: whether to stop the service on shutdown.
+ * @WING_SERVICE_IS_INTERACTIVE: whether service can interact with the desktop.
+ *
+ * The flags for the service.
+ */
 typedef enum
 {
   WING_SERVICE_NONE             = 0,
   WING_SERVICE_CAN_BE_SUSPENDED = 1 << 0,
   WING_SERVICE_CAN_BE_STOPPED   = 1 << 1,
-  WING_SERVICE_STOP_ON_SHUTDOWN = 1 << 2
+  WING_SERVICE_STOP_ON_SHUTDOWN = 1 << 2,
+  WING_SERVICE_IS_INTERACTIVE   = 1 << 3
 } WingServiceFlags;
 
 WING_AVAILABLE_IN_ALL
@@ -77,6 +88,9 @@ WING_AVAILABLE_IN_ALL
 const gchar           *wing_service_get_name        (WingService *service);
 
 WING_AVAILABLE_IN_ALL
+WingServiceFlags       wing_service_get_flags       (WingService *service);
+
+WING_AVAILABLE_IN_ALL
 int                    wing_service_run             (WingService  *service,
                                                      int           argc,
                                                      char        **argv);
diff --git a/wing/wingservicemanager.c b/wing/wingservicemanager.c
index cc718b7..a31d472 100644
--- a/wing/wingservicemanager.c
+++ b/wing/wingservicemanager.c
@@ -117,6 +117,8 @@ wing_service_manager_install_service (WingServiceManager  *manager,
   wchar_t *path;
   gboolean result = FALSE;
   const gchar *service_name;
+  WingServiceFlags service_flags;
+  DWORD service_type;
 
   g_return_val_if_fail (WING_IS_SERVICE_MANAGER (manager), FALSE);
   g_return_val_if_fail (WING_IS_SERVICE (service), FALSE);
@@ -128,11 +130,16 @@ wing_service_manager_install_service (WingServiceManager  *manager,
 
   path = get_file_path ();
   service_name = wing_service_get_name (service);
+  service_flags = wing_service_get_flags (service);
+  service_type = SERVICE_WIN32_OWN_PROCESS;
+  if (service_flags & WING_SERVICE_IS_INTERACTIVE)
+    service_type |= SERVICE_INTERACTIVE_PROCESS;
+
   service_handle = CreateServiceW (sc,
                                    _wing_service_get_namew (service),
                                    _wing_service_get_namew (service),
                                    SERVICE_ALL_ACCESS,
-                                   SERVICE_WIN32_OWN_PROCESS | SERVICE_INTERACTIVE_PROCESS,
+                                   service_type,
                                    SERVICE_AUTO_START,
                                    SERVICE_ERROR_NORMAL,
                                    path,


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]