3 * Copyright (C) 2011, BMW AG
7 * \file RoutingSend.cpp
10 * \author Christian Müller (christian.ei.mueller@bmw.de)
13 * GNU Lesser General Public License, version 2.1, with special exception (GENIVI clause)
14 * Copyright (C) 2011, BMW AG – Christian Müller Christian.ei.mueller@bmw.de
16 * This program is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License, version 2.1, as published by the Free Software Foundation.
17 * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License, version 2.1, for more details.
18 * You should have received a copy of the GNU Lesser General Public License, version 2.1, along with this program; if not, see <http://www.gnu.org/licenses/lgpl-2.1.html>.
19 * Note that the copyright holders assume that the GNU Lesser General Public License, version 2.1, may also be applicable to programs even in cases in which the program is not a library in the technical sense.
20 * Linking AudioManager statically or dynamically with other modules is making a combined work based on AudioManager. You may license such other modules under the GNU Lesser General Public License, version 2.1. If you do not want to license your linked modules under the GNU Lesser General Public License, version 2.1, you may use the program under the following exception.
21 * As a special exception, the copyright holders of AudioManager give you permission to combine AudioManager with software programs or libraries that are released under any license unless such a combination is not permitted by the license of such a software program or library. You may copy and distribute such a system following the terms of the GNU Lesser General Public License, version 2.1, including this special exception, for AudioManager and the licenses of the other code concerned.
22 * Note that people who make modified versions of AudioManager are not obligated to grant this special exception for their modified versions; it is their choice whether to do so. The GNU Lesser General Public License, version 2.1, gives permission to release a modified version without this exception; this exception also makes it possible to release a modified version which carries forward this exception.
27 #include "routinginterface.h"
36 DLT_DECLARE_CONTEXT(DBusPlugin)
38 DbusInterface::DbusInterface(): m_busname(DBUS_BUSNAME), m_path(DBUS_PATH) {
40 DLT_REGISTER_APP("DBusPlugin", "DBusPlugin");
41 DLT_REGISTER_CONTEXT(DBusPlugin, "DPlugin", "Dbus Plugin");
42 DLT_LOG(DBusPlugin, DLT_LOG_INFO, DLT_STRING("The DBus Plugin is started"));
45 DbusInterface::~DbusInterface() {
46 delete m_DbusInterface;
49 void DbusInterface::startup_interface(RoutingReceiveInterface* audioman,dbusRoothandler* dbushandler) {
50 m_audioman = audioman;
51 m_rootHandler = dbushandler;
52 m_DbusInterface = new AudioManagerInterface(audioman,dbushandler);
53 m_DbusInterface->startup_interface();
54 m_rootHandler->registerNode(MY_NODE);
56 dbus_error_init(&err);
58 m_conn = dbus_bus_get(DBUS_BUS_SESSION, &err);
59 if (dbus_error_is_set(&err)) {
60 DLT_LOG(DBusPlugin, DLT_LOG_INFO, DLT_STRING("Could not connect to DBUS for sending, Error: "), DLT_STRING(err.message));
61 dbus_error_free(&err);
64 DLT_LOG(DBusPlugin, DLT_LOG_INFO, DLT_STRING("DBus Interface started "));
67 void DbusInterface::return_BusName(char* BusName) {
68 strcpy(BusName, BUS_NAME);
71 genError_t DbusInterface::connect(source_t source, sink_t sink, connection_t connID) {
73 DbusSend send = DbusSend(m_conn,"PULSE",(const char*)m_busname,(const char*)m_path, "connect");
74 send.appendInteger(source);
75 send.appendInteger(sink);
76 send.appendInteger(connID);
77 send.sendReply(&reply);
84 void DbusInterface::system_ready() {
85 DLT_LOG(DBusPlugin, DLT_LOG_INFO, DLT_STRING("DBus Plugin got ready"));
86 m_DbusInterface->emit_systemReady();
89 genError_t DbusInterface::disconnect(connection_t connectionID) {
91 DbusSend send = DbusSend(m_conn,"PULSE",(const char*)m_busname,(const char*)m_path,"disconnect");
92 send.appendInteger(connectionID);
93 send.sendReply(&reply);
100 genError_t DbusInterface::setSinkVolume(volume_t volume, sink_t sink) {
102 DbusSend send = DbusSend(m_conn,"PULSE",(const char*)m_busname,(const char*)m_path,"setSinkVolume");
103 send.appendInteger(volume);
104 send.appendInteger(sink);
105 send.sendReply(&reply);
112 genError_t DbusInterface::setSourceVolume(volume_t volume, source_t source) {
114 DbusSend send = DbusSend(m_conn,"PULSE",(const char*)m_busname,(const char*)m_path,"setSourceVolume");
115 send.appendInteger(volume);
116 send.appendInteger(source);
117 send.sendReply(&reply);
124 genError_t DbusInterface::muteSource(source_t sourceID) {
126 DbusSend send = DbusSend(m_conn,"PULSE",(const char*)m_busname,(const char*)m_path,"muteSource");
127 send.appendInteger(sourceID);
128 send.sendReply(&reply);
135 genError_t DbusInterface::muteSink(sink_t sinkID) {
137 DbusSend send = DbusSend(m_conn,"PULSE",(const char*)m_busname,(const char*)m_path,"muteSink");
138 send.appendInteger(sinkID);
139 send.sendReply(&reply);
146 genError_t DbusInterface::unmuteSource(source_t sourceID) {
148 DbusSend send = DbusSend(m_conn,"PULSE",(const char*)m_busname,(const char*)m_path,"unmuteSource");
149 send.appendInteger(sourceID);
150 send.sendReply(&reply);
157 genError_t DbusInterface::unmuteSink(sink_t sinkID) {
159 DbusSend send = DbusSend(m_conn,"PULSE",(const char*)m_busname,(const char*)m_path,"unmuteSink");
160 send.appendInteger(sinkID);
161 send.sendReply(&reply);
168 //genError_t DbusInterface::asyncConnect(source_t source, sink_t sink, connection_t con_ID) {
175 //genError_t DbusInterface::asyncDisconnect(connection_t connection_ID){
182 //That is the actual implementation of the Factory Class returning the real sendInterface
184 extern "C" RoutingSendInterface* PluginRoutingInterfaceDbusFactory() {
185 return new DbusInterface();
188 extern "C" void destroyRoutingPluginInterfaceDbus(RoutingSendInterface* iface) {