remove dep for doxygen
[profile/ivi/ofono-qt.git] / lib / ofonocallbarring.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 <alex.kanavin@gmail.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 <QtCore/QObject>
25 #include <QtDBus/QtDBus>
26 #include "ofonocallbarring.h"
27 #include "ofonointerface.h"
28
29 #define SET_PROPERTY_TIMEOUT 300000
30
31 OfonoCallBarring::OfonoCallBarring(OfonoModem::SelectionSetting modemSetting, const QString &modemPath, QObject *parent)
32     : OfonoModemInterface(modemSetting, modemPath, "org.ofono.CallBarring", OfonoGetAllOnFirstRequest, parent)
33 {
34     connect(m_if, SIGNAL(propertyChanged(const QString&, const QVariant&)), 
35             this, SLOT(propertyChanged(const QString&, const QVariant&)));
36     connect(m_if, SIGNAL(setPropertyFailed(const QString&)), 
37             this, SLOT(setPropertyFailed(const QString&)));
38     connect(m_if, SIGNAL(requestPropertyComplete(bool, const QString&, const QVariant&)),
39             this, SLOT(requestPropertyComplete(bool, const QString&, const QVariant&)));
40
41     connect(modem(), SIGNAL(pathChanged(QString)), this, SLOT(pathChanged(const QString&)));
42
43     connectDbusSignals(path());
44 }
45
46 OfonoCallBarring::~OfonoCallBarring()
47 {
48 }
49
50 void OfonoCallBarring::pathChanged(const QString& path)
51 {
52     connectDbusSignals(path);
53 }
54
55 void OfonoCallBarring::connectDbusSignals(const QString& /*path*/)
56 {
57 }
58
59 void OfonoCallBarring::changePassword(const QString &old_password, 
60                                              const QString &new_password)
61 {
62     QDBusMessage request;
63
64     request = QDBusMessage::createMethodCall("org.ofono",
65                                              path(), m_if->ifname(),
66                                              "ChangePassword");
67     request << old_password << new_password;
68
69     QDBusConnection::systemBus().callWithCallback(request, this,
70                                         SLOT(changePasswordResp()),
71                                         SLOT(changePasswordErr(const QDBusError&)));
72 }
73
74 void OfonoCallBarring::disableAll(const QString &password)
75 {
76     QDBusMessage request;
77
78     request = QDBusMessage::createMethodCall("org.ofono",
79                                              path(), m_if->ifname(),
80                                              "DisableAll");
81     request << password;
82
83     QDBusConnection::systemBus().callWithCallback(request, this,
84                                         SLOT(disableAllResp()),
85                                         SLOT(disableAllErr(const QDBusError&)));
86 }
87
88 void OfonoCallBarring::disableAllIncoming(const QString &password)
89 {
90     QDBusMessage request;
91
92     request = QDBusMessage::createMethodCall("org.ofono",
93                                              path(), m_if->ifname(),
94                                              "DisableAllIncoming");
95     request << password;
96
97     QDBusConnection::systemBus().callWithCallback(request, this,
98                                         SLOT(disableAllIncomingResp()),
99                                         SLOT(disableAllIncomingErr(const QDBusError&)));
100 }
101
102 void OfonoCallBarring::disableAllOutgoing(const QString &password)
103 {
104     QDBusMessage request;
105
106     request = QDBusMessage::createMethodCall("org.ofono",
107                                              path(), m_if->ifname(),
108                                              "DisableAllOutgoing");
109     request << password;
110
111     QDBusConnection::systemBus().callWithCallback(request, this,
112                                         SLOT(disableAllOutgoingResp()),
113                                         SLOT(disableAllOutgoingErr(const QDBusError&)));
114 }
115
116
117 void OfonoCallBarring::requestVoiceIncoming()
118 {
119     m_if->requestProperty("VoiceIncoming");
120 }
121
122 void OfonoCallBarring::setVoiceIncoming(const QString &barrings, const QString &password)
123 {
124     m_if->setProperty("VoiceIncoming", qVariantFromValue(barrings), password);
125 }
126
127 void OfonoCallBarring::requestVoiceOutgoing()
128 {
129     m_if->requestProperty("VoiceOutgoing");
130 }
131
132 void OfonoCallBarring::setVoiceOutgoing(const QString &barrings, const QString &password)
133 {
134     m_if->setProperty("VoiceOutgoing", qVariantFromValue(barrings), password);
135 }
136
137 void OfonoCallBarring::propertyChanged(const QString& property, const QVariant& value)
138 {
139     if (property == "VoiceIncoming") {  
140         emit voiceIncomingChanged(value.value<QString>());
141     } else  if (property == "VoiceOutgoing") {  
142         emit voiceOutgoingChanged(value.value<QString>());
143     }
144 }
145
146 void OfonoCallBarring::setPropertyFailed(const QString& property)
147 {
148     if (property == "VoiceIncoming") {  
149         emit setVoiceIncomingFailed();
150     } else if (property == "VoiceOutgoing") {   
151         emit setVoiceOutgoingFailed();
152     }  
153 }
154
155 void OfonoCallBarring::requestPropertyComplete(bool success, const QString& property, const QVariant& value)
156 {
157     if (property == "VoiceIncoming") {  
158         emit voiceIncomingComplete(success, value.value<QString>());
159     } else if (property == "VoiceOutgoing") {   
160         emit voiceOutgoingComplete(success, value.value<QString>());
161     }
162 }
163
164 void OfonoCallBarring::changePasswordResp()
165 {
166     emit changePasswordComplete(TRUE);
167 }
168
169 void OfonoCallBarring::changePasswordErr(QDBusError error)
170 {
171     m_if->setError(error.name(), error.message());
172     emit changePasswordComplete(FALSE);
173 }
174
175 void OfonoCallBarring::disableAllResp()
176 {
177     emit disableAllComplete(TRUE);
178 }
179
180 void OfonoCallBarring::disableAllErr(QDBusError error)
181 {
182     m_if->setError(error.name(), error.message());
183     emit disableAllComplete(FALSE);
184 }
185
186 void OfonoCallBarring::disableAllIncomingResp()
187 {
188     emit disableAllIncomingComplete(TRUE);
189 }
190
191 void OfonoCallBarring::disableAllIncomingErr(QDBusError error)
192 {
193     m_if->setError(error.name(), error.message());
194     emit disableAllIncomingComplete(FALSE);
195 }
196
197 void OfonoCallBarring::disableAllOutgoingResp()
198 {
199     emit disableAllOutgoingComplete(TRUE);
200 }
201
202 void OfonoCallBarring::disableAllOutgoingErr(QDBusError error)
203 {
204     m_if->setError(error.name(), error.message());
205     emit disableAllOutgoingComplete(FALSE);
206 }