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>
26 #include <QDBusArgument>
28 #include "ofonointerface.h"
29 #include "ofonoconnman.h"
30 #include "ofonoconnmancontext.h"
33 OfonoConnmanContext::OfonoConnmanContext(const QString& contextId, QObject *parent)
36 m_if = new OfonoInterface(contextId, "org.ofono.ConnectionContext", OfonoGetAllOnStartup, this);
38 connect(m_if, SIGNAL(propertyChanged(const QString&, const QVariant&)),
39 this, SLOT(propertyChanged(const QString&, const QVariant&)));
43 OfonoConnmanContext::OfonoConnmanContext(const OfonoConnmanContext& context)
44 : QObject(context.parent())
46 m_if = new OfonoInterface(context.path(), "org.ofono.ConnectionContext", OfonoGetAllOnStartup, this);
48 connect(m_if, SIGNAL(propertyChanged(const QString&, const QVariant&)),
49 this, SLOT(propertyChanged(const QString&, const QVariant&)));
53 bool OfonoConnmanContext::operator==(const OfonoConnmanContext &context)
55 return path() == context.path();
58 OfonoConnmanContext::~OfonoConnmanContext()
62 bool OfonoConnmanContext::active() const
64 return m_if->properties()["Active"].value<bool>();
67 QString OfonoConnmanContext::accessPointName() const
69 return m_if->properties()["AccessPointName"].value<QString>();
72 QString OfonoConnmanContext::name() const
74 return m_if->properties()["Name"].value<QString>();
77 QString OfonoConnmanContext::type() const
79 return m_if->properties()["Type"].value<QString>();
82 QString OfonoConnmanContext::username() const
84 return m_if->properties()["Username"].value<QString>();
87 QString OfonoConnmanContext::password() const
89 return m_if->properties()["Password"].value<QString>();
92 QString OfonoConnmanContext::protocol() const
94 return m_if->properties()["Protocol"].value<QString>();
97 QString OfonoConnmanContext::messageProxy() const
99 return m_if->properties()["MessageProxy"].value<QString>();
102 QString OfonoConnmanContext::messageCenter() const
104 return m_if->properties()["MessageCenter"].value<QString>();
107 void OfonoConnmanContext::propertyChanged(const QString &property, const QVariant &value)
109 if (property == "Active") {
110 emit activeChanged(value.value<bool>());
111 } else if (property == "Name") {
112 emit nameChanged(value.value<QString>());
113 } else if (property == "AccessPointName") {
114 emit accessPointNameChanged(value.value<QString>());
115 } else if (property == "Type") {
116 emit typeChanged(value.value<QString>());
117 } else if (property == "Username") {
118 emit usernameChanged(value.value<QString>());
119 } else if (property == "Password") {
120 emit passwordChanged(value.value<QString>());
121 } else if (property == "Protocol") {
122 emit protocolChanged(value.value<QString>());
123 } else if (property == "MessageProxy") {
124 emit messageProxyChanged(value.value<QString>());
125 } else if (property == "MessageCenter") {
126 emit messageCenterChanged(value.value<QString>());
127 } else if (property == "Settings") {
129 value.value<QDBusArgument>()>>map;
130 emit settingsChanged(map);
131 } else if (property == "IPv6.Settings") {
133 value.value<QDBusArgument>()>>map;
134 emit IPv6SettingsChanged(map);
138 QVariantMap OfonoConnmanContext::settings() const
141 m_if->properties()["Settings"].value<QDBusArgument>()>>map;
145 QVariantMap OfonoConnmanContext::IPv6Settings() const
148 m_if->properties()["IPv6.Settings"].value<QDBusArgument>()>>map;
152 QString OfonoConnmanContext::path() const
157 QString OfonoConnmanContext::errorName() const
159 return m_if->errorName();
162 QString OfonoConnmanContext::errorMessage() const
164 return m_if->errorMessage();
168 void OfonoConnmanContext::setActive(const bool value)
170 m_if->setProperty("Active",QVariant(value));
173 void OfonoConnmanContext::setAccessPointName(const QString& value)
175 m_if->setProperty("AccessPointName",QVariant(value));
178 void OfonoConnmanContext::setType(const QString& value)
180 m_if->setProperty("Type",QVariant(value));
183 void OfonoConnmanContext::setUsername(const QString& value)
185 m_if->setProperty("Username",QVariant(value));
188 void OfonoConnmanContext::setPassword(const QString& value)
190 m_if->setProperty("Password",QVariant(value));
193 void OfonoConnmanContext::setProtocol(const QString& value)
195 m_if->setProperty("Protocol",QVariant(value));
198 void OfonoConnmanContext::setName(const QString& value)
200 m_if->setProperty("Name",QVariant(value));
203 void OfonoConnmanContext::setMessageProxy(const QString& value)
205 m_if->setProperty("MessageProxy",QVariant(value));
208 void OfonoConnmanContext::setMessageCenter(const QString& value)
210 m_if->setProperty("MessageCenter",QVariant(value));
213 void OfonoConnmanContext::setPropertyFailed(const QString &property)
215 if (property == "Active") {
216 emit setActiveFailed();
217 } else if (property == "AccessPointName") {
218 emit setAccessPointNameFailed();
219 } else if (property == "Type") {
220 emit setTypeFailed();
221 } else if (property == "Username") {
222 emit setUsernameFailed();
223 } else if (property == "Password") {
224 emit setPasswordFailed();
225 } else if (property == "Protocol") {
226 emit setProtocolFailed();
227 } else if (property == "Name") {
228 emit setNameFailed();
229 } else if (property == "MessageProxy") {
230 emit setMessageProxyFailed();
231 } else if (property == "MessageCenter") {
232 emit setMessageCenterFailed();