Music Hub  ..
A session-wide music playback service
track_list_skeleton.h
Go to the documentation of this file.
1 /*
2  * Copyright © 2013 Canonical Ltd.
3  *
4  * This program is free software: you can redistribute it and/or modify it
5  * under the terms of the GNU Lesser General Public License version 3,
6  * as published by the Free Software Foundation.
7  *
8  * This program is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  * GNU Lesser General Public License for more details.
12  *
13  * You should have received a copy of the GNU Lesser General Public License
14  * along with this program. If not, see <http://www.gnu.org/licenses/>.
15  *
16  * Authored by: Thomas Voß <thomas.voss@canonical.com>
17  */
18 #ifndef CORE_UBUNTU_MEDIA_TRACK_LIST_SKELETON_H_
19 #define CORE_UBUNTU_MEDIA_TRACK_LIST_SKELETON_H_
20 
21 #include "apparmor/ubuntu.h"
22 
23 #include <core/media/track_list.h>
24 
25 #include <core/media/player.h>
26 
27 #include <core/dbus/object.h>
28 #include <core/dbus/skeleton.h>
29 
30 namespace core
31 {
32 namespace ubuntu
33 {
34 namespace media
35 {
37 {
38 public:
39  TrackListSkeleton(const core::dbus::Bus::Ptr& bus, const core::dbus::Object::Ptr& object,
43 
44  bool has_next();
45  bool has_previous();
46  Track::Id next();
48  const Track::Id& current();
49 
50  const core::Property<bool>& can_edit_tracks() const;
51  const core::Property<Container>& tracks() const;
52 
53  const core::Signal<ContainerTrackIdTuple>& on_track_list_replaced() const;
54  core::Signal<ContainerTrackIdTuple>& on_track_list_replaced();
55  const core::Signal<Track::Id>& on_track_added() const;
56  core::Signal<Track::Id>& on_track_added();
57  const core::Signal<ContainerURI>& on_tracks_added() const;
58  core::Signal<ContainerURI>& on_tracks_added();
59  const core::Signal<TrackIdTuple>& on_track_moved() const;
60  core::Signal<TrackIdTuple>& on_track_moved();
61  const core::Signal<Track::Id>& on_track_removed() const;
62  const core::Signal<void>& on_track_list_reset() const;
63  const core::Signal<Track::Id>& on_track_changed() const;
64  core::Signal<Track::Id>& on_track_changed();
65  const core::Signal<Track::Id>& on_go_to_track() const;
66  core::Signal<Track::Id>& on_go_to_track();
67  const core::Signal<void>& on_end_of_tracklist() const;
68  core::Signal<void>& on_end_of_tracklist();
69  core::Signal<Track::Id>& on_track_removed();
70  core::Signal<void>& on_track_list_reset();
71 
72  core::Property<Container>& tracks();
75 
76  void on_position_changed(uint64_t position);
77 
80  void on_shuffle_changed(bool shuffle);
81 
82  virtual void set_shuffle(bool shuffle) = 0;
83  virtual bool shuffle() = 0;
84  virtual const media::TrackList::Container& shuffled_tracks() = 0;
85 
86 protected:
87  inline bool is_first_track(const ConstIterator &it)
88  { return it == std::begin(tracks().get()); }
89  inline bool is_last_track(const ConstIterator &it)
90  { return it == std::end(tracks().get()); }
95  void set_current_track(const media::Track::Id& id);
97 
98  core::Property<bool>& can_edit_tracks();
99 
101 
102  void reset();
103 
104 private:
105  struct Private;
106  std::unique_ptr<Private> d;
107 };
108 
109 // operator<< pretty prints the given TrackList status to the given output stream.
110 std::ostream& operator<<(std::ostream& out, const core::ubuntu::media::TrackList& tracklist);
111 
112 }
113 }
114 }
115 #endif // CORE_UBUNTU_MEDIA_PROPERTY_H_
const core::Signal< Track::Id > & on_go_to_track() const
media::Track::Id get_current_track(void)
const core::Property< Container > & tracks() const
virtual void set_shuffle(bool shuffle)=0
const core::Signal< Track::Id > & on_track_changed() const
Definition: player.h:33
const core::Signal< Track::Id > & on_track_removed() const
std::ostream & operator<<(std::ostream &out, Player::PlaybackStatus status)
Definition: player.h:198
std::shared_ptr< RequestContextResolver > Ptr
Definition: ubuntu.h:94
void set_current_track(const media::Track::Id &id)
void on_position_changed(uint64_t position)
const core::Signal< void > & on_end_of_tracklist() const
const core::Signal< ContainerURI > & on_tracks_added() const
core::ubuntu::media::Player::LoopStatus loop_status() const
const core::Signal< ContainerTrackIdTuple > & on_track_list_replaced() const
TrackList::ConstIterator get_current_shuffled()
bool update_current_iterator(const TrackList::ConstIterator &it)
const core::Signal< Track::Id > & on_track_added() const
bool is_last_track(const ConstIterator &it)
void on_loop_status_changed(const core::ubuntu::media::Player::LoopStatus &loop_status)
virtual const media::TrackList::Container & shuffled_tracks()=0
std::vector< Track::Id > Container
Definition: track_list.h:43
const core::Signal< TrackIdTuple > & on_track_moved() const
const core::Signal< void > & on_track_list_reset() const
bool is_first_track(const ConstIterator &it)
std::shared_ptr< RequestAuthenticator > Ptr
Definition: ubuntu.h:134
const core::Property< bool > & can_edit_tracks() const
Container::const_iterator ConstIterator
Definition: track_list.h:48
const TrackList::ConstIterator & current_iterator()
TrackListSkeleton(const core::dbus::Bus::Ptr &bus, const core::dbus::Object::Ptr &object, const core::ubuntu::media::apparmor::ubuntu::RequestContextResolver::Ptr &request_context_resolver, const core::ubuntu::media::apparmor::ubuntu::RequestAuthenticator::Ptr &request_authenticator)