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 "dbustypes.h"
23
#include "mmsdservice.h"
25
QDBusArgument &operator<<(QDBusArgument &argument, const MessageStruct &message)
27
argument.beginStructure();
28
argument << message.path << message.properties;
29
argument.endStructure();
33
const QDBusArgument &operator>>(const QDBusArgument &argument, MessageStruct &message)
35
argument.beginStructure();
36
argument >> message.path >> message.properties;
37
argument.endStructure();
41
MMSDService::MMSDService(QString objectPath, oFonoConnection* connection, QObject *parent)
43
m_servicePath(objectPath)
45
QDBusReply<MessageList> replyMessages;
46
QDBusReply<QVariantMap> replyProperties;
50
qDBusRegisterMetaType<MessageStruct>();
51
qDBusRegisterMetaType<MessageList>();
53
request = QDBusMessage::createMethodCall("org.ofono.mms",
54
m_servicePath, "org.ofono.mms.Service",
56
replyProperties = QDBusConnection::sessionBus().call(request);
57
m_properties = replyProperties;
59
request = QDBusMessage::createMethodCall("org.ofono.mms",
60
m_servicePath, "org.ofono.mms.Service",
62
replyMessages = QDBusConnection::sessionBus().call(request);
64
m_messages = replyMessages;
66
QDBusConnection::sessionBus().connect("org.ofono.mms", m_servicePath, "org.ofono.mms.Service",
68
SLOT(onMessageAdded(const QDBusObjectPath&, const QVariantMap&)));
69
QDBusConnection::sessionBus().connect("org.ofono.mms", m_servicePath, "org.ofono.mms.Service",
70
"MessageRemoved", this,
71
SLOT(onMessageRemoved(const QDBusObjectPath&)));
74
MMSDService::~MMSDService()
78
QString MMSDService::path() const
83
QVariantMap MMSDService::properties() const
88
MessageList MMSDService::messages() const
93
void MMSDService::onMessageAdded(const QDBusObjectPath &path, const QVariantMap &properties)
95
qDebug() << "message added" << path.path() << properties;
96
Q_EMIT messageAdded(path.path(), properties);
99
void MMSDService::onMessageRemoved(const QDBusObjectPath& path)
101
qDebug() << "message removed" << path.path();
102
Q_EMIT messageRemoved(path.path());
105
QDBusObjectPath MMSDService::sendMessage(QStringList recipients, QString smil, AttachmentList attachments)
107
QDBusMessage request;
108
QList<QVariant> arguments;
109
QDBusReply<QDBusObjectPath> reply;
110
arguments.append(recipients);
111
arguments.append(smil);
112
arguments.append(QVariant::fromValue(attachments));
113
request = QDBusMessage::createMethodCall("org.ofono.mms",
114
m_servicePath, "org.ofono.mms.Service",
116
request.setArguments(arguments);
117
reply = QDBusConnection::sessionBus().call(request);