2
* Copyright (C) 2013 Canonical, Ltd.
4
* This program is free software: you can redistribute it and/or modify it under
5
* the terms of the GNU Lesser General Public License version 3, as published by
6
* the Free Software Foundation.
8
* This program is distributed in the hope that it will be useful, but WITHOUT
9
* ANY WARRANTY; without even the implied warranties of MERCHANTABILITY,
10
* SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11
* Lesser General Public License for more details.
13
* You should have received a copy of the GNU Lesser General Public License
14
* along with this program. If not, see <http://www.gnu.org/licenses/>.
16
* Authors: Tiago Salem Herrmann <tiago.herrmann@canonical.com>
22
#include "mmsdmanager.h"
24
struct ServiceStruct {
26
QVariantMap properties;
29
typedef QList<ServiceStruct> ServiceList;
30
Q_DECLARE_METATYPE(ServiceStruct)
31
Q_DECLARE_METATYPE(ServiceList)
33
QDBusArgument &operator<<(QDBusArgument &argument, const ServiceStruct &service)
35
argument.beginStructure();
36
argument << service.path << service.properties;
37
argument.endStructure();
41
const QDBusArgument &operator>>(const QDBusArgument &argument, ServiceStruct &service)
43
argument.beginStructure();
44
argument >> service.path >> service.properties;
45
argument.endStructure();
49
MMSDManager::MMSDManager(QObject *parent)
52
QDBusReply<ServiceList> reply;
57
qDBusRegisterMetaType<ServiceStruct>();
58
qDBusRegisterMetaType<ServiceList>();
60
request = QDBusMessage::createMethodCall("org.ofono.mms",
61
"/org/ofono/mms", "org.ofono.mms.Manager",
63
reply = QDBusConnection::sessionBus().call(request);
66
Q_FOREACH(ServiceStruct service, services) {
67
m_services << service.path.path();
70
QDBusConnection::sessionBus().connect("org.ofono.mms","/org/ofono/mms","org.ofono.mms.Manager",
72
SLOT(onServiceAdded(const QDBusObjectPath&, const QVariantMap&)));
73
QDBusConnection::sessionBus().connect("org.ofono.mms","/org/ofono/mms","org.ofono.mms.Manager",
74
"ServiceRemoved", this,
75
SLOT(onServiceRemoved(const QDBusObjectPath&)));
78
MMSDManager::~MMSDManager()
82
QStringList MMSDManager::services() const
87
void MMSDManager::onServiceAdded(const QDBusObjectPath& path, const QVariantMap& map)
89
qDebug() << "service added" << path.path() << map;
90
m_services << path.path();
91
Q_EMIT serviceAdded(path.path());
94
void MMSDManager::onServiceRemoved(const QDBusObjectPath& path)
96
qDebug() << "service removed" << path.path();
97
m_services.removeAll(path.path());
98
Q_EMIT serviceRemoved(path.path());