~andreas-pokorny/telepathy-ofono/control-proximity-handling-in-powerd

« back to all changes in this revision

Viewing changes to mmsdmessage.cpp

  • Committer: Tiago Salem Herrmann
  • Date: 2013-07-08 15:55:12 UTC
  • mto: This revision was merged to the branch mainline in revision 37.
  • Revision ID: tiago.herrmann@canonical.com-20130708155512-0n61cdowordh9sev
add initial mms support

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/**
 
2
 * Copyright (C) 2013 Canonical, Ltd.
 
3
 *
 
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.
 
7
 *
 
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.
 
12
 *
 
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/>.
 
15
 *
 
16
 * Authors: Tiago Salem Herrmann <tiago.herrmann@canonical.com>
 
17
 */
 
18
 
 
19
#include <QtDBus>
 
20
#include <QObject>
 
21
 
 
22
#include "mmsdmessage.h"
 
23
 
 
24
MMSDMessage::MMSDMessage(QString objectPath, QVariantMap properties, QObject *parent)
 
25
    : QObject(parent), 
 
26
      m_messagePath(objectPath),
 
27
      m_properties(properties)
 
28
{
 
29
    QDBusConnection::sessionBus().connect("org.ofono.mms", m_messagePath, "org.ofono.mms.Message",
 
30
                                          "PropertyChanged", this,
 
31
                                          SLOT(onPropertyChanged(const QString&, const QVariant&)));
 
32
}
 
33
 
 
34
MMSDMessage::~MMSDMessage()
 
35
{
 
36
}
 
37
 
 
38
QString MMSDMessage::path() const
 
39
{
 
40
    return m_messagePath;
 
41
}
 
42
 
 
43
QVariantMap MMSDMessage::properties() const
 
44
{
 
45
    return m_properties;
 
46
}
 
47
 
 
48
void MMSDMessage::onPropertyChanged(const QString &property, const QVariant &value)
 
49
{
 
50
    qDebug() << "property changed" << property << value;
 
51
    m_properties[property] = value;
 
52
    Q_EMIT propertyChanged(property, value);
 
53
}
 
54
 
 
55
void MMSDMessage::markRead() const
 
56
{
 
57
    QDBusMessage request;
 
58
    request = QDBusMessage::createMethodCall("org.ofono.mms",
 
59
                                   m_messagePath, "org.ofono.mms.Message",
 
60
                                   "MarkRead");
 
61
    QDBusConnection::sessionBus().call(request);
 
62
}
 
63
 
 
64
void MMSDMessage::remove() const
 
65
{
 
66
    QDBusMessage request;
 
67
    request = QDBusMessage::createMethodCall("org.ofono.mms",
 
68
                                   m_messagePath, "org.ofono.mms.Message",
 
69
                                   "Delete");
 
70
    QDBusConnection::sessionBus().call(request);
 
71
}