OSDN Git Service

audio/player: Add implementation of MediaItem.AddToNowPlaying
authorLuiz Augusto von Dentz <luiz.von.dentz@intel.com>
Fri, 17 May 2013 11:48:27 +0000 (14:48 +0300)
committerLuiz Augusto von Dentz <luiz.von.dentz@intel.com>
Mon, 17 Jun 2013 15:13:54 +0000 (18:13 +0300)
profiles/audio/player.c

index d0ecc6c..701d366 100644 (file)
@@ -1408,7 +1408,23 @@ static DBusMessage *media_item_play(DBusConnection *conn, DBusMessage *msg,
 static DBusMessage *media_item_add_to_nowplaying(DBusConnection *conn,
                                                DBusMessage *msg, void *data)
 {
-       return btd_error_failed(msg, strerror(ENOTSUP));
+       struct media_item *item = data;
+       struct media_player *mp = item->player;
+       struct player_callback *cb = mp->cb;
+       int err;
+
+       if (!item->playable)
+               return btd_error_failed(msg, strerror(ENOTSUP));
+
+       if (cb->cbs->play_item == NULL)
+               return btd_error_failed(msg, strerror(ENOTSUP));
+
+       err = cb->cbs->add_to_nowplaying(mp, item->path, item->uid,
+                                                       cb->user_data);
+       if (err < 0)
+               return btd_error_failed(msg, strerror(-err));
+
+       return g_dbus_create_reply(msg, DBUS_TYPE_INVALID);
 }
 
 static gboolean item_name_exists(const GDBusPropertyTable *property,