[wing/wip/service-description] service: add a property to set the description
- From: Ignacio Casal Quinteiro <icq src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [wing/wip/service-description] service: add a property to set the description
- Date: Sun, 23 Oct 2016 16:37:57 +0000 (UTC)
commit e6a41f680e58daa9ac3a5785ef33d343733b4cc4
Author: Ignacio Casal Quinteiro <ignacio casal nice-software com>
Date: Sun Oct 23 18:33:19 2016 +0200
service: add a property to set the description
Before we were using the name as the description as well
instead it is better to have two different properties so
we have better fine grained control over the service.
wing/wingservice-private.h | 4 ++-
wing/wingservice.c | 45 ++++++++++++++++++++++++++++++++++++++++++++
wing/wingservice.h | 3 ++
wing/wingservicemanager.c | 7 ++---
4 files changed, 54 insertions(+), 5 deletions(-)
---
diff --git a/wing/wingservice-private.h b/wing/wingservice-private.h
index e523c62..b35e250 100644
--- a/wing/wingservice-private.h
+++ b/wing/wingservice-private.h
@@ -20,7 +20,9 @@
G_BEGIN_DECLS
-const wchar_t *_wing_service_get_namew (WingService *service);
+const wchar_t *_wing_service_get_namew (WingService *service);
+
+const wchar_t *_wing_service_get_descriptionw (WingService *service);
G_END_DECLS
diff --git a/wing/wingservice.c b/wing/wingservice.c
index 35f5044..6613ec5 100644
--- a/wing/wingservice.c
+++ b/wing/wingservice.c
@@ -28,6 +28,8 @@ typedef struct _WingServicePrivate
{
gchar *name;
wchar_t *namew;
+ gchar *description;
+ wchar_t *descriptionw;
WingServiceFlags flags;
GApplication *application;
GThread *thread;
@@ -109,6 +111,8 @@ wing_service_finalize (GObject *object)
g_free (priv->name);
g_free (priv->namew);
+ g_free (priv->description);
+ g_free (priv->descriptionw);
if (wing_service_get_default() == service)
wing_service_set_default(NULL);
@@ -150,6 +154,9 @@ wing_service_get_property (GObject *object,
case PROP_NAME:
g_value_set_string (value, priv->name);
break;
+ case PROP_DESCRIPTION:
+ g_value_set_string (value, priv->description);
+ break;
case PROP_FLAGS:
g_value_set_int (value, priv->flags);
break;
@@ -179,6 +186,10 @@ wing_service_set_property (GObject *object,
priv->name = g_value_dup_string (value);
priv->namew = g_utf8_to_utf16 (priv->name, -1, NULL, NULL, NULL);
break;
+ case PROP_DESCRIPTION:
+ priv->description = g_value_dup_string (value);
+ priv->descriptionw = g_utf8_to_utf16 (priv->description, -1, NULL, NULL, NULL);
+ break;
case PROP_FLAGS:
priv->flags = g_value_get_int (value);
break;
@@ -305,6 +316,14 @@ wing_service_class_init (WingServiceClass *klass)
G_PARAM_READWRITE |
G_PARAM_CONSTRUCT_ONLY);
+ props[PROP_DESCRIPTION] =
+ g_param_spec_string ("description",
+ "Description",
+ "Description",
+ NULL,
+ G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT_ONLY);
+
props[PROP_FLAGS] =
g_param_spec_int ("flags",
"Flags",
@@ -381,11 +400,13 @@ wing_service_init (WingService *service)
WingService *
wing_service_new (const gchar *name,
+ const gchar *description,
WingServiceFlags flags,
GApplication *application)
{
return g_object_new (WING_TYPE_SERVICE,
"name", name,
+ "description", description,
"flags", flags,
"application", application,
NULL);
@@ -429,6 +450,30 @@ _wing_service_get_namew (WingService *service)
return priv->namew;
}
+const gchar *
+wing_service_get_description (WingService *service)
+{
+ WingServicePrivate *priv;
+
+ g_return_val_if_fail (WING_IS_SERVICE (service), NULL);
+
+ priv = wing_service_get_instance_private (service);
+
+ return priv->description;
+}
+
+const wchar_t *
+_wing_service_get_descriptionw (WingService *service)
+{
+ WingServicePrivate *priv;
+
+ g_return_val_if_fail(WING_IS_SERVICE (service), NULL);
+
+ priv = wing_service_get_instance_private (service);
+
+ return priv->descriptionw;
+}
+
WingServiceFlags
wing_service_get_flags (WingService *service)
{
diff --git a/wing/wingservice.h b/wing/wingservice.h
index d63c353..4dfe961 100644
--- a/wing/wingservice.h
+++ b/wing/wingservice.h
@@ -88,6 +88,9 @@ WING_AVAILABLE_IN_ALL
const gchar *wing_service_get_name (WingService *service);
WING_AVAILABLE_IN_ALL
+const gchar *wing_service_get_description (WingService *service);
+
+WING_AVAILABLE_IN_ALL
WingServiceFlags wing_service_get_flags (WingService *service);
WING_AVAILABLE_IN_ALL
diff --git a/wing/wingservicemanager.c b/wing/wingservicemanager.c
index a31d472..2fe353d 100644
--- a/wing/wingservicemanager.c
+++ b/wing/wingservicemanager.c
@@ -116,7 +116,6 @@ wing_service_manager_install_service (WingServiceManager *manager,
SC_HANDLE service_handle;
wchar_t *path;
gboolean result = FALSE;
- const gchar *service_name;
WingServiceFlags service_flags;
DWORD service_type;
@@ -129,7 +128,6 @@ wing_service_manager_install_service (WingServiceManager *manager,
return FALSE;
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)
@@ -137,7 +135,7 @@ wing_service_manager_install_service (WingServiceManager *manager,
service_handle = CreateServiceW (sc,
_wing_service_get_namew (service),
- _wing_service_get_namew (service),
+ _wing_service_get_descriptionw (service),
SERVICE_ALL_ACCESS,
service_type,
SERVICE_AUTO_START,
@@ -145,11 +143,12 @@ wing_service_manager_install_service (WingServiceManager *manager,
path,
NULL, 0, NULL,
NULL, NULL);
+ g_free (path);
if (service_handle != NULL)
{
result = TRUE;
- CloseServiceHandle(service_handle);
+ CloseServiceHandle (service_handle);
}
else
{
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]