Adding CallVolume interface support in ofono-qt Bindings Signed-off-by: Arun Ravindra...
[profile/ivi/ofono-qt.git] / lib / ofonocallsettings.cpp
1 /*
2  * This file is part of ofono-qt
3  *
4  * Copyright (C) 2010-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 "ofonocallsettings.h"
28 #include "ofonointerface.h"
29
30 OfonoCallSettings::OfonoCallSettings(OfonoModem::SelectionSetting modemSetting, const QString &modemPath, QObject *parent)
31     : OfonoModemInterface(modemSetting, modemPath, "org.ofono.CallSettings", OfonoGetAllOnFirstRequest, parent)
32 {
33     connect(m_if, SIGNAL(propertyChanged(const QString&, const QVariant&)), 
34             this, SLOT(propertyChanged(const QString&, const QVariant&)));
35     connect(m_if, SIGNAL(setPropertyFailed(const QString&)), 
36             this, SLOT(setPropertyFailed(const QString&)));
37     connect(m_if, SIGNAL(requestPropertyComplete(bool, const QString&, const QVariant&)),
38             this, SLOT(requestPropertyComplete(bool, const QString&, const QVariant&)));
39 }
40
41 OfonoCallSettings::~OfonoCallSettings()
42 {
43 }
44
45 void OfonoCallSettings::requestCallingLinePresentation()
46 {
47     m_if->requestProperty("CallingLinePresentation");
48 }
49
50 void OfonoCallSettings::requestCalledLinePresentation()
51 {
52     m_if->requestProperty("CalledLinePresentation");
53 }
54
55 void OfonoCallSettings::requestConnectedLinePresentation()
56 {
57     m_if->requestProperty("ConnectedLinePresentation");
58 }
59
60 void OfonoCallSettings::requestConnectedLineRestriction()
61 {
62     m_if->requestProperty("ConnectedLineRestriction");
63 }
64
65 void OfonoCallSettings::requestCallingLineRestriction()
66 {
67     m_if->requestProperty("CallingLineRestriction");
68 }
69
70 void OfonoCallSettings::requestHideCallerId()
71 {
72     m_if->requestProperty("HideCallerId");
73 }
74
75 void OfonoCallSettings::requestVoiceCallWaiting()
76 {
77     m_if->requestProperty("VoiceCallWaiting");
78 }
79
80 void OfonoCallSettings::setHideCallerId(const QString &preference)
81 {
82     return m_if->setProperty("HideCallerId", qVariantFromValue(preference));
83 }
84
85 void OfonoCallSettings::setVoiceCallWaiting(const QString &preference)
86 {
87     return m_if->setProperty("VoiceCallWaiting", qVariantFromValue(preference));
88 }
89
90 void OfonoCallSettings::requestPropertyComplete(bool success, const QString& property, const QVariant& value)
91 {
92     if (property == "CallingLinePresentation") {        
93         success ? emit callingLinePresentationComplete(true, value.value<QString>()) : emit callingLinePresentationComplete(false, value.value<QString>());
94     } else if (property == "CalledLinePresentation") {  
95         success ? emit calledLinePresentationComplete(true, value.value<QString>()) : emit calledLinePresentationComplete(false, value.value<QString>());
96     } else if (property == "ConnectedLinePresentation") {
97         success ? emit connectedLinePresentationComplete(true, value.value<QString>()) : emit connectedLinePresentationComplete(false, value.value<QString>());
98     } else if (property == "ConnectedLineRestriction") {
99         success ? emit connectedLineRestrictionComplete(true, value.value<QString>()) : emit connectedLineRestrictionComplete(false, value.value<QString>());
100     } else if (property == "CallingLineRestriction") {  
101         success ? emit callingLineRestrictionComplete(true, value.value<QString>()) : emit callingLineRestrictionComplete(false, value.value<QString>());
102     } else if (property == "HideCallerId") {    
103         success ? emit hideCallerIdComplete(true, value.value<QString>()) : emit hideCallerIdComplete(false, value.value<QString>());
104     } else if (property == "VoiceCallWaiting") {        
105         success ? emit voiceCallWaitingComplete(true, value.value<QString>()) : emit voiceCallWaitingComplete(false, value.value<QString>());
106     }
107 }
108
109 void OfonoCallSettings::propertyChanged(const QString& property, const QVariant& value)
110 {
111     if (property == "CallingLinePresentation") {        
112         emit callingLinePresentationChanged(value.value<QString>());
113     } else if (property == "CalledLinePresentation") {  
114         emit calledLinePresentationChanged(value.value<QString>());
115     } else if (property == "ConnectedLinePresentation") {
116         emit connectedLinePresentationChanged(value.value<QString>());
117     } else if (property == "ConnectedLineRestriction") {
118         emit connectedLineRestrictionChanged(value.value<QString>());
119     } else if (property == "CallingLineRestriction") {  
120         emit callingLineRestrictionChanged(value.value<QString>());
121     } else if (property == "HideCallerId") {    
122         emit hideCallerIdChanged(value.value<QString>());
123     } else if (property == "VoiceCallWaiting") {        
124         emit voiceCallWaitingChanged(value.value<QString>());
125     }
126 }
127
128 void OfonoCallSettings::setPropertyFailed(const QString& property)
129 {
130     if (property == "HideCallerId") {   
131         emit setHideCallerIdFailed();
132     } else if (property == "VoiceCallWaiting") {        
133         emit setVoiceCallWaitingFailed();
134     }
135 }