Music Hub ..
A session-wide music playback service
external_services.h
Go to the documentation of this file.
1/*
2 * Copyright © 2014 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_EXTERNAL_SERVICES_H_
19#define CORE_UBUNTU_MEDIA_EXTERNAL_SERVICES_H_
20
21#include <core/dbus/bus.h>
22
23#include <core/dbus/asio/executor.h>
24
25#include <boost/asio.hpp>
26
27namespace core
28{
29namespace ubuntu
30{
31namespace media
32{
33namespace helper
34{
35// A helper struct that bundles:
36// * a dispatcher, i.e., the io_context
37// * access to the system and session bus
38//
39// In addtion, it allows us to mock out services and
40// for acceptance testing purposes.
42{
43 ExternalServices(const core::dbus::Bus::Ptr& session, const core::dbus::Bus::Ptr& system)
47 {
48 }
49
52 {
53 core::dbus::Bus::Ptr{new core::dbus::Bus{core::dbus::WellKnownBus::session}},
54 core::dbus::Bus::Ptr{new core::dbus::Bus{core::dbus::WellKnownBus::system}}
55 }
56 {
57 session->install_executor(core::dbus::asio::make_executor(session, io_context));
58 system->install_executor(core::dbus::asio::make_executor(system, io_context));
59 }
60
61
62 void run()
63 {
64 io_context.run();
65 }
66
67 void stop()
68 {
69 io_context.stop();
70 }
71
72 boost::asio::io_context io_context;
73 boost::asio::io_context::work keep_alive;
74
75 core::dbus::Bus::Ptr session;
76 core::dbus::Bus::Ptr system;
77};
78}
79}
80}
81}
82
83#endif // CORE_UBUNTU_MEDIA_EXTERNAL_SERVICES_H_
Definition: player.h:34
ExternalServices(const core::dbus::Bus::Ptr &session, const core::dbus::Bus::Ptr &system)