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

« back to all changes in this revision

Viewing changes to solid/modemmanager-0.4/modemcdmainterface.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 "modemcdmainterface.h"
 
23
#include "modemcdmainterface_p.h"
 
24
 
 
25
#include <KDebug>
 
26
 
 
27
MMModemCdmaInterfacePrivate::MMModemCdmaInterfacePrivate(const QString &path, QObject *owner)
 
28
    : MMModemInterfacePrivate(path, owner), modemCdmaIface(MMModemManager::DBUS_SERVICE, path, QDBusConnection::systemBus())
 
29
{
 
30
}
 
31
 
 
32
MMModemCdmaInterface::MMModemCdmaInterface(const QString & path, MMModemManager * manager, QObject * parent)
 
33
    : MMModemInterface(*new MMModemCdmaInterfacePrivate(path, this), manager, parent)
 
34
{
 
35
    Q_D(MMModemCdmaInterface);
 
36
 
 
37
    connect( &d->modemCdmaIface, SIGNAL(RegistrationStateChanged(const Solid::Control::ModemCdmaInterface::RegistrationState,
 
38
                                                                 const Solid::Control::ModemCdmaInterface::RegistrationState)),
 
39
                this, SIGNAL(registrationStateChanged(const Solid::Control::ModemCdmaInterface::RegistrationState,
 
40
                                                      const Solid::Control::ModemCdmaInterface::RegistrationState)));
 
41
    connect( &d->modemCdmaIface, SIGNAL(SignalQuality(uint)),
 
42
                this, SIGNAL(signalQualityChanged(uint)));
 
43
}
 
44
 
 
45
MMModemCdmaInterface::~MMModemCdmaInterface()
 
46
{
 
47
 
 
48
}
 
49
 
 
50
uint MMModemCdmaInterface::getSignalQuality()
 
51
{
 
52
    Q_D(MMModemCdmaInterface);
 
53
    QDBusReply< uint > signalQuality = d->modemCdmaIface.GetSignalQuality();
 
54
 
 
55
    if (signalQuality.isValid())
 
56
        return signalQuality.value();
 
57
 
 
58
    kDebug(1441) << "Error getting signal quality: " << signalQuality.error().name() << ": " << signalQuality.error().message();
 
59
    return 0;
 
60
}
 
61
 
 
62
QString MMModemCdmaInterface::getEsn()
 
63
{
 
64
    Q_D(MMModemCdmaInterface);
 
65
    QDBusReply<QString> esn = d->modemCdmaIface.GetEsn();
 
66
 
 
67
    if (esn.isValid())
 
68
        return esn.value();
 
69
 
 
70
    kDebug(1441) << "Error getting ESN: " << esn.error().name() << ": " << esn.error().message();
 
71
    return QString();
 
72
}
 
73
 
 
74
ServingSystemType MMModemCdmaInterface::getServingSystem()
 
75
{
 
76
    Q_D(MMModemCdmaInterface);
 
77
    QDBusReply<ServingSystemType> servingSystem = d->modemCdmaIface.GetServingSystem();
 
78
 
 
79
    if (servingSystem.isValid())
 
80
        return servingSystem.value();
 
81
 
 
82
    kDebug(1441) << "Error getting serving system info: " << servingSystem.error().name() << ": " << servingSystem.error().message();
 
83
    return ServingSystemType();
 
84
}
 
85
 
 
86
RegistrationStateResult MMModemCdmaInterface::getRegistrationState()
 
87
{
 
88
    Q_D(MMModemCdmaInterface);
 
89
    QDBusReply<RegistrationStateResult> registrationState = d->modemCdmaIface.GetRegistrationState();
 
90
 
 
91
    if (registrationState.isValid())
 
92
        return registrationState.value();
 
93
 
 
94
    kDebug(1441) << "Error getting registration state: " << registrationState.error().name() << ": " << registrationState.error().message();
 
95
    return RegistrationStateResult();
 
96
}
 
97
 
 
98
#include "modemcdmainterface.moc"