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 "ofonomodemmanager.h"
28 #include "ofonointerface.h"
30 QDBusArgument &operator<<(QDBusArgument &argument, const OfonoModemStruct &modem)
32 argument.beginStructure();
33 argument << modem.path << modem.properties;
34 argument.endStructure();
38 const QDBusArgument &operator>>(const QDBusArgument &argument, OfonoModemStruct &modem)
40 argument.beginStructure();
41 argument >> modem.path >> modem.properties;
42 argument.endStructure();
46 OfonoModemManager::OfonoModemManager(QObject *parent)
49 QDBusReply<OfonoModemList> reply;
50 OfonoModemList modems;
54 qDBusRegisterMetaType<OfonoModemStruct>();
55 qDBusRegisterMetaType<OfonoModemList>();
57 request = QDBusMessage::createMethodCall("org.ofono",
58 "/", "org.ofono.Manager",
60 reply = QDBusConnection::systemBus().call(request);
63 foreach(OfonoModemStruct modem, modems) {
64 m_modems << modem.path.path();
67 QDBusConnection::systemBus().connect("org.ofono","/","org.ofono.Manager",
69 SLOT(onModemAdded(const QDBusObjectPath&, const QVariantMap&)));
70 QDBusConnection::systemBus().connect("org.ofono","/","org.ofono.Manager",
72 SLOT(onModemRemoved(const QDBusObjectPath&)));
76 OfonoModemManager::~OfonoModemManager()
80 QStringList OfonoModemManager::modems() const
85 void OfonoModemManager::onModemAdded(const QDBusObjectPath& path, const QVariantMap& /*map*/)
87 m_modems << path.path();
88 emit modemAdded(path.path());
91 void OfonoModemManager::onModemRemoved(const QDBusObjectPath& path)
93 m_modems.removeAll(path.path());
94 emit modemRemoved(path.path());