[gnome-settings-daemon] common: Remove "hotplug-command" helper



commit c50ceb880e928506d987747f9e554079ad3d9826
Author: Bastien Nocera <hadess hadess net>
Date:   Thu Dec 17 15:51:10 2015 +0100

    common: Remove "hotplug-command" helper
    
    As we're not responsible for configuring input devices
    (mutter/gnome-shell is), the custom command to run when devices appear
    doesn't make sense any more, as it won't ever block the configuration of
    input devices.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=759599

 ...e.settings-daemon.peripherals.gschema.xml.in.in |    8 --
 plugins/common/Makefile.am                         |    3 -
 plugins/common/gsd-input-helper.c                  |   93 --------------------
 plugins/common/gsd-input-helper.h                  |    9 --
 plugins/common/input-device-example.sh             |   69 ---------------
 plugins/keyboard/gsd-keyboard-manager.c            |   18 ----
 6 files changed, 0 insertions(+), 200 deletions(-)
---
diff --git a/data/org.gnome.settings-daemon.peripherals.gschema.xml.in.in 
b/data/org.gnome.settings-daemon.peripherals.gschema.xml.in.in
index 6a65f08..f4120e9 100644
--- a/data/org.gnome.settings-daemon.peripherals.gschema.xml.in.in
+++ b/data/org.gnome.settings-daemon.peripherals.gschema.xml.in.in
@@ -4,7 +4,6 @@
     <child name="keyboard" schema="org.gnome.settings-daemon.peripherals.keyboard"/>
     <child name="mouse" schema="org.gnome.settings-daemon.peripherals.mouse"/>
     <child name="touchscreen" schema="org.gnome.settings-daemon.peripherals.touchscreen"/>
-    <child name="input-devices" schema="org.gnome.settings-daemon.peripherals.input-devices"/>
   </schema>
   <schema gettext-domain="@GETTEXT_PACKAGE@" id="org.gnome.settings-daemon.peripherals.smartcard" 
path="/org/gnome/settings-daemon/peripherals/smartcard/">
     <key name="removal-action" enum="org.gnome.settings-daemon.GsdSmartcardRemovalAction">
@@ -68,13 +67,6 @@
       <_summary>Whether the tablet's orientation is locked, or rotated automatically.</_summary>
     </key>
   </schema>
-  <schema gettext-domain="@GETTEXT_PACKAGE@" id="org.gnome.settings-daemon.peripherals.input-devices" 
path="/org/gnome/settings-daemon/peripherals/input-devices/">
-    <key name="hotplug-command" type="s">
-      <default>''</default>
-      <_summary>Device hotplug custom command</_summary>
-      <_description>Command to be run when a device is added or removed. An exit value of 1 means that the 
device will not be handled further by gnome-settings-daemon.</_description>
-    </key>
-  </schema>
 
   <!-- Deprecated schemas/keys -->
   <schema id="org.gnome.settings-daemon.peripherals.mouse.deprecated">
diff --git a/plugins/common/Makefile.am b/plugins/common/Makefile.am
index 0f85351..0331226 100644
--- a/plugins/common/Makefile.am
+++ b/plugins/common/Makefile.am
@@ -82,9 +82,6 @@ test_egg_key_parsing_SOURCES = test-egg-key-parsing.c
 test_egg_key_parsing_LDADD = libcommon.la $(COMMON_LIBS)
 test_egg_key_parsing_CFLAGS = $(libcommon_la_CFLAGS)
 
-scriptsdir = $(datadir)/gnome-settings-daemon- GSD_API_VERSION@
-scripts_DATA = input-device-example.sh
-
 EXTRA_DIST = $(scripts_DATA) test-plugin.h
 
 CLEANFILES = \
diff --git a/plugins/common/gsd-input-helper.c b/plugins/common/gsd-input-helper.c
index c8d4f51..077ff1c 100644
--- a/plugins/common/gsd-input-helper.c
+++ b/plugins/common/gsd-input-helper.c
@@ -31,9 +31,6 @@
 #include "gsd-input-helper.h"
 #include "gsd-device-manager.h"
 
-#define INPUT_DEVICES_SCHEMA "org.gnome.settings-daemon.peripherals.input-devices"
-#define KEY_HOTPLUG_COMMAND  "hotplug-command"
-
 #define ABS_MT_X "Abs MT Position X"
 #define ABS_MT_Y "Abs MT Position Y"
 #define ABS_X "Abs X"
@@ -342,96 +339,6 @@ set_device_enabled (int device_id,
         return TRUE;
 }
 
-static const char *
-custom_command_to_string (CustomCommand command)
-{
-        switch (command) {
-        case COMMAND_DEVICE_ADDED:
-                return "added";
-        case COMMAND_DEVICE_REMOVED:
-                return "removed";
-        case COMMAND_DEVICE_PRESENT:
-                return "present";
-        default:
-                g_assert_not_reached ();
-        }
-}
-
-/* Run a custom command on device presence events. Parameters passed into
- * the custom command are:
- * command -t [added|removed|present] -i <device ID> <device name>
- * Type 'added' and 'removed' signal 'device added' and 'device removed',
- * respectively. Type 'present' signals 'device present at
- * gnome-settings-daemon init'.
- *
- * The script is expected to run synchronously, and an exit value
- * of "1" means that no other settings will be applied to this
- * particular device.
- *
- * More options may be added in the future.
- *
- * This function returns TRUE if we should not apply any more settings
- * to the device.
- */
-gboolean
-run_custom_command (GdkDevice              *device,
-                    CustomCommand           command)
-{
-        GSettings *settings;
-        GError *error = NULL;
-        char *cmd;
-        char *argv[7];
-        int exit_status;
-        gboolean rc;
-        int id;
-        char *out;
-
-        settings = g_settings_new (INPUT_DEVICES_SCHEMA);
-        cmd = g_settings_get_string (settings, KEY_HOTPLUG_COMMAND);
-        g_object_unref (settings);
-
-        if (!cmd || cmd[0] == '\0') {
-                g_free (cmd);
-                return FALSE;
-        }
-
-        /* Easter egg! */
-        g_object_get (device, "device-id", &id, NULL);
-
-        argv[0] = cmd;
-        argv[1] = "-t";
-        argv[2] = (char *) custom_command_to_string (command);
-        argv[3] = "-i";
-        argv[4] = g_strdup_printf ("%d", id);
-        argv[5] = (char*) gdk_device_get_name (device);
-        argv[6] = NULL;
-
-        out = g_strjoinv (" ", argv);
-        g_debug ("About to launch command: %s", out);
-        g_free (out);
-
-        rc = g_spawn_sync (g_get_home_dir (), argv, NULL, G_SPAWN_SEARCH_PATH,
-                           NULL, NULL, NULL, NULL, &exit_status, &error);
-
-        if (rc == FALSE) {
-                g_warning ("Couldn't execute command '%s', verify that this is a valid command: %s", cmd, 
error->message);
-                g_clear_error (&error);
-        }
-
-        g_free (argv[0]);
-        g_free (argv[4]);
-
-        if (!g_spawn_check_exit_status (exit_status, &error)) {
-                if (g_error_matches (error, G_SPAWN_EXIT_ERROR, 1)) {
-                        g_clear_error (&error);
-                        return TRUE;
-                }
-                g_clear_error (&error);
-        }
-
-        return FALSE;
-}
-
 const char *
 xdevice_get_wacom_tool_type (int deviceid)
 {
diff --git a/plugins/common/gsd-input-helper.h b/plugins/common/gsd-input-helper.h
index 61addda..31e2e47 100644
--- a/plugins/common/gsd-input-helper.h
+++ b/plugins/common/gsd-input-helper.h
@@ -28,12 +28,6 @@ G_BEGIN_DECLS
 
 #define WACOM_SERIAL_IDS_PROP "Wacom Serial IDs"
 
-typedef enum {
-        COMMAND_DEVICE_ADDED,
-        COMMAND_DEVICE_REMOVED,
-        COMMAND_DEVICE_PRESENT
-} CustomCommand;
-
 /* Generic property setting code. Fill up the struct property with the property
  * data and pass it into device_set_property together with the device to be
  * changed.  Note: doesn't cater for non-zero offsets yet, but we don't have
@@ -64,9 +58,6 @@ gboolean  device_set_property     (XDevice                *xdevice,
                                    const char             *device_name,
                                    PropertyHelper         *property);
 
-gboolean  run_custom_command      (GdkDevice              *device,
-                                   CustomCommand           command);
-
 char *    xdevice_get_device_node  (int                     deviceid);
 int       xdevice_get_last_tool_id (int                     deviceid);
 gboolean  xdevice_get_dimensions   (int                     deviceid,
diff --git a/plugins/keyboard/gsd-keyboard-manager.c b/plugins/keyboard/gsd-keyboard-manager.c
index eb75c92..ddeeee6 100644
--- a/plugins/keyboard/gsd-keyboard-manager.c
+++ b/plugins/keyboard/gsd-keyboard-manager.c
@@ -90,7 +90,6 @@ struct GsdKeyboardManagerPrivate
         GsdNumLockState old_state;
         GdkDeviceManager *device_manager;
         guint device_added_id;
-        guint device_removed_id;
 };
 
 static void     gsd_keyboard_manager_class_init  (GsdKeyboardManagerClass *klass);
@@ -364,20 +363,6 @@ device_added_cb (GdkDeviceManager   *device_manager,
         if (source == GDK_SOURCE_KEYBOARD) {
                 g_debug ("New keyboard plugged in, applying all settings");
                 apply_numlock (manager);
-                run_custom_command (device, COMMAND_DEVICE_ADDED);
-        }
-}
-
-static void
-device_removed_cb (GdkDeviceManager   *device_manager,
-                   GdkDevice          *device,
-                   GsdKeyboardManager *manager)
-{
-        GdkInputSource source;
-
-        source = gdk_device_get_source (device);
-        if (source == GDK_SOURCE_KEYBOARD) {
-                run_custom_command (device, COMMAND_DEVICE_REMOVED);
         }
 }
 
@@ -393,8 +378,6 @@ set_devicepresence_handler (GsdKeyboardManager *manager)
 
         manager->priv->device_added_id = g_signal_connect (G_OBJECT (device_manager), "device-added",
                                                            G_CALLBACK (device_added_cb), manager);
-        manager->priv->device_removed_id = g_signal_connect (G_OBJECT (device_manager), "device-removed",
-                                                             G_CALLBACK (device_removed_cb), manager);
         manager->priv->device_manager = device_manager;
 }
 
@@ -775,7 +758,6 @@ gsd_keyboard_manager_stop (GsdKeyboardManager *manager)
 
         if (p->device_manager != NULL) {
                 g_signal_handler_disconnect (p->device_manager, p->device_added_id);
-                g_signal_handler_disconnect (p->device_manager, p->device_removed_id);
                 p->device_manager = NULL;
         }
 


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