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>
26 #include <QtCore/QDebug>
28 #include "ofononetworkoperator.h"
30 #define REGISTER_TIMEOUT 300000
32 OfonoNetworkOperator::OfonoNetworkOperator(const QString& operatorId, QObject *parent)
33 : OfonoInterface(operatorId, "org.ofono.NetworkOperator", OfonoInterface::GetAllOnStartup, parent)
35 connect(this, SIGNAL(propertyChanged(const QString&, const QVariant&)),
36 this, SLOT(propertyChanged(const QString&, const QVariant&)));
39 OfonoNetworkOperator::~OfonoNetworkOperator()
43 void OfonoNetworkOperator::requestRegister()
47 request = QDBusMessage::createMethodCall("org.ofono",
51 QDBusConnection::systemBus().callWithCallback(request, this,
53 SLOT(registerErr(const QDBusError&)),
57 void OfonoNetworkOperator::registerResp()
59 emit registerComplete(TRUE);
62 void OfonoNetworkOperator::registerErr(const QDBusError& error)
64 qDebug() << "Register failed" << error;
65 m_errorName = error.name();
66 m_errorMessage = error.message();
67 emit registerComplete(FALSE);
70 QString OfonoNetworkOperator::name() const
72 return properties()["Name"].value<QString>();
75 QString OfonoNetworkOperator::status() const
77 return properties()["Status"].value<QString>();
80 QString OfonoNetworkOperator::mcc() const
82 return properties()["MobileCountryCode"].value<QString>();
85 QString OfonoNetworkOperator::mnc() const
87 return properties()["MobileNetworkCode"].value<QString>();
90 QStringList OfonoNetworkOperator::technologies() const
92 return properties()["Technologies"].value<QStringList>();
95 QString OfonoNetworkOperator::additionalInfo() const
97 return properties()["AdditionalInformation"].value<QString>();
100 void OfonoNetworkOperator::propertyChanged(const QString& property, const QVariant& value)
102 if (property == "Name") {
103 emit nameChanged(value.value<QString>());
104 } else if (property == "Status") {
105 emit statusChanged(value.value<QString>());
106 } else if (property == "MobileCountryCode") {
107 emit mccChanged(value.value<QString>());
108 } else if (property == "MobileNetworkCode") {
109 emit mncChanged(value.value<QString>());
110 } else if (property == "Technologies") {
111 emit technologiesChanged(value.value<QStringList>());
112 } else if (property == "AdditionalInformation") {
113 emit additionalInfoChanged(value.value<QString>());