Added SMS support in ofono-qt
[profile/ivi/ofono-qt.git] / lib / ofonocallvolume.cpp
1 /*
2  * This file is part of ofono-qt
3  *
4  * Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
5  *
6  * Contact: Alexander Kanavin <alexander.kanavin@nokia.com>
7  *
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.
11  *
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.
16  *
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
20  * 02110-1301 USA
21  *
22  */
23
24 #include <QtDBus/QtDBus>
25 #include <QtCore/QObject>
26
27 #include "ofonocallvolume.h"
28 #include "ofonointerface.h"
29
30 OfonoCallVolume::OfonoCallVolume(OfonoModem::SelectionSetting modemSetting, const QString &modemPath, QObject *parent)
31     : OfonoModemInterface(modemSetting, modemPath, "org.ofono.CallVolume", OfonoGetAllOnStartup, parent)
32 {
33     connect(m_if, SIGNAL(propertyChanged(const QString&, const QVariant&)),
34             this, SLOT(propertyChanged(const QString&, const QVariant&)));
35
36     connect(m_if, SIGNAL(setPropertyFailed(const QString&)),
37             this, SLOT(setPropertyFailed(const QString&)));
38
39 }
40
41 OfonoCallVolume::~OfonoCallVolume()
42 {
43 }
44
45 void OfonoCallVolume::propertyChanged(const QString &property, const QVariant &value)
46 {
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>());
53     }
54 }
55
56 quint8 OfonoCallVolume::speakerVolume() const
57 {
58     return m_if->properties()["SpeakerVolume"].value<quint8>();
59 }
60
61 quint8 OfonoCallVolume::microphoneVolume() const
62 {
63     return m_if->properties()["MicrophoneVolume"].value<quint8>();
64 }
65
66 bool OfonoCallVolume::muted() const
67 {
68     return m_if->properties()["Muted"].value<bool>();
69 }
70
71 void OfonoCallVolume::setMuted(const bool value)
72 {
73     m_if->setProperty("Muted",QVariant(value));
74 }
75
76 void OfonoCallVolume::setPropertyFailed(const QString &property)
77 {
78     if (property == "SpeakerVolume") {
79         emit setSpeakerVolumeFailed();
80     } else if (property == "MicrophoneVolume") {
81         emit setMicrophoneVolumeFailed();
82     } else if (property == "Muted") {
83         emit setMutedFailed();
84     }
85 }
86
87 void OfonoCallVolume::setSpeakerVolume(const quint8 &spvolume)
88 {
89     m_if->setProperty("SpeakerVolume",qVariantFromValue(spvolume));
90 }
91
92 void OfonoCallVolume::setMicrophoneVolume(const quint8 &mpvolume)
93 {
94     m_if->setProperty("MicrophoneVolume",qVariantFromValue(mpvolume));
95 }