[gnome-settings-daemon/gnome-3-24] media-keys: Fix mmkeys D-Bus API to match API docs



commit 42f75ed4cdc86498d6e02e511a1314b8916bd4aa
Author: Bastien Nocera <hadess hadess net>
Date:   Fri Apr 21 15:30:47 2017 +0200

    media-keys: Fix mmkeys D-Bus API to match API docs
    
    Bizarrely, since 2011, gnome-settings-daemon was documented as using
    org.gnome.SettingsDaemon.MediaKeys D-Bus name, but everybody ended up
    using the org.gnome.SettingsDaemon owned by the daemon instead, and
    never reported the discrepancy.
    
    This fixes the code to match the 6-year old API as documented by owning
    the org.gnome.SettingsDaemon.MediaKeys as well as the
    org.gnome.SettingsDaemon D-Bus name to give 3rd-party users time to
    adapt their code.
    
    The portion of this patch adding the org.gnome.SettingsDaemon.MediaKeys
    name owning will need to be backported as far as reasonably possible by
    distributions, and all users of the API changed before GNOME 3.26. This
    would obviously have been easier if the problem was reported when
    detected, committer of this fix included.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=781326

 plugins/media-keys/gsd-media-keys-manager.c |   22 ++++++++++++++++++++++
 1 files changed, 22 insertions(+), 0 deletions(-)
---
diff --git a/plugins/media-keys/gsd-media-keys-manager.c b/plugins/media-keys/gsd-media-keys-manager.c
index 269fa91..ccfa57e 100644
--- a/plugins/media-keys/gsd-media-keys-manager.c
+++ b/plugins/media-keys/gsd-media-keys-manager.c
@@ -222,6 +222,9 @@ struct GsdMediaKeysManagerPrivate
 
         guint            start_idle_id;
 
+        /* Multimedia keys */
+        guint            mmkeys_name_id;
+        guint            gsd_name_id;
         MprisController *mpris_controller;
 };
 
@@ -2929,6 +2932,16 @@ gsd_media_keys_manager_stop (GsdMediaKeysManager *manager)
                 priv->start_idle_id = 0;
         }
 
+        if (priv->mmkeys_name_id > 0) {
+                g_bus_unown_name (priv->mmkeys_name_id);
+                priv->mmkeys_name_id = 0;
+        }
+
+        if (priv->gsd_name_id > 0) {
+                g_bus_unown_name (priv->gsd_name_id);
+                priv->gsd_name_id = 0;
+        }
+
         if (priv->bus_cancellable != NULL) {
                 g_cancellable_cancel (priv->bus_cancellable);
                 g_object_unref (priv->bus_cancellable);
@@ -3230,6 +3243,15 @@ on_bus_gotten (GObject             *source_object,
                                            NULL,
                                            NULL);
 
+        manager->priv->mmkeys_name_id = g_bus_own_name_on_connection (manager->priv->connection,
+                                                                      "org.gnome.SettingsDaemon.MediaKeys",
+                                                                      G_BUS_NAME_OWNER_FLAGS_NONE,
+                                                                      NULL, NULL, NULL, NULL);
+        manager->priv->gsd_name_id = g_bus_own_name_on_connection (manager->priv->connection,
+                                                                   "org.gnome.SettingsDaemon",
+                                                                   G_BUS_NAME_OWNER_FLAGS_NONE,
+                                                                   NULL, NULL, NULL, NULL);
+
         g_dbus_proxy_new (manager->priv->connection,
                           G_DBUS_PROXY_FLAGS_NONE,
                           NULL,


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