2 * This file is part of ofono-qt
4 * Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
6 * Contact: Alexander Kanavin <alexander.kanavin@nokia.com>
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public License
10 * version 2.1 as published by the Free Software Foundation.
12 * This library is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
24 #include <QtDBus/QtDBus>
25 #include <QtCore/QObject>
27 #include "ofonocallvolume.h"
28 #include "ofonointerface.h"
30 OfonoCallVolume::OfonoCallVolume(OfonoModem::SelectionSetting modemSetting, const QString &modemPath, QObject *parent)
31 : OfonoModemInterface(modemSetting, modemPath, "org.ofono.CallVolume", OfonoGetAllOnStartup, parent)
33 connect(m_if, SIGNAL(propertyChanged(const QString&, const QVariant&)),
34 this, SLOT(propertyChanged(const QString&, const QVariant&)));
36 connect(m_if, SIGNAL(setPropertyFailed(const QString&)),
37 this, SLOT(setPropertyFailed(const QString&)));
41 OfonoCallVolume::~OfonoCallVolume()
45 void OfonoCallVolume::propertyChanged(const QString &property, const QVariant &value)
47 if (property == "SpeakerVolume") {
48 emit speakerVolumeChanged(value.value<quint8>());
49 } else if (property == "MicrophoneVolume") {
50 emit microphoneVolumeChanged(value.value<quint8>());
51 } else if (property == "Muted") {
52 emit mutedChanged(value.value<bool>());
56 quint8 OfonoCallVolume::speakerVolume() const
58 return m_if->properties()["SpeakerVolume"].value<quint8>();
61 quint8 OfonoCallVolume::microphoneVolume() const
63 return m_if->properties()["MicrophoneVolume"].value<quint8>();
66 bool OfonoCallVolume::muted() const
68 return m_if->properties()["Muted"].value<bool>();
71 void OfonoCallVolume::setMuted(const bool value)
73 m_if->setProperty("Muted",QVariant(value));
76 void OfonoCallVolume::setPropertyFailed(const QString &property)
78 if (property == "SpeakerVolume") {
79 emit setSpeakerVolumeFailed();
80 } else if (property == "MicrophoneVolume") {
81 emit setMicrophoneVolumeFailed();
82 } else if (property == "Muted") {
83 emit setMutedFailed();
87 void OfonoCallVolume::setSpeakerVolume(const quint8 &spvolume)
89 m_if->setProperty("SpeakerVolume",qVariantFromValue(spvolume));
92 void OfonoCallVolume::setMicrophoneVolume(const quint8 &mpvolume)
94 m_if->setProperty("MicrophoneVolume",qVariantFromValue(mpvolume));