2 * Copyright (C) 2011, BMW AG
6 * \file DBusCommandInterface.cpp
9 * \author Christian Müller (christian.ei.mueller@bmw.de)
12 * GNU Lesser General Public License, version 2.1, with special exception (GENIVI clause)
13 * Copyright (C) 2011, BMW AG – Christian Müller Christian.ei.mueller@bmw.de
15 * 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.
16 * 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.
17 * 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>.
18 * 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.
19 * 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.
20 * 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.
21 * 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.
26 #include "DBusCommandInterface.h"
27 #include "DBusCommand.h"
29 DBusCommandInterface::DBusCommandInterface(QObject* parent) {
33 void DBusCommandInterface::startupInterface() {
34 DLT_LOG(AudioManager,DLT_LOG_INFO, DLT_STRING("Startup of DBUS Command interface"));
36 new DBusCommand(this);
37 QDBusConnection connection = QDBusConnection::sessionBus();
38 connection.registerService(QString(SERVICEINTERFACE));
39 if (connection.isConnected()) {
40 if (connection.registerObject(
43 (QDBusConnection::ExportAdaptors
44 | QDBusConnection::ExportAllSignals))) {
45 DLT_LOG(AudioManager,DLT_LOG_INFO, DLT_STRING("Registered DBUS Command interface succsessfully"));
47 DLT_LOG(AudioManager,DLT_LOG_ERROR, DLT_STRING("Failed to register DBUS Command interface succsessfully"));
52 int DBusCommandInterface::connect(int Source_ID, int Sink_ID) {
53 if (m_core->UserConnect(Source_ID, Sink_ID) == GEN_OK) {
59 int DBusCommandInterface::disconnect(int Source_ID, int Sink_ID) {
60 DLT_LOG(AudioManager,DLT_LOG_ERROR, DLT_STRING("Disconnect"));
61 genRoute_t ReturnRoute;
62 if (int value=m_core->returnDatabaseHandler()->returnMainconnectionIDforSinkSourceID(Sink_ID,Source_ID)>0) {
63 return m_core->UserDisconnect(value);
69 int DBusCommandInterface::interruptRequest(const QString &SourceName,
70 const QString &SinkName) {
71 source_t sourceID = m_core->returnSourceIDfromName(SourceName);
72 sink_t sinkID = m_core->returnSinkIDfromName(SinkName);
74 m_core->interruptRequest(sourceID, sinkID, &intID);
78 int DBusCommandInterface::interruptResume(int InterruptID) {
79 emit signal_interruptResume(InterruptID);
83 void DBusCommandInterface::registerAudioManagerCore(AudioManagerCore* core) {
85 QObject::connect((const QObject*) m_core,
86 SIGNAL(signal_connectionChanged()), (const QObject*) this,
87 SLOT(slot_connectionChanged()));
88 QObject::connect((const QObject*) m_core,
89 SIGNAL(signal_numberOfSinksChanged()), (const QObject*) this,
90 SLOT(slot_numberOfSinksChanged()));
91 QObject::connect((const QObject*) m_core,
92 SIGNAL(signal_numberOfSourcesChanged()), (const QObject*) this,
93 SLOT(slot_numberOfSourcesChanged()));
96 void DBusCommandInterface::slot_connectionChanged() {
97 emit signal_connectionChanged();
99 void DBusCommandInterface::slot_numberOfSinksChanged() {
100 emit signal_numberOfSinksChanged();
102 void DBusCommandInterface::slot_numberOfSourcesChanged() {
103 emit signal_numberOfSourcesChanged();
106 int DBusCommandInterface::setVolume(int SinkID, int Volume) {
107 if (m_core->UserSetVolume(SinkID, Volume) == GEN_OK) {
113 QList<SourceType> DBusCommandInterface::getListSources() {
114 return m_core->getListSources();
117 QList<SinkType> DBusCommandInterface::getListSinks() {
118 return m_core->getListSinks();
121 QList<ConnectionType> DBusCommandInterface::getListConnections() {
122 return m_core->getListConnections();