~ubuntu-branches/ubuntu/utopic/kde-workspace/utopic-proposed

« back to all changes in this revision

Viewing changes to solid/modemmanager-0.4/modemgsmussdinterface.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Michał Zając
  • Date: 2011-07-09 08:31:15 UTC
  • Revision ID: james.westby@ubuntu.com-20110709083115-ohyxn6z93mily9fc
Tags: upstream-4.6.90
Import upstream version 4.6.90

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
Copyright 2008 Will Stephenson <wstephenson@kde.org>
 
3
Copyright 2010 Lamarque Souza <lamarque@gmail.com>
 
4
 
 
5
This program is free software; you can redistribute it and/or
 
6
modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of
 
7
the License or (at your option) version 3 or any later version
 
8
accepted by the membership of KDE e.V. (or its successor approved
 
9
by the membership of KDE e.V.), which shall act as a proxy
 
10
defined in Section 14 of version 3 of the license.
 
11
 
 
12
This program is distributed in the hope that it will be useful,
 
13
but WITHOUT ANY WARRANTY; without even the implied warranty of
 
14
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
15
GNU General Public License for more details.
 
16
 
 
17
You should have received a copy of the GNU General Public License
 
18
along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
19
*/
 
20
 
 
21
#include "manager.h"
 
22
#include "modemgsmussdinterface.h"
 
23
#include "modemgsmussdinterface_p.h"
 
24
 
 
25
#include <KDebug>
 
26
 
 
27
MMModemGsmUssdInterfacePrivate::MMModemGsmUssdInterfacePrivate(const QString &path, QObject *owner)
 
28
    : MMModemInterfacePrivate(path, owner), modemGsmUssdIface(MMModemManager::DBUS_SERVICE, path, QDBusConnection::systemBus())
 
29
{
 
30
}
 
31
 
 
32
MMModemGsmUssdInterface::MMModemGsmUssdInterface(const QString & path, MMModemManager * manager, QObject * parent)
 
33
    : MMModemInterface(*new MMModemGsmUssdInterfacePrivate(path, this), manager, parent)
 
34
{
 
35
    Q_D(MMModemGsmUssdInterface);
 
36
 
 
37
    d->modemGsmUssdIface.connection().connect(MMModemManager::DBUS_SERVICE,
 
38
        path, QLatin1String("org.freedesktop.DBus.Properties"),
 
39
        QLatin1String("MmPropertiesChanged"), QLatin1String("sa{sv}"),
 
40
        this, SLOT(propertiesChanged(const QString &,const QVariantMap &)));
 
41
}
 
42
 
 
43
MMModemGsmUssdInterface::~MMModemGsmUssdInterface()
 
44
{
 
45
 
 
46
}
 
47
 
 
48
void MMModemGsmUssdInterface::propertiesChanged(const QString & interface, const QVariantMap & properties)
 
49
{
 
50
    kDebug(1441) << interface << properties.keys();
 
51
 
 
52
    if (interface == QString("org.freedesktop.ModemManager.Modem.Gsm.Ussd")) {
 
53
        QLatin1String state("State");
 
54
        QLatin1String networkNotification("NetworkNotification");
 
55
        QLatin1String networkRequest("NetworkRequest");
 
56
 
 
57
        QVariantMap::const_iterator it = properties.find(state);
 
58
        if ( it != properties.end()) {
 
59
            emit stateChanged(it->toString());
 
60
        }
 
61
        it = properties.find(networkNotification);
 
62
        if ( it != properties.end()) {
 
63
            emit networkNotificationChanged(it->toString());
 
64
        }
 
65
        it = properties.find(networkRequest);
 
66
        if ( it != properties.end()) {
 
67
            emit networkRequestChanged(it->toString());
 
68
        }
 
69
    }
 
70
}
 
71
 
 
72
QString MMModemGsmUssdInterface::initiate(const QString & command)
 
73
{
 
74
    Q_D(MMModemGsmUssdInterface);
 
75
    QDBusReply<QString> reply = d->modemGsmUssdIface.Initiate(command);
 
76
 
 
77
    if (reply.isValid()) {
 
78
        return reply.value();
 
79
    }
 
80
    return QString();
 
81
}
 
82
 
 
83
void MMModemGsmUssdInterface::respond(const QString response)
 
84
{
 
85
    Q_D(MMModemGsmUssdInterface);
 
86
    d->modemGsmUssdIface.Respond(response);
 
87
}
 
88
 
 
89
void MMModemGsmUssdInterface::cancel()
 
90
{
 
91
    Q_D(MMModemGsmUssdInterface);
 
92
    d->modemGsmUssdIface.Cancel();
 
93
}
 
94
 
 
95
QString MMModemGsmUssdInterface::getState()
 
96
{
 
97
    Q_D(const MMModemGsmUssdInterface);
 
98
    return d->modemGsmUssdIface.state();
 
99
}
 
100
 
 
101
QString MMModemGsmUssdInterface::getNetworkNotification()
 
102
{
 
103
    Q_D(const MMModemGsmUssdInterface);
 
104
    return d->modemGsmUssdIface.networkNotification();
 
105
}
 
106
 
 
107
QString MMModemGsmUssdInterface::getNetworkRequest()
 
108
{
 
109
    Q_D(const MMModemGsmUssdInterface);
 
110
    return d->modemGsmUssdIface.networkRequest();
 
111
}
 
112
 
 
113
#include "modemgsmussdinterface.moc"
 
114