Debian Codegraph @

tests/service-mocks/media-player-mpris-mock/MediaPlayerMprisMock.cpp

raw
1 /*
2 * Copyright (C) 2015 Canonical Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License version 3, as published
6 * by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranties of
10 * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
11 * PURPOSE. See the GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License along
14 * with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Author: Xavi Garcia <[email protected]>
17 */
18 #include <QDebug>
19
20 #include "MediaPlayerMprisMock.h"
21
22 using namespace ayatana::indicators::testing;
23
24 MediaPlayerMprisMock::MediaPlayerMprisMock(QString const &playerName, QObject* parent)
25 : QObject(parent)
26 , can_play_(true)
27 , can_pause_(true)
28 , can_gonext_(true)
29 , can_goprevious_(true)
30 , player_name_(playerName)
31 {
32 }
33
34 MediaPlayerMprisMock::~MediaPlayerMprisMock() = default;
35
36 bool MediaPlayerMprisMock::canPlay() const
37 {
38 return can_play_;
39 }
40
41 void MediaPlayerMprisMock::setCanPlay(bool canPlay)
42 {
43 can_play_ = canPlay;
44 notifier_.notifyPropertyChanged(QDBusConnection::sessionBus(),
45 "org.mpris.MediaPlayer2.Player",
46 "/org/mpris/MediaPlayer2",
47 "CanPlay",
48 property("CanPlay"));
49 }
50
51 bool MediaPlayerMprisMock::canPause() const
52 {
53 return can_pause_;
54 }
55
56 void MediaPlayerMprisMock::setCanPause(bool canPause)
57 {
58 can_pause_ = canPause;
59 notifier_.notifyPropertyChanged(QDBusConnection::sessionBus(),
60 "org.mpris.MediaPlayer2.Player",
61 "/org/mpris/MediaPlayer2",
62 "CanPause",
63 property("CanPause"));
64 }
65
66 bool MediaPlayerMprisMock::canGoNext() const
67 {
68 return can_gonext_;
69 }
70
71 void MediaPlayerMprisMock::setCanGoNext(bool canGoNext)
72 {
73 can_gonext_ = canGoNext;
74 notifier_.notifyPropertyChanged(QDBusConnection::sessionBus(),
75 "org.mpris.MediaPlayer2.Player",
76 "/org/mpris/MediaPlayer2",
77 "CanGoNext",
78 property("CanGoNext"));
79 }
80
81 bool MediaPlayerMprisMock::canGoPrevious() const
82 {
83 return can_goprevious_;
84 }
85
86 void MediaPlayerMprisMock::setCanGoPrevious(bool canGoPrevious)
87 {
88 can_goprevious_ = canGoPrevious;
89 notifier_.notifyPropertyChanged(QDBusConnection::sessionBus(),
90 "org.mpris.MediaPlayer2.Player",
91 "/org/mpris/MediaPlayer2",
92 "CanGoPrevious",
93 property("CanGoPrevious"));
94 }
95
96 QString MediaPlayerMprisMock::desktopEntry() const
97 {
98 return player_name_;
99 }
100
101 void MediaPlayerMprisMock::setDesktopEntry(QString const &)
102 {
103 }