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



commit 33d47e655606ac88ed7d529c1132e5be6299633b
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.
    
    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 |   12 ++++++++++++
 1 files changed, 12 insertions(+), 0 deletions(-)
---
diff --git a/plugins/media-keys/gsd-media-keys-manager.c b/plugins/media-keys/gsd-media-keys-manager.c
index e868c8a..33a42d4 100644
--- a/plugins/media-keys/gsd-media-keys-manager.c
+++ b/plugins/media-keys/gsd-media-keys-manager.c
@@ -222,6 +222,8 @@ struct GsdMediaKeysManagerPrivate
 
         guint            start_idle_id;
 
+        /* Multimedia keys */
+        guint            mmkeys_name_id;
         MprisController *mpris_controller;
 };
 
@@ -2925,6 +2927,11 @@ 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->bus_cancellable != NULL) {
                 g_cancellable_cancel (priv->bus_cancellable);
                 g_object_unref (priv->bus_cancellable);
@@ -3226,6 +3233,11 @@ 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);
+
         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]