diff -uNrp a/plugins/media-keys/bus-watch-namespace.c b/plugins/media-keys/bus-watch-namespace.c
--- a/plugins/media-keys/bus-watch-namespace.c 1970-01-01 01:00:00.000000000 +0100
+++ b/plugins/media-keys/bus-watch-namespace.c 2013-11-04 10:41:10.925022405 +0000
@@ -0,0 +1,347 @@
+/*
+ * Copyright 2013 Canonical Ltd.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * Author: Lars Uebernickel <lars.uebernickel@canonical.com>
+ */
+
+#include <gio/gio.h>
+#include <string.h>
+#include "bus-watch-namespace.h"
+
+typedef struct
+{
+ guint id;
+ gchar *name_space;
+ GBusNameAppearedCallback appeared_handler;
+ GBusNameVanishedCallback vanished_handler;
+ gpointer user_data;
+ GDestroyNotify user_data_destroy;
+
+ GDBusConnection *connection;
+ GCancellable *cancellable;
+ GHashTable *names;
+ guint subscription_id;
+} NamespaceWatcher;
+
+typedef struct
+{
+ NamespaceWatcher *watcher;
+ gchar *name;
+} GetNameOwnerData;
+
+static guint namespace_watcher_next_id;
+static GHashTable *namespace_watcher_watchers;
+
+static void
+namespace_watcher_stop (gpointer data)
+{
+ NamespaceWatcher *watcher = data;
+
+ g_cancellable_cancel (watcher->cancellable);
+ g_object_unref (watcher->cancellable);
+
+ if (watcher->subscription_id)
+ g_dbus_connection_signal_unsubscribe (watcher->connection, watcher->subscription_id);
+
+ if (watcher->vanished_handler)
+ {
+ GHashTableIter it;
+ const gchar *name;
+
+ g_hash_table_iter_init (&it, watcher->names);
+ while (g_hash_table_iter_next (&it, (gpointer *) &name, NULL))
+ watcher->vanished_handler (watcher->connection, name, watcher->user_data);
+ }
+
+ if (watcher->user_data_destroy)
+ watcher->user_data_destroy (watcher->user_data);
+
+ if (watcher->connection)
+ {
+ g_signal_handlers_disconnect_by_func (watcher->connection, namespace_watcher_stop, watcher);
+ g_object_unref (watcher->connection);
+ }
+
+ g_hash_table_unref (watcher->names);
+
+ g_hash_table_remove (namespace_watcher_watchers, GUINT_TO_POINTER (watcher->id));
+ if (g_hash_table_size (namespace_watcher_watchers) == 0)
+ g_clear_pointer (&namespace_watcher_watchers, g_hash_table_destroy);
+
+ g_free (watcher);
+}
+
+static void
+namespace_watcher_name_appeared (NamespaceWatcher *watcher,
+ const gchar *name,
+ const gchar *owner)
+{
+ /* There's a race between NameOwnerChanged signals arriving and the
+ * ListNames/GetNameOwner sequence returning, so this function might
+ * be called more than once for the same name. To ensure that
+ * appeared_handler is only called once for each name, it is only
+ * called when inserting the name into watcher->names (each name is
+ * only inserted once there).
+ */
+ if (g_hash_table_contains (watcher->names, name))
+ return;
+
+ g_hash_table_add (watcher->names, g_strdup (name));
+
+ if (watcher->appeared_handler)
+ watcher->appeared_handler (watcher->connection, name, owner, watcher->user_data);
+}
+
+static void
+namespace_watcher_name_vanished (NamespaceWatcher *watcher,
+ const gchar *name)
+{
+ if (g_hash_table_remove (watcher->names, name) && watcher->vanished_handler)
+ watcher->vanished_handler (watcher->connection, name, watcher->user_data);
+}
+
+static gboolean
+dbus_name_has_namespace (const gchar *name,
+ const gchar *name_space)
+{
+ gint len_name;
+ gint len_namespace;
+
+ len_name = strlen (name);
+ len_namespace = strlen (name_space);
+
+ if (len_name < len_namespace)
+ return FALSE;
+
+ if (memcmp (name_space, name, len_namespace) != 0)
+ return FALSE;
+
+ return len_namespace == len_name || name[len_namespace] == '.';
+}
+
+static void
+name_owner_changed (GDBusConnection *connection,
+ const gchar *sender_name,
+ const gchar *object_path,
+ const gchar *interface_name,
+ const gchar *signal_name,
+ GVariant *parameters,
+ gpointer user_data)
+{
+ NamespaceWatcher *watcher = user_data;
+ const gchar *name;
+ const gchar *old_owner;
+ const gchar *new_owner;
+
+ g_variant_get (parameters, "(&s&s&s)", &name, &old_owner, &new_owner);
+
+ if (old_owner[0] != '\0')
+ namespace_watcher_name_vanished (watcher, name);
+
+ if (new_owner[0] != '\0')
+ namespace_watcher_name_appeared (watcher, name, new_owner);
+}
+
+static void
+got_name_owner (GObject *object,
+ GAsyncResult *result,
+ gpointer user_data)
+{
+ GetNameOwnerData *data = user_data;
+ GError *error = NULL;
+ GVariant *reply;
+ const gchar *owner;
+
+ reply = g_dbus_connection_call_finish (G_DBUS_CONNECTION (object), result, &error);
+
+ if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
+ {
+ g_error_free (error);
+ goto out;
+ }
+
+ if (reply == NULL)
+ {
+ if (!g_error_matches (error, G_DBUS_ERROR, G_DBUS_ERROR_NAME_HAS_NO_OWNER))
+ g_warning ("bus_watch_namespace: error calling org.freedesktop.DBus.GetNameOwner: %s", error->message);
+ g_error_free (error);
+ goto out;
+ }
+
+ g_variant_get (reply, "(&s)", &owner);
+ namespace_watcher_name_appeared (data->watcher, data->name, owner);
+
+ g_variant_unref (reply);
+
+out:
+ g_free (data->name);
+ g_slice_free (GetNameOwnerData, data);
+}
+
+static void
+names_listed (GObject *object,
+ GAsyncResult *result,
+ gpointer user_data)
+{
+ NamespaceWatcher *watcher;
+ GError *error = NULL;
+ GVariant *reply;
+ GVariantIter *iter;
+ const gchar *name;
+
+ reply = g_dbus_connection_call_finish (G_DBUS_CONNECTION (object), result, &error);
+
+ if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
+ {
+ g_error_free (error);
+ return;
+ }
+
+ watcher = user_data;
+
+ if (reply == NULL)
+ {
+ g_warning ("bus_watch_namespace: error calling org.freedesktop.DBus.ListNames: %s", error->message);
+ g_error_free (error);
+ return;
+ }
+
+ g_variant_get (reply, "(as)", &iter);
+ while (g_variant_iter_next (iter, "&s", &name))
+ {
+ if (dbus_name_has_namespace (name, watcher->name_space))
+ {
+ GetNameOwnerData *data = g_slice_new (GetNameOwnerData);
+ data->watcher = watcher;
+ data->name = g_strdup (name);
+ g_dbus_connection_call (watcher->connection, "org.freedesktop.DBus", "/",
+ "org.freedesktop.DBus", "GetNameOwner",
+ g_variant_new ("(s)", name), G_VARIANT_TYPE ("(s)"),
+ G_DBUS_CALL_FLAGS_NONE, -1, watcher->cancellable,
+ got_name_owner, data);
+ }
+ }
+
+ g_variant_iter_free (iter);
+ g_variant_unref (reply);
+}
+
+static void
+connection_closed (GDBusConnection *connection,
+ gboolean remote_peer_vanished,
+ GError *error,
+ gpointer user_data)
+{
+ NamespaceWatcher *watcher = user_data;
+
+ namespace_watcher_stop (watcher);
+}
+
+static void
+got_bus (GObject *object,
+ GAsyncResult *result,
+ gpointer user_data)
+{
+ GDBusConnection *connection;
+ NamespaceWatcher *watcher;
+ GError *error = NULL;
+
+ connection = g_bus_get_finish (result, &error);
+
+ if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
+ {
+ g_error_free (error);
+ return;
+ }
+
+ watcher = user_data;
+
+ if (connection == NULL)
+ {
+ namespace_watcher_stop (watcher);
+ return;
+ }
+
+ watcher->connection = connection;
+ g_signal_connect (watcher->connection, "closed", G_CALLBACK (connection_closed), watcher);
+
+ watcher->subscription_id =
+ g_dbus_connection_signal_subscribe (watcher->connection, "org.freedesktop.DBus",
+ "org.freedesktop.DBus", "NameOwnerChanged", "/org/freedesktop/DBus",
+ watcher->name_space, G_DBUS_SIGNAL_FLAGS_MATCH_ARG0_NAMESPACE,
+ name_owner_changed, watcher, NULL);
+
+ g_dbus_connection_call (watcher->connection, "org.freedesktop.DBus", "/",
+ "org.freedesktop.DBus", "ListNames", NULL, G_VARIANT_TYPE ("(as)"),
+ G_DBUS_CALL_FLAGS_NONE, -1, watcher->cancellable,
+ names_listed, watcher);
+}
+
+guint
+bus_watch_namespace (GBusType bus_type,
+ const gchar *name_space,
+ GBusNameAppearedCallback appeared_handler,
+ GBusNameVanishedCallback vanished_handler,
+ gpointer user_data,
+ GDestroyNotify user_data_destroy)
+{
+ NamespaceWatcher *watcher;
+
+ /* same rules for interfaces and well-known names */
+ g_return_val_if_fail (name_space != NULL && g_dbus_is_interface_name (name_space), 0);
+ g_return_val_if_fail (appeared_handler || vanished_handler, 0);
+
+ watcher = g_new0 (NamespaceWatcher, 1);
+ watcher->id = namespace_watcher_next_id++;
+ watcher->name_space = g_strdup (name_space);
+ watcher->appeared_handler = appeared_handler;
+ watcher->vanished_handler = vanished_handler;
+ watcher->user_data = user_data;
+ watcher->user_data_destroy = user_data_destroy;
+ watcher->cancellable = g_cancellable_new ();;
+ watcher->names = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL);
+
+ if (namespace_watcher_watchers == NULL)
+ namespace_watcher_watchers = g_hash_table_new (g_direct_hash, g_direct_equal);
+ g_hash_table_insert (namespace_watcher_watchers, GUINT_TO_POINTER (watcher->id), watcher);
+
+ g_bus_get (bus_type, watcher->cancellable, got_bus, watcher);
+
+ return watcher->id;
+}
+
+void
+bus_unwatch_namespace (guint id)
+{
+ /* namespace_watcher_stop() might have already removed the watcher
+ * with @id in the case of a connection error. Thus, this function
+ * doesn't warn when @id is absent from the hash table.
+ */
+
+ if (namespace_watcher_watchers)
+ {
+ NamespaceWatcher *watcher;
+
+ watcher = g_hash_table_lookup (namespace_watcher_watchers, GUINT_TO_POINTER (id));
+ if (watcher)
+ {
+ /* make sure vanished() is not called as a result of this function */
+ g_hash_table_remove_all (watcher->names);
+
+ namespace_watcher_stop (watcher);
+ }
+ }
+}
diff -uNrp a/plugins/media-keys/bus-watch-namespace.h b/plugins/media-keys/bus-watch-namespace.h
--- a/plugins/media-keys/bus-watch-namespace.h 1970-01-01 01:00:00.000000000 +0100
+++ b/plugins/media-keys/bus-watch-namespace.h 2013-11-04 10:41:10.926022360 +0000
@@ -0,0 +1,34 @@
+/*
+ * Copyright 2013 Canonical Ltd.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * Author: Lars Uebernickel <lars.uebernickel@canonical.com>
+ */
+
+#ifndef __BUS_WATCH_NAMESPACE_H__
+#define __BUS_WATCH_NAMESPACE_H__
+
+#include <gio/gio.h>
+
+guint bus_watch_namespace (GBusType bus_type,
+ const gchar *name_space,
+ GBusNameAppearedCallback appeared_handler,
+ GBusNameVanishedCallback vanished_handler,
+ gpointer user_data,
+ GDestroyNotify user_data_destroy);
+
+void bus_unwatch_namespace (guint id);
+
+#endif
diff -uNrp a/plugins/media-keys/csd-media-keys-manager.c b/plugins/media-keys/csd-media-keys-manager.c
--- a/plugins/media-keys/csd-media-keys-manager.c 2013-11-03 15:50:04.000000000 +0000
+++ b/plugins/media-keys/csd-media-keys-manager.c 2013-11-04 11:14:29.158446609 +0000
@@ -44,6 +44,7 @@
#include <gudev/gudev.h>
#endif
+#include "mpris-controller.h"
#include "cinnamon-settings-profile.h"
#include "csd-marshal.h"
#include "csd-media-keys-manager.h"
@@ -186,6 +187,8 @@ struct CsdMediaKeysManagerPrivate
guint start_idle_id;
+ MprisController *mpris_controller;
+
/* Ubuntu notifications */
NotifyNotification *volume_notification;
NotifyNotification *brightness_notification;
@@ -1281,12 +1284,14 @@ csd_media_player_key_pressed (CsdMediaKe
have_listeners = (manager->priv->media_players != NULL);
if (!have_listeners) {
+ if (!mpris_controller_key (manager->priv->mpris_controller, key)) {
/* Popup a dialog with an (/) icon */
dialog_init (manager);
csd_osd_window_set_action_custom (CSD_OSD_WINDOW (manager->priv->dialog),
"action-unavailable-symbolic",
FALSE);
dialog_show (manager);
+ }
return TRUE;
}
@@ -2136,6 +2141,9 @@ start_media_keys_idle_cb (CsdMediaKeysMa
g_free(sound);
g_object_unref (settings);
+ g_debug ("Starting mpris controller");
+ manager->priv->mpris_controller = mpris_controller_new ();
+
cinnamon_settings_profile_end (NULL);
manager->priv->start_idle_id = 0;
@@ -2258,6 +2266,11 @@ csd_media_keys_manager_stop (CsdMediaKey
priv->power_keyboard_proxy = NULL;
}
+ if (priv->mpris_controller) {
+ g_object_unref (priv->mpris_controller);
+ priv->mpris_controller = NULL;
+ }
+
if (priv->upower_proxy) {
g_object_unref (priv->upower_proxy);
priv->upower_proxy = NULL;
diff -uNrp a/plugins/media-keys/Makefile.am b/plugins/media-keys/Makefile.am
--- a/plugins/media-keys/Makefile.am 2013-11-03 15:50:04.000000000 +0000
+++ b/plugins/media-keys/Makefile.am 2013-11-04 10:43:23.308286574 +0000
@@ -28,6 +28,10 @@ libmedia_keys_la_SOURCES = \
csd-osd-window.h \
csd-osd-window-private.h \
shortcuts-list.h \
+ bus-watch-namespace.c \
+ bus-watch-namespace.h \
+ mpris-controller.c \
+ mpris-controller.h \
$(BUILT_SOURCES) \
$(NULL)
@@ -101,6 +105,10 @@ csd_test_media_keys_SOURCES = \
csd-osd-window.c \
csd-osd-window.h \
csd-osd-window-private.h \
+ bus-watch-namespace.c \
+ bus-watch-namespace.h \
+ mpris-controller.c \
+ mpris-controller.h \
test-media-keys.c \
$(BUILT_SOURCES) \
$(NULL)
diff -uNrp a/plugins/media-keys/mpris-controller.c b/plugins/media-keys/mpris-controller.c
--- a/plugins/media-keys/mpris-controller.c 1970-01-01 01:00:00.000000000 +0100
+++ b/plugins/media-keys/mpris-controller.c 2013-11-04 10:58:55.607910850 +0000
@@ -0,0 +1,209 @@
+/*
+ * Copyright © 2013 Intel Corporation.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms and conditions of the GNU Lesser General Public License,
+ * version 2.1, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, see <http://www.gnu.org/licenses>
+ *
+ * Author: Michael Wood <michael.g.wood@intel.com>
+ */
+
+#include "mpris-controller.h"
+#include "bus-watch-namespace.h"
+#include <gio/gio.h>
+
+G_DEFINE_TYPE (MprisController, mpris_controller, G_TYPE_OBJECT)
+
+#define CONTROLLER_PRIVATE(o) \
+ (G_TYPE_INSTANCE_GET_PRIVATE ((o), MPRIS_TYPE_CONTROLLER, MprisControllerPrivate))
+
+struct _MprisControllerPrivate
+{
+ GCancellable *cancellable;
+ GDBusProxy *mpris_client_proxy;
+ guint namespace_watcher_id;
+ GSList *other_players;
+ gboolean connecting;
+};
+
+
+static void
+mpris_controller_dispose (GObject *object)
+{
+ MprisControllerPrivate *priv = MPRIS_CONTROLLER (object)->priv;
+
+ g_clear_object (&priv->cancellable);
+ g_clear_object (&priv->mpris_client_proxy);
+
+ if (priv->namespace_watcher_id)
+ {
+ bus_unwatch_namespace (priv->namespace_watcher_id);
+ priv->namespace_watcher_id = 0;
+ }
+
+ if (priv->other_players)
+ {
+ g_slist_free_full (priv->other_players, g_free);
+ priv->other_players = NULL;
+ }
+
+ G_OBJECT_CLASS (mpris_controller_parent_class)->dispose (object);
+}
+
+static void
+mpris_proxy_call_done (GObject *object,
+ GAsyncResult *res,
+ gpointer user_data)
+{
+ GError *error = NULL;
+ GVariant *ret;
+
+ if (!(ret = g_dbus_proxy_call_finish (G_DBUS_PROXY (object), res, &error)))
+ {
+ g_warning ("Error calling method %s", error->message);
+ g_clear_error (&error);
+ return;
+ }
+ g_variant_unref (ret);
+}
+
+gboolean
+mpris_controller_key (MprisController *self, const gchar *key)
+{
+ MprisControllerPrivate *priv = MPRIS_CONTROLLER (self)->priv;
+
+ if (!priv->mpris_client_proxy)
+ return FALSE;
+
+ g_debug ("calling %s over dbus to mpris client %s",
+ key, g_dbus_proxy_get_name (priv->mpris_client_proxy));
+ g_dbus_proxy_call (priv->mpris_client_proxy,
+ key, NULL, 0, -1, priv->cancellable,
+ mpris_proxy_call_done,
+ NULL);
+ return TRUE;
+}
+
+static void
+mpris_proxy_ready_cb (GObject *object,
+ GAsyncResult *res,
+ gpointer user_data)
+{
+ MprisControllerPrivate *priv = MPRIS_CONTROLLER (user_data)->priv;
+ GError *error = NULL;
+
+ priv->mpris_client_proxy = g_dbus_proxy_new_for_bus_finish (res, &error);
+
+ if (!priv->mpris_client_proxy)
+ g_warning ("Error connecting to mpris interface %s", error->message);
+
+ g_clear_error (&error);
+}
+
+static void
+start_mpris_proxy (MprisController *self, const gchar *name)
+{
+ MprisControllerPrivate *priv = MPRIS_CONTROLLER (self)->priv;
+
+ g_debug ("Creating proxy for for %s", name);
+ g_dbus_proxy_new_for_bus (G_BUS_TYPE_SESSION,
+ 0,
+ NULL,
+ name,
+ "/org/mpris/MediaPlayer2",
+ "org.mpris.MediaPlayer2.Player",
+ priv->cancellable,
+ mpris_proxy_ready_cb,
+ self);
+ priv->connecting = TRUE;
+}
+
+static void
+mpris_player_appeared (GDBusConnection *connection,
+ const gchar *name,
+ const gchar *name_owner,
+ gpointer user_data)
+{
+ MprisController *self = user_data;
+ MprisControllerPrivate *priv = MPRIS_CONTROLLER (self)->priv;
+
+ if (priv->mpris_client_proxy == NULL && !priv->connecting)
+ start_mpris_proxy (self, name);
+ else
+ self->priv->other_players = g_slist_prepend (self->priv->other_players, g_strdup (name));
+}
+
+static void
+mpris_player_vanished (GDBusConnection *connection,
+ const gchar *name,
+ gpointer user_data)
+{
+ MprisController *self = user_data;
+ MprisControllerPrivate *priv = MPRIS_CONTROLLER (self)->priv;
+
+ if (priv->mpris_client_proxy &&
+ g_strcmp0 (name, g_dbus_proxy_get_name (priv->mpris_client_proxy)) == 0)
+ {
+ g_clear_object (&priv->mpris_client_proxy);
+
+ /* take the next one if there's one */
+ if (self->priv->other_players && !priv->connecting)
+ {
+ GSList *first;
+ gchar *name;
+
+ first = self->priv->other_players;
+ name = first->data;
+
+ start_mpris_proxy (self, name);
+
+ self->priv->other_players = self->priv->other_players->next;
+ g_free (name);
+ g_slist_free_1 (first);
+ }
+ }
+}
+
+static void
+mpris_controller_constructed (GObject *object)
+{
+ MprisControllerPrivate *priv = MPRIS_CONTROLLER (object)->priv;
+
+ priv->namespace_watcher_id = bus_watch_namespace (G_BUS_TYPE_SESSION,
+ "org.mpris.MediaPlayer2",
+ mpris_player_appeared,
+ mpris_player_vanished,
+ MPRIS_CONTROLLER (object),
+ NULL);
+}
+
+static void
+mpris_controller_class_init (MprisControllerClass *klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+ g_type_class_add_private (klass, sizeof (MprisControllerPrivate));
+
+ object_class->constructed = mpris_controller_constructed;
+ object_class->dispose = mpris_controller_dispose;
+}
+
+static void
+mpris_controller_init (MprisController *self)
+{
+ self->priv = CONTROLLER_PRIVATE (self);
+}
+
+MprisController *
+mpris_controller_new (void)
+{
+ return g_object_new (MPRIS_TYPE_CONTROLLER, NULL);
+}
diff -uNrp a/plugins/media-keys/mpris-controller.h b/plugins/media-keys/mpris-controller.h
--- a/plugins/media-keys/mpris-controller.h 1970-01-01 01:00:00.000000000 +0100
+++ b/plugins/media-keys/mpris-controller.h 2013-11-04 10:58:55.607910850 +0000
@@ -0,0 +1,56 @@
+/*
+ * Copyright © 2013 Intel Corporation.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms and conditions of the GNU Lesser General Public License,
+ * version 2.1, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, see <http://www.gnu.org/licenses>
+ *
+ * Author: Michael Wood <michael.g.wood@intel.com>
+ */
+
+#ifndef __MPRIS_CONTROLLER_H__
+#define __MPRIS_CONTROLLER_H__
+
+#include <glib-object.h>
+
+G_BEGIN_DECLS
+
+#define MPRIS_TYPE_CONTROLLER mpris_controller_get_type()
+#define MPRIS_CONTROLLER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), MPRIS_TYPE_CONTROLLER, MprisController))
+#define MPRIS_CONTROLLER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), MPRIS_TYPE_CONTROLLER, MprisControllerClass))
+#define MPRIS_IS_CONTROLLER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), MPRIS_TYPE_CONTROLLER))
+#define MPRIS_IS_CONTROLLER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), MPRIS_TYPE_CONTROLLER))
+#define MPRIS_CONTROLLER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), MPRIS_TYPE_CONTROLLER, MprisControllerClass))
+
+typedef struct _MprisController MprisController;
+typedef struct _MprisControllerClass MprisControllerClass;
+typedef struct _MprisControllerPrivate MprisControllerPrivate;
+
+struct _MprisController
+{
+ GObject parent;
+
+ MprisControllerPrivate *priv;
+};
+
+struct _MprisControllerClass
+{
+ GObjectClass parent_class;
+};
+
+GType mpris_controller_get_type (void) G_GNUC_CONST;
+
+MprisController *mpris_controller_new (void);
+gboolean mpris_controller_key (MprisController *self, const gchar *key);
+
+G_END_DECLS
+
+#endif /* __MPRIS_CONTROLLER_H__ */