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

« back to all changes in this revision

Viewing changes to solid/modemmanager-0.4/modemgsmcardinterface.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 "modemgsmcardinterface.h"
 
23
#include "modemgsmcardinterface_p.h"
 
24
 
 
25
#include <KDebug>
 
26
 
 
27
MMModemGsmCardInterfacePrivate::MMModemGsmCardInterfacePrivate(const QString &path, QObject *owner)
 
28
    : MMModemInterfacePrivate(path, owner), modemGsmCardIface(MMModemManager::DBUS_SERVICE, path, QDBusConnection::systemBus())
 
29
{
 
30
}
 
31
 
 
32
MMModemGsmCardInterface::MMModemGsmCardInterface(const QString & path, MMModemManager * manager, QObject * parent)
 
33
    : MMModemInterface(*new MMModemGsmCardInterfacePrivate(path, this), manager, parent)
 
34
{
 
35
    Q_D(MMModemGsmCardInterface);
 
36
 
 
37
    d->modemGsmCardIface.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
MMModemGsmCardInterface::~MMModemGsmCardInterface()
 
44
{
 
45
 
 
46
}
 
47
 
 
48
void MMModemGsmCardInterface::propertiesChanged(const QString & interface, const QVariantMap & properties)
 
49
{
 
50
    kDebug(1441) << interface << properties.keys();
 
51
 
 
52
    if (interface == QString("org.freedesktop.ModemManager.Modem.Gsm.Card")) {
 
53
        QLatin1String supportedBands("SupportedBands");
 
54
        QLatin1String supportedModes("SupportedModes");
 
55
 
 
56
        QVariantMap::const_iterator it = properties.find(supportedBands);
 
57
        if ( it != properties.end()) {
 
58
            emit supportedBandsChanged((Solid::Control::ModemInterface::Band) it->toInt());
 
59
        }
 
60
        it = properties.find(supportedModes);
 
61
        if ( it != properties.end()) {
 
62
            emit supportedModesChanged((Solid::Control::ModemInterface::Mode) it->toInt());
 
63
        }
 
64
    }
 
65
}
 
66
 
 
67
QString MMModemGsmCardInterface::getImei()
 
68
{
 
69
    Q_D(MMModemGsmCardInterface);
 
70
    QDBusReply<QString> imei = d->modemGsmCardIface.GetImei();
 
71
 
 
72
    if (imei.isValid()) {
 
73
        return imei.value();
 
74
    }
 
75
 
 
76
    return QString();
 
77
}
 
78
 
 
79
QString MMModemGsmCardInterface::getImsi()
 
80
{
 
81
    Q_D(MMModemGsmCardInterface);
 
82
    QDBusReply<QString> imsi = d->modemGsmCardIface.GetImsi();
 
83
 
 
84
    if (imsi.isValid()) {
 
85
        return imsi.value();
 
86
    }
 
87
 
 
88
    return QString();
 
89
}
 
90
 
 
91
QDBusPendingReply<> MMModemGsmCardInterface::sendPuk(const QString & puk, const QString & pin)
 
92
{
 
93
    Q_D(MMModemGsmCardInterface);
 
94
    return d->modemGsmCardIface.SendPuk(puk, pin);
 
95
}
 
96
 
 
97
QDBusPendingReply<> MMModemGsmCardInterface::sendPin(const QString & pin)
 
98
{
 
99
    Q_D(MMModemGsmCardInterface);
 
100
    return d->modemGsmCardIface.SendPin(pin);
 
101
}
 
102
 
 
103
QDBusPendingReply<> MMModemGsmCardInterface::enablePin(const QString & pin, const bool enabled)
 
104
{
 
105
    Q_D(MMModemGsmCardInterface);
 
106
    return d->modemGsmCardIface.EnablePin(pin, enabled);
 
107
}
 
108
 
 
109
QDBusPendingReply<> MMModemGsmCardInterface::changePin(const QString & oldPin, const QString & newPin)
 
110
{
 
111
    Q_D(MMModemGsmCardInterface);
 
112
    return d->modemGsmCardIface.ChangePin(oldPin, newPin);
 
113
}
 
114
 
 
115
Solid::Control::ModemInterface::Band MMModemGsmCardInterface::getSupportedBands() const
 
116
{
 
117
    Q_D(const MMModemGsmCardInterface);
 
118
    return (Solid::Control::ModemInterface::Band) d->modemGsmCardIface.supportedBands();
 
119
}
 
120
 
 
121
Solid::Control::ModemInterface::Mode MMModemGsmCardInterface::getSupportedModes() const
 
122
{
 
123
    Q_D(const MMModemGsmCardInterface);
 
124
    return (Solid::Control::ModemInterface::Mode) d->modemGsmCardIface.supportedModes();
 
125
}
 
126
 
 
127
#include "modemgsmcardinterface.moc"
 
128