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>());
128 } else if (property == "Settings") {
131 value.value<QDBusArgument>()>>map;
132 emit settingsChanged(map);
136 QVariantMap OfonoConnmanContext::settings() const
139 m_if->properties()["Settings"].value<QDBusArgument>()>>map;
143 QString OfonoConnmanContext::path() const
148 QString OfonoConnmanContext::errorName() const
150 return m_if->errorName();
153 QString OfonoConnmanContext::errorMessage() const
155 return m_if->errorMessage();
159 void OfonoConnmanContext::setActive(const bool value)
161 m_if->setProperty("Active",QVariant(value));
164 void OfonoConnmanContext::setAccessPointName(const QString& value)
166 m_if->setProperty("AccessPointName",QVariant(value));
169 void OfonoConnmanContext::setType(const QString& value)
171 m_if->setProperty("Type",QVariant(value));
174 void OfonoConnmanContext::setUsername(const QString& value)
176 m_if->setProperty("Username",QVariant(value));
179 void OfonoConnmanContext::setPassword(const QString& value)
181 m_if->setProperty("Password",QVariant(value));
184 void OfonoConnmanContext::setProtocol(const QString& value)
186 m_if->setProperty("Protocol",QVariant(value));
189 void OfonoConnmanContext::setName(const QString& value)
191 m_if->setProperty("Name",QVariant(value));
194 void OfonoConnmanContext::setMessageProxy(const QString& value)
196 m_if->setProperty("MessageProxy",QVariant(value));
199 void OfonoConnmanContext::setMessageCenter(const QString& value)
201 m_if->setProperty("MessageCenter",QVariant(value));
204 void OfonoConnmanContext::setPropertyFailed(const QString &property)
206 if (property == "Active") {
207 emit setActiveFailed();
208 } else if (property == "AccessPointName") {
209 emit setAccessPointNameFailed();
210 } else if (property == "Type") {
211 emit setTypeFailed();
212 } else if (property == "Username") {
213 emit setUsernameFailed();
214 } else if (property == "Password") {
215 emit setPasswordFailed();
216 } else if (property == "Protocol") {
217 emit setProtocolFailed();
218 } else if (property == "Name") {
219 emit setNameFailed();
220 } else if (property == "MessageProxy") {
221 emit setMessageProxyFailed();
222 } else if (property == "MessageCenter") {
223 emit setMessageCenterFailed();