public void Dispose()
        {
            if (settings_daemon_222 != null)
            {
                settings_daemon_222.MediaPlayerKeyPressed -= OnMediaPlayerKeyPressed;
                settings_daemon_222.ReleaseMediaPlayerKeys(app_name);
                settings_daemon_222 = null;
            }

            if (settings_daemon_220 != null)
            {
                settings_daemon_220.MediaPlayerKeyPressed -= OnMediaPlayerKeyPressed;
                settings_daemon_220.ReleaseMediaPlayerKeys(app_name);
                settings_daemon_220 = null;
            }
        }
        public void Dispose()
        {
            if (settings_daemon_222 != null)
            {
                settings_daemon_222.MediaPlayerKeyPressed -= OnMediaPlayerKeyPressed;
                settings_daemon_222.ReleaseMediaPlayerKeys(Application.InternalName);
                settings_daemon_222 = null;
            }

            if (settings_daemon_220 != null)
            {
                settings_daemon_220.MediaPlayerKeyPressed -= OnMediaPlayerKeyPressed;
                settings_daemon_220.ReleaseMediaPlayerKeys(Application.InternalName);
                settings_daemon_220 = null;
            }
        }
        void IExtensionService.Initialize()
        {
            // It's a common theme in GNOME for APIs to change every 6 months
            // We are essentially an ISV, and actually care about backwards
            // compatibility! Therefore, fall back to the interface for GNOME 2.20
            // if the GNOME 2.22 interface cannot be found.
            //
            // Additionally, there is a design limitation in Managed DBus that restricts
            // it from flattening/following managed interfaces, therefore we must
            // explicitly handle two different GSD objects as if they had nothing in
            // common at this point. This at least will be fixed in Managed DBus.
            //
            // For instance, we can't do this currently (semi-pseudo-code):
            //
            //    interface IGsdBase { void Food (); }
            //    [Interface ("org.gnome.SettingsDaemon")] interface IGsd220 : IGsdBase { }
            //    [Interface ("org.gnome.SettingsDaemon.MediaKeys")] interface IGsd222 : IGsdBase { }
            //
            //    IGsdBase gsd = bus.GetObject<IGsd222> (name, path_222)
            //    if (gsd == null)
            //        gsd = bus.GetObject<IGsd220> (name, path_220)
            //    gsd.Foo ();
            //

            try {
                settings_daemon_222 = Bus.Session.GetObject <ISettingsDaemon222> (BusName,
                                                                                  new ObjectPath(ObjectPath + "/MediaKeys"));
                settings_daemon_222.GrabMediaPlayerKeys(app_name, 0);
                settings_daemon_222.MediaPlayerKeyPressed += OnMediaPlayerKeyPressed;

                Log.Debug("Using GNOME 2.22 API for Multimedia Keys");
            } catch {
                settings_daemon_222 = null;

                try {
                    settings_daemon_220 = Bus.Session.GetObject <ISettingsDaemon220> (BusName,
                                                                                      new ObjectPath(ObjectPath));
                    settings_daemon_220.GrabMediaPlayerKeys(app_name, 0);
                    settings_daemon_220.MediaPlayerKeyPressed += OnMediaPlayerKeyPressed;

                    Log.Debug("Using GNOME 2.20 API for Multimedia keys");
                } catch {
                    settings_daemon_220 = null;
                    throw new ApplicationException("No support GNOME Settings Daemon could be reached.");
                }
            }
        }
        void IExtensionService.Initialize ()
        {
            // It's a common theme in GNOME for APIs to change every 6 months
            // We are essentially an ISV, and actually care about backwards
            // compatibility! Therefore, fall back to the interface for GNOME 2.20
            // if the GNOME 2.22 interface cannot be found.
            //
            // Additionally, there is a design limitation in Managed DBus that restricts
            // it from flattening/following managed interfaces, therefore we must
            // explicitly handle two different GSD objects as if they had nothing in
            // common at this point. This at least will be fixed in Managed DBus.
            //
            // For instance, we can't do this currently (semi-pseudo-code):
            //
            //    interface IGsdBase { void Food (); }
            //    [Interface ("org.gnome.SettingsDaemon")] interface IGsd220 : IGsdBase { }
            //    [Interface ("org.gnome.SettingsDaemon.MediaKeys")] interface IGsd222 : IGsdBase { }
            //
            //    IGsdBase gsd = bus.GetObject<IGsd222> (name, path_222)
            //    if (gsd == null)
            //        gsd = bus.GetObject<IGsd220> (name, path_220)
            //    gsd.Foo ();
            //

            try {
                settings_daemon_222 = Bus.Session.GetObject<ISettingsDaemon222> (BusName,
                    new ObjectPath (ObjectPath + "/MediaKeys"));
                settings_daemon_222.GrabMediaPlayerKeys (app_name, 0);
                settings_daemon_222.MediaPlayerKeyPressed += OnMediaPlayerKeyPressed;

                Log.Debug ("Using GNOME 2.22 API for Multimedia Keys");
            } catch {
                settings_daemon_222 = null;

                try {
                    settings_daemon_220 = Bus.Session.GetObject<ISettingsDaemon220> (BusName,
                        new ObjectPath (ObjectPath));
                    settings_daemon_220.GrabMediaPlayerKeys (app_name, 0);
                    settings_daemon_220.MediaPlayerKeyPressed += OnMediaPlayerKeyPressed;

                    Log.Debug ("Using GNOME 2.20 API for Multimedia keys");
                } catch {
                    settings_daemon_220 = null;
                    throw new ApplicationException ("No support GNOME Settings Daemon could be reached.");
                }
            }
        }
        public void Dispose ()
        {
            if (settings_daemon_222 != null) {
                settings_daemon_222.MediaPlayerKeyPressed -= OnMediaPlayerKeyPressed;
                settings_daemon_222.ReleaseMediaPlayerKeys (app_name);
                settings_daemon_222 = null;
            }

            if (settings_daemon_220 != null) {
                settings_daemon_220.MediaPlayerKeyPressed -= OnMediaPlayerKeyPressed;
                settings_daemon_220.ReleaseMediaPlayerKeys (app_name);
                settings_daemon_220 = null;
            }
        }