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

« back to all changes in this revision

Viewing changes to solid/networkmanager-0.7/networkbtinterface.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 2011 Lamarque Souza <lamarque@gmail.com>
 
3
 
 
4
This program is free software; you can redistribute it and/or
 
5
modify it under the terms of the GNU General Public License as
 
6
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 <KDebug>
 
22
 
 
23
#include "networkbtinterface.h"
 
24
#include "networkbtinterface_p.h"
 
25
#include "manager.h"
 
26
 
 
27
#include "solid/control/modemmanager.h"
 
28
 
 
29
NMBtNetworkInterfacePrivate::NMBtNetworkInterfacePrivate(const QString & path, QObject * owner)
 
30
    : NMGsmNetworkInterfacePrivate(path, owner), btIface(NMNetworkManager::DBUS_SERVICE, path, QDBusConnection::systemBus())
 
31
{
 
32
    btCapabilities = static_cast<QFlags<Solid::Control::BtNetworkInterface::Capability> >(btIface.btCapabilities());
 
33
    hardwareAddress = btIface.hwAddress();
 
34
    name = btIface.name();
 
35
}
 
36
 
 
37
NMBtNetworkInterface::NMBtNetworkInterface(const QString & path, NMNetworkManager * manager, QObject * parent)
 
38
    : NMGsmNetworkInterface(*new NMBtNetworkInterfacePrivate(path, this), manager, parent)
 
39
{
 
40
    Q_D(NMBtNetworkInterface);
 
41
    connect( &d->btIface, SIGNAL(PropertiesChanged(const QVariantMap &)),
 
42
                this, SLOT(btPropertiesChanged(const QVariantMap &)));
 
43
}
 
44
 
 
45
NMBtNetworkInterface::~NMBtNetworkInterface()
 
46
{
 
47
 
 
48
}
 
49
 
 
50
void NMBtNetworkInterface::btPropertiesChanged(const QVariantMap & changedProperties)
 
51
{
 
52
    kDebug(1441) << changedProperties.keys();
 
53
    Q_D(NMBtNetworkInterface);
 
54
    QLatin1String hwAddrKey("HwAddress"),
 
55
                  name("Name"),
 
56
                  capabilities("BtCapabilities");
 
57
    QVariantMap::const_iterator it = changedProperties.find(hwAddrKey);
 
58
    it = changedProperties.find(hwAddrKey);
 
59
    if (it != changedProperties.end()) {
 
60
        d->hardwareAddress = it->toString();
 
61
    }
 
62
    it = changedProperties.find(name);
 
63
    if (it != changedProperties.end()) {
 
64
        d->name = it->toString();
 
65
        emit networkNameChanged(d->name);
 
66
    }
 
67
    if (it != changedProperties.end()) {
 
68
        d->btCapabilities = static_cast<Solid::Control::BtNetworkInterface::Capabilities>(it->toUInt());
 
69
    }
 
70
}
 
71
 
 
72
Solid::Control::BtNetworkInterface::Capabilities NMBtNetworkInterface::btCapabilities() const
 
73
{
 
74
    Q_D(const NMBtNetworkInterface);
 
75
    return d->btCapabilities;
 
76
}
 
77
 
 
78
QString NMBtNetworkInterface::hardwareAddress() const
 
79
{
 
80
    Q_D(const NMBtNetworkInterface);
 
81
    return d->hardwareAddress;
 
82
}
 
83
 
 
84
QString NMBtNetworkInterface::name() const
 
85
{
 
86
    Q_D(const NMBtNetworkInterface);
 
87
    return d->name;
 
88
}
 
89
 
 
90
#include "networkbtinterface.moc"
 
91
 
 
92
// vim: sw=4 sts=4 et tw=100