2 * This file is part of ofono-qt
4 * Copyright (C) 2010 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>
27 #include "ofonointerface.h"
28 #include "ofononetworkoperator.h"
30 #define REGISTER_TIMEOUT 300000
32 OfonoNetworkOperator::OfonoNetworkOperator(const QString& operatorId, QObject *parent)
35 m_if = new OfonoInterface(operatorId, "org.ofono.NetworkOperator", OfonoGetAllOnStartup, this);
36 connect(m_if, SIGNAL(propertyChanged(const QString&, const QVariant&)),
37 this, SLOT(propertyChanged(const QString&, const QVariant&)));
40 OfonoNetworkOperator::OfonoNetworkOperator(const OfonoNetworkOperator& op)
41 : QObject(op.parent())
43 m_if = new OfonoInterface(op.path(), "org.ofono.NetworkOperator", OfonoGetAllOnStartup, this);
44 connect(m_if, SIGNAL(propertyChanged(const QString&, const QVariant&)),
45 this, SLOT(propertyChanged(const QString&, const QVariant&)));
48 bool OfonoNetworkOperator::operator==(const OfonoNetworkOperator &op)
50 return path() == op.path();
53 OfonoNetworkOperator::~OfonoNetworkOperator()
57 void OfonoNetworkOperator::registerOp()
61 request = QDBusMessage::createMethodCall("org.ofono",
62 path(), m_if->ifname(),
65 QDBusConnection::systemBus().callWithCallback(request, this,
67 SLOT(registerErr(const QDBusError&)),
71 void OfonoNetworkOperator::registerResp()
73 emit registerComplete(TRUE);
76 void OfonoNetworkOperator::registerErr(const QDBusError& error)
78 m_if->setError(error.name(), error.message());
79 emit registerComplete(FALSE);
82 QString OfonoNetworkOperator::name() const
84 return m_if->properties()["Name"].value<QString>();
87 QString OfonoNetworkOperator::status() const
89 return m_if->properties()["Status"].value<QString>();
92 QString OfonoNetworkOperator::mcc() const
94 return m_if->properties()["MobileCountryCode"].value<QString>();
97 QString OfonoNetworkOperator::mnc() const
99 return m_if->properties()["MobileNetworkCode"].value<QString>();
102 QStringList OfonoNetworkOperator::technologies() const
104 return m_if->properties()["Technologies"].value<QStringList>();
107 QString OfonoNetworkOperator::additionalInfo() const
109 return m_if->properties()["AdditionalInformation"].value<QString>();
112 void OfonoNetworkOperator::propertyChanged(const QString& property, const QVariant& value)
114 if (property == "Name") {
115 emit nameChanged(value.value<QString>());
116 } else if (property == "Status") {
117 emit statusChanged(value.value<QString>());
118 } else if (property == "MobileCountryCode") {
119 emit mccChanged(value.value<QString>());
120 } else if (property == "MobileNetworkCode") {
121 emit mncChanged(value.value<QString>());
122 } else if (property == "Technologies") {
123 emit technologiesChanged(value.value<QStringList>());
124 } else if (property == "AdditionalInformation") {
125 emit additionalInfoChanged(value.value<QString>());
129 QString OfonoNetworkOperator::path() const
134 QString OfonoNetworkOperator::errorName() const
136 return m_if->errorName();
139 QString OfonoNetworkOperator::errorMessage() const
141 return m_if->errorMessage();