|
|
27be76 |
From 0d732317df634f7586cf6c5e34394082ea5ea931 Mon Sep 17 00:00:00 2001
|
|
|
7faf05 |
From: Rui Matos <tiagomatos@gmail.com>
|
|
|
7faf05 |
Date: Wed, 11 Oct 2017 18:10:40 +0200
|
|
|
7faf05 |
Subject: [PATCH 2/3] Revert "sharing: Fix function arguments"
|
|
|
7faf05 |
|
|
|
7faf05 |
This reverts commit 5b6b26eba58f5c3b8b5441f07f0af7a84af5cc52.
|
|
|
7faf05 |
---
|
|
|
7faf05 |
plugins/sharing/gsd-sharing-manager.c | 11 +++++++----
|
|
|
7faf05 |
1 file changed, 7 insertions(+), 4 deletions(-)
|
|
|
7faf05 |
|
|
|
7faf05 |
diff --git a/plugins/sharing/gsd-sharing-manager.c b/plugins/sharing/gsd-sharing-manager.c
|
|
|
7faf05 |
index a90df9a6..26663442 100644
|
|
|
7faf05 |
--- a/plugins/sharing/gsd-sharing-manager.c
|
|
|
7faf05 |
+++ b/plugins/sharing/gsd-sharing-manager.c
|
|
|
27be76 |
@@ -101,99 +101,102 @@ static const char * const services[] = {
|
|
|
27be76 |
"vino-server",
|
|
|
27be76 |
"gnome-remote-desktop",
|
|
|
27be76 |
"gnome-user-share-webdav"
|
|
|
27be76 |
};
|
|
|
27be76 |
|
|
|
27be76 |
static void
|
|
|
27be76 |
handle_unit_cb (GObject *source_object,
|
|
|
27be76 |
GAsyncResult *res,
|
|
|
27be76 |
gpointer user_data)
|
|
|
27be76 |
{
|
|
|
27be76 |
GError *error = NULL;
|
|
|
27be76 |
GVariant *ret;
|
|
|
27be76 |
const char *operation = user_data;
|
|
|
27be76 |
|
|
|
27be76 |
ret = g_dbus_connection_call_finish (G_DBUS_CONNECTION (source_object),
|
|
|
27be76 |
res, &error);
|
|
|
27be76 |
if (!ret) {
|
|
|
27be76 |
if (!g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
|
|
|
27be76 |
g_warning ("Failed to %s service: %s", operation, error->message);
|
|
|
27be76 |
g_error_free (error);
|
|
|
27be76 |
return;
|
|
|
27be76 |
}
|
|
|
27be76 |
|
|
|
27be76 |
g_variant_unref (ret);
|
|
|
27be76 |
|
|
|
27be76 |
}
|
|
|
27be76 |
|
|
|
7faf05 |
static void
|
|
|
7faf05 |
gsd_sharing_manager_handle_service (GsdSharingManager *manager,
|
|
|
7faf05 |
const char *method,
|
|
|
7faf05 |
+ GAsyncReadyCallback callback,
|
|
|
7faf05 |
ServiceInfo *service)
|
|
|
7faf05 |
{
|
|
|
7faf05 |
char *service_file;
|
|
|
27be76 |
|
|
|
27be76 |
service_file = g_strdup_printf ("%s.service", service->name);
|
|
|
27be76 |
g_dbus_connection_call (manager->priv->connection,
|
|
|
27be76 |
"org.freedesktop.systemd1",
|
|
|
27be76 |
"/org/freedesktop/systemd1",
|
|
|
27be76 |
"org.freedesktop.systemd1.Manager",
|
|
|
27be76 |
method,
|
|
|
27be76 |
g_variant_new ("(ss)", service_file, "replace"),
|
|
|
27be76 |
NULL,
|
|
|
7faf05 |
G_DBUS_CALL_FLAGS_NONE,
|
|
|
7faf05 |
-1,
|
|
|
7faf05 |
manager->priv->cancellable,
|
|
|
7faf05 |
- handle_unit_cb,
|
|
|
7faf05 |
- (gpointer) method);
|
|
|
7faf05 |
+ callback,
|
|
|
7faf05 |
+ manager);
|
|
|
7faf05 |
g_free (service_file);
|
|
|
7faf05 |
}
|
|
|
7faf05 |
|
|
|
27be76 |
static void
|
|
|
27be76 |
gsd_sharing_manager_start_service (GsdSharingManager *manager,
|
|
|
27be76 |
ServiceInfo *service)
|
|
|
27be76 |
{
|
|
|
27be76 |
g_debug ("About to start %s", service->name);
|
|
|
27be76 |
|
|
|
7faf05 |
/* We use StartUnit, not StartUnitReplace, since the latter would
|
|
|
7faf05 |
* cancel any pending start we already have going from an
|
|
|
7faf05 |
* earlier _start_service() call */
|
|
|
7faf05 |
- gsd_sharing_manager_handle_service (manager, "StartUnit", service);
|
|
|
7faf05 |
+ gsd_sharing_manager_handle_service (manager, "StartUnit",
|
|
|
7faf05 |
+ handle_unit_cb, "start");
|
|
|
7faf05 |
}
|
|
|
7faf05 |
|
|
|
7faf05 |
static void
|
|
|
27be76 |
gsd_sharing_manager_stop_service (GsdSharingManager *manager,
|
|
|
27be76 |
ServiceInfo *service)
|
|
|
7faf05 |
{
|
|
|
7faf05 |
g_debug ("About to stop %s", service->name);
|
|
|
7faf05 |
|
|
|
7faf05 |
- gsd_sharing_manager_handle_service (manager, "StopUnit", service);
|
|
|
7faf05 |
+ gsd_sharing_manager_handle_service (manager, "StopUnit",
|
|
|
7faf05 |
+ handle_unit_cb, "stop");
|
|
|
7faf05 |
}
|
|
|
7faf05 |
|
|
|
7faf05 |
#ifdef HAVE_NETWORK_MANAGER
|
|
|
27be76 |
static gboolean
|
|
|
27be76 |
service_is_enabled_on_current_connection (GsdSharingManager *manager,
|
|
|
27be76 |
ServiceInfo *service)
|
|
|
27be76 |
{
|
|
|
27be76 |
char **connections;
|
|
|
27be76 |
int j;
|
|
|
27be76 |
gboolean ret;
|
|
|
27be76 |
connections = g_settings_get_strv (service->settings, "enabled-connections");
|
|
|
27be76 |
ret = FALSE;
|
|
|
27be76 |
for (j = 0; connections[j] != NULL; j++) {
|
|
|
27be76 |
if (g_strcmp0 (connections[j], manager->priv->current_network) == 0) {
|
|
|
27be76 |
ret = TRUE;
|
|
|
27be76 |
break;
|
|
|
27be76 |
}
|
|
|
27be76 |
}
|
|
|
27be76 |
|
|
|
27be76 |
g_strfreev (connections);
|
|
|
27be76 |
return ret;
|
|
|
27be76 |
}
|
|
|
27be76 |
#else
|
|
|
27be76 |
static gboolean
|
|
|
27be76 |
service_is_enabled_on_current_connection (GsdSharingManager *manager,
|
|
|
27be76 |
ServiceInfo *service)
|
|
|
27be76 |
{
|
|
|
27be76 |
return FALSE;
|
|
|
27be76 |
}
|
|
|
27be76 |
#endif /* HAVE_NETWORK_MANAGER */
|
|
|
7faf05 |
--
|
|
|
27be76 |
2.17.0
|
|
|
7faf05 |
|