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