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  * Copyright © 2022 UBports Foundation.
4  *
5  * Contact: Alberto Mardegan <mardy@users.sourceforge.net>
6  *
7  * This program is free software: you can redistribute it and/or modify it
8  * under the terms of the GNU Lesser General Public License version 3,
9  * as published by the Free Software Foundation.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public License
17  * along with this program. If not, see <http://www.gnu.org/licenses/>.
18  *
19  * Authored by: Thomas Voß <thomas.voss@canonical.com>
20  */
21 #ifndef LOMIRI_MEDIAHUBSERVICE_TRACK_LIST_SKELETON_H
22 #define LOMIRI_MEDIAHUBSERVICE_TRACK_LIST_SKELETON_H
23 
24 #include "apparmor/lomiri.h"
25 
26 #include <QDBusContext>
27 #include <QDBusObjectPath>
28 #include <QList>
29 #include <QObject>
30 #include <QScopedPointer>
31 #include <QStringList>
32 #include <QMap>
33 
34 class QDBusConnection;
35 
36 namespace lomiri
37 {
38 namespace MediaHubService
39 {
40 
41 class TrackListImplementation;
42 
43 class TrackListSkeletonPrivate;
44 class TrackListSkeleton: public QObject, protected QDBusContext
45 {
46  Q_OBJECT
47  Q_CLASSINFO("D-Bus Interface", "org.mpris.MediaPlayer2.TrackList")
48  // FIXME: this should be QDBusObjectPath, and not QString!
49  Q_PROPERTY(QStringList Tracks READ tracks)
50  Q_PROPERTY(bool CanEditTracks READ canEditTracks)
51 
52 public:
53  TrackListSkeleton(const QDBusConnection &bus,
54  const lomiri::MediaHubService::apparmor::lomiri::RequestContextResolver::Ptr& request_context_resolver,
55  const lomiri::MediaHubService::apparmor::lomiri::RequestAuthenticator::Ptr& request_authenticator,
57  QObject *parent = nullptr);
59 
60  QStringList tracks() const;
61  bool canEditTracks() const;
62 
63 public Q_SLOTS:
64  // FIXME: these should all be QDBusObjectPath, and not QStrings!
65  // FIXME: this should take a list, not just a single track;
66  // and it should return an aa{sv}, not a{ss}
67  QMap<QString,QString> GetTracksMetadata(const QString &id);
68  void AddTrack(const QString &uri, const QString &after, bool makeCurrent);
69  void RemoveTrack(const QString &id);
70  void GoTo(const QString &id);
71 
72  // Not in MPRIS:
73  QString GetTracksUri(const QString &id);
74  void AddTracks(const QStringList &uris, const QString &after);
75  void MoveTrack(const QString &id, const QString &to);
76  void Reset();
77 
78 Q_SIGNALS:
79  // FIXME: these should all be QDBusObjectPath, and not QStrings!
80  Q_SCRIPTABLE void TrackListReplaced(const QStringList &tracks,
81  const QString &currentTrack);
82  // FIXME: For this reason the signature of this signal does not
83  // match the MPRIS specification: the metadata is missing.
84  Q_SCRIPTABLE void TrackAdded(const QString &id);
85  Q_SCRIPTABLE void TrackRemoved(const QString &id);
86  // FIXME: the order of parameters is incorrect!
87  Q_SCRIPTABLE void TrackMetadataChanged(const QVariantMap &metadata,
88  const QDBusObjectPath &path);
89 
90  // Not in MPRIS:
91  Q_SCRIPTABLE void TracksAdded(const QStringList &trackURIs);
92  Q_SCRIPTABLE void TrackMoved(const QString &id, const QString &to);
93  Q_SCRIPTABLE void TrackChanged(const QString &id);
94  Q_SCRIPTABLE void TrackListReset();
95 
96 private:
97  Q_DECLARE_PRIVATE(TrackListSkeleton)
98  QScopedPointer<TrackListSkeletonPrivate> d_ptr;
99 };
100 
101 }
102 }
103 
104 #endif // LOMIRI_MEDIAHUBSERVICE_PROPERTY_H
QObject
lomiri::MediaHubService::TrackListSkeleton::GetTracksMetadata
QMap< QString, QString > GetTracksMetadata(const QString &id)
Definition: track_list_skeleton.cpp:135
lomiri::MediaHubService::TrackListSkeleton::canEditTracks
bool canEditTracks() const
Definition: track_list_skeleton.cpp:129
lomiri::MediaHubService::TrackListSkeleton::GoTo
void GoTo(const QString &id)
Definition: track_list_skeleton.cpp:327
lomiri::MediaHubService::TrackListSkeleton::TrackMetadataChanged
Q_SCRIPTABLE void TrackMetadataChanged(const QVariantMap &metadata, const QDBusObjectPath &path)
lomiri::MediaHubService::TrackListSkeleton::Tracks
QStringList Tracks
Definition: track_list_skeleton.h:49
lomiri::MediaHubService::TrackListSkeleton::CanEditTracks
bool CanEditTracks
Definition: track_list_skeleton.h:50
QDBusContext
lomiri::MediaHubService::TrackListSkeleton::TrackChanged
Q_SCRIPTABLE void TrackChanged(const QString &id)
lomiri::MediaHubService::TrackListSkeletonPrivate
Definition: track_list_skeleton.cpp:45
lomiri::MediaHubService::TrackListSkeleton::tracks
QStringList tracks() const
Definition: track_list_skeleton.cpp:118
lomiri::MediaHubService::TrackListSkeleton::AddTrack
void AddTrack(const QString &uri, const QString &after, bool makeCurrent)
Definition: track_list_skeleton.cpp:153
lomiri::MediaHubService::TrackListSkeleton
Definition: track_list_skeleton.h:44
lomiri::MediaHubService::TrackListSkeleton::TrackListReset
Q_SCRIPTABLE void TrackListReset()
lomiri::MediaHubService::TrackListSkeleton::AddTracks
void AddTracks(const QStringList &uris, const QString &after)
Definition: track_list_skeleton.cpp:215
lomiri::MediaHubService::TrackListSkeleton::TrackListReplaced
Q_SCRIPTABLE void TrackListReplaced(const QStringList &tracks, const QString &currentTrack)
lomiri::MediaHubService::TrackListSkeleton::TrackMoved
Q_SCRIPTABLE void TrackMoved(const QString &id, const QString &to)
lomiri::MediaHubService::TrackListSkeleton::TrackRemoved
Q_SCRIPTABLE void TrackRemoved(const QString &id)
lomiri::MediaHubService::TrackListSkeleton::TrackAdded
Q_SCRIPTABLE void TrackAdded(const QString &id)
lomiri.h
lomiri::MediaHubService::TrackListSkeleton::MoveTrack
void MoveTrack(const QString &id, const QString &to)
Definition: track_list_skeleton.cpp:286
lomiri::MediaHubService::apparmor
Definition: context.h:30
lomiri::MediaHubService::TrackListSkeleton::RemoveTrack
void RemoveTrack(const QString &id)
Definition: track_list_skeleton.cpp:315
lomiri::MediaHubService::TrackListSkeleton::GetTracksUri
QString GetTracksUri(const QString &id)
Definition: track_list_skeleton.cpp:147
lomiri
Definition: dbus_utils.h:24
lomiri::MediaHubService::TrackListSkeleton::TracksAdded
Q_SCRIPTABLE void TracksAdded(const QStringList &trackURIs)
lomiri::MediaHubService::TrackListImplementation
Definition: track_list_implementation.h:74
lomiri::MediaHubService::TrackListSkeleton::Reset
void Reset()
Definition: track_list_skeleton.cpp:333